// THE STATS (module `stats`, region `stats`): a frame scan's running numbers // over the clips that declare them, in a panel in the footage // (`render.chrome.stats`, stats.mjs). chrome-stats.mjs writes the page. import path from "node:path"; import { statsGeometry } from "../deck.mjs"; import { statsHtml } from "../chrome-stats.mjs"; import { assertRegion, defineModule } from "./contract.mjs"; import { settingsOf } from "./settings.mjs"; export default defineModule({ id: "stats", version: 1, z: 50, kind: "overlay-whole", slot: "panel", // Its form in the stacked vertical deck (vertical-deck.mjs). vertical: { slot: "picture" }, title: "Stats", summary: "A frame scan's running numbers over the clips that declare them.", validate: settingsOf("stats").validate, docs: { heading: "Stats", intro: "A frame scan’s running numbers over the clips that declare them, in a panel in the footage (`render.chrome.stats`, stats.mjs).", rows: [ ["`render.chrome.stats.position`", "`top-left` `top-right` `bottom-left` `bottom-right` · default `bottom-left`", "manifest"], ["`render.chrome.stats.fields`, `.name`", "a list of `stack` `stackBB` `playersLeft` `level`; bool · default all, `true`", "manifest"], ], }, region: "stats", workers: "narrow", noun: "the stats region's", configKey: "render.chrome.stats", on: (schedule) => !!schedule?.stats?.clips?.length, check: (schedule) => (!schedule.stats?.clips?.length ? "the stats region needs a schedule with a clip that declares it (render.chrome.stats or a clip's stats, and frameScan.overlay points)" : null), async page(ctx) { // The stats region (chrome-stats.mjs): the deck's faces, no QR. const fonts = await ctx.fonts({ regular: "DeckSans", bold: "DeckSansBold" }, { strict: true }); return statsHtml(ctx.schedule, ctx.render, { fonts, from: ctx.from, duration: ctx.duration }); }, regions(schedule, { render, outDir, frames = null }) { return [assertRegion({ name: "stats", frames: frames ?? path.join(outDir, "chrome", "stats-frames"), ...statsGeometry(render, { feed: schedule.layout === "feed" }), })]; }, // Its page is its live preview: Play the cut seeks it in the cut's seconds (contract.mjs, PLAY). play: { clock: "cut", ready: "stats:ready" }, // A cue interpreter like the deck's: keyed per frame (frame-keys.mjs). frameKeys: { data: "stats-data", omit: ["init", "cues", "window", "total", "ids"] }, });