Archilyzer · Source

archilyzer

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

commit 53f6b694cd732e37725d081bd77ad57407780334
parent 71aa8b6f317d3d9856055db1194845ad3f8824fa
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Fri,  6 Nov 2026 17:45:05 -0500

umtool: the finale draws every diet on record under the rail (deck.finale.dietRuns)

The operator (6 Nov), of the diet-runs strip leaving the shelf: "a detailed
variant of that timeline could be good as a finale render".
- diet-record.mjs dietRecord: the WHOLE record of his diets in scope -- every
  regime row, on camera or not, from the earliest (2013's Weight Watchers) --
  as runs by the state's own rule (panel-model nextRegime: a run per change of
  regime, the open one with no end), each named by its opening row's words
  when they name it otherwise ("Weight Watchers" for calories); the rows that
  stopped a diet and the ones naming the medication as marks; his stated
  weights by the day they were his. measure-slice.mjs writes it as `record`
  ONLY when `deck.finale.dietRuns` is on: every other cut's slice is as it was.
- chrome-runs-finale.mjs + module `runs-finale` (z 94, a window over the
  finale's, region `runs-finale`, in LAYER_REGIONS so Play lays it): in the
  finale's timeline panel under the large rail's track, the rail's width, to
  the panel's foot ((120, 286) 1704x122 at 1080p) -- clear of the side video,
  the lower column's dial and the promise clock that takes it over. Each run a
  bar in its diet's ink; a stretch of more than two years with nothing on
  record squeezed to a marked break ("2013–2018"), a run whose end the record
  lacks fading into it; stops grey ticks, the medication purple ones; his
  weights a light line over the bars (the first and last labelled); the run
  still going and the longest labelled in two rows where they fit -- the
  word, "DIET #n" when the cut showed it (the shelf's number), dates, days,
  the open one "N days and counting" to the in-record date. It sweeps in left
  to right over 2.6 s after the finale's grow, each label as the sweep reaches
  it, then holds.
- finale.mjs: `dietRuns` (default false), refused unless railLabels is
  `sections` or `none` (the pips' words use that space), naming the way out.
Docs: the module's section, the finale's row (knobs.md regenerated). Tests:
runs-finale.test.mjs (the record, the slice only when asked, the axis and its
break, validation, the page, the module off by default); the registry's lists.

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

Diffstat:
Mumtool/docs/knobs.md | 13+++++++++++--
Mumtool/lib/report/serve.mjs | 2+-
Aumtool/report-to-video/chrome-runs-finale.mjs | 229+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aumtool/report-to-video/diet-record.mjs | 77+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mumtool/report-to-video/finale.mjs | 8++++++++
Mumtool/report-to-video/measure-slice.mjs | 3+++
Mumtool/report-to-video/modules/finale.mjs | 3++-
Mumtool/report-to-video/modules/index.mjs | 3++-
Mumtool/report-to-video/modules/registry.test.mjs | 4++--
Aumtool/report-to-video/modules/runs-finale.mjs | 68++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aumtool/report-to-video/runs-finale.test.mjs | 104+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
11 files changed, 507 insertions(+), 7 deletions(-)

diff --git a/umtool/docs/knobs.md b/umtool/docs/knobs.md @@ -1524,6 +1524,7 @@ filter. A knob absent is its default, and a module whose knobs are all absent dr | [Flips](#flips) `flips` | Pairs of what was said then and now, in the side panel. (a page over the whole cut) | `render.chrome.flips` | | [Chapters](#chapters) `chapter` | A section bumper over the first seconds of the clip it opens: title, subtitle, date. (pages at their own seconds) | `render.chrome.chapter` | | [Finale](#finale) `finale` | The cut's last clips under the rail redrawn large, the final totals and stats cards. (pages at their own seconds) | `render.chrome.deck.finale` | +| [Diet runs in the finale](#diet-runs-in-the-finale) `runs-finale` | The finale's detailed diet record: every run from the first row a bar in its diet's ink, the empty years a break, the stops and medication marked, his weights over it, the long runs and the open one labelled. (pages at their own seconds) | -- | | [Dial finale](#dial-finale) `dial-finale` | The finale with the dial and the odometer large: the needle drops to his last stated weight, the wheels roll to the total, NET holds. (pages at their own seconds) | -- | | [Promise clock](#promise-clock) `promise` | Days since a promise -- to the clip on screen, then to the render date -- with each check's words and whether it was kept. (a page over the whole cut) | `render.chrome.deck.promise` | @@ -1537,7 +1538,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`, `shelf`, `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`, `runs-finale`, `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` @@ -1886,9 +1887,17 @@ The full reference is [The finale](#the-finale-the-timeline-in-primary-view). It | Knob | Range · default | From a terminal | |---|---|---| -| `deck.finale` | `{video, motion, totals, stats, statsTitle, railLabels, pips, timelineShare, claims}` | `umtool look <p> deck.finale='{…}'` | +| `deck.finale` | `{video, motion, totals, stats, statsTitle, railLabels, pips, timelineShare, claims, dietRuns}` -- `dietRuns`: the whole diet record under the rail ([Diet runs in the finale](#diet-runs-in-the-finale)) | `umtool look <p> deck.finale='{…}'` | | a clip's `layout` | `finale` on one run of clips at the end | `umtool set <p> <clip> layout=finale` | +### Diet runs in the finale + +With `deck.finale.dietRuns: true` (and a measure ledger with a regime track), the finale's timeline panel -- under the large rail's track, the rail's width, down to the panel's foot: (120, 286) 1704×122 at 1080p -- carries the WHOLE record of his diets (the measure slice's `record`, diet-record.mjs: every regime row in scope, on camera or not, through the state's own rule): each run a bar in its diet's ink on a time axis from the earliest row; a stretch of more than two years with nothing on record squeezed to a marked break ("2013–2018"), and a run whose end the record does not have fading into it; a row that stopped a diet a grey tick under the bars, one naming the medication (GLP-1) a purple one; his stated weights a light line over the bars, the first and last labelled; the run still going and the longest ones labelled in two rows under the bars where they fit -- the diet's word (the run's own name when its row gives one: "WEIGHT WATCHERS"), its number when the cut showed it ("DIET #6", the shelf's), its dates and its days, the open one "N days and counting" to the in-record date. It sweeps in left to right over 2.6 s after the finale's grow, each label as the sweep reaches it, then holds; it stands clear of the side video, the lower column's instruments and the promise clock. It needs `deck.finale.railLabels` `sections` or `none` (the pips' labels and dates use that space) and at least 100 px under the rail. + +| Knob | Range · default | From a terminal | +|---|---|---| +| `deck.finale.dietRuns` | bool · default `false` | `umtool look <p> deck.finale.dietRuns=true` | + ### Dial finale With the dial on (`deck.dial`) and a finale (a run of `layout: "finale"` clips), the finale's lower column -- beside the clip, under the finale's totals when it draws them -- carries the instruments large over the finale's window: in over the finale's grow, the needle dropping (1.8 s, `back.out`) from his highest remembered weight (the measure's `totals.peakDrift` and remembered weights) to his last stated one (`totals.net.to`), every ghost tick and the latest goal on the bezel; the odometer rolling up from zero to the whole record's `totals.lost` (the rows the cut never shows included) with `ACROSS N RUNS`; NET (`totals.net`) held beside it; out through the finale's dissolve. Laid over the finale (z 95), in Play too. It needs the lower column clear: a finale with stats cards (`deck.finale.stats`) is refused -- set `deck.dial.finale` false, or drop the cards. 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", "shelf", "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", "runs-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-runs-finale.mjs b/umtool/report-to-video/chrome-runs-finale.mjs @@ -0,0 +1,229 @@ +// THE FINALE'S DETAILED DIET RUNS (module `runs-finale`, `deck.finale.dietRuns`): +// the whole record of his diets drawn large in the finale -- the measure +// slice's `record` (diet-record.mjs), every run from the earliest row a bar in +// its diet's ink along a time axis, a stretch of years with nothing on record +// drawn as a break (compressed, marked), the rows that stopped a diet or named +// the medication as marks under the bars, his stated weights as a light line +// over them; the longest runs (and the one still going) labelled with the +// diet's word, its number when the cut showed it ("DIET #6", the shelf's), its +// dates and its days -- the open one "N days and counting" to the in-record +// date. It stands in the finale's timeline panel under the large rail (clear +// of the side video, the lower column's instruments and the promise clock that +// takes it over), sweeps in left to right over the finale's first seconds, +// then holds. +// +// PURE: a schedule and a render block in, `{ html, items }` out. +import { formatDeckDate } from "./attribution.mjs"; +import { finaleLayout } from "./chrome-finale.mjs"; +import { compileCues, cuePageHtml, esc, INSTANT, r4 } from "./chrome-cues.mjs"; +import { FINALE_MOTION, resolveFinale } from "./finale.mjs"; +import { daysBetween, measureOf, shortDate } from "./measure-extras.mjs"; +import { DIET_COLORS, DIET_LABELS, resolveMeasureExtra } from "./modules/measure-extras-settings.mjs"; + +/** A stretch with nothing on record longer than this is drawn as a break, days. */ +export const RUNS_BREAK_DAYS = 730; +/** The motion: in after the finale's grow, swept left to right, s. */ +export const RUNS_MOTION = Object.freeze({ delay: 0.2, sweep: 2.6, label: 0.3 }); +/** The panel's least height (1080p px) under the rail; less, and there is no room. */ +export const RUNS_MIN_HEIGHT = 100; + +const DESIGN = Object.freeze({ top: 3, weights: 22, barY: 26, barH: 22, rowA: 64, rowB: 93, rowH: 28, years: 12, brk: 44 }); + +/** The record the slice carries, when the finale asks for it. */ +export const recordOf = (schedule) => { + const r = measureOf(schedule)?.record; + return r && Array.isArray(r.runs) && r.runs.length ? r : null; +}; + +/** + * Where it stands: the finale's timeline panel under the large rail's track, + * from the rail's left end to its right, down to the panel's foot -- or null + * when that is under RUNS_MIN_HEIGHT. + */ +export function runsFinaleGeometry(schedule, render) { + if (!schedule?.finale) return null; + const L = finaleLayout(schedule, render); + const kh = L.geo.H / 1080; + const y = Math.round(L.rail.track.y + 26 * kh); + const bottom = Math.round(L.rail.bottom - 4 * kh); + if (bottom - y < RUNS_MIN_HEIGHT * kh) return null; + const x = L.rail.track.x0; + const even = (v) => Math.round(v / 2) * 2; + return { x, y, width: even(L.rail.track.x1 - x), height: even(bottom - y) }; +} + +/** The in-record date at the finale: the latest date of anything the cut showed. */ +function recordDate(m) { + const ds = (m.events ?? []).map((e) => e.date).filter(Boolean).sort(); + return ds[ds.length - 1] ?? m.asOfRender ?? null; +} + +/** + * The time axis: dates to px, every stretch with nothing on record longer than + * RUNS_BREAK_DAYS squeezed to `brk` px and marked. `x(date)`, `breaks: [{ x, + * from, to }]`, the years' ticks. + */ +export function runsAxis(dates, width, { brk = DESIGN.brk, pad = 8 } = {}) { + const ds = [...new Set(dates.filter(Boolean))].sort(); + const spans = []; + for (let i = 1; i < ds.length; i += 1) spans.push({ a: ds[i - 1], b: ds[i], days: Math.max(0, daysBetween(ds[i - 1], ds[i]) ?? 0) }); + const broken = spans.filter((s) => s.days > RUNS_BREAK_DAYS); + const linear = spans.filter((s) => s.days <= RUNS_BREAK_DAYS).reduce((n, s) => n + s.days, 0); + const k = Math.max(0.01, (width - 2 * pad - broken.length * brk) / Math.max(1, linear)); + const stops = [{ date: ds[0], x: pad }]; + for (const s of spans) stops.push({ date: s.b, x: stops[stops.length - 1].x + (s.days > RUNS_BREAK_DAYS ? brk : s.days * k), broken: s.days > RUNS_BREAK_DAYS }); + const x = (d) => { + if (!d) return stops[stops.length - 1].x; + if (d <= stops[0].date) return stops[0].x; + for (let i = 1; i < stops.length; i += 1) { + if (d <= stops[i].date) { + const a = stops[i - 1], b = stops[i]; + if (b.broken) return a.x + (d === b.date ? b.x - a.x : Math.min(b.x - a.x, 6)); + return a.x + (daysBetween(a.date, d) ?? 0) * k; + } + } + return stops[stops.length - 1].x + (daysBetween(stops[stops.length - 1].date, d) ?? 0) * k; + }; + const breaks = stops.map((s, i) => (s.broken ? { x: r4((stops[i - 1].x + s.x) / 2), x0: stops[i - 1].x, x1: s.x, from: stops[i - 1].date, to: s.date } : null)).filter(Boolean); + const years = []; + const y0 = Number(String(ds[0]).slice(0, 4)), y1 = Number(String(ds[ds.length - 1]).slice(0, 4)); + for (let y = y0 + 1; y <= y1; y += 1) { + const d = `${y}-01-01`; + if (breaks.some((b) => d > b.from && d < b.to)) continue; + years.push({ year: y, x: r4(x(d)) }); + } + return { x, breaks, years, k }; +} + +/** The finale's detailed diet runs page over the finale's `window`: `{ html, items }`. */ +export function runsFinaleHtml(schedule, render, window, opts = {}) { + const m = measureOf(schedule); + const rec = recordOf(schedule); + const geo = runsFinaleGeometry(schedule, render); + if (!m || !rec || !geo) throw new Error("runs-finale: needs a finale, the measure slice's diet record (render.chrome.deck.finale.dietRuns) and room under the rail"); + const pal = render.palette; + const s = (render.width ?? 1920) / 1920; + const px = (v) => Math.max(1, Math.round(v * s)); + const cfg = resolveMeasureExtra("diet", render) ?? resolveMeasureExtra("diet", { chrome: { deck: {} } }); + const colors = { ...DIET_COLORS, ...(cfg?.colors ?? {}) }; + const labels = { ...DIET_LABELS, ...(cfg?.labels ?? {}) }; + const W = geo.width, H = geo.height; + const today = recordDate(m); + const dates = [rec.from, ...rec.runs.flatMap((r) => [r.since, r.end]), ...rec.marks.map((x) => x.date), ...rec.weights.map((w) => w.date), today].filter(Boolean); + const A = runsAxis(dates, W, { brk: px(DESIGN.brk), pad: px(8) }); + // The number the cut gave a diet (the shelf's "DIET #6"): its state's, by regime and since. + const shownN = new Map(); + for (const st of m.state ?? []) if (st?.diet?.since) shownN.set(`${st.diet.regime}|${st.diet.since}`, st.diet.n); + const crossesBreak = (r) => A.breaks.some((b) => r.since <= b.from && (r.end ?? today) >= b.to); + const runs = rec.runs.map((r, i) => { + const end = r.end ?? today; + const x0 = A.x(r.since); + // A run across a break has no record of its end: drawn to the break, fading into it. + const brk = crossesBreak(r) ? A.breaks.find((b) => r.since <= b.from) : null; + const x1 = brk ? brk.x0 + px(4) : A.x(end); + const days = brk ? null : Math.max(0, daysBetween(r.since, end) ?? 0); + const word = (r.name ?? labels[r.key] ?? r.key).toUpperCase(); + const n = shownN.get(`${r.key}|${r.since}`) ?? null; + return { ...r, i, x0: r4(x0), x1: r4(Math.max(x0 + px(3), x1)), days, word, n, open: r.end === null, faded: !!brk, color: colors[r.key] ?? colors.other }; + }); + // THE LABELS: the run still going first, then the longest; each in the first of two rows under the bars where + // it meets no other (its words ~0.56 em a character), at its bar's middle, clamped to the panel. + const fs = px(13); + const est = (t, size, bold = 0.58) => t.length * size * bold; + const rows = [[], []]; + const placed = []; + const order = [...runs].sort((a, b) => (b.open - a.open) || ((b.days ?? 1e6) - (a.days ?? 1e6))); + for (const r of order) { + const l1 = `${r.word}${r.n !== null ? ` · DIET #${r.n}` : ""}`; + const from = formatDeckDate(r.since); + const l2 = r.days === null ? `from ${from}` : r.open ? `${shortDate(r.since, { year: true })} · ${r.days} days and counting` : `${shortDate(r.since, { year: true })} – ${shortDate(r.end, { year: true })} · ${r.days} day${r.days === 1 ? "" : "s"}`; + const w = Math.ceil(Math.max(est(l1, fs, 0.62), est(l2, px(12), 0.55))) + px(6); + if ((r.x1 - r.x0) < px(14) && !r.open) continue; + const mid = (r.x0 + r.x1) / 2; + const lx = Math.max(0, Math.min(W - w, Math.round(r.open ? r.x1 - w : mid - w / 2))); + const row = rows.findIndex((list) => list.every((o) => lx + w + px(10) <= o.x || o.x + o.w + px(10) <= lx)); + if (row < 0) continue; + rows[row].push({ x: lx, w }); + placed.push({ r, row, x: lx, w, l1, l2 }); + } + // THE WEIGHTS: a light line over the bars, the first and the last labelled. + const ws = rec.weights.filter((w) => w.date); + const vals = ws.map((w) => w.value); + const lo = Math.min(...vals), hi = Math.max(...vals); + const wy = (v) => r4(px(DESIGN.top) + (hi > lo ? (hi - v) / (hi - lo) : 0.5) * px(DESIGN.weights - 4)); + const pts = ws.map((w) => [r4(A.x(w.date)), wy(w.value)]); + const segs = []; + for (let i = 1; i < pts.length; i += 1) { + const broken = A.breaks.some((b) => pts[i - 1][0] <= b.x0 + 1 && pts[i][0] >= b.x1 - 1); + if (!broken) segs.push(`M${pts[i - 1][0]},${pts[i - 1][1]}L${pts[i][0]},${pts[i][1]}`); + } + const wtext = (w, anchor) => `<div class="wl" style="left:${r4(anchor === "end" ? A.x(w.date) - px(60) : A.x(w.date) + px(5))}px;top:${r4(wy(w.value) - px(7))}px;text-align:${anchor === "end" ? "right" : "left"}">${esc(String(w.value))}</div>`; + // The motion: the panel sweeps open left to right, each label coming in as the sweep reaches it. + const fps = schedule.fps ?? render.fps ?? 30; + const from = r4(Number(window.from)); + const dur = r4(Number(window.to) - from); + if (!(dur > 0)) throw new Error("runs-finale: the window is empty"); + const t0 = from + FINALE_MOTION.grow + RUNS_MOTION.delay; + const init = { rv: { width: 0 }, pn: { autoAlpha: 0 } }; + const ev = [ + { k: "pn", at: t0 - 0.1, dur: 0.25, to: { autoAlpha: 1 }, ease: "power1.out" }, + { k: "rv", at: t0, dur: RUNS_MOTION.sweep, to: { width: W }, ease: "none" }, + ]; + const items = []; + const labelHtml = placed.map((p, j) => { + const key = `l${j}`; + init[key] = { autoAlpha: 0 }; + const at = t0 + RUNS_MOTION.sweep * Math.min(1, (p.r.x0 + p.r.x1) / 2 / W); + ev.push({ k: key, at, dur: RUNS_MOTION.label, to: { autoAlpha: 1 }, ease: "power1.out" }); + const top = px(p.row ? DESIGN.rowB : DESIGN.rowA); + const lead = Math.round((p.r.x0 + p.r.x1) / 2); + const html = `<div class="lb" data-k="${key}"><div class="ld" style="left:${lead}px;top:${px(DESIGN.barY + DESIGN.barH)}px;height:${top - px(DESIGN.barY + DESIGN.barH)}px;background:${p.r.color}"></div>` + + `<div class="lt" style="left:${p.x}px;top:${top}px;width:${p.w}px;${p.x + p.w >= W - 1 ? "text-align:right;" : ""}"><div class="l1" style="color:${p.r.color}">${esc(p.l1)}</div><div class="l2">${esc(p.l2)}</div></div></div>`; + items.push({ key, gate: [key, "autoAlpha"], html }); + return html; + }); + const bars = runs.map((r) => `<div class="bar${r.faded ? " fd" : ""}${r.open ? " op" : ""}" style="left:${r.x0}px;width:${r4(r.x1 - r.x0)}px;--c:${r.color}"></div>`).join(""); + const marks = rec.marks.map((x) => `<div class="mk ${x.kind}" style="left:${r4(A.x(x.date))}px"></div>`).join(""); + const years = A.years.map((y) => `<div class="yt" style="left:${y.x}px"></div><div class="yl" style="left:${r4(y.x + px(3))}px">${y.year}</div>`).join(""); + const breaks = A.breaks.map((b) => `<div class="bk" style="left:${r4(b.x0)}px;width:${r4(b.x1 - b.x0)}px"><span>${esc(String(b.from).slice(0, 4))}–${esc(String(b.to).slice(0, 4))}</span></div>`).join(""); + const css = ` + #pn { position: absolute; inset: 0; visibility: hidden; opacity: 0; } + #rv { position: absolute; left: 0; top: 0; height: ${H}px; overflow: hidden; } + #rw { position: absolute; left: 0; top: 0; width: ${W}px; height: ${H}px; } + .bar { position: absolute; top: ${px(DESIGN.barY)}px; height: ${px(DESIGN.barH)}px; background: var(--c); border-radius: ${px(2)}px; + box-shadow: inset 0 ${px(-3)}px 0 rgba(0, 0, 0, 0.18); } + .bar.fd { background: linear-gradient(90deg, var(--c) 0%, var(--c) 55%, transparent 100%); } + .bar.op { box-shadow: 0 0 ${px(10)}px var(--c); } + .ax { position: absolute; left: 0; width: ${W}px; top: ${px(DESIGN.barY + DESIGN.barH + 1)}px; height: ${px(2)}px; background: ${pal.muted}; opacity: 0.45; } + .mk { position: absolute; top: ${px(DESIGN.barY + DESIGN.barH + 2)}px; width: ${px(2)}px; height: ${px(6)}px; margin-left: ${px(-1)}px; background: ${pal.muted}; } + .mk.med { background: ${colors.glp1 ?? "#B168C6"}; height: ${px(8)}px; } + .bk { position: absolute; top: ${px(DESIGN.barY - 4)}px; height: ${px(DESIGN.barH + 10)}px; display: flex; align-items: center; justify-content: center; + background: repeating-linear-gradient(115deg, transparent 0 ${px(5)}px, ${pal.muted}55 ${px(5)}px ${px(7)}px); } + .bk span { font-family: 'DeckSansBold', sans-serif; font-size: ${px(10)}px; color: ${pal.fg}; background: ${pal.bg}; padding: 0 ${px(3)}px; white-space: nowrap; } + .yt { position: absolute; top: ${px(DESIGN.barY - 4)}px; width: 1px; height: ${px(DESIGN.barH + 8)}px; background: ${pal.muted}; opacity: 0.5; } + .yl { position: absolute; top: ${px(DESIGN.barY + DESIGN.barH + 4)}px; font-size: ${px(DESIGN.years)}px; line-height: ${px(14)}px; color: ${pal.muted}; } + svg.wt { position: absolute; left: 0; top: 0; overflow: visible; } + .wl { position: absolute; width: ${px(55)}px; font-family: 'DeckSansBold', sans-serif; font-size: ${px(11)}px; line-height: ${px(14)}px; color: ${pal.fg}; opacity: 0.8; } + .lb { position: absolute; inset: 0; visibility: hidden; opacity: 0; } + .ld { position: absolute; width: ${px(2)}px; margin-left: ${px(-1)}px; opacity: 0.7; } + .lt { position: absolute; white-space: nowrap; } + .l1 { font-family: 'DeckSansBold', sans-serif; font-size: ${fs}px; line-height: ${px(14)}px; letter-spacing: 0.06em; text-transform: uppercase; } + .l2 { font-size: ${px(12)}px; line-height: ${px(14)}px; color: ${pal.fg}; font-variant-numeric: tabular-nums; } +`; + const body = `<div id="pn" data-k="pn"> + <div id="rv" data-k="rv"><div id="rw"> + <svg class="wt" width="${W}" height="${px(DESIGN.weights + 2)}"><path d="${segs.join("")}" fill="none" stroke="${pal.fg}" stroke-opacity="0.45" stroke-width="${px(2)}"/>${pts.map(([x, y]) => `<circle cx="${x}" cy="${y}" r="${px(2)}" fill="${pal.fg}" fill-opacity="0.7"/>`).join("")}</svg> + ${ws.length ? wtext(ws[0], "start") + wtext(ws[ws.length - 1], "end") : ""} + ${years}<div class="ax"></div>${bars}${marks}${breaks} + </div></div> + ${labelHtml.join("\n ")} + </div>`; + const { cues } = compileCues(init, ev); + return { + html: cuePageHtml({ id: "runs-finale", W, H, fps, fonts: opts.fonts, gsapSrc: opts.gsap, css, body, init, cues, window: { from, dur } }), + items, + }; +} + +/** Is the detailed finale asked for (`deck.finale.dietRuns`)? */ +export const runsFinaleWanted = (render) => resolveFinale(render).dietRuns === true; diff --git a/umtool/report-to-video/diet-record.mjs b/umtool/report-to-video/diet-record.mjs @@ -0,0 +1,77 @@ +// THE DIET RECORD (the finale's detailed diet runs, `deck.finale.dietRuns`): +// the WHOLE record of his diets in scope -- every regime row, on camera or +// not, from the earliest -- as RUNS, with the rows that stopped one or named a +// medication as marks, and his stated weights along it. measure-slice.mjs +// writes it into the slice as `record` only when the finale asks for it, so a +// cut without it writes the slice it always did; chrome-runs-finale.mjs draws it. +// +// The runs follow the state's own rule (panel-model.mjs nextRegime: "on" keeps +// when a regime opened, "start" opens it again, an "off" closes only what it +// names; the track's off key is no diet): a new run at each change of regime, +// numbered as the state numbers its diets. A run is named by its opening row's +// own words when they name it otherwise ("Weight Watchers" for `calories`). +// +// Pure: rows and the schema in, plain data out. +import { chronological, dateKey } from "./ledger-shared.mjs"; +import { measureDisplay, plotDate } from "./measure-totals.mjs"; +import { CLOSING, nextRegime, offOf } from "./panel-model.mjs"; + +const GENERIC = /^(some diet|no diet|something unnamed)$/i; + +/** + * A run's own name from its opening row's words, or null when they only + * repeat the regime ("Keto", "Keto · 5 carbs a day", "off keto", "Some diet"). + */ +export function runName(display, regime) { + const d = String(display ?? "").trim(); + if (!d || GENERIC.test(d) || /^off\b/i.test(d) || /[·+]/.test(d)) return null; + const names = [regime?.key, regime?.label].filter(Boolean).map((x) => String(x).toLowerCase()); + if (names.some((n) => d.toLowerCase() === n || d.toLowerCase().startsWith(`${n} `))) return null; + return d; +} + +/** + * The record: `{ from, to, runs: [{ key, n, since, end, ended, name, row }], + * marks: [{ date, key, kind: "off" | "med", display, row }], weights: [{ date, + * value }] }` -- `end` null for the run still open; `from`/`to` the earliest and + * latest dates any of it has. + * + * @param {any[]} own his rows in scope + * @param {any} schema the resolved measure schema + * @param {string | null} regimeTrack the regime track's key + * @param {any[]} readings his weight rows (current and past) + */ +export function dietRecord(own, schema, regimeTrack, readings = []) { + if (!regimeTrack) return null; + const off = offOf(schema, regimeTrack)?.key ?? null; + const regimes = new Map((schema.regimes ?? []).map((r) => [r.key, r])); + const runs = []; + const marks = []; + let open = null; + let cur = null; + let n = 0; + for (const row of chronological(own.filter((r) => r.scope === regimeTrack))) { + open = nextRegime(open, row, schema); + const date = plotDate(row); + const key = open && open.key !== off ? open.key : null; + if (key !== (cur?.key ?? null)) { + if (cur) { cur.end = date; cur.ended = key ? "new" : "off"; } + cur = null; + if (key) { + n += 1; + cur = { key, n, since: open.since ?? date, end: null, ended: null, name: runName(measureDisplay(row, schema), regimes.get(key)), row: row.id }; + runs.push(cur); + } + } + const value = String(row.value ?? ""); + if (CLOSING.has(row.event)) marks.push({ date, key: value, kind: "off", display: measureDisplay(row, schema), row: row.id }); + else if (regimes.get(value)?.key === "glp1" && !(cur && cur.row === row.id)) marks.push({ date, key: value, kind: "med", display: measureDisplay(row, schema), row: row.id }); + } + const weights = readings + .filter((r) => r.population === "current" && Number.isFinite(Number(r.value))) + .map((r) => ({ date: plotDate(r), value: Number(r.value) })) + .filter((w) => w.date) + .sort((a, b) => dateKey(a.date).localeCompare(dateKey(b.date))); + const dates = [...runs.flatMap((r) => [r.since, r.end]), ...marks.map((m) => m.date), ...weights.map((w) => w.date)].filter(Boolean).map(dateKey).sort(); + return { from: dates[0] ?? null, to: dates[dates.length - 1] ?? null, runs, marks, weights }; +} diff --git a/umtool/report-to-video/finale.mjs b/umtool/report-to-video/finale.mjs @@ -18,6 +18,8 @@ // "pips": true | false false: the finale's own clips get no pip on the rail // (footer or large) -- the rail is the record alone; their // titles and dates stay in their own area (default true) +// "dietRuns": true | false the whole diet record drawn under the rail (module runs-finale, +// chrome-runs-finale.mjs; needs railLabels sections|none; default false) // "claims": "rotate" | "all" the claim checks (deck.claims) on the large rail: // one at a time, each for an even share of the page's // time (default "rotate"; all at once when there is @@ -87,6 +89,7 @@ export const FINALE_DEFAULTS = Object.freeze({ timelineShare: "auto", claims: "rotate", pips: true, + dietRuns: false, }); /** @@ -140,6 +143,11 @@ export function validateFinaleSettings(f, where = "render.chrome.deck.finale") { } if (f.totals !== undefined && typeof f.totals !== "boolean") errors.push(`${where}.totals must be true or false`); if (f.pips !== undefined && typeof f.pips !== "boolean") errors.push(`${where}.pips must be true or false`); + if (f.dietRuns !== undefined && typeof f.dietRuns !== "boolean") errors.push(`${where}.dietRuns must be true or false`); + // The diet runs stand under the rail, where "all" and "nodes" put the pips' labels and dates. + if (f.dietRuns === true && !["sections", "none"].includes(f.railLabels ?? FINALE_DEFAULTS.railLabels)) { + errors.push(`${where}.dietRuns draws under the rail, where railLabels "${f.railLabels ?? FINALE_DEFAULTS.railLabels}" puts the pips' words: set ${where}.railLabels "sections" or "none"`); + } if (f.statsTitle !== undefined && f.statsTitle !== null) { const p = lineProblem(f.statsTitle, FINALE_LIMITS.statsTitle, `${where}.statsTitle`); if (p) errors.push(p); diff --git a/umtool/report-to-video/measure-slice.mjs b/umtool/report-to-video/measure-slice.mjs @@ -24,6 +24,7 @@ import { chronological, dateKey, daysBetween } from "./ledger-shared.mjs"; import { PROMISE_FORMS, measureDisplay, measureQualifier, measureSchema, measureTotals, plotDate } from "./measure-totals.mjs"; import { goalCell, nextRegime, offOf } from "./panel-model.mjs"; import { offsetIn } from "./gaps.mjs"; +import { dietRecord } from "./diet-record.mjs"; export const MEASURE_SLICE_VERSION = 1; @@ -636,5 +637,7 @@ export function measureSlice(manifest, schedule, opts = {}) { hidden, state, totals, + // The whole diet record, for the finale's detailed runs (`deck.finale.dietRuns`): only when it asks. + ...(manifest?.render?.chrome?.deck?.finale?.dietRuns === true ? { record: dietRecord(own, s, regimeTrack, readings) } : {}), }; } diff --git a/umtool/report-to-video/modules/finale.mjs b/umtool/report-to-video/modules/finale.mjs @@ -36,12 +36,13 @@ export default defineModule({ { key: "pips", type: "boolean", label: "The finale's clips on the rail", default: true }, { key: "timelineShare", type: "number", min: 0.38, max: 0.6, step: 0.01, label: "Timeline share (auto when unset)" }, { key: "claims", type: "enum", options: ["rotate", "all"], label: "Claim checks", default: "rotate" }, + { key: "dietRuns", type: "boolean", label: "Every diet on record under the rail (railLabels sections or none)", default: false }, ], docs: { heading: "Finale", intro: "The full reference is [The finale](#the-finale-the-timeline-in-primary-view). It reads the counter's totals (`counter.totals`) and the rail's layout (`rail.layout`); the counter reads its window (`finale.window`): a mark that would stamp inside it counts as it opens.", rows: [ - ["`deck.finale`", "`{video, motion, totals, stats, statsTitle, railLabels, pips, timelineShare, claims}`", "`umtool look <p> deck.finale='{…}'`"], + ["`deck.finale`", "`{video, motion, totals, stats, statsTitle, railLabels, pips, timelineShare, claims, dietRuns}` -- `dietRuns`: the whole diet record under the rail ([Diet runs in the finale](#diet-runs-in-the-finale))", "`umtool look <p> deck.finale='{…}'`"], ["a clip's `layout`", "`finale` on one run of clips at the end", "`umtool set <p> <clip> layout=finale`"], ], }, diff --git a/umtool/report-to-video/modules/index.mjs b/umtool/report-to-video/modules/index.mjs @@ -41,12 +41,13 @@ import goals from "./goals.mjs"; import promise from "./promise.mjs"; import streak from "./streak.mjs"; import shelf from "./shelf.mjs"; +import runsFinale from "./runs-finale.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, shelf, 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, runsFinale] .sort((a, b) => a.z - b.z || a.id.localeCompare(b.id)), ); diff --git a/umtool/report-to-video/modules/registry.test.mjs b/umtool/report-to-video/modules/registry.test.mjs @@ -49,7 +49,7 @@ test("the registry: unique ids and regions, sorted by z, the deck's overlays in // 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); 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.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", "runs-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/); @@ -153,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", "shelf", "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", "runs-finale", "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/runs-finale.mjs b/umtool/report-to-video/modules/runs-finale.mjs @@ -0,0 +1,68 @@ +// THE FINALE'S DETAILED DIET RUNS (module `runs-finale`, region `runs-finale`): +// with `deck.finale.dietRuns: true`, the whole record of his diets drawn large +// in the finale's timeline panel under the rail -- every run from the earliest +// row, the empty years a marked break, the stops and the medication marked, +// his stated weights over it, the longest runs and the one still going +// labelled (chrome-runs-finale.mjs, the measure slice's `record`). A window over +// the finale's, laid over it; off by default. +import path from "node:path"; + +import { snapWindow } from "../deck.mjs"; +import { recordOf, runsFinaleGeometry, runsFinaleHtml, runsFinaleWanted } from "../chrome-runs-finale.mjs"; +import { assertRegion, defineModule } from "./contract.mjs"; + +const drawn = (schedule, render) => !!schedule?.finale && runsFinaleWanted(render) && !!recordOf(schedule) && !!runsFinaleGeometry(schedule, render); + +export default defineModule({ + id: "runs-finale", + version: 1, + z: 94, + kind: "overlay-window", + slot: "full", + title: "Diet runs in the finale", + summary: "The finale's detailed diet record: every run from the first row a bar in its diet's ink, the empty years a break, the stops and medication marked, his weights over it, the long runs and the open one labelled.", + docs: { + heading: "Diet runs in the finale", + intro: "With `deck.finale.dietRuns: true` (and a measure ledger with a regime track), the finale's timeline panel -- under the large rail's track, the rail's width, down to the panel's foot: (120, 286) 1704×122 at 1080p -- carries the WHOLE record of his diets (the measure slice's `record`, diet-record.mjs: every regime row in scope, on camera or not, through the state's own rule): each run a bar in its diet's ink on a time axis from the earliest row; a stretch of more than two years with nothing on record squeezed to a marked break (\"2013–2018\"), and a run whose end the record does not have fading into it; a row that stopped a diet a grey tick under the bars, one naming the medication (GLP-1) a purple one; his stated weights a light line over the bars, the first and last labelled; the run still going and the longest ones labelled in two rows under the bars where they fit -- the diet's word (the run's own name when its row gives one: \"WEIGHT WATCHERS\"), its number when the cut showed it (\"DIET #6\", the shelf's), its dates and its days, the open one \"N days and counting\" to the in-record date. It sweeps in left to right over 2.6 s after the finale's grow, each label as the sweep reaches it, then holds; it stands clear of the side video, the lower column's instruments and the promise clock. It needs `deck.finale.railLabels` `sections` or `none` (the pips' labels and dates use that space) and at least 100 px under the rail.", + rows: [ + ["`deck.finale.dietRuns`", "bool · default `false`", "`umtool look <p> deck.finale.dietRuns=true`"], + ], + }, + region: "runs-finale", + workers: "narrow", + noun: "the finale's diet runs'", + on: drawn, + check: (schedule, render) => { + if (!schedule?.finale) return "the finale's diet runs need a schedule with a finale (a clip with layout \"finale\")"; + if (!runsFinaleWanted(render)) return "the finale's diet runs are off (render.chrome.deck.finale.dietRuns)"; + if (!recordOf(schedule)) return "the finale's diet runs need the measure slice's diet record (a measure ledger with a regime track, and render.chrome.deck.measure)"; + if (!runsFinaleGeometry(schedule, render)) return "the finale's diet runs need 100 px under the large rail (a larger deck.finale.timelineShare)"; + return null; + }, + window: (schedule, { fps, total }) => snapWindow({ segment: "runs-finale", from: schedule.finale.from, to: schedule.finale.to }, { fps, total }), + names: ({ preview }) => ({ project: `runs-finale${preview ? "-preview" : ""}`, stem: "runs-finale" }), + async page(ctx) { + const fonts = await ctx.fonts({ regular: "DeckSans", bold: "DeckSansBold" }, { strict: true }); + return runsFinaleHtml(ctx.schedule, ctx.render, ctx.window, { fonts }); + }, + /** Over the finale's window, laid at its own second. */ + regions(schedule, { render, outDir, shift = 0, clip = null }) { + const f = schedule?.finale; + if (!f || !drawn(schedule, render)) return []; + const g = runsFinaleGeometry(schedule, render); + const fps = Number(schedule.fps ?? render.fps); + const s = snapWindow({ segment: "runs-finale", from: f.from, to: f.to }, { fps, total: schedule.total }); + if (clip && !(s.from < clip.at + clip.dur && s.to > clip.at)) return []; + return [assertRegion({ + name: "runs-finale", + frames: path.join(outDir, "chrome", "runs-finale-frames"), + ...g, + offset: s.from - shift, + frameCount: s.frames, + window: s, + }, "window")]; + }, + play: { clock: "cut", ready: "runs-finale:ready" }, + // A window of the cut, as the finale's: its frame n is cut time `from` + n / fps. + frameKeys: { data: "runs-finale-data", omit: ["init", "cues", "from", "dur"], offset: "from" }, +}); diff --git a/umtool/report-to-video/runs-finale.test.mjs b/umtool/report-to-video/runs-finale.test.mjs @@ -0,0 +1,104 @@ +// The finale's detailed diet runs (`deck.finale.dietRuns`; diet-record.mjs, +// chrome-runs-finale.mjs, modules/runs-finale.mjs): the whole diet record from +// its earliest row, an empty stretch a break, the stops and the medication +// marked, in the finale's panel under the rail -- and nothing of it unless asked. +// +// Run with: pnpm test:scripts +import assert from "node:assert/strict"; +import test from "node:test"; + +import { dietRecord, runName } from "./diet-record.mjs"; +import { RUNS_BREAK_DAYS, runsAxis, runsFinaleGeometry, runsFinaleHtml } from "./chrome-runs-finale.mjs"; +import { validateFinaleSettings } from "./finale.mjs"; +import { measureSchema } from "./measure-totals.mjs"; +import { measureSlice } from "./measure-slice.mjs"; +import { moduleById } from "./modules/index.mjs"; + +const SCHEMA = { + kind: "measure", unit: "lb", yMin: 210, yMax: 400, bandGapDays: 60, + tracks: [ + { key: "weight", role: "value", label: "Weight" }, + { key: "regime", role: "regime", label: "Diet", regimes: ["keto", "carnivore", "calories", "glp1", "off"], offKey: "off" }, + ], + forms: ["current", "past", "delta", "goal", "goal_loss", "overweight_by", "status"], + regimes: [ + { key: "keto", label: "Keto" }, { key: "carnivore", label: "Carnivore" }, { key: "calories", label: "Counting calories" }, + { key: "glp1", label: "GLP-1" }, { key: "off", label: "No diet" }, + ], +}; +const row = (o) => ({ scope: "weight", scopeBasis: "his words", scopeConfidence: "read", valueKind: "uttered", flags: [], asOf: null, ...o }); +const LEDGER = [ + // 2013 (MeVsMe): Weight Watchers, three weights -- then nothing until 2018. + row({ id: "r105", date: "2013-02-22", scope: "regime", population: "status", value: "calories", event: "start", display: "Weight Watchers" }), + row({ id: "w127", date: "2013-03-09", asOf: "2013-03-02", population: "current", value: 345, display: "345 lb" }), + row({ id: "w130", date: "2013-03-21", population: "current", value: 342.9, display: "342.9 lb" }), + row({ id: "r07", date: "2021-09-14", scope: "regime", population: "status", value: "keto", event: "start", display: "Keto", entryId: "c1" }), + row({ id: "r11", date: "2022-07-27", scope: "regime", population: "status", value: "keto", event: "off", display: "off Keto" }), + row({ id: "r14", date: "2022-12-30", scope: "regime", population: "status", value: "carnivore", event: "on", display: "Carnivore", entryId: "c2" }), + row({ id: "r40", date: "2024-04-25", scope: "regime", population: "status", value: "glp1", event: "off", display: "off GLP-1" }), + row({ id: "w50", date: "2024-05-01", population: "current", value: 330, display: "330 lb", entryId: "c2" }), +]; +const TIMELINE = [ + { type: "clip", id: "c1", video: "v1", start: 0, end: 10, quoteStart: 1 }, + { type: "clip", id: "c2", video: "v2", start: 0, end: 10, quoteStart: 1, layout: "finale" }, +]; +const SEGMENTS = [{ id: "c1", start: 0, duration: 10 }, { id: "c2", start: 10, duration: 10 }]; +const PALETTE = { bg: "#0F1312", fg: "#EDF0EC", muted: "#98A29B", accent: "#22AB83", amber: "#E8A33F" }; +const renderOf = (finale = { railLabels: "sections", dietRuns: true }) => ({ + width: 1920, height: 1080, fps: 30, transition: 0, palette: PALETTE, + chrome: { engine: "hyperframes", layout: "deck", deck: { measure: { scopes: ["weight", "regime"], scale: { min: 220, max: 400 } }, finale } }, +}); +const manifest = (render = renderOf()) => ({ ledgerSchema: SCHEMA, ledger: LEDGER, timeline: TIMELINE, render }); + +test("the record: every regime row from the earliest, runs by the state's rule, named by their own words; stops and medication marked", () => { + const own = LEDGER; + const readings = LEDGER.filter((r) => r.scope === "weight"); + const rec = dietRecord(own, measureSchema(SCHEMA), "regime", readings); + assert.equal(rec.from, "2013-02-22"); + assert.deepEqual(rec.runs.map((r) => [r.n, r.key, r.since, r.end, r.ended, r.name]), [ + [1, "calories", "2013-02-22", "2021-09-14", "new", "Weight Watchers"], + [2, "keto", "2021-09-14", "2022-07-27", "off", null], + [3, "carnivore", "2022-12-30", null, null, null], + ]); + assert.deepEqual(rec.marks.map((m) => [m.row, m.kind]), [["r11", "off"], ["r40", "off"]]); + assert.deepEqual(rec.weights.map((w) => [w.date, w.value]), [["2013-03-02", 345], ["2013-03-21", 342.9], ["2024-05-01", 330]], "by the day it was his weight"); + assert.equal(runName("Keto · 5 carbs a day", { key: "keto", label: "Keto" }), null); + assert.equal(runName("off GLP-1", { key: "glp1", label: "GLP-1" }), null); +}); + +test("the slice carries the record only when the finale asks for it", () => { + const off = measureSlice(manifest(renderOf({ railLabels: "sections" })), { segments: SEGMENTS }, { asOf: "2026-11-03" }); + assert.equal("record" in off, false, "a cut without it writes the slice it always did"); + const on = measureSlice(manifest(), { segments: SEGMENTS }, { asOf: "2026-11-03" }); + assert.equal(on.record.runs.length, 3); +}); + +test("the axis: an empty stretch past two years squeezed to a marked break; the years on the rest", () => { + const A = runsAxis(["2013-02-22", "2013-03-21", "2021-09-14", "2022-07-27", "2024-05-01"], 1704, { brk: 44, pad: 8 }); + assert.equal(A.breaks.length, 1); + assert.deepEqual([A.breaks[0].from, A.breaks[0].to], ["2013-03-21", "2021-09-14"]); + assert.equal(Math.round(A.breaks[0].x1 - A.breaks[0].x0), 44); + assert.ok(A.x("2024-05-01") <= 1704 - 8 + 1e-6); + assert.deepEqual(A.years.map((y) => y.year), [2022, 2023, 2024], "no year ticks inside the break"); + assert.ok(RUNS_BREAK_DAYS === 730); +}); + +test("validation and the page: railLabels must leave the space; the page labels the open run 'and counting'", () => { + assert.match(validateFinaleSettings({ dietRuns: true }).join(), /dietRuns draws under the rail, where railLabels "all" puts the pips' words: set render\.chrome\.deck\.finale\.railLabels "sections" or "none"/); + assert.deepEqual(validateFinaleSettings({ dietRuns: true, railLabels: "none" }), []); + assert.match(validateFinaleSettings({ dietRuns: "yes" }).join(), /dietRuns must be true or false/); + const r = renderOf(); + const m = measureSlice(manifest(r), { segments: SEGMENTS }, { asOf: "2026-11-03" }); + const schedule = { kind: "deck", fps: 30, total: 20, transition: 0, segments: SEGMENTS.map((s) => ({ ...s, end: s.start + s.duration, type: "clip", title: "", subtitle: "" })), finale: { segments: ["c2"], from: 10.5, to: 20, video: "side", motion: "grow", grow: 0.8 }, measure: m }; + const g = runsFinaleGeometry(schedule, r); + assert.ok(g && g.x === 120 && g.y > 200 && g.height >= 100, JSON.stringify(g)); + const { html, items } = runsFinaleHtml(schedule, r, { from: 10.5, to: 20 }, { fonts: {} }); + assert.match(html, /CARNIVORE/); + assert.match(html, /days and counting/); + assert.match(html, /WEIGHT WATCHERS/); + assert.match(html, /2013–2021/, "the break says what it spans"); + assert.ok(items.length >= 2); + const mod = moduleById("runs-finale"); + assert.equal(mod.on(schedule, r), true); + assert.equal(mod.on(schedule, renderOf({ railLabels: "sections" })), false, "off by default"); +});