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>
This commit is contained in:
parent
a4445d2c15
commit
3e69a5d57c
61 changed files with 2628 additions and 552 deletions
|
|
@ -1,14 +1,15 @@
|
|||
//! Games from Lichess and Chess.com on the desktop: the databases live in
|
||||
//! `<local data dir>/online/`; the downloads themselves are the `online-games` crate's
|
||||
//! (shared with the Android app). Both public APIs are probed at start; a platform that
|
||||
//! does not answer as expected (offline, the API changed) is simply not offered.
|
||||
//! does not answer as expected (offline, the API changed) is simply not offered. The
|
||||
//! web version has no online games: there only the names of such databases are known.
|
||||
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::time::Duration;
|
||||
|
||||
pub use online_games::{Account, Platform, State};
|
||||
#[cfg(not(web))]
|
||||
pub use online_games::{
|
||||
Account, Done, Failure, LICHESS_RATE, Lookup, Platform, Progress, State, download, lookup,
|
||||
probe_all, valid_nick,
|
||||
Done, Failure, LICHESS_RATE, Lookup, Progress, download, lookup, probe_all, valid_nick,
|
||||
};
|
||||
|
||||
/// Where the online databases live.
|
||||
|
|
@ -43,18 +44,20 @@ pub fn ago(t: i64) -> String {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(not(web))]
|
||||
/// The probe results and what the window shows, kept by the application.
|
||||
pub struct Probe {
|
||||
job: Option<std::sync::mpsc::Receiver<[bool; 2]>>,
|
||||
pub available: [bool; 2],
|
||||
/// When the last probe finished (a platform that did not answer is asked again
|
||||
/// after [`Probe::RETRY`]: the machine may have come online).
|
||||
last: Option<std::time::Instant>,
|
||||
last: Option<web_time::Instant>,
|
||||
ctx: egui::Context,
|
||||
}
|
||||
|
||||
#[cfg(not(web))]
|
||||
impl Probe {
|
||||
const RETRY: Duration = Duration::from_secs(300);
|
||||
const RETRY: std::time::Duration = std::time::Duration::from_secs(300);
|
||||
|
||||
/// Starts probing both platforms in the background.
|
||||
pub fn start(ctx: &egui::Context) -> Probe {
|
||||
|
|
@ -90,7 +93,7 @@ impl Probe {
|
|||
*have |= now;
|
||||
}
|
||||
self.job = None;
|
||||
self.last = Some(std::time::Instant::now());
|
||||
self.last = Some(web_time::Instant::now());
|
||||
}
|
||||
if self.job.is_none() && !self.available.iter().all(|a| *a) {
|
||||
match self.last {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue