diff --git a/docs/build.ts b/docs/build.ts index 459e1904..b0ac9449 100644 --- a/docs/build.ts +++ b/docs/build.ts @@ -437,6 +437,18 @@ const presets = parsed.flatMap((page) => })) .filter((preset) => playable(preset.source)), ); +// The size of each PNG the pages show, read from its header, so a still reserves its room before the image loads. +const publicDir = new URL("public/", root); +const imageSizes = new Map( + await Promise.all( + (await readdir(publicDir)) + .filter((file) => file.endsWith(".png")) + .map(async (file) => { + const head = await readFile(new URL(file, publicDir)); + return [file, [head.readUInt32BE(16), head.readUInt32BE(20)]] as const; + }), + ), +); // A still of a rendered document: no scripts, its plugins' styles collected into `styles` to go in the page once, // no ids, since a page holds many, and a chart without its data table, so the still is all plot. const stillOf = (html: string, styles: Set) => @@ -445,6 +457,10 @@ const stillOf = (html: string, styles: Set) => .replace(/