Archilyzer · Source

archilyzer

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

commit fedddcce4494e444fdcabdcc8fa78bb0c1f94745
parent 6b9c06c191898ca8bd239a28815fd8f8dc236b12
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Fri,  6 Nov 2026 11:50:37 -0500

umtool: the band keeps its date and clock -- the automatic source line set by token

Variant A's band at 11:13 read "TheQuartering (Rumble) · Huge Win For Cornell
7, Mamdani … · Oct … · 1:08:48": quartering-diet's parts are [channel, title,
date, clock], so the date is a MIDDLE part, and the one-line rule pinned parts
by position (the first and the last whole, every middle part shrinking) -- the
date shrank with the title. The default parts end on the date, which is why
most videos never showed it; Ember's two-line meta line [channel, date, clock]
had the same latent bug.
- attribution.mjs deckSubtitleParts / deckSubtitleLinesParts: the line's parts
  as [token, text] (deckSubtitle and deckSubtitleLines join them);
- deck.mjs deckText returns `subtitleParts` (and `subtitleLinesParts` in two
  lines) for a clip's and a still's AUTOMATIC line, carried on the schedule's
  segments as `subtitleLines` is; a typed `onscreen.subtitle`, a card and a
  post item carry none (lib/report/onscreen.mjs keeps them with a built line);
- chrome-deck.mjs subtitleMarkup(text, tokens) writes `data-p="date"` etc. when
  the parts ARE the line (subtitleTokens; stale parts fall back), and
  subtitlePartsCss sets them by token: the date and the clock never shrink, the
  title gives way first (an ellipsis at its end), a channel ellipsizes only
  past 40 % of the line; a typed line keeps the positional rule. The head and
  meta lines of `lines: 2` too, and the live preview's deck:text puts the
  tokened markup back (data-sub) when a typed subtitle is cleared;
- chrome-finale.mjs: the deck copy's `.dts` line by the same rule; the clip
  card's wrapped line puts the title last by token (titleLastParts; 5e205b6d's
  wrap stays, a line of two parts as it was).
No geometry changes; every deck video picks it up on its next render (the deck
page's items change, so its frames re-key). The two hash pins (deck-claims,
instruments) re-pinned: the schedules equal but for `subtitleParts`, the pages
differing only in the tokens, data-sub, the token CSS and the restore. Tests:
subtitle-lines (parts, schedule, markup, CSS, finale order); onscreen.spec's
DOM measure (a 4-part line, a 120-character title: the date's and the clock's
spans end inside .sc, unclipped). The subtitle module's docs say it, and that
`lines: 2` needs footageScale at most about 0.78 with full-width footage.

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

Diffstat:
Mumtool/docs/knobs.md | 4++--
Mumtool/e2e/onscreen.spec.ts | 48+++++++++++++++++++++++++++++++++++++++++++++++-
Mumtool/lib/report/onscreen.mjs | 18+++++++++++++-----
Mumtool/report-to-video/attribution.mjs | 31++++++++++++++++++++++++++++---
Mumtool/report-to-video/chrome-deck.mjs | 78++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------
Mumtool/report-to-video/chrome-finale.mjs | 37+++++++++++++++++++++++++++++--------
Mumtool/report-to-video/deck-claims.test.mjs | 14++++++++++----
Mumtool/report-to-video/deck.mjs | 23++++++++++++++++++++---
Mumtool/report-to-video/deck.test.mjs | 7+++++--
Mumtool/report-to-video/instruments.test.mjs | 9+++++++--
Mumtool/report-to-video/modules/subtitle.mjs | 4++--
Mumtool/report-to-video/subtitle-lines.test.mjs | 75+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
12 files changed, 296 insertions(+), 52 deletions(-)

