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.
This commit is contained in:
Carlo Baratto committed 2026-11-12 19:10:26 +01:00
commit 577682ae22
173 files changed
+23685

No files matched your search

+85
View File
@@ -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"
+37
View File
@@ -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("<IIIIHHHH", data[off + 4 : off + 28])
if 4096 <= blk <= 1048576 and (blk & (blk - 1)) == 0 and 1 <= comp <= 6 and 12 <= blog <= 20:
open(dst, "wb").write(data[:off])
print(f"runtime: {off} byte estratti da {src}")
return 0
off += 1
print("nessun superblocco squashfs valido: non è un'AppImage di tipo 2", file=sys.stderr)
return 1
if __name__ == "__main__":
raise SystemExit(main())
+53
View File
@@ -0,0 +1,53 @@
#!/usr/bin/env python3
"""Genera l'icona di Mosaic (globo blu/verde) in PNG."""
import sys
from PIL import Image, ImageDraw
size = int(sys.argv[1]) if len(sys.argv) > 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)