Archilyzer · Source

archilyzer

Archilyzer
git clone https://archilyzer.pages.dev/source/archilyzer.git
Log | Files | Refs | README | LICENSE

commit 2655fdb45e3840bbf6361f548741c9253083faf5
parent 91145b05e4a31909a99ae6dccbdd91ee79f3a050
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Tue, 10 Nov 2026 17:40:03 -0500

umtool: a tally label never refuses the chrome -- one wider than its cell is drawn smaller a pixel at a time down to 10 px, then cut with an ellipsis (factcheck.mjs fitTallyLabel; the cell's one inline font-size, so a page whose labels fit is byte for byte what it was); validateFactcheck and the counter's fit check refuse only a cell with no room for a letter; the lint names each label it shortened (tallyLabelNotes). play-cut-fixture's "Seizures" (117 px in the fixture's face against 112) composes again: the workspace fixture's "Seized" workaround is gone and play-cut.spec asserts the deck composes (E5 A1)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Diffstat:
Mumtool/docs/knobs.md | 6+++---
Mumtool/e2e/fixtures/make-fixture.mjs | 6+++---
Mumtool/e2e/play-cut.spec.ts | 4++++
Mumtool/report-to-video/chrome-deck.mjs | 16+++++++++-------
Mumtool/report-to-video/factcheck.mjs | 144++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------
Mumtool/report-to-video/factcheck.test.mjs | 34+++++++++++++++++++++++++++-------
Mumtool/report-to-video/lint.mjs | 7++++++-
Mumtool/report-to-video/modules/counter.mjs | 4++--
Mumtool/report-to-video/modules/counter.test.mjs | 16++++++++++------
Mumtool/report-to-video/modules/design.mjs | 4++--
10 files changed, 172 insertions(+), 69 deletions(-)

