Archilyzer · Source

archilyzer

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

commit a24777f3764cbf1a12f6a3590829a0b45d0073f4
parent 29742cfb3baedd8e82e4f461d2061a02f69e9009
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Sun,  1 Nov 2026 22:12:58 -0500

Merge lane/section-cap: up to 32 deck markers (report-to-video/marker-limits.mjs MARKER_LIMITS, one constant for the validators, writers and the Markers editor) and level-2 subsections (a half-height tick in the parent's colour, "Section › Sub" titles, a leading subsection refused)

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

Diffstat:
Mumtool/app/api/report/timeline/route.ts | 9+++++++--
Mumtool/components/projects/MarkersEditor.tsx | 63+++++++++++++++++++++++++++++++++++++++++++++++++++------------
Mumtool/components/projects/TimelineEditor.tsx | 7+++++--
Mumtool/components/projects/review/PlayCut.tsx | 4++--
Mumtool/components/projects/review/ReelStrip.tsx | 2+-
Mumtool/docs/knobs.md | 7++++---
Mumtool/e2e/fixtures/knobs-fixture.mjs | 23++++++++++++++++++++++-
Aumtool/e2e/markers-cap.spec.ts | 70++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mumtool/lib/report/knobs.test.mjs | 3++-
Mumtool/lib/report/knobsCli.mjs | 4+++-
Mumtool/lib/report/manifest.mjs | 26+++++++++++++++++---------
Mumtool/lib/report/playView.mjs | 8++++++--
Mumtool/lib/report/sectionEdit.mjs | 72+++++++++++++++++++++++++++++++++++++++++++++++++++---------------------
Aumtool/lib/report/sectionLevels.test.mjs | 129+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mumtool/lib/report/stripDrag.mjs | 5+++--
Mumtool/lib/report/timelineCli.mjs | 18+++++++++++-------
Mumtool/report-to-video/README.md | 34++++++++++++++++++++++++++--------
Mumtool/report-to-video/chrome-deck.mjs | 49++++++++++++++++++++++++++++++++++++++++---------
Mumtool/report-to-video/chrome-finale.mjs | 8++++++--
Mumtool/report-to-video/deck-counts.test.mjs | 9++++++++-
Aumtool/report-to-video/deck-subsections.test.mjs | 176+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mumtool/report-to-video/deck.mjs | 153++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----------------
Mumtool/report-to-video/finale-room.test.mjs | 13+++++++++++++
Aumtool/report-to-video/marker-limits.mjs | 22++++++++++++++++++++++
Mumtool/report-to-video/modules/rail.mjs | 4+++-
Mumtool/report-to-video/modules/section-title.mjs | 2+-
Mumtool/report-to-video/modules/settings.mjs | 11++++++++---
Mumtool/report-to-video/package.json | 1+
28 files changed, 809 insertions(+), 123 deletions(-)

diff --git a/umtool/app/api/report/timeline/route.ts b/umtool/app/api/report/timeline/route.ts @@ -154,13 +154,18 @@ export async function POST(request: Request) { case "section-move": return moveToSection(dir, Array.isArray(body.ids) ? body.ids.map(String) : [id], Number(body.section), { token, position: body.position === "start" ? "start" : "end" }); case "section-add": - return addSection(dir, String(body.afterId ?? id), { label: typeof body.label === "string" ? body.label : null, color: typeof body.color === "string" ? body.color : null }, { token }); + return addSection( + dir, + String(body.afterId ?? id), + { label: typeof body.label === "string" ? body.label : null, color: typeof body.color === "string" ? body.color : null, level: typeof body.level === "number" ? body.level : null }, + { token }, + ); case "section-boundary": return moveSectionBoundary(dir, Number(body.marker), String(body.afterId ?? ""), { token }); case "section-remove": return removeSection(dir, Number(body.marker), { token }); case "section-set": - return updateSection(dir, Number(body.marker), Object.fromEntries(["label", "color"].filter((k) => k in body).map((k) => [k, body[k]])), { token }); + return updateSection(dir, Number(body.marker), Object.fromEntries(["label", "color", "level"].filter((k) => k in body).map((k) => [k, body[k]])), { token }); default: throw new Error("op must be move, place, remove, reject, wrong-speaker, duplicate, insert, teaser, post, post-remove, factcheck, undo, section-move, section-add, section-boundary, section-remove or section-set"); } diff --git a/umtool/components/projects/MarkersEditor.tsx b/umtool/components/projects/MarkersEditor.tsx @@ -1,37 +1,56 @@ "use client"; import { useEffect, useState } from "react"; +import { MARKER_LIMITS } from "umtool-report-to-video/marker-limits"; import { buttonVariants } from "@/components/ui/button"; // THE DECK'S MARKERS (video knobs, plans/video-knobs-ui.md): the flags on the // pip track, `render.chrome.deck.markers` -- each after a clip (a picker of the // cut's clips), a label of at most 24 characters, a colour (a palette key or -// #hex), an alignment -- at most 12, added, removed and re-ordered here; and +// #hex), an alignment, a level (a section, or a subsection of the one before +// it) -- at most MARKER_LIMITS.count (marker-limits.mjs, the build's own +// number), added, removed and re-ordered here; and // `deck.markerLayout`, what the deck does when labels crowd: stagger them on a // second row, or truncate. One save writes the list and the layout and nothing // else of the deck (PUT /api/report/chrome { markers, markerLayout }), the // writer `umtool look deck.markers=…` uses. // `label` is optional: a marker without one is a tick at its boundary (and, -// with `pip.color: "section"`, where the rail's colour changes). -export type Marker = { after: string; label?: string; color?: string; align?: string }; -type Row = { after: string; label: string; color: string; align: string }; +// with `pip.color: "section"`, where the rail's colour changes). `level: 2` is +// a subsection: a section to every edit, drawn inside its parent on the rail +// (a shorter tick, its parent's colour, a quieter label; "Section › Sub" in +// the section title). The cut's first marker must be a section. +export type Marker = { after: string; label?: string; color?: string; align?: string; level?: number }; +type Row = { after: string; label: string; color: string; align: string; level: 1 | 2 }; -export const MARKER_MAX = 12; -export const MARKER_LABEL_MAX = 24; +export const MARKER_MAX: number = MARKER_LIMITS.count; +export const MARKER_LABEL_MAX: number = MARKER_LIMITS.label; const PALETTE = ["amber", "accent", "fg", "muted", "dim"]; const input = "rounded border border-[var(--color-line)] bg-[var(--color-ink)] px-1.5 py-0.5 text-[11px] text-[var(--color-text)] outline-none focus:border-[var(--color-sel)]"; -const rowOf = (m: Marker): Row => ({ after: m.after, label: m.label ?? "", color: m.color ?? "", align: m.align ?? "auto" }); +const rowOf = (m: Marker): Row => ({ after: m.after, label: m.label ?? "", color: m.color ?? "", align: m.align ?? "auto", level: m.level === 2 ? 2 : 1 }); const markerOf = (r: Row): Marker => ({ after: r.after, ...(r.label.trim() ? { label: r.label.trim() } : {}), ...(r.color.trim() ? { color: r.color.trim() } : {}), ...(r.align && r.align !== "auto" ? { align: r.align } : {}), + ...(r.level === 2 ? { level: 2 } : {}), }); +/** The row whose marker comes first in the cut (by its clip's place, then the list's order), or -1. */ +function firstInCut(rows: Row[], clips: { id: string }[]): number { + const pos = new Map(clips.map((c, i) => [c.id, i])); + let best = -1; + rows.forEach((r, i) => { + const p = pos.get(r.after); + if (p === undefined) return; + if (best < 0 || p < (pos.get(rows[best].after) as number)) best = i; + }); + return best; +} + export default function MarkersEditor({ markers, markerLayout, @@ -76,9 +95,14 @@ export default function MarkersEditor({ const add = () => { const used = new Set(rows.map((r) => r.after)); const after = clips.find((c) => !used.has(c.id))?.id ?? clips[0]?.id ?? ""; - change([...rows, { after, label: "", color: "", align: "auto" }]); + change([...rows, { after, label: "", color: "", align: "auto", level: 1 }]); }; const labelLong = rows.some((r) => [...r.label.trim()].length > MARKER_LABEL_MAX); + // A subsection sits inside the section before it: the cut's first marker + // must open a section. The build refuses it too (validateDeckMarkers); said + // here before a save. + const lead = firstInCut(rows, clips); + const leadSub = lead >= 0 && rows[lead].level === 2 ? lead : -1; return ( <div data-testid="markers-editor" className="space-y-1.5"> @@ -113,13 +137,18 @@ export default function MarkersEditor({ <button type="button" data-testid="markers-save" - disabled={busy || !dirty || labelLong || rows.some((r) => !r.label.trim() || !r.after)} + disabled={busy || !dirty || labelLong || leadSub >= 0 || rows.some((r) => !r.label.trim() || !r.after)} onClick={() => void save({ markers: rows.map(markerOf), markerLayout: layout || null }).then((ok) => ok && setDirty(false))} className={`${buttonVariants({ variant: "outline", size: "sm" })} ml-auto`} > save markers </button> </div> + {leadSub >= 0 && ( + <p data-testid="markers-level-refused" className="text-[11px] text-[var(--color-bad)]"> + Marker {leadSub + 1} (after {rows[leadSub].after}) is the cut&apos;s first, and a subsection needs a section before it: make it a section, or put a section before it. + </p> + )} {rows.length === 0 ? ( <p className="text-[11px] text-[var(--color-dim)]">No markers: the pip track has no flags.</p> ) : ( @@ -127,8 +156,14 @@ export default function MarkersEditor({ {rows.map((r, i) => { const n = [...r.label.trim()].length; return ( - <li key={i} data-testid={`marker-row-${i}`} className="flex flex-wrap items-center gap-1.5 text-[11px] text-[var(--color-dim)]"> + <li + key={i} + data-testid={`marker-row-${i}`} + data-level={r.level} + className={`flex flex-wrap items-center gap-1.5 text-[11px] text-[var(--color-dim)] ${r.level === 2 ? "pl-5" : ""}`} + > <span className="num w-4 text-right font-mono">{i + 1}</span> + {r.level === 2 && <span aria-hidden="true">›</span>} <label className="flex items-center gap-1"> after <select data-testid={`marker-after-${i}`} value={r.after} onChange={(e) => put(i, { after: e.target.value })} className={`${input} max-w-[16em]`}> @@ -154,11 +189,15 @@ export default function MarkersEditor({ data-testid={`marker-color-${i}`} list="marker-palette" value={r.color} - placeholder="amber" - title="a palette key (amber, accent, fg, muted, dim) or #hex" + placeholder={r.level === 2 ? "parent's" : "amber"} + title={r.level === 2 ? "blank: its section's colour; a palette key (amber, accent, fg, muted, dim) or #hex colours its flag only (the rail keeps its section's)" : "a palette key (amber, accent, fg, muted, dim) or #hex"} onChange={(e) => put(i, { color: e.target.value })} className={`${input} w-20 font-mono`} /> + <label className="flex items-center gap-1" title="a subsection: inside the section before it -- a shorter tick in that section's colour, its label quieter, and the section title says “Section › Sub”"> + <input type="checkbox" data-testid={`marker-sub-${i}`} checked={r.level === 2} onChange={(e) => put(i, { level: e.target.checked ? 2 : 1 })} /> + sub + </label> <select data-testid={`marker-align-${i}`} value={r.align} onChange={(e) => put(i, { align: e.target.value })} className={input} title="where the label sits against its flag"> {aligns.map((a) => ( <option key={a} value={a}> diff --git a/umtool/components/projects/TimelineEditor.tsx b/umtool/components/projects/TimelineEditor.tsx @@ -20,7 +20,8 @@ import { MANIFEST_CHANGED, announceManifestChanged, refusalOf, timelineOp } from // "Undo" restores the cut as it was before the last burst of edits. /** One section of a deck cut (lib/report/sectionEdit.mjs), as the timeline route sends it. */ -export type SectionInfo = { index: number; label: string | null; color: string | null; marker: number | null; clips: string[]; words: string }; +// `level` 2: a subsection (a section to every op, drawn inside `within`, its section, on the deck). +export type SectionInfo = { index: number; label: string | null; color: string | null; marker: number | null; clips: string[]; words: string; level?: number; within?: string | null }; type Ctx = { project: string; @@ -543,7 +544,8 @@ export function SectionBar({ section }: { section: SectionInfo }) { <li data-section-bar={section.index} data-marker={k ?? ""} - className="flex flex-wrap items-center gap-2 rounded-sm border-l-4 bg-[var(--color-panel-2)] px-2 py-1 text-[11.5px]" + data-section-level={section.level === 2 ? 2 : 1} + className={`flex flex-wrap items-center gap-2 rounded-sm border-l-4 bg-[var(--color-panel-2)] px-2 py-1 text-[11.5px] ${section.level === 2 ? "ml-6" : ""}`} style={{ borderLeftColor: section.color ?? "var(--color-line)" }} > {k !== null ? ( @@ -566,6 +568,7 @@ export function SectionBar({ section }: { section: SectionInfo }) { )} <span className="inline-block h-2.5 w-2.5 rounded-full" style={{ background: section.color ?? "transparent", border: "1px solid var(--color-line)" }} /> <span className="font-mono text-[var(--color-dim)]">§{section.index}</span> + {section.level === 2 && <span className="text-[var(--color-dim)]" title={`a subsection of ${section.within ?? "the section before it"}`}>›</span>} <span className="text-[var(--color-text)]" data-section-label=""> {section.label ?? (section.index === 0 ? "the opening" : "(no label)")} </span> diff --git a/umtool/components/projects/review/PlayCut.tsx b/umtool/components/projects/review/PlayCut.tsx @@ -122,14 +122,14 @@ export type PlayViewData = { /** The working cut's name: the latest whole-cut take, the edits since, the pick (lib/report/workingCut.mjs). */ working?: WorkingCut; /** The project's sections (the deck's markers) and each clip's: where a drop on the strip lands. */ - sections?: { index: number; label: string | null; color: string | null; marker: number | null; count: number }[]; + sections?: { index: number; label: string | null; color: string | null; marker: number | null; count: number; level?: 2; within?: string | null }[]; sectionOf?: Record<string, number>; /** The manifest's token when the view was read: a reorder from a stale view is refused, not lost. */ token?: string; /** The take's patch sets its own sections (markers out of step with the cut's): a drop changes the cut, not them. */ sectionsDiffer?: boolean; counter: { verdicts: { id: string; label: string }[]; stamps: { landed: number; verdict: string; count: number }[] }; - markers: { after: string; label: string }[]; + markers: { after: string; label: string; level?: 2 }[]; leadIn: number; transition: number; blurRendered: boolean; diff --git a/umtool/components/projects/review/ReelStrip.tsx b/umtool/components/projects/review/ReelStrip.tsx @@ -41,7 +41,7 @@ export type StripEntry = { id: string; type: string; heading: string; dateKey?: export type StripCounter = { id: string; label: string; steps: Array<{ t: number; n: number }> }; export type StripPin = { id: string; t: number; text: string; open: boolean }; export type StripSeam = { before: string; index: number; date: string | null; label: string | null }; -export type StripSection = { index: number; label: string | null; color: string | null; count?: number }; +export type StripSection = { index: number; label: string | null; color: string | null; count?: number; level?: 2; within?: string | null }; /** A structural edit the strip asks for: a drop, an Alt+arrow, or Move to…. */ export type StripEdit = | { op: "place"; ids: string[]; before: string | null; section: number | null; words: string } diff --git a/umtool/docs/knobs.md b/umtool/docs/knobs.md @@ -215,7 +215,7 @@ that mentions the seizure in question and one before it. The Marks box is on eve | `render.chrome.factcheck.verdicts.<V>.stampLabel` — the stamp's word (singular, `SEIZURE`) beside `label` (the tally's, `SEIZURES`) | fact-check labels, the third column | `factcheck.verdicts.CONTRADICTED.stampLabel=SEIZURE` | same | | `render.chrome.factcheck.verdicts.<V>.tallyLabel` — the deck tally cell's word (`PITCHES`) beside `label` (the finale's totals and stats keep the full `Huck's Blend pitches`). The cell never cuts a label short: without a `tallyLabel` it shows the `label` if it fits, else the longest run of the label's last words that fits (`Huck's Blend pitches` → `Blend pitches`); a `tallyLabel` that does not fit, or a `label` no run of whose last words fits, is refused by name at check time. Measured as drawn: 13 px capitals, 0.08 em spacing, 112 px, in Fira Sans Bold's advances (or 0.6 em a character in a `fontBold` named Mono) | none yet: `umtool look` | `umtool look <p> factcheck.verdicts.PARTLY.tallyLabel=Pitches` (`=` clears it) | `POST /api/report/timeline {op: "factcheck", factcheck}` | | `render.chrome.factcheck.tally.showAt` — `always` (default: every cell from the first frame, dim at 0) or `first` (a cell hidden until the stamp that gives it its first count lands, then it pops in — scale 0.5→1, 0.35 s, the markers' ease — already reading its count, and stays); one value for every cell, or `{ "<VERDICT>": "first" }` for each on its own (unnamed: `always`). A hidden cell keeps its place in the row; the finale's totals show every verdict as ever | fact-check labels, **pop in** per verdict (every one ticked writes `first`) | `umtool look <p> factcheck.tally.showAt=first`, or one cell: `factcheck.tally.showAt.PARTLY=first` (`factcheck.tally.showAt=` clears it) | same | -| `render.chrome.deck.markers[]` — `{after, label ≤ 24, color?, align?}`, at most 12; `align` `auto` `left` `right` `center` | On-screen, **markers**: add, the clip picker, label, colour, align, ↑ ↓, remove | `umtool look <p> deck.markers='[{"after":"c03","label":"Rescue","align":"right"}]'` | `PUT /api/report/chrome {project, token, markers}` | +| `render.chrome.deck.markers[]` — `{after, label ≤ 24, color?, align?, level?}`, at most 32; `align` `auto` `left` `right` `center`; `level` 1 (a section, the default) or 2 (a subsection of the section before it — a shorter tick in its parent's colour, a quieter label, "Section › Sub" in the section title; to every edit a section like any other; the cut's first marker must be a section) | On-screen, **markers**: add, the clip picker, label, colour, sub, align, ↑ ↓, remove | `umtool look <p> deck.markers='[{"after":"c03","label":"Rescue","align":"right"},{"after":"c05","label":"The vet","level":2}]'` · `umtool timeline <p> section-add --after c05 --label "The vet" --level 2` · `section-set <m> --level 1\|2` | `PUT /api/report/chrome {project, token, markers}` | | `render.chrome.deck.<key>` — any of the deck's own keys (`finale`, `pip`, …), as JSON; refused in the build's words when it does not know the key or the value | On-screen settings (the ones it has a field for) | `umtool look <p> deck.finale='{…}'` | — | | `render.chrome.deck.markerLayout` — `stagger` or `truncate` when labels crowd (default: stagger only when a label would truncate) | markers, **layout** | `deck.markerLayout=truncate` | `PUT /api/report/chrome {project, token, markerLayout}` | | `render.chrome.deck.claims[]` — his explicit claims drawn against the record on the rail, at most 6: a `count` or a `goalpost` ([below](#claim-checks-on-the-rail)) | On-screen, **claim checks**: add a count / a goalpost, the clip picker, **use the playhead**, his words, the window's dates, the record's verdict, per, the claim; a goalpost's steps (**add a step**), each its from date and due durations; remove — the build's validator under each as it is typed | `umtool look <p> deck.claims='[…]'` (`deck.claims=` none) | `PUT /api/report/chrome {project, token, claims}` | @@ -611,7 +611,7 @@ then-and-now archive look: dated subtitles, a pitched rail, the pair strip at th A project's `module-config.json` names the modules its video wants in the design's vocabulary (`{ preset, modules: { shell, subtitle, qr, counter, stamp, rail, chapter, pair, status, feed, intro, finale } }`). `umtool modules apply <p>` maps it into the manifest's homes (report-to-video `modules/config-loader.mjs`) and lists, by path, every field -that has none — a cut-wide deck title, a rail node over a year of clips, a marker past the deck's twelve, a citation +that has none — a cut-wide deck title, a rail node over a year of clips, a marker past the deck's 32, a citation URL a status row does not draw, a feed post (posts join through `umtool posts add`). `--take <id>` makes it a take's patch instead. A finale stat `value: "counter.totals.<series>"` is counted from the config's marks at apply time. @@ -713,6 +713,7 @@ The pip track along the top of the deck; the markers' flags stand over it ([mark | `deck.pip.color` | `accent` · `verdict` (a counted clip's pip takes its series' colour and shape) · `section` (every pip, the fuse and the marker's ring in the colour of the section it stands in: from one marker to the next, in that marker's `color`; fitted to 3:1 on the deck) · default `accent` | `umtool look <p> deck.pip='{"color":"verdict"}'` | | `deck.pip.sectionColor0` | the section before the first marker, with `color: "section"`: a `#hex` or a palette key (`fg`, `muted`, `accent`, `amber`, `dim`) · default the accent | `umtool look <p> deck.pip='{"color":"section","sectionColor0":"#5fa8d3"}'` | | `deck.markers[].label` | optional: a marker with none (or `""`) draws a tick at its boundary, no words, and takes no band over the track | `umtool look <p> deck.markers='[{"after":"c04","color":"#e07a9a"}]'` | +| `deck.markers[].level` | `1` (a section, the default) · `2` (a subsection of the section before it: a shorter flag or a half-height tick, its label smaller and quieter, and in sections no colour of its own -- its pips, fuse and ring keep its section's; to every edit a section like any other; the cut's first marker must be a section) · at most 32 markers in all; past a dozen labelled, a label too crowded to say anything is drawn as a tick | `umtool look <p> deck.markers='[{"after":"c04","label":"Early days","level":2}]'` | | `deck.rail.labels` | `false` draws every marker as a tick, no words, and no band over the track (the current section's name can stand under the rail instead: [Section title](#section-title)) · default `true` | `umtool look <p> deck.rail='{"labels":false}'` | ### Counter @@ -737,7 +738,7 @@ The full reference is [Claim checks on the rail](#claim-checks-on-the-rail). A c ### Section title -The current section's name on one quiet line centred under the rail (`render.chrome.deck.sectionTitle`): the label of the marker that opened the section ([Rail](#rail)), `first` before any marker; a marker with no label shows nothing for its section. It crossfades as the rail's marker crosses into the next section, rides the deck away over a card, and is independent of `deck.rail.labels` -- the track can carry no words while this says where the cut is. Off unless set: absent or `false` draws the deck as it always was. The clip's title moves down only by what the line needs. +The current section's name on one quiet line centred under the rail (`render.chrome.deck.sectionTitle`): the label of the marker that opened the section ([Rail](#rail)), `first` before any marker; a marker with no label shows nothing for its section. Inside a subsection (a marker with `level: 2`) it says both, "Section › Sub" (the section's name alone when the subsection has no label). It crossfades as the rail's marker crosses into the next section, rides the deck away over a card, and is independent of `deck.rail.labels` -- the track can carry no words while this says where the cut is. Off unless set: absent or `false` draws the deck as it always was. The clip's title moves down only by what the line needs. | Knob | Range · default | From a terminal | |---|---|---| diff --git a/umtool/e2e/fixtures/knobs-fixture.mjs b/umtool/e2e/fixtures/knobs-fixture.mjs @@ -9,6 +9,8 @@ // (the encoder stubbed: variants.e2e.mjs) and the Sync table // knobs-deck-fixture the deck on (make-fixture.mjs deckManifest), two clips // -- the Markers editor +// markers-cap-fixture the deck on, sixteen clips -- past twelve markers, +// subsections // // Synthetic, like every fixture. import { copyFileSync, mkdirSync, readFileSync, writeFileSync } from "node:fs"; @@ -44,5 +46,24 @@ export function makeKnobsFixture({ reports, manifest, deckManifest, cachedWindow 2, ) + "\n", ); - return { dir, deckDir }; + // markers-cap-fixture: the deck on, sixteen clips -- the Markers editor past + // the old twelve, a subsection row, and a leading one refused + // (markers-cap.spec.ts). + const capDir = path.join(reports, "markers-cap-fixture"); + mkdirSync(capDir, { recursive: true }); + writeFileSync( + path.join(capDir, "video.manifest.json"), + JSON.stringify( + deckManifest( + "markers-cap-fixture", + "The Markers Cap Fixture", + Array.from({ length: 16 }, (_, i) => ({ + type: "clip", id: `m${String(i + 1).padStart(2, "0")}`, video: "vid1", start: 3.0, end: 6.0, cite: 3, section: 0, lock: true, quote: "and because", + })), + ), + null, + 2, + ) + "\n", + ); + return { dir, deckDir, capDir }; } diff --git a/umtool/e2e/markers-cap.spec.ts b/umtool/e2e/markers-cap.spec.ts @@ -0,0 +1,70 @@ +import { test, expect } from "@playwright/test"; +import { readFileSync } from "node:fs"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; +import * as urls from "./urls"; + +// --------------------------------------------------------------------------- +// The deck past twelve markers, and subsections (2026-11-01): the On-screen +// Markers editor adds a fourteenth (the cap is 32, marker-limits.mjs), a row's +// "sub" makes it a subsection (`level: 2`) and the save writes it; a +// subsection as the cut's first marker is refused before a save, and by the +// route in the build's words. +// Fixture: e2e/fixtures/knobs-fixture.mjs (markers-cap-fixture, sixteen clips). +// --------------------------------------------------------------------------- + +const HERE = path.dirname(fileURLToPath(import.meta.url)); +const PROJECT = "reports/markers-cap-fixture"; +const DIR = path.join(HERE, "..", ".e2e-song", "reports", "markers-cap-fixture"); +type Marker = { after: string; label?: string; level?: number }; +const markers = (): Marker[] => JSON.parse(readFileSync(path.join(DIR, "video.manifest.json"), "utf8")).render.chrome?.deck?.markers ?? []; +const tokenOf = async (request: import("@playwright/test").APIRequestContext) => + (await (await request.get(`/api/report/chrome?project=${encodeURIComponent(PROJECT)}`)).json()).token; + +test("the Markers editor: fourteen markers, two of them subsections; a leading subsection refused", async ({ page, request }) => { + test.setTimeout(150_000); + const fonts = JSON.parse(readFileSync(path.join(DIR, "video.manifest.json"), "utf8")).render.fontRegular; + test.skip(!fonts, "the deck refuses to draw without render.fontRegular/fontBold, and make-fixture.mjs found no font on this machine"); + const reset = await request.put("/api/report/chrome", { data: { project: PROJECT, token: await tokenOf(request), markers: [], markerLayout: null } }); + expect(reset.ok(), await reset.text()).toBe(true); + + await page.setViewportSize({ width: 1366, height: 900 }); + await page.goto(urls.section(PROJECT, "onscreen")); + const ed = page.getByTestId("markers-editor"); + await expect(ed).toBeVisible({ timeout: 30_000 }); + // Past the old twelve: fourteen rows, each after the next clip; still room for more. + for (let i = 0; i < 14; i += 1) { + await ed.getByTestId("markers-add").click(); + await ed.getByTestId(`marker-label-${i}`).fill(`Part ${i + 1}`); + } + await expect(ed).toContainText("14 of 32"); + await expect(ed.getByTestId("markers-add")).toBeEnabled(); + await expect(ed.getByTestId("marker-after-13")).toHaveValue("m14"); + // Two subsections. + await ed.getByTestId("marker-sub-3").check(); + await ed.getByTestId("marker-sub-7").check(); + await expect(ed.getByTestId("marker-row-3")).toHaveAttribute("data-level", "2"); + await expect(ed.getByTestId("markers-level-refused")).toHaveCount(0); + await ed.getByTestId("markers-save").click(); + await expect.poll(() => markers().length, { timeout: 30_000 }).toBe(14); + expect(markers().map((m, i) => [i, m.level ?? 1]).filter(([, l]) => l === 2)).toEqual([[3, 2], [7, 2]]); + expect(markers()[3]).toEqual({ after: "m04", label: "Part 4", level: 2 }); + + // A subsection as the cut's first marker: said, and the save held. + await expect(ed.getByTestId("marker-row-3")).toHaveAttribute("data-level", "2", { timeout: 30_000 }); + await ed.getByTestId("marker-sub-0").check(); + await expect(ed.getByTestId("markers-level-refused")).toContainText("a subsection needs a section before it"); + await expect(ed.getByTestId("markers-save")).toBeDisabled(); + await ed.getByTestId("marker-sub-0").uncheck(); + await expect(ed.getByTestId("markers-level-refused")).toHaveCount(0); + await expect(ed.getByTestId("markers-save")).toBeEnabled(); + + // The route refuses it in the build's words, and writes nothing. + const before = markers(); + const r = await request.put("/api/report/chrome", { + data: { project: PROJECT, token: await tokenOf(request), markers: [{ after: "m02", label: "Sub", level: 2 }, { after: "m05", label: "Section" }] }, + }); + expect(r.ok()).toBe(false); + expect(await r.text()).toContain("is a subsection (level 2) with no section before it"); + expect(markers()).toEqual(before); +}); diff --git a/umtool/lib/report/knobs.test.mjs b/umtool/lib/report/knobs.test.mjs @@ -9,6 +9,7 @@ import { mkdir, mkdtemp, readFile, rm, writeFile } from "node:fs/promises"; import { tmpdir } from "node:os"; import path from "node:path"; import test from "node:test"; +import { MARKER_LIMITS } from "umtool-report-to-video/marker-limits"; // The read-back resolves files inside the reports root: this suite's own. const ROOT = await mkdtemp(path.join(tmpdir(), "umtool-knobs-")); @@ -188,7 +189,7 @@ test("updateDeckMarkers: sets the list (align auto dropped) and the layout, leav await assert.rejects(updateDeckMarkers(dir, { markerLayout: "wrap" }), /markerLayout must be/); await assert.rejects(updateDeckMarkers(dir, { markers: [{ after: "zz", label: "x" }] }), /zz/); await assert.rejects(updateDeckMarkers(dir, { markers: [{ after: "c01", label: "x".repeat(25) }] }), /at most 24/); - await assert.rejects(updateDeckMarkers(dir, { markers: Array.from({ length: 13 }, () => ({ after: "c01", label: "x" })) }), /at most 12/); + await assert.rejects(updateDeckMarkers(dir, { markers: Array.from({ length: MARKER_LIMITS.count + 1 }, () => ({ after: "c01", label: "x" })) }), /at most 32/); assert.equal(await readRaw(dir), before); await updateDeckMarkers(dir, { markers: [], markerLayout: null }); const after = (await read(dir)).render.chrome.deck; diff --git a/umtool/lib/report/knobsCli.mjs b/umtool/lib/report/knobsCli.mjs @@ -100,6 +100,8 @@ export const LOOK_USAGE = [ " factcheck.tally.showAt (always|first: a cell hidden until its first count lands, then popped in;", " factcheck.tally.showAt.<VERDICT>=first for one cell) .show .position (right|left)", " deck.markers='[{\"after\":\"c01\",\"label\":\"Arrival\",\"align\":\"left\"}]' deck.markerLayout=stagger|truncate", + " at most 32 markers; \"level\":2 a subsection of the section before it (a shorter tick in its colour, a quieter label,", + " \"Section › Sub\" in the section title); the cut's first marker is a section", " deck.<key>=<json>: any of the deck's own keys (deck.finale='{…}', deck.pip='{…}', …), checked by the build's rules;", " deck.<key>.<field>=… sets one field and keeps the rest (deck.subtitle.lines=2: the source's title on a line of its own)", " deck.pip.color=section: the rail coloured by section (marker to marker, each marker's color; deck.pip.sectionColor0 before", @@ -581,7 +583,7 @@ export function knobsLines(manifest) { } if (Object.keys(k.stamp).length) lines.push(` stamp ${Object.entries(k.stamp).map(([a, b]) => `${a}=${b}`).join(" ")}`); if (Object.keys(k.stampLabels).length) lines.push(` stamp word ${Object.entries(k.stampLabels).map(([a, b]) => `${a}=${b}`).join(" ")}`); - if (k.markers.length) lines.push(` markers ${k.markers.map((m) => `${m.after}:${m.label ? `"${m.label}"` : "(tick)"}${m.color ? `[${m.color}]` : ""}${m.align ? `(${m.align})` : ""}`).join(" ")}${k.markerLayout ? ` · layout ${k.markerLayout}` : ""}`); + if (k.markers.length) lines.push(` markers ${k.markers.map((m) => `${m.after}:${m.label ? `"${m.label}"` : "(tick)"}${m.color ? `[${m.color}]` : ""}${m.align ? `(${m.align})` : ""}${m.level === 2 ? "(sub)" : ""}`).join(" ")}${k.markerLayout ? ` · layout ${k.markerLayout}` : ""}`); for (const c of k.claims) { if (!isObj(c)) continue; if (c.kind === "count") { diff --git a/umtool/lib/report/manifest.mjs b/umtool/lib/report/manifest.mjs @@ -2315,11 +2315,12 @@ export async function placeEntries(dir, ids, { token = null, before = null, sect } /** - * New section here: a marker after clip `afterId`, with a label and a colour. + * New section here: a marker after clip `afterId`, with a label, a colour + * and a level (2: a subsection of the section it splits). * * @param {string} dir * @param {string} afterId - * @param {{ label?: string | null, color?: string | null }} spec + * @param {{ label?: string | null, color?: string | null, level?: number | null }} spec * @param {{ token?: string | null }} [opts] */ export async function addSection(dir, afterId, spec = {}, { token = null } = {}) { @@ -2348,10 +2349,10 @@ export async function removeSection(dir, marker, { token = null } = {}) { } /** - * A section's label and/or colour (its marker's). + * A section's label, colour and/or level (its marker's). * @param {string} dir * @param {number} marker - * @param {{ label?: string | null, color?: string | null }} patch + * @param {{ label?: string | null, color?: string | null, level?: number | null }} patch * @param {{ token?: string | null }} [opts] */ export async function updateSection(dir, marker, patch, { token = null } = {}) { @@ -2899,22 +2900,29 @@ function normalizeMarksInput(list, render) { /** * Normalise a list of deck markers as the editor sends them: each `{ after, - * label?, color?, align? }`, the label trimmed (an empty one left out: a tick), an empty colour and `align: - * "auto"` (the default) left out. + * label?, color?, align?, level? }`, the label trimmed (an empty one left out: a tick), an empty colour, + * `align: "auto"` and `level: 1` (the defaults) left out. * * @param {unknown} markers */ export function normalizeMarkers(markers) { - if (!Array.isArray(markers)) throw new Error("markers must be a list of { after, label?, color?, align? }"); + if (!Array.isArray(markers)) throw new Error("markers must be a list of { after, label?, color?, align?, level? }"); return markers.map((m, i) => { - if (!isObj(m)) throw new Error(`markers[${i}] must be { after, label?, color?, align? }`); + if (!isObj(m)) throw new Error(`markers[${i}] must be { after, label?, color?, align?, level? }`); // An empty label is no label (a tick at the boundary): left out. const label = String(m.label ?? "").trim(); const out = { after: String(m.after ?? "").trim(), ...(label ? { label } : {}) }; const color = typeof m.color === "string" ? m.color.trim() : ""; if (color) out.color = color; if (m.align !== undefined && m.align !== null && m.align !== "" && m.align !== "auto") out.align = m.align; - for (const k of Object.keys(m)) if (!["after", "label", "color", "align"].includes(k)) out[k] = m[k]; + // `level`: 2 a subsection; 1 (a section) is the default, left out. A + // number written as a word ("2") is the number; anything else is kept for + // the deck's check to refuse in words. + if (m.level !== undefined && m.level !== null && m.level !== "") { + const lv = typeof m.level === "string" && /^\s*\d+\s*$/.test(m.level) ? Number(m.level) : m.level; + if (lv !== 1) out.level = lv; + } + for (const k of Object.keys(m)) if (!["after", "label", "color", "align", "level"].includes(k)) out[k] = m[k]; return out; }); } diff --git a/umtool/lib/report/playView.mjs b/umtool/lib/report/playView.mjs @@ -140,7 +140,7 @@ export async function playView(project, { take = null, bare = false } = {}) { // A cut the deck cannot schedule counts nothing on the strip. } const markers = Array.isArray(render.chrome?.deck?.markers) - ? render.chrome.deck.markers.filter((m) => m && typeof m.after === "string").map((m) => ({ after: m.after, label: typeof m.label === "string" ? m.label : "" })) + ? render.chrome.deck.markers.filter((m) => m && typeof m.after === "string").map((m) => ({ after: m.after, label: typeof m.label === "string" ? m.label : "", ...(m.level === 2 ? { level: 2 } : {}) })) : []; // THE SECTIONS A DROP LANDS IN: the project's manifest's (what a reorder writes), each clip's // section and each section's label and colour (sectionEdit.mjs sectionModel) -- as many as @@ -150,7 +150,11 @@ export async function playView(project, { take = null, bare = false } = {}) { // not synced): a drop moves the cut's clips and sections, and this take keeps showing its own. const markersOf = (m) => JSON.stringify(m?.render?.chrome?.deck?.markers ?? null); const sectionsDiffer = !!takeInfo && markersOf(selected) !== markersOf(selectVariant(base, DEFAULT_VARIANT)); - const sections = model.sections.map((x) => ({ index: x.index, label: x.label, color: x.color, marker: x.marker, count: x.clips.length })); + // A subsection (level 2) is a section a drop lands in like any other; `within` names its section. + const sections = model.sections.map((x) => ({ + index: x.index, label: x.label, color: x.color, marker: x.marker, count: x.clips.length, + ...(x.level === 2 ? { level: 2, within: x.within ?? null } : {}), + })); return { project: project.id, title: text(manifest.title) || project.id, diff --git a/umtool/lib/report/sectionEdit.mjs b/umtool/lib/report/sectionEdit.mjs @@ -20,6 +20,14 @@ // - a boundary never moves past its neighbours (markers never cross); // - a marker never follows the last clip (a section after it is empty); // - markers stay within the deck's own limits (validateChrome says so). +// +// A SUBSECTION (a marker with `level: 2`) is a section to every rule here: a +// boundary like any other, never left empty, never crossed, its clips moved +// by the same ops -- so "§4" means the same thing to a drop, the Cut tab and +// the CLI whatever the levels. Only the deck draws it inside its parent (the +// rail's colour, the section title's "Section › Sub"), and the build refuses +// a cut whose first marker is one (validateDeckMarkers): an op that would +// leave one first is refused in those words. const isObj = (v) => !!v && typeof v === "object" && !Array.isArray(v); const isClip = (e) => !!e && (e.kind ?? e.type) === "clip"; @@ -43,9 +51,11 @@ function needDeck(m) { /** * The cut's sections, read from its markers. * - * `sections[i]`: `{ index, label, color, marker, clips, first, last }` -- - * `marker` is the index into `deck.markers` that opens it (null for section - * 0), `clips` its clip ids in order, `first`/`last` its first and last clip. + * `sections[i]`: `{ index, label, color, marker, level, clips, first, last }` + * -- `marker` is the index into `deck.markers` that opens it (null for section + * 0), `level` 1 or 2 (a subsection, which also carries `parent` and `within`, + * its section's index and label), `clips` its clip ids in order, + * `first`/`last` its first and last clip. * `sectionOf` maps a clip id to its section; `entrySection[i]` is the section * of timeline entry i (a card belongs to the section it stands in). Markers * naming no clip of the timeline are left out (`stray`: their indexes). @@ -70,18 +80,22 @@ export function sectionModel(m) { const pal = m?.render?.palette ?? {}; const key = m?.render?.chrome?.deck?.pip?.sectionColor0; const color0 = typeof key === "string" && /^#[0-9a-f]{3,8}$/i.test(key) ? key : (key && pal[key]) || pal.accent || null; - const sections = [ - { index: 0, label: null, color: color0, marker: null, clips: [], first: null, last: null }, - ...placed.map((p, i) => ({ - index: i + 1, - label: typeof p.mk.label === "string" && p.mk.label.trim() ? p.mk.label.trim() : null, - color: typeof p.mk.color === "string" && p.mk.color.trim() ? p.mk.color.trim() : null, - marker: p.k, - clips: [], - first: null, - last: null, - })), - ]; + const sections = [{ index: 0, label: null, color: color0, marker: null, level: 1, clips: [], first: null, last: null }]; + for (const [i, p] of placed.entries()) { + const label = typeof p.mk.label === "string" && p.mk.label.trim() ? p.mk.label.trim() : null; + const own = typeof p.mk.color === "string" && p.mk.color.trim() ? p.mk.color.trim() : null; + // A subsection (`level: 2`) is a section here like any other -- clips + // move into and out of it, its boundary drags, it is never left empty -- + // but it sits inside the section before it: `parent` is that section's + // index (0, the opening, when no level-1 marker comes first), `within` + // its label, and its colour is the parent's, as the rail draws it. + if (p.mk.level === 2) { + const parent = [...sections].reverse().find((x) => x.level === 1) ?? sections[0]; + sections.push({ index: i + 1, label, color: parent.color, marker: p.k, level: 2, parent: parent.index, within: parent.label, clips: [], first: null, last: null }); + } else { + sections.push({ index: i + 1, label, color: own, marker: p.k, level: 1, clips: [], first: null, last: null }); + } + } const sectionOf = new Map(); const entrySection = []; let s = 0; @@ -102,8 +116,11 @@ export function sectionModel(m) { return { sections, sectionOf, entrySection, stray, placed }; } -/** "§3 (Leaves it open)" -- how a sentence names a section. */ -export const sectionWords = (s) => `§${s.index}${s.label ? ` (${s.label})` : s.index === 0 ? " (the opening)" : ""}`; +/** "§3 (Leaves it open)" -- how a sentence names a section; a subsection "§4 (Leaves it open › Why)". */ +export const sectionWords = (s) => { + const words = s.level === 2 ? [s.within, s.label].filter(Boolean).join(" › ") : s.label; + return `§${s.index}${words ? ` (${words})` : s.index === 0 ? " (the opening)" : ""}`; +}; /** * Each marker's `after` again, from what section each clip is in: marker @@ -288,7 +305,7 @@ export function placeIn(m, ids, { before = null, section = null } = {}) { * @param {string} afterId * @param {{ label?: string | null, color?: string | null }} [spec] */ -export function addSectionIn(m, afterId, { label = null, color = null } = {}) { +export function addSectionIn(m, afterId, { label = null, color = null, level = null } = {}) { const markers = needDeck(m); const model = sectionModel(m); const id = String(afterId ?? "").trim(); @@ -305,12 +322,20 @@ export function addSectionIn(m, afterId, { label = null, color = null } = {}) { if (l) mk.label = l; const c = typeof color === "string" ? color.trim() : ""; if (c) mk.color = c; + const lv = levelOf(level); + if (lv !== 1) mk.level = lv; // In the cut's order in the list too: the Markers editor lists them so. const k = model.placed.filter((p) => p.pos < i).reduce((n, p) => Math.max(n, p.k + 1), 0); markers.splice(k, 0, mk); const opened = model.sections[model.entrySection[i]]; const nextClip = tl.slice(i + 1).find(isClip); - return { marker: k, after: id, label: l || null, color: c || null, opens: nextClip?.id ?? null, splitFrom: sectionWords(opened) }; + return { marker: k, after: id, label: l || null, color: c || null, ...(lv === 2 ? { level: 2 } : {}), opens: nextClip?.id ?? null, splitFrom: sectionWords(opened) }; +} + +/** A level as an op is handed it: 1 (or nothing) a section, 2 a subsection; the word "2" is 2; anything else kept for the deck's check. */ +function levelOf(v) { + if (v === null || v === undefined || v === "") return 1; + return typeof v === "string" && /^\s*\d+\s*$/.test(v) ? Number(v) : v; } /** @@ -365,12 +390,12 @@ export function removeBoundaryIn(m, k) { return { marker: n, removed: gone }; } -/** A section's label and/or colour (its marker's): null or "" removes one. */ +/** A section's label, colour and/or level (its marker's): null or "" removes a label or colour; level 1 (or null) a section, 2 a subsection. */ export function setSectionIn(m, k, patch) { const markers = needDeck(m); const n = Number(k); if (!Number.isInteger(n) || !markers[n]) throw new Error(`no marker ${k} (0–${markers.length - 1})`); - if (!isObj(patch) || (!("label" in patch) && !("color" in patch))) throw new Error("send label and/or color"); + if (!isObj(patch) || (!("label" in patch) && !("color" in patch) && !("level" in patch))) throw new Error("send label, color and/or level"); const mk = markers[n]; for (const key of ["label", "color"]) { if (!(key in patch)) continue; @@ -378,6 +403,11 @@ export function setSectionIn(m, k, patch) { if (v) mk[key] = v; else delete mk[key]; } + if ("level" in patch) { + const lv = levelOf(patch.level); + if (lv === 1) delete mk.level; + else mk.level = lv; + } return { marker: n, entry: { ...mk } }; } diff --git a/umtool/lib/report/sectionLevels.test.mjs b/umtool/lib/report/sectionLevels.test.mjs @@ -0,0 +1,129 @@ +// Subsections (`level: 2` on a deck marker, 2026-11-01) through umtool's +// writers: a subsection is a section to every op (it is dragged, moved into, +// never left empty), it sits inside its parent (the colour, "Section › Sub" +// in words), the cut's first marker must be a section -- refused in words, +// nothing written -- and the deck takes up to 32 markers. +// +// Run with: pnpm test:scripts +import assert from "node:assert/strict"; +import { mkdtemp, readFile, rm, writeFile } from "node:fs/promises"; +import { tmpdir } from "node:os"; +import path from "node:path"; +import test from "node:test"; + +import { MARKER_LIMITS } from "umtool-report-to-video/marker-limits"; +import { sectionModel, sectionWords } from "./sectionEdit.mjs"; +import { sectionName } from "./stripDrag.mjs"; +import { sectionLines } from "./timelineCli.mjs"; +import { + MANIFEST_NAME, + StructureRefused, + addSection, + manifestToken, + moveToSection, + removeSection, + updateDeckMarkers, + updateSection, +} from "./manifest.mjs"; + +const clip = (id, start, end) => ({ type: "clip", id, video: "v1", start, end }); +const cut = (markers, n = 8) => ({ + slug: "s", + provenance: { siteOrigin: "https://example.test", channelSlug: "chan" }, + render: { width: 1920, height: 1080, chrome: { engine: "hyperframes", layout: "deck", deck: markers ? { markers } : {} } }, + timeline: Array.from({ length: n }, (_, i) => clip(`c${i}`, 10 * i, 10 * i + 8)), +}); +async function project(manifest) { + const dir = await mkdtemp(path.join(tmpdir(), "umtool-levels-")); + await writeFile(path.join(dir, MANIFEST_NAME), JSON.stringify(manifest, null, 2) + "\n"); + return dir; +} +const raw = (dir) => readFile(path.join(dir, MANIFEST_NAME), "utf8"); +const markersOf = async (dir) => JSON.parse(await raw(dir)).render.chrome.deck.markers ?? []; + +const NESTED = [ + { after: "c1", label: "Who she is", color: "#e070d0" }, + { after: "c3", label: "Early days", level: 2 }, + { after: "c5", label: "After", color: "#7fdc9a" }, +]; + +test("sectionModel: a subsection is a section, with its level, its parent and its parent's colour; in words \"Section › Sub\"", () => { + const { sections, sectionOf } = sectionModel(cut(NESTED)); + assert.deepEqual(sections.map((s) => [s.index, s.level, s.label, s.color, s.parent ?? null, s.clips.join(" ")]), [ + [0, 1, null, null, null, "c0 c1"], + [1, 1, "Who she is", "#e070d0", null, "c2 c3"], + [2, 2, "Early days", "#e070d0", 1, "c4 c5"], + [3, 1, "After", "#7fdc9a", null, "c6 c7"], + ]); + assert.equal(sectionOf.get("c4"), 2); + assert.equal(sectionWords(sections[2]), "§2 (Who she is › Early days)"); + assert.equal(sectionWords(sections[1]), "§1 (Who she is)"); + // The strip's drop words and the CLI's `sections` say it too. + assert.equal(sectionName([{ index: 2, label: "Early days", level: 2, within: "Who she is" }], 2), "§2 Who she is › Early days"); + assert.match(sectionLines(sections)[2], / › Early days/); +}); + +test("updateDeckMarkers: level 1 is left out, \"2\" is 2, 3 is refused; a leading subsection is refused, nothing written", async () => { + const dir = await project(cut(null)); + try { + await updateDeckMarkers(dir, { markers: [{ after: "c1", label: "A", level: 1 }, { after: "c3", label: "a", level: "2" }] }, { token: await manifestToken(dir) }); + assert.deepEqual(await markersOf(dir), [{ after: "c1", label: "A" }, { after: "c3", label: "a", level: 2 }]); + const before = await raw(dir); + await assert.rejects(updateDeckMarkers(dir, { markers: [{ after: "c1", label: "A", level: 3 }] }), (e) => e instanceof StructureRefused && /level must be 1 \(a section\) or 2/.test(e.message)); + // Listed second, but it stands first in the cut. + await assert.rejects( + updateDeckMarkers(dir, { markers: [{ after: "c3", label: "A" }, { after: "c1", label: "a", level: 2 }] }), + (e) => e instanceof StructureRefused && /markers\[1\] \(after c1\) is a subsection \(level 2\) with no section before it/.test(e.message), + ); + assert.equal(await raw(dir), before); + } finally { + await rm(dir, { recursive: true, force: true }); + } +}); + +test("the cap: 32 markers are written, 33 refused", async () => { + const dir = await project(cut(null, 40)); + try { + const marks = (n) => Array.from({ length: n }, (_, i) => ({ after: `c${i}`, label: `S${i}`, ...(i % 3 === 2 ? { level: 2 } : {}) })); + await updateDeckMarkers(dir, { markers: marks(MARKER_LIMITS.count) }); + assert.equal((await markersOf(dir)).length, 32); + await assert.rejects(updateDeckMarkers(dir, { markers: marks(33) }), /33 markers \(at most 32\)/); + } finally { + await rm(dir, { recursive: true, force: true }); + } +}); + +test("section ops: add a subsection, set a level, move a clip into one; an op that leaves a subsection first is refused", async () => { + const dir = await project(cut([{ after: "c1", label: "Who she is" }, { after: "c5", label: "After" }])); + try { + const r = await addSection(dir, "c3", { label: "Early days", level: "2" }); + assert.equal(r.level, 2); + assert.deepEqual((await markersOf(dir)).map((m) => [m.after, m.level ?? 1]), [["c1", 1], ["c3", 2], ["c5", 1]]); + // Moved into the subsection like into any section; the markers follow. + await moveToSection(dir, ["c0"], 2); + const m1 = JSON.parse(await raw(dir)); + assert.deepEqual(sectionModel(m1).sections[2].clips, ["c4", "c5", "c0"]); + // Removing its section's boundary would leave it the cut's first marker: refused, nothing written. + const before = await raw(dir); + await assert.rejects(removeSection(dir, 0), (e) => e instanceof StructureRefused && /subsection \(level 2\) with no section before it/.test(e.message)); + assert.equal(await raw(dir), before); + // Back to a section: the key goes. + await updateSection(dir, 1, { level: 1 }); + assert.equal("level" in (await markersOf(dir))[1], false); + await updateSection(dir, 1, { level: 2 }); + assert.equal((await markersOf(dir))[1].level, 2); + } finally { + await rm(dir, { recursive: true, force: true }); + } +}); + +test("a leading subsection at its birth: a level-2 section added before every other marker is refused", async () => { + const dir = await project(cut([{ after: "c4", label: "Later" }])); + try { + const before = await raw(dir); + await assert.rejects(addSection(dir, "c1", { label: "Early", level: 2 }), (e) => e instanceof StructureRefused && /no section before it/.test(e.message)); + assert.equal(await raw(dir), before); + } finally { + await rm(dir, { recursive: true, force: true }); + } +}); diff --git a/umtool/lib/report/stripDrag.mjs b/umtool/lib/report/stripDrag.mjs @@ -33,10 +33,11 @@ export function itemSections(items, sectionOf) { return out.map((s) => s ?? 0); } -/** "§3 Leaves it open" -- a section in the drop's words. */ +/** "§3 Leaves it open" -- a section in the drop's words; a subsection "§4 Leaves it open › Why". */ export const sectionName = (sections, k) => { const s = (sections ?? []).find((x) => x.index === k); - return `§${k}${s?.label ? ` ${s.label}` : k === 0 ? " (the opening)" : ""}`; + const words = s?.level === 2 ? [s.within, s.label].filter(Boolean).join(" › ") : s?.label; + return `§${k}${words ? ` ${words}` : k === 0 ? " (the opening)" : ""}`; }; /** diff --git a/umtool/lib/report/timelineCli.mjs b/umtool/lib/report/timelineCli.mjs @@ -104,9 +104,11 @@ export const TIMELINE_USAGE = [ " umtool timeline <project> sections [--json] the deck's sections: §, label, colour, its marker, its clips", " umtool timeline <project> section-move <id> [<id>…] --to-section N [--start]", " clips to the end (--start: the start) of section N, every marker following", - " umtool timeline <project> section-add --after <id> [--label L] [--color C] new section after the clip", + " umtool timeline <project> section-add --after <id> [--label L] [--color C] [--level 2] new section after the clip", + " (--level 2: a subsection of the section it splits -- a section to every op, drawn inside its", + " parent on the rail; the cut's first marker must be a section)", " umtool timeline <project> section-boundary <marker> --after <id> drag a boundary (between its neighbours)", - " umtool timeline <project> section-remove <marker> | section-set <marker> [--label L] [--color C]", + " umtool timeline <project> section-remove <marker> | section-set <marker> [--label L] [--color C] [--level 1|2]", " every section op brings the take patches' markers (*.patch.json in step with the manifest) along", " umtool timeline <project> split <id> <second> two clips at that source second (each half's quote from the words)", " umtool timeline <project> flash-forward <id> <from>-<to> (--after <id|-> | --to-section N [--start])", @@ -122,7 +124,7 @@ export const TIMELINE_USAGE = [ const SECTION_VERBS = ["sections", "section-move", "section-add", "section-boundary", "section-remove", "section-set"]; const VERBS = ["ls", "insert", "move", "place", "remove", "reject", "wrong-speaker", "duplicate", "post", "post-remove", "teaser", "undo", ...SECTION_VERBS, "split", "flash-forward"]; -const VALUED = new Set(["--after", "--before", "--to", "--at", "--id", "--section", "--title", "--stream-title", "--date", "--quote", "--cite", "--cite-url", "--take", "--correction", "--note", "--to-section", "--label", "--color"]); +const VALUED = new Set(["--after", "--before", "--to", "--at", "--id", "--section", "--title", "--stream-title", "--date", "--quote", "--cite", "--cite-url", "--take", "--correction", "--note", "--to-section", "--label", "--color", "--level"]); /** What `--take <id>` does on a take's timeline (takeEdit.mjs): the walk's structure and its undo. */ const TAKE_VERBS = ["ls", "move", "remove", "undo"]; @@ -521,7 +523,7 @@ export async function timelineCommand(args, { root = REPORTS_ROOT, out = (s) => const after = flags.get("--after"); if (typeof after !== "string" || !after) throw new CliError("section-add needs --after <clip id>"); const str = (k) => (typeof flags.get(k) === "string" ? String(flags.get(k)) : null); - ({ result, editNotes } = await write((token) => addSection(project.dir, after, { label: str("--label"), color: str("--color") }, { token }))); + ({ result, editNotes } = await write((token) => addSection(project.dir, after, { label: str("--label"), color: str("--color"), level: str("--level") }, { token }))); break; } case "section-boundary": { @@ -538,7 +540,7 @@ export async function timelineCommand(args, { root = REPORTS_ROOT, out = (s) => } case "section-set": { const marker = Number(need(rest[0], "a marker's number (`sections` lists them)")); - const patch = Object.fromEntries([["--label", "label"], ["--color", "color"]].filter(([f]) => flags.has(f)).map(([f, k]) => [k, flags.get(f) === true ? "" : flags.get(f)])); + const patch = Object.fromEntries([["--label", "label"], ["--color", "color"], ["--level", "level"]].filter(([f]) => flags.has(f)).map(([f, k]) => [k, flags.get(f) === true ? "" : flags.get(f)])); ({ result, editNotes } = await write((token) => updateSection(project.dir, marker, patch, { token }))); break; } @@ -660,7 +662,9 @@ async function takeTimeline(project, take, verb, rest, flags, { out, json }) { export function sectionLines(sections) { return sections.map((s) => { const clips = s.clips.length > 6 ? `${s.clips.slice(0, 3).join(" ")} … ${s.clips.slice(-2).join(" ")}` : s.clips.join(" "); - return `§${String(s.index).padEnd(3)} ${s.marker === null ? " " : `m${String(s.marker).padEnd(4)} `} ${String(s.color ?? "").padEnd(8)} ${(s.label ?? (s.index === 0 ? "(the opening)" : "(no label)")).padEnd(26)} ${String(s.clips.length).padStart(3)} clip(s): ${clips}`; + // A subsection (level 2) is indented under its section: " › label". + const label = s.label ?? (s.index === 0 ? "(the opening)" : "(no label)"); + return `§${String(s.index).padEnd(3)} ${s.marker === null ? " " : `m${String(s.marker).padEnd(4)} `} ${String(s.color ?? "").padEnd(8)} ${(s.level === 2 ? ` › ${label}` : label).padEnd(26)} ${String(s.clips.length).padStart(3)} clip(s): ${clips}`; }); } @@ -669,7 +673,7 @@ function summaryOf(verb, r, attribution) { case "section-move": return `moved ${r.ids.join(", ")} to the ${r.position} of §${r.section}${r.label ? ` (${r.label})` : ""}`; case "section-add": - return `new section after ${r.after} (marker ${r.marker}${r.label ? `, "${r.label}"` : ""}${r.color ? `, ${r.color}` : ""}): it opens on ${r.opens}`; + return `new ${r.level === 2 ? "subsection" : "section"} after ${r.after} (marker ${r.marker}${r.label ? `, "${r.label}"` : ""}${r.color ? `, ${r.color}` : ""}): it opens on ${r.opens}`; case "section-boundary": return `marker ${r.marker} follows ${r.after} now (was ${r.from})${r.moved.length ? `: ${r.moved.join(", ")} now in ${r.into}` : ""}`; case "section-remove": diff --git a/umtool/report-to-video/README.md b/umtool/report-to-video/README.md @@ -434,7 +434,7 @@ whatever a manifest omits, one level deep: "background": "panel", // "panel" (lifted) | "flush" "pip": { "spacing": "even", "size": 6, "activeSize": 12, // spacing "even" | "time"; activeSize ≥ size "color": "accent" }, // | "verdict": a claimed clip's pip in its verdict's colour and shape (below) - "markers": [ { "after": "c07", "label": "3 to 5 weeks pass", "color": "amber" } ], // flags on the pip track (below); at most 12 + "markers": [ { "after": "c07", "label": "3 to 5 weeks pass", "color": "amber" } ], // flags on the pip track (below); at most 32; `level: 2` a subsection "title": { "size": 54, "maxChars": 48 }, // size 24–96; maxChars 10–120 (the editor's counter, not a refusal) "subtitle": { "parts": "auto", "dateFormat": "long", // parts "auto" | a distinct list of channel/title/date/clock; dateFormat "long" | "iso" "lines": 1, "head": "auto" }, // lines 2: `head`'s parts (auto = the title) on a line of their own over the rest; the deck grows by it @@ -534,14 +534,19 @@ timeline itself: - **`deck.markerLayout`** (`"stagger"`, the default, or `"truncate"`). When a label would not fit its box (`markerLabelWidth`: its characters at a bold sans's advances, a little over Fira Sans Bold's measured ones), "stagger" - splits the flags between two rows — every split is tried and the one where - the most labels fit wins, then the least cut off the rest, then the fewest in - the upper row. The band grows by `MARKER_ROW` (22 px) and the track, the + splits the flags between two rows — up to 12 labelled flags every split is + tried and the one where the most labels fit wins, then the least cut off the + rest, then the fewest in the upper row; past 12 (`MARKER_SPLIT_SEARCH`) it + starts from alternating flags and moves one flag at a time to the other row + while that lays better, by the same order. The band grows by `MARKER_ROW` (22 px) and the track, the title, the tally and the QR move down by it (the QR shrinks to the room left, as under one row). Row 1's flags carry a stick up to their labels, a row above row 0's; row 0's labels keep 8 px clear of those sticks; neither row reaches the flags' heads. A label that still does not fit is ellipsized, - as in one row. A row that fits is laid exactly as before, whichever the + as in one row — unless its box is also under `MARKER_LABEL_MIN_BOX` (44 px, + a letter and an ellipsis): then it is laid without words (`hide`, drawn as a + tick) and the others are laid again with its room, so a crowded rail (20, + 32 markers) says the labels it can rather than a row of "…". A row that fits is laid exactly as before, whichever the setting; "truncate" always keeps one row. `deckLayout(render, { schedule })` is what knows the band's height — the deck page and `compose-chrome` (for the QR's size) pass the schedule. @@ -558,6 +563,18 @@ timeline itself: section they stand in; a marker's own pip closes the section before it. A colour under 3:1 on the deck's ground is lifted toward white until it reads (`fitSectionColor`). +- **Subsections** (`level: 2` on a marker; absent is 1, a section). A + subsection sits inside the section before it: on the rail a shorter flag + (or a half-height tick), its label at 14 px (`MARKER_SUB_LABEL_SIZE`) and + quieter, and in sections no colour of its own — its pips, fuse bar and ring + keep its parent's (a flag with no `color` wears the parent's too); the + finale's large rail draws its flag thinner and its words quieter. The + section title says "Section › Sub" inside it. To every edit (umtool's + section ops, Play's strip, the Cut tab) it is a section like any other: a + boundary that is dragged, never left empty, never crossed. The cut's first + marker (by where it stands) must be a section: a leading subsection is + refused (`validateDeckMarkers`). `marker-limits.mjs` holds the count, the + label's length and the levels — the one copy, the browser's too. ```jsonc "deck": { "pip": { "color": "section", "sectionColor0": "#c8752a" }, @@ -565,9 +582,10 @@ timeline itself: "markers": [{ "after": "q01", "color": "#e07a9a" }, { "after": "d01", "color": "#5fa8d3" }] } ``` - **Refused.** `after` must name a CLIP in the timeline, a label (when given) - one line of ≤ 24 characters, at most 12 markers, a colour a hex or a - palette key, `align` one of the four, `markerLayout` one of the two, and - unknown keys are refused. `validateChrome` checks the + one line of ≤ 24 characters, at most 32 markers, a colour a hex or a + palette key, `align` one of the four, `level` 1 or 2 (and the cut's first + marker a section), `markerLayout` one of the two, and unknown keys are + refused. `validateChrome` checks the shape; `validateDeckMarkers(manifest)` (`deck.mjs`) checks the shape and `after` against the whole timeline — the build, the lint and umtool's writers all call it, so removing a clip a marker follows is refused until diff --git a/umtool/report-to-video/chrome-deck.mjs b/umtool/report-to-video/chrome-deck.mjs @@ -38,13 +38,14 @@ import { fileURLToPath } from "node:url"; import { - claimsLayout, cueTime, cueTimeAfter, PIP_PITCH_DEFAULT, stampsOnFrames, deckChoreography, deckLayout, deckMarkers, MARKER_DEFAULT_COLOR, MARKER_LABEL_SIZE, MARKER_ROW, pageDuration, pipSegments, pipXs, railSections, resolveDeck, + claimsLayout, cueTime, cueTimeAfter, PIP_PITCH_DEFAULT, stampsOnFrames, deckChoreography, deckLayout, deckMarkers, MARKER_DEFAULT_COLOR, MARKER_LABEL_SIZE, MARKER_ROW, MARKER_SUB_LABEL_SIZE, pageDuration, pipSegments, pipXs, railSections, resolveDeck, resolveSectionTitle, } from "./deck.mjs"; import { contrast } from "./chrome-intro.mjs"; import { claimsCues, claimsMarkup } from "./chrome-claims.mjs"; import { resolveFactcheck, tallyCues, tallyFinals, tallyKey, tallyLabelOf, tallyOf, tallyPopIns } from "./factcheck.mjs"; import { resolveCounter } from "./counter.mjs"; +import { SUBSECTION_SEPARATOR } from "./marker-limits.mjs"; /** * GSAP, vendored, for every chrome region. @@ -488,16 +489,37 @@ export function sectionTitleTimeline(schedule, render, ch = null) { const hexOf = (key, fallback) => (typeof key === "string" && HEX_RE.test(key) ? key : (key && pal[key]) || fallback); // The markers as the rail's sections take them: by the pip they follow. const ms = (Array.isArray(d.markers) ? d.markers : []) - .map((m) => ({ k: pipOf.get(String(m?.after ?? "").trim()), label: String(m?.label ?? "").trim(), color: m?.color ?? MARKER_DEFAULT_COLOR })) + .map((m) => ({ + k: pipOf.get(String(m?.after ?? "").trim()), label: String(m?.label ?? "").trim(), color: m?.color ?? MARKER_DEFAULT_COLOR, + sub: m?.level === 2, + })) .filter((m) => m.k !== undefined) .sort((a, b) => a.k - b.k); + // A subsection (`level: 2`) says its section too: "Section › Sub" (either + // alone when the other has no words), in its section's colour. Its section + // is the nearest level-1 marker before it (the opening, `first`, if none). + const parentOf = []; + for (let i = 0, p = 0; i < ms.length; i += 1) { + parentOf.push(p); + if (!ms[i].sub) p = i + 1; + } const sectionOf = (k) => ms.filter((m) => m.k < k).length; const byColor = st.color === "section"; - const colorOf = (i) => (i === 0 ? hexOf(d.pip.sectionColor0, pal.accent ?? "#ffffff") : hexOf(ms[i - 1].color, pal.fg ?? "#ffffff")); + const colorOf = (i) => { + if (i === 0) return hexOf(d.pip.sectionColor0, pal.accent ?? "#ffffff"); + return ms[i - 1].sub ? colorOf(parentOf[i - 1]) : hexOf(ms[i - 1].color, pal.fg ?? "#ffffff"); + }; + const labelOf = (i) => { + if (i === 0) return st.first; + const m = ms[i - 1]; + if (!m.sub) return m.label; + const up = parentOf[i - 1] === 0 ? st.first : ms[parentOf[i - 1] - 1].label; + return [up, m.label].filter(Boolean).join(SUBSECTION_SEPARATOR); + }; const titles = []; const ids = new Map(); const titleOf = (i) => { - const label = i === 0 ? st.first : ms[i - 1].label; + const label = labelOf(i); if (!label) return null; const color = byColor ? colorOf(i) : null; const key = `${label}\u0000${color ?? ""}`; @@ -757,12 +779,15 @@ export function deckHtml(schedule, render, opts = {}) { // their labels, a row above row 0's. A label's `align` sets its text's side. const markerHtml = markers .map((mk, j) => { - // Unlabelled: a tick at the boundary, no flag, no words. - if (!mk.label) return `<div class="mflag bare" data-k="mk${j}" data-after="${esc(mk.after)}" style="left:${r4(mk.x)}px; --mc:${esc(secColors ? secColors[sectionOfMarker(sections, mk)] : mk.color)}"><div class="mtick"></div></div>`; + // A subsection (`level: 2`): a shorter tick or flag, its words quieter. + const sub = mk.level === 2 ? " sub" : ""; + // Unlabelled -- or its label laid without words, the rail too crowded + // for it (`hide`): a tick at the boundary, no flag, no words. + if (!mk.label || mk.hide) return `<div class="mflag bare${sub}" data-k="mk${j}" data-after="${esc(mk.after)}" style="left:${r4(mk.x)}px; --mc:${esc(secColors ? secColors[sectionOfMarker(sections, mk)] : mk.color)}"><div class="mtick"></div></div>`; const left = r4(mk.box[0] - mk.x); const side = mk.align === "left" || mk.align === "right" ? `; text-align:${mk.align}` : ""; return ( - `<div class="mflag${mk.row === 1 ? " up" : ""}" data-k="mk${j}" data-after="${esc(mk.after)}" style="left:${r4(mk.x)}px; --mc:${esc(mk.color)}">` + + `<div class="mflag${mk.row === 1 ? " up" : ""}${sub}" data-k="mk${j}" data-after="${esc(mk.after)}" style="left:${r4(mk.x)}px; --mc:${esc(mk.color)}">` + `<div class="mstick"></div><div class="mhead"></div>` + `<div class="mlabel" style="left:${left}px; width:${mk.box[1] - mk.box[0]}px${side}">${esc(mk.label)}</div></div>` ); @@ -984,9 +1009,15 @@ export function deckHtml(schedule, render, opts = {}) { .mlabel { position: absolute; top: ${(band?.y ?? 3) + (staggered ? MARKER_ROW : 0) - tr.y}px; height: 20px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-family: 'DeckSansBold', sans-serif; font-size: ${MARKER_LABEL_SIZE}px; line-height: 20px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--mc); - text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6); }` : ""}${markers.some((mk) => !mk.label) ? ` + text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6); }` : ""}${markers.some((mk) => mk.level === 2 && mk.label && !mk.hide) ? ` + /* A subsection's flag: shorter, its head smaller, its words smaller and quieter. */ + .mflag.sub .mstick { top: -8px; height: 14px; width: 2px; left: -1px; } + .mflag.sub .mhead { top: -8px; left: 1px; width: 8px; height: 7px; } + .mflag.sub .mlabel { font-size: ${MARKER_SUB_LABEL_SIZE}px; opacity: 0.72; }` : ""}${markers.some((mk) => !mk.label || mk.hide) ? ` /* An unlabelled marker: a short tick across the track, no words. */ - .mtick { position: absolute; left: -1px; top: -6px; width: 2px; height: 12px; border-radius: 1px; background: var(--mc); opacity: 0.85; }` : ""}${staggered ? ` + .mtick { position: absolute; left: -1px; top: -6px; width: 2px; height: 12px; border-radius: 1px; background: var(--mc); opacity: 0.85; }` : ""}${markers.some((mk) => (!mk.label || mk.hide) && mk.level === 2) ? ` + /* A subsection's tick: half as tall. */ + .mflag.sub .mtick { top: -3px; height: 6px; opacity: 0.7; }` : ""}${staggered ? ` /* Staggered labels: row 1 a row above, its flag's stick up to it. */ .mflag.up .mlabel { top: ${band.y - tr.y}px; } .mflag.up .mstick { top: ${band.y + 20 - tr.y}px; height: ${tr.y + 6 - (band.y + 20)}px; }` : ""}${stRow ? ` diff --git a/umtool/report-to-video/chrome-finale.mjs b/umtool/report-to-video/chrome-finale.mjs @@ -410,7 +410,7 @@ export function finaleHtml(schedule, render, window, opts = {}) { ? `<div class="ml" data-k="ml${j}" style="top:${top - Y}px; ${mk.side === "right" ? "left:18px" : "right:18px"}; max-width:${mk.max}px">${esc(mk.label)}</div>` : ""; return ( - `<div class="mf" data-k="mk${j}" style="left:${r2(mk.x)}px; top:${Y}px; --mc:${esc(mk.color)}">` + + `<div class="mf${mk.level === 2 ? " sub" : ""}" data-k="mk${j}" style="left:${r2(mk.x)}px; top:${Y}px; --mc:${esc(mk.color)}">` + `<div class="ms" style="top:${-stick}px; height:${stick}px"></div>` + `<div class="mh${mk.side === "left" ? " left" : ""}" style="top:${-stick}px"></div>${label}</div>` ); @@ -522,7 +522,11 @@ export function finaleHtml(schedule, render, window, opts = {}) { .mh.left { left: -18px; clip-path: polygon(100% 0%, 0% 50%, 100% 100%); } .ml { position: absolute; height: ${Math.round(rail.markerSize * 1.25)}px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-family: 'DeckSansBold', sans-serif; font-size: ${rail.markerSize}px; line-height: ${Math.round(rail.markerSize * 1.25)}px; - letter-spacing: 0.04em; text-transform: uppercase; color: var(--mc); text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6); margin-top: -${Math.round(rail.markerSize * 0.2)}px; }${fq ? fq.css : ""} + letter-spacing: 0.04em; text-transform: uppercase; color: var(--mc); text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6); margin-top: -${Math.round(rail.markerSize * 0.2)}px; }${L.marks.some((mk) => mk.level === 2) ? ` + /* A subsection's flag (\`level: 2\`): a thinner stick, a smaller head, its words quieter. */ + .mf.sub .ms { left: -1.5px; width: 3px; } + .mf.sub .mh { width: 12px; height: 10px; } + .mf.sub .ml { opacity: 0.72; }` : ""}${fq ? fq.css : ""} .tc { position: absolute; border-radius: 14px; background: ${rgba(pal.fg, 0.045)}; box-shadow: inset 0 0 0 2px var(--vr); overflow: hidden; transform-origin: 0 0; } .tbar { position: absolute; left: 0; top: 0; width: 100%; height: 8px; background: var(--vc); } diff --git a/umtool/report-to-video/deck-counts.test.mjs b/umtool/report-to-video/deck-counts.test.mjs @@ -214,7 +214,14 @@ test("markers: shape refused in sentences -- unknown keys, labels, colours, coun assert.match(bad([{ after: "c2", label: "a\nb" }]), /must be one line/); assert.match(bad([{ after: "c2", label: "x", color: "red" }]), /color must be a #hex colour/); assert.equal(bad([{ after: "c2", label: "x", color: "amber" }]), ""); - assert.match(bad(Array.from({ length: 13 }, () => ({ after: "c2", label: "x" }))), /13 markers \(at most 12\)/); + // The count is the one shared constant (marker-limits.mjs): 32 since 2026-11-01, not 12. + assert.equal(MARKER_LIMITS.count, 32); + assert.equal(bad(Array.from({ length: 32 }, () => ({ after: "c2", label: "x" }))), ""); + assert.match(bad(Array.from({ length: 33 }, () => ({ after: "c2", label: "x" }))), /33 markers \(at most 32\)/); + // `level`: 1 (a section, the default) or 2 (a subsection); nothing else. + assert.equal(bad([{ after: "c2", label: "x", level: 1 }, { after: "c4", label: "y", level: 2 }]), ""); + assert.match(bad([{ after: "c2", label: "x", level: 3 }]), /markers\[0\]\.level must be 1 \(a section\) or 2 \(a subsection\)/); + assert.match(bad([{ after: "c2", label: "x", level: "2" }]), /level must be 1/); }); test("markers: `after` must name a clip in the timeline -- the build's, the lint's and the writer's check", () => { diff --git a/umtool/report-to-video/deck-subsections.test.mjs b/umtool/report-to-video/deck-subsections.test.mjs @@ -0,0 +1,176 @@ +// The deck past a dozen markers, and subsections (2026-11-01): the marker cap +// is one shared constant (marker-limits.mjs, 32); the rail lays 24 and 32 +// labelled flags without two labels meeting, saying the ones it can and a tick +// for the rest; a marker with `level: 2` is a subsection -- a shorter flag in +// its section's colour, a quieter label, no colour band of its own, "Section › +// Sub" in the section title -- and the cut's first marker must be a section. +// +// Run with: pnpm test:scripts +import assert from "node:assert/strict"; +import test from "node:test"; + +import { + deckLayout, deckMarkers, deckSchedule, MARKER_LABEL_MIN_BOX, MARKER_LEVELS, MARKER_LIMITS, MARKER_SUB_LABEL_SIZE, markerLabelWidth, + markerRowsOf, pipSegments, pipXs, railSections, resolveDeck, validateChrome, validateDeckMarkers, +} from "./deck.mjs"; +import { deckHtml, sectionTitleAt, sectionTitleTimeline } from "./chrome-deck.mjs"; +import * as limits from "./marker-limits.mjs"; + +const PALETTE = { bg: "#12101a", fg: "#f4f1ea", muted: "#9a93ad", accent: "#a97bff", amber: "#ffc860" }; +const CHROME = { engine: "hyperframes", layout: "deck" }; +const BASE = { width: 1920, height: 1080, fps: 30, transition: 0.5, palette: PALETTE }; +const PROV = { siteOrigin: "https://example.test", channelSlug: "chan" }; +const renderWith = (deck = {}) => ({ ...BASE, chrome: { ...CHROME, deck } }); + +const N = 40; +const ENTRIES = Array.from({ length: N }, (_, i) => ({ id: `c${i}`, type: "clip", video: `v${i}`, start: 0, end: 30 })); +const DURS = ENTRIES.map(() => 30); +const COLORS = ["#e070d0", "#f2a65a", "#ffc861", "#c4a1ff", "#6fc3ff", "#7fdc9a", "#5fd1c9", "#ff7a59"]; + +/** `n` labelled markers after c0…c(n-1), every `subEvery`-th one a subsection (none when 0). */ +const many = (n, { subEvery = 0, label = (i) => `Section ${i + 1}: words` } = {}) => + Array.from({ length: n }, (_, i) => ({ + after: `c${i}`, label: label(i), color: COLORS[i % COLORS.length], + ...(subEvery && i % subEvery === subEvery - 1 ? { level: 2 } : {}), + })); + +function lay(render) { + const s = deckSchedule({ entries: ENTRIES, durs: DURS, D: 0.5, render, provenance: PROV }); + const l = deckLayout(render, { schedule: s }); + const pipped = pipSegments(s); + const xs = pipXs(pipped.length, l.pipTrack.x0, l.pipTrack.x1, "even"); + return { s, l, ms: deckMarkers(s, render, xs, pipped, l), pipped }; +} + +/** No two labels in a row meet; row 0 keeps clear of row 1's sticks; every box inside the deck; a hidden label has no box. */ +function assertLegible(ms, W) { + const shown = ms.filter((m) => m.label && !m.hide); + for (const row of [0, 1]) { + const inRow = shown.filter((m) => (m.row ?? 0) === row).sort((a, b) => a.x - b.x); + for (let j = 1; j < inRow.length; j += 1) { + assert.ok(inRow[j - 1].box[1] < inRow[j].box[0], `row ${row}: ${inRow[j - 1].after} ${inRow[j - 1].box} and ${inRow[j].after} ${inRow[j].box} meet`); + } + } + const sticks = shown.filter((m) => m.row === 1).map((m) => m.x); + for (const m of shown.filter((x) => (x.row ?? 0) === 0)) { + for (const x of sticks) assert.ok(x < m.box[0] || x > m.box[1], `${m.after}'s label crosses a stick at ${x}`); + } + for (const m of shown) { + assert.ok(m.box[0] >= 16 && m.box[1] <= W - 16, `${m.after} ${m.box}`); + const w = m.box[1] - m.box[0]; + assert.ok(w >= MARKER_LABEL_MIN_BOX || markerLabelWidth(m.label, m.level === 2 ? MARKER_SUB_LABEL_SIZE : 18) <= w, `${m.after}'s box ${m.box} is too narrow to say anything and was not hidden`); + } + for (const m of ms.filter((x) => x.hide)) assert.equal(m.box[0], m.box[1], `${m.after} is hidden: an empty box`); +} + +test("the cap is one constant: 32 markers, 24 characters, levels 1 and 2 -- deck.mjs re-exports marker-limits.mjs", () => { + assert.equal(MARKER_LIMITS, limits.MARKER_LIMITS); + assert.deepEqual({ ...MARKER_LIMITS }, { count: 32, label: 24 }); + assert.deepEqual([...MARKER_LEVELS], [1, 2]); + assert.equal(limits.SUBSECTION_SEPARATOR, " › "); + const bad = (markers) => validateChrome({ ...CHROME, deck: { markers } }, BASE); + assert.deepEqual(bad(many(32)), []); + assert.match(bad(many(33)).join(" "), /has 33 markers \(at most 32\)/); +}); + +for (const n of [24, 32]) { + test(`${n} labelled markers stagger legibly: no label meets another, a stick or the edge; the rest are ticks, never "…" alone`, () => { + const r = renderWith({ markers: many(n) }); + const t0 = Date.now(); + const { s, l, ms } = lay(r); + assert.ok(Date.now() - t0 < 2000, `laid in ${Date.now() - t0} ms`); + assert.equal(ms.length, n); + assert.equal(markerRowsOf(s, r), 2); + assertLegible(ms, l.width); + // Two rows say more than one would: the labels with words, at least as many + // as half the flags (each row holds every other one or so). + const shown = ms.filter((m) => !m.hide); + assert.ok(shown.length >= Math.floor(n / 2), `${shown.length} of ${n} labels drawn`); + // The page draws a hidden label as a tick, the others as flags with words. + const html = deckHtml(s, r, {}); + assert.equal((html.match(/class="mflag bare"/g) ?? []).length, ms.filter((m) => m.hide).length); + assert.equal((html.match(/class="mlabel"/g) ?? []).length, shown.length); + }); + + test(`${n} markers, truncate: one row, no two labels meet, a box too narrow is a tick`, () => { + const { l, ms } = lay(renderWith({ markers: many(n), markerLayout: "truncate" })); + for (const m of ms) assert.equal("row" in m, false); + assertLegible(ms, l.width); + }); +} + +test("short labels at 32 markers all fit in two rows: nothing hidden", () => { + const { l, ms } = lay(renderWith({ markers: many(32, { label: (i) => `S${i + 1}` }) })); + assert.equal(ms.filter((m) => m.hide).length, 0); + assert.ok(ms.every((m) => markerLabelWidth(m.label) <= m.box[1] - m.box[0]), "every label fits its box"); + assertLegible(ms, l.width); +}); + +test("a dozen or fewer: the exhaustive split, as before -- nothing hidden on a roomy rail", () => { + const { ms } = lay(renderWith({ markers: many(12).map((m, i) => ({ ...m, after: `c${3 * i + 1}` })) })); + assert.equal(ms.filter((m) => m.hide).length, 0); + assert.ok(ms.every((m) => !("level" in m)), "no level key on a section"); +}); + +test("a subsection: `level: 2` placed, its own colour kept, else its section's; measured at its own size", () => { + const markers = [ + { after: "c2", label: "Who she is", color: "#e070d0" }, + { after: "c4", label: "Early days", level: 2 }, + { after: "c6", label: "On stage", level: 2, color: "#5fd1c9" }, + { after: "c9", label: "After", color: "#7fdc9a" }, + { after: "c11", label: "Later", level: 2 }, + ]; + const r = renderWith({ markers, pip: { color: "section", sectionColor0: "#b79cff" } }); + const { s, ms, pipped } = lay(r); + assert.deepEqual(ms.map((m) => [m.after, m.level ?? 1, m.color]), [ + ["c2", 1, "#e070d0"], ["c4", 2, "#e070d0"], ["c6", 2, "#5fd1c9"], ["c9", 1, "#7fdc9a"], ["c11", 2, "#7fdc9a"], + ]); + assert.ok(MARKER_SUB_LABEL_SIZE < 18); + assert.ok(markerLabelWidth("Early days", MARKER_SUB_LABEL_SIZE) < markerLabelWidth("Early days")); + // The rail's sections: one per marker (the pips, the fuse bars, the rings + // keep their indices), a subsection's colour its parent's -- even one that + // carries a colour of its own (its flag wears that). + const sec = railSections(ms, pipped.length, resolveDeck(r), PALETTE); + assert.deepEqual(sec.colors, ["#b79cff", "#e070d0", "#e070d0", "#e070d0", "#7fdc9a", "#7fdc9a"]); + // The page: a subsection's flag is `sub` (shorter, quieter); a section's is not. + const html = deckHtml(s, r, {}); + assert.equal((html.match(/class="mflag sub"/g) ?? []).length, 3); + assert.match(html, /\.mflag\.sub \.mlabel \{ font-size: 14px; opacity: 0\.72; \}/); + assert.match(html, /\.mflag\.sub \.mstick \{ top: -8px; height: 14px;/); + // An unlabelled subsection is a half-height tick. + const ticks = deckHtml(s, renderWith({ markers: markers.map(({ label: _l, ...m }) => m), pip: { color: "section" } }), {}); + assert.equal((ticks.match(/class="mflag bare sub"/g) ?? []).length, 3); + assert.match(ticks, /\.mflag\.sub \.mtick \{ top: -3px; height: 6px;/); + // No subsection: none of the sub css. + assert.doesNotMatch(deckHtml(s, renderWith({ markers: many(4) }), {}), /\.mflag\.sub/); +}); + +test("the section title inside a subsection: \"Section › Sub\"; either alone when the other has no words; the opening is the parent of a stray one", () => { + const markers = [ + { after: "c2", label: "Who she is", color: "#e070d0" }, + { after: "c4", label: "Early days", level: 2 }, + { after: "c6", level: 2 }, // unlabelled: still inside "Who she is" + { after: "c9", label: "After", color: "#7fdc9a" }, + ]; + const r = renderWith({ markers, rail: { labels: false }, sectionTitle: { first: "Opening", color: "section" }, pip: { sectionColor0: "#b79cff" } }); + const s = deckSchedule({ entries: ENTRIES, durs: DURS, D: 0.5, render: r, provenance: PROV }); + const tl = sectionTitleTimeline(s, r); + const at = (id) => sectionTitleAt(tl, s.segments.find((x) => x.id === id).start + 5); + assert.equal(at("c1"), "Opening"); + assert.equal(at("c3"), "Who she is"); + assert.equal(at("c5"), "Who she is › Early days"); + assert.equal(at("c7"), "Who she is", "an unlabelled subsection says its section"); + assert.equal(at("c10"), "After"); + // In the section's colour. + const sub = tl.titles.find((t) => t.label === "Who she is › Early days"); + assert.equal(sub.color, "#e070d0"); +}); + +test("the cut's first marker must be a section: a leading subsection is refused by where it stands, not where it is listed", () => { + const manifest = (markers) => ({ timeline: ENTRIES.slice(0, 8), render: renderWith({ markers }) }); + assert.deepEqual(validateDeckMarkers(manifest([{ after: "c1", label: "A" }, { after: "c3", label: "a", level: 2 }])), []); + const lead = validateDeckMarkers(manifest([{ after: "c3", label: "A" }, { after: "c1", label: "a", level: 2 }])); + assert.equal(lead.length, 1); + assert.match(lead[0], /markers\[1\] \(after c1\) is a subsection \(level 2\) with no section before it/); + assert.match(validateDeckMarkers(manifest([{ after: "c1", level: 2 }])).join(" "), /first marker opens a section/); +}); diff --git a/umtool/report-to-video/deck.mjs b/umtool/report-to-video/deck.mjs @@ -36,6 +36,7 @@ import { // The deck's settings and their limits live with the modules' validators // (modules/settings.mjs, a leaf: this file imports it); here under the names // they always had. +export { MARKER_LEVELS } from "./modules/settings.mjs"; export { DECK_DEFAULTS, MARKER_ALIGNS, MARKER_DEFAULT_COLOR, MARKER_LAYOUTS, MARKER_LIMITS, MARKER_PALETTE_KEYS, PIP_COLORS, PIP_PITCH_DEFAULT, PIP_SPACINGS, POST_AT, POST_LAYOUTS, POST_LINKS, POST_PERSIST, QR_LINKS, SUBTITLE_TOKENS, @@ -230,6 +231,21 @@ export function validateDeckMarkers(manifest) { if (!hit) errors.push(`${where} names ${m.after}, which is not in the timeline`); else if (hit.type !== "clip") errors.push(`${where} names ${m.after}, a ${hit.type ?? "entry"}: a marker follows a clip`); }); + // A subsection (`level: 2`) sits inside the section before it, so the + // first boundary of the cut -- by where it stands, not where it is listed + // -- opens a section. One refusal, naming the marker. + const pos = new Map(); + timeline.forEach((e, i) => { if (e?.type === "clip" && !pos.has(e.id)) pos.set(e.id, i); }); + const first = markers + .map((m, i) => ({ m, i, p: isObj(m) && typeof m.after === "string" ? pos.get(m.after.trim()) : undefined })) + .filter((x) => x.p !== undefined) + .sort((a, b) => a.p - b.p || a.i - b.i)[0]; + if (first && first.m.level === 2) { + errors.push( + `render.chrome.deck.markers[${first.i}] (after ${first.m.after}) is a subsection (level 2) with no section before it: ` + + "the cut's first marker opens a section (level 1)", + ); + } return errors; } @@ -702,10 +718,16 @@ export function markerRowsOf(schedule, render) { * and the empty box `[x, x]`: the crowded-label layout ignores it, so it * takes no room from a labelled neighbour. * + * A subsection (`level: 2`) carries `level: 2`; with no `color` of its own + * it wears its section's (the nearest level-1 marker before it). Its label + * is measured at MARKER_SUB_LABEL_SIZE. A label whose box would be narrower + * than MARKER_LABEL_MIN_BOX is laid without words (`hide`, an empty box): + * past a dozen labelled flags the rail keeps the ones it can say. + * * `xs` are the pips' x (pipXs), `pipped` their segments (pipSegments). * * @returns {Array<{ after: string, label: string, color: string, k: number, x: number, box: [number, number], - * align?: string, row?: number }>} + * align?: string, row?: number, level?: 2, hide?: true }>} */ export function deckMarkers(schedule, render, xs, pipped, lay = deckLayout(render)) { const d = resolveDeck(render); @@ -718,6 +740,7 @@ export function deckMarkers(schedule, render, xs, pipped, lay = deckLayout(rende const pipOf = new Map(pipped.map((s, k) => [s.id, k])); const words = d.rail?.labels !== false; const placed = []; + const own = []; for (const m of markers) { const after = String(m?.after ?? "").trim(); const k = pipOf.get(after); @@ -734,33 +757,84 @@ export function deckMarkers(schedule, render, xs, pipped, lay = deckLayout(rende const key = m.color ?? MARKER_DEFAULT_COLOR; const color = HEX_RE.test(key) ? key : pal[key] ?? pal.fg ?? "#ffffff"; const align = MARKER_ALIGNS.includes(m.align) && m.align !== "auto" ? m.align : null; - placed.push({ after, label: words ? String(m.label ?? "").trim() : "", color, k, x: Math.round(x * 100) / 100, ...(align ? { align } : {}) }); + const sub = m?.level === 2; + placed.push({ + after, label: words ? String(m.label ?? "").trim() : "", color, k, x: Math.round(x * 100) / 100, + ...(align ? { align } : {}), ...(sub ? { level: 2 } : {}), + }); + own.push(m.color !== undefined); + } + // A subsection with no colour of its own wears its section's: the nearest + // section marker before it on the rail (in the cut's order). + let parent = null; + for (const j of placed.map((_, j) => j).sort((a, b) => placed[a].k - placed[b].k || placed[a].x - placed[b].x || a - b)) { + if (placed[j].level !== 2) parent = placed[j].color; + else if (!own[j] && parent) placed[j].color = parent; } // The label boxes: each up to halfway to its neighbours, 360 px at most. - // The unlabelled are left out: an empty box at the flag. - const bare = (p) => ({ ...p, box: [Math.round(p.x), Math.round(p.x)] }); - const order = placed.map((p, j) => j).filter((j) => placed[j].label).sort((a, b) => placed[a].x - placed[b].x); - const W = lay.width; + // The unlabelled are left out: an empty box at the flag. A label that does + // not fit a box too narrow to say anything (MARKER_LABEL_MIN_BOX) loses its + // words -- the flag stays, + // `hide` on it -- and the rest are laid again without it, so a crowded + // rail (20, 32 markers) shows the labels it can and a tick for the others, + // never a row of "…". A subsection's label is measured at its own size. + const need = placed.map((p) => markerLabelWidth(p.label, p.level === 2 ? MARKER_SUB_LABEL_SIZE : MARKER_LABEL_SIZE)); + const hidden = new Set(); + let laid = null; + for (let pass = 0; pass < 4; pass += 1) { + laid = layMarkerLabels(placed, need, hidden, lay.width, d.markerLayout); + // Too narrow: a label that does not fit a box under the minimum (one that + // fits, however short, is drawn). + const narrow = laid.map((p, j) => j).filter((j) => { + const w = laid[j].box[1] - laid[j].box[0]; + return laid[j].label && !hidden.has(j) && w < MARKER_LABEL_MIN_BOX && need[j] > w; + }); + if (!narrow.length) break; + for (const j of narrow) hidden.add(j); + } + return laid; +} + +/** A label box narrower than this, px, draws no words (a letter and an ellipsis say nothing). */ +export const MARKER_LABEL_MIN_BOX = 44; + +/** A subsection's (`level: 2`) label: smaller than a section's, and quieter (chrome-deck.mjs). */ +export const MARKER_SUB_LABEL_SIZE = 14; + +/** + * Up to this many labels, every split of them between the two rows is tried; + * past it (13–32 markers), alternate flags and then single moves that lay + * better (the same order of better), until none does. + */ +export const MARKER_SPLIT_SEARCH = 12; + +/** + * deckMarkers' label layout: `placed` with each label's box (and row, when + * staggered). `need` each label's width, `hidden` the ones laid without + * words (drawn as flags with `hide`, their boxes empty). + */ +function layMarkerLabels(placed, need, hidden, W, layout) { + const bare = (p, j) => ({ ...p, box: [Math.round(p.x), Math.round(p.x)], ...(hidden.has(j) ? { hide: true } : {}) }); + const order = placed.map((p, j) => j).filter((j) => placed[j].label && !hidden.has(j)).sort((a, b) => placed[a].x - placed[b].x); const one = labelBoxes(order.map((j) => placed[j]), W); const boxOf = new Map(order.map((j, o) => [j, one[o]])); - const need = placed.map((p) => markerLabelWidth(p.label)); const fits = (j, box) => need[j] <= box[1] - box[0]; - if (d.markerLayout === "truncate" || order.every((j) => fits(j, boxOf.get(j)))) { - return placed.map((p, j) => (p.label ? { ...p, box: boxOf.get(j) } : bare(p))); - } + const oneRow = () => placed.map((p, j) => (boxOf.has(j) ? { ...p, box: boxOf.get(j) } : bare(p, j))); + if (layout === "truncate" || order.every((j) => fits(j, boxOf.get(j)))) return oneRow(); // Two rows: row 1's sticks reach up through row 0. Every split of the flags - // between the rows is tried (there are at most MARKER_LIMITS.count) and the - // one where the most labels fit wins -- then the least cut off the rest, - // then the fewest in row 1, then the first in order: alternating flags, - // when nothing tells two splits apart. Past 12 flags, they alternate. + // between the rows is tried (up to MARKER_SPLIT_SEARCH of them) and the one + // where the most labels fit wins -- then the least cut off the rest, then + // the fewest in row 1, then the first in order: alternating flags, when + // nothing tells two splits apart. Past that many, alternating flags, then + // any one flag moved to the other row while that lays better. const n = order.length; - const lay2 = (mask) => { - const rows = [order.filter((_, o) => !((mask >> o) & 1)), order.filter((_, o) => (mask >> o) & 1)]; - const up = labelBoxes(rows[1].map((j) => placed[j]), W); + const lay2 = (up) => { + const rows = [order.filter((_, o) => !up[o]), order.filter((_, o) => up[o])]; + const hi = labelBoxes(rows[1].map((j) => placed[j]), W); const low = labelBoxes(rows[0].map((j) => placed[j]), W, rows[1].map((j) => placed[j].x)); const at = new Map([ ...rows[0].map((j, o) => [j, { box: low[o], row: 0 }]), - ...rows[1].map((j, o) => [j, { box: up[o], row: 1 }]), + ...rows[1].map((j, o) => [j, { box: hi[o], row: 1 }]), ]); let fit = 0, short = 0; for (const [j, { box }] of at) { @@ -768,21 +842,30 @@ export function deckMarkers(schedule, render, xs, pipped, lay = deckLayout(rende if (over <= 0) fit += 1; else short += over; } - return { at, fit, short, ups: rows[1].length }; + return { at, fit, short, ups: rows[1].length, up }; }; - let alt = 0; - for (let o = 1; o < n; o += 2) alt |= 1 << o; + const better = (c, best) => c.fit > best.fit || (c.fit === best.fit && (c.short < best.short || (c.short === best.short && c.ups < best.ups))); + const alt = Array.from({ length: n }, (_, o) => o % 2 === 1); let best = lay2(alt); - if (n <= MARKER_LIMITS.count) { + if (n <= MARKER_SPLIT_SEARCH) { for (let mask = 0; mask < 1 << n; mask += 1) { - if (mask === alt) continue; - const c = lay2(mask); - if (c.fit > best.fit || (c.fit === best.fit && (c.short < best.short || (c.short === best.short && c.ups < best.ups)))) best = c; + const up = Array.from({ length: n }, (_, o) => ((mask >> o) & 1) === 1); + if (up.every((u, o) => u === alt[o])) continue; + const c = lay2(up); + if (better(c, best)) best = c; + } + } else { + for (let moved = true, rounds = 0; moved && rounds < 4 * n; rounds += 1) { + moved = false; + for (let o = 0; o < n; o += 1) { + const c = lay2(best.up.map((u, q) => (q === o ? !u : u))); + if (better(c, best)) { best = c; moved = true; } + } } } // All in one row is no stagger: the one row as above. - if (best.ups === 0) return placed.map((p, j) => (p.label ? { ...p, box: boxOf.get(j) } : bare(p))); - return placed.map((p, j) => (p.label ? { ...p, ...best.at.get(j) } : bare(p))); + if (best.ups === 0) return oneRow(); + return placed.map((p, j) => (best.at.has(j) ? { ...p, ...best.at.get(j) } : bare(p, j))); } /** @@ -790,9 +873,10 @@ export function deckMarkers(schedule, render, xs, pipped, lay = deckLayout(rende * marker, then one from each marker's boundary to the next. `placed` are * deckMarkers' (each with the pip `k` it follows, its `x`, its resolved * `color`); `n` the pips. Section 0 is `pip.sectionColor0` (a #hex or a - * palette key), else the accent; section i is its marker's colour. - * `pipSection[k]` is pip k's section -- the count of markers after a clip - * before it, so a marker's own pip closes the section before it -- and + * palette key), else the accent; section i is its marker's colour -- a + * subsection's (`level: 2`) the section's it sits in. `pipSection[k]` is + * pip k's section -- the count of markers after a clip before it, so a + * marker's own pip closes the section before it -- and * `bounds[i]` the x where section i+1 starts (non-decreasing). * * @returns {{ colors: string[], bounds: number[], pipSection: number[] }} @@ -803,8 +887,13 @@ export function railSections(placed, n, d, pal = {}) { const ms = [...placed].sort((a, b) => a.k - b.k || a.x - b.x); const bounds = []; for (const m of ms) bounds.push(Math.max(m.x, bounds.at(-1) ?? -Infinity)); + // A subsection (`level: 2`) is a section of its own here (its pips, its + // fuse bar, its ring) but has no colour of its own: it continues its + // parent's, whatever its flag wears. + const colors = [first]; + for (const m of ms) colors.push(m.level === 2 ? colors.at(-1) : m.color); return { - colors: [first, ...ms.map((m) => m.color)], + colors, bounds, pipSection: Array.from({ length: Math.max(0, n) }, (_, k) => ms.filter((m) => m.k < k).length), }; @@ -1587,7 +1676,7 @@ function finaleRailAt(schedule, render, railBottom, textScale) { const toBig = (x) => r2(x0 + ((x - lay.pipTrack.x0) * (rail.x1 - x0)) / (span || 1)); const footMarks = deckMarkers(schedule, render, fxs, pipped, lay); const marks = railMarkerLayout(footMarks.map((mk) => ({ x: toBig(mk.x), label: mk.label, color: mk.color })), base, { layout: deck.markerLayout }) - .map((mk, j) => ({ ...mk, foot: { x: r2(footMarks[j].x) } })); + .map((mk, j) => ({ ...mk, foot: { x: r2(footMarks[j].x) }, ...(footMarks[j].level === 2 ? { level: 2 } : {}) })); // The claim checks: in turn or all at once, packed in the rows over the markers'. const fcl = claimsLayout(schedule, render, fxs, pipped, lay); const slots = fcl ? finaleClaimSlots(fin, fcl.items.length, f.claims) : null; diff --git a/umtool/report-to-video/finale-room.test.mjs b/umtool/report-to-video/finale-room.test.mjs @@ -262,3 +262,16 @@ test("placeAbove: a label slides along its row, or rises with its stick kept in assert.equal(aboveLine(), 30); assert.ok(textWidth("x", 24) > 0); }); + +test("a subsection on the large rail: its flag `sub` (a thinner stick, quieter words); a cut without one draws none of it", () => { + const r = renderWith({ markers: [MARKERS[0], { ...MARKERS[1], level: 2 }] }); + const s = built(r); + const L = finaleLayout(s, r); + assert.deepEqual(L.marks.map((mk) => mk.level ?? 1), [1, 2]); + const win = snapWindow({ segment: "finale", from: s.finale.from, to: s.finale.to }, { fps: 30, total: s.total }); + const html = finaleHtml(s, r, win, {}); + assert.equal((html.match(/class="mf sub"/g) ?? []).length, 1); + assert.match(html, /\.mf\.sub \.ml \{ opacity: 0\.72; \}/); + const plain = finaleHtml(built(renderWith()), renderWith(), win, {}); + assert.doesNotMatch(plain, /\.mf\.sub|class="mf sub"/); +}); diff --git a/umtool/report-to-video/marker-limits.mjs b/umtool/report-to-video/marker-limits.mjs @@ -0,0 +1,22 @@ +// THE DECK'S MARKERS, their limits -- the one copy (a leaf: it imports +// nothing, so the build's validators, umtool's writers and the Markers editor +// in the browser all read the same numbers). modules/settings.mjs re-exports +// them under the names deck.mjs always had. + +/** + * A marker's limits: how many a deck may carry (`count`), and a label's + * characters (`label`, one line). 32 since the cut "in her own words" reached + * the old 12 (2026-11-01). + */ +export const MARKER_LIMITS = Object.freeze({ count: 32, label: 24 }); + +/** + * A marker's `level`: 1 opens a SECTION (absent is 1), 2 a SUBSECTION inside + * the section before it -- on the rail a shorter tick in its parent's colour + * and a quieter label, and in the section title "Section › Sub". A level-2 + * marker needs a level-1 marker before it in the cut (validateDeckMarkers). + */ +export const MARKER_LEVELS = Object.freeze([1, 2]); + +/** Between a section's name and its subsection's, wherever both are said. */ +export const SUBSECTION_SEPARATOR = " › "; diff --git a/umtool/report-to-video/modules/rail.mjs b/umtool/report-to-video/modules/rail.mjs @@ -20,7 +20,8 @@ // and the marker's ring take their section's colour, fitted to 3:1 on the // deck's ground. A marker may have no label: a tick at its boundary, no // words, and no band over the track for it; `rail.labels: false` drops every -// marker's words. +// marker's words. A marker with `level: 2` is a SUBSECTION: a shorter flag in +// its section's colour, a quieter label, no section colour of its own. import { DECK_DEFAULTS, MARKER_ALIGNS, MARKER_LAYOUTS, PIP_COLORS, PIP_PITCH, PIP_PITCH_DEFAULT, PIP_SPACINGS, settingsOf } from "./settings.mjs"; import { defineModule } from "./contract.mjs"; @@ -70,6 +71,7 @@ export default defineModule({ ["`deck.pip.color`", "`accent` · `verdict` (a counted clip's pip takes its series' colour and shape) · `section` (every pip, the fuse and the marker's ring in the colour of the section it stands in: from one marker to the next, in that marker's `color`; fitted to 3:1 on the deck) · default `accent`", "`umtool look <p> deck.pip='{\"color\":\"verdict\"}'`"], ["`deck.pip.sectionColor0`", "the section before the first marker, with `color: \"section\"`: a `#hex` or a palette key (`fg`, `muted`, `accent`, `amber`, `dim`) · default the accent", "`umtool look <p> deck.pip='{\"color\":\"section\",\"sectionColor0\":\"#5fa8d3\"}'`"], ["`deck.markers[].label`", "optional: a marker with none (or `\"\"`) draws a tick at its boundary, no words, and takes no band over the track", "`umtool look <p> deck.markers='[{\"after\":\"c04\",\"color\":\"#e07a9a\"}]'`"], + ["`deck.markers[].level`", "`1` (a section, the default) · `2` (a subsection of the section before it: a shorter flag or a half-height tick, its label smaller and quieter, and in sections no colour of its own -- its pips, fuse and ring keep its section's; to every edit a section like any other; the cut's first marker must be a section) · at most 32 markers in all; past a dozen labelled, a label too crowded to say anything is drawn as a tick", "`umtool look <p> deck.markers='[{\"after\":\"c04\",\"label\":\"Early days\",\"level\":2}]'`"], ["`deck.rail.labels`", "`false` draws every marker as a tick, no words, and no band over the track (the current section's name can stand under the rail instead: [Section title](#section-title)) · default `true`","`umtool look <p> deck.rail='{\"labels\":false}'`"], ], }, diff --git a/umtool/report-to-video/modules/section-title.mjs b/umtool/report-to-video/modules/section-title.mjs @@ -49,7 +49,7 @@ export default defineModule({ ], docs: { heading: "Section title", - intro: "The current section's name on one quiet line centred under the rail (`render.chrome.deck.sectionTitle`): the label of the marker that opened the section ([Rail](#rail)), `first` before any marker; a marker with no label shows nothing for its section. It crossfades as the rail's marker crosses into the next section, rides the deck away over a card, and is independent of `deck.rail.labels` -- the track can carry no words while this says where the cut is. Off unless set: absent or `false` draws the deck as it always was. The clip's title moves down only by what the line needs.", + intro: "The current section's name on one quiet line centred under the rail (`render.chrome.deck.sectionTitle`): the label of the marker that opened the section ([Rail](#rail)), `first` before any marker; a marker with no label shows nothing for its section. Inside a subsection (a marker with `level: 2`) it says both, \"Section › Sub\" (the section's name alone when the subsection has no label). It crossfades as the rail's marker crosses into the next section, rides the deck away over a card, and is independent of `deck.rail.labels` -- the track can carry no words while this says where the cut is. Off unless set: absent or `false` draws the deck as it always was. The clip's title moves down only by what the line needs.", rows: [ ["`deck.sectionTitle`", "`true` (on, every default) · `false` · an object of the keys below · default off", "`umtool look <p> deck.sectionTitle=true`"], ["`deck.sectionTitle.first`", `the section before the first marker: a line of at most ${L.first} characters · default \`""\` (nothing)`, "`umtool look <p> deck.sectionTitle='{\"first\":\"Who she is\"}'`"], diff --git a/umtool/report-to-video/modules/settings.mjs b/umtool/report-to-video/modules/settings.mjs @@ -17,6 +17,7 @@ import { validateFlips } from "../flips.mjs"; import { validateStats } from "../stats.mjs"; import { validateFx } from "../fx.mjs"; import { validateChapter, validatePair, validateStatus } from "./story-settings.mjs"; +import { MARKER_LEVELS, MARKER_LIMITS } from "../marker-limits.mjs"; /** * Every deck setting and its default. A manifest names only what it changes; @@ -90,8 +91,9 @@ export const DECK_DEFAULTS = Object.freeze({ */ export const PIP_COLORS = Object.freeze(["accent", "verdict", "section"]); -/** A marker's limits: how many, and a label's characters. */ -export const MARKER_LIMITS = Object.freeze({ count: 12, label: 24 }); +// A marker's limits (how many, a label's characters) and levels: the one +// copy is marker-limits.mjs, a leaf the browser imports too. +export { MARKER_LEVELS, MARKER_LIMITS }; /** * Where a marker's label sits against its flag: "auto" (centred when it has @@ -205,8 +207,11 @@ export function markerShapeErrors(markers, where) { const at = `${where}[${i}]`; if (!isObj(m)) { errors.push(`${at} must be { after, label?, color? }`); return; } for (const k of Object.keys(m)) { - if (!["after", "label", "color", "align"].includes(k)) errors.push(`${at}.${k} is not a marker setting (after, label, color, align)`); + if (!["after", "label", "color", "align", "level"].includes(k)) errors.push(`${at}.${k} is not a marker setting (after, label, color, align, level)`); } + // `level`: 1 a section (absent is 1), 2 a subsection of the section + // before it (validateDeckMarkers refuses one with no section before it). + if (m.level !== undefined && !MARKER_LEVELS.includes(m.level)) errors.push(`${at}.level must be 1 (a section) or 2 (a subsection)`); if (m.align !== undefined && !MARKER_ALIGNS.includes(m.align)) { errors.push(`${at}.align must be ${MARKER_ALIGNS.map((a) => `"${a}"`).join(", ")}`); } diff --git a/umtool/report-to-video/package.json b/umtool/report-to-video/package.json @@ -48,6 +48,7 @@ "./local-media": "./local-media.mjs", "./join-preview": "./join-preview.mjs", "./look": "./look.mjs", + "./marker-limits": "./marker-limits.mjs", "./modules": "./modules/index.mjs", "./modules/*": "./modules/*.mjs", "./mute": "./mute.mjs",