Archilyzer · Source

archilyzer

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

commit 41679eb22f28fdd1ef2bf61206e509f9bdcb4940
parent eb5b8b2a5d5b67b532c2c8de806b3d8626a7f28a
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Mon,  2 Nov 2026 18:12:45 -0500

umtool: render a post item -- its card drawn by a browser from the archived post, its attachments laid in by ffmpeg, framed under the deck

report-to-video/post-render.mjs: buildPostSegment draws the card's page(s) (postCardHtml,
the deck's palette and faces, never a platform screenshot) with Playwright's chromium,
then one encode lays each attachment into the card's slot on the item's plan -- the
first one's first frame up while the words are read, a video from its trim with its
sound delayed to its step, a GIF looped, an image held (zoompan'd when it asks for a
push-in), a grid of images at once, a video's transcript (media[i].words) as captions
at the slot's foot -- and frames it into the deck's footage box like a clip, so the
rail, the section bars and the date ride over it. `<id>.post.json` keys the segment
(the entry, the box, the look, each file's size and mtime): an unchanged item keeps it.
postSegmentArgs is the argv, pure (post-render.test.mjs reads it).

build-video: `post` is not a clip (NON_CLIP_TYPES), is framed under the deck, has
nothing to fetch, and its chapter is its author and first words.

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

Diffstat:
Mumtool/report-to-video/build-video.mjs | 28++++++++++++++++++++++++----
Aumtool/report-to-video/post-render.mjs | 263+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aumtool/report-to-video/post-render.test.mjs | 62++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 349 insertions(+), 4 deletions(-)

diff --git a/umtool/report-to-video/build-video.mjs b/umtool/report-to-video/build-video.mjs @@ -211,6 +211,7 @@ import { } from "./cut-points.mjs"; // The snap itself (a montage's window snaps with it too), re-exported for the tests. import { snap } from "./snap.mjs"; +import { buildPostSegment } from "./post-render.mjs"; export { snap }; // The lint a build runs before it renders, and the prune after its final mux. import { lintManifest, lintManifestFile, narrationLengthErrors } from "./lint.mjs"; @@ -466,7 +467,7 @@ export function clipBaseFilters({ render, VW, VH, HH, hasHeader, attribPath, cha /** Is this entry's segment framed into the footage box under the deck (rather than full frame)? */ export function framedUnderDeck(entry, render) { - if (entry.type === "clip" || entry.type === "image") return true; + if (entry.type === "clip" || entry.type === "image" || entry.type === "post") return true; return entry.type === "card" && !hidesDeck(entry, resolveDeck(render)); } @@ -1126,7 +1127,7 @@ export function needsFetchMessage(missing) { // The timeline's vocabulary is OPEN; the build loop treats everything it has // no other branch for as a clip, and so does this. -const NON_CLIP_TYPES = new Set(["card", "teaser", "image", "scroll", "chart", "ledger", "intro"]); +const NON_CLIP_TYPES = new Set(["card", "teaser", "image", "scroll", "chart", "ledger", "intro", "post"]); const isClipEntry = (e) => !NON_CLIP_TYPES.has(e?.type); /** @@ -5523,6 +5524,11 @@ export async function chapterTitle(entry, index, provenance, { deck = false } = if (entry.type === "image") { return imageAttributionLine(entry) || `Image ${index + 1}`; } + // A post item: who posted it, and the first words. + if (entry.type === "post") { + const words = String(entry.text ?? "").replace(/^RT @[A-Za-z0-9_]+:\s*/, "").replace(/\s+/g, " ").trim(); + return `${entry.author ?? (entry.handle ? `@${entry.handle}` : "Post")}: ${words.length > 60 ? `${words.slice(0, 57)}…` : words || "(no words)"}`; + } if (entry.type !== "clip") return entry.title ?? entry.heading ?? `Card ${index + 1}`; try { const meta = await clipMeta(entry, provenance); @@ -6158,8 +6164,8 @@ export async function buildVideo({ manifestPath, opts = {}, out, only, fetchOnly // A still has nothing to fetch and is already on disk, so this is a no-op // rather than an error: a bench that walks the timeline asking for each // entry's window should not have to know which kinds have one. - if (entry?.type === "image" || entry?.type === "teaser" || (entry?.type === "clip" && hasLocalMedia(entry))) { - const what = entry.type === "image" ? "an image" : entry.type === "teaser" ? "a teaser" : "a clip with its own `src`"; + if (entry?.type === "image" || entry?.type === "teaser" || entry?.type === "post" || (entry?.type === "clip" && hasLocalMedia(entry))) { + const what = entry.type === "image" ? "an image" : entry.type === "teaser" ? "a teaser" : entry.type === "post" ? "a post item (its media is in the project)" : "a clip with its own `src`"; EMIT("note", { message: `${fetchOnly} is ${what} entry — nothing to fetch` }); EMIT("done", { out: null, nothingToFetch: true }); return { out: null, failures: [] }; @@ -6383,6 +6389,20 @@ export async function buildVideo({ manifestPath, opts = {}, out, only, fetchOnly EMIT("card", { id: entry.id, i, n: entries.length }); return buildImageSegment(entry, render, outDir, chrome, provenance, manifestDir, framing); } + if (entry.type === "post") { + // A post item (post-render.mjs): its card drawn from the archived post, its attachments laid in. + EMIT("card", { id: entry.id, i, n: entries.length }); + const fr = deck ? framing ?? segmentFraming(render) : null; + const df = fr ? deckFraming(render, { feed: fr.layout === "feed" }) : null; + const seg = await buildPostSegment(entry, { + render, outDir, manifestDir, + box: df ? { width: df.box.width, height: df.box.height } : { width: render.width, height: render.height }, + place: df ? df.place : [`fps=${render.fps}`], + encode: encodeArgs(render), exec: execFileP, ffmpeg: FFMPEG, emit: (ev, f) => EMIT(ev, f), + }); + if (fr) await writeCutRecord(seg, { version: 1, id: entry.id, framing: fr }); + return seg; + } if (entry.type === "scroll" || entry.type === "chart" || entry.type === "ledger") { EMIT("card", { id: entry.id, i, n: entries.length }); if (!manifest.ledger?.length) diff --git a/umtool/report-to-video/post-render.mjs b/umtool/report-to-video/post-render.mjs @@ -0,0 +1,263 @@ +// A POST ITEM's SEGMENT (post-item.mjs; umtool/docs/report-video.md, "Post +// items"): the card drawn by a browser from the archived post -- the deck's +// palette and faces, never a screenshot of the platform -- and its +// attachments laid into the card's slot by ffmpeg, on the item's plan +// (postItemPlan): the words read first, then each attachment in turn, a +// video with its sound, a GIF looped, an image held (pushed in on, when it +// asks). Framed into the deck's footage box like a clip, so the deck's rail, +// section bars and date stamp ride over it as over any segment. +// +// buildPostSegment(entry, ctx) render the card PNG(s), then one encode +// postSegmentArgs(...) that encode's argv, PURE (the tests read it) +// +// The card is rendered once per change: `<id>.post.json` beside the segment +// records the key (the entry, the box, the palette and faces, each +// attachment's size and mtime), and a build whose key matches keeps the +// segment it has. +import { createHash } from "node:crypto"; +import { mkdir, readFile, rename, stat, writeFile } from "node:fs/promises"; +import path from "node:path"; +import { pathToFileURL } from "node:url"; +import { POST_PUSH, postCardHtml, postItemPlan, postLayout, stepBoxes } from "./post-item.mjs"; + +const r3 = (v) => Math.round(v * 1000) / 1000; +const num = (v) => String(r3(v)); + +/** The record beside a post item's segment: what it was built from. */ +export const postRecordPath = (seg) => seg.replace(/\.mp4$/, ".post.json"); + +/** + * The cues of a video attachment's transcript (`media[i].words`: the editor's + * transcribe result, `{cues: [{start, end, text}]}` on the file's clock), or []. + */ +export async function readMediaCues(file) { + try { + const doc = JSON.parse(await readFile(file, "utf8")); + const cues = Array.isArray(doc?.cues) ? doc.cues : Array.isArray(doc) ? doc : []; + return cues + .filter((c) => c && Number.isFinite(c.start) && Number.isFinite(c.end) && typeof c.text === "string" && c.text.trim()) + .map((c) => ({ start: c.start, end: c.end, text: c.text.replace(/\s+/g, " ").trim() })); + } catch { + return []; + } +} + +/** A step's cues on the ITEM's clock: each cue inside its source span, moved to where it plays. */ +export function stepCaptions(step, cues) { + if (step?.kind !== "video" || !cues?.length) return []; + const end = step.at + step.seconds; + return cues + .filter((c) => c.end > step.srcFrom && c.start < step.srcTo) + .map((c) => ({ from: r3(Math.max(step.at, step.at + c.start - step.srcFrom)), to: r3(Math.min(end, step.at + c.end - step.srcFrom)), text: c.text })) + .filter((c) => c.to - c.from > 0.05); +} + +/** + * The encode, pure. `cards`: the read-phase PNG and (a stack layout) the + * media-phase one; `files[i]`: attachment i's absolute path; `captions`: + * `[{from, to, textfile}]` on the item's clock (drawn over the slot's foot); + * `place`: the deck's framing filters after the box (deckFraming's `place`), + * none without the deck; `encode`: build-video's encodeArgs. + * + * @returns {string[]} + */ +export function postSegmentArgs({ entry, box, plan, layout, cards, files, render, place = [], encode = [], captions = [], fontfile = null, outPath }) { + const fps = render.fps ?? 30; + const T = plan.total; + const inputs = []; + const parts = []; + const add = (args) => { + inputs.push(...args); + return inputs.filter((a) => a === "-i").length - 1; + }; + const read = add(["-loop", "1", "-framerate", String(fps), "-t", num(T), "-i", cards.read]); + parts.push(`[${read}:v]scale=${box.width}:${box.height},setsar=1,fps=${fps}[b0]`); + let cur = "b0"; + let n = 0; + const lay = (label, x, y, a, b) => { + const next = `b${++n}`; + parts.push(`[${cur}][${label}]overlay=x=${x}:y=${y}:enable='between(t,${num(a)},${num(b)})'[${next}]`); + cur = next; + }; + if (layout.mode === "stack" && cards.media && plan.steps.length) { + const mi = add(["-loop", "1", "-framerate", String(fps), "-t", num(T), "-i", cards.media]); + parts.push(`[${mi}:v]scale=${box.width}:${box.height},setsar=1,fps=${fps}[mc]`); + lay("mc", 0, 0, plan.steps[0].at, T); + } + const audio = []; + plan.steps.forEach((step, si) => { + const last = si === plan.steps.length - 1; + const until = last ? T : step.at + step.seconds; + // Beside the card, the first attachment is up from the first frame (its first frame while the words are read). + const shownFrom = si === 0 && layout.mode === "side" ? 0 : step.at; + const boxes = stepBoxes(step, layout.slot); + step.items.forEach((m, j) => { + const b = boxes[j]; + const file = files[m.i]; + const crop = Array.isArray(m.crop) ? `crop=iw*${num(m.crop[2])}:ih*${num(m.crop[3])}:iw*${num(m.crop[0])}:ih*${num(m.crop[1])},` : ""; + const label = `m${si}_${j}`; + if (step.kind === "image") { + if (m.push === true) { + const frames = Math.max(1, Math.round((until - shownFrom) * fps)); + const k = add(["-i", file]); + parts.push( + `[${k}:v]${crop}scale=${b.width * 2}:${b.height * 2},setsar=1,` + + `zoompan=z='1+${POST_PUSH}*on/${frames}':x='iw/2-(iw/zoom/2)':y='ih/2-(ih/zoom/2)':d=${frames}:s=${b.width}x${b.height}:fps=${fps},` + + `setpts=PTS-STARTPTS+${num(shownFrom)}/TB[${label}]`, + ); + } else { + const k = add(["-loop", "1", "-framerate", String(fps), "-t", num(until), "-i", file]); + parts.push(`[${k}:v]${crop}scale=${b.width}:${b.height},setsar=1,fps=${fps}[${label}]`); + } + } else { + // A video or a GIF: its span from srcFrom, its first frame held from the item's start until it plays. + const len = until - step.at; + const k = add([...(step.loop ? ["-stream_loop", "-1"] : []), "-ss", num(step.srcFrom), "-t", num(len), "-i", file]); + parts.push( + `[${k}:v]${crop}scale=${b.width}:${b.height},setsar=1,fps=${fps},setpts=PTS-STARTPTS,` + + `tpad=start_duration=${num(step.at)}:start_mode=clone:stop_mode=clone:stop_duration=${num(T)}[${label}]`, + ); + if (step.sound) { + const ms = Math.round(step.at * 1000); + const dur = Math.min(step.seconds, len); + audio.push({ label: `a${si}`, chain: `[${k}:a]aresample=${render.audioRate ?? 48000},aformat=channel_layouts=stereo,asetpts=PTS-STARTPTS,atrim=0:${num(dur)},afade=t=in:d=0.04,afade=t=out:st=${num(Math.max(0, dur - 0.06))}:d=0.06,adelay=${ms}|${ms}[a${si}]` }); + } + } + lay(label, b.x, b.y, shownFrom, until); + }); + }); + // A video attachment's words (its transcript), at the slot's foot. + if (captions.length && fontfile && layout.slot) { + const size = Math.round(34 * (box.height / 1080)); + const y = Math.round(layout.slot.y + layout.slot.height - size * 2.2); + const cx = Math.round(layout.slot.x + layout.slot.width / 2); + for (const c of captions) { + const next = `b${++n}`; + parts.push( + `[${cur}]drawtext=fontfile='${fontfile}':textfile='${c.textfile}':fontsize=${size}:fontcolor=white:box=1:boxcolor=black@0.62:boxborderw=${Math.round(size * 0.35)}:` + + `x=${cx}-text_w/2:y=${y}:enable='between(t,${num(c.from)},${num(c.to)})'[${next}]`, + ); + cur = next; + } + } + parts.push(`[${cur}]format=yuv420p${place.length ? `,${place.join(",")}` : ",setsar=1"}[v]`); + const sil = add(["-f", "lavfi", "-t", num(T), "-i", `anullsrc=channel_layout=stereo:sample_rate=${render.audioRate ?? 48000}`]); + if (audio.length) { + parts.push(...audio.map((a) => a.chain)); + parts.push(`[${sil}:a]${audio.map((a) => `[${a.label}]`).join("")}amix=inputs=${audio.length + 1}:normalize=0:duration=first[a]`); + } else parts.push(`[${sil}:a]anull[a]`); + return [ + "-nostdin", "-v", "error", "-y", + ...inputs, + "-filter_complex", parts.join(";"), + "-map", "[v]", "-map", "[a]", + ...encode, + "-t", num(T), + outPath, + ]; +} + +async function loadChromium() { + let mod; + try { + mod = await import("@playwright/test"); + } catch (err) { + throw new Error(`a post item's card is drawn by a browser, and Playwright is not available here (it ships with umtool): ${err.message}`); + } + const chromium = mod.chromium ?? mod.default?.chromium; + if (!chromium) throw new Error("Playwright loaded but has no chromium export"); + return chromium; +} + +/** + * Draw the card's pages as PNGs, `box` px each: `read` always, `media` for a + * stack layout. The page is a file beside them, so its faces and the parent + * shot load from disk (an about:blank page may not read file: urls). + */ +export async function renderPostCards(entry, { box, render, dir, manifestDir, layout }) { + await mkdir(dir, { recursive: true }); + const fonts = { + regular: render.fontRegular ? pathToFileURL(render.fontRegular).href : "", + bold: render.fontBold ? pathToFileURL(render.fontBold).href : "", + }; + const parentShotUrl = typeof entry.parentShot === "string" ? pathToFileURL(path.resolve(manifestDir, entry.parentShot)).href : null; + const phases = layout.mode === "stack" ? ["read", "media"] : ["read"]; + const chromium = await loadChromium(); + const browser = await chromium.launch({ headless: true }); + const out = {}; + try { + const ctx = await browser.newContext({ viewport: { width: box.width, height: box.height }, deviceScaleFactor: 1, offline: true, serviceWorkers: "block" }); + const page = await ctx.newPage(); + for (const phase of phases) { + const html = postCardHtml(entry, { width: box.width, height: box.height, palette: render.palette, fonts, phase, parentShotUrl }); + const file = path.join(dir, `${phase}.html`); + await writeFile(file, html, "utf8"); + await page.goto(pathToFileURL(file).href, { waitUntil: "load" }); + await page.waitForSelector("body[data-post-ready='1']", { timeout: 15000 }); + const png = path.join(dir, `${phase}.png`); + await page.screenshot({ path: png, clip: { x: 0, y: 0, width: box.width, height: box.height } }); + out[phase] = png; + } + await ctx.close(); + } finally { + await browser.close(); + } + return out; +} + +/** + * Build post item `entry`'s segment. `ctx`: `{ render, outDir, manifestDir, + * box, place, encode, exec, ffmpeg, emit }` -- the box it fills (the deck's + * footage box, or the frame), the deck's framing after it, build-video's + * encode args and ffmpeg runner. Returns the segment's path. + */ +export async function buildPostSegment(entry, { render, outDir, manifestDir, box, place = [], encode = [], exec, ffmpeg = "ffmpeg", emit = () => {} }) { + const seg = path.join(outDir, "segments", `${entry.id}.mp4`); + const plan = postItemPlan(entry); + const layout = postLayout(entry, box); + const files = (entry.media ?? []).map((m) => path.resolve(manifestDir, m.src)); + for (const [i, f] of files.entries()) { + if (!(await stat(f).catch(() => null))) throw new Error(`${entry.id}: media[${i}] is not on disk: ${f} (src: ${entry.media[i].src})`); + } + const wordFiles = (entry.media ?? []).map((m) => (typeof m.words === "string" ? path.resolve(manifestDir, m.words) : null)); + const stamps = await Promise.all([...files, ...wordFiles.filter(Boolean), ...(entry.parentShot ? [path.resolve(manifestDir, entry.parentShot)] : [])].map(async (f) => { + const st = await stat(f).catch(() => null); + return st ? `${f}:${st.size}:${Math.round(st.mtimeMs)}` : `${f}:-`; + })); + const key = createHash("sha256") + .update(JSON.stringify({ v: 1, entry, box, place, palette: render.palette, fonts: [render.fontRegular, render.fontBold], fps: render.fps, encode, stamps })) + .digest("hex"); + const record = postRecordPath(seg); + const had = await readFile(record, "utf8").then((t) => JSON.parse(t), () => null); + if (had?.key === key && (await stat(seg).catch(() => null))) { + emit("note", { message: `${entry.id}: post item unchanged — its segment kept` }); + return seg; + } + const cardDir = path.join(outDir, "cards", `post-${entry.id}`); + const cards = await renderPostCards(entry, { box, render, dir: cardDir, manifestDir, layout }); + // Its video attachments' words, when transcribed: one textfile per cue. + const captions = []; + for (const [si, step] of plan.steps.entries()) { + if (step.kind !== "video") continue; + const m = step.items[0]; + const wf = wordFiles[m.i]; + if (!wf) continue; + for (const [ci, c] of stepCaptions(step, await readMediaCues(wf)).entries()) { + const textfile = path.join(cardDir, `cue-${si}-${ci}.txt`); + await writeFile(textfile, c.text, "utf8"); + captions.push({ ...c, textfile }); + } + } + const tmp = seg.replace(/\.mp4$/, ".post-tmp.mp4"); + const argv = postSegmentArgs({ entry, box, plan, layout, cards, files, render, place, encode, captions, fontfile: render.fontBold ?? render.fontRegular ?? null, outPath: tmp }); + try { + await exec(ffmpeg, argv, { maxBuffer: 1 << 24 }); + } catch (err) { + const detail = String(err?.stderr ?? "").trim() || err?.message || String(err); + throw new Error(`${entry.id}: ffmpeg failed on the post item\n${detail}`); + } + await rename(tmp, seg); + await writeFile(record, JSON.stringify({ version: 1, id: entry.id, key, layout: layout.mode, total: plan.total, steps: plan.steps.length }, null, 2) + "\n", "utf8"); + emit("note", { message: `${entry.id}: post item ${plan.total.toFixed(1)} s (${layout.mode}: ${plan.reading.toFixed(1)} s to read${plan.steps.length ? `, ${plan.steps.length} attachment step(s)` : ""})` }); + return seg; +} diff --git a/umtool/report-to-video/post-render.test.mjs b/umtool/report-to-video/post-render.test.mjs @@ -0,0 +1,62 @@ +// post-render.mjs: a post item's encode, read as argv (no encoder runs here). +import assert from "node:assert/strict"; +import { test } from "node:test"; +import { postItemPlan, postLayout } from "./post-item.mjs"; +import { postSegmentArgs, stepCaptions } from "./post-render.mjs"; + +const render = { fps: 30, audioRate: 48000 }; +const box = { width: 1440, height: 810 }; +const entry = (o = {}) => ({ + type: "post", id: "p1", post: "c-x/1", platform: "x", author: "A", handle: "a", date: "2026-10-30T04:00:00Z", text: "six words of a short post", + media: [ + { src: "m/v.mp4", kind: "video", seconds: 6, width: 1920, height: 1080, audio: true, start: 1, end: 4 }, + { src: "m/i.jpg", kind: "image", width: 1000, height: 1000 }, + ], + ...o, +}); +const argsOf = (e) => { + const plan = postItemPlan(e); + const layout = postLayout(e, box); + const argv = postSegmentArgs({ + entry: e, box, plan, layout, cards: { read: "/c/read.png", media: "/c/media.png" }, files: ["/m/v.mp4", "/m/i.jpg"], render, + place: ["pad=1920:1080:240:10:color=#000", "setsar=1", "fps=30"], encode: ["-c:v", "libx264"], outPath: "/o/p1.mp4", + }); + return { plan, layout, argv, graph: argv[argv.indexOf("-filter_complex") + 1] }; +}; + +test("the render plan: the card, the video from its trim with its sound delayed to its step, the image after it, the deck's framing", () => { + const { plan, argv, graph } = argsOf(entry()); + assert.equal(plan.total, 3 + 3 + 3.5); + // The card for the whole item, the video's trimmed span, the image held to the end, silence under all. + assert.deepEqual(argv.slice(argv.indexOf("-i") - 6, argv.indexOf("-i") + 2), ["-loop", "1", "-framerate", "30", "-t", "9.5", "-i", "/c/read.png"]); + const v = argv.indexOf("/m/v.mp4"); + assert.deepEqual(argv.slice(v - 5, v + 1), ["-ss", "1", "-t", "3", "-i", "/m/v.mp4"]); + assert.ok(argv.includes("/m/i.jpg")); + // Beside the card, the video's first frame is up while the words are read; it plays at 3 s. + assert.match(graph, /tpad=start_duration=3:start_mode=clone/); + assert.match(graph, /overlay=x=\d+:y=\d+:enable='between\(t,0,6\)'/); + assert.match(graph, /overlay=x=\d+:y=\d+:enable='between\(t,6,9.5\)'/); + // Its sound from the step's start, mixed over the silence. + assert.match(graph, /adelay=3000\|3000\[a0\]/); + assert.match(graph, /amix=inputs=2:normalize=0:duration=first\[a\]/); + assert.match(graph, /pad=1920:1080:240:10:color=#000,setsar=1,fps=30\[v\];/); + assert.deepEqual(argv.slice(-3), ["-t", "9.5", "/o/p1.mp4"]); +}); + +test("a muted video plays silent; a text-only post is the card alone; a stack lays the media page over the card when the media starts", () => { + const muted = argsOf(entry({ media: [{ src: "m/v.mp4", kind: "video", seconds: 6, width: 1920, height: 1080, mute: true }] })); + assert.match(muted.graph, /\[\d+:a\]anull\[a\]/); + const text = argsOf(entry({ media: undefined })); + assert.equal(text.argv.filter((a) => a === "-i").length, 2); // the card and the silence + const long = Array.from({ length: 480 }, () => "word").join(" "); + const stack = argsOf(entry({ text: long })); + assert.equal(stack.layout.mode, "stack"); + assert.ok(stack.argv.includes("/c/media.png")); + assert.match(stack.graph, new RegExp(`\\[mc\\]overlay=x=0:y=0:enable='between\\(t,${stack.plan.reading},`)); +}); + +test("a video attachment's transcript, on the item's clock", () => { + const plan = postItemPlan(entry()); + const caps = stepCaptions(plan.steps[0], [{ start: 0, end: 1.5, text: "before" }, { start: 1.5, end: 2.5, text: "said" }, { start: 5, end: 6, text: "after" }]); + assert.deepEqual(caps.map((c) => [c.text, c.from, c.to]), [["before", 3, 3.5], ["said", 3.5, 4.5]]); +});