Archilyzer · Source

archilyzer

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

commit e9ae127bf33b0bf12e2bce4f1f097301204c1396
parent 5abf0009900ad6d3017a90d7a0aa7fd85a8d0b4c
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Wed,  4 Nov 2026 17:26:35 -0500

umtool: a join opens EXACTLY as the item before ended and dissolves from there -- that item's card stays whole on top until this one is in under it (never gone at the second frame: main's carried post switched at frame 1 and its counts, quote and clock vanished at once, mid-7 at 2357 s); its shot is its last frame whole (its clock placed as its segment placed it, its parent's shot, a visit's pointer); the carried post after a plain card draws its head at the card's size and its words a card's gap below (main's sat 12-18 px lower); this item's clock carries on from that one's when near, else that one dissolves in its shot and this one comes in -- never moved across the card's words; Play the same (its join frame at its last state with its clock, the same-content rule, the clock over the join); a joined segment's key carries jv and the clock the item before ran, an item with no join keeps its key (operator, 4 Nov: "If one post is visible in the next scene, there should be a transition")

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

Diffstat:
Mumtool/app/api/report/post-item/route.ts | 12++++++++----
Mumtool/components/projects/review/PlayCut.tsx | 2+-
Mumtool/components/projects/review/PostItemPlayer.tsx | 66+++++++++++++++++++++++++++++++++++++++++++++++++++---------------
Mumtool/docs/report-video.md | 41++++++++++++++++++++++++++++++++---------
Mumtool/report-to-video/post-item.mjs | 7+++++--
Aumtool/report-to-video/post-join-continuity.test.mjs | 90+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mumtool/report-to-video/post-join.mjs | 63++++++++++++++++++++++++++++++++++++++++++++++++++-------------
Mumtool/report-to-video/post-render.mjs | 120++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----------------
8 files changed, 332 insertions(+), 69 deletions(-)

diff --git a/umtool/app/api/report/post-item/route.ts b/umtool/app/api/report/post-item/route.ts @@ -63,12 +63,16 @@ async function itemOf(project: { dir: string }, manifest: Record<string, unknown return { item: at >= 0 ? tl[at] : null, prev: ctx.prev, ctx, prevCtx, manifest: m }; } -/** The size the item before draws its post's words at (post-item.mjs cardWordsSize; threaded when its plan is). */ -function joinWordsSize(prev: Entry, prevCtx: Record<string, unknown> | null, render: Record<string, unknown>, box: { width: number; height: number }) { +/** + * How the item before draws its post: its words' size (post-item.mjs cardWordsSize; threaded when its plan is) and + * whether its card is PLAIN (no thread: its head the card's, the carried post drawn with it -- the build's measure). + */ +function joinCarry(prev: Entry, prevCtx: Record<string, unknown> | null, render: Record<string, unknown>, box: { width: number; height: number }) { const pe = panelEntry(prev, render) as Entry; const follow = followKnobs(pe, render).on; const plan = postItemPlan(pe, render, (prevCtx ?? {}) as never) as { follow?: { thread?: unknown } }; - return cardWordsSize(pe, box, { follow, threaded: follow && !!plan.follow?.thread }); + const threaded = follow && !!plan.follow?.thread; + return { size: cardWordsSize(pe, box, { follow, threaded }), plain: !threaded }; } /** A project file under posts-media/, never outside it (its real path checked). */ @@ -221,7 +225,7 @@ export async function GET(request: Request) { thread: followOn ? (scene ? sceneLayout(isNarrated(item) ? tlayout : null, item, scene) ?? tlayout : tlayout) : null, redaction, // THE JOIN (post-join.mjs): the post the item before ended on drawn as it drew its post (Play lays the morph). - join: followOn && found.ctx.join && found.prev?.type === "post" ? { size: joinWordsSize(found.prev as Entry, found.prevCtx, cutRender, { width: w, height: h }) } : null, + join: followOn && found.ctx.join && found.prev?.type === "post" ? joinCarry(found.prev as Entry, found.prevCtx, cutRender, { width: w, height: h }) : null, }); return new Response(html, { headers: { "content-type": "text/html; charset=utf-8", ...noStore } }); } diff --git a/umtool/components/projects/review/PlayCut.tsx b/umtool/components/projects/review/PlayCut.tsx @@ -863,7 +863,7 @@ export default function PlayCut({ joinFrom={(() => { // THE JOIN (post-join.mjs): the item before, so this one opens on it as it ended. const before = ui.cur > 0 ? entryOf.get(plan.items[ui.cur - 1]?.id ?? "") : null; - return postNow.entry.postPlan?.follow?.join && before?.type === "post" && before.post && before.postPlan ? { entry: before.post, plan: before.postPlan } : null; + return postNow.entry.postPlan?.follow?.join && before?.type === "post" && before.post && before.postPlan ? { entry: before.post, plan: before.postPlan, clock: before.postClock ?? null } : null; })()} /> ) : null; diff --git a/umtool/components/projects/review/PostItemPlayer.tsx b/umtool/components/projects/review/PostItemPlayer.tsx @@ -2,7 +2,7 @@ import { useCallback, useEffect, useMemo, useRef, useState } from "react"; import { POST_PUSH, mediaTimeAt, postLayout, stepAt, stepBoxes } from "umtool-report-to-video/post-item"; -import { applyJoinState, endMediaOf, joinFrameAt } from "umtool-report-to-video/post-join"; +import { applyJoinState, endMediaOf, joinClockOf, joinEase, joinFrameAt } from "umtool-report-to-video/post-join"; import { applyVisitState } from "umtool-report-to-video/post-link-visit"; import { applyMapState, mapHtml, mapPlace, mapSize } from "umtool-report-to-video/post-branch-map"; import { dryGainAt, mixPhaseAt, pickedTake, wetGainAt } from "umtool-report-to-video/post-narration"; @@ -427,6 +427,9 @@ function JoinEnds({ project, ends, layout, box, op }: { project: string; ends: A ); } +/** A clock's plan (post-clock.mjs clockPlan). */ +type ClockPlan = { to: number; from: number | null; mode: "forward" | "rewind" | "none"; zone: string; gap: number; forced: boolean }; + export default function PostItemPlayer({ project, take = null, entry, plan, box, s, playing, cardKey = null, speed = 1, published = false, uncensored = false, scene = null, clock = null, joinFrom = null, }: { @@ -449,9 +452,9 @@ export default function PostItemPlayer({ /** Its media scene (post-media-scene.mjs): which, and its place in it. */ scene?: { key: string; n: number; of: number } | null; /** Its clock (post-clock.mjs clockPlan, from the item before it), or none. */ - clock?: { to: number; from: number | null; mode: "forward" | "rewind" | "none"; zone: string; gap: number; forced: boolean } | null; - /** THE JOIN (post-join.mjs): the item before (its entry and plan) -- this one opens on it as it ended. */ - joinFrom?: { entry: Record<string, unknown> & { id: string }; plan: PostPlan } | null; + clock?: ClockPlan | null; + /** THE JOIN (post-join.mjs): the item before (its entry, plan and clock) -- this one opens on it as it ended. */ + joinFrom?: { entry: Record<string, unknown> & { id: string }; plan: PostPlan; clock?: ClockPlan | null } | null; }) { const wrap = useRef<HTMLDivElement | null>(null); const [scale, setScale] = useState(0); @@ -520,10 +523,12 @@ export default function PostItemPlayer({ const readFrame = useRef<HTMLIFrameElement | null>(null); // ---- THE JOIN, live (post-join.mjs): the item before's page in a frame of its own, at its last frame's state ---- const joinFrame = useRef<HTMLIFrameElement | null>(null); - const joinMeasure = useRef<{ A: Rect; anchor: number | null; slotA: Rect | null } | null>(null); + const joinMeasure = useRef<{ A: Rect; anchor: number | null; slotA: Rect | null; clock: { x: number; y: number; st: ReturnType<typeof clockStateAt> } | null } | null>(null); const [joinReady, setJoinReady] = useState(0); const joinSecs = plan.follow?.join?.seconds ?? 0; const joinOn = !!joinFrom && joinSecs > 0; + // It carries the post the item before ended on (post-thread.mjs: a carried parent, or the scene's post). + const carries = !!(plan.follow?.thread as { tiles?: Array<{ mode?: string; wasPost?: boolean }> } | undefined)?.tiles?.some((t) => t.mode === "carry" || (t.mode === "scene" && t.wasPost)); const onJoinLoad = useCallback(() => { let tries = 0; const tick = () => { @@ -533,16 +538,32 @@ export default function PostItemPlayer({ return; } const pf = joinFrom.plan.follow ?? null; - if (pf && doc.querySelector("[data-post-flow]")) { - const g = measureFollow(doc); - applyFollowState(followStateAt(pf, g ? followPath(pf, g) : null, Math.max(0, joinFrom.plan.total - 1 / 30)), doc); + const endS = Math.max(0, joinFrom.plan.total - 1 / 30); + const pl = postLayout(joinFrom.entry, box); + const route = pf && doc.querySelector("[data-post-flow]") ? followPath(pf, measureFollow(doc)) : null; + // ITS CLOCK as it ended (post-clock.mjs), placed as Play places this item's: the card at its read's end -- + // laid on its card when this item's does not carry on from it (joinClockOf), as the build's shot is. + const pc = joinFrom.clock && !(pl.mode === "stack" && joinFrom.plan.steps.length) ? joinFrom.clock : null; + let jclock: { x: number; y: number; st: ReturnType<typeof clockStateAt> } | null = null; + if (pc) { + const face = clockFace(pc.to, pc.zone); + const size = mountClock({ css: clockCss({ height: box.height, palette: paletteOfDoc(doc) }), html: clockHtml(), widest: { time: "12:58 PM", zone: face.zone, date: "Wed 30 Sep" } }, doc); + if (pf && route) applyFollowState(followStateAt(pf, route, joinFrom.plan.total), doc); + const at = size ? measureClockPlace({ size, inset: Math.round(22 * (box.height / 1080)) }, doc) : null; + if (at) jclock = { x: at.x, y: at.y, st: clockStateAt(pc, endS) }; + } + if (pf && route) { + const st = followStateAt(pf, route, endS); + applyFollowState(st, doc); + // A link visit's pointer, as it ended. + const visits = (pf as unknown as { visits?: unknown[] }).visits; + if (visits?.length) applyVisitState({ visits, st: st.visit ?? null }, doc); } const card = doc.querySelector("[data-post-card]"); if (!card) return; const c = card.getBoundingClientRect(); const post = doc.querySelector('[data-thread-slot="post"] .head') ?? card.querySelector(".head"); - const pl = postLayout(joinFrom.entry, box); - joinMeasure.current = { A: { x: c.left, y: c.top, width: c.width, height: c.height }, anchor: post ? post.getBoundingClientRect().top - c.top : null, slotA: pl.slot && pl.mode === "side" ? pl.slot : null }; + joinMeasure.current = { A: { x: c.left, y: c.top, width: c.width, height: c.height }, anchor: post ? post.getBoundingClientRect().top - c.top : null, slotA: pl.slot && pl.mode === "side" ? pl.slot : null, clock: jclock }; setJoinReady((n) => n + 1); }; tick(); @@ -709,13 +730,24 @@ export default function PostItemPlayer({ const jm = joinMeasure.current; if (!doc?.body || !jm) return; if (!doc.body.getAttribute("data-join")) { - doc.body.setAttribute("data-join", JSON.stringify({ A: jm.A, slotA: jm.slotA, slotB: layout.slot && layout.mode === "side" ? layout.slot : null, same: false })); const c = doc.querySelector("[data-post-card]")?.getBoundingClientRect(); + // The same content (the build's rule): the same width, the post it ended on carried in. + const same = !!c && Math.abs(jm.A.width - c.width) < 2 && carries; + doc.body.setAttribute("data-join", JSON.stringify({ A: jm.A, slotA: jm.slotA, slotB: layout.slot && layout.mode === "side" ? layout.slot : null, same })); if (c) setOwnBox({ x: c.left, y: c.top, width: c.width, height: c.height }); } applyJoinState(jp, doc); - }, [jp, joinReady, layout]); - const jframe = jp !== null && joinMeasure.current && ownBox ? joinFrameAt({ A: joinMeasure.current.A, B: ownBox, slotA: joinMeasure.current.slotA, slotB: layout.slot && layout.mode === "side" ? layout.slot : null, same: false }, jp) : null; + }, [jp, joinReady, layout, carries]); + const jframe = jp !== null && joinMeasure.current && ownBox ? joinFrameAt({ A: joinMeasure.current.A, B: ownBox, slotA: joinMeasure.current.slotA, slotB: layout.slot && layout.mode === "side" ? layout.slot : null, same: Math.abs(joinMeasure.current.A.width - ownBox.width) < 2 && carries }, jp) : null; + // THE CLOCK OVER THE JOIN (post-join.mjs joinClockOf): carried on from the item before's (moved the little way), + // or that one on its card as it ended, dissolving with it, and this one coming in. + const joinClock = useMemo(() => (joinOn && joinReady && joinMeasure.current ? joinClockOf({ from: joinMeasure.current.clock, own: clock ? clockAt : null, k: box.height / 1080 }) : null), [joinOn, joinReady, clock, clockAt, box.height]); + useEffect(() => { + const doc = joinFrame.current?.contentDocument; + const jm = joinMeasure.current; + if (!doc || !jm) return; + setClockState(joinClock?.bake && jm.clock?.st ? { x: jm.clock.x, y: jm.clock.y, st: jm.clock.st } : null, doc); + }, [joinClock, joinReady]); // THE BRANCH MAP (post-branch-map.mjs): its own layer over the attachments, where the build lays it. const branchMap = (follow?.thread as { map?: Record<string, unknown> } | undefined)?.map ?? null; const mapRef = useRef<HTMLDivElement | null>(null); @@ -761,8 +793,12 @@ export default function PostItemPlayer({ const doc = readFrame.current?.contentDocument; if (!doc) return; const until = layout.mode === "stack" && plan.steps.length ? plan.steps[0].at : Infinity; - setClockState(clockSt && clockAt && s < until ? { ...clockAt, st: clockSt } : null, doc); - }, [clockSt, clockAt, s, layout.mode, plan.steps]); + // Over the join: from the item before's place (eased as the card is), or coming in (as the build's fade). + const jc = joinClock && s < joinSecs ? joinClock : null; + const left = jc?.move ? 1 - joinEase(s / joinSecs) : 0; + const at = clockAt && jc?.move ? { x: clockAt.x + jc.move.dx * left, y: clockAt.y + jc.move.dy * left } : clockAt; + setClockState(clockSt && at && s < until ? { ...at, st: clockSt, ...(jc?.fadeIn ? { opacity: Math.max(0, s / joinSecs) } : {}) } : null, doc); + }, [clockSt, clockAt, s, layout.mode, plan.steps, joinClock, joinSecs]); const src = shown && inStep ? mediaTimeAt(shown, s) : null; const cue = wordsRel && src !== null ? (cues[wordsRel] ?? []).find((c) => src >= c.start && src < c.end) ?? null : null; return ( diff --git a/umtool/docs/report-video.md b/umtool/docs/report-video.md @@ -1036,16 +1036,39 @@ Kirsche 17:45, his reply 19:03). A tile that does not answer the one drawn just **The join** (`report-to-video/post-join.mjs`; "I'd like a thread-like smooth transition here rather than a cut"). An item of a conversation run (or a manual thread) opens on the item before AS IT ENDED and morphs into its own -layout over its first `seconds` (0.6; the same content at the same width -- a carried post drawn alike -- switches -at the first frame, never a double image) -- a card beside an attachment to a card alone, another attachment, another +layout over its first `seconds` (0.6) -- a card beside an attachment to a card alone, another attachment, another width: the card's container eases from that item's box to its own (the words scaled with it, never re-flowed), that -item's card -- shot at its last frame in the build, its page in a second frame in Play -- rides the container and -fades as this one's comes in, the post it ended on (carried in, or the scene's) is drawn as that item drew its post -(its head, its words at their size) and framed where it sat (the anchor measured on both pages), the slot's well -fades in or out, and the attachment it ended on (its last frame) cross-fades into this one's -- the same one (a media -scene) is held. The read starts AFTER the join (`narrationSchedule`'s `pre`): an item in a run is the join longer. -`render.posts.join = { on, seconds }`; an item's `join: false` cuts. The build shoots the whole box while it joins -(the card and the slot's well move); `readInViewErrors` checks every read from its settle, after the join. +item's card -- shot at its last frame in the build, its page in a second frame in Play -- rides the container ON TOP +and dissolves into this one's, which is whole under it before it starts to go (`joinOpacities`: what both draw never +dims; the same content at the same width -- a carried post drawn alike -- is this card's from the first frame), the +post it ended on (carried in, or the scene's) is drawn as that item drew its post (its head -- a plain card's head at +the card's size, not the words' -- its words at their size and gap) and framed where it sat (the anchor measured on +both pages), the slot's well fades in or out, and the attachment it ended on (its last frame) cross-fades into this +one's -- the same one (a media scene) is held. The read starts AFTER the join (`narrationSchedule`'s `pre`): an item +in a run is the join longer. `render.posts.join = { on, seconds }`; an item's `join: false` cuts. The build shoots the +whole box while it joins (the card and the slot's well move); `readInViewErrors` checks every read from its settle, +after the join. + +**The join opens EXACTLY on the item before's last frame** (operator, 4 Nov, on mid-7 at 2357 s: "the transition from +some posts hard cutting into the same post with children should be addressed. If one post is visible in the next +scene, there should be a transition"). Its shot is that item's page in its read-follow's LAST state, with what its +segment lays over the card: its parent's shot, a link visit's pointer, and its CLOCK, placed as its own segment placed +it. The clock (`joinClockOf`): within 24 px (at 1080) of where this item's sits, this one opens there and moves the +little way with the card; further apart a move would cross the card's words, so the item before's is laid in its shot +(dissolving with it) and this one comes in over the join; none before, this one comes in; none now, that one dissolves. +Before this, a carried post switched to this card at the second frame and everything only the item before drew -- its +counts, its quote, its clock -- vanished at once, and the carried head (the words' size, not a card's) moved the words +down 12-18 px. A joined segment's key carries `jv` (the join's drawing, `POST_JOIN_DRAW_V`) and the clock the item +before ran, so a changed join rebuilds; an item with no join keeps its key. + +**Checking it** (`umtool check-joins <project> --take <id> [--json] [--all] [--limit <n>]`, +`report-to-video/check-joins.mjs`, read-only): every boundary of a rendered take's master where the next post item +draws a post the one before showed (its post, a parent, the quote, a linked post, a scene tile), its relation +(self-reply, reply to it, quotes it, manual thread, same thread…), its planned join, the SSIM of the last frame before +against the first after over the post box (the deck strip left out), and the largest frame-to-frame step across it and +its join -- worst first; `JUMPS` is a planned join whose frames still jump (SSIM < 0.97, or one frame-to-frame step 3 above its neighbours). The boundary is +found where the concat put it: the segments' file lengths as the concat demuxer reads them (a file's longest stream: +an audio a few ms longer than its video moves every later segment -- 0.33 s by the end of mid-7), not the schedule's. **A manual thread** (`thread.group`; "basically do all of them chronologically as if a thread, maybe subtly indicate the original relations"). Consecutive items with the same `thread.group` are one run even when X does not link them diff --git a/umtool/report-to-video/post-item.mjs b/umtool/report-to-video/post-item.mjs @@ -970,7 +970,7 @@ export function nameHtml(who, { redact, cls = "" }) { * highlight?: { scope: string, from: number, to: number, color: string } | null, * redaction?: { terms: Array<{term: string, wholeWord?: boolean}>, markup?: Record<string, any> } | null, follow?: boolean, * thread?: { tiles?: Array<{ scope: string, mode: string }> } | null, - * join?: { A?: { x: number, y: number, width: number, height: number }, slotA?: Record<string, number> | null, fromUrl?: string | null, size?: number | null, same?: boolean } | null }} o + * join?: { A?: { x: number, y: number, width: number, height: number }, slotA?: Record<string, number> | null, fromUrl?: string | null, size?: number | null, same?: boolean, plain?: boolean } | null }} o */ export function postCardHtml(entry, { width, height, palette = {}, fonts = {}, phase = "read", parentShotUrl = null, transparent = false, avatars = {}, highlight = null, redaction = null, follow = false, thread = null, join = null }) { const hlOf = (scope) => (highlight && highlight.scope === scope ? highlight : null); @@ -1072,10 +1072,11 @@ export function postCardHtml(entry, { width, height, palette = {}, fonts = {}, p // THE JOIN (post-join.mjs): the post the item before ended on -- carried in, or the scene's -- drawn as that item // drew its post (its head, its words at their size), so the item opens on it exactly as it ended. const asPost = (scope, p, r, attr, mode, slotAttr = "") => { + // A PLAIN card before (no thread): its head is the card's (not the words' size) and its words a card's gap below. const sz = fin(join?.size) ? join.size : sizeFor(contextText(p) || " ", innerW, innerH - 170 * k); const own2 = { author: p.author, handle: p.handle }; const headP = `<div class="head"${r ? ' data-redacted=""' : ""}>${avatarHtml(own2, { redact: r, size: Math.round(64 * k), accent: r ? undefined : pal.accent, img: r ? null : pic(p) })}<div class="hwho">${nameHtml(own2, { redact: r, cls: "big" })}<div class="date">${esc(cardDate(p.date))}</div></div><div class="mark">${esc(PLATFORM_NAME[entry.platform] ?? "")}</div></div>`; - tileHtml.push(`<div class="tslot" data-thread-slot="${esc(scope)}"${slotAttr}><div class="tile tpost tcarry" data-thread-tile="${esc(scope)}" data-thread-mode="${mode}" ${attr} data-join-anchor="">${relationHtml(t0(scope))}${headP}<div class="twords" style="font-size:${sz}px">${wordsHtml(contextText(p), r && p.handle ? [...blurred, p.handle] : blurred)}</div></div></div>`); + tileHtml.push(`<div class="tslot" data-thread-slot="${esc(scope)}"${slotAttr}><div class="tile tpost tcarry${join?.plain ? " tplain" : ""}" data-thread-tile="${esc(scope)}" data-thread-mode="${mode}" ${attr} data-join-anchor="">${relationHtml(t0(scope))}${headP}<div class="twords" style="font-size:${sz}px">${wordsHtml(contextText(p), r && p.handle ? [...blurred, p.handle] : blurred)}</div></div></div>`); }; const refTile = (scope, p, where, attr) => { const mode = tmode(scope); @@ -1207,6 +1208,8 @@ b, .name, .mark { font-family: 'PostSansBold', sans-serif; font-weight: 400; } .tparent { display: flex; gap: ${Math.round(16 * k)}px; position: relative; } .tparent::after { content: ""; position: absolute; left: ${Math.round(27 * k)}px; top: ${Math.round(64 * k)}px; bottom: -${Math.round(20 * k)}px; width: 2px; background: ${line}; } .tpost { display: flex; flex-direction: column; gap: ${Math.round(16 * k)}px; } +.tplain { gap: ${Math.round(18 * k)}px; } +.tplain > .head { font-size: 16px; line-height: normal; } ${tiles?.some((t) => t?.rel) ? `.rel { color: ${pal.muted}; font-size: ${Math.round(18 * k)}px; margin-bottom: ${Math.round(4 * k)}px; letter-spacing: 0.01em; } .rel::before { content: "\\21b3 "; } ` : ""}.tile .tt { display: block; -webkit-line-clamp: none; overflow: visible; line-height: ${LINE}; color: ${pal.fg}; margin-top: ${Math.round(6 * k)}px; } diff --git a/umtool/report-to-video/post-join-continuity.test.mjs b/umtool/report-to-video/post-join-continuity.test.mjs @@ -0,0 +1,90 @@ +// THE JOIN's continuity (operator, 4 Nov, on mid-7 at 2357 s: "the transition from some posts hard cutting into the +// same post with children should be addressed. If one post is visible in the next scene, there should be a +// transition"): the item opens EXACTLY as the item before ended -- its card, what only it drew (its counts, its quote, +// its clock) dissolving rather than gone at the second frame -- and the check that measures it (check-joins.mjs). +import assert from "node:assert/strict"; +import { test } from "node:test"; + +import { JOIN_CLOCK_NEAR, joinClockOf, joinFrameAt, joinOpacities } from "./post-join.mjs"; +import { clockJoinExpr, postSegmentArgs, postSegmentKey, postSegmentKeyOf, POST_JOIN_DRAW_V } from "./post-render.mjs"; +import { postCardHtml, postItemPlan } from "./post-item.mjs"; +import { planContext } from "./post-conversation.mjs"; + +const at = (h) => `2026-11-04T${String(h).padStart(2, "0")}:00:00.000Z`; +const narrate = (e, parts) => ({ ...e, narration: { takes: [{ file: `narration/${e.id}.wav`, seconds: 6, parts: parts.map((p) => ({ text: p.join(" ") })) }], picked: 0 } }); +const post = (id, text, h, extra = {}) => ({ type: "post", id: `p-${id}`, post: `ObviousRises-x/${id}`, platform: "x", author: "MR. OBVIOUS", handle: "ObviousRises", date: at(h), text, url: `https://x.com/ObviousRises/status/${id}`, ...extra }); +const ref = (id, text, h) => ({ id, author: "MR. OBVIOUS", handle: "ObviousRises", date: at(h), text }); + +test("THE DISSOLVE: at the boundary the item before's card is whole and on top; this one is in under it before it starts to go; what both draw never dims", () => { + // The first frames (e ~ 0): the item before, exactly. + assert.deepEqual(joinOpacities(0, true), { own: 1, from: 1 }); + assert.deepEqual(joinOpacities(0, false), { own: 0, from: 1 }); + // Never a frame where the item before's card is gone at once (main's `same` dropped it after the first frame). + const g = { A: { x: 100, y: 100, width: 968, height: 554 }, B: { x: 100, y: 0, width: 968, height: 787 }, slotA: null, slotB: null, same: true }; + assert.equal(joinFrameAt(g, 1 / 18).from.op, 1, "the second frame still shows what the item before showed"); + // This card is whole before the item before's starts to fade: over it, the shared post is lit throughout. + for (let e = 0; e <= 1.0001; e += 0.05) { + const o = joinOpacities(e, false); + if (o.from < 1) assert.equal(o.own, 1, `at e ${e.toFixed(2)} this card is in before that one fades`); + } + assert.deepEqual(joinOpacities(1, false), { own: 1, from: 0 }); + assert.ok(joinFrameAt(g, 0.9).from.op === 0, "gone well before the join ends"); +}); + +test("THE CLOCK OVER A JOIN: near, it carries on (moved the little way); apart, the item before's is laid in its shot and dissolves, this one comes in -- never across the card's words", () => { + assert.deepEqual(joinClockOf({ from: { x: 100, y: 200 }, own: { x: 110, y: 190 }, k: 1 }), { bake: false, move: { dx: -10, dy: 10 }, fadeIn: false }); + // mid-7 at 2357 s: the card's foot (bottom-right) to above the card (top-right). + assert.deepEqual(joinClockOf({ from: { x: 1050, y: 620 }, own: { x: 1050, y: 20 }, k: 886 / 1080 }), { bake: true, move: null, fadeIn: true }); + assert.deepEqual(joinClockOf({ from: null, own: { x: 1, y: 1 } }), { bake: false, move: null, fadeIn: true }); + assert.deepEqual(joinClockOf({ from: { x: 1, y: 1 }, own: null }), { bake: true, move: null, fadeIn: false }); + assert.deepEqual(joinClockOf({ from: null, own: null }), { bake: false, move: null, fadeIn: false }); + assert.ok(JOIN_CLOCK_NEAR > 0); + // The move's expression: base + d at the start, base from the join's end. + const ex = clockJoinExpr(900, -12, 0.6); + // ffmpeg's expression, evaluated as ffmpeg would (if, lt, min, pow). + const ev = (t) => Function("t", "min", "pow", "lt", "iff", `return ${ex.replace(/\bif\(/g, "iff(")};`)(t, Math.min, Math.pow, (a, b) => a < b, (c, a, b) => (c ? a : b)); + assert.equal(ev(0), 888); + assert.equal(ev(0.6), 900); + assert.equal(ev(2), 900); +}); + +test("THE SEGMENT's CLOCK over a join: moved from the item before's place (an expression on t), or faded in -- a clock with no join drawn as before", () => { + const plan = { total: 10, steps: [], reading: 10 }; + const base = { entry: { id: "p-1", media: [] }, box: { width: 1574, height: 886 }, plan, layout: { mode: "text", slot: null }, cards: { read: "read.png" }, files: [], render: { fps: 30 }, outPath: "out.mp4" }; + const graph = (clock) => postSegmentArgs({ ...base, clock }).find((a) => String(a).includes("[clk]overlay")); + const plain = graph({ list: "c.ffconcat", x: 900, y: 600, until: 10 }); + assert.match(plain, /\[clk\]overlay=x=900:y=600:eof_action=repeat/); + assert.doesNotMatch(plain, /fade=t=in/); + const moved = graph({ list: "c.ffconcat", x: 900, y: 600, until: 10, join: { seconds: 0.6, from: { dx: 0, dy: 14 }, fadeIn: false } }); + assert.match(moved, /overlay=x=900:y='600\+14\*\(1-if\(lt\(min\(1,t\/0\.6\),0\.5\)/); + const faded = graph({ list: "c.ffconcat", x: 900, y: 20, until: 10, join: { seconds: 0.6, from: null, fadeIn: true } }); + assert.match(faded, /fade=t=in:st=0:d=0\.6:alpha=1\[clk\]/); + assert.match(faded, /overlay=x=900:y=20:/); +}); + +test("THE CARRIED POST drawn as a PLAIN card drew it: its head at the card's size (not the words'), its words a card's gap below -- a threaded card before keeps the tile's", () => { + const before = post("10", "I'm only giving mercy because I'm concerned for my moms.", 7); + const reply = narrate(post("11", "notice how thats the exact character limit", 8, { parents: [ref("10", before.text, 7)], thread: { group: "limit" } }), [["notice how thats the exact character limit"]]); + const tl = [narrate(before, [[before.text]]), reply]; + const ctx = planContext(tl, 1); + const plan = postItemPlan(reply, undefined, ctx); + const html = (plain) => postCardHtml(reply, { width: 1574, height: 886, follow: true, thread: plan.follow.thread, join: { A: { x: 10, y: 10, width: 800, height: 500 }, size: 38, plain } }); + assert.match(html(true), /class="tile tpost tcarry tplain"/); + assert.match(html(true), /\.tplain > \.head \{ font-size: 16px; line-height: normal; \}/); + assert.match(html(false), /class="tile tpost tcarry" /); +}); + +test("THE KEY: a joined item's key carries the join's drawing and the clock the item before ran -- its key changes; an item with no join keeps the key it had", () => { + const entry = post("11", "notice how", 8); + const plan = { narration: null, follow: null, total: 5, steps: [] }; + const common = { entry, box: { width: 1574, height: 886 }, render: { fps: 30, palette: {} }, plan }; + const none = postSegmentKeyOf(common); + assert.equal(none.joinFrom, undefined); + const from = { entry: post("10", "mercy", 7), plan: { follow: null, total: 15.9 }, media: [], fadeIn: false, clock: { to: 1, from: null, mode: "none", zone: "America/New_York", gap: 0, forced: false } }; + const joined = postSegmentKeyOf({ ...common, from }); + assert.equal(joined.joinFrom.jv, POST_JOIN_DRAW_V); + assert.deepEqual(joined.joinFrom.clock, from.clock); + const other = postSegmentKeyOf({ ...common, from: { ...from, clock: { ...from.clock, to: 2 } } }); + assert.notEqual(postSegmentKey(joined), postSegmentKey(other), "the item before's clock is in the key"); + assert.notEqual(postSegmentKey(joined), postSegmentKey(none)); +}); diff --git a/umtool/report-to-video/post-join.mjs b/umtool/report-to-video/post-join.mjs @@ -6,8 +6,11 @@ // // the CARD its container morphs from the item before's box (as it ended) to its own -- position, // width and height eased; the words inside scaled with its width, never re-flowed -// what it SHOWED the item before's card as it ended (the build: a shot of its page at its last frame; -// Play: its page in a second frame) rides the container and fades out as this one's fades in +// what it SHOWED the item before's card as it ended (the build: a shot of its page at its last frame -- its +// clock, its parent's shot, a visit's pointer on it; Play: its page in a second frame) rides +// the container on top and dissolves into this one's, whole under it first (joinOpacities) +// the CLOCK carried on from the item before's when near, else that one dissolves and this comes in +// (joinClockOf) -- never moved across the card's words // the COLUMN the post the item before ended on (carried, or the scene's) is drawn as that item drew it // -- its head, its words at their size -- and the column opens framed where it was // the SLOT a slot that appears fades in, one that goes fades out; another attachment cross-fades @@ -60,6 +63,17 @@ const lerpRect = (a, b, f) => ({ x: lerp(a.x, b.x, f), y: lerp(a.y, b.y, f), wid const sameRect = (a, b) => !!a && !!b && ["x", "y", "width", "height"].every((k) => Math.abs(a[k] - b[k]) < 1.5); /** + * THE DISSOLVE's strengths at eased progress `e`, pure: `{ own, from }` -- this card's (under) in by e 0.3 (from the + * first frame when the content is the same), the item before's (over it) out from e 0.25 to 0.75. Both are whole + * across the boundary (e 0: the item before as it ended) and the item before's is gone well before the join ends. + */ +export function joinOpacities(e, same = false) { + const own = same ? 1 : Math.min(1, Math.max(0, e / 0.3)); + const from = 1 - Math.min(1, Math.max(0, (e - 0.25) / 0.5)); + return { own, from }; +} + +/** * THE JOIN's FRAME at progress `p` (0: the item before as it ended, 1: this item's own), pure: `{ e, R, own, from, * slotFrom, slotTo }` -- `R` the container's box; `own` this card's transform (`tx`, `ty`, `s`: its top-left moved to * R's, scaled by R's width over its own; `clipH` the height of it that shows; `op`); `from` the item before's card @@ -73,22 +87,44 @@ export function joinFrameAt(g, p) { const B = g.B; const R = lerpRect(A, B, e); const s = R.width / Math.max(1, B.width); - // The content cross-fades over the middle half of the join; the same content (sameRect, a carry alike) shows - // this card's from the first frame -- the item before's drawn under it only as long as the box moves. - const x = Math.min(1, Math.max(0, (e - 0.4) / 0.4)); - const y = Math.min(1, Math.max(0, (e - 0.1) / 0.4)); - const opOwn = g.same ? 1 : x; + // The item before's card (on top) dissolves into this one's, which is in UNDER it before it starts to go -- so + // what both draw (the post carried in) never dims, and what only the item before drew (its counts, its quote, its + // clock) fades out; never a frame where it is all gone at once (operator, 4 Nov, mid-7: "if one post is visible + // in the next scene, there should be a transition"). The same content (a carry alike) is this card's from the + // first frame, under the item before's. + const { own: opOwn, from: opFrom } = joinOpacities(e, !!g.same); const sameSlot = sameRect(g.slotA, g.slotB); return { e: r2(e), R: { x: r2(R.x), y: r2(R.y), width: r2(R.width), height: r2(R.height) }, own: { tx: r2(R.x - B.x), ty: r2(R.y - B.y), s: Math.round(s * 10000) / 10000, clipH: r2(R.height / Math.max(1e-6, s)), op: r2(opOwn) }, - from: { x: r2(R.x), y: r2(R.y), s: Math.round((R.width / Math.max(1, A.width)) * 10000) / 10000, op: r2(g.same ? (p <= 0 ? 1 : 0) : 1 - y) }, + from: { x: r2(R.x), y: r2(R.y), s: Math.round((R.width / Math.max(1, A.width)) * 10000) / 10000, op: r2(opFrom) }, slotFrom: g.slotA && !sameSlot ? r2(1 - e) : g.slotA ? 1 : 0, slotTo: g.slotB && !sameSlot ? r2(e) : g.slotB ? 1 : 0, }; } +/** How far (px at 1080) the clock may carry on from the item before's place by moving: never across the card's words. */ +export const JOIN_CLOCK_NEAR = 24; + +/** + * THE CLOCK OVER A JOIN, pure (post-clock.mjs): `{ bake, move, fadeIn }` -- `from` where the item before's clock sat + * as it ended (or null: it showed none), `own` where this item's sits (or null), `k` the box's height over 1080. + * Near (within JOIN_CLOCK_NEAR): this one opens on that one's place and moves the little way (`move` its offset + * there), nothing faded. Apart: a move would cross the card's words -- that one is laid in the item before's shot + * (`bake`) and dissolves with it, this one comes in over the join (`fadeIn`). None before: this one comes in; none + * now: that one is laid in the shot. + * @param {{ from: { x: number, y: number } | null, own: { x: number, y: number } | null, k?: number }} o + */ +export function joinClockOf({ from, own, k = 1 }) { + if (!own) return { bake: !!from, move: null, fadeIn: false }; + if (!from) return { bake: false, move: null, fadeIn: true }; + const dx = from.x - own.x; + const dy = from.y - own.y; + if (Math.hypot(dx, dy) <= JOIN_CLOCK_NEAR * k) return { bake: false, move: { dx: r2(dx), dy: r2(dy) }, fadeIn: false }; + return { bake: true, move: null, fadeIn: true }; +} + /** The join's progress at item second `s` (null: over, or none). */ export const joinProgressAt = (join, s) => (join && fin(join.seconds) && s < join.seconds - 1e-6 ? Math.max(0, s / join.seconds) : null); @@ -171,8 +207,9 @@ export function applyJoinState(p, doc = document) { const L = (a, b2) => a + (b2 - a) * e; const R = { x: L(A.x, B.x), y: L(A.y, B.y), width: L(A.width, B.width), height: L(A.height, B.height) }; const s = R.width / Math.max(1, B.width); - const x = Math.min(1, Math.max(0, (e - 0.4) / 0.4)); - const y = Math.min(1, Math.max(0, (e - 0.1) / 0.4)); + // joinOpacities, inlined. + const x = g.same ? 1 : Math.min(1, Math.max(0, e / 0.3)); + const y = 1 - Math.min(1, Math.max(0, (e - 0.25) / 0.5)); const same = (a, b2) => !!a && !!b2 && ["x", "y", "width", "height"].every((k) => Math.abs(a[k] - b2[k]) < 1.5); const sameSlot = same(g.slotA, g.slotB); card.style.transformOrigin = "0 0"; @@ -180,7 +217,7 @@ export function applyJoinState(p, doc = document) { card.style.clipPath = `inset(0 0 ${Math.max(0, B.height - R.height / s)}px 0)`; card.style.background = "transparent"; card.style.borderColor = "transparent"; - card.style.opacity = String(g.same ? 1 : x); + card.style.opacity = String(x); if (bg) { bg.style.display = "block"; bg.style.left = `${R.x}px`; @@ -195,8 +232,8 @@ export function applyJoinState(p, doc = document) { from.style.width = `${A.width}px`; from.style.transform = `scale(${R.width / Math.max(1, A.width)})`; from.style.clipPath = `inset(0 0 ${Math.max(0, A.height - R.height / (R.width / Math.max(1, A.width)))}px 0)`; - // The same content drawn alike: the item before's card is the first frame only (never a double image). - from.style.opacity = String(g.same ? (v <= 0 ? 1 : 0) : 1 - y); + // Over this card, dissolving into it (the same content drawn alike: identical where they overlap). + from.style.opacity = String(y); } if (slotFrom) { slotFrom.style.display = g.slotA && !sameSlot ? "block" : "none"; diff --git a/umtool/report-to-video/post-render.mjs b/umtool/report-to-video/post-render.mjs @@ -28,7 +28,7 @@ import { sceneEntry } from "./post-media-scene.mjs"; import { CAPTION_OUT, CAPTION_SLIDE, captionCss, captionInnerHtml, captionPlan, measureCaptionWords, mountCaptions, placeCaption, setCaptionState, slideDir } from "./post-caption.mjs"; import { clockCss, clockFace, clockFrameTimes, clockHtml, clockPlan, clockStateAt, measureClockPlace, mountClock, setClockState } from "./post-clock.mjs"; import { panelReadErrors } from "./post-thread.mjs"; -import { applyJoinState, endMediaOf } from "./post-join.mjs"; +import { applyJoinState, endMediaOf, joinClockOf } from "./post-join.mjs"; import { applyVisitState } from "./post-link-visit.mjs"; import { applyMapState, mapPageHtml, mapPlace, mapSize, mapStateAt } from "./post-branch-map.mjs"; import { WORD_ZOOM_DEFAULTS, findMatch, overlappingZooms, resolveWordZoom, targetScope, targetTextOf, wordZoomTimes, zoomSpan, zoomTarget, zoompanExprs } from "./word-zoom.mjs"; @@ -87,6 +87,16 @@ export function scrollExpr(keys) { * * @returns {string[]} */ +/** + * The clock's place over a join, an ffmpeg expression on `t`: `base + d` at the join's start, `base` from its end, + * eased between as the card is (post-join.mjs joinEase, in-out cubic). + */ +export function clockJoinExpr(base, d, seconds) { + const p = `min(1,t/${num(seconds)})`; + const e = `if(lt(${p},0.5),4*pow(${p},3),1-pow(2-2*${p},3)/2)`; + return `${num(base)}+${num(d)}*(1-${e})`; +} + export function postSegmentArgs({ entry, box, plan, layout, cards, files, render, place = [], encode = [], captions = [], fontfile = null, outPath, narration = null, zooms = [], follow = null, panelFiles = [], join = null, map = null, captionFx = [], clock = null }) { const fps = render.fps ?? 30; const T = plan.total; @@ -171,9 +181,14 @@ export function postSegmentArgs({ entry, box, plan, layout, cards, files, render // over the card's corner from the first frame (a stack card's: until its media phase). if (clock) { const ci = add(["-f", "concat", "-safe", "0", "-i", clock.list]); - parts.push(`[${ci}:v]fps=${fps},format=rgba,setsar=1,setpts=PTS-STARTPTS[clk]`); + // THE JOIN (post-join.mjs): it opens where the item before's clock sat and moves with the card (its ease), or, + // the item before showing none, comes in over the join. + const cj = clock.join && clock.join.seconds > 0 ? clock.join : null; + const fadeIn = cj?.fadeIn ? `,fade=t=in:st=0:d=${num(cj.seconds)}:alpha=1` : ""; + parts.push(`[${ci}:v]fps=${fps},format=rgba,setsar=1,setpts=PTS-STARTPTS${fadeIn}[clk]`); + const pos = (base, d) => (cj?.from && Math.abs(d) >= 0.5 ? `'${clockJoinExpr(base, d, cj.seconds)}'` : String(base)); const next = `b${++n}`; - parts.push(`[${cur}][clk]overlay=x=${clock.x}:y=${clock.y}:eof_action=repeat${clock.until < T ? `:enable='lt(t,${num(clock.until)})'` : ""}[${next}]`); + parts.push(`[${cur}][clk]overlay=x=${pos(clock.x, cj?.from?.dx ?? 0)}:y=${pos(clock.y, cj?.from?.dy ?? 0)}:eof_action=repeat${clock.until < T ? `:enable='lt(t,${num(clock.until)})'` : ""}[${next}]`); cur = next; } const audio = []; @@ -384,19 +399,39 @@ export async function renderPostCards(entry, { box, render, dir, manifestDir, la const av = Object.fromEntries(Object.entries(avatars).map(([h, f]) => [h, pathToFileURL(f).href])); // THE JOIN (post-join.mjs): the item before's card as it ENDED -- its page drawn, its last frame's state set, its // card shot -- and where its post's words sat; this card opens on it and morphs into its own. + // The shot is the item before's LAST FRAME as its segment draws it (check-joins.mjs measures it): its page (its + // parent's shot too), its read-follow's last state, a link visit's pointer, and its clock -- in the shot when + // this item has none (it fades with the card), else this item's clock starts where that one sat and moves. let join = null; if (follow?.join && joinFrom?.entry) { const fps = render.fps ?? 30; const pe = joinFrom.entry; const pf = joinFrom.plan?.follow ?? null; - const ph = postCardHtml(pe, { width: box.width, height: box.height, palette: render.palette, fonts, phase: "read", avatars: av, follow: !!pf, thread: pf?.thread ?? null, redaction }); + const pShot = typeof pe.parentShot === "string" ? pathToFileURL(path.resolve(manifestDir, pe.parentShot)).href : null; + const ph = postCardHtml(pe, { width: box.width, height: box.height, palette: render.palette, fonts, phase: "read", parentShotUrl: pShot, avatars: av, follow: !!pf, thread: pf?.thread ?? null, redaction }); const pfile = path.join(dir, "join-from.html"); await writeFile(pfile, ph, "utf8"); await page.goto(pathToFileURL(pfile).href, { waitUntil: "load" }); await page.waitForSelector("body[data-post-ready='1']", { timeout: 15000 }); + const endS = Math.max(0, joinFrom.plan.total - 1 / fps); + const pl0 = postLayout(pe, box); + // Its clock, placed as its own segment placed it (clockPlaceOn), shown at its end unless a stack card's media + // phase hid it. + const pClock = joinFrom.clock && !(pl0.mode === "stack" && joinFrom.plan.steps?.length) ? joinFrom.clock : null; + let clockFrom = null; + if (pClock) { + const k = box.height / 1080; + const face = clockFace(pClock.to, pClock.zone); + const size = await page.evaluate(mountClock, { css: clockCss({ height: box.height, palette: render.palette }), html: clockHtml(), widest: { time: "12:58 PM", zone: face.zone, date: "Wed 30 Sep" } }); + await page.evaluate(() => document.fonts.ready.then(() => true)); + const at = size ? await clockPlaceOn(page, { follow: pf, total: joinFrom.plan.total, size, k }) : null; + if (at) clockFrom = { x: at.x, y: at.y, st: clockStateAt(pClock, endS) }; + } if (pf) { const pgeo = await page.evaluate(measureFollow); - await page.evaluate(applyFollowState, followStateAt(pf, followPath(pf, pgeo), Math.max(0, joinFrom.plan.total - 1 / fps))); + const st = followStateAt(pf, followPath(pf, pgeo), endS); + await page.evaluate(applyFollowState, st); + if (pf.visits?.length) await page.evaluate(applyVisitState, { visits: pf.visits, st: st.visit ?? null }); } const m = await page.evaluate(() => { const card = document.querySelector("[data-post-card]"); @@ -407,19 +442,36 @@ export async function renderPostCards(entry, { box, render, dir, manifestDir, la const post = document.querySelector('[data-thread-slot="post"] .head') ?? card.querySelector(".head"); const words = document.querySelector('[data-thread-slot="post"] .twords') ?? document.querySelector("[data-post-words]"); const pr = post ? post.getBoundingClientRect() : null; - return { A: { x: c.left, y: c.top, width: c.width, height: c.height }, anchor: pr ? pr.top - c.top : null, size: words ? parseFloat(getComputedStyle(words).fontSize) : null }; + return { A: { x: c.left, y: c.top, width: c.width, height: c.height }, anchor: pr ? pr.top - c.top : null, size: words ? parseFloat(getComputedStyle(words).fontSize) : null, plain: !document.querySelector('[data-thread-slot="post"]') }; }); if (m) { const png = path.join(dir, "join-from.png"); const x = Math.max(0, Math.floor(m.A.x)); const y = Math.max(0, Math.floor(m.A.y)); - await page.screenshot({ path: png, clip: { x, y, width: Math.min(box.width - x, Math.ceil(m.A.width)), height: Math.min(box.height - y, Math.ceil(m.A.height)) } }); + const clip = { x, y, width: Math.min(box.width - x, Math.ceil(m.A.width)), height: Math.min(box.height - y, Math.ceil(m.A.height)) }; + await page.screenshot({ path: png, clip }); + // And with its clock on it, as it ended (laid in the shot when this item's clock does not carry on from it). + let pngClock = null; + if (clockFrom) { + pngClock = path.join(dir, "join-from-clock.png"); + await page.evaluate(setClockState, clockFrom); + await page.screenshot({ path: pngClock, clip }); + await page.evaluate(setClockState, null); + } const pl = postLayout(pe, box); const same = Math.abs(m.A.width - layout.card.width) < 2 && !!(follow.thread?.tiles ?? []).some((t) => t.mode === "carry" || (t.mode === "scene" && t.wasPost)); - join = { A: { x, y, width: Math.ceil(m.A.width), height: Math.ceil(m.A.height) }, slotA: pl.slot && pl.mode === "side" ? pl.slot : null, fromUrl: pathToFileURL(png).href, size: m.size, same, anchor: m.anchor }; - out.joinFrom = { A: join.A, layout: pl }; + join = { A: { x, y, width: Math.ceil(m.A.width), height: Math.ceil(m.A.height) }, slotA: pl.slot && pl.mode === "side" ? pl.slot : null, fromUrl: pathToFileURL(png).href, size: m.size, same, anchor: m.anchor, plain: m.plain }; + out.joinFrom = { A: join.A, layout: pl, clock: clockFrom ? { x: clockFrom.x, y: clockFrom.y } : null, pngClock }; } } + // THE CLOCK (post-clock.mjs), shot before the read's frames: over a join, where it opens decides the shot the + // card opens on (joinClockOf: carried on from the item before's clock, or that one laid in the shot, fading). + if (clock) out.clock = await shootClock(browser, entry, { box, render, dir, fonts, parentShotUrl, avatars, clock, redaction, follow, total }); + if (join) { + const jc = joinClockOf({ from: out.joinFrom?.clock ?? null, own: out.clock?.at ?? null, k: box.height / 1080 }); + if (jc.bake && out.joinFrom?.pngClock) join.fromUrl = pathToFileURL(out.joinFrom.pngClock).href; + if (out.clock) out.clock.join = { seconds: follow.join.seconds, from: jc.move, fadeIn: jc.fadeIn }; + } for (const phase of phases) { const html = postCardHtml(entry, { width: box.width, height: box.height, palette: render.palette, fonts, phase, parentShotUrl, @@ -463,7 +515,6 @@ export async function renderPostCards(entry, { box, render, dir, manifestDir, la } await ctx.close(); if (zooms.length) out.zooms = await shootZooms(browser, entry, { box, render, dir, fonts, parentShotUrl, avatars, zooms, redaction, follow }); - if (clock) out.clock = await shootClock(browser, entry, { box, render, dir, fonts, parentShotUrl, avatars, clock, redaction, follow, total }); // A caption covers none of the attachments (`obstacles`: their boxes) nor the clock. if (captions.length) out.captions = await shootCaptions(browser, entry, { box, render, dir, fonts, parentShotUrl, avatars, captions, redaction, follow, obstacles: [...obstacles, ...(out.clock ? [out.clock.box] : [])] }); } finally { @@ -768,6 +819,26 @@ export async function shootCaptions(browser, entry, { box, render, dir, fonts, p } /** + * WHERE THE CLOCK SITS on a card page with the clock mounted (`size` its box): placed as the card is when its own + * post is in (the read's end: a threaded card's counts row is there), and judged over the read (its start, middle + * and end) -- the place covering fewest words over all three wins; the follow put back at its start. Null: no card. + * The item's own shot (shootClock) and the join's (the item before's clock, where it sat) place it alike. + */ +async function clockPlaceOn(page, { follow, total, size, k }) { + const fpath = follow ? followPath(follow, await page.evaluate(measureFollow)) : null; + const states = follow ? [total, 0, total / 2] : [0]; + const looks = []; + for (const s of states) { + if (follow) await page.evaluate(applyFollowState, followStateAt(follow, fpath, s)); + looks.push(await page.evaluate(measureClockPlace, { size, inset: Math.round(22 * k), fixed: looks[0]?.tries ?? null })); + } + const at0 = looks[0]; + const at = at0 ? at0.tries.map((t, i) => ({ ...t, covers: looks.reduce((a, l) => a + (l?.tries?.[i]?.covers ?? 0), 0) })).sort((a, b) => a.covers - b.covers)[0] : null; + if (follow) await page.evaluate(applyFollowState, followStateAt(follow, fpath, 0)); + return at; +} + +/** * THE CLOCK's FRAMES (post-clock.mjs): on the card page as drawn, the chip * mounted at its widest and placed (measureClockPlace: the bottom-right corner * by the counts row, else the top-right -- over no word), then shot alone on a @@ -789,18 +860,7 @@ export async function shootClock(browser, entry, { box, render, dir, fonts, pare const face = clockFace(clock.to, clock.zone); const size = await page.evaluate(mountClock, { css: clockCss({ height: box.height, palette: render.palette }), html: clockHtml(), widest: { time: "12:58 PM", zone: face.zone, date: "Wed 30 Sep" } }); await page.evaluate(() => document.fonts.ready.then(() => true)); - // Placed as the card is when its own post is in (the read's end: a threaded card's counts row is there), and - // judged over the read (its start, middle and end): the place covering fewest words over all three wins. - const fpath = follow ? followPath(follow, await page.evaluate(measureFollow)) : null; - const states = follow ? [total, 0, total / 2] : [0]; - const looks = []; - for (const s of states) { - if (follow) await page.evaluate(applyFollowState, followStateAt(follow, fpath, s)); - looks.push(await page.evaluate(measureClockPlace, { size, inset: Math.round(22 * k), fixed: looks[0]?.tries ?? null })); - } - const at0 = looks[0]; - const at = at0 ? at0.tries.map((t, i) => ({ ...t, covers: looks.reduce((a, l) => a + (l?.tries?.[i]?.covers ?? 0), 0) })).sort((a, b) => a.covers - b.covers)[0] : null; - if (follow) await page.evaluate(applyFollowState, followStateAt(follow, fpath, 0)); + const at = await clockPlaceOn(page, { follow, total, size, k }); if (!at) throw new Error(`${entry.id}: the clock has no card to sit on`); await page.evaluate(() => { const st = document.createElement("style"); @@ -835,7 +895,7 @@ export async function shootClock(browser, entry, { box, render, dir, fonts, pare lines.push(`file ${q(shots.get(runs[runs.length - 1].key))}`); const list = path.join(fdir, "frames.ffconcat"); await writeFile(list, lines.join("\n") + "\n", "utf8"); - return { list, x: clip.x, y: clip.y, place: at.place, covers: at.covers, shots: shots.size, box: { x: at.x - Math.round(240 * k), y: at.y, width: size.width + Math.round(240 * k), height: size.height } }; + return { list, x: clip.x, y: clip.y, at: { x: at.x, y: at.y }, place: at.place, covers: at.covers, shots: shots.size, box: { x: at.x - Math.round(240 * k), y: at.y, width: size.width + Math.round(240 * k), height: size.height } }; } finally { await ctx.close(); } @@ -880,6 +940,12 @@ export function postZoomPlan(entry, render, total = Infinity, schedule = undefin * a cut-level pace changes them without touching the entry) */ export const POST_CAPTION_DRAW_V = 2; +/** + * The join's drawing (in a joined item's key only: an item with no join keeps its key). 2: the item before's card + * dissolves into this one's (never gone at the first frame), its last frame shot whole (its clock, its parent's shot, + * a visit's pointer), the carried post's head drawn as a plain card drew it, this item's clock moving from that one's. + */ +export const POST_JOIN_DRAW_V = 2; export const POST_CLOCK_DRAW_V = 1; export function postFxKeyFields(entry, render, prev = null) { const out = {}; @@ -920,7 +986,9 @@ export function postSegmentKeyOf({ entry, redaction = null, box, place = [], ren ...(plan.follow ? { follow: plan.follow } : {}), ...(bleeps ? { bleeps } : {}), ...(slursOn(redaction?.slurs) ? { slurs: redaction.slurs } : {}), - ...(from ? { joinFrom: { entry: from.entry, follow: from.plan.follow ?? null, total: from.plan.total, media: from.media.map((x) => [x.m.src, x.t, x.box]), fadeIn: from.fadeIn } } : {}), + // `jv`: the join's drawing (POST_JOIN_DRAW_V) and what the item before showed as it ended beyond its card -- its + // clock (where this one's starts) and its parent's shot. + ...(from ? { joinFrom: { entry: from.entry, follow: from.plan.follow ?? null, total: from.plan.total, media: from.media.map((x) => [x.m.src, x.t, x.box]), fadeIn: from.fadeIn, jv: POST_JOIN_DRAW_V, clock: from.clock ?? null } } : {}), ...(plan.panel ? { panel: plan.panel } : {}), ...(layout?.panel === "top" || layout?.panel === "bottom" ? { layout: { panel: layout.panel, card: layout.card, slot: layout.slot } } : {}), // A caption, the clock, the pace (post-caption.mjs, post-clock.mjs): nothing for an item with none of them. @@ -981,6 +1049,8 @@ export async function buildPostSegment(entry, { render, outDir, manifestDir, box const held = !!firstOwn && ends.length === 1 && ends[0].m.src === firstOwn.src && !!ownBox && Math.abs(ownBox.x - eb[0].x) < 2 && Math.abs(ownBox.y - eb[0].y) < 2 && Math.abs(ownBox.width - eb[0].width) < 2; from = { entry: pe, plan: pp, + // Its clock (post-clock.mjs) as its own segment runs it: from the clock item before IT. + clock: clockPlan(pe, render, joinFrom.prev ?? null), media: held ? [] : ends.map((x, j) => ({ file: path.resolve(manifestDir, x.m.src), m: x.m, t: x.t, box: eb[j] })), fadeIn: !held && !!firstOwn, }; @@ -1001,7 +1071,7 @@ export async function buildPostSegment(entry, { render, outDir, manifestDir, box if (takeFile && !(await stat(takeFile).catch(() => null))) throw new Error(`${entry.id}: its narration take is not on disk: ${takeFile} (${take.file})`); // The slurs its take SAYS, covered (post-slurs.mjs): a public render never plays one -- without word timings it is refused. const bleeps = take ? takeSlurBleeps(entry, take, redaction) : null; - const stamps = await Promise.all([...files, ...panelFiles.flat(), ...(from?.media ?? []).map((x) => x.file), ...wordFiles.filter(Boolean), ...Object.values(avatars), ...(takeFile ? [takeFile] : []), ...(entry.parentShot ? [path.resolve(manifestDir, entry.parentShot)] : [])].map(async (f) => { + const stamps = await Promise.all([...files, ...panelFiles.flat(), ...(from?.media ?? []).map((x) => x.file), ...wordFiles.filter(Boolean), ...Object.values(avatars), ...(takeFile ? [takeFile] : []), ...(entry.parentShot ? [path.resolve(manifestDir, entry.parentShot)] : []), ...(typeof from?.entry?.parentShot === "string" ? [path.resolve(manifestDir, from.entry.parentShot)] : [])].map(async (f) => { const st = await stat(f).catch(() => null); return st ? `${f}:${st.size}:${Math.round(st.mtimeMs)}` : `${f}:-`; }));