commit 9f1bb6795ef5bf6dba9d2681ac4e087abee89ebb
parent 9472acd3cd2a835d7a5a760fc32e6788cc5c8ab7
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Mon, 9 Nov 2026 14:10:37 -0500
umtool: the intro's words and title card, its preview page, and `umtool intro`
render.intro gains `title` and `lines` (one line each, the title <= 80, <= 3 lines)
and a `title-card` style: the project's title and its date over the brand, the
lockup small under them (boot-mark's motion, the mark on the chime). Unwritten, a
boot style's page is byte for byte what it was (the cached intros still hit);
title-card's words default to the manifest's title and generatedOn.
The page is now one call (intro.mjs introPageHtml) for the build and the previews:
writeIntroPage puts it beside GSAP (and the words' face), composeIntroPreview adds
Play's seek, and POST /api/report/chrome/intro composes the cut's intro (or the
intro editor's unsaved one) under out/<variant>/chrome/intro-preview/. GET serves
its state and its sound; PUT switches a version's intro off (render.intro: null in
its patch, through editTakeManifest).
`umtool intro <p> [key=value …] [--off] | --take <t> --off|--on` is the twin
(lib/report/introEdit.mjs, introCli.mjs).
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
18 files changed, 1119 insertions(+), 38 deletions(-)
diff --git a/common/lib/report/intro.d.mts b/common/lib/report/intro.d.mts
@@ -15,9 +15,17 @@ export type Intro = {
site?: IntroSite; swap?: IntroSwap; url?: IntroUrlMode; urlPlace?: IntroUrlPlace;
/** The brand (release 39): the kit it draws, the suffix a site's name keeps, the project URL the swap writes. */
brand?: string; suffix?: string; projectUrl?: string | false;
+ /** The words: title-card's title and lines (or under a boot style's wordmark), only when written. */
+ title?: string; lines?: string[];
};
export const INTRO_STYLES: readonly string[];
+export const INTRO_STYLE_DEFAULT: string;
+export const INTRO_KEYS: readonly string[];
+export const INTRO_TITLE_MAX: number;
+export const INTRO_LINES_MAX: number;
+export const INTRO_LINE_MAX: number;
+export function introWordsErrors(o: Record<string, unknown>): string[];
export const INTRO_GROUNDS: readonly IntroGround[];
export const INTRO_STYLE_GROUND: Readonly<Record<string, IntroGround>>;
export const INTRO_MARKS: readonly IntroMark[];
diff --git a/common/lib/report/intro.mjs b/common/lib/report/intro.mjs
@@ -15,6 +15,15 @@
// "sound": "intro.wav", "seconds": 4.5 } } or its knobs
// "render": { "intro": { "style": "boot-dark", "mark": "chime", "site": "auto",
// "swap": "swipe-down", "url": "both", "urlPlace": "under" } }
+// "render": { "intro": { "style": "title-card", "title": "In her own words",
+// "lines": ["29 October 2026"] } }
+//
+// `title-card` is the project's title and its date over the brand (the
+// lockup small under them, MEDIA on the chime): `title` defaults to the
+// manifest's title and `lines` to its date (report-to-video intro.mjs
+// introEntry). On the boot styles `title` and `lines`, when written, come in
+// under the wordmark on the chime; unwritten, the page is byte for byte the
+// one it was.
//
// `site` turns the Archilyzer intro into a site's: on the chime the wordmark's
// "Archi" becomes the site's own lead ("Jera" of Jeralyzer), "lyzer" stays, and
@@ -28,7 +37,10 @@
const isObj = (v) => !!v && typeof v === "object" && !Array.isArray(v);
/** The styles, in the order the docs and the variant renders list them. */
-export const INTRO_STYLES = Object.freeze(["boot", "boot-wipe", "boot-dark", "boot-cascade", "boot-mark"]);
+export const INTRO_STYLES = Object.freeze(["boot", "boot-wipe", "boot-dark", "boot-cascade", "boot-mark", "title-card"]);
+
+/** The brand sting: the style an intro is given when one is first written (the Cut tab's editor, `umtool intro`). */
+export const INTRO_STYLE_DEFAULT = "boot-dark";
/** The grounds a style is drawn on. Each style has its own default (INTRO_STYLE_GROUND). */
export const INTRO_GROUNDS = Object.freeze(["light", "dark"]);
@@ -40,6 +52,7 @@ export const INTRO_STYLE_GROUND = Object.freeze({
"boot-dark": "dark",
"boot-cascade": "light",
"boot-mark": "dark",
+ "title-card": "dark",
});
/**
@@ -58,6 +71,7 @@ export const INTRO_STYLE_MARK = Object.freeze({
"boot-dark": "none",
"boot-cascade": "none",
"boot-mark": "draw",
+ "title-card": "chime",
});
/**
@@ -119,6 +133,12 @@ export const INTRO_BRAND_DEFAULT = "archilyzer-media";
/** The project's URL as the swap writes it, unless `render.intro.projectUrl` sets another (or false: none). */
export const INTRO_PROJECT_URL = "archilyzer.pages.dev";
+/** `title`'s longest, in characters: one line on the card (it shrinks to fit the frame's width). */
+export const INTRO_TITLE_MAX = 80;
+/** `lines`: at most this many, each at most INTRO_LINE_MAX characters. */
+export const INTRO_LINES_MAX = 3;
+export const INTRO_LINE_MAX = 80;
+
/** The intro's timeline id (its segment is segments/<id>.mp4). */
export const INTRO_ID = "brand-intro";
@@ -146,6 +166,9 @@ export function introOf(render) {
...(typeof o.brand === "string" && o.brand ? { brand: o.brand } : {}),
...(typeof o.suffix === "string" && o.suffix ? { suffix: o.suffix } : {}),
...(o.projectUrl === false || (typeof o.projectUrl === "string" && o.projectUrl) ? { projectUrl: o.projectUrl } : {}),
+ // The words (title-card's, or under a boot style's wordmark): only when written.
+ ...(typeof o.title === "string" && o.title.trim() ? { title: o.title.trim() } : {}),
+ ...(Array.isArray(o.lines) ? { lines: o.lines.filter((l) => typeof l === "string" && l.trim()).map((l) => l.trim()) } : {}),
// The site's knobs only when there is a site: an intro without one reads
// exactly as it did before the key existed.
...(site
@@ -208,13 +231,37 @@ export function introSiteErrors(site) {
return errors;
}
-const KEYS = ["style", "ground", "mark", "sound", "seconds", "site", "swap", "url", "urlPlace", "brand", "suffix", "projectUrl"];
+const KEYS = ["style", "ground", "mark", "sound", "seconds", "site", "swap", "url", "urlPlace", "brand", "suffix", "projectUrl", "title", "lines"];
+
+/** The keys `render.intro`'s object form may hold, in the order the docs list them. */
+export const INTRO_KEYS = Object.freeze([...KEYS]);
+
+/** A line of words the card draws: a string of 1 to `max` characters on one line. */
+const oneLine = (v, max) => typeof v === "string" && !!v.trim() && v.trim().length <= max && !/[\r\n]/.test(v);
+
+/** Every reason `title` / `lines` (of a `render.intro`) cannot be drawn. */
+export function introWordsErrors(o) {
+ const errors = [];
+ if (o.title !== undefined && !oneLine(o.title, INTRO_TITLE_MAX)) {
+ errors.push(`render.intro.title must be one line of 1 to ${INTRO_TITLE_MAX} characters`);
+ }
+ if (o.lines !== undefined) {
+ if (!Array.isArray(o.lines) || o.lines.length > INTRO_LINES_MAX) {
+ errors.push(`render.intro.lines must be a list of at most ${INTRO_LINES_MAX} lines`);
+ } else {
+ o.lines.forEach((l, i) => {
+ if (!oneLine(l, INTRO_LINE_MAX)) errors.push(`render.intro.lines[${i}] must be one line of 1 to ${INTRO_LINE_MAX} characters`);
+ });
+ }
+ }
+ return errors;
+}
/** Every reason `value` (a `render.intro`) cannot be built, as sentences naming the key. */
export function introErrors(value) {
if (value === undefined || value === null) return [];
const o = typeof value === "string" ? { style: value } : value;
- if (!isObj(o)) return [`render.intro must be a style name (${INTRO_STYLES.join(", ")}) or an object {style, ground?, mark?, sound?, seconds?, site?, swap?, url?, urlPlace?}`];
+ if (!isObj(o)) return [`render.intro must be a style name (${INTRO_STYLES.join(", ")}) or an object {style, ground?, mark?, sound?, seconds?, site?, swap?, url?, urlPlace?, title?, lines?}`];
const errors = [];
for (const k of Object.keys(o)) if (!KEYS.includes(k)) errors.push(`render.intro.${k} is not a key (${KEYS.join(", ")})`);
if (!INTRO_STYLES.includes(o.style)) {
@@ -253,6 +300,7 @@ export function introErrors(value) {
if (o.projectUrl !== undefined && o.projectUrl !== false && !(typeof o.projectUrl === "string" && introUrlText(o.projectUrl))) {
errors.push(`render.intro.projectUrl must be the project's URL (e.g. "${INTRO_PROJECT_URL}") or false (none)`);
}
+ errors.push(...introWordsErrors(o));
return errors;
}
diff --git a/umtool/app/api/report/chrome/intro/route.ts b/umtool/app/api/report/chrome/intro/route.ts
@@ -0,0 +1,174 @@
+import path from "node:path";
+import { realpath, stat } from "node:fs/promises";
+import { composeIntroPreview } from "@/lib/report/onscreen.mjs";
+import { introPreviewSrc, rangeResponse, resolveReport } from "@/lib/report/serve.mjs";
+import { selectVariant } from "umtool-report-to-video/build-video";
+import { INTRO_STANDIN_SOUND, introEntry, isIntro } from "umtool-report-to-video/intro";
+import { validateIntroSettings } from "umtool-report-to-video/modules/intro";
+import { cachedTakeManifest, takePlayDir, writePlayManifest } from "@/lib/report/takeManifest.mjs";
+import { isTakeId } from "@/lib/report/takes.mjs";
+import { introState, setVersionIntro } from "@/lib/report/introEdit.mjs";
+import { StaleToken } from "@/lib/report/manifest.mjs";
+import { refuseCaller } from "@/lib/report/caller";
+import {
+ INTRO_GROUNDS, INTRO_LINE_MAX, INTRO_LINES_MAX, INTRO_MARKS, INTRO_SECONDS, INTRO_SECONDS_MAX, INTRO_SECONDS_MIN, INTRO_STYLE_DEFAULT,
+ INTRO_STYLES, INTRO_TITLE_MAX,
+} from "yt-dlp-transcript-common/lib/report/intro.mjs";
+
+export const dynamic = "force-dynamic";
+
+// THE INTRO, PLAYABLE (`render.intro`; operator, 8 Nov 2026: "more first-class intro support (view in
+// play the cut)"): the cut's brand intro composed as the build draws it -- report-to-video intro.mjs's
+// own page (writeIntroPage), Play's seek appended (onscreen.mjs composeIntroPreview) -- so Play,
+// Present and the Cut tab's intro editor show the real intro instead of a placeholder. No render.
+//
+// POST { project, take?, intro? } -> { intro: { id, style, seconds, width, height, src, sound } | null }
+// the cut's intro (or a take's), as selectVariant opens the cut with it; with `intro` (the editor's
+// unsaved value, `null` for none) that value instead, composed as the editor's draft page. A value the
+// build would refuse is a 400 { errors }.
+// GET ?project=<p> -> introState: the intro as written, its entry, each version's
+// GET ?project=<p>&sound=1[&path=<file>] -> the intro's sound (the stand-in, or a file of the project)
+// PUT { project, take, on, token? } -> a VERSION with (on) or without the cut's intro: its patch's
+// `render.intro: null` (introEdit.mjs setVersionIntro)
+// The project's own intro is written by the look writer, PUT /api/report/render { patch: { intro } }.
+
+const noStore = { "cache-control": "no-store" };
+
+const inside = (base: string, p: string) => {
+ const rel = path.relative(base, p);
+ return !!rel && !rel.startsWith("..") && !path.isAbsolute(rel);
+};
+
+/** The sound a page plays with the intro: the stand-in (the sound absent), a project file, or none. */
+function soundSrc(projectId: string, sound: unknown): string | null {
+ if (sound === false) return null;
+ const q = new URLSearchParams({ project: projectId, sound: "1" });
+ if (typeof sound === "string" && sound) q.set("path", sound);
+ return `/api/report/chrome/intro?${q.toString()}`;
+}
+
+export async function GET(request: Request) {
+ const url = new URL(request.url);
+ const r = await resolveReport(url.searchParams.get("project") ?? "");
+ if ("error" in r) return Response.json({ error: r.error }, { status: r.status });
+ if (url.searchParams.get("sound") === "1") {
+ const rel = url.searchParams.get("path");
+ let abs: string | null = null;
+ if (!rel) abs = INTRO_STANDIN_SOUND;
+ else {
+ // A project's own sound file only (render.intro.sound is relative to the manifest).
+ const base = await realpath(r.project.dir).catch(() => null);
+ const real = await realpath(path.resolve(r.project.dir, rel)).catch(() => null);
+ if (base && real && inside(base, real)) abs = real;
+ }
+ const st = abs ? await stat(abs).catch(() => null) : null;
+ if (!abs || !st?.isFile()) return new Response("no intro sound here", { status: 404 });
+ const type = /\.mp3$/i.test(abs) ? "audio/mpeg" : /\.(m4a|aac)$/i.test(abs) ? "audio/mp4" : /\.(ogg|opus)$/i.test(abs) ? "audio/ogg" : "audio/wav";
+ return rangeResponse(request, { abs, size: st.size, headers: { "content-type": type, "accept-ranges": "bytes", "cache-control": "no-store" } });
+ }
+ try {
+ const state = await introState(r.project);
+ return Response.json(
+ {
+ ...state,
+ choices: {
+ styles: INTRO_STYLES, styleDefault: INTRO_STYLE_DEFAULT, marks: INTRO_MARKS, grounds: INTRO_GROUNDS,
+ seconds: { min: INTRO_SECONDS_MIN, max: INTRO_SECONDS_MAX, default: INTRO_SECONDS },
+ titleMax: INTRO_TITLE_MAX, linesMax: INTRO_LINES_MAX, lineMax: INTRO_LINE_MAX,
+ },
+ },
+ { headers: noStore },
+ );
+ } catch (e) {
+ return Response.json({ error: e instanceof Error ? e.message : String(e) }, { status: 400 });
+ }
+}
+
+export async function POST(request: Request) {
+ let body: Record<string, unknown>;
+ try {
+ body = await request.json();
+ } catch {
+ return Response.json({ error: "expected JSON" }, { status: 400 });
+ }
+ const r = await resolveReport(String(body.project ?? ""), body.variant ? String(body.variant) : null);
+ if ("error" in r) return Response.json({ error: r.error }, { status: r.status });
+ const take = body.take === undefined || body.take === null || body.take === "" ? null : String(body.take);
+ if (take !== null && !isTakeId(take)) return Response.json({ error: "take is a take id" }, { status: 400 });
+ const draft = "intro" in body;
+ let manifest = r.manifest as Record<string, unknown>;
+ let target: { dir: string } = r.project;
+ if (take && !draft) {
+ try {
+ manifest = (await cachedTakeManifest(r.project.dir, take)).manifest;
+ target = { dir: takePlayDir(r.project.dir, take) };
+ await writePlayManifest(r.project.dir, take, manifest);
+ } catch (e) {
+ return Response.json({ error: e instanceof Error ? e.message : String(e) }, { status: 404 });
+ }
+ }
+ const selected = selectVariant(manifest, r.variant) as Record<string, unknown> & { timeline?: Record<string, unknown>[]; render?: Record<string, unknown> };
+ const render = (selected.render ?? {}) as Record<string, unknown>;
+ let entry: Record<string, unknown> | null;
+ if (draft) {
+ // The editor's unsaved intro: checked as the writer will check it, then made into the entry the cut would open with.
+ const value = body.intro ?? null;
+ const errors = validateIntroSettings(value);
+ if (errors.length) return Response.json({ error: errors.join("; "), errors }, { status: 400 });
+ try {
+ entry = value === null ? null : (introEntry({ ...render, intro: value }, { provenance: (manifest.provenance ?? null) as never, manifest }) as Record<string, unknown> | null);
+ } catch (e) {
+ return Response.json({ error: e instanceof Error ? e.message : String(e) }, { status: 400 });
+ }
+ } else {
+ entry = (selected.timeline ?? []).find(isIntro) ?? null;
+ }
+ if (!entry) return Response.json({ intro: null }, { headers: noStore });
+ const width = typeof render.width === "number" ? render.width : 1920;
+ const height = typeof render.height === "number" ? render.height : 1080;
+ try {
+ const c = await composeIntroPreview(target, r.variant, entry, render, { draft });
+ return Response.json(
+ {
+ intro: {
+ id: String(entry.id),
+ style: String(entry.style),
+ seconds: Number(entry.seconds),
+ width,
+ height,
+ src: `${introPreviewSrc(r.project.id, r.variant, draft ? null : take, c.file)}?v=${Date.now()}`,
+ sound: soundSrc(r.project.id, entry.sound),
+ ...(typeof entry.title === "string" ? { title: entry.title } : {}),
+ ...(Array.isArray(entry.lines) ? { lines: entry.lines } : {}),
+ },
+ },
+ { headers: noStore },
+ );
+ } catch (e) {
+ return Response.json({ error: e instanceof Error ? e.message : String(e) }, { status: 500 });
+ }
+}
+
+export async function PUT(request: Request) {
+ const refused = refuseCaller(request, "/api/report/chrome/intro");
+ if (refused) return refused;
+ let body: Record<string, unknown>;
+ try {
+ body = await request.json();
+ } catch {
+ return Response.json({ error: "expected JSON" }, { status: 400 });
+ }
+ const r = await resolveReport(String(body.project ?? ""));
+ if ("error" in r) return Response.json({ error: r.error }, { status: r.status });
+ const take = String(body.take ?? "");
+ if (!isTakeId(take)) return Response.json({ error: "take is a take id" }, { status: 400 });
+ if (typeof body.on !== "boolean") return Response.json({ error: "on is true (the cut's intro) or false (none)" }, { status: 400 });
+ try {
+ // A take's patch is not a generated manifest: no edit notes (takeScope.mjs's rule).
+ const result = await setVersionIntro(r.project.dir, take, body.on as boolean, { token: body.token === undefined || body.token === null ? null : String(body.token) });
+ return Response.json({ ok: true, take, intro: body.on ? "cut" : "off", unchanged: result.unchanged, token: result.token }, { headers: noStore });
+ } catch (e) {
+ if (e instanceof StaleToken) return Response.json({ error: e.message, stale: true }, { status: 409 });
+ return Response.json({ error: e instanceof Error ? e.message : String(e) }, { status: 400 });
+ }
+}
diff --git a/umtool/bin/umtool.mjs b/umtool/bin/umtool.mjs
@@ -37,6 +37,8 @@
// umtool set <project> <clip> key=value … a clip's knobs: claim.at|hold|stamp|count|label,
// marks=<json> mark.add=<verdict>[@<sec>] mark.remove=<id> mark.verdict=<v> [--mark <id>],
// audio.offset|gain|fadeIn|fadeOut (`key=` clears) (docs/knobs.md)
+// umtool intro <project> [key=value …] [--off] | --take <t> --off|--on [--json] the intro the cut opens on
+// (render.intro: style seconds mark sound site title lines …); --take: a version without it
// umtool look <project> key=value … the cut's knobs: factcheck.stamp.*, factcheck.verdicts.<V>.*,
// deck.markers=<json>, deck.markerLayout, variants=<json>, the look's keys
// umtool variants <project> [--take <t>] [--list] [--json] make the encode ladder; the sync report
@@ -931,6 +933,10 @@ function usage() {
" · hideModules=diet,streak (those modules hidden over the entry's span; any entry)",
" · shelfNote='words' (a line on the shelf over the entry's span; any entry)",
" --take <t>: the entry knobs into the take's patch, the project's manifest untouched",
+ " umtool intro <project> [key=value …] [--off] [--json] THE INTRO the cut opens on (render.intro): prints it,",
+ " what the cut opens with and each version's on/off; key=value writes it (style seconds mark sound",
+ " site title lines …; `key=` clears; a new one starts as boot-dark); --off takes it off;",
+ " --take <t> --off|--on: that version opens on no intro (its patch's render.intro: null) or the cut's",
" umtool look <project> key=value … the cut's knobs: factcheck.stamp.scale|motion|opacity|seconds,",
" factcheck.verdicts.<V>.stampLabel|label|color, deck.markers=<json>, deck.markerLayout,",
" variants=<json>, and the look's keys (transition=0.3, …)",
@@ -1151,6 +1157,7 @@ const COMMANDS = {
// The clip bench's walk, of the cut or of a take (walk a take): lib/report/walkCli.mjs.
walk: async () => process.exit(await (await import("../lib/report/walkCli.mjs")).walkCommand(argv.slice(argv.indexOf("walk") + 1))),
// Present mode: the cut as slides (lib/report/presentCli.mjs).
+ intro: async () => process.exit(await (await import("../lib/report/introCli.mjs")).introCommand(argv.slice(argv.indexOf("intro") + 1))),
present: async () => process.exit(await (await import("../lib/report/presentCli.mjs")).presentCommand(argv.slice(argv.indexOf("present") + 1))),
link: cmdLink,
// The video knobs (plans/video-knobs-ui.md): lib/report/knobsCli.mjs.
diff --git a/umtool/docs/knobs.md b/umtool/docs/knobs.md
@@ -1785,13 +1785,15 @@ A timeline entry `{ type: "teaser", lines, … }`: a full-frame card whose lines
### Intro
-The brand sting (`render.intro`); the style, mark and site knobs are in [The cut](#the-cut). The brand it draws is configurable; unset, it is the Archilyzer intro, byte for byte.
+The brand sting (`render.intro`); the style, mark and site knobs are in [The cut](#the-cut), the words and the editor in [The intro](#the-intro-played-and-edited). The brand it draws is configurable; unset, it is the Archilyzer intro, byte for byte.
| Knob | Range · default | From a terminal |
|---|---|---|
| `render.intro.brand` | a brand kit id (archilyzer-media) · default `archilyzer-media` | `umtool look <p> intro='{"style":"boot","brand":"archilyzer-media"}'` |
| `render.intro.suffix` | the letters a site's name keeps of the brand's, 1–16 · default `lyzer` (Jeralyzer swaps "Archi" for "Jera") | a take: `--set render.intro.suffix=lyzer` |
| `render.intro.projectUrl` | the project URL the swap writes beside the site's · `false` none · default `archilyzer.pages.dev` | a take: `--set render.intro.projectUrl=false` |
+| `render.intro.title` | one line, 1–80 · `title-card`: default the project's title; a boot style: drawn under the wordmark only when written | `umtool intro <p> title='In her own words'` (`title=` clears) |
+| `render.intro.lines` | ≤ 3 lines of 1–80 · `title-card`: default the project's date in words (`generatedOn`) | `umtool intro <p> lines='29 October 2026|Part one'` |
### Blur
diff --git a/umtool/lib/report/introCli.mjs b/umtool/lib/report/introCli.mjs
@@ -0,0 +1,118 @@
+// `umtool intro <project> [key=value …] [--off] [--take <t> --off|--on] [--json]`: THE INTRO from a terminal
+// (umtool/docs/knobs.md, "The intro"), the twin of the Cut tab's intro editor -- the same reading (introEdit.mjs
+// introState) and the same writers: the project's render.intro through the look writer, a version's "no intro"
+// through the take's own (its patch's `render.intro: null`).
+//
+// Plain ESM: the CLI runs under bare node.
+import { REPORTS_ROOT, resolveProject } from "../projects/core.mjs";
+import { INTRO_KEYS, INTRO_STYLES } from "yt-dlp-transcript-common/lib/report/intro.mjs";
+import { introPatch, introState, setVersionIntro, writeIntro } from "./introEdit.mjs";
+import { withEditNotes } from "./edit-guard.mjs";
+
+export const INTRO_USAGE = [
+ "usage: umtool intro <project> [key=value …] [--off] [--json]",
+ " umtool intro <project> --take <t> --off|--on [--json]",
+ "",
+ "THE INTRO the cut opens on (render.intro): with no key, prints it -- as written, what the cut opens with (its",
+ "title-card words resolved) and each version's on/off. key=value writes it (a new intro starts as the brand",
+ "sting, boot-dark); `key=` clears a key; --off takes the intro off the cut. Keys:",
+ ` ${INTRO_KEYS.join(" ")}`,
+ ` style: ${INTRO_STYLES.join(" ")} · seconds 3.5–8 · mark none|draw|chime · sound=<file>|false`,
+ " title=<one line, ≤ 80> · lines='29 October 2026|Part one' (≤ 3, or a JSON list) · site=auto|<id>|none",
+ "--take <t> --off: that version opens on no intro (its patch's render.intro: null; the cut's untouched);",
+ "--on: it opens on the cut's intro again. Play, Present and the Cut tab show the intro as the build draws it.",
+].join("\n");
+
+class CliError extends Error {}
+
+/** One line per thing the intro is: what the CLI prints. */
+function describe(state) {
+ const lines = [];
+ const w = state.intro;
+ if (w === null || w === undefined) lines.push("intro: none (the cut opens on its first entry)");
+ else lines.push(`intro: ${JSON.stringify(w)}`);
+ for (const e of state.errors) lines.push(` REFUSED: ${e}`);
+ if (state.entryError) lines.push(` does not resolve: ${state.entryError}`);
+ const e = state.entry;
+ if (e) {
+ const site = e.site ? ` · site ${e.site.name}` : "";
+ const words = [e.title ? `"${e.title}"` : null, ...(e.lines ?? []).map((l) => `"${l}"`)].filter(Boolean).join(" / ");
+ lines.push(` opens with: ${e.style} (${e.ground}, mark ${e.mark}) ${e.seconds} s${site}${words ? ` · ${words}` : ""}${e.sound === false ? " · silent" : ""}`);
+ }
+ if (state.versions.length) {
+ lines.push("versions:");
+ for (const v of state.versions) lines.push(` ${v.id.padEnd(16)} ${v.intro === "off" ? "no intro" : v.intro === "own" ? "its own intro" : "the cut's intro"}${v.draft ? " (draft)" : ""}`);
+ }
+ return lines;
+}
+
+/**
+ * @param {string[]} args the words after `intro`
+ * @param {{ root?: string, out?: (s: string) => void, err?: (s: string) => void }} [opts]
+ * @returns {Promise<number>}
+ */
+export async function introCommand(args, { root = REPORTS_ROOT, out = (s) => console.log(s), err = (s) => console.error(s) } = {}) {
+ try {
+ const words = [];
+ const flags = new Map();
+ for (let i = 0; i < args.length; i += 1) {
+ const a = args[i];
+ if (a === "--take") {
+ if (i + 1 >= args.length) throw new CliError("--take needs a take id");
+ flags.set(a, args[++i]);
+ } else if (a.startsWith("--")) flags.set(a, true);
+ else words.push(a);
+ }
+ if (!words[0] || flags.has("--help")) {
+ (flags.has("--help") ? out : err)(INTRO_USAGE);
+ return flags.has("--help") ? 0 : 2;
+ }
+ for (const f of flags.keys()) if (!["--take", "--off", "--on", "--json"].includes(f)) throw new CliError(`unknown flag ${f}\n\n${INTRO_USAGE}`);
+ const r = await resolveProject(words[0], root);
+ if (r.ambiguous) throw new CliError(`"${words[0]}" is the name of ${r.ambiguous.length} projects — pass its id`);
+ if (!r.project) throw new CliError(`no project matches "${words[0]}"`);
+ const project = r.project;
+ const json = flags.has("--json");
+ const pairs = words.slice(1).map((w) => {
+ const at = w.indexOf("=");
+ if (at <= 0) throw new CliError(`"${w}" is not key=value\n\n${INTRO_USAGE}`);
+ return /** @type {[string, string]} */ ([w.slice(0, at), w.slice(at + 1)]);
+ });
+ const done = [];
+ if (flags.has("--take")) {
+ const take = String(flags.get("--take"));
+ if (pairs.length) throw new CliError("--take sets a version's on/off only (--off or --on); its own knobs are a take's patch (umtool take … --set render.intro.<key>=…)");
+ if (flags.has("--off") === flags.has("--on")) throw new CliError("--take needs --off or --on");
+ const res = await setVersionIntro(project.dir, take, flags.has("--on"));
+ done.push(`${take}: ${flags.has("--on") ? "the cut's intro" : "no intro"}${res.unchanged ? " (already)" : res.revision ? ` · undo point ${res.revision.rel}` : ""}`);
+ } else if (flags.has("--off")) {
+ if (pairs.length) throw new CliError("--off takes the intro off; key=value writes one -- one or the other");
+ const { editNotes } = await withEditNotes(project, () => writeIntro(project.dir, null));
+ done.push(`intro: off${editNotes?.length ? ` · ${editNotes.length} edit note(s)` : ""}`);
+ } else if (pairs.length) {
+ const before = (await introState(project)).intro;
+ let value;
+ try {
+ value = introPatch(before, pairs);
+ } catch (e) {
+ throw new CliError(e instanceof Error ? e.message : String(e));
+ }
+ const { editNotes } = await withEditNotes(project, () => writeIntro(project.dir, value));
+ done.push(`intro: ${JSON.stringify(value)}${editNotes?.length ? ` · ${editNotes.length} edit note(s)` : ""}`);
+ }
+ const state = await introState(project);
+ if (json) out(JSON.stringify({ ok: true, ...state }, null, 2));
+ else {
+ for (const d of done) out(d);
+ if (!done.length) for (const l of describe(state)) out(l);
+ }
+ return 0;
+ } catch (e) {
+ if (e instanceof CliError) {
+ err(`umtool intro: ${e.message}`);
+ return 1;
+ }
+ err(`umtool intro: ${e instanceof Error ? (/** @type {any} */ (e).errors ? /** @type {any} */ (e).errors.join("\n") : e.message) : String(e)}`);
+ return 1;
+ }
+}
diff --git a/umtool/lib/report/introEdit.mjs b/umtool/lib/report/introEdit.mjs
@@ -0,0 +1,185 @@
+// THE INTRO, EDITED (`render.intro`; operator, 8 Nov 2026: "more first-class
+// intro support (view in play the cut)"): one reading and the writes behind
+// the Cut tab's intro editor (components/projects/report/IntroEditor.tsx,
+// /api/report/chrome/intro) and `umtool intro`, so a terminal and the page
+// cannot disagree about what the cut opens on.
+//
+// introState(project) the intro as written, the entry the cut opens with
+// (its words resolved), each version's on/off
+// introPatch(current, pairs) `key=value …` onto the intro as written (the CLI's)
+// writeIntro(dir, value, { token }) the project's render.intro -- updateRender, the one
+// look writer, so the build's own checks refuse it
+// setVersionIntro(dir, take, on, …) a VERSION (a made take) without the intro: its patch
+// carries `render.intro: null` (a style variant), written
+// by the take's own writer (takeEdit.mjs editTakeManifest)
+//
+// Plain ESM: `umtool intro` runs it under bare node.
+import { INTRO_KEYS, INTRO_STYLE_DEFAULT, introErrors } from "yt-dlp-transcript-common/lib/report/intro.mjs";
+import { readManifest } from "../projects/report.mjs";
+import { manifestToken, updateRender } from "./manifest.mjs";
+import { listTakes } from "./takes.mjs";
+
+const isObj = (v) => !!v && typeof v === "object" && !Array.isArray(v);
+const clone = (v) => (v === undefined ? undefined : JSON.parse(JSON.stringify(v)));
+
+/** `render.intro` as written, always its object form (a bare style name is `{ style }`); null for none. */
+export function introObject(v) {
+ if (v === undefined || v === null || v === false) return null;
+ if (typeof v === "string") return { style: v };
+ return isObj(v) ? clone(v) : null;
+}
+
+/**
+ * The object written back: a lone `style` stays the bare name it was
+ * (`"intro": "boot-dark"`), so an edit that only changes the style does not
+ * reshape the manifest.
+ */
+export function introWritten(o) {
+ if (!o) return null;
+ const keys = Object.keys(o);
+ return keys.length === 1 && keys[0] === "style" ? o.style : o;
+}
+
+/** A take patch that switches the intro off: `render.intro: null`. */
+export const takeIntroOff = (patch) => isObj(patch) && isObj(patch.render) && "intro" in patch.render && patch.render.intro === null;
+
+/**
+ * One `key=value` read for the intro: `seconds` a number, `lines` a JSON list
+ * or `a|b|c`, `sound=false` silence, `url=false|true`, `projectUrl=false`,
+ * `site` a JSON object or a word, anything else the text. `key=` (empty)
+ * clears the key.
+ *
+ * @param {string} key
+ * @param {string} raw
+ */
+export function introValue(key, raw) {
+ const s = String(raw ?? "");
+ if (s === "") return undefined;
+ if (key === "seconds") {
+ const n = Number(s);
+ return Number.isFinite(n) ? n : s;
+ }
+ if (key === "lines") {
+ if (s.trim().startsWith("[")) {
+ try {
+ return JSON.parse(s);
+ } catch {
+ return s;
+ }
+ }
+ return s.split("|").map((l) => l.trim()).filter(Boolean);
+ }
+ if ((key === "sound" || key === "projectUrl") && s === "false") return false;
+ if (key === "url" && (s === "false" || s === "true")) return s === "true";
+ if (key === "site" && s.trim().startsWith("{")) {
+ try {
+ return JSON.parse(s);
+ } catch {
+ return s;
+ }
+ }
+ return s;
+}
+
+/**
+ * `pairs` (`[key, raw]`, the CLI's `key=value`) onto the intro as written:
+ * a new intro starts as the brand sting (INTRO_STYLE_DEFAULT); a key not of
+ * the intro's is refused by name. Returns the object to write (introErrors
+ * still decides whether it builds).
+ *
+ * @param {unknown} current render.intro as written
+ * @param {Array<[string, string]>} pairs
+ */
+export function introPatch(current, pairs) {
+ const o = introObject(current) ?? { style: INTRO_STYLE_DEFAULT };
+ for (const [k, raw] of pairs) {
+ if (!INTRO_KEYS.includes(k)) throw new Error(`render.intro.${k} is not a key (${INTRO_KEYS.join(", ")})`);
+ const v = introValue(k, raw);
+ if (v === undefined) {
+ if (k === "style") throw new Error("render.intro.style cannot be cleared: --off takes the intro off");
+ delete o[k];
+ } else o[k] = v;
+ }
+ return o;
+}
+
+/**
+ * The intro of a project: as written, the entry the cut opens with (selectVariant's, its title-card
+ * words and its site resolved -- or the reason it does not resolve), and every made version's state.
+ *
+ * @param {{ id: string, dir: string }} project
+ */
+export async function introState(project) {
+ const manifest = await readManifest(project.dir);
+ if (!manifest) throw new Error("the project has no video.manifest.json");
+ const written = manifest.render?.intro ?? null;
+ const errors = introErrors(written);
+ let entry = null;
+ let entryError = null;
+ if (written !== null && !errors.length) {
+ try {
+ const { selectVariant } = await import("umtool-report-to-video/build-video");
+ const { isIntro } = await import("umtool-report-to-video/intro");
+ entry = (selectVariant(manifest).timeline ?? []).find(isIntro) ?? null;
+ } catch (e) {
+ entryError = e instanceof Error ? e.message : String(e);
+ }
+ }
+ const { takes } = await listTakes(project.dir);
+ const versions = takes.map((t) => ({
+ id: t.id,
+ label: t.label,
+ draft: !!t.draft,
+ // A version's own word: its patch takes the intro off (or puts one on of its own).
+ intro: takeIntroOff(t.patch) ? "off" : isObj(t.patch?.render) && "intro" in t.patch.render ? "own" : "cut",
+ }));
+ return {
+ project: project.id,
+ token: await manifestToken(project.dir),
+ title: typeof manifest.title === "string" ? manifest.title : null,
+ generatedOn: typeof manifest.generatedOn === "string" ? manifest.generatedOn : null,
+ intro: written,
+ errors,
+ entry,
+ entryError,
+ versions,
+ };
+}
+
+/**
+ * The project's `render.intro`, through the one look writer (updateRender: the build's checks, the
+ * manifest's token). `value` null takes the intro off.
+ *
+ * @param {string} dir
+ * @param {unknown} value
+ * @param {{ token?: string | null }} [opts]
+ */
+export async function writeIntro(dir, value, { token = null } = {}) {
+ return updateRender(dir, { intro: value === null ? null : introWritten(introObject(value)) }, { token });
+}
+
+/**
+ * A VERSION (a made take) with or without the cut's intro: off writes `render.intro: null` into its
+ * patch (a style variant: the cut opens on no intro in that version only), on puts the cut's intro
+ * back. Through the take's own writer (editTakeManifest: its token, an undo point, the project's
+ * manifest untouched). On is the cut's intro as it is now, copied into the patch -- the take writer
+ * composes, it never deletes a key -- so the version opens on what the cut opens on.
+ *
+ * @param {string} dir
+ * @param {string} take
+ * @param {boolean} on
+ * @param {{ token?: string | null }} [opts]
+ */
+export async function setVersionIntro(dir, take, on, { token = null } = {}) {
+ const manifest = await readManifest(dir);
+ if (!manifest) throw new Error("the project has no video.manifest.json");
+ const cut = manifest.render?.intro ?? null;
+ if (on && (cut === null || cut === undefined)) throw new Error("the cut has no intro to put back: write one first (umtool intro <p> style=…)");
+ const { editTakeManifest } = await import("./takeEdit.mjs");
+ return editTakeManifest(dir, take, on ? "intro-on" : "intro-off", token, (m) => {
+ m.render = isObj(m.render) ? m.render : {};
+ if (on) m.render.intro = clone(cut);
+ else delete m.render.intro;
+ return { intro: on ? "cut" : "off" };
+ });
+}
diff --git a/umtool/lib/report/introEdit.test.mjs b/umtool/lib/report/introEdit.test.mjs
@@ -0,0 +1,153 @@
+// The intro, edited and previewed (lane intro-play, 9 Nov 2026): introEdit.mjs (the Cut tab's intro editor and
+// `umtool intro`), and onscreen.mjs composeIntroPreview (Play's, Present's and the editor's page).
+import assert from "node:assert/strict";
+import { mkdir, mkdtemp, readFile, rm, stat, writeFile } from "node:fs/promises";
+import { tmpdir } from "node:os";
+import path from "node:path";
+import test from "node:test";
+
+import { introObject, introPatch, introState, introValue, introWritten, setVersionIntro, takeIntroOff, writeIntro } from "./introEdit.mjs";
+import { INTRO_SEEK_SCRIPT, composeIntroPreview } from "./onscreen.mjs";
+import { introPreviewDir, introPreviewSrc, previewDirFor } from "./serve.mjs";
+import { draftTake } from "./takeMaker.mjs";
+import { resolveTakeManifest } from "./takeManifest.mjs";
+import { introEntry } from "umtool-report-to-video/intro";
+import { introCommand } from "./introCli.mjs";
+import { PROJECT_KINDS } from "../projects/kinds.mjs";
+
+const TAKES_KIND = PROJECT_KINDS.find((k) => k.makesTakes).id;
+const MANIFEST = {
+ schemaVersion: 1,
+ slug: "fixture",
+ title: "Fixture, in its own words",
+ generatedOn: "2026-10-29",
+ render: { width: 640, height: 360, fps: 15, transition: 0, crf: 30, intro: "boot-dark" },
+ timeline: [{ type: "clip", id: "c01", channel: "chan", video: "vid", start: 100, end: 110, cite: 100 }],
+};
+
+async function project(manifest = MANIFEST) {
+ const root = await mkdtemp(path.join(tmpdir(), "introedit-"));
+ const dir = path.join(root, "reports", "proj");
+ await mkdir(dir, { recursive: true });
+ await writeFile(path.join(dir, "video.manifest.json"), JSON.stringify(manifest, null, 2) + "\n");
+ return { root, dir, ref: { id: "proj", dir, kind: TAKES_KIND }, reportsRoot: path.join(root, "reports") };
+}
+const read = async (dir) => JSON.parse(await readFile(path.join(dir, "video.manifest.json"), "utf8"));
+const exists = (p) => stat(p).then(() => true, () => false);
+
+test("introValue: seconds a number, lines a list (JSON or a|b), false words, an empty value clears", () => {
+ assert.equal(introValue("seconds", "4.5"), 4.5);
+ assert.deepEqual(introValue("lines", "29 October 2026|Part one"), ["29 October 2026", "Part one"]);
+ assert.deepEqual(introValue("lines", '["a, b","c"]'), ["a, b", "c"]);
+ assert.equal(introValue("sound", "false"), false);
+ assert.equal(introValue("sound", "intro.wav"), "intro.wav");
+ assert.equal(introValue("url", "false"), false);
+ assert.deepEqual(introValue("site", '{"name":"Jeralyzer"}'), { name: "Jeralyzer" });
+ assert.equal(introValue("title", ""), undefined);
+});
+
+test("introPatch: onto the intro as written (a bare style its object), a new one from the brand sting; a stray key refused", () => {
+ assert.deepEqual(introPatch("boot", [["title", "T"]]), { style: "boot", title: "T" });
+ assert.deepEqual(introPatch(null, [["seconds", "5"]]), { style: "boot-dark", seconds: 5 });
+ assert.deepEqual(introPatch({ style: "title-card", title: "T", lines: ["x"] }, [["title", ""], ["lines", ""]]), { style: "title-card" });
+ assert.throws(() => introPatch("boot", [["subtitle", "x"]]), /render\.intro\.subtitle is not a key/);
+ assert.throws(() => introPatch("boot", [["style", ""]]), /--off/);
+ assert.equal(introWritten({ style: "boot" }), "boot", "a lone style stays the bare name");
+ assert.deepEqual(introObject("boot"), { style: "boot" });
+ assert.equal(introObject(null), null);
+});
+
+test("writeIntro: the look writer -- the build's checks refuse a bad intro, null takes it off", async () => {
+ const { root, dir } = await project();
+ try {
+ await writeIntro(dir, { style: "title-card", title: "Mine" });
+ assert.deepEqual((await read(dir)).render.intro, { style: "title-card", title: "Mine" });
+ await assert.rejects(writeIntro(dir, { style: "title-card", seconds: 9 }), /render\.intro\.seconds must be a number from 3\.5 to 8/);
+ await writeIntro(dir, { style: "boot" });
+ assert.equal((await read(dir)).render.intro, "boot");
+ await writeIntro(dir, null);
+ assert.ok(!("intro" in (await read(dir)).render));
+ } finally {
+ await rm(root, { recursive: true, force: true });
+ }
+});
+
+test("a version without the intro: its patch carries render.intro: null (the project's manifest untouched); on puts the cut's back", async () => {
+ const { root, dir, ref } = await project();
+ try {
+ await draftTake(dir, { id: "v1", label: "V1", patch: {} });
+ const before = await readFile(path.join(dir, "video.manifest.json"), "utf8");
+ const off = await setVersionIntro(dir, "v1", false);
+ assert.equal(off.unchanged, false);
+ const doc = JSON.parse(await readFile(path.join(dir, "takes", "v1", "take.json"), "utf8"));
+ assert.equal(doc.patch.render.intro, null);
+ assert.ok(takeIntroOff(doc.patch));
+ assert.equal(await readFile(path.join(dir, "video.manifest.json"), "utf8"), before, "the project's manifest is not touched");
+ assert.ok(!("intro" in ((await resolveTakeManifest(dir, "v1")).manifest.render ?? {})), "the version opens on no intro");
+ const state = await introState(ref);
+ assert.deepEqual(state.versions.map((v) => [v.id, v.intro]), [["v1", "off"]]);
+ assert.equal(state.entry?.style, "boot-dark");
+ assert.equal((await setVersionIntro(dir, "v1", false)).unchanged, true, "off twice writes nothing");
+ await setVersionIntro(dir, "v1", true);
+ assert.equal((await resolveTakeManifest(dir, "v1")).manifest.render.intro, "boot-dark");
+ await writeIntro(dir, null);
+ await assert.rejects(setVersionIntro(dir, "v1", true), /the cut has no intro to put back/);
+ } finally {
+ await rm(root, { recursive: true, force: true });
+ }
+});
+
+test("composeIntroPreview: the build's page with Play's seek, GSAP beside it, the face only when there are words; the draft its own file", async () => {
+ const { root, dir } = await project();
+ try {
+ const render = { width: 640, height: 360, fps: 15 };
+ const plain = introEntry({ intro: "boot-dark" }, {});
+ const c = await composeIntroPreview({ dir }, "full", plain, render);
+ const pdir = introPreviewDir(dir, "full");
+ assert.equal(c.file, "index.html");
+ const html = await readFile(path.join(pdir, "index.html"), "utf8");
+ assert.ok(html.includes(INTRO_SEEK_SCRIPT), "Play's seek appended");
+ assert.ok(html.indexOf(INTRO_SEEK_SCRIPT) < html.lastIndexOf("</body>"));
+ assert.ok(await exists(path.join(pdir, "assets", "gsap.min.js")));
+ assert.ok(!(await exists(path.join(pdir, "assets", "IntroDisplay.ttf"))), "no words, no face");
+ const card = introEntry({ intro: "title-card" }, { manifest: MANIFEST });
+ const d = await composeIntroPreview({ dir }, "full", card, render, { draft: true });
+ assert.equal(d.file, "draft.html");
+ const draft = await readFile(path.join(pdir, "draft.html"), "utf8");
+ assert.ok(draft.includes("Fixture, in its own words") && draft.includes("29 October 2026"));
+ assert.ok(await exists(path.join(pdir, "assets", "IntroDisplay.ttf")));
+ assert.equal(await readFile(path.join(pdir, "index.html"), "utf8"), html, "the draft never overwrites the cut's page");
+ // Served under intro-preview/ by the files route, a take's under its own prefix.
+ assert.deepEqual(previewDirFor(dir, "full", ["intro-preview", "draft.html"], []), { dir: pdir, rest: ["draft.html"] });
+ assert.match(introPreviewSrc("reports/proj", "full", null), /\/full\/intro-preview\/index\.html$/);
+ assert.match(introPreviewSrc("reports/proj", "full", "v1", "index.html"), /\/full\/@take\/v1\/intro-preview\/index\.html$/);
+ } finally {
+ await rm(root, { recursive: true, force: true });
+ }
+});
+
+test("umtool intro: prints the intro, writes key=value, --off takes it off, --take <t> --off a version's", async () => {
+ const { root, dir, reportsRoot } = await project();
+ const out = [];
+ const err = [];
+ const run = (args) => introCommand(args, { root: reportsRoot, out: (s) => out.push(s), err: (s) => err.push(s) });
+ try {
+ assert.equal(await run(["proj"]), 0);
+ assert.match(out.join("\n"), /boot-dark/);
+ assert.equal(await run(["proj", "style=title-card", "seconds=5", "lines=29 October 2026|Part one"]), 0);
+ assert.deepEqual((await read(dir)).render.intro, { style: "title-card", seconds: 5, lines: ["29 October 2026", "Part one"] });
+ assert.equal(await run(["proj", "seconds=9"]), 1);
+ assert.match(err.join("\n"), /seconds must be a number from 3\.5 to 8/);
+ await draftTake(dir, { id: "v1", label: "V1", patch: {} });
+ assert.equal(await run(["proj", "--take", "v1", "--off"]), 0);
+ assert.equal(JSON.parse(await readFile(path.join(dir, "takes", "v1", "take.json"), "utf8")).patch.render.intro, null);
+ out.length = 0;
+ assert.equal(await run(["proj", "--json"]), 0);
+ const j = JSON.parse(out.join("\n"));
+ assert.deepEqual(j.versions.map((v) => v.intro), ["off"]);
+ assert.equal(await run(["proj", "--off"]), 0);
+ assert.ok(!("intro" in (await read(dir)).render));
+ } finally {
+ await rm(root, { recursive: true, force: true });
+ }
+});
diff --git a/umtool/lib/report/onscreen.mjs b/umtool/lib/report/onscreen.mjs
@@ -50,7 +50,7 @@ import {
readCues,
} from "../projects/report.mjs";
import { normalizePostPatches, splitOnscreenRow } from "./manifest.mjs";
-import { deckPreviewDir, feedPreviewDir, finalePreviewDir, postsPreviewDir, stampPreviewDir, teaserPreviewDir } from "./serve.mjs";
+import { INTRO_PREVIEW_FILES, deckPreviewDir, feedPreviewDir, finalePreviewDir, introPreviewDir, postsPreviewDir, stampPreviewDir, teaserPreviewDir } from "./serve.mjs";
import { ensureWriteDir } from "./storage.mjs";
/** The schedule document deck.mjs defines, built or estimated. */
@@ -689,6 +689,55 @@ export async function composeTeaserPreviews(project, variant, timeline, { compos
}
/**
+ * PLAY'S SEEK for the intro's preview page (onscreen.mjs composeIntroPreview):
+ * the teaser's (TEASER_SEEK_SCRIPT), on the intro's timeline -- under
+ * `?preview=1` the page answers `deck:seek` (seconds into the intro) and posts
+ * `intro:ready` once its words (when it draws any) are fitted. Appended to the
+ * preview's copy only: the build renders introPageHtml's page as it is.
+ */
+export const INTRO_SEEK_SCRIPT = `<script data-play-seek="">
+ (function () {
+ if (new URLSearchParams(location.search).get("preview") === null) return;
+ var tl = window.__timelines && window.__timelines["intro"];
+ if (!tl) return;
+ addEventListener("message", function (e) {
+ if (e.origin !== location.origin || !e.data || e.data.type !== "deck:seek") return;
+ tl.seek(Math.max(0, Number(e.data.t) || 0), false);
+ });
+ var tries = 0;
+ (function wait() {
+ var fitted = !document.getElementById("intro-words") || document.documentElement.dataset.fit === "1";
+ if (fitted || tries++ > 200) parent.postMessage({ type: "intro:ready" }, location.origin);
+ else setTimeout(wait, 25);
+ })();
+ })();
+</script>`;
+
+/**
+ * Compose the PREVIEW page of the cut's INTRO (`render.intro`): report-to-video
+ * intro.mjs's own page for `entry` (introEntry's, as selectVariant opens the
+ * cut with it) at the render's size, Play's seek appended, under
+ * out/<variant>/chrome/intro-preview/<file> -- `index.html` for the cut's
+ * intro, `draft.html` for the intro editor's unsaved one (INTRO_PREVIEW_FILES).
+ * No render; nothing else of the cut is read. `write` is injectable for the
+ * unit test; the routes never pass it.
+ *
+ * @param {{ dir: string }} project
+ * @param {string} variant
+ * @param {Record<string, any>} entry
+ * @param {Record<string, any>} render
+ * @param {{ draft?: boolean, write?: (dir: string, entry: any, render: any, o: { file: string, extraScript: string }) => Promise<any> }} [opts]
+ * @returns {Promise<{ file: string, dir: string }>}
+ */
+export async function composeIntroPreview(project, variant, entry, render, { draft = false, write = null } = {}) {
+ const dir = introPreviewDir(project.dir, variant);
+ const file = draft ? INTRO_PREVIEW_FILES.draft : INTRO_PREVIEW_FILES.cut;
+ const writer = write ?? (await import("umtool-report-to-video/intro")).writeIntroPage;
+ await serialised(path.join(dir, file), () => writer(dir, entry, render, { file, extraScript: INTRO_SEEK_SCRIPT }));
+ return { file, dir };
+}
+
+/**
* Compose the PREVIEW of the finale (a schedule with `finale`): compose-chrome's
* `finale` region, one project for its window under
* out/<variant>/chrome/finale-preview/. No render. The page is seeked in the
diff --git a/umtool/lib/report/serve.mjs b/umtool/lib/report/serve.mjs
@@ -935,6 +935,26 @@ export const teaserPreviewDir = (projectDir, variant, segment) =>
export const teaserPreviewSrc = (projectId, variant, segment, take = null) =>
`${previewBase(projectId, variant, take)}/${TEASER_PREVIEW_PREFIX}${encodeURIComponent(segment)}/index.html`;
+// THE INTRO's preview page (`render.intro`; Play's first segment, Present's
+// first slide, the Cut tab's intro editor): report-to-video intro.mjs's own
+// page, written beside GSAP (and the words' face) under
+// out/<variant>/chrome/intro-preview/ -- `index.html` the cut's intro,
+// `draft.html` the editor's unsaved one -- served one segment deeper,
+// `intro-preview/…` (onscreen.mjs composeIntroPreview).
+const INTRO_PREVIEW = "intro-preview";
+
+/** The pages an intro preview writes: the cut's, and the intro editor's unsaved draft. */
+export const INTRO_PREVIEW_FILES = Object.freeze({ cut: "index.html", draft: "draft.html" });
+
+/** The preview project of a cut's intro. */
+export const introPreviewDir = (projectDir, variant) =>
+ path.join(projectDir, "out", variant, "chrome", INTRO_PREVIEW);
+
+/** The iframe src for a cut's intro preview page (`file`: INTRO_PREVIEW_FILES' cut or draft). */
+/** @type {(projectId: string, variant: string, take?: string | null, file?: string) => string} */
+export const introPreviewSrc = (projectId, variant, take = null, file = INTRO_PREVIEW_FILES.cut) =>
+ `${previewBase(projectId, variant, take)}/${INTRO_PREVIEW}/${file}`;
+
/** The preview project of the posts window on one segment. */
export const postsPreviewDir = (projectDir, variant, segment) =>
path.join(projectDir, "out", variant, "chrome", `${POSTS_PREVIEW_PREFIX}${segment}`);
@@ -950,7 +970,8 @@ export const postsPreviewSrc = (projectId, variant, segment, take = null) =>
*
* `feed-preview/…` is the posts feed's project (one per cut),
* `stamp-preview/…` the fact-check stamps' (one per cut) and
- * `finale-preview/…` the finale's (one per cut).
+ * `finale-preview/…` the finale's (one per cut) and `intro-preview/…` the
+ * intro's (one per cut: the cut's page and the intro editor's draft).
* `teaser-preview-<segment>/…` is a teaser entry's page when `<segment>` is one
* of `segmentIds`, as a posts window's is.
* `posts-preview-<segment>/…` is a posts window's project when `<segment>` is
@@ -978,6 +999,7 @@ export function previewDirFor(projectDir, variant, rest, segmentIds) {
if (head === FEED_PREVIEW) return { dir: feedPreviewDir(projectDir, variant), rest: rest.slice(1) };
if (head === STAMP_PREVIEW) return { dir: stampPreviewDir(projectDir, variant), rest: rest.slice(1) };
if (head === FINALE_PREVIEW) return { dir: finalePreviewDir(projectDir, variant), rest: rest.slice(1) };
+ if (head === INTRO_PREVIEW) return { dir: introPreviewDir(projectDir, variant), rest: rest.slice(1) };
if (typeof head === "string" && head.startsWith(TEASER_PREVIEW_PREFIX)) {
const seg = head.slice(TEASER_PREVIEW_PREFIX.length);
if (!seg || /[\/\\\0]/.test(seg) || seg === "." || seg === "..") return null;
diff --git a/umtool/report-to-video/chrome-intro.mjs b/umtool/report-to-video/chrome-intro.mjs
@@ -17,6 +17,8 @@
// a render is a seek per frame, from parallel workers, in any order). Every
// cue is a fromTo whose FROM is stated; the page is a dumb interpreter of
// `introCues`, so the tests read every time it uses.
+import { fileURLToPath } from "node:url";
+
import {
INTRO_BEATS, INTRO_PROJECT_URL, INTRO_SITE_DEFAULTS, INTRO_STYLE_MARK, INTRO_SUFFIX, introSitePrefix, introUrlText,
} from "yt-dlp-transcript-common/lib/report/intro.mjs";
@@ -25,6 +27,16 @@ import { INTRO_GLYPHS, INTRO_GLYPH_CAP, INTRO_GLYPH_UPEM } from "./intro-glyphs.
const r3 = (v) => Math.round(v * 1000) / 1000;
+/**
+ * The words' face (`title`, `lines`): Archivo, the face the wordmark's letters
+ * were drawn from (intro-glyphs.mjs), copied in beside the page as
+ * `assets/IntroDisplay.ttf` under a private name -- only when the page draws
+ * words, so a page without them loads no face, as it never did. Reached only
+ * through a dynamic import of this module (chrome-teaser.mjs says why).
+ */
+export const INTRO_FONT_FILE = fileURLToPath(new URL("./fonts/Archivo[wdth,wght].ttf", import.meta.url));
+export const INTRO_FONT_ASSET = "assets/IntroDisplay.ttf";
+
const esc = (s) =>
String(s ?? "")
.replace(/&/g, "&")
@@ -391,7 +403,7 @@ export function swapPlan({
* mark (`mark`, the style's own when absent) is drawn during the first sound
* or pops in on the chime.
*/
-export function introCues({ style, ground, mark = INTRO_STYLE_MARK[style] ?? "none", seconds, parts, palette, swap = null }) {
+export function introCues({ style, ground, mark = INTRO_STYLE_MARK[style] ?? "none", seconds, parts, palette, swap = null, words = null }) {
const B = INTRO_BEATS;
const init = {};
const cues = [];
@@ -401,7 +413,9 @@ export function introCues({ style, ground, mark = INTRO_STYLE_MARK[style] ?? "no
const nW = word.length;
const fin = (l) => (l.role === "lead" ? palette.lead : l.role === "suffix" ? palette.suffix : palette.media);
const rand = seeded(0xa2c41);
- const motion = style === "boot-dark" ? "boot" : style;
+ // title-card's lockup moves as boot-mark's does (the wordmark sliding out
+ // of the mark, MEDIA on the chime): the words over it carry the card.
+ const motion = style === "boot-dark" ? "boot" : style === "title-card" ? "boot-mark" : style;
const build = B.build;
const chime = B.chime.from;
@@ -548,6 +562,27 @@ export function introCues({ style, ground, mark = INTRO_STYLE_MARK[style] ?? "no
if (swap) siteSwapCues({ swap, init, cues, cue, parts, palette, mark, nW, word, media, fin });
+ // THE WORDS (`title`, `lines`; `words`: { title, lines } -- whether there is
+ // a title, how many lines). On title-card they are the card: the title
+ // rises in on the first sound, each line after it, before the brand under
+ // them lands on the chime. Under a boot style's wordmark they come in after
+ // the chime. They fade with the drawing.
+ if (words) {
+ const card = style === "title-card";
+ const t0 = card ? build.from : chime + 0.3;
+ if (words.title) {
+ init.tt = { opacity: 0, y: 28 };
+ cue("tt", t0, 0.7, { opacity: 0, y: 28 }, { opacity: 1, y: 0 }, "power3.out");
+ }
+ for (let j = 0; j < words.lines; j++) {
+ const at = t0 + (words.title ? (card ? 0.5 : 0.18) : 0) + j * (card ? 0.18 : 0.12);
+ init[`tl${j}`] = { opacity: 0, y: 18 };
+ cue(`tl${j}`, at, 0.55, { opacity: 0, y: 18 }, { opacity: 1, y: 0 }, "power3.out");
+ }
+ init.words = { opacity: 1 };
+ cue("words", seconds - B.fade, B.fade, { opacity: 1 }, { opacity: 0 }, "power1.in");
+ }
+
// The fade to the ground, over the last beat.
cue("stage", seconds - B.fade, B.fade, { opacity: 1 }, { opacity: 0 }, "power1.in");
return { init, cues: cues.sort((a, b) => a.at - b.at || a.k.localeCompare(b.k)) };
@@ -713,6 +748,22 @@ function markShapes(mark) {
return shapes.map((s) => ({ ...s, k }));
}
+/** title-card's lockup, as a fraction of the plain intro's size: the brand small, under the words. */
+export const TITLE_CARD_LOCKUP = 0.46;
+
+/**
+ * Where the words go, as fractions of the frame's height: the block's top and
+ * height (the words centred in it) and, on title-card, the lockup's centre.
+ * title-card: the words over the upper part, the brand under them. A boot
+ * style: the words under the wordmark (lower still when a site's URLs hang
+ * under it). A portrait frame keeps both inside the Shorts safe area.
+ */
+export function wordsLayout({ card, portrait, swapped = false }) {
+ if (card) return portrait ? { top: 0.16, height: 0.4, lockup: 0.66 } : { top: 0.16, height: 0.44, lockup: 0.7 };
+ if (portrait) return { top: swapped ? 0.6 : 0.56, height: 0.18 };
+ return { top: swapped ? 0.72 : 0.66, height: 0.26 };
+}
+
/**
* The intro's page.
* `site` (`{ name, lead?, accent?, url? }`, intro.mjs resolveIntroSite's) turns
@@ -721,12 +772,13 @@ function markShapes(mark) {
* @param {{ style: string, ground: "light" | "dark", mark?: "none" | "draw" | "chime", seconds: number,
* width?: number, height?: number, fps?: number, kit: any, gsapSrc?: string,
* site?: null | { name: string, lead?: string, accent?: string, url?: string | false },
- * swap?: "swipe-down" | "roll" | "wipe", url?: "both" | "site" | "project" | "none", urlPlace?: "under" | "replace" }} o
+ * swap?: "swipe-down" | "roll" | "wipe", url?: "both" | "site" | "project" | "none", urlPlace?: "under" | "replace",
+ * suffix?: string, projectUrl?: string | false, title?: string | null, lines?: string[] | null, font?: string }} o
*/
export function introHtml({
style, ground, mark = INTRO_STYLE_MARK[style] ?? "none", seconds, width = 1920, height = 1080, fps = 30, kit, gsapSrc = "assets/gsap.min.js",
site = null, swap = INTRO_SITE_DEFAULTS.swap, url = INTRO_SITE_DEFAULTS.url, urlPlace = INTRO_SITE_DEFAULTS.urlPlace,
- suffix = INTRO_SUFFIX, projectUrl = PROJECT_URL_TEXT,
+ suffix = INTRO_SUFFIX, projectUrl = PROJECT_URL_TEXT, title = null, lines = null, font = INTRO_FONT_ASSET,
}) {
const W = width;
const H = height;
@@ -743,7 +795,15 @@ export function introHtml({
const x1 = parts.width;
const y0 = Math.min(parts.top, withMark ? parts.mark.y : Infinity);
const y1 = Math.max(parts.bottom, withMark ? parts.mark.y + parts.mark.size : -Infinity);
- const k = H > W ? r3(Math.min(W * (withMark ? 0.7 : 0.61), W * PORTRAIT_SAFE_WIDTH) / (x1 - x0)) : r3((W * (withMark ? 0.7 : 0.61)) / (x1 - x0));
+ // The words (`title`, `lines`): drawn only when written, so a page without
+ // them is the page it always was, byte for byte.
+ const wordTitle = typeof title === "string" && title.trim() ? title.trim() : null;
+ const wordLines = (Array.isArray(lines) ? lines : []).filter((l) => typeof l === "string" && l.trim()).map((l) => l.trim());
+ const words = wordTitle || wordLines.length ? { title: !!wordTitle, lines: wordLines.length } : null;
+ // title-card with words: the brand small, under them (WORDS_LAYOUT).
+ const card = !!words && style === "title-card";
+ const shrink = card ? TITLE_CARD_LOCKUP : 1;
+ const k = H > W ? r3((shrink * Math.min(W * (withMark ? 0.7 : 0.61), W * PORTRAIT_SAFE_WIDTH)) / (x1 - x0)) : r3((shrink * W * (withMark ? 0.7 : 0.61)) / (x1 - x0));
const ox = r3(W / 2 - ((x0 + x1) / 2) * k);
// The site swap: what changes on the chime. The lockup is centred exactly as
// the plain intro centres it, and the URLs hang below it, left out of the
@@ -754,13 +814,17 @@ export function introHtml({
// and keeps it inside 12 % of either side (the right 12 % carries its buttons).
// A landscape frame is centred exactly as it always was.
const portrait = H > W;
- const oy = portrait ? r3(H * PORTRAIT_SAFE_CENTRE - ((y0 + y1) / 2) * k) : r3(H / 2 - ((y0 + y1) / 2) * k);
+ const layout = words ? wordsLayout({ card, portrait, swapped: !!site }) : null;
+ const oy = card
+ ? r3(H * layout.lockup - ((y0 + y1) / 2) * k)
+ : portrait ? r3(H * PORTRAIT_SAFE_CENTRE - ((y0 + y1) / 2) * k) : r3(H / 2 - ((y0 + y1) / 2) * k);
const plan = site ? swapPlan({ parts, site, url, urlPlace, markX: withMark ? parts.mark.x : null, suffix, projectUrl }) : null;
const accent = site ? introAccent(site.accent, ground, palette) : null;
const lift = 0;
const { init, cues } = introCues({
style, ground, mark: withMark ? mark : "none", seconds, parts: { ...parts, markShapes: shapes }, palette,
...(plan ? { swap: { plan, kind: swap, accent, lift } } : {}),
+ ...(words ? { words } : {}),
});
const dur = pageDuration(seconds, fps);
@@ -819,8 +883,46 @@ export function introHtml({
</g>${popped ? "</g>" : ""}`
: "";
const edgeH = r3(parts.wordBottom - parts.top + 24);
- const data = { init, cues };
+ // The words' sizes: px at 1080p, scaled with the frame (a portrait frame by its width).
+ const u = portrait ? W / 1080 : Math.min(W / 1920, H / 1080);
+ const ty = words ? { title: Math.round((card ? 92 : 54) * u), line: Math.round((card ? 40 : 32) * u), gap: Math.round((card ? 18 : 10) * u) } : null;
+ const maxW = Math.round(W * (portrait ? PORTRAIT_SAFE_WIDTH : 0.86));
+ const data = { init, cues, ...(words ? { words: { maxW, floor: Math.round(24 * u) } } : {}) };
const json = JSON.stringify(data).replace(/</g, "\\u003c");
+ const wordsCss = words
+ ? `
+ /* The words: one variable face under a private name, the real file beside the page (chrome-teaser.mjs's rule). */
+ @font-face { font-family: 'IntroDisplay'; font-style: normal; font-weight: 100 900; font-stretch: 62% 125%; src: url('${esc(font)}'); }
+ #intro-words { position: absolute; left: 0; top: ${Math.round(H * layout.top)}px; width: ${W}px; height: ${Math.round(H * layout.height)}px;
+ display: flex; flex-direction: column; align-items: center; justify-content: center; gap: ${ty.gap}px;
+ font-family: 'IntroDisplay', sans-serif; font-synthesis: none; font-stretch: 118%;
+ -webkit-font-smoothing: antialiased; text-rendering: geometricPrecision; text-align: center; }
+ #intro-words .t { font-size: ${ty.title}px; font-weight: 720; line-height: 1.06; color: ${palette.lead}; white-space: nowrap; }
+ #intro-words .l { font-size: ${ty.line}px; font-weight: 480; line-height: 1.2; letter-spacing: 0.02em; color: ${palette.media}; white-space: nowrap; }`
+ : "";
+ const wordsEls = words
+ ? `
+ <div id="intro-words" data-k="words">${wordTitle ? `
+ <div class="t" data-k="tt">${esc(wordTitle)}</div>` : ""}${wordLines.map((l, j) => `
+ <div class="l" data-k="tl${j}">${esc(l)}</div>`).join("")}
+ </div>`
+ : "";
+ // The fit (the teaser's): a line wider than the frame allows shrinks a pixel
+ // at a time, once the face is in; the renderer waits on document.fonts.ready.
+ const wordsJs = words
+ ? `
+ function fit(row) {
+ let s = parseFloat(getComputedStyle(row).fontSize);
+ while (s > D.words.floor && row.scrollWidth > D.words.maxW + 0.5) {
+ s -= 1;
+ row.style.fontSize = s + "px";
+ }
+ }
+ const ready = Promise.all([document.fonts.load("720 90px IntroDisplay"), document.fonts.load("480 40px IntroDisplay")]).catch(() => {}).then(() => {
+ document.querySelectorAll("#intro-words > div").forEach(fit);
+ document.documentElement.dataset.fit = "1";
+ });`
+ : "";
return `<!doctype html>
<html lang="en">
@@ -833,7 +935,7 @@ export function introHtml({
html, body { width: ${W}px; height: ${H}px; overflow: hidden; background: ${palette.ground}; }
#root { position: relative; width: ${W}px; height: ${H}px; overflow: hidden; }
#intro-clip { position: absolute; left: 0; top: 0; width: ${W}px; height: ${H}px; overflow: hidden; background: ${palette.ground}; }
- svg { position: absolute; left: 0; top: 0; }
+ svg { position: absolute; left: 0; top: 0; }${wordsCss}
</style>
</head>
<body>
@@ -869,7 +971,7 @@ export function introHtml({
</g>` : ""}
</g>
</g>
- </svg>
+ </svg>${wordsEls}
</div>
</div>
@@ -890,9 +992,10 @@ export function introHtml({
// The timeline is as long as the page, whatever the last cue is.
tl.set({}, {}, ${dur});
window.__timelines = window.__timelines || {};
- window.__timelines["intro"] = tl;
+ window.__timelines["intro"] = tl;${wordsJs}
const still = new URLSearchParams(location.search).get("still");
- if (still !== null) tl.seek(Number(still), false);
+ if (still !== null) tl.seek(Number(still), false);${words ? `
+ if (still !== null) ready.then(() => tl.seek(Number(still), false));` : ""}
</script>
</body>
</html>
diff --git a/umtool/report-to-video/intro-site.test.mjs b/umtool/report-to-video/intro-site.test.mjs
@@ -199,6 +199,9 @@ const PLAIN_PAGES = {
"boot-cascade/dark/none": "e6688e3b824d0264", "boot-cascade/dark/draw": "bf4442b27759e9d8", "boot-cascade/dark/chime": "c28a423b4b7d3713",
"boot-mark/light/none": "8dd36eca63449b09", "boot-mark/light/draw": "ccce2bdc9e2a1c92", "boot-mark/light/chime": "0816d90979a7d62a",
"boot-mark/dark/none": "8c56b66e319ddea8", "boot-mark/dark/draw": "06936a62572f6c88", "boot-mark/dark/chime": "89e4e087e67af811",
+ // title-card (lane intro-play, 9 Nov) without words: boot-mark's motion, its own page.
+ "title-card/light/none": "ed845730c051db8f", "title-card/light/draw": "d2d697471f1279d7", "title-card/light/chime": "1537771013ccc805",
+ "title-card/dark/none": "e23fdccbff88e8d5", "title-card/dark/draw": "3ebb9262c1f4a897", "title-card/dark/chime": "88d148cf54d71096",
};
test("no site (absent, none, or an auto that matched nothing): every page is byte-identical to before, so cached intros still hit", () => {
diff --git a/umtool/report-to-video/intro-words.test.mjs b/umtool/report-to-video/intro-words.test.mjs
@@ -0,0 +1,115 @@
+// The intro's words and its title card (lane intro-play, 9 Nov 2026): `title`, `lines`, the
+// `title-card` style (the project's title and date over the brand), and the page that draws them.
+import { test } from "node:test";
+import assert from "node:assert/strict";
+
+import {
+ INTRO_LINE_MAX, INTRO_LINES_MAX, INTRO_SECONDS, INTRO_SECONDS_MAX, INTRO_SECONDS_MIN, INTRO_STYLES, INTRO_TITLE_MAX, introErrors, introOf,
+} from "yt-dlp-transcript-common/lib/report/intro.mjs";
+import { introDateWords, introEntry, introManifest, introPageHtml, introWords } from "./intro.mjs";
+import { INTRO_FONT_ASSET, introCues, introHtml, introPalette, lockupParts, wordsLayout } from "./chrome-intro.mjs";
+import { brandKit } from "./brand.mjs";
+
+const kit = brandKit("archilyzer-media");
+
+test("title-card is a style; the brand sting stays first, and a new intro's default", async () => {
+ assert.ok(INTRO_STYLES.includes("title-card"));
+ assert.equal(INTRO_STYLES[0], "boot");
+ const { INTRO_STYLE_DEFAULT } = await import("yt-dlp-transcript-common/lib/report/intro.mjs");
+ assert.equal(INTRO_STYLE_DEFAULT, "boot-dark");
+ assert.deepEqual(introErrors("title-card"), []);
+ const o = introOf({ intro: "title-card" });
+ assert.deepEqual([o.ground, o.mark], ["dark", "chime"], "title-card: dark, the mark on the chime");
+});
+
+test("title and lines: one line each, the title at most 80, at most 3 lines; each refused by its name", () => {
+ assert.deepEqual(introErrors({ style: "boot-dark", title: "In her own words", lines: ["29 October 2026"] }), []);
+ assert.deepEqual(introErrors({ style: "title-card", lines: [] }), [], "no lines is a list");
+ assert.match(introErrors({ style: "boot", title: "" }).join(), /render\.intro\.title must be one line of 1 to 80/);
+ assert.match(introErrors({ style: "boot", title: "x".repeat(INTRO_TITLE_MAX + 1) }).join(), /render\.intro\.title/);
+ assert.deepEqual(introErrors({ style: "boot", title: "x".repeat(INTRO_TITLE_MAX) }), []);
+ assert.match(introErrors({ style: "boot", title: "two\nlines" }).join(), /render\.intro\.title must be one line/);
+ assert.match(introErrors({ style: "boot", title: 7 }).join(), /render\.intro\.title/);
+ assert.match(introErrors({ style: "boot", lines: "29 October" }).join(), /render\.intro\.lines must be a list of at most 3/);
+ assert.match(introErrors({ style: "boot", lines: Array(INTRO_LINES_MAX + 1).fill("a") }).join(), /at most 3/);
+ assert.match(introErrors({ style: "boot", lines: ["ok", ""] }).join(), /render\.intro\.lines\[1\] must be one line/);
+ assert.match(introErrors({ style: "boot", lines: ["y".repeat(INTRO_LINE_MAX + 1)] }).join(), /render\.intro\.lines\[0\]/);
+ assert.match(introErrors({ style: "boot", subtitle: "x" }).join(), /render\.intro\.subtitle is not a key \(.*title, lines\)/);
+});
+
+test("seconds: 3.5 to 8, inclusive", () => {
+ assert.equal(INTRO_SECONDS_MIN, 3.5);
+ assert.equal(INTRO_SECONDS_MAX, 8);
+ assert.deepEqual(introErrors({ style: "title-card", seconds: 3.5 }), []);
+ assert.deepEqual(introErrors({ style: "title-card", seconds: 8 }), []);
+ for (const s of [3.49, 8.01, "5", Number.NaN]) assert.match(introErrors({ style: "title-card", seconds: s }).join(), /render\.intro\.seconds must be a number from 3\.5 to 8/, String(s));
+});
+
+test("introOf carries the words only when written, trimmed", () => {
+ assert.ok(!("title" in introOf({ intro: "boot" })));
+ assert.ok(!("lines" in introOf({ intro: "boot" })));
+ const o = introOf({ intro: { style: "boot", title: " A title ", lines: [" one ", "two"] } });
+ assert.equal(o.title, "A title");
+ assert.deepEqual(o.lines, ["one", "two"]);
+});
+
+test("title-card's words default to the project's title and its date; written words win; a boot style draws none unless written", () => {
+ const m = { title: "EmberParadox, in her own words", generatedOn: "2026-10-29" };
+ assert.equal(introDateWords("2026-10-29"), "29 October 2026");
+ assert.equal(introDateWords("2026-13-01"), null);
+ assert.equal(introDateWords(undefined), null);
+ assert.deepEqual(introWords({ style: "title-card" }, m), { title: m.title, lines: ["29 October 2026"] });
+ assert.deepEqual(introWords({ style: "title-card", title: "Mine", lines: [] }, m), { title: "Mine" }, "lines: [] is none");
+ assert.deepEqual(introWords({ style: "title-card" }, {}), {}, "nothing to draw: the brand alone");
+ assert.deepEqual(introWords({ style: "boot-dark" }, m), {});
+ assert.deepEqual(introWords({ style: "boot-dark", title: "T" }, m), { title: "T" });
+ // The entry the cut opens with carries them; selectVariant's door (introManifest) passes the manifest.
+ const cut = introManifest({ ...m, render: { intro: "title-card" }, timeline: [{ id: "c1", type: "clip" }] });
+ assert.equal(cut.timeline[0].title, m.title);
+ assert.deepEqual(cut.timeline[0].lines, ["29 October 2026"]);
+ const plain = introEntry({ intro: "boot" }, { manifest: m });
+ assert.ok(!("title" in plain) && !("lines" in plain), "a plain intro's entry is what it was");
+});
+
+test("the page: no words, no face and no words block (byte for byte the old page); words, the face linked and each line drawn", async () => {
+ const plain = introHtml({ style: "boot-dark", ground: "dark", seconds: INTRO_SECONDS, kit });
+ assert.ok(!plain.includes("IntroDisplay"));
+ assert.ok(!plain.includes("intro-words"));
+ const page = introHtml({ style: "title-card", ground: "dark", mark: "chime", seconds: INTRO_SECONDS, kit, title: "A <b>title</b>", lines: ["29 October 2026"] });
+ assert.ok(page.includes(`url('${INTRO_FONT_ASSET}')`));
+ assert.match(page, /<div class="t" data-k="tt">A <b>title<\/b><\/div>/, "escaped");
+ assert.match(page, /<div class="l" data-k="tl0">29 October 2026<\/div>/);
+ assert.match(page, /dataset\.fit = "1"/, "the fit marks the page ready");
+ // introPageHtml is the same call the build makes.
+ const entry = introEntry({ intro: { style: "title-card", title: "A title" } }, {});
+ assert.equal(await introPageHtml(entry, {}), introHtml({ style: "title-card", ground: "dark", mark: "chime", seconds: INTRO_SECONDS, kit, title: "A title" }));
+});
+
+test("title-card: the brand small and low, under the words; a portrait frame keeps both in the safe area", () => {
+ const card = wordsLayout({ card: true, portrait: false });
+ assert.ok(card.top + card.height < card.lockup, "the words end above the brand's centre");
+ const portrait = wordsLayout({ card: true, portrait: true });
+ assert.ok(portrait.top >= 0.08 && portrait.lockup <= 0.8, "inside the Shorts safe area");
+ const under = wordsLayout({ card: false, portrait: false });
+ assert.ok(under.top > 0.5, "under a boot style's wordmark");
+ assert.ok(wordsLayout({ card: false, portrait: false, swapped: true }).top > under.top, "lower still under a site's URLs");
+});
+
+test("the words' cues: title-card's title on the first sound, its lines after; a boot style's after the chime; both fade with the drawing", () => {
+ const p = lockupParts(kit);
+ const pal = introPalette("dark", kit);
+ const card = introCues({ style: "title-card", ground: "dark", mark: "chime", seconds: 5, parts: { ...p, markShapes: [] }, palette: pal, words: { title: true, lines: 2 } });
+ const tt = card.cues.find((c) => c.k === "tt");
+ assert.equal(tt.at, 0.34);
+ const l0 = card.cues.find((c) => c.k === "tl0");
+ const l1 = card.cues.find((c) => c.k === "tl1");
+ assert.ok(l0.at > tt.at && l1.at > l0.at);
+ assert.ok(l1.at + l1.dur < 2.78, "the card is read before the brand lands");
+ const fade = card.cues.find((c) => c.k === "words");
+ assert.equal(fade.at, 4.5);
+ const boot = introCues({ style: "boot-dark", ground: "dark", seconds: 5, parts: { ...p, markShapes: [] }, palette: pal, words: { title: true, lines: 0 } });
+ assert.ok(boot.cues.find((c) => c.k === "tt").at > 2.78);
+ // Without words the cue list is exactly what it was.
+ const none = introCues({ style: "boot-dark", ground: "dark", seconds: 5, parts: { ...p, markShapes: [] }, palette: pal });
+ assert.ok(!none.cues.some((c) => c.k === "tt" || c.k === "words"));
+});
diff --git a/umtool/report-to-video/intro.mjs b/umtool/report-to-video/intro.mjs
@@ -51,7 +51,7 @@
// node intro.mjs render --style boot [--ground light|dark] [--mark none|draw|chime] [--seconds 4.18]
// [--site auto|<id>|'{"name":"Jeralyzer","accent":"brass"}' [--site-origin <url>]
// [--swap swipe-down|roll|wipe] [--url both|site|project|false] [--url-place under|replace]]
-// [--sound <wav> | --silent] [--width 1920 --height 1080 --fps 30] --out <file.mp4>
+// [--title T] [--line L …] [--sound <wav> | --silent] [--width 1920 --height 1080 --fps 30] --out <file.mp4>
// node intro.mjs extract-sound <reference.mp4>
// `render` takes the heavy slot (heavy-gate.mjs) unless HEAVY=0.
@@ -182,16 +182,48 @@ export function resolveIntroSite(site, { siteOrigin = null, sitesDir = SITES_DIR
return strip(r);
}
+const MONTHS = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
+
+/** `YYYY-MM-DD` (a manifest's `generatedOn`) in words, "29 October 2026"; null for anything else. */
+export function introDateWords(v) {
+ const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(String(v ?? ""));
+ if (!m || Number(m[2]) < 1 || Number(m[2]) > 12) return null;
+ return `${Number(m[3])} ${MONTHS[Number(m[2]) - 1]} ${m[1]}`;
+}
+
+/**
+ * The words an intro draws: its own `title` and `lines` when written; on
+ * title-card, unwritten, the project's title (the manifest's `title`) and its
+ * date in words (`generatedOn`) -- "project title + date over the brand".
+ * A boot style draws words only when they are written.
+ *
+ * @param {{ style: string, title?: string, lines?: string[] }} o introOf's
+ * @param {{ title?: unknown, generatedOn?: unknown } | null} [manifest]
+ * @returns {{ title?: string, lines?: string[] }}
+ */
+export function introWords(o, manifest = null) {
+ const card = o.style === "title-card";
+ const title = o.title ?? (card && typeof manifest?.title === "string" && manifest.title.trim() ? manifest.title.trim().slice(0, 80) : undefined);
+ const date = card ? introDateWords(manifest?.generatedOn) : null;
+ const lines = o.lines ?? (date ? [date] : undefined);
+ return { ...(title ? { title } : {}), ...(lines && lines.length ? { lines } : {}) };
+}
+
/**
* The timeline entry `render.intro` adds, or null for none. A key that does
* not validate adds nothing here: the build's validators refuse it by name.
- * `provenance` (the manifest's) is what `site: "auto"` reads its siteOrigin from.
+ * `provenance` (the manifest's) is what `site: "auto"` reads its siteOrigin from;
+ * `manifest` (its title, its `generatedOn`) is what title-card's words default to.
+ *
+ * @param {any} render
+ * @param {{ provenance?: any, sitesDir?: string, manifest?: any }} [o]
*/
-export function introEntry(render, { provenance = null, sitesDir = SITES_DIR } = {}) {
+export function introEntry(render, { provenance = null, sitesDir = SITES_DIR, manifest = null } = {}) {
if (introErrors(render?.intro).length) return null;
const o = introOf(render);
if (!o) return null;
const site = o.site ? resolveIntroSite(o.site, { siteOrigin: provenance?.siteOrigin ?? null, sitesDir }) : null;
+ const words = introWords(o, manifest);
return {
type: INTRO_TYPE, id: INTRO_ID, style: o.style, ground: o.ground, mark: o.mark, seconds: o.seconds,
...(o.sound !== undefined ? { sound: o.sound } : {}),
@@ -202,6 +234,8 @@ export function introEntry(render, { provenance = null, sitesDir = SITES_DIR } =
// The site's swap, resolved: only when one was found, so an intro with no
// site (or an "auto" that matched none) is the plain intro's entry.
...(site ? { site, swap: o.swap, url: o.url, urlPlace: o.urlPlace } : {}),
+ // The words (title-card's, or under a boot style's wordmark): only when there are any.
+ ...words,
// A placeholder's words (umtool's Play view, the deck's table).
heading: "Intro",
};
@@ -245,7 +279,7 @@ export const isIntro = (entry) => entry?.type === INTRO_TYPE;
* downstream can tell a manifest without the key from before it existed.
*/
export function introManifest(manifest, { sitesDir = SITES_DIR } = {}) {
- const entry = introEntry(manifest?.render, { provenance: manifest?.provenance ?? null, sitesDir });
+ const entry = introEntry(manifest?.render, { provenance: manifest?.provenance ?? null, sitesDir, manifest });
if (!entry) return manifest;
const timeline = manifest.timeline ?? [];
if (timeline.some(isIntro)) return manifest;
@@ -337,6 +371,65 @@ async function probeSeconds(file) {
}
/**
+ * The intro's page for an entry (introEntry's) at a render's size and fps:
+ * what renderIntro renders and keys, and what umtool's Play and the Cut tab's
+ * intro editor preview (lib/report/onscreen.mjs composeIntroPreview) -- one
+ * call, so the preview is the page the build renders.
+ *
+ * @param {Record<string, any>} entry
+ * @param {Record<string, any>} render
+ */
+export async function introPageHtml(entry, render, { gsapSrc } = {}) {
+ const { introHtml } = await import("./chrome-intro.mjs");
+ const { brandKit } = await import("./brand.mjs");
+ const siteKnobs = introSiteKnobs(entry);
+ return introHtml({
+ style: entry.style, ground: entry.ground, ...(entry.mark !== undefined ? { mark: entry.mark } : {}),
+ seconds: entry.seconds, width: render.width ?? 1920, height: render.height ?? 1080, fps: render.fps ?? 30,
+ kit: introKit(brandKit, entry.brand ?? INTRO_BRAND_DEFAULT),
+ ...(siteKnobs ?? {}),
+ ...(entry.suffix !== undefined ? { suffix: entry.suffix } : {}),
+ ...(entry.projectUrl !== undefined ? { projectUrl: entry.projectUrl } : {}),
+ ...(entry.title !== undefined ? { title: entry.title } : {}),
+ ...(entry.lines !== undefined ? { lines: entry.lines } : {}),
+ ...(gsapSrc ? { gsapSrc } : {}),
+ });
+}
+
+/**
+ * The intro's page written as a project a browser can open: `dir/<file>`
+ * (introPageHtml's, `extraScript` before its `</body>` -- Play's seek, the
+ * preview's only), GSAP and, when the page draws words, their face under
+ * `dir/assets/`. What umtool's previews serve (lib/report/onscreen.mjs
+ * composeIntroPreview); no render.
+ *
+ * @param {string} dir
+ * @param {Record<string, any>} entry introEntry's
+ * @param {Record<string, any>} render
+ * @param {{ file?: string, extraScript?: string }} [opts]
+ * @returns {Promise<{ file: string, html: string }>}
+ */
+export async function writeIntroPage(dir, entry, render, { file = "index.html", extraScript = "" } = {}) {
+ const { INTRO_FONT_FILE, INTRO_FONT_ASSET } = await import("./chrome-intro.mjs");
+ const { GSAP_FILE } = await import("./chrome-deck.mjs");
+ const html = await introPageHtml(entry, render);
+ await mkdir(/* turbopackIgnore: true */ path.join(/* turbopackIgnore: true */ dir, "assets"), { recursive: true });
+ const gsap = path.join(/* turbopackIgnore: true */ dir, "assets", "gsap.min.js");
+ if (!(await exists(gsap))) await copyFile(/* turbopackIgnore: true */ GSAP_FILE, gsap);
+ if (entry.title || entry.lines?.length) {
+ const face = path.join(/* turbopackIgnore: true */ dir, INTRO_FONT_ASSET);
+ if (!(await exists(face))) await copyFile(/* turbopackIgnore: true */ INTRO_FONT_FILE, face);
+ }
+ const at = html.lastIndexOf("</body>");
+ const page = !extraScript ? html : at < 0 ? html + extraScript : `${html.slice(0, at)}${extraScript}\n ${html.slice(at)}`;
+ const out = path.join(/* turbopackIgnore: true */ dir, file);
+ const tmp = `${out}.${process.pid}.tmp`;
+ await writeFile(/* turbopackIgnore: true */ tmp, page, "utf8");
+ await rename(tmp, out);
+ return { file: out, html };
+}
+
+/**
* The intro rendered and encoded at this cut's size, fps and encode, from
* the cache when it is there: `{ path, key, cached }`. `workDir` holds the
* page and its frames while it renders (both removed once encoded).
@@ -353,6 +446,8 @@ export async function renderIntro({ entry, render, encode, manifestDir = process
...(entry.brand !== undefined ? { brand: entry.brand } : {}),
...(entry.suffix !== undefined ? { suffix: entry.suffix } : {}),
...(entry.projectUrl !== undefined ? { projectUrl: entry.projectUrl } : {}),
+ ...(entry.title !== undefined ? { title: entry.title } : {}),
+ ...(entry.lines !== undefined ? { lines: entry.lines } : {}),
...(siteKnobs
? {
site: siteObject(siteKnobs.site), swap: siteKnobs.swap, urlPlace: siteKnobs.urlPlace,
@@ -361,19 +456,10 @@ export async function renderIntro({ entry, render, encode, manifestDir = process
: {}),
});
if (errors.length) throw new Error(errors.join("; "));
- const { introHtml } = await import("./chrome-intro.mjs");
- const { brandKit } = await import("./brand.mjs");
+ const { INTRO_FONT_FILE, INTRO_FONT_ASSET } = await import("./chrome-intro.mjs");
const { hyperframesCommand, frameCount } = await import("./deck.mjs");
- const W = render.width ?? 1920;
- const H = render.height ?? 1080;
const fps = render.fps ?? 30;
- const html = introHtml({
- style: entry.style, ground: entry.ground, ...(entry.mark !== undefined ? { mark: entry.mark } : {}),
- seconds: entry.seconds, width: W, height: H, fps, kit: introKit(brandKit, entry.brand ?? INTRO_BRAND_DEFAULT),
- ...(siteKnobs ?? {}),
- ...(entry.suffix !== undefined ? { suffix: entry.suffix } : {}),
- ...(entry.projectUrl !== undefined ? { projectUrl: entry.projectUrl } : {}),
- });
+ const html = await introPageHtml(entry, render);
const sound = introSoundPath(entry, manifestDir, standin);
let soundSha = null;
if (sound) {
@@ -396,6 +482,8 @@ export async function renderIntro({ entry, render, encode, manifestDir = process
const { HF_JSON, runRenderer } = await import("./compose-chrome.mjs");
const { GSAP_FILE } = await import("./chrome-deck.mjs");
await copyFile(/* turbopackIgnore: true */ GSAP_FILE, path.join(/* turbopackIgnore: true */ proj, "assets", "gsap.min.js"));
+ // The words' face, when the page draws words (introHtml links it only then).
+ if (entry.title || entry.lines?.length) await copyFile(/* turbopackIgnore: true */ INTRO_FONT_FILE, path.join(/* turbopackIgnore: true */ proj, INTRO_FONT_ASSET));
await writeFile(/* turbopackIgnore: true */ path.join(/* turbopackIgnore: true */ proj, "index.html"), html, "utf8");
await writeFile(/* turbopackIgnore: true */ path.join(/* turbopackIgnore: true */ proj, "hyperframes.json"), HF_JSON + "\n", "utf8");
await runRenderer(hf.cmd, [
@@ -483,7 +571,7 @@ async function main(argv) {
"usage: intro.mjs render --style <" + INTRO_STYLES.join("|") + "> [--ground light|dark] [--mark " + INTRO_MARKS.join("|") + "]\n" +
" [--seconds s] [--site auto|<id>|<json> [--site-origin <url>] [--swap " + INTRO_SWAPS.join("|") + "]\n" +
" [--url " + INTRO_URLS.join("|") + "|false] [--url-place " + INTRO_URL_PLACES.join("|") + "]]\n" +
- " [--sound <wav> | --silent] [--width 1920 --height 1080 --fps 30] --out <file.mp4>\n" +
+ " [--title T] [--line L …] [--sound <wav> | --silent] [--width 1920 --height 1080 --fps 30] --out <file.mp4>\n" +
" intro.mjs extract-sound <reference.mp4> [--out <wav>]",
);
return 2;
@@ -499,6 +587,8 @@ async function main(argv) {
...(flag("--swap") ? { swap: flag("--swap") } : {}),
...(flag("--url") ? { url: flag("--url") === "false" ? false : flag("--url") === "true" ? true : flag("--url") } : {}),
...(flag("--url-place") ? { urlPlace: flag("--url-place") } : {}),
+ ...(flag("--title") ? { title: flag("--title") } : {}),
+ ...(rest.includes("--line") ? { lines: rest.flatMap((a, i) => (a === "--line" && rest[i + 1] !== undefined ? [rest[i + 1]] : [])) } : {}),
...(rest.includes("--silent") ? { sound: false } : flag("--sound") ? { sound: path.resolve(/* turbopackIgnore: true */ flag("--sound")) } : {}),
};
const render = {
diff --git a/umtool/report-to-video/intro.test.mjs b/umtool/report-to-video/intro.test.mjs
@@ -62,9 +62,9 @@ test("render.intro: an unknown style is refused by name, with the styles listed"
assert.match(introErrors({ ground: "dark" })[0], /style null is not an intro style/);
});
-test("render.intro.mark: none, draw or chime; boot-mark draws it, every other style has none", () => {
+test("render.intro.mark: none, draw or chime; boot-mark draws it, title-card chimes it, every other style has none", () => {
assert.deepEqual([...INTRO_MARKS], ["none", "draw", "chime"]);
- for (const s of INTRO_STYLES) assert.equal(introOf({ intro: s }).mark, s === "boot-mark" ? "draw" : "none", s);
+ for (const s of INTRO_STYLES) assert.equal(introOf({ intro: s }).mark, s === "boot-mark" ? "draw" : s === "title-card" ? "chime" : "none", s);
assert.equal(INTRO_STYLE_MARK["boot-mark"], "draw");
assert.equal(introOf({ intro: { style: "boot-dark", mark: "chime" } }).mark, "chime", "a mark named beats the style's");
assert.equal(introOf({ intro: { style: "boot-mark", mark: "none" } }).mark, "none");
diff --git a/umtool/report-to-video/modules/intro.mjs b/umtool/report-to-video/modules/intro.mjs
@@ -11,7 +11,7 @@
// none). Unset, the intro is the bytes it always was.
import {
INTRO_BRAND_DEFAULT, INTRO_GROUNDS, INTRO_MARKS, INTRO_PROJECT_URL, INTRO_SECONDS, INTRO_SECONDS_MAX, INTRO_SECONDS_MIN,
- INTRO_STYLES, INTRO_SUFFIX, INTRO_SWAPS, INTRO_URL_PLACES, INTRO_URLS, introErrors, introOf,
+ INTRO_LINE_MAX, INTRO_LINES_MAX, INTRO_STYLES, INTRO_SUFFIX, INTRO_SWAPS, INTRO_TITLE_MAX, INTRO_URL_PLACES, INTRO_URLS, introErrors, introOf,
} from "yt-dlp-transcript-common/lib/report/intro.mjs";
import { BRAND_IDS } from "../brand-ids.mjs";
import { defineModule } from "./contract.mjs";
@@ -54,14 +54,17 @@ export default defineModule({
{ key: "brand", type: "enum", options: BRAND_IDS, label: "Brand kit", default: INTRO_BRAND_DEFAULT },
{ key: "suffix", type: "text", label: "Shared suffix", default: INTRO_SUFFIX },
{ key: "projectUrl", type: "text", label: "Project URL", default: INTRO_PROJECT_URL },
+ { key: "title", type: "text", label: "Title (title-card: the project's)" },
],
docs: {
heading: "Intro",
- intro: "The brand sting (`render.intro`); the style, mark and site knobs are in [The cut](#the-cut). The brand it draws is configurable; unset, it is the Archilyzer intro, byte for byte.",
+ intro: "The brand sting (`render.intro`); the style, mark and site knobs are in [The cut](#the-cut), the words and the editor in [The intro](#the-intro-played-and-edited). The brand it draws is configurable; unset, it is the Archilyzer intro, byte for byte.",
rows: [
["`render.intro.brand`", `a brand kit id (${BRAND_IDS.join(", ")}) · default \`${INTRO_BRAND_DEFAULT}\``, "`umtool look <p> intro='{\"style\":\"boot\",\"brand\":\"archilyzer-media\"}'`"],
["`render.intro.suffix`", `the letters a site's name keeps of the brand's, 1–16 · default \`${INTRO_SUFFIX}\` (Jeralyzer swaps "Archi" for "Jera")`, "a take: `--set render.intro.suffix=lyzer`"],
["`render.intro.projectUrl`", `the project URL the swap writes beside the site's · \`false\` none · default \`${INTRO_PROJECT_URL}\``, "a take: `--set render.intro.projectUrl=false`"],
+ ["`render.intro.title`", `one line, 1–${INTRO_TITLE_MAX} · \`title-card\`: default the project's title; a boot style: drawn under the wordmark only when written`, "`umtool intro <p> title='In her own words'` (`title=` clears)"],
+ ["`render.intro.lines`", `≤ ${INTRO_LINES_MAX} lines of 1–${INTRO_LINE_MAX} · \`title-card\`: default the project's date in words (\`generatedOn\`)`, "`umtool intro <p> lines='29 October 2026|Part one'`"],
],
},
});
diff --git a/umtool/report-to-video/package.json b/umtool/report-to-video/package.json
@@ -42,6 +42,7 @@
"./cues": "./cues.mjs",
"./cut-points": "./cut-points.mjs",
"./deck": "./deck.mjs",
+ "./intro": "./intro.mjs",
"./drafts-review": "./drafts-review.mjs",
"./factcheck": "./factcheck.mjs",
"./finale": "./finale.mjs",
diff --git a/umtool/report-to-video/reel-intro.mjs b/umtool/report-to-video/reel-intro.mjs
@@ -49,7 +49,7 @@ export function reelIntroOf({ build, introSpec = null, sitesDir = undefined }) {
const entryOf = (spec, what) => {
const errors = introErrors(spec);
if (errors.length) throw new ReelIntroError(`${what}: ${errors.join("; ")}`);
- const e = introEntry({ ...build.render, intro: spec }, { provenance, ...(sitesDir ? { sitesDir } : {}) });
+ const e = introEntry({ ...build.render, intro: spec }, { provenance, manifest: build.manifest ?? null, ...(sitesDir ? { sitesDir } : {}) });
if (!e) throw new ReelIntroError(`${what}: not an intro`);
return e;
};