From 67a609dd5e98df4df9a3fb40104817e0c25e5582 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Thu, 2 Jul 2026 13:10:54 -0400 Subject: feat(theme-studio): screenshot harness + ecosystem coverage policy Two speedrun-enabling pieces. A #preview=&theme= hash handler plus screenshot-previews.sh shoot any app's face table and live preview headlessly under a real theme (WIP.json by default), so preview work can be verified without a human clicking through the studio. The README gains the coverage policy: the studio themes popular packages even when uninstalled, pinning their faces rather than dropping them, and unloaded packages' previews matter more, not less. --- scripts/theme-studio/screenshot-previews.sh | 51 +++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100755 scripts/theme-studio/screenshot-previews.sh (limited to 'scripts/theme-studio/screenshot-previews.sh') diff --git a/scripts/theme-studio/screenshot-previews.sh b/scripts/theme-studio/screenshot-previews.sh new file mode 100755 index 00000000..72894aa7 --- /dev/null +++ b/scripts/theme-studio/screenshot-previews.sh @@ -0,0 +1,51 @@ +#!/usr/bin/env bash +# Screenshot each theme-studio app's page (face table + live preview) headlessly. +# +# ./screenshot-previews.sh OUTDIR [APP ...] +# THEME=dupre.json ./screenshot-previews.sh OUTDIR [APP ...] +# +# With no APP arguments, shoots every app in the studio. Rides the #preview= +# hash handler in app.js (the same hash-URL pattern as the browser gates), so the +# page selects the app itself before Chrome takes the shot. THEME names a theme +# JSON next to this script (default dupre.json; THEME= empty shoots untitled) so +# shots show real theme colors -- fresh headless profiles carry no localStorage. +# Regenerate the page first (make gen) when sources changed; this script shoots +# what is on disk. +set -uo pipefail + +HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +OUT="${1:?usage: screenshot-previews.sh OUTDIR [APP ...]}" +shift || true +mkdir -p "$OUT" + +BROWSER="" +for b in google-chrome-stable google-chrome chromium chromium-browser; do + command -v "$b" >/dev/null 2>&1 && { BROWSER="$b"; break; } +done +[ -n "$BROWSER" ] || { echo "no Chromium-family browser found" >&2; exit 1; } + +if [ "$#" -gt 0 ]; then + APPS="$*" +else + APPS="$(cd "$HERE" && python3 -c 'import generate; print(" ".join(sorted(generate.APPS)))')" +fi + +THEME="${THEME-WIP.json}" +SUFFIX="" +if [ -n "$THEME" ]; then + [ -f "$HERE/$THEME" ] || { echo "theme not found: $HERE/$THEME" >&2; exit 1; } + SUFFIX="&theme=$THEME" +fi + +for app in $APPS; do + "$BROWSER" --headless=new --disable-gpu --hide-scrollbars \ + --allow-file-access-from-files \ + --window-size=1500,2000 --virtual-time-budget=6000 \ + --screenshot="$OUT/$app.png" \ + "file://$HERE/theme-studio.html#preview=$app$SUFFIX" >/dev/null 2>&1 + if [ -s "$OUT/$app.png" ]; then + echo " shot $app" + else + echo " FAILED $app" >&2 + fi +done \ No newline at end of file -- cgit v1.2.3