commit 76426415a9f65953b7d1b9078b657df748dfd7be
parent 7066f8eddf4eef9db787264108bc8d65745916af
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Fri, 6 Nov 2026 23:36:18 -0500
Merge lane/leaflit-labels: Play the cut draws teaser (X-post) cards as the build does, the count stepping on them; the counter holds up to 12 series with labels as written (operator, 6 Nov: "play the cut needs to handle x posts … make groups with the literal spoken label")
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
18 files changed, 640 insertions(+), 45 deletions(-)
diff --git a/editor/CHANGELOG.md b/editor/CHANGELOG.md
@@ -2,6 +2,7 @@
## [Unreleased]
- **umtool: each character has a voice, auditioned on a page, the same in every project.** The operator wanted to "pick different voices for different characters, and in UI alone be able to try rendering different ones to compare … and try to maintain consistent voices for different repeating characters" -- tonight TheQuartering's reads were re-voiced by hand after scoring five voices against his real one. `/projects/<p>/voices` (from the Cut tab's Reads and voices) lists every character a project's reads use, the voice each reads in now and where it comes from (the cast, the project, the narrator's, the default), its reads in another voice, and its real voice. **Audition** reads one line (its own words here, a stock line, or typed) in 2-6 stock voices -- a job: the editor's tts, then each one's closeness to the real voice (speakers.json, TitaNet, local) -- played side by side at one loudness beside the real voice, a reference never a target. **Use for this project** or **Use everywhere** (the cast, `<reports>/.umtool/cast.json`), then the items to re-read, queued. A recording of an item can be made a character's read: kept, cleaned, converted to its stock voice. Every read -- a single post's and each piece of a thread read -- asks the same order (the read's own, the project's map, the cast, the narrator's, the default), and a cast voice of another engine is synthesized by it. `umtool cast ls|add|set|rm|undo|project|audition|use|reread`, `posts narrate … --recording`, and `umtool lint` warns when a cast character is read in another voice.
+- **umtool: Play the cut draws a text card as the render does, and a counter can count her words as she said them.** Play showed a teaser -- the Leaflit video's X posts quoted on text cards -- as a grey placeholder, so the card's words and the count stepping on it could not be checked without a render (operator, 6 Nov: "play the cut needs to handle x posts"). Play now lays each card's own page, composed by the build's own code (`POST /api/report/chrome/teasers`), full frame and seeked on the cut clock, the deck over a card that counts. And the counter takes up to 12 series (8 before): past 8 its cells narrow into one row so the title keeps its column, and `deck.counter.labels: "as-written"` sets each cell's words in their own case in up to two lines instead of capitals cut to their last words -- "moderate conservative" no longer reads CONSERVATIVE (operator: "make groups with the literal spoken label e.g. 'moderate', 'moderate conservative', 'close to MAGA'").
- **Rumble clips play the words their quotes say: one clock per recording.** On 6 Nov seven Rumble clips of the weight video played other words than their quotes, c43 13.1 seconds early (the "310" clip), and one stream was right at 10 minutes and 13.6 seconds off at 38. A Rumble channel's transcript is made from a separate audio download, and its clips were cut from another file; the two do not keep the same time, and not by a constant. The operator: "stop trying to grab rumble individual clips and instead grab whole streams and clip after." **Whole, never seeked:** umtool's fetch (the bench's fetch more, `umtool fetch`, a build's fetch) asks for a Rumble clip through Fetch windows, which saves the stream once and cuts the clip from it; nothing falls back to a seek, and a failed save says why. **The right video:** a report cites a Rumble video by its embed id while the archive keeps it under its page's id; every fetch, save and render now finds the video under either (6 Nov: every such fetch went to a folder that did not exist, and one got a Rumble 403). **The time map:** before a clip is cut from a saved Rumble stream, the stream's audio is matched against the audio the transcript was made from, every 5 minutes and around each clip, and the map (`clock.json` beside the video, with how well it fits) moves every cut onto the transcript's time; clips cut before the map, or by a seek, are cut again. A stretch where the two files part (a dropped piece of the stream) is narrowed to a few seconds, and a clip on it is said to be uncertain. **The check:** `umtool quote-check <project>` has the editor transcribe what each clip will actually play and finds the quote in it: `moved` (heard seconds away), `not-found`, or `ok`; `umtool window <p> <clip> --align` puts the cut on the words as heard, `umtool check` blocks on a moved or missing quote, a take refuses one unless a person rules it (`--quote-ruled`), and `umtool prep --status` counts them. Needs a restart of the editor (umtool's half works at once).
- **umtool: a counter series nobody counted shows 0, and a text card can count.** The Leaflit side-tally video has no title or totals cards, so the deck's counter is the only place the counts show, and it left out "Left" (the point of the video: she never once says she is on the left) because the tally drew only the series some mark used. A series of `deck.counter` that says `showAt: "always"` (its own, or the counter's) is now a cell from the first frame, dim at 0, whether or not anything counts it; a series that says nothing (so a counter `umtool migrate` wrote draws what it drew), a `first` series, and the fact-check verdicts' tally of a cut without a `deck.counter` are as before, and a cut that counts nothing still draws no counter. Her two X posts are text cards (`teaser`s), which could not carry a mark, so they did not step the count. A teaser now takes marks as a clip does (`umtool set <p> x-d28 mark.add=CENTER@2.15`, the second counted from the card's start; validated, stamped over the card, counted, in Play and the On-screen table), and a teaser that carries one keeps the deck up over it, with no title of its own, so the count is seen to step. A teaser that dips still hides the deck at the black.
- **Free disk, weekly, with one command: `archilyzer housekeeping`.** On 6 Nov /home was at 37 GB free, and a session freed 83 GB by hand. The operator: "We should build a regularly run command for this after we're done." It runs three passes of the apps' own commands. **Superseded takes:** `umtool prune --versions` deletes whole takes through `umtool takes delete`. Per version line it keeps the highest built number; the line is the take id with its digits folded (`draft-3` and `draft-4`), and a letter is never folded (`v6c` is not `v6d`, `release-6u` is not `release-6`). An older take goes only once the newer one is 7 days old (`--grace`). It also keeps any take picked, pinned, given any verdict, rendering, a build's base, the manifest's, with operator notes on it, or refused by `takes delete`, and skips a project whose verdicts file cannot be read. **Work files:** every project's takes' work files by its prune policy; in a project idle 3 days, the newest and picked takes' work goes too (`--idle-work`). **Worktrees:** `pnpm wt prune` removes merged, clean, idle worktrees with no process in them and no ignored files of anyone's (a corpus, an env file, a changed settings file, a nested repository), keeping their branches. A project or worktree touched in the last 3 days is left alone, and a run is skipped while a render, an e2e suite or a heavy job runs, or when that cannot be checked. Each run is recorded in `~/.local/state/archilyzer/housekeeping.json`. **Worktree ports no longer move:** a worktree's port block is recorded when it is added, so removing another worktree cannot shift a running suite's ports. **Upgrading:** `archilyzer service install` (host mode) now also installs `archilyzer-housekeeping.timer`, weekly; `--dry-run` shows it first, and `--no-housekeeping` leaves it out. OPERATING.md, "Free disk".
diff --git a/umtool/app/api/report/chrome/teasers/route.ts b/umtool/app/api/report/chrome/teasers/route.ts
@@ -0,0 +1,64 @@
+import { composeTeaserPreviews } from "@/lib/report/onscreen.mjs";
+import { resolveReport, teaserPreviewSrc } from "@/lib/report/serve.mjs";
+import { selectVariant } from "umtool-report-to-video/build-video";
+import { teaserSeconds, transitionOf } from "umtool-report-to-video/deck";
+import { cachedTakeManifest, takePlayDir, writePlayManifest } from "@/lib/report/takeManifest.mjs";
+import { isTakeId } from "@/lib/report/takes.mjs";
+
+export const dynamic = "force-dynamic";
+
+// THE TEASERS' PAGES for Play the cut (lane leaflit-labels): every `teaser`
+// entry of the cut -- a text card, an X post quoted on one -- composed for
+// preview by the build's own page (compose-chrome's `teaser` region, under
+// out/<variant>/chrome/teaser-preview-<id>/, Play's seek appended:
+// onscreen.mjs composeTeaserPreviews), so Play draws the card as the render
+// does instead of a placeholder. No render. With or without a deck: a teaser is
+// full frame, the deck (when there is one, and the card counts) is laid over it
+// by the deck's own page.
+//
+// POST { project, take? } -> { teasers: [{ id, seconds, width, height, src } |
+// { id, error }] }. `seconds` is the card's length (deck.mjs teaserSeconds); the
+// page is seeked in seconds from its start. A take's pages are composed under
+// its own directory and served under `@take/<id>/`, as the deck's are.
+export async function POST(request: Request) {
+ let body: Record<string, unknown>;
+ try {
+ body = await request.json();
+ } catch {
+ return Response.json({ error: "expected JSON" }, { status: 400 });
+ }
+ const r = await resolveReport(String(body.project ?? ""), body.variant ? String(body.variant) : null);
+ if ("error" in r) return Response.json({ error: r.error }, { status: r.status });
+ const take = body.take === undefined || body.take === null || body.take === "" ? null : String(body.take);
+ if (take !== null && !isTakeId(take)) return Response.json({ error: "take is a take id" }, { status: 400 });
+ let manifest = r.manifest;
+ let target: { dir: string; manifestFile?: string } = r.project;
+ if (take) {
+ try {
+ manifest = (await cachedTakeManifest(r.project.dir, take)).manifest;
+ target = { dir: takePlayDir(r.project.dir, take), manifestFile: await writePlayManifest(r.project.dir, take, manifest) };
+ } catch (e) {
+ return Response.json({ error: e instanceof Error ? e.message : String(e) }, { status: 404 });
+ }
+ }
+ const selected = selectVariant(manifest, r.variant);
+ const render = (selected.render ?? {}) as Record<string, unknown>;
+ const timeline = ((selected.timeline ?? []) as Record<string, unknown>[]).filter((e) => e && e.type === "teaser");
+ const composed = await composeTeaserPreviews(target, r.variant, timeline);
+ const D = transitionOf(render);
+ const fps = typeof render.fps === "number" ? render.fps : 30;
+ const width = typeof render.width === "number" ? render.width : 1920;
+ const height = typeof render.height === "number" ? render.height : 1080;
+ const stamp = Date.now();
+ return Response.json(
+ {
+ teasers: composed.map((c) => {
+ const e = timeline.find((x) => x.id === c.id)!;
+ return c.ok
+ ? { id: c.id, seconds: teaserSeconds(e, D, fps), width, height, src: `${teaserPreviewSrc(r.project.id, r.variant, c.id, take)}?v=${stamp}` }
+ : { id: c.id, error: c.error ?? "did not compose" };
+ }),
+ },
+ { headers: { "cache-control": "no-store" } },
+ );
+}
diff --git a/umtool/components/projects/review/PlayCut.tsx b/umtool/components/projects/review/PlayCut.tsx
@@ -34,6 +34,7 @@ import { Options, PanelSlot } from "@/components/ui/disclosure";
import PostItemPlayer, { postItemAssets, type PostPlan } from "./PostItemPlayer";
import SidePostOverlay from "./SidePostOverlay";
import VideoEntryPlayer from "./VideoEntryPlayer";
+import TeaserCardPlayer, { type TeaserPage } from "./TeaserCardPlayer";
import { videoStageAt, type VideoEntryPlay } from "@/lib/report/playVideo.mjs";
import ComboBadge, { type ComboInfo } from "./ComboBadge";
@@ -246,7 +247,7 @@ function approximateLine(edges: RenderCuts, info: EngineInfo | null) {
const picture = !info ? "" : info.picture === "webcodecs" ? "picture: WebCodecs" : info.picture === "mixed" ? "picture: WebCodecs, some clips on <video>" : "picture: <video>";
const silent = info ? Object.keys(info.silent) : [];
return [
- "Approximate: cards and teasers are placeholders (a post item plays its card and attachments, its sound from its own element), a push or a wipe is drawn as a dissolve, the chrome is composed on the estimate's clock;",
+ "Approximate: cards are placeholders (a teaser plays the build's own card, silent; a post item plays its card and attachments, its sound from its own element), a push or a wipe is drawn as a dissolve, the chrome is composed on the estimate's clock;",
`${edge};`,
`${sound}${picture ? `; ${picture}` : ""}.`,
silent.length ? `No sound decoded for ${silent.join(", ")}.` : "",
@@ -384,6 +385,35 @@ export default function PlayCut({
}, []);
const hasPosts = useMemo(() => view.entries.some((e) => e.type === "post"), [view.entries]);
const hasVideoEntries = useMemo(() => view.entries.some((e) => e.type === "video" && !!e.videoEntry), [view.entries]);
+ // THE TEASERS (lane leaflit-labels): each text card's own page, composed for preview (POST
+ // /api/report/chrome/teasers) and laid full frame while it is on screen -- the build's card, not a placeholder.
+ // Composed again whenever the manifest moved (its token), with or without a deck.
+ const teaserKey = useMemo(() => view.entries.filter((e) => e.type === "teaser").map((e) => e.id).join("\n"), [view.entries]);
+ const [teaserPages, setTeaserPages] = useState<Record<string, TeaserPage | { id: string; error: string }>>({});
+ useEffect(() => {
+ if (!teaserKey) {
+ setTeaserPages({});
+ return;
+ }
+ let live = true;
+ void (async () => {
+ try {
+ const r = await fetch("/api/report/chrome/teasers", {
+ method: "POST",
+ headers: { "content-type": "application/json" },
+ body: JSON.stringify({ project, ...(take ? { take } : {}) }),
+ });
+ const j = (await r.json().catch(() => ({}))) as { teasers?: (TeaserPage | { id: string; error: string })[]; error?: string };
+ if (!live) return;
+ setTeaserPages(Object.fromEntries((j.teasers ?? []).map((x) => [x.id, x])));
+ } catch {
+ if (live) setTeaserPages({});
+ }
+ })();
+ return () => {
+ live = false;
+ };
+ }, [project, take, teaserKey, view.token]);
useEffect(() => {
try {
// The URL first (Back from the bench lands on the URL Play left), then this browser's choice.
@@ -893,7 +923,10 @@ export default function PlayCut({
// A VIDEO entry (lib/report/playVideo.mjs): its file, the whole frame -- and the item before it darkening into it.
const vstage = hasVideoEntries ? videoStageAt(plan, entryOf, t) : null;
const videoNow = vstage?.video ? { ...vstage, video: vstage.video } : null;
- const placeholder = item && !postNow && !videoNow && (!item.clip || missing || broken) ? { kind: !item.clip ? "card" : "missing", item, entry } : null;
+ // A teaser plays its own page (TeaserCardPlayer), once composed; until then -- or if it did not compose -- a placeholder.
+ const teaserPage = item && entry?.type === "teaser" ? teaserPages[item.id] : undefined;
+ const teaserNow = item && teaserPage && "src" in teaserPage ? { item, page: teaserPage } : null;
+ const placeholder = item && !postNow && !videoNow && !teaserNow && (!item.clip || missing || broken) ? { kind: !item.clip ? "card" : "missing", item, entry } : null;
// The clips' sound fades with the picture into a video entry and is off over it (its element plays its own).
const duck = vstage ? vstage.duck : 1;
useEffect(() => {
@@ -1012,6 +1045,8 @@ export default function PlayCut({
const videoUnder = videoNow && !videoNow.video.noChrome ? videoPlayer : null;
// The item before a video entry, darkening into it: the whole stage, its chrome with it.
const dipVeil = vstage && vstage.dark > 0 ? <div data-play-dip={vstage.id} className="pointer-events-none absolute inset-0 z-30 bg-black" style={{ opacity: vstage.dark }} /> : null;
+ // A teaser on screen: its page, seeked to the seconds into the card (the item's own clock, as a post item's).
+ const teaserCard = teaserNow ? <TeaserCardPlayer key={teaserNow.item.id} page={teaserNow.page} s={t - teaserNow.item.start} /> : null;
const placeholderCard = placeholder ? (
<div
data-play-placeholder={placeholder.kind}
@@ -1023,7 +1058,9 @@ export default function PlayCut({
<>
<span className="micro text-white/60">{placeholder.item.type}</span>
<span className="max-w-[80%] font-display text-[clamp(15px,2.6vw,32px)] font-semibold text-white">{placeholder.entry?.heading ?? placeholder.item.id}</span>
- <span className="text-[11px] text-white/55">a placeholder: the build draws it</span>
+ <span className="text-[11px] text-white/55">
+ {teaserPage && "error" in teaserPage ? `the card did not compose: ${teaserPage.error}` : placeholder.item.type === "teaser" ? "composing the card…" : "a placeholder: the build draws it"}
+ </span>
</>
) : (
<span className="rounded-[3px] bg-black/75 px-2.5 py-1 text-[12.5px] text-white">
@@ -1177,6 +1214,7 @@ export default function PlayCut({
{comboBadge({ width: box.width, height: box.height })}
</div>
)}
+ {teaserCard}
{placeholderCard}
{sideNow && rect && <div className="pointer-events-none absolute" style={{ left: pct(rect.x, g.W), top: pct(rect.y, g.H), width: pct(rect.width, g.W), height: pct(rect.height, g.H) }}>{sideNow}</div>}
{doc.feed && <FeedOverlay key={doc.feed.src ?? "none"} feed={doc.feed} frame={g} t={tc} testid="play-feed" />}
@@ -1195,6 +1233,7 @@ export default function PlayCut({
{footageCanvas({ inset: 0, width: "100%", height: "100%" }, 1280, 720)}
{postNow && <div className="absolute inset-0" style={{ background: bg }}>{postPlayer({ width: 1920, height: 1080 })}{comboBadge({ width: 1920, height: 1080 })}</div>}
{videoUnder}
+ {teaserCard}
{placeholderCard}
{sideNow}
</div>
diff --git a/umtool/components/projects/review/TeaserCardPlayer.tsx b/umtool/components/projects/review/TeaserCardPlayer.tsx
@@ -0,0 +1,76 @@
+"use client";
+
+import { useEffect, useRef, useState } from "react";
+
+// A TEASER on Play's stage (lane leaflit-labels): the card the build draws --
+// its own page (chrome-teaser.mjs, composed for preview by POST
+// /api/report/chrome/teasers) -- full frame, seeked to `s`, the seconds into
+// the card. The page says `teaser:ready` once its words are fitted; nothing is
+// sent before it. Laid where a placeholder would be: under the deck's page, so
+// a card that counts keeps the deck (and the count stepping at its mark) over it.
+
+export type TeaserPage = { id: string; seconds: number; width: number; height: number; src: string };
+
+export default function TeaserCardPlayer({ page, s }: { page: TeaserPage; s: number }) {
+ const box = useRef<HTMLDivElement | null>(null);
+ const el = useRef<HTMLIFrameElement | null>(null);
+ const [width, setWidth] = useState(0);
+ const [readySrc, setReadySrc] = useState<string | null>(null);
+ const src = `${page.src}${page.src.includes("?") ? "&" : "?"}preview=1`;
+
+ useEffect(() => {
+ const node = box.current;
+ if (!node) return;
+ const ro = new ResizeObserver(([e]) => setWidth(e.contentRect.width));
+ ro.observe(node);
+ return () => ro.disconnect();
+ }, []);
+
+ useEffect(() => {
+ const onMsg = (e: MessageEvent) => {
+ if (e.source !== el.current?.contentWindow || e.origin !== window.location.origin) return;
+ if ((e.data as { type?: string } | null)?.type === "teaser:ready") setReadySrc(src);
+ };
+ window.addEventListener("message", onMsg);
+ return () => window.removeEventListener("message", onMsg);
+ }, [src]);
+
+ const live = readySrc === src;
+ // Clamped into the card: a hard cut shows its middle, never past its last frame.
+ const at = Math.max(0, Math.min(page.seconds, s));
+ useEffect(() => {
+ if (live) el.current?.contentWindow?.postMessage({ type: "deck:seek", t: at }, window.location.origin);
+ }, [live, at]);
+
+ const scale = width > 0 ? width / page.width : 0;
+ return (
+ <div
+ ref={box}
+ data-play-teaser={page.id}
+ data-play-teaser-ready={live ? "1" : "0"}
+ data-play-teaser-at={at.toFixed(2)}
+ className="pointer-events-none absolute inset-0 overflow-hidden bg-black"
+ >
+ <iframe
+ ref={el}
+ key={src}
+ src={src}
+ title={`teaser ${page.id}`}
+ data-testid="play-teaser-iframe"
+ tabIndex={-1}
+ aria-hidden
+ style={{
+ position: "absolute",
+ left: 0,
+ top: 0,
+ width: page.width,
+ height: page.height,
+ border: 0,
+ transform: `scale(${scale})`,
+ transformOrigin: "0 0",
+ visibility: live ? "visible" : "hidden",
+ }}
+ />
+ </div>
+ );
+}
diff --git a/umtool/docs/knobs.md b/umtool/docs/knobs.md
@@ -1698,7 +1698,8 @@ The deck's tally as named series (`render.chrome.deck.counter`). A clip's mark n
| Knob | Range · default | From a terminal |
|---|---|---|
-| `deck.counter.series[]` | 1–8 `{id, label, color?, stampLabel?, tallyLabel?, showAt?, shape?, unit?}` -- an `id` a letter then letters, digits, `_` `-`; a verdict's id (`CORROBORATED` …) takes its default label, colour and shape; `label` ≤ 24 and fitting the cell, as the verdicts' are | `umtool look <p> deck.counter='{"series":[{"id":"seizures","label":"Seizures","color":"#e5534b","stampLabel":"Seizure"}]}'` |
+| `deck.counter.series[]` | 1–12 `{id, label, color?, stampLabel?, tallyLabel?, showAt?, shape?, unit?}` -- an `id` a letter then letters, digits, `_` `-`; a verdict's id (`CORROBORATED` …) takes its default label, colour and shape; `label` ≤ 24 (≤ 32 as written) and fitting the cell, as the verdicts' are. Up to 8 the cells are 124 px; past 8 they narrow into one row of 1040 px (9 → 108 px, 10 → 96, 12 → 79), so the title keeps a column of about 520 px, and a label must fit the narrower cell (refused by name, never cut) | `umtool look <p> deck.counter='{"series":[{"id":"seizures","label":"Seizures","color":"#e5534b","stampLabel":"Seizure"}]}'` |
+| `deck.counter.labels` | `caps` `as-written` · default `caps`: each cell's word capitalised on one line (its `tallyLabel`, else its label or the last words of it that fit). `as-written`: the label in its own case ("close to MAGA"), letter-spaced 0.02 em, broken between words into at most two lines, never cut to its last words -- a word wider than the cell, or a third line, is refused by name | `umtool look <p> deck.counter.labels=as-written` |
| `deck.counter.series[].shape` | `circle` `diamond` `square` `triangle` `ring` · default by place (a verdict's own) | same |
| `deck.counter.series[].unit` | ≤ 24 · the noun a count claim's number reads (default its label, lower-cased) | same |
| `deck.counter.show`, `.position`, `.showAt` | bool · `right` `left` · `always` `first` (a series' own `showAt` wins) · defaults `true`, `right`, `always`. A series that SAYS `always` (its own `showAt`, else the counter's) is a cell from the first frame, dim at 0, whether or not a mark ever counts it ("Left 0"); one with no `showAt` said, or `first`, is a cell once it is counted, so one never counted is not drawn. The cells show once the cut counts anything | same |
diff --git a/umtool/e2e/fixtures/make-fixture.mjs b/umtool/e2e/fixtures/make-fixture.mjs
@@ -2050,6 +2050,32 @@ pm.timeline = pm.timeline.map((e) => (e.id === "c03" ? { ...e, verdict: "incorre
writeFileSync(pmFile, JSON.stringify(pm, null, 2) + "\n");
}
+// A TEXT CARD in Play the cut (play-teaser.spec.ts, lane leaflit-labels): the Play cut
+// with its card k01 replaced by a teaser t01 -- an X post quoted on a card -- that
+// carries a mark (CORROBORATED, 1.0 s into the card), so the deck stays up over it
+// and the count steps on it. Play draws the build's own page, not a placeholder.
+{
+const { dir: playTeaserDir } = makePlayCutFixture({
+ reports, deckManifest, cachedWindow: path.join(REPORT, "out", "clips-raw", "vid1_0.00-9.00.mp4"),
+ name: "play-teaser-fixture", title: "The Play Teaser Fixture",
+ chrome: { factcheck: { verdicts: { CORROBORATED: { label: "Seizures", tallyLabel: "Seized", color: "#6fa8dc" } }, stamp: { seconds: 1 } } },
+});
+const ptFile = path.join(playTeaserDir, "video.manifest.json");
+const pt = JSON.parse(readFileSync(ptFile, "utf8"));
+pt.timeline = pt.timeline.map((e) => (e.id === "k01"
+ ? {
+ type: "teaser", id: "t01", seconds: 4,
+ lines: [
+ { text: "@someone on X · 1 Feb 2026", role: "overline" },
+ { text: "“I want to understand your perspective", role: "kicker" },
+ { text: "behind them as a moderate.”", role: "kicker" },
+ ],
+ claim: { id: "kx", verdict: "CORROBORATED", at: 1.0 },
+ }
+ : e));
+writeFileSync(ptFile, JSON.stringify(pt, null, 2) + "\n");
+}
+
// The measure's instruments (instruments.spec.ts): the Play cut with the dial, the odometer and
// the trail on, and a built schedule carrying a measure slice (instruments-fixture.mjs).
await makeInstrumentsFixture({ reports, deckManifest, cachedWindow: path.join(REPORT, "out", "clips-raw", "vid1_0.00-9.00.mp4"), makePlayCutFixture });
diff --git a/umtool/e2e/play-teaser.spec.ts b/umtool/e2e/play-teaser.spec.ts
@@ -0,0 +1,72 @@
+import { test, expect, type Page } from "@playwright/test";
+import * as urls from "./urls";
+
+// ---------------------------------------------------------------------------
+// A TEXT CARD in Play the cut (lane leaflit-labels; operator, 6 Nov: "play the
+// cut needs to handle x posts"): a `teaser` entry -- an X post quoted on a card
+// -- plays as the build draws it, its own page (chrome-teaser.mjs, composed for
+// preview by POST /api/report/chrome/teasers) laid full frame and seeked on the
+// cut clock, not a placeholder. A card that carries a mark keeps the deck up
+// over it (deck.mjs teaserCounts) and the count steps at the mark.
+//
+// Fixture: e2e/fixtures/make-fixture.mjs, play-teaser-fixture -- the Play cut
+// with its card k01 replaced by t01 (4 s, three lines), marked CORROBORATED at
+// 1.0 s into the card; c02's mark (k1) lands before it, so the count is 1 on
+// the card's first second and 2 after its mark.
+// ---------------------------------------------------------------------------
+
+const PROJECT = "reports/play-teaser-fixture";
+
+const root = (page: Page) => page.locator("[data-play-cut]");
+const card = (page: Page) => page.locator('[data-play-teaser="t01"]');
+const frame = (page: Page) => page.frameLocator('[data-testid="play-teaser-iframe"]');
+/** A line's visibility inside the card's own page (the build's pixels, seeked by the parent). */
+const lineOpacity = (page: Page, i: number) =>
+ frame(page).locator(`[data-k="l${i}.o"]`).evaluate((el) => Number(getComputedStyle(el).opacity));
+const tally = (page: Page) => page.locator("[data-play-tally]");
+
+test.beforeEach(() => {
+ test.setTimeout(120_000);
+});
+
+test("a teaser card that carries a mark plays as the build draws it: its lines, the deck over it, the count stepping at its mark", async ({ page }) => {
+ await page.setViewportSize({ width: 1366, height: 1000 });
+ // Into the card, before its mark (1.0 s): seeked there from the URL.
+ await page.goto(urls.playHref(PROJECT, { clip: "t01", at: 0.6 }));
+ await expect(root(page)).toHaveAttribute("data-play-item", "t01", { timeout: 30_000 });
+ await expect(page.locator('[data-testid="play-deck"]')).toBeVisible({ timeout: 30_000 });
+ // The card's own page, not a placeholder.
+ await expect(card(page)).toHaveAttribute("data-play-teaser-ready", "1", { timeout: 30_000 });
+ await expect(page.locator("[data-play-placeholder]")).toHaveCount(0);
+ await expect(frame(page).locator('[data-k="l1.t"]')).toHaveText("“I want to understand your perspective");
+ await expect(frame(page).locator('[data-k="l2.t"]')).toHaveText("behind them as a moderate.”");
+ // Before the mark: c02's k1 has counted, the card's has not.
+ await expect(tally(page)).toHaveAttribute("data-play-tally", "CORROBORATED:1");
+ await page.screenshot({ path: test.info().outputPath("play-teaser-before-mark.png") });
+
+ // Seek through the card past its mark (→ is 5 s on, past the card: back with ← lands before it, so step by the URL).
+ await page.goto(urls.playHref(PROJECT, { clip: "t01", at: 2.6 }));
+ await expect(root(page)).toHaveAttribute("data-play-item", "t01", { timeout: 30_000 });
+ await expect(card(page)).toHaveAttribute("data-play-teaser-ready", "1", { timeout: 30_000 });
+ await expect(page.locator('[data-testid="play-deck"]')).toHaveAttribute("data-deck-ready", "1", { timeout: 30_000 });
+ // Every line is in by now: the card's last line too.
+ await expect.poll(() => lineOpacity(page, 2), { timeout: 10_000 }).toBeGreaterThan(0.9);
+ await expect.poll(() => lineOpacity(page, 1), { timeout: 10_000 }).toBeGreaterThan(0.9);
+ // After the mark: the count stepped on the card.
+ await expect(tally(page)).toHaveAttribute("data-play-tally", "CORROBORATED:2");
+ await page.screenshot({ path: test.info().outputPath("play-teaser-after-mark.png") });
+
+ // Playing across the mark from the card's start: the count steps while the card is on screen.
+ await page.goto(urls.playHref(PROJECT, { clip: "t01", at: 0.2 }));
+ await expect(card(page)).toHaveAttribute("data-play-teaser-ready", "1", { timeout: 30_000 });
+ await expect(tally(page)).toHaveAttribute("data-play-tally", "CORROBORATED:1");
+ await page.locator("[data-play-toggle]").click();
+ await expect(tally(page)).toHaveAttribute("data-play-tally", "CORROBORATED:2", { timeout: 15_000 });
+ await page.keyboard.press("k");
+ await expect(root(page)).toHaveAttribute("data-play-state", "paused");
+
+ // Out of it (c01): no card on screen.
+ await page.locator('[data-play-row="c01"]').press("Enter");
+ await expect(root(page)).toHaveAttribute("data-play-item", "c01");
+ await expect(card(page)).toHaveCount(0);
+});
diff --git a/umtool/lib/report/livePreview.test.mjs b/umtool/lib/report/livePreview.test.mjs
@@ -13,8 +13,8 @@ import test from "node:test";
import { MANIFEST_NAME, StaleToken } from "./manifest.mjs";
import { clipEditorView, runClipEditorOp } from "./clipEditor.mjs";
import { clipRenderFile, clipRenderSteps, readClipRender, windowMoved } from "./clipRender.mjs";
-import { composeFinalePreview, renderSeconds, scheduleForPreview } from "./onscreen.mjs";
-import { finalePreviewDir, finalePreviewSrc, previewDirFor } from "./serve.mjs";
+import { composeFinalePreview, composeTeaserPreviews, renderSeconds, scheduleForPreview, TEASER_SEEK_SCRIPT, withTeaserSeek } from "./onscreen.mjs";
+import { finalePreviewDir, finalePreviewSrc, previewDirFor, teaserPreviewDir, teaserPreviewSrc } from "./serve.mjs";
import { PIPELINE_DIR, RENDER_BUDGET, buildSteps, buildTimeoutMs } from "./driver.mjs";
import { takeTimeoutMs } from "./takeMaker.mjs";
@@ -94,6 +94,52 @@ test("the finale's preview is served from finale-preview/ under the files route"
});
});
+test("composeTeaserPreviews: each teaser of the cut through compose-chrome's teaser region, into teaser-preview-<id>, Play's seek appended", async () => {
+ const dir = await mkdtemp(path.join(tmpdir(), "teaser-preview-"));
+ try {
+ const calls = [];
+ const timeline = [
+ { type: "clip", id: "a" },
+ { type: "teaser", id: "x1", lines: ["One"] },
+ { type: "teaser", id: "x2", lines: ["Two"] },
+ ];
+ const r = await composeTeaserPreviews({ dir }, "sourced", timeline, {
+ compose: async (args) => {
+ calls.push(args);
+ if (args.segment === "x2") throw new Error("teaser x2: no lines");
+ const projDir = path.join(args.outDir, "chrome", `teaser-preview-${args.segment}`);
+ await mkdir(projDir, { recursive: true });
+ await writeFile(path.join(projDir, "index.html"), "<html><body><p>card</p></body></html>\n");
+ return { projDir };
+ },
+ });
+ assert.deepEqual(calls.map((c) => [c.region, c.segment, c.preview]), [["teaser", "x1", true], ["teaser", "x2", true]]);
+ assert.deepEqual(r, [{ id: "x1", ok: true }, { id: "x2", ok: false, error: "teaser x2: no lines" }]);
+ const html = await readFile(path.join(teaserPreviewDir(dir, "sourced", "x1"), "index.html"), "utf8");
+ assert.ok(html.includes(TEASER_SEEK_SCRIPT), "the preview copy answers Play's seek");
+ assert.ok(html.indexOf(TEASER_SEEK_SCRIPT) < html.indexOf("</body>"), "before </body>");
+ assert.ok(html.startsWith("<html><body><p>card</p>"), "the build's page otherwise");
+ // Refused when compose-chrome writes anywhere else.
+ const bad = await composeTeaserPreviews({ dir }, "sourced", [timeline[1]], { compose: async () => ({ projDir: "/elsewhere" }) });
+ assert.match(bad[0].error ?? "", /not .*teaser-preview-x1/);
+ } finally {
+ await rm(dir, { recursive: true, force: true });
+ }
+});
+
+test("a teaser's preview is served from teaser-preview-<id>/ when <id> is an entry of the cut", () => {
+ assert.equal(teaserPreviewDir("/p", "sourced", "x-d28"), path.join("/p", "out", "sourced", "chrome", "teaser-preview-x-d28"));
+ assert.match(teaserPreviewSrc("reports/x", "sourced", "x-d28", "a-take"), /^\/api\/report\/chrome\/files\/[A-Za-z0-9_-]+\/sourced\/@take\/a-take\/teaser-preview-x-d28\/index\.html$/);
+ assert.deepEqual(previewDirFor("/p", "sourced", ["teaser-preview-x-d28", "assets", "gsap.min.js"], ["x-d28"]), {
+ dir: path.join("/p", "out", "sourced", "chrome", "teaser-preview-x-d28"),
+ rest: ["assets", "gsap.min.js"],
+ });
+ assert.equal(previewDirFor("/p", "sourced", ["teaser-preview-nope", "index.html"], ["x-d28"]), null);
+ assert.equal(previewDirFor("/p", "sourced", ["teaser-preview-..", "index.html"], [".."]), null);
+ // A page with no </body> still gets it, at its end.
+ assert.ok(withTeaserSeek("<p>x</p>").endsWith(TEASER_SEEK_SCRIPT));
+});
+
test("the editor's `onscreen` op: the clip's deck words through the On-screen writer; null is automatic; the view carries them", async () => {
const p = await project();
try {
diff --git a/umtool/lib/report/onscreen.mjs b/umtool/lib/report/onscreen.mjs
@@ -15,7 +15,7 @@
//
// The preview never renders and never touches the build's project or cache:
// compose-chrome's `preview: true` writes out/<variant>/chrome/deck-preview/.
-import { readFile, rm } from "node:fs/promises";
+import { readFile, rm, writeFile } from "node:fs/promises";
import path from "node:path";
import { composeChrome } from "umtool-report-to-video/compose-chrome";
import { selectVariant } from "umtool-report-to-video/build-video";
@@ -50,7 +50,7 @@ import {
readCues,
} from "../projects/report.mjs";
import { normalizePostPatches, splitOnscreenRow } from "./manifest.mjs";
-import { deckPreviewDir, feedPreviewDir, finalePreviewDir, postsPreviewDir, stampPreviewDir } from "./serve.mjs";
+import { deckPreviewDir, feedPreviewDir, finalePreviewDir, postsPreviewDir, stampPreviewDir, teaserPreviewDir } from "./serve.mjs";
import { ensureWriteDir } from "./storage.mjs";
/** The schedule document deck.mjs defines, built or estimated. */
@@ -619,6 +619,76 @@ export async function composeStampPreview(project, variant, schedule, { compose
}
/**
+ * PLAY'S SEEK for a teaser's preview page: appended to the PREVIEW copy only
+ * (compose-chrome never renders a preview project, so the build's page and its
+ * render key are untouched). Under `?preview=1` the page answers the parent's
+ * `deck:seek` (seconds into the card) by seeking its own timeline, and posts
+ * `teaser:ready` once its words are fitted -- the build's page otherwise, byte
+ * for byte.
+ */
+export const TEASER_SEEK_SCRIPT = `<script data-play-seek="">
+ (function () {
+ if (new URLSearchParams(location.search).get("preview") === null) return;
+ var tl = window.__timelines && window.__timelines["teaser"];
+ if (!tl) return;
+ addEventListener("message", function (e) {
+ if (e.origin !== location.origin || !e.data || e.data.type !== "deck:seek") return;
+ tl.seek(Math.max(0, Number(e.data.t) || 0), false);
+ });
+ var tries = 0;
+ (function wait() {
+ if (document.documentElement.dataset.fit === "1" || tries++ > 200) parent.postMessage({ type: "teaser:ready" }, location.origin);
+ else setTimeout(wait, 25);
+ })();
+ })();
+</script>`;
+
+/** The page with Play's seek before its `</body>`. */
+export const withTeaserSeek = (html) => {
+ const at = html.lastIndexOf("</body>");
+ return at < 0 ? html + TEASER_SEEK_SCRIPT : `${html.slice(0, at)}${TEASER_SEEK_SCRIPT}\n ${html.slice(at)}`;
+};
+
+/**
+ * Compose the PREVIEW page of every TEASER in the cut (Play the cut, lane
+ * leaflit-labels: a text card -- an X post quoted on a card -- plays as the
+ * build draws it, not as a placeholder): compose-chrome's `teaser` region per
+ * entry, under out/<variant>/chrome/teaser-preview-<id>/, Play's seek
+ * appended. No render. A teaser that does not compose says why in its row; the
+ * others are composed either way.
+ *
+ * @param {{ dir: string, manifestFile?: string }} project
+ * @param {string} variant
+ * @param {Array<Record<string, any>>} timeline the cut's (the variant's) entries
+ * @param {{ compose?: (args: Record<string, unknown>) => Promise<any> }} [opts]
+ * @returns {Promise<Array<{ id: string, ok: boolean, error?: string }>>}
+ */
+export async function composeTeaserPreviews(project, variant, timeline, { compose = composeChrome } = {}) {
+ const outDir = path.join(project.dir, "out", variant);
+ const teasers = (timeline ?? []).filter((e) => e?.type === "teaser" && typeof e.id === "string");
+ const out = [];
+ for (const e of teasers) {
+ const want = teaserPreviewDir(project.dir, variant, e.id);
+ try {
+ await serialised(want, async () => {
+ /** @type {Record<string, unknown>} */
+ const args = { manifestPath: manifestOf(project), outDir, variant, region: "teaser", segment: e.id, preview: true };
+ const r = await compose(/** @type {any} */ (args));
+ if (r?.projDir && path.resolve(r.projDir) !== path.resolve(want)) {
+ throw new Error(`compose-chrome wrote the teaser preview to ${r.projDir}, not ${want}`);
+ }
+ const file = path.join(want, "index.html");
+ await writeFile(file, withTeaserSeek(await readFile(file, "utf8")), "utf8");
+ });
+ out.push({ id: e.id, ok: true });
+ } catch (err) {
+ out.push({ id: e.id, ok: false, error: err instanceof Error ? err.message : String(err) });
+ }
+ }
+ return out;
+}
+
+/**
* Compose the PREVIEW of the finale (a schedule with `finale`): compose-chrome's
* `finale` region, one project for its window under
* out/<variant>/chrome/finale-preview/. No render. The page is seeked in the
diff --git a/umtool/lib/report/serve.mjs b/umtool/lib/report/serve.mjs
@@ -919,6 +919,22 @@ export const finalePreviewDir = (projectDir, variant) =>
export const finalePreviewSrc = (projectId, variant, take = null) =>
`${previewBase(projectId, variant, take)}/${FINALE_PREVIEW}/index.html`;
+// A TEASER's preview page (Play the cut, lane leaflit-labels): compose-chrome's
+// `teaser-preview-<id>/` for one teaser entry of the cut -- the build's own page
+// (chrome-teaser.mjs), with Play's seek appended (onscreen.mjs
+// composeTeaserPreviews) -- served one segment deeper, `teaser-preview-<id>/…`,
+// when `<id>` is one of the cut's entries.
+const TEASER_PREVIEW_PREFIX = "teaser-preview-";
+
+/** The preview project of one teaser entry. */
+export const teaserPreviewDir = (projectDir, variant, segment) =>
+ path.join(projectDir, "out", variant, "chrome", `${TEASER_PREVIEW_PREFIX}${segment}`);
+
+/** The iframe src for one teaser entry's preview page. */
+/** @type {(projectId: string, variant: string, segment: string, take?: string | null) => string} */
+export const teaserPreviewSrc = (projectId, variant, segment, take = null) =>
+ `${previewBase(projectId, variant, take)}/${TEASER_PREVIEW_PREFIX}${encodeURIComponent(segment)}/index.html`;
+
/** The preview project of the posts window on one segment. */
export const postsPreviewDir = (projectDir, variant, segment) =>
path.join(projectDir, "out", variant, "chrome", `${POSTS_PREVIEW_PREFIX}${segment}`);
@@ -935,6 +951,8 @@ export const postsPreviewSrc = (projectId, variant, segment, take = null) =>
* `feed-preview/…` is the posts feed's project (one per cut),
* `stamp-preview/…` the fact-check stamps' (one per cut) and
* `finale-preview/…` the finale's (one per cut).
+ * `teaser-preview-<segment>/…` is a teaser entry's page when `<segment>` is one
+ * of `segmentIds`, as a posts window's is.
* `posts-preview-<segment>/…` is a posts window's project when `<segment>` is
* one of `segmentIds` -- the cut's own entry ids, which the caller reads from
* the manifest, so a name the client made up is not a directory this serves.
@@ -960,6 +978,12 @@ export function previewDirFor(projectDir, variant, rest, segmentIds) {
if (head === FEED_PREVIEW) return { dir: feedPreviewDir(projectDir, variant), rest: rest.slice(1) };
if (head === STAMP_PREVIEW) return { dir: stampPreviewDir(projectDir, variant), rest: rest.slice(1) };
if (head === FINALE_PREVIEW) return { dir: finalePreviewDir(projectDir, variant), rest: rest.slice(1) };
+ if (typeof head === "string" && head.startsWith(TEASER_PREVIEW_PREFIX)) {
+ const seg = head.slice(TEASER_PREVIEW_PREFIX.length);
+ if (!seg || /[\/\\\0]/.test(seg) || seg === "." || seg === "..") return null;
+ if (!new Set(segmentIds).has(seg)) return null;
+ return { dir: teaserPreviewDir(projectDir, variant, seg), rest: rest.slice(1) };
+ }
if (typeof head === "string" && head.startsWith(POSTS_PREVIEW_PREFIX)) {
const seg = head.slice(POSTS_PREVIEW_PREFIX.length);
if (!seg || /[\/\\\0]/.test(seg) || seg === "." || seg === "..") return null;
diff --git a/umtool/report-to-video/chrome-deck.mjs b/umtool/report-to-video/chrome-deck.mjs
@@ -43,7 +43,7 @@ import {
} from "./deck.mjs";
import { contrast } from "./chrome-intro.mjs";
import { claimsCues, claimsMarkup } from "./chrome-claims.mjs";
-import { resolveFactcheck, tallyCues, tallyFinals, tallyKey, tallyLabelOf, tallyOf, tallyPopIns } from "./factcheck.mjs";
+import { resolveFactcheck, TALLY_WRITTEN, tallyCues, tallyFinals, tallyKey, tallyLabelLines, tallyOf, tallyPopIns } from "./factcheck.mjs";
import { resolveCounter } from "./counter.mjs";
import { SUBSECTION_SEPARATOR } from "./marker-limits.mjs";
@@ -841,11 +841,22 @@ export function deckHtml(schedule, render, opts = {}) {
// will show stacked in one box (`n0` … `n<final>`), its label under it.
const tb = lay.tally ?? null;
const verdictSet = tb ? resolveFactcheck(render).verdicts : null;
- const countSize = tb ? Math.round(tb.height * 0.42) : 0;
+ // Each cell's words (factcheck.mjs tallyLabelLines): the cell's own short word, else the label (or its last
+ // words) that fits, capitalised -- never an ellipsis; AS WRITTEN (`counter.labels`), the label in up to two
+ // lines, its own case. Past 8 series the cells are narrower (design.mjs counterCell).
+ const written = counter.labels === "as-written";
+ const fontBold = render.fontBold ?? null;
+ const cellWords = tb
+ ? Object.fromEntries(tally.map((v) => [v, tallyLabelLines(verdictSet[v], { fontBold, n: tally.length, labels: counter.labels }) ?? [verdictSet[v].label]]))
+ : {};
+ const labelLines = written ? Math.max(1, ...Object.values(cellWords).map((l) => l.length)) : 1;
+ // As written in two lines, the count gives the second line its room.
+ const countSize = tb ? Math.round(tb.height * (labelLines > 1 ? 0.36 : 0.42)) : 0;
const countBox = Math.round(countSize * 1.12);
- const labelSize = 13;
- const labelBox = 17;
- const cellTop = tb ? Math.round((tb.height - (countBox + 8 + labelBox)) / 2) + 2 : 0;
+ const labelSize = written ? TALLY_WRITTEN.size : 13;
+ const labelBox = written ? TALLY_WRITTEN.lineBox : 17;
+ const labelBlock = labelBox * labelLines;
+ const cellTop = tb ? Math.round((tb.height - (countBox + 8 + labelBlock)) / 2) + 2 : 0;
const tallyHtml = tb
? `<div class="tally">` +
tally
@@ -865,9 +876,8 @@ export function deckHtml(schedule, render, opts = {}) {
(byVerdict
? `<div class="tshape" data-shape="${shapes[v]}" style="${shapeCss(shapes[v], 12, esc(color))}"></div>`
: "") +
- // tallyLabelOf: the cell's own short word, else the label (or its
- // last words) that fits -- never an ellipsis.
- `<div class="tlabel">${esc(tallyLabelOf(verdictSet[v], { fontBold: render.fontBold ?? null }) ?? verdictSet[v].label)}</div>` +
+ // cellWords: its line, or (as written) its lines.
+ `<div class="tlabel">${cellWords[v].map(esc).join("<br>")}</div>` +
`<div class="tflash" data-k="${tallyKey(v, "flash")}"></div></div>`
);
})
@@ -1037,7 +1047,7 @@ export function deckHtml(schedule, render, opts = {}) {
font-size: ${countSize}px; line-height: ${countBox}px; color: var(--vc); font-variant-numeric: tabular-nums; }
.tlabel { position: absolute; left: 6px; top: ${cellTop + countBox + 8}px; width: ${tb.cell - 12}px; text-align: center;
font-family: 'DeckSansBold', sans-serif; font-size: ${labelSize}px; line-height: ${labelBox}px;
- letter-spacing: 0.08em; text-transform: uppercase; white-space: nowrap; overflow: hidden;
+ letter-spacing: ${written ? TALLY_WRITTEN.tracking : 0.08}em; text-transform: ${written ? "none" : "uppercase"}; white-space: nowrap; overflow: hidden;
text-overflow: ellipsis; color: var(--vl); }
.tflash { position: absolute; inset: 0; border-radius: 8px; opacity: 0; pointer-events: none;
box-shadow: inset 0 0 0 2px var(--vc), inset 0 0 22px var(--vg); }` : ""}${tb && byVerdict ? `
diff --git a/umtool/report-to-video/counter.mjs b/umtool/report-to-video/counter.mjs
@@ -37,8 +37,17 @@ export const COUNTER_SHOW_AT = Object.freeze(["always", "first"]);
/** Which end of the deck's text column the counter takes. */
export const COUNTER_POSITIONS = Object.freeze(["right", "left"]);
-/** The counter's limits: how many series, an id's and a unit's characters. */
-export const COUNTER_LIMITS = Object.freeze({ series: 8, id: 32, unit: 24, label: VERDICT_LABEL_MAX });
+/** How a series' words are set in its cell: capitalised (as the verdicts always were), or as written. */
+export const COUNTER_LABELS = Object.freeze(["caps", "as-written"]);
+
+/**
+ * The counter's limits: how many series, an id's and a unit's characters, a
+ * label's (`writtenLabel`: a label or cell word set as written, which may take
+ * two lines). Past 8 series the cells narrow into one row (design.mjs
+ * counterCell, lane leaflit-labels): 12 is the most whose cells still hold a
+ * short word at the deck's own label size.
+ */
+export const COUNTER_LIMITS = Object.freeze({ series: 12, id: 32, unit: 24, label: VERDICT_LABEL_MAX, writtenLabel: 32 });
/** A series id: what a mark names. A letter, then letters, digits, `_` or `-`. */
export const SERIES_ID_RE = /^[A-Za-z][A-Za-z0-9_-]{0,31}$/;
@@ -50,7 +59,7 @@ export const SERIES_COLORS = Object.freeze(["#e5534b", "#e3b23c", "#3fbf7f", "#7
export const SERIES_KEYS = Object.freeze(["id", "label", "color", "stampLabel", "tallyLabel", "showAt", "unit", "shape"]);
/** The keys `deck.counter` may carry. */
-export const COUNTER_KEYS = Object.freeze(["series", "show", "position", "showAt"]);
+export const COUNTER_KEYS = Object.freeze(["series", "show", "position", "showAt", "labels"]);
const isObj = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
@@ -93,6 +102,7 @@ export function resolveCounter(render) {
showAt: Object.fromEntries(series.map((s) => [s.id, s.showAt])),
show: c.show !== false,
position: COUNTER_POSITIONS.includes(c.position) ? c.position : "right",
+ labels: COUNTER_LABELS.includes(c.labels) ? c.labels : "caps",
};
}
// The fact-check verdicts, as the tally always counted them.
@@ -111,6 +121,7 @@ export function resolveCounter(render) {
showAt,
show: tally.show !== false,
position: COUNTER_POSITIONS.includes(tally.position) ? tally.position : "right",
+ labels: "caps",
};
}
@@ -141,6 +152,10 @@ export function validateCounter(c, { factcheck = undefined, labelFits = null, wh
if (c.showAt !== undefined && !COUNTER_SHOW_AT.includes(c.showAt)) {
errors.push(`${where}.showAt must be ${COUNTER_SHOW_AT.map((p) => `"${p}"`).join(" or ")}`);
}
+ if (c.labels !== undefined && !COUNTER_LABELS.includes(c.labels)) {
+ errors.push(`${where}.labels must be ${COUNTER_LABELS.map((p) => `"${p}"`).join(" or ")}`);
+ }
+ const written = c.labels === "as-written";
if (!Array.isArray(c.series) || !c.series.length) {
errors.push(`${where}.series must list at least one series { id, label }`);
return errors;
@@ -161,7 +176,11 @@ export function validateCounter(c, { factcheck = undefined, labelFits = null, wh
if (word === undefined) continue;
if (typeof word !== "string" || !word.trim()) errors.push(`${w}.${key} must be words, not empty`);
else if (/[\r\n]/.test(word)) errors.push(`${w}.${key} must be one line`);
- else if (word.trim().length > COUNTER_LIMITS.label) errors.push(`${w}.${key} is ${word.trim().length} characters (at most ${COUNTER_LIMITS.label})`);
+ else {
+ // A label or cell word set as written may run to two lines; a stamp's word is one line, as ever.
+ const max = written && key !== "stampLabel" ? COUNTER_LIMITS.writtenLabel : COUNTER_LIMITS.label;
+ if (word.trim().length > max) errors.push(`${w}.${key} is ${word.trim().length} characters (at most ${max})`);
+ }
}
if (s.color !== undefined && !(typeof s.color === "string" && VERDICT_COLOR_RE.test(s.color))) errors.push(`${w}.color must be a hex colour, #rgb or #rrggbb`);
if (s.showAt !== undefined && !COUNTER_SHOW_AT.includes(s.showAt)) errors.push(`${w}.showAt must be ${COUNTER_SHOW_AT.map((p) => `"${p}"`).join(" or ")}`);
@@ -170,7 +189,7 @@ export function validateCounter(c, { factcheck = undefined, labelFits = null, wh
errors.push(`${w}.unit must be a word, 1 to ${COUNTER_LIMITS.unit} characters`);
}
if (labelFits && !errors.some((e) => e.startsWith(`${w}.`))) {
- const problem = labelFits(s, w);
+ const problem = labelFits(s, w, { n: c.series.length, labels: written ? "as-written" : "caps" });
if (problem) errors.push(problem);
}
});
diff --git a/umtool/report-to-video/deck.mjs b/umtool/report-to-video/deck.mjs
@@ -31,7 +31,7 @@ import {
import { resolveCounter } from "./counter.mjs";
import { INSTRUMENT_COLUMN, instrumentsOn, instrumentsPlacement, instrumentsWanted, resolveDial } from "./instruments.mjs";
import { TRAILER_HIT_TIERS, TRAILER_SWELL } from "./trailer-hits.mjs";
-import { DECK_PAD_X, COUNTER_CELL } from "./modules/design.mjs";
+import { DECK_PAD_X, counterCell } from "./modules/design.mjs";
import { parseShelfNote, resolveShelf, SHELF_MIN } from "./modules/shelf-settings.mjs";
// An entry's note on the shelf, as written (`umtool set <p> <entry> shelfNote=…`; manifest.mjs checks it here).
@@ -646,7 +646,8 @@ export function deckLayout(render, { tally = null, schedule = null } = {}) {
// A cell per verdict the cut uses: its count over its label. Beside the
// QR's cell (whose plate starts 46 px before the code) on the right, or
// ahead of the title on the left; 40 px of air to the text either way.
- const { cell, gap } = COUNTER_CELL;
+ // Past 8 series the cells narrow into one row's budget (design.mjs counterCell).
+ const { cell, gap } = counterCell(tally.length);
const width = tally.length * cell + (tally.length - 1) * gap;
const height = Math.min(bodyH - 8, 118);
const y = Math.round(bodyTop + (bodyH - height) / 2);
diff --git a/umtool/report-to-video/factcheck.mjs b/umtool/report-to-video/factcheck.mjs
@@ -37,7 +37,7 @@
import { offsetIn } from "./gaps.mjs";
import { isIsoDate } from "./claims.mjs";
import { resolveCounter, VERDICT_SHAPES } from "./counter.mjs";
-import { COUNTER_CELL } from "./modules/design.mjs";
+import { COUNTER_CELL, counterCell } from "./modules/design.mjs";
import {
VERDICT_DEFAULTS,
VERDICT_LABEL_MAX,
@@ -135,12 +135,26 @@ function unknownKeys(obj, allowed, where, errors) {
*/
export const TALLY_LABEL = Object.freeze({ size: 13, tracking: 0.08, width: COUNTER_CELL.cell - 2 * COUNTER_CELL.labelPad });
+/**
+ * A label AS WRITTEN (`deck.counter.labels: "as-written"`, lane leaflit-labels:
+ * "the literal spoken label e.g. 'moderate', 'close to MAGA'"): not capitalised,
+ * letter-spaced 0.02 em, in up to two lines of `lineBox` px -- broken between
+ * words, never inside one, never cut to its last words.
+ */
+export const TALLY_WRITTEN = Object.freeze({ size: 13, tracking: 0.02, lines: 2, lineBox: 15 });
+
+/** The label's room in the cell for `n` series (design.mjs counterCell): the cell less its pad a side. */
+export const tallyLabelRoom = (n) => {
+ const c = counterCell(n);
+ return c.cell - 2 * c.labelPad;
+};
+
// Fira Sans Bold's advances (the deck's bold unless a brand sets one), per
// character a capitalised label can hold, in 1/1000 em, rounded UP --
// measured from /usr/share/fonts/TTF/FiraSans-Bold.ttf. Kerning is not
// counted; the 2 % margin below covers it.
-const FIRA_BOLD_CHARS = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`{|}~’‘“”…–—ÀÁÂÄÅÇÈÉÊËÌÍÎÏÑÒÓÔÖØÙÚÛÜ";
-const FIRA_BOLD_ADV = "237,240,439,557,549,859,760,238,325,325,449,531,240,407,240,520,585,464,517,520,565,536,564,468,581,560,240,240,519,519,519,481,1020,590,617,575,651,526,487,645,666,293,317,633,513,786,663,691,600,690,617,572,540,651,570,847,581,594,544,324,520,324,559,520,340,324,376,324,514,243,243,448,448,727,520,796,590,590,590,590,590,575,526,526,526,526,293,293,293,293,663,691,691,691,691,691,651,651,651,651";
+const FIRA_BOLD_CHARS = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`{|}~’‘“”…–—ÀÁÂÄÅÇÈÉÊËÌÍÎÏÑÒÓÔÖØÙÚÛÜabcdefghijklmnopqrstuvwxyz";
+const FIRA_BOLD_ADV = "237,240,439,557,549,859,760,238,325,325,449,531,240,407,240,520,585,464,517,520,565,536,564,468,581,560,240,240,519,519,519,481,1020,590,617,575,651,526,487,645,666,293,317,633,513,786,663,691,600,690,617,572,540,651,570,847,581,594,544,324,520,324,559,520,340,324,376,324,514,243,243,448,448,727,520,796,590,590,590,590,590,575,526,526,526,526,293,293,293,293,663,691,691,691,691,691,651,651,651,651,546,591,479,594,554,356,551,573,280,280,551,300,841,573,584,591,594,400,480,386,568,513,749,512,518,454";
/**
* How wide a tally label draws, px, as the page sets it (upper-cased, the
@@ -150,16 +164,18 @@ const FIRA_BOLD_ADV = "237,240,439,557,549,859,760,238,325,325,449,531,240,407,2
* counted at 1.02 em (wider than any capital Fira draws but @), so a label
* called fitting fits. 2 % over the sum, for kerning.
*/
-export function tallyLabelWidth(label, { fontBold = null, size = TALLY_LABEL.size } = {}) {
+export function tallyLabelWidth(label, { fontBold = null, size = TALLY_LABEL.size, caps = true } = {}) {
const mono = typeof fontBold === "string" && /mono/i.test(fontBold);
const fira = !fontBold || /fira ?sans[-_ ]?bold/i.test(String(fontBold).split("/").pop() ?? "");
const adv = FIRA_BOLD_ADV.split(",");
+ // As written (TALLY_WRITTEN): the label's own case, and its tighter spacing.
+ const tracking = caps ? TALLY_LABEL.tracking : TALLY_WRITTEN.tracking;
let em = 0;
- const chars = [...String(label ?? "").toUpperCase()];
+ const chars = [...(caps ? String(label ?? "").toUpperCase() : String(label ?? ""))];
for (const ch of chars) {
const i = FIRA_BOLD_CHARS.indexOf(ch);
em += mono ? 0.6 : fira && i >= 0 ? Number(adv[i]) / 1000 : 1.02;
- em += TALLY_LABEL.tracking;
+ em += tracking;
}
return Math.ceil(em * size * 1.02);
}
@@ -169,12 +185,13 @@ export function tallyLabelWidth(label, { fontBold = null, size = TALLY_LABEL.siz
* `tallyLabel`, else its `label` when that fits the cell, else the longest run
* of the label's LAST words that does ("Huck's Blend pitches" → "pitches"),
* else null (validateFactcheck refuses it). The finale and the stamp keep
- * their own words.
+ * their own words. `width` is the label's room (TALLY_LABEL's, or a dense
+ * row's: tallyLabelRoom).
*
* @returns {string|null}
*/
-export function tallyLabelOf(v, { fontBold = null } = {}) {
- const fits = (s) => tallyLabelWidth(s, { fontBold }) <= TALLY_LABEL.width;
+export function tallyLabelOf(v, { fontBold = null, width = TALLY_LABEL.width } = {}) {
+ const fits = (s) => tallyLabelWidth(s, { fontBold }) <= width;
if (typeof v?.tallyLabel === "string" && v.tallyLabel.trim()) return fits(v.tallyLabel.trim()) ? v.tallyLabel.trim() : null;
const label = String(v?.label ?? "");
if (fits(label)) return label;
@@ -187,21 +204,74 @@ export function tallyLabelOf(v, { fontBold = null } = {}) {
}
/**
+ * A label AS WRITTEN in its lines (TALLY_WRITTEN): its words filled into lines
+ * of at most `width` px, at most two; null when a word alone is wider or it
+ * needs a third line. Its own case, never cut.
+ *
+ * @returns {string[]|null}
+ */
+export function writtenLabelLines(label, { fontBold = null, width = TALLY_LABEL.width } = {}) {
+ const words = String(label ?? "").trim().split(/\s+/).filter(Boolean);
+ if (!words.length) return null;
+ const fits = (x) => tallyLabelWidth(x, { fontBold, size: TALLY_WRITTEN.size, caps: false }) <= width;
+ const lines = [];
+ for (const w of words) {
+ if (!fits(w)) return null;
+ const last = lines.length ? `${lines[lines.length - 1]} ${w}` : null;
+ if (last !== null && fits(last)) lines[lines.length - 1] = last;
+ else lines.push(w);
+ }
+ return lines.length <= TALLY_WRITTEN.lines ? lines : null;
+}
+
+/**
+ * The lines a counter's cell shows for series `v` (`{ label, tallyLabel? }`):
+ * as written (`labels: "as-written"`), its `tallyLabel` else its label in up to
+ * two lines; else the one line tallyLabelOf picks, capitalised by the page.
+ * `n` is how many cells the row holds (a dense row's are narrower). null: no
+ * words of it fit.
+ *
+ * @param {{ label?: string, tallyLabel?: string }} v
+ * @param {{ fontBold?: string | null, n?: number, labels?: string }} [opts]
+ * @returns {string[]|null}
+ */
+export function tallyLabelLines(v, { fontBold = null, n = 1, labels = "caps" } = {}) {
+ const width = tallyLabelRoom(n);
+ if (labels === "as-written") {
+ const words = typeof v?.tallyLabel === "string" && v.tallyLabel.trim() ? v.tallyLabel : v?.label;
+ return writtenLabelLines(words, { fontBold, width });
+ }
+ const one = tallyLabelOf(v, { fontBold, width });
+ return one === null ? null : [one];
+}
+
+/**
* Why a counter series' words do not fit its tally cell (`deck.counter`,
* counter.mjs), as the verdicts' are held: its `tallyLabel` must fit, else
- * its label or a run of its last words must. null when they fit.
+ * its label or a run of its last words must -- in the cell a row of `n` gives
+ * it (design.mjs counterCell). As written (`labels: "as-written"`), its
+ * tallyLabel or label must fill at most two lines, no word wider than the
+ * cell. null when they fit.
*/
-export function counterLabelProblem(s, w, { fontBold = null } = {}) {
+export function counterLabelProblem(s, w, { fontBold = null, n = 1, labels = "caps" } = {}) {
const label = s.label ?? VERDICT_DEFAULTS[s.id]?.label ?? s.id;
+ const room = tallyLabelRoom(n);
+ const cells = room !== TALLY_LABEL.width ? ` (${n} cells in the row)` : "";
+ if (labels === "as-written") {
+ const key = typeof s.tallyLabel === "string" ? "tallyLabel" : "label";
+ const words = key === "tallyLabel" ? s.tallyLabel : label;
+ if (writtenLabelLines(words, { fontBold, width: room }) !== null) return null;
+ return `${w}.${key} "${String(words).trim()}" does not fit the tally's cell${cells} in two lines of ${room} px: set ${w}.tallyLabel to fewer or shorter words`;
+ }
if (typeof s.tallyLabel === "string") {
const px = tallyLabelWidth(s.tallyLabel.trim(), { fontBold });
- return px > TALLY_LABEL.width
- ? `${w}.tallyLabel "${s.tallyLabel.trim()}" is ${px} px wide in the tally's cell, which has ${TALLY_LABEL.width} px: shorten it`
+ return px > room
+ ? `${w}.tallyLabel "${s.tallyLabel.trim()}" is ${px} px wide in the tally's cell${cells}, which has ${room} px: shorten it`
: null;
}
- if (tallyLabelOf({ label }, { fontBold }) !== null) return null;
+ if (tallyLabelOf({ label }, { fontBold, width: room }) !== null) return null;
const px = tallyLabelWidth(label, { fontBold });
- return `${w}.label "${String(label).trim()}" is ${px} px wide in the tally's cell, which has ${TALLY_LABEL.width} px, and no run of its last words fits: set ${w}.tallyLabel to a shorter word`;
+ return `${w}.label "${String(label).trim()}" is ${px} px wide in the tally's cell${cells}, which has ${room} px, and no run of its last words fits: set ${w}.tallyLabel to a shorter word`;
}
/**
diff --git a/umtool/report-to-video/modules/counter.mjs b/umtool/report-to-video/modules/counter.mjs
@@ -3,7 +3,7 @@
// a mark's stamp lands (report-to-video counter.mjs; factcheck.mjs
// `tallyCues`; chrome-deck.mjs draws the cells). The finale reads its totals
// (`counter.totals`); the claim checks name its series.
-import { COUNTER_POSITIONS, COUNTER_SHAPES, COUNTER_SHOW_AT, resolveCounter } from "../counter.mjs";
+import { COUNTER_LABELS, COUNTER_POSITIONS, COUNTER_SHAPES, COUNTER_SHOW_AT, resolveCounter } from "../counter.mjs";
import { settingsOf } from "./settings.mjs";
import { defineModule } from "./contract.mjs";
@@ -17,7 +17,7 @@ export default defineModule({
title: "Counter",
summary: "A running tally of named series in the deck, each cell stepping as a mark's stamp lands.",
configKey: "render.chrome.deck.counter",
- defaults: { series: [], show: true, position: "right", showAt: "always" },
+ defaults: { series: [], show: true, position: "right", showAt: "always", labels: "caps" },
validate: settingsOf("counter").validate,
resolve: resolveCounter,
provides: ["counter.totals", "counter.series"],
@@ -35,12 +35,14 @@ export default defineModule({
{ key: "show", type: "boolean", label: "Show the cells", default: true },
{ key: "position", type: "enum", options: COUNTER_POSITIONS, label: "Side", default: "right" },
{ key: "showAt", type: "enum", options: COUNTER_SHOW_AT, label: "Cells appear", default: "always" },
+ { key: "labels", type: "enum", options: COUNTER_LABELS, label: "Cell words", default: "caps" },
],
docs: {
heading: "Counter",
intro: "The deck's tally as named series (`render.chrome.deck.counter`). A clip's mark names the series it counts (`claim.verdict`, or its alias `claim.counter`); a deck claim's `tally` names one by id or label. Without `counter` the series are the fact-check verdicts with `factcheck.verdicts`' relabels and `factcheck.tally`'s settings, as ever; `umtool migrate <p>` writes those as a `counter` (the render is the same) and the two are not set together.",
rows: [
- ["`deck.counter.series[]`", "1–8 `{id, label, color?, stampLabel?, tallyLabel?, showAt?, shape?, unit?}` -- an `id` a letter then letters, digits, `_` `-`; a verdict's id (`CORROBORATED` …) takes its default label, colour and shape; `label` ≤ 24 and fitting the cell, as the verdicts' are", "`umtool look <p> deck.counter='{\"series\":[{\"id\":\"seizures\",\"label\":\"Seizures\",\"color\":\"#e5534b\",\"stampLabel\":\"Seizure\"}]}'`"],
+ ["`deck.counter.series[]`", "1–12 `{id, label, color?, stampLabel?, tallyLabel?, showAt?, shape?, unit?}` -- an `id` a letter then letters, digits, `_` `-`; a verdict's id (`CORROBORATED` …) takes its default label, colour and shape; `label` ≤ 24 (≤ 32 as written) and fitting the cell, as the verdicts' are. Up to 8 the cells are 124 px; past 8 they narrow into one row of 1040 px (9 → 108 px, 10 → 96, 12 → 79), so the title keeps a column of about 520 px, and a label must fit the narrower cell (refused by name, never cut)", "`umtool look <p> deck.counter='{\"series\":[{\"id\":\"seizures\",\"label\":\"Seizures\",\"color\":\"#e5534b\",\"stampLabel\":\"Seizure\"}]}'`"],
+ ["`deck.counter.labels`", "`caps` `as-written` · default `caps`: each cell's word capitalised on one line (its `tallyLabel`, else its label or the last words of it that fit). `as-written`: the label in its own case (\"close to MAGA\"), letter-spaced 0.02 em, broken between words into at most two lines, never cut to its last words -- a word wider than the cell, or a third line, is refused by name", "`umtool look <p> deck.counter.labels=as-written`"],
["`deck.counter.series[].shape`", "`circle` `diamond` `square` `triangle` `ring` · default by place (a verdict's own)", "same"],
["`deck.counter.series[].unit`", "≤ 24 · the noun a count claim's number reads (default its label, lower-cased)", "same"],
["`deck.counter.show`, `.position`, `.showAt`", "bool · `right` `left` · `always` `first` (a series' own `showAt` wins) · defaults `true`, `right`, `always`. A series that SAYS `always` (its own `showAt`, else the counter's) is a cell from the first frame, dim at 0, whether or not a mark ever counts it (\"Left 0\"); one with no `showAt` said, or `first`, is a cell once it is counted, so one never counted is not drawn. The cells show once the cut counts anything", "same"],
diff --git a/umtool/report-to-video/modules/counter.test.mjs b/umtool/report-to-video/modules/counter.test.mjs
@@ -5,9 +5,11 @@ import assert from "node:assert/strict";
import { counterOrder, resolveCounter, validateCounter, VERDICT_SHAPES } from "../counter.mjs";
import {
- claimOf, marksOf, normalizeClaim, resolveFactcheck, tallyAlways, tallyCells, tallyCellsFrom, tallyCues, tallyFinals, tallyOf, tallyShowAt, validateClaims,
+ claimOf, counterLabelProblem, marksOf, normalizeClaim, resolveFactcheck, tallyAlways, tallyCells, tallyCellsFrom, tallyCues, tallyFinals, tallyLabelLines,
+ tallyOf, tallyShowAt, validateClaims, writtenLabelLines,
} from "../factcheck.mjs";
-import { estimateSchedule, validateChrome } from "../deck.mjs";
+import { deckLayout, estimateSchedule, validateChrome } from "../deck.mjs";
+import { counterCell } from "./design.mjs";
import { deckHtml } from "../chrome-deck.mjs";
import counter from "./counter.mjs";
import { moduleProblems } from "./index.mjs";
@@ -156,6 +158,62 @@ test("a series that says `showAt: always` is drawn at 0 though no mark uses it (
assert.deepEqual(tallyCellsFrom([{ verdict: "c" }], ["a", "b", "c"]), ["c"]);
});
+test("past 8 series the cells narrow into one row (up to 12); as written, a label keeps its case in up to two lines (lane leaflit-labels)", () => {
+ // The cell: 124 px up to 8, then the dense row's share of 1040 px.
+ assert.deepEqual(counterCell(8), { cell: 124, gap: 10, labelPad: 6 });
+ assert.deepEqual(counterCell(9), { cell: 108, gap: 8, labelPad: 6 });
+ assert.deepEqual(counterCell(10), { cell: 96, gap: 8, labelPad: 6 });
+ assert.deepEqual(counterCell(12), { cell: 79, gap: 8, labelPad: 6 });
+ const twelve = Array.from({ length: 12 }, (_, i) => ({ id: `s${i}`, label: `S${i}` }));
+ assert.deepEqual(validateCounter({ series: twelve }), []);
+ assert.match(validateCounter({ series: [...twelve, { id: "s12", label: "S12" }] }).join(), /series holds 13 \(at most 12\)/);
+ assert.match(validateCounter({ series: SERIES, labels: "lower" })[0], /labels must be "caps" or "as-written"/);
+ // Her phrases, as said: two lines in a 10-cell row's 84 px, no word cut, no last-words fallback.
+ assert.deepEqual(writtenLabelLines("slightly more conservative", { width: 84 }), ["slightly more", "conservative"]);
+ assert.deepEqual(writtenLabelLines("close to MAGA", { width: 84 }), ["close to", "MAGA"]);
+ assert.deepEqual(writtenLabelLines("moderate", { width: 84 }), ["moderate"]);
+ assert.equal(writtenLabelLines("a b c d e f g h i j k l m n o p q r s t", { width: 40 }), null, "never a third line");
+ assert.equal(writtenLabelLines("conservatively", { width: 60 }), null, "never inside a word");
+ assert.deepEqual(tallyLabelLines({ label: "moderate center right" }, { n: 10, labels: "as-written" }), ["moderate", "center right"]);
+ // Capitalised (the default), the one line it always was -- in a 9-cell row's narrower room.
+ assert.deepEqual(tallyLabelLines({ label: "Seizures" }, { n: 4 }), ["Seizures"]);
+ assert.deepEqual(tallyLabelLines({ label: "Moderate center right" }, { n: 10 }), ["right"]);
+ // Its fit check, in the row it stands in: a word wider than a 12-cell row's room is refused by name.
+ assert.equal(counterLabelProblem({ id: "a", label: "slightly more conservative" }, "w", { n: 10, labels: "as-written" }), null);
+ assert.match(counterLabelProblem({ id: "a", label: "conservative" }, "w", { n: 12, labels: "as-written" }) ?? "", /does not fit the tally's cell \(12 cells in the row\) in two lines of 67 px/);
+ // Through the deck's validator: 10 phrases as written, a written label to 32 characters, a stamp word still 24.
+ const PHRASES = ["moderate", "moderate conservative", "centrist", "moderate right", "centered conservative", "slightly more conservative", "moderate center right", "socially moderate", "conservative", "close to MAGA"];
+ const series = PHRASES.map((label, i) => ({ id: `p${i}`, label }));
+ const asWritten = render({ counter: { series, labels: "as-written" } });
+ assert.deepEqual(validateChrome(asWritten.chrome, asWritten), []);
+ const capped = render({ counter: { series } });
+ assert.match(validateChrome(capped.chrome, capped).join("\n"), /series\[5\]\.label is 26 characters \(at most 24\)/);
+ const stampy = render({ counter: { series: [{ id: "a", label: "slightly more conservative", stampLabel: "slightly more conservative" }], labels: "as-written" } });
+ assert.match(validateChrome(stampy.chrome, stampy).join("\n"), /stampLabel is 26 characters \(at most 24\)/);
+ // The deck: one row of 10 narrower cells, each label as written in its lines, the count over them.
+ const manifest = {
+ provenance: {}, posts: [], render: asWritten,
+ timeline: series.map((x, i) => ({ type: "clip", id: `c${i}`, video: `v${i}`, start: 0, end: 5, claim: { id: `k${i}`, verdict: x.id } })),
+ };
+ assert.deepEqual(validateClaims(manifest), []);
+ const s = estimateSchedule(manifest);
+ const lay = deckLayout(asWritten, { tally: tallyOf(s, asWritten), schedule: s });
+ assert.equal(lay.tally?.cell, 96);
+ assert.equal(lay.tally?.width, 10 * 96 + 9 * 8);
+ assert.ok((lay.text.width ?? 0) > 500, `the title keeps a column (${lay.text.width} px)`);
+ const html = deckHtml(s, asWritten, {});
+ assert.match(html, /<div class="tlabel">slightly more<br>conservative<\/div>/);
+ assert.match(html, /<div class="tlabel">close to<br>MAGA<\/div>/);
+ assert.match(html, /<div class="tlabel">moderate<\/div>/);
+ assert.match(html, /letter-spacing: 0\.02em; text-transform: none;/);
+ // Capitalised up to 8 series: the page it always was.
+ const four = render({ counter: { series: SERIES } });
+ const s4 = estimateSchedule({ ...manifest, render: four, timeline: [{ type: "clip", id: "a", video: "v", start: 0, end: 5, claim: { id: "k", verdict: "seizures" } }] });
+ const h4 = deckHtml(s4, four, {});
+ assert.match(h4, /letter-spacing: 0\.08em; text-transform: uppercase;/);
+ assert.match(h4, /<div class="tlabel">Seizures<\/div>/);
+});
+
test("the counter module: its home, its validator, its docs", () => {
assert.equal(counter.kind, "part");
assert.equal(counter.host, "shell");
diff --git a/umtool/report-to-video/modules/design.mjs b/umtool/report-to-video/modules/design.mjs
@@ -21,5 +21,21 @@ export const DECK_PAD_X = 48;
*/
export const COUNTER_CELL = Object.freeze({ cell: 124, gap: 10, labelPad: 6 });
+/**
+ * THE DENSE COUNTER (lane leaflit-labels): past 8 series (up to 12, counter.mjs
+ * COUNTER_LIMITS) the cells share `budget` px -- the room 8 cells took less a
+ * cell, so the deck's title keeps a column -- `gap` apart. 9 cells are 99 px,
+ * 12 are 72; a label that does not fit its narrower cell is refused by the
+ * counter's fit check, never cut.
+ */
+export const COUNTER_DENSE = Object.freeze({ budget: 1040, gap: 8, from: 9 });
+
+/** The counter's cell for `n` series: COUNTER_CELL's up to 8, else the dense row's. */
+export function counterCell(n) {
+ if (!(n >= COUNTER_DENSE.from)) return { cell: COUNTER_CELL.cell, gap: COUNTER_CELL.gap, labelPad: COUNTER_CELL.labelPad };
+ const { budget, gap } = COUNTER_DENSE;
+ return { cell: Math.floor((budget - gap * (n - 1)) / n), gap, labelPad: COUNTER_CELL.labelPad };
+}
+
/** A design-unit length at this render's width (what the scaled geometry multiplies by). */
export const designScale = (render) => (render?.width ?? DESIGN.width) / DESIGN.width;
diff --git a/umtool/report-to-video/modules/settings.mjs b/umtool/report-to-video/modules/settings.mjs
@@ -476,7 +476,7 @@ export const SETTINGS = Object.freeze([
validate: (v, { where }) => validateMeasureSettings(v, `${where}.measure`) },
{ id: "counter", key: "deck.counter", configKey: "render.chrome.deck.counter", deck: true,
validate: (v, { chrome, render }) => validateCounter(v, {
- factcheck: chrome.factcheck, labelFits: (s, where) => counterLabelProblem(s, where, { fontBold: render.fontBold ?? null }),
+ factcheck: chrome.factcheck, labelFits: (s, where, fit) => counterLabelProblem(s, where, { fontBold: render.fontBold ?? null, ...fit }),
}) },
{ id: "shell", key: "deck", configKey: "render.chrome.deck", deck: true, whole: true, validate: validateShellSettings },
{ id: "rail", key: "deck", configKey: "render.chrome.deck.pip", deck: true, whole: true, validate: validateRailSettings },