commit 577682ae2256e932b3924173969b794565fba767 Author: Carlo Baratto Date: Thu Nov 12 19:10:26 2026 +0100 Mosaic: motore di rendering proprio, gusci desktop e Sailfish Primo commit del progetto: motore Rust con parser HTML, cascata CSS, layout, raster CPU, formulari, bidi, flex, tabelle, JavaScript (Boa) con eventi e costruzione di nodi, rete HTTP/HTTPS con TLS, sotto-risorse, invio dei formulari; guscio grafico per Sailfish (QML/Silica) e per desktop (minifb, distribuito come AppImage), con 11 documenti di specifica e 91 casi di reftest. diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..47d66ea --- /dev/null +++ b/.gitignore @@ -0,0 +1,17 @@ +# Build: mai nel repository. Il motore si ricostruisce con `cargo build --release`, +# i gusci con `scripts/build.sh` e `appimage/build.sh`. +engine/target/ +target/ +desktop/appimage/build/ +desktop/appimage/runtime-x86_64 + +# Statici e pacchetti: sono prodotti, non sorgenti (135 MB di libreria, 6-7 MB a pacchetto) +harbour-mosaic/libs/ +harbour-mosaic/RPMS/ +*.rpm +*.AppImage +*.a + +# File di lavoro delle prove +*.png.orig +*.tmp diff --git a/README.md b/README.md new file mode 100644 index 0000000..e52132e --- /dev/null +++ b/README.md @@ -0,0 +1,79 @@ +# Motore di rendering indipendente — documentazione funzionale + +Corpus di specifiche per un motore di rendering HTML/CSS scritto da zero, destinato a un +browser indipendente. Nessuna dipendenza da WebKit, Blink, Gecko, Servo, Ladybird o altri +motori esistenti: pipeline, parser, motore di stile, layout e rasterizzazione sono +implementati internamente. + +## Stato + +| Campo | Valore | +|---|---| +| Versione documento | 0.1 (bozza di progetto) | +| Linguaggio di riferimento | Rust 2021 (assunzione; le interfacce sono descritte in modo neutro) | +| Piattaforme target | Linux x86_64/aarch64, Wayland e X11; Sailfish OS 5.1 (aarch64/armv7hl) come piattaforma di test primaria (doc 11); Windows e macOS in fase successiva | +| Standard di riferimento | WHATWG HTML Living Standard, CSS Snapshot 2023, DOM Standard, Fetch, ECMAScript | + +## Implementazione + +| Componente | Percorso | Stato | +|---|---|---| +| Motore | `engine/` | M1 chiusa, M2.6 avviata: 90 reftest verdi, 8 dipendenze dirette (2 nuove per TLS) | +| Guscio Sailfish | `harbour-mosaic/` | RPM `0.4.1-1.aarch64` | +| Guscio desktop | `desktop/` | AppImage `0.1.0` x86_64 (Zorin/Ubuntu) | + +I due gusci condividono lo stesso motore: si ricostruiscono insieme. + +**Versioni:** si incrementa sempre la terza cifra (`x.x.1`), non la seconda. + +## Convenzioni + +- `DEVE` / `DOVREBBE` / `PUÒ` hanno valore normativo (RFC 2119). +- Ogni requisito ha un identificatore stabile (`RF-*` funzionale, `RN-*` non funzionale, + `RS-*` sicurezza) citabile nei test e nelle review. +- Le interfacce sono pseudo-firme: nomi, tipi e semantica sono vincolanti, la sintassi no. +- Il perimetro esclude le estensioni del browser: questa documentazione riguarda solo il + motore. UI, gestione schede e sync sono fuori ambito. + +## Indice + +| # | Documento | Contenuto | +|---|---|---| +| 01 | [Requisiti](docs/01-requisiti.md) | obiettivi, perimetro, requisiti funzionali e non funzionali, metriche di accettazione | +| 02 | [Architettura](docs/02-architettura.md) | pipeline, processi, thread, IPC, modello di invalidazione e frame | +| 03 | [Parsing HTML](docs/03-parsing-html.md) | tokenizer, tree builder, recupero dagli errori, contenuto estraneo, preload scanner | +| 04 | [Stile e CSS](docs/04-stile-css.md) | parsing CSS, cascata, matching dei selettori, invalidazione, animazioni | +| 05 | [Layout](docs/05-layout.md) | albero dei box, contesti di formattazione, dimensioni intrinseche, incrementale | +| 06 | [Paint e compositing](docs/06-paint-compositing.md) | display list, layerizzazione, tile, GPU, gestione del danno, colore | +| 07 | [DOM e scripting](docs/07-dom-scripting.md) | binding JavaScript, event loop, integrazione con il parsing, GC | +| 08 | [Rete e sicurezza](docs/08-rete-sicurezza.md) | stack di rete, cookie, cache, isolamento per sito, sandbox | +| 09 | [Test e conformità](docs/09-test-conformita.md) | WPT, reftest, fuzzing, budget di prestazioni, CI | +| 10 | [Roadmap](docs/10-roadmap.md) | milestone M0–M4 con criteri di uscita | +| 11 | [Browser Sailfish per i test](docs/11-browser-sailfish-test.md) | guscio `harbour-mosaic`, integrazione Rust↔Qt, harness on-device, budget su dispositivo | + +## Dipendenze ammesse + +Il divieto riguarda i **motori di rendering**, non le librerie di supporto. Sono ammesse +e previste: + +- `rustls` + `quinn` per TLS e QUIC; `h2` per HTTP/2. +- `rustls` + `webpki-roots` per TLS (M2.6): `ring` porta codice C e assembly, quindi il + cross-build aarch64 richiede `gcc-aarch64-linux-gnu` e `CC_aarch64_unknown_linux_gnu`; +- `rustybuzz` (port Rust di HarfBuzz) per lo shaping: nessuna dipendenza C, quindi la + staticlib resta cross-compilabile per Sailfish senza toolchain di cross-link (doc 11 §7). + `ICU4X` per line breaking, bidi e collazione. +- `wgpu` per l'accesso a Vulkan/Metal/DX12. +- `ab_glyph` per gli outline dei glifi, `image` (solo backend Rust) per PNG/JPEG/WebP. + +Sono escluse: qualsiasi libreria che implementi parsing HTML, cascade CSS, layout o +compositing proveniente da un motore esistente. + +## Decisioni aperte + +| ID | Questione | Stato | +|---|---|---| +| DA-1 | Motore JavaScript proprio o `Boa` (Rust puro) come host | da decidere entro M1 | +| DA-2 | Modello di processo: un processo per sito o per origine | proposta in 02, da confermare | +| DA-3 | Supporto al testo verticale e all'RTL nella prima release | proposta: RTL sì, verticale in M3 | +| DA-4 | Modello di processo su Sailfish: motore in-process nell'app invece di un content process | proposta: in-process, con codice che non assume isolamento (TS-09) | +| DA-5 | Nome del guscio di riferimento per i test: `harbour-mosaic` | proposta: prefisso del pacchetto, chrome dalla riedizione Mosaic | diff --git a/desktop/Cargo.lock b/desktop/Cargo.lock new file mode 100644 index 0000000..4eb5d1e --- /dev/null +++ b/desktop/Cargo.lock @@ -0,0 +1,1953 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "ab_glyph" +version = "0.2.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01c0457472c38ea5bd1c3b5ada5e368271cb550be7a4ca4a0b4634e9913f6cc2" +dependencies = [ + "ab_glyph_rasterizer", + "owned_ttf_parser", +] + +[[package]] +name = "ab_glyph_rasterizer" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "366ffbaa4442f4684d91e2cd7c5ea7c4ed8add41959a31447066e279e432b618" + +[[package]] +name = "adler2" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" + +[[package]] +name = "allocator-api2" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" + +[[package]] +name = "arrayvec" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3fb67a6e08acf24fdeccbac2cb6ac4305825bd1f117462e0e6f2f193345ad56" + +[[package]] +name = "autocfg" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitflags" +version = "2.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06" + +[[package]] +name = "boa_ast" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c340fe0f0b267787095cbe35240c6786ff19da63ec7b69367ba338eace8169b" +dependencies = [ + "bitflags 2.13.2", + "boa_interner", + "boa_macros", + "boa_string", + "indexmap", + "num-bigint", + "rustc-hash", +] + +[[package]] +name = "boa_engine" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f620c3f06f51e65c0504ddf04978be1b814ac6586f0b45f6019801ab5efd37f9" +dependencies = [ + "arrayvec", + "bitflags 2.13.2", + "boa_ast", + "boa_gc", + "boa_interner", + "boa_macros", + "boa_parser", + "boa_profiler", + "boa_string", + "bytemuck", + "cfg-if", + "dashmap", + "fast-float2", + "hashbrown 0.15.5", + "icu_normalizer", + "indexmap", + "intrusive-collections", + "itertools", + "num-bigint", + "num-integer", + "num-traits", + "num_enum", + "once_cell", + "pollster", + "portable-atomic", + "rand", + "regress", + "rustc-hash", + "ryu-js", + "serde", + "serde_json", + "sptr", + "static_assertions", + "tap", + "thin-vec", + "thiserror", + "time", +] + +[[package]] +name = "boa_gc" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2425c0b7720d42d73eaa6a883fbb77a5c920da8694964a3d79a67597ac55cce2" +dependencies = [ + "boa_macros", + "boa_profiler", + "boa_string", + "hashbrown 0.15.5", + "thin-vec", +] + +[[package]] +name = "boa_interner" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42407a3b724cfaecde8f7d4af566df4b56af32a2f11f0956f5570bb974e7f749" +dependencies = [ + "boa_gc", + "boa_macros", + "hashbrown 0.15.5", + "indexmap", + "once_cell", + "phf", + "rustc-hash", + "static_assertions", +] + +[[package]] +name = "boa_macros" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fd3f870829131332587f607a7ff909f1af5fc523fd1b192db55fbbdf52e8d3c" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", + "synstructure 0.13.2", +] + +[[package]] +name = "boa_parser" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9cc142dac798cdc6e2dbccfddeb50f36d2523bb977a976e19bdb3ae19b740804" +dependencies = [ + "bitflags 2.13.2", + "boa_ast", + "boa_interner", + "boa_macros", + "boa_profiler", + "fast-float2", + "icu_properties", + "num-bigint", + "num-traits", + "regress", + "rustc-hash", +] + +[[package]] +name = "boa_profiler" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4064908e7cdf9b6317179e9b04dcb27f1510c1c144aeab4d0394014f37a0f922" + +[[package]] +name = "boa_string" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7debc13fbf7997bf38bf8e9b20f1ad5e2a7d27a900e1f6039fe244ce30f589b5" +dependencies = [ + "fast-float2", + "paste", + "rustc-hash", + "sptr", + "static_assertions", +] + +[[package]] +name = "bumpalo" +version = "3.20.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72f5acc6cb2ba439de613abc23857ec3d78374d8ed5ac84e9d11336e87da8649" + +[[package]] +name = "bytemuck" +version = "1.25.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95832e849adfb21180ccb6826a99da14e5d266ae5c2e668e1602cf234f153797" +dependencies = [ + "bytemuck_derive", +] + +[[package]] +name = "bytemuck_derive" +version = "1.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a1f896587b6f2c069c73d2f0913e2d590c3990285cd2f0b6aa02b786b4c679c" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", +] + +[[package]] +name = "byteorder-lite" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f1fe948ff07f4bd06c30984e69f5b4899c516a3ef74f34df92a2df2ab535495" + +[[package]] +name = "cc" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ff2a8126fff0f8c839080d619675a585e61720bb12d2baceae45769fd66f155" +dependencies = [ + "find-msvc-tools", + "shlex", +] + +[[package]] +name = "cfg-if" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600" + +[[package]] +name = "console_error_panic_hook" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a06aeb73f470f66dcdbf7223caeebb85984942f22f1adb2a088cf9668146bbbc" +dependencies = [ + "cfg-if", + "wasm-bindgen", +] + +[[package]] +name = "core_maths" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77745e017f5edba1a9c1d854f6f3a52dac8a12dd5af5d2f54aecf61e43d80d30" +dependencies = [ + "libm", +] + +[[package]] +name = "crc32fast" +version = "1.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b929dd2a135771f40afabd1073f85eed59c800b7c61901e5c254270497dad64" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a31eee39dddec8330830986fcd7625edb5a24ec90ea038215273bbc3adb08ac6" + +[[package]] +name = "dashmap" +version = "6.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6361d5c062261c78a176addb82d4c821ae42bed6089de0e12603cd25de2059c" +dependencies = [ + "cfg-if", + "crossbeam-utils", + "hashbrown 0.14.5", + "lock_api", + "once_cell", + "parking_lot_core", +] + +[[package]] +name = "deranged" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e9de72ce2ad1f90dc62fa25f0f430ef85eb4b0d8fa0be4f30373bc40a21d28e" + +[[package]] +name = "displaydoc" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6232dd377dcc64799954cbd3a9bb882e9cdc1308ccd87b1c098f1fb2eaf82a8" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", +] + +[[package]] +name = "either" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e9c71c2167ca323c882b99918929403426e2373ea17242ff5653e0d5e1058be" + +[[package]] +name = "engine" +version = "0.1.0" +dependencies = [ + "ab_glyph", + "boa_engine", + "image", + "png 0.17.16", + "rustls", + "rustybuzz", + "serde_json", + "webpki-roots 0.26.11", +] + +[[package]] +name = "equivalent" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00d174d5400e5e8fd687ad1049e2f578285fa914201b1af7e8b112a4546bd826" + +[[package]] +name = "fast-float2" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6e8948ce679d00a02a94739ea185595dca7118ed04feb991127e443bd3d761f" + +[[package]] +name = "fdeflate" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e6853b52649d4ac5c0bd02320cddc5ba956bdb407c4b75a2c6b75bf51500f8c" +dependencies = [ + "simd-adler32", +] + +[[package]] +name = "find-msvc-tools" +version = "0.1.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c66915cc5391097de7a2b0b972e8505aa33c0df401fd3a6811dbdb32881ba48" + +[[package]] +name = "flate2" +version = "1.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "626d4928326b646e70f65ed36fc7cf9f206bdb68a0019ee7c6b4709da4e084c4" +dependencies = [ + "crc32fast", + "miniz_oxide 0.9.1", + "zlib-rs", +] + +[[package]] +name = "foldhash" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" + +[[package]] +name = "foldhash" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb" + +[[package]] +name = "futures" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a31d2a3fbaaeb2af2368bbdd904aa8e812d3c04a1ee10d3171f52d556e5d0a3" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1f9e3d69d39e4862ffed03ed071a76f9a13ba1d9109d355b0f0aa6b15e393c4" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92d699e522242e69e3003b94ecc1f960f3a5e015aa7c5d7486e65ad01dd94f5e" + +[[package]] +name = "futures-executor" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "031b47cf1a3c6cc8bc2fc76cd437f521619387907d469316e7c0bc278f1f5432" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-io" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53c0fa8157de1303bfffdaa1cc2a673bfffb60102f76b0ef4441659124373fed" + +[[package]] +name = "futures-macro" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fb9654ba8355388abeb8dcb4fc62f511300867002afc858860463bdd9fe0c44" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", +] + +[[package]] +name = "futures-sink" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1944426bf7d03f1d14f708785e4b33efd750b36d48a157b836b3efc15ede8e1d" + +[[package]] +name = "futures-task" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd417de3d1d015fc3bfd2b1ea46dfc7bab72ef86f1cc7cc9c78e728b34a6d1fd" + +[[package]] +name = "futures-util" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d50a92467f8ba5dd6e3ee5d4bd04d73ab2e4e1c44474a0674821dfce14b79bc" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "slab", +] + +[[package]] +name = "getrandom" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "hashbrown" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" + +[[package]] +name = "hashbrown" +version = "0.15.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" +dependencies = [ + "allocator-api2", + "equivalent", + "foldhash 0.1.5", +] + +[[package]] +name = "hashbrown" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" +dependencies = [ + "allocator-api2", + "equivalent", + "foldhash 0.2.0", +] + +[[package]] +name = "hashbrown" +version = "0.17.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a" + +[[package]] +name = "icu_collections" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db2fa452206ebee18c4b5c2274dbf1de17008e874b4dc4f0aea9d01ca79e4526" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locid" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13acbb8371917fc971be86fc8057c41a64b521c184808a698c02acc242dbf637" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_locid_transform" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01d11ac35de8e40fdeda00d9e1e9d92525f3f9d887cdd7aa81d727596788b54e" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_locid_transform_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_locid_transform_data" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7515e6d781098bf9f7205ab3fc7e9709d34554ae0b21ddbcb5febfa4bc7df11d" + +[[package]] +name = "icu_normalizer" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19ce3e0da2ec68599d193c93d088142efd7f9c5d6fc9b803774855747dc6a84f" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "utf16_iter", + "utf8_iter", + "write16", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c5e8338228bdc8ab83303f16b797e177953730f601a96c25d10cb3ab0daa0cb7" + +[[package]] +name = "icu_properties" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93d6020766cfc6302c15dbbc9c8778c37e62c14427cb7f6e601d849e092aeef5" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_locid_transform", + "icu_properties_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85fb8799753b75aee8d2a21d7c14d9f38921b54b3dbda10f5a3c7a7b82dba5e2" + +[[package]] +name = "icu_provider" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ed421c8a8ef78d3e2dbc98a973be2f3770cb42b606e3ab18d6237c4dfde68d9" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_provider_macros", + "stable_deref_trait", + "tinystr", + "writeable", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_provider_macros" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "image" +version = "0.25.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85ab80394333c02fe689eaf900ab500fbd0c2213da414687ebf995a65d5a6104" +dependencies = [ + "bytemuck", + "byteorder-lite", + "image-webp", + "moxcms", + "num-traits", + "png 0.18.1", + "zune-core", + "zune-jpeg", +] + +[[package]] +name = "image-webp" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "525e9ff3e1a4be2fbea1fdf0e98686a6d98b4d8f937e1bf7402245af1909e8c3" +dependencies = [ + "byteorder-lite", + "quick-error", +] + +[[package]] +name = "indexmap" +version = "2.14.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc4e190f5d26ca7051642629da2c52fc03bde85a03197c99408dcd291734c855" +dependencies = [ + "equivalent", + "hashbrown 0.17.1", +] + +[[package]] +name = "instant" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0242819d153cba4b4b05a5a8f2a7e9bbf97b6055b2a002b395c96b5ff3c0222" +dependencies = [ + "cfg-if", + "js-sys", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "intrusive-collections" +version = "0.9.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "189d0897e4cbe8c75efedf3502c18c887b05046e59d28404d4d8e46cbc4d1e86" +dependencies = [ + "memoffset", +] + +[[package]] +name = "itertools" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3bd1574e617a9a6c1f8f8181bd7e841e1f20e4277607ef28945765188d6284d4" + +[[package]] +name = "js-sys" +version = "0.3.107" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8dc09d2154098bbf4ef54eab6b117a3c24cbbffe94046b16ee6d6d4510584d3a" +dependencies = [ + "cfg-if", + "futures-util", + "wasm-bindgen", +] + +[[package]] +name = "lazy_static" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20870f649af7073d53e38067b2a84312175d56ea15217e1b15bc83506ec50afb" + +[[package]] +name = "libc" +version = "0.2.191" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a" + +[[package]] +name = "libm" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981" + +[[package]] +name = "libredox" +version = "0.1.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61ff90caf6077a803a240f62fdbe88645a890bbca49ef8174c3cb0404362171d" +dependencies = [ + "bitflags 2.13.2", + "libc", + "plain", + "redox_syscall 0.9.5", +] + +[[package]] +name = "litemap" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23fb14cb19457329c82206317a5663005a4d404783dc74f4252769b0d5f42856" + +[[package]] +name = "lock_api" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965" +dependencies = [ + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d15f86d12da44cd8d4ec3c73984537eb7f4cadcb9776a575a0a8a05ca11005c" + +[[package]] +name = "memchr" +version = "2.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98" + +[[package]] +name = "memoffset" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a" +dependencies = [ + "autocfg", +] + +[[package]] +name = "minifb" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1a093126f2ed9012fc0b146934c97eb0273e54983680a8bf5309b6b4a365b32" +dependencies = [ + "cc", + "console_error_panic_hook", + "futures", + "instant", + "js-sys", + "libc", + "orbclient", + "raw-window-handle", + "serde", + "serde_derive", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "winapi", + "x11-dl", +] + +[[package]] +name = "miniz_oxide" +version = "0.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316" +dependencies = [ + "adler2", + "simd-adler32", +] + +[[package]] +name = "miniz_oxide" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b63fbc4a50860e98e7b2aa7804ded1db5cbc3aff9193adaff57a6931bf7c4b4c" +dependencies = [ + "adler2", + "simd-adler32", +] + +[[package]] +name = "mosaic-desktop" +version = "0.2.0" +dependencies = [ + "engine", + "minifb", +] + +[[package]] +name = "moxcms" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb85c154ba489f01b25c0d36ae69a87e4a1c73a72631fc6c0eb6dde34a73e44b" +dependencies = [ + "num-traits", + "pxfm", +] + +[[package]] +name = "num-bigint" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c89e69e7e0f03bea5ef08013795c25018e101932225a656383bd384495ecc367" +dependencies = [ + "num-integer", + "num-traits", + "serde", +] + +[[package]] +name = "num-conv" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "521739c6d2bac4aa25192232afe6841231376b2b26d4d9fae5ecf8ca5772e441" + +[[package]] +name = "num-integer" +version = "0.1.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ce2d95d4b3734dc35aa2f45e1aa22cd416814592a4f9d9205e11affd5b8e10b" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "num_enum" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d0bca838442ec211fa11de3a8b0e0e8f3a4522575b5c4c06ed722e005036f26" +dependencies = [ + "num_enum_derive", + "rustversion", +] + +[[package]] +name = "num_enum_derive" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "680998035259dcfcafe653688bf2aa6d3e2dc05e98be6ab46afb089dc84f1df8" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "num_threads" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cabcc654086861f9e1bc5115258de62ef92c79b20f4615a1b0cc57c4e82027d4" +dependencies = [ + "libc", +] + +[[package]] +name = "once_cell" +version = "1.21.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" + +[[package]] +name = "orbclient" +version = "0.3.55" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5df339f526ea9a60e371768d50efc2f2508c7203290731565d1f7a6f71d21747" +dependencies = [ + "libc", + "libredox", + "sdl2", +] + +[[package]] +name = "owned_ttf_parser" +version = "0.25.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36820e9051aca1014ddc75770aab4d68bc1e9e632f0f5627c4086bc216fb583b" +dependencies = [ + "ttf-parser", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall 0.5.18", + "smallvec", + "windows-link", +] + +[[package]] +name = "paste" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" + +[[package]] +name = "phf" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd6780a80ae0c52cc120a26a1a42c1ae51b247a253e4e06113d23d2c2edd078" +dependencies = [ + "phf_macros", + "phf_shared", +] + +[[package]] +name = "phf_generator" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c80231409c20246a13fddb31776fb942c38553c51e871f8cbd687a4cfb5843d" +dependencies = [ + "phf_shared", + "rand", +] + +[[package]] +name = "phf_macros" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f84ac04429c13a7ff43785d75ad27569f2951ce0ffd30a3321230db2fc727216" +dependencies = [ + "phf_generator", + "phf_shared", + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "phf_shared" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67eabc2ef2a60eb7faa00097bd1ffdb5bd28e62bf39990626a582201b7a754e5" +dependencies = [ + "siphasher", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" + +[[package]] +name = "pkg-config" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6b464fbc74e149a392436b17d523f769e057cb6877f6a5c4618bc6f11800548" + +[[package]] +name = "plain" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" + +[[package]] +name = "png" +version = "0.17.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82151a2fc869e011c153adc57cf2789ccb8d9906ce52c0b39a6b5697749d7526" +dependencies = [ + "bitflags 1.3.2", + "crc32fast", + "fdeflate", + "flate2", + "miniz_oxide 0.8.9", +] + +[[package]] +name = "png" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60769b8b31b2a9f263dae2776c37b1b28ae246943cf719eb6946a1db05128a61" +dependencies = [ + "bitflags 2.13.2", + "crc32fast", + "fdeflate", + "flate2", + "miniz_oxide 0.8.9", +] + +[[package]] +name = "pollster" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f3a9f18d041e6d0e102a0a46750538147e5e8992d3b4873aaafee2520b00ce3" + +[[package]] +name = "portable-atomic" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05c8b63e8d9609db387f0324918f81d68fe27748f084ef092fb35954d0539a85" + +[[package]] +name = "powerfmt" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a6394b9e965e73d0a289ee54f589087e2c676aedf60885baf52c76b771e4958" + +[[package]] +name = "ppv-lite86" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" +dependencies = [ + "zerocopy", +] + +[[package]] +name = "proc-macro-crate" +version = "3.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e67ba7e9b2b56446f1d419b1d807906278ffa1a658a8a5d8a39dcb1f5a78614f" +dependencies = [ + "toml_edit", +] + +[[package]] +name = "proc-macro2" +version = "1.0.107" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "pxfm" +version = "0.1.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d55d956fa96f5ec02be2e13af0e20391a5aa83d6a074e3ad368959d0fab299ea" + +[[package]] +name = "quick-error" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a993555f31e5a609f617c12db6250dedcac1b0a85076912c436e6fc9b2c8e6a3" + +[[package]] +name = "quote" +version = "1.0.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand" +version = "0.8.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e058c7de0b26af77780c769414d6257830bb240f3c38477dbc2c16e5f54d6d4c" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + +[[package]] +name = "raw-window-handle" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20675572f6f24e9e76ef639bc5552774ed45f1c30e2951e1e99c59888861c539" + +[[package]] +name = "redox_syscall" +version = "0.5.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" +dependencies = [ + "bitflags 2.13.2", +] + +[[package]] +name = "redox_syscall" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "580c875845b41ecb1564ad1ae4703044cef774145e3d7a94dc2b3fa7c97868fd" +dependencies = [ + "bitflags 2.13.2", +] + +[[package]] +name = "regress" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2057b2325e68a893284d1538021ab90279adac1139957ca2a74426c6f118fb48" +dependencies = [ + "hashbrown 0.16.1", + "memchr", +] + +[[package]] +name = "ring" +version = "0.17.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7" +dependencies = [ + "cc", + "cfg-if", + "getrandom", + "libc", + "untrusted", + "windows-sys", +] + +[[package]] +name = "rustc-hash" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b1e7f9a428571be2dc5bc0505c13fb6bf936822b894ec87abf8a08a4e51742d" + +[[package]] +name = "rustls" +version = "0.23.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48e13bd8c0e9365c43cfa5c9e8f9ad49d3c8444926c9aac819e0e4dc503c8fdf" +dependencies = [ + "log", + "once_cell", + "ring", + "rustls-pki-types", + "rustls-webpki", + "subtle", + "zeroize", +] + +[[package]] +name = "rustls-pki-types" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "102f35f7de7b06d8c61f1cff6592f5253e0dea431c74867aad5dfd70f44663fb" +dependencies = [ + "zeroize", +] + +[[package]] +name = "rustls-webpki" +version = "0.103.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4443b1b6d39d7c663139942cc4558262562d2c84123bb6282ef177009ca8b281" +dependencies = [ + "ring", + "rustls-pki-types", + "untrusted", +] + +[[package]] +name = "rustversion" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f" + +[[package]] +name = "rustybuzz" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd3c7c96f8a08ee34eff8857b11b49b07d71d1c3f4e88f8a88d4c9e9f90b1702" +dependencies = [ + "bitflags 2.13.2", + "bytemuck", + "core_maths", + "log", + "smallvec", + "ttf-parser", + "unicode-bidi-mirroring", + "unicode-ccc", + "unicode-properties", + "unicode-script", +] + +[[package]] +name = "ryu-js" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04d056b875a9d2e6cb9a61d127afee9ac5999b9f87bcb32079d1318e505be714" + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "sdl2" +version = "0.38.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d42407afc6a8ab67e36f92e80b8ba34cbdc55aaeed05249efe9a2e8d0e9feef" +dependencies = [ + "bitflags 1.3.2", + "lazy_static", + "libc", + "sdl2-sys", +] + +[[package]] +name = "sdl2-sys" +version = "0.38.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ff61407fc75d4b0bbc93dc7e4d6c196439965fbef8e4a4f003a36095823eac0" +dependencies = [ + "cfg-if", + "libc", + "version-compare", +] + +[[package]] +name = "serde" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", +] + +[[package]] +name = "serde_json" +version = "1.0.154" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7e9cc8b1b85264074fbcc02a88680c4096b1e47df8f739dceb03bf482f04bd6" +dependencies = [ + "itoa", + "memchr", + "serde", + "serde_core", + "zmij", +] + +[[package]] +name = "shlex" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba" + +[[package]] +name = "simd-adler32" +version = "0.3.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a219298ac11a56ea9a6d2120044824d6f01aeb034955e7af7bc16858527deea" + +[[package]] +name = "siphasher" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33f4fe9184a62d842c9ef383018f3306d8ba224fd9d836f56d7288308847c256" + +[[package]] +name = "slab" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" + +[[package]] +name = "smallvec" +version = "1.16.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "149309498a5f7334b12ddae0cad8aba81ce785fe91755068867e017cf98fee46" + +[[package]] +name = "sptr" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b9b39299b249ad65f3b7e96443bad61c02ca5cd3589f46cb6d610a0fd6c0d6a" + +[[package]] +name = "stable_deref_trait" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "subtle" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" + +[[package]] +name = "syn" +version = "2.0.119" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "3.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ae9ccbea3a7b0b09443036490c8f34a8b1b760fd345e5c0dae0aac718faea79" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "synstructure" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "synstructure" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "901704edd0dfe137f1987838ee4f259e4e063c31371bdb423f7ae38ec6f77f02" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", +] + +[[package]] +name = "tap" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" + +[[package]] +name = "thin-vec" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6a4b9ba8738cb4a4f399d37e266becfd475e75eb73425b87a05a2f2039ba63e" + +[[package]] +name = "thiserror" +version = "2.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09e52cb86a36cede5cb101bf8908837b3e4c6e5e59fe7fd85c23fb56200d189e" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "2.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe5197923287db20a58125f0bc85c062f7f2c892de97b18c356f9efb14b28524" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", +] + +[[package]] +name = "time" +version = "0.3.55" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdb87b95ec50ddfa440816d227a17b2ccbdda963a316a727fda0fc4334f7d134" +dependencies = [ + "deranged", + "js-sys", + "libc", + "num-conv", + "num_threads", + "powerfmt", + "serde_core", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e1c906769ad99c88eaa54e728060edef082f8e358ff32030cb7c7d315e81109" + +[[package]] +name = "time-macros" +version = "0.2.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e689342a48d2ea927c87ea50cabf8594854bf940e9310208848d680d668ed85" +dependencies = [ + "num-conv", + "time-core", +] + +[[package]] +name = "tinystr" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9117f5d4db391c1cf6927e7bea3db74b9a1c1add8f7eda9ffd5364f40f57b82f" +dependencies = [ + "displaydoc", + "zerovec", +] + +[[package]] +name = "tokio" +version = "1.54.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b52fd3255258d26fac7264ab5a76b53c13367136dc011d3d6ad4f8ed070396a3" +dependencies = [ + "pin-project-lite", +] + +[[package]] +name = "toml_datetime" +version = "1.1.3+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "173f25c883cd2176a2d8212155638c0a60d484a9d84546d270866f40f56b6e49" +dependencies = [ + "serde_core", +] + +[[package]] +name = "toml_edit" +version = "0.25.19+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd43688c4858d7264ae1cf9a9f874a67c3feb74a883b1cd7bebd6a4ea8307218" +dependencies = [ + "indexmap", + "toml_datetime", + "toml_parser", + "winnow", +] + +[[package]] +name = "toml_parser" +version = "1.1.5+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baa693a8032d7e1cada7d0041e96126df243179ff061456783ac7f12bda4744c" +dependencies = [ + "winnow", +] + +[[package]] +name = "ttf-parser" +version = "0.25.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2df906b07856748fa3f6e0ad0cbaa047052d4a7dd609e231c4f72cee8c36f31" +dependencies = [ + "core_maths", +] + +[[package]] +name = "unicode-bidi-mirroring" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dfa6e8c60bb66d49db113e0125ee8711b7647b5579dc7f5f19c42357ed039fe" + +[[package]] +name = "unicode-ccc" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce61d488bcdc9bc8b5d1772c404828b17fc481c0a582b5581e95fb233aef503e" + +[[package]] +name = "unicode-ident" +version = "1.0.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563" + +[[package]] +name = "unicode-properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "993ad287eb20e8ba755312801cfe1413e0f25d604075863acaddca10b04c1833" + +[[package]] +name = "unicode-script" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa04c955db05429d464c74d495c1ee677e1866e783a4c3747f9c0cef7756cabf" + +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + +[[package]] +name = "utf16_iter" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c7de35d9d8757dbc1f5125dc8b51438c68b4430546a735c3a9b91aaaaf9a18a" +dependencies = [ + "utf_types", +] + +[[package]] +name = "utf8_iter" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af3bd9d3e571c26fcce9d033b87ea5ab061b8d2ffe9b7a5675d810d68f03edf0" +dependencies = [ + "utf_types", +] + +[[package]] +name = "utf_types" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a3b425286980a367278453f3b6d28cdcb134b574e5a35824a6ff5eebad50bb6" + +[[package]] +name = "version-compare" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "579a42fc0b8e0c63b76519a339be31bed574929511fa53c1a3acae26eb258f29" + +[[package]] +name = "wasi" +version = "0.11.1+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" + +[[package]] +name = "wasm-bindgen" +version = "0.2.130" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0181c14ddd6c7b8b0b0132a5f1ea2f32be0d893cd3ea97b6e3b28886b8a3d1c" +dependencies = [ + "cfg-if", + "rustversion", + "serde", + "serde_json", + "wasm-bindgen-macro", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.80" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e14e0327cb5368ad60ccb22d04a9827a693c95a926d8d125e9fa39e0baec501" +dependencies = [ + "js-sys", + "tokio", + "wasm-bindgen", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.130" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e931a02a39abdbf66966fc35902b5ed58344750a70885bed4ebb3d8eaf28ed9" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.130" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ca4b54280e455bd831e33a6b8e734baf432fe63fbc35c42ac14ce67a043a53a" +dependencies = [ + "bumpalo", + "proc-macro2", + "quote", + "syn 3.0.10", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.130" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b1f9c3798725016c6ee5f2f57869ec0831e8bbc0ab0310a86e787e97f41389e" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "web-sys" +version = "0.3.107" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7d179596ff5ec0f6de4db64d54011bde6289cc49603d3a6e4ce3f329207ab88" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "webpki-roots" +version = "0.26.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "521bc38abb08001b01866da9f51eb7c5d647a19260e00054a8c7fd5f9e57f7a9" +dependencies = [ + "webpki-roots 1.0.12", +] + +[[package]] +name = "webpki-roots" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7265c9301c16a8711c992c2d8da90ee77ef54b1ed51482d6dfeb00dc756b1297" +dependencies = [ + "rustls-pki-types", +] + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "winnow" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c3b93199df0ab874cdf0c6a94f0a0dc3423fe41f1cafb62b8bd7b1deb277aef" +dependencies = [ + "memchr", +] + +[[package]] +name = "write16" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1890f4022759daae28ed4fe62859b1236caebfc61ede2f63ed4e695f3f6d936" + +[[package]] +name = "writeable" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51" + +[[package]] +name = "x11-dl" +version = "2.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38735924fedd5314a6e548792904ed8c6de6636285cb9fec04d5b1db85c1516f" +dependencies = [ + "libc", + "once_cell", + "pkg-config", +] + +[[package]] +name = "yoke" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "120e6aef9aa629e3d4f52dc8cc43a015c7724194c97dfaf45180d2daf2b77f40" +dependencies = [ + "serde", + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2380878cad4ac9aac1e2435f3eb4020e8374b5f13c296cb75b4620ff8e229154" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", + "synstructure 0.13.2", +] + +[[package]] +name = "zerocopy" +version = "0.8.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5fe1f8f1b06191a00962174c61aa5005e0bb391a6d80d07e24d115c01a92ed8" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.8.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "863ad3ac83293fb4d740aedbfdc9240dd8d1a50c1099acd76ce80ce7c7230c7f" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "zerofrom" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ec05a11813ea801ff6d75110ad09cd0824ddba17dfe17128ea0d5f68e6c5272" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f75b4683f6c7f45248d4d64056a24298c6281e0993356d7d1b4a1a962ef10d4a" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", + "synstructure 0.14.0", +] + +[[package]] +name = "zeroize" +version = "1.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13084392c5e4bc371903e2935a5eaeed24905a7511356b883835e18a78f6879" + +[[package]] +name = "zerovec" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa2b893d79df23bfb12d5461018d408ea19dfafe76c2c7ef6d4eba614f8ff079" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e3c6377872d72510393f688a555d7097b0f741995c7a00f0407f786dd486b2d" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "zlib-rs" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b268e58e7c693d7c271f93ffc4ba3b380412554231c85bf61ca7af91042a4112" + +[[package]] +name = "zmij" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b" + +[[package]] +name = "zune-core" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d56377fd46368984a170bc5aac5567e52ca5da874caa60bea39fcbca78fb658b" + +[[package]] +name = "zune-jpeg" +version = "0.5.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27bc9d5b815bc103f142aa054f561d9187d191692ec7c2d1e2b4737f8dbd7296" +dependencies = [ + "zune-core", +] diff --git a/desktop/Cargo.toml b/desktop/Cargo.toml new file mode 100644 index 0000000..c9c8df8 --- /dev/null +++ b/desktop/Cargo.toml @@ -0,0 +1,17 @@ +[package] +name = "mosaic-desktop" +version = "0.2.0" +edition = "2021" +description = "Mosaic desktop: viewer nativo del motore di rendering" + +[[bin]] +name = "mosaic-desktop" +path = "src/main.rs" + +[dependencies] +engine = { path = "../engine" } +# Solo backend X11, di proposito: sotto Wayland minifb chiede le decorazioni al +# compositore, che su GNOME non le fornisce — niente cornice né pulsante di chiusura, +# e la rotella non arriva. Via XWayland la finestra è decorata dal window manager. +# x11-dl usa dlopen: nessuna libreria X11 richiesta al link, solo a runtime. +minifb = { version = "0.28", default-features = false, features = ["x11"] } diff --git a/desktop/README.md b/desktop/README.md new file mode 100644 index 0000000..7b1140e --- /dev/null +++ b/desktop/README.md @@ -0,0 +1,68 @@ +# Mosaic desktop (Zorin / Ubuntu) + +Guscio nativo che mostra il raster prodotto da `../engine`. Nessun toolkit grafico: +`minifb` apre una finestra X11/Wayland e fornisce il buffer, il motore produce RGBA. +Il binario non linka Qt né WebKit; a runtime servono le sole `libX11`/`libxkbcommon` +di sistema (presenti su ogni Ubuntu/Zorin). + +``` +desktop/ +├── src/main.rs finestra, scroll, zoom, ricarica, modo --render-out +├── demo.html pagina dimostrativa (float, liste, @font-face, immagini) +├── fonts/ DejaVu Sans + Serif, gli stessi del pacchetto Sailfish +└── appimage/ + ├── build.sh binario → AppDir → squashfs → runtime + payload + ├── extract-runtime.py recupera il runtime ELF da un'AppImage esistente + └── make-icon.py icona 256 px (globo, la stessa del progetto Mosaic) +``` + +## Comandi + +Rotella = scorrimento · **Ctrl+rotella** o **+ / −** = zoom · frecce, PgUp/PgDn, +Home/End = scorrimento · **0** = zoom 1,0 · **R** = ricarica il file. + +Moduli: clic su un campo gli dà il fuoco e il cursore; **frecce** muovono il cursore, +**Shift+frecce** selezionano, **Home/End** vanno ai bordi, **Backspace/Delete** cancellano +(prima la selezione), digitare sostituisce la selezione. Clic su un `select` apre +l'elenco, **frecce** cambiano la voce evidenziata, **Invio** conferma, **Esc** chiude; +un clic su una voce la sceglie. + +Chiusura: pulsante della finestra, **Esc**, **Q**, **Ctrl+Q**, **Ctrl+W**. Con la finestra +ridotta a icona il ciclo continua a leggere gli eventi (`window.update()`), altrimenti il +clic sul pulsante di chiusura non arriverebbe più e la finestra resterebbe appesa. +La barra del titolo mostra zoom, tempo di rasterizzazione e altezza dell'immagine. + +```bash +cargo build --release +./target/release/mosaic-desktop --html demo.html --zoom 1.25 +``` + +Opzioni: `--html FILE` (obbligatorio), `--css FILE`, `--zoom N` (0,5–4), +`--size WxH`, `--font TTF`, `--render-out PNG` (nessuna finestra: rasterizza e scrive +il PNG, usato per la verifica su server senza display). + +## AppImage + +```bash +VERSION=0.1.1 ./appimage/build.sh # → Mosaic-desktop-0.1.1-x86_64.AppImage +``` + +L'immagine è composta a mano, senza `appimagetool`: `[runtime ELF][squashfs]`. +Il runtime viene estratto da un'AppImage di tipo 2 già presente +(`extract-runtime.py`, che valida la magic `hsqs` e i campi del superblocco); +il payload è uno squashfs gzip da 128 KB creato con `mksquashfs` — quello del +container del Sailfish SDK se sul sistema non c'è. + +Requisiti di sistema sul desktop: `libfuse2` (come per ogni AppImage). +glibc richiesta dal binario: 2.34 → Zorin 17/18 e Ubuntu 22.04+. + +Verifica senza display, utile in CI o via SSH: + +```bash +APPIMAGE_EXTRACT_AND_RUN=1 ./Mosaic-desktop-0.1.1-x86_64.AppImage --render-out /tmp/p.png +``` + +## Nota sul motore + +L'AppImage e l'RPM Sailfish condividono lo stesso motore: quando si ricostruisce +l'uno va ricostruito anche l'altro, altrimenti le due piattaforme divergono. diff --git a/desktop/appimage/build.sh b/desktop/appimage/build.sh new file mode 100755 index 0000000..84c6333 --- /dev/null +++ b/desktop/appimage/build.sh @@ -0,0 +1,85 @@ +#!/bin/bash +# Costruisce Mosaic-desktop-x.y.z-x86_64.AppImage senza appimagetool: +# [runtime ELF estratto da un'AppImage esistente] + [squashfs dell'AppDir] +# Richiede: cargo, python3+PIL per l'icona, mksquashfs (qui, o nel container del SDK). +set -eu + +# cargo può non essere nel PATH di una shell non interattiva +if ! command -v cargo >/dev/null 2>&1; then + PATH="$HOME/.cargo/bin:$PATH" + export PATH +fi + +set -o pipefail + +HERE="$(cd "$(dirname "$0")" && pwd)" +ROOT="$(cd "$HERE/.." && pwd)" +BUILD="$HERE/build" +APPDIR="$BUILD/AppDir" +VER="${VERSION:-0.1.0}" +OUT="$ROOT/Mosaic-desktop-$VER-x86_64.AppImage" +RUNTIME="${RUNTIME:-$HERE/runtime-x86_64}" +SRC_APPIMAGE="${SRC_APPIMAGE:-$ROOT/../../mosaic/Mosaic-1.0.0-x86_64.AppImage}" +CONTAINER="${CONTAINER:-sailfish-sdk-build-engine_kaneda}" + +echo "== binario (release)" +(cd "$ROOT" && cargo build --release) +BIN="$ROOT/target/release/mosaic-desktop" +[ -x "$BIN" ] || { echo "binario non prodotto" >&2; exit 1; } + +echo "== runtime AppImage" +if [ ! -f "$RUNTIME" ]; then + python3 "$HERE/extract-runtime.py" "$SRC_APPIMAGE" "$RUNTIME" +fi +chmod +x "$RUNTIME" + +echo "== AppDir" +rm -rf "$APPDIR" +mkdir -p "$APPDIR/usr/bin" "$APPDIR/usr/share/mosaic/fonts" \ + "$APPDIR/usr/share/applications" "$APPDIR/usr/share/icons/hicolor/256x256/apps" +install -m 755 "$BIN" "$APPDIR/usr/bin/mosaic-desktop" +install -m 644 "$ROOT/demo.html" "$APPDIR/usr/share/mosaic/" +install -m 644 "$ROOT/fonts/DejaVuSans.ttf" "$ROOT/fonts/DejaVuSerif.ttf" "$APPDIR/usr/share/mosaic/fonts/" + +python3 "$HERE/make-icon.py" 256 "$APPDIR/mosaic-desktop.png" +install -m 644 "$APPDIR/mosaic-desktop.png" "$APPDIR/usr/share/icons/hicolor/256x256/apps/mosaic-desktop.png" + +cat > "$APPDIR/mosaic-desktop.desktop" <<'DESKTOP' +[Desktop Entry] +Type=Application +Name=Mosaic +GenericName=Web Browser +Comment=Browser Mosaic con motore di rendering indipendente +Exec=mosaic-desktop +Icon=mosaic-desktop +Terminal=false +Categories=Network;WebBrowser; +Keywords=web;browser;mosaic;retro;hypertext; +DESKTOP +cp "$APPDIR/mosaic-desktop.desktop" "$APPDIR/usr/share/applications/" + +# AppRun: pagina demo e font interni al pacchetto, così non dipende dai font di sistema +cat > "$APPDIR/AppRun" <<'APPRUN' +#!/bin/sh +HERE="$(dirname "$(readlink -f "$0")")" +exec "$HERE/usr/bin/mosaic-desktop" \ + --html "$HERE/usr/share/mosaic/demo.html" \ + --font "$HERE/usr/share/mosaic/fonts/DejaVuSans.ttf" \ + --zoom 1.25 "$@" +APPRUN +chmod +x "$APPDIR/AppRun" + +echo "== squashfs" +if command -v mksquashfs >/dev/null 2>&1; then + mksquashfs "$APPDIR" "$BUILD/payload.squashfs" -comp gzip -b 131072 -root-owned -noappend -no-xattrs -no-progress +else + docker exec "$CONTAINER" mksquashfs "$APPDIR" "$BUILD/payload.squashfs" \ + -comp gzip -b 131072 -root-owned -noappend -no-xattrs -no-progress +fi + +echo "== immagine finale" +rm -f "$OUT" +cat "$RUNTIME" "$BUILD/payload.squashfs" > "$OUT" +chmod +x "$OUT" +echo "Creato: $OUT" +ls -lh "$OUT" diff --git a/desktop/appimage/extract-runtime.py b/desktop/appimage/extract-runtime.py new file mode 100755 index 0000000..4929443 --- /dev/null +++ b/desktop/appimage/extract-runtime.py @@ -0,0 +1,37 @@ +#!/usr/bin/env python3 +"""Estrae il runtime di un'AppImage esistente (tipo 2) per riusarlo. + +AppImage = [runtime ELF][immagine squashfs]. Il runtime finisce dove inizia il +superblocco squashfs: si cerca la magic "hsqs" e si valida (block_size potenza di +due, compressione 1-6), perché "hsqs" compare anche dentro il codice del runtime. +""" +import struct +import sys + + +def main() -> int: + if len(sys.argv) < 3: + print("uso: extract-runtime.py APPIMAGE RUNTIME_OUT", file=sys.stderr) + return 2 + src, dst = sys.argv[1], sys.argv[2] + data = open(src, "rb").read() + + off = 0 + while True: + off = data.find(b"hsqs", off) + if off < 0: + break + if off + 28 <= len(data): + _, _, blk, _, comp, blog, _, _ = struct.unpack(" 1 else 256 +out = sys.argv[2] if len(sys.argv) > 2 else "mosaic.png" + +S = 4 # sovracampionamento per bordi puliti +W = size * S +img = Image.new("RGBA", (W, W), (0, 0, 0, 0)) +d = ImageDraw.Draw(img) + +m = W * 0.06 +cx = cy = W / 2 +r = W / 2 - m + +blue = (31, 90, 168, 255) +green = (63, 155, 70, 255) +green_dark = (20, 80, 31, 255) +edge = (0, 0, 0, 255) +grid = (156, 196, 234, 230) + +d.ellipse([cx - r, cy - r, cx + r, cy + r], fill=blue, outline=edge, width=max(2, int(W * 0.012))) + + +def poly(points, fill, outline=None): + pts = [(cx + x * r / 100.0, cy + y * r / 100.0) for x, y in points] + d.polygon(pts, fill=fill) + if outline: + d.line(pts + [pts[0]], fill=outline, width=max(1, int(W * 0.006))) + + +# continenti stilizzati +poly([(-78, -42), (-46, -58), (-22, -36), (-30, -8), (-62, -6)], green, green_dark) +poly([(-26, 4), (0, 0), (14, 30), (-8, 62), (-28, 30)], green, green_dark) +poly([(4, -46), (54, -40), (62, -6), (26, 4), (10, -22)], green, green_dark) +poly([(18, 16), (44, 24), (34, 48), (16, 40)], green, green_dark) +poly([(-64, 44), (-40, 40), (-44, 58), (-62, 56)], green, green_dark) + +# reticolo +w = max(1, int(W * 0.006)) +for k in (0.34, 0.66): + rr = r * k + d.ellipse([cx - r, cy - rr, cx + r, cy + rr], outline=grid, width=w) +d.ellipse([cx - r * 0.35, cy - r, cx + r * 0.35, cy + r], outline=grid, width=w) +d.line([cx, cy - r, cx, cy + r], fill=grid, width=w) +d.line([cx - r, cy, cx + r, cy], fill=grid, width=w) + +# luce +img = img.resize((size, size), Image.LANCZOS) +img.save(out) +print("icona:", out, size) diff --git a/desktop/demo.html b/desktop/demo.html new file mode 100644 index 0000000..b69ca0e --- /dev/null +++ b/desktop/demo.html @@ -0,0 +1,139 @@ + + + + +Mosaic — motore M1 + + + +

