Archilyzer · Source

archilyzer

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

commit f1d9efcf05e7f9f81ce9e340d3e8edfb18c70b91
parent e8b4412de936787d67c04f4612cf68b970de9554
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Thu, 29 Oct 2026 15:58:36 -0400

Deck subtitle in two lines: render.chrome.deck.subtitle.lines 2

The operator asked for the clip's source title and its metadata on two
lines, so a long stream title no longer squeezes the date and clock into
an ellipsis ("Working my way bac... Oct 28...").

- deck.subtitle.lines: 1 (default, unchanged) | 2. With 2, line 1 is the
  parts deck.subtitle.head names ("auto" = the source's title), a size up
  and brighter, shrunk to fit down to 70 % (fitHead) before it ellipsizes;
  line 2 is the rest of parts (channel . date . clock) in the old style.
  Untitled clips promote both lines into the title's band, as before.
- Geometry: deck.mjs subtitleBoxes; deckGeometry's band grows by the head
  line (39 px at title size 54: 190 -> 229), so the footage box, the feed
  column, render-cards' reserved footer and every layout slot move with it.
  validateChrome's footage-fit refusal names the subtitle's share and the
  largest footageScale that fits.
- Schedule segments carry subtitleLines beside subtitle (two-line decks
  only); the page's items carry the markup, so frame keys follow the lines.
  The on-screen preview patch keeps/restores them; the finale's grow copy
  draws them.
- umtool look deck.<key>.<field>=... (deck.subtitle.lines=2), the module
  panel and On-screen form fields, docs (knobs.md generated, report-video.md,
  the pipeline README).
- A manifest without the key: deck geometry, layout, slots, estimate and the
  deck page HTML/items are byte-identical (checked on the Huck final take).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

Diffstat:
Mumtool/components/projects/OnscreenSection.tsx | 4+++-
Mumtool/docs/knobs.md | 2++
Mumtool/docs/report-video.md | 14++++++++++++++
Mumtool/lib/report/knobsCli.mjs | 17++++++++++++++---
Mumtool/lib/report/knobsCli.test.mjs | 21+++++++++++++++++++++
Mumtool/lib/report/onscreen.mjs | 7+++++--
Mumtool/report-to-video/README.md | 3++-
Mumtool/report-to-video/attribution.mjs | 29++++++++++++++++++++++++++---
Mumtool/report-to-video/chrome-deck.mjs | 69+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------
Mumtool/report-to-video/chrome-finale.mjs | 14++++++++++++--
Mumtool/report-to-video/deck.mjs | 75+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------
Mumtool/report-to-video/modules/settings.mjs | 39++++++++++++++++++++++++++++++++-------
Mumtool/report-to-video/modules/subtitle.mjs | 13+++++++++++--
Mumtool/report-to-video/render-cards.mjs | 5+++--
Aumtool/report-to-video/subtitle-lines.test.mjs | 193+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
15 files changed, 458 insertions(+), 47 deletions(-)

diff --git a/umtool/components/projects/OnscreenSection.tsx b/umtool/components/projects/OnscreenSection.tsx @@ -533,7 +533,7 @@ type DeckSettings = { background: string; pip: { spacing: string; size: number; activeSize: number; color: string }; title: { size: number; maxChars: number }; - subtitle: { parts: "auto" | string[]; dateFormat: string }; + subtitle: { parts: "auto" | string[]; dateFormat: string; lines: number; head: "auto" | string[] }; qr: { show: boolean; size: number; links: string }; overCards: string; motion: { out: number; in: number; pip: number }; @@ -587,6 +587,8 @@ const GROUPS: { name: string; fields: Field[] }[] = [ fields: [ { key: "subtitle.parts", label: "parts", kind: "parts", hint: "auto, or a list of channel, title, date, clock" }, { key: "subtitle.dateFormat", label: "date", kind: "select", options: ["long", "iso"], hint: "long is Aug 14, 2026" }, + { key: "subtitle.lines", label: "lines", kind: "int", hint: "1 or 2: the source's title on a line of its own over the rest; the panel grows by that line, so the footage scale may have to come down" }, + { key: "subtitle.head", label: "first line", kind: "parts", hint: "with 2 lines: auto (the source's title), or the parts on the first line; the rest go on the second" }, ], }, { diff --git a/umtool/docs/knobs.md b/umtool/docs/knobs.md @@ -396,6 +396,8 @@ The source line under each clip's title, in the deck. |---|---|---| | `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"}'` | +| `deck.subtitle.lines` | `1` · `2`: the source's title on a line of its own (a size up; it shrinks to 70 % before it ellipsizes), the other parts under it. The deck grows by that line (39 px at the default title size) and the footage must still fit above it · default `1` | `umtool look <p> deck.subtitle.lines=2 deck.footageScale=0.78` | +| `deck.subtitle.head` | `auto` (the source's title) · a list of distinct parts for the first of two lines; the rest of `parts` take the second · default `auto` | `umtool look <p> deck.subtitle.head='["channel","title"]'` | ### QR diff --git a/umtool/docs/report-video.md b/umtool/docs/report-video.md @@ -377,6 +377,20 @@ through, with the fact-check block and the other regions (threads, flips, stats, fx), as saved. With the stamps off the preview composes no stamp region (`stampsDrawn`). +**Two-line subtitle** (`deck.subtitle.lines: 2`, the form's **lines** under subtitle; +`umtool look <p> deck.subtitle.lines=2`). The source line is drawn in two: the source's +title on a line of its own, a size up and brighter (it shrinks to 70 % before it +ellipsizes), and the other parts (channel · date · clock) under it — so a long title no +longer squeezes the date out. `deck.subtitle.head` picks the first line's parts (`auto` +is the title). The deck grows by that line (39 px at the default title size: 190 → 229) +through `deckGeometry`, so the footage box, the feed column and every slot the layout +engine hands out move with it; the footage must still fit above it, and a refusal names +the largest `footageScale` that does — set both at once +(`deck.subtitle.lines=2 deck.footageScale=0.78`). An entry's typed `onscreen.subtitle` +stays one line. The schedule carries each segment's `subtitleLines` beside `subtitle` +(only in two lines), the page's items carry the markup, so a frame key changes with the +lines. Absent or `1`: the deck, its page and its keys are what they were. + ### The video's knobs (the pipeline's side) Every knob below is a manifest key the build reads; absent, the render is diff --git a/umtool/lib/report/knobsCli.mjs b/umtool/lib/report/knobsCli.mjs @@ -74,7 +74,8 @@ export const LOOK_USAGE = [ " factcheck.tally.showAt (always|first: a cell hidden until its first count lands, then popped in;", " factcheck.tally.showAt.<VERDICT>=first for one cell) .show .position (right|left)", " deck.markers='[{\"after\":\"c01\",\"label\":\"Arrival\",\"align\":\"left\"}]' deck.markerLayout=stagger|truncate", - " deck.<key>=<json>: any of the deck's own keys (deck.finale='{…}', deck.pip='{…}', …), checked by the build's rules", + " deck.<key>=<json>: any of the deck's own keys (deck.finale='{…}', deck.pip='{…}', …), checked by the build's rules;", + " deck.<key>.<field>=… sets one field and keeps the rest (deck.subtitle.lines=2: the source's title on a line of its own)", " pair=<json> | pair.<key>=…, chapter=<json> | chapter.<key>=…, status=<json> | status.<key>=…: the story modules", " (render.chrome.pair / .chapter / .status, docs/knobs.md \"Modules\"), checked by the build's rules", " variants='[{\"name\":\"master\"},{\"name\":\"720p\",\"height\":720,\"crf\":23},{\"name\":\"fit24\",\"maxMiB\":24}]'", @@ -319,7 +320,7 @@ export async function lookCommand(args, { root = REPORTS_ROOT, out = (s) => cons const story = pairs.filter(([k]) => isStory(k)); const unknown = pairs.filter(([k]) => !k.startsWith("factcheck.") && !k.startsWith("deck.") && k !== "variants" && !LOOK_KEYS.includes(k) && !isStory(k)); if (unknown.length) throw new CliError(`not a knob here: ${unknown.map(([k]) => k).join(", ")}\n\n${LOOK_USAGE}`); - for (const [k] of deck) if (k.split(".").length !== 2 || !k.split(".")[1]) throw new CliError(`${k}: name one of the deck's own keys (deck.<key>=<json>)`); + for (const [k] of deck) if (k.split(".").some((p) => !p)) throw new CliError(`${k}: name one of the deck's own keys (deck.<key>=<json>, or deck.<key>.<field>=…)`); const done = {}; let notes = null; const write = async (fn) => { @@ -336,8 +337,18 @@ export async function lookCommand(args, { root = REPORTS_ROOT, out = (s) => cons done.factcheck = r.factcheck; } if (deck.length) { + // `deck.<key>.<field>=…` sets one field of a deck key's object + // (deck.subtitle.lines=2), keeping the rest of what it holds. + const current = deck.some(([k]) => k.split(".").length > 2) ? (await readManifest(project.dir))?.render?.chrome?.deck ?? {} : {}; const patch = {}; - for (const [k, v] of deck) patch[k.slice("deck.".length)] = v; + for (const [k, v] of deck) { + const [, top, ...rest] = k.split("."); + if (!rest.length) patch[top] = v; + else { + const next = setPath(patch[top] !== undefined ? patch[top] : current[top], rest, v); + patch[top] = Object.keys(next).length ? next : null; + } + } const r = await write((token) => updateDeckKeys(project.dir, patch, { token })); for (const k of Object.keys(patch)) done[`deck.${k}`] = r.deck[k] ?? null; } diff --git a/umtool/lib/report/knobsCli.test.mjs b/umtool/lib/report/knobsCli.test.mjs @@ -119,6 +119,27 @@ test("umtool look: the fact-check's stamp, a verdict's stamp word, markers, layo assert.ok(knobsLines(m).some((l) => /variants\s+master, 480p$/.test(l))); }); +test("umtool look deck.<key>.<field>: one field set, the rest kept; the subtitle's second line refused until the footage fits", async () => { + const dir = await project("look-nested"); + const { lines, run } = runner(lookCommand); + assert.equal(await run("look-nested", 'deck.subtitle={"parts":["channel","title","date","clock"]}'), 0, lines.join("\n")); + // 0.82 leaves the footage 4 px over a 190 px deck: one more line does not fit, and the refusal says what does. + assert.equal(await run("look-nested", "deck.subtitle.lines=2"), 1); + assert.match(lines.at(-1), /subtitle\.lines 2.*footageScale at most 0\.787/); + assert.deepEqual((await read(dir)).render.chrome.deck.subtitle, { parts: ["channel", "title", "date", "clock"] }); + assert.equal(await run("look-nested", "deck.subtitle.lines=2", "deck.footageScale=0.78"), 0, lines.join("\n")); + let deck = (await read(dir)).render.chrome.deck; + assert.deepEqual(deck.subtitle, { parts: ["channel", "title", "date", "clock"], lines: 2 }); + assert.equal(deck.footageScale, 0.78); + assert.equal(await run("look-nested", "deck.subtitle.lines=3"), 1); + assert.match(lines.at(-1), /subtitle\.lines must be 1 or 2/); + // key= clears one field; the object goes when nothing is left in it. + assert.equal(await run("look-nested", "deck.subtitle.lines=", "deck.subtitle.parts="), 0, lines.join("\n")); + deck = (await read(dir)).render.chrome.deck; + assert.equal("subtitle" in deck, false); + assert.equal(await run("look-nested", "deck.subtitle..lines=2"), 2); +}); + test("umtool variants: refuses an unbuilt cut; makes the ladder (stub encoder) and lists it with the sync report", async () => { const dir = await project("vars"); const { lines, run } = runner((args, o) => variantsCommand(args, { ...o, env: { ...process.env, E2E_UMTOOL_VARIANTS_SCRIPT: STUB } })); diff --git a/umtool/lib/report/onscreen.mjs b/umtool/lib/report/onscreen.mjs @@ -270,9 +270,12 @@ export function previewSchedule({ variantManifest, built, draft, metas, postsDra segments: claimed.map((s, i) => { const e = patchedEntries[i]; const meta = metas[i] ?? null; - const { title, subtitle } = deckText(e, meta, provenance, deck, built.multiChannel); + const { title, subtitle, subtitleLines } = deckText(e, meta, provenance, deck, built.multiChannel); const keepBuilt = e.type === "clip" && e.onscreen?.subtitle === undefined && !meta; - return { ...s, title, subtitle: keepBuilt ? s.subtitle : subtitle }; + // A two-line subtitle's lines go with the subtitle they were cut from. + const { subtitleLines: builtLines, ...seg } = s; + const lines = keepBuilt ? (deck.subtitle?.lines === 2 ? builtLines : undefined) : subtitleLines; + return { ...seg, title, subtitle: keepBuilt ? s.subtitle : subtitle, ...(lines ? { subtitleLines: lines } : {}) }; }), ...(stamps.length ? { factcheck: { stamps: roundStamps(stamps) } } : {}), ...(placed.length ? { posts: roundPosts(placed) } : {}), diff --git a/umtool/report-to-video/README.md b/umtool/report-to-video/README.md @@ -425,7 +425,8 @@ whatever a manifest omits, one level deep: "color": "accent" }, // | "verdict": a claimed clip's pip in its verdict's colour and shape (below) "markers": [ { "after": "c07", "label": "3 to 5 weeks pass", "color": "amber" } ], // flags on the pip track (below); at most 12 "title": { "size": 54, "maxChars": 48 }, // size 24–96; maxChars 10–120 (the editor's counter, not a refusal) - "subtitle": { "parts": "auto", "dateFormat": "long" }, // parts "auto" | a distinct list of channel/title/date/clock; dateFormat "long" | "iso" + "subtitle": { "parts": "auto", "dateFormat": "long", // parts "auto" | a distinct list of channel/title/date/clock; dateFormat "long" | "iso" + "lines": 1, "head": "auto" }, // lines 2: `head`'s parts (auto = the title) on a line of their own over the rest; the deck grows by it "qr": { "show": true, "size": 150, // size 80–380, and at most height − 20 "links": "site" }, // | "original": a clip's QR opens its record's own page (below) "overCards": "hide", // "hide" | "show" diff --git a/umtool/report-to-video/attribution.mjs b/umtool/report-to-video/attribution.mjs @@ -167,6 +167,13 @@ export function formatDeckDate(d, format = "long") { * @param {boolean} [multiChannel] */ export function deckSubtitle(parts, opts = {}, multiChannel = false) { + return subtitleValues(parts, opts, multiChannel) + .map(([, v]) => v) + .join(" · "); +} + +/** The subtitle's parts as `[token, text]`, in order, the empty ones dropped. */ +function subtitleValues(parts, opts, multiChannel) { const want = !opts.parts || opts.parts === "auto" ? (multiChannel ? ["channel", "title", "date"] : ["title", "date"]) : opts.parts; @@ -177,9 +184,25 @@ export function deckSubtitle(parts, opts = {}, multiChannel = false) { clock: () => (parts.at === null || parts.at === undefined ? "" : hms(parts.at)), }; return want - .map((k) => String(value[k]?.() ?? "").trim()) - .filter(Boolean) - .join(" · "); + .map((k) => [k, String(value[k]?.() ?? "").trim()]) + .filter(([, v]) => Boolean(v)); +} + +/** + * The deck's subtitle in TWO lines (`subtitle.lines: 2`): `[head, rest]`, + * each joined as `deckSubtitle` joins the one line -- the head the parts + * `opts.head` names ("auto": the source's title), the rest every other part, + * both in `parts` order. null when either line would be empty (a clip with + * no title on record, a still with no date): the one line is drawn then. + * + * @returns {[string, string] | null} + */ +export function deckSubtitleLines(parts, opts = {}, multiChannel = false) { + const head = !opts.head || opts.head === "auto" ? ["title"] : opts.head; + const values = subtitleValues(parts, opts, multiChannel); + const one = values.filter(([k]) => head.includes(k)).map(([, v]) => v).join(" · "); + const two = values.filter(([k]) => !head.includes(k)).map(([, v]) => v).join(" · "); + return one && two ? [one, two] : null; } /** diff --git a/umtool/report-to-video/chrome-deck.mjs b/umtool/report-to-video/chrome-deck.mjs @@ -458,6 +458,14 @@ export function deckHtml(schedule, render, opts = {}) { const uSubBox = Math.round(uSubSize * 1.3); const uSubY = Math.round(t.titleY + (t.subtitleY + t.subtitleBox - t.titleY - uSubBox - 14) / 2); const uRuleY = uSubY + uSubBox + 6; + // A two-line subtitle (`subtitle.lines: 2`, deckLayout's `lines`): the head + // line (the source's title) a size up and brighter over the source line. + // Untitled, the two are promoted into the title's band as the one line is, + // and centred on the same block. + const two = t.lines === 2; + const u2HeadBox = Math.round(uSubSize * 1.25); + const u2Block = u2HeadBox + t.subtitleBox; + const u2Y = two ? Math.round(t.titleY + (t.subtitleY + (t.headBox ?? 0) + t.subtitleBox - t.titleY - u2Block - 14) / 2) : 0; const plateX = qr ? qr.x - 46 : W; const ink = panel ? mix(pal.bg, pal.fg, 0.085) : pal.bg; // what the marker's ring cuts back to @@ -469,14 +477,21 @@ export function deckHtml(schedule, render, opts = {}) { const segHtml = schedule.segments .map((s, i) => { const src = qrSrcs[s.id]; + // Two lines only where the schedule gave them (deckText): an entry's own + // one-line subtitle, or a card's, stays one line in a two-line deck. + const lines = two && Array.isArray(s.subtitleLines) && s.subtitleLines.length === 2 ? s.subtitleLines : null; + const sub = lines + ? `<div class="deck-sub head">${subtitleMarkup(lines[0])}</div><div class="deck-sub meta">${subtitleMarkup(lines[1])}</div>` + : `<div class="deck-sub">${subtitleMarkup(s.subtitle)}</div>`; const html = ( - `<div class="seg${s.title ? "" : " untitled"}" data-seg="${esc(s.id)}" data-k="s${i}">` + + `<div class="seg${s.title ? "" : " untitled"}${lines ? " two" : ""}" data-seg="${esc(s.id)}" data-k="s${i}"` + + `${lines ? ` data-sub="${esc(s.subtitle)}"` : ""}>` + `<div class="tc" data-k="s${i}.tc"><div class="ti" data-k="s${i}.ti">` + `<div class="deck-title">${esc(s.title)}</div></div>` + `<div class="blade" data-k="s${i}.blade"></div></div>` + `<div class="rule" data-k="s${i}.rule"></div>` + `<div class="sc" data-k="s${i}.sc"><div class="si" data-k="s${i}.si">` + - `<div class="deck-sub">${subtitleMarkup(s.subtitle)}</div></div></div>` + + `${sub}</div></div>` + (qr ? `<div class="deck-qr${src ? "" : " empty"}" data-k="s${i}.qr">` + (src ? `<img src="${esc(src)}" width="${qr.size}" height="${qr.size}" alt="">` : "") + @@ -672,7 +687,17 @@ export function deckHtml(schedule, render, opts = {}) { .seg.untitled .deck-sub { font-size: ${uSubSize}px; line-height: ${uSubBox}px; color: ${mix(pal.muted, pal.fg, 0.55)}; } .seg.untitled .rule { top: ${uRuleY}px; } .rule { position: absolute; left: ${t.x}px; top: ${t.ruleY}px; width: ${Math.round(t.titleSize * 1.5)}px; - height: 4px; border-radius: 2px; background: ${pal.accent}; } + height: 4px; border-radius: 2px; background: ${pal.accent}; }${two ? ` + /* Two lines (subtitle.lines 2): the source's title over the rest of the + source line, both in the one wipe. The head shrinks to fit (fitHead), + to 70 % of its size, before it ellipsizes. */ + .seg.two .sc { height: ${t.headBox + t.subtitleBox}px; } + .deck-sub.head { font-size: ${t.headSize}px; line-height: ${t.headBox}px; color: ${mix(pal.muted, pal.fg, 0.6)}; } + .deck-sub.fitting .part { flex: none !important; } + .seg.untitled.two .sc { top: ${u2Y}px; height: ${u2Block}px; } + .seg.untitled.two .deck-sub.head { font-size: ${uSubSize}px; line-height: ${u2HeadBox}px; color: ${mix(pal.muted, pal.fg, 0.8)}; } + .seg.untitled.two .deck-sub.meta { font-size: ${t.subtitleSize}px; line-height: ${t.subtitleBox}px; color: ${pal.muted}; } + .seg.untitled.two .rule { top: ${u2Y + u2Block + 6}px; }` : ""} .deck-qr { position: absolute; left: ${qr?.x ?? 0}px; top: ${qr?.y ?? 0}px; width: ${qr?.size ?? 0}px; height: ${qr?.size ?? 0}px; transform-style: preserve-3d; } /* The QR's host, reading up its left side. fitHost sizes it at load so @@ -780,8 +805,26 @@ export function deckHtml(schedule, render, opts = {}) { node.style.fontSize = s + "px"; } } - const fitAll = () => document.querySelectorAll(".deck-title").forEach(fitTitle); - +${two ? ` // A two-line subtitle's head likewise, from its own size to 70 % of it, + // measured with every part at its full width (".fitting"). + function fitHead(node) { + node.style.fontSize = ""; + const base = parseFloat(getComputedStyle(node).fontSize); + const floor = Math.ceil(base * 0.7); + let s = base; + node.classList.add("fitting"); + while (s > floor && node.scrollWidth > node.clientWidth + 0.5) { + s -= 1; + node.style.fontSize = s + "px"; + } + node.classList.remove("fitting"); + } + const fitAll = () => { + document.querySelectorAll(".deck-title").forEach(fitTitle); + document.querySelectorAll(".deck-sub.head").forEach(fitHead); + }; +` : ` const fitAll = () => document.querySelectorAll(".deck-title").forEach(fitTitle); +`} // The QR's host runs up beside the code, and its INK is exactly as long // as the code is tall, whatever the host. Every length in it scales with // the font size (the tracking is in em), so one measurement in the @@ -837,10 +880,20 @@ export function deckHtml(schedule, render, opts = {}) { const node = seg.querySelector(".deck-title"); node.textContent = m.title; seg.classList.toggle("untitled", !m.title); - fitTitle(node); + fitTitle(node);${two ? ` + seg.querySelectorAll(".deck-sub.head").forEach(fitHead);` : ""} } - if (typeof m.subtitle === "string") seg.querySelector(".deck-sub").innerHTML = subMarkup(m.subtitle); - } +${two ? ` // A typed subtitle is one line; the automatic one (data-sub) puts the two back. + if (typeof m.subtitle === "string" && seg.dataset.sub !== undefined) { + const si = seg.querySelector(".si"); + if (seg._two === undefined) seg._two = si.innerHTML; + const auto = m.subtitle === seg.dataset.sub; + si.innerHTML = auto ? seg._two : '<div class="deck-sub">' + subMarkup(m.subtitle) + "</div>"; + seg.classList.toggle("two", auto); + seg.querySelectorAll(".deck-sub.head").forEach(fitHead); + } else if (typeof m.subtitle === "string") seg.querySelector(".deck-sub").innerHTML = subMarkup(m.subtitle); +` : ` if (typeof m.subtitle === "string") seg.querySelector(".deck-sub").innerHTML = subMarkup(m.subtitle); +`} } }); ready.then(() => { if (window.parent !== window) { diff --git a/umtool/report-to-video/chrome-finale.mjs b/umtool/report-to-video/chrome-finale.mjs @@ -98,7 +98,11 @@ export function finaleLayout(schedule, render) { : []; const panel = { bottom: rail.bottom + 12 }; const segs = schedule.segments.filter((s) => finSet.has(s.id)); - const captions = segs.map((s) => ({ id: s.id, start: s.start, title: s.title, subtitle: s.subtitle, qrUrl: s.qrUrl ?? null })); + const captions = segs.map((s) => ({ + id: s.id, start: s.start, title: s.title, subtitle: s.subtitle, qrUrl: s.qrUrl ?? null, + // Only in a two-line subtitle (deck.mjs deckText), so a finale without one is what it was. + ...(Array.isArray(s.subtitleLines) && lay.text.lines === 2 ? { subtitleLines: s.subtitleLines } : {}), + })); return { geo, rail: { ...rail, x0, track: { x0, x1: rail.x1, y: R.Y } }, @@ -356,7 +360,13 @@ export function finaleHtml(schedule, render, window, opts = {}) { `<div class="dt" data-k="dt">` + (c0?.title ? `<div class="dtt" style="left:${ftx.x}px; top:${ftx.titleY}px; max-width:${ftx.width}px">${esc(c0.title)}</div>` + `<div class="drule" style="left:${ftx.x}px; top:${ftx.ruleY}px"></div>` : "") + - `<div class="dts" style="left:${ftx.x}px; top:${c0?.title ? ftx.subtitleY : ftx.titleY}px; max-width:${ftx.width}px">${subtitleMarkup(c0?.subtitle ?? "")}</div></div>` + (c0?.subtitleLines + // Two lines: the head line a size up over the source line, as the deck drew them. + ? `<div class="dts dth" style="left:${ftx.x}px; top:${c0.title ? ftx.subtitleY : ftx.titleY}px; max-width:${ftx.width}px; ` + + `font-size:${ftx.headSize}px; line-height:${ftx.headBox}px; color:${mix(pal.muted, pal.fg, 0.6)}">${subtitleMarkup(c0.subtitleLines[0])}</div>` + + `<div class="dts" style="left:${ftx.x}px; top:${(c0.title ? ftx.subtitleY : ftx.titleY) + ftx.headBox}px; max-width:${ftx.width}px">${subtitleMarkup(c0.subtitleLines[1])}</div>` + : `<div class="dts" style="left:${ftx.x}px; top:${c0?.title ? ftx.subtitleY : ftx.titleY}px; max-width:${ftx.width}px">${subtitleMarkup(c0?.subtitle ?? "")}</div>`) + + `</div>` : ""; const lineL = Math.round(rail.labelSize * 1.15); diff --git a/umtool/report-to-video/deck.mjs b/umtool/report-to-video/deck.mjs @@ -18,7 +18,7 @@ import { createHash } from "node:crypto"; import { COMPOSITION_PARAMS } from "yt-dlp-transcript-common/lib/report/fxParams.mjs"; import { INTRO_SECONDS } from "yt-dlp-transcript-common/lib/report/intro.mjs"; -import { attributionParts, deckSubtitle } from "./attribution.mjs"; +import { attributionParts, deckSubtitle, deckSubtitleLines } from "./attribution.mjs"; import { claimOf, marksOf, originalUrlAt, resolveFactcheck, roundStamps, stampSchedule, stampsWithFinale, tallyOf, tallyVerdicts, validateFactcheck, } from "./factcheck.mjs"; @@ -36,6 +36,7 @@ export { DECK_DEFAULTS, MARKER_ALIGNS, MARKER_DEFAULT_COLOR, MARKER_LAYOUTS, MARKER_LIMITS, MARKER_PALETTE_KEYS, PIP_COLORS, PIP_PITCH_DEFAULT, PIP_SPACINGS, POST_AT, POST_LAYOUTS, POST_LINKS, QR_LINKS, SUBTITLE_TOKENS, }; +export { SUBTITLE_LINES } from "./modules/settings.mjs"; import { threadOf, threadSchedule, threadsOn, validateThreads } from "./threads.mjs"; import { flipSchedule, flipsOn, validateFlips } from "./flips.mjs"; import { overlayPointsOf, resolveStats, statsSchedule, statsWanted, validateStats } from "./stats.mjs"; @@ -175,9 +176,14 @@ export function validateChrome(chrome, render = {}) { } if (g.footage.height > room) { const max = Math.floor((room / g.H) * 1000) / 1000; + // A two-line subtitle's head line is part of the band: say so, and the way back. + const extra = subtitleBoxes(resolveDeck({ chrome })).extra; + const band = extra + ? `a ${g.deck.height}px deck (height ${g.deck.height - extra} + ${extra} for subtitle.lines 2)` + : `a ${g.deck.height}px deck`; errors.push( `${w}.footageScale ${resolveDeck({ chrome }).footageScale} needs ${g.footage.height}px ` + - `but a ${g.deck.height}px deck leaves ${room} (footageScale at most ${max})`, + `but ${band} leaves ${room} (footageScale at most ${max}${extra ? ", or subtitle.lines 1" : ""})`, ); } } @@ -381,7 +387,9 @@ export function deckGeometry(render) { const W = render?.width ?? 1920; const H = render?.height ?? 1080; const deck = resolveDeck(render); - const dh = deck.height; + // A two-line subtitle grows the band by its head line (subtitleBoxes): + // the footage box stands on the band's top edge wherever that is. + const dh = deck.height + subtitleBoxes(deck).extra; const fw = even(W * deck.footageScale); const fh = even((fw * H) / W); const fx = railOn(render) ? W - fw - railGap(render) : Math.floor((W - fw) / 2); @@ -475,13 +483,15 @@ export function deckLayout(render, { tally = null, schedule = null } = {}) { } // Line boxes, not font sizes: the title's box holds its descenders inside the // wipe's overflow clip, and the rule sits in the gap between the two lines. - // The subtitle scales with the title (26 px at the default 54). + // The subtitle scales with the title (26 px at the default 54); in two + // lines its head line stands over it (subtitleBoxes), and the band is that + // much taller (deckGeometry), so the block keeps the air it always had. const titleSize = d.title.size; - const subtitleSize = Math.round(Math.max(18, Math.min(34, titleSize * 0.48))); + const sb = subtitleBoxes(d); + const { subtitleSize, subtitleBox } = sb; const titleBox = Math.round(titleSize * 1.2); - const subtitleBox = Math.round(subtitleSize * 1.3); const gap = Math.round(titleSize * 0.3); - const block = titleBox + gap + subtitleBox; + const block = titleBox + gap + sb.extra + subtitleBox; const titleY = Math.round(bodyTop + Math.max(0, (bodyH - block) / 2)); return { width: W, @@ -497,6 +507,9 @@ export function deckLayout(render, { tally = null, schedule = null } = {}) { ruleY: titleY + titleBox + Math.round((gap - 4) / 2), subtitleY: titleY + titleBox + gap, subtitleBox, + // Only in two lines, so a one-line deck lays out as it always did: the + // head line's size and box, at subtitleY, the source line under it. + ...(sb.lines === 2 ? { lines: 2, headSize: sb.headSize, headBox: sb.headBox } : {}), }, qr, // Only with a tally, so a deck without claims lays out as it always did. @@ -508,6 +521,26 @@ export function deckLayout(render, { tally = null, schedule = null } = {}) { }; } +/** + * The subtitle's line boxes, px, for a resolved deck: the source line's size + * and box (scaled with the title: 26 and 34 at the default 54), and with + * `subtitle.lines: 2` the head line's over it -- a size up (31 and 39 at 54) + * -- which is `extra`, what the band grows by. One line: `extra` 0, and the + * deck is the one it always was. + * + * @returns {{ lines: 1|2, subtitleSize: number, subtitleBox: number, extra: number, + * headSize?: number, headBox?: number }} + */ +export function subtitleBoxes(d) { + const titleSize = d.title?.size ?? DECK_DEFAULTS.title.size; + const subtitleSize = Math.round(Math.max(18, Math.min(34, titleSize * 0.48))); + const subtitleBox = Math.round(subtitleSize * 1.3); + if (d.subtitle?.lines !== 2) return { lines: 1, subtitleSize, subtitleBox, extra: 0 }; + const headSize = Math.round(subtitleSize * 1.2); + const headBox = Math.round(headSize * 1.25); + return { lines: 2, subtitleSize, subtitleBox, headSize, headBox, extra: headBox }; +} + /** How far the track moves down for a goalpost's words (`deck.claims`). */ export const CLAIM_ROW = 22; @@ -802,31 +835,39 @@ export function hidesDeck(entry, deck) { return deck.overCards === "hide" && CARD_TYPES.includes(entry.type); } -/** The deck's title and subtitle for one entry. Pure: the caller resolves `meta`. */ +/** + * The deck's title and subtitle for one entry. Pure: the caller resolves `meta`. + * With `subtitle.lines: 2`, a clip's or a still's automatic subtitle comes in + * its two lines too (`subtitleLines`, deckSubtitleLines) -- never an entry's + * own `onscreen.subtitle`, which is the one line its author typed. + */ export function deckText(entry, meta, provenance, deck, multiChannel) { const o = entry.onscreen ?? {}; let title = o.title ?? ""; let subtitle = o.subtitle; + let subtitleLines = null; + const two = deck.subtitle?.lines === 2; if (subtitle === undefined) { if (entry.type === "clip") { - subtitle = deckSubtitle(attributionParts(entry, meta ?? {}, provenance), deck.subtitle, multiChannel); + const parts = attributionParts(entry, meta ?? {}, provenance); + subtitle = deckSubtitle(parts, deck.subtitle, multiChannel); + if (two) subtitleLines = deckSubtitleLines(parts, deck.subtitle, multiChannel); } else if (entry.type === "teaser") { // The deck is never up over a teaser; its words are what a table of // the cut (umtool's On-screen rows, the schedule) names it by. if (!title) title = teaserTitle(entry); subtitle = ""; } else if (entry.type === "image") { - subtitle = deckSubtitle( - { channel: "", title: String(entry.title ?? "").trim(), date: String(entry.date ?? "").trim(), at: null }, - { ...deck.subtitle, parts: ["title", "date"] }, - false, - ); + const parts = { channel: "", title: String(entry.title ?? "").trim(), date: String(entry.date ?? "").trim(), at: null }; + const opts = { ...deck.subtitle, parts: ["title", "date"] }; + subtitle = deckSubtitle(parts, opts, false); + if (two) subtitleLines = deckSubtitleLines(parts, { ...opts, head: ["title"] }, false); } else { if (!title) title = entry.heading ?? ""; subtitle = entry.sub ?? ""; } } - return { title, subtitle }; + return subtitleLines ? { title, subtitle, subtitleLines } : { title, subtitle }; } /** @@ -977,7 +1018,7 @@ export function deckSchedule({ multiChannel, ...(feed ? { layout: "feed" } : {}), segments: entries.map((e, i) => { - const { title, subtitle } = deckText(e, metas[i] ?? null, provenance, deck, multiChannel); + const { title, subtitle, subtitleLines } = deckText(e, metas[i] ?? null, provenance, deck, multiChannel); return { id: e.id, type: e.type, @@ -988,6 +1029,8 @@ export function deckSchedule({ ...(holds.get(e.id) ? { hold: round(holds.get(e.id)) } : {}), title, subtitle, + // Only in a two-line subtitle (`subtitle.lines: 2`): `subtitle` is still the whole line. + ...(subtitleLines ? { subtitleLines } : {}), qrUrl: deck.qr.show ? deckQrUrl(e, provenance, { links: deck.qr.links, meta: metas[i] ?? null }) : null, hideDeck: hidesDeck(e, deck), // Only on a teaser that dips, so a cut without one writes the schedule it always did. diff --git a/umtool/report-to-video/modules/settings.mjs b/umtool/report-to-video/modules/settings.mjs @@ -34,7 +34,11 @@ export const DECK_DEFAULTS = Object.freeze({ // 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" + // dateFormat | "iso". `lines` 2 draws the source line in two: `head` (the + // parts on line 1, "auto" = the source's title) a size up and brighter, the + // rest of `parts` under it; the band grows by the head line (deck.mjs + // subtitleBoxes). 1 is the one line it always was. + subtitle: Object.freeze({ parts: "auto", dateFormat: "long", lines: 1, head: "auto" }), // `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. @@ -107,6 +111,12 @@ 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 many lines the subtitle takes (`subtitle.lines`). */ +export const SUBTITLE_LINES = Object.freeze([1, 2]); + +/** The parts on a two-line subtitle's first line when `subtitle.head` is "auto". */ +export const SUBTITLE_HEAD_AUTO = Object.freeze(["title"]); + /** 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"]); @@ -247,21 +257,36 @@ export function validateRailSettings(d, { where: w }) { return errors; } -/** The subtitle: its parts and its date's format. */ +/** The subtitle: its parts, its date's format, its lines and what heads the second. */ export function validateSubtitleSettings(d, { where: w }) { const errors = []; - sub(d, "subtitle", ["parts", "dateFormat"], w, errors, (s) => { + const tokens = (v) => Array.isArray(v) && v.length > 0 && v.every((p) => SUBTITLE_TOKENS.includes(p)) && new Set(v).size === v.length; + sub(d, "subtitle", ["parts", "dateFormat", "lines", "head"], 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) { + if (!tokens(s.parts)) { 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"`); } + if (s.lines !== undefined && !SUBTITLE_LINES.includes(s.lines)) { + errors.push(`${w}.subtitle.lines must be 1 or 2`); + } + const headOk = s.head === undefined || s.head === "auto" || tokens(s.head); + if (!headOk) { + errors.push(`${w}.subtitle.head must be "auto" or a list of distinct ${SUBTITLE_TOKENS.join("/")} (the parts on the first of two lines)`); + } + // Two lines over an explicit parts list: each line has to show something. + if (s.lines === 2 && headOk && tokens(s.parts)) { + const head = s.head === undefined || s.head === "auto" ? SUBTITLE_HEAD_AUTO : s.head; + const missing = head.filter((p) => !s.parts.includes(p)); + if (missing.length) { + errors.push(`${w}.subtitle.head${s.head === undefined || s.head === "auto" ? " (auto)" : ""} names ${missing.join(", ")}, which subtitle.parts leaves out`); + } else if (s.parts.every((p) => head.includes(p))) { + errors.push(`${w}.subtitle.head takes every part of subtitle.parts, leaving the second line empty`); + } + } }); return errors; } diff --git a/umtool/report-to-video/modules/subtitle.mjs b/umtool/report-to-video/modules/subtitle.mjs @@ -1,8 +1,11 @@ // 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"; +// attribution.mjs `deckSubtitle`). `lines: 2` draws it in two: the source's +// title (`head`) a size up over the rest, the band one line taller (deck.mjs +// `subtitleBoxes`, which deckGeometry -- the layout's `footer` slot -- reads), +// so every module placed by the slots moves with it. +import { DECK_DEFAULTS, SUBTITLE_LINES, SUBTITLE_TOKENS, settingsOf } from "./settings.mjs"; import { defineModule } from "./contract.mjs"; export default defineModule({ @@ -22,6 +25,10 @@ export default defineModule({ { 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" }, + { key: "lines", type: "number", min: SUBTITLE_LINES[0], max: SUBTITLE_LINES[SUBTITLE_LINES.length - 1], step: 1, label: "Lines", default: 1, + help: "2: the source's title on a line of its own (it shrinks to fit before it ellipsizes), the channel, date and clock under it; the deck grows by that line" }, + { key: "head", type: "list", options: ["auto", ...SUBTITLE_TOKENS], label: "First line", default: "auto", + when: { lines: 2 }, help: "\"auto\" (the source's title), or the parts on the first line; the rest of the parts go on the second" }, ], docs: { heading: "Subtitle", @@ -29,6 +36,8 @@ export default defineModule({ 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\"}'`"], + ["`deck.subtitle.lines`", "`1` · `2`: the source's title on a line of its own (a size up; it shrinks to 70 % before it ellipsizes), the other parts under it. The deck grows by that line (39 px at the default title size) and the footage must still fit above it · default `1`", "`umtool look <p> deck.subtitle.lines=2 deck.footageScale=0.78`"], + ["`deck.subtitle.head`", "`auto` (the source's title) · a list of distinct parts for the first of two lines; the rest of `parts` take the second · default `auto`", "`umtool look <p> deck.subtitle.head='[\"channel\",\"title\"]'`"], ], }, }); diff --git a/umtool/report-to-video/render-cards.mjs b/umtool/report-to-video/render-cards.mjs @@ -37,7 +37,7 @@ import { dateKey, ledgerTotals, rosterLine } from "./ledger-totals.mjs"; import { brandFaces, brandManifest, brandSvgFace, childOpts } from "./brand.mjs"; import { BRAND_CARD_STYLES, renderBrandCard } from "./brand-cards.mjs"; import { FIRA_SANS, textWidth } from "./svg-faces.mjs"; -import { deckOn, resolveDeck } from "./deck.mjs"; +import { deckOn, resolveDeck, subtitleBoxes } from "./deck.mjs"; import { ensureWriteDir } from "../lib/report/storage.mjs"; const execFileP = promisify(execFile); @@ -539,7 +539,8 @@ export function railGeometry(render, nClaims) { export function reservedFooterHeight(render) { if (deckOn(render)) { const deck = resolveDeck(render); - return deck.overCards === "show" ? deck.height : 0; + // The band as drawn: a two-line subtitle's head line included (deck.mjs subtitleBoxes). + return deck.overCards === "show" ? deck.height + subtitleBoxes(deck).extra : 0; } return render.chromeEngine === "hyperframes" ? (render.chart?.height ?? 200) diff --git a/umtool/report-to-video/subtitle-lines.test.mjs b/umtool/report-to-video/subtitle-lines.test.mjs @@ -0,0 +1,193 @@ +// The deck's two-line subtitle (`render.chrome.deck.subtitle.lines: 2`): the +// source's title on a line of its own over the rest of the source line, the +// band one line taller through the layout engine, and a deck that does not +// set it laid out, scheduled and drawn exactly as before. +// +// Run with: pnpm test:scripts +import assert from "node:assert/strict"; +import test from "node:test"; + +import { deckSubtitle, deckSubtitleLines } from "./attribution.mjs"; +import { deckHtml } from "./chrome-deck.mjs"; +import { + deckGeometry, deckLayout, deckText, estimateSchedule, feedGeometry, resolveDeck, subtitleBoxes, validateChrome, +} from "./deck.mjs"; +import { slotRect, slotRects } from "./modules/layout.mjs"; +import { reservedFooterHeight } from "./render-cards.mjs"; + +const PALETTE = { bg: "#12101a", fg: "#f4f1ea", muted: "#9a93ad", accent: "#a97bff", amber: "#ffc860" }; +const renderOf = (deck = {}, { width = 1920, height = 1080 } = {}) => ({ + width, height, fps: 30, transition: 0.5, palette: PALETTE, + chrome: { engine: "hyperframes", layout: "deck", deck }, +}); +const TWO = { subtitle: { lines: 2, parts: ["channel", "title", "date", "clock"] } }; + +const LONG = 'Working my way back to "normal" -- a very long stream title that will never fit on one line of the deck at all'; +const PARTS = { channel: "EmberParadox", title: LONG, date: "2026-10-28", at: 3725 }; + +test("the default is one line, and a deck without the key lays out as it always did", () => { + assert.equal(resolveDeck(renderOf()).subtitle.lines, 1); + const g = deckGeometry(renderOf()); + // The documented geometry: 1574×886 at (173, 2) over a 190 px deck. + assert.deepEqual(g.footage, { x: 173, y: 2, width: 1574, height: 886 }); + assert.deepEqual(g.deck, { x: 0, y: 890, width: 1920, height: 190 }); + assert.equal(subtitleBoxes(resolveDeck(renderOf())).extra, 0); + const t = deckLayout(renderOf()).text; + assert.deepEqual(t, { x: 48, width: 1626, titleSize: 54, subtitleSize: 26, titleY: 49, titleBox: 65, ruleY: 120, subtitleY: 130, subtitleBox: 34 }); + // `lines: 1` written out is the same deck as no key. + assert.deepEqual(deckGeometry(renderOf({ subtitle: { lines: 1 } })), g); + assert.deepEqual(deckLayout(renderOf({ subtitle: { lines: 1 } })), deckLayout(renderOf())); +}); + +test("two lines at 1920×1080: the band grows by the head line and every slot moves with it", () => { + const render = renderOf({ ...TWO, footageScale: 0.78 }); + const one = renderOf({ footageScale: 0.78 }); + const sb = subtitleBoxes(resolveDeck(render)); + assert.deepEqual(sb, { lines: 2, subtitleSize: 26, subtitleBox: 34, headSize: 31, headBox: 39, extra: 39 }); + const g = deckGeometry(render); + assert.deepEqual(g.deck, { x: 0, y: 1080 - 229, width: 1920, height: 229 }); + // The footage keeps its size and stands on the band's top edge, centred in what is left. + assert.equal(g.footage.width, deckGeometry(one).footage.width); + assert.ok(g.footage.y + g.footage.height <= g.deck.y, "the footage clears the band"); + assert.ok(g.footage.y >= 0); + // The layout engine's slots are the geometry's: the footer is the band, the rest stand above it. + assert.deepEqual(slotRect("footer", render), g.deck); + const slots = slotRects(render); + for (const s of ["footage", "stamp", "panel", "side", "popup"]) { + assert.ok(slots[s].y + slots[s].height <= g.deck.y, `${s} clears the band`); + } + assert.equal(feedGeometry(render).column.height, g.deck.y, "the feed's column stands on the band"); + assert.ok(slotRects(render, { feed: true }).footage.y + slotRects(render, { feed: true }).footage.height <= g.deck.y); + // Inside the band: the title where it was, the two lines under it, the QR and the block in the body. + const lay = deckLayout(render); + const t = lay.text; + assert.equal(t.titleY, deckLayout(one).text.titleY, "the block keeps the air it had"); + assert.equal(t.lines, 2); + assert.equal(t.headSize, 31); + assert.equal(t.headBox, 39); + assert.ok(t.subtitleY + t.headBox + t.subtitleBox <= lay.height - 8, "both lines inside the band"); + assert.ok(lay.qr.y + lay.qr.size <= lay.height, "the QR inside the band"); + // A card leaving the deck free at the foot leaves the band as drawn. + assert.equal(reservedFooterHeight(renderOf({ ...TWO, footageScale: 0.78, overCards: "show" })), 229); + assert.equal(reservedFooterHeight(renderOf({ overCards: "show" })), 190); +}); + +test("two lines at 1280×720: the same band, and the footage still above it", () => { + const render = renderOf({ ...TWO, footageScale: 0.6 }, { width: 1280, height: 720 }); + assert.deepEqual(validateChrome(render.chrome, render), []); + const g = deckGeometry(render); + assert.deepEqual(g.deck, { x: 0, y: 720 - 229, width: 1280, height: 229 }); + assert.ok(g.footage.y + g.footage.height <= g.deck.y); + const lay = deckLayout(render); + assert.ok(lay.text.subtitleY + lay.text.headBox + lay.text.subtitleBox <= lay.height - 8); + assert.ok(lay.text.x + lay.text.width <= lay.qr.x, "the text column stops short of the QR"); +}); + +test("validation: the band that does not leave the footage room is refused in words that say how to fix it", () => { + const render = renderOf(TWO); + const errors = validateChrome(render.chrome, render); + assert.equal(errors.length, 1); + assert.match(errors[0], /footageScale 0\.82 needs 886px but a 229px deck \(height 190 \+ 39 for subtitle\.lines 2\) leaves 851 \(footageScale at most 0\.787, or subtitle\.lines 1\)/); + assert.deepEqual(validateChrome(renderOf({ ...TWO, footageScale: 0.787 }).chrome, renderOf()), []); + const bad = (subtitle) => validateChrome({ engine: "hyperframes", layout: "deck", deck: { footageScale: 0.7, subtitle } }, {}); + assert.match(bad({ lines: 3 })[0], /subtitle\.lines must be 1 or 2/); + assert.match(bad({ lines: "2" })[0], /subtitle\.lines must be 1 or 2/); + assert.match(bad({ head: ["title", "title"] })[0], /subtitle\.head must be "auto" or a list/); + assert.match(bad({ lines: 2, parts: ["title"] })[0], /leaving the second line empty/); + assert.match(bad({ lines: 2, parts: ["date", "clock"] })[0], /head \(auto\) names title, which subtitle\.parts leaves out/); + assert.match(bad({ lines: 2, parts: ["title", "date"], head: ["channel"] })[0], /names channel/); + assert.deepEqual(bad({ lines: 2, parts: ["channel", "title", "date"], head: ["channel", "title"] }), []); + assert.deepEqual(bad({ lines: 2 }), [], "auto parts: the title heads, the date follows"); + assert.match(bad({ nope: 1 })[0], /subtitle\.nope is not a deck setting/); +}); + +test("deckSubtitleLines: the head's parts over the rest, each joined as the one line is", () => { + const opts = { parts: ["channel", "title", "date", "clock"] }; + assert.deepEqual(deckSubtitleLines(PARTS, opts), [LONG, "EmberParadox · Oct 28, 2026 · 1:02:05"]); + // The one line is unchanged, and is the two joined in parts order. + assert.equal(deckSubtitle(PARTS, opts), `EmberParadox · ${LONG} · Oct 28, 2026 · 1:02:05`); + assert.deepEqual(deckSubtitleLines(PARTS, { ...opts, head: ["channel", "title"] }), [`EmberParadox · ${LONG}`, "Oct 28, 2026 · 1:02:05"]); + assert.deepEqual(deckSubtitleLines(PARTS, { ...opts, dateFormat: "iso" })[1], "EmberParadox · 2026-10-28 · 1:02:05"); + // auto: title and date, the channel only across channels. + assert.deepEqual(deckSubtitleLines(PARTS, {}), [LONG, "Oct 28, 2026"]); + assert.deepEqual(deckSubtitleLines(PARTS, {}, true), [LONG, "EmberParadox · Oct 28, 2026"]); + // A line with nothing on it: no two lines (the one line is drawn). + assert.equal(deckSubtitleLines({ ...PARTS, title: "" }, opts), null); + assert.equal(deckSubtitleLines(PARTS, { parts: ["title"] }), null); +}); + +test("deckText: a clip's and a still's automatic subtitle in two lines; a typed one, or a one-line deck, never", () => { + const deck2 = resolveDeck(renderOf(TWO)); + const deck1 = resolveDeck(renderOf({ subtitle: { parts: TWO.subtitle.parts } })); + const clip = { type: "clip", id: "x02", video: "v", start: 3725, end: 3740, channel: "ember", title: LONG, date: "2026-10-28" }; + const meta = { title: LONG, uploadDate: "20261028", channel: "EmberParadox" }; + const prov = { channelSlug: "ember", siteOrigin: "https://example.test" }; + const two = deckText(clip, meta, prov, deck2, false); + assert.equal(two.subtitleLines.length, 2); + assert.equal(two.subtitleLines[0], LONG); + assert.match(two.subtitleLines[1], /Oct 28, 2026 · 1:02:05$/); + const one = deckText(clip, meta, prov, deck1, false); + assert.equal(one.subtitle, two.subtitle, "the whole line is the same either way"); + assert.equal("subtitleLines" in one, false); + assert.equal("subtitleLines" in deckText({ ...clip, onscreen: { subtitle: "typed" } }, meta, prov, deck2, false), false); + const still = deckText({ type: "image", id: "i1", title: "A still", date: "2026-10-01" }, null, prov, deck2, false); + assert.deepEqual(still.subtitleLines, ["A still", "Oct 1, 2026"]); + assert.equal("subtitleLines" in deckText({ type: "card", id: "k", heading: "H", sub: "s" }, null, prov, deck2, false), false); +}); + +test("the schedule carries the lines only in a two-line deck", () => { + const manifest = (deck) => ({ + schemaVersion: 1, provenance: { channelSlug: "ember", siteOrigin: "https://example.test" }, + render: renderOf(deck), + timeline: [ + { type: "clip", id: "x02", video: "v", start: 10, end: 20, title: LONG, date: "2026-10-28" }, + { type: "clip", id: "c01", video: "w", start: 0, end: 8, title: "Short", date: "2026-10-27", onscreen: { title: "A title" } }, + ], + }); + const one = estimateSchedule(manifest({})); + assert.ok(one.segments.every((s) => !("subtitleLines" in s))); + const two = estimateSchedule(manifest({ ...TWO, footageScale: 0.78 })); + assert.deepEqual(two.segments.map((s) => s.subtitleLines?.[0]), [LONG, "Short"]); + assert.deepEqual(two.segments.map((s) => s.subtitle), estimateSchedule(manifest({ subtitle: { parts: TWO.subtitle.parts } })).segments.map((s) => s.subtitle)); +}); + +/** A cut of a long-titled untitled clip, a short-titled titled one, and a typed subtitle. */ +function schedule(lines) { + const seg = (id, start, extra) => ({ id, type: "clip", start, duration: 10, end: start + 10, title: "", qrUrl: null, hideDeck: false, ...extra }); + const L = (a, b) => (lines ? { subtitleLines: [a, b] } : {}); + return { + version: 1, kind: "deck", estimated: true, fps: 30, transition: 0.5, total: 29, multiChannel: false, + segments: [ + seg("x02", 0, { subtitle: `EmberParadox · ${LONG} · Oct 28, 2026 · 1:02:05`, ...L(LONG, "EmberParadox · Oct 28, 2026 · 1:02:05") }), + seg("c01", 9.5, { title: "A title", subtitle: "EmberParadox · Short · Oct 27, 2026", ...L("Short", "EmberParadox · Oct 27, 2026") }), + seg("c02", 19, { title: "Typed", subtitle: "a typed line" }), + ], + }; +} + +test("the page: two lines where the schedule gave them, a fitted head, and a one-line deck's page untouched", () => { + const render = renderOf({ ...TWO, footageScale: 0.78 }); + const items = []; + const html = deckHtml(schedule(true), render, { items }); + // The long title is in the markup whole: the page fits it, never the text. + assert.ok(html.includes(`<div class="deck-sub head"><span class="part">${LONG.replace(/"/g, "&quot;")}</span></div>`)); + assert.match(html, /class="seg untitled two" data-seg="x02"/); + assert.match(html, /class="seg two" data-seg="c01"/); + assert.match(html, /class="seg" data-seg="c02"/, "a typed subtitle stays one line"); + assert.match(html, /<div class="deck-sub meta"><span class="part">EmberParadox<\/span><span class="sep">·<\/span><span class="part">Oct 28, 2026<\/span>/); + assert.match(html, /\.seg\.two \.sc \{ height: 73px; \}/); + assert.match(html, /\.deck-sub\.head \{ font-size: 31px; line-height: 39px;/); + assert.match(html, /function fitHead\(node\)/); + assert.match(html, /Math\.ceil\(base \* 0\.7\)/, "the head shrinks to 70 % before it ellipsizes"); + // The items carry the line layout: a frame that shows a clip's text keys on its lines. + const one = []; + deckHtml(schedule(false), renderOf({ footageScale: 0.78 }), { items: one }); + const item = (list, k) => list.find((i) => i.key === k).html; + assert.notEqual(item(items, "s0"), item(one, "s0")); + assert.match(item(items, "s0"), /deck-sub head/); + assert.equal(item(items, "s2"), item(one, "s2"), "a one-line segment's item is the one-line item"); + // A one-line deck's page has none of it -- and ignores a stray subtitleLines. + const plain = deckHtml(schedule(false), renderOf()); + assert.equal(deckHtml(schedule(true), renderOf()), plain); + for (const s of ["fitHead", "deck-sub head", "seg two", "untitled two", ".two", "data-sub=", ".fitting"]) assert.equal(plain.includes(s), false, s); +});