commit 8d6ca18c87f91132916ce00f31b9d1c3077f9c9c
parent e1e8b7aebf4305bbbe4a26b13dd23064e2ee30d0
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Fri, 6 Nov 2026 14:42:20 -0500
Merge main into lane/housekeeping (band-shelf) before landing
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
33 files changed, 1261 insertions(+), 86 deletions(-)
diff --git a/umtool/bin/umtool.mjs b/umtool/bin/umtool.mjs
@@ -911,6 +911,7 @@ function usage() {
" mark.remove=<id> mark.verdict=<verdict> marks=<json> (≤ 8, each its own stamp and count)",
" · audio.offset (ms, + later) audio.gain (dB) audio.fadeIn audio.fadeOut",
" · hideModules=diet,streak (those modules hidden over the entry's span; any entry)",
+ " · shelfNote='words' (a line on the shelf over the entry's span; any entry)",
" --take <t>: the entry knobs into the take's patch, the project's manifest untouched",
" umtool look <project> key=value … the cut's knobs: factcheck.stamp.scale|motion|opacity|seconds,",
" factcheck.verdicts.<V>.stampLabel|label|color, deck.markers=<json>, deck.markerLayout,",
diff --git a/umtool/docs/knobs.md b/umtool/docs/knobs.md
@@ -36,6 +36,7 @@ that generates it ([notes.md](notes.md)).
| `layout` — `finale`: the deck's finale layout for this clip (`render.chrome.deck.finale`); `clip` is the default | — | `umtool set <p> <clip> layout=finale` | — |
| `chat` — `on`: the clip's live chat (its video's `live_chat.cues.json`, for the clip's source span, timed through its gaps) in a column beside the footage; `off` or `chat=` (the default): none. A video with no chat draws nothing and the build log says so ([Live chat](#live-chat)) | — | `umtool set <p> <clip> chat=on` (`chat=` clears it) | — |
| `hideModules` — `["diet","streak",…]`: the measure extras (`goals` `peak` `promise` `diet` `streak`) hidden over THIS entry's span, each with its own fade, whatever it would otherwise do there -- for text in the footage no dodge can know of (a DM screenshot's refund email under the diet badge). Any entry, a post item too; an id no entry can hide is refused | — | `umtool set <p> <entry> hideModules=diet,streak` (`hideModules=` clears it; `--take <t>` writes the take's patch, the project's manifest untouched) | — |
+| `shelfNote` — one line of at most 80 characters on the shelf (`render.chrome.deck.shelf`, its `note` slot) over THIS entry's span, coming and going with it -- a short fact beside the footage for any video, with or without a measure slice ([Shelf](#shelf)). Any entry, a post item too | — | `umtool set <p> <entry> shelfNote='Weighed in on camera'` (`shelfNote=` clears it; `--take <t>` writes the take's patch) | — |
| `fx.zoom` — `{shot, focus, at?, hold?}`: a screenshot (a file in the project; a bare name under its `shots/` is written as `shots/<name>`) that comes up over the footage and pushes in on `focus` (`[left, top, right, bottom]`, fractions of the shot) — drawn once `render.chrome.fx.zoom` is on ([Effects](#effects)). **How long it stays**: up 0.2 s into the clip's clean span (rising in over 0.38 s), its focus box drawn 0.55 s later, the push at `at` (seconds into the clip; default as soon as the box has drawn) over 1 s, then a slow drift on the detail; it leaves with a 0.3 s fade 0.3 s before the clip's clean span ends — or, with `hold` (0.5–10 s), that long after the push lands (never past the clip's own leave) | — | `umtool set <p> <clip> fx.zoom='{"shot":"shots/x.png","focus":[0.1,0.2,0.9,0.4],"at":5.9,"hold":4}'` (`fx.zoom=` clears it) | `PUT /api/report/window {project, clip, "fx.zoom": {…} \| null}` |
| `fx.receipts`, `fx.punch`, `fx.quote`, `fx.punchIn`, `fx.speakers` — the clip's other effect fields (`[{shot, mark?, at?, hold?, label?}]` 1–4, `at` the source second a receipt flies in at (default: as the clip comes up), `hold` 0.5–10 s it stays once landed (on every one: they leave then, not with the clip), `label` a line of at most 80 characters in a band under the screenshot (when it was taken, what it is); the words to punch; `false`: no line; 1–8 source seconds inside the clip; `[{at, who: 0\|1}]`), each inert until its effect is on; `fx` is all of them at once. Checked by the build's own `validateFxEntries` | — | `fx.punch="the words"` `fx.punchIn='[231.4]'` · `fx='{…}'` sets them all, `fx=` clears every one | `PUT /api/report/window {project, clip, fx}` (or one `"fx.<field>"`) |
| `gaps` — `[{from, to}]`, SOURCE seconds cut out of the clip's middle: it renders as ONE segment of jump cuts (one pip, one card), not two clips with a crossfade ([below](#gaps-inside-a-clip)) | clip bench (Edit this clip), the waveform: **Select a gap** (`g`) or Alt + drag a span, **Cut gap** (`g`), **Hear it**; a click on a gap's band puts it back (`G`: the one at the playhead); **Undo** | `umtool window <p> <clip> --gap 12.3-15.1` (repeatable) · `--gap-remove 12.3` · `--gaps '12.3-15.1,20-20.6'` (`--gaps ''` clears) · `umtool set <p> <clip> gap.add=12.3-15.1 gap.remove=12.3 gaps=` | `PUT /api/report/window {project, clip, token, gapAdd \| gapRemove \| gaps}` |
@@ -1511,6 +1512,7 @@ filter. A knob absent is its default, and a module whose knobs are all absent dr
| [Then and now (pair)](#then-and-now-pair) `pair` | Two clips on one subject, each with its date: a then \| now strip (or a then→now card) with the pair's caption. (a page over the whole cut) | `render.chrome.pair` |
| [Status ledger](#status-ledger) `status` | A row per item -- announced, then followed up or not -- filling a column as the cut plays. (a page over the whole cut) | `render.chrome.status` |
| [Effects](#effects) `fx` | Overlays on the picture: receipts, a zoom, a scrubber, captions. (a page over the whole cut) | `render.chrome.fx` |
+| [Shelf](#shelf) `shelf` | A strip cleared under (or over) the footage for the diet's dated tags, the streak chain, a goal stack or an entry's note -- nothing on it stands on the picture. (a page over the whole cut) | `render.chrome.deck.shelf` |
| [Streak chain](#streak-chain) `streak` | A chain per run along the in-record dates, cracked with its length when the run ends; past runs dimmed in a row. (a page over the whole cut) | `render.chrome.deck.streak` |
| [Diet badge](#diet-badge) `diet` | The diet he names as a stamp that slams on at each change, with its number; "No diet" when the state says so. (a page over the whole cut) | `render.chrome.deck.diet` |
| [Moving start](#moving-start) `peak` | The starting weight as he retells it: a tick per telling on a small scale, a count per repeat, the drift bracketed. (a page over the whole cut) | `render.chrome.deck.peak` |
@@ -1535,7 +1537,7 @@ it can be seeked. `POST /api/report/chrome/preview` returns every such module th
build's predicate) as `layers: [{id, z, region, clock, ready, geometry, src | windows}]`; the client lays them
by z over the deck's page, a whole-cut page for the whole cut, a window module's page only inside each window.
-Declaring `play`: `stats`, `pair`, `status`, `fx`, `streak`, `diet`, `peak`, `goals`, `threads`, `dial`, `odometer`, `trail`, `flips`, `chapter`, `dial-finale`, `promise`.
+Declaring `play`: `stats`, `pair`, `status`, `fx`, `shelf`, `streak`, `diet`, `peak`, `goals`, `threads`, `dial`, `odometer`, `trail`, `flips`, `chapter`, `dial-finale`, `promise`.
Still drawn by their own paths (the response's `src`, `feed`, `posts`, `stamp` and `finale` keys), and what moving
each onto `play` needs: the deck (`shell`) -- its typed words patched in live (`deck:text`) and the `deck:ready`
@@ -1560,13 +1562,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
@@ -1740,6 +1742,18 @@ Overlays on the picture -- receipts, a zoom, the scrubber, a kinetic quote, punc
| beside popup posts that move the footage (`deck.posts.shift`) | the effects are drawn over the footage box where it stays, so an effect on screen WHILE the posts hold the footage aside is refused, naming both and their seconds — a zoom, receipts, a quote or a punch-in on its own clip's span; a whip, glitch or THEN/NOW wipe around its cut; the scrubber and the odometer over every clip (so beside any shift). A persisting bar holds it aside from its first post to its glide back. Apart in time, both are drawn. `umtool check` reads the estimated schedule; the build checks again on the measured one before any chrome is drawn | `deck.posts.shift=false`, the feed, or move one of them |
| the zoom's timing (`fx.zoom.at`, `.hold`) | up 0.2 s into the clip's clean span (the card rises in over 0.38 s, `back.out`); its focus box draws 0.55 s later (0.45 s); it pushes in on the box at `at` — seconds into the clip, default as soon as the box has drawn — over 1 s (`power2.inOut`), then drifts slowly on the detail. It leaves with a 0.3 s fade 0.3 s before the clip's clean span ends, or with `hold` (0.5–10 s) that long after the push lands (never past the clip's own leave) | `fx.zoom='{…,"hold":4}'` |
+### Shelf
+
+A strip of the frame cleared beside the footage (`render.chrome.deck.shelf`, shelf-settings.mjs): the footage moves to the frame's top, `railGap` (24 px) in (`side: "below"`), or down onto the deck (`"above"`), and what it leaves -- as wide as the footage, 24 px clear of it and of the frame's edge or the deck -- is the shelf (beside the instruments' column, 1248×116 at (24, 750)). Everything that reads the footage box (the instruments, the posts, the chapter band, the finale, Play) follows it. Its occupants stand in it left to right in `items` order, `gap` apart, each at its own width scaled to the shelf's height (all a size down together when they would not fit): the measure extras that take `position: "shelf"` -- `diet` (its dated tags by default: `deck.diet.form`), `streak`, `goals`, `peak` -- and `note`, an entry's `shelfNote` in the width left (a chip that comes and goes with its entry; at least 160 px). Nothing covers the shelf, so its occupants never dodge a post card or a chapter band (an entry's `hideModules` still hides one). It needs 72 px of room or the deck refuses, naming the way out (a smaller `footageScale`, or `subtitle.lines 1`): with the instruments' column it is 116 px, 77 with `subtitle.lines: 2`; full-width footage at the default 0.82 leaves none. Off (absent, `false`), the footage stands where it always did.
+
+| Knob | Range · default | From a terminal |
+|---|---|---|
+| `deck.shelf` | `true` · `false` · `{show, side, items, gap, finale}` · default off | `umtool look <p> deck.shelf=true deck.diet.position=shelf deck.streak.position=shelf` |
+| `deck.shelf.side` | `below` (the footage at the top) · `above` (the footage on the deck) · default `below` | `umtool look <p> deck.shelf.side=above` |
+| `deck.shelf.items` | a list of distinct `diet` `streak` `goals` `peak` `note` · default the measure extras whose `position` is `shelf`, then `note`; an extra listed here is on the shelf, and one whose position is `shelf` must be listed | `umtool look <p> deck.shelf.items='["diet","streak"]'` |
+| `deck.shelf.gap`, `.finale` | 0–64 design px · `hide` `show` · default 16, `hide` (its occupants hide over the finale with it) | `umtool look <p> deck.shelf.finale=show` |
+| a timeline entry's `shelfNote` | one line of at most 80 characters, shown in the shelf's `note` slot over the entry's span · any entry | `umtool set <p> <entry> shelfNote='Weighed in on camera'` (`shelfNote=` clears it; `--take <t>` for a take) |
+
### Streak chain
A chain per run along a time axis by in-record date (`render.chrome.deck.streak`, measure-extras.mjs): a run starts a chain, each day it holds extends it (the live chain grows with the in-record date of what is on screen, its day count beside it), and when the run ends the chain cracks -- its tip snaps off, a red break, its length tagged ("KETO · 41 days", a lapse "after 73 days") -- then dims into the row, so the stop-start rhythm stays on screen. `source` picks the runs: `diet` (the state's diet turning on or changing -- a new regime or diet number -- ends the last and starts the next; off ends it), `lostRuns` (the odometer's runs, each from its start to the next one's), `pledges` (the sobriety video's: a `pledge` event starts a run, a `lapse` snaps it -- an adapter only until the ledger writes those kinds). `axis: "runs"` lays the chains one after another, each as wide as the square root of its length, instead of on the dates. It sits bottom-centre, between the diet badge and the goal stack, so the diet badge, the chain, or both can run (`umtool look <p> deck.diet=false` / `deck.streak=false`).
@@ -1752,6 +1766,7 @@ A chain per run along a time axis by in-record date (`render.chrome.deck.streak`
| `deck.streak.hold`, `.finale` | 0 (up from the first run on) or 2–600 s · `hide` `show` · default 0, `hide` | `umtool look <p> deck.streak.hold=15` |
| `deck.streak.title`, `.color`, `.colors`, `.labels` | ≤40 · #hex · `{<regime>: #hex}` · `{<regime>: words}` · default the source's word, the accent, the regimes' inks and names | `umtool look <p> deck.streak.title='Every diet'` |
| `deck.streak.onPosts`, `.onChapters` | `dodge` `hide` `show` · default `dodge`: while a post item's card (its card, slot and strip as postLayout lays them: the schedule's `covers`) or a chapter band is up where it stands, it moves to a free anchor of the footage box -- a size down to half if it must, never onto another measure extra that is up -- and hides when none fits; `hide` hides, `show` stays over it | `umtool look <p> deck.streak.onPosts=hide` |
+| `deck.streak.position=shelf` | in its own slot on the shelf (`deck.shelf`: under or over the footage), scaled to the shelf's height, left to right in `deck.shelf.items` order -- nothing covers it there, so it never dodges (`onPosts`, `onChapters`, `x`/`y`, `scale` and `avoid` do not apply), and it is over the finale as the shelf is (`deck.shelf.finale`) | `umtool look <p> deck.shelf=true deck.streak.position=shelf` |
| a timeline entry's `hideModules` | `["streak", …]` on an entry hides it over that entry's span, with its own fade, whatever it would otherwise do there (text in the footage no dodge can know of) · any entry, a post item too | `umtool set <p> <entry> hideModules=streak` (`--take <t>` for a take) |
### Diet badge
@@ -1763,8 +1778,10 @@ The diet he names as a rubber stamp in a corner of the footage box (`render.chro
| `deck.diet` | `true` · `false` · `{show, position, x, y, scale, hold, finale, colors, labels}` · default on with a measure slice | `umtool look <p> deck.diet=false` |
| `deck.diet.position`, `.x`/`.y`, `.scale` | an anchor in the footage box · design px · 0.5–2 · default `bottom-left`, unset, 1 | `umtool look <p> deck.diet.position=top-right` |
| `deck.diet.hold`, `.finale` | 0 (up from the first diet on) or 2–600 s · `hide` `show` · default 0, `hide` | `umtool look <p> deck.diet.hold=15` |
+| `deck.diet.form`, `.tags` | `stamp` · `tags`: the last `tags` diets as a row of dated tags -- each a small stamp with the regime's word in its ink, "DIET #n" and the ledger's words (less the regime they open with: "5 carbs a day"), and the day he switched to it (`state.diet.since`, "Mar 14, 2025"; new words for the same diet keep that day); at each change the new tag slams in at the left, the older slide right and dim, the one past `tags` falls off; a change of words alone fades the new tag over the old; a null diet is a grey "NO DIET" tag with its date · 1–4 · default `stamp` (`tags` on the shelf), 3 | `umtool look <p> deck.diet.form=tags deck.diet.tags=2` |
| `deck.diet.colors`, `.labels` | `{<regime>: #hex}` · `{<regime>: words ≤40}` · default the regimes' inks and names | `umtool look <p> deck.diet.labels='{"glp1":"Ozempic"}'` |
| `deck.diet.onPosts`, `.onChapters` | `dodge` `hide` `show` · default `dodge`: while a post item's card (its card, slot and strip as postLayout lays them: the schedule's `covers`) or a chapter band is up where it stands, it moves to a free anchor of the footage box -- a size down to half if it must, never onto another measure extra that is up -- and hides when none fits; `hide` hides, `show` stays over it | `umtool look <p> deck.diet.onPosts=hide` |
+| `deck.diet.position=shelf` | in its own slot on the shelf (`deck.shelf`: under or over the footage), scaled to the shelf's height, left to right in `deck.shelf.items` order -- nothing covers it there, so it never dodges (`onPosts`, `onChapters`, `x`/`y`, `scale` and `avoid` do not apply), and it is over the finale as the shelf is (`deck.shelf.finale`) | `umtool look <p> deck.shelf=true deck.diet.position=shelf` |
| a timeline entry's `hideModules` | `["diet", …]` on an entry hides it over that entry's span, with its own fade, whatever it would otherwise do there (text in the footage no dodge can know of) · any entry, a post item too | `umtool set <p> <entry> hideModules=diet` (`--take <t>` for a take) |
### Moving start
@@ -1778,6 +1795,7 @@ The weight he says he started at, as he retells it (`render.chrome.deck.peak`, m
| `deck.peak.hold`, `.finale` | 0 (stays up) or 2–600 s · `hide` `show` · default 12, `hide` | `umtool look <p> deck.peak.hold=0` |
| `deck.peak.title`, `.values`, `.color` | ≤40 · `drift` `all` · #hex · default "The start keeps moving", `drift`, #FF5A4E | `umtool look <p> deck.peak.values=all` |
| `deck.peak.onPosts`, `.onChapters` | `dodge` `hide` `show` · default `dodge`: while a post item's card (its card, slot and strip as postLayout lays them: the schedule's `covers`) or a chapter band is up where it stands, it moves to a free anchor of the footage box -- a size down to half if it must, never onto another measure extra that is up -- and hides when none fits; `hide` hides, `show` stays over it | `umtool look <p> deck.peak.onPosts=hide` |
+| `deck.peak.position=shelf` | in its own slot on the shelf (`deck.shelf`: under or over the footage), scaled to the shelf's height, left to right in `deck.shelf.items` order -- nothing covers it there, so it never dodges (`onPosts`, `onChapters`, `x`/`y`, `scale` and `avoid` do not apply), and it is over the finale as the shelf is (`deck.shelf.finale`) | `umtool look <p> deck.shelf=true deck.peak.position=shelf` |
| a timeline entry's `hideModules` | `["peak", …]` on an entry hides it over that entry's span, with its own fade, whatever it would otherwise do there (text in the footage no dodge can know of) · any entry, a post item too | `umtool set <p> <entry> hideModules=peak` (`--take <t>` for a take) |
### Goal stack
@@ -1791,6 +1809,7 @@ A sticky note per goal on a pile in a corner of the footage box, read off the sc
| `deck.goals.max`, `.color`, `.countdown` | 1–8 notes · #hex paper · bool · default 4, the palette's amber, `true` | `umtool look <p> deck.goals.max=6` |
| `deck.goals.hold`, `.finale` | 0 (up from the first goal on) or 2–600 s after each · `hide` `show` · default 20, `hide` | `umtool look <p> deck.goals.hold=0` |
| `deck.goals.onPosts`, `.onChapters` | `dodge` `hide` `show` · default `dodge`: while a post item's card (its card, slot and strip as postLayout lays them: the schedule's `covers`) or a chapter band is up where it stands, it moves to a free anchor of the footage box -- a size down to half if it must, never onto another measure extra that is up -- and hides when none fits; `hide` hides, `show` stays over it | `umtool look <p> deck.goals.onPosts=hide` |
+| `deck.goals.position=shelf` | in its own slot on the shelf (`deck.shelf`: under or over the footage), scaled to the shelf's height, left to right in `deck.shelf.items` order -- nothing covers it there, so it never dodges (`onPosts`, `onChapters`, `x`/`y`, `scale` and `avoid` do not apply), and it is over the finale as the shelf is (`deck.shelf.finale`) | `umtool look <p> deck.shelf=true deck.goals.position=shelf` |
| a timeline entry's `hideModules` | `["goals", …]` on an entry hides it over that entry's span, with its own fade, whatever it would otherwise do there (text in the footage no dodge can know of) · any entry, a post item too | `umtool set <p> <entry> hideModules=goals` (`--take <t>` for a take) |
### Thread rail
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/e2e/play-measure.spec.ts b/umtool/e2e/play-measure.spec.ts
@@ -102,3 +102,51 @@ test("the measure extras play in Play the cut, each page seeked to the playhead'
expect(await shown(page, "promise")).toBeNull();
await page.screenshot({ path: test.info().outputPath("play-measure-c02.png") });
});
+
+test("on the shelf: the footage at the frame's top, the diet's dated tags and the streak in the strip under it, seeked as before", async ({ page, request }) => {
+ await page.setViewportSize({ width: 1366, height: 1000 });
+ const enc = encodeURIComponent;
+ const read = async () => (await (await request.get(`/api/report/chrome?project=${enc(PROJECT)}`)).json()) as { chrome: Record<string, any>; token: string };
+ const put = async (chrome: unknown) => {
+ const { token } = await read();
+ const r = await request.put("/api/report/chrome", { data: { project: PROJECT, chrome, token } });
+ expect(r.ok(), await r.text()).toBeTruthy();
+ };
+ const before = (await read()).chrome;
+ const deck = before.deck ?? {};
+ try {
+ await put({
+ ...before,
+ deck: { ...deck, shelf: { items: ["diet", "streak"] }, diet: { ...(deck.diet ?? {}), position: "shelf" }, streak: { ...(deck.streak ?? {}), position: "shelf" } },
+ });
+ await page.goto(urls.playHref(PROJECT, { clip: "c04", at: 1 }));
+ await ready(page);
+ // Where Play laid them, in % of the frame: the footage from 24 px down, the shelf's slots at y 750 of 1080.
+ const top = (sel: string) => page.locator(sel).first().evaluate((el) => parseFloat((el as HTMLElement).style.top));
+ expect(await top("[data-play-footage]")).toBeCloseTo((24 / 1080) * 100, 1);
+ for (const id of ["diet", "streak"]) expect(await top(`[data-testid="play-layer-${id}"]`)).toBeCloseTo((750 / 1080) * 100, 1);
+ // The tags: the newest (carnivore, c03) and keto (c01) under it, each with the day he named it.
+ const tags = () =>
+ page.frameLocator('[data-testid="play-layer-diet-iframe"]').locator("#pn").evaluate((pn) =>
+ [...pn.querySelectorAll<HTMLElement>(".tg")]
+ .filter((e) => getComputedStyle(e).visibility !== "hidden" && Number(getComputedStyle(e).opacity) > 0.5)
+ // Left to right, as they stand on the shelf (the page holds them in the order they came in).
+ .sort((a, b) => a.getBoundingClientRect().left - b.getBoundingClientRect().left)
+ .map((e) => (e.textContent ?? "").replace(/\s+/g, " ").trim()));
+ await expect.poll(tags, { timeout: 10_000 }).toHaveLength(2);
+ const [newest, older] = await tags();
+ expect(newest).toContain("Carnivore");
+ expect(older).toContain("Keto");
+ for (const t of [newest, older]) expect(t).toMatch(/[A-Z][a-z]{2} \d{1,2}, \d{4}/);
+ expect(await shown(page, "streak")).toContain("Carnivore");
+ await page.screenshot({ path: test.info().outputPath("play-measure-shelf.png") });
+ // Back into c02: one tag, keto.
+ await expect(root(page)).toHaveAttribute("data-play-state", "paused");
+ await page.getByRole("button", { name: "−5" }).click();
+ await expect(root(page)).toHaveAttribute("data-play-item", "c02");
+ await expect.poll(tags, { timeout: 10_000 }).toHaveLength(1);
+ expect((await tags())[0]).toContain("Keto");
+ } finally {
+ await put(before);
+ }
+});
diff --git a/umtool/lib/report/knobsCli.mjs b/umtool/lib/report/knobsCli.mjs
@@ -59,7 +59,7 @@ export const VERTICAL_SET_KEYS = Object.freeze(["vertical", "vertical.crop", "ve
export const SIDE_SET_KEYS = Object.freeze(["side", "side.item", "side.post", "side.from", "side.to", "side.place"]);
const SET_KEYS = [
...CLAIM_KNOBS.map((k) => `claim.${k}`), ...MARK_KEYS, ...AUDIO_KNOBS.map((k) => `audio.${k}`), ...BLUR_KNOBS.map((k) => `blur.${k}`), "layout", ...REVIEW_KEYS,
- ...FX_KEYS, ...GAP_KEYS, "chat", "hideModules",
+ ...FX_KEYS, ...GAP_KEYS, "chat", "hideModules", "shelfNote",
// The vertical format (lane vertical): the clip's 9:16 crop and layout, and its side post.
...VERTICAL_SET_KEYS, ...SIDE_SET_KEYS,
];
@@ -99,6 +99,8 @@ export const SET_USAGE = [
" build log says so. The column's look: umtool look <p> chat.position=left (docs/knobs.md \"Live chat\").",
" hideModules=diet,streak hides those modules over this entry's span, each with its own fade (text in the",
" footage no dodge can know of; any entry, a post item too): goals peak promise diet streak; `hideModules=` none.",
+ " shelfNote='Weighed in on camera' puts one line (≤ 80 characters) on the shelf (render.chrome.deck.shelf, its",
+ " `note` slot) over this entry's span, coming and going with it; any entry; `shelfNote=` none.",
" --take <t>: the entry knobs (not claim.* or marks) land in takes/<t>/take.json's patch, an undo point first",
" (`umtool timeline <p> --take <t> undo`); the project's manifest is untouched.",
" vertical.crop='[x,y,w,h]' (fractions of the source: the 9:16 box a vertical render cuts; vertical.aspect the",
@@ -232,6 +234,11 @@ export async function setCommand(args, { root = REPORTS_ROOT, out = (s) => conso
entryPatch[key] = key === "side.item" && value !== null ? String(value) : value;
continue;
}
+ if (key === "shelfNote") {
+ // A note on the shelf over this entry's span (deck.mjs parseShelfNote checks it); words whatever they parse as.
+ entryPatch.shelfNote = value === null || value === undefined ? null : String(value);
+ continue;
+ }
if (key === "hideModules") {
// The modules hidden over this entry's span (deck.mjs parseHideModules checks the ids); `hideModules=` none.
entryPatch.hideModules = value === null || value === undefined ? null : value;
@@ -304,6 +311,7 @@ export async function setCommand(args, { root = REPORTS_ROOT, out = (s) => conso
: await withEditNotes(project, async () => updateClip(project.dir, clipId, entryPatch, { token: await manifestToken(project.dir), edit: "trim" }));
if (take) results.take = { id: take, undo: result.revision?.rel ? `takes/${take}/${result.revision.rel}` : null };
if ("hideModules" in entryPatch) results.hideModules = result.entry.hideModules ?? null;
+ if ("shelfNote" in entryPatch) results.shelfNote = result.entry.shelfNote ?? null;
if ("audio" in entryPatch) results.audio = result.entry.audio ?? null;
if ("blur" in entryPatch) results.blur = result.entry.blur ?? null;
if ("layout" in entryPatch) results.layout = result.entry.layout ?? "clip";
@@ -340,6 +348,7 @@ export async function setCommand(args, { root = REPORTS_ROOT, out = (s) => conso
if ("blur" in results) out(`${clipId}: blur ${results.blur ? JSON.stringify(results.blur) : "none (the picture as recorded)"}`);
if ("layout" in results) out(`${clipId}: layout ${results.layout}`);
if ("hideModules" in results) out(`${clipId}${results.take ? ` (take ${results.take.id})` : ""}: hideModules ${results.hideModules ? `${results.hideModules.join(", ")} (hidden over its span)` : "none"}`);
+ if ("shelfNote" in results) out(`${clipId}${results.take ? ` (take ${results.take.id})` : ""}: shelfNote ${results.shelfNote ? JSON.stringify(results.shelfNote) + " (on the shelf over its span)" : "none"}`);
if (results.take?.undo) out(` undo point: ${results.take.undo} (umtool timeline ${project.id} --take ${results.take.id} undo)`);
if ("chat" in results) out(`${clipId}: chat ${results.chat === true ? "on (its video's live_chat.cues.json beside the footage; the build says if there is none)" : results.chat === false ? "off" : "default (off)"}`);
if ("fx" in results) out(`${clipId}: fx ${results.fx ? JSON.stringify(results.fx) : "none"}`);
diff --git a/umtool/lib/report/knobsCli.test.mjs b/umtool/lib/report/knobsCli.test.mjs
@@ -97,6 +97,31 @@ test("umtool set hideModules=diet,streak: the modules hidden over an entry's spa
assert.match(lines.at(-1), /--take sets a take's entry knobs/);
});
+test("umtool set shelfNote='…': a line on the shelf over an entry's span, any entry; --take writes the take's patch", async () => {
+ const dir = await project("note");
+ const m = await read(dir);
+ m.timeline.push({ type: "post", id: "x01", item: "123" });
+ await writeFile(path.join(dir, "video.manifest.json"), JSON.stringify(m, null, 2) + "\n");
+ const { lines, run } = runner(setCommand);
+ assert.equal(await run("note", "c02", "shelfNote= Weighed in on camera "), 0, lines.join("\n"));
+ assert.equal((await read(dir)).timeline[1].shelfNote, "Weighed in on camera", "trimmed");
+ assert.match(lines.at(-1), /c02: shelfNote "Weighed in on camera" \(on the shelf over its span\)/);
+ assert.equal(await run("note", "x01", "shelfNote=2026"), 0, lines.join("\n"));
+ assert.equal((await read(dir)).timeline[2].shelfNote, "2026", "a post item too; words whatever they parse as");
+ assert.equal(await run("note", "c02", `shelfNote=${"x".repeat(81)}`), 1);
+ assert.match(lines.at(-1), /shelfNote is 81 characters \(at most 80\)/);
+ assert.equal(await run("note", "c02", "shelfNote="), 0);
+ assert.equal("shelfNote" in (await read(dir)).timeline[1], false);
+ const { draftTake } = await import("./takeMaker.mjs");
+ const { resolveTakeManifest } = await import("./takeManifest.mjs");
+ await draftTake(dir, { id: "panel", label: "Panel", patch: {} });
+ const before = await readFile(path.join(dir, "video.manifest.json"), "utf8");
+ assert.equal(await run("note", "c02", "shelfNote=Day 41", "hideModules=diet", "--take", "panel"), 0, lines.join("\n"));
+ assert.equal(await readFile(path.join(dir, "video.manifest.json"), "utf8"), before);
+ const t = (await resolveTakeManifest(dir, "panel")).manifest.timeline[1];
+ assert.deepEqual([t.shelfNote, t.hideModules], ["Day 41", ["diet"]]);
+});
+
test("umtool set: claim and audio knobs through the writers; key= clears; a bad key or value is refused", async () => {
const dir = await project("set");
const { lines, run } = runner(setCommand);
diff --git a/umtool/lib/report/manifest.mjs b/umtool/lib/report/manifest.mjs
@@ -32,7 +32,7 @@ import {
} from "umtool-report-to-video/ledger-totals";
import { isCalendarDate } from "umtool-report-to-video/attribution";
import {
- normalizeOnscreen, parseHideModules, validateChrome, validateDeckClaims, validateDeckMarkers, validatePosts, validateTeaser, validateTeasers,
+ normalizeOnscreen, parseHideModules, parseShelfNote, validateChrome, validateDeckClaims, validateDeckMarkers, validatePosts, validateTeaser, validateTeasers,
} from "umtool-report-to-video/deck";
import { validateThreadEntries } from "yt-dlp-transcript-common/lib/report/panels.mjs";
import { validateAssist } from "yt-dlp-transcript-common/lib/clips/assist.mjs";
@@ -310,6 +310,21 @@ function applyHideModules(entry, value) {
}
/**
+ * Set an entry's `shelfNote` (deck.mjs parseShelfNote: one line, at most 80 characters); null or "" removes it.
+ * @param {Record<string, unknown>} entry
+ * @param {unknown} value
+ */
+function applyShelfNote(entry, value) {
+ const { value: text, error } = parseShelfNote(value);
+ if (error) throw new Error(error);
+ if (text) entry.shelfNote = text;
+ else delete entry.shelfNote;
+}
+
+/** The patch keys any timeline entry may carry (a post item, a still, a clip): applied before the clip-only rules. */
+const ANY_ENTRY_KEYS = Object.freeze(["hideModules", "shelfNote"]);
+
+/**
* updateClip's rules over a manifest held in memory: the ONE place a clip
* patch is checked and applied. updateClip runs it on the project's file
* inside its lock; a take's walk (takeEdit.mjs) runs it on the take's
@@ -333,8 +348,11 @@ export function patchClipEntry(manifest, clipId, patch, { edit = "trim", now = n
if (!entry) throw new Error(`no timeline entry with id ${clipId}`);
// The modules this entry hides over its span (`hideModules`, deck.mjs entryHides): any entry may carry it -- a
// post item, a still, a clip -- so a patch of it alone is applied here, before the clip-only rules.
- if (patch !== RESTORE_PATCH && Object.keys(patch).length && Object.keys(patch).every((k) => k === "hideModules")) {
- applyHideModules(entry, patch.hideModules);
+ // So may its note on the shelf (`shelfNote`, deck.mjs entryShelfNotes).
+ if (patch !== RESTORE_PATCH && Object.keys(patch).length && Object.keys(patch).every((k) => ANY_ENTRY_KEYS.includes(k))) {
+ if (patch.hideModules !== undefined) applyHideModules(entry, patch.hideModules);
+ if (patch.shelfNote !== undefined) applyShelfNote(entry, patch.shelfNote);
+ if (patch.shelfNote !== undefined) applyShelfNote(entry, patch.shelfNote);
return { entry, before: { start: entry.start, end: entry.end } };
}
// `!== "clip"`, not `=== "card"`. The timeline's vocabulary is open -- one
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/lib/report/serve.mjs b/umtool/lib/report/serve.mjs
@@ -982,7 +982,7 @@ export function previewDirFor(projectDir, variant, rest, segmentIds) {
// (Every module that declares `play` must be here, or Play's iframe of its page is a 404: the measure
// extras and the instruments too -- the dial's finale is a window its module names `dial-finale-preview`,
// never confused with the dial's `dial-preview-<segment>`.)
-export const LAYER_REGIONS = Object.freeze(["pair", "status", "chapter", "stats", "threads", "flips", "fx", "diet", "peak", "goals", "promise", "streak", "dial", "odometer", "trail", "dial-finale"]);
+export const LAYER_REGIONS = Object.freeze(["pair", "status", "chapter", "stats", "threads", "flips", "fx", "shelf", "diet", "peak", "goals", "promise", "streak", "dial", "odometer", "trail", "dial-finale"]);
/** The project name a layer preview is served under, or null when `head` is not one. */
export function layerPreviewOf(head, segmentIds = []) {
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/chrome-measure-extras.mjs b/umtool/report-to-video/chrome-measure-extras.mjs
@@ -12,10 +12,11 @@
// with its FROM stated, so a seek from anywhere lands on the same pixels.
//
// PURE: a schedule and a render block in, `{ html, items }` out.
+import { formatDeckDate } from "./attribution.mjs";
import { rgba } from "./chrome-deck.mjs";
import { compileCues, cuePageHtml, esc, INSTANT, joinSpans, r4, spanEvents } from "./chrome-cues.mjs";
import {
- daysBetween, daysLeftText, daysText, dietStates, goalStates, measureBox, measureExtraGeometry, measureOf, MEASURE_BOXES, promiseStripRect, promiseStripType,
+ daysBetween, daysLeftText, daysText, DIET_TAG, dietStates, goalStates, measureBox, measureExtraGeometry, measureOf, MEASURE_BOXES, promiseStripRect, promiseStripType,
MEASURE_DODGE_MOVE, measurePlacements, monthYear, peakStates, promiseStates, shortDate, streakStates, upSpans, weightText,
} from "./measure-extras.mjs";
import { MEASURE_RED, resolveMeasureExtra } from "./modules/measure-extras-settings.mjs";
@@ -611,11 +612,12 @@ export function stampSize(label, room) {
// An ink texture: fractal noise as the stamp's alpha, so it reads pressed, not printed.
const INK = "url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='120'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='2' seed='7'/><feColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1.6 1.75'/></filter><rect width='240' height='120' filter='url(%23n)'/></svg>\")";
-/** The diet badge's page: `{ html, items }`. */
+/** The diet badge's page: `{ html, items }` -- the stamp, or (`form: "tags"`) the row of dated tags. */
export function dietHtml(schedule, render, opts = {}) {
const cfg = resolveMeasureExtra("diet", render);
const states = dietStates(schedule, render);
if (!cfg || !states.length) throw new Error("diet: the schedule's measure slice has no diet on camera");
+ if (cfg.form === "tags") return dietTagsHtml(schedule, render, opts, cfg, states);
const F = frameOf("diet", schedule, render);
const { geo, px } = F;
const pal = render.palette;
@@ -680,6 +682,142 @@ export function dietHtml(schedule, render, opts = {}) {
return { html: page("diet", schedule, opts, F, css, body, init, cues, states.map((_, j) => `s${j}`), render), items };
}
+/**
+ * A tag's regime word a size that fits its width (`room`, design px: the tag
+ * less its plate, border and padding): the condensed extra-bold face set in
+ * capitals and spaced, at ~0.62 em a letter ("CARNIVORE" 31 px, "KETO" 44).
+ */
+export function tagWordSize(label, room = DIET_TAG.width - 44) {
+ const n = Math.max(1, [...String(label)].length);
+ return Math.max(16, Math.min(44, Math.floor(room / (0.62 * n))));
+}
+
+/**
+ * A tag's words without the regime they open with: the tag already says it in
+ * its ink, so "Keto · 5 carbs a day" is "5 carbs a day" (and fits) -- only
+ * where a separator follows it ("Keto + IF + walking" stays whole). Words
+ * that are only the regime are none.
+ */
+export function tagWords(detail, names) {
+ let w = String(detail ?? "").trim();
+ for (const name of names) {
+ const n = String(name ?? "").trim();
+ if (!n) continue;
+ const re = new RegExp(`^${n.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}(?:\\s*[·:,;–—-]\\s*|$)`, "i");
+ if (re.test(w)) { w = w.replace(re, "").trim(); break; }
+ }
+ return w;
+}
+
+/**
+ * The diet as a row of DATED TAGS (`diet.form: "tags"`, the shelf's default):
+ * the last `tags` diets (dietStates' `tags`, newest first), each a small stamp
+ * -- the regime's word in its ink, "DIET #n" and the ledger's words when they
+ * say more, and the day he named it ("Mar 14, 2025", formatDeckDate). At a
+ * change of diet the new tag slams in at the left with the stamp's motion (in
+ * big and turned, a shake), the older ones slide right a place and dim, and the
+ * one past `tags` slides off and fades; a change of words alone fades the new
+ * tag in over the old; "No diet" is a grey tag with its date.
+ */
+function dietTagsHtml(schedule, render, opts, cfg, states) {
+ const F = frameOf("diet", schedule, render);
+ const { px } = F;
+ const pal = render.palette;
+ const SLAM = 0.16;
+ const SLIDE = 0.4;
+ const DIM = 0.45;
+ const n = cfg.tags ?? 3;
+ const slotX = (i) => px(i * (DIET_TAG.width + DIET_TAG.gap));
+ const spans = upSpans(states.map((s) => s.at), cfg, schedule);
+ const init = { pn: { autoAlpha: 0 } };
+ const ev = [];
+ for (const sp of spans) ev.push(...spanEvents("pn", sp.in, sp.out, { fadeIn: MEASURE_FADE.in, fadeOut: MEASURE_FADE.out }));
+ // Every tag once, by its id: what it shows, and the first state it is in (how it comes in).
+ const tags = new Map();
+ states.forEach((st) => { for (const t of st.tags) if (!tags.has(t.id)) tags.set(t.id, t); });
+ for (const id of tags.keys()) {
+ const k = `t${id}`;
+ init[k] = { x: 0, autoAlpha: 0 };
+ init[`${k}.d`] = { opacity: 1 };
+ init[`${k}.w`] = { x: 0 };
+ init[`${k}.s`] = { scale: 1, rotation: -3, opacity: 1 };
+ }
+ states.forEach((st, j) => {
+ const prev = j ? states[j - 1].tags.map((t) => t.id) : [];
+ const cur = st.tags.map((t) => t.id);
+ const at = st.at;
+ const front = cur[0];
+ if (!prev.includes(front)) {
+ const k = `t${front}`;
+ ev.push({ k, at, dur: INSTANT, to: { x: 0, autoAlpha: 1 }, ease: "none" });
+ if (st.slam) {
+ // The slam: in from big and turned, hard onto the shelf, then a shake.
+ init[`${k}.s`] = { scale: 2.3, rotation: -15, opacity: 0 };
+ ev.push({ k: `${k}.s`, at, dur: SLAM, to: { scale: 1, rotation: -3, opacity: 1 }, ease: "power4.in" });
+ [8, -6, 4, -2, 0].map((v) => Math.round(v * F.k)).forEach((x, m) => ev.push({ k: `${k}.w`, at: at + SLAM + m * 0.045, dur: 0.045, to: { x }, ease: "sine.inOut" }));
+ } else {
+ init[`${k}.s`] = { scale: 1, rotation: -3, opacity: 0 };
+ ev.push({ k: `${k}.s`, at, dur: 0.3, to: { opacity: 1 }, ease: "power1.out" });
+ }
+ }
+ // The older ones a place to the right, dimmed.
+ cur.forEach((id, i) => {
+ const p = prev.indexOf(id);
+ if (p < 0 || p === i) return;
+ ev.push({ k: `t${id}`, at, dur: SLIDE, to: { x: slotX(i) }, ease: "power2.inOut" });
+ ev.push({ k: `t${id}.d`, at, dur: SLIDE, to: { opacity: i === 0 ? 1 : DIM }, ease: "power1.out" });
+ });
+ // Off the row: the one replaced by new words fades where it stands; the one past `tags` slides off.
+ for (const id of prev) {
+ if (cur.includes(id)) continue;
+ if (st.replaced && id === prev[0]) ev.push({ k: `t${id}`, at, dur: 0.25, to: { autoAlpha: 0 }, ease: "power1.in" });
+ else ev.push({ k: `t${id}`, at, dur: SLIDE, to: { x: slotX(n), autoAlpha: 0 }, ease: "power2.in" });
+ }
+ });
+ const { cues } = compileCues(init, ev);
+ const items = [];
+ const room = DIET_TAG.width - 44;
+ const blocks = [...tags.values()].map((t) => {
+ const k = `t${t.id}`;
+ const d = t.diet;
+ const label = d ? d.label : cfg.labels.off ?? "No diet";
+ const ink = d ? d.color : pal.muted;
+ const size = tagWordSize(label, room);
+ const date = t.since ? formatDeckDate(t.since) : "";
+ const words = d ? tagWords(d.detail, [d.label, d.regime]) : "";
+ const sub = d
+ ? `<div class="sb"><span class="dn">Diet${d.n !== null ? ` #${d.n}` : ""}</span>${words ? `<span class="dd">${esc(words)}</span>` : ""}</div>`
+ : `<div class="sb"><span class="dd">he says he is on none</span></div>`;
+ const html = `<div class="tg" data-k="${k}"><div class="dm" data-k="${k}.d"><div class="sw" data-k="${k}.w"><div class="sp${d ? "" : " off"}" data-k="${k}.s">` +
+ `<div class="ink" style="color:${ink};border-color:${ink}"><div class="lb" style="font-size:${px(size)}px;line-height:${px(Math.round(size * 1.02))}px">${esc(label)}</div>${sub}` +
+ `${date ? `<div class="dt">${esc(date)}</div>` : ""}</div></div></div></div></div>`;
+ items.push({ key: k, gate: [k, "autoAlpha"], html });
+ return html;
+ });
+ const css = `
+ #pn { position: absolute; inset: 0; visibility: hidden; opacity: 0; }
+ .tg { position: absolute; left: 0; top: 0; width: ${px(DIET_TAG.width)}px; height: ${px(DIET_TAG.height)}px; visibility: hidden; opacity: 0; }
+ .dm, .sw { position: absolute; inset: 0; }
+ /* A tag: the stamp's plate and pressed ink, small. The plate is solid; only the ink is pressed. */
+ .sp { position: absolute; left: ${px(4)}px; top: ${px(4)}px; right: ${px(4)}px; bottom: ${px(4)}px; border-radius: ${px(8)}px;
+ background: ${rgba(pal.bg, 0.93)}; padding: ${px(4)}px; box-shadow: 0 ${px(6)}px ${px(16)}px rgba(0, 0, 0, 0.45); }
+ .ink { height: 100%; padding: ${px(3)}px ${px(10)}px ${px(4)}px; border: ${px(4)}px solid; border-radius: ${px(6)}px;
+ box-shadow: inset 0 0 0 ${px(2)}px ${rgba(pal.bg, 0.9)}, inset 0 0 0 ${px(3)}px currentColor;
+ display: flex; flex-direction: column; align-items: center; justify-content: center; overflow: hidden;
+ -webkit-mask-image: ${INK}; mask-image: ${INK}; -webkit-mask-size: ${px(240)}px ${px(120)}px; mask-size: ${px(240)}px ${px(120)}px; }
+ .lb { font-family: ${DISPLAY}; text-transform: uppercase; letter-spacing: 0.03em; white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
+ .sb { display: flex; align-items: baseline; justify-content: center; gap: ${px(8)}px; white-space: nowrap; max-width: 100%; }
+ .dn { flex: none; font-family: 'DeckSansBold', sans-serif; font-size: ${px(14)}px; line-height: ${px(18)}px; letter-spacing: 0.14em; text-transform: uppercase; }
+ .dd { min-width: 0; font-family: 'DeckSansBold', sans-serif; font-size: ${px(14)}px; line-height: ${px(18)}px; color: ${pal.fg}; overflow: hidden; text-overflow: ellipsis; }
+ .off .dd { color: ${pal.muted}; }
+ .dt { margin-top: ${px(2)}px; font-family: 'DeckSansBold', sans-serif; font-size: ${px(17)}px; line-height: ${px(21)}px; color: ${pal.fg};
+ letter-spacing: 0.02em; white-space: nowrap; font-variant-numeric: tabular-nums; }`;
+ const body = `<div id="pn" data-k="pn">
+ ${blocks.join("\n ")}
+ </div>`;
+ return { html: page("diet", schedule, opts, F, css, body, init, cues, items.map((i) => i.key), render), items };
+}
+
// ---------------------------------------------------------------------------
// STREAK: the chains.
// ---------------------------------------------------------------------------
diff --git a/umtool/report-to-video/chrome-shelf.mjs b/umtool/report-to-video/chrome-shelf.mjs
@@ -0,0 +1,74 @@
+// THE SHELF'S OWN PAGE (module `shelf`, region `shelf`): the note an entry puts
+// on the shelf (`entry.shelfNote`, deck.mjs entryShelfNotes -> schedule.shelf.notes),
+// a short chip in the note's slot (measure-extras.mjs shelfLayout) that comes in
+// and goes with its entry. The shelf's other occupants -- the diet's tags, the
+// streak chain, a goal stack -- are their own modules' pages, laid in their own
+// slots of it; this page draws only the notes, so a video with no measure slice
+// has a use for the shelf too.
+//
+// PURE: a schedule and a render block in, `{ html, items }` out. A cue page
+// (chrome-cues.mjs) over the whole cut: each note an item gated by its own
+// autoAlpha, so a frame keys only the note it shows.
+import { rgba } from "./chrome-deck.mjs";
+import { compileCues, cuePageHtml, esc, spanEvents } from "./chrome-cues.mjs";
+import { shelfLayout } from "./measure-extras.mjs";
+import { resolveShelf } from "./modules/shelf-settings.mjs";
+
+/** How a note comes in and goes, s. */
+export const SHELF_NOTE_FADE = Object.freeze({ in: 0.35, out: 0.3 });
+
+/** The schedule's shelf notes, `[{ segment, from, to, text }]` (none without the shelf). */
+export function shelfNotes(schedule, render) {
+ if (!resolveShelf(render)) return [];
+ const notes = schedule?.shelf?.notes;
+ return Array.isArray(notes) ? notes.filter((n) => Number.isFinite(n?.from) && Number.isFinite(n?.to) && n.to > n.from && typeof n.text === "string" && n.text) : [];
+}
+
+/** The note's slot on the shelf, or null (no shelf, `items` without "note", or too little width left). */
+export function shelfNoteGeometry(render) {
+ const slot = shelfLayout(render)?.slots.note;
+ return slot ? { ...slot } : null;
+}
+
+/** Does the cut draw the shelf's page: the shelf on, a slot for the note, and a note to show. */
+export const shelfOn = (schedule, render) => !!shelfNoteGeometry(render) && shelfNotes(schedule, render).length > 0;
+
+/** The shelf's page: `{ html, items }`. */
+export function shelfHtml(schedule, render, opts = {}) {
+ const geo = shelfNoteGeometry(render);
+ const notes = shelfNotes(schedule, render);
+ if (!geo || !notes.length) throw new Error("shelf: no note for the shelf (render.chrome.deck.shelf with \"note\" in its items, and an entry's shelfNote)");
+ const pal = render.palette;
+ const k = (render.width ?? 1920) / 1920;
+ const px = (v) => Math.max(1, Math.round(v * k));
+ // Two lines of words at most, in the slot's height less its padding.
+ const size = Math.max(12, Math.round(Math.min(24 * k, (geo.height - px(20)) / 2.5)));
+ const init = {};
+ const ev = [];
+ const items = [];
+ const blocks = notes.map((n, i) => {
+ const key = `n${i}`;
+ init[key] = { autoAlpha: 0 };
+ ev.push(...spanEvents(key, n.from, n.to, { fadeIn: SHELF_NOTE_FADE.in, fadeOut: SHELF_NOTE_FADE.out }));
+ const html = `<div class="nt" data-k="${key}"><div class="ch"><div class="tx">${esc(n.text)}</div></div></div>`;
+ items.push({ key, gate: [key, "autoAlpha"], html });
+ return html;
+ });
+ const { cues } = compileCues(init, ev);
+ const css = `
+ .nt { position: absolute; inset: 0; visibility: hidden; opacity: 0; display: flex; align-items: center; }
+ /* A chip: the deck's ground, the accent down its left edge, the words in at most two lines. */
+ .ch { max-width: 100%; max-height: 100%; border-radius: ${px(8)}px; background: ${rgba(pal.bg, 0.9)};
+ box-shadow: inset ${px(4)}px 0 0 ${pal.accent}, 0 ${px(6)}px ${px(16)}px rgba(0, 0, 0, 0.4);
+ padding: ${px(8)}px ${px(16)}px ${px(8)}px ${px(20)}px; }
+ .tx { font-size: ${size}px; line-height: ${Math.round(size * 1.2)}px; color: ${pal.fg};
+ display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }`;
+ return {
+ html: cuePageHtml({
+ id: "shelf", W: geo.width, H: geo.height, fps: schedule.fps ?? render.fps ?? 30, fonts: opts.fonts, gsapSrc: opts.gsap,
+ css, body: blocks.join("\n "), init, cues,
+ whole: { total: schedule.total, from: opts.from, duration: opts.duration, ids: items.map((i) => i.key) }, primeWindow: true,
+ }),
+ items,
+ };
+}
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 {
@@ -32,6 +32,10 @@ import { resolveCounter } from "./counter.mjs";
import { INSTRUMENT_COLUMN, instrumentsOn, instrumentsPlacement, instrumentsWanted, resolveDial } from "./instruments.mjs";
import { TRAILER_HIT_TIERS, TRAILER_SWELL } from "./trailer-hits.mjs";
import { DECK_PAD_X, COUNTER_CELL } from "./modules/design.mjs";
+import { parseShelfNote, resolveShelf, SHELF_MIN } from "./modules/shelf-settings.mjs";
+
+// An entry's note on the shelf, as written (`umtool set <p> <entry> shelfNote=…`; manifest.mjs checks it here).
+export { parseShelfNote };
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, POST_PERSIST, QR_LINKS, SECTION_TITLE_DEFAULTS, SETTINGS, settingValue,
@@ -219,6 +223,23 @@ export function validateChrome(chrome, render = {}) {
errors.push(`${which} leaves the rail ${rail.cards.width}px wide (at least 220: a smaller footageScale)`);
}
}
+ // The shelf needs SHELF_MIN px (at 1080) beside the footage: the footage shrinks, or the band gives back its
+ // second line. And it is the deck's footage box it clears, not the feed's.
+ const shelf = resolveShelf({ chrome });
+ if (shelf && g.shelf) {
+ if (resolveDeck({ chrome }).posts.layout === "feed") errors.push(`${w}.shelf needs the popup posts, not the feed (${w}.posts.layout)`);
+ const need = Math.round(SHELF_MIN * (g.H / 1080));
+ if (g.shelf.height < need) {
+ const gap = railGap({ ...render, chrome });
+ const most = Math.floor(((g.deck.y - 3 * gap - need) / g.H) * 1000) / 1000;
+ const extra = subtitleBoxes(resolveDeck({ chrome })).extra;
+ errors.push(
+ `${w}.shelf needs at least ${need}px ${shelf.side} the footage, but footageScale ${resolveDeck({ chrome }).footageScale} ` +
+ `(${g.footage.height}px of footage) over a ${g.deck.height}px deck leaves ${Math.max(0, g.shelf.height)} ` +
+ `(footageScale at most ${Math.max(0, most)}${extra ? ", or subtitle.lines 1" : ""}, or ${w}.shelf=false)`,
+ );
+ }
+ }
if (g.footage.height > room) {
const max = Math.floor((room / g.H) * 1000) / 1000;
// A two-line subtitle's head line is part of the band: say so, and the way back.
@@ -458,10 +479,28 @@ export function deckGeometry(render) {
: even(W * deck.footageScale);
const fh = even((fw * H) / W);
const fx = inst ? railGap(render) : railOn(render) ? W - fw - railGap(render) : Math.floor((W - fw) / 2);
+ // The shelf (`deck.shelf`, modules/shelf-settings.mjs): the footage goes to
+ // the frame's top (`below`) or down onto the deck (`above`), `railGap` from
+ // the edge, and the strip it leaves -- `railGap` clear of the footage and of
+ // the frame's edge or the deck -- is the shelf, as wide as the footage. Off,
+ // the footage is centred above the deck as it always was.
+ const shelf = resolveShelf(render);
+ if (!shelf) {
+ return {
+ W, H,
+ footage: { x: fx, y: Math.floor((H - dh - fh) / 2), width: fw, height: fh },
+ deck: { x: 0, y: H - dh, width: W, height: dh },
+ };
+ }
+ const gap = railGap(render);
+ const fy = shelf.side === "above" ? H - dh - fh - gap : gap;
+ const sy = shelf.side === "above" ? gap : fy + fh + gap;
+ const sh = shelf.side === "above" ? fy - 2 * gap : H - dh - gap - sy;
return {
W, H,
- footage: { x: fx, y: Math.floor((H - dh - fh) / 2), width: fw, height: fh },
+ footage: { x: fx, y: fy, width: fw, height: fh },
deck: { x: 0, y: H - dh, width: W, height: dh },
+ shelf: { x: fx, y: sy, width: fw, height: sh },
};
}
@@ -1157,12 +1196,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 +1227,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 +1410,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 +1421,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.
@@ -1448,10 +1504,34 @@ export function deckSchedule({
const hides = entryHides(entries, doc.segments);
if (hides.length) doc.hides = hides;
}
+ // The shelf's notes (`deck.shelf`, an entry's `shelfNote`): only with the shelf on, so a cut without one
+ // writes the schedule it always did.
+ if (resolveShelf(render)) {
+ const notes = entryShelfNotes(entries, doc.segments);
+ if (notes.length) doc.shelf = { notes };
+ }
return doc;
}
/**
+ * The notes an entry puts on the shelf (`entry.shelfNote`, one line): `[{ segment,
+ * from, to, text }]` -- `from`/`to` its segment's span in the cut. The shelf
+ * module (modules/shelf.mjs) shows each over its span, fading with the entry.
+ */
+export function entryShelfNotes(entries, segments) {
+ const byId = new Map((segments ?? []).map((s) => [s.id, s]));
+ const out = [];
+ for (const e of entries ?? []) {
+ if (e?.shelfNote === undefined || e?.shelfNote === null) continue;
+ const { value } = parseShelfNote(e.shelfNote);
+ const seg = byId.get(e.id);
+ if (!value || !seg || !Number.isFinite(seg.start) || !Number.isFinite(seg.duration)) continue;
+ out.push({ segment: e.id, from: seg.start, to: Math.round((seg.start + seg.duration) * 1000) / 1000, text: value });
+ }
+ return out;
+}
+
+/**
* The modules a timeline entry may hide over its own span (`entry.hideModules`):
* the measure extras, which stand over the footage. The instruments' column and
* the deck never cover footage, so there is nothing to hide them for.
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/measure-extras.mjs b/umtool/report-to-video/measure-extras.mjs
@@ -27,11 +27,13 @@
// off-scope rule: this only draws state.diet).
import { deckGeometry, feedGeometry, instrumentsGeometry } from "./deck.mjs";
import { chapterCover, chapterWindows } from "./chrome-story.mjs";
-import { MEASURE_EXTRAS, MEASURE_POSITIONS, resolveMeasureExtra } from "./modules/measure-extras-settings.mjs";
+import { MEASURE_EXTRAS, MEASURE_POSITIONS, resolveMeasureExtra, SHELF_POSITION } from "./modules/measure-extras-settings.mjs";
+import { resolveShelf } from "./modules/shelf-settings.mjs";
const r4 = (v) => Math.round(v * 10000) / 10000;
const isObj = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
const even = (v) => 2 * Math.round(v / 2);
+const evenDown = (v) => 2 * Math.floor(v / 2);
/** The schedule's measure slice, when it has one the extras can read. */
export function measureOf(schedule) {
@@ -482,14 +484,30 @@ export function dietStates(schedule, render) {
const label = cfg.labels[regime] ?? regime;
const display = d ? String(d.display ?? "").trim() : "";
const generic = !display || display.toLowerCase() === label.toLowerCase() || display.toLowerCase() === String(cfg.labels.other ?? "").toLowerCase() || display.toLowerCase() === regime;
- const diet = d ? { regime, label, detail: generic ? "" : display, n: Number.isFinite(d.n) ? d.n : null, color: cfg.colors[regime] ?? cfg.colors.other } : null;
+ // `since`: the in-record day he named it (the state's, the producer's), else the event's date.
+ const since = (d ? d.since : null) ?? e.date ?? null;
+ const diet = d ? { regime, label, detail: generic ? "" : display, n: Number.isFinite(d.n) ? d.n : null, color: cfg.colors[regime] ?? cfg.colors.other, since } : null;
const slam = !!d && (!prev?.diet || prev.diet.regime !== regime || prev.diet.n !== diet.n);
const at = r4(e.t);
if (out.length && Math.abs(out[out.length - 1].at - at) < 1e-6) out.pop();
- out.push({ at, diet, slam, key });
+ out.push({ at, diet, slam, key, since });
prev = { key, diet };
}
- return out.map(({ key: _k, ...st }) => st);
+ // THE HISTORY (the tags form, `diet.form: "tags"`): each state's last `tags` diets, newest first -- a new
+ // diet (a slam) or a "No diet" pushes a tag in at the front and the oldest past `tags` off; a change of the
+ // words alone replaces the newest tag in place. Each tag `{ id, diet, since }`, `id` stable across states.
+ const n = cfg.tags ?? 3;
+ let shown = [];
+ let id = 0;
+ return out.map(({ key: _k, since, ...st }, j) => {
+ const wordsOnly = j > 0 && !!st.diet && !st.slam && !!out[j - 1].diet;
+ // New words for the same diet keep the day he switched to it: the tag dates the SWITCH, not the words.
+ const kept = wordsOnly && shown[0] ? shown[0].since : since;
+ const diet = wordsOnly && st.diet ? { ...st.diet, since: kept } : st.diet;
+ const tag = { id: id++, diet, since: kept };
+ shown = wordsOnly ? [tag, ...shown.slice(1)] : [tag, ...shown].slice(0, n);
+ return { ...st, diet, tags: shown, replaced: wordsOnly };
+ });
}
// ---------------------------------------------------------------------------
@@ -672,12 +690,62 @@ export const MEASURE_BOXES = Object.freeze({
promiseColumn: Object.freeze({ width: 600, height: 138 }),
});
-/** A module's design box: the promise clock's compact one in the column. */
+/** One diet tag (`diet.form: "tags"`), design px: its width, the air between two, and the row's height. */
+export const DIET_TAG = Object.freeze({ width: 220, gap: 12, height: 116 });
+
+/** The diet's row of `n` tags, design px. */
+export const dietTagsBox = (n) => ({ width: n * DIET_TAG.width + (n - 1) * DIET_TAG.gap, height: DIET_TAG.height });
+
+/** A module's design box: the promise clock's compact one in the column, the diet's row of tags. */
export function measureBox(id, render) {
if (id === "promise" && resolveMeasureExtra("promise", render)?.slot === "column") return MEASURE_BOXES.promiseColumn;
+ if (id === "diet") {
+ const cfg = resolveMeasureExtra("diet", render);
+ if (cfg?.form === "tags") return dietTagsBox(cfg.tags ?? 3);
+ }
return MEASURE_BOXES[id];
}
+/** The note's slot on the shelf is only drawn this wide or wider, design px. */
+export const SHELF_NOTE_MIN = 160;
+
+/**
+ * The SHELF's occupants laid out (`deck.shelf`, deck.mjs deckGeometry's
+ * `shelf`): `{ rect, slots: { [item]: {x, y, width, height} } }`, or null with
+ * no shelf. Left to right in `items` order, `gap` apart: each measure extra on
+ * it at its own design box scaled to the shelf's height (all of them a size
+ * down together, centred in the height, when they would not fit its width);
+ * the note takes what width is left at its place (none under SHELF_NOTE_MIN).
+ * An item that is off takes no slot.
+ */
+export function shelfLayout(render) {
+ const shelf = resolveShelf(render);
+ const g = deckGeometry(render);
+ if (!shelf || !g.shelf) return null;
+ const rect = g.shelf;
+ const k = g.W / 1920;
+ const gap = Math.round(shelf.gap * k);
+ const items = shelf.items.filter((i) => i === "note" || resolveMeasureExtra(i, render)?.position === SHELF_POSITION);
+ const boxes = items.map((i) => (i === "note" ? null : measureBox(i, render)));
+ const fixed = boxes.reduce((a, b) => a + (b ? (b.width * rect.height) / b.height : 0), 0);
+ const gaps = gap * Math.max(0, items.length - 1);
+ const fit = fixed > 0 ? Math.min(1, (rect.width - gaps) / fixed) : 1;
+ const h = Math.max(2, evenDown(rect.height * fit));
+ const widths = boxes.map((b) => (b ? evenDown((b.width * h) / b.height) : 0));
+ const rest = rect.width - widths.reduce((a, b) => a + b, 0) - gaps;
+ const noteW = items.includes("note") && rest >= SHELF_NOTE_MIN * k ? evenDown(rest) : 0;
+ const slots = {};
+ let x = rect.x;
+ const y = rect.y + Math.round((rect.height - h) / 2);
+ items.forEach((it, i) => {
+ const w = it === "note" ? noteW : widths[i];
+ if (!w) return;
+ slots[it] = it === "note" ? { x, y: rect.y, width: w, height: evenDown(rect.height) } : { x, y, width: w, height: h };
+ x += w + gap;
+ });
+ return { rect, slots };
+}
+
/**
* The promise clock's slot in the instruments' column: the trail's (it yields
* while the clock is up), else the column's foot as tall as the trail would be.
@@ -739,10 +807,15 @@ export function promiseStripType(rect, render, chars) {
export function measureExtraGeometry(id, render, { feed = false } = {}) {
const cfg = resolveMeasureExtra(id, render) ?? resolveMeasureExtra(id, { chrome: { deck: {} } });
if (id === "promise" && cfg.slot === "column") return promiseColumnRect(render);
+ // On the shelf: its slot there (shelfLayout).
+ if (cfg.position === SHELF_POSITION) {
+ const slot = shelfLayout(render)?.slots[id];
+ if (slot) return { ...slot };
+ }
const g = deckGeometry(render);
const f = feed ? feedGeometry(render).footage : g.footage;
const k = (g.W / 1920) * (cfg.scale ?? 1);
- const box = MEASURE_BOXES[id];
+ const box = measureBox(id, render);
const width = Math.min(even(box.width * k), even(g.W));
const height = Math.min(even(box.height * k), even(g.H));
let x;
@@ -794,7 +867,7 @@ export function anchorRect(id, render, anchor, size = 1, { feed = false } = {})
const g = deckGeometry(render);
const f = feed ? feedGeometry(render).footage : g.footage;
const k = (g.W / 1920) * (cfg.scale ?? 1) * size;
- const box = MEASURE_BOXES[id];
+ const box = measureBox(id, render);
const width = Math.min(even(box.width * k), even(f.width));
const height = Math.min(even(box.height * k), even(f.height));
const inset = Math.round(24 * (g.W / 1920));
@@ -864,6 +937,9 @@ function carveSpans(spans, from, to) {
export function measurePlacements(schedule, render, { finaleSlot = null } = {}) {
const feed = schedule?.layout === "feed";
const covers = schedule ? measureCovers(schedule, render) : [];
+ // A module on the shelf stands in its own slot there, clear of the footage: nothing covers it, so it never
+ // dodges and nothing dodges around it (only an entry's hideModules hides it).
+ const shelved = (id) => resolveMeasureExtra(id, render)?.position === SHELF_POSITION;
const out = {};
for (const id of MEASURE_EXTRAS) {
const home = measureExtraGeometry(id, render, { feed });
@@ -891,7 +967,7 @@ export function measurePlacements(schedule, render, { finaleSlot = null } = {})
for (const id of MEASURE_EXTRAS) if (!out[id].up.length && resolveMeasureExtra(id, render)) out[id].up = upOf(id, schedule, render);
DODGE_ORDER.forEach((a, i) => {
for (const b of DODGE_ORDER.slice(i + 1)) {
- if (!resolveMeasureExtra(a, render) || !resolveMeasureExtra(b, render) || !intersects(out[a].home, out[b].home)) continue;
+ if (!resolveMeasureExtra(a, render) || !resolveMeasureExtra(b, render) || shelved(a) || shelved(b) || !intersects(out[a].home, out[b].home)) continue;
if ((a === "promise" || b === "promise") && inColumn) continue;
for (const sa of out[a].up) for (const sb of out[b].up) {
const from = Math.max(sa.in, sb.in);
@@ -906,7 +982,7 @@ export function measurePlacements(schedule, render, { finaleSlot = null } = {})
const hit = (r) => c.rects.some((b) => intersects(r, b));
// (The promise clock is not moved by a post card here: in the column nothing in the footage meets it, and in
// the footage box it becomes the strip above.)
- const skip = (id) => id === "promise" && (inColumn || c.kind === "post");
+ const skip = (id) => shelved(id) || (id === "promise" && (inColumn || c.kind === "post"));
const active = DODGE_ORDER.filter((id) => !skip(id) && resolveMeasureExtra(id, render) && overlapsSpan(out[id].up, c.from, c.to) && (!c.only || c.only === id));
// The modules that stay where they are take their homes first.
const taken = [];
@@ -919,7 +995,7 @@ export function measurePlacements(schedule, render, { finaleSlot = null } = {})
}
// Every other extra up in the span keeps its place: no slot onto it.
for (const id of DODGE_ORDER) {
- if (active.includes(id) || (id === "promise" && inColumn) || !resolveMeasureExtra(id, render) || !overlapsSpan(out[id].up, c.from, c.to)) continue;
+ if (active.includes(id) || shelved(id) || (id === "promise" && inColumn) || !resolveMeasureExtra(id, render) || !overlapsSpan(out[id].up, c.from, c.to)) continue;
taken.push(out[id].home);
}
const footage = feed ? feedGeometry(render).footage : deckGeometry(render).footage;
diff --git a/umtool/report-to-video/modules/contract.mjs b/umtool/report-to-video/modules/contract.mjs
@@ -52,9 +52,10 @@ export const MODULE_KINDS = Object.freeze([
* band at the foot of the frame, the posts column, the stamp's box in the
* footage, the footage box itself, the side panel beside it, a popup column
* over the footage, the measure's instruments' column at the frame's right
- * (instruments.mjs), the whole frame, or `inline` (a part, in its host's slot).
+ * (instruments.mjs), the shelf beside the footage (`deck.shelf`: deckGeometry's
+ * `shelf`), the whole frame, or `inline` (a part, in its host's slot).
*/
-export const MODULE_SLOTS = Object.freeze(["footer", "column", "popup", "stamp", "panel", "footage", "side", "instruments", "full", "inline"]);
+export const MODULE_SLOTS = Object.freeze(["footer", "column", "popup", "stamp", "panel", "footage", "side", "instruments", "shelf", "full", "inline"]);
/**
* The clocks a module's live page is seeked on (`play.clock`): the cut's
diff --git a/umtool/report-to-video/modules/diet.mjs b/umtool/report-to-video/modules/diet.mjs
@@ -8,6 +8,7 @@
import { dietHtml } from "../chrome-measure-extras.mjs";
import { dietStates } from "../measure-extras.mjs";
import { measureExtraModule } from "./measure-extras-module.mjs";
+import { DIET_FORMS, DIET_TAGS } from "./measure-extras-settings.mjs";
export default measureExtraModule({
id: "diet",
@@ -20,6 +21,8 @@ export default measureExtraModule({
ui: [
{ key: "colors", type: "object", label: "Ink per regime ({keto: \"#E0913C\", …})" },
{ key: "labels", type: "object", label: "Words per regime ({glp1: \"Ozempic\", …})" },
+ { key: "form", type: "enum", options: DIET_FORMS, label: "Drawn as (default: the stamp, the tags on the shelf)" },
+ { key: "tags", type: "number", min: DIET_TAGS[0], max: DIET_TAGS[1], step: 1, label: "Tags in the row", default: 3, when: { form: "tags" } },
],
docs: {
intro: "The diet he names as a rubber stamp in a corner of the footage box (`render.chrome.deck.diet`, measure-extras.mjs): at each change of the state's diet -- its regime or its diet number -- a new stamp slams on (in big and turned, onto the page, a shake), the regime's word in its ink and \"DIET #n\" under it with the ledger's words when they say more (\"Keto · 5 carbs a day\"); a change of words alone fades the new stamp in. A null diet after one fades to \"NO DIET\" in grey. It draws `state.diet` as the measure slice gives it -- the off-scope rule (\"off GLP-1\" while on keto is still keto) is the ledger's. The inks default to the quartering-diet regimes' (keto #E0913C, carnivore #C9534B, fasting #4E9BD8, calories #3FA9A0, glp1 #B168C6, other #8E97A8, off #98A29B).",
@@ -27,6 +30,7 @@ export default measureExtraModule({
["`deck.diet`", "`true` · `false` · `{show, position, x, y, scale, hold, finale, colors, labels}` · default on with a measure slice", "`umtool look <p> deck.diet=false`"],
["`deck.diet.position`, `.x`/`.y`, `.scale`", "an anchor in the footage box · design px · 0.5–2 · default `bottom-left`, unset, 1", "`umtool look <p> deck.diet.position=top-right`"],
["`deck.diet.hold`, `.finale`", "0 (up from the first diet on) or 2–600 s · `hide` `show` · default 0, `hide`", "`umtool look <p> deck.diet.hold=15`"],
+ ["`deck.diet.form`, `.tags`", "`stamp` · `tags`: the last `tags` diets as a row of dated tags -- each a small stamp with the regime's word in its ink, \"DIET #n\" and the ledger's words (less the regime they open with: \"5 carbs a day\"), and the day he switched to it (`state.diet.since`, \"Mar 14, 2025\"; new words for the same diet keep that day); at each change the new tag slams in at the left, the older slide right and dim, the one past `tags` falls off; a change of words alone fades the new tag over the old; a null diet is a grey \"NO DIET\" tag with its date · 1–4 · default `stamp` (`tags` on the shelf), 3", "`umtool look <p> deck.diet.form=tags deck.diet.tags=2`"],
["`deck.diet.colors`, `.labels`", "`{<regime>: #hex}` · `{<regime>: words ≤40}` · default the regimes' inks and names", "`umtool look <p> deck.diet.labels='{\"glp1\":\"Ozempic\"}'`"],
],
},
diff --git a/umtool/report-to-video/modules/index.mjs b/umtool/report-to-video/modules/index.mjs
@@ -40,12 +40,13 @@ import peak from "./peak.mjs";
import goals from "./goals.mjs";
import promise from "./promise.mjs";
import streak from "./streak.mjs";
+import shelf from "./shelf.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, sectionTitle, counter, claims, feed, popupPosts, stamp, stats, fx, threads, flips, finale, teaser, intro, blur, pair, chapter, status, chat, diet, peak, goals, promise, streak, dial, odometer, trail, dialFinale]
+ [chart, shell, subtitle, qr, rail, sectionTitle, counter, claims, feed, popupPosts, stamp, stats, fx, threads, flips, finale, teaser, intro, blur, pair, chapter, status, chat, shelf, diet, peak, goals, promise, streak, dial, odometer, trail, dialFinale]
.sort((a, b) => a.z - b.z || a.id.localeCompare(b.id)),
);
@@ -141,6 +142,8 @@ export function scheduleSlices(doc) {
// The measure ledger's slice (measure-slice.mjs): every instrument module
// (dial, odometer, trail, goals, peak, promise, diet) reads it whole.
...(doc.measure ? { measure: doc.measure } : {}),
+ // The shelf's notes (`deck.shelf`, an entry's shelfNote): only with one on the shelf.
+ ...(doc.shelf ? { shelf: doc.shelf } : {}),
};
return out;
}
diff --git a/umtool/report-to-video/modules/layout.mjs b/umtool/report-to-video/modules/layout.mjs
@@ -58,6 +58,11 @@ export function slotRect(slot, render, { feed = false } = {}) {
}
case "instruments":
return { ...instrumentsGeometry(render).column };
+ case "shelf": {
+ // The shelf (`deck.shelf`); without one, an empty strip at the footage's foot.
+ const g = deckGeometry(render);
+ return g.shelf ? { ...g.shelf } : { x: g.footage.x, y: g.footage.y + g.footage.height, width: g.footage.width, height: 0 };
+ }
case "full":
return { x: 0, y: 0, width: render?.width ?? DESIGN.width, height: render?.height ?? DESIGN.height };
default:
diff --git a/umtool/report-to-video/modules/measure-extras-module.mjs b/umtool/report-to-video/modules/measure-extras-module.mjs
@@ -11,14 +11,15 @@ import { measureExtraGeometry, measureOf } from "../measure-extras.mjs";
import { placementsFor } from "../chrome-measure-extras.mjs";
import { assertRegion, defineModule } from "./contract.mjs";
import {
- MEASURE_AVOID, MEASURE_DEFAULTS, MEASURE_FINALE, MEASURE_LIMITS, MEASURE_POSITIONS, resolveMeasureExtra,
+ MEASURE_AVOID, MEASURE_DEFAULTS, MEASURE_FINALE, MEASURE_LIMITS, MEASURE_POSITIONS, resolveMeasureExtra, SHELF_POSITION,
} from "./measure-extras-settings.mjs";
+import { SHELF_EXTRAS } from "./shelf-settings.mjs";
import { settingsOf } from "./settings.mjs";
/** The ui fields every one of the four has: on, where, how big, how long, over the finale. */
const commonUi = (id) => [
{ key: "show", type: "boolean", label: "Drawn (with a measure slice)", default: true },
- { key: "position", type: "enum", options: MEASURE_POSITIONS, label: "Anchor in the footage", default: MEASURE_DEFAULTS[id].position },
+ { key: "position", type: "enum", options: SHELF_EXTRAS.includes(id) ? [...MEASURE_POSITIONS, SHELF_POSITION] : MEASURE_POSITIONS, label: SHELF_EXTRAS.includes(id) ? "Anchor in the footage, or the shelf" : "Anchor in the footage", default: MEASURE_DEFAULTS[id].position },
{ key: "x", type: "number", min: MEASURE_LIMITS.x[0], max: MEASURE_LIMITS.x[1], label: "x (design px, with y: overrides the anchor)" },
{ key: "y", type: "number", min: MEASURE_LIMITS.y[0], max: MEASURE_LIMITS.y[1], label: "y (design px)" },
{ key: "scale", type: "number", min: MEASURE_LIMITS.scale[0], max: MEASURE_LIMITS.scale[1], step: 0.05, label: "Scale", default: 1 },
@@ -57,6 +58,7 @@ export function measureExtraModule(spec) {
rows: [
...spec.docs.rows,
[`\`deck.${id}.onPosts\`, \`.onChapters\``, "`dodge` `hide` `show` · default `dodge`: while a post item's card (its card, slot and strip as postLayout lays them: the schedule's `covers`) or a chapter band is up where it stands, it moves to a free anchor of the footage box -- a size down to half if it must, never onto another measure extra that is up -- and hides when none fits; `hide` hides, `show` stays over it", `\`umtool look <p> deck.${id}.onPosts=hide\``],
+ ...(SHELF_EXTRAS.includes(id) ? [[`\`deck.${id}.position=shelf\``, `in its own slot on the shelf (\`deck.shelf\`: under or over the footage), scaled to the shelf's height, left to right in \`deck.shelf.items\` order -- nothing covers it there, so it never dodges (\`onPosts\`, \`onChapters\`, \`x\`/\`y\`, \`scale\` and \`avoid\` do not apply), and it is over the finale as the shelf is (\`deck.shelf.finale\`)`, `\`umtool look <p> deck.shelf=true deck.${id}.position=shelf\``]] : []),
["a timeline entry's `hideModules`", `\`["${id}", …]\` on an entry hides it over that entry's span, with its own fade, whatever it would otherwise do there (text in the footage no dodge can know of) · any entry, a post item too`, `\`umtool set <p> <entry> hideModules=${id}\` (\`--take <t>\` for a take)`],
],
},
diff --git a/umtool/report-to-video/modules/measure-extras-settings.mjs b/umtool/report-to-video/modules/measure-extras-settings.mjs
@@ -9,7 +9,7 @@
// render.chrome.deck.goals { show, position, x, y, scale, hold, finale, max, color, countdown }
// render.chrome.deck.peak { show, position, x, y, scale, hold, finale, title, color, values }
// render.chrome.deck.promise { show, position, x, y, scale, hold, finale, label, verb, kept, broken, checks, speakers, claimVerb, claimColor }
-// render.chrome.deck.diet { show, position, x, y, scale, hold, finale, colors, labels }
+// render.chrome.deck.diet { show, position, x, y, scale, hold, finale, colors, labels, form, tags }
// render.chrome.deck.streak { show, position, x, y, scale, hold, finale, source, axis, title, color, colors, labels }
//
// Each is ON whenever the cut has a measure slice (the build writes one only
@@ -30,11 +30,19 @@
// `scale` sizes it.
import { instrumentsOn, resolveDial } from "../instruments.mjs";
+import { resolveShelf, SHELF_EXTRAS } from "./shelf-settings.mjs";
/** The anchors in the footage box a module may sit at (`position`). */
export const MEASURE_POSITIONS = Object.freeze(["top-left", "top-right", "bottom-left", "bottom-right", "top-center", "bottom-center"]);
/**
+ * The anchors, and the SHELF (`deck.shelf`, shelf-settings.mjs): the strip the
+ * footage leaves beside it, where a module stands in its own slot, clear of
+ * everything (no dodging there). Diet, streak, goals and peak may take it.
+ */
+export const SHELF_POSITION = "shelf";
+
+/**
* What a module does when a post item's card (`onPosts`) or a chapter band
* (`onChapters`) is up where it stands: moves to a slot clear of it (a size
* down if it must, hidden when nothing fits), hides, or stays (drawn over it).
@@ -56,6 +64,12 @@ export const STREAK_AXES = Object.freeze(["date", "runs"]);
/** What a promise check's line quotes (`promise.checks`): the ledger row's label, or its transcript quote. */
export const PROMISE_CHECKS = Object.freeze(["label", "quote"]);
+/** How the diet is drawn (`diet.form`): the stamp that slams on, or a row of dated tags, the newest first. */
+export const DIET_FORMS = Object.freeze(["stamp", "tags"]);
+
+/** How many tags the diet's row keeps (`diet.tags`). */
+export const DIET_TAGS = Object.freeze([1, 4]);
+
/** The diet regimes the ledger names (ledgerSchema.regimes), and what the badge calls each. */
export const DIET_LABELS = Object.freeze({
keto: "Keto", carnivore: "Carnivore", fasting: "Fasting", calories: "Counting calories",
@@ -101,7 +115,8 @@ export const MEASURE_DEFAULTS = Object.freeze({
promise: Object.freeze({ ...COMMON, position: "top-center", finale: "show", label: null, verb: "offered", kept: "Posted", broken: "None posted", checks: "label",
speakers: Object.freeze({}), claimVerb: "paid", claimColor: "#E37AB8", slot: "auto" }),
// The diet badge: up from the first diet on, re-stamped at every change.
- diet: Object.freeze({ ...COMMON, position: "bottom-left", colors: Object.freeze({}), labels: Object.freeze({}) }),
+ // `form` "tags" (the default on the shelf): the last `tags` diets as dated tags, the newest slammed in at the left.
+ diet: Object.freeze({ ...COMMON, position: "bottom-left", colors: Object.freeze({}), labels: Object.freeze({}), form: "stamp", tags: 3 }),
// The streak chain: bottom-centre, between the diet badge and the goal
// stack, so either or both can run. `title` null is the source's own word.
streak: Object.freeze({ ...COMMON, position: "bottom-center", source: "diet", axis: "date", title: null, color: null, colors: Object.freeze({}), labels: Object.freeze({}) }),
@@ -147,6 +162,17 @@ export function resolveMeasureExtra(id, render) {
out.position = COLUMN_POSITIONS[id];
if (own.scale === undefined && COLUMN_SCALES[id]) out.scale = COLUMN_SCALES[id];
}
+ // On the shelf (`deck.shelf.items` names it, or its own position is "shelf"): its slot there, scaled to the
+ // shelf (shelfLayout); over the finale as the shelf is; the diet as its dated tags unless a form is named.
+ const shelf = resolveShelf(render);
+ if (shelf && SHELF_EXTRAS.includes(id) && (shelf.items.includes(id) || own.position === SHELF_POSITION)) {
+ out.position = SHELF_POSITION;
+ out.finale = shelf.finale;
+ if (id === "diet" && own.form === undefined) out.form = "tags";
+ } else if (out.position === SHELF_POSITION) {
+ // No shelf to stand on (validateMeasureExtra says so): its default anchor, so a stray key draws something.
+ out.position = MEASURE_DEFAULTS[id].position;
+ }
// Where the promise clock stands: the column's trail slot when the instruments are on ("auto").
if (id === "promise") out.slot = out.slot === "auto" ? (instrumentsOn(render) ? "column" : "footage") : out.slot;
if (id === "diet" || id === "streak") {
@@ -175,7 +201,7 @@ const color = (v, where, errors) => {
* @param {"goals" | "peak" | "promise" | "diet"} id
* @returns {string[]}
*/
-export function validateMeasureExtra(id, v, where = `render.chrome.deck.${id}`) {
+export function validateMeasureExtra(id, v, where = `render.chrome.deck.${id}`, { chrome = null } = {}) {
if (v === undefined || typeof v === "boolean") return [];
const keys = Object.keys(MEASURE_DEFAULTS[id]);
if (!isObj(v)) return [`${where} must be true, false or { ${keys.join(", ")} }`];
@@ -183,8 +209,13 @@ export function validateMeasureExtra(id, v, where = `render.chrome.deck.${id}`)
const L = MEASURE_LIMITS;
for (const k of Object.keys(v)) if (!keys.includes(k)) errors.push(`${where}.${k} is not a deck setting (${keys.join(", ")})`);
if (v.show !== undefined && typeof v.show !== "boolean") errors.push(`${where}.show must be true or false`);
- if (v.position !== undefined && !MEASURE_POSITIONS.includes(v.position)) {
- errors.push(`${where}.position must be ${MEASURE_POSITIONS.map((p) => `"${p}"`).join(", ")}`);
+ const shelfOk = SHELF_EXTRAS.includes(id);
+ if (v.position !== undefined && !MEASURE_POSITIONS.includes(v.position) && !(shelfOk && v.position === SHELF_POSITION)) {
+ errors.push(`${where}.position must be ${[...MEASURE_POSITIONS, ...(shelfOk ? [SHELF_POSITION] : [])].map((p) => `"${p}"`).join(", ")}`);
+ }
+ // The shelf is a place only while there is one (`chrome` given: the deck it sits in).
+ if (shelfOk && v.position === SHELF_POSITION && chrome && !resolveShelf({ chrome })) {
+ errors.push(`${where}.position is "shelf", but render.chrome.deck.shelf is off (umtool look <p> deck.shelf=true, or another position)`);
}
for (const k of ["x", "y"]) {
if (v[k] !== undefined && v[k] !== null && !numIn(v[k], L[k][0], L[k][1])) {
@@ -243,6 +274,12 @@ export function validateMeasureExtra(id, v, where = `render.chrome.deck.${id}`)
text(v.title, L.text, `${where}.title`, errors);
color(v.color, `${where}.color`, errors);
}
+ if (id === "diet") {
+ if (v.form !== undefined && !DIET_FORMS.includes(v.form)) errors.push(`${where}.form must be "stamp" or "tags"`);
+ if (v.tags !== undefined && !(Number.isInteger(v.tags) && numIn(v.tags, DIET_TAGS[0], DIET_TAGS[1]))) {
+ errors.push(`${where}.tags must be a whole number from ${DIET_TAGS[0]} to ${DIET_TAGS[1]}`);
+ }
+ }
if (id === "diet" || id === "streak") {
for (const k of ["colors", "labels"]) {
if (v[k] === undefined) continue;
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", "chat", "pair", "chapter", "status", "finale", "claims", "measure", "counter", "shell", "rail", "section-title", "subtitle", "qr", "popup-posts", "dial", "odometer", "trail", "diet", "peak", "goals", "promise", "streak"]);
+ assert.deepEqual(SETTINGS.map((s) => s.id), ["stamp", "threads", "flips", "stats", "fx", "chat", "pair", "chapter", "status", "finale", "claims", "measure", "counter", "shell", "rail", "section-title", "subtitle", "qr", "popup-posts", "dial", "odometer", "trail", "diet", "peak", "goals", "promise", "streak", "shelf"]);
});
diff --git a/umtool/report-to-video/modules/registry.test.mjs b/umtool/report-to-video/modules/registry.test.mjs
@@ -47,8 +47,9 @@ test("the registry: unique ids and regions, sorted by z, the deck's overlays in
assert.equal(new Set(ids).size, ids.length);
for (let i = 1; i < MODULES.length; i += 1) assert.ok(MODULES[i - 1].z <= MODULES[i].z);
// The order the build has always laid them in, the measure's instruments beside the side panel; the
- // finale over all of them but the dial's finale and the promise clock, drawn over it (z 95 both).
- assert.deepEqual(deckOverlays().map((m) => m.region), ["deck", "feed", "posts", "stamp", "chat", "stats", "pair", "status", "fx", "streak", "diet", "peak", "goals", "threads", "dial", "odometer", "trail", "flips", "chapter", "finale", "dial-finale", "promise"]);
+ // finale over all of them but the dial's finale and the promise clock, drawn over it (z 95 both); the shelf's
+ // note page under the measure extras (it never meets them: they stand in slots of their own beside it).
+ assert.deepEqual(deckOverlays().map((m) => m.region), ["deck", "feed", "posts", "stamp", "chat", "stats", "pair", "status", "fx", "shelf", "streak", "diet", "peak", "goals", "threads", "dial", "odometer", "trail", "flips", "chapter", "finale", "dial-finale", "promise"]);
assert.equal(moduleOfRegion("deck").id, "shell");
assert.equal(regionModule("posts").id, "popup-posts");
assert.throws(() => regionModule("nope"), /unknown chrome region: nope/);
@@ -152,7 +153,7 @@ test("play: a live-preview contract only an overlay with a page and regions decl
assert.throws(() => defineModule({ ...base, play: { clock: "cut", ready: "x" } }), /play must be/);
assert.throws(() => defineModule({ ...base, page: undefined, play: { clock: "cut", ready: "x:ready" } }), /only an overlay with a page/);
assert.throws(() => defineModule({ ...base, kind: "segment", play: { clock: "cut", ready: "x:ready" } }), /only an overlay with a page/);
- assert.deepEqual(playModules().map((m) => m.id), ["stats", "pair", "status", "fx", "streak", "diet", "peak", "goals", "threads", "dial", "odometer", "trail", "flips", "chapter", "dial-finale", "promise"]);
+ assert.deepEqual(playModules().map((m) => m.id), ["stats", "pair", "status", "fx", "shelf", "streak", "diet", "peak", "goals", "threads", "dial", "odometer", "trail", "flips", "chapter", "dial-finale", "promise"]);
for (const m of playModules()) assert.equal(m.play.ready, `${m.region}:ready`, m.id);
});
diff --git a/umtool/report-to-video/modules/settings.mjs b/umtool/report-to-video/modules/settings.mjs
@@ -22,6 +22,7 @@ import { MARKER_LEVELS, MARKER_LIMITS } from "../marker-limits.mjs";
import { validateDial, validateOdometer, validateTrail } from "../instruments.mjs";
import { MEASURE_EXTRAS, validateMeasureExtra } from "./measure-extras-settings.mjs";
import { validateMeasureSettings } from "../measure-slice.mjs";
+import { validateShelf } from "./shelf-settings.mjs";
/**
* Every deck setting and its default. A manifest names only what it changes;
@@ -491,8 +492,11 @@ export const SETTINGS = Object.freeze([
// start, the promise clock and the diet badge, each its own deck key.
...MEASURE_EXTRAS.map((id) => ({
id, key: `deck.${id}`, configKey: `render.chrome.deck.${id}`, deck: true,
- validate: (v, { where }) => validateMeasureExtra(id, v, `${where}.${id}`),
+ validate: (v, { where, chrome }) => validateMeasureExtra(id, v, `${where}.${id}`, { chrome }),
})),
+ // The shelf (shelf-settings.mjs): the strip beside the footage its occupants stand in.
+ { id: "shelf", key: "deck.shelf", configKey: "render.chrome.deck.shelf", deck: true,
+ validate: (v, { where, chrome }) => validateShelf(v, `${where}.shelf`, chrome) },
].map((s) => Object.freeze(s)));
/** A module's settings entry, or undefined. */
diff --git a/umtool/report-to-video/modules/shelf-settings.mjs b/umtool/report-to-video/modules/shelf-settings.mjs
@@ -0,0 +1,128 @@
+// THE SHELF'S SETTINGS (weight video, variant A): a strip of the frame cleared
+// beside the footage -- under it, or over it -- for whatever the video wants in
+// view without standing on the picture: the diet's dated tags, the streak
+// chain, a goal stack, an entry's note. `render.chrome.deck.shelf`:
+//
+// { show, side: "below" | "above", items: [...], gap, finale: "hide" | "show" }
+//
+// Absent (or false), there is no shelf and the footage stands where it always
+// did. On, deck.mjs deckGeometry moves the footage to the frame's top (`below`)
+// or down onto the deck (`above`), and the strip it leaves is the shelf; its
+// occupants (measure-extras.mjs shelfLayout) stand in it left to right in
+// `items` order, each at its own width scaled to the shelf's height.
+//
+// A LEAF: no imports. deck.mjs and measure-extras-settings.mjs read it, and both
+// are read by files it must not cycle through.
+
+/** Where the shelf stands: under the footage (the footage at the frame's top), or over it (the footage on the deck). */
+export const SHELF_SIDES = Object.freeze(["below", "above"]);
+
+/** What the shelf does over the finale's window: hidden under it (its occupants with it), or drawn over it. */
+export const SHELF_FINALE = Object.freeze(["hide", "show"]);
+
+/** What may stand on the shelf: the measure extras that take `position: "shelf"`, and an entry's `shelfNote`. */
+export const SHELF_ITEMS = Object.freeze(["diet", "streak", "goals", "peak", "note"]);
+
+/** The measure extras among them. */
+export const SHELF_EXTRAS = Object.freeze(SHELF_ITEMS.filter((i) => i !== "note"));
+
+/** The least room the shelf needs, frame px (at 1080): less, and the footage must shrink. */
+export const SHELF_MIN = 72;
+
+/** An entry's note on the shelf (`shelfNote`): at most this many characters. */
+export const SHELF_NOTE_MAX = 80;
+
+/** Bounds: the air between two occupants, design px. */
+export const SHELF_LIMITS = Object.freeze({ gap: Object.freeze([0, 64]) });
+
+/** The shelf's settings and their defaults (`items` null: the extras whose position is "shelf", then the note). */
+export const SHELF_DEFAULTS = Object.freeze({ show: true, side: "below", items: null, gap: 16, finale: "hide" });
+
+const isObj = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
+
+/**
+ * The shelf with its defaults filled, or null when there is none (absent,
+ * `false`, `show: false`). `items` resolved: the list as written, or -- unset
+ * -- the measure extras whose own `position` is "shelf" (in SHELF_ITEMS order),
+ * then `note`.
+ *
+ * @returns {{ show: true, side: "below" | "above", items: string[], gap: number, finale: "hide" | "show" } | null}
+ */
+export function resolveShelf(render) {
+ const deck = render?.chrome?.deck;
+ const v = isObj(deck) ? deck.shelf : undefined;
+ if (v === undefined || v === null || v === false) return null;
+ const own = isObj(v) ? v : {};
+ if (own.show === false) return null;
+ const items = Array.isArray(own.items)
+ ? own.items.filter((i) => SHELF_ITEMS.includes(i))
+ : [...SHELF_EXTRAS.filter((id) => isObj(deck[id]) && deck[id].position === "shelf"), "note"];
+ return {
+ show: true,
+ side: SHELF_SIDES.includes(own.side) ? own.side : SHELF_DEFAULTS.side,
+ items,
+ gap: typeof own.gap === "number" && Number.isFinite(own.gap) ? own.gap : SHELF_DEFAULTS.gap,
+ finale: SHELF_FINALE.includes(own.finale) ? own.finale : SHELF_DEFAULTS.finale,
+ };
+}
+
+/** Is `id` (a measure extra) on the shelf: the shelf on and its items naming it. */
+export const onShelf = (id, render) => !!resolveShelf(render)?.items.includes(id);
+
+/**
+ * Every reason `render.chrome.deck.shelf` cannot be drawn, as sentences: its
+ * own keys, and against the deck it sits in -- an item that puts a measure
+ * extra on the shelf while the extra's `position` names somewhere else, or one
+ * whose position is "shelf" that an explicit `items` leaves out. (The room it
+ * needs is the deck's to check: deck.mjs validateChrome, with the geometry.)
+ *
+ * @returns {string[]}
+ */
+export function validateShelf(v, where = "render.chrome.deck.shelf", chrome = {}) {
+ if (v === undefined || typeof v === "boolean") return [];
+ const keys = Object.keys(SHELF_DEFAULTS);
+ if (!isObj(v)) return [`${where} must be true, false or { ${keys.join(", ")} }`];
+ const errors = [];
+ for (const k of Object.keys(v)) if (!keys.includes(k)) errors.push(`${where}.${k} is not a shelf setting (${keys.join(", ")})`);
+ if (v.show !== undefined && typeof v.show !== "boolean") errors.push(`${where}.show must be true or false`);
+ if (v.side !== undefined && !SHELF_SIDES.includes(v.side)) errors.push(`${where}.side must be "below" or "above"`);
+ if (v.finale !== undefined && !SHELF_FINALE.includes(v.finale)) errors.push(`${where}.finale must be "hide" or "show"`);
+ const [lo, hi] = SHELF_LIMITS.gap;
+ if (v.gap !== undefined && !(typeof v.gap === "number" && Number.isFinite(v.gap) && v.gap >= lo && v.gap <= hi)) {
+ errors.push(`${where}.gap must be from ${lo} to ${hi} (design px between two items)`);
+ }
+ if (v.items !== undefined && v.items !== null) {
+ if (!Array.isArray(v.items) || !v.items.every((i) => SHELF_ITEMS.includes(i)) || new Set(v.items).size !== v.items.length) {
+ errors.push(`${where}.items must be a list of distinct items (${SHELF_ITEMS.join(", ")})`);
+ } else if (v.show !== false) {
+ const deck = isObj(chrome?.deck) ? chrome.deck : {};
+ for (const id of SHELF_EXTRAS) {
+ const pos = isObj(deck[id]) ? deck[id].position : undefined;
+ if (v.items.includes(id) && pos !== undefined && pos !== "shelf") {
+ errors.push(`${where}.items puts ${id} on the shelf, but render.chrome.deck.${id}.position is "${pos}" (position "shelf", or take it out of items)`);
+ }
+ if (!v.items.includes(id) && pos === "shelf") {
+ errors.push(`render.chrome.deck.${id}.position is "shelf", but ${where}.items leaves it out (add it, or another position)`);
+ }
+ }
+ }
+ }
+ return errors;
+}
+
+/**
+ * An entry's `shelfNote` as written: `{ value, error }` -- the words trimmed
+ * (null for none: the key removed), `error` a sentence when they are not one
+ * line of at most SHELF_NOTE_MAX characters.
+ *
+ * @returns {{ value: string | null, error: string | null }}
+ */
+export function parseShelfNote(v) {
+ if (v === null || v === undefined || v === "" || v === false) return { value: null, error: null };
+ if (typeof v !== "string") return { value: null, error: `shelfNote is words, not ${JSON.stringify(v)}` };
+ const s = v.trim();
+ if (!s) return { value: null, error: null };
+ if (/[\r\n]/.test(s)) return { value: null, error: "shelfNote must be one line" };
+ if ([...s].length > SHELF_NOTE_MAX) return { value: null, error: `shelfNote is ${[...s].length} characters (at most ${SHELF_NOTE_MAX})` };
+ return { value: s, error: null };
+}
diff --git a/umtool/report-to-video/modules/shelf.mjs b/umtool/report-to-video/modules/shelf.mjs
@@ -0,0 +1,71 @@
+// THE SHELF (module `shelf`, region `shelf`): a strip cleared beside the footage
+// -- under it (the footage moved to the frame's top) or over it -- for what a
+// video wants in view without standing on the picture (`render.chrome.deck.shelf`,
+// shelf-settings.mjs; deck.mjs deckGeometry moves the footage and names the
+// strip). Its occupants stand in it left to right (measure-extras.mjs
+// shelfLayout): the measure extras that take `position: "shelf"` -- the diet's
+// dated tags, the streak chain, a goal stack, the moving start -- each its own
+// module's page in its slot, and an entry's `shelfNote`, drawn by this module's
+// own page (chrome-shelf.mjs) in the slot that is left.
+import path from "node:path";
+
+import { shelfHtml, shelfNoteGeometry, shelfNotes, shelfOn } from "../chrome-shelf.mjs";
+import { assertRegion, defineModule } from "./contract.mjs";
+import { resolveShelf, SHELF_DEFAULTS, SHELF_FINALE, SHELF_ITEMS, SHELF_LIMITS, SHELF_MIN, SHELF_NOTE_MAX, SHELF_SIDES } from "./shelf-settings.mjs";
+import { settingsOf } from "./settings.mjs";
+
+export default defineModule({
+ id: "shelf",
+ version: 1,
+ z: 64,
+ kind: "overlay-whole",
+ slot: "shelf",
+ title: "Shelf",
+ summary: "A strip cleared under (or over) the footage for the diet's dated tags, the streak chain, a goal stack or an entry's note -- nothing on it stands on the picture.",
+ configKey: "render.chrome.deck.shelf",
+ defaults: SHELF_DEFAULTS,
+ validate: settingsOf("shelf").validate,
+ resolve: resolveShelf,
+ ui: [
+ { key: "show", type: "boolean", label: "A shelf beside the footage", default: true },
+ { key: "side", type: "enum", options: SHELF_SIDES, label: "Side of the footage", default: "below" },
+ { key: "items", type: "list", options: SHELF_ITEMS, label: "On it, left to right", help: "default: the measure extras whose position is \"shelf\", then the note" },
+ { key: "gap", type: "number", min: SHELF_LIMITS.gap[0], max: SHELF_LIMITS.gap[1], label: "Air between two (design px)", default: SHELF_DEFAULTS.gap },
+ { key: "finale", type: "enum", options: SHELF_FINALE, label: "Over the finale", default: "hide" },
+ ],
+ docs: {
+ heading: "Shelf",
+ intro: `A strip of the frame cleared beside the footage (\`render.chrome.deck.shelf\`, shelf-settings.mjs): the footage moves to the frame's top, \`railGap\` (24 px) in (\`side: "below"\`), or down onto the deck (\`"above"\`), and what it leaves -- as wide as the footage, 24 px clear of it and of the frame's edge or the deck -- is the shelf (beside the instruments' column, 1248×116 at (24, 750)). Everything that reads the footage box (the instruments, the posts, the chapter band, the finale, Play) follows it. Its occupants stand in it left to right in \`items\` order, \`gap\` apart, each at its own width scaled to the shelf's height (all a size down together when they would not fit): the measure extras that take \`position: "shelf"\` -- \`diet\` (its dated tags by default: \`deck.diet.form\`), \`streak\`, \`goals\`, \`peak\` -- and \`note\`, an entry's \`shelfNote\` in the width left (a chip that comes and goes with its entry; at least 160 px). Nothing covers the shelf, so its occupants never dodge a post card or a chapter band (an entry's \`hideModules\` still hides one). It needs ${SHELF_MIN} px of room or the deck refuses, naming the way out (a smaller \`footageScale\`, or \`subtitle.lines 1\`): with the instruments' column it is 116 px, 77 with \`subtitle.lines: 2\`; full-width footage at the default 0.82 leaves none. Off (absent, \`false\`), the footage stands where it always did.`,
+ rows: [
+ ["`deck.shelf`", "`true` · `false` · `{show, side, items, gap, finale}` · default off", "`umtool look <p> deck.shelf=true deck.diet.position=shelf deck.streak.position=shelf`"],
+ ["`deck.shelf.side`", "`below` (the footage at the top) · `above` (the footage on the deck) · default `below`", "`umtool look <p> deck.shelf.side=above`"],
+ ["`deck.shelf.items`", `a list of distinct ${SHELF_ITEMS.map((i) => `\`${i}\``).join(" ")} · default the measure extras whose \`position\` is \`shelf\`, then \`note\`; an extra listed here is on the shelf, and one whose position is \`shelf\` must be listed`, "`umtool look <p> deck.shelf.items='[\"diet\",\"streak\"]'`"],
+ ["`deck.shelf.gap`, `.finale`", `${SHELF_LIMITS.gap.join("–")} design px · \`hide\` \`show\` · default ${SHELF_DEFAULTS.gap}, \`hide\` (its occupants hide over the finale with it)`, "`umtool look <p> deck.shelf.finale=show`"],
+ ["a timeline entry's `shelfNote`", `one line of at most ${SHELF_NOTE_MAX} characters, shown in the shelf's \`note\` slot over the entry's span · any entry`, "`umtool set <p> <entry> shelfNote='Weighed in on camera'` (`shelfNote=` clears it; `--take <t>` for a take)"],
+ ],
+ },
+ region: "shelf",
+ workers: "narrow",
+ noun: "the shelf's",
+ on: shelfOn,
+ check: (schedule, render) => {
+ if (!resolveShelf(render)) return "the shelf region is off (render.chrome.deck.shelf)";
+ if (!shelfNoteGeometry(render)) return "the shelf has no room for a note (\"note\" in render.chrome.deck.shelf.items, and width left beside its other items)";
+ return shelfNotes(schedule, render).length ? null : "the shelf region needs an entry with a shelfNote";
+ },
+ async page(ctx) {
+ const fonts = await ctx.fonts({ regular: "DeckSans", bold: "DeckSansBold" }, { strict: true });
+ return shelfHtml(ctx.schedule, ctx.render, { fonts, from: ctx.from, duration: ctx.duration });
+ },
+ regions(schedule, { render, outDir, frames = null }) {
+ return [assertRegion({
+ name: "shelf", frames: frames ?? path.join(outDir, "chrome", "shelf-frames"),
+ .../** @type {{x:number,y:number,width:number,height:number}} */ (shelfNoteGeometry(render)),
+ })];
+ },
+ preview: (_slice, { render }) => ({ region: "shelf", geometry: shelfNoteGeometry(render) }),
+ // Its page is its live preview: Play the cut seeks it in the cut's seconds (contract.mjs, PLAY).
+ play: { clock: "cut", ready: "shelf:ready" },
+ // A cue interpreter: each note an item, keyed only while it is shown (frame-keys.mjs).
+ frameKeys: { data: "shelf-data", omit: ["init", "cues", "window", "total", "ids"] },
+});
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/shelf.test.mjs b/umtool/report-to-video/shelf.test.mjs
@@ -0,0 +1,204 @@
+// THE SHELF (modules/shelf.mjs, shelf-settings.mjs; deck.mjs deckGeometry,
+// measure-extras.mjs shelfLayout): a strip cleared beside the footage for the
+// diet's dated tags, the streak chain and an entry's note -- and a deck without
+// it laid out exactly as before.
+//
+// Run with: pnpm test:scripts
+import assert from "node:assert/strict";
+import { readFileSync } from "node:fs";
+import path from "node:path";
+import test from "node:test";
+import { fileURLToPath } from "node:url";
+
+import { dietHtml, tagWords, tagWordSize } from "./chrome-measure-extras.mjs";
+import { shelfHtml, shelfNoteGeometry } from "./chrome-shelf.mjs";
+import { deckGeometry, entryShelfNotes, estimateSchedule, instrumentsGeometry, parseShelfNote, validateChrome } from "./deck.mjs";
+import { dietStates, measureExtraGeometry, measurePlacements, shelfLayout } from "./measure-extras.mjs";
+import { slotRect } from "./modules/layout.mjs";
+import { moduleById, moduleProblems, scheduleSlices } from "./modules/index.mjs";
+import { resolveMeasureExtra, validateMeasureExtra } from "./modules/measure-extras-settings.mjs";
+import { resolveShelf, validateShelf } from "./modules/shelf-settings.mjs";
+
+const HERE = path.dirname(fileURLToPath(import.meta.url));
+const MEASURE = JSON.parse(readFileSync(path.join(HERE, "fixtures/measure-extras/measure.json"), "utf8"));
+const PALETTE = { bg: "#0F1312", fg: "#EDF0EC", muted: "#98A29B", accent: "#22AB83", amber: "#E8A33F" };
+const INSTRUMENTS = { dial: true, odometer: true, trail: true };
+const renderOf = (deck = {}) => ({ width: 1920, height: 1080, fps: 30, palette: PALETTE, chrome: { engine: "hyperframes", layout: "deck", deck } });
+const SHELF = { ...INSTRUMENTS, shelf: { items: ["diet", "streak"] }, diet: { position: "shelf" }, streak: { position: "shelf" } };
+const schedule = (extra = {}) => ({ kind: "deck", fps: 30, total: 740, transition: 0.4, segments: [{ id: "a", start: 0, duration: 740, end: 740 }], measure: MEASURE, ...extra });
+const clone = (v) => JSON.parse(JSON.stringify(v));
+
+test("off, the deck is the deck it was: no shelf key, the footage where it stood", () => {
+ for (const deck of [{}, INSTRUMENTS, { ...INSTRUMENTS, shelf: false }, { ...INSTRUMENTS, shelf: { show: false } }]) {
+ const g = deckGeometry(renderOf(deck));
+ assert.equal("shelf" in g, false);
+ assert.equal(resolveShelf(renderOf(deck)), null);
+ assert.equal(shelfLayout(renderOf(deck)), null);
+ }
+ assert.deepEqual(deckGeometry(renderOf(INSTRUMENTS)).footage, { x: 24, y: 94, width: 1248, height: 702 });
+ assert.deepEqual(slotRect("shelf", renderOf(INSTRUMENTS)), { x: 24, y: 796, width: 1248, height: 0 });
+});
+
+test("below: the footage at the frame's top and the shelf under it; above: mirrored; the instruments' column unchanged", () => {
+ const below = deckGeometry(renderOf(SHELF));
+ assert.deepEqual(below.footage, { x: 24, y: 24, width: 1248, height: 702 });
+ assert.deepEqual(below.shelf, { x: 24, y: 750, width: 1248, height: 116 });
+ assert.deepEqual(below.deck, deckGeometry(renderOf(INSTRUMENTS)).deck);
+ const above = deckGeometry(renderOf({ ...SHELF, shelf: { ...SHELF.shelf, side: "above" } }));
+ assert.deepEqual(above.footage, { x: 24, y: 164, width: 1248, height: 702 });
+ assert.deepEqual(above.shelf, { x: 24, y: 24, width: 1248, height: 116 });
+ assert.deepEqual(instrumentsGeometry(renderOf(SHELF)), instrumentsGeometry(renderOf(INSTRUMENTS)));
+ assert.deepEqual(slotRect("shelf", renderOf(SHELF)), below.shelf);
+ assert.deepEqual(validateChrome(renderOf(SHELF).chrome, renderOf(SHELF)), []);
+});
+
+test("shelfLayout: left to right in items order, each scaled to the shelf's height; the note takes the width left", () => {
+ const L = shelfLayout(renderOf(SHELF));
+ assert.deepEqual(L.slots.diet, { x: 24, y: 750, width: 684, height: 116 }, "three tags at 220, 12 apart");
+ assert.deepEqual(L.slots.streak, { x: 724, y: 750, width: 478, height: 116 }, "the streak's 620×150 at 116 high");
+ assert.equal("note" in L.slots, false, "an explicit items list without the note has none");
+ assert.deepEqual(measureExtraGeometry("diet", renderOf(SHELF)), L.slots.diet);
+ // Two tags; the note (in the default items) in what is left.
+ const two = renderOf({ ...INSTRUMENTS, shelf: true, diet: { position: "shelf", tags: 2 }, streak: { position: "shelf" } });
+ assert.deepEqual(resolveShelf(two).items, ["diet", "streak", "note"]);
+ const L2 = shelfLayout(two);
+ assert.equal(L2.slots.diet.width, 452);
+ assert.equal(L2.slots.streak.x, 24 + 452 + 16);
+ assert.deepEqual(L2.slots.note, { x: 24 + 452 + 16 + 478 + 16, y: 750, width: 286, height: 116 });
+ // Two lines in the band: a 77 px shelf, everything a size down.
+ const lines2 = renderOf({ ...SHELF, subtitle: { lines: 2, parts: ["channel", "title", "date", "clock"] } });
+ assert.equal(deckGeometry(lines2).shelf.height, 77);
+ assert.deepEqual(validateChrome(lines2.chrome, lines2), []);
+ assert.ok(shelfLayout(lines2).slots.diet.height <= 77);
+});
+
+test("validation: room for the shelf, and the way out; positions and items that disagree", () => {
+ const full = renderOf({ shelf: true });
+ const [e] = validateChrome(full.chrome, full);
+ assert.match(e, /deck\.shelf needs at least 72px below the footage, but footageScale 0\.82 \(886px of footage\) over a 190px deck leaves 0 \(footageScale at most 0\.69, or render\.chrome\.deck\.shelf=false\)/);
+ assert.deepEqual(validateChrome(renderOf({ shelf: true, footageScale: 0.69 }).chrome, renderOf()), []);
+ const two = renderOf({ shelf: true, footageScale: 0.7, subtitle: { lines: 2 } });
+ assert.match(validateChrome(two.chrome, two)[0], /or subtitle\.lines 1/);
+ const bad = (deck) => validateChrome(renderOf({ ...INSTRUMENTS, ...deck }).chrome, renderOf());
+ assert.match(bad({ diet: { position: "shelf" } }).join(), /diet\.position is "shelf", but render\.chrome\.deck\.shelf is off/);
+ assert.match(bad({ shelf: { items: ["diet"] }, diet: { position: "top-right" } }).join(), /items puts diet on the shelf, but render\.chrome\.deck\.diet\.position is "top-right"/);
+ assert.match(bad({ shelf: { items: ["streak"] }, diet: { position: "shelf" } }).join(), /diet\.position is "shelf", but render\.chrome\.deck\.shelf\.items leaves it out/);
+ assert.match(bad({ shelf: { items: ["dial"] } }).join(), /items must be a list of distinct items/);
+ assert.match(bad({ shelf: { side: "left" } }).join(), /side must be "below" or "above"/);
+ assert.match(bad({ shelf: { nope: 1 } }).join(), /shelf\.nope is not a shelf setting/);
+ assert.match(validateMeasureExtra("promise", { position: "shelf" }).join(), /position must be/, "the promise clock has its own slot");
+ assert.match(validateMeasureExtra("diet", { form: "badge" }).join(), /form must be "stamp" or "tags"/);
+ assert.match(validateMeasureExtra("diet", { tags: 5 }).join(), /tags must be a whole number from 1 to 4/);
+ assert.deepEqual(validateShelf({ side: "above", gap: 8, finale: "show", items: ["note"] }), []);
+ assert.deepEqual(moduleProblems({ render: renderOf(SHELF) }), {});
+ // On the shelf the diet is its tags unless a form is named, and the shelf's finale is the occupants'.
+ assert.equal(resolveMeasureExtra("diet", renderOf(SHELF)).form, "tags");
+ assert.equal(resolveMeasureExtra("diet", renderOf({ ...SHELF, diet: { position: "shelf", form: "stamp" } })).form, "stamp");
+ assert.equal(resolveMeasureExtra("diet", renderOf(INSTRUMENTS)).form, "stamp");
+ assert.equal(resolveMeasureExtra("streak", renderOf({ ...SHELF, shelf: { ...SHELF.shelf, finale: "show" } })).finale, "show");
+});
+
+test("on the shelf nothing dodges: a post card or a chapter band over the footage leaves it where it is; hideModules still hides", () => {
+ const r = renderOf(SHELF);
+ const card = { from: 100, to: 110, rects: [{ x: 24, y: 24, width: 1248, height: 702 }] };
+ const p = measurePlacements(schedule({ covers: [card] }), r);
+ assert.deepEqual(p.diet.moves, []);
+ assert.deepEqual(p.streak.moves, []);
+ assert.deepEqual(p.diet.region, shelfLayout(r).slots.diet);
+ // Off the shelf, the same card moves the badge.
+ const off = measurePlacements(schedule({ covers: [card] }), renderOf(INSTRUMENTS));
+ assert.ok(off.diet.moves.length > 0);
+ const hid = measurePlacements(schedule({ covers: [card], hides: [{ segment: "v02", from: 600, to: 610, modules: ["diet"] }] }), r);
+ assert.deepEqual(hid.diet.moves, [{ from: 600, to: 610, rect: null, size: 1 }]);
+});
+
+test("the diet's tags: each change pushes a dated tag in at the front, the oldest past n falls off, words alone replace the newest", () => {
+ const r = renderOf(SHELF);
+ const states = dietStates(schedule(), r);
+ assert.equal(states[0].tags.length, 1);
+ assert.equal(states[0].diet.since, states[0].tags[0].since);
+ assert.ok(states.every((s) => s.tags.length <= 3));
+ assert.deepEqual(states[3].tags.map((t) => t.id), [3, 2, 1], "the newest first; the fourth diet pushed the first off");
+ assert.ok(states.every((s) => s.tags[0].diet === s.diet || (s.tags[0].diet === null && s.diet === null)));
+ const two = dietStates(schedule(), renderOf({ ...SHELF, diet: { position: "shelf", tags: 2 } }));
+ assert.ok(two.every((s) => s.tags.length <= 2));
+ // A change of words only: the newest tag replaced in place; a null after one: a "No diet" tag pushed in.
+ const m = clone(MEASURE);
+ const k = m.state.findIndex((s) => s.diet?.n === 63);
+ m.state[k + 1] = { ...m.state[k + 1], diet: { ...m.state[k].diet, display: "Keto · strict" } };
+ m.state[m.state.length - 1].diet = null;
+ const s2 = dietStates(schedule({ measure: m }), r);
+ const j = s2.findIndex((s) => s.diet?.detail === "Keto · strict");
+ assert.equal(s2[j].replaced, true);
+ assert.deepEqual(s2[j].tags.slice(1).map((t) => t.id), s2[j - 1].tags.slice(1).map((t) => t.id), "the older tags stay where they were");
+ const last = s2.at(-1);
+ assert.equal(last.tags[0].diet, null);
+ assert.equal(last.replaced, false);
+ // The page: each tag once, with its date; drawn at the shelf's scale.
+ const { html, items } = dietHtml(schedule(), r, { fonts: {} });
+ assert.equal(items.length, new Set(states.flatMap((s) => s.tags.map((t) => t.id))).size);
+ assert.match(html, /<div class="dt">Feb 6, 2018<\/div>/);
+ assert.match(html, /data-k="t0\.s"/);
+ assert.match(html, /\.tg \{ position: absolute; left: 0; top: 0; width: 220px; height: 116px;/);
+ // The regime's word fits its tag: CARNIVORE a size down, KETO at the top size.
+ assert.equal(tagWordSize("Keto"), 44);
+ assert.equal(tagWordSize("Carnivore"), 31);
+});
+
+test("a tag dates the SWITCH: new words for the same diet keep its since; a new diet gets its own; the words lose the regime they repeat", () => {
+ const r = renderOf(SHELF);
+ const m = clone(MEASURE);
+ // Keto #63 named on its day; later the ledger's words change ("5 carbs a day") with a since of their own.
+ const k = m.state.findIndex((s) => s.diet?.n === 63);
+ const keto = m.state[k].diet;
+ m.state[k + 1] = { ...m.state[k + 1], diet: { ...keto, display: "Keto · 2 carbs a day", since: "2026-08-02" } };
+ const s2 = dietStates(schedule({ measure: m }), r);
+ const j = s2.findIndex((s) => s.diet?.detail === "Keto · 2 carbs a day");
+ assert.equal(s2[j].replaced, true);
+ assert.notEqual(s2[j - 1].tags[0].since, "2026-08-02");
+ assert.equal(s2[j].tags[0].since, s2[j - 1].tags[0].since, "the words' day is not the switch's");
+ assert.equal(s2[j].diet.since, s2[j - 1].tags[0].since);
+ // A new diet (a slam) gets the day it was named.
+ const slam = s2.findIndex((s, i) => i > 0 && s.slam);
+ assert.equal(s2[slam].tags[0].since, s2[slam].diet.since);
+ assert.notEqual(s2[slam].tags[0].since, s2[slam - 1].tags[0].since);
+ // The words: the regime they open with dropped where a separator follows it.
+ assert.equal(tagWords("Keto · 5 carbs a day", ["Keto", "keto"]), "5 carbs a day");
+ assert.equal(tagWords("Keto + IF + walking", ["Keto", "keto"]), "Keto + IF + walking");
+ assert.equal(tagWords("Keto", ["Keto", "keto"]), "");
+ const { html } = dietHtml(schedule({ measure: m }), r, { fonts: {} });
+ assert.match(html, /<span class="dd">5 carbs a day<\/span>/);
+ assert.match(html, /<span class="dd">2 carbs a day<\/span>/);
+ assert.doesNotMatch(html, /Aug 2, 2026/);
+});
+
+test("the shelf's note: an entry's shelfNote over its span, only with the shelf on; its own page in the slot left", () => {
+ assert.deepEqual(parseShelfNote(" Day 41 "), { value: "Day 41", error: null });
+ assert.equal(parseShelfNote("").value, null);
+ assert.match(parseShelfNote("a\nb").error, /one line/);
+ assert.match(parseShelfNote("x".repeat(81)).error, /at most 80/);
+ const manifest = (deck) => ({
+ schemaVersion: 1, provenance: { channelSlug: "c", siteOrigin: "https://example.test" }, render: renderOf(deck),
+ timeline: [
+ { type: "clip", id: "c01", video: "v", start: 0, end: 8, title: "T", date: "2026-10-27", shelfNote: "Weighed in on camera" },
+ { type: "clip", id: "c02", video: "v", start: 10, end: 18, title: "T", date: "2026-10-28" },
+ ],
+ });
+ assert.equal("shelf" in estimateSchedule(manifest(INSTRUMENTS)), false, "no shelf: the schedule it always was");
+ const deck = { ...INSTRUMENTS, shelf: { items: ["note"] } };
+ const s = estimateSchedule(manifest(deck));
+ assert.deepEqual(s.shelf.notes.map((n) => [n.segment, n.text, n.from]), [["c01", "Weighed in on camera", 0]]);
+ assert.deepEqual(entryShelfNotes([{ id: "x", shelfNote: "" }], [{ id: "x", start: 0, duration: 1 }]), []);
+ assert.deepEqual(scheduleSlices(s).shelf, s.shelf);
+ const r = renderOf(deck);
+ const mod = moduleById("shelf");
+ assert.equal(mod.on(s, r), true);
+ assert.equal(mod.on(s, renderOf(INSTRUMENTS)), false);
+ assert.deepEqual(shelfNoteGeometry(r), { x: 24, y: 750, width: 1248, height: 116 });
+ const [region] = mod.regions(s, { render: r, outDir: "/o" });
+ assert.deepEqual([region.name, region.frames, region.y, region.height], ["shelf", "/o/chrome/shelf-frames", 750, 116]);
+ const { html, items } = shelfHtml(s, r, { fonts: {} });
+ assert.equal(items.length, 1);
+ assert.match(html, /Weighed in on camera/);
+ assert.match(mod.check(s, renderOf(INSTRUMENTS)), /shelf region is off/);
+});
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);
+});