Archilyzer · Source

archilyzer

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

commit eeac4a1b832af6968e4618003af17deee0b4685f
parent fedddcce4494e444fdcabdcc8fa78bb0c1f94745
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Fri,  6 Nov 2026 12:03:32 -0500

umtool: the shelf -- a strip under (or over) the footage; the diet as dated tags on it

Variant A stamped the diet badge and the diet-runs strip ON the footage, where
post cards and the chapter band pushed them about (and v02's refund email
needed hideModules). The operator: "we clear a space under the video to show
the last n of those cards ... and put the date on that tag graphic ... a module
we can use for other info". Beside the instruments' column the footage is
centred with 94 px empty over and under it; the shelf takes that.
- `render.chrome.deck.shelf` {show, side: below|above, items, gap, finale}
  (modules/shelf-settings.mjs, a leaf; a SETTINGS entry, so the deck's
  validator and moduleProblems run it). Absent or false: no shelf, every
  geometry byte-identical (no `shelf` key in deckGeometry).
- deck.mjs deckGeometry: on, the footage goes to y = railGap (`below`) or onto
  the deck (`above`) and the strip it leaves, railGap clear, is `shelf` (1248x116
  at (24, 750) beside the instruments; 77 with subtitle.lines 2). The
  instruments, posts, chapter band, finale and Play read the footage box from
  it and follow. validateChrome: under 72 px (at 1080) it refuses, naming
  footageScale at most N (or subtitle.lines 1, or shelf=false); the feed is
  refused.
- measure-extras.mjs shelfLayout: the occupants left to right in `items`
  order, `gap` apart, each at its own design box scaled to the shelf's height
  (all a size down together when too wide); the note takes the width left
  (none under 160). `position: "shelf"` for diet, streak, goals and peak (not
  the promise clock: it has its slot); listed in items = on the shelf, and the
  two must agree (validateShelf / validateMeasureExtra say which way out). On
  the shelf: its slot is home, no dodging of post cards, chapter bands or each
  other (hideModules still hides), and its finale is the shelf's (default hide).
- The diet's `form: "tags"` (the default on the shelf; `tags` 1-4, default 3):
  dietStates carries each state's last n diets (`tags`, newest first; a words-
  only change `replaced` in place) and each diet's `since`; dietTagsHtml draws
  each as a small stamp -- the regime word in its ink, DIET #n and the ledger's
  words, and the day he named it (formatDeckDate, "Mar 14, 2025") -- the new
  one slammed in at the left with the stamp's motion, the older sliding right
  and dimming, the (n+1)th sliding off; "No diet" a grey tag with its date.
- The `shelf` module (z 64, region `shelf`, slot `shelf`, play `shelf:ready`,
  in LAYER_REGIONS): its page (chrome-shelf.mjs) draws an entry's `shelfNote`
  -- one line, at most 80 characters -- as a chip in the note's slot, coming
  and going with its entry (deck.mjs entryShelfNotes -> schedule.shelf.notes,
  only with the shelf on; scheduleSlices `shelf`). `umtool set <p> <entry>
  shelfNote='…' [--take t]` writes it through patchClipEntry (any entry, as
  hideModules; `shelfNote=` clears).
Docs: the Shelf module's section, the diet's form/tags and each extra's
position=shelf rows (knobs.md regenerated), the clip table's shelfNote row,
`umtool set`'s usage. Tests: shelf.test.mjs (geometry off/below/above, layout,
validation, no dodging, the tags' history and page, the note), the CLI's
shelfNote (a post item, --take); the registry and SETTINGS lists gain shelf.

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

Diffstat:
Mumtool/bin/umtool.mjs | 1+
Mumtool/docs/knobs.md | 21++++++++++++++++++++-
Mumtool/lib/report/knobsCli.mjs | 11++++++++++-
Mumtool/lib/report/knobsCli.test.mjs | 25+++++++++++++++++++++++++
Mumtool/lib/report/manifest.mjs | 24+++++++++++++++++++++---
Mumtool/lib/report/serve.mjs | 2+-
Mumtool/report-to-video/chrome-measure-extras.mjs | 120+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
Aumtool/report-to-video/chrome-shelf.mjs | 74++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mumtool/report-to-video/deck.mjs | 65++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
Mumtool/report-to-video/measure-extras.mjs | 93++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------
Mumtool/report-to-video/modules/contract.mjs | 5+++--
Mumtool/report-to-video/modules/diet.mjs | 4++++
Mumtool/report-to-video/modules/index.mjs | 5++++-
Mumtool/report-to-video/modules/layout.mjs | 5+++++
Mumtool/report-to-video/modules/measure-extras-module.mjs | 6++++--
Mumtool/report-to-video/modules/measure-extras-settings.mjs | 47++++++++++++++++++++++++++++++++++++++++++-----
Mumtool/report-to-video/modules/rail.test.mjs | 2+-
Mumtool/report-to-video/modules/registry.test.mjs | 7++++---
Mumtool/report-to-video/modules/settings.mjs | 6+++++-
Aumtool/report-to-video/modules/shelf-settings.mjs | 128+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aumtool/report-to-video/modules/shelf.mjs | 71+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aumtool/report-to-video/shelf.test.mjs | 174+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
22 files changed, 862 insertions(+), 34 deletions(-)

diff --git a/umtool/bin/umtool.mjs b/umtool/bin/umtool.mjs @@ -910,6 +910,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` @@ -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, and the day he named it (`state.diet.since`, "Mar 14, 2025"); 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/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/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/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,120 @@ 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: the condensed face at ~0.52 em a letter. */ +export function tagWordSize(label, room = DIET_TAG.width - 40) { + const n = Math.max(1, [...String(label)].length); + return Math.max(18, Math.min(44, Math.floor(room / (0.52 * n)))); +} + +/** + * 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 - 40; + 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 sub = d + ? `<div class="sb"><span class="dn">Diet${d.n !== null ? ` #${d.n}` : ""}</span>${d.detail ? `<span class="dd">${esc(d.detail)}</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.mjs b/umtool/report-to-video/deck.mjs @@ -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 }, }; } @@ -1465,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/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,27 @@ 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 tag = { id: id++, diet: st.diet, since }; + const wordsOnly = j > 0 && !!st.diet && !st.slam && !!out[j - 1].diet; + shown = wordsOnly ? [tag, ...shown.slice(1)] : [tag, ...shown].slice(0, n); + return { ...st, tags: shown, replaced: wordsOnly }; + }); } // --------------------------------------------------------------------------- @@ -672,12 +687,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 +804,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 +864,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 +934,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 +964,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 +979,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 +992,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, and the day he named it (`state.diet.since`, \"Mar 14, 2025\"); 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/shelf.test.mjs b/umtool/report-to-video/shelf.test.mjs @@ -0,0 +1,174 @@ +// 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 } 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;/); +}); + +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/); +});