commit 572c5f5781e9b434b71a9183f011dda3f0f0a79f
parent c21316a839d95af8cdfa56050a18989acdbdace0
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Thu, 22 Oct 2026 10:27:45 -0400
fact-check knobs: a claim's at/hold/stamp/count/label; the stamp's scale, motion, opacity and stampLabel
On the entry that stamps (the last carrying the id), each optional:
- claim.at: the source second the stamp lands and the tally steps, mapped
to the cut through the segment's real source start (its cut record:
snapped, room included; the play window's start in an estimate or a
preview). Validated inside the clip's window. The schedule keeps the
segment's sourceFrom when a claim uses it.
- claim.hold 0.5-10 s: how long it stays (default stamp.seconds).
- claim.stamp false: counted in the tally, not drawn.
- claim.count 1-99: the tally steps by n; each count still has its own number.
- claim.label <= 20 chars: the stamp's words.
render.chrome.factcheck.stamp gains scale 0.5-2 (the region's size), motion
slam|pop|fade|none and opacity 0.3-1; verdicts[V].stampLabel is the stamp's
word beside the tally's label. Absent, the schedule and the pages are the
bytes they were.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
8 files changed, 470 insertions(+), 50 deletions(-)
diff --git a/umtool/lib/report/onscreen.mjs b/umtool/lib/report/onscreen.mjs
@@ -27,6 +27,7 @@ import {
deckText,
estimateSchedule,
footageMoves,
+ playWindow,
postHolds,
postSchedule,
postWindows,
@@ -239,7 +240,14 @@ export function previewSchedule({ variantManifest, built, draft, metas, postsDra
const c = claimOf(patchedEntries[i]);
return c ? { ...bare, claim: c } : bare;
});
- const stamps = stampSchedule({ segments: claimed, D: built.transition, total, render });
+ // A claim stamped at a source second (`claim.at`): the play window's start
+ // stands in for the cut record's (the build's is exact; snapping moves it).
+ const stamps = stampSchedule({
+ segments: claimed.map((s, i) => (s.claim?.at !== undefined
+ ? { ...s, sourceFrom: s.sourceFrom ?? playWindow(patchedEntries[i], render).from }
+ : s)),
+ D: built.transition, total, render,
+ });
return {
...rest,
...(feed ? { layout: "feed" } : {}),
diff --git a/umtool/report-to-video/build-video.mjs b/umtool/report-to-video/build-video.mjs
@@ -145,7 +145,7 @@ import {
} from "./deck.mjs";
// The effects region (`render.chrome.fx`, release 35): pure, in fx.mjs.
import { fxOn, fxQuoteSpan, resolveFx, fxWhipJoins, fxWipeJoins, fxWordsOf, fxZoomJoins, validateFxEntries } from "./fx.mjs";
-import { stampsDrawn, validateClaims } from "./factcheck.mjs";
+import { claimOf, stampsDrawn, validateClaims } from "./factcheck.mjs";
import { AUDIO_ON_CLOCK } from "./clip-audio.mjs";
import { SYNC_FILE, writeSyncReport } from "./sync-report.mjs";
import { validateThreadEntries } from "./threads.mjs";
@@ -4891,11 +4891,24 @@ export async function measureChromeSchedule({ manifest, entries, segments, D })
// The effects' words (render.chrome.fx): read only when an effect is on, so
// a cut without them measures exactly what it did.
const fx = fxOn(render) ? await fxClipWords({ entries, segments, provenance, render }) : null;
+ // A claim stamped at a source second (`claim.at`): the source second each
+ // claimed clip's segment really starts at, from its cut record (snapped,
+ // room included). Read only then.
+ let clipClock = null;
+ if (entries.some((e) => claimOf(e)?.at !== undefined)) {
+ clipClock = new Map();
+ for (let i = 0; i < entries.length; i += 1) {
+ if (claimOf(entries[i])?.at === undefined || !segments[i]) continue;
+ const rec = await readCutRecord(segments[i]).catch(() => null);
+ if (Number.isFinite(rec?.start)) clipClock.set(entries[i].id, rec.start);
+ }
+ }
// The variant's posts, placed on the clips this cut plays with their real
// upload dates. A manifest without posts writes the schedule it always did.
return deckSchedule({
entries, durs, D, render, provenance, metas, posts: manifest.posts ?? [], frameScan: manifest.frameScan ?? null,
...(fx ? { fxWords: fx.words, fxClock: fx.clock } : {}),
+ ...(clipClock ? { clipClock } : {}),
});
}
diff --git a/umtool/report-to-video/chrome-deck.mjs b/umtool/report-to-video/chrome-deck.mjs
@@ -38,7 +38,7 @@
import { fileURLToPath } from "node:url";
import { deckChoreography, deckLayout, deckMarkers, pageDuration, pipSegments, pipXs, resolveDeck } from "./deck.mjs";
-import { resolveFactcheck, tallyCues, tallyKey, tallyOf, VERDICT_SHAPES } from "./factcheck.mjs";
+import { resolveFactcheck, tallyCues, tallyFinals, tallyKey, tallyOf, VERDICT_SHAPES } from "./factcheck.mjs";
/**
* GSAP, vendored, for every chrome region.
@@ -460,7 +460,7 @@ export function deckHtml(schedule, render, opts = {}) {
? `<div class="tally">` +
tally
.map((v, j) => {
- const finals = schedule.factcheck.stamps.filter((s) => s.verdict === v).length;
+ const finals = tallyFinals(schedule.factcheck.stamps)[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("");
diff --git a/umtool/report-to-video/chrome-stamp.mjs b/umtool/report-to-video/chrome-stamp.mjs
@@ -13,7 +13,7 @@
// why at length). The times are factcheck.mjs `stampSchedule`'s, untouched.
import { pageDuration, stampGeometry } from "./deck.mjs";
import { mix, rgba } from "./chrome-deck.mjs";
-import { resolveFactcheck, STAMP_MOTION } from "./factcheck.mjs";
+import { drawnStamps, resolveFactcheck, STAMP_MOTION } from "./factcheck.mjs";
/** Instant cues still take a millisecond: a zero-duration tween has its own seek rules. */
const INSTANT = 0.001;
@@ -28,7 +28,7 @@ const esc = (s) =>
const r4 = (v) => Math.round(v * 10000) / 10000;
/** The stamp's tilt at rest, and how far past it (and how large) it starts its slam. */
-export const STAMP_POSE = Object.freeze({ rest: -6, from: -14, scale: 1.7, leaveScale: 0.96 });
+export const STAMP_POSE = Object.freeze({ rest: -6, from: -14, scale: 1.7, leaveScale: 0.96, popScale: 0.6 });
/**
* Everything the stamps' timeline does, as data. Stamp j is `st<j>` (autoAlpha,
@@ -37,24 +37,46 @@ export const STAMP_POSE = Object.freeze({ rest: -6, from: -14, scale: 1.7, leave
* `landed` -- the second the tally steps -- flashes, holds, and fades over its
* `out`.
*
+ * `factcheck.stamp.motion` (the render's; slam without one) changes only the
+ * entrance, which still ends at `landed`: "pop" grows it from
+ * `STAMP_POSE.popScale` × with an overshoot, "fade" fades it in, "none" puts
+ * it there at `landed`. Only slam and pop flash; "none" also leaves at once.
+ *
* @returns {{ init: Record<string, object>, cues: Array<{ k: string, at: number,
* dur: number, from: object, to: object, ease: string, why: string }> }}
*/
-export function stampCues(schedule) {
- const stamps = schedule.factcheck?.stamps ?? [];
+export function stampCues(schedule, render = null) {
+ // A claim's `stamp: false` counts in the tally and is not drawn here.
+ const stamps = drawnStamps(schedule.factcheck?.stamps);
+ const motion = render ? resolveFactcheck(render).stamp.motion ?? "slam" : "slam";
const P = STAMP_POSE;
const m = STAMP_MOTION;
const init = {};
const ev = [];
const add = (k, at, dur, to, ease, why) => ev.push({ k, at: r4(at), dur: r4(Math.max(INSTANT, dur)), to, ease, why });
stamps.forEach((s, j) => {
- init[`st${j}`] = { autoAlpha: 0, scale: P.scale, rotation: P.from };
- init[`fl${j}`] = { opacity: 0 };
const why = `stamp ${s.claim}`;
- add(`st${j}`, s.at, s.landed - s.at, { autoAlpha: 1, scale: 1, rotation: P.rest }, "power4.in", `${why} in`);
- add(`fl${j}`, s.landed, m.flashUp, { opacity: 1 }, "none", `${why} flash`);
- add(`fl${j}`, s.landed + m.flashUp, m.flashDown, { opacity: 0 }, "power2.out", `${why} flash`);
- add(`st${j}`, s.out[0], s.out[1] - s.out[0], { autoAlpha: 0, scale: P.leaveScale }, "power1.in", `${why} out`);
+ const rest = { autoAlpha: 1, scale: 1, rotation: P.rest };
+ if (motion === "slam") {
+ init[`st${j}`] = { autoAlpha: 0, scale: P.scale, rotation: P.from };
+ add(`st${j}`, s.at, s.landed - s.at, rest, "power4.in", `${why} in`);
+ } else if (motion === "pop") {
+ init[`st${j}`] = { autoAlpha: 0, scale: P.popScale, rotation: P.rest };
+ add(`st${j}`, s.at, s.landed - s.at, rest, "back.out(2.2)", `${why} in`);
+ } else if (motion === "fade") {
+ init[`st${j}`] = { autoAlpha: 0, scale: 1, rotation: P.rest };
+ add(`st${j}`, s.at, s.landed - s.at, { autoAlpha: 1 }, "power1.out", `${why} in`);
+ } else {
+ init[`st${j}`] = { autoAlpha: 0, scale: 1, rotation: P.rest };
+ add(`st${j}`, s.landed, INSTANT, { autoAlpha: 1 }, "none", `${why} in`);
+ }
+ if (motion === "slam" || motion === "pop") {
+ init[`fl${j}`] = { opacity: 0 };
+ add(`fl${j}`, s.landed, m.flashUp, { opacity: 1 }, "none", `${why} flash`);
+ add(`fl${j}`, s.landed + m.flashUp, m.flashDown, { opacity: 0 }, "power2.out", `${why} flash`);
+ }
+ if (motion === "none") add(`st${j}`, s.out[0], INSTANT, { autoAlpha: 0 }, "none", `${why} out`);
+ else add(`st${j}`, s.out[0], s.out[1] - s.out[0], { autoAlpha: 0, scale: P.leaveScale }, "power1.in", `${why} out`);
});
// Order, clamp (a cue never starts before the last on its element ends),
// and state every from: the last to on its element, or its init.
@@ -90,7 +112,7 @@ export function stampCues(schedule) {
* seconds.
*/
export function stampHtml(schedule, render, opts = {}) {
- const stamps = schedule.factcheck?.stamps ?? [];
+ const stamps = drawnStamps(schedule.factcheck?.stamps);
if (!stamps.length) throw new Error("stamp: the schedule stamps no claim");
const geo = stampGeometry(render, { feed: schedule.layout === "feed" });
const fc = resolveFactcheck(render);
@@ -103,7 +125,7 @@ export function stampHtml(schedule, render, opts = {}) {
const dur = opts.duration != null ? r4(Number(opts.duration)) : r4(total - from);
if (!(dur > 0)) throw new Error(`stamp: nothing to render from ${from}s of a ${total}s cut`);
const windowed = from > 0 || Math.abs(dur - total) > 1e-6;
- const { init, cues } = stampCues(schedule);
+ const { init, cues } = stampCues(schedule, render);
// The stamp's box: inside the region with room for its tilt, so no corner
// is clipped at rest (the slam's overscale passes the edges for a moment).
@@ -113,10 +135,12 @@ export function stampHtml(schedule, render, opts = {}) {
const stampHtmlList = stamps
.map((s, j) => {
const v = fc.verdicts[s.verdict] ?? { label: s.verdict, color: pal.accent };
+ // The words: the claim's own `label`, else the verdict's `stampLabel`, else its label.
+ const word = s.label ?? v.stampLabel ?? v.label;
return (
`<div class="stamp" data-claim="${esc(s.claim)}" data-verdict="${esc(s.verdict)}" data-k="st${j}" ` +
`style="--vc:${esc(v.color)}; --vg:${rgba(v.color, 0.6)}; --vb:${rgba(mix(pal.bg, v.color, 0.12), 0.82)}">` +
- `<div class="word">${esc(v.label)}</div>` +
+ `<div class="word">${esc(word)}</div>` +
`<div class="flash" data-k="fl${j}"></div></div>`
);
})
@@ -152,7 +176,7 @@ export function stampHtml(schedule, render, opts = {}) {
body { font-family: 'DeckSansBold', sans-serif; font-synthesis: none;
-webkit-font-smoothing: antialiased; text-rendering: geometricPrecision; }
#root { position: relative; width: ${W}px; height: ${H}px; overflow: hidden; }
- #stamp-clip { position: absolute; left: 0; top: 0; width: ${W}px; height: ${H}px; }
+ #stamp-clip { position: absolute; left: 0; top: 0; width: ${W}px; height: ${H}px;${fc.stamp.opacity !== undefined && fc.stamp.opacity !== 1 ? ` opacity: ${fc.stamp.opacity};` : ""} }
/* A rubber stamp: a double rule in the verdict's colour round its word,
on a dark wash so it reads over any footage. Hidden until its cue. */
.stamp { position: absolute; left: ${Math.round((W - bw) / 2)}px; top: ${Math.round((H - bh) / 2)}px;
diff --git a/umtool/report-to-video/claim-knobs.test.mjs b/umtool/report-to-video/claim-knobs.test.mjs
@@ -0,0 +1,231 @@
+// The claim's own knobs (factcheck.mjs): `at` (a source second the stamp lands
+// and the count steps), `hold`, `stamp: false`, `count`, `label`; and the
+// fact-check stamp's `scale`, `motion`, `opacity` and a verdict's `stampLabel`.
+// Absent, every one leaves the schedule and the pages as they were.
+//
+// Run with: pnpm test:scripts
+import assert from "node:assert/strict";
+import test from "node:test";
+
+import {
+ CLAIM_LIMITS, drawnStamps, normalizeClaim, resolveFactcheck, STAMP_MOTION, stampSchedule, stampsDrawn,
+ tallyCues, tallyFinals, tallySteps, validateClaims, validateFactcheck,
+} from "./factcheck.mjs";
+import { deckSchedule, stampGeometry } from "./deck.mjs";
+import { deckHtml } from "./chrome-deck.mjs";
+import { stampCues, stampHtml } from "./chrome-stamp.mjs";
+
+const PALETTE = { bg: "#12101a", fg: "#f4f1ea", muted: "#9a93ad", accent: "#a97bff", amber: "#ffc860" };
+const CHROME = { engine: "hyperframes", layout: "deck", deck: {} };
+const RENDER = { width: 1920, height: 1080, fps: 30, transition: 0.5, palette: PALETTE, chrome: CHROME };
+const PROV = { siteOrigin: "https://example.test", channelSlug: "demo-channel" };
+const near = (a, b, msg) => assert.ok(Math.abs(a - b) < 1e-3, `${msg}: ${a} != ${b}`);
+const withFc = (factcheck) => ({ ...RENDER, chrome: { ...CHROME, factcheck } });
+
+// ---- the claim ----------------------------------------------------------------
+
+test("normalizeClaim: the knobs ride along when set, and only then; out-of-range refused in sentences", () => {
+ assert.deepEqual(normalizeClaim({ id: "k1", verdict: "PARTLY" }), { id: "k1", verdict: "PARTLY" });
+ assert.deepEqual(
+ normalizeClaim({ id: "k1", verdict: "PARTLY", at: 12.5, hold: 2, stamp: false, count: 2, label: " 2 SEIZURES " }),
+ { id: "k1", verdict: "PARTLY", at: 12.5, hold: 2, stamp: false, count: 2, label: "2 SEIZURES" },
+ );
+ // The defaults written out are the defaults: dropped.
+ assert.deepEqual(normalizeClaim({ id: "k1", verdict: "PARTLY", stamp: true, count: 1 }), { id: "k1", verdict: "PARTLY" });
+ assert.throws(() => normalizeClaim({ id: "k1", verdict: "PARTLY", at: -1 }), /claim\.at must be a source second/);
+ assert.throws(() => normalizeClaim({ id: "k1", verdict: "PARTLY", hold: 0.2 }), /claim\.hold must be from 0\.5 to 10/);
+ assert.throws(() => normalizeClaim({ id: "k1", verdict: "PARTLY", hold: 11 }), /claim\.hold/);
+ assert.throws(() => normalizeClaim({ id: "k1", verdict: "PARTLY", stamp: "no" }), /claim\.stamp must be true or false/);
+ assert.throws(() => normalizeClaim({ id: "k1", verdict: "PARTLY", count: 0 }), /claim\.count must be a whole number from 1 to 99/);
+ assert.throws(() => normalizeClaim({ id: "k1", verdict: "PARTLY", count: 1.5 }), /claim\.count/);
+ assert.throws(() => normalizeClaim({ id: "k1", verdict: "PARTLY", count: 100 }), /claim\.count/);
+ assert.throws(() => normalizeClaim({ id: "k1", verdict: "PARTLY", label: " " }), /claim\.label must be words/);
+ assert.throws(() => normalizeClaim({ id: "k1", verdict: "PARTLY", label: "x".repeat(CLAIM_LIMITS.label + 1) }), /at most 20/);
+ assert.throws(() => normalizeClaim({ id: "k1", verdict: "PARTLY", label: "a\nb" }), /one line/);
+ assert.throws(() => normalizeClaim({ id: "k1", verdict: "PARTLY", when: 3 }), /claim\.when is not a claim field/);
+});
+
+test("validateClaims: `at` must lie in its clip's window (source seconds)", () => {
+ const at = (v) => ({ timeline: [{ type: "clip", id: "c1", start: 100, end: 130, claim: { id: "k", verdict: "PARTLY", at: v } }] });
+ assert.deepEqual(validateClaims(at(100)), []);
+ assert.deepEqual(validateClaims(at(130)), []);
+ assert.match(validateClaims(at(99.5))[0], /timeline\[0\] \(c1\)\.claim\.at 99\.5 is outside the clip's window 100–130/);
+ assert.equal(validateClaims(at(131)).length, 1);
+});
+
+// ---- the stamp's timing -------------------------------------------------------
+
+// Three 10 s segments, D 0.5: starts 0, 9.5, 19; c2's source starts at 200.
+const SEGS = (claim) => [
+ { id: "c1", start: 0, duration: 10, claim: null },
+ { id: "c2", start: 9.5, duration: 10, claim, sourceFrom: 200 },
+ { id: "c3", start: 19, duration: 10, claim: null },
+];
+const TOTAL = 29;
+
+test("stampSchedule: without knobs, the stamp it always placed", () => {
+ const [s] = stampSchedule({ segments: SEGS({ id: "k", verdict: "PARTLY" }), D: 0.5, total: TOTAL, render: RENDER });
+ assert.deepEqual(Object.keys(s), ["claim", "verdict", "segment", "at", "landed", "out"]);
+ near(s.at, 16, "3 s before the out");
+ near(s.landed, 16 + STAMP_MOTION.slam, "landed");
+ assert.deepEqual(s.out, [19, 19.5]);
+});
+
+test("stampSchedule: `at` lands the stamp at the source second's place in the cut; it stays `hold`, or stamp.seconds", () => {
+ // Source 203 is 3 s into c2, which starts at 9.5: lands at 12.5.
+ const [s] = stampSchedule({ segments: SEGS({ id: "k", verdict: "PARTLY", at: 203 }), D: 0.5, total: TOTAL, render: RENDER });
+ near(s.landed, 12.5, "landed");
+ near(s.at, 12.5 - STAMP_MOTION.slam, "slams in before");
+ near(s.out[0], s.at + 3, "stays stamp.seconds from its start");
+ near(s.out[1] - s.out[0], 0.5, "leaves over the transition's length");
+ // hold: 1.5
+ const [h] = stampSchedule({ segments: SEGS({ id: "k", verdict: "PARTLY", at: 203, hold: 1.5 }), D: 0.5, total: TOTAL, render: RENDER });
+ near(h.out[0], h.at + 1.5, "hold");
+ // A hold past the segment's out leaves with the transition, as ever.
+ const [late] = stampSchedule({ segments: SEGS({ id: "k", verdict: "PARTLY", at: 208, hold: 10 }), D: 0.5, total: TOTAL, render: RENDER });
+ assert.deepEqual(late.out, [19, 19.5]);
+ // Kept inside the segment: before its start lands at its start; past its out, at the out.
+ const [early] = stampSchedule({ segments: SEGS({ id: "k", verdict: "PARTLY", at: 150 }), D: 0.5, total: TOTAL, render: RENDER });
+ near(early.landed, 9.5, "clamped to the segment's start");
+ near(early.at, 9.5, "never before it");
+ const [past] = stampSchedule({ segments: SEGS({ id: "k", verdict: "PARTLY", at: 260 }), D: 0.5, total: TOTAL, render: RENDER });
+ near(past.landed, 19, "clamped to its out");
+ // hold without `at`: comes in `hold` before the out.
+ const [ho] = stampSchedule({ segments: SEGS({ id: "k", verdict: "PARTLY", hold: 5 }), D: 0.5, total: TOTAL, render: RENDER });
+ near(ho.at, 14, "hold before the out");
+ // No source clock: as if there were no `at`.
+ const segs = SEGS({ id: "k", verdict: "PARTLY", at: 203 }).map(({ sourceFrom: _s, ...s }) => s);
+ const [noClock] = stampSchedule({ segments: segs, D: 0.5, total: TOTAL, render: RENDER });
+ near(noClock.at, 16, "no clock, default timing");
+});
+
+test("stampSchedule: count, stamp:false and label ride on the stamp, and only when set", () => {
+ const [s] = stampSchedule({
+ segments: SEGS({ id: "k", verdict: "PARTLY", count: 2, stamp: false, label: "2 SEIZURES" }), D: 0.5, total: TOTAL, render: RENDER,
+ });
+ assert.equal(s.count, 2);
+ assert.equal(s.stamp, false);
+ assert.equal(s.label, "2 SEIZURES");
+});
+
+test("deckSchedule: a claim's `at` through the cut record's clock; the segment keeps its sourceFrom; none without `at`", () => {
+ const entries = [
+ { type: "clip", id: "c1", video: "v1", start: 10, end: 20 },
+ { type: "clip", id: "c2", video: "v2", start: 200, end: 210, claim: { id: "k", verdict: "PARTLY", at: 203.4 } },
+ ];
+ const s = deckSchedule({ entries, durs: [10, 10], D: 0.5, render: RENDER, provenance: PROV, clipClock: new Map([["c2", 200.4]]) });
+ // 203.4 is 3.0 s past where c2's segment really starts (200.4): 9.5 + 3.
+ near(s.factcheck.stamps[0].landed, 12.5, "landed");
+ assert.equal(s.segments[1].sourceFrom, 200.4);
+ assert.deepEqual(s.segments[1].claim, { id: "k", verdict: "PARTLY", at: 203.4 });
+ // Without the clock: the play window's start (200) stands in.
+ const est = deckSchedule({ entries, durs: [10, 10], D: 0.5, render: RENDER, provenance: PROV });
+ near(est.factcheck.stamps[0].landed, 12.9, "estimated");
+ // Without `at`, no sourceFrom key at all.
+ const plain = deckSchedule({ entries: entries.map((e) => (e.claim ? { ...e, claim: { id: "k", verdict: "PARTLY" } } : e)), durs: [10, 10], D: 0.5, render: RENDER, provenance: PROV });
+ assert.equal("sourceFrom" in plain.segments[1], false);
+});
+
+// ---- the tally ------------------------------------------------------------------
+
+const ST = (claim, verdict, landed, extra = {}) => ({ claim, verdict, segment: claim, at: landed - 0.28, landed, out: [landed + 2, landed + 2.5], ...extra });
+
+test("tallySteps / tallyFinals: a claim's count steps its verdict by n", () => {
+ const stamps = [ST("a", "PARTLY", 5), ST("b", "PARTLY", 10, { count: 2 }), ST("c", "CONTRADICTED", 12, { count: 3 })];
+ const steps = tallySteps(stamps);
+ assert.deepEqual(steps.map((s) => [s.verdict, s.count, s.step]), [["PARTLY", 1, 1], ["PARTLY", 3, 2], ["CONTRADICTED", 3, 3]]);
+ assert.equal(tallyFinals(stamps).PARTLY, 3);
+ assert.equal(tallyFinals(stamps).CONTRADICTED, 3);
+});
+
+test("tallyCues: a step of n rolls the number it was on out and the number it reaches in", () => {
+ const stamps = [ST("a", "PARTLY", 5), ST("b", "PARTLY", 10, { count: 2 })];
+ const { init, events } = tallyCues(stamps, ["PARTLY"]);
+ // Every count up to the final has its element (n2 is passed over, never shown).
+ assert.deepEqual(Object.keys(init).filter((k) => /\.n\d+$/.test(k)), ["ty.PARTLY.n0", "ty.PARTLY.n1", "ty.PARTLY.n2", "ty.PARTLY.n3"]);
+ const at10 = events.filter((e) => e.at === 10 && /\.n\d+$/.test(e.k)).map((e) => [e.k, e.to.autoAlpha]);
+ assert.deepEqual(at10, [["ty.PARTLY.n1", 0], ["ty.PARTLY.n3", 1]]);
+ // The cell lights at its first step whatever that step's size.
+ const first = tallyCues([ST("x", "PARTLY", 4, { count: 2 })], ["PARTLY"]).events.filter((e) => e.k === "ty.PARTLY" && e.to.opacity === 1);
+ assert.equal(first.length, 1);
+});
+
+test("the deck's tally page carries every number the tally reaches", () => {
+ const entries = [
+ { type: "clip", id: "c1", video: "v1", start: 10, end: 20, claim: { id: "k1", verdict: "PARTLY", count: 2 } },
+ { type: "clip", id: "c2", video: "v2", start: 30, end: 40, claim: { id: "k2", verdict: "PARTLY" } },
+ ];
+ const s = deckSchedule({ entries, durs: [10, 10], D: 0.5, render: RENDER, provenance: PROV });
+ const html = deckHtml(s, RENDER, {});
+ assert.match(html, /data-k="ty\.PARTLY\.n3">3</);
+ assert.doesNotMatch(html, /data-k="ty\.PARTLY\.n4"/);
+});
+
+// ---- drawing ------------------------------------------------------------------
+
+test("stamp:false: counted in the tally, not drawn; a cut whose every claim is hidden draws no stamps", () => {
+ const sched = { total: 30, fps: 30, factcheck: { stamps: [ST("a", "PARTLY", 5, { stamp: false }), ST("b", "PARTLY", 10)] } };
+ assert.equal(drawnStamps(sched.factcheck.stamps).length, 1);
+ const { cues } = stampCues(sched);
+ assert.ok(cues.every((c) => /st0|fl0/.test(c.k)));
+ assert.ok(cues.some((c) => c.at === 9.72 && c.k === "st0"), "the drawn one is stamp 0");
+ assert.equal(tallySteps(sched.factcheck.stamps).at(-1).count, 2);
+ assert.equal(stampsDrawn(sched, RENDER), true);
+ const none = { ...sched, factcheck: { stamps: [ST("a", "PARTLY", 5, { stamp: false })] } };
+ assert.equal(stampsDrawn(none, RENDER), false);
+});
+
+test("the stamp's words: the claim's label, else the verdict's stampLabel, else its label", () => {
+ const sched = { total: 30, fps: 30, factcheck: { stamps: [ST("a", "PARTLY", 5, { label: "2 Seizures" }), ST("b", "PARTLY", 10), ST("c", "CONTRADICTED", 15)] } };
+ const r = withFc({ verdicts: { PARTLY: { label: "Seizures", stampLabel: "Seizure" } } });
+ const html = stampHtml(sched, r, {});
+ const words = [...html.matchAll(/<div class="word">([^<]*)<\/div>/g)].map((m) => m[1]);
+ assert.deepEqual(words, ["2 Seizures", "Seizure", "Contradicted"]);
+});
+
+// ---- the stamp's look -------------------------------------------------------------
+
+test("factcheck stamp scale/motion/opacity and verdicts[V].stampLabel: validated, defaulted", () => {
+ const fc = resolveFactcheck(RENDER);
+ assert.equal(fc.stamp.scale, 1);
+ assert.equal(fc.stamp.motion, "slam");
+ assert.equal(fc.stamp.opacity, 1);
+ assert.deepEqual(validateFactcheck({ stamp: { scale: 0.5, motion: "fade", opacity: 0.3 } }), []);
+ assert.deepEqual(validateFactcheck({ stamp: { scale: 2, motion: "none", opacity: 1 } }), []);
+ const bad = validateFactcheck({ stamp: { scale: 2.5, motion: "spin", opacity: 0.2 } });
+ assert.equal(bad.length, 3);
+ assert.match(bad[0], /stamp\.scale must be from 0\.5 to 2/);
+ assert.match(bad[1], /stamp\.motion must be "slam", "pop", "fade", "none"/);
+ assert.match(bad[2], /stamp\.opacity must be from 0\.3 to 1/);
+ assert.deepEqual(validateFactcheck({ verdicts: { PARTLY: { label: "Seizures", stampLabel: "Seizure" } } }), []);
+ assert.match(validateFactcheck({ verdicts: { PARTLY: { stampLabel: "" } } })[0], /stampLabel must be words/);
+ assert.match(validateFactcheck({ verdicts: { PARTLY: { stampLabel: "x".repeat(25) } } })[0], /stampLabel is 25 characters \(at most 24\)/);
+ assert.equal(resolveFactcheck(withFc({ verdicts: { PARTLY: { stampLabel: "Seizure" } } })).verdicts.PARTLY.stampLabel, "Seizure");
+});
+
+test("stamp motion: slam as ever; pop and fade change the entrance; none appears; scale and opacity on the box", () => {
+ const sched = { total: 30, fps: 30, factcheck: { stamps: [ST("a", "PARTLY", 5)] } };
+ const slam = stampCues(sched, RENDER);
+ const def = stampCues(sched);
+ assert.deepEqual(slam, def, "the render's default motion is the motion without one");
+ assert.equal(slam.init.st0.scale, 1.7);
+ const pop = stampCues(sched, withFc({ stamp: { motion: "pop" } }));
+ assert.ok(pop.init.st0.scale < 1 && pop.init.st0.rotation === -6);
+ const fade = stampCues(sched, withFc({ stamp: { motion: "fade" } }));
+ assert.deepEqual(fade.init.st0, { autoAlpha: 0, scale: 1, rotation: -6 });
+ const none = stampCues(sched, withFc({ stamp: { motion: "none" } }));
+ const inCue = none.cues.find((c) => c.k === "st0" && c.to.autoAlpha === 1);
+ assert.ok(inCue.dur <= 0.002 && Math.abs(inCue.at + inCue.dur - 5) < 0.002, "appears at its landing");
+ assert.equal(none.cues.filter((c) => c.k === "fl0").length, 0, "no flash without a slam or a pop");
+ // The look: scale sizes the stamp's region (and the stamp with it), kept in
+ // the footage box; opacity is the whole region's, written only when set.
+ assert.deepEqual(stampGeometry(RENDER), stampGeometry(withFc({ stamp: { scale: 1 } })));
+ const big = stampGeometry(withFc({ stamp: { scale: 1.5 } }));
+ assert.equal(big.width, 840);
+ assert.equal(big.height, 300);
+ assert.equal(stampGeometry(withFc({ stamp: { scale: 0.5 } })).width, 280);
+ const plain = stampHtml(sched, RENDER, {});
+ assert.doesNotMatch(plain, /#stamp-clip \{[^}]*opacity/);
+ const looked = stampHtml(sched, withFc({ stamp: { opacity: 0.6 } }), {});
+ assert.match(looked, /#stamp-clip \{[^}]*opacity: 0\.6;/);
+});
diff --git a/umtool/report-to-video/deck.mjs b/umtool/report-to-video/deck.mjs
@@ -801,7 +801,7 @@ export function deckQrUrl(entry, provenance = {}, { links = DECK_DEFAULTS.qr.lin
*/
export function deckSchedule({
entries, durs, D, render, provenance = {}, metas = [], estimated = false, posts = [], frameScan = null,
- fxWords = null, fxClock = null,
+ fxWords = null, fxClock = null, clipClock = null,
}) {
const deck = resolveDeck(render);
const fps = render.fps ?? 30;
@@ -820,7 +820,18 @@ export function deckSchedule({
// the deck alone, and writes the schedule a deck without posts always did.
const feed = placed.length > 0 && deck.posts.layout === "feed";
const moves = placed.length && !feed ? footageMoves({ posts: placed, segments: segs, render }) : [];
- const stamps = stampSchedule({ segments: segs.map((s, i) => ({ ...s, claim: claimOf(entries[i]) })), D, total, render });
+ // A claim stamped at a source second (`claim.at`) needs the source second
+ // its segment starts at: the cut record's (`clipClock`), else the play
+ // window's estimate. Only then: a cut without `at` places what it did.
+ const stamps = stampSchedule({
+ segments: segs.map((s, i) => {
+ const claim = claimOf(entries[i]);
+ if (claim?.at === undefined) return { ...s, claim };
+ const e = entries[i];
+ return { ...s, claim, sourceFrom: clipClock?.get(e.id) ?? fxClock?.get(e.id) ?? playWindow(e, render).from };
+ }),
+ D, total, render,
+ });
const threads = threadsOn(render)
? threadSchedule({ segments: segs.map((s, i) => ({ ...s, thread: threadOf(entries[i]) })), D, total, render, moves })
: null;
@@ -874,6 +885,9 @@ export function deckSchedule({
...(dipOf(e, fps) ? { dip: dipOf(e, fps) } : {}),
// Only on an entry that carries a claim (factcheck.mjs), likewise.
...(claimOf(e) ? { claim: claimOf(e) } : {}),
+ // 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.
+ ...(claimOf(e)?.at !== undefined ? { sourceFrom: round(clipClock?.get(e.id) ?? fxClock?.get(e.id) ?? playWindow(e, render).from) } : {}),
};
}),
// The fact-check stamps: present only when a claim is stamped.
@@ -1448,10 +1462,11 @@ export function stampGeometry(render, { feed = false } = {}) {
const { W } = deckGeometry(render);
const f = feed ? feedGeometry(render).footage : deckGeometry(render).footage;
const k = W / 1920;
- const width = Math.min(even(560 * k), even(f.width));
- const height = Math.min(even(200 * k), even(f.height));
+ // `stamp.scale` sizes the region (the stamp is drawn to it), still inside the footage.
+ const { position: pos, scale = 1 } = resolveFactcheck(render).stamp;
+ const width = Math.min(even(560 * k * scale), even(f.width));
+ const height = Math.min(even(200 * k * scale), even(f.height));
const inset = Math.round(28 * k);
- const pos = resolveFactcheck(render).stamp.position;
const [v, h] = pos === "center" ? ["center", "center"] : pos.split("-");
const x = h === "left" ? f.x + inset : h === "right" ? f.x + f.width - inset - width : f.x + (f.width - width) / 2;
const y = v === "top" ? f.y + inset : v === "bottom" ? f.y + f.height - inset - height : f.y + (f.height - height) / 2;
diff --git a/umtool/report-to-video/factcheck.mjs b/umtool/report-to-video/factcheck.mjs
@@ -3,8 +3,14 @@
// deck whose counts step up as each stamp lands.
//
// timeline entry: "claim": { "id": "k3", "verdict": "CONTRADICTED" }
-// render.chrome: "factcheck": { "verdicts": { "PARTLY": { "label": "Half true" } },
-// "stamp": { "show": true, "seconds": 3, "position": "top-left" },
+// -- and, each optional, on the entry that stamps (the
+// LAST carrying the id): "at" (source seconds the stamp
+// lands and the count steps), "hold" (seconds on screen),
+// "stamp": false (counts, draws nothing), "count" (steps
+// the tally by n), "label" (the stamp's words)
+// render.chrome: "factcheck": { "verdicts": { "PARTLY": { "label": "Half true", "stampLabel": "Half" } },
+// "stamp": { "show": true, "seconds": 3, "position": "top-left",
+// "scale": 1, "motion": "slam", "opacity": 1 },
// "tally": { "show": true, "position": "right" } }
//
// `claim` is its own key: an entry's `verdict` is the clip review's
@@ -35,6 +41,9 @@ export { VERDICTS };
/** Where the stamp sits in the footage box. */
export const STAMP_POSITIONS = Object.freeze(["top-left", "top-right", "bottom-left", "bottom-right", "center"]);
+/** How a stamp comes in: slammed down (as ever), popped up, faded in, or just there. */
+export const STAMP_MOTIONS = Object.freeze(["slam", "pop", "fade", "none"]);
+
/** Which end of the deck's text column the tally takes. */
export const TALLY_POSITIONS = Object.freeze(["right", "left"]);
@@ -48,12 +57,28 @@ export const FACTCHECK_DEFAULTS = Object.freeze({
verdicts: VERDICT_DEFAULTS,
// `show: false` draws no stamp at all -- no composition, no overlay -- and
// the tally still counts each claim at the second its stamp would have landed.
- stamp: Object.freeze({ show: true, seconds: 3, position: "top-left" }),
+ // `scale` sizes the stamp's region (and so the stamp), `motion` is how it
+ // comes in, `opacity` the whole stamp's.
+ stamp: Object.freeze({ show: true, seconds: 3, position: "top-left", scale: 1, motion: "slam", opacity: 1 }),
tally: Object.freeze({ show: true, position: "right" }),
});
/** The limits: a stamp's seconds on screen, a label's characters. */
-export const FACTCHECK_LIMITS = Object.freeze({ seconds: Object.freeze([1, 10]), label: VERDICT_LABEL_MAX });
+export const FACTCHECK_LIMITS = Object.freeze({
+ seconds: Object.freeze([1, 10]),
+ label: VERDICT_LABEL_MAX,
+ scale: Object.freeze([0.5, 2]),
+ opacity: Object.freeze([0.3, 1]),
+});
+
+/**
+ * A claim's own knobs (on the entry that stamps): `hold` seconds on screen,
+ * `count` the tally's step, `label` the stamp's characters.
+ */
+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"]);
/**
* The stamp's motion, in seconds: it slams in over `slam` (landing is when the
@@ -103,7 +128,19 @@ export function validateFactcheck(f, where = "render.chrome.factcheck") {
for (const [k, v] of Object.entries(f.verdicts)) {
const w = `${where}.verdicts.${k}`;
if (!VERDICTS.includes(k)) { errors.push(`${w} is not a verdict (${VERDICTS.join(", ")})`); continue; }
- errors.push(...verdictOverrideProblems(v, w));
+ // `stampLabel` is the video's own (the stamp's word beside the tally's
+ // `label`); the rest is common's override, checked by common's rule.
+ if (isObj(v) && v.stampLabel !== undefined) {
+ const { stampLabel, ...rest } = v;
+ if (typeof stampLabel !== "string" || !stampLabel.trim()) errors.push(`${w}.stampLabel must be words, not empty`);
+ else if (/[\r\n]/.test(stampLabel)) errors.push(`${w}.stampLabel must be one line`);
+ else if (stampLabel.trim().length > VERDICT_LABEL_MAX) {
+ errors.push(`${w}.stampLabel is ${stampLabel.trim().length} characters (at most ${VERDICT_LABEL_MAX})`);
+ }
+ errors.push(...verdictOverrideProblems(rest, w));
+ } else {
+ errors.push(...verdictOverrideProblems(v, w));
+ }
}
}
}
@@ -113,13 +150,20 @@ export function validateFactcheck(f, where = "render.chrome.factcheck") {
unknownKeys(f[key], allowed, `${where}.${key}`, errors);
check(f[key]);
};
- sub("stamp", ["show", "seconds", "position"], (s) => {
+ sub("stamp", ["show", "seconds", "position", "scale", "motion", "opacity"], (s) => {
if (s.show !== undefined && typeof s.show !== "boolean") errors.push(`${where}.stamp.show must be true or false`);
const [lo, hi] = FACTCHECK_LIMITS.seconds;
if (s.seconds !== undefined && !numIn(s.seconds, lo, hi)) errors.push(`${where}.stamp.seconds must be from ${lo} to ${hi}`);
if (s.position !== undefined && !STAMP_POSITIONS.includes(s.position)) {
errors.push(`${where}.stamp.position must be ${STAMP_POSITIONS.map((p) => `"${p}"`).join(", ")}`);
}
+ const [slo, shi] = FACTCHECK_LIMITS.scale;
+ if (s.scale !== undefined && !numIn(s.scale, slo, shi)) errors.push(`${where}.stamp.scale must be from ${slo} to ${shi}`);
+ if (s.motion !== undefined && !STAMP_MOTIONS.includes(s.motion)) {
+ errors.push(`${where}.stamp.motion must be ${STAMP_MOTIONS.map((m) => `"${m}"`).join(", ")}`);
+ }
+ const [olo, ohi] = FACTCHECK_LIMITS.opacity;
+ if (s.opacity !== undefined && !numIn(s.opacity, olo, ohi)) errors.push(`${where}.stamp.opacity must be from ${olo} to ${ohi}`);
});
sub("tally", ["show", "position"], (t) => {
if (t.show !== undefined && typeof t.show !== "boolean") errors.push(`${where}.tally.show must be true or false`);
@@ -136,21 +180,59 @@ export function validateFactcheck(f, where = "render.chrome.factcheck") {
/**
* A `claim` value, normalised: `{ id, verdict }` with the id trimmed, or null
- * for none (`undefined`, `null`). Throws a sentence on a shape no writer
- * should store.
+ * for none (`undefined`, `null`), plus each knob it sets -- `at` (source
+ * seconds), `hold` (seconds), `stamp: false`, `count` (1–99) and `label`
+ * (trimmed, ≤ 20 characters) -- and nothing it does not, so a claim without
+ * knobs is the `{ id, verdict }` it always was. `stamp: true` is the default
+ * and is dropped. Throws a sentence on a shape no writer should store. (That
+ * `at` lies in its entry's window is validateClaims', which has the entry.)
*
- * @returns {{ id: string, verdict: string } | null}
+ * @returns {{ id: string, verdict: string, at?: number, hold?: number,
+ * stamp?: false, count?: number, label?: string } | null}
*/
export function normalizeClaim(v) {
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)) {
- if (k !== "id" && k !== "verdict") throw new Error(`claim.${k} is not a claim field (id, verdict)`);
+ if (!CLAIM_KEYS.includes(k)) throw new Error(`claim.${k} is not a claim field (${CLAIM_KEYS.join(", ")})`);
}
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(", ")}`);
- return { id, verdict: v.verdict };
+ const out = { id, verdict: v.verdict };
+ 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;
+ }
+ if (v.hold !== undefined) {
+ const [lo, hi] = CLAIM_LIMITS.hold;
+ if (!numIn(v.hold, lo, hi)) throw new Error(`claim.hold must be from ${lo} to ${hi} seconds`);
+ out.hold = v.hold;
+ }
+ if (v.stamp !== undefined) {
+ if (typeof v.stamp !== "boolean") throw new Error("claim.stamp must be true or false");
+ if (v.stamp === false) out.stamp = false;
+ }
+ if (v.count !== undefined) {
+ const [lo, hi] = CLAIM_LIMITS.count;
+ if (!Number.isInteger(v.count) || v.count < lo || v.count > hi) throw new Error(`claim.count must be a whole number from ${lo} to ${hi}`);
+ if (v.count !== 1) out.count = v.count;
+ }
+ if (v.label !== undefined) {
+ const label = typeof v.label === "string" ? v.label.trim() : "";
+ if (!label) throw new Error("claim.label must be words, not empty");
+ if (/[\r\n]/.test(label)) throw new Error("claim.label must be one line");
+ if (label.length > CLAIM_LIMITS.label) throw new Error(`claim.label is ${label.length} characters (at most ${CLAIM_LIMITS.label})`);
+ out.label = label;
+ }
+ return out;
+}
+
+/** The knobs of a normalised claim (everything but its id and verdict). */
+export function claimKnobs(claim) {
+ if (!claim) return {};
+ const { id: _i, verdict: _v, ...knobs } = claim;
+ return knobs;
}
/** An entry's claim when it carries a sound one, else null. Never throws. */
@@ -185,6 +267,10 @@ export function validateClaims(manifest) {
errors.push(`${where}.${err.message}`);
return;
}
+ // `at` is the entry's own clock: a second of the source inside its window.
+ if (c.at !== undefined && Number.isFinite(e.start) && Number.isFinite(e.end) && (c.at < e.start || c.at > e.end)) {
+ errors.push(`${where}.claim.at ${c.at} is outside the clip's window ${e.start}–${e.end} (source seconds)`);
+ }
const seen = verdictOf.get(c.id);
if (seen && seen.verdict !== c.verdict) {
errors.push(`${where}.claim ${c.id} is ${c.verdict} here and ${seen.verdict} at ${seen.where} -- one claim, one verdict`);
@@ -204,15 +290,28 @@ export function validateClaims(manifest) {
* The stamp leaves with that segment's outgoing transition -- the next
* segment's start to its start + D with a crossfade, the 0.3 s before the cut
* on a hard cut, the last 0.3 s of the last segment -- and comes in `seconds`
- * before it leaves (`stamp.seconds`), or as the segment's incoming dissolve
- * ends when the segment is shorter than that. It has LANDED -- and the tally
- * steps -- `STAMP_MOTION.slam` after it starts, never after it starts leaving.
+ * before it leaves (`stamp.seconds`, or the claim's `hold`), or as the
+ * segment's incoming dissolve ends when the segment is shorter than that. It
+ * has LANDED -- and the tally steps -- `STAMP_MOTION.slam` after it starts,
+ * never after it starts leaving.
+ *
+ * A claim with `at` (a SOURCE second) lands then instead: at the segment's
+ * start plus `at` less the source second the segment starts at (its
+ * `sourceFrom`, the cut record's: snapped, room included), kept inside the
+ * segment; it slams in over the `slam` before, stays `hold` (else
+ * `stamp.seconds`) from its start, and leaves over as long as the segment's
+ * transition -- or with the transition, if that comes first. A segment with
+ * no `sourceFrom` stamps the claim as if it had no `at`.
+ *
+ * The claim's other knobs ride on its stamp only when set: `count` (the
+ * tally's step), `stamp: false` (counted, not drawn), `label` (the stamp's
+ * words). A claim without knobs stamps exactly as it always did.
*
* `segments` are the schedule's, in order, each `{ id, start, duration,
- * claim? }` (`claim` as `claimOf` gives it).
+ * claim?, sourceFrom? }` (`claim` as `claimOf` gives it).
*
* @returns {Array<{ claim: string, verdict: string, segment: string, at: number,
- * landed: number, out: [number, number] }>}
+ * landed: number, out: [number, number], count?: number, stamp?: false, label?: string }>}
*/
export function stampSchedule({ segments, D, total, render }) {
const seconds = resolveFactcheck(render).stamp.seconds;
@@ -222,24 +321,44 @@ export function stampSchedule({ segments, D, total, render }) {
.sort((a, b) => a[1] - b[1])
.map(([claim, i]) => {
const seg = segments[i];
+ const c = seg.claim;
const next = segments[i + 1];
const out = !next
? [total - 0.3, total]
: D > 0 ? [next.start, next.start + D] : [next.start - 0.3, next.start];
const from = seg.start + (i > 0 ? D : 0);
- const at = Math.min(Math.max(from, out[0] - seconds), out[0]);
+ const stay = c.hold ?? seconds;
+ const knobs = {
+ ...(c.count !== undefined && c.count !== 1 ? { count: c.count } : {}),
+ ...(c.stamp === false ? { stamp: false } : {}),
+ ...(c.label !== undefined ? { label: c.label } : {}),
+ };
+ if (c.at !== undefined && Number.isFinite(seg.sourceFrom)) {
+ // The cut's second the source's `at` plays at, inside the segment
+ // and before its stamp has to leave.
+ const want = seg.start + (c.at - seg.sourceFrom);
+ const landed = Math.min(Math.max(seg.start, want), out[0]);
+ const at = Math.max(seg.start, landed - STAMP_MOTION.slam);
+ const leave = Math.min(at + stay, out[0]);
+ const own = leave < out[0] ? [leave, leave + (out[1] - out[0])] : out;
+ return { claim, verdict: c.verdict, segment: seg.id, at, landed, out: own, ...knobs };
+ }
+ const at = Math.min(Math.max(from, out[0] - stay), out[0]);
const landed = Math.min(at + STAMP_MOTION.slam, out[0]);
- return { claim, verdict: seg.claim.verdict, segment: seg.id, at, landed, out };
+ return { claim, verdict: c.verdict, segment: seg.id, at, landed, out, ...knobs };
});
}
+/** The stamps that are DRAWN: all but a claim's `stamp: false`. */
+export const drawnStamps = (stamps = []) => stamps.filter((s) => s.stamp !== false);
+
/**
* Are the stamps DRAWN: the schedule stamps a claim and `stamp.show` is on.
* With it off the schedule still carries its stamps -- the tally counts at
* each one's `landed` -- but no stamp composition is rendered or laid.
*/
export function stampsDrawn(schedule, render) {
- return !!schedule?.factcheck?.stamps?.length && resolveFactcheck(render).stamp.show !== false;
+ return drawnStamps(schedule?.factcheck?.stamps).length > 0 && resolveFactcheck(render).stamp.show !== false;
}
/**
@@ -265,20 +384,30 @@ export function tallyVerdicts(stamps = []) {
/**
* The tally's steps, in landing order: at each stamp's `landed`, its verdict's
- * count goes up by one. `counts` is every verdict's count after the step.
+ * count goes up by the stamp's `count` (1 unless its claim says). `count` is
+ * the verdict's count after the step, `step` what it went up by, `counts`
+ * every verdict's count after it.
*
- * @returns {Array<{ at: number, verdict: string, count: number, counts: Record<string, number> }>}
+ * @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]));
return [...stamps]
.sort((a, b) => a.landed - b.landed)
.map((s) => {
- counts[s.verdict] += 1;
- return { at: s.landed, verdict: s.verdict, count: counts[s.verdict], counts: { ...counts } };
+ const step = s.count ?? 1;
+ counts[s.verdict] += 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;
+ return finals;
+}
+
/**
* The verdicts a deck schedule's tally shows, or null for no tally: the
* setting is on and the cut stamps at least one claim.
@@ -320,8 +449,8 @@ export function tallyCues(stamps, verdicts = tallyVerdicts(stamps)) {
const events = [];
for (const s of steps) {
const why = `tally ${s.verdict} ${s.count}`;
- if (s.count === 1) events.push({ k: tallyKey(s.verdict), at: s.at, dur: 0.2, to: { opacity: 1 }, ease: "power1.out", why });
- events.push({ k: tallyKey(s.verdict, `n${s.count - 1}`), at: s.at, dur: m.roll, to: { yPercent: -100, autoAlpha: 0 }, ease: "power2.in", why });
+ if (s.count === s.step) events.push({ k: tallyKey(s.verdict), at: s.at, dur: 0.2, to: { opacity: 1 }, ease: "power1.out", why });
+ events.push({ k: tallyKey(s.verdict, `n${s.count - s.step}`), at: s.at, dur: m.roll, to: { yPercent: -100, autoAlpha: 0 }, ease: "power2.in", why });
events.push({ k: tallyKey(s.verdict, `n${s.count}`), at: s.at, dur: m.roll, to: { yPercent: 0, autoAlpha: 1 }, ease: "power3.out", why });
events.push({ k: tallyKey(s.verdict, "flash"), at: s.at, dur: m.flashUp, to: { opacity: 1 }, ease: "none", why });
events.push({ k: tallyKey(s.verdict, "flash"), at: s.at + m.flashUp, dur: m.flashDown, to: { opacity: 0 }, ease: "power2.out", why });
diff --git a/umtool/report-to-video/factcheck.test.mjs b/umtool/report-to-video/factcheck.test.mjs
@@ -94,12 +94,12 @@ test("validateClaims: shape, never on a teaser, one verdict per claim id; the re
test("resolveFactcheck: every default, a verdict's label and colour filled on their own", () => {
assert.deepEqual(resolveFactcheck(RENDER), {
verdicts: Object.fromEntries(VERDICTS.map((v) => [v, { ...FACTCHECK_DEFAULTS.verdicts[v] }])),
- stamp: { show: true, seconds: 3, position: "top-left" },
+ stamp: { show: true, seconds: 3, position: "top-left", scale: 1, motion: "slam", opacity: 1 },
tally: { show: true, position: "right" },
});
const f = resolveFactcheck({ chrome: { ...CHROME, factcheck: { verdicts: { PARTLY: { label: "Half true" } }, stamp: { seconds: 5 } } } });
assert.deepEqual(f.verdicts.PARTLY, { label: "Half true", color: FACTCHECK_DEFAULTS.verdicts.PARTLY.color });
- assert.deepEqual(f.stamp, { show: true, seconds: 5, position: "top-left" });
+ assert.deepEqual(f.stamp, { show: true, seconds: 5, position: "top-left", scale: 1, motion: "slam", opacity: 1 });
});
test("validateChrome refuses a bad factcheck block in sentences, unknown keys included", () => {