// The reading pin's fixtures and what it hashes (post-reading-pin.test.mjs; lane/line-rerun): imported by the // tests that hold an edit to a read to the card main drew (lib/report/screenSaidAs.test.mjs too). import { createHash } from "node:crypto"; import { postCardHtml, postItemPlan } from "./post-item.mjs"; import { drawnScreens, threadLayout } from "./post-thread.mjs"; import { followBlocks } from "./read-follow.mjs"; import { screenLineSaid } from "./post-screens.mjs"; import { draftScript } from "./post-narration.mjs"; const sha = (v) => createHash("sha1").update(typeof v === "string" ? v : JSON.stringify(v)).digest("hex"); const POST = "The council met on Tuesday about the new bridge.\n\nNobody from the ministry came to explain the delay."; const QUOTED = { id: "7002", handle: "harbourwatch", author: "Harbour Watch", text: "Bridge works paused again, the notice says.", date: "2026-10-01T09:00:00.000Z" }; const PARENT = { id: "7001", handle: "rivertalk", author: "River Talk", date: "2026-10-01T08:00:00.000Z", text: "Does anyone know why the tolls on the old crossing keep rising?\n\nA second paragraph nobody reads aloud in this cut.", }; const IMG = { src: "posts-media/bridge-x/7003/7003_1.png", kind: "image", width: 900, height: 1400 }; const DM = { id: "s1", media: 0, kind: "dm", read: "all", lines: [ { who: "rivertalk", text: "Are the tolls going up again?" }, { who: "bridgefan", text: "Not this year, they said." }, ], }; const base = (o = {}) => ({ type: "post", id: "p-7003", post: "bridge-x/7003", platform: "x", author: "Bridge Fan", handle: "bridgefan", date: "2026-10-02T10:00:00.000Z", text: POST, subjects: ["bridgefan"], ...o, }); const drafted = draftScript(POST).script; /** A single read of his words: one file, its script his words as drafted. */ export function singleItem(o = {}) { return base({ quoted: QUOTED, ...o, narration: { script: drafted, pick: 0, takes: [{ file: "narration/posts/7003/take-1.orpheus-zac.wav", engine: "orpheus", voice: "zac", seconds: 6.2, script: drafted }] }, }); } /** A thread read: the parent's first paragraph only (its tile an excerpt), the quoted post, his words, the screen's lines. */ export function threadItem(o = {}) { const e = base({ parents: [PARENT], quoted: QUOTED, thread: { parent: "excerpt" }, media: [IMG], screens: [DM], ...o }); const parts = []; let t = 0; const add = (text, role, piece, gap, more = {}) => { t += parts.length ? gap : 0; const sec = Math.round((text.split(/\s+/).length / 3) * 100) / 100; parts.push({ n: parts.length + 1, para: piece * 100 + (more.para ?? 0), text, voice: role === "post" ? "zac" : "leo", role, start: Math.round(t * 1000) / 1000, seconds: sec, ...(more.line ? { line: more.line, speaker: more.speaker } : {}) }); t += sec; }; add(draftScript(PARENT.text.split("\n\n")[0]).script, "parent:0", 0, 0); add(draftScript(QUOTED.text).script, "quoted", 1, 0.8); const [p1, p2] = drafted.split("\n\n"); add(p1, "post", 2, 0.8); add(p2, "post", 2, 0.6, { para: 1 }); DM.lines.forEach((l, n) => { const said = screenLineSaid(DM, n); add(draftScript(said).script, `screen:s1:${n}`, 3 + n, n ? 0.35 : 0.8, { line: draftScript(said).script, speaker: l.who }); }); return { ...e, narration: { script: drafted, pick: 0, takes: [{ file: "narration/posts/7003/take-1.orpheus-thread.wav", engine: "orpheus", voice: "zac+leo", seconds: Math.round(t * 1000) / 1000, script: parts.map((p) => p.text).join("\n\n"), parts, read: { kind: "thread", parents: "0" } }], }, }; } /** What the card DRAWS of an item: never what its read sounds like (no timing). */ export function drawn(e) { const render = { postNarration: { lead: 0.4 } }; const plan = postItemPlan(e, render); const box = { width: 1600, height: 900 }; const fb = followBlocks(e); return { plain: sha(postCardHtml(e, { ...box })), follow: sha(postCardHtml(e, { ...box, follow: true, thread: plan.follow?.thread ?? null })), // The blocks: their words, their scope, the screen line they are -- and whether a part reads them at all (an // excerpt tile hides the ones none does). blocks: sha(fb.blocks.map((b) => [b.k, b.scope, b.from, b.to, b.line ?? null, b.part === null])), tiles: sha(Array.isArray(e.parents) || e.quoted ? (threadLayout(e, render).tiles ?? []).map((x) => [x.scope, x.mode, x.above ?? null, x.inside ?? null]) : []), screens: sha(drawnScreens(e).map((s) => s.id)), }; } export const FIXTURES = { single: singleItem(), thread: threadItem() }; // Recorded on main (19fb842b5), before the S3 code. export const PINNED_SHAS = { single: { plain: "b2d58c132a00371da7ae824538067737551a4e3f", follow: "80b1456aff9178519d0def976396c9a4e5d61047", blocks: "6dd74f6c9ca620ed3d2ec690fd229fc848dc5a59", tiles: "b22e780f2eed98b5f9cefe21828d3600bd5af3c0", screens: "97d170e1550eee4afc0af065b78cda302a97674c", }, thread: { plain: "2bbb8717d3cad9f607463c969f5f7df622133cdf", follow: "b0574d9a6149c221f3ed675ce748c98b48f6316b", blocks: "3d085f775b916acd294b454fafde7bc770e72b85", tiles: "68c08a31d2d1eaaac527741a5e83eaf5093d1b51", screens: "2d021c30467f8a663cbd09eb672c85a6c484355a", }, };