commit 5ee40d9cc480f77341170b442e3c14fdcea262f4
parent 053d9be096e94e9950f7a934c71c452b4dc87f8f
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Wed, 28 Oct 2026 23:19:49 -0400
umtool: the deck's pieces as modules -- counter series, migrateManifest, a configurable intro
Ported onto the contract (report-to-video/modules/):
- Parts of the shell's page, each with its home, defaults, validator, UI
descriptor and docs: subtitle, qr, rail (pip.spacing gains "pitch" and
pip.pitch), counter, claims. Segments and inputs: intro, blur, teaser.
The region modules gain their settings, validators and docs.
- modules/settings.mjs (a leaf) holds every module's validator and the
deck's constants; deck.mjs's validateChrome runs them in one list and
re-exports the constants under their old names. moduleProblems() and
scheduleSlices() give each module its own sentences and slice.
- The COUNTER: named series {id, label, color, stampLabel, tallyLabel,
showAt, shape, unit} at render.chrome.deck.counter (counter.mjs
resolveCounter / validateCounter). Without it, the series are the
verdicts, as ever. A mark names its series by `verdict` or the alias
`counter`; a deck claim's tally by id or label; the finale's stamp clamp
is the counter's rule (stampsWithFinale) reading the finale's window.
- migrateManifest (pure, idempotent): factcheck.verdicts/tally become
deck.counter (every verdict a series, its id the verdict), a deck
claim's tally by id. `umtool migrate <p> [--dry-run]` writes it through
manifest.mjs migrateManifestFile (lock, token, auto snapshot).
- The intro's brand is configurable: render.intro.brand (the kit),
.suffix ("lyzer"), .projectUrl (or false); unset, the same page.
Checked: the Huck manifest and its migration draw byte-identical
schedules and deck, stamp, feed, finale and intro pages (main's code
against this branch's).
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
35 files changed, 1792 insertions(+), 340 deletions(-)
diff --git a/common/lib/report/intro.d.mts b/common/lib/report/intro.d.mts
@@ -13,6 +13,8 @@ export type IntroSite = "auto" | "none" | string | IntroSiteObject;
export type Intro = {
style: string; ground: IntroGround; mark: IntroMark; sound: string | false | undefined; seconds: number;
site?: IntroSite; swap?: IntroSwap; url?: IntroUrlMode; urlPlace?: IntroUrlPlace;
+ /** The brand (release 39): the kit it draws, the suffix a site's name keeps, the project URL the swap writes. */
+ brand?: string; suffix?: string; projectUrl?: string | false;
};
export const INTRO_STYLES: readonly string[];
@@ -32,9 +34,11 @@ export const INTRO_URLS: readonly Exclude<IntroUrlMode, "none">[];
export const INTRO_URL_PLACES: readonly IntroUrlPlace[];
export const INTRO_SITE_DEFAULTS: Readonly<{ swap: IntroSwap; url: IntroUrlMode; urlPlace: IntroUrlPlace }>;
export const INTRO_SUFFIX: string;
+export const INTRO_BRAND_DEFAULT: string;
+export const INTRO_PROJECT_URL: string;
export function introUrlMode(v: unknown): IntroUrlMode;
export function introUrlText(u: unknown): string;
-export function introSitePrefix(name: unknown): string;
+export function introSitePrefix(name: unknown, suffix?: string): string;
export function introSiteErrors(site: unknown): string[];
export const INTRO_SECONDS: number;
export const INTRO_SECONDS_MIN: number;
diff --git a/common/lib/report/intro.mjs b/common/lib/report/intro.mjs
@@ -110,9 +110,15 @@ export const INTRO_URL_PLACES = Object.freeze(["under", "replace"]);
/** The swap's defaults: the operator's pick. */
export const INTRO_SITE_DEFAULTS = Object.freeze({ swap: "swipe-down", url: "both", urlPlace: "under" });
-/** The family's shared suffix: what a site's name keeps of "Archilyzer". */
+/** The family's shared suffix: what a site's name keeps of "Archilyzer". `render.intro.suffix` sets another brand's. */
export const INTRO_SUFFIX = "lyzer";
+/** The brand kit the intro draws (report-to-video brands/<id>.json) unless `render.intro.brand` names another. */
+export const INTRO_BRAND_DEFAULT = "archilyzer-media";
+
+/** The project's URL as the swap writes it, unless `render.intro.projectUrl` sets another (or false: none). */
+export const INTRO_PROJECT_URL = "archilyzer.pages.dev";
+
/** The intro's timeline id (its segment is segments/<id>.mp4). */
export const INTRO_ID = "brand-intro";
@@ -135,6 +141,11 @@ export function introOf(render) {
mark: INTRO_MARKS.includes(o.mark) ? o.mark : (INTRO_STYLE_MARK[style] ?? "none"),
sound: o.sound === false || typeof o.sound === "string" ? o.sound : undefined,
seconds: Number.isFinite(o.seconds) ? o.seconds : INTRO_SECONDS,
+ // The brand's knobs only when set: an intro without them reads exactly
+ // as it did before they existed (the Archilyzer kit, "lyzer", its URL).
+ ...(typeof o.brand === "string" && o.brand ? { brand: o.brand } : {}),
+ ...(typeof o.suffix === "string" && o.suffix ? { suffix: o.suffix } : {}),
+ ...(o.projectUrl === false || (typeof o.projectUrl === "string" && o.projectUrl) ? { projectUrl: o.projectUrl } : {}),
// The site's knobs only when there is a site: an intro without one reads
// exactly as it did before the key existed.
...(site
@@ -168,9 +179,9 @@ export const introUrlText = (u) => String(u ?? "").trim().replace(/^[a-z][a-z0-9
* wordmark that changes; `lead` (the site's wordmarkLead) only says which of
* its letters are heavy.
*/
-export function introSitePrefix(name) {
+export function introSitePrefix(name, suffix = INTRO_SUFFIX) {
const n = String(name ?? "");
- return n.length > INTRO_SUFFIX.length && n.endsWith(INTRO_SUFFIX) ? n.slice(0, -INTRO_SUFFIX.length) : n;
+ return n.length > suffix.length && n.endsWith(suffix) ? n.slice(0, -suffix.length) : n;
}
/** Every reason `site` (a `render.intro.site`) cannot be drawn, as sentences naming the key. */
@@ -197,7 +208,7 @@ export function introSiteErrors(site) {
return errors;
}
-const KEYS = ["style", "ground", "mark", "sound", "seconds", "site", "swap", "url", "urlPlace"];
+const KEYS = ["style", "ground", "mark", "sound", "seconds", "site", "swap", "url", "urlPlace", "brand", "suffix", "projectUrl"];
/** Every reason `value` (a `render.intro`) cannot be built, as sentences naming the key. */
export function introErrors(value) {
@@ -231,6 +242,17 @@ export function introErrors(value) {
if (o.urlPlace !== undefined && !INTRO_URL_PLACES.includes(o.urlPlace)) {
errors.push(`render.intro.urlPlace must be ${INTRO_URL_PLACES.join(" or ")}, got ${JSON.stringify(o.urlPlace)}`);
}
+ // The brand (release 39): which kit it draws, the suffix a site's name
+ // keeps of it, the project URL the swap writes.
+ if (o.brand !== undefined && !(typeof o.brand === "string" && /^[a-z0-9][a-z0-9-]{0,39}$/.test(o.brand))) {
+ errors.push(`render.intro.brand must be a brand kit's id (e.g. "${INTRO_BRAND_DEFAULT}"), got ${JSON.stringify(o.brand)}`);
+ }
+ if (o.suffix !== undefined && !(typeof o.suffix === "string" && /^[A-Za-z]{1,16}$/.test(o.suffix))) {
+ errors.push(`render.intro.suffix must be the letters a site's name keeps of the brand's (e.g. "${INTRO_SUFFIX}"), 1 to 16, got ${JSON.stringify(o.suffix)}`);
+ }
+ if (o.projectUrl !== undefined && o.projectUrl !== false && !(typeof o.projectUrl === "string" && introUrlText(o.projectUrl))) {
+ errors.push(`render.intro.projectUrl must be the project's URL (e.g. "${INTRO_PROJECT_URL}") or false (none)`);
+ }
return errors;
}
diff --git a/umtool/bin/umtool.mjs b/umtool/bin/umtool.mjs
@@ -732,6 +732,8 @@ function usage() {
" umtool look <project> key=value … the cut's knobs: factcheck.stamp.scale|motion|opacity|seconds,",
" factcheck.verdicts.<V>.stampLabel|label|color, deck.markers=<json>, deck.markerLayout,",
" variants=<json>, and the look's keys (transition=0.3, …)",
+ " umtool migrate <project> [--dry-run] [--json] move the manifest into the video modules' homes",
+ " (the fact-check verdicts and tally become deck.counter's series); renders the same",
" umtool variants <project> [--take <t>] [--list] [--json] make the encode ladder of a build (render.variants);",
" --list: what was made, and the build's sync report (each clip's lag, past a frame flagged)",
" umtool corrections <project> what the report got wrong + the walk's coverage",
@@ -841,6 +843,8 @@ const COMMANDS = {
// The video knobs (plans/video-knobs-ui.md): lib/report/knobsCli.mjs.
set: async () => process.exit(await (await import("../lib/report/knobsCli.mjs")).setCommand(argv.slice(argv.indexOf("set") + 1))),
look: async () => process.exit(await (await import("../lib/report/knobsCli.mjs")).lookCommand(argv.slice(argv.indexOf("look") + 1))),
+ // The video modules' homes (release 39): lib/report/migrateCli.mjs.
+ migrate: async () => process.exit(await (await import("../lib/report/migrateCli.mjs")).migrateCommand(argv.slice(argv.indexOf("migrate") + 1))),
variants: async () => process.exit(await (await import("../lib/report/knobsCli.mjs")).variantsCommand(argv.slice(argv.indexOf("variants") + 1))),
corrections: cmdCorrections,
build: cmdBuild,
diff --git a/umtool/lib/report/manifest.mjs b/umtool/lib/report/manifest.mjs
@@ -41,6 +41,7 @@ import { validateRoom } from "umtool-report-to-video/room";
import { applySectionEnter } from "./sections.mjs";
import { parseClipSpec } from "./clipEditorModel.mjs";
import { normalizeClaim, validateClaims } from "umtool-report-to-video/factcheck";
+import { migrateManifest } from "umtool-report-to-video/modules/migrate";
import { validateFinaleEntries } from "umtool-report-to-video/finale";
import { validateClipAudio } from "umtool-report-to-video/clip-audio";
import { BLUR_CAPTION_DEFAULT, BLUR_STRENGTH, validateClipBlur, validateClipBlurEntries } from "umtool-report-to-video/clip-blur";
@@ -2164,6 +2165,39 @@ export async function replaceManifest(dir, manifest, { token = null, op = "repla
}
/**
+ * Migrate the manifest into the video modules' homes (release 39,
+ * report-to-video modules/migrate.mjs `migrateManifest`): the fact-check
+ * verdicts and tally become the counter's named series, and the cut renders
+ * as it did. The same path as a structural edit -- the lock, the token, the
+ * auto snapshot (`auto-before-migrate`, so "Undo last edit" takes it back),
+ * the atomic write -- refused when the result carries a problem the
+ * renderer's validators name that the manifest did not. `dryRun` writes
+ * nothing. Nothing to migrate: nothing written, `changes` empty.
+ *
+ * @param {string} dir
+ * @param {{ token?: string | null, dryRun?: boolean }} [opts]
+ * @returns {Promise<{ changes: string[], manifest: Record<string, any>, token?: string | null, snapshot?: unknown }>}
+ */
+export async function migrateManifestFile(dir, { token = null, dryRun = false } = {}) {
+ const problems = (m) => {
+ const { chrome, ...rest } = m.render ?? {};
+ return [...validateChrome(chrome, rest), ...validateClaims(m)];
+ };
+ const current = JSON.parse(await readFile(manifestFile(dir), "utf8"));
+ const planned = migrateManifest(current);
+ if (dryRun || !planned.changes.length) return { changes: planned.changes, manifest: planned.manifest };
+ return structural(dir, "migrate", token, (m) => {
+ const { manifest: next, changes } = migrateManifest(m);
+ const already = new Set(problems(m));
+ const errors = problems(next).filter((e) => !already.has(e));
+ if (errors.length) throw new StructureRefused(errors);
+ for (const k of Object.keys(m)) delete m[k];
+ Object.assign(m, next);
+ return { changes, manifest: next };
+ });
+}
+
+/**
* Take back the newest structural edit: restore the newest `auto-before-<op>`
* snapshot, byte for byte. The manifest as it is now is kept first
* (`undo-saved`), and the restored snapshot is renamed `undone-<op>` so the
diff --git a/umtool/lib/report/migrateCli.mjs b/umtool/lib/report/migrateCli.mjs
@@ -0,0 +1,60 @@
+// `umtool migrate` (release 39, the video-modules toolkit): a project's
+// manifest moved into the modules' homes -- the fact-check verdicts and tally
+// become the counter's named series (report-to-video modules/migrate.mjs) --
+// through the one writer (manifest.mjs `migrateManifestFile`: the lock, the
+// token, an `auto-before-migrate` snapshot, refused on a problem the
+// renderer's validators would name). The cut renders as it did.
+//
+// umtool migrate <project> [--dry-run] [--json]
+//
+// Plain ESM: the CLI runs under bare node.
+import { REPORTS_ROOT, resolveProject } from "../projects/core.mjs";
+import { manifestToken, migrateManifestFile } from "./manifest.mjs";
+
+export const MIGRATE_USAGE = [
+ "usage: umtool migrate <project> [--dry-run] [--json]",
+ "",
+ "Moves the manifest's settings into the video modules' homes (report-to-video/modules/migrate.mjs):",
+ "the fact-check verdicts and tally become render.chrome.deck.counter's named series, a deck claim's",
+ "tally names its series by id. The render is the same, frame for frame. --dry-run prints the moves",
+ "and writes nothing; a manifest already migrated is left as it is.",
+].join("\n");
+
+/**
+ * @param {string[]} args
+ * @param {{ root?: string, out?: (s: string) => void, err?: (s: string) => void }} [io]
+ * @returns {Promise<number>}
+ */
+export async function migrateCommand(args, { root = REPORTS_ROOT, out = (s) => console.log(s), err = (s) => console.error(s) } = {}) {
+ const words = args.filter((a) => !a.startsWith("--"));
+ const dryRun = args.includes("--dry-run");
+ const json = args.includes("--json");
+ if (!words[0] || args.includes("--help")) {
+ err(MIGRATE_USAGE);
+ return 2;
+ }
+ const r = await resolveProject(words[0], root);
+ if (r.ambiguous) {
+ err(`"${words[0]}" is the name of ${r.ambiguous.length} projects — pass its id`);
+ return 1;
+ }
+ if (!r.project) {
+ err(`no project matches "${words[0]}"`);
+ return 1;
+ }
+ try {
+ const token = await manifestToken(r.project.dir);
+ const res = await migrateManifestFile(r.project.dir, { token, dryRun });
+ if (json) out(JSON.stringify({ project: r.project.id, dryRun, changes: res.changes, ...(res.token ? { token: res.token } : {}) }));
+ else if (!res.changes.length) out(`${r.project.id}: nothing to migrate`);
+ else {
+ out(`${r.project.id}: ${dryRun ? "would migrate" : "migrated"}`);
+ for (const c of res.changes) out(` ${c}`);
+ }
+ return 0;
+ } catch (e) {
+ const errors = /** @type {any} */ (e)?.errors;
+ err(Array.isArray(errors) ? `refused:\n ${errors.join("\n ")}` : String(/** @type {any} */ (e)?.message ?? e));
+ return 1;
+ }
+}
diff --git a/umtool/report-to-video/chrome-deck.mjs b/umtool/report-to-video/chrome-deck.mjs
@@ -41,7 +41,8 @@ import {
claimsLayout, cueTime, cueTimeAfter, stampsOnFrames, deckChoreography, deckLayout, deckMarkers, MARKER_LABEL_SIZE, MARKER_ROW, pageDuration, pipSegments, pipXs, resolveDeck,
} from "./deck.mjs";
import { claimsCues, claimsMarkup } from "./chrome-claims.mjs";
-import { resolveFactcheck, tallyCues, tallyFinals, tallyKey, tallyLabelOf, tallyOf, tallyPopIns, VERDICT_SHAPES } from "./factcheck.mjs";
+import { resolveFactcheck, tallyCues, tallyFinals, tallyKey, tallyLabelOf, tallyOf, tallyPopIns } from "./factcheck.mjs";
+import { resolveCounter } from "./counter.mjs";
/**
* GSAP, vendored, for every chrome region.
@@ -406,6 +407,9 @@ export function deckHtml(schedule, render, opts = {}) {
// The verdicts' colours as the tally draws them (relabels and recolours
// included), so a claimed pip and its tally cell are the same colour.
const verdictColors = resolveFactcheck(render).verdicts;
+ // The counter's series (counter.mjs): their order and each one's shape.
+ const counter = resolveCounter(render);
+ const shapes = counter.shapes;
const byVerdict = pip.color === "verdict";
// The lift: a few percent toward the foreground, so the deck reads as a
@@ -452,9 +456,9 @@ export function deckHtml(schedule, render, opts = {}) {
const color = verdictColors[p.verdict]?.color ?? pal.accent;
return (
base +
- `<div class="pip lit vpip" data-k="pip${k}" data-verdict="${esc(p.verdict)}" data-shape="${VERDICT_SHAPES[p.verdict]}" ` +
+ `<div class="pip lit vpip" data-k="pip${k}" data-verdict="${esc(p.verdict)}" data-shape="${shapes[p.verdict]}" ` +
`style="left:${r4(p.x - vSize / 2)}px; top:${r4(-vSize / 2)}px; width:${vSize}px; height:${vSize}px; ` +
- `${shapeCss(VERDICT_SHAPES[p.verdict], vSize, esc(color))}"></div>`
+ `${shapeCss(shapes[p.verdict], vSize, esc(color))}"></div>`
);
})
.join("");
@@ -487,7 +491,7 @@ export function deckHtml(schedule, render, opts = {}) {
? `<div class="tally">` +
tally
.map((v, j) => {
- const finals = tallyFinals(schedule.factcheck.stamps)[v];
+ const finals = tallyFinals(schedule.factcheck.stamps, counter.order)[v];
const color = verdictSet[v].color;
const nums = Array.from({ length: finals + 1 }, (_, k) =>
`<div class="tn" data-k="${tallyKey(v, `n${k}`)}">${k}</div>`).join("");
@@ -500,7 +504,7 @@ export function deckHtml(schedule, render, opts = {}) {
// top corner (the label keeps its width): the key a viewer who
// cannot tell the colours apart reads the rail by.
(byVerdict
- ? `<div class="tshape" data-shape="${VERDICT_SHAPES[v]}" style="${shapeCss(VERDICT_SHAPES[v], 12, esc(color))}"></div>`
+ ? `<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.
diff --git a/umtool/report-to-video/chrome-finale.mjs b/umtool/report-to-video/chrome-finale.mjs
@@ -25,7 +25,8 @@
import { cueTime, cueTimeAfter, finaleRail, pageDuration, resolveDeck } from "./deck.mjs";
import { finaleClaimsMarkup } from "./chrome-claims.mjs";
import { mix, rgba, shapeCss, subtitleMarkup } from "./chrome-deck.mjs";
-import { resolveFactcheck, tallyFinals, tallyOf, tallyVerdicts, VERDICT_SHAPES } from "./factcheck.mjs";
+import { resolveFactcheck, tallyFinals, tallyOf, tallyVerdicts } from "./factcheck.mjs";
+import { resolveCounter } from "./counter.mjs";
import { aboveTop, FINALE_CLAIMS, FINALE_MOTION, finaleGeometry, resolveFinale } from "./finale.mjs";
/** Instant cues still take a millisecond: a zero-duration tween has its own seek rules. */
@@ -61,7 +62,8 @@ export function finaleLayout(schedule, render) {
const fc = resolveFactcheck(render);
const pal = render.palette;
const stamps = schedule.factcheck?.stamps ?? [];
- const verdicts = f.totals && stamps.length ? tallyVerdicts(stamps) : [];
+ const counter = resolveCounter(render);
+ const verdicts = f.totals && stamps.length ? tallyVerdicts(stamps, counter.order) : [];
// The large rail (deck.mjs finaleRail): in the room the schedule gave it.
const R = finaleRail(schedule, render, { railBottom: fin.railBottom ?? finaleGeometry(render).rail.bottom, textScale: fin.textScale ?? 1 });
const { geo, x0, labels, marks, claims, lay, fxs, footSize } = R;
@@ -74,13 +76,13 @@ export function finaleLayout(schedule, render) {
const tally = tallyOf(schedule, render);
// The totals: the tally's verdicts, each at its final count.
- const finals = tallyFinals(stamps);
+ const finals = tallyFinals(stamps, counter.order);
const tb = lay.tally ?? null;
const T = geo.totals;
const totals = T
? verdicts.map((v, j) => ({
verdict: v, count: finals[v], label: verdictColors[v]?.label ?? v, color: verdictColors[v]?.color ?? pal.accent,
- shape: VERDICT_SHAPES[v], x: T.x + j * (T.cell + T.gap), y: T.y, width: T.cell, height: T.height,
+ shape: counter.shapes[v], x: T.x + j * (T.cell + T.gap), y: T.y, width: T.cell, height: T.height,
...(tb && tally?.[j] === v ? { foot: { x: tb.x + j * (tb.cell + tb.gap), y: deckY + tb.y, width: tb.cell, height: tb.height } } : {}),
}))
: [];
diff --git a/umtool/report-to-video/chrome-intro.mjs b/umtool/report-to-video/chrome-intro.mjs
@@ -17,7 +17,9 @@
// a render is a seek per frame, from parallel workers, in any order). Every
// cue is a fromTo whose FROM is stated; the page is a dumb interpreter of
// `introCues`, so the tests read every time it uses.
-import { INTRO_BEATS, INTRO_SITE_DEFAULTS, INTRO_STYLE_MARK, introSitePrefix } from "yt-dlp-transcript-common/lib/report/intro.mjs";
+import {
+ INTRO_BEATS, INTRO_PROJECT_URL, INTRO_SITE_DEFAULTS, INTRO_STYLE_MARK, INTRO_SUFFIX, introSitePrefix, introUrlText,
+} from "yt-dlp-transcript-common/lib/report/intro.mjs";
import { pageDuration } from "./deck.mjs";
import { INTRO_GLYPHS, INTRO_GLYPH_CAP, INTRO_GLYPH_UPEM } from "./intro-glyphs.mjs";
@@ -147,8 +149,12 @@ export function lockupParts(kit) {
// The site swap (`render.intro.site`).
// ---------------------------------------------------------------------------
-/** The project's own URL, as the intro writes it: common/lib/project.ts PROJECT_URL without its scheme. */
-export const PROJECT_URL_TEXT = "archilyzer.pages.dev";
+/**
+ * The project's own URL, as the intro writes it: common/lib/project.ts
+ * PROJECT_URL without its scheme -- the default; `render.intro.projectUrl`
+ * sets another brand's (or false: none).
+ */
+export const PROJECT_URL_TEXT = INTRO_PROJECT_URL;
/** The weights the swap draws in (intro-glyphs.mjs): the wordmark's lead and suffix, and the URLs. */
const W_LEAD = 720;
@@ -241,12 +247,15 @@ export function setRun(text, { size, track = 0, weightOf = () => W_URL, x = 0, b
* it. A lead that runs into "lyzer" (Bonnell|yzer) takes those letters too; a
* name not ending in "lyzer" swaps the whole word.
*/
-export function swapPlan({ parts, site, url = INTRO_SITE_DEFAULTS.url, urlPlace = INTRO_SITE_DEFAULTS.urlPlace, markX = null }) {
+export function swapPlan({
+ parts, site, url = INTRO_SITE_DEFAULTS.url, urlPlace = INTRO_SITE_DEFAULTS.urlPlace, markX = null,
+ suffix = INTRO_SUFFIX, projectUrl = PROJECT_URL_TEXT,
+}) {
const word = parts.letters.filter((l) => l.role !== "media");
const media = parts.letters.filter((l) => l.role === "media");
const nW = word.length;
const name = String(site.name);
- let prefix = introSitePrefix(name);
+ let prefix = introSitePrefix(name, suffix);
const lead = typeof site.lead === "string" && name.startsWith(site.lead) && site.lead.length < name.length ? site.lead : null;
if (lead && lead.length > prefix.length) prefix = name.slice(0, lead.length);
const keep = name.length - prefix.length;
@@ -309,7 +318,8 @@ export function swapPlan({ parts, site, url = INTRO_SITE_DEFAULTS.url, urlPlace
const siteUrl = typeof site.url === "string" && site.url ? site.url : null;
const texts = [];
if ((url === "both" || url === "site") && siteUrl) texts.push({ text: siteUrl, tone: "site" });
- if (url === "both" || url === "project") texts.push({ text: PROJECT_URL_TEXT, tone: "project" });
+ const project = projectUrl === false ? null : introUrlText(projectUrl) || null;
+ if ((url === "both" || url === "project") && project) texts.push({ text: project, tone: "project" });
const urls = [];
const cap = INTRO_GLYPH_CAP / INTRO_GLYPH_UPEM;
let bottom = parts.bottom;
@@ -711,6 +721,7 @@ function markShapes(mark) {
export function introHtml({
style, ground, mark = INTRO_STYLE_MARK[style] ?? "none", seconds, width = 1920, height = 1080, fps = 30, kit, gsapSrc = "assets/gsap.min.js",
site = null, swap = INTRO_SITE_DEFAULTS.swap, url = INTRO_SITE_DEFAULTS.url, urlPlace = INTRO_SITE_DEFAULTS.urlPlace,
+ suffix = INTRO_SUFFIX, projectUrl = PROJECT_URL_TEXT,
}) {
const W = width;
const H = height;
@@ -734,7 +745,7 @@ export function introHtml({
// centring -- so on the chime it only ever moves sideways, never a vertical
// lift (operator, 2026-10-26).
const oy = r3(H / 2 - ((y0 + y1) / 2) * k);
- const plan = site ? swapPlan({ parts, site, url, urlPlace, markX: withMark ? parts.mark.x : null }) : null;
+ const plan = site ? swapPlan({ parts, site, url, urlPlace, markX: withMark ? parts.mark.x : null, suffix, projectUrl }) : null;
const accent = site ? introAccent(site.accent, ground, palette) : null;
const lift = 0;
const { init, cues } = introCues({
diff --git a/umtool/report-to-video/counter.mjs b/umtool/report-to-video/counter.mjs
@@ -0,0 +1,184 @@
+// THE COUNTER (release 39): the deck's running tally, generalised from the
+// fact-check verdicts to arbitrary NAMED SERIES.
+//
+// render.chrome.deck.counter: {
+// "series": [ { "id": "seizures", "label": "Seizures", "color": "#e5534b",
+// "stampLabel": "Seizure", "tallyLabel": "Fits", "showAt": "first",
+// "unit": "seizures", "shape": "diamond" }, … ],
+// "show": true, "position": "right", "showAt": "always"
+// }
+//
+// A clip's MARK names the series it counts by id (`claim.verdict`, or its
+// alias `claim.counter`), and the counter steps as its stamp lands
+// (factcheck.mjs `stampSchedule`, `tallySteps`). The series are the tally's
+// cells, in the order listed; a deck claim (`deck.claims[].tally`) names one
+// by id or label.
+//
+// BACK-COMPAT: without `counter`, the series are the fact-check verdicts
+// (common's VERDICTS, in that order) with `render.chrome.factcheck.verdicts`'s
+// relabels and `factcheck.tally`'s show/position/showAt -- exactly what the
+// tally always drew. `migrateManifest` (modules/migrate.mjs) writes that as
+// a `counter` the bytes of whose render are the same. A series whose id is a
+// verdict takes that verdict's default label, colour and shape.
+//
+// PURE: no fs. factcheck.mjs, deck.mjs and the pages read `resolveCounter`;
+// modules/counter.mjs validates and documents it.
+import { VERDICT_DEFAULTS, VERDICT_COLOR_RE, VERDICT_LABEL_MAX, VERDICTS } from "yt-dlp-transcript-common/lib/report/verdicts.mjs";
+
+/** A series' cell shape, so a viewer who cannot tell the colours apart can tell the series apart. */
+export const COUNTER_SHAPES = Object.freeze(["circle", "diamond", "square", "triangle", "ring"]);
+
+/** Each verdict's shape (VERDICTS order): what a verdict series takes by default. */
+export const VERDICT_SHAPES = Object.freeze(Object.fromEntries(VERDICTS.map((v, i) => [v, COUNTER_SHAPES[i] ?? "circle"])));
+
+/** When a cell is on screen: from the first frame (dim at 0), or from its first count. */
+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 });
+
+/** 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}$/;
+
+/** A custom series' colour when it names none, by its place in the list. */
+export const SERIES_COLORS = Object.freeze(["#e5534b", "#e3b23c", "#3fbf7f", "#7d8fd6", "#c55f9c", "#22ab83", "#d2732f", "#8b93a7"]);
+
+/** The keys a series may carry. */
+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"]);
+
+const isObj = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
+
+/** Is `render` counting named series (`deck.counter`) rather than the fact-check verdicts? */
+export const counterOn = (render) => isObj(render?.chrome?.deck?.counter);
+
+/**
+ * The counter resolved: `series` (each `{ id, label, color, stampLabel?,
+ * tallyLabel?, showAt, shape, unit? }`, in the tally's order), `order` (their
+ * ids), `byId` (each `{ label, color, stampLabel?, tallyLabel? }` -- the shape
+ * `resolveVerdicts` has always given, so every reader of a verdict's label and
+ * colour reads a series' the same way), `shapes`, `showAt` (id → "always" |
+ * "first"), `show`, `position`, and `custom` (a `deck.counter` was given).
+ * A shape no validator would pass reads as what it can.
+ */
+export function resolveCounter(render) {
+ const c = render?.chrome?.deck?.counter;
+ const f = isObj(render?.chrome?.factcheck) ? render.chrome.factcheck : {};
+ const one = (v) => (COUNTER_SHOW_AT.includes(v) ? v : "always");
+ if (isObj(c)) {
+ const list = (Array.isArray(c.series) ? c.series : []).filter((s) => isObj(s) && typeof s.id === "string" && SERIES_ID_RE.test(s.id));
+ const series = list.map((s, i) => {
+ const { id, showAt, unit, shape, ...look } = s;
+ const base = VERDICT_DEFAULTS[id] ?? { label: id, color: SERIES_COLORS[i % SERIES_COLORS.length] };
+ return {
+ id,
+ ...base,
+ ...look,
+ showAt: one(showAt ?? c.showAt),
+ shape: COUNTER_SHAPES.includes(shape) ? shape : (VERDICT_SHAPES[id] ?? COUNTER_SHAPES[i % COUNTER_SHAPES.length]),
+ ...(typeof unit === "string" && unit.trim() ? { unit: unit.trim() } : {}),
+ };
+ });
+ return {
+ custom: true,
+ series,
+ order: series.map((s) => s.id),
+ byId: Object.fromEntries(series.map(({ id, showAt: _a, shape: _s, unit: _u, ...look }) => [id, look])),
+ shapes: Object.fromEntries(series.map((s) => [s.id, s.shape])),
+ showAt: Object.fromEntries(series.map((s) => [s.id, s.showAt])),
+ show: c.show !== false,
+ position: COUNTER_POSITIONS.includes(c.position) ? c.position : "right",
+ };
+ }
+ // The fact-check verdicts, as the tally always counted them.
+ const given = isObj(f.verdicts) ? f.verdicts : {};
+ const tally = isObj(f.tally) ? f.tally : {};
+ const byId = {};
+ for (const v of VERDICTS) byId[v] = { ...VERDICT_DEFAULTS[v], ...(isObj(given[v]) ? given[v] : {}) };
+ const w = tally.showAt;
+ const showAt = Object.fromEntries(VERDICTS.map((v) => [v, isObj(w) ? one(w[v]) : one(w)]));
+ return {
+ custom: false,
+ series: VERDICTS.map((id) => ({ id, ...byId[id], showAt: showAt[id], shape: VERDICT_SHAPES[id] })),
+ order: [...VERDICTS],
+ byId,
+ shapes: { ...VERDICT_SHAPES },
+ showAt,
+ show: tally.show !== false,
+ position: COUNTER_POSITIONS.includes(tally.position) ? tally.position : "right",
+ };
+}
+
+/** The series ids a mark may name: the counter's, else the verdicts. */
+export const counterOrder = (render) => resolveCounter(render).order;
+
+/**
+ * Every reason a `deck.counter` cannot be drawn, as sentences (empty: it can).
+ * Unknown keys are refused. `factcheck` is the cut's `render.chrome.factcheck`:
+ * a counter beside the legacy `verdicts` or `tally` is refused (one home for
+ * the series). `labelFits(series)` is the tally cell's fit check
+ * (factcheck.mjs `tallyLabelOf`), handed in so this file stays free of it.
+ *
+ * @returns {string[]}
+ */
+export function validateCounter(c, { factcheck = undefined, labelFits = null, where = "render.chrome.deck.counter" } = {}) {
+ if (c === undefined) return [];
+ if (!isObj(c)) return [`${where} must be an object { series, show?, position?, showAt? }`];
+ const errors = [];
+ for (const k of Object.keys(c)) if (!COUNTER_KEYS.includes(k)) errors.push(`${where}.${k} is not a counter setting (${COUNTER_KEYS.join(", ")})`);
+ if (isObj(factcheck) && (factcheck.verdicts !== undefined || factcheck.tally !== undefined)) {
+ errors.push(`${where} replaces render.chrome.factcheck.verdicts and .tally: set the series and the cells in one place`);
+ }
+ if (c.show !== undefined && typeof c.show !== "boolean") errors.push(`${where}.show must be true or false`);
+ if (c.position !== undefined && !COUNTER_POSITIONS.includes(c.position)) {
+ errors.push(`${where}.position must be ${COUNTER_POSITIONS.map((p) => `"${p}"`).join(" or ")}`);
+ }
+ 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 (!Array.isArray(c.series) || !c.series.length) {
+ errors.push(`${where}.series must list at least one series { id, label }`);
+ return errors;
+ }
+ if (c.series.length > COUNTER_LIMITS.series) errors.push(`${where}.series holds ${c.series.length} (at most ${COUNTER_LIMITS.series})`);
+ const seen = new Set();
+ c.series.forEach((s, i) => {
+ const w = `${where}.series[${i}]`;
+ if (!isObj(s)) { errors.push(`${w} must be { id, label, color? }`); return; }
+ for (const k of Object.keys(s)) if (!SERIES_KEYS.includes(k)) errors.push(`${w}.${k} is not a series setting (${SERIES_KEYS.join(", ")})`);
+ if (typeof s.id !== "string" || !SERIES_ID_RE.test(s.id)) {
+ errors.push(`${w}.id must be a letter then letters, digits, _ or - (at most ${COUNTER_LIMITS.id})`);
+ } else if (seen.has(s.id)) errors.push(`${w}.id ${s.id} is listed twice -- one series, one id`);
+ else seen.add(s.id);
+ if (!VERDICTS.includes(s.id) && s.label === undefined) errors.push(`${w}.label is needed: only a verdict series has a default label`);
+ for (const key of ["label", "stampLabel", "tallyLabel"]) {
+ const word = s[key];
+ 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})`);
+ }
+ 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 ")}`);
+ if (s.shape !== undefined && !COUNTER_SHAPES.includes(s.shape)) errors.push(`${w}.shape must be one of ${COUNTER_SHAPES.join(", ")}`);
+ if (s.unit !== undefined && !(typeof s.unit === "string" && s.unit.trim() && s.unit.trim().length <= COUNTER_LIMITS.unit)) {
+ 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);
+ if (problem) errors.push(problem);
+ }
+ });
+ return errors;
+}
+
+/**
+ * The series a mark counts: its `counter`, else its `verdict` -- one name for
+ * the same thing, `counter` the toolkit's, `verdict` the fact-check's.
+ */
+export const markSeries = (m) => (isObj(m) ? (m.counter ?? m.verdict) : undefined);
diff --git a/umtool/report-to-video/deck.mjs b/umtool/report-to-video/deck.mjs
@@ -20,9 +20,22 @@ import { INTRO_SECONDS } from "yt-dlp-transcript-common/lib/report/intro.mjs";
import { attributionParts, deckSubtitle } from "./attribution.mjs";
import {
- claimOf, marksOf, originalUrlAt, resolveFactcheck, roundStamps, stampSchedule, tallyOf, tallyVerdicts, validateFactcheck,
- VERDICT_SHAPES,
+ claimOf, marksOf, originalUrlAt, resolveFactcheck, roundStamps, stampSchedule, stampsWithFinale, tallyOf, tallyVerdicts, validateFactcheck,
} from "./factcheck.mjs";
+import { resolveCounter } from "./counter.mjs";
+import { DECK_PAD_X, COUNTER_CELL } from "./modules/design.mjs";
+import {
+ DECK_DEFAULTS, MARKER_ALIGNS, MARKER_DEFAULT_COLOR, MARKER_LAYOUTS, MARKER_LIMITS, MARKER_PALETTE_KEYS, markerShapeErrors,
+ PIP_COLORS, PIP_SPACINGS, POST_AT, POST_LAYOUTS, POST_LINKS, QR_LINKS, SETTINGS, settingValue, SUBTITLE_TOKENS,
+} from "./modules/settings.mjs";
+
+// The deck's settings and their limits live with the modules' validators
+// (modules/settings.mjs, a leaf: this file imports it); here under the names
+// they always had.
+export {
+ DECK_DEFAULTS, MARKER_ALIGNS, MARKER_DEFAULT_COLOR, MARKER_LAYOUTS, MARKER_LIMITS, MARKER_PALETTE_KEYS, PIP_COLORS, PIP_SPACINGS,
+ POST_AT, POST_LAYOUTS, POST_LINKS, QR_LINKS, SUBTITLE_TOKENS,
+};
import { threadOf, threadSchedule, threadsOn, validateThreads } from "./threads.mjs";
import { flipSchedule, flipsOn, validateFlips } from "./flips.mjs";
import { overlayPointsOf, resolveStats, statsSchedule, statsWanted, validateStats } from "./stats.mjs";
@@ -43,86 +56,6 @@ export const railOn = (render) => threadsOn(render) || flipsOn(render);
export const HYPERFRAMES_PKG_DEFAULT = "hyperframes@0.8.24";
/**
- * Every deck setting and its default. A manifest names only what it changes;
- * `resolveDeck` fills the rest. Each default is a setting, not a constant --
- * the alternative in each comment is a supported value.
- */
-export const DECK_DEFAULTS = Object.freeze({
- height: 190,
- footageScale: 0.82,
- background: "panel", // | "flush"
- // spacing | "time". `color` "verdict": a claimed clip's pip, once lit, takes
- // its claim's verdict colour and shape (factcheck.mjs VERDICT_SHAPES).
- pip: Object.freeze({ spacing: "even", size: 6, activeSize: 12, color: "accent" }),
- title: Object.freeze({ size: 54, maxChars: 48 }),
- subtitle: Object.freeze({ parts: "auto", dateFormat: "long" }), // dateFormat | "iso"
- // `links` is where a clip's QR goes: "site" (the archive's page at the
- // clip's start) or "original" (the record's own page -- YouTube at the
- // second, a Rumble page, an X post). An entry's `citeUrl` wins either way.
- qr: Object.freeze({ show: true, size: 150, links: "site" }),
- overCards: "hide", // | "show"
- motion: Object.freeze({ out: 0.3, in: 0.45, pip: 0.7 }),
- // The manifest's `posts`, drawn as cards over the footage at the end of the
- // clip each one is attached to. position | "top-left".
- // `hold` freezes the last frame of a clip that carries posts for that long,
- // so the last of them can be read before the next clip; `shift` moves the
- // footage away from the posts column (scaled to `scale`, over `seconds`)
- // while they are up, or is `false`.
- // `layout` "popup" draws them as above; "feed" keeps them in a column of
- // their own beside the footage for the whole cut (feedGeometry), each one
- // ticking in as its clip starts -- no hold, no move.
- // `links` is where a post's QR goes: "archive" (the post's page on the
- // archive the manifest names, `provenance.siteOrigin`, which survives the
- // post or the platform going away, and links on to the original) or
- // "original" (the bsky.app / x.com link itself).
- // `at` is when a popup's posts come up: "end" (the last `seconds` of the
- // clip, as above) or "start" (from the clip's start, sharing the whole clip
- // in the order the manifest lists them -- the post beside the words it goes
- // with, so no hold is needed). `shotMaxHeight` caps a post's screenshot in
- // px; null keeps it to the height of a full card of words (`maxLines`).
- posts: Object.freeze({
- show: true, layout: "popup", seconds: 4, hold: 2.5, position: "top-right", width: 600, qrSize: 120, maxLines: 7,
- inset: 24, shift: Object.freeze({ scale: 0.86, seconds: 0.6 }), links: "archive", at: "end", shotMaxHeight: null,
- // `qr: false` draws no QR on any post card (popup or feed); the words
- // take the code's width. The clip's own deck QR (`qr`) is untouched.
- qr: true,
- }),
- // Flags on the pip track: `[{ after, label, color?, align? }]`, each between
- // the pip of the clip `after` names and the next, hidden until the fuse
- // reaches it (deckMarkers). An empty list is no flags, and the deck lays out
- // as it always did.
- markers: Object.freeze([]),
- // Crowded labels: "stagger" lays them in two rows when one would not fit in
- // a single row (the band grows by MARKER_ROW, the track moves down by it);
- // "truncate" keeps one row and ellipsizes. A single row that fits is laid
- // the same either way.
- markerLayout: "stagger",
-});
-
-/** The pip's colour when lit (`pip.color`): the deck's accent, or a claimed clip's verdict. */
-export const PIP_COLORS = Object.freeze(["accent", "verdict"]);
-
-/** A marker's limits: how many, and a label's characters. */
-export const MARKER_LIMITS = Object.freeze({ count: 12, label: 24 });
-
-/**
- * Where a marker's label sits against its flag: "auto" (centred when it has
- * the room, else the stretch it may take -- as it always was), "left" (it
- * starts at the flag and reads on to the right), "right" (it ends at the
- * flag), "center" (centred on it, always).
- */
-export const MARKER_ALIGNS = Object.freeze(["auto", "left", "right", "center"]);
-
-/** `deck.markerLayout`: crowded labels in two rows, or one row ellipsized. */
-export const MARKER_LAYOUTS = Object.freeze(["stagger", "truncate"]);
-
-/** The palette keys a marker's `color` may name (else a `#rgb` / `#rrggbb`). */
-export const MARKER_PALETTE_KEYS = Object.freeze(["fg", "muted", "accent", "amber", "dim"]);
-
-/** A marker with no `color` is drawn in this palette key. */
-export const MARKER_DEFAULT_COLOR = "amber";
-
-/**
* The deck's TUNABLE params (release 38): the settings the video assistant's
* `fx` op may set by name, each with the bounds validateChrome holds it to
* (declared in common lib/report/fxParams.mjs; fx-params.test.mjs keeps the
@@ -130,12 +63,6 @@ export const MARKER_DEFAULT_COLOR = "amber";
*/
export const DECK_PARAMS = COMPOSITION_PARAMS.deck;
-/** Where a clip's deck QR links (`qr.links`): the archive at the clip, or the original. */
-export const QR_LINKS = Object.freeze(["site", "original"]);
-
-/** Subtitle tokens a `subtitle.parts` array may name. "auto" picks from these. */
-export const SUBTITLE_TOKENS = Object.freeze(["channel", "title", "date", "clock"]);
-
/**
* Segment types the deck slides away over when `overCards: "hide"`. A
* `teaser` is one too, and the deck slides away over it whatever `overCards`
@@ -173,6 +100,7 @@ export function resolveDeck(render) {
// refuses with it, so a manifest umtool accepted is one the build accepts.
// ---------------------------------------------------------------------------
+const HEX_RE = /^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/;
const isObj = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
const numIn = (v, lo, hi) => typeof v === "number" && Number.isFinite(v) && v >= lo && v <= hi;
@@ -206,143 +134,28 @@ export function validateChrome(chrome, render = {}) {
// The end fade is a render key the deck's cut is finished with; checked
// here too, so a writer that validates the deck refuses a bad one.
errors.push(...validateEndFade(render));
- // The fact-check stamps and tally (factcheck.mjs): drawn only by the deck.
- errors.push(...validateFactcheck(chrome.factcheck, undefined, { fontBold: render.fontBold ?? null }));
- // The thread rail (threads.mjs): the deck's layout only, beside the footage.
- errors.push(...validateThreads(chrome.threads));
- // The flips panel (flips.mjs): the same region as the rail, so not both.
- errors.push(...validateFlips(chrome.flips));
- // The stats region (stats.mjs): a frame scan's running numbers over the footage.
- errors.push(...validateStats(chrome.stats));
- // The effects region (fx.mjs): overlays drawn over the footage box.
- errors.push(...validateFx(chrome.fx));
- if (threadsOn({ chrome }) && flipsOn({ chrome })) errors.push("render.chrome.threads and render.chrome.flips share the left panel: set one");
+ // Every module's own settings (modules/settings.mjs), in SETTINGS order:
+ // the fact-check's, the side panel's, the stats', the effects', then the
+ // deck's own keys -- the finale's, the claim checks', the counter's, the
+ // shell's, the rail's, the subtitle's, the QR's, the posts'.
const d = chrome.deck ?? {};
- if (!isObj(d)) return [...errors, "render.chrome.deck must be an object"];
const w = "render.chrome.deck";
- // `finale` (finale.mjs) is the deck's too, with no default to fill: absent,
- // nothing about the deck changes. So are `claims` (claims.mjs): his words
- // against the record, drawn on the rail.
- unknownKeys(d, [...Object.keys(DECK_DEFAULTS), "finale", "claims"], w, errors);
- errors.push(...validateFinaleSettings(d.finale, `${w}.finale`));
- errors.push(...deckClaimShapeErrors(d.claims, `${w}.claims`));
-
- if (d.height !== undefined && !(Number.isInteger(d.height) && numIn(d.height, 120, 400))) {
- errors.push(`${w}.height must be a whole number of pixels from 120 to 400`);
- }
- if (d.footageScale !== undefined && !numIn(d.footageScale, 0.5, 1)) {
- errors.push(`${w}.footageScale must be from 0.5 to 1`);
- }
- if (d.background !== undefined && !["panel", "flush"].includes(d.background)) {
- errors.push(`${w}.background must be "panel" or "flush"`);
- }
- if (d.overCards !== undefined && !["hide", "show"].includes(d.overCards)) {
- errors.push(`${w}.overCards must be "hide" or "show"`);
+ let deckChecked = false;
+ for (const entry of SETTINGS) {
+ if (entry.deck && !deckChecked) {
+ // The thread rail and the flips share the left panel: one or the other.
+ if (threadsOn({ chrome }) && flipsOn({ chrome })) errors.push("render.chrome.threads and render.chrome.flips share the left panel: set one");
+ if (!isObj(d)) return [...errors, "render.chrome.deck must be an object"];
+ // `finale` (finale.mjs) is the deck's too, with no default to fill:
+ // absent, nothing about the deck changes. So are `claims` (claims.mjs:
+ // his words against the record, drawn on the rail) and `counter`
+ // (counter.mjs: the tally's named series).
+ unknownKeys(d, [...Object.keys(DECK_DEFAULTS), "finale", "claims", "counter"], w, errors);
+ deckChecked = true;
+ }
+ errors.push(...entry.validate(settingValue(chrome, entry), { render, chrome, deck: d, where: w }));
}
- const sub = (key, allowed, check) => {
- if (d[key] === undefined) return;
- if (!isObj(d[key])) { errors.push(`${w}.${key} must be an object`); return; }
- unknownKeys(d[key], allowed, `${w}.${key}`, errors);
- check(d[key]);
- };
- sub("pip", ["spacing", "size", "activeSize", "color"], (p) => {
- if (p.spacing !== undefined && !["even", "time"].includes(p.spacing)) {
- errors.push(`${w}.pip.spacing must be "even" or "time"`);
- }
- if (p.color !== undefined && !PIP_COLORS.includes(p.color)) {
- errors.push(`${w}.pip.color must be ${PIP_COLORS.map((c) => `"${c}"`).join(" or ")}`);
- }
- if (p.size !== undefined && !numIn(p.size, 2, 24)) errors.push(`${w}.pip.size must be from 2 to 24`);
- if (p.activeSize !== undefined && !numIn(p.activeSize, 2, 40)) {
- errors.push(`${w}.pip.activeSize must be from 2 to 40`);
- }
- const size = p.size ?? DECK_DEFAULTS.pip.size;
- const active = p.activeSize ?? DECK_DEFAULTS.pip.activeSize;
- if (numIn(size, 2, 24) && numIn(active, 2, 40) && active < size) {
- errors.push(`${w}.pip.activeSize must be at least pip.size`);
- }
- });
- sub("title", ["size", "maxChars"], (t) => {
- if (t.size !== undefined && !numIn(t.size, 24, 96)) errors.push(`${w}.title.size must be from 24 to 96`);
- if (t.maxChars !== undefined && !(Number.isInteger(t.maxChars) && numIn(t.maxChars, 10, 120))) {
- errors.push(`${w}.title.maxChars must be a whole number from 10 to 120`);
- }
- });
- sub("subtitle", ["parts", "dateFormat"], (s) => {
- if (s.parts !== undefined && s.parts !== "auto") {
- const ok = Array.isArray(s.parts) && s.parts.length > 0 &&
- s.parts.every((p) => SUBTITLE_TOKENS.includes(p)) &&
- new Set(s.parts).size === s.parts.length;
- if (!ok) {
- errors.push(`${w}.subtitle.parts must be "auto" or a list of distinct ${SUBTITLE_TOKENS.join("/")}`);
- }
- }
- if (s.dateFormat !== undefined && !["long", "iso"].includes(s.dateFormat)) {
- errors.push(`${w}.subtitle.dateFormat must be "long" or "iso"`);
- }
- });
- sub("qr", ["show", "size", "links"], (q) => {
- if (q.show !== undefined && typeof q.show !== "boolean") errors.push(`${w}.qr.show must be true or false`);
- if (q.links !== undefined && !QR_LINKS.includes(q.links)) {
- errors.push(`${w}.qr.links must be ${QR_LINKS.map((l) => `"${l}"`).join(" or ")}`);
- }
- if (q.size !== undefined && !numIn(q.size, 80, 380)) errors.push(`${w}.qr.size must be from 80 to 380`);
- const h = d.height ?? DECK_DEFAULTS.height;
- const size = q.size ?? DECK_DEFAULTS.qr.size;
- if (numIn(size, 80, 380) && Number.isInteger(h) && size > h - 20) {
- errors.push(`${w}.qr.size ${size} does not fit a ${h}px deck (at most ${h - 20})`);
- }
- });
- sub("posts", ["show", "layout", "seconds", "hold", "position", "width", "qrSize", "maxLines", "inset", "shift", "links", "at", "shotMaxHeight", "qr"], (p) => {
- if (p.qr !== undefined && typeof p.qr !== "boolean") errors.push(`${w}.posts.qr must be true or false`);
- if (p.at !== undefined && !POST_AT.includes(p.at)) {
- errors.push(`${w}.posts.at must be ${POST_AT.map((a) => `"${a}"`).join(" or ")}`);
- }
- if (p.shotMaxHeight !== undefined && p.shotMaxHeight !== null &&
- !(Number.isInteger(p.shotMaxHeight) && numIn(p.shotMaxHeight, 120, 1080))) {
- errors.push(`${w}.posts.shotMaxHeight must be null or a whole number of pixels from 120 to 1080`);
- }
- if (p.layout !== undefined && !POST_LAYOUTS.includes(p.layout)) {
- errors.push(`${w}.posts.layout must be ${POST_LAYOUTS.map((l) => `"${l}"`).join(" or ")}`);
- }
- if (p.links !== undefined && !POST_LINKS.includes(p.links)) {
- errors.push(`${w}.posts.links must be ${POST_LINKS.map((l) => `"${l}"`).join(" or ")}`);
- }
- if (p.hold !== undefined && !numIn(p.hold, 0, 10)) errors.push(`${w}.posts.hold must be from 0 to 10 seconds`);
- if (p.shift !== undefined && p.shift !== false) {
- if (!isObj(p.shift)) errors.push(`${w}.posts.shift must be false or { scale, seconds }`);
- else {
- unknownKeys(p.shift, ["scale", "seconds"], `${w}.posts.shift`, errors);
- if (p.shift.scale !== undefined && !numIn(p.shift.scale, 0.5, 1)) errors.push(`${w}.posts.shift.scale must be from 0.5 to 1`);
- if (p.shift.seconds !== undefined && !numIn(p.shift.seconds, 0, 3)) errors.push(`${w}.posts.shift.seconds must be from 0 to 3`);
- }
- }
- if (p.show !== undefined && typeof p.show !== "boolean") errors.push(`${w}.posts.show must be true or false`);
- if (p.seconds !== undefined && !numIn(p.seconds, 0.5, 10)) errors.push(`${w}.posts.seconds must be from 0.5 to 10`);
- if (p.position !== undefined && !["top-right", "top-left"].includes(p.position)) {
- errors.push(`${w}.posts.position must be "top-right" or "top-left"`);
- }
- if (p.width !== undefined && !(Number.isInteger(p.width) && numIn(p.width, 320, 900))) {
- errors.push(`${w}.posts.width must be a whole number of pixels from 320 to 900`);
- }
- if (p.qrSize !== undefined && !numIn(p.qrSize, 80, 200)) errors.push(`${w}.posts.qrSize must be from 80 to 200`);
- if (p.maxLines !== undefined && !(Number.isInteger(p.maxLines) && numIn(p.maxLines, 2, 14))) {
- errors.push(`${w}.posts.maxLines must be a whole number from 2 to 14`);
- }
- if (p.inset !== undefined && !numIn(p.inset, 0, 80)) errors.push(`${w}.posts.inset must be from 0 to 80`);
- });
- errors.push(...markerShapeErrors(d.markers, `${w}.markers`));
- if (d.markerLayout !== undefined && !MARKER_LAYOUTS.includes(d.markerLayout)) {
- errors.push(`${w}.markerLayout must be ${MARKER_LAYOUTS.map((l) => `"${l}"`).join(" or ")}`);
- }
- sub("motion", ["out", "in", "pip"], (m) => {
- for (const k of ["out", "in"]) {
- if (m[k] !== undefined && !numIn(m[k], 0, 2)) errors.push(`${w}.motion.${k} must be from 0 to 2 seconds`);
- }
- if (m.pip !== undefined && !numIn(m.pip, 0, 3)) errors.push(`${w}.motion.pip must be from 0 to 3 seconds`);
- });
-
// The footage has to fit above the deck. Clamping the scale instead would
// make the setting lie about what was drawn.
if (!errors.length) {
@@ -371,43 +184,6 @@ export function validateChrome(chrome, render = {}) {
return errors;
}
-const HEX_RE = /^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/;
-
-/**
- * Every reason a `deck.markers` list cannot be drawn, its shape alone (the
- * timeline is not in `render.chrome`: `validateDeckMarkers` checks `after`
- * against it). validateChrome calls this.
- *
- * @returns {string[]}
- */
-function markerShapeErrors(markers, where) {
- if (markers === undefined) return [];
- if (!Array.isArray(markers)) return [`${where} must be a list of { after, label, color? }`];
- const errors = [];
- if (markers.length > MARKER_LIMITS.count) errors.push(`${where} has ${markers.length} markers (at most ${MARKER_LIMITS.count})`);
- markers.forEach((m, i) => {
- const at = `${where}[${i}]`;
- if (!isObj(m)) { errors.push(`${at} must be { after, label, color? }`); return; }
- for (const k of Object.keys(m)) {
- if (!["after", "label", "color", "align"].includes(k)) errors.push(`${at}.${k} is not a marker setting (after, label, color, align)`);
- }
- if (m.align !== undefined && !MARKER_ALIGNS.includes(m.align)) {
- errors.push(`${at}.align must be ${MARKER_ALIGNS.map((a) => `"${a}"`).join(", ")}`);
- }
- if (typeof m.after !== "string" || !m.after.trim()) errors.push(`${at}.after must name a clip's id`);
- const label = typeof m.label === "string" ? m.label.trim() : "";
- if (!label) errors.push(`${at}.label must be a word or two`);
- else if (/[\r\n]/.test(label)) errors.push(`${at}.label must be one line`);
- else if ([...label].length > MARKER_LIMITS.label) {
- errors.push(`${at}.label is ${[...label].length} characters (at most ${MARKER_LIMITS.label})`);
- }
- if (m.color !== undefined && !(typeof m.color === "string" && (HEX_RE.test(m.color) || MARKER_PALETTE_KEYS.includes(m.color)))) {
- errors.push(`${at}.color must be a #hex colour or one of ${MARKER_PALETTE_KEYS.join(", ")}`);
- }
- });
- return errors;
-}
-
/**
* The deck's markers checked whole: their shape (as validateChrome checks
* it) and, against the WHOLE timeline, that each `after` names a clip in it.
@@ -654,7 +430,7 @@ export function threadsGeometry(render) {
export function deckLayout(render, { tally = null, schedule = null } = {}) {
const { W, deck: rect } = deckGeometry(render);
const d = resolveDeck(render);
- const padX = 48;
+ const padX = DECK_PAD_X;
// The markers' labels (`deck.markers`) stand in a band above the track: the
// track moves down by it, and only when there is a marker to label, so a
// deck without them lays out as it always did.
@@ -684,7 +460,7 @@ 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 = 124, gap = 10;
+ const { cell, gap } = COUNTER_CELL;
const width = tally.length * cell + (tally.length - 1) * gap;
const height = Math.min(bodyH - 8, 118);
const y = Math.round(bodyTop + (bodyH - height) / 2);
@@ -1097,6 +873,8 @@ export function deckSchedule({
}) {
const deck = resolveDeck(render);
const fps = render.fps ?? 30;
+ // The series a mark may count (counter.mjs): the counter's, else the verdicts.
+ const series = resolveCounter(render).order;
// A clip that carries posts is held on its last frame for `posts.hold`: the
// hold is part of the segment's length in the cut, so every start, the total
// and the posts' timing below are measured with it. `durs` are the segments'
@@ -1129,7 +907,7 @@ export function deckSchedule({
// An entry's marks (`claims`, two or more) ride beside its first.
const stamped = stampSchedule({
segments: segs.map((s, i) => {
- const marks = marksOf(entries[i]);
+ const marks = marksOf(entries[i], series);
const claim = marks[0] ?? null;
const many = marks.length > 1 ? { claims: marks } : {};
if (!marks.some((c) => c.at !== undefined)) return { ...s, claim, ...many };
@@ -1143,11 +921,10 @@ export function deckSchedule({
// -- its totals are final -- and is not drawn: there is no footage box to
// stamp, and the clip before is not the claim's.
const finale = fin ? finaleSchedule({ entries, segs, fin, D, total, render, feed, metas, provenance, deck }) : null;
- const stamps = finale
- ? stamped.map((s) => (finIds.has(s.segment)
- ? { ...s, at: finale.start, landed: finale.start, out: [finale.start, finale.start], stamp: false, finale: true }
- : s))
- : stamped;
+ // The counter's stamps (factcheck.mjs `stampsWithFinale`): the finale's
+ // window is an output the counter reads (`finale.window`), and the finale
+ // reads the counter's totals -- neither writes the other's slice.
+ const stamps = stampsWithFinale(stamped, finale ? { start: finale.start, segments: finIds } : null);
const allMoves = finale ? [...moves, ...finale.moves] : moves;
const threads = threadsOn(render)
? threadSchedule({ segments: segs.map((s, i) => ({ ...s, thread: threadOf(entries[i]) })), D, total, render, moves })
@@ -1208,13 +985,13 @@ export function deckSchedule({
// Only on a teaser that dips, so a cut without one writes the schedule it always did.
...(dipOf(e, fps) ? { dip: dipOf(e, fps) } : {}),
// Only on an entry that carries a claim (factcheck.mjs), likewise.
- ...(claimOf(e) ? { claim: claimOf(e) } : {}),
+ ...(claimOf(e, series) ? { claim: claimOf(e, series) } : {}),
// Its marks, only when it carries two or more (`claim` is the first).
- ...(marksOf(e).length > 1 ? { claims: marksOf(e) } : {}),
+ ...(marksOf(e, series).length > 1 ? { claims: marksOf(e, series) } : {}),
// And on one stamped at a source second, the second its segment starts
// at -- what placed the stamp, kept for a preview to place it again.
// So does a clip a deck claim check is said in (`deck.claims`).
- ...(marksOf(e).some((c) => c.at !== undefined) || claimClips.has(e.id)
+ ...(marksOf(e, series).some((c) => c.at !== undefined) || claimClips.has(e.id)
? { sourceFrom: round(clipClock?.get(e.id) ?? fxClock?.get(e.id) ?? playWindow(e, render).from) }
: {}),
// Only on a finale clip, likewise.
@@ -1282,6 +1059,7 @@ export function claimsSchedule({ entries, segments, D, total, metas = [], render
const list = render?.chrome?.deck?.claims;
if (!Array.isArray(list) || !list.length || deckClaimShapeErrors(list).length) return null;
const verdicts = resolveFactcheck(render).verdicts;
+ const unitOf = (id) => resolveCounter(render).series.find((s) => s.id === id)?.unit ?? null;
const idx = new Map(segments.map((s, i) => [s.id, i]));
const round = (v) => Math.round(v * 1000) / 1000;
const dates = {};
@@ -1319,7 +1097,8 @@ export function claimsSchedule({ entries, segments, D, total, metas = [], render
items.push({
kind: "count", n, segment: c.at, at: cutAt(c.at, c.t), until: untilOf(c.at), said: c.said.trim(),
window: { from: c.window.from, to: c.window.to }, verdict,
- noun: String(verdicts[verdict].label ?? verdict).trim().toLowerCase(),
+ // A counter series' `unit` (counter.mjs) when it names one, else its label.
+ noun: String(unitOf(verdict) ?? verdicts[verdict].label ?? verdict).trim().toLowerCase(),
total: sum,
stamps: inWindow.map(({ landed: _l, ...s }) => s),
...(c.per ? { per: c.per, spans } : {}),
@@ -1608,7 +1387,7 @@ function finaleRailAt(schedule, render, railBottom, textScale) {
const fc = resolveFactcheck(render);
const pal = render.palette ?? {};
const stamps = schedule.factcheck?.stamps ?? [];
- const verdicts = f.totals && stamps.length ? tallyVerdicts(stamps) : [];
+ const verdicts = f.totals && stamps.length ? tallyVerdicts(stamps, resolveCounter(render).order) : [];
const H = render?.height ?? 1080;
const kh = H / 1080;
const py = (v) => Math.round(v * kh);
@@ -1651,7 +1430,7 @@ function finaleRailAt(schedule, render, railBottom, textScale) {
const v = byVerdict && s.claim?.verdict ? s.claim.verdict : null;
return {
id: s.id, x: r2(xs[k]), size: v ? bigV : bigSize,
- ...(v ? { verdict: v, shape: VERDICT_SHAPES[v], color: fc.verdicts[v]?.color ?? pal.accent } : {}),
+ ...(v ? { verdict: v, shape: resolveCounter(render).shapes[v], color: fc.verdicts[v]?.color ?? pal.accent } : {}),
...(finSet.has(s.id) ? { here: true } : {}),
};
});
@@ -1839,14 +1618,8 @@ export function pipSegments(schedule) {
// ---------------------------------------------------------------------------
export const POST_PLATFORMS = Object.freeze(["bluesky", "x", "web"]);
-/** When a popup's posts come up (`posts.at`): the end of their clip, or its start. */
-export const POST_AT = Object.freeze(["end", "start"]);
/** The cuts a post may be limited to (`posts[].variant`) -- build-video's VARIANTS. */
const POST_VARIANTS = Object.freeze(["sourced", "full"]);
-/** How posts are drawn (`posts.layout`): cards at the end of a clip, or a column for the whole cut. */
-export const POST_LAYOUTS = Object.freeze(["popup", "feed"]);
-/** Where a post's QR links (`posts.links`): its page on the archive, or the platform's own link. */
-export const POST_LINKS = Object.freeze(["archive", "original"]);
const POST_KEYS = ["id", "platform", "author", "handle", "date", "text", "url", "attachTo", "hide", "siteChannel", "siteUrl", "postId", "shot", "variant", "accent", "logo", "flag"];
/** A post's `flag`: at most this many characters. */
export const POST_FLAG_MAX = 60;
diff --git a/umtool/report-to-video/factcheck.mjs b/umtool/report-to-video/factcheck.mjs
@@ -35,6 +35,8 @@
// copy shared with report.json and the export site's report pages. This file
// re-exports the list and lays the stamp and tally settings beside the labels.
import { isIsoDate } from "./claims.mjs";
+import { resolveCounter, VERDICT_SHAPES } from "./counter.mjs";
+import { COUNTER_CELL } from "./modules/design.mjs";
import {
VERDICT_DEFAULTS,
VERDICT_LABEL_MAX,
@@ -95,7 +97,7 @@ export const FACTCHECK_LIMITS = Object.freeze({
export const CLAIM_LIMITS = Object.freeze({ hold: Object.freeze([0.5, 10]), count: Object.freeze([1, 99]), label: 20 });
/** The keys a `claim` may carry. */
-export const CLAIM_KEYS = Object.freeze(["id", "verdict", "at", "hold", "stamp", "count", "label", "eventDate"]);
+export const CLAIM_KEYS = Object.freeze(["id", "verdict", "counter", "at", "hold", "stamp", "count", "label", "eventDate"]);
/** The most marks (`claims`) one entry may carry. */
export const CLAIM_MARKS_MAX = 8;
@@ -130,7 +132,7 @@ function unknownKeys(obj, allowed, where, errors) {
* (deck.mjs deckLayout's 124 px cell). The page ellipsizes what overruns, so
* a label is fitted HERE, before the page is written.
*/
-export const TALLY_LABEL = Object.freeze({ size: 13, tracking: 0.08, width: 124 - 12 });
+export const TALLY_LABEL = Object.freeze({ size: 13, tracking: 0.08, width: COUNTER_CELL.cell - 2 * COUNTER_CELL.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 --
@@ -183,13 +185,40 @@ export function tallyLabelOf(v, { fontBold = null } = {}) {
return null;
}
-/** The fact-check settings with every default filled in. */
+/**
+ * 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.
+ */
+export function counterLabelProblem(s, w, { fontBold = null } = {}) {
+ const label = s.label ?? VERDICT_DEFAULTS[s.id]?.label ?? s.id;
+ 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`
+ : null;
+ }
+ if (tallyLabelOf({ label }, { fontBold }) !== 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`;
+}
+
+/**
+ * The fact-check settings with every default filled in. `verdicts` are the
+ * COUNTER's series (counter.mjs `resolveCounter`): the verdicts with their
+ * relabels, as ever, or a `deck.counter`'s named series -- each `{ label,
+ * color, stampLabel?, tallyLabel? }` by id either way -- and `tally` its
+ * cells' show, position and showAt.
+ */
export function resolveFactcheck(render) {
const f = isObj(render?.chrome?.factcheck) ? render.chrome.factcheck : {};
+ const counter = resolveCounter(render);
return {
- verdicts: resolveVerdicts(f.verdicts),
+ verdicts: counter.custom ? counter.byId : resolveVerdicts(f.verdicts),
stamp: { ...FACTCHECK_DEFAULTS.stamp, ...(isObj(f.stamp) ? f.stamp : {}) },
- tally: { ...FACTCHECK_DEFAULTS.tally, ...(isObj(f.tally) ? f.tally : {}) },
+ tally: counter.custom
+ ? { show: counter.show, position: counter.position, showAt: counter.showAt }
+ : { ...FACTCHECK_DEFAULTS.tally, ...(isObj(f.tally) ? f.tally : {}) },
};
}
@@ -299,7 +328,7 @@ export function validateFactcheck(f, where = "render.chrome.factcheck", { fontBo
* @returns {{ id: string, verdict: string, at?: number, hold?: number,
* stamp?: false, count?: number, label?: string, eventDate?: string } | null}
*/
-export function normalizeClaim(v) {
+export function normalizeClaim(v, { series = null } = {}) {
if (v === undefined || v === null) return null;
if (!isObj(v)) throw new Error("claim must be { id, verdict }");
for (const k of Object.keys(v)) {
@@ -307,8 +336,13 @@ export function normalizeClaim(v) {
}
const id = typeof v.id === "string" ? v.id.trim() : "";
if (!CLAIM_ID_RE.test(id)) throw new Error("claim.id must be letters, digits, dots, colons, dashes or underscores (at most 64)");
- if (!VERDICTS.includes(v.verdict)) throw new Error(`claim.verdict must be one of ${VERDICTS.join(", ")}`);
- const out = { id, verdict: v.verdict };
+ // The series it counts (counter.mjs): `verdict`, or its alias `counter` --
+ // one of the counter's series ids (`series`; the verdicts unless given).
+ if (v.counter !== undefined && v.verdict !== undefined) throw new Error("claim.counter and claim.verdict are one setting: set one");
+ const name = v.counter ?? v.verdict;
+ const allowed = series ?? VERDICTS;
+ if (!allowed.includes(name)) throw new Error(`claim.verdict must be one of ${allowed.join(", ")}`);
+ const out = { id, verdict: name };
if (v.at !== undefined) {
if (!numIn(v.at, 0, Number.MAX_SAFE_INTEGER)) throw new Error("claim.at must be a source second, 0 or more");
out.at = v.at;
@@ -369,7 +403,7 @@ export function rawMarksOf(entry) {
*
* @returns {Array<NonNullable<ReturnType<typeof normalizeClaim>>>}
*/
-export function normalizeMarks(v) {
+export function normalizeMarks(v, { series = null } = {}) {
if (!Array.isArray(v)) throw new Error("claims must be a list of marks [{ id, verdict, … }]");
if (!v.length) throw new Error("claims must name at least one mark (remove the key for none)");
if (v.length > CLAIM_MARKS_MAX) throw new Error(`claims holds ${v.length} marks (at most ${CLAIM_MARKS_MAX})`);
@@ -377,7 +411,7 @@ export function normalizeMarks(v) {
return v.map((m, k) => {
let c;
try {
- c = normalizeClaim(m);
+ c = normalizeClaim(m, { series });
} catch (err) {
throw new Error(String(err.message).replace(/^claim\b/, `claims[${k}]`));
}
@@ -393,11 +427,11 @@ export function normalizeMarks(v) {
* written. None on a teaser, or on a shape that does not normalise. Never
* throws.
*/
-export function marksOf(entry) {
+export function marksOf(entry, series = null) {
if (!isObj(entry) || entry.type === "teaser") return [];
try {
- if (Array.isArray(entry.claims)) return entry.claim === undefined || entry.claim === null ? normalizeMarks(entry.claims) : [];
- const c = normalizeClaim(entry.claim);
+ if (Array.isArray(entry.claims)) return entry.claim === undefined || entry.claim === null ? normalizeMarks(entry.claims, { series }) : [];
+ const c = normalizeClaim(entry.claim, { series });
return c ? [c] : [];
} catch {
return [];
@@ -408,8 +442,8 @@ export function marksOf(entry) {
* An entry's claim when it carries a sound one, else null: its FIRST mark --
* the one its pip and rail take their verdict's colour from. Never throws.
*/
-export function claimOf(entry) {
- return marksOf(entry)[0] ?? null;
+export function claimOf(entry, series = null) {
+ return marksOf(entry, series)[0] ?? null;
}
/**
@@ -422,6 +456,8 @@ export function claimOf(entry) {
*/
export function validateClaims(manifest) {
const errors = [];
+ // The series a mark may count: the counter's (counter.mjs), else the verdicts.
+ const series = resolveCounter(manifest?.render).order;
const verdictOf = new Map();
const timeline = Array.isArray(manifest?.timeline) ? manifest.timeline : [];
// The last entry carrying each id: a mark stamps there, and only there.
@@ -439,7 +475,7 @@ export function validateClaims(manifest) {
if (e.type === "teaser") { errors.push(`${where}.${key}: a teaser is not evidence for a claim`); return; }
let marks;
try {
- marks = many ? normalizeMarks(e.claims) : [normalizeClaim(e.claim)];
+ marks = many ? normalizeMarks(e.claims, { series }) : [normalizeClaim(e.claim, { series })];
} catch (err) {
errors.push(`${where}.${err.message}`);
return;
@@ -601,6 +637,21 @@ export function stampSchedule({ segments, D, total, render }) {
});
}
+/**
+ * The counter's stamps given the finale's window (`finale.window`: its
+ * `start` and the `segments` it plays, or null for none): a stamp that would
+ * land on a finale clip counts as the finale opens instead -- its totals are
+ * final -- and is not drawn (there is no footage box to stamp, and the clip
+ * before is not the claim's). Every other stamp is as stamped.
+ */
+export function stampsWithFinale(stamps, finale) {
+ if (!finale) return stamps;
+ const at = finale.start;
+ return stamps.map((s) => (finale.segments.has(s.segment)
+ ? { ...s, at, landed: at, out: [at, at], stamp: false, finale: true }
+ : s));
+}
+
/** The stamps that are DRAWN: all but a claim's `stamp: false`. */
export const drawnStamps = (stamps = []) => stamps.filter((s) => s.stamp !== false);
@@ -617,10 +668,9 @@ export function stampsDrawn(schedule, render) {
* The shape a claimed clip's pip takes (`deck.pip.color: "verdict"`), one per
* verdict in VERDICTS order, so a viewer who cannot tell the colours apart
* can still tell the verdicts apart. The tally's cells carry the same shape.
+ * A counter's series take theirs from `resolveCounter(render).shapes`.
*/
-export const VERDICT_SHAPES = Object.freeze(Object.fromEntries(
- VERDICTS.map((v, i) => [v, ["circle", "diamond", "square", "triangle", "ring"][i] ?? "circle"]),
-));
+export { VERDICT_SHAPES };
/** `stampSchedule`'s stamps as a schedule writes them: seconds to the millisecond. */
export function roundStamps(stamps) {
@@ -628,10 +678,10 @@ export function roundStamps(stamps) {
return stamps.map((s) => ({ ...s, at: round(s.at), landed: round(s.landed), out: s.out.map(round) }));
}
-/** The verdicts a cut's stamps use, in VERDICTS order: the tally's cells. */
-export function tallyVerdicts(stamps = []) {
+/** The series a cut's stamps use, in the counter's order (`order`, the verdicts unless given): the tally's cells. */
+export function tallyVerdicts(stamps = [], order = VERDICTS) {
const used = new Set(stamps.map((s) => s.verdict));
- return VERDICTS.filter((v) => used.has(v));
+ return order.filter((v) => used.has(v));
}
/**
@@ -642,21 +692,21 @@ export function tallyVerdicts(stamps = []) {
*
* @returns {Array<{ at: number, verdict: string, count: number, step: number, counts: Record<string, number> }>}
*/
-export function tallySteps(stamps = []) {
- const counts = Object.fromEntries(VERDICTS.map((v) => [v, 0]));
+export function tallySteps(stamps = [], order = VERDICTS) {
+ const counts = Object.fromEntries(order.map((v) => [v, 0]));
return [...stamps]
.sort((a, b) => a.landed - b.landed)
.map((s) => {
const step = s.count ?? 1;
- counts[s.verdict] += step;
+ counts[s.verdict] = (counts[s.verdict] ?? 0) + step;
return { at: s.landed, verdict: s.verdict, count: counts[s.verdict], step, counts: { ...counts } };
});
}
/** Each verdict's count at the end of the cut: the tally's last numbers. */
-export function tallyFinals(stamps = []) {
- const finals = Object.fromEntries(VERDICTS.map((v) => [v, 0]));
- for (const s of stamps) finals[s.verdict] += s.count ?? 1;
+export function tallyFinals(stamps = [], order = VERDICTS) {
+ const finals = Object.fromEntries(order.map((v) => [v, 0]));
+ for (const s of stamps) finals[s.verdict] = (finals[s.verdict] ?? 0) + (s.count ?? 1);
return finals;
}
@@ -667,7 +717,7 @@ export function tallyFinals(stamps = []) {
export function tallyOf(schedule, render) {
const stamps = schedule?.factcheck?.stamps ?? [];
if (!stamps.length || !resolveFactcheck(render).tally.show) return null;
- return tallyVerdicts(stamps);
+ return tallyVerdicts(stamps, resolveCounter(render).order);
}
/**
@@ -677,9 +727,7 @@ export function tallyOf(schedule, render) {
* @returns {Record<string, "always" | "first">}
*/
export function tallyShowAt(render) {
- const w = resolveFactcheck(render).tally.showAt;
- const one = (v) => (TALLY_SHOW_AT.includes(v) ? v : "always");
- return Object.fromEntries(VERDICTS.map((v) => [v, isObj(w) ? one(w[v]) : one(w)]));
+ return { ...resolveCounter(render).showAt };
}
/**
diff --git a/umtool/report-to-video/intro.mjs b/umtool/report-to-video/intro.mjs
@@ -65,16 +65,16 @@ import { fileURLToPath, pathToFileURL } from "node:url";
import { promisify } from "node:util";
import {
- INTRO_BEATS, INTRO_GROUNDS, INTRO_ID, INTRO_MARKS, INTRO_SECONDS, INTRO_SECONDS_MAX, INTRO_SECONDS_MIN, INTRO_SITE_DEFAULTS,
- INTRO_STYLE_GROUND, INTRO_STYLE_MARK, INTRO_STYLES, INTRO_SWAPS, INTRO_URL_PLACES, INTRO_URLS, introErrors, introOf,
- introSitePrefix, introUrlText, validateIntro,
+ INTRO_BEATS, INTRO_BRAND_DEFAULT, INTRO_GROUNDS, INTRO_ID, INTRO_MARKS, INTRO_PROJECT_URL, INTRO_SECONDS, INTRO_SECONDS_MAX,
+ INTRO_SECONDS_MIN, INTRO_SITE_DEFAULTS, INTRO_STYLE_GROUND, INTRO_STYLE_MARK, INTRO_STYLES, INTRO_SUFFIX, INTRO_SWAPS,
+ INTRO_URL_PLACES, INTRO_URLS, introErrors, introOf, introSitePrefix, introUrlText, validateIntro,
} from "yt-dlp-transcript-common/lib/report/intro.mjs";
import { SITES_DIR } from "../lib/paths.mjs";
export {
- INTRO_BEATS, INTRO_GROUNDS, INTRO_ID, INTRO_MARKS, INTRO_SECONDS, INTRO_SECONDS_MAX, INTRO_SECONDS_MIN, INTRO_SITE_DEFAULTS,
- INTRO_STYLE_GROUND, INTRO_STYLE_MARK, INTRO_STYLES, INTRO_SWAPS, INTRO_URL_PLACES, INTRO_URLS, introErrors, introOf,
- introSitePrefix, introUrlText, validateIntro,
+ INTRO_BEATS, INTRO_BRAND_DEFAULT, INTRO_GROUNDS, INTRO_ID, INTRO_MARKS, INTRO_PROJECT_URL, INTRO_SECONDS, INTRO_SECONDS_MAX,
+ INTRO_SECONDS_MIN, INTRO_SITE_DEFAULTS, INTRO_STYLE_GROUND, INTRO_STYLE_MARK, INTRO_STYLES, INTRO_SUFFIX, INTRO_SWAPS,
+ INTRO_URL_PLACES, INTRO_URLS, introErrors, introOf, introSitePrefix, introUrlText, validateIntro,
};
const execFileP = promisify(execFile);
@@ -195,6 +195,10 @@ export function introEntry(render, { provenance = null, sitesDir = SITES_DIR } =
return {
type: INTRO_TYPE, id: INTRO_ID, style: o.style, ground: o.ground, mark: o.mark, seconds: o.seconds,
...(o.sound !== undefined ? { sound: o.sound } : {}),
+ // The brand's knobs, only when set (introOf): the plain intro's entry otherwise.
+ ...(o.brand !== undefined ? { brand: o.brand } : {}),
+ ...(o.suffix !== undefined ? { suffix: o.suffix } : {}),
+ ...(o.projectUrl !== undefined ? { projectUrl: o.projectUrl } : {}),
// The site's swap, resolved: only when one was found, so an intro with no
// site (or an "auto" that matched none) is the plain intro's entry.
...(site ? { site, swap: o.swap, url: o.url, urlPlace: o.urlPlace } : {}),
@@ -209,6 +213,15 @@ const siteObject = (site) => {
return rest;
};
+/** The brand kit the intro draws (`render.intro.brand`), refused by the intro's own key. */
+function introKit(brandKit, id) {
+ try {
+ return brandKit(id);
+ } catch (e) {
+ throw new Error(String(e?.message ?? e).replace(/^render\.brand /, "render.intro.brand "));
+ }
+}
+
/**
* The page's site knobs from an entry: `{ site, swap, url, urlPlace }` with the
* defaults filled in, or null (no site: introHtml is called exactly as before).
@@ -337,6 +350,9 @@ export async function renderIntro({ entry, render, encode, manifestDir = process
style: entry.style, ground: entry.ground, seconds: entry.seconds,
...(entry.mark !== undefined ? { mark: entry.mark } : {}),
...(entry.sound !== undefined ? { sound: entry.sound } : {}),
+ ...(entry.brand !== undefined ? { brand: entry.brand } : {}),
+ ...(entry.suffix !== undefined ? { suffix: entry.suffix } : {}),
+ ...(entry.projectUrl !== undefined ? { projectUrl: entry.projectUrl } : {}),
...(siteKnobs
? {
site: siteObject(siteKnobs.site), swap: siteKnobs.swap, urlPlace: siteKnobs.urlPlace,
@@ -353,8 +369,10 @@ export async function renderIntro({ entry, render, encode, manifestDir = process
const fps = render.fps ?? 30;
const html = introHtml({
style: entry.style, ground: entry.ground, ...(entry.mark !== undefined ? { mark: entry.mark } : {}),
- seconds: entry.seconds, width: W, height: H, fps, kit: brandKit("archilyzer-media"),
+ seconds: entry.seconds, width: W, height: H, fps, kit: introKit(brandKit, entry.brand ?? INTRO_BRAND_DEFAULT),
...(siteKnobs ?? {}),
+ ...(entry.suffix !== undefined ? { suffix: entry.suffix } : {}),
+ ...(entry.projectUrl !== undefined ? { projectUrl: entry.projectUrl } : {}),
});
const sound = introSoundPath(entry, manifestDir, standin);
let soundSha = null;
diff --git a/umtool/report-to-video/modules/blur.mjs b/umtool/report-to-video/modules/blur.mjs
@@ -0,0 +1,34 @@
+// THE BLUR (module `blur`, an input): a clip's picture blurred at its segment
+// encode, a caption drawn on it, the sound untouched (a clip's `blur`,
+// `render.blur` on/off for the uncensored variant; report-to-video
+// clip-blur.mjs). It filters the footage, so it has no page and no region.
+import {
+ BLUR_CAPTION_DEFAULT, BLUR_CAPTION_MAX, BLUR_STRENGTH, CLIP_BLUR_KEYS, RENDER_BLUR_VALUES, validateClipBlurEntries, validateRenderBlur,
+} from "../clip-blur.mjs";
+import { defineModule } from "./contract.mjs";
+
+export default defineModule({
+ id: "blur",
+ version: 1,
+ z: 2,
+ kind: "input",
+ slot: "footage",
+ title: "Blur",
+ summary: "A clip's picture blurred at its encode, a caption on it, the sound as recorded.",
+ configKey: "render.blur",
+ defaults: { blur: "on", caption: BLUR_CAPTION_DEFAULT, strength: BLUR_STRENGTH.default },
+ validate: (_value, { manifest }) => [...validateRenderBlur(manifest), ...validateClipBlurEntries(manifest)],
+ ui: [
+ { key: "blur", type: "enum", options: RENDER_BLUR_VALUES, label: "Blurred clips", default: "on" },
+ { key: "clip.blur", type: "object", keys: CLIP_BLUR_KEYS, label: "A clip's blur",
+ caption: { max: BLUR_CAPTION_MAX, default: BLUR_CAPTION_DEFAULT }, strength: BLUR_STRENGTH },
+ ],
+ docs: {
+ heading: "Blur",
+ intro: "The full reference is [A clip's picture, blurred](#a-clips-picture-blurred).",
+ rows: [
+ ["`render.blur`", "`on` · `off` (the uncensored variant) · default `on`", "`umtool look <p> blur=off`"],
+ ["a clip's `blur`", `\`{on, caption?, strength?, from?, to?}\` -- caption ≤ ${BLUR_CAPTION_MAX}, strength ${BLUR_STRENGTH.min}–${BLUR_STRENGTH.max} (default ${BLUR_STRENGTH.default})`, "`umtool set <p> <clip> blur.on=true`"],
+ ],
+ },
+});
diff --git a/umtool/report-to-video/modules/claims.mjs b/umtool/report-to-video/modules/claims.mjs
@@ -0,0 +1,34 @@
+// THE CLAIM CHECKS (module `claims`, a part of the shell): a subject's
+// explicit claims drawn against the record on the deck's rail -- a count over
+// a window of dates, or a goalpost moved (report-to-video claims.mjs; deck.mjs
+// `claimsSchedule`, `claimsLayout`; chrome-claims.mjs). Reads the counter's
+// series (`counter.series`): a count claim's record is one series' stamps.
+import { DECK_CLAIM_KINDS, DECK_CLAIM_LIMITS, DECK_CLAIM_OPS, DECK_CLAIM_PERS } from "../claims.mjs";
+import { settingsOf } from "./settings.mjs";
+import { defineModule } from "./contract.mjs";
+
+export default defineModule({
+ id: "claims",
+ version: 1,
+ z: 15,
+ kind: "part",
+ host: "shell",
+ slot: "inline",
+ title: "Claim checks",
+ summary: "His explicit claims against the record on the rail: a count over a window, a goalpost moved.",
+ configKey: "render.chrome.deck.claims",
+ defaults: { claims: [] },
+ validate: settingsOf("claims").validate,
+ resolve: (render) => (Array.isArray(render?.chrome?.deck?.claims) ? render.chrome.deck.claims : []),
+ deps: ["counter.series", "rail.layout"],
+ ui: [
+ { key: "claims", type: "claims", label: "Claim checks", kinds: DECK_CLAIM_KINDS, ops: DECK_CLAIM_OPS, pers: DECK_CLAIM_PERS, max: DECK_CLAIM_LIMITS.count },
+ ],
+ docs: {
+ heading: "Claim checks",
+ intro: "The full reference is [Claim checks on the rail](#claim-checks-on-the-rail). A count claim's `tally` names a counter series by id or label.",
+ rows: [
+ ["`deck.claims[]`", `at most ${DECK_CLAIM_LIMITS.count}, each a \`count\` or a \`goalpost\``, "`umtool look <p> deck.claims='[…]'` (`deck.claims=` none)"],
+ ],
+ },
+});
diff --git a/umtool/report-to-video/modules/counter.mjs b/umtool/report-to-video/modules/counter.mjs
@@ -0,0 +1,50 @@
+// THE COUNTER (module `counter`, a part of the shell): the deck's running
+// tally of named series, a cell per series the cut counts, each stepping as
+// 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 { settingsOf } from "./settings.mjs";
+import { defineModule } from "./contract.mjs";
+
+export default defineModule({
+ id: "counter",
+ version: 1,
+ z: 14,
+ kind: "part",
+ host: "shell",
+ slot: "inline",
+ 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" },
+ validate: settingsOf("counter").validate,
+ resolve: resolveCounter,
+ provides: ["counter.totals", "counter.series"],
+ ui: [
+ { key: "series", type: "series", label: "Series", item: [
+ { key: "id", type: "text", label: "Id" },
+ { key: "label", type: "text", label: "Label" },
+ { key: "color", type: "color", label: "Colour" },
+ { key: "stampLabel", type: "text", label: "Stamp word" },
+ { key: "tallyLabel", type: "text", label: "Cell word" },
+ { key: "showAt", type: "enum", options: COUNTER_SHOW_AT, label: "Show" },
+ { key: "shape", type: "enum", options: COUNTER_SHAPES, label: "Shape" },
+ { key: "unit", type: "text", label: "Unit" },
+ ] },
+ { 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" },
+ ],
+ 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[].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`", "same"],
+ ["a mark's series", "`claim.verdict` (or `claim.counter`): one of the series' ids", "`umtool set <p> <clip> mark.add=seizures@190.2`"],
+ ],
+ },
+});
diff --git a/umtool/report-to-video/modules/counter.test.mjs b/umtool/report-to-video/modules/counter.test.mjs
@@ -0,0 +1,113 @@
+// The counter module: named series in place of the fact-check verdicts
+// (report-to-video counter.mjs, modules/counter.mjs).
+import { test } from "node:test";
+import assert from "node:assert/strict";
+
+import { counterOrder, resolveCounter, validateCounter, VERDICT_SHAPES } from "../counter.mjs";
+import { claimOf, marksOf, normalizeClaim, resolveFactcheck, tallyFinals, tallyOf, tallyShowAt, validateClaims } from "../factcheck.mjs";
+import { estimateSchedule, validateChrome } from "../deck.mjs";
+import { deckHtml } from "../chrome-deck.mjs";
+import counter from "./counter.mjs";
+import { moduleProblems } from "./index.mjs";
+
+const PALETTE = { bg: "#101219", fg: "#f2f0ea", muted: "#979caa", accent: "#e5534b", amber: "#ffc860" };
+const render = (deck = {}, factcheck = undefined) => ({
+ width: 1920, height: 1080, fps: 30, transition: 0.5, palette: PALETTE,
+ chrome: { engine: "hyperframes", layout: "deck", deck, ...(factcheck ? { factcheck } : {}) },
+});
+const SERIES = [
+ { id: "seizures", label: "Seizures", color: "#e5534b", stampLabel: "Seizure" },
+ { id: "pitches", label: "Pitches", color: "#e3b23c", showAt: "first" },
+];
+
+test("without a counter the series are the verdicts, as the tally always counted them", () => {
+ const c = resolveCounter(render({}, { verdicts: { CORROBORATED: { label: "Seizures" } }, tally: { showAt: { PARTLY: "first" } } }));
+ assert.equal(c.custom, false);
+ assert.deepEqual(c.order, ["CORROBORATED", "PARTLY", "CONTRADICTED", "NOT_FOUND", "UNTESTABLE"]);
+ assert.equal(c.byId.CORROBORATED.label, "Seizures");
+ assert.deepEqual(c.shapes, VERDICT_SHAPES);
+ assert.equal(c.showAt.PARTLY, "first");
+ assert.equal(c.showAt.CORROBORATED, "always");
+ assert.deepEqual(resolveFactcheck(render()).verdicts, resolveCounter(render()).byId);
+});
+
+test("named series: their order, labels, colours, shapes by place, showAt and unit", () => {
+ const r = render({ counter: { series: [...SERIES, { id: "NOT_FOUND" }, { id: "x", label: "X", unit: "things" }], position: "left" } });
+ const c = resolveCounter(r);
+ assert.equal(c.custom, true);
+ assert.deepEqual(c.order, ["seizures", "pitches", "NOT_FOUND", "x"]);
+ assert.deepEqual(c.byId.seizures, { label: "Seizures", color: "#e5534b", stampLabel: "Seizure" });
+ assert.deepEqual(c.byId.NOT_FOUND, { label: "Not found", color: "#8b93a7" });
+ assert.equal(c.shapes.seizures, "circle");
+ assert.equal(c.shapes.pitches, "diamond");
+ assert.equal(c.shapes.NOT_FOUND, "triangle", "a verdict keeps its own shape");
+ assert.equal(c.series[3].unit, "things");
+ assert.equal(c.showAt.pitches, "first");
+ assert.deepEqual(tallyShowAt(r), c.showAt);
+ assert.equal(resolveFactcheck(r).tally.position, "left");
+ assert.deepEqual(counterOrder(r), c.order);
+});
+
+test("validateCounter: every shape refused in a sentence; one home for the series", () => {
+ assert.deepEqual(validateCounter(undefined), []);
+ assert.deepEqual(validateCounter({ series: SERIES }), []);
+ assert.match(validateCounter({ series: [] })[0], /at least one series/);
+ assert.match(validateCounter({ series: [{ id: "9x", label: "A" }] })[0], /id must be a letter/);
+ assert.match(validateCounter({ series: [{ id: "a", label: "A" }, { id: "a", label: "B" }] })[0], /listed twice/);
+ assert.match(validateCounter({ series: [{ id: "custom" }] })[0], /label is needed/);
+ assert.match(validateCounter({ series: [{ id: "a", label: "A", color: "red" }] })[0], /color must be a hex/);
+ 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/);
+ assert.deepEqual(validateChrome(render({ counter: { series: SERIES } }).chrome, render()), []);
+});
+
+test("a mark names a series by id: `verdict`, or its alias `counter`", () => {
+ const series = ["seizures", "pitches"];
+ assert.deepEqual(normalizeClaim({ id: "k1", counter: "seizures" }, { series }), { id: "k1", verdict: "seizures" });
+ assert.deepEqual(normalizeClaim({ id: "k1", verdict: "pitches", at: 3 }, { series }), { id: "k1", verdict: "pitches", at: 3 });
+ assert.throws(() => normalizeClaim({ id: "k1", counter: "seizures", verdict: "pitches" }, { series }), /one setting/);
+ assert.throws(() => normalizeClaim({ id: "k1", verdict: "CORROBORATED" }, { series }), /must be one of seizures, pitches/);
+ // Without the series named, the verdicts (as ever).
+ assert.throws(() => normalizeClaim({ id: "k1", verdict: "seizures" }), /must be one of CORROBORATED/);
+ assert.deepEqual(marksOf({ type: "clip", claim: { id: "k", counter: "pitches" } }, series), [{ id: "k", verdict: "pitches" }]);
+ assert.equal(claimOf({ type: "clip", claim: { id: "k", counter: "pitches" } }), null, "not a verdict, not a mark without the series");
+});
+
+test("a cut counting named series: the schedule, the tally's cells, the deck's page", () => {
+ const r = render({ counter: { series: SERIES }, pip: { color: "verdict" } });
+ const manifest = {
+ provenance: {}, posts: [],
+ render: r,
+ timeline: [
+ { type: "clip", id: "a", video: "v1", start: 0, end: 10, claim: { id: "s1", counter: "seizures" } },
+ { type: "clip", id: "b", video: "v2", start: 0, end: 10, claims: [{ id: "p1", verdict: "pitches" }, { id: "s2", verdict: "seizures", count: 2 }] },
+ { type: "clip", id: "c", video: "v3", start: 0, end: 10 },
+ ],
+ };
+ assert.deepEqual(validateClaims(manifest), []);
+ assert.deepEqual(moduleProblems(manifest), {});
+ const s = estimateSchedule(manifest);
+ assert.deepEqual(s.factcheck.stamps.map((x) => [x.claim, x.verdict]), [["s1", "seizures"], ["p1", "pitches"], ["s2", "seizures"]]);
+ assert.deepEqual(tallyOf(s, r), ["seizures", "pitches"]);
+ assert.deepEqual(tallyFinals(s.factcheck.stamps, counterOrder(r)), { seizures: 3, pitches: 1 });
+ const html = deckHtml(s, r, {});
+ assert.match(html, /data-verdict="seizures"/);
+ assert.match(html, /<div class="tlabel">Pitches<\/div>/);
+ assert.match(html, /data-shape="diamond"/);
+ // A series the counter does not have is refused by name.
+ const bad = { ...manifest, timeline: [{ type: "clip", id: "a", video: "v", start: 0, end: 5, claim: { id: "x", verdict: "CORROBORATED" } }] };
+ assert.match(validateClaims(bad)[0], /claim\.verdict must be one of seizures, pitches/);
+});
+
+test("the counter module: its home, its validator, its docs", () => {
+ assert.equal(counter.kind, "part");
+ assert.equal(counter.host, "shell");
+ assert.equal(counter.configKey, "render.chrome.deck.counter");
+ assert.deepEqual(counter.provides, ["counter.totals", "counter.series"]);
+ assert.match(counter.docs.rows[0][0], /deck\.counter\.series/);
+ assert.ok(counter.ui.some((f) => f.key === "series"));
+});
diff --git a/umtool/report-to-video/modules/feed.mjs b/umtool/report-to-video/modules/feed.mjs
@@ -7,6 +7,7 @@ import path from "node:path";
import { feedGeometry, resolveDeck } from "../deck.mjs";
import { feedHtml } from "../chrome-feed.mjs";
import { assertRegion, defineModule } from "./contract.mjs";
+import { DECK_DEFAULTS, POST_LAYOUTS, POST_LINKS, settingsOf } from "./settings.mjs";
export default defineModule({
id: "feed",
@@ -16,6 +17,30 @@ export default defineModule({
slot: "column",
title: "Posts feed",
summary: "The cut's posts in a column beside the footage, each ticking in as its clip starts.",
+ configKey: "render.chrome.deck.posts",
+ defaults: DECK_DEFAULTS.posts,
+ // `deck.posts` is the popup posts' and the feed's alike: one validator.
+ validate: (_value, ctx) => settingsOf("popup-posts").validate(ctx.deck ?? {}, ctx),
+ ui: [
+ { key: "show", type: "boolean", label: "Show the posts", default: true },
+ { key: "layout", type: "enum", options: POST_LAYOUTS, label: "Layout", default: "popup" },
+ { key: "links", type: "enum", options: POST_LINKS, label: "QR links to", default: "archive" },
+ { key: "qr", type: "boolean", label: "QR on each card", default: true },
+ { key: "width", type: "number", min: 320, max: 900, label: "Width (px)", default: DECK_DEFAULTS.posts.width },
+ { key: "inset", type: "number", min: 0, max: 80, label: "Inset (px)", default: DECK_DEFAULTS.posts.inset },
+ { key: "maxLines", type: "number", min: 2, max: 14, label: "Lines of words", default: DECK_DEFAULTS.posts.maxLines },
+ { key: "qrSize", type: "number", min: 80, max: 200, label: "QR size", default: DECK_DEFAULTS.posts.qrSize },
+ { key: "shotMaxHeight", type: "number", min: 120, max: 1080, label: "Screenshot height cap", default: null },
+ ],
+ docs: {
+ heading: "Posts feed",
+ intro: "`deck.posts.layout: \"feed\"` with posts to draw: a column for the whole cut, each post ticking in as its clip starts; no hold, no footage move. Shares `deck.posts` with the popup posts.",
+ rows: [
+ ["`deck.posts.layout`", "`popup` · `feed` · default `popup`", "`umtool look <p> deck.posts='{\"layout\":\"feed\"}'`"],
+ ["`deck.posts.width`, `.inset`", "320–900 · 0–80 px · default 600, 24 (the column's width; the footage keeps the inset clear)", "same"],
+ ["`deck.posts.links`, `.qr`", "`archive` · `original`; bool · default `archive`, `true`", "same"],
+ ],
+ },
region: "feed",
workers: "wide",
noun: "the feed's",
diff --git a/umtool/report-to-video/modules/finale.mjs b/umtool/report-to-video/modules/finale.mjs
@@ -9,6 +9,8 @@ import path from "node:path";
import { resolveDeck, snapWindow } from "../deck.mjs";
import { finaleHtml, finaleLayout } from "../chrome-finale.mjs";
import { assertRegion, defineModule } from "./contract.mjs";
+import { FINALE_DEFAULTS, resolveFinale } from "../finale.mjs";
+import { settingsOf } from "./settings.mjs";
export default defineModule({
id: "finale",
@@ -18,6 +20,31 @@ export default defineModule({
slot: "full",
title: "Finale",
summary: "The cut's last clips under the rail redrawn large, the final totals and stats cards.",
+ configKey: "render.chrome.deck.finale",
+ defaults: FINALE_DEFAULTS,
+ validate: settingsOf("finale").validate,
+ resolve: resolveFinale,
+ deps: ["counter.totals", "rail.layout"],
+ provides: ["finale.window"],
+ ui: [
+ { key: "video", type: "enum", options: ["side", "corner", "hidden"], label: "The clip", default: "side" },
+ { key: "motion", type: "enum", options: ["grow", "cut"], label: "Motion", default: "grow" },
+ { key: "totals", type: "boolean", label: "Totals", default: true },
+ { key: "statsTitle", type: "text", label: "Stats title" },
+ { key: "stats", type: "stats", label: "Stats cards", max: 8 },
+ { key: "railLabels", type: "enum", options: ["all", "nodes"], label: "Rail labels", default: "all" },
+ { key: "pips", type: "boolean", label: "The finale's clips on the rail", default: true },
+ { key: "timelineShare", type: "number", min: 0.38, max: 0.6, step: 0.01, label: "Timeline share (auto when unset)" },
+ { key: "claims", type: "enum", options: ["rotate", "all"], label: "Claim checks", default: "rotate" },
+ ],
+ docs: {
+ heading: "Finale",
+ intro: "The full reference is [The finale](#the-finale-the-timeline-in-primary-view). It reads the counter's totals (`counter.totals`) and the rail's layout (`rail.layout`); the counter reads its window (`finale.window`): a mark that would stamp inside it counts as it opens.",
+ rows: [
+ ["`deck.finale`", "`{video, motion, totals, stats, statsTitle, railLabels, pips, timelineShare, claims}`", "`umtool look <p> deck.finale='{…}'`"],
+ ["a clip's `layout`", "`finale` on one run of clips at the end", "`umtool set <p> <clip> layout=finale`"],
+ ],
+ },
region: "finale",
workers: "narrow",
noun: "the finale's",
diff --git a/umtool/report-to-video/modules/flips.mjs b/umtool/report-to-video/modules/flips.mjs
@@ -5,6 +5,7 @@ import path from "node:path";
import { flipsHtml } from "../chrome-flips.mjs";
import { defineModule } from "./contract.mjs";
+import { settingsOf } from "./settings.mjs";
import { sideRegion } from "./threads.mjs";
export default defineModule({
@@ -15,6 +16,14 @@ export default defineModule({
slot: "side",
title: "Flips",
summary: "Pairs of what was said then and now, in the side panel.",
+ validate: settingsOf("flips").validate,
+ docs: {
+ heading: "Flips",
+ intro: "Then-and-now pairs in the side panel (`render.chrome.flips`, flips.mjs); the thread rail and the flips share the panel: one or the other.",
+ rows: [
+ ["`render.chrome.flips`", "see flips.mjs", "manifest"],
+ ],
+ },
region: "flips",
workers: "narrow",
noun: "the flips panel's",
diff --git a/umtool/report-to-video/modules/fx.mjs b/umtool/report-to-video/modules/fx.mjs
@@ -5,6 +5,7 @@ import path from "node:path";
import { fxGeometry } from "../deck.mjs";
import { assertRegion, defineModule } from "./contract.mjs";
+import { settingsOf } from "./settings.mjs";
export default defineModule({
id: "fx",
@@ -14,6 +15,14 @@ export default defineModule({
slot: "footage",
title: "Effects",
summary: "Overlays on the picture: receipts, a zoom, a scrubber, captions.",
+ validate: settingsOf("fx").validate,
+ docs: {
+ heading: "Effects",
+ intro: "Overlays on the picture -- receipts, a zoom, the scrubber, a kinetic quote, punch-ins, whip cuts -- (`render.chrome.fx`, fx.mjs); `umtool takes effects <p>` lists the presets.",
+ rows: [
+ ["`render.chrome.fx.<effect>`", "scrubber · receipts · zoom · kineticQuote · redact · odometer · punchIn · thenNow · whip · glitch", "a take: `umtool take <p> --effect <name>`"],
+ ],
+ },
region: "fx",
workers: "wide",
noun: "the effects'",
diff --git a/umtool/report-to-video/modules/index.mjs b/umtool/report-to-video/modules/index.mjs
@@ -6,6 +6,7 @@
//
// Pure: the module files are, and so is this.
import { assertRegion, defineModule, MODULE_KINDS, MODULE_SLOTS, REGION_PLACEMENTS } from "./contract.mjs";
+import { settingsOf, settingValue } from "./settings.mjs";
import chart from "./chart.mjs";
import shell from "./shell.mjs";
@@ -18,12 +19,19 @@ import threads from "./threads.mjs";
import flips from "./flips.mjs";
import finale from "./finale.mjs";
import teaser from "./teaser.mjs";
+import subtitle from "./subtitle.mjs";
+import qr from "./qr.mjs";
+import rail from "./rail.mjs";
+import counter from "./counter.mjs";
+import claims from "./claims.mjs";
+import intro from "./intro.mjs";
+import blur from "./blur.mjs";
export { assertRegion, defineModule, MODULE_KINDS, MODULE_SLOTS, REGION_PLACEMENTS };
/** Every module, by z (stack order), then id. */
export const MODULES = Object.freeze(
- [chart, shell, feed, popupPosts, stamp, stats, fx, threads, flips, finale, teaser]
+ [chart, shell, subtitle, qr, rail, counter, claims, feed, popupPosts, stamp, stats, fx, threads, flips, finale, teaser, intro, blur]
.sort((a, b) => a.z - b.z || a.id.localeCompare(b.id)),
);
@@ -38,8 +46,10 @@ export const MODULES = Object.freeze(
regions.add(m.region);
}
}
+ const provided = new Set(MODULES.flatMap((m) => m.provides ?? []));
for (const m of MODULES) {
if (m.host && !ids.has(m.host)) throw new Error(`registry: ${m.id}'s host ${m.host} is not a module`);
+ for (const d of m.deps ?? []) if (!provided.has(d)) throw new Error(`registry: ${m.id} reads ${d}, which no module provides`);
}
}
@@ -86,3 +96,53 @@ export function regionCaching(region) {
/** The parts drawn in `host`'s page, by z. */
export const partsOf = (host) => MODULES.filter((m) => m.host === host);
+
+/**
+ * The deck schedule as its modules' SLICES, `{ [moduleId]: slice }`: what
+ * each module reads of the one schedule the build writes (schedule.json
+ * keeps its shape -- the pages, umtool's preview and the caches read it).
+ * A module the cut does not use has no slice.
+ */
+export function scheduleSlices(doc) {
+ if (!doc || doc.kind !== "deck") return {};
+ const stamps = doc.factcheck?.stamps ?? [];
+ const out = {
+ shell: { segments: doc.segments, total: doc.total, fps: doc.fps, transition: doc.transition, ...(doc.moves ? { moves: doc.moves } : {}) },
+ rail: { pips: doc.segments.filter((s) => !s.noPip).map((s) => s.id) },
+ ...(stamps.length ? { counter: { stamps }, stamp: { stamps: stamps.filter((s) => s.stamp !== false) } } : {}),
+ ...(doc.layout === "feed" ? { feed: { posts: doc.posts ?? [] } } : doc.posts ? { "popup-posts": { posts: doc.posts } } : {}),
+ ...(doc.finale ? { finale: doc.finale } : {}),
+ ...(doc.deckClaims ? { claims: doc.deckClaims } : {}),
+ ...(doc.threads ? { threads: doc.threads } : {}),
+ ...(doc.flips ? { flips: doc.flips } : {}),
+ ...(doc.stats ? { stats: doc.stats } : {}),
+ ...(doc.fx ? { fx: doc.fx } : {}),
+ };
+ return out;
+}
+
+/**
+ * Every module's own settings checked against a manifest: `{ [moduleId]:
+ * sentences }`, only the modules with something to say. What umtool's
+ * generic panel shows under each module; the build refuses with the same
+ * sentences (deck.mjs validateChrome runs the deck's in one list).
+ */
+export function moduleProblems(manifest) {
+ const render = manifest?.render ?? {};
+ const chrome = render.chrome ?? {};
+ const deckOnCut = !!chrome && typeof chrome === "object" && chrome.layout === "deck";
+ const out = {};
+ for (const m of MODULES) {
+ if (!m.validate) continue;
+ // A deck module's settings are read through its SETTINGS entry (the
+ // path validateChrome reads); any other's at its configKey.
+ const entry = settingsOf(m.id);
+ if ((entry || m.configKey?.startsWith("render.chrome")) && !deckOnCut) continue;
+ const value = entry
+ ? settingValue(chrome, entry)
+ : (m.configKey ?? "").split(".").slice(1).reduce((o, k) => (o && typeof o === "object" ? o[k] : undefined), render);
+ const errors = m.validate(value, { render, chrome, deck: chrome.deck ?? {}, manifest, where: "render.chrome.deck" });
+ if (errors.length) out[m.id] = errors;
+ }
+ return out;
+}
diff --git a/umtool/report-to-video/modules/intro.mjs b/umtool/report-to-video/modules/intro.mjs
@@ -0,0 +1,67 @@
+// THE INTRO (module `intro`, a segment): the brand sting a cut opens with --
+// the wordmark built on the first sound, "media" under it, a mark drawn or
+// chimed, and on the chime a site's name swapped in (`render.intro`;
+// common lib/report/intro.mjs holds its rules, report-to-video intro.mjs
+// renders it, chrome-intro.mjs writes its page).
+//
+// The BRAND is configurable: `brand` names the kit it draws (brands/<id>.json,
+// default archilyzer-media), `suffix` the letters a site's name keeps of the
+// brand's ("lyzer": Jeralyzer swaps "Archi" for "Jera"), `projectUrl` the URL
+// the swap writes beside the site's (default archilyzer.pages.dev; false
+// none). Unset, the intro is the bytes it always was.
+import {
+ INTRO_BRAND_DEFAULT, INTRO_GROUNDS, INTRO_MARKS, INTRO_PROJECT_URL, INTRO_SECONDS, INTRO_SECONDS_MAX, INTRO_SECONDS_MIN,
+ INTRO_STYLES, INTRO_SUFFIX, INTRO_SWAPS, INTRO_URL_PLACES, INTRO_URLS, introErrors, introOf,
+} from "yt-dlp-transcript-common/lib/report/intro.mjs";
+import { BRAND_IDS } from "../brand-ids.mjs";
+import { defineModule } from "./contract.mjs";
+
+/** Every reason `render.intro` cannot be drawn: the common rules, and a brand kit this renderer has. */
+export function validateIntroSettings(value) {
+ const errors = introErrors(value);
+ const brand = value && typeof value === "object" ? value.brand : undefined;
+ if (typeof brand === "string" && !errors.some((e) => e.startsWith("render.intro.brand")) && !BRAND_IDS.includes(brand)) {
+ errors.push(`render.intro.brand "${brand}" is not a brand kit — one of ${BRAND_IDS.join(", ")}`);
+ }
+ return errors;
+}
+
+export default defineModule({
+ id: "intro",
+ version: 1,
+ z: 1,
+ kind: "segment",
+ slot: "full",
+ title: "Intro",
+ summary: "The brand sting the cut opens with, a site's name swapped in on the chime.",
+ configKey: "render.intro",
+ defaults: { style: null, brand: INTRO_BRAND_DEFAULT, suffix: INTRO_SUFFIX, projectUrl: INTRO_PROJECT_URL, seconds: INTRO_SECONDS },
+ validate: (value) => validateIntroSettings(value),
+ resolve: introOf,
+ async render(ctx) {
+ const { renderIntro } = await import("../intro.mjs");
+ return renderIntro(ctx);
+ },
+ ui: [
+ { key: "style", type: "enum", options: INTRO_STYLES, label: "Style" },
+ { key: "ground", type: "enum", options: INTRO_GROUNDS, label: "Ground" },
+ { key: "mark", type: "enum", options: INTRO_MARKS, label: "Mark" },
+ { key: "seconds", type: "number", min: INTRO_SECONDS_MIN, max: INTRO_SECONDS_MAX, step: 0.05, label: "Seconds", default: INTRO_SECONDS },
+ { key: "site", type: "text", label: "Site (auto, an id, none)" },
+ { key: "swap", type: "enum", options: INTRO_SWAPS, label: "Swap" },
+ { key: "url", type: "enum", options: [...INTRO_URLS, false], label: "URLs" },
+ { key: "urlPlace", type: "enum", options: INTRO_URL_PLACES, label: "URLs go" },
+ { key: "brand", type: "enum", options: BRAND_IDS, label: "Brand kit", default: INTRO_BRAND_DEFAULT },
+ { key: "suffix", type: "text", label: "Shared suffix", default: INTRO_SUFFIX },
+ { key: "projectUrl", type: "text", label: "Project URL", default: INTRO_PROJECT_URL },
+ ],
+ docs: {
+ heading: "Intro",
+ intro: "The brand sting (`render.intro`); the style, mark and site knobs are in [The cut](#the-cut). The brand it draws is configurable; unset, it is the Archilyzer intro, byte for byte.",
+ rows: [
+ ["`render.intro.brand`", `a brand kit id (${BRAND_IDS.join(", ")}) · default \`${INTRO_BRAND_DEFAULT}\``, "`umtool look <p> intro='{\"style\":\"boot\",\"brand\":\"archilyzer-media\"}'`"],
+ ["`render.intro.suffix`", `the letters a site's name keeps of the brand's, 1–16 · default \`${INTRO_SUFFIX}\` (Jeralyzer swaps "Archi" for "Jera")`, "a take: `--set render.intro.suffix=lyzer`"],
+ ["`render.intro.projectUrl`", `the project URL the swap writes beside the site's · \`false\` none · default \`${INTRO_PROJECT_URL}\``, "a take: `--set render.intro.projectUrl=false`"],
+ ],
+ },
+});
diff --git a/umtool/report-to-video/modules/intro.test.mjs b/umtool/report-to-video/modules/intro.test.mjs
@@ -0,0 +1,53 @@
+// The intro module: the brand it draws is configurable (render.intro.brand,
+// .suffix, .projectUrl); unset, the page is the Archilyzer intro's.
+import { test } from "node:test";
+import assert from "node:assert/strict";
+
+import { INTRO_PROJECT_URL, INTRO_SUFFIX, introErrors, introOf, introSitePrefix } from "yt-dlp-transcript-common/lib/report/intro.mjs";
+import { introHtml, swapPlan, lockupParts, PROJECT_URL_TEXT } from "../chrome-intro.mjs";
+import { brandKit } from "../brand.mjs";
+import { introEntry } from "../intro.mjs";
+import intro, { validateIntroSettings } from "./intro.mjs";
+
+const kit = brandKit("archilyzer-media");
+const base = { style: "boot-dark", mark: "chime", seconds: 4.75, width: 1920, height: 1080, fps: 30, kit };
+const SITE = { name: "Jeralyzer", lead: "Jer", url: "jeralyzer.pages.dev" };
+
+test("the brand's knobs are refused by name and read only when set", () => {
+ assert.deepEqual(introErrors({ style: "boot", brand: "archilyzer-media", suffix: "lyzer", projectUrl: "x.pages.dev" }), []);
+ assert.deepEqual(introErrors({ style: "boot", projectUrl: false }), []);
+ assert.match(introErrors({ style: "boot", brand: "Not An Id" })[0], /render\.intro\.brand must be a brand kit's id/);
+ assert.match(introErrors({ style: "boot", suffix: "ly zer" })[0], /render\.intro\.suffix/);
+ assert.match(introErrors({ style: "boot", projectUrl: "" })[0], /render\.intro\.projectUrl/);
+ assert.match(validateIntroSettings({ style: "boot", brand: "someone-else" })[0], /is not a brand kit — one of archilyzer-media/);
+ assert.equal("brand" in introOf({ intro: "boot" }), false, "an intro without them reads as it did");
+ assert.deepEqual(introOf({ intro: { style: "boot", suffix: "lytics", projectUrl: false } }).projectUrl, false);
+ const entry = introEntry({ intro: { style: "boot", brand: "archilyzer-media", suffix: "lytics" } });
+ assert.equal(entry.brand, "archilyzer-media");
+ assert.equal(entry.suffix, "lytics");
+ assert.equal("projectUrl" in entry, false);
+});
+
+test("the defaults keep today's page; the suffix and the project URL change the swap", () => {
+ assert.equal(PROJECT_URL_TEXT, INTRO_PROJECT_URL);
+ assert.equal(introHtml({ ...base, site: SITE }), introHtml({ ...base, site: SITE, suffix: INTRO_SUFFIX, projectUrl: INTRO_PROJECT_URL }));
+ assert.equal(introSitePrefix("Jeralyzer"), "Jera");
+ assert.equal(introSitePrefix("Jeralytics", "lytics"), "Jera");
+ const parts = lockupParts(kit);
+ const plain = swapPlan({ parts, site: SITE });
+ const none = swapPlan({ parts, site: SITE, projectUrl: false });
+ const other = swapPlan({ parts, site: SITE, projectUrl: "https://example.org/" });
+ assert.deepEqual(plain.urls.map((u) => u.text), ["jeralyzer.pages.dev", "archilyzer.pages.dev"]);
+ assert.deepEqual(none.urls.map((u) => u.text), ["jeralyzer.pages.dev"]);
+ assert.deepEqual(other.urls.map((u) => u.text), ["jeralyzer.pages.dev", "example.org"]);
+ // A suffix the name does not end in swaps the whole word.
+ const whole = swapPlan({ parts, site: SITE, suffix: "lytics" });
+ assert.ok(whole.glyphs.length > plain.glyphs.length);
+});
+
+test("the intro module: a segment with its home, its validator and its docs", () => {
+ assert.equal(intro.kind, "segment");
+ assert.equal(intro.configKey, "render.intro");
+ assert.deepEqual(intro.validate({ style: "boot" }, {}), []);
+ assert.ok(intro.docs.rows.some((r) => r[0].includes("render.intro.brand")));
+});
diff --git a/umtool/report-to-video/modules/migrate.mjs b/umtool/report-to-video/modules/migrate.mjs
@@ -0,0 +1,104 @@
+// MANIFEST MIGRATION (release 39): a manifest written before the modules,
+// rewritten into the modules' homes -- PURE, and the render of what it
+// returns is the render of what it was given, frame for frame.
+//
+// One migration so far, `counter-series`: the fact-check tally becomes the
+// COUNTER's named series (counter.mjs).
+//
+// render.chrome.factcheck.verdicts -> render.chrome.deck.counter.series
+// every verdict a series, in VERDICTS order, its id the verdict (so every
+// mark's `verdict` names it as it always did, and the pages it draws are
+// the bytes they were), carrying the relabels it had: label, colour,
+// stampLabel, tallyLabel.
+// render.chrome.factcheck.tally -> counter.show / position / showAt
+// (one showAt for all is the counter's; one per verdict is the series').
+// render.chrome.deck.claims[].tally -> the series id when it named a label.
+//
+// The stamp's settings (`factcheck.stamp`) stay where they are: they are the
+// stamp module's. A manifest with nothing to count, or already migrated, is
+// returned as it was (`changes` empty). Idempotent.
+import { VERDICTS } from "yt-dlp-transcript-common/lib/report/verdicts.mjs";
+
+import { resolveCounter } from "../counter.mjs";
+import { tallyVerdictOf } from "../claims.mjs";
+import { rawMarksOf } from "../factcheck.mjs";
+
+/** The migrations, in the order they run, each `{ id, summary }`. */
+export const MIGRATIONS = Object.freeze([
+ Object.freeze({ id: "counter-series", summary: "the fact-check verdicts and tally become the counter's named series (render.chrome.deck.counter)" }),
+]);
+
+const isObj = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
+const clone = (v) => JSON.parse(JSON.stringify(v));
+
+/** Does this manifest count anything the counter would: a relabel, the tally's settings, a mark, a deck claim? */
+function counts(m) {
+ const chrome = m?.render?.chrome;
+ if (!isObj(chrome) || chrome.layout !== "deck") return false;
+ if (isObj(chrome.deck?.counter)) return false;
+ const f = isObj(chrome.factcheck) ? chrome.factcheck : {};
+ if (f.verdicts !== undefined || f.tally !== undefined) return true;
+ if ((m.timeline ?? []).some((e) => rawMarksOf(e).length)) return true;
+ return Array.isArray(chrome.deck?.claims) && chrome.deck.claims.some((c) => isObj(c) && c.kind === "count");
+}
+
+function counterSeries(m, changes) {
+ const chrome = m.render.chrome;
+ const f = isObj(chrome.factcheck) ? chrome.factcheck : {};
+ const resolved = resolveCounter(m.render);
+ const given = isObj(f.verdicts) ? f.verdicts : {};
+ const tally = isObj(f.tally) ? f.tally : {};
+ const perSeries = isObj(tally.showAt);
+ const series = VERDICTS.map((id) => {
+ const own = isObj(given[id]) ? given[id] : {};
+ return {
+ id,
+ ...own,
+ ...(perSeries && tally.showAt[id] === "first" ? { showAt: "first" } : {}),
+ };
+ });
+ const counter = {
+ series,
+ ...(tally.show === false ? { show: false } : {}),
+ ...(tally.position === "left" ? { position: "left" } : {}),
+ ...(!perSeries && tally.showAt === "first" ? { showAt: "first" } : {}),
+ };
+ const deck = isObj(chrome.deck) ? { ...chrome.deck } : {};
+ // A count claim names its series by id from here on.
+ if (Array.isArray(deck.claims)) {
+ deck.claims = deck.claims.map((c, n) => {
+ if (!isObj(c) || c.kind !== "count" || typeof c.tally !== "string") return c;
+ const id = tallyVerdictOf(c.tally, resolved.byId);
+ if (!id || id === c.tally) return c;
+ changes.push(`render.chrome.deck.claims[${n}].tally: "${c.tally}" -> "${id}" (the series by id)`);
+ return { ...c, tally: id };
+ });
+ }
+ deck.counter = counter;
+ const { verdicts: _v, tally: _t, ...rest } = f;
+ const next = { ...chrome, deck };
+ if (chrome.factcheck !== undefined) next.factcheck = rest;
+ m.render.chrome = next;
+ const relabelled = Object.keys(given).filter((k) => VERDICTS.includes(k));
+ changes.push(
+ `render.chrome.factcheck.verdicts -> render.chrome.deck.counter.series (${VERDICTS.length} series` +
+ `${relabelled.length ? `; ${relabelled.join(", ")} relabelled` : ""})`,
+ );
+ if (f.tally !== undefined) changes.push("render.chrome.factcheck.tally -> render.chrome.deck.counter (show, position, showAt)");
+}
+
+/**
+ * The manifest migrated into the modules' homes: `{ manifest, changes }`,
+ * `manifest` a new object (the one given is not touched) and `changes` a
+ * sentence per move, empty when there was nothing to do.
+ *
+ * @param {Record<string, any>} manifest
+ * @returns {{ manifest: Record<string, any>, changes: string[] }}
+ */
+export function migrateManifest(manifest) {
+ if (!isObj(manifest)) throw new Error("migrateManifest: a manifest is an object");
+ const m = clone(manifest);
+ const changes = [];
+ if (counts(m)) counterSeries(m, changes);
+ return { manifest: changes.length ? m : clone(manifest), changes };
+}
diff --git a/umtool/report-to-video/modules/migrate.test.mjs b/umtool/report-to-video/modules/migrate.test.mjs
@@ -0,0 +1,96 @@
+// migrateManifest (modules/migrate.mjs): the fact-check verdicts and tally
+// into the counter's named series -- pure, idempotent, and the pages it draws
+// the bytes they were.
+import { test } from "node:test";
+import assert from "node:assert/strict";
+
+import { migrateManifest, MIGRATIONS } from "./migrate.mjs";
+import { estimateSchedule, snapWindow, validateChrome } from "../deck.mjs";
+import { validateClaims } from "../factcheck.mjs";
+import { deckHtml } from "../chrome-deck.mjs";
+import { stampHtml } from "../chrome-stamp.mjs";
+import { finaleHtml } from "../chrome-finale.mjs";
+
+const PALETTE = { bg: "#101219", fg: "#f2f0ea", muted: "#979caa", accent: "#e5534b", amber: "#ffc860" };
+
+/** A Huck-shaped cut: one verdict relabelled, a per-verdict showAt, marks, a count claim by label, a finale. */
+function huckish({ tally = { show: true, position: "right", showAt: { PARTLY: "first" } } } = {}) {
+ return {
+ provenance: {}, posts: [],
+ render: {
+ width: 1920, height: 1080, fps: 30, transition: 0.5, palette: PALETTE,
+ fontBold: "/usr/share/fonts/TTF/FiraSans-Bold.ttf",
+ chrome: {
+ engine: "hyperframes", layout: "deck",
+ deck: {
+ pip: { color: "verdict" },
+ finale: { totals: true },
+ claims: [{ kind: "count", at: "b", t: 4, said: "“less than ten”", window: { from: "2026-01-01", to: "2026-12-31" }, tally: "Seizures" }],
+ },
+ factcheck: {
+ verdicts: { CORROBORATED: { label: "Seizures", color: "#e5534b", stampLabel: "Seizure" }, PARTLY: { label: "Huck's Blend pitches", tallyLabel: "Pitches" } },
+ stamp: { seconds: 3, position: "top-left", show: true },
+ ...(tally ? { tally } : {}),
+ },
+ },
+ },
+ timeline: [
+ { type: "clip", id: "a", video: "v1", start: 0, end: 10, date: "2026-03-01", claim: { id: "s1", verdict: "CORROBORATED" } },
+ { type: "clip", id: "b", video: "v2", start: 0, end: 12, date: "2026-04-01", claims: [{ id: "p1", verdict: "PARTLY", at: 2 }, { id: "s2", verdict: "CORROBORATED", at: 8 }] },
+ { type: "clip", id: "c", video: "v3", start: 0, end: 10, date: "2026-05-01", layout: "finale", claim: { id: "s3", verdict: "CORROBORATED" } },
+ ],
+ };
+}
+
+function pages(m) {
+ const s = estimateSchedule(m);
+ const r = m.render;
+ return {
+ schedule: JSON.stringify(s),
+ deck: deckHtml(s, r, {}),
+ stamp: stampHtml(s, r, {}),
+ finale: finaleHtml(s, r, snapWindow({ segment: "finale", from: s.finale.from, to: s.finale.to }, { fps: 30, total: s.total }), {}),
+ };
+}
+
+test("the migration moves the verdicts and the tally into deck.counter, and the claim names its series by id", () => {
+ const before = huckish();
+ const frozen = JSON.stringify(before);
+ const { manifest, changes } = migrateManifest(before);
+ assert.equal(JSON.stringify(before), frozen, "the manifest given is not touched");
+ const c = manifest.render.chrome;
+ assert.deepEqual(c.deck.counter, {
+ series: [
+ { id: "CORROBORATED", label: "Seizures", color: "#e5534b", stampLabel: "Seizure" },
+ { id: "PARTLY", label: "Huck's Blend pitches", tallyLabel: "Pitches", showAt: "first" },
+ { id: "CONTRADICTED" }, { id: "NOT_FOUND" }, { id: "UNTESTABLE" },
+ ],
+ });
+ assert.deepEqual(c.factcheck, { stamp: { seconds: 3, position: "top-left", show: true } });
+ assert.equal(c.deck.claims[0].tally, "CORROBORATED");
+ assert.equal(changes.length, 3);
+ assert.match(changes.join("\n"), /factcheck\.verdicts -> render\.chrome\.deck\.counter\.series/);
+ assert.deepEqual(validateChrome(c, manifest.render), []);
+ assert.deepEqual(validateClaims(manifest), []);
+ assert.equal(MIGRATIONS[0].id, "counter-series");
+});
+
+test("the migrated cut draws the same pages, byte for byte", () => {
+ for (const tally of [undefined, { show: true, position: "left", showAt: "first" }, { showAt: { PARTLY: "first" } }]) {
+ const before = huckish({ tally });
+ const a = pages(before);
+ const b = pages(migrateManifest(before).manifest);
+ for (const k of Object.keys(a)) assert.equal(b[k], a[k], `${k} (tally ${JSON.stringify(tally)})`);
+ }
+});
+
+test("idempotent; nothing to count is nothing to do", () => {
+ const once = migrateManifest(huckish()).manifest;
+ const twice = migrateManifest(once);
+ assert.deepEqual(twice.changes, []);
+ assert.deepEqual(twice.manifest, once);
+ const plain = { render: { chrome: { engine: "hyperframes", layout: "deck", deck: {} } }, timeline: [{ type: "clip", id: "a" }] };
+ assert.deepEqual(migrateManifest(plain), { manifest: plain, changes: [] });
+ assert.deepEqual(migrateManifest({ render: {}, timeline: [] }).changes, []);
+ assert.throws(() => migrateManifest(null), /a manifest is an object/);
+});
diff --git a/umtool/report-to-video/modules/popup-posts.mjs b/umtool/report-to-video/modules/popup-posts.mjs
@@ -8,6 +8,7 @@ import path from "node:path";
import { postsGeometry, postWindows, resolveDeck, snapWindow } from "../deck.mjs";
import { postsHtml, windowPosts } from "../chrome-posts.mjs";
import { assertRegion, defineModule } from "./contract.mjs";
+import { DECK_DEFAULTS, POST_AT, POST_LAYOUTS, POST_LINKS, settingsOf } from "./settings.mjs";
const SEGMENT_RE = /^[A-Za-z0-9_-]+$/;
@@ -19,6 +20,35 @@ export default defineModule({
slot: "popup",
title: "Popup posts",
summary: "A clip's posts as cards over the footage, each window its own short page at its own second.",
+ configKey: "render.chrome.deck.posts",
+ defaults: DECK_DEFAULTS.posts,
+ validate: settingsOf("popup-posts").validate,
+ ui: [
+ { key: "show", type: "boolean", label: "Show the posts", default: true },
+ { key: "layout", type: "enum", options: POST_LAYOUTS, label: "Layout", default: "popup" },
+ { key: "links", type: "enum", options: POST_LINKS, label: "QR links to", default: "archive" },
+ { key: "qr", type: "boolean", label: "QR on each card", default: true },
+ { key: "width", type: "number", min: 320, max: 900, label: "Width (px)", default: DECK_DEFAULTS.posts.width },
+ { key: "inset", type: "number", min: 0, max: 80, label: "Inset (px)", default: DECK_DEFAULTS.posts.inset },
+ { key: "maxLines", type: "number", min: 2, max: 14, label: "Lines of words", default: DECK_DEFAULTS.posts.maxLines },
+ { key: "qrSize", type: "number", min: 80, max: 200, label: "QR size", default: DECK_DEFAULTS.posts.qrSize },
+ { key: "at", type: "enum", options: POST_AT, label: "Come up at", default: "end" },
+ { key: "seconds", type: "number", min: 0.5, max: 10, step: 0.5, label: "Seconds each", default: DECK_DEFAULTS.posts.seconds },
+ { key: "hold", type: "number", min: 0, max: 10, step: 0.5, label: "Hold (s)", default: DECK_DEFAULTS.posts.hold },
+ { key: "position", type: "enum", options: ["top-right", "top-left"], label: "Side", default: "top-right" },
+ { key: "shotMaxHeight", type: "number", min: 120, max: 1080, label: "Screenshot height cap", default: null },
+ ],
+ docs: {
+ heading: "Popup posts",
+ intro: "A clip's posts as cards over the footage (`deck.posts`, the `popup` layout), each window its own short page.",
+ rows: [
+ ["`deck.posts.at`", "`end` (the clip's last `seconds` each) · `start` (from the clip's start, sharing it) · default `end`", "`umtool look <p> deck.posts='{\"at\":\"start\"}'`"],
+ ["`deck.posts.seconds`, `.hold`", "0.5–10 · 0–10 s · default 4, 2.5 (the last frame held so the last card can be read)", "same"],
+ ["`deck.posts.position`", "`top-right` · `top-left` · default `top-right`", "same"],
+ ["`deck.posts.shift`", "`false` · `{scale 0.5–1, seconds 0–3}` · default 0.86, 0.6 (the footage moves aside while they are up)", "same"],
+ ["`deck.posts.shotMaxHeight`", "null · 120–1080 px · default null (a full card of words)", "same"],
+ ],
+ },
region: "posts",
workers: "narrow",
noun: "the posts window's",
diff --git a/umtool/report-to-video/modules/qr.mjs b/umtool/report-to-video/modules/qr.mjs
@@ -0,0 +1,35 @@
+// THE QR (module `qr`, a part of the shell): each clip's code in the deck's
+// source cell, and the host it resolves to read up its side -- linked to the
+// archive at the clip (`site`) or to the record itself (`original`). The
+// deck's QR maker (compose-chrome.mjs `qrPngsFor`) draws the codes.
+import { DECK_DEFAULTS, QR_LINKS, settingsOf } from "./settings.mjs";
+import { defineModule } from "./contract.mjs";
+
+export default defineModule({
+ id: "qr",
+ version: 1,
+ z: 12,
+ kind: "part",
+ host: "shell",
+ slot: "inline",
+ title: "QR",
+ summary: "Each clip's code in the deck, to the archive at the clip or to the record itself.",
+ configKey: "render.chrome.deck.qr",
+ defaults: DECK_DEFAULTS.qr,
+ validate: settingsOf("qr").validate,
+ resolve: (render) => ({ ...DECK_DEFAULTS.qr, ...(render?.chrome?.deck?.qr ?? {}) }),
+ ui: [
+ { key: "show", type: "boolean", label: "Show the code", default: true },
+ { key: "size", type: "number", min: 80, max: 380, step: 2, label: "Size (px)", default: 150 },
+ { key: "links", type: "enum", options: QR_LINKS, label: "Links to", default: "site" },
+ ],
+ docs: {
+ heading: "QR",
+ intro: "Each clip's QR in the deck's source cell. An entry's `citeUrl` wins either way.",
+ rows: [
+ ["`deck.qr.show`", "bool · default `true`", "`umtool look <p> deck.qr='{\"show\":false}'`"],
+ ["`deck.qr.size`", "80–380 px, at most the deck's height less 20 · default 150", "`umtool look <p> deck.qr='{\"size\":130}'`"],
+ ["`deck.qr.links`", "`site` (the archive at the clip's start) · `original` (YouTube at the second, a Rumble page, an X post) · default `site`", "`umtool look <p> deck.qr='{\"links\":\"original\"}'`"],
+ ],
+ },
+});
diff --git a/umtool/report-to-video/modules/rail.mjs b/umtool/report-to-video/modules/rail.mjs
@@ -0,0 +1,61 @@
+// THE RAIL (module `rail`, a part of the shell): the deck's pip track -- a
+// pip per clip, the marker on the one playing, the fuse burning toward the
+// next -- and the markers' flags over it (deck.mjs `pipXs`, `deckMarkers`;
+// chrome-deck.mjs `deckCues`). The finale redraws it large (finale.mjs).
+//
+// `pip.spacing`:
+// - "even" (the default): the pips spread evenly over the track.
+// - "time": each pip at its clip's middle in the cut's clock.
+// - "pitch": each pip `pip.pitch` px after the one before, from the track's
+// left end, and the fuse measured against the whole track -- so a pip's
+// place, and the fuse's progress to it, depend on the clips before it
+// alone, and a clip inserted later moves nothing drawn before it (the
+// frame keys then reuse those frames). The pips the cut has not reached
+// are not drawn until the fuse sets off toward them. A cut with more pips
+// than the track holds at that pitch lays them at the pitch that fits.
+import { DECK_DEFAULTS, MARKER_ALIGNS, MARKER_LAYOUTS, PIP_COLORS, PIP_PITCH, PIP_PITCH_DEFAULT, PIP_SPACINGS, settingsOf } from "./settings.mjs";
+import { defineModule } from "./contract.mjs";
+
+export default defineModule({
+ id: "rail",
+ version: 1,
+ z: 13,
+ kind: "part",
+ host: "shell",
+ slot: "inline",
+ title: "Rail",
+ summary: "The deck's pip track: a pip per clip, the marker, the fuse, and the markers' flags.",
+ configKey: "render.chrome.deck.pip",
+ configKeys: ["render.chrome.deck.markers", "render.chrome.deck.markerLayout"],
+ defaults: { pip: DECK_DEFAULTS.pip, markers: DECK_DEFAULTS.markers, markerLayout: DECK_DEFAULTS.markerLayout },
+ provides: ["rail.layout"],
+ validate: settingsOf("rail").validate,
+ resolve(render) {
+ const d = render?.chrome?.deck ?? {};
+ const pip = { ...DECK_DEFAULTS.pip, ...(d.pip ?? {}) };
+ return {
+ pip: pip.spacing === "pitch" ? { ...pip, pitch: pip.pitch ?? PIP_PITCH_DEFAULT } : pip,
+ markers: d.markers ?? DECK_DEFAULTS.markers,
+ markerLayout: d.markerLayout ?? DECK_DEFAULTS.markerLayout,
+ };
+ },
+ ui: [
+ { key: "pip.spacing", type: "enum", options: PIP_SPACINGS, label: "Spacing", default: "even" },
+ { key: "pip.pitch", type: "number", min: PIP_PITCH[0], max: PIP_PITCH[1], label: "Pitch (px)", default: PIP_PITCH_DEFAULT, when: { "pip.spacing": "pitch" } },
+ { key: "pip.size", type: "number", min: 2, max: 24, label: "Pip size", default: 6 },
+ { key: "pip.activeSize", type: "number", min: 2, max: 40, label: "Marker size", default: 12 },
+ { key: "pip.color", type: "enum", options: PIP_COLORS, label: "Lit pip colour", default: "accent" },
+ { key: "markers", type: "markers", label: "Markers", align: MARKER_ALIGNS },
+ { key: "markerLayout", type: "enum", options: MARKER_LAYOUTS, label: "Crowded labels", default: "stagger" },
+ ],
+ docs: {
+ heading: "Rail",
+ intro: "The pip track along the top of the deck; the markers' flags stand over it ([markers](#the-cut)).",
+ rows: [
+ ["`deck.pip.spacing`", "`even` · `time` (each pip at its clip's middle) · `pitch` (each `pip.pitch` px after the last, from the left; the pips not yet reached are not drawn, so an insert keeps the frames before it) · default `even`", "`umtool look <p> deck.pip='{\"spacing\":\"pitch\",\"pitch\":24}'`"],
+ ["`deck.pip.pitch`", `${PIP_PITCH[0]}–${PIP_PITCH[1]} px · default ${PIP_PITCH_DEFAULT} (only with \`spacing: "pitch"\`; a cut with more pips than the track holds at it is laid at the pitch that fits)`, "same"],
+ ["`deck.pip.size`, `deck.pip.activeSize`", "2–24 · 2–40 px, the marker at least the pip · default 6, 12", "`umtool look <p> deck.pip='{\"size\":8}'`"],
+ ["`deck.pip.color`", "`accent` · `verdict` (a counted clip's pip takes its series' colour and shape) · default `accent`", "`umtool look <p> deck.pip='{\"color\":\"verdict\"}'`"],
+ ],
+ },
+});
diff --git a/umtool/report-to-video/modules/settings.mjs b/umtool/report-to-video/modules/settings.mjs
@@ -0,0 +1,366 @@
+// THE MODULES' SETTINGS (release 39): every chrome module's home in the
+// manifest, its defaults and its validator -- the one copy. The registry
+// (modules/index.mjs) hands each module its entry, and deck.mjs's
+// validateChrome runs them all in SETTINGS order, so umtool's writers and
+// the build refuse the same things.
+//
+// A LEAF: it imports only files that do not import deck.mjs, because deck.mjs
+// imports it (a cycle through the module files would read a binding before it
+// is set). The deck's own constants live here for that reason, and deck.mjs
+// re-exports them under the names they always had.
+import { deckClaimShapeErrors } from "../claims.mjs";
+import { validateFinaleSettings } from "../finale.mjs";
+import { counterLabelProblem, validateFactcheck } from "../factcheck.mjs";
+import { validateCounter } from "../counter.mjs";
+import { validateThreads } from "../threads.mjs";
+import { validateFlips } from "../flips.mjs";
+import { validateStats } from "../stats.mjs";
+import { validateFx } from "../fx.mjs";
+
+/**
+ * Every deck setting and its default. A manifest names only what it changes;
+ * `resolveDeck` fills the rest. Each default is a setting, not a constant --
+ * the alternative in each comment is a supported value.
+ */
+export const DECK_DEFAULTS = Object.freeze({
+ height: 190,
+ footageScale: 0.82,
+ background: "panel", // | "flush"
+ // spacing | "time" | "pitch". `color` "verdict": a claimed clip's pip, once
+ // lit, takes its claim's verdict colour and shape (counter.mjs). With
+ // "pitch", `pip.pitch` is the px between two pips (PIP_PITCH_DEFAULT when
+ // unset; rail.mjs) -- not a default here, so a deck without it resolves as
+ // it always did.
+ pip: Object.freeze({ spacing: "even", size: 6, activeSize: 12, color: "accent" }),
+ title: Object.freeze({ size: 54, maxChars: 48 }),
+ subtitle: Object.freeze({ parts: "auto", dateFormat: "long" }), // dateFormat | "iso"
+ // `links` is where a clip's QR goes: "site" (the archive's page at the
+ // clip's start) or "original" (the record's own page -- YouTube at the
+ // second, a Rumble page, an X post). An entry's `citeUrl` wins either way.
+ qr: Object.freeze({ show: true, size: 150, links: "site" }),
+ overCards: "hide", // | "show"
+ motion: Object.freeze({ out: 0.3, in: 0.45, pip: 0.7 }),
+ // The manifest's `posts`, drawn as cards over the footage at the end of the
+ // clip each one is attached to. position | "top-left".
+ // `hold` freezes the last frame of a clip that carries posts for that long,
+ // so the last of them can be read before the next clip; `shift` moves the
+ // footage away from the posts column (scaled to `scale`, over `seconds`)
+ // while they are up, or is `false`.
+ // `layout` "popup" draws them as above; "feed" keeps them in a column of
+ // their own beside the footage for the whole cut (feedGeometry), each one
+ // ticking in as its clip starts -- no hold, no move.
+ // `links` is where a post's QR goes: "archive" (the post's page on the
+ // archive the manifest names, `provenance.siteOrigin`, which survives the
+ // post or the platform going away, and links on to the original) or
+ // "original" (the bsky.app / x.com link itself).
+ // `at` is when a popup's posts come up: "end" (the last `seconds` of the
+ // clip, as above) or "start" (from the clip's start, sharing the whole clip
+ // in the order the manifest lists them -- the post beside the words it goes
+ // with, so no hold is needed). `shotMaxHeight` caps a post's screenshot in
+ // px; null keeps it to the height of a full card of words (`maxLines`).
+ posts: Object.freeze({
+ show: true, layout: "popup", seconds: 4, hold: 2.5, position: "top-right", width: 600, qrSize: 120, maxLines: 7,
+ inset: 24, shift: Object.freeze({ scale: 0.86, seconds: 0.6 }), links: "archive", at: "end", shotMaxHeight: null,
+ // `qr: false` draws no QR on any post card (popup or feed); the words
+ // take the code's width. The clip's own deck QR (`qr`) is untouched.
+ qr: true,
+ }),
+ // Flags on the pip track: `[{ after, label, color?, align? }]`, each between
+ // the pip of the clip `after` names and the next, hidden until the fuse
+ // reaches it (deckMarkers). An empty list is no flags, and the deck lays out
+ // as it always did.
+ markers: Object.freeze([]),
+ // Crowded labels: "stagger" lays them in two rows when one would not fit in
+ // a single row (the band grows by MARKER_ROW, the track moves down by it);
+ // "truncate" keeps one row and ellipsizes. A single row that fits is laid
+ // the same either way.
+ markerLayout: "stagger",
+});
+
+/** The pip's colour when lit (`pip.color`): the deck's accent, or a claimed clip's verdict. */
+export const PIP_COLORS = Object.freeze(["accent", "verdict"]);
+
+/** A marker's limits: how many, and a label's characters. */
+export const MARKER_LIMITS = Object.freeze({ count: 12, label: 24 });
+
+/**
+ * Where a marker's label sits against its flag: "auto" (centred when it has
+ * the room, else the stretch it may take -- as it always was), "left" (it
+ * starts at the flag and reads on to the right), "right" (it ends at the
+ * flag), "center" (centred on it, always).
+ */
+export const MARKER_ALIGNS = Object.freeze(["auto", "left", "right", "center"]);
+
+/** `deck.markerLayout`: crowded labels in two rows, or one row ellipsized. */
+export const MARKER_LAYOUTS = Object.freeze(["stagger", "truncate"]);
+
+/** The palette keys a marker's `color` may name (else a `#rgb` / `#rrggbb`). */
+export const MARKER_PALETTE_KEYS = Object.freeze(["fg", "muted", "accent", "amber", "dim"]);
+
+/** A marker with no `color` is drawn in this palette key. */
+export const MARKER_DEFAULT_COLOR = "amber";
+
+/** Where a clip's deck QR links (`qr.links`): the archive at the clip, or the original. */
+export const QR_LINKS = Object.freeze(["site", "original"]);
+
+/** Subtitle tokens a `subtitle.parts` array may name. "auto" picks from these. */
+export const SUBTITLE_TOKENS = Object.freeze(["channel", "title", "date", "clock"]);
+
+/** How the rail lays its pips (`pip.spacing`): evenly, by time, or at a fixed pitch (rail.mjs). */
+export const PIP_SPACINGS = Object.freeze(["even", "time", "pitch"]);
+
+/** The rail's pitch (`pip.pitch`, px between two pips when `spacing` is "pitch"): its bounds. */
+export const PIP_PITCH = Object.freeze([8, 200]);
+
+/** The pitch when `spacing` is "pitch" and `pip.pitch` is unset. */
+export const PIP_PITCH_DEFAULT = 28;
+
+/** When a popup's posts come up (`posts.at`): the end of their clip, or its start. */
+export const POST_AT = Object.freeze(["end", "start"]);
+/** How posts are drawn (`posts.layout`): cards at the end of a clip, or a column for the whole cut. */
+export const POST_LAYOUTS = Object.freeze(["popup", "feed"]);
+/** Where a post's QR links (`posts.links`): its page on the archive, or the platform's own link. */
+export const POST_LINKS = Object.freeze(["archive", "original"]);
+
+const isObj = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
+const numIn = (v, lo, hi) => typeof v === "number" && Number.isFinite(v) && v >= lo && v <= hi;
+
+function unknownKeys(obj, allowed, where, errors) {
+ for (const k of Object.keys(obj)) {
+ if (!allowed.includes(k)) errors.push(`${where}.${k} is not a deck setting`);
+ }
+}
+
+/**
+ * A deck sub-object's check: absent passes, not an object is refused, unknown
+ * keys are refused, then `check` reads it.
+ */
+function sub(d, key, allowed, w, errors, check) {
+ if (d[key] === undefined) return;
+ if (!isObj(d[key])) { errors.push(`${w}.${key} must be an object`); return; }
+ unknownKeys(d[key], allowed, `${w}.${key}`, errors);
+ check(d[key]);
+}
+
+const HEX_RE = /^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/;
+
+/**
+ * Every reason a `deck.markers` list cannot be drawn, its shape alone (the
+ * timeline is not in `render.chrome`: `validateDeckMarkers` checks `after`
+ * against it). validateChrome calls this.
+ *
+ * @returns {string[]}
+ */
+export function markerShapeErrors(markers, where) {
+ if (markers === undefined) return [];
+ if (!Array.isArray(markers)) return [`${where} must be a list of { after, label, color? }`];
+ const errors = [];
+ if (markers.length > MARKER_LIMITS.count) errors.push(`${where} has ${markers.length} markers (at most ${MARKER_LIMITS.count})`);
+ markers.forEach((m, i) => {
+ const at = `${where}[${i}]`;
+ if (!isObj(m)) { errors.push(`${at} must be { after, label, color? }`); return; }
+ for (const k of Object.keys(m)) {
+ if (!["after", "label", "color", "align"].includes(k)) errors.push(`${at}.${k} is not a marker setting (after, label, color, align)`);
+ }
+ if (m.align !== undefined && !MARKER_ALIGNS.includes(m.align)) {
+ errors.push(`${at}.align must be ${MARKER_ALIGNS.map((a) => `"${a}"`).join(", ")}`);
+ }
+ if (typeof m.after !== "string" || !m.after.trim()) errors.push(`${at}.after must name a clip's id`);
+ const label = typeof m.label === "string" ? m.label.trim() : "";
+ if (!label) errors.push(`${at}.label must be a word or two`);
+ else if (/[\r\n]/.test(label)) errors.push(`${at}.label must be one line`);
+ else if ([...label].length > MARKER_LIMITS.label) {
+ errors.push(`${at}.label is ${[...label].length} characters (at most ${MARKER_LIMITS.label})`);
+ }
+ if (m.color !== undefined && !(typeof m.color === "string" && (HEX_RE.test(m.color) || MARKER_PALETTE_KEYS.includes(m.color)))) {
+ errors.push(`${at}.color must be a #hex colour or one of ${MARKER_PALETTE_KEYS.join(", ")}`);
+ }
+ });
+ return errors;
+}
+
+
+// ---------------------------------------------------------------------------
+// Each module's validator: (its value, { render, chrome, deck, where }) =>
+// sentences. `deck` is `render.chrome.deck` (an object by the time these
+// run), `where` the dotted path the messages name.
+// ---------------------------------------------------------------------------
+
+/** The shell: the deck's size, ground, the title and the motion. */
+export function validateShellSettings(d, { where: w }) {
+ const errors = [];
+ if (d.height !== undefined && !(Number.isInteger(d.height) && numIn(d.height, 120, 400))) {
+ errors.push(`${w}.height must be a whole number of pixels from 120 to 400`);
+ }
+ if (d.footageScale !== undefined && !numIn(d.footageScale, 0.5, 1)) {
+ errors.push(`${w}.footageScale must be from 0.5 to 1`);
+ }
+ if (d.background !== undefined && !["panel", "flush"].includes(d.background)) {
+ errors.push(`${w}.background must be "panel" or "flush"`);
+ }
+ if (d.overCards !== undefined && !["hide", "show"].includes(d.overCards)) {
+ errors.push(`${w}.overCards must be "hide" or "show"`);
+ }
+ sub(d, "title", ["size", "maxChars"], w, errors, (t) => {
+ if (t.size !== undefined && !numIn(t.size, 24, 96)) errors.push(`${w}.title.size must be from 24 to 96`);
+ if (t.maxChars !== undefined && !(Number.isInteger(t.maxChars) && numIn(t.maxChars, 10, 120))) {
+ errors.push(`${w}.title.maxChars must be a whole number from 10 to 120`);
+ }
+ });
+ sub(d, "motion", ["out", "in", "pip"], w, errors, (m) => {
+ for (const k of ["out", "in"]) {
+ if (m[k] !== undefined && !numIn(m[k], 0, 2)) errors.push(`${w}.motion.${k} must be from 0 to 2 seconds`);
+ }
+ if (m.pip !== undefined && !numIn(m.pip, 0, 3)) errors.push(`${w}.motion.pip must be from 0 to 3 seconds`);
+ });
+ return errors;
+}
+
+/** The rail: the pips, the markers and how crowded labels lay. */
+export function validateRailSettings(d, { where: w }) {
+ const errors = [];
+ sub(d, "pip", ["spacing", "size", "activeSize", "color", "pitch"], w, errors, (p) => {
+ if (p.spacing !== undefined && !PIP_SPACINGS.includes(p.spacing)) {
+ errors.push(`${w}.pip.spacing must be "even", "time" or "pitch"`);
+ }
+ if (p.color !== undefined && !PIP_COLORS.includes(p.color)) {
+ errors.push(`${w}.pip.color must be ${PIP_COLORS.map((c) => `"${c}"`).join(" or ")}`);
+ }
+ if (p.size !== undefined && !numIn(p.size, 2, 24)) errors.push(`${w}.pip.size must be from 2 to 24`);
+ if (p.activeSize !== undefined && !numIn(p.activeSize, 2, 40)) {
+ errors.push(`${w}.pip.activeSize must be from 2 to 40`);
+ }
+ if (p.pitch !== undefined && !numIn(p.pitch, PIP_PITCH[0], PIP_PITCH[1])) {
+ errors.push(`${w}.pip.pitch must be from ${PIP_PITCH[0]} to ${PIP_PITCH[1]} pixels`);
+ }
+ const size = p.size ?? DECK_DEFAULTS.pip.size;
+ const active = p.activeSize ?? DECK_DEFAULTS.pip.activeSize;
+ if (numIn(size, 2, 24) && numIn(active, 2, 40) && active < size) {
+ errors.push(`${w}.pip.activeSize must be at least pip.size`);
+ }
+ });
+ errors.push(...markerShapeErrors(d.markers, `${w}.markers`));
+ if (d.markerLayout !== undefined && !MARKER_LAYOUTS.includes(d.markerLayout)) {
+ errors.push(`${w}.markerLayout must be ${MARKER_LAYOUTS.map((l) => `"${l}"`).join(" or ")}`);
+ }
+ return errors;
+}
+
+/** The subtitle: its parts and its date's format. */
+export function validateSubtitleSettings(d, { where: w }) {
+ const errors = [];
+ sub(d, "subtitle", ["parts", "dateFormat"], w, errors, (s) => {
+ if (s.parts !== undefined && s.parts !== "auto") {
+ const ok = Array.isArray(s.parts) && s.parts.length > 0 &&
+ s.parts.every((p) => SUBTITLE_TOKENS.includes(p)) &&
+ new Set(s.parts).size === s.parts.length;
+ if (!ok) {
+ errors.push(`${w}.subtitle.parts must be "auto" or a list of distinct ${SUBTITLE_TOKENS.join("/")}`);
+ }
+ }
+ if (s.dateFormat !== undefined && !["long", "iso"].includes(s.dateFormat)) {
+ errors.push(`${w}.subtitle.dateFormat must be "long" or "iso"`);
+ }
+ });
+ return errors;
+}
+
+/** The QR: shown, its size (inside the deck), where it links. */
+export function validateQrSettings(d, { where: w }) {
+ const errors = [];
+ sub(d, "qr", ["show", "size", "links"], w, errors, (q) => {
+ if (q.show !== undefined && typeof q.show !== "boolean") errors.push(`${w}.qr.show must be true or false`);
+ if (q.links !== undefined && !QR_LINKS.includes(q.links)) {
+ errors.push(`${w}.qr.links must be ${QR_LINKS.map((l) => `"${l}"`).join(" or ")}`);
+ }
+ if (q.size !== undefined && !numIn(q.size, 80, 380)) errors.push(`${w}.qr.size must be from 80 to 380`);
+ const h = d.height ?? DECK_DEFAULTS.height;
+ const size = q.size ?? DECK_DEFAULTS.qr.size;
+ if (numIn(size, 80, 380) && Number.isInteger(h) && size > h - 20) {
+ errors.push(`${w}.qr.size ${size} does not fit a ${h}px deck (at most ${h - 20})`);
+ }
+ });
+ return errors;
+}
+
+/** The posts (the popup cards and the feed): every `deck.posts` setting. */
+export function validatePostsSettings(d, { where: w }) {
+ const errors = [];
+ sub(d, "posts", ["show", "layout", "seconds", "hold", "position", "width", "qrSize", "maxLines", "inset", "shift", "links", "at", "shotMaxHeight", "qr"], w, errors, (p) => {
+ if (p.qr !== undefined && typeof p.qr !== "boolean") errors.push(`${w}.posts.qr must be true or false`);
+ if (p.at !== undefined && !POST_AT.includes(p.at)) {
+ errors.push(`${w}.posts.at must be ${POST_AT.map((a) => `"${a}"`).join(" or ")}`);
+ }
+ if (p.shotMaxHeight !== undefined && p.shotMaxHeight !== null &&
+ !(Number.isInteger(p.shotMaxHeight) && numIn(p.shotMaxHeight, 120, 1080))) {
+ errors.push(`${w}.posts.shotMaxHeight must be null or a whole number of pixels from 120 to 1080`);
+ }
+ if (p.layout !== undefined && !POST_LAYOUTS.includes(p.layout)) {
+ errors.push(`${w}.posts.layout must be ${POST_LAYOUTS.map((l) => `"${l}"`).join(" or ")}`);
+ }
+ if (p.links !== undefined && !POST_LINKS.includes(p.links)) {
+ errors.push(`${w}.posts.links must be ${POST_LINKS.map((l) => `"${l}"`).join(" or ")}`);
+ }
+ if (p.hold !== undefined && !numIn(p.hold, 0, 10)) errors.push(`${w}.posts.hold must be from 0 to 10 seconds`);
+ if (p.shift !== undefined && p.shift !== false) {
+ if (!isObj(p.shift)) errors.push(`${w}.posts.shift must be false or { scale, seconds }`);
+ else {
+ unknownKeys(p.shift, ["scale", "seconds"], `${w}.posts.shift`, errors);
+ if (p.shift.scale !== undefined && !numIn(p.shift.scale, 0.5, 1)) errors.push(`${w}.posts.shift.scale must be from 0.5 to 1`);
+ if (p.shift.seconds !== undefined && !numIn(p.shift.seconds, 0, 3)) errors.push(`${w}.posts.shift.seconds must be from 0 to 3`);
+ }
+ }
+ if (p.show !== undefined && typeof p.show !== "boolean") errors.push(`${w}.posts.show must be true or false`);
+ if (p.seconds !== undefined && !numIn(p.seconds, 0.5, 10)) errors.push(`${w}.posts.seconds must be from 0.5 to 10`);
+ if (p.position !== undefined && !["top-right", "top-left"].includes(p.position)) {
+ errors.push(`${w}.posts.position must be "top-right" or "top-left"`);
+ }
+ if (p.width !== undefined && !(Number.isInteger(p.width) && numIn(p.width, 320, 900))) {
+ errors.push(`${w}.posts.width must be a whole number of pixels from 320 to 900`);
+ }
+ if (p.qrSize !== undefined && !numIn(p.qrSize, 80, 200)) errors.push(`${w}.posts.qrSize must be from 80 to 200`);
+ if (p.maxLines !== undefined && !(Number.isInteger(p.maxLines) && numIn(p.maxLines, 2, 14))) {
+ errors.push(`${w}.posts.maxLines must be a whole number from 2 to 14`);
+ }
+ if (p.inset !== undefined && !numIn(p.inset, 0, 80)) errors.push(`${w}.posts.inset must be from 0 to 80`);
+ });
+ return errors;
+}
+
+/**
+ * Every module's settings, in the order validateChrome runs them: `id` the
+ * module's, `key` its path under `render.chrome` (`deck` keys are read from
+ * the deck object), `configKey` the manifest path its docs name.
+ */
+export const SETTINGS = Object.freeze([
+ // The fact-check (the stamps' settings, and the verdicts and tally the counter reads without `deck.counter`).
+ { id: "stamp", key: "factcheck", configKey: "render.chrome.factcheck",
+ validate: (v, { render }) => validateFactcheck(v, undefined, { fontBold: render.fontBold ?? null }) },
+ { id: "threads", key: "threads", configKey: "render.chrome.threads", validate: (v) => validateThreads(v) },
+ { id: "flips", key: "flips", configKey: "render.chrome.flips", validate: (v) => validateFlips(v) },
+ { id: "stats", key: "stats", configKey: "render.chrome.stats", validate: (v) => validateStats(v) },
+ { id: "fx", key: "fx", configKey: "render.chrome.fx", validate: (v) => validateFx(v) },
+ // From here the deck's own keys: `deck` is an object.
+ { id: "finale", key: "deck.finale", configKey: "render.chrome.deck.finale", deck: true,
+ validate: (v, { where }) => validateFinaleSettings(v, `${where}.finale`) },
+ { id: "claims", key: "deck.claims", configKey: "render.chrome.deck.claims", deck: true,
+ validate: (v, { where }) => deckClaimShapeErrors(v, `${where}.claims`) },
+ { 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 }),
+ }) },
+ { 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 },
+ { id: "subtitle", key: "deck", configKey: "render.chrome.deck.subtitle", deck: true, whole: true, validate: validateSubtitleSettings },
+ { id: "qr", key: "deck", configKey: "render.chrome.deck.qr", deck: true, whole: true, validate: validateQrSettings },
+ { id: "popup-posts", key: "deck", configKey: "render.chrome.deck.posts", deck: true, whole: true, validate: validatePostsSettings },
+].map((s) => Object.freeze(s)));
+
+/** A module's settings entry, or undefined. */
+export const settingsOf = (id) => SETTINGS.find((s) => s.id === id);
+
+/** The value a SETTINGS entry reads from `render.chrome`. */
+export function settingValue(chrome, entry) {
+ if (entry.whole) return chrome.deck ?? {};
+ return entry.key.split(".").reduce((o, k) => (isObj(o) ? o[k] : undefined), chrome);
+}
diff --git a/umtool/report-to-video/modules/shell.mjs b/umtool/report-to-video/modules/shell.mjs
@@ -9,6 +9,7 @@ import path from "node:path";
import { deckGeometry, deckLayout } from "../deck.mjs";
import { deckHtml } from "../chrome-deck.mjs";
import { assertRegion, defineModule } from "./contract.mjs";
+import { DECK_DEFAULTS, settingsOf } from "./settings.mjs";
export default defineModule({
id: "shell",
@@ -18,6 +19,35 @@ export default defineModule({
slot: "footer",
title: "Deck",
summary: "The panel at the foot of the frame: each clip's title, and the band the subtitle, QR, rail and counter draw in.",
+ configKey: "render.chrome.deck",
+ defaults: {
+ height: DECK_DEFAULTS.height, footageScale: DECK_DEFAULTS.footageScale, background: DECK_DEFAULTS.background,
+ overCards: DECK_DEFAULTS.overCards, title: DECK_DEFAULTS.title, motion: DECK_DEFAULTS.motion,
+ },
+ validate: settingsOf("shell").validate,
+ ui: [
+ { key: "height", type: "number", min: 120, max: 400, label: "Deck height (px)", default: DECK_DEFAULTS.height },
+ { key: "footageScale", type: "number", min: 0.5, max: 1, step: 0.01, label: "Footage scale", default: DECK_DEFAULTS.footageScale },
+ { key: "background", type: "enum", options: ["panel", "flush"], label: "Ground", default: DECK_DEFAULTS.background },
+ { key: "overCards", type: "enum", options: ["hide", "show"], label: "Over cards", default: DECK_DEFAULTS.overCards },
+ { key: "title.size", type: "number", min: 24, max: 96, label: "Title size", default: DECK_DEFAULTS.title.size },
+ { key: "title.maxChars", type: "number", min: 10, max: 120, label: "Title characters", default: DECK_DEFAULTS.title.maxChars },
+ { key: "motion.out", type: "number", min: 0, max: 2, step: 0.05, label: "Text out (s)", default: DECK_DEFAULTS.motion.out },
+ { key: "motion.in", type: "number", min: 0, max: 2, step: 0.05, label: "Text in (s)", default: DECK_DEFAULTS.motion.in },
+ { key: "motion.pip", type: "number", min: 0, max: 3, step: 0.05, label: "Marker move (s)", default: DECK_DEFAULTS.motion.pip },
+ ],
+ docs: {
+ heading: "Deck (the shell)",
+ intro: "The panel at the foot of the frame and each clip's title (`render.chrome.deck`); its parts -- the subtitle, the QR, the rail, the counter, the claim checks -- are their own modules below.",
+ rows: [
+ ["`deck.height`", "120–400 px · default 190", "`umtool look <p> deck.height=210`"],
+ ["`deck.footageScale`", "0.5–1 (the footage must fit above the deck) · default 0.82", "`umtool look <p> deck.footageScale=0.8`"],
+ ["`deck.background`", "`panel` · `flush` · default `panel`", "`umtool look <p> deck.background=flush`"],
+ ["`deck.overCards`", "`hide` (the deck slides away over a card) · `show` · default `hide`", "`umtool look <p> deck.overCards=show`"],
+ ["`deck.title`", "`{size 24–96, maxChars 10–120}` · default 54, 48", "`umtool look <p> deck.title='{\"size\":60}'`"],
+ ["`deck.motion`", "`{out 0–2, in 0–2, pip 0–3}` s · default 0.3, 0.45, 0.7", "`umtool look <p> deck.motion='{\"in\":0.6}'`"],
+ ],
+ },
region: "deck",
workers: "wide",
noun: "the deck's",
diff --git a/umtool/report-to-video/modules/stamp.mjs b/umtool/report-to-video/modules/stamp.mjs
@@ -7,6 +7,8 @@ import { stampGeometry } from "../deck.mjs";
import { stampHtml } from "../chrome-stamp.mjs";
import { stampsDrawn } from "../factcheck.mjs";
import { assertRegion, defineModule } from "./contract.mjs";
+import { FACTCHECK_DEFAULTS, FACTCHECK_LIMITS, STAMP_MOTIONS, STAMP_POSITIONS } from "../factcheck.mjs";
+import { settingsOf } from "./settings.mjs";
export default defineModule({
id: "stamp",
@@ -16,6 +18,28 @@ export default defineModule({
slot: "stamp",
title: "Stamps",
summary: "Each counted mark's word, stamped over the footage as it lands.",
+ configKey: "render.chrome.factcheck.stamp",
+ defaults: FACTCHECK_DEFAULTS.stamp,
+ validate: settingsOf("stamp").validate,
+ deps: ["counter.series"],
+ ui: [
+ { key: "show", type: "boolean", label: "Draw the stamps", default: true },
+ { key: "seconds", type: "number", min: FACTCHECK_LIMITS.seconds[0], max: FACTCHECK_LIMITS.seconds[1], step: 0.5, label: "Seconds", default: 3 },
+ { key: "position", type: "enum", options: STAMP_POSITIONS, label: "Corner", default: "top-left" },
+ { key: "scale", type: "number", min: FACTCHECK_LIMITS.scale[0], max: FACTCHECK_LIMITS.scale[1], step: 0.05, label: "Scale", default: 1 },
+ { key: "motion", type: "enum", options: STAMP_MOTIONS, label: "Motion", default: "slam" },
+ { key: "opacity", type: "number", min: FACTCHECK_LIMITS.opacity[0], max: FACTCHECK_LIMITS.opacity[1], step: 0.05, label: "Opacity", default: 1 },
+ ],
+ docs: {
+ heading: "Stamps",
+ intro: "Each counted mark's word stamped over the footage as it lands (`render.chrome.factcheck.stamp`); the word is the mark's `label`, else its series' `stampLabel`, else its label.",
+ rows: [
+ ["`factcheck.stamp.show`", "bool · default `true` (`false`: nothing drawn, the counter still counts)", "`umtool look <p> factcheck.stamp.show=false`"],
+ ["`factcheck.stamp.seconds`", `${FACTCHECK_LIMITS.seconds[0]}–${FACTCHECK_LIMITS.seconds[1]} s · default 3`, "`umtool look <p> factcheck.stamp.seconds=4`"],
+ ["`factcheck.stamp.position`", `${STAMP_POSITIONS.map((p) => `\`${p}\``).join(" ")} · default \`top-left\``, "`umtool look <p> factcheck.stamp.position=center`"],
+ ["`factcheck.stamp.scale`, `.motion`, `.opacity`", "0.5–2 · `slam` `pop` `fade` `none` · 0.3–1 · default 1, `slam`, 1", "`umtool look <p> factcheck.stamp.motion=pop`"],
+ ],
+ },
region: "stamp",
workers: "narrow",
noun: "the stamps'",
diff --git a/umtool/report-to-video/modules/stats.mjs b/umtool/report-to-video/modules/stats.mjs
@@ -6,6 +6,7 @@ import path from "node:path";
import { statsGeometry } from "../deck.mjs";
import { statsHtml } from "../chrome-stats.mjs";
import { assertRegion, defineModule } from "./contract.mjs";
+import { settingsOf } from "./settings.mjs";
export default defineModule({
id: "stats",
@@ -15,6 +16,15 @@ export default defineModule({
slot: "panel",
title: "Stats",
summary: "A frame scan's running numbers over the clips that declare them.",
+ validate: settingsOf("stats").validate,
+ docs: {
+ heading: "Stats",
+ intro: "A frame scan’s running numbers over the clips that declare them, in a panel in the footage (`render.chrome.stats`, stats.mjs).",
+ rows: [
+ ["`render.chrome.stats.position`", "`top-left` `top-right` `bottom-left` `bottom-right` · default `bottom-left`", "manifest"],
+ ["`render.chrome.stats.fields`, `.name`", "a list of `stack` `stackBB` `playersLeft` `level`; bool · default all, `true`", "manifest"],
+ ],
+ },
region: "stats",
workers: "narrow",
noun: "the stats region's",
diff --git a/umtool/report-to-video/modules/subtitle.mjs b/umtool/report-to-video/modules/subtitle.mjs
@@ -0,0 +1,34 @@
+// THE SUBTITLE (module `subtitle`, a part of the shell): each clip's source
+// line under its title -- who said it, the source's title, the date, the
+// clock in the source -- in the deck's page (deck.mjs `deckText`,
+// attribution.mjs `deckSubtitle`).
+import { DECK_DEFAULTS, SUBTITLE_TOKENS, settingsOf } from "./settings.mjs";
+import { defineModule } from "./contract.mjs";
+
+export default defineModule({
+ id: "subtitle",
+ version: 1,
+ z: 11,
+ kind: "part",
+ host: "shell",
+ slot: "inline",
+ title: "Subtitle",
+ summary: "Each clip's source line under its title: the channel, the source's title, the date, the clock.",
+ configKey: "render.chrome.deck.subtitle",
+ defaults: DECK_DEFAULTS.subtitle,
+ validate: settingsOf("subtitle").validate,
+ resolve: (render) => ({ ...DECK_DEFAULTS.subtitle, ...(render?.chrome?.deck?.subtitle ?? {}) }),
+ ui: [
+ { key: "parts", type: "list", options: ["auto", ...SUBTITLE_TOKENS], label: "Parts", default: "auto",
+ help: "\"auto\", or the parts in order: channel, title, date, clock" },
+ { key: "dateFormat", type: "enum", options: ["long", "iso"], label: "Date format", default: "long" },
+ ],
+ docs: {
+ heading: "Subtitle",
+ intro: "The source line under each clip's title, in the deck.",
+ rows: [
+ ["`deck.subtitle.parts`", "`auto` · a list of distinct `channel` `title` `date` `clock` · default `auto`", "`umtool look <p> deck.subtitle='{\"parts\":[\"channel\",\"date\",\"clock\"]}'`"],
+ ["`deck.subtitle.dateFormat`", "`long` (24 Oct 2020) · `iso` · default `long`", "`umtool look <p> deck.subtitle='{\"dateFormat\":\"iso\"}'`"],
+ ],
+ },
+});
diff --git a/umtool/report-to-video/modules/teaser.mjs b/umtool/report-to-video/modules/teaser.mjs
@@ -3,7 +3,7 @@
// (`{ type: "teaser" }`, deck.mjs). chrome-teaser.mjs writes the page; the
// build encodes its frames into segments/<id>.mp4 (build-video's
// buildTeaserSegment).
-import { teaserSeconds, validateTeaser } from "../deck.mjs";
+import { teaserSeconds, validateTeaser, validateTeasers } from "../deck.mjs";
import { defineModule } from "./contract.mjs";
export default defineModule({
@@ -14,6 +14,14 @@ export default defineModule({
slot: "full",
title: "Teaser",
summary: "A full-frame card of lines popping in on the beat, inserted as its own segment.",
+ validate: (_value, { manifest }) => validateTeasers(manifest),
+ docs: {
+ heading: "Teaser",
+ intro: "A timeline entry `{ type: \"teaser\", lines, … }`: a full-frame card whose lines pop in on the beat, cut in as its own segment (deck.mjs `validateTeaser`; [report-video.md](report-video.md)).",
+ rows: [
+ ["a `teaser` entry", "`lines` (each `{text, role?, hold?, …}`), `tail?`, `dip?`", "`umtool timeline <p> insert …`"],
+ ],
+ },
region: "teaser",
workers: "wide",
noun: "the teaser's",
diff --git a/umtool/report-to-video/modules/threads.mjs b/umtool/report-to-video/modules/threads.mjs
@@ -6,6 +6,7 @@ import path from "node:path";
import { threadsGeometry } from "../deck.mjs";
import { threadsHtml } from "../chrome-threads.mjs";
import { assertRegion, defineModule } from "./contract.mjs";
+import { settingsOf } from "./settings.mjs";
/** The side panel as an overlay region (the thread rail's and the flips'). */
export function sideRegion(render, frames, name) {
@@ -21,6 +22,14 @@ export default defineModule({
slot: "side",
title: "Thread rail",
summary: "A card per thread beside the footage, lit as its clips play.",
+ validate: settingsOf("threads").validate,
+ docs: {
+ heading: "Thread rail",
+ intro: "A card per thread in the side panel beside the footage, lit as its clips play; a thread’s outcome stamped on its last clip (`render.chrome.threads`, threads.mjs).",
+ rows: [
+ ["`render.chrome.threads.list[]`", "`{id, label, outcome?: {verdict, label?}}`; a clip names its thread with `thread`", "`umtool look <p> chrome.threads=…` (manifest)"],
+ ],
+ },
region: "threads",
workers: "narrow",
noun: "the thread rail's",