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:
vrubelroman 2026-10-30 15:09:17 +03:00
parent a4445d2c15
commit 3e69a5d57c
61 changed files with 2628 additions and 552 deletions

View file

@ -61,29 +61,31 @@ impl Lang {
pub fn from_locales<S: AsRef<str>>(locales: impl IntoIterator<Item = S>) -> Lang {
locales
.into_iter()
.find_map(|l| {
// "ru-RU", "ru_RU.UTF-8", "de-CH", "es-419", "fr".
let code = l
.as_ref()
.split(['-', '_', '.', '@'])
.next()?
.to_ascii_lowercase();
match code.as_str() {
"en" => Some(Lang::En),
"ru" => Some(Lang::Ru),
"fr" => Some(Lang::Fr),
"de" => Some(Lang::De),
"es" => Some(Lang::Es),
"it" => Some(Lang::It),
"pt" => Some(Lang::Pt),
"uz" => Some(Lang::Uz),
"kk" => Some(Lang::Kk),
_ => None,
}
})
.find_map(|l| Lang::from_locale(l.as_ref()))
.unwrap_or_default()
}
/// The language of a locale ("ru-RU", "ru_RU.UTF-8", "de-CH", "es-419", "fr"), if
/// it is one of ours.
pub fn from_locale(locale: &str) -> Option<Lang> {
let code = locale
.split(['-', '_', '.', '@'])
.next()?
.to_ascii_lowercase();
match code.as_str() {
"en" => Some(Lang::En),
"ru" => Some(Lang::Ru),
"fr" => Some(Lang::Fr),
"de" => Some(Lang::De),
"es" => Some(Lang::Es),
"it" => Some(Lang::It),
"pt" => Some(Lang::Pt),
"uz" => Some(Lang::Uz),
"kk" => Some(Lang::Kk),
_ => None,
}
}
/// The language of this system (see [`Lang::from_locales`]).
pub fn system() -> Lang {
Lang::from_locales(sys_locale::get_locales())
@ -214,6 +216,51 @@ pub fn trf(key: &'static str, args: &[(&str, &dyn Display)]) -> String {
// [English, Русский, Français, Deutsch, Español, Italiano, Português (BR), O‘zbekcha, Қазақша]
// Uzbek o‘ and g‘ are written with ‘ (U+2018): the interface font has no U+02BB.
const ROWS: &[[&str; 9]] = &[
// --- the web version ---
[
"⇩ Download PGN",
"⇩ Скачать PGN",
"⇩ Télécharger le PGN",
"⇩ PGN herunterladen",
"⇩ Descargar PGN",
"⇩ Scarica PGN",
"⇩ Baixar PGN",
"⇩ PGN yuklab olish",
"⇩ PGN жүктеп алу",
],
[
"Download the game as a PGN file: the browser puts it where it puts downloads",
"Скачать партию файлом PGN: браузер положит его туда же, куда все загрузки",
"Télécharger la partie en fichier PGN : le navigateur le met avec les autres téléchargements",
"Die Partie als PGN-Datei herunterladen: Der Browser legt sie zu den anderen Downloads",
"Descargar la partida como archivo PGN: el navegador lo guarda con las demás descargas",
"Scarica la partita come file PGN: il browser lo mette insieme agli altri download",
"Baixar a partida como arquivo PGN: o navegador o coloca junto dos outros downloads",
"Partiyani PGN fayl sifatida yuklab olish: brauzer uni boshqa yuklamalar qatoriga qo‘yadi",
"Партияны PGN файлы ретінде жүктеп алу: браузер оны басқа жүктемелермен бірге сақтайды",
],
[
"The PGN could not be downloaded: {e}",
"Не удалось скачать PGN: {e}",
"Impossible de télécharger le PGN : {e}",
"PGN konnte nicht heruntergeladen werden: {e}",
"No se pudo descargar el PGN: {e}",
"Impossibile scaricare il PGN: {e}",
"Não foi possível baixar o PGN: {e}",
"PGN yuklab olinmadi: {e}",
"PGN жүктеп алынбады: {e}",
],
[
"a browser cannot start it",
"браузер не может его запустить",
"un navigateur ne peut pas le lancer",
"ein Browser kann ihn nicht starten",
"un navegador no puede iniciarlo",
"un browser non può avviarlo",
"um navegador não consegue iniciá-lo",
"brauzer uni ishga tushira olmaydi",
"браузер оны іске қоса алмайды",
],
// --- engine download ---
[
"Stockfish installed — game analysis started",