Public: anyone can read this; the crew can change it.
OG renderer: SVG composed from data, rasterized to PNG with resvg, cached by input hash #536
Adds src/web/og/, which composes an SVG from typed inputs, rasterizes it to a 1200×630 PNG with the resvg binary, and serves it at GET /og/:kind/:slug.png?t=…&s=…. bun x tsc --noEmit is clean and bun test test/og.test.ts passes (7 pass, 1 skipped). I did not run the full check from forge.json locally.
stopped closed without shipping deploy b4b40cc
2 earlier comments
Adds src/web/og/: it composes an SVG from typed inputs, rasterizes it to a 1200×630 PNG with the resvg binary, and serves it at GET /og/:kind/:slug.png?t=…&s=….
Check fix: adding test/og.test.ts pushed check.run in forge.json past the forge's 1000-character limit. I shortened it with two shell globs, test/fork*.test.ts and test/crew-[lsw][air]*.test.ts. Each glob matches exactly the files it replaced, so the set of tests run is unchanged. The command is now 958 characters.
Verification: bun x tsc --noEmit is clean. I ran bun run check once, with the fork* glob in place. It passed: 652 tests across 43 files, in 3 shards. The crew glob came after that run. I confirmed it lists the same three files and re-ran tsc, but I did not re-run the full check.
- Composition:
compose.tsescapes every input and gives the same output for the same input. Titles wrap to a bounded number of lines and end in an ellipsis where they are cut. - Rasterizing:
raster.tsrunsresvg, found throughFORGE_RESVGorPATH. It adds no dependency. Ifresvgis missing, the request gets a 503. - Cache:
render.tskeys on the sha256 of the inputs. Equal inputs rasterize once, concurrent identical requests share one render, and failures are not cached. - Route:
route.tsreturns 404 for an unknown kind, a missing title or control characters. A good response isimage/png,immutable, with an ETag and a 304 onIf-None-Match. The route is registered insrc/http/server.ts. - Tests: compose escaping and determinism, wrapping, cache and single-flight behaviour, and the route's 404/200/304/503 cases using a stand-in renderer. A test that renders every kind for real checks the PNG header size, that it decodes, and a warm response under 50 ms.
The real-render test is skipped on hosts without resvg, and this clone has none, so it has not run here.
Not done:
- I used the host's
resvgbinary instead of a wasm build. - No fonts are embedded. Text uses whatever fonts the host's
resvgfinds, andforge.jsondoes not install them. - No Chromium fallback, because it takes about 14 s a picture.
To try it, install resvg and open /og/repo/x.png?t=Hello&s=World.
🤖 Generated with Claude Code
I merged main into the branch and pushed it. The only conflict was in forge.json, and the full check passes locally: 665 tests across 44 files.
main had changed check.run to list tests by bare name after -- (for example crew crew-wrapup …). I took that form and appended og. The globs I used earlier to get under the 1000-character limit (test/fork*.test.ts and test/crew-[lsw][air]*.test.ts) are gone, since the bare-name list is shorter and names each file exactly.
The OG renderer is unchanged: SVG composed from data, rasterized with resvg, cached by a hash of the inputs, and served at /og/:kind/:slug.png. The test that renders every kind for real is still skipped on hosts without resvg, and this clone has none, so it has not run here.
To try it: install resvg and open /og/repo/x.png?t=Hello&s=World.
🤖 Generated with Claude Code
Adds
src/web/og/, which composes an SVG from typed inputs, rasterizes it to a 1200×630 PNG with theresvgbinary, and serves it atGET /og/:kind/:slug.png?t=…&s=….bun x tsc --noEmitis clean andbun test test/og.test.tspasses (7 pass, 1 skipped). I did not run the full check fromforge.jsonlocally.compose.tsbuilds the SVG from the kind, title and subtitle (the kinds areOG_KINDS). Every input is escaped, and the output is deterministic. Titles wrap to a bounded number of lines with an ellipsis at the cut.raster.tsrunsresvg, found throughFORGE_RESVGorPATH. It is not a package, so there is no new dependency. Ifresvgis missing, the request gets a 503, never a made-up picture.render.tskeys on the sha256 of the inputs. Equal inputs rasterize once, concurrent identical requests share one render, and failures are not cached.route.tsreturns 404 for an unknown kind, a missing title or control characters. A good response isimage/png,immutable, with an ETag and 304 onIf-None-Match. The route is registered insrc/http/server.tsandtest/og.test.tsis added to the check list inforge.json.The real-render test is skipped on hosts without
resvg, and this clone has none, so it has not run here. The stand-in tests do run.I did not use a wasm build or embed fonts. It depends on the host's
resvgand its fonts, whichforge.jsondoes not install. I also dropped the Chromium fallback because it takes about 14 s a picture.To try it, install
resvgand open/og/repo/x.png?t=Hello&s=World.🤖 Generated with Claude Code
Closes #452