// THE FINALE (module `finale`, region `finale`): the cut's last clips with the // rail redrawn large across the top, the counter's final totals under it, // stats cards beside them and the clip in a smaller box (a clip's `layout: // "finale"`, `render.chrome.deck.finale`, finale.mjs). One full-frame window // over the run, laid LAST: its ground covers every region under it while it // is up. chrome-finale.mjs writes the page. import path from "node:path"; import { resolveDeck, snapWindow } from "../deck.mjs"; import { finaleHtml, finaleLayout } from "../chrome-finale.mjs"; import { assertRegion, defineModule } from "./contract.mjs"; import { FINALE_DEFAULTS, resolveFinale } from "../finale.mjs"; import { settingsOf } from "./settings.mjs"; export default defineModule({ id: "finale", version: 1, z: 90, kind: "overlay-window", slot: "full", title: "Finale", summary: "The cut's last clips under the rail redrawn large, the final totals and stats cards.", configKey: "render.chrome.deck.finale", defaults: FINALE_DEFAULTS, validate: settingsOf("finale").validate, resolve: resolveFinale, deps: ["counter.totals", "rail.layout"], provides: ["finale.window"], ui: [ { key: "video", type: "enum", options: ["side", "corner", "hidden"], label: "The clip", default: "side" }, { key: "motion", type: "enum", options: ["grow", "cut"], label: "Motion", default: "grow" }, { key: "totals", type: "boolean", label: "Totals", default: true }, { key: "statsTitle", type: "text", label: "Stats title" }, { key: "stats", type: "stats", label: "Stats cards", max: 8 }, { key: "railLabels", type: "enum", options: ["all", "nodes", "sections", "none"], label: "Rail labels", default: "all" }, { key: "pips", type: "boolean", label: "The finale's clips on the rail", default: true }, { key: "timelineShare", type: "number", min: 0.38, max: 0.6, step: 0.01, label: "Timeline share (auto when unset)" }, { key: "claims", type: "enum", options: ["rotate", "all"], label: "Claim checks", default: "rotate" }, { key: "dietRuns", type: "boolean", label: "Every diet on record under the rail (railLabels sections or none)", default: false }, ], docs: { heading: "Finale", intro: "The full reference is [The finale](#the-finale-the-timeline-in-primary-view). It reads the counter's totals (`counter.totals`) and the rail's layout (`rail.layout`); the counter reads its window (`finale.window`): a mark that would stamp inside it counts as it opens.", rows: [ ["`deck.finale`", "`{video, motion, totals, stats, statsTitle, railLabels, pips, timelineShare, claims, dietRuns}` -- `dietRuns`: the whole diet record under the rail ([Diet runs in the finale](#diet-runs-in-the-finale))", "`umtool look

deck.finale='{…}'`"], ["a clip's `layout`", "`finale` on one run of clips at the end", "`umtool set

layout=finale`"], ], }, region: "finale", // Its page fades out through the dissolve after the run: over a full-frame item it is left out only once that // dissolve is over (full-frame.mjs `ownFade`). fullFrame: { ownFade: true }, workers: "narrow", noun: "the finale's", on: (schedule) => !!schedule?.finale, check: (schedule) => (!schedule.finale ? "the finale region needs a schedule with a finale (a clip with layout \"finale\", render.chrome.deck.finale)" : null), // The finale's window: the schedule's, snapped outward to the frame grid. window: (schedule, { fps, total }) => snapWindow({ segment: "finale", from: schedule.finale.from, to: schedule.finale.to }, { fps, total }), names: ({ preview }) => ({ project: `finale${preview ? "-preview" : ""}`, stem: "finale" }), async page(ctx) { // The finale (chrome-finale.mjs): the deck's faces and QR maker, one page // for its window. const { render, schedule } = ctx; const fonts = await ctx.fonts({ regular: "DeckSans", bold: "DeckSansBold" }, { strict: true }); const L = finaleLayout(schedule, render); const qrSrcs = {}; if (resolveDeck(render).qr.show) { const byUrl = await ctx.qrs(L.captions.map((c) => c.qrUrl), L.geo.qr.size); for (const c of L.captions) if (c.qrUrl) qrSrcs[c.id] = byUrl.get(c.qrUrl); } return finaleHtml(schedule, render, ctx.window, { fonts, qrSrcs }); }, /** * The finale's page as an overlay region: the whole frame, its window * snapped to the frame grid and laid at its own second like a posts window * -- `offset` in the BASE's clock (the cut's, or a preview's that starts * `shift` in). `clip` (`{at, dur}`) keeps it only when it intersects. */ regions(schedule, { render, outDir, shift = 0, clip = null }) { const f = schedule?.finale; if (!f) return []; const fps = Number(schedule.fps ?? render.fps); const s = snapWindow({ segment: "finale", from: f.from, to: f.to }, { fps, total: schedule.total }); if (clip && !(s.from < clip.at + clip.dur && s.to > clip.at)) return []; return [assertRegion({ name: "finale", frames: path.join(outDir, "chrome", "finale-frames"), x: 0, y: 0, width: render.width ?? 1920, height: render.height ?? 1080, offset: s.from - shift, frameCount: s.frames, window: s, }, "window")]; }, // The finale is a window of the cut by design: its frame n is cut time // `from` + n / fps, and its one ease of its own is the page's smoothstep. frameKeys: { data: "finale-data", omit: ["init", "cues", "from", "dur"], offset: "from", eases: { smoothstep: { page: "const EASES = { smoothstep: (p) => p * p * (3 - 2 * p) };", fn: (p) => p * p * (3 - 2 * p) } }, }, });