Screenshots of live websites. Minimal interface, powerful engine.
Wait for image loads and entrance animations in the settle pass
Bridger Tower1bade2ae62df
diff --git a/Cargo.lock b/Cargo.lockindex cfcf00f..0b3a135 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -963,7 +963,7 @@ dependencies = [[[package]]name = "shot"-version = "0.1.0"+version = "0.1.1"dependencies = ["anyhow","chromiumoxide",diff --git a/Cargo.toml b/Cargo.tomlindex cdce9f9..8a371a8 100644--- a/Cargo.toml+++ b/Cargo.toml@@ -1,6 +1,6 @@[package]name = "shot"-version = "0.1.0"+version = "0.1.1"edition = "2024"rust-version = "1.85"description = "Minimal, powerful screenshots of live websites"diff --git a/README.md b/README.mdindex 61abe18..964687f 100644--- a/README.md+++ b/README.md@@ -28,7 +28,7 @@ The only runtime dependency is an installed Chrome-family browser (Chrome, Chrom## What it does for you- Renders with your real installed Chrome, driven over the DevTools Protocol-- Waits for fonts, paint frames, and — on `--full` — scroll-triggers lazy-loaded content before capturing+- Waits for fonts, image loads, entrance animations, and — on `--full` — scroll-triggers lazy-loaded content before capturing- Retina `@2x` output by default; full pages taller than Chrome's ~16k px render limit fall back to `@1x` automatically (the report tells you which you got)- Image format from the `-o` extension or `--format`: `png` (default), `jpg`, `webp` (JPEG/WebP encode at quality 90)- One browser process, concurrent tabs; a failed URL prints `✗` and never kills the batch (exit code 1 if anything failed)diff --git a/src/capture.rs b/src/capture.rsindex c57d13b..804cddb 100644--- a/src/capture.rs+++ b/src/capture.rs@@ -313,9 +313,27 @@ fn find_chrome() -> Option<PathBuf> {CANDIDATES.iter().map(PathBuf::from).find(|p| p.exists())}-/// Fonts loaded + two animation frames painted.+/// Fonts loaded, images loaded (5s cap each), two frames painted, then any+/// running finite animations/transitions — entrance fade-ins — allowed to+/// finish (3s cap; infinite loops are skipped, they never settle).const SETTLE_JS: &str = r#"(async () => {if (document.fonts) { try { await document.fonts.ready; } catch {} }+ await Promise.all(Array.from(document.images, img => img.complete ? 0 :+ new Promise(r => {+ img.addEventListener('load', r, { once: true });+ img.addEventListener('error', r, { once: true });+ setTimeout(r, 5000);+ })));+ await new Promise(r => requestAnimationFrame(() => requestAnimationFrame(r)));+ const finite = document.getAnimations().filter(a => {+ try {+ return a.playState === 'running' && a.effect.getTiming().iterations !== Infinity;+ } catch { return false; }+ });+ await Promise.race([+ Promise.all(finite.map(a => a.finished.catch(() => {}))),+ new Promise(r => setTimeout(r, 3000)),+ ]);await new Promise(r => requestAnimationFrame(() => requestAnimationFrame(r)));})()"#;