diff --git a/umtool/docs/knobs.md b/umtool/docs/knobs.md @@ -1560,13 +1560,13 @@ The panel at the foot of the frame and each clip's title (`render.chrome.deck`); ### Subtitle -The source line under each clip's title, in the deck. +The source line under each clip's title, in the deck. The automatic line is set by what each part IS, wherever it stands: when it runs long the title gives way first (an ellipsis at its end), a channel ellipsizes only past 40 % of the line, and the date and the clock always show whole -- so `[channel, title, date, clock]` never reads "… · Oct … · 1:08:48" (the schedule's `subtitleParts`, chrome-deck.mjs subtitleMarkup; the finale's copy of the line too). An entry's typed `onscreen.subtitle` has no parts to name: its middle parts give way, its first and last show whole. | Knob | Range · default | From a terminal | |---|---|---| | `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.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: with full-width footage that needs `footageScale` at most about 0.78 · 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/e2e/onscreen.spec.ts b/umtool/e2e/onscreen.spec.ts @@ -1,6 +1,6 @@ import { test, expect, type APIRequestContext, type Locator, type Page } from "@playwright/test"; import { execFileSync } from "node:child_process"; -import { existsSync, readFileSync, statSync } from "node:fs"; +import { existsSync, readFileSync, statSync, writeFileSync } from "node:fs"; import path from "node:path"; import { fileURLToPath } from "node:url"; import * as urls from "./urls"; @@ -319,6 +319,52 @@ test("the preview is the composition: it reports ready, and typing reaches it be await expect(page.locator('li[data-entry="t01"][data-kind="teaser"]')).toContainText(teaserTitle); }); +test("a long source line keeps its date and clock whole: the title gives way, measured in the page", async ({ + page, + request, +}) => { + // Variant A's band ("TheQuartering (Rumble) · Huge Win For Cornell 7, Mamdani … · Oct … · 1:08:48"): with + // parts [channel, title, date, clock] the date is a MIDDLE part, and the positional rule shrank it with the + // title. By token it never shrinks: the date's and the clock's spans end inside the line's box, unclipped. + const file = path.join(DIR, "video.manifest.json"); + const before = readFileSync(file, "utf8"); + try { + const m = JSON.parse(before) as Manifest; + const c01 = m.timeline.find((e) => e.id === "c01") as Entry & Record<string, unknown>; + // A 120-character title. + c01.title = "Huge Win For Cornell 7, Mamdani Responds To Everything At Once And The Whole Internet Loses Its Mind".padEnd(120, " x"); + c01.channelTitle = "TheQuartering (Rumble)"; + c01.date = "2026-10-23"; + delete c01.onscreen; + writeFileSync(file, `${JSON.stringify(m, null, 2)}\n`); + await putChrome(request, PROJECT, { ...DECK_ON, deck: { subtitle: { parts: ["channel", "title", "date", "clock"] } } }); + await openSection(page); + await expect(page.getByTestId("onscreen-preview")).toHaveAttribute("data-deck-ready", "1", { timeout: 30_000 }); + const frame = page.frameLocator('[data-testid="onscreen-preview-iframe"]'); + const seg = frame.locator('[data-seg="c01"]'); + await expect(seg.locator('.deck-sub [data-p="date"]')).toHaveText("Oct 23, 2026"); + await expect(seg.locator('.deck-sub [data-p="clock"]')).toHaveText("0:03"); + const box = await seg.evaluate((el) => { + const sc = el.querySelector(".sc")!.getBoundingClientRect(); + const span = (p: string) => { + const n = el.querySelector(`.deck-sub [data-p="${p}"]`) as HTMLElement; + const r = n.getBoundingClientRect(); + return { right: r.right, width: r.width, scroll: n.scrollWidth, client: n.clientWidth }; + }; + const title = el.querySelector('.deck-sub [data-p="title"]') as HTMLElement; + return { sc: { left: sc.left, right: sc.right }, date: span("date"), clock: span("clock"), titleClipped: title.scrollWidth > title.clientWidth }; + }); + for (const p of ["date", "clock"] as const) { + expect(box[p].width, `${p} has its width`).toBeGreaterThan(0); + expect(box[p].right, `${p} ends inside the line`).toBeLessThanOrEqual(box.sc.right + 0.5); + expect(box[p].scroll, `${p} unclipped`).toBe(box[p].client); + } + expect(box.titleClipped, "the title is what gives way").toBe(true); + } finally { + writeFileSync(file, before); + } +}); + test("a true still is the render browser's PNG of the deck region", async ({ page, request }) => { test.skip(!existsSync(CHROME), `the true still needs chromium at ${CHROME} (set CHROME)`); await putChrome(request, PROJECT, DECK_ON); diff --git a/umtool/lib/report/onscreen.mjs b/umtool/lib/report/onscreen.mjs @@ -270,12 +270,20 @@ 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, subtitleLines } = deckText(e, meta, provenance, deck, built.multiChannel); + const { title, subtitle, subtitleParts, subtitleLines, subtitleLinesParts } = deckText(e, meta, provenance, deck, built.multiChannel); const keepBuilt = e.type === "clip" && e.onscreen?.subtitle === undefined && !meta; - // 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 } : {}) }; + // A two-line subtitle's lines, and the line's parts by token, go with the subtitle they were cut from. + const { subtitleLines: builtLines, subtitleParts: builtParts, subtitleLinesParts: builtLinesParts, ...seg } = s; + const two = deck.subtitle?.lines === 2; + const lines = keepBuilt ? (two ? builtLines : undefined) : subtitleLines; + const parts = keepBuilt ? builtParts : subtitleParts; + const linesParts = keepBuilt ? (two ? builtLinesParts : undefined) : subtitleLinesParts; + return { + ...seg, title, subtitle: keepBuilt ? s.subtitle : subtitle, + ...(parts ? { subtitleParts: parts } : {}), + ...(lines ? { subtitleLines: lines } : {}), + ...(linesParts ? { subtitleLinesParts: linesParts } : {}), + }; }), ...(stamps.length ? { factcheck: { stamps: roundStamps(stamps) } } : {}), ...(placed.length ? { posts: roundPosts(placed) } : {}), diff --git a/umtool/report-to-video/attribution.mjs b/umtool/report-to-video/attribution.mjs @@ -172,6 +172,19 @@ export function deckSubtitle(parts, opts = {}, multiChannel = false) { .join(" · "); } +/** + * The deck's automatic subtitle as its parts, `[token, text]` in order (the + * empty ones dropped): what `deckSubtitle` joins, kept apart so the page can + * set each part by WHAT it is -- the date and the clock never give way, the + * title gives way first -- rather than by where it stands in the line + * (chrome-deck.mjs subtitleMarkup). Tokens: channel, title, date, clock. + * + * @returns {Array<[string, string]>} + */ +export function deckSubtitleParts(parts, opts = {}, multiChannel = false) { + return subtitleValues(parts, opts, multiChannel); +} + /** 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" @@ -198,11 +211,23 @@ function subtitleValues(parts, opts, multiChannel) { * @returns {[string, string] | null} */ export function deckSubtitleLines(parts, opts = {}, multiChannel = false) { + const lines = deckSubtitleLinesParts(parts, opts, multiChannel); + return lines ? [lines[0].map(([, v]) => v).join(" · "), lines[1].map(([, v]) => v).join(" · ")] : null; +} + +/** + * `deckSubtitleLines` as parts: `[headParts, restParts]`, each `[token, text]` + * pairs in `parts` order (deckSubtitleParts), or null when either line would + * be empty. + * + * @returns {[Array<[string, string]>, Array<[string, string]>] | null} + */ +export function deckSubtitleLinesParts(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; + const one = values.filter(([k]) => head.includes(k)); + const two = values.filter(([k]) => !head.includes(k)); + return one.length && two.length ? [one, two] : null; } /** diff --git a/umtool/report-to-video/chrome-deck.mjs b/umtool/report-to-video/chrome-deck.mjs @@ -645,8 +645,31 @@ export function shapeCss(shape, size, color) { // The page. // --------------------------------------------------------------------------- -/** The subtitle's markup: its " · " separators become accent dots. */ -export function subtitleMarkup(text) { +/** + * The automatic line's parts by token (deck.mjs deckText's `subtitleParts`), + * when they ARE `text` -- joined, the same line -- else null: a typed line, or + * parts that went stale against their line, are drawn by position. + * + * @param {string} text + * @param {unknown} tokens `[token, text]` pairs + * @returns {Array<[string, string]> | null} + */ +export function subtitleTokens(text, tokens) { + if (!Array.isArray(tokens) || !tokens.length) return null; + if (!tokens.every((t) => Array.isArray(t) && typeof t[0] === "string" && typeof t[1] === "string")) return null; + return tokens.map((t) => t[1]).join(" · ") === String(text ?? "") ? /** @type {Array<[string, string]>} */ (tokens) : null; +} + +/** + * The subtitle's markup: its " · " separators become accent dots. With its + * parts by token (`tokens`, subtitleTokens) each part says what it is + * (`data-p="date"`), and the page's CSS keeps the date and the clock whole and + * lets the title give way, wherever they stand in the line; without, the + * positional rule (the first and last whole) of a typed line. + */ +export function subtitleMarkup(text, tokens = null) { + const tok = subtitleTokens(text, tokens); + if (tok) return tok.map(([k, v]) => `<span class="part" data-p="${esc(k)}">${esc(v)}</span>`).join('<span class="sep">·</span>'); return String(text ?? "") .split(" · ") .map((p) => `<span class="part">${esc(p)}</span>`) @@ -654,6 +677,22 @@ export function subtitleMarkup(text) { } /** + * The CSS that sets a source line's parts (`sel` the line's selector): by + * TOKEN for the automatic line -- the date and the clock never shrink, the + * title gives way first (ellipsis at its end), a channel ellipsizes only past + * 40 % of the line -- and by POSITION for a typed one (its middle parts give + * way, the first and the last show whole; a line of one or two parts shrinks + * its first). + */ +export function subtitlePartsCss(sel) { + return `${sel} .part, ${sel} .sep { flex: none; } + ${sel} .part:not([data-p]):not(:first-child):not(:last-child), ${sel} .part:not([data-p]):first-child:nth-last-child(-n+3) { + flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; } + ${sel} .part[data-p="title"] { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; } + ${sel} .part[data-p="channel"] { max-width: 40%; overflow: hidden; text-overflow: ellipsis; }`; +} + +/** * The deck composition's HTML. * * `fonts` = `{ regular, bold }` asset-relative paths (DeckSans / DeckSansBold), @@ -727,12 +766,16 @@ export function deckHtml(schedule, render, opts = {}) { // 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 lp = lines && Array.isArray(s.subtitleLinesParts) && s.subtitleLinesParts.length === 2 ? s.subtitleLinesParts : [null, 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>`; + ? `<div class="deck-sub head">${subtitleMarkup(lines[0], lp[0])}</div><div class="deck-sub meta">${subtitleMarkup(lines[1], lp[1])}</div>` + : `<div class="deck-sub">${subtitleMarkup(s.subtitle, s.subtitleParts)}</div>`; + // The automatic line (its lines, or its parts by token) is what the live preview puts back when a typed + // subtitle is cleared (data-sub, the runtime's deck:text). + const auto = lines || subtitleTokens(s.subtitle, s.subtitleParts); const html = ( `<div class="seg${s.title ? "" : " untitled"}${lines ? " two" : ""}" data-seg="${esc(s.id)}" data-k="s${i}"` + - `${lines ? ` data-sub="${esc(s.subtitle)}"` : ""}>` + + `${auto ? ` 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>` + @@ -942,15 +985,14 @@ export function deckHtml(schedule, render, opts = {}) { text-overflow: ellipsis; font-family: 'DeckSansBold', sans-serif; font-size: ${t.titleSize}px; line-height: ${t.titleBox}px; letter-spacing: -0.012em; color: ${pal.fg}; } - /* The source line is a row of parts: when it runs long, the middle parts - (the title) give way and the first (who) and last (the date) always - show whole; a line of one or two parts shrinks its first. */ + /* The source line is a row of parts: when it runs long, the title gives + way and the date and the clock always show whole (by token, the + automatic line); a typed line's middle parts give way, its first and + last whole (subtitlePartsCss). */ .deck-sub { display: flex; max-width: ${t.width}px; white-space: nowrap; overflow: hidden; font-size: ${t.subtitleSize}px; line-height: ${t.subtitleBox}px; letter-spacing: 0.005em; color: ${pal.muted}; } - .deck-sub .part, .deck-sub .sep { flex: none; } - .deck-sub .part:not(:first-child):not(:last-child), .deck-sub .part:first-child:nth-last-child(-n+3) { - flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; } + ${subtitlePartsCss(".deck-sub")} .deck-sub .sep { color: ${pal.accent}; padding: 0 0.42em; font-family: 'DeckSansBold', sans-serif; } .blade { position: absolute; right: 0; top: ${Math.round(t.titleBox * 0.14)}px; width: 4px; height: ${Math.round(t.titleBox * 0.72)}px; border-radius: 2px; background: ${pal.accent}; @@ -1176,17 +1218,17 @@ ${two ? ` // A two-line subtitle's head likewise, from its own size to 70 % fitTitle(node);${two ? ` seg.querySelectorAll(".deck-sub.head").forEach(fitHead);` : ""} } -${two ? ` // A typed subtitle is one line; the automatic one (data-sub) puts the two back. + // A typed subtitle is one line set by position; the automatic one (data-sub) puts back the markup the + // page was drawn with -- its parts by token${two ? ", and its two lines" : ""}. if (typeof m.subtitle === "string" && seg.dataset.sub !== undefined) { const si = seg.querySelector(".si"); - if (seg._two === undefined) seg._two = si.innerHTML; + if (seg._auto === undefined) { seg._auto = si.innerHTML; seg._wasTwo = seg.classList.contains("two"); } 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); + si.innerHTML = auto ? seg._auto : '<div class="deck-sub">' + subMarkup(m.subtitle) + "</div>";${two ? ` + seg.classList.toggle("two", auto && seg._wasTwo); + 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 @@ -24,7 +24,7 @@ // The timeline is cues, each stating its from (chrome-deck.mjs says why). import { cueTime, cueTimeAfter, finaleRail, pageDuration, resolveDeck } from "./deck.mjs"; import { finaleClaimsMarkup } from "./chrome-claims.mjs"; -import { mix, rgba, shapeCss, subtitleMarkup } from "./chrome-deck.mjs"; +import { mix, rgba, shapeCss, subtitleMarkup, subtitlePartsCss, subtitleTokens } from "./chrome-deck.mjs"; import { resolveFactcheck, tallyFinals, tallyOf, tallyVerdicts } from "./factcheck.mjs"; import { resolveCounter } from "./counter.mjs"; import { aboveTop, FINALE_CLAIMS, FINALE_MOTION, finaleGeometry, resolveFinale } from "./finale.mjs"; @@ -100,8 +100,11 @@ export function finaleLayout(schedule, render) { 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, + // The automatic line's parts by token (deck.mjs deckText), so the date and the clock stay whole here too. + ...(Array.isArray(s.subtitleParts) ? { subtitleParts: s.subtitleParts } : {}), // 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 } : {}), + ...(Array.isArray(s.subtitleLinesParts) && Array.isArray(s.subtitleLines) && lay.text.lines === 2 ? { subtitleLinesParts: s.subtitleLinesParts } : {}), })); return { geo, @@ -316,6 +319,22 @@ export function titleLast(subtitle) { return [parts[0], ...parts.slice(2), parts[1]].join(" · "); } +/** + * `titleLast` by token, for the automatic line (deck.mjs deckText's + * `subtitleParts`): the title part moved to the end, the others in order -- + * whichever position the title stood at (a line of fewer than three parts as it is). null for a typed line + * (subtitleTokens). + * + * @returns {Array<[string, string]> | null} + */ +export function titleLastParts(subtitle, tokens) { + const tok = subtitleTokens(subtitle, tokens); + if (!tok) return null; + // As titleLast: a line of one or two parts stays in its order. + if (tok.length < 3) return tok; + return [...tok.filter(([k]) => k !== "title"), ...tok.filter(([k]) => k === "title")]; +} + export function finaleHtml(schedule, render, window, opts = {}) { const L = finaleLayout(schedule, render); const { init, cues } = finaleCues(schedule, render, L); @@ -375,9 +394,9 @@ export function finaleHtml(schedule, render, window, opts = {}) { (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>`) + + `font-size:${ftx.headSize}px; line-height:${ftx.headBox}px; color:${mix(pal.muted, pal.fg, 0.6)}">${subtitleMarkup(c0.subtitleLines[0], c0.subtitleLinesParts?.[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], c0.subtitleLinesParts?.[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 ?? "", c0?.subtitleParts)}</div>`) + `</div>` : ""; @@ -455,7 +474,10 @@ export function finaleHtml(schedule, render, window, opts = {}) { return ( `<div class="cap" data-k="cap${i}" data-seg="${esc(c.id)}" style="left:${cap.x}px; top:${cap.y}px; width:${cap.width}px">` + (c.title ? `<div class="ct">${esc(c.title)}</div>` : "") + - `<div class="cs">${subtitleMarkup(titleLast(c.subtitle))}</div></div>` + + `<div class="cs">${(() => { + const tl = titleLastParts(c.subtitle, c.subtitleParts); + return tl ? subtitleMarkup(tl.map(([, v]) => v).join(" · "), tl) : subtitleMarkup(titleLast(c.subtitle)); + })()}</div></div>` + `<div class="cqr" data-k="qr${i}" style="left:${q.x}px; top:${q.y}px; width:${q.size}px; height:${q.size}px">` + (src ? `<img src="${esc(src)}" width="${q.size}" height="${q.size}" alt="">` : "") + `</div>` @@ -503,9 +525,8 @@ export function finaleHtml(schedule, render, window, opts = {}) { .dt > div { position: absolute; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .dtt { font-family: 'DeckSansBold', sans-serif; font-size: ${L.foot.text.titleSize}px; line-height: ${L.foot.text.titleBox}px; letter-spacing: -0.012em; } .dts { display: flex; font-size: ${L.foot.text.subtitleSize}px; line-height: ${L.foot.text.subtitleBox}px; color: ${pal.muted}; } - .dts .sep { flex: none; color: ${pal.accent}; padding: 0 0.42em; font-family: 'DeckSansBold', sans-serif; } - .dts .part { flex: none; } - .dts .part:not(:first-child):not(:last-child), .dts .part:first-child:nth-last-child(-n+3) { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; } + .dts .sep { color: ${pal.accent}; padding: 0 0.42em; font-family: 'DeckSansBold', sans-serif; } + ${subtitlePartsCss(".dts")} .drule { width: ${Math.round(L.foot.text.titleSize * 1.5)}px; height: 4px; border-radius: 2px; background: ${pal.accent}; } .hole { position: absolute; transform-origin: 0 0; box-shadow: 0 0 0 ${HOLE_REACH}px ${pal.bg}; } .ground { position: absolute; inset: 0; background: ${pal.bg}; } diff --git a/umtool/report-to-video/deck-claims.test.mjs b/umtool/report-to-video/deck-claims.test.mjs @@ -331,17 +331,23 @@ test("absent claims: the schedule, the deck's page and the finale's are byte-ide assert.equal(md5(JSON.stringify(d)), BEFORE.built); }); +// Re-pinned on lane/band-shelf (6 Nov, variant A's truncated dates): the automatic subtitle's parts by token +// (deckText's `subtitleParts`, each segment's line as `[token, text]`) and nothing else -- the schedule and the +// built one equal to the last pins with `subtitleParts` taken out, the deck's and the finale's pages differing +// only in the parts' `data-p`, a segment's `data-sub` and the token CSS (subtitlePartsCss). Was schedule +// 3a6c6abc6f5d4c095333dbbbe7c85aef, deck d56d6f45c667dea15c0fec5675dbcc95, finale +// ff1dd61a2a1de8a38b1fbf12a420b71d, built c6a44e98fce846811cbf87d449e6b40d. const BEFORE = { - schedule: "3a6c6abc6f5d4c095333dbbbe7c85aef", + schedule: "35c1ebe1db5506d42e3254507c5ec521", // Re-pinned on lane/fast-rerender: the deck's cue times moved onto the // sub-frame grid (deck.mjs CUE_GRID) and nothing else -- checked on the // Huck cut's 1,539 deck cues against main: the same elements, values, // eases and durations, every time within 4 ms. (Was 4966f5f6904d7c91e8c3bd64b16763b8.) - deck: "d56d6f45c667dea15c0fec5675dbcc95", + deck: "4f6381f694890c6e3b7ff501961a2401", // Likewise the finale's (its 181 cues on the Huck cut: times within 2 ms, // its window's start on the grid). Was e4cb165d4e3b816c0d648240cac91eb1; then afc1b758… until rev 9 (6 Nov) // wrapped the clip card's source line to two lines with the title last (chrome-finale.mjs titleLast): the // page's css and that line, nothing else. - finale: "ff1dd61a2a1de8a38b1fbf12a420b71d", - built: "c6a44e98fce846811cbf87d449e6b40d", + finale: "140a9057fa35784110521eacae464fdc", + built: "035eadac91f3b2efd3000f18743e376b", }; diff --git a/umtool/report-to-video/deck.mjs b/umtool/report-to-video/deck.mjs @@ -22,7 +22,7 @@ import { measureOn, measureSlice } from "./measure-slice.mjs"; 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, deckSubtitleLines, formatDeckDate } from "./attribution.mjs"; +import { attributionParts, deckSubtitle, deckSubtitleLines, deckSubtitleLinesParts, deckSubtitleParts, formatDeckDate } from "./attribution.mjs"; import { panelEntry, postDeckText, postItemSeconds, postLayout } from "./post-item.mjs"; import { videoDip, videoEnter, videoHidesChrome, videoSeconds } from "./video-entry.mjs"; import { @@ -1157,12 +1157,19 @@ export function deckText(entry, meta, provenance, deck, multiChannel) { let title = o.title ?? ""; let subtitle = o.subtitle; let subtitleLines = null; + // The automatic line's parts by token (deckSubtitleParts): the page sets the + // date and the clock whole and lets the title give way, wherever each stands. + // A typed subtitle has none: its parts are only positions. + let subtitleParts = null; + let subtitleLinesParts = null; const two = deck.subtitle?.lines === 2; if (subtitle === undefined) { if (entry.type === "clip") { const parts = attributionParts(entry, meta ?? {}, provenance); subtitle = deckSubtitle(parts, deck.subtitle, multiChannel); + subtitleParts = deckSubtitleParts(parts, deck.subtitle, multiChannel); if (two) subtitleLines = deckSubtitleLines(parts, deck.subtitle, multiChannel); + if (subtitleLines) subtitleLinesParts = deckSubtitleLinesParts(parts, deck.subtitle, multiChannel); // Two lines already name the source: an on-screen title that only // repeats it is not drawn again over them (the block takes the // title's band, as for a clip with none). A different one stands. @@ -1181,13 +1188,20 @@ export function deckText(entry, meta, provenance, deck, multiChannel) { 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); + subtitleParts = deckSubtitleParts(parts, opts, false); if (two) subtitleLines = deckSubtitleLines(parts, { ...opts, head: ["title"] }, false); + if (subtitleLines) subtitleLinesParts = deckSubtitleLinesParts(parts, { ...opts, head: ["title"] }, false); } else { if (!title) title = entry.heading ?? ""; subtitle = entry.sub ?? ""; } } - return subtitleLines ? { title, subtitle, subtitleLines } : { title, subtitle }; + return { + title, subtitle, + ...(subtitleParts?.length ? { subtitleParts } : {}), + ...(subtitleLines ? { subtitleLines } : {}), + ...(subtitleLinesParts ? { subtitleLinesParts } : {}), + }; } /** @@ -1357,7 +1371,7 @@ export function deckSchedule({ multiChannel, ...(feed ? { layout: "feed" } : {}), segments: entries.map((e, i) => { - const { title, subtitle, subtitleLines } = deckText(e, metas[i] ?? null, provenance, deck, multiChannel); + const { title, subtitle, subtitleParts, subtitleLines, subtitleLinesParts } = deckText(e, metas[i] ?? null, provenance, deck, multiChannel); return { id: e.id, type: e.type, @@ -1368,8 +1382,11 @@ export function deckSchedule({ ...(holds.get(e.id) ? { hold: round(holds.get(e.id)) } : {}), title, subtitle, + // The automatic line's parts by token (deckText): only where the line is the automatic one. + ...(subtitleParts ? { subtitleParts } : {}), // Only in a two-line subtitle (`subtitle.lines: 2`): `subtitle` is still the whole line. ...(subtitleLines ? { subtitleLines } : {}), + ...(subtitleLinesParts ? { subtitleLinesParts } : {}), 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/deck.test.mjs b/umtool/report-to-video/deck.test.mjs @@ -134,14 +134,17 @@ test("deckText: onscreen overrides, clip/image/card fallbacks", () => { const deck = resolveDeck(RENDER); const meta = { title: "Stream", uploadDate: "20260814" }; const clip = { id: "c1", type: "clip", video: "v", start: 1, end: 9 }; - assert.deepEqual(deckText(clip, meta, PROV, deck, false), { title: "", subtitle: "Stream · Aug 14, 2026" }); + // The automatic line carries its parts by token (the page sets the date whole by them); a typed one does not. + assert.deepEqual(deckText(clip, meta, PROV, deck, false), { + title: "", subtitle: "Stream · Aug 14, 2026", subtitleParts: [["title", "Stream"], ["date", "Aug 14, 2026"]], + }); assert.deepEqual( deckText({ ...clip, onscreen: { title: "T", subtitle: "S" } }, meta, PROV, deck, false), { title: "T", subtitle: "S" }, ); assert.deepEqual( deckText({ id: "i", type: "image", title: "Poster", date: "2026-01-02" }, null, PROV, deck, true), - { title: "", subtitle: "Poster · Jan 2, 2026" }, + { title: "", subtitle: "Poster · Jan 2, 2026", subtitleParts: [["title", "Poster"], ["date", "Jan 2, 2026"]] }, ); assert.deepEqual( deckText({ id: "k", type: "card", heading: "H", sub: "S" }, null, PROV, deck, false), diff --git a/umtool/report-to-video/instruments.test.mjs b/umtool/report-to-video/instruments.test.mjs @@ -45,9 +45,14 @@ function cut(render = RENDER) { // What the release 28 kit's manifests drew on main before the instruments (c05e5314): the estimate's // schedule, the deck's page, the frame and every whole-cut overlay's region, hashed. Unchanged. +// Re-pinned on lane/band-shelf (6 Nov): the automatic subtitle's parts by token -- the schedule equal but for +// `subtitleParts`, the frame and the regions equal, the deck's page differing only in the parts' `data-p`, a +// segment's `data-sub`, the token CSS and the live preview's restore (chrome-deck.mjs subtitleMarkup). +// full was 0eeb6303e621af4b88c8e0eaae2eca7228da0e3dbae997c60fd45fdd5744e18a, flips +// 565472d4e03834bdf8f2fdd656d76f48d1bca37019be27f33422c0f27d6f270e. const BEFORE = { - full: "0eeb6303e621af4b88c8e0eaae2eca7228da0e3dbae997c60fd45fdd5744e18a", - flips: "565472d4e03834bdf8f2fdd656d76f48d1bca37019be27f33422c0f27d6f270e", + full: "a072b99f19faefe264655cf34899ea86807d2bbe42fdb06d6455ec6393467fda", + flips: "ae320afa4c16e51f8d4b283b69304b078f8e79f30eb82d21b9c4b84427ba0ada", }; test("a cut without the instruments draws exactly what it drew before them (the release 28 kit's manifests)", () => { diff --git a/umtool/report-to-video/modules/subtitle.mjs b/umtool/report-to-video/modules/subtitle.mjs @@ -32,11 +32,11 @@ export default defineModule({ ], docs: { heading: "Subtitle", - intro: "The source line under each clip's title, in the deck.", + intro: "The source line under each clip's title, in the deck. The automatic line is set by what each part IS, wherever it stands: when it runs long the title gives way first (an ellipsis at its end), a channel ellipsizes only past 40 % of the line, and the date and the clock always show whole -- so `[channel, title, date, clock]` never reads \"… · Oct … · 1:08:48\" (the schedule's `subtitleParts`, chrome-deck.mjs subtitleMarkup; the finale's copy of the line too). An entry's typed `onscreen.subtitle` has no parts to name: its middle parts give way, its first and last show whole.", 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.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: with full-width footage that needs `footageScale` at most about 0.78 · 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/subtitle-lines.test.mjs b/umtool/report-to-video/subtitle-lines.test.mjs @@ -7,8 +7,9 @@ import assert from "node:assert/strict"; import test from "node:test"; -import { deckSubtitle, deckSubtitleLines } from "./attribution.mjs"; -import { deckHtml } from "./chrome-deck.mjs"; +import { deckSubtitle, deckSubtitleLines, deckSubtitleLinesParts, deckSubtitleParts } from "./attribution.mjs"; +import { deckHtml, subtitleMarkup } from "./chrome-deck.mjs"; +import { titleLastParts } from "./chrome-finale.mjs"; import { deckGeometry, deckLayout, deckText, estimateSchedule, feedGeometry, resolveDeck, subtitleBoxes, validateChrome, } from "./deck.mjs"; @@ -191,3 +192,73 @@ test("the page: two lines where the schedule gave them, a fitted head, and a one 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); }); + +// --------------------------------------------------------------------------- +// THE PARTS BY TOKEN (weight video, variant A: "the dates are getting +// truncated"): a line `[channel, title, date, clock]` has its date in the +// MIDDLE, and the positional rule shrank it with the title ("Huge Win For +// Cornell 7, Mamdani … · Oct … · 1:08:48"). The automatic line now says what +// each part is, and the page keeps the date and the clock whole by token. +// --------------------------------------------------------------------------- + +const FOUR = { subtitle: { parts: ["channel", "title", "date", "clock"] } }; + +test("deckSubtitleParts: the line's parts as [token, text], the empty ones dropped; the lines' parts split by the head", () => { + assert.deepEqual(deckSubtitleParts(PARTS, FOUR.subtitle), [ + ["channel", "EmberParadox"], ["title", LONG], ["date", "Oct 28, 2026"], ["clock", "1:02:05"], + ]); + assert.equal(deckSubtitleParts(PARTS, FOUR.subtitle).map(([, v]) => v).join(" · "), deckSubtitle(PARTS, FOUR.subtitle)); + assert.deepEqual(deckSubtitleParts({ ...PARTS, title: "" }, {}), [["date", "Oct 28, 2026"]]); + assert.deepEqual(deckSubtitleLinesParts(PARTS, FOUR.subtitle), [ + [["title", LONG]], [["channel", "EmberParadox"], ["date", "Oct 28, 2026"], ["clock", "1:02:05"]], + ]); + assert.equal(deckSubtitleLinesParts({ ...PARTS, title: "" }, FOUR.subtitle), null); +}); + +test("deckText and the schedule: the automatic line carries its parts; a typed one, a card or a post item none", () => { + const deck = resolveDeck(renderOf(FOUR)); + const clip = { type: "clip", id: "x02", video: "v", start: 3725, end: 3740, channelTitle: "EmberParadox", title: LONG, date: "2026-10-28", cite: 3725 }; + const t = deckText(clip, {}, { channelSlug: "ember" }, deck, false); + assert.deepEqual(t.subtitleParts.map(([k]) => k), ["channel", "title", "date", "clock"]); + assert.equal(t.subtitleParts.map(([, v]) => v).join(" · "), t.subtitle); + assert.equal("subtitleLinesParts" in t, false, "one line: no lines' parts"); + assert.equal("subtitleParts" in deckText({ ...clip, onscreen: { subtitle: "typed" } }, {}, {}, deck, false), false); + assert.equal("subtitleParts" in deckText({ type: "card", id: "k", heading: "H", sub: "s" }, null, {}, deck, false), false); + const deck2 = resolveDeck(renderOf({ subtitle: { ...FOUR.subtitle, lines: 2 }, footageScale: 0.78 })); + const t2 = deckText(clip, {}, { channelSlug: "ember" }, deck2, false); + assert.deepEqual(t2.subtitleLinesParts.map((l) => l.map(([k]) => k)), [["title"], ["channel", "date", "clock"]]); + const sched = estimateSchedule({ + schemaVersion: 1, provenance: { channelSlug: "ember", siteOrigin: "https://example.test" }, + render: renderOf(FOUR), + timeline: [clip, { ...clip, id: "c03", onscreen: { subtitle: "typed" } }], + }); + assert.deepEqual(sched.segments[0].subtitleParts.map(([k]) => k), ["channel", "title", "date", "clock"]); + assert.equal("subtitleParts" in sched.segments[1], false); +}); + +test("the page sets the automatic line by token: the date and the clock never shrink, the title gives way; a typed line by position", () => { + const four = [["channel", "TheQuartering (Rumble)"], ["title", LONG], ["date", "Oct 23, 2026"], ["clock", "1:08:48"]]; + const line = four.map(([, v]) => v).join(" · "); + const m = subtitleMarkup(line, four); + assert.match(m, /<span class="part" data-p="date">Oct 23, 2026<\/span>/); + assert.match(m, /<span class="part" data-p="clock">1:08:48<\/span>/); + assert.match(m, /<span class="part" data-p="title">/); + // Parts that are not the line (stale against a retyped subtitle), or none: by position, as before. + assert.equal(subtitleMarkup("a typed · line", four), subtitleMarkup("a typed · line")); + assert.equal(subtitleMarkup(line).includes("data-p"), false); + const seg = (id, start, extra) => ({ id, type: "clip", start, duration: 10, end: start + 10, title: "", qrUrl: null, hideDeck: false, ...extra }); + const sched = { + version: 1, kind: "deck", estimated: true, fps: 30, transition: 0.5, total: 19, multiChannel: false, + segments: [seg("c01", 0, { subtitle: line, subtitleParts: four }), seg("c02", 9.5, { title: "Typed", subtitle: "a typed line · Oct 1" })], + }; + const html = deckHtml(sched, renderOf(FOUR)); + assert.match(html, /data-seg="c01" data-k="s0" data-sub="/, "the automatic line is what a cleared typed one puts back"); + assert.doesNotMatch(html, /data-seg="c02" data-k="s1" data-sub=/); + assert.match(html, /\.deck-sub \.part\[data-p="title"\] \{ flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; \}/); + assert.match(html, /\.deck-sub \.part:not\(\[data-p\]\):not\(:first-child\):not\(:last-child\)/, "a typed line keeps the positional rule"); + assert.doesNotMatch(html, /\[data-p="date"\][^}]*flex: 0 1/, "nothing lets the date shrink"); + assert.doesNotMatch(html, /\[data-p="clock"\][^}]*flex: 0 1/, "nothing lets the clock shrink"); + // The finale's clip card: the title last by token, wherever it stood. + assert.deepEqual(titleLastParts(line, four).map(([k]) => k), ["channel", "date", "clock", "title"]); + assert.equal(titleLastParts("typed · line · here", four), null); +});