commit 6b9cc95571d978ddb0a05bb12b046d2db14032c9
parent e574c2669b048c009b621fbb391442ab7f5113f2
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Mon, 26 Oct 2026 10:06:16 -0400
Finale room: the timeline takes the height its rows need, claims take turns, nothing overprints
The Huck finale printed every claim check's words on one line over the rail,
ran the span labels into the markers' flags and overlapped the turned dates.
- deck.finale.claims "rotate" (default): one claim check at a time, an even
share of the page's time from the rail in place to the run's end, >= 6 s
each, 0.5 s crossfade, in deck.claims order; "all" stacks them (also the
fallback for one claim or too little time). Cues state every from.
- The claims' words, span labels and markers' labels are packed in rows over
the track (finale.mjs placeAbove): a span label on its bar or higher on a
leader, a claim's words above the markers' rows at their bracket, the stick
moved inside the bracket and never through words under it.
- A crowded rail says each date once (its longest run) and fans the turned
labels along the rail on thin leaders (fanSlots); never two that meet.
- deck.finale.timelineShare "auto" (default) | 0.38-0.6: deck.mjs finaleRail
measures the rows; the schedule records finale.railBottom/textScale when
they differ, with the clip's smaller box the footage moves into. With
claims the rail's words are set up to 1.3x when the room lets them; the
clip, totals and stats shrink to the column. No claims and nothing crowded:
the schedule and page as before (byte-identity tests hold).
- finaleClaims moved to finale.mjs (pure; chrome-claims re-exports it).
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
7 files changed, 899 insertions(+), 185 deletions(-)
diff --git a/editor/CHANGELOG.md b/editor/CHANGELOG.md
@@ -1,6 +1,7 @@
# Changelog
## [Unreleased]
+- **A report video's finale timeline no longer prints words over words.** In the Huck cut's finale the claim checks' words all stood on one line over the rail (`“less than ten” a year`, `19 seizures on camera`, `12 in a day · 4 in a week`, both pill-test goalposts), the `12 IN A DAY`/`4 IN A WEEK` labels ran into the markers' flags, and the turned dates under the rail overlapped. Now the claim checks take turns (`deck.finale.claims`: `rotate`, the default — one claim at a time for an even share of the finale's time, at least 6 s each, with a short crossfade; `all` stacks them), every claim's words, span label and marker label is laid in its own place in rows over the rail, with its stick kept inside its bracket and clear of the words under it, and a crowded rail says each date once and fans the turned labels out on thin leaders so no two meet. The timeline takes the height its rows need (`deck.finale.timelineShare`: `auto`, up to just over half the frame, its words set larger when there is room; or a share 0.38–0.6), and the clip, the totals and the stats shrink to fit under it. A finale without claim checks and with room for its labels renders as before. Re-render a take to see it.
- **An assistant can finish a report video from umtool's command line without hand fixes.** `umtool variants <project> --take <take>` now makes the delivery ladder (master, 1080p, 720p, fit24) of a finished take, and so does the Deliver tab's **Make variants** with a take picked. A take used to be refused with "has no build to make variants of" because its render was moved to `takes/<take>/preview.mp4`; the take maker now also leaves it in the take's `out/` under the build's name (a hard link, so no extra disk), and a take made before this is encoded from its `preview.mp4`. `umtool timeline <project> insert` writes a clip the way the rest of the cut is written: in a cut with the on-screen deck, `--title` sets the deck's title (`onscreen.title`; `--stream-title` sets the stream's), a cut whose deck titles are dates gets `--date` as one in the same format (`9 Dec 2024`), the clip takes the section of the clip it goes after unless `--section N` says otherwise, and `--lock` and `--lock-end` lock its edges. `umtool check` now says how to fix a clip with no cue file: `pnpm ops build-cues --json '{"slug":"<channel>","ids":["<video>"]}' --wait` when the video is in the archive, and the Rumble two-ids check when it is not. A take of part of a cut says in its log what timed the window: the last build's schedule, or the clips' own lengths when there is no schedule or it does not time clips inserted since the build.
- **A streaming channel can fetch its live chats after its downloads, by itself.** A stream's chat replay (7–42 MB) came down with its captions and made each YouTube download 2–4× slower while the Ethanalyzer backlog was archived; the fix was a hand edit of `subLangs` and a hand-written watcher that ran `pnpm ops fetch-chat` per streamed episode once the downloads were done — and died on reboot. Configure → **Live chat replay** (`chat`: with the download, Later or Never): with Later the downloads leave the chat out and, once the channel has nothing left to download, the download lane queues one paced **Fetch chat backlog** job for every stream (by its metadata) whose chat is not here, 25 at a time, skipping what landed and the streams known to have none, and resumed after a restart. The Download stage has the button; `pnpm ops fetch-chat-backlog {slug, dryRun?, limit?}` runs it by hand. **Caption languages** (`subLangs`) is a Configure field and a `channel-config` patch key now. Needs a restart of the editor.
- **What an import adds is work for the lanes at once, not when the import ends.** On 2026-10-26 an archive.org import added 64 recordings over several hours while the channel's report still listed the 32 it had at 01:10; the transcription lane reads its work from that report, so the 64 waited untranscribed and the GPU went to another site's backlog, and `pnpm ops transcribe-bucket` answered "64 of ids not in the downloadedNoTranscript bucket". An archive.org import, an attach of local media and a persist now regenerate the channel's report as items land (the first at once, then at least every 10 items or 2 minutes), and `transcribe-bucket` regenerates a report that is behind the disk before it answers. Needs a restart of the editor.
diff --git a/umtool/docs/knobs.md b/umtool/docs/knobs.md
@@ -145,7 +145,9 @@ box with its title, source line and QR. The deck footer and popup posts are not
| `deck.finale.totals` | bool · `true` — the verdicts' final counts, 128 px | same |
| `deck.finale.stats` | ≤ 8 `{label ≤ 32, value ≤ 16, note? ≤ 60, color?}` (`color`: a `#hex` or `fg` `muted` `accent` `amber`) · none | same |
| `deck.finale.statsTitle` | ≤ 40 characters · none | same |
-| `deck.finale.railLabels` | `all` (each pip's label, its date when the label does not already say it, the markers' labels) · `nodes` (the pips' labels only) · default `all` | same |
+| `deck.finale.railLabels` | `all` (each pip's label, its date when the label does not already say it, the markers' labels) · `nodes` (the pips' labels only) · default `all`. A run of clips with the same label is labelled once; on a crowded rail each label is said once (its longest run) and the turned labels fan out along the rail on thin leaders so no two meet — `all` keeps every distinct date | same |
+| `deck.finale.timelineShare` | `auto` · a number 0.38–0.6 · default `auto`: the timeline (rail, markers, claim checks, labels) takes the height its rows need, from the share it always had (0.415, 448 px of 1080) up to 0.54, and with claim checks to show its words are set as large (up to 1.3×) as that room lets them; the clip shrinks in its aspect and the totals and stats to the column under it. A number: that share of the frame's height. A finale with no claim checks and nothing crowded is laid as it always was | same |
+| `deck.finale.claims` | `rotate` (one claim check at a time — a count claim with its band or spans, a goalpost with its steps — each for an even share of the finale's time once the rail is in place, at least 6 s, with a 0.5 s crossfade, in the order `deck.claims` lists them) · `all` (all at once, stacked in rows) · default `rotate`; one claim, or too little time for 6 s each, stands as `all`. Either way the words, span labels and markers' labels are laid in rows so no two meet, each claim's words at its bracket with its stick (moved inside the bracket, never through other words) | same |
Every key of `deck.finale` goes in one JSON value, e.g.
diff --git a/umtool/report-to-video/chrome-claims.mjs b/umtool/report-to-video/chrome-claims.mjs
@@ -23,6 +23,7 @@
// window -- off the rail's end when that lies past its last date, where
// the new bracket's arrow and its dates stand.
import { MARKER_LABEL_SIZE } from "./deck.mjs";
+import { aboveLine, aboveTop } from "./finale.mjs";
/** The claims' one colour: the alarm red the markers and the Seizures tally use. */
export const CLAIM_RED = "#e5534b";
@@ -248,77 +249,9 @@ export function claimsMarkup(cl, { lay, pal, ground, pipSize }) {
// The finale's large rail (chrome-finale.mjs): every claim's final state.
// ---------------------------------------------------------------------------
-/**
- * The claims on the finale's large rail, frame px: the footer's layout
- * (`fcl`, claimsLayout) mapped onto the large track by `toBig`, around the
- * track at `Y`. Each count claim's band (with the rail dimmed outside it and
- * its record's pips ringed) or its spans, and every goalpost step -- each
- * superseded one dashed, the last solid. Their words stand in rows above the
- * markers' (`markerRows` of them in use), each from `top` down, packed so no
- * two meet: his words, and the record in red.
- *
- * @returns {{ items: any[], rowTops: number[] }}
- */
-export function finaleClaims(fcl, { toBig, Y, top, markerRows = 0, bigX, size, textWidth, ringSize, pips = [] }) {
- const r2 = (v) => Math.round(v * 100) / 100;
- const rowTops = [];
- for (let r = Math.max(1, markerRows); ; r += 1) {
- const t = Y - 72 - 40 * r;
- if (t < top) break;
- rowTops.push(t);
- }
- if (!rowTops.length) rowTops.push(Math.max(top, Y - 112));
- const rows = rowTops.map(() => []);
- const place = (left, width) => {
- const right = left + width;
- for (let r = 0; r < rows.length; r += 1) {
- if (rows[r].every(([a, b]) => right + 24 <= a || left >= b + 24)) { rows[r].push([left, right]); return r; }
- }
- rows[rows.length - 1].push([left, right]);
- return rows.length - 1;
- };
- const words = (said, record, lead = null) => ({
- said, record, ...(lead ? { lead } : {}),
- width: (lead ? textWidth(`${lead} `, size) + 8 : 0) + textWidth(said, size) + (record ? textWidth(` ${record}`, size) + 12 : 0),
- });
- const labels = [];
- const items = fcl.items.map((it, j) => {
- if (it.kind === "count") {
- const band = it.band ? { a: r2(toBig(it.band.a)), b: r2(toBig(it.band.b)) } : null;
- // Dimmed: the track under each veil, and each pip under one as a dot of
- // its own size -- a finale pip's ring (it is playing) stays whole.
- const veils = (it.veils ?? []).map(([a, b]) => [r2(toBig(a)), r2(toBig(b))]);
- const dots = pips.filter((p) => veils.some(([a, b]) => p.x > a && p.x < b)).map((p) => ({ x: p.x, size: p.size + 4 }));
- const rings = it.band ? it.tags.map((t) => ({ x: bigX(t.k), size: ringSize })) : [];
- const spans = (it.spans ?? []).map((sp) => ({
- a: r2(toBig(sp.a)), b: r2(toBig(sp.b)), cx: r2(toBig(sp.cx)), label: sp.label,
- bars: sp.bars.map((bar) => ({ a: r2(toBig(bar.a)), b: r2(toBig(bar.b)) })),
- }));
- const record = it.band ? `${it.total} ${it.noun} on camera` : spans.map((sp) => sp.label).join(" · ") || "none on camera";
- const w = words(it.said, record);
- const left = band ? band.a : spans.length ? spans[0].a : bigX(0);
- // A band's words hang from its left edge; a per claim's from nothing (its spans carry their counts).
- const label = { ...w, left: r2(left), stickX: band ? r2(left + 1) : null, j };
- labels.push(label);
- return { kind: "count", j, band, veils, dots, rings, spans, label };
- }
- const steps = it.steps.map((st, s) => {
- const a = r2(toBig(st.a)), b = r2(toBig(st.b));
- // What it is (the goalpost's `label`) leads its standing step's words.
- const last = s === it.steps.length - 1;
- const w = words(st.said, st.open ? `→ ${st.dueText}` : `· ${st.dueText}`, last && it.label ? `${it.label}:` : null);
- const align = st.align;
- const left = align === "right" ? b - w.width : a;
- const label = { ...w, left: r2(left), stickX: r2(align === "right" ? b - 1 : a + 1), j, s, ghost: s + 1 < it.steps.length };
- labels.push(label);
- return { a, b, open: st.open, off: st.off, ghost: s + 1 < it.steps.length, label };
- });
- return { kind: "goalpost", j, ...(it.label ? { name: it.label } : {}), steps };
- });
- // The words, packed into the rows left to right.
- for (const l of [...labels].sort((x, y) => x.left - y.left)) l.top = rowTops[place(l.left, l.width)];
- return { items, rowTops };
-}
+// The claims' places on the large rail (finaleClaims) are finale.mjs's: the
+// deck's schedule measures the room they need with them (deck.mjs finaleRail).
+export { finaleClaims } from "./finale.mjs";
/**
* The finale's claims as markup and the keys its cues reveal (`fq<j>`, one
@@ -329,11 +262,15 @@ export function finaleClaimsMarkup(fc, { Y, ground, size, pal }) {
const red = CLAIM_RED;
const html = [];
const keys = [];
+ const rowTop = (row) => Y - aboveTop(row, size);
const labelHtml = (l) => {
- const stickTop = l.top + Math.round(size * 1.25);
+ const top = rowTop(l.row);
+ const stickTop = top + Math.round(size * 1.25);
return (
(l.stickX === null ? "" : `<div class="fqstick${l.ghost ? " ghost" : ""}" style="left:${r4(l.stickX - 1)}px; top:${stickTop}px; height:${Math.max(0, Y - 16 - stickTop)}px"></div>`) +
- `<div class="fqlabel${l.ghost ? " ghost" : ""}" style="left:${l.left}px; top:${l.top}px; width:${l.width + 8}px">` +
+ // The words sit at the end of their box their stick is nearer (the box is the measure's generous width).
+ `<div class="fqlabel${l.ghost ? " ghost" : ""}" style="left:${l.left}px; top:${top}px; width:${l.width + 8}px` +
+ `${l.stickX !== null && l.stickX > l.left + (l.width + 8) / 2 ? "; text-align:right" : ""}">` +
(l.lead ? `<span class="fqlead">${esc(l.lead)}</span> ` : "") +
`<span class="fqsaid">${esc(l.said)}</span>${l.record ? ` <span class="fqrec">${esc(l.record)}</span>` : ""}</div>`
);
@@ -343,7 +280,10 @@ export function finaleClaimsMarkup(fc, { Y, ground, size, pal }) {
keys.push(k);
const parts = [];
if (it.kind === "count") {
- if (it.band) parts.push(`<div class="fqband" style="left:${it.band.a}px; width:${r4(it.band.b - it.band.a)}px; top:${Y - 46}px; height:${66}px"></div>`);
+ if (it.band) {
+ const bt = aboveTop(0, size) + 4;
+ parts.push(`<div class="fqband" style="left:${it.band.a}px; width:${r4(it.band.b - it.band.a)}px; top:${Y - bt}px; height:${bt + 20}px"></div>`);
+ }
for (const [a, b] of it.veils) parts.push(`<div class="fqveil" style="left:${a}px; width:${r4(b - a)}px; top:${Y - 4}px; background:${ground}"></div>`);
for (const d of it.dots) {
parts.push(`<div class="fqveil dot" style="left:${r4(d.x - d.size / 2)}px; top:${r4(Y - d.size / 2)}px; width:${d.size}px; height:${d.size}px; background:${ground}"></div>`);
@@ -351,7 +291,14 @@ export function finaleClaimsMarkup(fc, { Y, ground, size, pal }) {
for (const rg of it.rings) parts.push(`<div class="fqring" style="left:${r4(rg.x - rg.size / 2)}px; top:${r4(Y - rg.size / 2)}px; width:${rg.size}px; height:${rg.size}px"></div>`);
for (const sp of it.spans) {
for (const bar of sp.bars) parts.push(`<div class="fqspan" style="left:${bar.a}px; width:${r4(bar.b - bar.a)}px; top:${Y - 7}px"></div>`);
- parts.push(`<div class="fqspl" style="left:${r4(sp.cx - 120)}px; top:${Y - 42}px">${esc(sp.label)}</div>`);
+ // On its bar (row 0), else higher with a leader down to the bar.
+ const top = rowTop(sp.row ?? 0);
+ if ((sp.row ?? 0) > 0) {
+ const from = top + aboveLine(size);
+ parts.push(`<div class="fqstick" style="left:${r4(sp.stickX - 1)}px; top:${from}px; height:${Math.max(0, Y - 9 - from)}px"></div>`);
+ }
+ const bw = Math.max(240, Math.ceil(sp.w ?? 0) + 24);
+ parts.push(`<div class="fqspl" style="left:${r4((sp.left ?? sp.cx - sp.w / 2) + sp.w / 2 - bw / 2)}px; top:${top}px${bw > 240 ? `; width:${bw}px` : ""}">${esc(sp.label)}</div>`);
}
parts.push(labelHtml(it.label));
} else {
diff --git a/umtool/report-to-video/chrome-finale.mjs b/umtool/report-to-video/chrome-finale.mjs
@@ -22,13 +22,11 @@
// in place. Either way the page fades out through the dissolve after the run.
//
// The timeline is cues, each stating its from (chrome-deck.mjs says why).
-import { claimsLayout, deckLayout, deckMarkers, pageDuration, pipSegments, pipXs, resolveDeck } from "./deck.mjs";
-import { finaleClaims, finaleClaimsMarkup } from "./chrome-claims.mjs";
+import { finaleRail, pageDuration, resolveDeck } from "./deck.mjs";
+import { finaleClaimsMarkup } from "./chrome-claims.mjs";
import { mix, rgba, shapeCss, subtitleMarkup } from "./chrome-deck.mjs";
import { resolveFactcheck, tallyFinals, tallyOf, tallyVerdicts, VERDICT_SHAPES } from "./factcheck.mjs";
-import {
- FINALE_MOTION, finaleGeometry, railLabelLayout, railMarkerLayout, resolveFinale, textWidth,
-} from "./finale.mjs";
+import { aboveTop, FINALE_CLAIMS, FINALE_MOTION, finaleGeometry, resolveFinale } from "./finale.mjs";
/** Instant cues still take a millisecond: a zero-duration tween has its own seek rules. */
const INSTANT = 0.001;
@@ -64,55 +62,16 @@ export function finaleLayout(schedule, render) {
const pal = render.palette;
const stamps = schedule.factcheck?.stamps ?? [];
const verdicts = f.totals && stamps.length ? tallyVerdicts(stamps) : [];
- const geo = finaleGeometry(render, { verdicts: verdicts.length, stats: f.stats.length, statsTitle: !!f.statsTitle });
+ // The large rail (deck.mjs finaleRail): in the room the schedule gave it.
+ const R = finaleRail(schedule, render, { railBottom: fin.railBottom ?? finaleGeometry(render).rail.bottom, textScale: fin.textScale ?? 1 });
+ const { geo, x0, labels, marks, claims, lay, fxs, footSize } = R;
const { rail } = geo;
-
- // The footer, as chrome-deck.mjs lays it: where the grow starts.
- const tally = tallyOf(schedule, render);
- const lay = deckLayout(render, { tally, schedule });
const deckY = geo.H - lay.height;
- const pipped = pipSegments(schedule);
- const time = deck.pip.spacing === "time" ? { total: schedule.total, segments: pipped } : null;
- const fxs = pipXs(pipped.length, lay.pipTrack.x0, lay.pipTrack.x1, deck.pip.spacing, time);
- const byVerdict = deck.pip.color === "verdict";
- const footSize = deck.pip.size;
const footV = Math.max(footSize, Math.round((footSize * 5) / 3));
- const bigSize = Math.max(14, Math.round(footSize * 2.5));
- const bigV = Math.round((bigSize * 5) / 3);
-
- // The large rail: the pips across it, then their labels -- and when the
- // labels turn, the track starts far enough in that the first one reads whole.
- const info = pipped.map((s) => ({ label: s.title || fin.dates?.[s.id] || "", date: fin.dates?.[s.id] ?? "" }));
- const dates = f.railLabels === "all";
- let x0 = rail.x0;
- let xs = pipXs(pipped.length, x0, rail.x1, deck.pip.spacing, time);
- let labels = railLabelLayout(xs.map((x, k) => ({ x, ...info[k] })), geo, { dates });
- if (labels.mode === "turned" && labels.groups.length) {
- const g0 = labels.groups[0];
- const w0 = Math.min(320, Math.max(textWidth(g0.label, rail.labelSize), textWidth(g0.date, rail.dateSize, false)));
- const need = Math.round(geo.margin / 2 + w0 * Math.cos((labels.angle * Math.PI) / 180));
- if (need > x0) {
- x0 = Math.min(need, Math.round(geo.W * 0.2));
- xs = pipXs(pipped.length, x0, rail.x1, deck.pip.spacing, time);
- labels = railLabelLayout(xs.map((x, k) => ({ x, ...info[k] })), geo, { dates });
- }
- }
+ const pips = R.pips.map((p, k) => ({ ...p, foot: { x: r2(fxs[k]), size: p.verdict ? footV : footSize } }));
const verdictColors = fc.verdicts;
const finSet = new Set(fin.segments);
- const pips = pipped.map((s, k) => {
- const v = byVerdict && s.claim?.verdict ? s.claim.verdict : null;
- return {
- id: s.id, x: r2(xs[k]), size: v ? bigV : bigSize, ...(v ? { verdict: v, shape: VERDICT_SHAPES[v], color: verdictColors[v]?.color ?? pal.accent } : {}),
- foot: { x: r2(fxs[k]), size: v ? footV : footSize },
- ...(finSet.has(s.id) ? { here: true } : {}),
- };
- });
- // The flags, mapped from the footer's track onto the large one.
- const span = lay.pipTrack.x1 - lay.pipTrack.x0;
- const toBig = (x) => r2(x0 + ((x - lay.pipTrack.x0) * (rail.x1 - x0)) / (span || 1));
- const footMarks = deckMarkers(schedule, render, fxs, pipped, lay);
- const marks = railMarkerLayout(footMarks.map((mk) => ({ x: toBig(mk.x), label: mk.label, color: mk.color })), geo, { layout: deck.markerLayout })
- .map((mk, j) => ({ ...mk, foot: { x: r2(footMarks[j].x) } }));
+ const tally = tallyOf(schedule, render);
// The totals: the tally's verdicts, each at its final count.
const finals = tallyFinals(stamps);
@@ -135,35 +94,12 @@ export function finaleLayout(schedule, render) {
width: S.cardW, height: S.cardH,
}))
: [];
- // The rail's panel ends under its lowest label (inside the rail's region).
- const lineL = Math.round(rail.labelSize * 1.15), lineD = Math.round(rail.dateSize * 1.15);
- const blockOf = (gr) => lineL + (gr.date ? lineD : 0);
- let low = rail.y + 60;
- for (const gr of labels.groups) {
- if (labels.mode === "turned") {
- const a = (labels.angle * Math.PI) / 180;
- const w = Math.min(gr.max, Math.max(textWidth(gr.label, rail.labelSize), textWidth(gr.date, rail.dateSize, false)));
- low = Math.max(low, rail.y + 24 + w * Math.sin(a) + blockOf(gr) * Math.cos(a));
- } else low = Math.max(low, rail.y + 30 + (gr.row + 1) * (blockOf(gr) + 6));
- }
- // What the labels leave of the rail's region, half above the flags and half
- // under the labels: the track moves down by half of it.
- const shift = Math.max(0, Math.floor((rail.bottom - low) / 2));
const panel = { bottom: rail.bottom + 12 };
const segs = schedule.segments.filter((s) => finSet.has(s.id));
const captions = segs.map((s) => ({ id: s.id, start: s.start, title: s.title, subtitle: s.subtitle, qrUrl: s.qrUrl ?? null }));
- // The claim checks (`deck.claims`): the footer's, on the large track, in
- // their final state. None: nothing here.
- const fcl = claimsLayout(schedule, render, fxs, pipped, lay);
- const claims = fcl
- ? finaleClaims(fcl, {
- toBig, Y: rail.y + shift, top: rail.top, markerRows: marks.length ? Math.max(...marks.map((mk) => mk.row)) + 1 : 0,
- bigX: (k) => r2(xs[k]), size: rail.markerSize, textWidth, ringSize: bigSize + 14, pips,
- })
- : null;
return {
geo,
- rail: { ...rail, x0, track: { x0, x1: rail.x1, y: rail.y + shift } },
+ rail: { ...rail, x0, track: { x0, x1: rail.x1, y: R.Y } },
foot: {
y: deckY,
track: { x0: lay.pipTrack.x0, x1: lay.pipTrack.x1, y: deckY + lay.pipTrack.y },
@@ -281,10 +217,24 @@ export function finaleCues(schedule, render, L = finaleLayout(schedule, render))
travel(`mk${j}`, { x: r2(mk.foot.x - mk.x), y: r2(ft.y - bt.y), scale: 0.4 }, "finale marker");
if (L.railLabels === "all") reveal(`ml${j}`, R + j * m.stagger, "finale marker label");
});
- // The claim checks, once the rail is in place.
- (L.claims?.items ?? []).forEach((it, j) => reveal(`fq${it.j}`, R + 0.15 + j * m.stagger, "finale claim"));
+ // The claim checks, once the rail is in place: all at once, or ("rotate")
+ // each in its slot, crossfading into the next at the slot's edge.
+ const rotate = L.claims?.mode === "rotate";
+ const half = FINALE_CLAIMS.fade / 2;
+ (L.claims?.items ?? []).forEach((it, j, all) => {
+ const k = `fq${it.j}`;
+ if (!rotate || j === 0) reveal(k, R + 0.15 + (rotate ? 0 : j * m.stagger), "finale claim");
+ if (!rotate) return;
+ const [a, b] = L.claims.slots[j];
+ if (j > 0) {
+ put(k, { opacity: 0 });
+ add(k, a - half, FINALE_CLAIMS.fade, { opacity: 1 }, "power1.inOut", `finale claim ${j} in`);
+ }
+ if (j < all.length - 1) add(k, b - half, FINALE_CLAIMS.fade, { opacity: 0 }, "power1.inOut", `finale claim ${j} out`);
+ });
L.labels.groups.forEach((g, j) => {
reveal(`pl${j}`, R + 0.05 + j * (m.stagger / 2), "finale label");
+ if (L.labels.lead) reveal(`ld${j}`, R + 0.05 + j * (m.stagger / 2), "finale label");
if (g.to > g.from) reveal(`sp${j}`, R, "finale span");
});
@@ -408,10 +358,25 @@ export function finaleHtml(schedule, render, window, opts = {}) {
const lineL = Math.round(rail.labelSize * 1.15);
const lineD = Math.round(rail.dateSize * 1.15);
const turned = L.labels.mode === "turned";
+ // Fanned labels (finale.mjs railLabelLayout): each joined to its pip, or its
+ // run's middle, by a leader over the band under the track.
+ const lead = turned ? L.labels.lead ?? 0 : 0;
+ const pipHalf = Math.max(0, ...L.pips.map((p) => p.size / 2));
+ const leaderHtml = lead
+ ? L.labels.groups
+ .map((gr, j) => {
+ const y1 = Y + Math.round(pipHalf) + 10, y2 = Y + 24 + lead - 3;
+ const a = Math.min(gr.x, gr.lx) - 2, w = Math.abs(gr.lx - gr.x) + 4;
+ return `<svg class="ld" data-k="ld${j}" style="left:${r2(a)}px; top:${y1}px" width="${r2(w)}" height="${y2 - y1}" viewBox="0 0 ${r2(w)} ${y2 - y1}">` +
+ `<line x1="${r2(gr.x - a)}" y1="0" x2="${r2(gr.lx - a)}" y2="${y2 - y1}"/></svg>`;
+ })
+ .join("")
+ : "";
const labelHtml = L.labels.groups
.map((gr, j) => {
- const top = turned ? Y + 24 : Y + 30 + gr.row * (lineL + (gr.date ? lineD : 0) + 6);
- const left = turned ? gr.x - gr.max : gr.x - gr.max / 2;
+ const top = turned ? Y + 24 + lead : Y + 30 + gr.row * (lineL + (gr.date ? lineD : 0) + 6);
+ const at = gr.lx ?? gr.x;
+ const left = turned ? at - gr.max : at - gr.max / 2;
const style = turned
? `left:${r2(left)}px; top:${top}px; width:${gr.max}px; text-align:right; transform-origin:100% 0; transform:rotate(${-L.labels.angle}deg)`
: `left:${r2(left)}px; top:${top}px; width:${gr.max}px; text-align:center`;
@@ -422,7 +387,7 @@ export function finaleHtml(schedule, render, window, opts = {}) {
})
.join("");
- const rowTop = [Y - 72, Y - 112, Y - 152];
+ const rowTop = [1, 2, 3].map((r) => Y - aboveTop(r, rail.markerSize));
const markHtml = L.marks
.map((mk, j) => {
const top = rowTop[mk.row] ?? rowTop[0];
@@ -532,7 +497,9 @@ export function finaleHtml(schedule, render, window, opts = {}) {
.pll, .pld { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pll { font-family: 'DeckSansBold', sans-serif; font-size: ${rail.labelSize}px; line-height: ${lineL}px; color: ${pal.fg};
text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5); }
- .pld { font-size: ${rail.dateSize}px; line-height: ${lineD}px; color: ${pal.muted}; }
+ .pld { font-size: ${rail.dateSize}px; line-height: ${lineD}px; color: ${pal.muted}; }${lead ? `
+ .ld { position: absolute; overflow: visible; }
+ .ld line { stroke: ${rgba(pal.fg, 0.38)}; stroke-width: 2; stroke-linecap: round; }` : ""}
.mf { position: absolute; width: 0; height: 0; transform-origin: 0 0; }
.ms { position: absolute; left: -2px; width: 4px; border-radius: 2px; background: var(--mc); }
.mh { position: absolute; left: 2px; width: 16px; height: 14px; background: var(--mc); clip-path: polygon(0% 0%, 100% 50%, 0% 100%); }
@@ -582,7 +549,7 @@ export function finaleHtml(schedule, render, window, opts = {}) {
<div class="track" data-k="track"></div>
${L.pips.length > 1 ? `<div class="fuse" data-k="fuse"></div>` : ""}
${spans}${markHtml}${pipHtml}${fq ? fq.html : ""}
- ${labelHtml}
+ ${leaderHtml}${labelHtml}
${totalsHtml}
${statsHtml}
${captionHtml}
diff --git a/umtool/report-to-video/deck.mjs b/umtool/report-to-video/deck.mjs
@@ -20,14 +20,18 @@ import { INTRO_SECONDS } from "yt-dlp-transcript-common/lib/report/intro.mjs";
import { attributionParts, deckSubtitle } from "./attribution.mjs";
import {
- claimOf, marksOf, originalUrlAt, resolveFactcheck, roundStamps, stampSchedule, validateFactcheck,
+ claimOf, marksOf, originalUrlAt, resolveFactcheck, roundStamps, stampSchedule, tallyOf, tallyVerdicts, validateFactcheck,
+ VERDICT_SHAPES,
} from "./factcheck.mjs";
import { threadOf, threadSchedule, threadsOn, validateThreads } from "./threads.mjs";
import { flipSchedule, flipsOn, validateFlips } from "./flips.mjs";
import { overlayPointsOf, resolveStats, statsSchedule, statsWanted, validateStats } from "./stats.mjs";
import { fxOn, fxSchedule, validateFx } from "./fx.mjs";
import { estimatedNarratedCardSeconds, hasNarration } from "./narration.mjs";
-import { FINALE_MOTION, finaleGeometry, finaleRunOf, finaleRunProblems, resolveFinale, validateFinaleSettings } from "./finale.mjs";
+import {
+ aboveTop, FINALE_MOTION, FINALE_SHARE, finaleClaims, finaleClaimSlots, finaleGeometry, finaleRunOf, finaleRunProblems,
+ railLabelLayout, railMarkerLayout, resolveFinale, textWidth as finaleTextWidth, validateFinaleSettings,
+} from "./finale.mjs";
import {
compares, dayOf, dayRange, deckClaimShapeErrors, dueWindow, findSpans, isIsoDate, tallyVerdictOf,
} from "./claims.mjs";
@@ -1178,7 +1182,7 @@ export function deckSchedule({
sourceFrom: (e) => clipClock?.get(e.id) ?? fxClock?.get(e.id) ?? playWindow(e, render).from,
});
const claimClips = deckClaims ? deckClaimClips(render) : new Set();
- return {
+ const doc = {
version: 1,
kind: "deck",
estimated,
@@ -1236,6 +1240,17 @@ export function deckSchedule({
// The claim checks (`deck.claims`): present only when the deck carries one.
...(deckClaims ? { deckClaims } : {}),
};
+ // The finale's timeline, when it needs more of the frame's height than it
+ // always had (finaleRail): its region's bottom, and the clip's smaller box
+ // that leaves -- the footage moves into that one. Otherwise nothing new.
+ const room = doc.finale ? finaleRoom(doc, render) : null;
+ if (room !== null) {
+ const was = doc.finale.box;
+ const box = was ? finaleGeometry(render, { railBottom: room.railBottom }).video : null;
+ doc.finale = { ...doc.finale, box, railBottom: room.railBottom, ...(room.textScale !== 1 ? { textScale: room.textScale } : {}) };
+ if (was && doc.moves) doc.moves = doc.moves.map((m) => (m.to === was ? { ...m, to: box } : m));
+ }
+ return doc;
}
/**
@@ -1546,6 +1561,163 @@ function finaleSchedule({ entries, segs, fin, D, total, render, feed, metas, pro
};
}
+/** The scales the large rail's words may be set at when there are claims to show, largest first. */
+export const FINALE_TEXT_SCALES = Object.freeze([1.3, 1.2, 1.1, 1]);
+
+/**
+ * The finale's large rail, frame px: the pips across it, their labels under
+ * it, the markers flagged over it and the claim checks (`deck.claims`) in
+ * the rows over those -- and how tall it is. THE arithmetic: the schedule
+ * asks it how much of the frame's height the timeline takes (`finaleRoom`),
+ * chrome-finale.mjs draws what it lays, so the clip's box the build moves
+ * the footage into and the page's hole around it are one.
+ *
+ * `railBottom`: the rail region's bottom (the schedule's `finale.railBottom`);
+ * absent, the one `timelineShare` asks for -- "auto": the height the rows
+ * need, from the share the finale always had (FINALE_SHARE.base) up to
+ * FINALE_SHARE.auto; a number: that share of the frame. `textScale`: the
+ * size its words are set at against the design's (the schedule's
+ * `finale.textScale`, else 1); absent with claims to show and no room given,
+ * the largest of FINALE_TEXT_SCALES whose rows fit.
+ */
+export function finaleRail(schedule, render, { railBottom = null, textScale = null } = {}) {
+ const scale = Number.isFinite(textScale) ? textScale : schedule.finale?.textScale ?? null;
+ if (scale !== null) return finaleRailAt(schedule, render, railBottom, scale);
+ // With claims to show, the rail's words are set as large as the room lets
+ // them (FINALE_TEXT_SCALES, largest first): the one whose rows fit the
+ // timeline's most -- FINALE_SHARE.auto, or the share `timelineShare` names.
+ // Without, the size they always had.
+ if (schedule.deckClaims?.items?.length && !Number.isFinite(railBottom)) {
+ const f = resolveFinale(render);
+ const H = render?.height ?? 1080;
+ const most = Math.round(H * (typeof f.timelineShare === "number" ? f.timelineShare : FINALE_SHARE.auto)) - Math.round(36 * (H / 1080));
+ for (const k of FINALE_TEXT_SCALES) {
+ const R = finaleRailAt(schedule, render, null, k);
+ if (R.want <= most || k === 1) return R;
+ }
+ }
+ return finaleRailAt(schedule, render, railBottom, 1);
+}
+
+function finaleRailAt(schedule, render, railBottom, textScale) {
+ const fin = schedule.finale;
+ const f = resolveFinale(render);
+ const deck = resolveDeck(render);
+ const fc = resolveFactcheck(render);
+ const pal = render.palette ?? {};
+ const stamps = schedule.factcheck?.stamps ?? [];
+ const verdicts = f.totals && stamps.length ? tallyVerdicts(stamps) : [];
+ const H = render?.height ?? 1080;
+ const kh = H / 1080;
+ const py = (v) => Math.round(v * kh);
+ const r2 = (v) => Math.round(v * 100) / 100;
+ const geoAt = (B) => finaleGeometry(render, { verdicts: verdicts.length, stats: f.stats.length, statsTitle: !!f.statsTitle, railBottom: B, textScale });
+ const base = geoAt(null);
+ const { rail } = base;
+
+ // The footer, as chrome-deck.mjs lays it: where the grow starts.
+ const tally = tallyOf(schedule, render);
+ const lay = deckLayout(render, { tally, schedule });
+ const pipped = pipSegments(schedule);
+ const time = deck.pip.spacing === "time" ? { total: schedule.total, segments: pipped } : null;
+ const fxs = pipXs(pipped.length, lay.pipTrack.x0, lay.pipTrack.x1, deck.pip.spacing, time);
+ const footSize = deck.pip.size;
+ const bigSize = Math.max(14, Math.round(footSize * 2.5));
+ const bigV = Math.round((bigSize * 5) / 3);
+
+ // The pips across the rail, then their labels -- and when the labels turn,
+ // the track starts far enough in that the first one reads whole.
+ const info = pipped.map((s) => ({ label: s.title || fin.dates?.[s.id] || "", date: fin.dates?.[s.id] ?? "" }));
+ const dates = f.railLabels === "all";
+ const labelsAt = (xs, geo) => railLabelLayout(xs.map((x, k) => ({ x, ...info[k] })), geo, { dates });
+ let x0 = rail.x0;
+ let xs = pipXs(pipped.length, x0, rail.x1, deck.pip.spacing, time);
+ let labels = labelsAt(xs, base);
+ if (labels.mode === "turned" && labels.groups.length) {
+ const g0 = labels.groups[0];
+ const w0 = Math.min(320, Math.max(finaleTextWidth(g0.label, rail.labelSize), finaleTextWidth(g0.date, rail.dateSize, false)));
+ const need = Math.round(base.margin / 2 + w0 * Math.cos((labels.angle * Math.PI) / 180));
+ if (need > x0) {
+ x0 = Math.min(need, Math.round(base.W * 0.2));
+ xs = pipXs(pipped.length, x0, rail.x1, deck.pip.spacing, time);
+ labels = labelsAt(xs, base);
+ }
+ }
+ const byVerdict = deck.pip.color === "verdict";
+ const finSet = new Set(fin.segments);
+ const pips = pipped.map((s, k) => {
+ const v = byVerdict && s.claim?.verdict ? s.claim.verdict : null;
+ return {
+ id: s.id, x: r2(xs[k]), size: v ? bigV : bigSize,
+ ...(v ? { verdict: v, shape: VERDICT_SHAPES[v], color: fc.verdicts[v]?.color ?? pal.accent } : {}),
+ ...(finSet.has(s.id) ? { here: true } : {}),
+ };
+ });
+ // The flags, mapped from the footer's track onto the large one.
+ const span = lay.pipTrack.x1 - lay.pipTrack.x0;
+ const toBig = (x) => r2(x0 + ((x - lay.pipTrack.x0) * (rail.x1 - x0)) / (span || 1));
+ const footMarks = deckMarkers(schedule, render, fxs, pipped, lay);
+ const marks = railMarkerLayout(footMarks.map((mk) => ({ x: toBig(mk.x), label: mk.label, color: mk.color })), base, { layout: deck.markerLayout })
+ .map((mk, j) => ({ ...mk, foot: { x: r2(footMarks[j].x) } }));
+ // The claim checks: in turn or all at once, packed in the rows over the markers'.
+ const fcl = claimsLayout(schedule, render, fxs, pipped, lay);
+ const slots = fcl ? finaleClaimSlots(fin, fcl.items.length, f.claims) : null;
+ const claims = fcl
+ ? {
+ ...finaleClaims(fcl, {
+ toBig, bigX: (k) => r2(xs[k]), size: rail.markerSize, ringSize: bigSize + 14, pips, marks,
+ markerLabels: f.railLabels === "all", W: base.W, margin: base.margin, mode: slots.mode,
+ }),
+ slots: slots.slots,
+ }
+ : null;
+
+ // How tall: the track sits under the rows over it (the claims' and the
+ // markers' -- without claims, where it always sat), the labels hang under it.
+ const Yneed = claims ? Math.max(rail.y, rail.top + aboveTop(claims.rows - 1, rail.markerSize)) : rail.y;
+ const lineL = Math.round(rail.labelSize * 1.15), lineD = Math.round(rail.dateSize * 1.15);
+ const blockOf = (gr) => lineL + (gr.date ? lineD : 0);
+ const lowOf = (lb, Y, natural) => {
+ let low = Y + 60;
+ for (const gr of lb.groups) {
+ if (lb.mode === "turned") {
+ const a = (lb.angle * Math.PI) / 180;
+ const nat = Math.max(finaleTextWidth(gr.label, rail.labelSize), finaleTextWidth(gr.date, rail.dateSize, false));
+ const w = natural ? nat : Math.min(gr.max, nat);
+ low = Math.max(low, Y + 24 + (lb.lead ?? 0) + w * Math.sin(a) + blockOf(gr) * Math.cos(a));
+ } else low = Math.max(low, Y + 30 + (gr.row + 1) * (blockOf(gr) + 6));
+ }
+ return low;
+ };
+ // The room they would take, and the room they get: the schedule's, else
+ // the share `timelineShare` names, else ("auto") what they take, from the
+ // share the finale always had up to FINALE_SHARE.auto.
+ const want = Math.ceil(lowOf(labels, Yneed, true) + py(24));
+ let B = Number.isFinite(railBottom) ? Math.round(railBottom) : null;
+ if (B === null) {
+ if (typeof f.timelineShare === "number") B = Math.round(H * f.timelineShare) - py(36);
+ else B = Math.max(rail.bottom, Math.min(Math.round(H * FINALE_SHARE.auto) - py(36), want));
+ }
+ const geo = B === rail.bottom ? base : geoAt(B);
+ // The labels again, cut to the room under the track; the track moves down
+ // by half of what they leave.
+ labels = labelsAt(xs, { ...geo, rail: { ...geo.rail, y: Yneed } });
+ const low = lowOf(labels, Yneed, false);
+ const Y = Yneed + Math.max(0, Math.floor((B - low) / 2));
+ return { geo, x0, xs, pips, labels, marks, claims, Y, railBottom: B, want, textScale, lay, fxs, pipped, bigSize, bigV, footSize };
+}
+
+/**
+ * The room the finale's page needs (finaleRail's): the rail region's bottom
+ * and the scale its words are set at, when they are not what they always
+ * were -- else null, and the schedule says nothing new.
+ */
+export function finaleRoom(schedule, render) {
+ if (!schedule?.finale) return null;
+ const { railBottom, textScale } = finaleRail(schedule, render);
+ return railBottom === finaleGeometry(render).rail.bottom && textScale === 1 ? null : { railBottom, textScale };
+}
+
/**
* `postSchedule`'s placements as a schedule writes them: their seconds to the
* millisecond -- a popup's `appear` and `out`, a feed's `in`. umtool's preview
diff --git a/umtool/report-to-video/finale-room.test.mjs b/umtool/report-to-video/finale-room.test.mjs
@@ -0,0 +1,264 @@
+// The finale's room (finale.mjs, deck.mjs finaleRail, chrome-finale.mjs): the
+// timeline taking the height its rows need (`timelineShare`), the claim
+// checks' words, span labels and the markers' laid so no two meet, the rail's
+// date labels said once and fanned with leaders when crowded, and the claims
+// standing in turn (`claims: "rotate"`) -- every cue stating its from.
+//
+// Run with: node --test finale-room.test.mjs
+import assert from "node:assert/strict";
+import test from "node:test";
+
+import { deckSchedule, estimateSchedule, finaleRail, snapWindow } from "./deck.mjs";
+import { finaleCues, finaleHtml, finaleLayout } from "./chrome-finale.mjs";
+import {
+ aboveLine, aboveTop, FINALE_CLAIMS, FINALE_SHARE, fanSlots, finaleClaimSlots, finaleGeometry, placeAbove, aboveRows,
+ railLabelLayout, textWidth, validateFinaleSettings,
+} from "./finale.mjs";
+
+const PALETTE = { bg: "#101219", fg: "#f2f0ea", muted: "#979caa", accent: "#e5534b", amber: "#ffc860" };
+const SEIZURES = { verdicts: { CORROBORATED: { label: "Seizures", color: "#e5534b", stampLabel: "Seizure" } } };
+
+// The Huck walked cut in small (deck-claims.test.mjs's): dated clips in the
+// cut's order, his two count claims in one late clip, a goalpost, a marker.
+const CLIPS = [
+ ["arrive", "20201024"], ["meds", "20250514"], ["neuro", "20251106"], ["worst", "20260120", 1, "2026-01-19"],
+ ["dozen", "20260824", 12, "2026-08-24"], ["ten-k", "20260826"], ["flash", "20261016"], ["rescue", "20260908", 1, "2026-09-08"],
+ ["pill-test", "20260923"], ["costco-ok", "20261008", 1, "2026-09-22"], ["on-stream-b", "20261014", 3, "2026-10-14"],
+ ["screenshot", "20261015"], ["blind-oct", "20261020", 1, "2026-10-20"], ["quality", "20261021"], ["less-than-ten", "20261022"],
+ ["blend", "20261022"], ["tism", "20190613"], ["heartstrings", "20210408"],
+];
+const entries = (finale = ["heartstrings"]) => CLIPS.map(([id, , count, eventDate], i) => ({
+ type: "clip", id, video: `v${i}`, start: 100 * i, end: 100 * i + 30,
+ ...(count ? { claim: { id, verdict: "CORROBORATED", at: 100 * i + 10, ...(count > 1 ? { count } : {}), eventDate } } : {}),
+ ...(finale.includes(id) ? { layout: "finale" } : {}),
+}));
+const metas = () => CLIPS.map(([, up]) => ({ title: "T", uploadDate: up, channel: "C", webpageUrl: null }));
+const CLAIMS = [
+ { kind: "count", at: "less-than-ten", t: 1405, said: "“doesn't have multiple seizures a week”", window: { from: "2025-10-22", to: "2026-10-22" },
+ tally: "Seizures", per: "P1W", claim: { op: "<", value: 2 } },
+ { kind: "count", at: "less-than-ten", t: 1410, said: "“less than ten” in a year", window: { from: "2025-10-22", to: "2026-10-22" },
+ tally: "Seizures", claim: { op: "<", value: 10 } },
+ { kind: "goalpost", label: "Pill test results", steps: [
+ { at: "pill-test", t: 815, said: "“3–5 weeks”", from: "2026-09-23", due: ["P3W", "P5W"] },
+ { at: "screenshot", t: 1112, said: "“6–8 weeks”", from: "2026-10-15", due: ["P6W", "P8W"] },
+ ] },
+];
+const MARKERS = [
+ { after: "quality", label: "No results after 8 wks", color: "#e5534b" },
+ { after: "blend", label: "MRI + neurologist Mon 26", color: "#e3b23c" },
+];
+const renderWith = (deck = {}, finale = {}) => ({
+ width: 1920, height: 1080, fps: 30, transition: 0.5, palette: PALETTE,
+ chrome: {
+ engine: "hyperframes", layout: "deck",
+ deck: { pip: { color: "verdict" }, markers: MARKERS, finale: { video: "side", ...finale }, ...deck },
+ factcheck: SEIZURES,
+ },
+});
+const PROV = { siteOrigin: "https://example.test", channelSlug: "c" };
+// The finale run: its last three clips, each `secs` long (time for the claims to take turns, or not).
+const built = (render, { secs = 30, finale = ["blend", "tism", "heartstrings"] } = {}) => {
+ const es = entries(finale);
+ return deckSchedule({ entries: es, durs: es.map((e) => (finale.includes(e.id) ? secs : 30)), D: 0.5, render, metas: metas(), provenance: PROV });
+};
+
+/** Each label's box on its row, for overlap checks: [row, left, right]. */
+function claimBoxes(claims) {
+ const out = [];
+ for (const it of claims.items) {
+ for (const sp of it.spans ?? []) out.push({ who: sp.label, it: it.j, row: sp.row, a: sp.left, b: sp.left + sp.w, stickX: sp.row > 0 ? sp.stickX : null });
+ const ls = it.kind === "count" ? [it.label] : it.steps.map((st) => st.label);
+ for (const l of ls) out.push({ who: l.said, it: it.j, row: l.row, a: l.left, b: l.left + l.width + 8, stickX: l.stickX });
+ }
+ return out;
+}
+const markerBoxes = (marks) => marks.map((mk) => ({
+ who: mk.label, row: mk.row + 1, a: mk.side === "left" ? mk.x - 18 - mk.max : mk.x, b: mk.side === "left" ? mk.x : mk.x + 18 + mk.max, stickX: mk.x,
+}));
+/** No two boxes in one row meet; no stick rises through a box in a row under its own. */
+function assertNoneMeet(boxes, why) {
+ for (let i = 0; i < boxes.length; i += 1) {
+ for (let j = i + 1; j < boxes.length; j += 1) {
+ const p = boxes[i], q = boxes[j];
+ if (p.row === q.row) assert.ok(p.b <= q.a || q.b <= p.a, `${why}: "${p.who}" and "${q.who}" meet in row ${p.row}`);
+ }
+ }
+ for (const p of boxes) {
+ if (p.stickX === null || p.stickX === undefined) continue;
+ for (const q of boxes) {
+ if (q === p || q.row >= p.row) continue;
+ assert.ok(p.stickX < q.a || p.stickX > q.b, `${why}: the stick of "${p.who}" (row ${p.row}) crosses "${q.who}" (row ${q.row})`);
+ }
+ }
+}
+
+/** A key's value at cut second t, from the cues (linear inside a tween: enough to say on or off mid-slot). */
+function valueAt({ init, cues }, k, prop, t) {
+ let v = init[k]?.[prop] ?? 1;
+ for (const c of cues) {
+ if (c.k !== k || !(prop in c.to) || c.at > t) continue;
+ const p = c.dur > 0 ? Math.min(1, (t - c.at) / c.dur) : 1;
+ v = c.from[prop] + (c.to[prop] - c.from[prop]) * p;
+ }
+ return v;
+}
+
+test("deck.finale.timelineShare and .claims: validated, defaults auto and rotate", () => {
+ assert.deepEqual(validateFinaleSettings({ timelineShare: "auto", claims: "all" }), []);
+ assert.deepEqual(validateFinaleSettings({ timelineShare: 0.5, claims: "rotate" }), []);
+ const bad = validateFinaleSettings({ timelineShare: 0.9, claims: "cycle" });
+ assert.ok(bad.some((e) => e.startsWith("render.chrome.deck.finale.timelineShare must be \"auto\" or a number from 0.38 to 0.6")), bad.join("\n"));
+ assert.ok(bad.includes('render.chrome.deck.finale.claims must be "rotate", "all"'), bad.join("\n"));
+ assert.deepEqual(validateFinaleSettings({ timelineShare: "half" }).length, 1);
+});
+
+test("geometry: a taller rail shrinks the clip in its aspect and the panels to the column; the default is as it was", () => {
+ const r = renderWith({}, { stats: [{ label: "a", value: "1" }, { label: "b", value: "2" }, { label: "c", value: "3" }, { label: "d", value: "4" }], statsTitle: "T" });
+ const was = finaleGeometry(r, { verdicts: 2, stats: 4, statsTitle: true });
+ assert.deepEqual(was.video, { x: 1104, y: 448, width: 768, height: 432 });
+ assert.equal(was.totals.height, 236);
+ for (const B of [520, 560, Math.round(1080 * FINALE_SHARE.max) - 36]) {
+ for (const video of ["side", "corner", "hidden"]) {
+ const g = finaleGeometry(renderWith({}, { video }), { verdicts: 2, stats: 4, statsTitle: true, railBottom: B });
+ assert.equal(g.rail.bottom, B);
+ if (g.video) {
+ assert.ok(g.video.width < was.video.width || video !== "side", `${video} @${B}: ${g.video.width}`);
+ assert.ok(Math.abs(g.video.width / g.video.height - 16 / 9) < 0.02, `${video} @${B}: the clip keeps its aspect`);
+ assert.ok(g.qr.size >= 96, `${video} @${B}: QR ${g.qr.size}`);
+ }
+ for (const box of [g.totals, g.video, { ...g.qr, width: g.qr.size, height: g.qr.size }].filter(Boolean)) {
+ assert.ok(box.y >= B && box.y + box.height <= 1080 && box.x >= 0 && box.x + box.width <= 1920, `${video} @${B}: ${JSON.stringify(box)}`);
+ }
+ assert.ok(g.totals.numberSize >= 96);
+ assert.ok(g.stats.cardH >= 100, `${video} @${B}: cards ${g.stats.cardH} px`);
+ assert.ok(g.stats.y + g.stats.titleH + g.stats.rows * g.stats.cardH + (g.stats.rows - 1) * g.stats.gap <= 1080 - 36);
+ }
+ }
+});
+
+test("rail labels: a crowded rail says each date once and fans them -- no two meet, each joined to its pip", () => {
+ const g = finaleGeometry(renderWith());
+ // 40 pips 28 px apart, dates repeating in runs and out of order (a cut is not a calendar).
+ const days = ["24 Aug", "24 Aug", "25 Aug", "26 Aug", "26 Aug", "26 Aug", "25 Aug", "27 Aug", "22 Oct", "21 Oct", "22 Oct", "22 Oct"];
+ const pips = Array.from({ length: 40 }, (_, i) => ({ x: 120 + i * 28, label: `${days[i % days.length]} 2026` }));
+ const lb = railLabelLayout(pips, g);
+ assert.equal(lb.mode, "turned");
+ const labels = lb.groups.map((gr) => gr.label);
+ assert.equal(new Set(labels).size, labels.length, "each date once");
+ assert.deepEqual(new Set(labels), new Set(pips.map((p) => p.label)), "every distinct date kept");
+ const sin = Math.sin((lb.angle * Math.PI) / 180);
+ const block = Math.round(g.rail.labelSize * 1.15);
+ for (let j = 1; j < lb.groups.length; j += 1) {
+ assert.ok((lb.groups[j].lx - lb.groups[j - 1].lx) * sin >= block, `labels ${j - 1} and ${j} meet`);
+ }
+ assert.ok(lb.lead > 0, "a leader band under the track");
+ for (const gr of lb.groups) assert.ok(gr.lx >= gr.x - 0.01 || gr.lx >= lb.groups[0].x, "slots never before the rail");
+ // The page draws a leader per label.
+ // Uncrowded: as it was -- no slots moved, no leaders.
+ const few = railLabelLayout(Array.from({ length: 12 }, (_, i) => ({ x: 160 + i * 130, label: `${i + 1} Oct 2026` })), g);
+ assert.ok(few.groups.every((gr) => (gr.lx ?? gr.x) === gr.x) && !few.lead);
+ // fanSlots: least movement, the pitch kept, inside its bounds.
+ const s = fanSlots([100, 101, 102, 400], 40, 90, 1000);
+ assert.deepEqual(s.map(Math.round), [90, 130, 170, 400]);
+ assert.deepEqual(fanSlots([500, 990, 995], 40, 0, 1000).map(Math.round), [500, 960, 1000]);
+});
+
+test("the claims' words, span labels and the markers' never meet -- rotate and all", () => {
+ for (const claims of ["rotate", "all"]) {
+ const r = renderWith({ claims: CLAIMS }, { claims });
+ const s = built(r);
+ const R = finaleRail(s, r, { railBottom: s.finale.railBottom, textScale: s.finale.textScale ?? 1 });
+ assert.equal(R.claims.mode, claims);
+ const marks = markerBoxes(R.marks);
+ if (claims === "rotate") for (const it of R.claims.items) assertNoneMeet([...marks, ...claimBoxes({ items: [it] })], `rotate, claim ${it.j}`);
+ else assertNoneMeet([...marks, ...claimBoxes(R.claims)], "all");
+ // Every word on the frame; claims' words above the markers' rows.
+ const markerTop = Math.max(...R.marks.map((mk) => mk.row + 1));
+ for (const b of claimBoxes(R.claims)) {
+ assert.ok(b.a >= 0 && b.b <= 1920, `${b.who} off the frame`);
+ if (!/^\d+ in a/.test(b.who)) assert.ok(b.row > markerTop, `${b.who} in row ${b.row}, under the markers' ${markerTop}`);
+ }
+ // Every row's words inside the rail's region.
+ const topRow = Math.max(...claimBoxes(R.claims).map((b) => b.row));
+ assert.ok(R.Y - aboveTop(topRow, R.geo.rail.markerSize) >= R.geo.rail.top - 12, `${claims}: row ${topRow} over the panel`);
+ }
+});
+
+test("the timeline takes the room its rows need: the schedule's railBottom, the clip's smaller box, the footage moved into it", () => {
+ const r = renderWith({ claims: CLAIMS });
+ const s = built(r);
+ const f = s.finale;
+ assert.ok(f.railBottom > 412 && f.railBottom <= Math.round(1080 * FINALE_SHARE.auto) - 36, `railBottom ${f.railBottom}`);
+ const g = finaleGeometry(r, { railBottom: f.railBottom });
+ assert.deepEqual(f.box, g.video);
+ assert.ok(f.box.width < 768);
+ for (const mv of s.moves.filter((m) => f.segments.includes(m.segment))) assert.deepEqual(mv.to, f.box);
+ // The page draws its hole where the schedule says, and the rail's panel to its bottom.
+ const L = finaleLayout(s, r);
+ assert.deepEqual(L.box, f.box);
+ assert.equal(L.panel.bottom, f.railBottom + 12);
+ // An estimate (umtool's preview) says the same.
+ const est = estimateSchedule({ timeline: entries(["blend", "tism", "heartstrings"]), render: r, provenance: PROV }, { metas: metas() });
+ assert.ok(est.finale.railBottom > 412);
+ // A number: that share, needed or not.
+ const half = built(renderWith({ claims: CLAIMS }, { timelineShare: 0.5 })).finale;
+ assert.equal(half.railBottom, 540 - 36);
+ // No claims and nothing crowded: no new keys, the box it always had.
+ const plain = built(renderWith()).finale;
+ assert.ok(!("railBottom" in plain) && !("textScale" in plain));
+ assert.deepEqual(plain.box, { x: 1104, y: 448, width: 768, height: 432 });
+});
+
+test("claims: rotate gives each an even share of the page's time, crossfading; too little time and they stand together", () => {
+ const fin = { at: 100, grow: 0.8, to: 160 };
+ const rot = finaleClaimSlots(fin, 3, "rotate");
+ assert.equal(rot.mode, "rotate");
+ assert.deepEqual(rot.slots, [[100.8, 120.533], [120.533, 140.267], [140.267, 160]]);
+ assert.equal(finaleClaimSlots(fin, 1, "rotate").mode, "all", "one claim stands alone");
+ assert.equal(finaleClaimSlots(fin, 3, "all").mode, "all");
+ assert.equal(finaleClaimSlots({ at: 100, grow: 0.8, to: 110 }, 3, "rotate").mode, "all", `under ${FINALE_CLAIMS.minHold} s each`);
+ assert.equal(finaleClaimSlots({ at: 100, grow: 0, to: 200, out: [130, 130.5] }, 4, "rotate").mode, "rotate", "to the run's end, not the window's");
+
+ const r = renderWith({ claims: CLAIMS });
+ const s = built(r);
+ const L = finaleLayout(s, r);
+ assert.equal(L.claims.mode, "rotate");
+ const cued = finaleCues(s, r, L);
+ assert.ok(cued.cues.every((c) => Object.keys(c.to).every((p) => p in c.from)), "every cue states its from");
+ // Mid-slot, its claim alone stands; the rail's labels and markers stand throughout.
+ L.claims.slots.forEach(([a, b], j) => {
+ const mid = (a + b) / 2;
+ L.claims.items.forEach((it, i) => {
+ assert.equal(Math.round(valueAt(cued, `fq${it.j}`, "opacity", mid)), i === j ? 1 : 0, `slot ${j}: fq${it.j}`);
+ });
+ assert.equal(valueAt(cued, "pl0", "opacity", mid), 1);
+ });
+ // The last holds to the end.
+ const last = L.claims.items[L.claims.items.length - 1];
+ assert.equal(valueAt(cued, `fq${last.j}`, "opacity", s.finale.to - 0.01), 1);
+ // A short run: they stand together, the rows packed for all of them.
+ const short = built(r, { secs: 6 });
+ assert.equal(finaleLayout(short, r).claims.mode, "all");
+ // The page renders each claim's group once.
+ const html = finaleHtml(s, r, snapWindow({ segment: "finale", from: s.finale.from, to: s.finale.to }, { fps: 30, total: s.total }), {});
+ for (const it of L.claims.items) assert.equal((html.match(new RegExp(`data-k="fq${it.j}"`, "g")) ?? []).length, 1);
+});
+
+test("placeAbove: a label slides along its row, or rises with its stick kept in its bracket and clear of what is under it", () => {
+ const geo = { W: 1920, margin: 48 };
+ const rows = aboveRows([{ x: 1060, row: 0, side: "right", max: 300 }]);
+ // A span label at 990 would meet the marker's stick in row 0: slid along it.
+ const sp = placeAbove(rows, { w: 160, left: 910, align: "center", stick: { x: 990, a: 990, b: 990 }, minRow: 0, stickFrom: 1 }, geo);
+ assert.equal(sp.row, 0);
+ assert.ok(sp.left + 160 + 12 <= 1057, JSON.stringify(sp));
+ assert.ok(sp.left <= 990 && sp.left + 160 >= 990, "still over its point");
+ // Words whose stick would rise through the marker's label: the stick moves inside the bracket.
+ const w = placeAbove(rows, { w: 400, left: 1100, align: "left", stick: { x: 1101, a: 900, b: 1500 }, minRow: 2, stickFrom: 0 }, geo);
+ assert.ok(w.row >= 2);
+ assert.ok(w.stickX < 1060 - 8 || w.stickX > 1378 + 8, JSON.stringify(w));
+ assert.ok(w.stickX >= w.left && w.stickX <= w.left + 400);
+ assert.equal(aboveTop(0), 42);
+ assert.deepEqual([1, 2, 3].map((r) => aboveTop(r)), [72, 112, 152], "the markers' rows where they always were");
+ assert.equal(aboveLine(), 30);
+ assert.ok(textWidth("x", 24) > 0);
+});
diff --git a/umtool/report-to-video/finale.mjs b/umtool/report-to-video/finale.mjs
@@ -9,7 +9,16 @@
// "stats": [{ "label", "value", "note"?, "color"? }], up to 8, the author's words
// "statsTitle": "…", over the stats (optional)
// "railLabels": "all" | "nodes" every label and date and the markers' labels,
-// } or each pip's label alone (default "all")
+// or each pip's label alone (default "all")
+// "timelineShare": "auto" | 0.38–0.6 how much of the frame's height the timeline takes:
+// "auto" (the default) the height its rows need, from
+// the share it always had up to FINALE_SHARE.auto;
+// a number, that share of the frame, needed or not
+// "claims": "rotate" | "all" the claim checks (deck.claims) on the large rail:
+// one at a time, each for an even share of the page's
+// time (default "rotate"; all at once when there is
+// one, or too little time for FINALE_CLAIMS.minHold)
+// }
//
// While a finale entry plays, the footer's rail is redrawn large across the
// top of the frame (every pip lit, the whole history), the totals panel and
@@ -37,6 +46,24 @@ export const FINALE_MOTIONS = Object.freeze(["grow", "cut"]);
/** What the large rail labels: everything (labels, dates, markers) or the pips' labels only. */
export const FINALE_RAIL_LABELS = Object.freeze(["all", "nodes"]);
+/** How the claim checks stand on the large rail: one at a time in turn, or all at once. */
+export const FINALE_CLAIM_MODES = Object.freeze(["rotate", "all"]);
+
+/**
+ * The timeline's share of the frame's height (the rail's region and the gap
+ * under it, from the frame's top to the lower area): `base` is the share it
+ * always had (448 of 1080 px), `auto` the most "auto" grows it to, `min` and
+ * `max` what a number may say.
+ */
+export const FINALE_SHARE = Object.freeze({ base: 448 / 1080, auto: 0.54, min: 0.38, max: 0.6 });
+
+/**
+ * "rotate": each claim stands for an even share of the page's time once the
+ * rail is in place, at least `minHold` seconds, with a `fade`-second crossfade
+ * between them; less time than that for each, and they stand all at once.
+ */
+export const FINALE_CLAIMS = Object.freeze({ minHold: 6, fade: 0.5 });
+
/** The palette keys a stat's `color` may name (else a `#rgb` / `#rrggbb`). */
export const FINALE_PALETTE_KEYS = Object.freeze(["fg", "muted", "accent", "amber"]);
@@ -51,6 +78,8 @@ export const FINALE_DEFAULTS = Object.freeze({
stats: Object.freeze([]),
statsTitle: null,
railLabels: "all",
+ timelineShare: "auto",
+ claims: "rotate",
});
/**
@@ -97,6 +126,11 @@ export function validateFinaleSettings(f, where = "render.chrome.deck.finale") {
oneOf("video", FINALE_VIDEOS);
oneOf("motion", FINALE_MOTIONS);
oneOf("railLabels", FINALE_RAIL_LABELS);
+ oneOf("claims", FINALE_CLAIM_MODES);
+ if (f.timelineShare !== undefined && f.timelineShare !== "auto" &&
+ !(typeof f.timelineShare === "number" && f.timelineShare >= FINALE_SHARE.min && f.timelineShare <= FINALE_SHARE.max)) {
+ errors.push(`${where}.timelineShare must be "auto" or a number from ${FINALE_SHARE.min} to ${FINALE_SHARE.max} (the frame's height the timeline takes)`);
+ }
if (f.totals !== undefined && typeof f.totals !== "boolean") errors.push(`${where}.totals must be true or false`);
if (f.statsTitle !== undefined && f.statsTitle !== null) {
const p = lineProblem(f.statsTitle, FINALE_LIMITS.statsTitle, `${where}.statsTitle`);
@@ -242,16 +276,21 @@ export function textWidth(text, size, bold = true) {
/**
* Where everything sits in the finale's frame, px. `verdicts` is how many
- * cells the totals panel has (0: none), `stats` how many cards.
+ * cells the totals panel has (0: none), `stats` how many cards, `railBottom`
+ * where the rail's region ends (the schedule's `finale.railBottom`, which
+ * `finaleRailBottom` decides; default 412 at 1080p -- the timeline's share as
+ * it always was).
*
- * At 1920×1080: the rail across the top (y 36–412, the track at `rail.y`);
- * under it the lower area (y 448–1044). "side": the clip 768×432 at the
- * right (40 % of the width), its caption under it with the QR at its end;
- * the totals and stats in the left column (1008 wide). "corner": the clip
- * 538×302 (28 %) in the bottom-right corner over its caption; the column
- * 1238 wide. "hidden": no box; the caption and QR at the top of a right
- * column, the left as in "corner". The totals' numbers are 128 px (≥ 96),
- * the rail's labels 28 px and its dates 24.
+ * At 1920×1080 and the default: the rail across the top (y 36–412, the track
+ * at `rail.y`); under it the lower area (y 448–1044). "side": the clip 768×432
+ * at the right (40 % of the width), its caption under it with the QR at its
+ * end; the totals and stats in the left column (1008 wide). "corner": the clip
+ * 538×302 (28 %) in the bottom-right corner over its caption; the column 1238
+ * wide. "hidden": no box; the caption and QR at the top of a right column, the
+ * left as in "corner". The totals' numbers are 128 px (≥ 96), the rail's
+ * labels 28 px and its dates 24. A taller rail shrinks the lower area: the
+ * clip keeps its aspect and shrinks to fit over its caption and a QR of at
+ * least 96 px, the totals and the cards to the column's height.
*
* @returns {{ W: number, H: number, k: number, margin: number,
* rail: { top: number, bottom: number, y: number, x0: number, x1: number, labelSize: number, dateSize: number, markerSize: number },
@@ -263,7 +302,7 @@ export function textWidth(text, size, bold = true) {
* cols: number, rows: number, cardW: number, cardH: number, gap: number, valueSize: number, labelSize: number, noteSize: number } | null,
* column: { x: number, y: number, width: number, height: number } }}
*/
-export function finaleGeometry(render, { verdicts = 0, stats = 0, statsTitle = false } = {}) {
+export function finaleGeometry(render, { verdicts = 0, stats = 0, statsTitle = false, railBottom = null, textScale = 1 } = {}) {
const W = render?.width ?? 1920;
const H = render?.height ?? 1080;
const k = W / 1920;
@@ -272,13 +311,14 @@ export function finaleGeometry(render, { verdicts = 0, stats = 0, statsTitle = f
const py = (v) => Math.round(v * kh);
const m = px(48);
const f = resolveFinale(render);
+ const bottom = Number.isFinite(railBottom) ? Math.round(railBottom) : py(412);
const rail = {
- top: py(36), bottom: py(412), y: py(176),
+ top: py(36), bottom, y: py(176),
x0: px(120), x1: W - px(96),
- labelSize: Math.max(FINALE_MIN.railLabel, px(28)), dateSize: Math.max(FINALE_MIN.railLabel, px(24)),
- markerSize: Math.max(FINALE_MIN.railLabel, px(24)),
+ labelSize: Math.max(FINALE_MIN.railLabel, px(28 * textScale)), dateSize: Math.max(FINALE_MIN.railLabel, px(24 * textScale)),
+ markerSize: Math.max(FINALE_MIN.railLabel, px(24 * textScale)),
};
- const lowTop = py(448);
+ const lowTop = bottom + py(36);
const lowBottom = H - py(36);
let video = null;
let caption;
@@ -287,15 +327,18 @@ export function finaleGeometry(render, { verdicts = 0, stats = 0, statsTitle = f
const capTitle = px(34), capSub = Math.max(20, px(24));
const capH = Math.round(capTitle * 1.2) + Math.round(capSub * 1.3) + py(8);
if (f.video === "side") {
- const vw = even(W * 0.4), vh = even((vw * H) / W);
+ // 40 % of the width -- or, under a taller rail, what fits over the caption and a 96 px QR.
+ const room = lowBottom - lowTop - py(14) - Math.max(capH, px(96));
+ const vw = Math.min(even(W * 0.4), even((room * W) / H)), vh = even((vw * H) / W);
video = { x: W - m - vw, y: lowTop, width: vw, height: vh };
const size = Math.min(px(112), lowBottom - (video.y + vh + py(14)));
qr = { x: video.x + vw - size, y: video.y + vh + py(14), size };
caption = { x: video.x, y: video.y + vh + py(14), width: vw - size - px(20), titleSize: capTitle, subSize: capSub };
colRight = video.x - m;
} else if (f.video === "corner") {
- const vw = even(W * 0.28), vh = even((vw * H) / W);
const size = px(96);
+ const room = lowBottom - size - py(12) - lowTop;
+ const vw = Math.min(even(W * 0.28), even((room * W) / H)), vh = even((vw * H) / W);
video = { x: W - m - vw, y: lowBottom - size - py(12) - vh, width: vw, height: vh };
qr = { x: video.x + vw - size, y: lowBottom - size, size };
caption = { x: video.x, y: lowBottom - size, width: vw - size - px(16), titleSize: capTitle, subSize: capSub };
@@ -310,10 +353,17 @@ export function finaleGeometry(render, { verdicts = 0, stats = 0, statsTitle = f
const column = { x: m, y: lowTop, width: colRight - m, height: lowBottom - lowTop };
let totals = null;
let y = lowTop;
+ const twoRows = (verdicts > 0 ? py(150) + py(28) : 0) + (statsTitle ? Math.round(Math.max(22, px(28)) * 1.5) : 0) + 2 * py(124) + px(16);
if (verdicts > 0) {
const gap = px(20);
const cell = Math.min(px(320), Math.floor((column.width - (verdicts - 1) * gap) / verdicts));
- const height = stats > 0 ? py(236) : Math.min(py(320), column.height);
+ // 236 px over the stats -- in a shorter column what the cards leave (each
+ // at least 124 px), never under 150 -- else up to 320.
+ const sRows = statsGrid(stats, column, twoRows).rows;
+ const sNeed = (statsTitle ? Math.round(Math.max(22, px(28)) * 1.5) : 0) + sRows * py(124) + (sRows - 1) * px(16);
+ const height = stats > 0
+ ? Math.min(py(236), Math.max(py(150), column.height - py(28) - sNeed))
+ : Math.min(py(320), column.height);
totals = {
x: column.x, y, width: verdicts * cell + (verdicts - 1) * gap, height, cell, gap,
numberSize: Math.max(FINALE_MIN.totals, Math.round(Math.min(height * 0.54, cell * 0.62))),
@@ -326,9 +376,7 @@ export function finaleGeometry(render, { verdicts = 0, stats = 0, statsTitle = f
const titleSize = Math.max(22, px(28));
const titleH = statsTitle ? Math.round(titleSize * 1.5) : 0;
const height = lowBottom - y;
- // Up to three in a row; four as two by two; then three or four to a row.
- const cols = stats <= 3 ? stats : stats === 4 ? 2 : stats <= 6 ? 3 : 4;
- const rows = Math.ceil(stats / cols);
+ const { cols, rows } = statsGrid(stats, column, twoRows);
const gap = px(16);
const cardW = Math.floor((column.width - (cols - 1) * gap) / cols);
// At most 220 px a card in one row, 170 in two: a card is a number and two lines, not a poster.
@@ -344,6 +392,17 @@ export function finaleGeometry(render, { verdicts = 0, stats = 0, statsTitle = f
}
/**
+ * The stats cards' grid in `column`: up to three in a row; four as two by two
+ * -- or, in a column shorter than `twoRows` (under a taller rail: the least
+ * totals and two rows of 124 px cards), four in one; then three or four to a row.
+ */
+function statsGrid(stats, column, twoRows = 0) {
+ if (stats === 4 && column.height < twoRows && column.width / 4 >= 240) return { cols: 4, rows: 1 };
+ const cols = stats <= 3 ? stats : stats === 4 ? 2 : stats <= 6 ? 3 : 4;
+ return { cols, rows: Math.ceil(stats / cols) };
+}
+
+/**
* Does `label` already say the date `date` says, in any spelling ("26 Aug
* 2026", "Aug 26, 2026", "2026-08-26")? Then the date line would say it twice.
*/
@@ -407,23 +466,103 @@ export function railLabelLayout(pips, geo, { dates = true } = {}) {
const lines = groups.some((g) => g.date) ? 2 : 1;
const block = Math.round(labelSize * 1.15) + (lines > 1 ? Math.round(dateSize * 1.15) : 0);
if (lines === 1 && fitsRows(2)) return { mode: "rows", angle: 0, groups: groups.map((g, j) => ({ ...g, row: j % 2, max: widthOf(g) })) };
- // Turned: hung down-left of each pip, reading up to it.
+ // Turned: hung down-left of each pip, reading up to it -- at the smallest
+ // angle at which neighbours clear each other.
let minD = Infinity;
for (let j = 1; j < groups.length; j += 1) minD = Math.min(minD, groups[j].x - groups[j - 1].x);
- const angle = [35, 50, 65].find((a) => minD * Math.sin((a * Math.PI) / 180) >= block + 4) ?? 65;
+ const clearAt = [35, 50, 65].find((a) => minD * Math.sin((a * Math.PI) / 180) >= block + 4);
+ let angle = clearAt ?? 65;
+ // None clears: the rail is crowded. Each label is said ONCE -- a run that
+ // repeats a label laid elsewhere on the rail goes, each distinct one kept
+ // at its longest run (else its first) -- and the rest are FANNED: each slid
+ // along the rail, as little as it can, to a slot at least `pitch` from the
+ // next, joined to its pip by a thin leader over a LEAD-px band under the
+ // track. Only when even the distinct labels' slots do not fit the rail
+ // (past ~45 at 1080p) is the one with the nearest neighbours dropped, until
+ // they fit. Never two that meet.
+ let laid = groups.map((g) => ({ ...g, lx: g.x }));
+ let lead = 0;
+ if (clearAt === undefined && groups.length > 1) {
+ const pitchAt = (a) => Math.ceil((block + 6) / Math.sin((a * Math.PI) / 180));
+ let pitch = pitchAt(65);
+ // A turned label's line stands to the right of its slot by up to its height: the last slot keeps it on the panel.
+ const lo = groups[0].x, hi = Math.max(groups[groups.length - 1].x, W - m / 2 - block - 4);
+ const fits = (gs) => (gs.length - 1) * pitch <= hi - lo;
+ let kept = [...groups];
+ {
+ const best = new Map();
+ for (const g of kept) {
+ const key = `${g.label}\u0000${g.date}`;
+ const b0 = best.get(key);
+ if (!b0 || g.to - g.from > b0.to - b0.from) best.set(key, g);
+ }
+ kept = kept.filter((g) => best.get(`${g.label}\u0000${g.date}`) === g);
+ }
+ while (kept.length > 1 && !fits(kept)) {
+ // The one with the nearest neighbours (never the first).
+ let at = 1, near = Infinity;
+ for (let j = 1; j < kept.length; j += 1) {
+ const d = Math.min(kept[j].x - kept[j - 1].x, j + 1 < kept.length ? kept[j + 1].x - kept[j].x : Infinity);
+ if (d < near) { near = d; at = j; }
+ }
+ kept.splice(at, 1);
+ }
+ // The flattest angle whose slots stay near their pips (none more than
+ // FAN_REACH px off) -- flatter reads easier -- else the steepest.
+ const reach = Math.round(FAN_REACH * (W / 1920));
+ let lxs = fanSlots(kept.map((g) => g.x), pitch, lo, hi);
+ for (const a of [35, 50]) {
+ const p = pitchAt(a);
+ if ((kept.length - 1) * p > hi - lo) continue;
+ const at = fanSlots(kept.map((g) => g.x), p, lo, hi);
+ if (at.every((v, j) => Math.abs(v - kept[j].x) <= reach)) { angle = a; pitch = p; lxs = at; break; }
+ }
+ laid = kept.map((g, j) => ({ ...g, lx: lxs[j] }));
+ if (laid.some((g) => Math.abs(g.lx - g.x) > 1)) lead = RAIL_LABEL_LEAD;
+ }
const sin = Math.sin((angle * Math.PI) / 180), cos = Math.cos((angle * Math.PI) / 180);
- const drop = Math.max(40, bottom - (y + Math.round(labelSize * 0.9)));
+ const drop = Math.max(40, bottom - (y + Math.round(labelSize * 0.9) + lead));
return {
mode: "turned",
angle,
- groups: groups.map((g) => {
+ lead,
+ groups: laid.map((g) => {
// The room: down to the rail's bottom, and left to the frame's margin.
- const room = Math.min(drop / sin, (g.x - m / 2) / cos);
+ const room = Math.min(drop / sin, (g.lx - m / 2) / cos);
return { ...g, row: 0, max: Math.max(40, Math.floor(Math.min(room, Math.max(widthOf(g), 40)))) };
}),
};
}
+/** The band under the track a fanned label's leader crosses, px (1080p design). */
+export const RAIL_LABEL_LEAD = 26;
+
+/** How far a fanned label may stand from its pip at a flatter angle than 65°, px (1080p design). */
+export const FAN_REACH = 120;
+
+/**
+ * Slots for labels anchored at `xs` (ascending): each as near its anchor as it
+ * can be (least squares), consecutive ones at least `pitch` apart, all inside
+ * [lo, hi] -- pool-adjacent-violators on x_j − j·pitch, clamped.
+ */
+export function fanSlots(xs, pitch, lo, hi) {
+ const n = xs.length;
+ if (!n) return [];
+ const blocks = [];
+ xs.forEach((x, j) => {
+ blocks.push({ sum: x - j * pitch, n: 1 });
+ while (blocks.length > 1 && blocks[blocks.length - 2].sum / blocks[blocks.length - 2].n > blocks[blocks.length - 1].sum / blocks[blocks.length - 1].n) {
+ const top = blocks.pop();
+ blocks[blocks.length - 1].sum += top.sum;
+ blocks[blocks.length - 1].n += top.n;
+ }
+ });
+ const ys = [];
+ for (const b of blocks) for (let i = 0; i < b.n; i += 1) ys.push(b.sum / b.n);
+ const yHi = Math.max(lo, hi - (n - 1) * pitch);
+ return ys.map((v, j) => Math.round((Math.min(yHi, Math.max(lo, v)) + j * pitch) * 100) / 100);
+}
+
/**
* The large rail's markers: each flag's x (mapped from its x on the footer's
* track), its label's row (0 just over the track's band, 1 above it, 2 above
@@ -483,3 +622,225 @@ export function railMarkerLayout(marks, geo, { layout = "stagger" } = {}) {
/** How many rows the large rail's marker labels may take when they stagger. */
export const RAIL_MARKER_ROWS = 3;
+
+// ---------------------------------------------------------------------------
+// Over the large rail: the rows the claim checks' words, their span labels and
+// the markers' labels stand in, packed so no two meet.
+// ---------------------------------------------------------------------------
+
+/**
+ * How far over the track each row's text box starts, px (1080p design): row 0
+ * just over the track (a per claim's span labels, `12 in a day`), rows 1–3
+ * the markers' (railMarkerLayout's rows 0–2, at the heights they always had),
+ * every row on 40 px over the last.
+ */
+export const aboveTop = (row, size = 24) =>
+ (row <= 0 ? Math.round(size * 1.75) : Math.round(size * 3) + (aboveLine(size) + 10) * (row - 1));
+
+/** A row's text box, px: the marker face's line (24 px × 1.25 at the design's size). */
+export const aboveLine = (size = 24) => Math.round(size * 1.25);
+
+/**
+ * One rail's rows: the intervals laid in each, and the sticks that rise
+ * through them. `markers` reserves each marker's label (`labels: false`: its
+ * flag only) in its row and its stick through every row under it.
+ */
+export function aboveRows(marks = [], { labels = true } = {}) {
+ const rows = [];
+ const put = (r, a, b) => { (rows[r] ??= []).push([a, b]); };
+ for (const mk of marks) {
+ const r = mk.row + 1;
+ const w = labels ? 18 + mk.max : 18;
+ if (mk.side === "left") put(r, mk.x - w, mk.x + 2);
+ else put(r, mk.x - 2, mk.x + w);
+ for (let q = 0; q < r; q += 1) (rows[q] ??= []).push([mk.x - 3, mk.x + 3, "stick"]);
+ }
+ return rows;
+}
+
+const TEXT_GAP = 24;
+const STICK_GAP = 8;
+const STEP = 24;
+const MAX_ROWS = 12;
+
+/**
+ * Lay one label in `rows` (aboveRows'), the lowest row first: at its
+ * preferred place, else slid along its row, its stick (when it has one)
+ * anywhere inside its bracket [a, b] and always under the words. Each
+ * candidate must clear its row's words by 24 px and, with its stick, every
+ * row the stick rises through. Records what it takes.
+ *
+ * `item`: `{ w, left, align: "left" | "right" | "center", stick: { x, a, b } | null,
+ * minRow, stickFrom }` -- `stickFrom`: the first row from which the label needs
+ * its stick (a span label in row 0 sits on its bar and needs none).
+ *
+ * @returns {{ row: number, left: number, stickX: number | null }}
+ */
+export function placeAbove(rows, item, { W, margin }) {
+ const { w, align = "left", stick = null, minRow = 0, stickFrom = 0 } = item;
+ const lo = margin / 2, hi = W - margin - w;
+ // Words keep TEXT_GAP from words, and STICK_GAP + 4 from a stick (a thin line needs less air).
+ const clears = (r, a, b, gap) => (rows[r] ?? []).every(([c, d, kind]) => {
+ const g = kind === "stick" ? Math.min(gap, STICK_GAP + 4) : gap;
+ return b + g <= c || a >= d + g;
+ });
+ const stickClears = (r, x) => {
+ for (let q = 0; q < r; q += 1) if (!clears(q, x - 1.5, x + 1.5, STICK_GAP)) return false;
+ return true;
+ };
+ const byNear = (base, from, to) => {
+ const out = [];
+ for (let k = 0; k <= 60; k += 1) {
+ for (const v of k ? [base - k * STEP, base + k * STEP] : [base]) if (v >= from - 1e-6 && v <= to + 1e-6) out.push(v);
+ if (base - k * STEP < from && base + k * STEP > to) break;
+ }
+ return out;
+ };
+ const take = (r, left, sx) => {
+ (rows[r] ??= []).push([left, left + w]);
+ if (sx !== null) for (let q = 0; q < r; q += 1) (rows[q] ??= []).push([sx - 1.5, sx + 1.5, "stick"]);
+ return { row: r, left: Math.round(left * 100) / 100, stickX: sx === null ? null : Math.round(sx * 100) / 100 };
+ };
+ const sticksIn = (x, a, b) => {
+ // Every STEP from its own place, and every 6 px between: a narrow gap between two sticks is found.
+ const out = byNear(x, a, b);
+ for (let v = a; v <= b; v += 6) if (!out.includes(v)) out.push(v);
+ return out;
+ };
+ for (let r = minRow; r < MAX_ROWS; r += 1) {
+ const withStick = stick && r >= stickFrom;
+ const sxs = withStick ? sticksIn(stick.x, Math.min(stick.a, stick.x), Math.max(stick.b, stick.x)) : [null];
+ for (const sx of sxs) {
+ if (sx !== null && !stickClears(r, sx)) continue;
+ const base = sx === null
+ ? item.left
+ : align === "right" ? sx - w + 1 : align === "center" ? sx - w / 2 : sx - 1;
+ // With a stick the words stay over it; without, a span label stays over its point, other words go where they clear.
+ const anchor = stick?.x ?? null;
+ const from = sx !== null ? Math.max(lo, sx - w + 6) : anchor !== null ? Math.max(lo, anchor - w + 6) : lo;
+ const to = sx !== null ? Math.min(hi, sx - 6) : anchor !== null ? Math.min(hi, anchor - 6) : hi;
+ for (const left of byNear(Math.min(to, Math.max(from, base)), from, to)) {
+ if (clears(r, left, left + w, TEXT_GAP)) return take(r, left, sx);
+ }
+ }
+ }
+ // No stick rises clear of the rows under it (everything at once, crowded):
+ // the words without one, in the lowest row they clear near their place.
+ for (let r = Math.max(minRow, 1); r < MAX_ROWS; r += 1) {
+ const anchor = stick?.x ?? item.left + w / 2;
+ for (const left of byNear(Math.min(hi, Math.max(lo, item.left)), Math.max(lo, anchor - w), Math.min(hi, anchor))) {
+ if (clears(r, left, left + w, TEXT_GAP)) return take(r, left, null);
+ }
+ }
+ return take(MAX_ROWS - 1, Math.min(hi, Math.max(lo, item.left)), null);
+}
+
+/**
+ * When the claim checks stand on the large rail: "rotate" gives each of the
+ * `n` claims (a count claim with its band or spans; a goalpost with its
+ * steps) an even share of the page's time from the moment the rail is in
+ * place (`at` + `grow`) to the run's end (`out[0]`, else `to`), in the order
+ * the deck lists them -- when there are two or more and each gets at least
+ * FINALE_CLAIMS.minHold. Otherwise "all", the whole window.
+ *
+ * @returns {{ mode: "rotate" | "all", slots: Array<[number, number]> }}
+ */
+export function finaleClaimSlots(fin, n, setting = "rotate") {
+ const r3 = (v) => Math.round(v * 1000) / 1000;
+ const from = (fin?.at ?? 0) + (fin?.grow > 0 ? fin.grow : 0);
+ const to = fin?.out ? fin.out[0] : fin?.to ?? from;
+ const hold = n > 0 ? (to - from) / n : 0;
+ if (setting !== "rotate" || n < 2 || !(hold >= FINALE_CLAIMS.minHold)) {
+ return { mode: "all", slots: Array.from({ length: n }, () => [r3(from), r3(to)]) };
+ }
+ return { mode: "rotate", slots: Array.from({ length: n }, (_, j) => [r3(from + j * hold), r3(j === n - 1 ? to : from + (j + 1) * hold)]) };
+}
+
+/**
+ * The claims on the finale's large rail, frame px: the footer's layout
+ * (`fcl`, deck.mjs claimsLayout) mapped onto the large track by `toBig`. Each
+ * count claim's band (with the rail dimmed outside it and its record's pips
+ * ringed) or its spans, and every goalpost step -- each superseded one
+ * dashed, the last solid. Their words, and a per claim's span labels, are
+ * laid in the rows over the track (aboveTop) around the markers' (`marks`,
+ * railMarkerLayout's) so no two meet: a span label on its bar, else higher
+ * with a leader down to it; a claim's words at their bracket's edge, else slid
+ * along their row with their stick moved inside the bracket.
+ *
+ * `mode` "rotate" packs each claim against the markers alone (they stand one
+ * at a time), "all" packs them all together. `rows` is how many rows over
+ * the track the tallest needs, the markers' included.
+ *
+ * @returns {{ mode: "rotate" | "all", rows: number, items: any[] }}
+ */
+export function finaleClaims(fcl, {
+ toBig, bigX, size, textWidth: tw = textWidth, ringSize, pips = [], marks = [], markerLabels = true, W = 1920, margin = 48, mode = "all",
+}) {
+ const r2 = (v) => Math.round(v * 100) / 100;
+ const base = aboveRows(marks, { labels: markerLabels });
+ const markerRows = marks.length ? Math.max(...marks.map((mk) => mk.row)) + 2 : 0;
+ const words = (said, record, lead = null) => ({
+ said, record, ...(lead ? { lead } : {}),
+ width: (lead ? tw(`${lead} `, size) + 8 : 0) + tw(said, size) + (record ? tw(` ${record}`, size) + 12 : 0),
+ });
+ const items = fcl.items.map((it, j) => {
+ if (it.kind === "count") {
+ const band = it.band ? { a: r2(toBig(it.band.a)), b: r2(toBig(it.band.b)) } : null;
+ // Dimmed: the track under each veil, and each pip under one as a dot of
+ // its own size -- a finale pip's ring (it is playing) stays whole.
+ const veils = (it.veils ?? []).map(([a, b]) => [r2(toBig(a)), r2(toBig(b))]);
+ const dots = pips.filter((p) => veils.some(([a, b]) => p.x > a && p.x < b)).map((p) => ({ x: p.x, size: p.size + 4 }));
+ const rings = it.band ? it.tags.map((t) => ({ x: bigX(t.k), size: ringSize })) : [];
+ const spans = (it.spans ?? []).map((sp) => ({
+ a: r2(toBig(sp.a)), b: r2(toBig(sp.b)), cx: r2(toBig(sp.cx)), label: sp.label,
+ w: tw(String(sp.label).toUpperCase(), size) + Math.round(size * 0.04 * String(sp.label).length),
+ bars: sp.bars.map((bar) => ({ a: r2(toBig(bar.a)), b: r2(toBig(bar.b)) })),
+ }));
+ const record = it.band ? `${it.total} ${it.noun} on camera` : spans.map((sp) => sp.label).join(" · ") || "none on camera";
+ const left = band ? band.a : spans.length ? spans[0].a : bigX(0);
+ // A band's words hang from its left edge; a per claim's from nothing (its spans carry their counts).
+ const label = { ...words(it.said, record), left: r2(left), stickX: band ? r2(left + 1) : null, j };
+ return { kind: "count", j, band, veils, dots, rings, spans, label };
+ }
+ const steps = it.steps.map((st, s) => {
+ const a = r2(toBig(st.a)), b = r2(toBig(st.b));
+ // What it is (the goalpost's `label`) leads its standing step's words.
+ const last = s === it.steps.length - 1;
+ const w = words(st.said, st.open ? `→ ${st.dueText}` : `· ${st.dueText}`, last && it.label ? `${it.label}:` : null);
+ const align = st.align;
+ const left = align === "right" ? b - w.width : a;
+ const label = { ...w, left: r2(left), stickX: r2(align === "right" ? b - 1 : a + 1), align, j, s, ghost: s + 1 < it.steps.length };
+ return { a, b, open: st.open, off: st.off, ghost: s + 1 < it.steps.length, label };
+ });
+ return { kind: "goalpost", j, ...(it.label ? { name: it.label } : {}), steps };
+ });
+ // The words, laid: per claim against the markers ("rotate"), or all together.
+ const geo = { W, margin };
+ const lay = (its, rows) => {
+ // A per claim's span labels first (on their bars when they can), then each claim's words, a goalpost's standing step first.
+ for (const it of its) {
+ for (const sp of it.spans ?? []) {
+ Object.assign(sp, placeAbove(rows, { w: sp.w, left: sp.cx - sp.w / 2, align: "center", stick: { x: sp.cx, a: sp.cx, b: sp.cx }, minRow: 0, stickFrom: 1 }, geo));
+ }
+ }
+ for (const it of its) {
+ const labels = it.kind === "count" ? [it.label] : [...it.steps].reverse().map((st) => st.label);
+ for (const l of labels) {
+ const range = it.kind === "count"
+ ? (it.band ? { a: it.band.a + 1, b: it.band.b - 1 } : null)
+ : (() => { const st = it.steps[l.s]; return { a: st.a + 1, b: st.b - 1 }; })();
+ const placed = placeAbove(rows, {
+ w: l.width + 8, left: l.left, align: l.align === "right" ? "right" : "left",
+ stick: l.stickX === null ? null : { x: l.stickX, a: range.a, b: range.b }, minRow: Math.max(1, markerRows), stickFrom: 0,
+ }, geo);
+ Object.assign(l, placed);
+ }
+ }
+ return rows.length;
+ };
+ let rows = markerRows;
+ if (mode === "rotate") {
+ for (const it of items) rows = Math.max(rows, lay([it], base.map((r) => [...r])));
+ } else rows = Math.max(rows, lay(items, base.map((r) => [...r])));
+ return { mode, rows, items };
+}