Web version, stage 1: the interface as a library over a platform layer; apps/web
apps/desktop becomes a library (chesspenguin_app: the interface) and a thin
binary; apps/web starts the same interface in a page's canvas (eframe's
WebRunner). cfg(web) (build.rs) marks WebAssembly in a browser.
The platform layer (apps/desktop/src/platform): the program's folders, files,
background work, the files the user opens or saves, the clipboard and what
the platform offers (CAPS). On a computer it is the system as before; in a
browser the program's data lives in IndexedDB behind an in-memory file tree
loaded before the start, the files the user opens are read into it for the
session (only read), background jobs run on the page's thread after the
frame, the clipboard is read through the browser's API, sounds play through
audio elements, a game is saved as a download.
What a browser does not have is not built for it: updates, the online games
window and its probe, engine processes (analysis starts a Web Worker there;
the review and preparation jobs, Rodent and the judge are native), blocking
requests (engine, Maia and Rodent downloads report no download for the
platform, translation reports that it makes no requests). The desktop
program behaves as before; its build finds unused code (the web build
compiles parts it never shows).
apps/web: the entry point, the page /app/ (device check before anything large
is loaded: phones and tablets get the page about the apps in the site's nine
languages, keys app_* in website/site/i18n), build.sh (wasm-bindgen, profile
web), a static server and headless Firefox checks.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 15:09:17 +03:00
|
|
|
//! The files the user opens and saves: the system's dialogs on a computer; in a
|
|
|
|
|
//! browser its file chooser, files dropped on the page, and downloads. A file the user
|
|
|
|
|
//! gives the page is only read (decisions «Веб-версия»): it gets a path of the page's
|
Web version: databases read in a worker, the shelf's counts, Chrome and Edge remember chosen files
The page's reader: a Web Worker with a second instance of the program reads
a database (PGN, CBV, ZIP, 7Z) and gives back its text and index; the page
puts it together without reading it again (chess_core::PgnIndex,
PgnDatabase::into_index / from_index, serde behind a feature). A 13 MB CBV:
the longest frame 17 ms in Firefox, 67 ms in Chromium (1000 ms before).
platform::open_database is the same on both sides: away from the screen,
done when read. The shelf's cards count the games the same way (one file
at a time); the counts are kept through platform::fs.
Chrome, Edge (File System Access): a chosen file's handle is kept in the
browser's storage; at the next visit the file is read again by itself when
the browser allows it, else the card offers «Allow reading» (the browser's
own question). Files of different visits get folders of their own.
Checks: t.choose(files, open) for both browsers (in Chromium the handles of
the site's private file system stand for the dialog's); app.mjs checks the
draft, the question on leaving and the remembered file.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 17:50:54 +03:00
|
|
|
//! file tree for the session and is opened by that path like a file on a disk. Chrome
|
|
|
|
|
//! and Edge remember a chosen file for the next visit ([`super::web::remembered`]).
|
Web version, stage 1: the interface as a library over a platform layer; apps/web
apps/desktop becomes a library (chesspenguin_app: the interface) and a thin
binary; apps/web starts the same interface in a page's canvas (eframe's
WebRunner). cfg(web) (build.rs) marks WebAssembly in a browser.
The platform layer (apps/desktop/src/platform): the program's folders, files,
background work, the files the user opens or saves, the clipboard and what
the platform offers (CAPS). On a computer it is the system as before; in a
browser the program's data lives in IndexedDB behind an in-memory file tree
loaded before the start, the files the user opens are read into it for the
session (only read), background jobs run on the page's thread after the
frame, the clipboard is read through the browser's API, sounds play through
audio elements, a game is saved as a download.
What a browser does not have is not built for it: updates, the online games
window and its probe, engine processes (analysis starts a Web Worker there;
the review and preparation jobs, Rodent and the judge are native), blocking
requests (engine, Maia and Rodent downloads report no download for the
platform, translation reports that it makes no requests). The desktop
program behaves as before; its build finds unused code (the web build
compiles parts it never shows).
apps/web: the entry point, the page /app/ (device check before anything large
is loaded: phones and tablets get the page about the apps in the site's nine
languages, keys app_* in website/site/i18n), build.sh (wasm-bindgen, profile
web), a static server and headless Firefox checks.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 15:09:17 +03:00
|
|
|
|
|
|
|
|
use std::path::PathBuf;
|
|
|
|
|
|
|
|
|
|
/// The extensions of the databases the program opens (both cases for the dialogs of
|
|
|
|
|
/// systems that tell them apart).
|
|
|
|
|
const DATABASES: [&str; 10] = [
|
|
|
|
|
"pgn", "PGN", "cbh", "CBH", "cbv", "CBV", "zip", "ZIP", "7z", "7Z",
|
|
|
|
|
];
|
|
|
|
|
|
2026-10-30 20:42:18 +03:00
|
|
|
/// Databases a browser does not open: their files together larger than this (the
|
|
|
|
|
/// program for the computer opens them).
|
|
|
|
|
pub const TOO_BIG: u64 = 2_000_000_000;
|
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>
2026-10-30 16:35:16 +03:00
|
|
|
|
2026-10-30 20:42:18 +03:00
|
|
|
/// What the user chose or dropped: the databases to open, the ones left out because
|
|
|
|
|
/// they are too big for a browser (name, bytes of their files), the ChessBase
|
2026-10-31 13:16:15 +03:00
|
|
|
/// databases not all files of which were given (the name of their `.cbh`), whether a
|
|
|
|
|
/// chosen (or, on a computer, dropped) folder held no database, and the files dropped
|
|
|
|
|
/// on a computer's window that are no databases (their names).
|
|
|
|
|
#[derive(Debug, Default, PartialEq)]
|
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>
2026-10-30 16:35:16 +03:00
|
|
|
pub struct Picked {
|
|
|
|
|
pub paths: Vec<PathBuf>,
|
|
|
|
|
pub too_big: Vec<(String, u64)>,
|
2026-10-30 20:42:18 +03:00
|
|
|
pub incomplete: Vec<String>,
|
|
|
|
|
pub empty_folder: bool,
|
2026-10-31 13:16:15 +03:00
|
|
|
pub unsupported: Vec<String>,
|
Review engine and dropped files: fixes after the independent check
- The probe turns down an engine not called «Stockfish 19» right after `uci`, without
a search; a search has a 10 s guard, the probe 30 s; probes stop and their engines
quit (or are killed) when the program quits. Play engines (Rodent, Maia) are never
candidates.
- «Did not start» is its own outcome, said once and tried again next time; verdicts
are kept for the real file with the reference's key; the engine's name is checked
again when a job starts (a wrapper may run another program).
- The wait for a probe belongs to its game or preparation; the game analysis and the
opening errors wait apart; «analyse anew» keeps its `full`.
- The offer says why: another engine (settings / system), a Stockfish 19 that
calculates otherwise, one that did not start; the size line is back.
- Dropped files: missing ones told, known ChessBase parts only, duplicates by the real
file, each folder listed once; drops never replace a database being chosen again,
a cancelled «Choose again» ends it; «Added to the shelf» over a game; a framed
highlight with a card; long names shortened.
- decisions.md: where dropping works (not in a Wayland session: winit 0.30).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 13:42:19 +03:00
|
|
|
/// Files dropped on a computer's window that are no longer there (their names).
|
|
|
|
|
pub missing: Vec<String>,
|
2026-10-30 20:42:18 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// The files the user gave the page, made databases: the ChessBase ones of their
|
|
|
|
|
/// several files (`chess_import::group_chosen`), each kept for the session in a folder
|
|
|
|
|
/// of its own. Also the files of each database kept (its path, their places in
|
|
|
|
|
/// `files`), for the browser to remember.
|
|
|
|
|
#[cfg(web)]
|
|
|
|
|
pub(super) fn gather(
|
|
|
|
|
files: &[web_sys::File],
|
|
|
|
|
folder: bool,
|
|
|
|
|
) -> (Picked, Vec<(PathBuf, Vec<usize>)>) {
|
|
|
|
|
let names: Vec<String> = files.iter().map(|f| f.name()).collect();
|
|
|
|
|
let refs: Vec<&str> = names.iter().map(String::as_str).collect();
|
|
|
|
|
let chosen = chess_import::group_chosen(&refs, folder);
|
|
|
|
|
let mut picked = Picked {
|
|
|
|
|
incomplete: chosen.incomplete,
|
|
|
|
|
..Picked::default()
|
|
|
|
|
};
|
|
|
|
|
let mut kept = Vec::new();
|
|
|
|
|
for db in chosen.databases {
|
|
|
|
|
let size: u64 = db.iter().map(|&i| files[i].size() as u64).sum();
|
|
|
|
|
if size > TOO_BIG {
|
|
|
|
|
picked.too_big.push((names[db[0]].clone(), size));
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
let path = super::web::vfs::add_opened(db.iter().map(|&i| files[i].clone()).collect());
|
|
|
|
|
picked.paths.push(path.clone());
|
|
|
|
|
kept.push((path, db));
|
|
|
|
|
}
|
|
|
|
|
picked.empty_folder = folder
|
|
|
|
|
&& picked.paths.is_empty()
|
|
|
|
|
&& picked.too_big.is_empty()
|
|
|
|
|
&& picked.incomplete.is_empty();
|
|
|
|
|
(picked, kept)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// A ChessBase database's `.cbh` given without the files it cannot be read without
|
|
|
|
|
/// (a browser has only the files the user gave it).
|
|
|
|
|
pub fn chessbase_incomplete(path: &std::path::Path) -> bool {
|
|
|
|
|
#[cfg(web)]
|
|
|
|
|
{
|
|
|
|
|
let cbh = path
|
|
|
|
|
.extension()
|
|
|
|
|
.is_some_and(|e| e.eq_ignore_ascii_case("cbh"));
|
|
|
|
|
cbh && super::web::vfs::database_files(path).is_ok_and(|files| {
|
|
|
|
|
!files
|
|
|
|
|
.iter()
|
|
|
|
|
.any(|(name, _)| name.to_lowercase().ends_with(".cbg"))
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
#[cfg(not(web))]
|
|
|
|
|
{
|
|
|
|
|
let _ = path;
|
|
|
|
|
false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// How the user's file `path` is named to the user: on a computer its path, in a
|
|
|
|
|
/// browser its name (the page's own places, `/opened/…`, mean nothing to the user).
|
|
|
|
|
pub fn shown(path: &std::path::Path) -> String {
|
|
|
|
|
#[cfg(web)]
|
|
|
|
|
return path
|
|
|
|
|
.file_name()
|
|
|
|
|
.map(|n| n.to_string_lossy().into_owned())
|
|
|
|
|
.unwrap_or_default();
|
|
|
|
|
#[cfg(not(web))]
|
|
|
|
|
path.display().to_string()
|
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>
2026-10-30 16:35:16 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// A file the browser holds for this visit only (one the user chose or dropped): after
|
|
|
|
|
/// a reload it is gone, the user chooses it again or keeps a copy. Never on a computer.
|
|
|
|
|
pub fn session_only(path: &std::path::Path) -> bool {
|
|
|
|
|
#[cfg(web)]
|
|
|
|
|
return path.starts_with(super::web::vfs::OPENED);
|
|
|
|
|
#[cfg(not(web))]
|
|
|
|
|
{
|
|
|
|
|
let _ = path;
|
|
|
|
|
false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-30 20:42:18 +03:00
|
|
|
/// Keeps a copy of the session database `path` (all its files) in the browser's
|
|
|
|
|
/// storage, where it stays between visits; `then` gets the copy's path. Refused when
|
|
|
|
|
/// the browser gives the site too little room (the size and what is free, for the
|
|
|
|
|
/// message).
|
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>
2026-10-30 16:35:16 +03:00
|
|
|
#[cfg(web)]
|
2026-10-30 20:42:18 +03:00
|
|
|
pub fn keep_copy(path: &std::path::Path, then: impl FnOnce(Result<PathBuf, KeepCopy>) + 'static) {
|
|
|
|
|
use wasm_bindgen::JsCast;
|
|
|
|
|
let parts = match super::web::vfs::database_files(path) {
|
|
|
|
|
Ok(p) => p,
|
|
|
|
|
Err(e) => return then(Err(KeepCopy::Failed(e.to_string()))),
|
|
|
|
|
};
|
|
|
|
|
let need: u64 = parts
|
|
|
|
|
.iter()
|
|
|
|
|
.map(|(_, s)| match s.dyn_ref::<web_sys::Blob>() {
|
|
|
|
|
Some(b) => b.size() as u64,
|
|
|
|
|
None => js_sys::Reflect::get(s, &"length".into())
|
|
|
|
|
.ok()
|
|
|
|
|
.and_then(|l| l.as_f64())
|
|
|
|
|
.unwrap_or(0.0) as u64,
|
|
|
|
|
})
|
|
|
|
|
.sum();
|
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>
2026-10-30 16:35:16 +03:00
|
|
|
if let Some(free) = super::storage_free()
|
|
|
|
|
&& need + need / 10 > free
|
|
|
|
|
{
|
2026-10-30 20:42:18 +03:00
|
|
|
return then(Err(KeepCopy::NoRoom { need, free }));
|
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>
2026-10-30 16:35:16 +03:00
|
|
|
}
|
2026-10-30 20:42:18 +03:00
|
|
|
// A folder of its own, as the database had: the names stay as they were.
|
|
|
|
|
let dir = super::data_dir()
|
|
|
|
|
.unwrap_or_default()
|
|
|
|
|
.join("copies")
|
|
|
|
|
.join((js_sys::Date::now() as u64).to_string());
|
|
|
|
|
let first = dir.join(&parts[0].0);
|
|
|
|
|
wasm_bindgen_futures::spawn_local(async move {
|
|
|
|
|
for (name, source) in parts {
|
|
|
|
|
let bytes = match source.dyn_into::<web_sys::Blob>() {
|
|
|
|
|
Ok(blob) => match wasm_bindgen_futures::JsFuture::from(blob.array_buffer()).await {
|
|
|
|
|
Ok(buf) => js_sys::Uint8Array::new(&buf).to_vec(),
|
|
|
|
|
Err(e) => return then(Err(KeepCopy::Failed(format!("{e:?}")))),
|
|
|
|
|
},
|
|
|
|
|
Err(array) => js_sys::Uint8Array::new(&array).to_vec(),
|
|
|
|
|
};
|
|
|
|
|
if let Err(e) = super::fs::write_atomic(&dir.join(name), &bytes) {
|
|
|
|
|
return then(Err(KeepCopy::Failed(e.to_string())));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
then(Ok(first));
|
|
|
|
|
});
|
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>
2026-10-30 16:35:16 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Why no copy was kept.
|
|
|
|
|
#[cfg(web)]
|
|
|
|
|
pub enum KeepCopy {
|
|
|
|
|
NoRoom { need: u64, free: u64 },
|
|
|
|
|
Failed(String),
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Asks the user for databases to open; `then` gets what was chosen (nothing when the
|
Web version, stage 1: the interface as a library over a platform layer; apps/web
apps/desktop becomes a library (chesspenguin_app: the interface) and a thin
binary; apps/web starts the same interface in a page's canvas (eframe's
WebRunner). cfg(web) (build.rs) marks WebAssembly in a browser.
The platform layer (apps/desktop/src/platform): the program's folders, files,
background work, the files the user opens or saves, the clipboard and what
the platform offers (CAPS). On a computer it is the system as before; in a
browser the program's data lives in IndexedDB behind an in-memory file tree
loaded before the start, the files the user opens are read into it for the
session (only read), background jobs run on the page's thread after the
frame, the clipboard is read through the browser's API, sounds play through
audio elements, a game is saved as a download.
What a browser does not have is not built for it: updates, the online games
window and its probe, engine processes (analysis starts a Web Worker there;
the review and preparation jobs, Rodent and the judge are native), blocking
requests (engine, Maia and Rodent downloads report no download for the
platform, translation reports that it makes no requests). The desktop
program behaves as before; its build finds unused code (the web build
compiles parts it never shows).
apps/web: the entry point, the page /app/ (device check before anything large
is loaded: phones and tablets get the page about the apps in the site's nine
languages, keys app_* in website/site/i18n), build.sh (wasm-bindgen, profile
web), a static server and headless Firefox checks.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 15:09:17 +03:00
|
|
|
/// user cancelled). The dialog does not hold the screen: `then` comes later.
|
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>
2026-10-30 16:35:16 +03:00
|
|
|
pub fn pick_databases(then: impl FnOnce(Picked) + Send + 'static) {
|
Web version, stage 1: the interface as a library over a platform layer; apps/web
apps/desktop becomes a library (chesspenguin_app: the interface) and a thin
binary; apps/web starts the same interface in a page's canvas (eframe's
WebRunner). cfg(web) (build.rs) marks WebAssembly in a browser.
The platform layer (apps/desktop/src/platform): the program's folders, files,
background work, the files the user opens or saves, the clipboard and what
the platform offers (CAPS). On a computer it is the system as before; in a
browser the program's data lives in IndexedDB behind an in-memory file tree
loaded before the start, the files the user opens are read into it for the
session (only read), background jobs run on the page's thread after the
frame, the clipboard is read through the browser's API, sounds play through
audio elements, a game is saved as a download.
What a browser does not have is not built for it: updates, the online games
window and its probe, engine processes (analysis starts a Web Worker there;
the review and preparation jobs, Rodent and the judge are native), blocking
requests (engine, Maia and Rodent downloads report no download for the
platform, translation reports that it makes no requests). The desktop
program behaves as before; its build finds unused code (the web build
compiles parts it never shows).
apps/web: the entry point, the page /app/ (device check before anything large
is loaded: phones and tablets get the page about the apps in the site's nine
languages, keys app_* in website/site/i18n), build.sh (wasm-bindgen, profile
web), a static server and headless Firefox checks.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 15:09:17 +03:00
|
|
|
#[cfg(not(web))]
|
|
|
|
|
{
|
|
|
|
|
use crate::i18n::tr;
|
|
|
|
|
let _ = std::thread::Builder::new()
|
|
|
|
|
.name("dialog".into())
|
|
|
|
|
.spawn(move || {
|
|
|
|
|
let picked = rfd::FileDialog::new()
|
|
|
|
|
.set_title(tr("Open database"))
|
|
|
|
|
.add_filter(tr("Chess databases"), &DATABASES)
|
|
|
|
|
.add_filter("PGN", &["pgn", "PGN"])
|
|
|
|
|
.add_filter(tr("All files"), &["*"])
|
|
|
|
|
.pick_files();
|
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>
2026-10-30 16:35:16 +03:00
|
|
|
then(Picked {
|
|
|
|
|
paths: picked.unwrap_or_default(),
|
2026-10-30 20:42:18 +03:00
|
|
|
..Picked::default()
|
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>
2026-10-30 16:35:16 +03:00
|
|
|
});
|
Web version, stage 1: the interface as a library over a platform layer; apps/web
apps/desktop becomes a library (chesspenguin_app: the interface) and a thin
binary; apps/web starts the same interface in a page's canvas (eframe's
WebRunner). cfg(web) (build.rs) marks WebAssembly in a browser.
The platform layer (apps/desktop/src/platform): the program's folders, files,
background work, the files the user opens or saves, the clipboard and what
the platform offers (CAPS). On a computer it is the system as before; in a
browser the program's data lives in IndexedDB behind an in-memory file tree
loaded before the start, the files the user opens are read into it for the
session (only read), background jobs run on the page's thread after the
frame, the clipboard is read through the browser's API, sounds play through
audio elements, a game is saved as a download.
What a browser does not have is not built for it: updates, the online games
window and its probe, engine processes (analysis starts a Web Worker there;
the review and preparation jobs, Rodent and the judge are native), blocking
requests (engine, Maia and Rodent downloads report no download for the
platform, translation reports that it makes no requests). The desktop
program behaves as before; its build finds unused code (the web build
compiles parts it never shows).
apps/web: the entry point, the page /app/ (device check before anything large
is loaded: phones and tablets get the page about the apps in the site's nine
languages, keys app_* in website/site/i18n), build.sh (wasm-bindgen, profile
web), a static server and headless Firefox checks.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 15:09:17 +03:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
#[cfg(web)]
|
|
|
|
|
{
|
Web version: databases read in a worker, the shelf's counts, Chrome and Edge remember chosen files
The page's reader: a Web Worker with a second instance of the program reads
a database (PGN, CBV, ZIP, 7Z) and gives back its text and index; the page
puts it together without reading it again (chess_core::PgnIndex,
PgnDatabase::into_index / from_index, serde behind a feature). A 13 MB CBV:
the longest frame 17 ms in Firefox, 67 ms in Chromium (1000 ms before).
platform::open_database is the same on both sides: away from the screen,
done when read. The shelf's cards count the games the same way (one file
at a time); the counts are kept through platform::fs.
Chrome, Edge (File System Access): a chosen file's handle is kept in the
browser's storage; at the next visit the file is read again by itself when
the browser allows it, else the card offers «Allow reading» (the browser's
own question). Files of different visits get folders of their own.
Checks: t.choose(files, open) for both browsers (in Chromium the handles of
the site's private file system stand for the dialog's); app.mjs checks the
draft, the question on leaving and the remembered file.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 17:50:54 +03:00
|
|
|
let extensions: Vec<String> = DATABASES
|
Web version, stage 1: the interface as a library over a platform layer; apps/web
apps/desktop becomes a library (chesspenguin_app: the interface) and a thin
binary; apps/web starts the same interface in a page's canvas (eframe's
WebRunner). cfg(web) (build.rs) marks WebAssembly in a browser.
The platform layer (apps/desktop/src/platform): the program's folders, files,
background work, the files the user opens or saves, the clipboard and what
the platform offers (CAPS). On a computer it is the system as before; in a
browser the program's data lives in IndexedDB behind an in-memory file tree
loaded before the start, the files the user opens are read into it for the
session (only read), background jobs run on the page's thread after the
frame, the clipboard is read through the browser's API, sounds play through
audio elements, a game is saved as a download.
What a browser does not have is not built for it: updates, the online games
window and its probe, engine processes (analysis starts a Web Worker there;
the review and preparation jobs, Rodent and the judge are native), blocking
requests (engine, Maia and Rodent downloads report no download for the
platform, translation reports that it makes no requests). The desktop
program behaves as before; its build finds unused code (the web build
compiles parts it never shows).
apps/web: the entry point, the page /app/ (device check before anything large
is loaded: phones and tablets get the page about the apps in the site's nine
languages, keys app_* in website/site/i18n), build.sh (wasm-bindgen, profile
web), a static server and headless Firefox checks.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 15:09:17 +03:00
|
|
|
.iter()
|
|
|
|
|
.step_by(2)
|
|
|
|
|
.map(|e| format!(".{e}"))
|
Web version: databases read in a worker, the shelf's counts, Chrome and Edge remember chosen files
The page's reader: a Web Worker with a second instance of the program reads
a database (PGN, CBV, ZIP, 7Z) and gives back its text and index; the page
puts it together without reading it again (chess_core::PgnIndex,
PgnDatabase::into_index / from_index, serde behind a feature). A 13 MB CBV:
the longest frame 17 ms in Firefox, 67 ms in Chromium (1000 ms before).
platform::open_database is the same on both sides: away from the screen,
done when read. The shelf's cards count the games the same way (one file
at a time); the counts are kept through platform::fs.
Chrome, Edge (File System Access): a chosen file's handle is kept in the
browser's storage; at the next visit the file is read again by itself when
the browser allows it, else the card offers «Allow reading» (the browser's
own question). Files of different visits get folders of their own.
Checks: t.choose(files, open) for both browsers (in Chromium the handles of
the site's private file system stand for the dialog's); app.mjs checks the
draft, the question on leaving and the remembered file.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 17:50:54 +03:00
|
|
|
.collect();
|
|
|
|
|
if super::web::remembered::supported() {
|
2026-10-30 20:42:18 +03:00
|
|
|
super::web::remembered::pick(&extensions, then);
|
Web version: databases read in a worker, the shelf's counts, Chrome and Edge remember chosen files
The page's reader: a Web Worker with a second instance of the program reads
a database (PGN, CBV, ZIP, 7Z) and gives back its text and index; the page
puts it together without reading it again (chess_core::PgnIndex,
PgnDatabase::into_index / from_index, serde behind a feature). A 13 MB CBV:
the longest frame 17 ms in Firefox, 67 ms in Chromium (1000 ms before).
platform::open_database is the same on both sides: away from the screen,
done when read. The shelf's cards count the games the same way (one file
at a time); the counts are kept through platform::fs.
Chrome, Edge (File System Access): a chosen file's handle is kept in the
browser's storage; at the next visit the file is read again by itself when
the browser allows it, else the card offers «Allow reading» (the browser's
own question). Files of different visits get folders of their own.
Checks: t.choose(files, open) for both browsers (in Chromium the handles of
the site's private file system stand for the dialog's); app.mjs checks the
draft, the question on leaving and the remembered file.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 17:50:54 +03:00
|
|
|
} else {
|
2026-10-30 20:42:18 +03:00
|
|
|
super::web::page::pick_files(&extensions.join(","), move |files| {
|
|
|
|
|
then(gather(&files, false).0)
|
|
|
|
|
});
|
Web version: databases read in a worker, the shelf's counts, Chrome and Edge remember chosen files
The page's reader: a Web Worker with a second instance of the program reads
a database (PGN, CBV, ZIP, 7Z) and gives back its text and index; the page
puts it together without reading it again (chess_core::PgnIndex,
PgnDatabase::into_index / from_index, serde behind a feature). A 13 MB CBV:
the longest frame 17 ms in Firefox, 67 ms in Chromium (1000 ms before).
platform::open_database is the same on both sides: away from the screen,
done when read. The shelf's cards count the games the same way (one file
at a time); the counts are kept through platform::fs.
Chrome, Edge (File System Access): a chosen file's handle is kept in the
browser's storage; at the next visit the file is read again by itself when
the browser allows it, else the card offers «Allow reading» (the browser's
own question). Files of different visits get folders of their own.
Checks: t.choose(files, open) for both browsers (in Chromium the handles of
the site's private file system stand for the dialog's); app.mjs checks the
draft, the question on leaving and the remembered file.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 17:50:54 +03:00
|
|
|
}
|
Web version, stage 1: the interface as a library over a platform layer; apps/web
apps/desktop becomes a library (chesspenguin_app: the interface) and a thin
binary; apps/web starts the same interface in a page's canvas (eframe's
WebRunner). cfg(web) (build.rs) marks WebAssembly in a browser.
The platform layer (apps/desktop/src/platform): the program's folders, files,
background work, the files the user opens or saves, the clipboard and what
the platform offers (CAPS). On a computer it is the system as before; in a
browser the program's data lives in IndexedDB behind an in-memory file tree
loaded before the start, the files the user opens are read into it for the
session (only read), background jobs run on the page's thread after the
frame, the clipboard is read through the browser's API, sounds play through
audio elements, a game is saved as a download.
What a browser does not have is not built for it: updates, the online games
window and its probe, engine processes (analysis starts a Web Worker there;
the review and preparation jobs, Rodent and the judge are native), blocking
requests (engine, Maia and Rodent downloads report no download for the
platform, translation reports that it makes no requests). The desktop
program behaves as before; its build finds unused code (the web build
compiles parts it never shows).
apps/web: the entry point, the page /app/ (device check before anything large
is loaded: phones and tablets get the page about the apps in the site's nine
languages, keys app_* in website/site/i18n), build.sh (wasm-bindgen, profile
web), a static server and headless Firefox checks.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 15:09:17 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-30 20:42:18 +03:00
|
|
|
/// Asks the user for a database's folder (a ChessBase database is several files): its
|
|
|
|
|
/// databases are found by their files' names. Chrome and Edge remember the folder.
|
|
|
|
|
#[cfg(web)]
|
|
|
|
|
pub fn pick_database_folder(then: impl FnOnce(Picked) + Send + 'static) {
|
|
|
|
|
if super::web::remembered::supported_folder() {
|
|
|
|
|
super::web::remembered::pick_folder(then);
|
|
|
|
|
} else {
|
|
|
|
|
super::web::page::pick_folder(move |files| then(gather(&files, true).0));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-30 17:58:01 +03:00
|
|
|
/// The browser remembers the files chosen in its dialog for the next visit (Chrome,
|
|
|
|
|
/// Edge); the others, and a computer, have no need or no way.
|
|
|
|
|
pub fn remembers_chosen() -> bool {
|
|
|
|
|
#[cfg(web)]
|
|
|
|
|
return super::web::remembered::supported();
|
|
|
|
|
#[cfg(not(web))]
|
|
|
|
|
false
|
|
|
|
|
}
|
|
|
|
|
|
Web version: databases read in a worker, the shelf's counts, Chrome and Edge remember chosen files
The page's reader: a Web Worker with a second instance of the program reads
a database (PGN, CBV, ZIP, 7Z) and gives back its text and index; the page
puts it together without reading it again (chess_core::PgnIndex,
PgnDatabase::into_index / from_index, serde behind a feature). A 13 MB CBV:
the longest frame 17 ms in Firefox, 67 ms in Chromium (1000 ms before).
platform::open_database is the same on both sides: away from the screen,
done when read. The shelf's cards count the games the same way (one file
at a time); the counts are kept through platform::fs.
Chrome, Edge (File System Access): a chosen file's handle is kept in the
browser's storage; at the next visit the file is read again by itself when
the browser allows it, else the card offers «Allow reading» (the browser's
own question). Files of different visits get folders of their own.
Checks: t.choose(files, open) for both browsers (in Chromium the handles of
the site's private file system stand for the dialog's); app.mjs checks the
draft, the question on leaving and the remembered file.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 17:50:54 +03:00
|
|
|
/// The browser remembers the file `path` of an earlier visit and asks the user before
|
|
|
|
|
/// the page reads it again ([`allow_reading`]). Never on a computer.
|
|
|
|
|
pub fn waiting_to_read(path: &std::path::Path) -> bool {
|
|
|
|
|
#[cfg(web)]
|
|
|
|
|
return super::web::remembered::waiting(path);
|
|
|
|
|
#[cfg(not(web))]
|
|
|
|
|
{
|
|
|
|
|
let _ = path;
|
|
|
|
|
false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Asks the browser to let the page read the remembered file `path` again (soon after
|
|
|
|
|
/// the user's click); `then`: whether it is back.
|
|
|
|
|
#[cfg(web)]
|
|
|
|
|
pub fn allow_reading(path: &std::path::Path, then: impl FnOnce(bool) + 'static) {
|
|
|
|
|
super::web::remembered::allow(path, then);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// The file `path` left the library: a browser forgets it too.
|
|
|
|
|
pub fn forget(path: &std::path::Path) {
|
|
|
|
|
#[cfg(web)]
|
|
|
|
|
super::web::remembered::forget(path);
|
|
|
|
|
#[cfg(not(web))]
|
|
|
|
|
let _ = path;
|
|
|
|
|
}
|
|
|
|
|
|
Web version, stage 1: the interface as a library over a platform layer; apps/web
apps/desktop becomes a library (chesspenguin_app: the interface) and a thin
binary; apps/web starts the same interface in a page's canvas (eframe's
WebRunner). cfg(web) (build.rs) marks WebAssembly in a browser.
The platform layer (apps/desktop/src/platform): the program's folders, files,
background work, the files the user opens or saves, the clipboard and what
the platform offers (CAPS). On a computer it is the system as before; in a
browser the program's data lives in IndexedDB behind an in-memory file tree
loaded before the start, the files the user opens are read into it for the
session (only read), background jobs run on the page's thread after the
frame, the clipboard is read through the browser's API, sounds play through
audio elements, a game is saved as a download.
What a browser does not have is not built for it: updates, the online games
window and its probe, engine processes (analysis starts a Web Worker there;
the review and preparation jobs, Rodent and the judge are native), blocking
requests (engine, Maia and Rodent downloads report no download for the
platform, translation reports that it makes no requests). The desktop
program behaves as before; its build finds unused code (the web build
compiles parts it never shows).
apps/web: the entry point, the page /app/ (device check before anything large
is loaded: phones and tablets get the page about the apps in the site's nine
languages, keys app_* in website/site/i18n), build.sh (wasm-bindgen, profile
web), a static server and headless Firefox checks.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 15:09:17 +03:00
|
|
|
/// The files dropped on the window in this frame, as databases to open: `then` gets
|
|
|
|
|
/// their paths once read (in a browser they are kept for the session like chosen
|
2026-10-31 13:16:15 +03:00
|
|
|
/// ones; on a computer they are opened where they are, as «Add database» does).
|
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>
2026-10-30 16:35:16 +03:00
|
|
|
pub fn take_dropped(ctx: &egui::Context, then: impl FnOnce(Picked) + Send + 'static) {
|
Web version, stage 1: the interface as a library over a platform layer; apps/web
apps/desktop becomes a library (chesspenguin_app: the interface) and a thin
binary; apps/web starts the same interface in a page's canvas (eframe's
WebRunner). cfg(web) (build.rs) marks WebAssembly in a browser.
The platform layer (apps/desktop/src/platform): the program's folders, files,
background work, the files the user opens or saves, the clipboard and what
the platform offers (CAPS). On a computer it is the system as before; in a
browser the program's data lives in IndexedDB behind an in-memory file tree
loaded before the start, the files the user opens are read into it for the
session (only read), background jobs run on the page's thread after the
frame, the clipboard is read through the browser's API, sounds play through
audio elements, a game is saved as a download.
What a browser does not have is not built for it: updates, the online games
window and its probe, engine processes (analysis starts a Web Worker there;
the review and preparation jobs, Rodent and the judge are native), blocking
requests (engine, Maia and Rodent downloads report no download for the
platform, translation reports that it makes no requests). The desktop
program behaves as before; its build finds unused code (the web build
compiles parts it never shows).
apps/web: the entry point, the page /app/ (device check before anything large
is loaded: phones and tablets get the page about the apps in the site's nine
languages, keys app_* in website/site/i18n), build.sh (wasm-bindgen, profile
web), a static server and headless Firefox checks.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 15:09:17 +03:00
|
|
|
#[cfg(not(web))]
|
|
|
|
|
{
|
2026-10-31 13:16:15 +03:00
|
|
|
let paths: Vec<PathBuf> = ctx.input(|i| {
|
|
|
|
|
i.raw
|
|
|
|
|
.dropped_files
|
|
|
|
|
.iter()
|
|
|
|
|
.map(|f| f.path().to_path_buf())
|
|
|
|
|
.filter(|p| p.is_absolute())
|
|
|
|
|
.collect()
|
|
|
|
|
});
|
|
|
|
|
if paths.is_empty() {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// Folders are listed and files' neighbours looked at: off the screen's thread.
|
|
|
|
|
let _ = std::thread::Builder::new()
|
|
|
|
|
.name("dropped".into())
|
|
|
|
|
.spawn(move || then(sort_dropped(&paths)));
|
Web version, stage 1: the interface as a library over a platform layer; apps/web
apps/desktop becomes a library (chesspenguin_app: the interface) and a thin
binary; apps/web starts the same interface in a page's canvas (eframe's
WebRunner). cfg(web) (build.rs) marks WebAssembly in a browser.
The platform layer (apps/desktop/src/platform): the program's folders, files,
background work, the files the user opens or saves, the clipboard and what
the platform offers (CAPS). On a computer it is the system as before; in a
browser the program's data lives in IndexedDB behind an in-memory file tree
loaded before the start, the files the user opens are read into it for the
session (only read), background jobs run on the page's thread after the
frame, the clipboard is read through the browser's API, sounds play through
audio elements, a game is saved as a download.
What a browser does not have is not built for it: updates, the online games
window and its probe, engine processes (analysis starts a Web Worker there;
the review and preparation jobs, Rodent and the judge are native), blocking
requests (engine, Maia and Rodent downloads report no download for the
platform, translation reports that it makes no requests). The desktop
program behaves as before; its build finds unused code (the web build
compiles parts it never shows).
apps/web: the entry point, the page /app/ (device check before anything large
is loaded: phones and tablets get the page about the apps in the site's nine
languages, keys app_* in website/site/i18n), build.sh (wasm-bindgen, profile
web), a static server and headless Firefox checks.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 15:09:17 +03:00
|
|
|
}
|
|
|
|
|
#[cfg(web)]
|
|
|
|
|
{
|
|
|
|
|
let files: Vec<web_sys::File> = ctx.input(|i| {
|
|
|
|
|
i.raw
|
|
|
|
|
.dropped_files
|
|
|
|
|
.iter()
|
|
|
|
|
.filter_map(|f| f.web_file().cloned())
|
|
|
|
|
.collect()
|
|
|
|
|
});
|
|
|
|
|
if files.is_empty() {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2026-10-30 20:42:18 +03:00
|
|
|
then(gather(&files, false).0);
|
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>
2026-10-30 16:35:16 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
Web version, stage 1: the interface as a library over a platform layer; apps/web
apps/desktop becomes a library (chesspenguin_app: the interface) and a thin
binary; apps/web starts the same interface in a page's canvas (eframe's
WebRunner). cfg(web) (build.rs) marks WebAssembly in a browser.
The platform layer (apps/desktop/src/platform): the program's folders, files,
background work, the files the user opens or saves, the clipboard and what
the platform offers (CAPS). On a computer it is the system as before; in a
browser the program's data lives in IndexedDB behind an in-memory file tree
loaded before the start, the files the user opens are read into it for the
session (only read), background jobs run on the page's thread after the
frame, the clipboard is read through the browser's API, sounds play through
audio elements, a game is saved as a download.
What a browser does not have is not built for it: updates, the online games
window and its probe, engine processes (analysis starts a Web Worker there;
the review and preparation jobs, Rodent and the judge are native), blocking
requests (engine, Maia and Rodent downloads report no download for the
platform, translation reports that it makes no requests). The desktop
program behaves as before; its build finds unused code (the web build
compiles parts it never shows).
apps/web: the entry point, the page /app/ (device check before anything large
is loaded: phones and tablets get the page about the apps in the site's nine
languages, keys app_* in website/site/i18n), build.sh (wasm-bindgen, profile
web), a static server and headless Firefox checks.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 15:09:17 +03:00
|
|
|
/// Files are dragged over the window now (the page shows where they go).
|
|
|
|
|
pub fn dragging(ctx: &egui::Context) -> bool {
|
2026-10-31 13:16:15 +03:00
|
|
|
ctx.input(|i| !i.raw.hovered_files.is_empty())
|
|
|
|
|
}
|
|
|
|
|
|
Review engine and dropped files: fixes after the independent check
- The probe turns down an engine not called «Stockfish 19» right after `uci`, without
a search; a search has a 10 s guard, the probe 30 s; probes stop and their engines
quit (or are killed) when the program quits. Play engines (Rodent, Maia) are never
candidates.
- «Did not start» is its own outcome, said once and tried again next time; verdicts
are kept for the real file with the reference's key; the engine's name is checked
again when a job starts (a wrapper may run another program).
- The wait for a probe belongs to its game or preparation; the game analysis and the
opening errors wait apart; «analyse anew» keeps its `full`.
- The offer says why: another engine (settings / system), a Stockfish 19 that
calculates otherwise, one that did not start; the size line is back.
- Dropped files: missing ones told, known ChessBase parts only, duplicates by the real
file, each folder listed once; drops never replace a database being chosen again,
a cancelled «Choose again» ends it; «Added to the shelf» over a game; a framed
highlight with a card; long names shortened.
- decisions.md: where dropping works (not in a Wayland session: winit 0.30).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 13:42:19 +03:00
|
|
|
/// The extensions of the other files of a ChessBase database (beside its `.cbh`).
|
|
|
|
|
#[cfg(not(web))]
|
|
|
|
|
const CHESSBASE_PARTS: [&str; 14] = [
|
|
|
|
|
"cbg", "cba", "cbp", "cbt", "cbc", "cbs", "cbj", "cbe", "cbm", "cbb", "cbgi", "cbtt", "cbpi",
|
|
|
|
|
"cbl",
|
|
|
|
|
];
|
|
|
|
|
|
2026-10-31 13:16:15 +03:00
|
|
|
/// The databases of the files and folders dropped on a computer's window: a file of
|
Review engine and dropped files: fixes after the independent check
- The probe turns down an engine not called «Stockfish 19» right after `uci`, without
a search; a search has a 10 s guard, the probe 30 s; probes stop and their engines
quit (or are killed) when the program quits. Play engines (Rodent, Maia) are never
candidates.
- «Did not start» is its own outcome, said once and tried again next time; verdicts
are kept for the real file with the reference's key; the engine's name is checked
again when a job starts (a wrapper may run another program).
- The wait for a probe belongs to its game or preparation; the game analysis and the
opening errors wait apart; «analyse anew» keeps its `full`.
- The offer says why: another engine (settings / system), a Stockfish 19 that
calculates otherwise, one that did not start; the size line is back.
- Dropped files: missing ones told, known ChessBase parts only, duplicates by the real
file, each folder listed once; drops never replace a database being chosen again,
a cancelled «Choose again» ends it; «Added to the shelf» over a game; a framed
highlight with a card; long names shortened.
- decisions.md: where dropping works (not in a Wayland session: winit 0.30).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 13:42:19 +03:00
|
|
|
/// [`chess_import::EXTENSIONS`] is one; another file of a ChessBase database (its
|
|
|
|
|
/// `.cbg`, `.cba`, …: [`CHESSBASE_PARTS`]) stands for the `.cbh` of the same name
|
|
|
|
|
/// beside it; a folder gives the databases in it. Each database once (its real file),
|
|
|
|
|
/// in the order dropped; a file no longer there and a file of no database are named.
|
2026-10-31 13:16:15 +03:00
|
|
|
#[cfg(not(web))]
|
|
|
|
|
fn sort_dropped(paths: &[PathBuf]) -> Picked {
|
Review engine and dropped files: fixes after the independent check
- The probe turns down an engine not called «Stockfish 19» right after `uci`, without
a search; a search has a 10 s guard, the probe 30 s; probes stop and their engines
quit (or are killed) when the program quits. Play engines (Rodent, Maia) are never
candidates.
- «Did not start» is its own outcome, said once and tried again next time; verdicts
are kept for the real file with the reference's key; the engine's name is checked
again when a job starts (a wrapper may run another program).
- The wait for a probe belongs to its game or preparation; the game analysis and the
opening errors wait apart; «analyse anew» keeps its `full`.
- The offer says why: another engine (settings / system), a Stockfish 19 that
calculates otherwise, one that did not start; the size line is back.
- Dropped files: missing ones told, known ChessBase parts only, duplicates by the real
file, each folder listed once; drops never replace a database being chosen again,
a cancelled «Choose again» ends it; «Added to the shelf» over a game; a framed
highlight with a card; long names shortened.
- decisions.md: where dropping works (not in a Wayland session: winit 0.30).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 13:42:19 +03:00
|
|
|
use std::collections::{HashMap, HashSet};
|
2026-10-31 13:16:15 +03:00
|
|
|
let mut picked = Picked::default();
|
Review engine and dropped files: fixes after the independent check
- The probe turns down an engine not called «Stockfish 19» right after `uci`, without
a search; a search has a 10 s guard, the probe 30 s; probes stop and their engines
quit (or are killed) when the program quits. Play engines (Rodent, Maia) are never
candidates.
- «Did not start» is its own outcome, said once and tried again next time; verdicts
are kept for the real file with the reference's key; the engine's name is checked
again when a job starts (a wrapper may run another program).
- The wait for a probe belongs to its game or preparation; the game analysis and the
opening errors wait apart; «analyse anew» keeps its `full`.
- The offer says why: another engine (settings / system), a Stockfish 19 that
calculates otherwise, one that did not start; the size line is back.
- Dropped files: missing ones told, known ChessBase parts only, duplicates by the real
file, each folder listed once; drops never replace a database being chosen again,
a cancelled «Choose again» ends it; «Added to the shelf» over a game; a framed
highlight with a card; long names shortened.
- decisions.md: where dropping works (not in a Wayland session: winit 0.30).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 13:42:19 +03:00
|
|
|
let mut seen = HashSet::new();
|
|
|
|
|
// Each folder is listed once, however many of its files were dropped.
|
|
|
|
|
let mut listed: HashMap<PathBuf, Vec<PathBuf>> = HashMap::new();
|
|
|
|
|
let mut list = |dir: &std::path::Path| -> Vec<PathBuf> {
|
|
|
|
|
listed
|
|
|
|
|
.entry(dir.to_path_buf())
|
|
|
|
|
.or_insert_with(|| {
|
|
|
|
|
let mut files: Vec<PathBuf> = std::fs::read_dir(dir)
|
|
|
|
|
.map(|entries| {
|
|
|
|
|
entries
|
|
|
|
|
.flatten()
|
|
|
|
|
.map(|e| e.path())
|
|
|
|
|
.filter(|f| f.is_file())
|
|
|
|
|
.collect()
|
|
|
|
|
})
|
|
|
|
|
.unwrap_or_default();
|
|
|
|
|
files.sort();
|
|
|
|
|
files
|
|
|
|
|
})
|
|
|
|
|
.clone()
|
|
|
|
|
};
|
|
|
|
|
let name = |p: &std::path::Path| {
|
|
|
|
|
p.file_name()
|
|
|
|
|
.map_or_else(|| p.display().to_string(), |n| n.to_string_lossy().into())
|
2026-10-31 13:16:15 +03:00
|
|
|
};
|
|
|
|
|
for p in paths {
|
Review engine and dropped files: fixes after the independent check
- The probe turns down an engine not called «Stockfish 19» right after `uci`, without
a search; a search has a 10 s guard, the probe 30 s; probes stop and their engines
quit (or are killed) when the program quits. Play engines (Rodent, Maia) are never
candidates.
- «Did not start» is its own outcome, said once and tried again next time; verdicts
are kept for the real file with the reference's key; the engine's name is checked
again when a job starts (a wrapper may run another program).
- The wait for a probe belongs to its game or preparation; the game analysis and the
opening errors wait apart; «analyse anew» keeps its `full`.
- The offer says why: another engine (settings / system), a Stockfish 19 that
calculates otherwise, one that did not start; the size line is back.
- Dropped files: missing ones told, known ChessBase parts only, duplicates by the real
file, each folder listed once; drops never replace a database being chosen again,
a cancelled «Choose again» ends it; «Added to the shelf» over a game; a framed
highlight with a card; long names shortened.
- decisions.md: where dropping works (not in a Wayland session: winit 0.30).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 13:42:19 +03:00
|
|
|
let found = if p.is_dir() {
|
|
|
|
|
let found: Vec<PathBuf> = list(p)
|
|
|
|
|
.into_iter()
|
|
|
|
|
.filter(|f| chess_import::EXTENSIONS.contains(&extension(f).as_str()))
|
|
|
|
|
.collect();
|
2026-10-31 13:16:15 +03:00
|
|
|
if found.is_empty() {
|
|
|
|
|
picked.empty_folder = true;
|
|
|
|
|
}
|
Review engine and dropped files: fixes after the independent check
- The probe turns down an engine not called «Stockfish 19» right after `uci`, without
a search; a search has a 10 s guard, the probe 30 s; probes stop and their engines
quit (or are killed) when the program quits. Play engines (Rodent, Maia) are never
candidates.
- «Did not start» is its own outcome, said once and tried again next time; verdicts
are kept for the real file with the reference's key; the engine's name is checked
again when a job starts (a wrapper may run another program).
- The wait for a probe belongs to its game or preparation; the game analysis and the
opening errors wait apart; «analyse anew» keeps its `full`.
- The offer says why: another engine (settings / system), a Stockfish 19 that
calculates otherwise, one that did not start; the size line is back.
- Dropped files: missing ones told, known ChessBase parts only, duplicates by the real
file, each folder listed once; drops never replace a database being chosen again,
a cancelled «Choose again» ends it; «Added to the shelf» over a game; a framed
highlight with a card; long names shortened.
- decisions.md: where dropping works (not in a Wayland session: winit 0.30).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 13:42:19 +03:00
|
|
|
found
|
|
|
|
|
} else if !p.is_file() {
|
|
|
|
|
picked.missing.push(name(p));
|
|
|
|
|
continue;
|
2026-10-31 13:16:15 +03:00
|
|
|
} else {
|
Review engine and dropped files: fixes after the independent check
- The probe turns down an engine not called «Stockfish 19» right after `uci`, without
a search; a search has a 10 s guard, the probe 30 s; probes stop and their engines
quit (or are killed) when the program quits. Play engines (Rodent, Maia) are never
candidates.
- «Did not start» is its own outcome, said once and tried again next time; verdicts
are kept for the real file with the reference's key; the engine's name is checked
again when a job starts (a wrapper may run another program).
- The wait for a probe belongs to its game or preparation; the game analysis and the
opening errors wait apart; «analyse anew» keeps its `full`.
- The offer says why: another engine (settings / system), a Stockfish 19 that
calculates otherwise, one that did not start; the size line is back.
- Dropped files: missing ones told, known ChessBase parts only, duplicates by the real
file, each folder listed once; drops never replace a database being chosen again,
a cancelled «Choose again» ends it; «Added to the shelf» over a game; a framed
highlight with a card; long names shortened.
- decisions.md: where dropping works (not in a Wayland session: winit 0.30).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 13:42:19 +03:00
|
|
|
let ext = extension(p);
|
|
|
|
|
if chess_import::EXTENSIONS.contains(&ext.as_str()) {
|
|
|
|
|
vec![p.clone()]
|
|
|
|
|
} else if CHESSBASE_PARTS.contains(&ext.as_str())
|
|
|
|
|
&& let Some(cbh) = p.parent().and_then(|dir| cbh_beside(p, &list(dir)))
|
|
|
|
|
{
|
|
|
|
|
vec![cbh]
|
|
|
|
|
} else {
|
|
|
|
|
picked.unsupported.push(name(p));
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
for f in found {
|
|
|
|
|
if seen.insert(f.canonicalize().unwrap_or_else(|_| f.clone())) {
|
|
|
|
|
picked.paths.push(f);
|
|
|
|
|
}
|
2026-10-31 13:16:15 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
picked
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// The extension of `p`, in lower case.
|
|
|
|
|
#[cfg(not(web))]
|
|
|
|
|
fn extension(p: &std::path::Path) -> String {
|
|
|
|
|
p.extension()
|
|
|
|
|
.map(|e| e.to_string_lossy().to_lowercase())
|
|
|
|
|
.unwrap_or_default()
|
|
|
|
|
}
|
|
|
|
|
|
Review engine and dropped files: fixes after the independent check
- The probe turns down an engine not called «Stockfish 19» right after `uci`, without
a search; a search has a 10 s guard, the probe 30 s; probes stop and their engines
quit (or are killed) when the program quits. Play engines (Rodent, Maia) are never
candidates.
- «Did not start» is its own outcome, said once and tried again next time; verdicts
are kept for the real file with the reference's key; the engine's name is checked
again when a job starts (a wrapper may run another program).
- The wait for a probe belongs to its game or preparation; the game analysis and the
opening errors wait apart; «analyse anew» keeps its `full`.
- The offer says why: another engine (settings / system), a Stockfish 19 that
calculates otherwise, one that did not start; the size line is back.
- Dropped files: missing ones told, known ChessBase parts only, duplicates by the real
file, each folder listed once; drops never replace a database being chosen again,
a cancelled «Choose again» ends it; «Added to the shelf» over a game; a framed
highlight with a card; long names shortened.
- decisions.md: where dropping works (not in a Wayland session: winit 0.30).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 13:42:19 +03:00
|
|
|
/// The `.cbh` of the ChessBase database the file `part` belongs to, among the files
|
|
|
|
|
/// of its folder (names differ in case in sets copied from Windows).
|
2026-10-31 13:16:15 +03:00
|
|
|
#[cfg(not(web))]
|
Review engine and dropped files: fixes after the independent check
- The probe turns down an engine not called «Stockfish 19» right after `uci`, without
a search; a search has a 10 s guard, the probe 30 s; probes stop and their engines
quit (or are killed) when the program quits. Play engines (Rodent, Maia) are never
candidates.
- «Did not start» is its own outcome, said once and tried again next time; verdicts
are kept for the real file with the reference's key; the engine's name is checked
again when a job starts (a wrapper may run another program).
- The wait for a probe belongs to its game or preparation; the game analysis and the
opening errors wait apart; «analyse anew» keeps its `full`.
- The offer says why: another engine (settings / system), a Stockfish 19 that
calculates otherwise, one that did not start; the size line is back.
- Dropped files: missing ones told, known ChessBase parts only, duplicates by the real
file, each folder listed once; drops never replace a database being chosen again,
a cancelled «Choose again» ends it; «Added to the shelf» over a game; a framed
highlight with a card; long names shortened.
- decisions.md: where dropping works (not in a Wayland session: winit 0.30).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 13:42:19 +03:00
|
|
|
fn cbh_beside(part: &std::path::Path, folder: &[PathBuf]) -> Option<PathBuf> {
|
|
|
|
|
let stem = part.file_stem()?.to_string_lossy().to_lowercase();
|
2026-10-31 13:16:15 +03:00
|
|
|
let want = format!("{stem}.cbh");
|
Review engine and dropped files: fixes after the independent check
- The probe turns down an engine not called «Stockfish 19» right after `uci`, without
a search; a search has a 10 s guard, the probe 30 s; probes stop and their engines
quit (or are killed) when the program quits. Play engines (Rodent, Maia) are never
candidates.
- «Did not start» is its own outcome, said once and tried again next time; verdicts
are kept for the real file with the reference's key; the engine's name is checked
again when a job starts (a wrapper may run another program).
- The wait for a probe belongs to its game or preparation; the game analysis and the
opening errors wait apart; «analyse anew» keeps its `full`.
- The offer says why: another engine (settings / system), a Stockfish 19 that
calculates otherwise, one that did not start; the size line is back.
- Dropped files: missing ones told, known ChessBase parts only, duplicates by the real
file, each folder listed once; drops never replace a database being chosen again,
a cancelled «Choose again» ends it; «Added to the shelf» over a game; a framed
highlight with a card; long names shortened.
- decisions.md: where dropping works (not in a Wayland session: winit 0.30).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 13:42:19 +03:00
|
|
|
folder
|
|
|
|
|
.iter()
|
2026-10-31 13:16:15 +03:00
|
|
|
.find(|f| {
|
Review engine and dropped files: fixes after the independent check
- The probe turns down an engine not called «Stockfish 19» right after `uci`, without
a search; a search has a 10 s guard, the probe 30 s; probes stop and their engines
quit (or are killed) when the program quits. Play engines (Rodent, Maia) are never
candidates.
- «Did not start» is its own outcome, said once and tried again next time; verdicts
are kept for the real file with the reference's key; the engine's name is checked
again when a job starts (a wrapper may run another program).
- The wait for a probe belongs to its game or preparation; the game analysis and the
opening errors wait apart; «analyse anew» keeps its `full`.
- The offer says why: another engine (settings / system), a Stockfish 19 that
calculates otherwise, one that did not start; the size line is back.
- Dropped files: missing ones told, known ChessBase parts only, duplicates by the real
file, each folder listed once; drops never replace a database being chosen again,
a cancelled «Choose again» ends it; «Added to the shelf» over a game; a framed
highlight with a card; long names shortened.
- decisions.md: where dropping works (not in a Wayland session: winit 0.30).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 13:42:19 +03:00
|
|
|
f.file_name()
|
|
|
|
|
.is_some_and(|n| n.to_string_lossy().to_lowercase() == want)
|
2026-10-31 13:16:15 +03:00
|
|
|
})
|
Review engine and dropped files: fixes after the independent check
- The probe turns down an engine not called «Stockfish 19» right after `uci`, without
a search; a search has a 10 s guard, the probe 30 s; probes stop and their engines
quit (or are killed) when the program quits. Play engines (Rodent, Maia) are never
candidates.
- «Did not start» is its own outcome, said once and tried again next time; verdicts
are kept for the real file with the reference's key; the engine's name is checked
again when a job starts (a wrapper may run another program).
- The wait for a probe belongs to its game or preparation; the game analysis and the
opening errors wait apart; «analyse anew» keeps its `full`.
- The offer says why: another engine (settings / system), a Stockfish 19 that
calculates otherwise, one that did not start; the size line is back.
- Dropped files: missing ones told, known ChessBase parts only, duplicates by the real
file, each folder listed once; drops never replace a database being chosen again,
a cancelled «Choose again» ends it; «Added to the shelf» over a game; a framed
highlight with a card; long names shortened.
- decisions.md: where dropping works (not in a Wayland session: winit 0.30).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 13:42:19 +03:00
|
|
|
.cloned()
|
Web version, stage 1: the interface as a library over a platform layer; apps/web
apps/desktop becomes a library (chesspenguin_app: the interface) and a thin
binary; apps/web starts the same interface in a page's canvas (eframe's
WebRunner). cfg(web) (build.rs) marks WebAssembly in a browser.
The platform layer (apps/desktop/src/platform): the program's folders, files,
background work, the files the user opens or saves, the clipboard and what
the platform offers (CAPS). On a computer it is the system as before; in a
browser the program's data lives in IndexedDB behind an in-memory file tree
loaded before the start, the files the user opens are read into it for the
session (only read), background jobs run on the page's thread after the
frame, the clipboard is read through the browser's API, sounds play through
audio elements, a game is saved as a download.
What a browser does not have is not built for it: updates, the online games
window and its probe, engine processes (analysis starts a Web Worker there;
the review and preparation jobs, Rodent and the judge are native), blocking
requests (engine, Maia and Rodent downloads report no download for the
platform, translation reports that it makes no requests). The desktop
program behaves as before; its build finds unused code (the web build
compiles parts it never shows).
apps/web: the entry point, the page /app/ (device check before anything large
is loaded: phones and tablets get the page about the apps in the site's nine
languages, keys app_* in website/site/i18n), build.sh (wasm-bindgen, profile
web), a static server and headless Firefox checks.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 15:09:17 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Gives `pgn` to the user as the file `name` (a download, where the browser puts
|
|
|
|
|
/// them). Only a browser does this: the desktop program saves into files it chose.
|
|
|
|
|
#[cfg(web)]
|
|
|
|
|
pub fn download_pgn(name: &str, pgn: &str) -> Result<(), String> {
|
|
|
|
|
super::web::page::download(name, "application/x-chess-pgn", pgn.as_bytes())
|
|
|
|
|
.map_err(|e| format!("{e:?}"))
|
|
|
|
|
}
|
2026-10-31 13:16:15 +03:00
|
|
|
|
|
|
|
|
#[cfg(all(test, not(web)))]
|
|
|
|
|
mod tests {
|
|
|
|
|
use super::*;
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn dropped_files_are_sorted_into_databases() {
|
|
|
|
|
let dir = std::env::temp_dir().join(format!("cp-dropped-{}", std::process::id()));
|
|
|
|
|
let _ = std::fs::remove_dir_all(&dir);
|
|
|
|
|
let base = dir.join("Mega");
|
|
|
|
|
std::fs::create_dir_all(&base).unwrap();
|
|
|
|
|
let touch = |p: &std::path::Path| std::fs::write(p, b"x").unwrap();
|
|
|
|
|
let games = dir.join("games.PGN");
|
|
|
|
|
let archive = dir.join("set.7z");
|
|
|
|
|
let notes = dir.join("notes.txt");
|
|
|
|
|
let cbh = base.join("Mega.CBH");
|
Review engine and dropped files: fixes after the independent check
- The probe turns down an engine not called «Stockfish 19» right after `uci`, without
a search; a search has a 10 s guard, the probe 30 s; probes stop and their engines
quit (or are killed) when the program quits. Play engines (Rodent, Maia) are never
candidates.
- «Did not start» is its own outcome, said once and tried again next time; verdicts
are kept for the real file with the reference's key; the engine's name is checked
again when a job starts (a wrapper may run another program).
- The wait for a probe belongs to its game or preparation; the game analysis and the
opening errors wait apart; «analyse anew» keeps its `full`.
- The offer says why: another engine (settings / system), a Stockfish 19 that
calculates otherwise, one that did not start; the size line is back.
- Dropped files: missing ones told, known ChessBase parts only, duplicates by the real
file, each folder listed once; drops never replace a database being chosen again,
a cancelled «Choose again» ends it; «Added to the shelf» over a game; a framed
highlight with a card; long names shortened.
- decisions.md: where dropping works (not in a Wayland session: winit 0.30).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 13:42:19 +03:00
|
|
|
let parts = ["Mega.cbg", "Mega.cba", "Mega.cbj", "Mega.CBTT"].map(|n| base.join(n));
|
|
|
|
|
let ini = base.join("Mega.ini");
|
2026-10-31 13:16:15 +03:00
|
|
|
let lonely = dir.join("lost.cbg");
|
Review engine and dropped files: fixes after the independent check
- The probe turns down an engine not called «Stockfish 19» right after `uci`, without
a search; a search has a 10 s guard, the probe 30 s; probes stop and their engines
quit (or are killed) when the program quits. Play engines (Rodent, Maia) are never
candidates.
- «Did not start» is its own outcome, said once and tried again next time; verdicts
are kept for the real file with the reference's key; the engine's name is checked
again when a job starts (a wrapper may run another program).
- The wait for a probe belongs to its game or preparation; the game analysis and the
opening errors wait apart; «analyse anew» keeps its `full`.
- The offer says why: another engine (settings / system), a Stockfish 19 that
calculates otherwise, one that did not start; the size line is back.
- Dropped files: missing ones told, known ChessBase parts only, duplicates by the real
file, each folder listed once; drops never replace a database being chosen again,
a cancelled «Choose again» ends it; «Added to the shelf» over a game; a framed
highlight with a card; long names shortened.
- decisions.md: where dropping works (not in a Wayland session: winit 0.30).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 13:42:19 +03:00
|
|
|
for p in [&games, &archive, ¬es, &cbh, &lonely, &ini] {
|
2026-10-31 13:16:15 +03:00
|
|
|
touch(p);
|
|
|
|
|
}
|
|
|
|
|
for p in &parts {
|
|
|
|
|
touch(p);
|
|
|
|
|
}
|
|
|
|
|
let cbv = base.join("Other.cbv");
|
|
|
|
|
touch(&cbv);
|
|
|
|
|
let empty = dir.join("empty");
|
|
|
|
|
std::fs::create_dir_all(&empty).unwrap();
|
|
|
|
|
touch(&empty.join("readme.md"));
|
|
|
|
|
|
|
|
|
|
// Files of each kind; all the files of a ChessBase database give it once.
|
|
|
|
|
let mut dropped = vec![games.clone(), archive.clone()];
|
|
|
|
|
dropped.extend(parts.iter().cloned());
|
|
|
|
|
dropped.push(cbh.clone());
|
|
|
|
|
let picked = sort_dropped(&dropped);
|
|
|
|
|
assert_eq!(
|
|
|
|
|
picked.paths,
|
|
|
|
|
vec![games.clone(), archive.clone(), cbh.clone()]
|
|
|
|
|
);
|
Review engine and dropped files: fixes after the independent check
- The probe turns down an engine not called «Stockfish 19» right after `uci`, without
a search; a search has a 10 s guard, the probe 30 s; probes stop and their engines
quit (or are killed) when the program quits. Play engines (Rodent, Maia) are never
candidates.
- «Did not start» is its own outcome, said once and tried again next time; verdicts
are kept for the real file with the reference's key; the engine's name is checked
again when a job starts (a wrapper may run another program).
- The wait for a probe belongs to its game or preparation; the game analysis and the
opening errors wait apart; «analyse anew» keeps its `full`.
- The offer says why: another engine (settings / system), a Stockfish 19 that
calculates otherwise, one that did not start; the size line is back.
- Dropped files: missing ones told, known ChessBase parts only, duplicates by the real
file, each folder listed once; drops never replace a database being chosen again,
a cancelled «Choose again» ends it; «Added to the shelf» over a game; a framed
highlight with a card; long names shortened.
- decisions.md: where dropping works (not in a Wayland session: winit 0.30).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 13:42:19 +03:00
|
|
|
assert!(picked.unsupported.is_empty() && picked.missing.is_empty());
|
2026-10-31 13:16:15 +03:00
|
|
|
assert!(!picked.empty_folder);
|
|
|
|
|
|
Review engine and dropped files: fixes after the independent check
- The probe turns down an engine not called «Stockfish 19» right after `uci`, without
a search; a search has a 10 s guard, the probe 30 s; probes stop and their engines
quit (or are killed) when the program quits. Play engines (Rodent, Maia) are never
candidates.
- «Did not start» is its own outcome, said once and tried again next time; verdicts
are kept for the real file with the reference's key; the engine's name is checked
again when a job starts (a wrapper may run another program).
- The wait for a probe belongs to its game or preparation; the game analysis and the
opening errors wait apart; «analyse anew» keeps its `full`.
- The offer says why: another engine (settings / system), a Stockfish 19 that
calculates otherwise, one that did not start; the size line is back.
- Dropped files: missing ones told, known ChessBase parts only, duplicates by the real
file, each folder listed once; drops never replace a database being chosen again,
a cancelled «Choose again» ends it; «Added to the shelf» over a game; a framed
highlight with a card; long names shortened.
- decisions.md: where dropping works (not in a Wayland session: winit 0.30).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 13:42:19 +03:00
|
|
|
// What is no database is named: another file, a ChessBase part without its
|
|
|
|
|
// .cbh, a file of an unknown kind beside a .cbh.
|
|
|
|
|
let picked = sort_dropped(&[notes.clone(), lonely.clone(), ini.clone(), games.clone()]);
|
2026-10-31 13:16:15 +03:00
|
|
|
assert_eq!(picked.paths, vec![games.clone()]);
|
Review engine and dropped files: fixes after the independent check
- The probe turns down an engine not called «Stockfish 19» right after `uci`, without
a search; a search has a 10 s guard, the probe 30 s; probes stop and their engines
quit (or are killed) when the program quits. Play engines (Rodent, Maia) are never
candidates.
- «Did not start» is its own outcome, said once and tried again next time; verdicts
are kept for the real file with the reference's key; the engine's name is checked
again when a job starts (a wrapper may run another program).
- The wait for a probe belongs to its game or preparation; the game analysis and the
opening errors wait apart; «analyse anew» keeps its `full`.
- The offer says why: another engine (settings / system), a Stockfish 19 that
calculates otherwise, one that did not start; the size line is back.
- Dropped files: missing ones told, known ChessBase parts only, duplicates by the real
file, each folder listed once; drops never replace a database being chosen again,
a cancelled «Choose again» ends it; «Added to the shelf» over a game; a framed
highlight with a card; long names shortened.
- decisions.md: where dropping works (not in a Wayland session: winit 0.30).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 13:42:19 +03:00
|
|
|
assert_eq!(picked.unsupported, ["notes.txt", "lost.cbg", "Mega.ini"]);
|
|
|
|
|
|
|
|
|
|
// A file no longer there: named, not taken.
|
|
|
|
|
let picked = sort_dropped(&[dir.join("gone.pgn"), games.clone()]);
|
|
|
|
|
assert_eq!(picked.paths, vec![games.clone()]);
|
|
|
|
|
assert_eq!(picked.missing, ["gone.pgn"]);
|
|
|
|
|
assert!(picked.unsupported.is_empty());
|
2026-10-31 13:16:15 +03:00
|
|
|
|
|
|
|
|
// A folder: its databases (by name); one without any is told.
|
|
|
|
|
let picked = sort_dropped(&[base.clone(), empty.clone()]);
|
|
|
|
|
assert_eq!(picked.paths, vec![cbh.clone(), cbv.clone()]);
|
|
|
|
|
assert!(picked.empty_folder);
|
|
|
|
|
|
Review engine and dropped files: fixes after the independent check
- The probe turns down an engine not called «Stockfish 19» right after `uci`, without
a search; a search has a 10 s guard, the probe 30 s; probes stop and their engines
quit (or are killed) when the program quits. Play engines (Rodent, Maia) are never
candidates.
- «Did not start» is its own outcome, said once and tried again next time; verdicts
are kept for the real file with the reference's key; the engine's name is checked
again when a job starts (a wrapper may run another program).
- The wait for a probe belongs to its game or preparation; the game analysis and the
opening errors wait apart; «analyse anew» keeps its `full`.
- The offer says why: another engine (settings / system), a Stockfish 19 that
calculates otherwise, one that did not start; the size line is back.
- Dropped files: missing ones told, known ChessBase parts only, duplicates by the real
file, each folder listed once; drops never replace a database being chosen again,
a cancelled «Choose again» ends it; «Added to the shelf» over a game; a framed
highlight with a card; long names shortened.
- decisions.md: where dropping works (not in a Wayland session: winit 0.30).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 13:42:19 +03:00
|
|
|
// The same file by a link and by its own path: once.
|
|
|
|
|
#[cfg(unix)]
|
|
|
|
|
{
|
|
|
|
|
let link = dir.join("link.pgn");
|
|
|
|
|
std::os::unix::fs::symlink(&games, &link).unwrap();
|
|
|
|
|
let picked = sort_dropped(&[link.clone(), games.clone()]);
|
|
|
|
|
assert_eq!(picked.paths, vec![link]);
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-31 13:16:15 +03:00
|
|
|
let _ = std::fs::remove_dir_all(&dir);
|
|
|
|
|
}
|
|
|
|
|
}
|