NCSA Mosaic

+

riedizione 2026 — motore di rendering scritto da zero

+
+ +

Che cosa sa fare

+ + +
61 reftest verdi: geometria, pixel sondati, larghezza del testo, + estensione dell'inchiostro a diversi zoom.
+ +

Font

+

Questo paragrafo è in DejaVu Serif, caricato con @font-face dal pacchetto.

+

Questo è il font predefinito, usato quando la famiglia non è disponibile.

+ +

Disposizione con flex

+
+
uno — cresce di 1
+
due — cresce di 2
+
tre — cresce di 1
+
+
+ allineato a sinistracentrodestra +
+ +

Modulo di prova

+

Nome: cognome

+

attivo   A   B

+

Modalità: +  

+

Note:

+ +

Tabella

+ + + + + +
funzionestatotest
flexboxriga, colonna, grow, gap68–73
tabellecolonne automatiche e colspan
bidiparagrafi RTL e testo misto63–67
+ +

Testo da destra (bidi)

+

שלום עולם — paragrafo con dir="rtl" allineato a destra

+

שלום abc 123 — parole latine e cifre dentro un paragrafo RTL

+ +

Ancora fuori ambito

+

JavaScript, rete, grid; dei moduli mancano invio del form, caret e selezione, menu a tendina a comparsa.