diff --git a/umtool/docs/knobs.md b/umtool/docs/knobs.md @@ -324,7 +324,7 @@ that mentions the seizure in question and one before it. The Marks box is on eve |---|---|---|---| | `render.chrome.factcheck.stamp.scale` (0.5–2), `.motion` (`slam` `pop` `fade` `none`), `.opacity` (0.3–1) | Structure, **fact-check labels**: scale, motion, opacity | `umtool look <p> factcheck.stamp.scale=1.3 factcheck.stamp.motion=pop` | `POST /api/report/timeline {op: "factcheck", factcheck}` | | `render.chrome.factcheck.verdicts.<V>.stampLabel` — the stamp's word (singular, `SEIZURE`) beside `label` (the tally's, `SEIZURES`) | fact-check labels, the third column | `factcheck.verdicts.CONTRADICTED.stampLabel=SEIZURE` | same | -| `render.chrome.factcheck.verdicts.<V>.tallyLabel` — the deck tally cell's word (`PITCHES`) beside `label` (the finale's totals and stats keep the full `Huck's Blend pitches`). The cell never cuts a label short: without a `tallyLabel` it shows the `label` if it fits, else the longest run of the label's last words that fits (`Huck's Blend pitches` → `Blend pitches`); a `tallyLabel` that does not fit, or a `label` no run of whose last words fits, is refused by name at check time. Measured as drawn: 13 px capitals, 0.08 em spacing, 112 px, in Fira Sans Bold's advances (or 0.6 em a character in a `fontBold` named Mono) | none yet: `umtool look` | `umtool look <p> factcheck.verdicts.PARTLY.tallyLabel=Pitches` (`=` clears it) | `POST /api/report/timeline {op: "factcheck", factcheck}` | +| `render.chrome.factcheck.verdicts.<V>.tallyLabel` — the deck tally cell's word (`PITCHES`) beside `label` (the finale's totals and stats keep the full `Huck's Blend pitches`). Without a `tallyLabel` it shows the `label` if it fits, else the longest run of the label's last words that fits (`Huck's Blend pitches` → `Blend pitches`); a `tallyLabel` that does not fit, or a `label` no run of whose last words fits, is drawn smaller a pixel at a time down to 10 px, then cut with an ellipsis (factcheck.mjs `fitTallyLabel`) -- the chrome is never refused for it, and the lint names each label it shortened. Measured as drawn: 13 px capitals, 0.08 em spacing, 112 px, in Fira Sans Bold's advances (or 0.6 em a character in a `fontBold` named Mono) | none yet: `umtool look` | `umtool look <p> factcheck.verdicts.PARTLY.tallyLabel=Pitches` (`=` clears it) | `POST /api/report/timeline {op: "factcheck", factcheck}` | | `render.chrome.factcheck.tally.showAt` — `always` (default: every cell from the first frame, dim at 0) or `first` (a cell hidden until the stamp that gives it its first count lands, then it pops in — scale 0.5→1, 0.35 s, the markers' ease — already reading its count, and stays); one value for every cell, or `{ "<VERDICT>": "first" }` for each on its own (unnamed: `always`). A hidden cell keeps its place in the row; the finale's totals show every verdict as ever | fact-check labels, **pop in** per verdict (every one ticked writes `first`) | `umtool look <p> factcheck.tally.showAt=first`, or one cell: `factcheck.tally.showAt.PARTLY=first` (`factcheck.tally.showAt=` clears it) | same | | `render.chrome.deck.markers[]` — `{after, label ≤ 24, color?, align?, level?}`, at most 32; `align` `auto` `left` `right` `center`; `level` 1 (a section, the default) or 2 (a subsection of the section before it — a shorter tick in its parent's colour, a quieter label, "Section › Sub" in the section title; to every edit a section like any other; the cut's first marker must be a section) | On-screen, **markers**: add, the clip picker, label, colour, sub, align, ↑ ↓, remove | `umtool look <p> deck.markers='[{"after":"c03","label":"Rescue","align":"right"},{"after":"c05","label":"The vet","level":2}]'` · `umtool timeline <p> section-add --after c05 --label "The vet" --level 2` · `section-set <m> --level 1\|2` | `PUT /api/report/chrome {project, token, markers}` | | `render.chrome.deck.<key>` — any of the deck's own keys (`finale`, `pip`, …), as JSON; refused in the build's words when it does not know the key or the value | On-screen settings (the ones it has a field for) | `umtool look <p> deck.finale='{…}'` | — | @@ -2185,8 +2185,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–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[]` | 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), fitted to 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 wider than its cell is drawn smaller (down to 10 px), then cut with an ellipsis -- never a refused chrome; the lint names it | `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 -- one that does not fit is drawn smaller (down to 10 px), then a word or its second line is cut with an ellipsis; the lint names it | `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 @@ -2171,9 +2171,9 @@ makePlayCutFixture({ reports, deckManifest, cachedWindow: path.join(REPORT, "out }); const wsFile = path.join(wsDir, "video.manifest.json"); const wsM = JSON.parse(readFileSync(wsFile, "utf8")); - // The counter's cell word short enough for the tally's cell (play-cut-fixture's "Seizures" no longer fits since - // the tally's 72 px row): the deck COMPOSES here, so workspace.spec can say a composition failure is a regression. - wsM.render.chrome.factcheck.verdicts.CORROBORATED.tallyLabel = "Seized"; + // The counter's word is play-cut-fixture's "Seizures", wider than the tally's cell in the fixture's face: it is + // drawn smaller (factcheck.mjs fitTallyLabel) and the deck COMPOSES, so workspace.spec can say a composition + // failure is a regression. wsM.timeline.splice(2, 0, { type: "post", id: "p-5", post: "postchan-x/5", platform: "x", author: "Post Subject", handle: "postsubject", date: "2026-10-30T12:00:00.000Z", text: "The scale said 291 this morning. I said the scale was broken.", url: "https://x.com/postsubject/status/5", subjects: ["postsubject"], diff --git a/umtool/e2e/play-cut.spec.ts b/umtool/e2e/play-cut.spec.ts @@ -56,6 +56,10 @@ test("the cut plays clip after clip on one clock; prev / next / keys; the strip await expect(page.locator("[data-play-counter-end]")).toHaveText("Seizures 3"); await expect(page.locator("[data-play-strip-at]")).toContainText("Seizures 0"); await expect(page.locator("[data-play-clock]")).toContainText("00:00 / 00:09"); + // The deck composes: "Seizures" is wider than the tally's cell in the fixture's face, and is drawn smaller + // (factcheck.mjs fitTallyLabel) -- never "the chrome did not compose". + await expect(root(page)).toHaveAttribute("data-play-compose", "ready", { timeout: 60_000 }); + await expect(page.locator("[data-play-compose-error]")).toHaveCount(0); // Hovering a cell names it: the clip, its recording's date, how long it plays. await page.locator('[data-play-row="c02"]').hover(); await expect(page.locator('[data-play-strip-hover="c02"]')).toHaveText("c02 · 2 Dec 2024 · 2.9 s"); 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, TALLY_WRITTEN, tallyCues, tallyFinals, tallyKey, tallyLabelLines, tallyOf, tallyPopIns } from "./factcheck.mjs"; +import { fitTallyLabel, resolveFactcheck, TALLY_WRITTEN, tallyCues, tallyFinals, tallyKey, tallyOf, tallyPopIns } from "./factcheck.mjs"; import { resolveCounter } from "./counter.mjs"; import { SUBSECTION_SEPARATOR } from "./marker-limits.mjs"; @@ -841,14 +841,16 @@ 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; - // 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). + // Each cell's words (factcheck.mjs fitTallyLabel): the cell's own short word, else the label (or its last + // words) that fits, capitalised; AS WRITTEN (`counter.labels`), the label in up to two lines, its own case. One + // wider than its cell is drawn smaller (its own font-size, the one inline style), then cut with an ellipsis -- + // never a chrome refused. 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 cellFit = tb + ? Object.fromEntries(tally.map((v) => [v, fitTallyLabel(verdictSet[v], { fontBold, n: tally.length, labels: counter.labels })])) : {}; + const cellWords = Object.fromEntries(Object.entries(cellFit).map(([v, f]) => [v, f.lines])); 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; @@ -880,7 +882,7 @@ export function deckHtml(schedule, render, opts = {}) { ? `<div class="tshape" data-shape="${shapes[v]}" style="${shapeCss(shapes[v], 12, esc(color))}"></div>` : "") + // cellWords: its line, or (as written) its lines. - `<div class="tlabel">${cellWords[v].map(esc).join("<br>")}</div>` + + `<div class="tlabel"${cellFit[v].shortened ? ` style="font-size:${zs(cellFit[v].size)}px"` : ""}>${cellWords[v].map(esc).join("<br>")}</div>` + `<div class="tflash" data-k="${tallyKey(v, "flash")}"></div></div>` ); }) diff --git a/umtool/report-to-video/factcheck.mjs b/umtool/report-to-video/factcheck.mjs @@ -124,14 +124,14 @@ function unknownKeys(obj, allowed, where, errors) { } // --------------------------------------------------------------------------- -// The tally cell's label: it must fit, every time. +// The tally cell's label: fitted to its cell (fitTallyLabel), every time. // --------------------------------------------------------------------------- /** * The tally cell's label as chrome-deck.mjs sets it: 13 px capitals in the * deck's bold, letter-spaced 0.08 em, in the cell's width less 6 px a side - * (deck.mjs deckLayout's 124 px cell). The page ellipsizes what overruns, so - * a label is fitted HERE, before the page is written. + * (deck.mjs deckLayout's 124 px cell). A label is fitted HERE, before the + * page is written (fitTallyLabel: smaller, then cut with an ellipsis). */ export const TALLY_LABEL = Object.freeze({ size: 13, tracking: 0.08, width: COUNTER_CELL.cell - 2 * COUNTER_CELL.labelPad }); @@ -190,8 +190,8 @@ export function tallyLabelWidth(label, { fontBold = null, size = TALLY_LABEL.siz * * @returns {string|null} */ -export function tallyLabelOf(v, { fontBold = null, width = TALLY_LABEL.width } = {}) { - const fits = (s) => tallyLabelWidth(s, { fontBold }) <= width; +export function tallyLabelOf(v, { fontBold = null, width = TALLY_LABEL.width, size = TALLY_LABEL.size } = {}) { + const fits = (s) => tallyLabelWidth(s, { fontBold, size }) <= 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; @@ -210,10 +210,10 @@ export function tallyLabelOf(v, { fontBold = null, width = TALLY_LABEL.width } = * * @returns {string[]|null} */ -export function writtenLabelLines(label, { fontBold = null, width = TALLY_LABEL.width } = {}) { +export function writtenLabelLines(label, { fontBold = null, width = TALLY_LABEL.width, size = TALLY_WRITTEN.size } = {}) { 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 fits = (x) => tallyLabelWidth(x, { fontBold, size, caps: false }) <= width; const lines = []; for (const w of words) { if (!fits(w)) return null; @@ -245,33 +245,106 @@ export function tallyLabelLines(v, { fontBold = null, n = 1, labels = "caps" } = return one === null ? null : [one]; } +/** The smallest a tally label is drawn (px at 1080): one that does not fit shrinks to this, then is cut (fitTallyLabel). */ +export const TALLY_LABEL_FLOOR = 10; + /** - * 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 -- 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. + * THE TALLY LABEL FITTED TO ITS CELL -- what the cell draws, never a refusal of the whole chrome (umtool redesign + * E5): the words tallyLabelLines picks at the label's own size; else the same pick a pixel smaller at a time, down to + * TALLY_LABEL_FLOOR; else, at the floor, its words cut with an ellipsis (capitalised: its tallyLabel, else its + * label's last word; as written: its words in up to two lines, a word or the second line cut). `shortened` is what + * the lint says (tallyLabelNotes): "shrunk", "cut", or null when it is drawn as it always was. + * + * @param {{ label?: string, tallyLabel?: string }} v + * @param {{ fontBold?: string | null, n?: number, labels?: string }} [opts] + * @returns {{ lines: string[], size: number, shortened: null | "shrunk" | "cut" }} + */ +export function fitTallyLabel(v, { fontBold = null, n = 1, labels = "caps" } = {}) { + const written = labels === "as-written"; + const base = written ? TALLY_WRITTEN.size : TALLY_LABEL.size; + const same = tallyLabelLines(v, { fontBold, n, labels }); + if (same) return { lines: same, size: base, shortened: null }; + const width = tallyLabelRoom(n); + const own = typeof v?.tallyLabel === "string" && v.tallyLabel.trim() ? v.tallyLabel.trim() : null; + const words = own ?? String(v?.label ?? "").trim(); + for (let size = base - 1; size >= TALLY_LABEL_FLOOR; size -= 1) { + const lines = written + ? writtenLabelLines(words, { fontBold, width, size }) + : (() => { + const one = tallyLabelOf(v, { fontBold, width, size }); + return one === null ? null : [one]; + })(); + if (lines) return { lines, size, shortened: "shrunk" }; + } + const size = TALLY_LABEL_FLOOR; + const fits = (x) => tallyLabelWidth(x, { fontBold, size, caps: !written }) <= width; + // The longest start of `x` that fits with an ellipsis after it. + const cut = (x) => { + let chars = [...x]; + while (chars.length && !fits(`${chars.join("").trimEnd()}…`)) chars = chars.slice(0, -1); + return `${chars.join("").trimEnd()}…`; + }; + if (!written) { + const last = own ?? words.split(/\s+/).filter(Boolean).at(-1) ?? ""; + return { lines: [fits(last) ? last : cut(last)], size, shortened: "cut" }; + } + const filled = []; + for (const w of words.split(/\s+/).filter(Boolean)) { + const joined = filled.length ? `${filled[filled.length - 1]} ${w}` : null; + if (joined !== null && fits(joined)) filled[filled.length - 1] = joined; + else filled.push(w); + } + const lines = filled.length > TALLY_WRITTEN.lines ? [filled[0], filled.slice(1).join(" ")] : filled; + return { lines: lines.map((l) => (fits(l) ? l : cut(l))), size, shortened: "cut" }; +} + +/** A cell fitted to nothing but an ellipsis: the one tally label that cannot be drawn at all. */ +const noRoomAtAll = (fit) => fit.lines.every((l) => l === "…"); + +/** + * Why a counter series' words cannot be drawn in its tally cell (`deck.counter`, counter.mjs) -- in the cell a row of + * `n` gives it (design.mjs counterCell). A label wider than the cell is no reason: it is fitted (fitTallyLabel: + * shrunk, then cut) and the lint says so. Only a cell with no room for a single letter is. null when it can be drawn. */ 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 (!noRoomAtAll(fitTallyLabel({ ...s, label }, { fontBold, n, labels }))) return null; + return `${w}: the tally's cell (${n} in the row) has ${tallyLabelRoom(n)} px for its label, no room for a letter at ${TALLY_LABEL_FLOOR} px`; +} + +/** + * The lint's word on each tally label drawn shortened (fitTallyLabel): the fact-check's relabelled verdicts (one + * cell's room, as validateFactcheck measures them) and a counter's series (in their row). Notes, never refusals. + * + * @returns {string[]} + */ +export function tallyLabelNotes(render) { + const chrome = render?.chrome; + if (!isObj(chrome)) return []; + const fontBold = render.fontBold ?? null; + const out = []; + const say = (where, v, fit) => { + const words = typeof v.tallyLabel === "string" && v.tallyLabel.trim() ? `tallyLabel "${v.tallyLabel.trim()}"` : `label "${String(v.label ?? "").trim()}"`; + const how = fit.shortened === "shrunk" ? `drawn at ${fit.size} px` : `cut to "${fit.lines.join(" ")}" at ${fit.size} px`; + out.push(`${where}.${words} is wider than the tally's cell: ${how} (set ${where}.tallyLabel to a shorter word to draw it whole at its own size)`); + }; + const verdicts = isObj(chrome.factcheck?.verdicts) ? chrome.factcheck.verdicts : {}; + for (const [k, v] of Object.entries(verdicts)) { + if (!VERDICTS.includes(k) || !isObj(v) || (typeof v.label !== "string" && typeof v.tallyLabel !== "string")) continue; + const fit = fitTallyLabel({ label: v.label ?? VERDICT_DEFAULTS[k]?.label, tallyLabel: v.tallyLabel }, { fontBold }); + if (fit.shortened) say(`render.chrome.factcheck.verdicts.${k}`, v, fit); } - if (typeof s.tallyLabel === "string") { - const px = tallyLabelWidth(s.tallyLabel.trim(), { fontBold }); - 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; + const counter = isObj(chrome.deck) && isObj(chrome.deck.counter) ? chrome.deck.counter : null; + if (counter && Array.isArray(counter.series)) { + const labels = counter.labels === "as-written" ? "as-written" : "caps"; + counter.series.forEach((s, i) => { + if (!isObj(s)) return; + const v = { ...s, label: s.label ?? VERDICT_DEFAULTS[s.id]?.label ?? s.id }; + const fit = fitTallyLabel(v, { fontBold, n: counter.series.length, labels }); + if (fit.shortened) say(`render.chrome.deck.counter.series[${i}]`, v, fit); + }); } - 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${cells}, which has ${room} px, and no run of its last words fits: set ${w}.tallyLabel to a shorter word`; + return out; } /** @@ -328,16 +401,11 @@ export function validateFactcheck(f, where = "render.chrome.factcheck", { fontBo } else { errors.push(...verdictOverrideProblems(v, w)); } - // The tally cell never ellipsizes: its words fit, or the check says so. - if (isObj(v) && !errors.some((e) => e.startsWith(`${w}.`))) { - if (typeof v.tallyLabel === "string") { - const px = tallyLabelWidth(v.tallyLabel.trim(), { fontBold }); - if (px > TALLY_LABEL.width) { - errors.push(`${w}.tallyLabel "${v.tallyLabel.trim()}" is ${px} px wide in the tally's cell, which has ${TALLY_LABEL.width} px: shorten it`); - } - } else if (typeof v.label === "string" && tallyLabelOf(v, { fontBold }) === null) { - const px = tallyLabelWidth(v.label, { fontBold }); - errors.push(`${w}.label "${v.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`); + // A label wider than the tally's cell is fitted to it (fitTallyLabel) and said by the lint + // (tallyLabelNotes); only a cell with no room for a letter is refused. + if (isObj(v) && !errors.some((e) => e.startsWith(`${w}.`)) && (typeof v.tallyLabel === "string" || typeof v.label === "string")) { + if (noRoomAtAll(fitTallyLabel({ label: v.label ?? VERDICT_DEFAULTS[k]?.label, tallyLabel: v.tallyLabel }, { fontBold }))) { + errors.push(`${w}: the tally's cell has ${TALLY_LABEL.width} px for its label, no room for a letter at ${TALLY_LABEL_FLOOR} px`); } } } diff --git a/umtool/report-to-video/factcheck.test.mjs b/umtool/report-to-video/factcheck.test.mjs @@ -12,7 +12,7 @@ import test from "node:test"; import { claimOf, FACTCHECK_DEFAULTS, FACTCHECK_LIMITS, ledgerPinOf, marksOf, normalizeClaim, pinsLedgerRows, rawMarksOf, originalUrlAt, resolveFactcheck, roundStamps, STAMP_MOTION, stampSchedule, - TALLY_LABEL, TALLY_POP, tallyCues, tallyLabelOf, tallyLabelWidth, tallyOf, tallyPopIns, tallyShowAt, tallySteps, tallyVerdicts, validateClaims, validateFactcheck, VERDICTS, + fitTallyLabel, TALLY_LABEL, TALLY_LABEL_FLOOR, tallyLabelNotes, TALLY_POP, tallyCues, tallyLabelOf, tallyLabelWidth, tallyOf, tallyPopIns, tallyShowAt, tallySteps, tallyVerdicts, validateClaims, validateFactcheck, VERDICTS, } from "./factcheck.mjs"; import { VERDICT_DEFAULTS, VERDICT_LABEL_MAX, VERDICTS as COMMON_VERDICTS, @@ -498,7 +498,7 @@ for (let i = 1; i <= Math.round(dur * fps); i += 1) writeFileSync(out + "/frame_ } }); -test("the tally cell's label always fits: a tallyLabel, else the label, else its last words; refused by name when none fits", () => { +test("the tally cell's label: a tallyLabel, else the label, else its last words; one wider than its cell is fitted (shrunk, then cut) and said by the lint, never a refused chrome", () => { // The cell's width is deckLayout's cell less 6 px a side. assert.equal(TALLY_LABEL.width, deckLayout(RENDER, { tally: ["PARTLY"] }).tally.cell - 12); // Every stock label fits as it is (Fira Sans Bold and the brand's mono bold). @@ -516,11 +516,26 @@ test("the tally cell's label always fits: a tallyLabel, else the label, else its assert.equal(tallyLabelOf({ label: "Huck's Blend pitches", tallyLabel: " Pitches " }), "Pitches"); assert.deepEqual(validateFactcheck({ verdicts: { PARTLY: { label: "Huck's Blend pitches" } } }), []); assert.deepEqual(validateFactcheck({ verdicts: { PARTLY: { label: "Huck's Blend pitches", tallyLabel: "Pitches" } } }), []); - // A tallyLabel that does not fit, or a label no run of whose last words fits: refused by name. - assert.match(validateFactcheck({ verdicts: { PARTLY: { tallyLabel: "Blend pitches galore" } } })[0], - /^render\.chrome\.factcheck\.verdicts\.PARTLY\.tallyLabel "Blend pitches galore" is \d+ px wide in the tally's cell, which has 112 px: shorten it$/); - assert.match(validateFactcheck({ verdicts: { PARTLY: { label: "Misrepresentations" } } })[0], - /verdicts\.PARTLY\.label "Misrepresentations" is \d+ px wide .* set render\.chrome\.factcheck\.verdicts\.PARTLY\.tallyLabel/); + // What fits is drawn as it always was. + assert.deepEqual(fitTallyLabel({ label: "Huck's Blend pitches" }), { lines: ["Blend pitches"], size: 13, shortened: null }); + // Wider than its cell: no refusal -- shrunk a pixel at a time, then cut at the floor. + assert.deepEqual(validateFactcheck({ verdicts: { PARTLY: { tallyLabel: "Blend pitches galore" } } }), []); + assert.deepEqual(validateFactcheck({ verdicts: { PARTLY: { label: "Misrepresentations" } } }), []); + assert.deepEqual(fitTallyLabel({ label: "Uncorroborated" }), { lines: ["Uncorroborated"], size: 11, shortened: "shrunk" }); + assert.ok(tallyLabelWidth("Uncorroborated", { size: 11 }) <= TALLY_LABEL.width); + assert.deepEqual(fitTallyLabel({ label: "Misrepresentations" }), { lines: ["Misrepresentati…"], size: TALLY_LABEL_FLOOR, shortened: "cut" }); + const cut = fitTallyLabel({ tallyLabel: "Extraordinarily long misrepresentations" }); + assert.equal(cut.shortened, "cut"); + assert.equal(cut.size, TALLY_LABEL_FLOOR); + assert.equal(cut.lines[0], "Extraordinarily…"); + assert.ok(tallyLabelWidth(cut.lines[0], { size: TALLY_LABEL_FLOOR }) <= TALLY_LABEL.width); + // A face the table lacks (counted at 1.02 em, the e2e fixture's): "Seizures" is 117 px -- shrunk, and the chrome composes. + const other = { ...RENDER, fontBold: "/x/DejaVuSans-Bold.ttf", chrome: { ...CHROME, factcheck: { verdicts: { CORROBORATED: { label: "Seizures" } } } } }; + assert.ok(tallyLabelWidth("Seizures", { fontBold: other.fontBold }) > TALLY_LABEL.width); + assert.deepEqual(validateChrome(other.chrome, other), []); + // The lint names it (and nothing when every label fits). + assert.match(tallyLabelNotes(other).join("\n"), /^render\.chrome\.factcheck\.verdicts\.CORROBORATED\.label "Seizures" is wider than the tally's cell: drawn at \d+ px/); + assert.deepEqual(tallyLabelNotes({ ...RENDER, chrome: { ...CHROME, factcheck: { verdicts: { PARTLY: { label: "Huck's Blend pitches" } } } } }), []); assert.match(validateFactcheck({ verdicts: { PARTLY: { tallyLabel: "" } } })[0], /tallyLabel must be words/); // validateChrome measures in the render's own bold (here the brand's mono). const mono = { ...RENDER, fontBold: "/x/IBMPlexMono-Bold.ttf", chrome: { ...CHROME, factcheck: { verdicts: { PARTLY: { tallyLabel: "Pitches" } } } } }; @@ -536,4 +551,9 @@ test("the tally: a page whose labels fit is byte-for-byte what it was, a long on const longHtml = deckHtml(sched(long), long, {}); assert.match(longHtml, /<div class="tlabel">Coffee pitches<\/div>/); assert.doesNotMatch(longHtml, /class="tlabel">Huck/); + // Wider than its cell: drawn at its fitted size (the one inline style), never refused. + const wide = { ...RENDER, chrome: { ...CHROME, factcheck: { verdicts: { PARTLY: { label: "Uncorroborated" }, CONTRADICTED: { label: "Misrepresentations" } } } } }; + const wideHtml = deckHtml(sched(wide), wide, {}); + assert.match(wideHtml, /<div class="tlabel" style="font-size:11px">Uncorroborated<\/div>/); + assert.match(wideHtml, /<div class="tlabel" style="font-size:10px">Misrepresentati…<\/div>/); }); diff --git a/umtool/report-to-video/lint.mjs b/umtool/report-to-video/lint.mjs @@ -53,6 +53,9 @@ // and validateTeasers refuses it.) // - a QR under WARN_QR_PX_PER_MODULE_720P pixels per module at 720p: it // scans on a good screen with a steady hand, not reliably. +// - a tally label wider than its cell: drawn smaller, down to +// TALLY_LABEL_FLOOR, then cut with an ellipsis (factcheck.mjs +// fitTallyLabel) -- the chrome is never refused for it. // // THE QR ARITHMETIC. A QR's side is (17 + 4·version) modules plus its quiet // zone on each side (`render.qr.quiet`, 3 as qrencode is run here). The @@ -81,7 +84,7 @@ import { deckOn, deckQrUrl, estimateSchedule, postArchiveUrl, postNativeId, postQrUrl, resolveDeck, teaserLines, validateChrome, validateCutEdits, validateDeckMarkers, validatePosts, validateTeasers, deckClaimNotes, validateDeckClaims, } from "./deck.mjs"; -import { validateClaims } from "./factcheck.mjs"; +import { tallyLabelNotes, validateClaims } from "./factcheck.mjs"; import { validateClipAudioEntries } from "./clip-audio.mjs"; import { validateClipBlurEntries } from "./clip-blur.mjs"; import { validateGapEntries } from "./gaps.mjs"; @@ -447,6 +450,8 @@ export function lintManifest(manifest, { // refusal); a twocrop clip's band drawn past ENLARGE_WARN times its source's pixels (a 16:9 source of the cut's // `maxHeightSource`, 1080 by default: the build says it again from the real one); a twocrop where no stacked deck plays it. if (!only) warnings.push(...stackedLeftOut(manifest)); + // A tally label wider than its cell, drawn smaller or cut (factcheck.mjs fitTallyLabel): said, never refused. + if (!only) warnings.push(...tallyLabelNotes(render)); warnings.push(...stackedLintWarnings(manifest, { only })); for (const { where, src } of imageSrcsOf(manifest, { only })) { diff --git a/umtool/report-to-video/modules/counter.mjs b/umtool/report-to-video/modules/counter.mjs @@ -43,8 +43,8 @@ export default defineModule({ 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–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[]`", "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), fitted to 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 wider than its cell is drawn smaller (down to 10 px), then cut with an ellipsis -- never a refused chrome; the lint names it", "`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 -- one that does not fit is drawn smaller (down to 10 px), then a word or its second line is cut with an ellipsis; the lint names it", "`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,7 +5,7 @@ import assert from "node:assert/strict"; import { counterOrder, resolveCounter, validateCounter, VERDICT_SHAPES } from "../counter.mjs"; import { - claimOf, counterLabelProblem, marksOf, normalizeClaim, resolveFactcheck, tallyAlways, tallyCells, tallyCellsFrom, tallyCues, tallyFinals, tallyLabelLines, + claimOf, counterLabelProblem, fitTallyLabel, tallyLabelNotes, marksOf, normalizeClaim, resolveFactcheck, tallyAlways, tallyCells, tallyCellsFrom, tallyCues, tallyFinals, tallyLabelLines, tallyOf, tallyShowAt, validateClaims, writtenLabelLines, } from "../factcheck.mjs"; import { deckLayout, estimateSchedule, validateChrome } from "../deck.mjs"; @@ -63,9 +63,10 @@ test("validateCounter: every shape refused in a sentence; one home for the serie assert.match(validateCounter({ series: [{ id: "a", label: "A", shape: "star" }] })[0], /shape must be one of/); assert.match(validateCounter({ series: SERIES, colour: 1 })[0], /colour is not a counter setting/); assert.match(validateCounter({ series: SERIES }, { factcheck: { verdicts: {} } })[0], /replaces render.chrome.factcheck.verdicts/); - // Through the deck's validator: the cell's fit, as the verdicts' labels are held. - const long = validateChrome(render({ counter: { series: [{ id: "a", label: "Extraordinarilylong" }] } }).chrome, render()); - assert.match(long.join("\n"), /no run of its last words fits: set render.chrome.deck.counter.series\[0\].tallyLabel/); + // Through the deck's validator: a label wider than its cell is fitted, never refused -- the lint says so. + const wide = render({ counter: { series: [{ id: "a", label: "Extraordinarilylong" }] } }); + assert.deepEqual(validateChrome(wide.chrome, render()), []); + assert.match(tallyLabelNotes(wide).join("\n"), /^render\.chrome\.deck\.counter\.series\[0\]\.label "Extraordinarilylong" is wider than the tally's cell: (drawn at|cut to)/); assert.deepEqual(validateChrome(render({ counter: { series: SERIES } }).chrome, render()), []); }); @@ -178,9 +179,12 @@ test("past 8 series the cells narrow into one row (up to 12); as written, a labe // 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. + // Its fit check, in the row it stands in: a word wider than a 12-cell row's room is fitted (drawn smaller), never refused. 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/); + assert.equal(counterLabelProblem({ id: "a", label: "conservative" }, "w", { n: 12, labels: "as-written" }), null); + const fit = fitTallyLabel({ label: "conservative" }, { n: 12, labels: "as-written" }); + assert.deepEqual([fit.lines, fit.shortened], [["conservative"], "shrunk"]); + assert.ok(fit.size < 13); // 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 })); diff --git a/umtool/report-to-video/modules/design.mjs b/umtool/report-to-video/modules/design.mjs @@ -25,8 +25,8 @@ 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. + * 12 are 72; a label that does not fit its narrower cell is drawn smaller, + * then cut (factcheck.mjs fitTallyLabel). */ export const COUNTER_DENSE = Object.freeze({ budget: 1040, gap: 8, from: 9 });