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:
commit
577682ae22
173 files changed
+23685
No files matched your search
Executable
+66
@@ -0,0 +1,66 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Estrae demoHtml/demoCss da qml/pages/MainPage.qml e li rende col motore.
|
||||
|
||||
Serve a verificare quello che il guscio Sailfish mostra davvero, senza device:
|
||||
si prende il testo esatto dal QML (concatenazioni e sequenze di escape comprese)
|
||||
e lo si passa al motore come farebbe EngineView.
|
||||
|
||||
Uso: scripts/check-demo.py [uscita.png] [larghezza_css] [scale]
|
||||
"""
|
||||
import pathlib
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
RADICE = pathlib.Path(__file__).resolve().parent.parent
|
||||
QML = RADICE / "qml/pages/MainPage.qml"
|
||||
ENGINE = RADICE.parent / "engine/target/release/render"
|
||||
|
||||
|
||||
def estrai(blocco: str) -> str:
|
||||
"""Concatena i letterali di stringa del blocco, sciogliendo gli escape QML."""
|
||||
pezzi = re.findall(r'"((?:[^"\\]|\\.)*)"', blocco, re.S)
|
||||
testo = "".join(pezzi)
|
||||
return testo.replace('\\"', '"').replace("\\\\", "\\")
|
||||
|
||||
|
||||
def main() -> int:
|
||||
uscita = sys.argv[1] if len(sys.argv) > 1 else "/tmp/mobile-demo.png"
|
||||
larghezza_css = float(sys.argv[2]) if len(sys.argv) > 2 else 380.0
|
||||
scala = float(sys.argv[3]) if len(sys.argv) > 3 else 2.85
|
||||
|
||||
sorgente = QML.read_text()
|
||||
i = sorgente.index("property string demoHtml:")
|
||||
j = sorgente.index("property string demoCss:")
|
||||
k = sorgente.index("\n\n", j)
|
||||
html = estrai(sorgente[i:j])
|
||||
css = estrai(sorgente[j:k])
|
||||
|
||||
tmp_html = pathlib.Path("/tmp/mobile-demo.html")
|
||||
tmp_css = pathlib.Path("/tmp/mobile-demo.css")
|
||||
tmp_html.write_text(html)
|
||||
tmp_css.write_text(css)
|
||||
|
||||
larghezza = int(round(larghezza_css * scala))
|
||||
cmd = [
|
||||
str(ENGINE),
|
||||
"--html",
|
||||
str(tmp_html),
|
||||
"--css",
|
||||
str(tmp_css),
|
||||
"--size",
|
||||
f"{larghezza}x2200",
|
||||
"--scale",
|
||||
str(scala),
|
||||
"--auto-height",
|
||||
"--base-dir",
|
||||
str(RADICE),
|
||||
"--out",
|
||||
uscita,
|
||||
]
|
||||
print(" ".join(cmd))
|
||||
return subprocess.call(cmd)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
Reference in new issue
Block a user