commit c42d3d03f13ece49f848a2c41cee08bfad9d509a
parent 2a32bd0a66321a05af66cff618bbcb04dee8dac8
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Fri, 30 Oct 2026 15:24:38 -0400
umtool section-title module: the current section's name on one quiet line under the rail
A deck part (modules/section-title.mjs, render.chrome.deck.sectionTitle):
the label of the marker that opened the section the rail's marker stands
in -- `first` before any marker, nothing for an unlabelled one -- centred
in a row of its own under the track (deckLayout `sectionTitle`; the clip's
title moves down only by what the line needs). It crossfades as the marker
crosses into the next section (`fade`, the old out then the new in), is set
at once as the deck rises, and rides the panel away over a card.
Independent of deck.rail.labels.
`true` or { first <=24, size 12-32 (18), opacity 0.2-1 (0.85), fade 0-2 s
(0.4), color auto|section|#hex|palette key }. "auto" is the subtitle's
muted grey lifted toward fg only as far as 4.5:1 at that opacity needs.
Absent or false: the page, cues and layout are byte-identical.
Each title is an item of the deck's page gated on its own opacity, so a
frame's key holds the title it shows: a renamed section recaptures only
the frames it is up on. Validated with the deck's settings; module-config
`modules.section-title`; the generic panel switches it on and off; knobs.md
generated; umtool look deck.sectionTitle=… through the deck's own keys.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
13 files changed, 652 insertions(+), 21 deletions(-)
diff --git a/umtool/docs/knobs.md b/umtool/docs/knobs.md
@@ -380,6 +380,7 @@ filter. A knob absent is its default, and a module whose knobs are all absent dr
| [Rail](#rail) `rail` | The deck's pip track: a pip per clip, the marker, the fuse, and the markers' flags. (drawn in the deck's page) | `render.chrome.deck.pip` |
| [Counter](#counter) `counter` | A running tally of named series in the deck, each cell stepping as a mark's stamp lands. (drawn in the deck's page) | `render.chrome.deck.counter` |
| [Claim checks](#claim-checks) `claims` | His explicit claims against the record on the rail: a count over a window, a goalpost moved. (drawn in the deck's page) | `render.chrome.deck.claims` |
+| [Section title](#section-title) `section-title` | The current section's name (the marker that opened it) on one quiet line under the rail. (drawn in the deck's page) | `render.chrome.deck.sectionTitle` |
| [Teaser](#teaser) `teaser` | A full-frame card of lines popping in on the beat, inserted as its own segment. (a segment cut into the timeline) | -- |
| [Intro](#intro) `intro` | The brand sting the cut opens with, a site's name swapped in on the chime. (a segment cut into the timeline) | `render.intro` |
| [Blur](#blur) `blur` | A clip's picture blurred at its encode, a caption on it, the sound as recorded. (a filter on the footage) | `render.blur` |
@@ -461,7 +462,7 @@ The pip track along the top of the deck; the markers' flags stand over it ([mark
| `deck.pip.color` | `accent` · `verdict` (a counted clip's pip takes its series' colour and shape) · `section` (every pip, the fuse and the marker's ring in the colour of the section it stands in: from one marker to the next, in that marker's `color`; fitted to 3:1 on the deck) · default `accent` | `umtool look <p> deck.pip='{"color":"verdict"}'` |
| `deck.pip.sectionColor0` | the section before the first marker, with `color: "section"`: a `#hex` or a palette key (`fg`, `muted`, `accent`, `amber`, `dim`) · default the accent | `umtool look <p> deck.pip='{"color":"section","sectionColor0":"#5fa8d3"}'` |
| `deck.markers[].label` | optional: a marker with none (or `""`) draws a tick at its boundary, no words, and takes no band over the track | `umtool look <p> deck.markers='[{"after":"c04","color":"#e07a9a"}]'` |
-| `deck.rail.labels` | `false` draws every marker as a tick, no words, and no band over the track · default `true` | `umtool look <p> deck.rail='{"labels":false}'` |
+| `deck.rail.labels` | `false` draws every marker as a tick, no words, and no band over the track (the current section's name can stand under the rail instead: [Section title](#section-title)) · default `true` | `umtool look <p> deck.rail='{"labels":false}'` |
### Counter
@@ -483,6 +484,19 @@ The full reference is [Claim checks on the rail](#claim-checks-on-the-rail). A c
|---|---|---|
| `deck.claims[]` | at most 6, each a `count` or a `goalpost` | `umtool look <p> deck.claims='[…]'` (`deck.claims=` none) |
+### Section title
+
+The current section's name on one quiet line centred under the rail (`render.chrome.deck.sectionTitle`): the label of the marker that opened the section ([Rail](#rail)), `first` before any marker; a marker with no label shows nothing for its section. It crossfades as the rail's marker crosses into the next section, rides the deck away over a card, and is independent of `deck.rail.labels` -- the track can carry no words while this says where the cut is. Off unless set: absent or `false` draws the deck as it always was. The clip's title moves down only by what the line needs.
+
+| Knob | Range · default | From a terminal |
+|---|---|---|
+| `deck.sectionTitle` | `true` (on, every default) · `false` · an object of the keys below · default off | `umtool look <p> deck.sectionTitle=true` |
+| `deck.sectionTitle.first` | the section before the first marker: a line of at most 24 characters · default `""` (nothing) | `umtool look <p> deck.sectionTitle='{"first":"Who she is"}'` |
+| `deck.sectionTitle.size` | 12–32 px · default 18 (a touch under the subtitle's 26) | `umtool look <p> deck.sectionTitle.size=20` |
+| `deck.sectionTitle.opacity` | 0.2–1 · default 0.85 | `umtool look <p> deck.sectionTitle.opacity=0.7` |
+| `deck.sectionTitle.fade` | 0–2 s: the old title out over its first half, the new in over the second (0: a cut) · default 0.4 | `umtool look <p> deck.sectionTitle.fade=0.6` |
+| `deck.sectionTitle.color` | `auto` (the subtitle's muted grey, lifted toward the deck's fg only as far as it needs to read at 4.5:1 at that opacity) · `section` (its section's colour, fitted to 4.5:1) · a `#hex` · a palette key (`fg`, `muted`, `accent`, `amber`, `dim`) · default `auto` | `umtool look <p> deck.sectionTitle.color=section` |
+
### Teaser
A timeline entry `{ type: "teaser", lines, … }`: a full-frame card whose lines pop in on the beat, cut in as its own segment (deck.mjs `validateTeaser`; [report-video.md](report-video.md)).
diff --git a/umtool/docs/report-video.md b/umtool/docs/report-video.md
@@ -398,7 +398,8 @@ feed). The fact-check form beside the structure editors has **stamp effect**
counts) and, per verdict, **pop in** (`factcheck.tally.showAt`: the tally's cell
hidden until its first count lands, then popped in; every verdict ticked writes
`"first"`, some `{ <VERDICT>: "first" }`, none removes the key). `deck.markers` — flags on the pip track, `[{ after, label?, color? }]`
-(no `label`: a tick at the boundary, no words and no band over the track; `deck.rail.labels: false` makes every marker one)
+(no `label`: a tick at the boundary, no words and no band over the track; `deck.rail.labels: false` makes every marker one;
+`deck.sectionTitle` says the current section's label on one quiet line under the rail instead -- [knobs](knobs.md#section-title))
([the pipeline's README](../report-to-video/README.md#deckmarkers--flags-on-the-pip-track))
— has no form: write them in the manifest. A settings save carries them
through, with the fact-check block and the other regions (threads, flips,
diff --git a/umtool/lib/report/knobsCli.mjs b/umtool/lib/report/knobsCli.mjs
@@ -82,6 +82,8 @@ export const LOOK_USAGE = [
" deck.<key>.<field>=… sets one field and keeps the rest (deck.subtitle.lines=2: the source's title on a line of its own)",
" deck.pip.color=section: the rail coloured by section (marker to marker, each marker's color; deck.pip.sectionColor0 before",
" the first); a marker's label is optional (none: a tick); deck.rail.labels=false draws no marker's words",
+ " deck.sectionTitle=true | deck.sectionTitle='{\"first\":\"Who she is\"}': the current section's name (its marker's label)",
+ " on one quiet line under the rail; .size .opacity .fade .color (auto|section|#hex|palette key); false or `=` is off",
" 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}]'",
diff --git a/umtool/report-to-video/chrome-deck.mjs b/umtool/report-to-video/chrome-deck.mjs
@@ -38,7 +38,8 @@
import { fileURLToPath } from "node:url";
import {
- claimsLayout, cueTime, cueTimeAfter, PIP_PITCH_DEFAULT, stampsOnFrames, deckChoreography, deckLayout, deckMarkers, MARKER_LABEL_SIZE, MARKER_ROW, pageDuration, pipSegments, pipXs, railSections, resolveDeck,
+ claimsLayout, cueTime, cueTimeAfter, PIP_PITCH_DEFAULT, stampsOnFrames, deckChoreography, deckLayout, deckMarkers, MARKER_DEFAULT_COLOR, MARKER_LABEL_SIZE, MARKER_ROW, pageDuration, pipSegments, pipXs, railSections, resolveDeck,
+ resolveSectionTitle,
} from "./deck.mjs";
import { contrast } from "./chrome-intro.mjs";
import { claimsCues, claimsMarkup } from "./chrome-claims.mjs";
@@ -405,6 +406,27 @@ export function deckCues(schedule, render) {
const claims = claimsLayout(schedule, render, xs, pipped, lay);
if (claims) claimsCues(claims, { put, add, segIndex: (id) => idx.get(id), W: lay.width });
+ // The section title (`deck.sectionTitle`, sectionTitleTimeline): a line per
+ // distinct title, the current one at the setting's opacity; at a boundary
+ // the old fades out over the first half of `fade` and the new in over the
+ // second, or both at once as the deck rises. Off: nothing here.
+ const sectionTitle = sectionTitleTimeline(schedule, render, ch);
+ if (sectionTitle) {
+ const { titles, changes, opacity } = sectionTitle;
+ titles.forEach((_, j) => put(`st${j}`, { opacity: j === sectionTitle.init ? opacity : 0 }));
+ const half = sectionTitle.fade / 2;
+ for (const c of changes) {
+ const why = `section title ${c.from ?? "none"}->${c.to ?? "none"}`;
+ if (c.instant) {
+ if (c.from !== null) add(`st${c.from}`, c.at, INSTANT, { opacity: 0 }, "none", why);
+ if (c.to !== null) add(`st${c.to}`, c.at, INSTANT, { opacity }, "none", why);
+ } else {
+ if (c.from !== null) add(`st${c.from}`, c.at - half, half, { opacity: 0 }, "power1.in", why);
+ if (c.to !== null) add(`st${c.to}`, c.at, half, { opacity }, "power1.out", why);
+ }
+ }
+ }
+
// ---- order, clamp, and state the froms ---------------------------------
ev.forEach((e, n) => { e.n = n; });
ev.sort((x, y) => x.at - y.at || x.n - y.n);
@@ -429,7 +451,113 @@ export function deckCues(schedule, render) {
return {
init, cues, pips, slideY, choreography: ch, ...(markers.length ? { markers } : {}), ...(claims ? { claims } : {}),
...(sections ? { sections: { ...sections, fuses: fuseParts ?? [], rings } } : {}),
+ ...(sectionTitle ? { sectionTitle } : {}),
+ };
+}
+
+const HEX_RE = /^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/;
+
+/**
+ * THE SECTION TITLE's timeline (`deck.sectionTitle`, modules/section-title.mjs):
+ * which section's name is up when. The sections are the rail's (deck.mjs
+ * railSections): the stretch before the first marker, then one from each
+ * marker on. A section's title is the label of the marker that opened it
+ * -- `first` for the one before any -- and an empty one shows nothing.
+ * The title changes as the marker crosses into another section: half-way
+ * through its move from pip to pip (the handover's middle), or in the
+ * instant the deck rises on a pip of another section. Two sections of one
+ * title in a row are one run: nothing changes between them.
+ *
+ * `titles` are the distinct titles, `{ label, color }` (`color` the
+ * section's colour with `color: "section"`, else null), `init` the one up
+ * at t = 0 (an index, or null for none) and each change `{ at, from, to,
+ * instant }` (indices or null). null when the section title is off.
+ *
+ * @returns {null | { titles: Array<{ label: string, color: string | null }>, init: number | null,
+ * changes: Array<{ at: number, from: number | null, to: number | null, instant: boolean }>,
+ * fade: number, opacity: number, size: number, color: string }}
+ */
+export function sectionTitleTimeline(schedule, render, ch = null) {
+ const st = resolveSectionTitle(render);
+ if (!st) return null;
+ const d = resolveDeck(render);
+ const pal = render?.palette ?? {};
+ const segs = schedule.segments ?? [];
+ const pipped = pipSegments(schedule);
+ const pipOf = new Map(pipped.map((s, k) => [s.id, k]));
+ const hexOf = (key, fallback) => (typeof key === "string" && HEX_RE.test(key) ? key : (key && pal[key]) || fallback);
+ // The markers as the rail's sections take them: by the pip they follow.
+ const ms = (Array.isArray(d.markers) ? d.markers : [])
+ .map((m) => ({ k: pipOf.get(String(m?.after ?? "").trim()), label: String(m?.label ?? "").trim(), color: m?.color ?? MARKER_DEFAULT_COLOR }))
+ .filter((m) => m.k !== undefined)
+ .sort((a, b) => a.k - b.k);
+ const sectionOf = (k) => ms.filter((m) => m.k < k).length;
+ const byColor = st.color === "section";
+ const colorOf = (i) => (i === 0 ? hexOf(d.pip.sectionColor0, pal.accent ?? "#ffffff") : hexOf(ms[i - 1].color, pal.fg ?? "#ffffff"));
+ const titles = [];
+ const ids = new Map();
+ const titleOf = (i) => {
+ const label = i === 0 ? st.first : ms[i - 1].label;
+ if (!label) return null;
+ const color = byColor ? colorOf(i) : null;
+ const key = `${label}\u0000${color ?? ""}`;
+ if (!ids.has(key)) {
+ ids.set(key, titles.length);
+ titles.push({ label, color });
+ }
+ return ids.get(key);
};
+ const choreo = ch ?? deckChoreography(schedule, render);
+ const moves = [];
+ for (const h of choreo.handovers) {
+ const k = pipOf.get(h.to);
+ if (k !== undefined) moves.push({ at: (h.pip[0] + h.pip[1]) / 2, k, instant: false });
+ }
+ for (const v of choreo.visibility) {
+ if (v.hide) continue;
+ const k = pipOf.get(segs[v.i].id);
+ if (k !== undefined) moves.push({ at: v.at[0], k, instant: true });
+ }
+ moves.sort((a, b) => a.at - b.at);
+ const init = pipped.length ? titleOf(sectionOf(0)) : null;
+ let cur = init;
+ const changes = [];
+ for (const m of moves) {
+ const next = titleOf(sectionOf(m.k));
+ if (next === cur) continue;
+ changes.push({ at: r4(m.at), from: cur, to: next, instant: m.instant || !(st.fade > 0) });
+ cur = next;
+ }
+ return { titles, init, changes, fade: st.fade, opacity: st.opacity, size: st.size, color: st.color };
+}
+
+/** The section title up at `t` (seconds of the cut): its words, or "" for none. A change counts from its `at`. */
+export function sectionTitleAt(timeline, t) {
+ if (!timeline) return "";
+ let cur = timeline.init;
+ for (const c of timeline.changes) if (c.at <= t) cur = c.to;
+ return cur === null ? "" : timeline.titles[cur].label;
+}
+
+/**
+ * The section title's colour on its ground: "auto" is the subtitle's muted
+ * grey, moved toward the deck's fg in 5 % steps only until, at the line's
+ * opacity, it stands at 4.5:1 on the deck -- the quietest neutral that
+ * reads; "section" the section's own colour fitted to 4.5:1 (words, not a
+ * graphic); else the #hex or palette key it names.
+ */
+export function sectionTitleColor(title, timeline, pal, ground) {
+ const c = timeline.color;
+ if (c === "auto") {
+ const muted = pal.muted ?? pal.fg;
+ for (let step = 0; step <= 100; step += 5) {
+ const out = step ? mix(muted, pal.fg, step / 100) : muted;
+ if (contrast(mix(ground, out, timeline.opacity), ground) >= 4.5) return out;
+ }
+ return pal.fg;
+ }
+ if (c === "section") return fitSectionColor(title.color ?? pal.accent, ground, 4.5);
+ return HEX_RE.test(c) ? c : pal[c] ?? pal.fg;
}
/** The section an (unlabelled) marker opens: one past the markers before it. */
@@ -528,7 +656,7 @@ export function deckHtml(schedule, render, opts = {}) {
if (!(dur > 0)) throw new Error(`deck: nothing to render from ${from}s of a ${total}s cut`);
const windowed = from > 0 || Math.abs(dur - total) > 1e-6;
- const { init, cues, pips, markers = [], claims = null, sections = null } = deckCues(schedule, render);
+ const { init, cues, pips, markers = [], claims = null, sections = null, sectionTitle = null } = deckCues(schedule, render);
const t = lay.text;
const tr = lay.pipTrack;
const qr = lay.qr;
@@ -689,6 +817,22 @@ export function deckHtml(schedule, render, opts = {}) {
})
: null;
+ // The section title (`deck.sectionTitle`): a line per distinct title in
+ // its row under the track (deckLayout `sectionTitle`), each an ITEM gated
+ // by its own opacity -- a frame's key holds the title it shows and no
+ // other, so a renamed section recaptures only the frames it is up on.
+ const stRow = sectionTitle ? lay.sectionTitle : null;
+ const stHtml = stRow
+ ? sectionTitle.titles
+ .map((title, j) => {
+ const ground = mix(top, bottom, (stRow.y + stRow.height / 2) / H);
+ const html = `<div class="stitle" data-k="st${j}" style="color:${esc(sectionTitleColor(title, sectionTitle, pal, ground))}">${esc(title.label)}</div>`;
+ if (items) items.push({ key: `st${j}`, gate: [`st${j}`, "opacity"], html });
+ return html;
+ })
+ .join("")
+ : "";
+
const fuseLeft = pips[0]?.x ?? tr.x0;
const fuseWidth = pips.length > 1 ? (pitched ? tr.x1 - fuseLeft : pips[pips.length - 1].x - fuseLeft) : 0;
@@ -845,7 +989,12 @@ export function deckHtml(schedule, render, opts = {}) {
.mtick { position: absolute; left: -1px; top: -6px; width: 2px; height: 12px; border-radius: 1px; background: var(--mc); opacity: 0.85; }` : ""}${staggered ? `
/* Staggered labels: row 1 a row above, its flag's stick up to it. */
.mflag.up .mlabel { top: ${band.y - tr.y}px; }
- .mflag.up .mstick { top: ${band.y + 20 - tr.y}px; height: ${tr.y + 6 - (band.y + 20)}px; }` : ""}${claimMarkup ? claimMarkup.css : ""}
+ .mflag.up .mstick { top: ${band.y + 20 - tr.y}px; height: ${tr.y + 6 - (band.y + 20)}px; }` : ""}${stRow ? `
+ /* The section title: the current section's name, one quiet line
+ centred under the track; ellipsized, never wrapped. */
+ .stitle { position: absolute; left: ${stRow.x}px; top: ${stRow.y}px; width: ${stRow.width}px; height: ${stRow.height}px;
+ text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
+ font-size: ${stRow.size}px; line-height: ${stRow.height}px; letter-spacing: 0.02em; }` : ""}${claimMarkup ? claimMarkup.css : ""}
.deck-qr img { display: block; width: ${qr?.size ?? 0}px; height: ${qr?.size ?? 0}px; border-radius: 6px;
image-rendering: pixelated; backface-visibility: hidden;
box-shadow: 0 0 0 1px ${rgba(pal.fg, 0.25)}, 0 6px 18px rgba(0, 0, 0, 0.35); }
@@ -868,7 +1017,8 @@ export function deckHtml(schedule, render, opts = {}) {
${secColors
? `<div class="marker sec" data-k="marker">${sections.rings.map((r) => `<div class="mring" data-k="mr${r}" style="--rc:${rgba(secColors[r], 0.95)}; --rg:${rgba(secColors[r], 0.45)}"></div>`).join("")}</div>`
: `<div class="marker" data-k="marker"></div>`}
- </div>
+ </div>${stHtml ? `
+ ${stHtml}` : ""}
${tallyHtml}
${segHtml}${claimMarkup ? claimMarkup.text : ""}
</div>
diff --git a/umtool/report-to-video/deck.mjs b/umtool/report-to-video/deck.mjs
@@ -27,7 +27,8 @@ import { resolveCounter } from "./counter.mjs";
import { DECK_PAD_X, COUNTER_CELL } from "./modules/design.mjs";
import {
DECK_DEFAULTS, MARKER_ALIGNS, MARKER_DEFAULT_COLOR, MARKER_LAYOUTS, MARKER_LIMITS, MARKER_PALETTE_KEYS, markerShapeErrors,
- PIP_COLORS, PIP_PITCH_DEFAULT, PIP_SPACINGS, POST_AT, POST_LAYOUTS, POST_LINKS, QR_LINKS, SETTINGS, settingValue, SUBTITLE_TOKENS,
+ PIP_COLORS, PIP_PITCH_DEFAULT, PIP_SPACINGS, POST_AT, POST_LAYOUTS, POST_LINKS, QR_LINKS, SECTION_TITLE_DEFAULTS, SETTINGS, settingValue,
+ SUBTITLE_TOKENS,
} from "./modules/settings.mjs";
// The deck's settings and their limits live with the modules' validators
@@ -37,7 +38,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";
+export { SECTION_TITLE_DEFAULTS, 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";
@@ -78,6 +79,19 @@ export function deckOn(render) {
return !!c && c.engine === "hyperframes" && c.layout === "deck";
}
+/**
+ * The section title's settings (`deck.sectionTitle`, modules/section-title.mjs)
+ * with every default filled in, or null when it is off (absent or false).
+ */
+export function resolveSectionTitle(render) {
+ const v = render?.chrome?.deck?.sectionTitle;
+ if (v === true) return { ...SECTION_TITLE_DEFAULTS };
+ if (!isObj(v)) return null;
+ const out = { ...SECTION_TITLE_DEFAULTS, ...v };
+ out.first = String(out.first ?? "").trim();
+ return out;
+}
+
/** The deck settings with every default filled in. */
export function resolveDeck(render) {
const d = render?.chrome?.deck ?? {};
@@ -152,8 +166,9 @@ export function validateChrome(chrome, render = {}) {
// absent, nothing about the deck changes. So are `claims` (claims.mjs:
// his words against the record, drawn on the rail) and `counter`
// (counter.mjs: the tally's named series).
- // `rail` (rail.mjs: `{labels}`) likewise has no default to fill.
- unknownKeys(d, [...Object.keys(DECK_DEFAULTS), "finale", "claims", "counter", "rail"], w, errors);
+ // `rail` (rail.mjs: `{labels}`) likewise has no default to fill, nor
+ // `sectionTitle` (section-title.mjs: the current section's name).
+ unknownKeys(d, [...Object.keys(DECK_DEFAULTS), "finale", "claims", "counter", "rail", "sectionTitle"], w, errors);
deckChecked = true;
}
errors.push(...entry.validate(settingValue(chrome, entry), { render, chrome, deck: d, where: w }));
@@ -495,7 +510,28 @@ export function deckLayout(render, { tally = null, schedule = null } = {}) {
const titleBox = Math.round(titleSize * 1.2);
const gap = Math.round(titleSize * 0.3);
const block = titleBox + gap + sb.extra + subtitleBox;
- const titleY = Math.round(bodyTop + Math.max(0, (bodyH - block) / 2));
+ let titleY = Math.round(bodyTop + Math.max(0, (bodyH - block) / 2));
+ // The section title (`deck.sectionTitle`, modules/section-title.mjs): one
+ // line centred under the track, clear of the marker's ring, and between
+ // whatever stands at the deck's sides (the QR's cell, the tally). The text
+ // block moves down only by what the line needs; nothing else moves. Only
+ // when it is on, so a deck without it lays out as it always did.
+ const st = resolveSectionTitle(render);
+ let sectionTitle = null;
+ if (st) {
+ const y = trackY + Math.ceil(d.pip.activeSize / 2) + 6;
+ const height = Math.round(st.size * 1.3);
+ let lo = padX;
+ let hi = W - padX;
+ if (qr) hi = Math.min(hi, qr.x - 46 - 24);
+ if (tallyBox) {
+ if (tallyBox.x < W / 2) lo = Math.max(lo, tallyBox.x + tallyBox.width + 24);
+ else hi = Math.min(hi, tallyBox.x - 24);
+ }
+ const half = Math.max(0, Math.floor(Math.min(W / 2 - lo, hi - W / 2)));
+ sectionTitle = { x: Math.round(W / 2 - half), y, width: 2 * half, height, size: st.size };
+ titleY = Math.max(titleY, y + height + 2);
+ }
return {
width: W,
height: rect.height,
@@ -521,6 +557,8 @@ export function deckLayout(render, { tally = null, schedule = null } = {}) {
...(markerBand ? { markerBand: { y: 3 + claimRow, height: markerBand + 6, ...(rows > 1 ? { rows } : {}) } } : {}),
// Only with a goalpost: where its words stand (claimsLayout).
...(claimRow ? { claimBand: { y: 3, height: claimRow } } : {}),
+ // Only with the section title on: its line under the track.
+ ...(sectionTitle ? { sectionTitle } : {}),
};
}
diff --git a/umtool/report-to-video/modules/config-loader.mjs b/umtool/report-to-video/modules/config-loader.mjs
@@ -12,6 +12,7 @@
// modules.counter.marks -> each clip's marks (`claim` / `claims`, the series' id as verdict, `at`)
// modules.stamp -> render.chrome.factcheck.stamp (`series.<id>.label` -> the series' stampLabel)
// modules.rail -> render.chrome.deck.pip (spacing, pitch) + deck.markers (nodes and markers)
+// modules.section-title -> render.chrome.deck.sectionTitle (true, or first, size, opacity, fade, color)
// modules.chapter[] -> render.chrome.chapter.list
// modules.pair[] -> render.chrome.pair.pairs
// modules.status[] -> render.chrome.status.items
@@ -23,7 +24,7 @@
import { VERDICTS } from "yt-dlp-transcript-common/lib/report/verdicts.mjs";
import { mergePatch } from "../montage-styles.mjs";
-import { MARKER_LIMITS } from "./settings.mjs";
+import { MARKER_LIMITS, SECTION_TITLE_DEFAULTS, SECTION_TITLE_LIMITS } from "./settings.mjs";
import { CHAPTER_LIMITS, DATE_RE, PAIR_LIMITS, STATUS_LIMITS } from "./story-settings.mjs";
const isObj = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
@@ -125,6 +126,22 @@ export function moduleConfigToManifest(config, manifest) {
case "rail":
railOf(v, at, { deck, has, prev, say, notes });
break;
+ case "section-title": {
+ // The current section's name under the rail: true, or its settings.
+ if (typeof v === "boolean") { deck.sectionTitle = v; break; }
+ if (!isObj(v)) { say(at, "must be true, false or { first, size, opacity, fade, color }"); break; }
+ const s = {};
+ for (const [k, x] of Object.entries(v)) {
+ if (k === "first" && typeof x === "string") {
+ const one = x.replace(/\s+/g, " ").trim();
+ if (chars(one) > SECTION_TITLE_LIMITS.first) say(`${at}.first`, `shortened to ${SECTION_TITLE_LIMITS.first} characters`);
+ s.first = fit(one, SECTION_TITLE_LIMITS.first);
+ } else if (Object.hasOwn(SECTION_TITLE_DEFAULTS, k)) s[k] = x;
+ else say(`${at}.${k}`, `not a section title setting (${Object.keys(SECTION_TITLE_DEFAULTS).join(", ")})`);
+ }
+ deck.sectionTitle = s;
+ break;
+ }
case "chapter": {
const list = [];
(Array.isArray(v) ? v : []).forEach((c, i) => {
diff --git a/umtool/report-to-video/modules/index.mjs b/umtool/report-to-video/modules/index.mjs
@@ -29,12 +29,13 @@ import blur from "./blur.mjs";
import pair from "./pair.mjs";
import chapter from "./chapter.mjs";
import status from "./status.mjs";
+import sectionTitle from "./section-title.mjs";
export { assertRegion, defineModule, MODULE_KINDS, MODULE_SLOTS, PLAY_CLOCKS, REGION_PLACEMENTS };
/** Every module, by z (stack order), then id. */
export const MODULES = Object.freeze(
- [chart, shell, subtitle, qr, rail, counter, claims, feed, popupPosts, stamp, stats, fx, threads, flips, finale, teaser, intro, blur, pair, chapter, status]
+ [chart, shell, subtitle, qr, rail, sectionTitle, counter, claims, feed, popupPosts, stamp, stats, fx, threads, flips, finale, teaser, intro, blur, pair, chapter, status]
.sort((a, b) => a.z - b.z || a.id.localeCompare(b.id)),
);
diff --git a/umtool/report-to-video/modules/panel.mjs b/umtool/report-to-video/modules/panel.mjs
@@ -11,9 +11,10 @@
// under render.chrome) or updateRender (a look key: intro, blur).
//
// ENABLE / DISABLE: a module whose settings are an object of their own (the
-// story modules, the finale, the counter, the intro, the claim checks) is ON
-// while that object is in the manifest -- or its look preset -- and OFF when
-// it is removed. The deck's own parts are on with the deck.
+// story modules, the finale, the counter, the intro, the claim checks, the
+// section title) is ON while that object is in the manifest -- or its look
+// preset -- and OFF when it is removed (or, the section title, `false`). The
+// deck's other parts are on with the deck.
import { MODULES } from "./index.mjs";
const isObj = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
@@ -40,6 +41,7 @@ const TOGGLES = Object.freeze({
counter: { series: [{ id: "count", label: "Count" }] },
intro: { style: "boot-dark", site: "auto" },
claims: null,
+ "section-title": {},
});
/** Is this module toggled by its object's presence, and what does turning it on write? */
@@ -100,7 +102,8 @@ export function panelState(manifest, seen, problems = {}) {
}
const toggle = toggleOf(m);
const cfgRel = (m.configKey ?? "").split(".").slice(1).join(".");
- const enabled = toggle ? getPath(seen.render ?? {}, cfgRel) !== undefined : true;
+ const on = getPath(seen.render ?? {}, cfgRel);
+ const enabled = toggle ? on !== undefined && on !== false : true;
return {
id: m.id, title: m.title, summary: m.summary ?? "", kind: m.kind, slot: m.slot, z: m.z,
configKey: m.configKey, base, ui: uiOf(m), docs: m.docs?.heading ?? null,
@@ -138,7 +141,8 @@ export function panelWrite(manifest, id, { fields = {}, enabled } = {}) {
if (enabled === true) {
const t = toggleOf(m);
if (!t) throw new Error(`${id} is drawn with the deck: it is not switched on and off`);
- if (getPath(next, cfgRel) === undefined) next = setPath(next, cfgRel, structuredClone(t.on ?? {}));
+ const was = getPath(next, cfgRel);
+ if (was === undefined || was === false) next = setPath(next, cfgRel, structuredClone(t.on ?? {}));
}
const rel = base.split(".").slice(1).join(".");
for (const [k, v] of Object.entries(fields)) next = setPath(next, rel ? `${rel}.${k}` : k, v === "" ? null : v);
diff --git a/umtool/report-to-video/modules/rail.mjs b/umtool/report-to-video/modules/rail.mjs
@@ -36,7 +36,7 @@ export default defineModule({
configKey: "render.chrome.deck.pip",
configKeys: ["render.chrome.deck.markers", "render.chrome.deck.markerLayout", "render.chrome.deck.rail"],
defaults: { pip: DECK_DEFAULTS.pip, markers: DECK_DEFAULTS.markers, markerLayout: DECK_DEFAULTS.markerLayout },
- provides: ["rail.layout"],
+ provides: ["rail.layout", "rail.sections"],
validate: settingsOf("rail").validate,
resolve(render) {
const d = render?.chrome?.deck ?? {};
@@ -70,7 +70,7 @@ export default defineModule({
["`deck.pip.color`", "`accent` · `verdict` (a counted clip's pip takes its series' colour and shape) · `section` (every pip, the fuse and the marker's ring in the colour of the section it stands in: from one marker to the next, in that marker's `color`; fitted to 3:1 on the deck) · default `accent`", "`umtool look <p> deck.pip='{\"color\":\"verdict\"}'`"],
["`deck.pip.sectionColor0`", "the section before the first marker, with `color: \"section\"`: a `#hex` or a palette key (`fg`, `muted`, `accent`, `amber`, `dim`) · default the accent", "`umtool look <p> deck.pip='{\"color\":\"section\",\"sectionColor0\":\"#5fa8d3\"}'`"],
["`deck.markers[].label`", "optional: a marker with none (or `\"\"`) draws a tick at its boundary, no words, and takes no band over the track", "`umtool look <p> deck.markers='[{\"after\":\"c04\",\"color\":\"#e07a9a\"}]'`"],
- ["`deck.rail.labels`", "`false` draws every marker as a tick, no words, and no band over the track · default `true`", "`umtool look <p> deck.rail='{\"labels\":false}'`"],
+ ["`deck.rail.labels`", "`false` draws every marker as a tick, no words, and no band over the track (the current section's name can stand under the rail instead: [Section title](#section-title)) · default `true`","`umtool look <p> deck.rail='{\"labels\":false}'`"],
],
},
});
diff --git a/umtool/report-to-video/modules/rail.test.mjs b/umtool/report-to-video/modules/rail.test.mjs
@@ -47,5 +47,5 @@ test("rail settings: spacing, pitch, and the deck's other keys refused by name",
assert.equal(resolveDeck(render({})).pip.pitch, undefined, "no pitch unless set: the deck resolves as it did");
assert.equal(rail.resolve(render({ spacing: "pitch" })).pip.pitch, 28);
assert.equal(rail.validate, settingsOf("rail").validate);
- assert.deepEqual(SETTINGS.map((s) => s.id), ["stamp", "threads", "flips", "stats", "fx", "pair", "chapter", "status", "finale", "claims", "counter", "shell", "rail", "subtitle", "qr", "popup-posts"]);
+ assert.deepEqual(SETTINGS.map((s) => s.id), ["stamp", "threads", "flips", "stats", "fx", "pair", "chapter", "status", "finale", "claims", "counter", "shell", "rail", "section-title", "subtitle", "qr", "popup-posts"]);
});
diff --git a/umtool/report-to-video/modules/section-title.mjs b/umtool/report-to-video/modules/section-title.mjs
@@ -0,0 +1,62 @@
+// THE SECTION TITLE (module `section-title`, a part of the shell): the
+// CURRENT section's name -- what chapter of the cut this is -- on one quiet
+// line centred just under the rail (`render.chrome.deck.sectionTitle`). The
+// sections are the rail's (rail.mjs, deck.mjs railSections): the stretch
+// before the first marker, then one from each marker on; a section's title
+// is the label of the marker that opened it, `first` before any, and a
+// marker with no label shows nothing for its section. It crossfades as the
+// marker crosses into another section (chrome-deck.mjs
+// sectionTitleTimeline). Independent of `rail.labels`: a rail with no words
+// on its track can still say which section it is in, here.
+//
+// Drawn in the deck's page (its row is deckLayout's `sectionTitle`, between
+// the track and the clip's title; the title moves down only by what the line
+// needs), so it slides away with the deck over a card and its frames are the
+// shell's: each title is an item of the page, keyed only on the frames it is
+// up on. Absent or `false`, the deck is the one it always was.
+import { DECK_DEFAULTS, MARKER_PALETTE_KEYS, SECTION_TITLE_COLORS, SECTION_TITLE_DEFAULTS, SECTION_TITLE_LIMITS, settingsOf } from "./settings.mjs";
+import { defineModule } from "./contract.mjs";
+
+const L = SECTION_TITLE_LIMITS;
+
+export default defineModule({
+ id: "section-title",
+ version: 1,
+ z: 16,
+ kind: "part",
+ host: "shell",
+ slot: "inline",
+ title: "Section title",
+ summary: "The current section's name (the marker that opened it) on one quiet line under the rail.",
+ configKey: "render.chrome.deck.sectionTitle",
+ defaults: SECTION_TITLE_DEFAULTS,
+ deps: ["rail.sections"],
+ validate: settingsOf("section-title").validate,
+ resolve(render) {
+ const v = render?.chrome?.deck?.sectionTitle;
+ if (v === true) return { ...SECTION_TITLE_DEFAULTS };
+ if (!v || typeof v !== "object" || Array.isArray(v)) return null;
+ return { ...SECTION_TITLE_DEFAULTS, ...v, first: String(v.first ?? "").trim() };
+ },
+ ui: [
+ { key: "first", type: "text", label: "First section's title", default: "",
+ help: `the section before the first marker (at most ${L.first} characters); the others are their markers' labels` },
+ { key: "size", type: "number", min: L.size[0], max: L.size[1], step: 1, label: "Size (px)", default: SECTION_TITLE_DEFAULTS.size },
+ { key: "opacity", type: "number", min: L.opacity[0], max: L.opacity[1], step: 0.05, label: "Opacity", default: SECTION_TITLE_DEFAULTS.opacity },
+ { key: "fade", type: "number", min: L.fade[0], max: L.fade[1], step: 0.05, label: "Crossfade (s)", default: SECTION_TITLE_DEFAULTS.fade },
+ { key: "color", type: "color", label: "Colour", default: SECTION_TITLE_DEFAULTS.color,
+ help: `${SECTION_TITLE_COLORS.map((c) => `"${c}"`).join(" · ")} (its section's) · a #hex · ${MARKER_PALETTE_KEYS.join(", ")}` },
+ ],
+ docs: {
+ heading: "Section title",
+ intro: "The current section's name on one quiet line centred under the rail (`render.chrome.deck.sectionTitle`): the label of the marker that opened the section ([Rail](#rail)), `first` before any marker; a marker with no label shows nothing for its section. It crossfades as the rail's marker crosses into the next section, rides the deck away over a card, and is independent of `deck.rail.labels` -- the track can carry no words while this says where the cut is. Off unless set: absent or `false` draws the deck as it always was. The clip's title moves down only by what the line needs.",
+ rows: [
+ ["`deck.sectionTitle`", "`true` (on, every default) · `false` · an object of the keys below · default off", "`umtool look <p> deck.sectionTitle=true`"],
+ ["`deck.sectionTitle.first`", `the section before the first marker: a line of at most ${L.first} characters · default \`""\` (nothing)`, "`umtool look <p> deck.sectionTitle='{\"first\":\"Who she is\"}'`"],
+ ["`deck.sectionTitle.size`", `${L.size[0]}–${L.size[1]} px · default ${SECTION_TITLE_DEFAULTS.size} (a touch under the subtitle's ${Math.round(DECK_DEFAULTS.title.size * 0.48)})`, "`umtool look <p> deck.sectionTitle.size=20`"],
+ ["`deck.sectionTitle.opacity`", `${L.opacity[0]}–${L.opacity[1]} · default ${SECTION_TITLE_DEFAULTS.opacity}`, "`umtool look <p> deck.sectionTitle.opacity=0.7`"],
+ ["`deck.sectionTitle.fade`", `${L.fade[0]}–${L.fade[1]} s: the old title out over its first half, the new in over the second (0: a cut) · default ${SECTION_TITLE_DEFAULTS.fade}`, "`umtool look <p> deck.sectionTitle.fade=0.6`"],
+ ["`deck.sectionTitle.color`", `\`auto\` (the subtitle's muted grey, lifted toward the deck's fg only as far as it needs to read at 4.5:1 at that opacity) · \`section\` (its section's colour, fitted to 4.5:1) · a \`#hex\` · a palette key (${MARKER_PALETTE_KEYS.map((k) => `\`${k}\``).join(", ")}) · default \`auto\``, "`umtool look <p> deck.sectionTitle.color=section`"],
+ ],
+ },
+});
diff --git a/umtool/report-to-video/modules/settings.mjs b/umtool/report-to-video/modules/settings.mjs
@@ -131,6 +131,22 @@ export const PIP_PITCH = Object.freeze([8, 200]);
/** The pitch when `spacing` is "pitch" and `pip.pitch` is unset. */
export const PIP_PITCH_DEFAULT = 28;
+/**
+ * THE SECTION TITLE (module `section-title`, `deck.sectionTitle`): the
+ * current section's name -- the label of the marker that opened it, `first`
+ * before any -- on one quiet line centred under the rail. Off unless set
+ * (`true`, or an object); `false` is off. `color` "auto" is the subtitle's
+ * muted grey, lifted toward the deck's fg only as far as it needs to read
+ * (4.5:1 at the line's opacity; chrome-deck.mjs sectionTitleColor).
+ */
+export const SECTION_TITLE_DEFAULTS = Object.freeze({ first: "", size: 18, opacity: 0.85, fade: 0.4, color: "auto" });
+
+/** The section title's limits: `first`'s characters (a marker label's), size px, opacity, fade s. */
+export const SECTION_TITLE_LIMITS = Object.freeze({ first: 24, size: Object.freeze([12, 32]), opacity: Object.freeze([0.2, 1]), fade: Object.freeze([0, 2]) });
+
+/** The section title's colour words beside a #hex and a palette key: "auto" (the neutral text), "section" (its section's). */
+export const SECTION_TITLE_COLORS = Object.freeze(["auto", "section"]);
+
/** When a popup's posts come up (`posts.at`): the end of their clip, or its start. */
export const POST_AT = Object.freeze(["end", "start"]);
/** How posts are drawn (`posts.layout`): cards at the end of a clip, or a column for the whole cut. */
@@ -275,6 +291,33 @@ export function validateRailSettings(d, { where: w }) {
return errors;
}
+/**
+ * The section title (`deck.sectionTitle`): `true`/`false`, or `{ first?, size?,
+ * opacity?, fade?, color? }`. Absent or false: off.
+ */
+export function validateSectionTitleSettings(v, { where: w }) {
+ const at = `${w}.sectionTitle`;
+ if (v === undefined || typeof v === "boolean") return [];
+ if (!isObj(v)) return [`${at} must be true, false or { first, size, opacity, fade, color }`];
+ const errors = [];
+ for (const k of Object.keys(v)) {
+ if (!Object.hasOwn(SECTION_TITLE_DEFAULTS, k)) errors.push(`${at}.${k} is not a section title setting (${Object.keys(SECTION_TITLE_DEFAULTS).join(", ")})`);
+ }
+ const L = SECTION_TITLE_LIMITS;
+ if (v.first !== undefined) {
+ if (typeof v.first !== "string") errors.push(`${at}.first must be a word or two (or "" for none)`);
+ else if (/[\r\n]/.test(v.first)) errors.push(`${at}.first must be one line`);
+ else if ([...v.first.trim()].length > L.first) errors.push(`${at}.first is ${[...v.first.trim()].length} characters (at most ${L.first})`);
+ }
+ if (v.size !== undefined && !numIn(v.size, L.size[0], L.size[1])) errors.push(`${at}.size must be from ${L.size[0]} to ${L.size[1]} pixels`);
+ if (v.opacity !== undefined && !numIn(v.opacity, L.opacity[0], L.opacity[1])) errors.push(`${at}.opacity must be from ${L.opacity[0]} to ${L.opacity[1]}`);
+ if (v.fade !== undefined && !numIn(v.fade, L.fade[0], L.fade[1])) errors.push(`${at}.fade must be from ${L.fade[0]} to ${L.fade[1]} seconds`);
+ if (v.color !== undefined && !(SECTION_TITLE_COLORS.includes(v.color) || isMarkerColor(v.color))) {
+ errors.push(`${at}.color must be "auto", "section", a #hex colour or one of ${MARKER_PALETTE_KEYS.join(", ")}`);
+ }
+ return errors;
+}
+
/** The subtitle: its parts, its date's format, its lines and what heads the second. */
export function validateSubtitleSettings(d, { where: w }) {
const errors = [];
@@ -399,6 +442,7 @@ export const SETTINGS = Object.freeze([
}) },
{ id: "shell", key: "deck", configKey: "render.chrome.deck", deck: true, whole: true, validate: validateShellSettings },
{ id: "rail", key: "deck", configKey: "render.chrome.deck.pip", deck: true, whole: true, validate: validateRailSettings },
+ { id: "section-title", key: "deck.sectionTitle", configKey: "render.chrome.deck.sectionTitle", deck: true, validate: validateSectionTitleSettings },
{ id: "subtitle", key: "deck", configKey: "render.chrome.deck.subtitle", deck: true, whole: true, validate: validateSubtitleSettings },
{ id: "qr", key: "deck", configKey: "render.chrome.deck.qr", deck: true, whole: true, validate: validateQrSettings },
{ id: "popup-posts", key: "deck", configKey: "render.chrome.deck.posts", deck: true, whole: true, validate: validatePostsSettings },
diff --git a/umtool/report-to-video/section-title.test.mjs b/umtool/report-to-video/section-title.test.mjs
@@ -0,0 +1,298 @@
+// The section title (module `section-title`, `deck.sectionTitle`): the
+// current section's name on one quiet line under the rail. Its timeline
+// (which title is up when, the crossfade), its settings, its row in the
+// deck's layout, its frame keys, the module's registration, and that a deck
+// without it is the deck it always was -- then a still, when the tools are here.
+//
+// Run with: pnpm test:scripts
+import assert from "node:assert/strict";
+import { spawnSync } from "node:child_process";
+import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
+import { tmpdir } from "node:os";
+import path from "node:path";
+import test from "node:test";
+import { fileURLToPath } from "node:url";
+
+import { deckCues, deckHtml, sectionTitleAt, sectionTitleColor, sectionTitleTimeline } from "./chrome-deck.mjs";
+import { contrast } from "./chrome-intro.mjs";
+import { cueTime, deckLayout, resolveSectionTitle, validateChrome } from "./deck.mjs";
+import { frameKeys } from "./frame-keys.mjs";
+import { moduleConfigToManifest } from "./modules/config-loader.mjs";
+import { moduleById, partsOf } from "./modules/index.mjs";
+import { panelState, panelWrite } from "./modules/panel.mjs";
+import sectionTitle from "./modules/section-title.mjs";
+
+const HERE = path.dirname(fileURLToPath(import.meta.url));
+const PALETTE = { bg: "#12100c", fg: "#f6f1e6", muted: "#a2957f", accent: "#c8752a", amber: "#ffc860" };
+const CHROME = { engine: "hyperframes", layout: "deck" };
+const BASE = { width: 1920, height: 1080, fps: 30, transition: 0.5, palette: PALETTE };
+const MARKERS = [
+ { after: "c0", label: "Second", color: "#e07a9a" },
+ { after: "c1", color: "#5fa8d3" }, // unlabelled: nothing for its section
+ { after: "c2", label: "Fourth", color: "#7fdc9a" },
+ { after: "c3", label: "Fourth", color: "#ffc861" }, // the same words: one run
+];
+const renderWith = (deck = {}) => ({ ...BASE, chrome: { ...CHROME, deck: { markers: MARKERS, rail: { labels: false }, ...deck } } });
+const ON = (st = { first: "First" }, extra = {}) => renderWith({ sectionTitle: st, ...extra });
+const FONTS = { regular: "assets/DeckSans.ttf", bold: "assets/DeckSansBold.ttf" };
+
+/** Five clips and a card between c2 and c3 (the deck slides away over it). */
+function schedule() {
+ const seg = (id, type, start, duration, extra = {}) => ({
+ id, type, start, duration, end: start + duration, title: `Clip ${id}`, subtitle: "Somebody · Oct 1, 2026", qrUrl: null, hideDeck: false, ...extra,
+ });
+ return {
+ version: 1, kind: "deck", estimated: true, fps: 30, transition: 0.5, total: 52.5, multiChannel: false,
+ segments: [
+ seg("c0", "clip", 0, 10), seg("c1", "clip", 9.5, 10), seg("c2", "clip", 19, 10),
+ seg("k1", "card", 28.5, 5, { hideDeck: true }),
+ seg("c3", "clip", 33, 10), seg("c4", "clip", 42.5, 10),
+ ],
+ };
+}
+
+test("the timeline: first, then each marker's label as the marker crosses into its section; unlabelled is nothing; one run for the same words", () => {
+ const s = schedule();
+ const tl = sectionTitleTimeline(s, ON());
+ assert.deepEqual(tl.titles.map((t) => t.label), ["First", "Second", "Fourth"]);
+ assert.equal(tl.init, 0);
+ // The handover's middle (c1 starts at 9.5, the dissolve is 0.5); into c3 the deck rises on it: instant.
+ assert.deepEqual(tl.changes, [
+ { at: 9.75, from: 0, to: 1, instant: false },
+ { at: 19.25, from: 1, to: null, instant: false },
+ { at: 33, from: null, to: 2, instant: true },
+ ]);
+ const at = (t) => sectionTitleAt(tl, t);
+ assert.equal(at(0), "First");
+ assert.equal(at(9.7), "First");
+ assert.equal(at(9.75), "Second");
+ assert.equal(at(15), "Second");
+ assert.equal(at(25), "", "an unlabelled marker's section shows nothing");
+ assert.equal(at(30), "");
+ assert.equal(at(35), "Fourth");
+ assert.equal(at(50), "Fourth", "the same words after the next marker: no change");
+ // No `first`: the first section shows nothing.
+ const bare = sectionTitleTimeline(s, ON(true));
+ assert.equal(bare.init, null);
+ assert.equal(sectionTitleAt(bare, 1), "");
+ assert.equal(sectionTitleAt(bare, 12), "Second");
+ // Off: no timeline.
+ assert.equal(sectionTitleTimeline(s, renderWith()), null);
+ assert.equal(sectionTitleTimeline(s, renderWith({ sectionTitle: false })), null);
+});
+
+test("the cues: the old out over the fade's first half, the new in over its second; an instant as the deck rises", () => {
+ const s = schedule();
+ const { init, cues, sectionTitle: tl } = deckCues(s, ON());
+ assert.deepEqual(init.st0, { opacity: 0.85 });
+ assert.deepEqual(init.st1, { opacity: 0 });
+ assert.deepEqual(init.st2, { opacity: 0 });
+ const st = cues.filter((c) => /^st\d+$/.test(c.k)).map(({ k, at, dur, from, to }) => ({ k, at, dur, from: from.opacity, to: to.opacity }));
+ assert.deepEqual(st, [
+ { k: "st0", at: cueTime(9.55, 30), dur: 0.2, from: 0.85, to: 0 },
+ { k: "st1", at: cueTime(9.75, 30), dur: 0.2, from: 0, to: 0.85 },
+ { k: "st1", at: cueTime(19.05, 30), dur: 0.2, from: 0.85, to: 0 },
+ { k: "st2", at: 33, dur: 0.001, from: 0, to: 0.85 },
+ ]);
+ assert.equal(tl.titles.length, 3);
+ // fade and opacity are the settings'; a fade of 0 is a cut.
+ const cut = deckCues(s, ON({ first: "First", fade: 0, opacity: 0.6 })).cues.filter((c) => c.k === "st0");
+ assert.deepEqual(cut.map((c) => [c.at, c.dur, c.to.opacity]), [[9.75, 0.001, 0]]);
+ const slow = deckCues(s, ON({ first: "First", fade: 1 })).cues.find((c) => c.k === "st1");
+ assert.deepEqual([slow.at, slow.dur], [9.75, 0.5]);
+});
+
+test("settings: true, false and the object validate; bad values refused in the build's words", () => {
+ const ok = (deck) => validateChrome({ ...CHROME, deck }, BASE);
+ assert.deepEqual(ok({ sectionTitle: true }), []);
+ assert.deepEqual(ok({ sectionTitle: false }), []);
+ assert.deepEqual(ok({ sectionTitle: { first: "Who she is", size: 20, opacity: 0.7, fade: 0.6, color: "section" } }), []);
+ assert.deepEqual(ok({ sectionTitle: { color: "#9fb3c8" } }), []);
+ assert.deepEqual(ok({ sectionTitle: { color: "fg" } }), []);
+ const bad = (st) => ok({ sectionTitle: st }).join(" | ");
+ assert.match(bad("yes"), /sectionTitle must be true, false or \{ first, size, opacity, fade, color \}/);
+ assert.match(bad({ first: "x".repeat(25) }), /sectionTitle\.first is 25 characters \(at most 24\)/);
+ assert.match(bad({ first: "two\nlines" }), /sectionTitle\.first must be one line/);
+ assert.match(bad({ first: 3 }), /sectionTitle\.first must be a word or two/);
+ assert.match(bad({ size: 40 }), /sectionTitle\.size must be from 12 to 32 pixels/);
+ assert.match(bad({ opacity: 0 }), /sectionTitle\.opacity must be from 0\.2 to 1/);
+ assert.match(bad({ fade: 3 }), /sectionTitle\.fade must be from 0 to 2 seconds/);
+ assert.match(bad({ color: "pink" }), /sectionTitle\.color must be "auto", "section", a #hex colour or one of fg, muted, accent, amber, dim/);
+ assert.match(bad({ label: "x" }), /sectionTitle\.label is not a section title setting \(first, size, opacity, fade, color\)/);
+ // The resolved settings.
+ assert.equal(resolveSectionTitle(renderWith()), null);
+ assert.equal(resolveSectionTitle(renderWith({ sectionTitle: false })), null);
+ assert.deepEqual(resolveSectionTitle(ON(true)), { first: "", size: 18, opacity: 0.85, fade: 0.4, color: "auto" });
+ assert.deepEqual(resolveSectionTitle(ON({ first: " A ", size: 22 })), { first: "A", size: 22, opacity: 0.85, fade: 0.4, color: "auto" });
+});
+
+test("the layout: one row under the track, clear of the marker's ring and the QR's cell; the title moves down only by what it needs", () => {
+ const off = deckLayout(renderWith());
+ const on = deckLayout(ON());
+ const row = on.sectionTitle;
+ assert.equal(off.sectionTitle, undefined);
+ assert.equal(row.y, on.pipTrack.y + 6 + 6, "the ring (activeSize 12: 6 px) and 6 px of air");
+ assert.equal(row.height, Math.round(18 * 1.3));
+ assert.equal(row.x + row.width / 2, 960, "centred");
+ assert.ok(row.x + row.width <= on.qr.x - 46 - 24, "short of the QR's cell");
+ assert.equal(on.text.titleY, Math.max(off.text.titleY, row.y + row.height + 2));
+ // Nothing else moves.
+ assert.deepEqual(on.qr, off.qr);
+ assert.deepEqual(on.pipTrack, off.pipTrack);
+ assert.equal(on.text.x, off.text.x);
+ // A bigger line takes more room; the title follows it.
+ const big = deckLayout(ON({ size: 28 }));
+ assert.ok(big.text.titleY > on.text.titleY);
+});
+
+test("the colour: auto is the quietest neutral that reads at the line's opacity; section is the section's, fitted to 4.5:1", () => {
+ const s = schedule();
+ const ground = "#231e19";
+ const tl = sectionTitleTimeline(s, ON());
+ const auto = sectionTitleColor(tl.titles[0], tl, PALETTE, ground);
+ const blend = (c, a) => {
+ const p = (h) => [1, 3, 5].map((i) => Number.parseInt(h.slice(i, i + 2), 16));
+ const [x, y] = [p(ground), p(c)];
+ return `#${x.map((v, i) => Math.round(v + (y[i] - v) * a).toString(16).padStart(2, "0")).join("")}`;
+ };
+ assert.ok(contrast(blend(auto, 0.85), ground) >= 4.5);
+ assert.notEqual(auto, PALETTE.fg, "not the title's own white");
+ // On a ground the muted grey reads on as it is, it is the muted grey.
+ assert.equal(sectionTitleColor(tl.titles[0], tl, PALETTE, "#000000"), PALETTE.muted);
+ const sec = sectionTitleTimeline(s, ON({ first: "First", color: "section" }));
+ assert.equal(sec.titles[1].color, "#e07a9a");
+ assert.ok(contrast(sectionTitleColor(sec.titles[1], sec, PALETTE, ground), ground) >= 4.5);
+ assert.equal(sectionTitleColor(tl.titles[0], { ...tl, color: "#123456" }, PALETTE, ground), "#123456");
+ assert.equal(sectionTitleColor(tl.titles[0], { ...tl, color: "amber" }, PALETTE, ground), PALETTE.amber);
+});
+
+test("the page: a line per title in the panel under the track, its words escaped; absent or false is the deck it always was, byte for byte", () => {
+ const s = schedule();
+ const html = deckHtml(s, ON({ first: "<b>&</b>" }), { fonts: FONTS });
+ const lines = html.match(/<div class="stitle" data-k="st\d" style="color:#[0-9a-f]{6}">[^<]*<\/div>/g);
+ assert.equal(lines.length, 3);
+ assert.ok(html.includes("><b>&</b></div>"));
+ const panel = html.indexOf('data-k="panel"');
+ const track = html.indexOf('<div class="track">');
+ const line = html.indexOf('class="stitle"');
+ assert.ok(panel < track && track < line && line < html.indexOf('data-seg="c0"'), "in the panel (it slides with it), after the track");
+ assert.match(html, /\.stitle \{ position: absolute; left: 268px; top: 28px; width: 1384px; height: 23px;/);
+ assert.match(html, /text-overflow: ellipsis;/);
+ // Absent, false: identical pages, cues and layout -- no trace of the line.
+ const absent = renderWith();
+ const off = renderWith({ sectionTitle: false });
+ for (const sch of [s, { ...s, segments: s.segments.map((x) => ({ ...x, hideDeck: false })) }]) {
+ const a = deckHtml(sch, absent, { fonts: FONTS });
+ assert.equal(deckHtml(sch, off, { fonts: FONTS }), a);
+ assert.doesNotMatch(a, /stitle|data-k="st\d/);
+ assert.deepEqual(deckCues(sch, off), deckCues(sch, absent));
+ assert.equal(deckCues(sch, absent).sectionTitle, undefined);
+ }
+ assert.deepEqual(deckLayout(off), deckLayout(absent));
+ // Items: each line is one, gated on its own opacity.
+ const items = [];
+ deckHtml(s, ON(), { fonts: FONTS, items });
+ const st = items.filter((i) => i.key.startsWith("st"));
+ assert.deepEqual(st.map((i) => [i.key, i.gate]), [["st0", ["st0", "opacity"]], ["st1", ["st1", "opacity"]], ["st2", ["st2", "opacity"]]]);
+});
+
+test("frame keys: the line changes keys only around its boundaries, and a renamed section only where it is up", () => {
+ const s = schedule();
+ const frames = Math.round(s.total * 30);
+ const keys = (render) => {
+ const items = [];
+ const html = deckHtml(s, render, { fonts: FONTS, items });
+ return frameKeys({ html, region: "deck", fps: 30, frames, version: "v", items });
+ };
+ const off = keys(renderWith());
+ const on = keys(ON());
+ assert.equal(on.length, frames);
+ // Where the line's key moves from frame to frame and the deck's does not:
+ // only inside a crossfade (or on the frame after it lands).
+ const fades = [[9.55, 9.95], [19.05, 19.25], [33, 33.001]];
+ const inFade = (f) => fades.some(([a, b]) => f / 30 >= a - 1 / 30 && f / 30 <= b + 1 / 30);
+ // Outside them a frame repeats the one before exactly when the deck's does
+ // (the crossfades fall in the deck's own handovers, which move every frame).
+ for (let f = 1; f < frames; f += 1) {
+ if (inFade(f)) continue;
+ assert.equal(on[f] === on[f - 1], off[f] === off[f - 1], `frame ${f} (${(f / 30).toFixed(3)} s) moved outside a crossfade`);
+ }
+ // Renaming the second section: the frames it is up on change, and no other.
+ const renamed = keys(ON({ first: "First" }, { markers: MARKERS.map((m) => (m.label === "Second" ? { ...m, label: "Segundo" } : m)) }));
+ const differ = [];
+ for (let f = 0; f < frames; f += 1) if (renamed[f] !== on[f]) differ.push(f / 30);
+ assert.ok(differ.length > 0);
+ assert.ok(differ.every((t) => t >= 9.75 - 1e-6 && t <= 19.25 + 1e-6), `changed at ${differ[0]}..${differ.at(-1)}`);
+ assert.ok(differ.length >= Math.floor((19.05 - 9.95) * 30), "every frame it is up on");
+ // Renaming the first changes only its own frames.
+ const first = keys(ON({ first: "Opening" }));
+ const d1 = [];
+ for (let f = 0; f < frames; f += 1) if (first[f] !== on[f]) d1.push(f / 30);
+ assert.ok(d1.length && d1.every((t) => t < 9.75 + 1e-6));
+});
+
+test("the module: a part of the deck, registered, its home and ui; module-config and the panel switch it on", () => {
+ const m = moduleById("section-title");
+ assert.equal(m, sectionTitle);
+ assert.equal(m.kind, "part");
+ assert.equal(m.host, "shell");
+ assert.ok(partsOf("shell").includes(m));
+ assert.equal(m.configKey, "render.chrome.deck.sectionTitle");
+ assert.deepEqual(m.deps, ["rail.sections"]);
+ assert.ok(moduleById("rail").provides.includes("rail.sections"));
+ assert.deepEqual(m.ui.map((u) => u.key), ["first", "size", "opacity", "fade", "color"]);
+ assert.equal(m.resolve(renderWith()), null);
+ assert.deepEqual(m.resolve(ON(true)), resolveSectionTitle(ON(true)));
+ assert.deepEqual(m.validate({ size: 99 }, { where: "render.chrome.deck" }), ["render.chrome.deck.sectionTitle.size must be from 12 to 32 pixels"]);
+ // module-config.json: `modules.section-title`.
+ const manifest = { timeline: [{ id: "c0", type: "clip" }], render: { chrome: { ...CHROME, deck: {} } } };
+ const { patch, unmapped } = moduleConfigToManifest({ modules: { "section-title": { first: "A very long first section title", size: 20, glow: true } } }, manifest);
+ assert.deepEqual(patch.render.chrome.deck.sectionTitle, { first: "A very long first secti…", size: 20 });
+ assert.deepEqual(unmapped, [
+ "modules.section-title.first: shortened to 24 characters",
+ "modules.section-title.glow: not a section title setting (first, size, opacity, fade, color)",
+ ]);
+ assert.equal(moduleConfigToManifest({ modules: { "section-title": true } }, manifest).patch.render.chrome.deck.sectionTitle, true);
+ // The generic panel: off until switched on; on writes {}; false reads as off.
+ const state = (render) => panelState({ render }, { render }).find((x) => x.id === "section-title");
+ assert.equal(state(manifest.render).enabled, false);
+ assert.equal(state(ON(false)).enabled, false);
+ assert.equal(state(ON()).enabled, true);
+ assert.deepEqual(panelWrite(manifest, "section-title", { enabled: true }).chrome.deck.sectionTitle, {});
+ assert.deepEqual(panelWrite({ render: ON(false) }, "section-title", { enabled: true, fields: { first: "Who" } }).chrome.deck.sectionTitle, { first: "Who" });
+ assert.equal(panelWrite({ render: ON() }, "section-title", { enabled: false }).chrome.deck.sectionTitle, undefined);
+});
+
+const haveTools = ["qrencode", "magick"].every((b) => spawnSync(b, [b === "magick" ? "-version" : "-V"], { stdio: "ignore" }).status === 0);
+const haveChromium = haveTools && spawnSync(process.env.CHROME ?? "/usr/bin/chromium", ["--version"], { stdio: "ignore" }).status === 0;
+
+test("a still: the line's ink is centred in its row under the rail; without it the row is the panel's ground", { skip: !haveChromium }, async () => {
+ const { composeChrome } = await import("./compose-chrome.mjs");
+ const dir = mkdtempSync(path.join(tmpdir(), "section-title-"));
+ try {
+ const fonts = { fontRegular: path.join(HERE, "fonts", "IBMPlexMono-Regular.ttf"), fontBold: path.join(HERE, "fonts", "IBMPlexMono-Bold.ttf") };
+ const inkOf = async (render, name) => {
+ const manifestPath = path.join(dir, `${name}.manifest.json`);
+ writeFileSync(manifestPath, JSON.stringify({ slug: "t", title: "t", provenance: {}, render: { ...render, ...fonts }, timeline: [] }));
+ const png = path.join(dir, `${name}.png`);
+ await composeChrome({ manifestPath, region: "deck", schedule: schedule(), still: 14, png, outDir: path.join(dir, `out-${name}`) });
+ const row = deckLayout(ON()).sectionTitle;
+ const raw = spawnSync("magick", [png, "-crop", `${row.width}x${row.height}+${row.x}+${row.y}`, "+repage", "-colorspace", "gray", "-depth", "8", "gray:-"], { maxBuffer: 1 << 24 }).stdout;
+ const ref = raw[0];
+ const cols = [];
+ for (let x = 0; x < row.width; x += 1) {
+ for (let y = 0; y < row.height; y += 1) if (raw[y * row.width + x] - ref > 40) { cols.push(x); break; }
+ }
+ return { cols, row };
+ };
+ const { cols, row } = await inkOf(ON(), "on");
+ assert.ok(cols.length > 20, `ink in ${cols.length} columns`);
+ const mid = (Math.min(...cols) + Math.max(...cols)) / 2;
+ assert.ok(Math.abs(mid - row.width / 2) <= 3, `centred: ${mid} vs ${row.width / 2}`);
+ const none = await inkOf(renderWith(), "off");
+ // Off, the marker (on c1's pip, under the row's left part) may reach in; no words do.
+ assert.ok(none.cols.filter((x) => Math.abs(x - row.width / 2) < 120).length === 0, "no words in the middle");
+ } finally {
+ rmSync(dir, { recursive: true, force: true });
+ }
+});