+ +

Due colonne con float

+
+

Colonna sinistra. Testo che scorre accanto all'altra colonna, con + margini collassanti e a capo sulle parole. Il motore impagina in pixel CSS e rasterizza + alla scala del display, quindi lo zoom non sfoca il testo.

+
+
+

Colonna destra. Immagini PNG/JPEG/WebP, corsivo, + colori ereditati e proprietà personalizzate:

+
+
+ +

Script

+

Un pulsante che cambia testo e colore al clic, senza ricaricare: + fermo

+ +

Uno script può anche costruire contenuto nuovo: +

+
+ +

Eventi di modulo

+
+

Nome: (vuoto)

+

+
+ + + diff --git a/desktop/fonts/DejaVuSans.ttf b/desktop/fonts/DejaVuSans.ttf new file mode 100644 index 0000000..5789a29 Binary files /dev/null and b/desktop/fonts/DejaVuSans.ttf differ diff --git a/desktop/fonts/DejaVuSerif.ttf b/desktop/fonts/DejaVuSerif.ttf new file mode 100644 index 0000000..fa774f3 Binary files /dev/null and b/desktop/fonts/DejaVuSerif.ttf differ diff --git a/desktop/src/main.rs b/desktop/src/main.rs new file mode 100644 index 0000000..1e965c2 --- /dev/null +++ b/desktop/src/main.rs @@ -0,0 +1,1077 @@ +//! Mosaic desktop: finestra nativa che mostra il raster del motore. +//! +//! Non usa Qt né toolkit: `minifb` apre la finestra e fornisce i byte del buffer, +//! il motore produce RGBA. Comandi: rotella = scroll, Ctrl+rotella o +/− = zoom, +//! frecce/PgUp/PgDn/Home/End = scorrimento, 0 = zoom iniziale, R = ricarica, Q/Esc = esci. +//! +//! Con `--render-out FILE` non apre finestre: renderizza e scrive un PNG (serve alla +//! verifica in CI e sul server senza display). + +use std::path::{Path, PathBuf}; +use std::time::Instant; + +use engine::{pngio, ControlKind, Focusable, FormState, RenderOptions}; +use minifb::{Key, KeyRepeat, MouseButton, MouseMode, Window, WindowOptions}; + +struct Page { + html: String, + css: String, + base_dir: PathBuf, + /// indirizzo del documento quando arriva dalla rete (M2.6) + base_url: Option, +} + +struct Rendered { + width: u32, + height: u32, + rgba: Vec, + ms: f64, + focusables: Vec, + /// albero impaginato: serve a sapere quale nodo sta sotto il puntatore + layout: engine::layout::LayoutBox, +} + +/// Nodo più profondo sotto il punto (px CSS). +fn nodo_al_punto(b: &engine::layout::LayoutBox, x: f32, y: f32) -> Option { + let dentro = x >= b.rect.x && x <= b.rect.x + b.rect.w && y >= b.rect.y && y <= b.rect.y + b.rect.h; + if !dentro { + return None; + } + for figlio in &b.children { + if let Some(n) = nodo_al_punto(figlio, x, y) { + return Some(n); + } + } + // i controlli non hanno un box proprio: vivono nelle righe del testo + for linea in &b.lines { + for run in &linea.runs { + if let Some(c) = &run.control { + let r = engine::layout::Rect::new(run.x, run.baseline - c.above, c.width, c.height); + if x >= r.x && x <= r.x + r.w && y >= r.y && y <= r.y + r.h { + return Some(c.node); + } + } + } + } + Some(b.node) +} + +/// Centro del box che rappresenta il nodo, se è stato impaginato. +fn centro_del_nodo(b: &engine::layout::LayoutBox, nodo: usize) -> Option<(f32, f32)> { + if b.node == nodo && b.rect.w > 0.0 && b.rect.h > 0.0 { + return Some((b.rect.x + b.rect.w / 2.0, b.rect.y + b.rect.h / 2.0)); + } + // un controllo (pulsante, campo) sta in una riga, non in un box + for linea in &b.lines { + for run in &linea.runs { + if let Some(c) = &run.control { + if c.node == nodo { + return Some(( + run.x + c.width / 2.0, + run.baseline - c.above + c.height / 2.0, + )); + } + } + } + } + for figlio in &b.children { + if let Some(c) = centro_del_nodo(figlio, nodo) { + return Some(c); + } + } + None +} + +fn nodo_con_id(doc: &engine::dom::Document, id: &str) -> Option { + for (i, n) in doc.nodes.iter().enumerate() { + if let engine::dom::NodeKind::Element(e) = &n.kind { + if e.attr("id") == Some(id) { + return Some(i); + } + } + } + None +} + +/// Consegna gli eventi di un clic: `submit` al form se il bersaglio è un +/// pulsante, poi `click` al nodo con la propagazione agli antenati. +/// Restituisce quanti gestori hanno reagito. +fn consegna_eventi_clic( + macchina: &mut engine::script::Macchina, + contenuto: &mut engine::ContenutoPagina, + form: &FormState, + r: &Rendered, + cx: f32, + cy: f32, + base_url_del_documento: Option<&str>, +) -> AzioneClic { + let Some(nodo) = nodo_al_punto(&r.layout, cx, cy) else { + return AzioneClic::Nessuna(0); + }; + // `element.value` deve vedere quello che l'utente ha scritto + let mut valori = std::collections::HashMap::new(); + for f in &r.focusables { + if let Some(v) = form.values.get(&f.key) { + valori.insert(f.node, v.clone()); + } + } + macchina.imposta_valori(valori); + let mut gestori = 0; + if let Some(f) = r.focusables.iter().find(|f| f.node == nodo) { + if f.kind == ControlKind::Button { + let bersaglio = antenato_con_tag(&contenuto.doc, nodo, "form").unwrap_or(nodo); + let rami = catena_antenati(&contenuto.doc, bersaglio); + gestori += macchina.evento(&mut contenuto.doc, "submit", &rami, cx, cy); + // senza `preventDefault` l'invio va fatto davvero + if !macchina.preventuto_default() { + if let Some(form_node) = antenato_con_tag(&contenuto.doc, nodo, "form") { + match engine::invio::prepara( + &contenuto.doc, + form, + form_node, + base_url_del_documento, + ) { + Ok(richiesta) => return AzioneClic::Invia(richiesta), + Err(e) => eprintln!("mosaic: invio non preparabile: {}", e), + } + } + } + } + } + let rami = catena_antenati(&contenuto.doc, nodo); + gestori += macchina.evento(&mut contenuto.doc, "click", &rami, cx, cy); + AzioneClic::Nessuna(gestori) +} + +/// Esegue l'invio del formulario e sostituisce la pagina con la risposta. +fn esegui_invio( + page: &mut Page, + contenuto: &mut engine::ContenutoPagina, + macchina: &mut engine::script::Macchina, + richiesta: &engine::invio::Invio, +) -> Result<(), String> { + let limiti = engine::net::Limiti::default(); + let risposta = match (&richiesta.corpo, richiesta.metodo.as_str()) { + (Some(corpo), "POST") => engine::net::post(&richiesta.url, corpo, &limiti), + _ => engine::net::get(&richiesta.url, &limiti), + }?; + let testo = risposta.text()?; + eprintln!("mosaic: invio {} -> HTTP {}", richiesta.url, risposta.status); + page.html = testo; + page.base_url = Some(risposta.url.clone()); + *contenuto = engine::ContenutoPagina::da_html(&page.html); + if let Ok(m) = engine::script::Macchina::nuova() { + *macchina = m; + for e in contenuto.esegui_script(macchina) { + eprintln!("script: {}", e); + } + } + Ok(()) +} + +/// Cosa fare dopo un clic: niente, oppure inviare un formulario. +enum AzioneClic { + Nessuna(usize), + Invia(engine::invio::Invio), +} + +/// Primo antenato (o il nodo stesso) con quel nome di elemento. +fn antenato_con_tag(doc: &engine::dom::Document, nodo: usize, tag: &str) -> Option { + let mut corrente = Some(nodo); + while let Some(n) = corrente { + if doc.element_name(n) == Some(tag) { + return Some(n); + } + corrente = doc.nodes.get(n).and_then(|x| x.parent); + } + None +} + +/// Nodo e antenati, dal più profondo alla radice: è l'ordine di propagazione. +fn catena_antenati(doc: &engine::dom::Document, nodo: usize) -> Vec { + let mut out = Vec::new(); + let mut corrente = Some(nodo); + while let Some(n) = corrente { + out.push(n); + corrente = doc.nodes.get(n).and_then(|x| x.parent); + } + out +} + +fn main() { + let mut args = std::env::args().skip(1); + let mut html_path: Option = None; + let mut url: Option = None; + let mut css_path: Option = None; + let mut zoom = 1.0f64; + let mut size = (1100u32, 800u32); + let mut render_out: Option = None; + // clic da consegnare prima di scrivere il PNG: serve a provare gli eventi + // senza finestra (il percorso è lo stesso del mouse, non un altro codice) + let mut clic_nodi: Vec = Vec::new(); + // testo da scrivere in un campo prima del PNG: prova l'evento `input` + let mut digitazioni: Vec<(String, String)> = Vec::new(); + let mut font = default_font(); + + while let Some(a) = args.next() { + match a.as_str() { + "--html" => html_path = args.next().map(PathBuf::from), + "--url" => url = args.next(), + "--digita" => { + if let Some(v) = args.next() { + if let Some((id, testo)) = v.split_once('=') { + digitazioni.push((id.to_string(), testo.to_string())); + } + } + } + "--clic-nodo" => { + if let Some(id) = args.next() { + clic_nodi.push(id); + } + } + "--css" => css_path = args.next().map(PathBuf::from), + "--zoom" => { + zoom = args + .next() + .and_then(|v| v.parse::().ok()) + .unwrap_or(1.0) + .clamp(0.5, 4.0) + } + "--size" => { + if let Some(v) = args.next() { + if let Some((w, h)) = v.split_once('x') { + size = ( + w.parse().unwrap_or(1100), + h.parse().unwrap_or(800), + ); + } + } + } + "--font" => font = args.next().map(PathBuf::from).unwrap_or_else(default_font), + "--render-out" => render_out = args.next().map(PathBuf::from), + "--aiuto" | "--help" | "-h" => { + println!( + "mosaic-desktop [--html FILE] [--css FILE] [--zoom N] [--size WxH]\n\ + \x20 [--font TTF] [--render-out PNG]\n\ + \x20--url URL carica una pagina da http:// (TLS non ancora incluso)\n\n\ + Rotella: scroll · Ctrl+rotella o +/−: zoom · frecce/PgUp/PgDn/Home/End: scorri\n\ + 0: zoom 1.0 · R: ricarica\n\ + Chiudi: pulsante della finestra, Esc, Q, Ctrl+Q, Ctrl+W" + ); + return; + } + altro => eprintln!("argomento ignorato: {}", altro), + } + } + + let (html_path, css_path) = match (html_path, css_path) { + (Some(h), c) => (h, c), + // con --url non serve un file: il documento arriva dalla rete + (None, c) if url.is_some() => (PathBuf::new(), c), + (None, _) => { + eprintln!("serve --html FILE oppure --url URL (o usa --help)"); + std::process::exit(2); + } + }; + + let base_dir = html_path + .parent() + .map(|p| p.to_path_buf()) + .unwrap_or_else(|| PathBuf::from(".")); + + let mut page = match load(&html_path, css_path.as_deref(), &base_dir, url.as_deref()) { + Ok(p) => p, + Err(e) => { + eprintln!("errore: {}", e); + std::process::exit(1); + } + }; + + // documento vivo: gli eventi modificano questo DOM e la pagina si ridisegna + // senza ripartire dall'HTML (M2.5b) + let mut contenuto = engine::ContenutoPagina::da_html(&page.html); + let mut macchina = match engine::script::Macchina::nuova() { + Ok(m) => m, + Err(e) => { + eprintln!("errore: interprete JavaScript non disponibile: {}", e); + std::process::exit(1); + } + }; + let errori_script = contenuto.esegui_script(&mut macchina); + for e in &errori_script { + eprintln!("script: {}", e); + } + + // stato dei moduli: valori digitati e fuoco (vuoto in modalità headless) + let mut form = FormState::default(); + // stato del tasto del mouse: serve il fronte di discesa, non il livello + let mut mouse_giu = false; + // font per misurare il testo: serve a posizionare il cursore dove si clicca + let metri = engine::FontHolder::load(&font).ok(); + let mut ultimo_clic: Option<(std::time::Instant, f32, f32)> = None; + + // modalità senza finestra: render + PNG, utile su server e in CI + if let Some(out) = render_out { + match render_page(&page, &contenuto, size.0, size.1, zoom as f32, &font, &form) { + Ok(mut r) => { + for (id, testo) in &digitazioni { + let Some(nodo) = nodo_con_id(&contenuto.doc, id) else { + eprintln!("digita: nessun nodo con id {}", id); + continue; + }; + let Some(f) = r.focusables.iter().find(|f| f.node == nodo).cloned() else { + eprintln!("digita: il nodo {} non è un controllo", id); + continue; + }; + form.values.insert(f.key.clone(), testo.clone()); + let mut valori = std::collections::HashMap::new(); + for x in &r.focusables { + if let Some(v) = form.values.get(&x.key) { + valori.insert(x.node, v.clone()); + } + } + macchina.imposta_valori(valori); + let rami = catena_antenati(&contenuto.doc, nodo); + let gestori = macchina.evento(&mut contenuto.doc, "input", &rami, 0.0, 0.0); + eprintln!("digita su {}: {} gestori di input", id, gestori); + match render_page(&page, &contenuto, size.0, size.1, zoom as f32, &font, &form) { + Ok(nuovo) => r = nuovo, + Err(e) => eprintln!("errore dopo la digitazione: {}", e), + } + } + + for id in &clic_nodi { + let Some(nodo) = nodo_con_id(&contenuto.doc, id) else { + eprintln!("clic: nessun nodo con id {}", id); + continue; + }; + let Some((cx, cy)) = centro_del_nodo(&r.layout, nodo) else { + eprintln!("clic: nodo {} non impaginato", id); + continue; + }; + let azione = consegna_eventi_clic( + &mut macchina, + &mut contenuto, + &form, + &r, + cx, + cy, + page.base_url.as_deref(), + ); + let mut da_ridisegnare = false; + match azione { + AzioneClic::Nessuna(n) => { + eprintln!("clic su {}: {} gestori", id, n); + da_ridisegnare = n > 0; + } + AzioneClic::Invia(richiesta) => { + eprintln!("invio del formulario: {} {}", richiesta.metodo, richiesta.url); + match esegui_invio(&mut page, &mut contenuto, &mut macchina, &richiesta) { + Ok(()) => da_ridisegnare = true, + Err(e) => eprintln!("mosaic: invio fallito: {}", e), + } + } + } + if da_ridisegnare { + match render_page(&page, &contenuto, size.0, size.1, zoom as f32, &font, &form) { + Ok(nuovo) => r = nuovo, + Err(e) => eprintln!("errore dopo il clic: {}", e), + } + } + } + if let Err(e) = pngio::write_rgba(&out, r.width, r.height, &r.rgba) { + eprintln!("errore scrittura PNG: {}", e); + std::process::exit(1); + } + println!( + "{{\"png\":\"{}\",\"size\":[{},{}],\"zoom\":{},\"ms\":{:.2}}}", + out.display(), + r.width, + r.height, + zoom, + r.ms + ); + return; + } + Err(e) => { + eprintln!("errore: {}", e); + std::process::exit(1); + } + } + } + + // resize: true → la finestra si può ridimensionare e massimizzare come le altre + let opzioni = WindowOptions { + resize: true, + ..WindowOptions::default() + }; + let mut window = match Window::new("Mosaic", size.0 as usize, size.1 as usize, opzioni) { + Ok(w) => w, + Err(e) => { + eprintln!("impossibile aprire la finestra: {} (usa --render-out per il rendering senza display)", e); + std::process::exit(1); + } + }; + window.set_target_fps(60); + + let mut zoom = zoom as f32; + let mut rendered: Option = None; + let mut scroll = 0f32; + let mut needs_render = true; + + while window.is_open() { + // Chiusura: pulsante della finestra (is_open torna falso), Esc, Q, Ctrl+Q, Ctrl+W. + // `is_key_pressed` intercetta anche il tocco singolo; `is_key_down` copre Q tenuto. + if window.is_key_pressed(Key::Escape, KeyRepeat::No) + || window.is_key_pressed(Key::Q, KeyRepeat::No) + || (window.is_key_down(Key::Q) + && (window.is_key_down(Key::LeftCtrl) || window.is_key_down(Key::RightCtrl))) + || (window.is_key_pressed(Key::W, KeyRepeat::No) + && (window.is_key_down(Key::LeftCtrl) || window.is_key_down(Key::RightCtrl))) + { + break; + } + + let (w, h) = (window.get_size().0 as u32, window.get_size().1 as u32); + if w == 0 || h == 0 { + // finestra ridotta a icona: gli eventi vanno comunque letti, altrimenti + // il clic sul pulsante di chiusura non arriva mai e la finestra resta appesa + let _ = window.update(); + continue; + } + + // zoom: rotella con Ctrl oppure + / - + if let Some((_, dy)) = window.get_scroll_wheel() { + let ctrl = window.is_key_down(Key::LeftCtrl) || window.is_key_down(Key::RightCtrl); + if ctrl { + let nuovo = (zoom * if dy > 0.0 { 1.1 } else { 1.0 / 1.1 }).clamp(0.5, 4.0); + if (nuovo - zoom).abs() > 1e-4 { + zoom = nuovo; + needs_render = true; + } + } else { + // tre righe di testo, in pixel del dispositivo: a zoom alto la + // rotella deve muoversi di quanto si vede, non di 60 px fissi + scroll -= dy * 60.0 * zoom; + } + } + if window.is_key_pressed(Key::Equal, KeyRepeat::Yes) || window.is_key_pressed(Key::NumPadPlus, KeyRepeat::Yes) { + zoom = (zoom * 1.1).clamp(0.5, 4.0); + needs_render = true; + } + if window.is_key_pressed(Key::Minus, KeyRepeat::Yes) || window.is_key_pressed(Key::NumPadMinus, KeyRepeat::Yes) { + zoom = (zoom / 1.1).clamp(0.5, 4.0); + needs_render = true; + } + if window.is_key_pressed(Key::Key0, KeyRepeat::No) { + zoom = 1.0; + needs_render = true; + } + if window.is_key_pressed(Key::R, KeyRepeat::No) { + if let Ok(p) = load(&html_path, css_path.as_deref(), &base_dir, url.as_deref()) { + page = p; + contenuto = engine::ContenutoPagina::da_html(&page.html); + if let Ok(m) = engine::script::Macchina::nuova() { + macchina = m; + for e in contenuto.esegui_script(&mut macchina) { + eprintln!("script: {}", e); + } + } + needs_render = true; + } + } + + // --- clic su un controllo: fuoco e cursore in fondo al testo --- + let premuto = window.get_mouse_down(MouseButton::Left); + let clic = premuto && !mouse_giu; + mouse_giu = premuto; + if clic { + if let Some((mx, my)) = window.get_mouse_pos(MouseMode::Clamp) { + let cx = mx / zoom; + let cy = (my + scroll) / zoom; + + // M2.5b/d: eventi al nodo sotto il puntatore, con propagazione; + // se un gestore ha modificato il DOM la pagina si ridisegna + if let Some(r) = rendered.as_ref() { + let azione = consegna_eventi_clic( + &mut macchina, + &mut contenuto, + &form, + r, + cx, + cy, + page.base_url.as_deref(), + ); + match azione { + AzioneClic::Nessuna(n) => { + if n > 0 { + needs_render = true; + } + } + AzioneClic::Invia(richiesta) => { + eprintln!("invio del formulario: {} {}", richiesta.metodo, richiesta.url); + match esegui_invio(&mut page, &mut contenuto, &mut macchina, &richiesta) { + Ok(()) => needs_render = true, + Err(e) => eprintln!("mosaic: invio fallito: {}", e), + } + } + } + } + let trovato = rendered.as_ref().and_then(|r| { + r.focusables.iter().find(|f| { + cx >= f.rect.x + && cx <= f.rect.x + f.rect.w + && cy >= f.rect.y + && cy <= f.rect.y + f.rect.h + }) + }); + // 1) una voce dell'elenco aperto ha la precedenza + let mut scelto = false; + if let Some(ap) = form.open_select.clone() { + if let Some(f) = rendered + .as_ref() + .and_then(|r| r.focusables.iter().find(|f| f.key == ap)) + .cloned() + { + if let Some(pp) = f.popup { + if cx >= pp.x + && cx <= pp.x + pp.w + && cy >= pp.y + && cy <= pp.y + pp.h + { + let riga = ((cy - pp.y) / f.row_height.max(1.0)).floor() as usize; + if let Some((_, valore)) = f.options.get(riga) { + let valore = valore.clone(); + form.values.insert(f.key.clone(), valore); + form.open_select = None; + form.select_highlight = None; + needs_render = true; + scelto = true; + } + } else { + // clic fuori: si chiude senza scegliere + form.open_select = None; + form.select_highlight = None; + needs_render = true; + } + } + } + } + if !scelto { + if let Some(f) = trovato.cloned() { + let ora = std::time::Instant::now(); + let doppio = ultimo_clic + .map(|(t, px, py)| { + ora.duration_since(t).as_millis() < 350 + && (px - cx).abs() < 3.0 + && (py - cy).abs() < 3.0 + }) + .unwrap_or(false); + ultimo_clic = Some((ora, cx, cy)); + + // il testo su cui si clicca è quello che il motore ha disegnato + let testo_corrente = form + .values + .get(&f.key) + .cloned() + .unwrap_or_else(|| f.text.clone()); + let modificabile = matches!( + f.kind, + ControlKind::Text | ControlKind::Password | ControlKind::Textarea + ); + if modificabile { + if let Some(m) = &metri { + let rel_x = cx - (f.rect.x + 4.0); + let indice = if f.kind == ControlKind::Textarea { + let top = f.rect.y + f.font_size * 0.37; + engine::layout::caret_index_in_lines( + m, + &testo_corrente, + f.font_size, + rel_x, + cy - top, + ) + } else { + engine::layout::caret_index_at( + m, + &testo_corrente, + f.font_size, + rel_x, + ) + }; + form.caret = Some(indice); + if doppio { + form.selection = + Some(engine::layout::word_range(&testo_corrente, indice)); + } else { + form.selection = None; + } + } + } + + if f.kind == ControlKind::Select { + let aperto = form.open_select.as_deref() == Some(f.key.as_str()); + form.open_select = if aperto { None } else { Some(f.key.clone()) }; + form.select_highlight = if aperto { None } else { Some(f.selected) }; + form.focus = Some(f.key.clone()); + needs_render = true; + } else if f.kind == ControlKind::Button { + // invio del form: l'evento va al
, che è il + // bersaglio naturale; senza gestori non si invia + // nulla e lo si dice, invece di far finta + let bersaglio = + antenato_con_tag(&contenuto.doc, f.node, "form").unwrap_or(f.node); + let rami = catena_antenati(&contenuto.doc, bersaglio); + let gestori = + macchina.evento(&mut contenuto.doc, "submit", &rami, 0.0, 0.0); + if gestori == 0 { + eprintln!("mosaic: nessun gestore di submit (invio non implementato)"); + } + needs_render = true; + } else if matches!(f.kind, ControlKind::Checkbox | ControlKind::Radio) + { + // il clic sulla casella la spunta: prima serviva la + // barra spaziatrice, che nessuno indovina + let valore = form.values.get(&f.key).cloned().unwrap_or_default(); + let nuovo = if valore == "on" || valore == "true" { + String::new() + } else { + "on".to_string() + }; + form.values.insert(f.key.clone(), nuovo); + form.focus = Some(f.key.clone()); + form.open_select = None; + needs_render = true; + } else { + form.open_select = None; + if form.focus.as_deref() != Some(f.key.as_str()) { + form.focus = Some(f.key.clone()); + if modificabile { + // il cursore è già stato calcolato dal punto del clic + } else { + form.selection = None; + let valore = + form.values.get(&f.key).cloned().unwrap_or_default(); + form.caret = Some(valore.chars().count()); + } + } + needs_render = true; + } + } else if form.open_select.is_some() { + form.open_select = None; + form.select_highlight = None; + needs_render = true; + } + } + } + } + + // --- elenco aperto: frecce spostano l'evidenza, Invio conferma, Esc chiude --- + if let Some(ap) = form.open_select.clone() { + let voci = rendered + .as_ref() + .and_then(|r| r.focusables.iter().find(|f| f.key == ap)) + .map(|f| f.options.len()) + .unwrap_or(0); + if voci > 0 { + let mut hi = form.select_highlight.unwrap_or(0).min(voci - 1); + if window.is_key_pressed(Key::Down, KeyRepeat::Yes) { + hi = (hi + 1).min(voci - 1); + form.select_highlight = Some(hi); + needs_render = true; + } + if window.is_key_pressed(Key::Up, KeyRepeat::Yes) { + hi = hi.saturating_sub(1); + form.select_highlight = Some(hi); + needs_render = true; + } + if window.is_key_pressed(Key::Enter, KeyRepeat::No) { + if let Some(f) = rendered + .as_ref() + .and_then(|r| r.focusables.iter().find(|f| f.key == ap)) + .cloned() + { + if let Some((_, valore)) = f.options.get(hi) { + let valore = valore.clone(); + form.values.insert(ap.clone(), valore); + } + } + form.open_select = None; + form.select_highlight = None; + needs_render = true; + } + if window.is_key_pressed(Key::Escape, KeyRepeat::No) { + form.open_select = None; + form.select_highlight = None; + needs_render = true; + } + } + } + + // --- moduli: Tab sposta il fuoco, i tasti scrivono nel campo attivo --- + let focusables = rendered + .as_ref() + .map(|r| r.focusables.clone()) + .unwrap_or_default(); + if window.is_key_pressed(Key::Tab, KeyRepeat::No) && !focusables.is_empty() { + let indice = form + .focus + .as_ref() + .and_then(|k| focusables.iter().position(|f| &f.key == k)) + .map(|i| (i + 1) % focusables.len()) + .unwrap_or(0); + form.focus = Some(focusables[indice].key.clone()); + needs_render = true; + } + if let Some(attivo) = form + .focus + .as_ref() + .and_then(|k| focusables.iter().find(|f| &f.key == k)) + .cloned() + { + let tipo = attivo.kind; + let modificabile = matches!( + tipo, + ControlKind::Text | ControlKind::Password | ControlKind::Textarea + ); + let mut testo = form.values.get(&attivo.key).cloned().unwrap_or_default(); + let mut cambiato = false; + + if modificabile { + // posizione del cursore in caratteri; selezione come intervallo + let len = testo.chars().count(); + let mut caret = form.caret.unwrap_or(len).min(len); + let mut ancora = form.selection.map(|(a, _)| a.min(len)); + let shift = window.is_key_down(Key::LeftShift); + + let muovi = |nuovo: usize, caret: &mut usize, ancora: &mut Option| { + if shift { + // shift estende la selezione dall'ancora + if ancora.is_none() { + *ancora = Some(*caret); + } + } else { + *ancora = None; + } + *caret = nuovo; + }; + if window.is_key_pressed(Key::Left, KeyRepeat::Yes) { + muovi(caret.saturating_sub(1), &mut caret, &mut ancora); + } + if window.is_key_pressed(Key::Right, KeyRepeat::Yes) { + muovi((caret + 1).min(len), &mut caret, &mut ancora); + } + if window.is_key_pressed(Key::Home, KeyRepeat::Yes) { + muovi(0, &mut caret, &mut ancora); + } + if window.is_key_pressed(Key::End, KeyRepeat::Yes) { + muovi(len, &mut caret, &mut ancora); + } + form.selection = ancora.map(|a| (a, caret)); + + // cancellazione: prima la selezione, poi il carattere vicino + let mut cancella = |testo: &mut String, caret: &mut usize, avanti: bool| { + let len = testo.chars().count(); + match form.selection { + Some((a, b)) if a != b => { + let (lo, hi) = if a <= b { (a, b) } else { (b, a) }; + let inizio = char_to_byte(testo, lo); + let fine = char_to_byte(testo, hi); + testo.replace_range(inizio..fine, ""); + *caret = lo.min(len); + form.selection = None; + } + _ => { + let bersaglio = if avanti { *caret } else { caret.saturating_sub(1) }; + if bersaglio < len { + let inizio = char_to_byte(testo, bersaglio); + let fine = char_to_byte(testo, bersaglio + 1); + testo.replace_range(inizio..fine, ""); + *caret = bersaglio; + } + } + } + }; + if window.is_key_pressed(Key::Backspace, KeyRepeat::Yes) { + cancella(&mut testo, &mut caret, false); + cambiato = true; + } + if window.is_key_pressed(Key::Delete, KeyRepeat::Yes) { + cancella(&mut testo, &mut caret, true); + cambiato = true; + } + form.caret = Some(caret); + + // inserimento: se c'è una selezione la si sostituisce + let mut inserisci = |testo: &mut String, c: char, caret: &mut usize| { + if let Some((a, b)) = form.selection.take() { + let (lo, hi) = if a <= b { (a, b) } else { (b, a) }; + let inizio = char_to_byte(testo, lo); + let fine = char_to_byte(testo, hi); + testo.replace_range(inizio..fine, ""); + *caret = lo; + } + let at = char_to_byte(testo, *caret); + testo.insert(at, c); + *caret += 1; + }; + if window.is_key_pressed(Key::Space, KeyRepeat::Yes) { + inserisci(&mut testo, ' ', &mut caret); + cambiato = true; + } + if tipo == ControlKind::Textarea + && window.is_key_pressed(Key::Enter, KeyRepeat::No) + { + inserisci(&mut testo, '\n', &mut caret); + cambiato = true; + } + for k in window.get_keys_pressed(KeyRepeat::No) { + if let Some(c) = key_char(k, shift) { + inserisci(&mut testo, c, &mut caret); + cambiato = true; + } + } + form.caret = Some(caret); + } else if window.is_key_pressed(Key::Space, KeyRepeat::Yes) + && matches!(tipo, ControlKind::Checkbox | ControlKind::Radio) + { + let nuovo = if testo == "on" || testo == "true" { + String::new() + } else { + "on".to_string() + }; + form.values.insert(attivo.key.clone(), nuovo); + needs_render = true; + } + + if cambiato { + form.values.insert(attivo.key.clone(), testo); + // M2.5d: chi ascolta `input` deve sapere che il campo è cambiato + let rami = catena_antenati(&contenuto.doc, attivo.node); + macchina.evento(&mut contenuto.doc, "input", &rami, 0.0, 0.0); + needs_render = true; + } + } + + let passo = (if window.is_key_down(Key::LeftShift) { 400.0 } else { 80.0 }) * zoom; + if window.is_key_down(Key::Down) { + scroll += passo * 0.25; + } + if window.is_key_down(Key::Up) { + scroll -= passo * 0.25; + } + if window.is_key_pressed(Key::PageDown, KeyRepeat::Yes) { + scroll += h as f32 * 0.9; + } + if window.is_key_pressed(Key::PageUp, KeyRepeat::Yes) { + scroll -= h as f32 * 0.9; + } + if window.is_key_pressed(Key::Home, KeyRepeat::No) { + scroll = 0.0; + } + if window.is_key_pressed(Key::End, KeyRepeat::No) { + scroll = f32::MAX; + } + + if needs_render || rendered.as_ref().map(|r| r.width != w).unwrap_or(true) { + match render_page(&page, &contenuto, w, h, zoom, &font, &form) { + Ok(r) => { + window.set_title(&format!( + "Mosaic — {}% · {:.*} ms · {}×{} · Esc/Q per chiudere", + (zoom * 100.0).round(), + 1, + r.ms, + r.width, + r.height + )); + rendered = Some(r); + } + Err(e) => { + eprintln!("errore di rendering: {}", e); + rendered = None; + } + } + needs_render = false; + } + + let buf = match &rendered { + Some(r) => blit(r, w, h, &mut scroll), + None => vec![0x00ff_ffff; (w * h) as usize], + }; + if let Err(e) = window.update_with_buffer(&buf, w as usize, h as usize) { + eprintln!("errore di presentazione: {}", e); + break; + } + } +} + +/// Copia la parte visibile dell'immagine nel buffer della finestra (0RGB). +/// Lo scroll qui non costa nulla: l'immagine è già tutta rasterizzata. +fn blit(img: &Rendered, w: u32, h: u32, scroll: &mut f32) -> Vec { + let max_scroll = (img.height as f32 - h as f32).max(0.0); + if *scroll < 0.0 { + *scroll = 0.0; + } + if *scroll > max_scroll { + *scroll = max_scroll; + } + let y0 = *scroll as u32; + let mut out = vec![0x00ff_ffffu32; (w * h) as usize]; + for y in 0..h { + let sy = y0 + y; + if sy >= img.height || y >= img.height { + break; + } + let src_start = ((sy * img.width) * 4) as usize; + let dst_start = (y * w) as usize; + for x in 0..w.min(img.width) { + let i = src_start + (x * 4) as usize; + let r = img.rgba[i] as u32; + let g = img.rgba[i + 1] as u32; + let b = img.rgba[i + 2] as u32; + out[dst_start + x as usize] = (r << 16) | (g << 8) | b; + } + } + out +} + +fn render_page( + page: &Page, + contenuto: &engine::ContenutoPagina, + w: u32, + h: u32, + zoom: f32, + font: &Path, + form: &FormState, +) -> Result { + let opts = RenderOptions { + viewport: (w, h), + dpi_scale: zoom, + font_path: font.to_path_buf(), + auto_height: true, + base_dir: page.base_dir.clone(), + base_url: page.base_url.clone(), + }; + let t = Instant::now(); + let res = engine::render_contenuto(contenuto, &page.css, &opts, form)?; + let ms = t.elapsed().as_secs_f64() * 1000.0; + Ok(Rendered { + layout: res.layout.clone(), + width: res.width, + height: res.height, + rgba: res.rgba, + ms, + focusables: res.focusables, + }) +} + +fn load( + html: &Path, + css: Option<&Path>, + _base: &Path, + url: Option<&str>, +) -> Result { + // con --url il documento arriva dalla rete; senza, dal file + let html_text = match url { + Some(u) => { + let risposta = engine::net::get(u, &engine::net::Limiti::default()) + .map_err(|e| format!("richiesta a {} fallita: {}", u, e))?; + risposta + .text() + .map_err(|e| format!("corpo di {} inutilizzabile: {}", u, e))? + } + None => std::fs::read_to_string(html).map_err(|e| format!("{}: {}", html.display(), e))?, + }; + let css_text = match css { + Some(p) => std::fs::read_to_string(p).map_err(|e| format!("{}: {}", p.display(), e))?, + None => String::new(), + }; + let base_dir = html.parent().map(|p| p.to_path_buf()).unwrap_or_else(|| PathBuf::from(".")); + Ok(Page { + html: html_text, + css: css_text, + base_dir, + base_url: url.map(|u| u.to_string()), + }) +} + +/// Offset in byte della posizione di carattere `idx` (il cursore si conta in caratteri). +fn char_to_byte(s: &str, idx: usize) -> usize { + s.char_indices() + .nth(idx) + .map(|(b, _)| b) + .unwrap_or(s.len()) +} + +/// Carattere prodotto da un tasto, con il maiuscolo gestito dallo shift. +fn key_char(k: Key, shift: bool) -> Option { + let c = match k { + Key::A => 'a', + Key::B => 'b', + Key::C => 'c', + Key::D => 'd', + Key::E => 'e', + Key::F => 'f', + Key::G => 'g', + Key::H => 'h', + Key::I => 'i', + Key::J => 'j', + Key::K => 'k', + Key::L => 'l', + Key::M => 'm', + Key::N => 'n', + Key::O => 'o', + Key::P => 'p', + Key::Q => 'q', + Key::R => 'r', + Key::S => 's', + Key::T => 't', + Key::U => 'u', + Key::V => 'v', + Key::W => 'w', + Key::X => 'x', + Key::Y => 'y', + Key::Z => 'z', + Key::Key0 => '0', + Key::Key1 => '1', + Key::Key2 => '2', + Key::Key3 => '3', + Key::Key4 => '4', + Key::Key5 => '5', + Key::Key6 => '6', + Key::Key7 => '7', + Key::Key8 => '8', + Key::Key9 => '9', + Key::Period => '.', + Key::Comma => ',', + Key::Minus => '-', + Key::Equal => '=', + Key::Slash => '/', + Key::Semicolon => ';', + Key::Apostrophe => '\'', + Key::Backslash => '\\', + Key::LeftBracket => '[', + Key::RightBracket => ']', + _ => return None, + }; + Some(if shift { c.to_ascii_uppercase() } else { c }) +} + +fn default_font() -> PathBuf { + if let Ok(p) = std::env::var("MOSAIC_FONT") { + return PathBuf::from(p); + } + for c in [ + "/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", + "/usr/share/fonts/dejavu/DejaVuSans.ttf", + ] { + if Path::new(c).exists() { + return PathBuf::from(c); + } + } + PathBuf::from("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf") +} + +// evita il warning sull'import non usato di MouseMode in alcune versioni di minifb +#[allow(dead_code)] +fn _mouse(_: MouseMode) {} diff --git a/docs/01-requisiti.md b/docs/01-requisiti.md new file mode 100644 index 0000000..0b7e1af --- /dev/null +++ b/docs/01-requisiti.md @@ -0,0 +1,93 @@ +# 01 — Requisiti + +## 1. Obiettivo + +Realizzare un motore di rendering autonomo in grado di visualizzare in modo corretto e +fluido pagine web reali, senza riuso di codice di motori esistenti. Il motore è una +libreria con API stabile, incorporata da un guscio applicativo che gestisce finestre, +schede e interfaccia. + +Successo = una pagina di riferimento (documento informativo, forum, portale di notizie, +webmail, documentazione tecnica) si carica, si impagina e reagisce all'input senza +differenze visibili rispetto a un browser di riferimento. + +## 2. Perimetro + +### In ambito + +- HTML Living Standard: parsing, DOM, formulari, contenuto incorporato (`iframe`, `img`, + `video` limitato a file progressivi), SVG e MathML in contenuto estraneo. +- CSS: selettori, cascade con layer, box model, block/inline, flexbox, grid, tabelle, + posizionamento, trasformazioni, transizioni e animazioni, `@media`, `@supports`, + custom properties, container queries (M3). +- Scripting: ECMAScript via host dedicato, `DOM`, `HTML`, `CSSOM`, `Fetch`, `WebSocket`, + `IntersectionObserver`, `ResizeObserver`, `MutationObserver`. +- Rete: HTTP/1.1, HTTP/2, HTTP/3; cache, cookie, redirect, CORS. + +### Fuori ambito (vincolante) + +- Estensioni, WebExtensions, plugin. +- WebRTC, WebGL (WebGPU sì, come accelerazione interna e API), DRM/EME. +- Sync, profili, gestione delle schede: appartengono al guscio. +- XSLT 1.0 e `document.write` in fase di parsing avanzata: solo comportamento best effort. +- Rendering di PDF, stampa vettoriale con `@page` completa: M4. + +## 3. Requisiti funzionali + +| ID | Requisito | Priorità | +|---|---|---| +| RF-01 | Il motore DEVE costruire un DOM conforme per ogni documento HTML valido o malformato, senza eccezioni non gestite. | M1 | +| RF-02 | Il motore DEVE applicare la cascata CSS nell'ordine origine/importanza/layer/specificità/ordine di documento. | M1 | +| RF-03 | Il motore DEVE produrre un albero di layout con dimensioni in pixel frazionari coerenti con il box model. | M1 | +| RF-04 | Il motore DEVE rasterizzare una display list su una superficie GPU o software con esito identico entro la tolleranza di 1/255 per canale. | M2 | +| RF-05 | Il motore DEVE supportare flexbox e grid con allineamento, `gap`, `min/max-content` e wrapping. | M2 | +| RF-06 | Il motore DEVE eseguire script e rispondere agli eventi con latenza input-per-frame ≤ 16 ms su hardware di riferimento. | M2 | +| RF-07 | Il motore DEVE supportare animazioni e transizioni con interpolazione sul compositor quando la proprietà è compositabile. | M2 | +| RF-08 | Il motore DEVE gestire formulari, `input` di testo con IME, selezione, copia/incolla e focus. | M3 | +| RF-09 | Il motore DEVE supportare SVG inline con `path`, `transform`, gradienti e clip. | M3 | +| RF-10 | Il motore DEVE esporre osservatori (`Mutation`, `Resize`, `Intersection`) con semantica conforme. | M3 | + +## 4. Requisiti non funzionali + +| ID | Requisito | Metrica di accettazione | +|---|---|---| +| RN-01 | Avvio a freddo del motore (processo pronto al primo byte) | ≤ 120 ms su SSD, senza cache calda | +| RN-02 | Memoria per pagina statica di 5 000 nodi | ≤ 45 MB RSS oltre il processo guscio | +| RN-03 | Tempo di layout incrementale su modifica di una proprietà geometrica | ≤ 4 ms al 95° percentile | +| RN-04 | Frame rate durante scroll su pagina di 20 000 px | ≥ 58 fps stabili, nessun frame > 20 ms | +| RN-05 | Nessuna regressione di correttezza ammessa senza test di riferimento aggiornato esplicitamente | gate CI bloccante | +| RN-06 | Copertura dei test sul codice di parsing, stile e layout | ≥ 85 % di rami | +| RN-07 | Determinismo: stesso input ⇒ stesso output pixel, anche con GPU diverse (tolleranza 1/255) | test notturno su 3 GPU | +| RN-08 | Nessun `unsafe` non documentato fuori dai moduli di interoperabilità (`unsafe` audit) | lint bloccante | + +Nota: gli stessi indicatori misurati su Sailfish hanno budget distinti, definiti in +[11 §5](11-browser-sailfish-test.md) (`TS-02`…`TS-06`). Una metrica, un proprietario per +piattaforma: i valori di questa tabella valgono sull'host di riferimento. + +## 5. Requisiti di sicurezza + +| ID | Requisito | +|---|---| +| RS-01 | Isolamento per sito: contenuti di origini diverse non condividono uno spazio di indirizzamento. | +| RS-02 | Il renderer DEVE girare senza accesso al filesystem di rete e con seccomp filter attivo. | +| RS-03 | Nessuna esecuzione di codice macchina generato dal contenuto fuori dalle pagine dichiarate JIT (`COEP`/`COOP` rispettati). | +| RS-04 | Il parser HTML DEVE resistere a input ostili senza crescita super-lineare (limite: O(n), nessun crash entro 10 minuti di fuzzing continuo). | +| RS-05 | Ogni accesso cross-origin DEVE passare da una policy esplicita (CORS/CSP), con default negato. | + +## 6. Metriche di accettazione della release M2 + +1. Punteggio WPT su sottocategorie `html/dom`, `css/css-cascade`, `css/css-flexbox`, + `css/css-grid` ≥ 92 %. +2. Nessuna differenza visiva oltre tolleranza su 200 pagine del corpus di reftest. +3. Scroll e animazioni compositate nei budget RN-03/RN-04 su hardware di riferimento + (4 core, GPU integrata, 8 GB). +4. Zero crash su 72 ore di navigazione automatizzata del corpus. + +## 7. Rischi + +| Rischio | Impatto | Mitigazione | +|---|---|---| +| Sottostima del tree builder HTML (recupero errori) | alto | implementazione guidata da test WPT dal primo giorno, non a fine progetto | +| Layout incrementale troppo ambizioso | alto | partire da relayout completo, introdurre granularità solo con dati alla mano | +| Shaping del testo e fallback font | medio | `rustybuzz` in M1 (fatto), fallback font ancora da fare | +| Divergenza su pixel tra GPU | medio | reftest con tolleranza e raster di riferimento software come arbitro | diff --git a/docs/02-architettura.md b/docs/02-architettura.md new file mode 100644 index 0000000..51fd815 --- /dev/null +++ b/docs/02-architettura.md @@ -0,0 +1,140 @@ +# 02 — Architettura + +## 1. Pipeline + +``` +byte → [Loader] → [Parser HTML] → DOM → [Style] → style tree + ↓ + [Layout] → box/fragment tree + ↓ + [Paint] → display list + ↓ + [Compositor] → tile GPU → schermo +``` + +Ogni stadio consuma l'output del precedente e produce una struttura immutabile o +copy-on-write, con l'eccezione del DOM che è mutabile per contratto. Il motore non +mantiene stato globale mutabile: lo stato vive in un `DocumentContext` per documento. + +## 2. Processi e thread + +| Componente | Dove | Note | +|---|---|---| +| Guscio (UI, schede) | processo principale | non tocca il DOM | +| Content process | uno per sito (DA-2) | parser, DOM, stile, layout, paint | +| Compositor | processo dedicato | layer, tile, vsync, input routing | +| Network | processo dedicato | socket, TLS, cache HTTP | +| GPU/raster | thread pool nel compositor | comandi `wgpu` | + +Motivazione dell'isolamento: un errore di memoria nel parser non deve poter corrompere il +compositor né leggere memoria di un altro sito. Costo accettato: latenza IPC. + +Thread nel content process: + +- `main`: event loop, script, stile, layout — tutto ciò che tocca il DOM. +- `parser`: thread separato che produce token e li invia al tree builder sul `main` + tramite coda limitata (backpressure: 8 KB di token non consumati bloccano la lettura). +- `raster-workers`: decode di immagini, raster di glifi. + +Eccezione dichiarata: sulla piattaforma di test Sailfish (doc 11) il motore gira +in-process dentro l'applicazione, perché RAM e sandbox SailJail non reggono un content +process separato. Conseguenza vincolante per il codice: nessuna struttura condivisa fra +documenti, nessuno stato globale mutabile (TS-09). + +## 3. IPC + +Messaggi binari serializzati (`bincode`-like), canali bidirezionali per coppia di +processi, nessun oggetto condiviso oltre alle regioni di memoria per i buffer di tile. + +Contratti principali: + +```rust +// content → compositor +enum CompositorMsg { + Commit { frame_id: u64, layers: Vec }, + RequestResize { viewport: Size }, + ScrollUpdate { layer_id: LayerId, offset: Point }, +} + +// network → content +enum NetworkMsg { + ResponseHeaders { request_id: RequestId, status: u16, headers: HeaderMap }, + BodyChunk { request_id: RequestId, bytes: Bytes }, + BodyEnd { request_id: RequestId, ok: bool }, +} +``` + +Regole: + +1. Nessun messaggio bloccante sincrono sul percorso di rendering. +2. Ogni messaggio è idempotente o numerato: la perdita non è ammessa, la duplicazione + viene ignorata. +3. Il content process non attende mai il compositor: i commit sono asincroni e il + compositor conserva l'ultimo frame valido. + +## 4. Modello di invalidazione + +Ogni nodo DOM ha bit di stato: + +```rust +bitflags! { + struct NodeFlags: u16 { + const STYLE_DIRTY = 1 << 0; // ricomputare lo stile + const LAYOUT_DIRTY = 1 << 1; // ricomputare la geometria + const PAINT_DIRTY = 1 << 2; // rigenerare la display list + const COMPOSITE_DIRTY = 1 << 3; // riposizionare un layer + const CHILDREN_DIRTY = 1 << 4; // propagazione ai discendenti + } +} +``` + +Regola di propagazione: + +- mutazione di un attributo di classe/id o del testo ⇒ `STYLE_DIRTY` sul nodo, i + discendenti vengono rivalutati solo se esistono regole potenzialmente applicabili + (invalidation set, vedi 04). +- mutazione di una proprietà che cambia solo il colore ⇒ `PAINT_DIRTY`, nessun layout. +- mutazione di proprietà geometriche ⇒ `LAYOUT_DIRTY`, propagazione verso l'alto fino + alla radice del contesto di formattazione (vedi 05). +- `transform`/`opacity` su elemento già layerizzato ⇒ `COMPOSITE_DIRTY`, solo + compositor. + +Il ciclo si chiude al `requestAnimationFrame`: stile → layout → paint → commit. Nessuno +stadio viene eseguito due volte nello stesso frame. + +## 5. Frame + +``` +vsync (compositor) ──► BeginFrame(frame_id, deadline) + │ + │ content: script dei rAF, stile, layout, paint + ▼ + Commit(frame_id, layers) ──► compositor: raster dei tile mancanti, present +``` + +- Deadline = vsync − 6 ms (margine per raster e present). +- Se il content non ha finito entro la deadline, il compositor presenta l'ultimo frame e + il successivo lavora sulla nuova versione: nessun blocco sull'attesa. +- Il contatore `frame_id` è monotono; i commit con id inferiore all'ultimo presentato + vengono scartati. + +## 6. Strutture dati + +| Struttura | Allocazione | Note | +|---|---|---| +| DOM | arena con indici (`NodeId = u32`) + slot vecchio stile HTML: nodi non spostabili | nessun `Rc>`: mutabilità controllata da borrow a runtime nel `main` | +| Style tree | array piatto, `StyleId` per nodo | condivisione delle struct per stile identico | +| Box tree | arena per contesto di formattazione | scartato e ricostruito al relayout del contesto | +| Display list | vettore lineare di comandi | immutabile dopo la costruzione, danno calcolato per intervallo | + +Scelta dell'arena: eliminare i puntatori fra nodi e rendere banale il controllo di +integrità in debug; il costo è l'invalidazione degli indici alla rimozione, risolta con +generazione (`{index, generation}`). + +## 7. Cosa il motore non fa + +- Non gestisce la persistenza dei profili né i segnalibri. +- Non decide la politica di aggiornamento: riceve notifiche e riparte dal flusso di + invalidazione. +- Non implementa la barra degli indirizzi, il gestore di download o i permessi: il guscio + fornisce callback e il motore le invoca. diff --git a/docs/03-parsing-html.md b/docs/03-parsing-html.md new file mode 100644 index 0000000..94abf90 --- /dev/null +++ b/docs/03-parsing-html.md @@ -0,0 +1,134 @@ +# 03 — Parsing HTML + +## 1. Perimetro + +Il parser implementa l'algoritmo di WHATWG HTML Living Standard §13: tokenizzazione, +costruzione dell'albero, contenuto estraneo (SVG/MathML), parsing di frammenti. Non è +ammesso un parser "semplificato": il recupero dagli errori è parte del contratto, perché +il web reale ne dipende. + +## 2. Input e decodifica + +```rust +fn decode(bytes: &[u8], transport_charset: Option, context: &str) -> (String, Charset) +``` + +Ordine di sniffing: + +1. BOM (`EF BB BF`, `FF FE`, `FE FF`) — prevale su tutto. +2. `transport_charset` (header `Content-Type`). +3. Meta prescan: primi 1024 byte, `` o ``. +4. Precedenza fra meta e header: il meta **non** scavalca il BOM; scavalca l'header solo se + l'header è assente, oppure se il charset dichiarato è `utf-16`/`x-user-defined` e il + documento non è UTF-16 (regola di compatibilità). +5. Default `windows-1252` → rimappatura su UTF-8 con replacement per byte non validi. + +`NUL` nel flusso: sostituito con U+FFFD in tokenizzazione, **non** rimosso. + +## 3. Tokenizer + +Macchina a stati finiti, stato salvato come singolo `u8` con i sottostati di ritorno +(`text`, `rcdata`, `rawtext`, `script data`, `plaintext`) in uno stack esplicito. + +```rust +struct Tokenizer { state: State, return_state: Option, ... } + +enum Token { + StartTag { name: Atom, attrs: Vec<(Atom, String)>, self_closing: bool }, + EndTag { name: Atom }, + Comment(String), + Doctype { name: Option, public_id: Option, system_id: Option }, + Character(char), + Eof, +} +``` + +Vincoli: + +- RE-01: nessun token può eccedere 1 MB di attributi cumulati; oltre, gli attributi + successivi vengono scartati con warning (comportamento documentato, non crash). +- RE-02: interning dei nomi di tag e attributi in un `Atom` globale (indice `u32`): il + confronto dei nomi non deve fare comparazione di stringhe nel percorso caldo. +- RE-03: l'emissione è a blocchi, con flush a ogni tag o a 4 KB di caratteri. +- RE-04: `CDATA` ammesso solo in contenuto estraneo; altrove trattato come bogus comment. + +## 4. Tree builder + +Insertion modes (§13.2.6), tutti implementati, con stack di elementi aperti e lista di +elementi attivi per la formattazione (adoption agency algorithm): + +`initial`, `before html`, `before head`, `in head`, `in head noscript`, `after head`, +`in body`, `text`, `in table`, `in table text`, `in caption`, `in column group`, +`in table body`, `in row`, `in cell`, `in select`, `in select in table`, `in template`, +`after body`, `in frameset`, `after frameset`, `after after body`, `after after frameset`. + +Punti critici da trattare con test dedicati: + +| ID | Caso | Comportamento richiesto | +|---|---|---| +| PB-01 | `adoption agency algorithm` | corretta chiusura di `` senza discendenza artificiale | +| PB-02 | Foster parenting | nodi testuali in `` spostati prima della tabella | +| PB-03 | `in body` + `