Archilyzer · Source

archilyzer

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

commit c720818cfe6d0e4338f33307d374a79ff94fc27f
parent f214f964d0b13e2fe9f1efe40113760dc9103a56
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Wed,  4 Nov 2026 12:41:42 -0500

umtool: Play plays the join -- the item before's page in a frame of its own at its last state riding the morph, this card's box eased from that one's (post-join.mjs applyJoinState, the build's), the item before's attachment fading out and this one's in; the card route draws the carried post as that item drew its post; e2e thread-scenes (a layout-switching join, a manual thread, a wide attachment)

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

Diffstat:
Mumtool/app/api/report/post-item/route.ts | 18+++++++++++++++---
Mumtool/components/projects/review/PlayCut.tsx | 5+++++
Mumtool/components/projects/review/PostItemPlayer.tsx | 115++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
Aumtool/e2e/thread-scenes.spec.ts | 125+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mumtool/report-to-video/package.json | 1+
Mumtool/report-to-video/post-item.mjs | 3++-
Mumtool/report-to-video/post-join.mjs | 16++++++++++++++--
7 files changed, 273 insertions(+), 10 deletions(-)

diff --git a/umtool/app/api/report/post-item/route.ts b/umtool/app/api/report/post-item/route.ts @@ -1,6 +1,6 @@ import { readFile, realpath, stat } from "node:fs/promises"; import path from "node:path"; -import { panelEntry, postCardHtml } from "umtool-report-to-video/post-item"; +import { cardWordsSize, panelEntry, postCardHtml, postItemPlan } from "umtool-report-to-video/post-item"; import { avatarUrls } from "umtool-report-to-video/post-avatars"; import { jobState, startJob } from "@/lib/research/case-editor"; import { withEditNotes } from "@/lib/report/guard"; @@ -57,8 +57,18 @@ async function itemOf(project: { dir: string }, manifest: Record<string, unknown const at = tl.findIndex((e) => e?.type === "post" && e.id === id); // `ctx`: the item before it in the cut (post-thread.mjs: a parent that is that item is carried in) and the scene its // run leaves on screen (post-conversation.mjs), as Play's plan has them. - const ctx = planContext(tl, at, (m.render ?? {}) as Record<string, unknown>) as { prev: Record<string, unknown> | null; scene: Record<string, unknown> | null }; - return { item: at >= 0 ? tl[at] : null, prev: ctx.prev, ctx, manifest: m }; + const ctx = planContext(tl, at, (m.render ?? {}) as Record<string, unknown>) as { prev: Record<string, unknown> | null; scene: Record<string, unknown> | null; join: { seconds: number } | null }; + // THE JOIN (post-join.mjs): the item before's own context, so its post's size is known (the carried post drawn alike). + const prevCtx = at > 0 && ctx.join ? (planContext(tl, at - 1, (m.render ?? {}) as Record<string, unknown>) as Record<string, unknown>) : null; + 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 }) { + 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 }); } /** A project file under posts-media/, never outside it (its real path checked). */ @@ -210,6 +220,8 @@ export async function GET(request: Request) { // read is its base; un-narrated, none). 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, }); 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 @@ -857,6 +857,11 @@ export default function PlayCut({ published={asPublished} uncensored={uncensored} scene={postNow.entry.postScene ?? null} + 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; + })()} /> ) : null; // A post item that repeats an earlier one's attachment: its combo badge, beside the player. diff --git a/umtool/components/projects/review/PostItemPlayer.tsx b/umtool/components/projects/review/PostItemPlayer.tsx @@ -2,6 +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 { dryGainAt, mixPhaseAt, pickedTake, wetGainAt } from "umtool-report-to-video/post-narration"; import { applyFollowState, followPath, followStateAt, measureFollow } from "umtool-report-to-video/read-follow"; import { scrollAt, showOpacityAt } from "umtool-report-to-video/post-thread"; @@ -81,6 +82,7 @@ export type NarrationSchedule = { at: number; seconds: number; takeSeconds?: num /** The plan's read-follow (read-follow.mjs followSchedule). */ export type FollowPlan = { + join?: { seconds: number }; dim: number; ease: number; readEnd: number; @@ -236,8 +238,10 @@ function PixelLayer({ source, crop, censor }: { source: React.RefObject<HTMLVide } function MediaEl({ - project, m, box, b, step, s, playing, inStep, mix = null, speed = 1, + project, m, box, b, step, s, playing, inStep, mix = null, speed = 1, joinOp = 1, }: { + /** THE JOIN (post-join.mjs): its strength while it fades in over the attachment the item before ended on. */ + joinOp?: number; project: string; m: PostPlan["steps"][number]["items"][number]; box: Box; @@ -302,7 +306,7 @@ function MediaEl({ data-post-censor-style={blur ? blur.style : undefined} data-post-censor-band={blur?.band ? blur.band.join(",") : undefined} className="absolute overflow-hidden" - style={{ left: pct(b.x, box.width), top: pct(b.y, box.height), width: pct(b.width, box.width), height: pct(b.height, box.height), containerType: blur ? "size" : undefined }} + style={{ left: pct(b.x, box.width), top: pct(b.y, box.height), width: pct(b.width, box.width), height: pct(b.height, box.height), containerType: blur ? "size" : undefined, opacity: joinOp < 1 ? joinOp : undefined }} > {timed ? ( <video @@ -385,8 +389,29 @@ function PanelShows({ project, shows, fade, slot, box, s }: { project: string; s ); } +/** THE JOIN's outgoing attachments (post-join.mjs endMediaOf): the item before's last frame at its slot, fading out. */ +function JoinEnds({ project, ends, layout, box, op }: { project: string; ends: Array<{ m: Record<string, unknown> & { src?: string; kind?: string }; t: number }>; layout: { slot: Rect | null }; box: Box; op: number }) { + if (!layout.slot || !ends.length || op <= 0) return null; + const boxes = stepBoxes({ items: ends.map((x, j) => ({ ...x.m, i: j })) } as never, layout.slot) as Rect[]; + return ( + <> + {ends.map((x, j) => { + const b = boxes[j]; + const src = postFileUrl(project, String(x.m.src ?? "")); + const style = { left: pct(b.x, box.width), top: pct(b.y, box.height), width: pct(b.width, box.width), height: pct(b.height, box.height), opacity: op, zIndex: 3 }; + return x.m.kind === "image" ? ( + // eslint-disable-next-line @next/next/no-img-element + <img key={j} alt="" src={src} data-post-join-end={j} className="absolute object-cover" style={style} /> + ) : ( + <video key={j} src={`${src}#t=${x.t}`} muted playsInline preload="auto" data-post-join-end={j} className="absolute object-cover" style={style} /> + ); + })} + </> + ); +} + export default function PostItemPlayer({ - project, take = null, entry, plan, box, s, playing, cardKey = null, speed = 1, published = false, uncensored = false, scene = null, + project, take = null, entry, plan, box, s, playing, cardKey = null, speed = 1, published = false, uncensored = false, scene = null, joinFrom = null, }: { project: string; take?: string | null; @@ -406,6 +431,8 @@ export default function PostItemPlayer({ uncensored?: boolean; /** Its media scene (post-media-scene.mjs): which, and its place in it. */ scene?: { key: string; n: number; of: number } | 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; }) { const wrap = useRef<HTMLDivElement | null>(null); const [scale, setScale] = useState(0); @@ -442,6 +469,8 @@ export default function PostItemPlayer({ return () => ro.disconnect(); }, [box.width]); const layout = useMemo(() => postLayout(entry, box), [entry, box]); + const pageUrlOf = (id: string, phase: "read" | "media") => + `/api/report/post-item?project=${encodeURIComponent(project)}&id=${encodeURIComponent(id)}&w=${Math.round(box.width)}&h=${Math.round(box.height)}&phase=${phase}${take ? `&take=${encodeURIComponent(take)}` : ""}${published ? `&published=1${uncensored ? "&uncensored=1" : ""}` : ""}`; const pageUrl = (phase: "read" | "media") => `/api/report/post-item?project=${encodeURIComponent(project)}&id=${encodeURIComponent(entry.id)}&w=${Math.round(box.width)}&h=${Math.round(box.height)}&phase=${phase}${take ? `&take=${encodeURIComponent(take)}` : ""}${cardKey ? `&v=${encodeURIComponent(cardKey)}` : ""}${published ? `&published=1${uncensored ? "&uncensored=1" : ""}` : ""}`; const reading = s < plan.reading || !plan.steps.length; @@ -470,6 +499,35 @@ export default function PostItemPlayer({ }, [wordsRel, project, cues]); // ---- the word zooms, live: measured in the card page once it is drawn, applied on the item's clock ---- 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 [joinReady, setJoinReady] = useState(0); + const joinSecs = plan.follow?.join?.seconds ?? 0; + const joinOn = !!joinFrom && joinSecs > 0; + const onJoinLoad = useCallback(() => { + let tries = 0; + const tick = () => { + const doc = joinFrame.current?.contentDocument; + if (!doc || doc.body?.getAttribute("data-post-ready") !== "1" || !joinFrom) { + if (tries++ < 50) setTimeout(tick, 100); + 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 card = doc.querySelector("[data-post-card]"); + if (!card) return; + const c = card.getBoundingClientRect(); + const post = doc.querySelector('[data-thread-slot="post"]') ?? 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 }; + setJoinReady((n) => n + 1); + }; + tick(); + }, [joinFrom, box]); const [zooms, setZooms] = useState<LiveZoom[]>([]); const boxes = useRef<Map<Element, Rect>>(new Map()); const zoomTimes = useMemo(() => (Array.isArray(entry.fx) && entry.fx.length ? wordZoomTimes(entry, undefined, plan.narration as never) : []), [entry, plan.narration]); @@ -484,6 +542,13 @@ export default function PostItemPlayer({ // Laid out untransformed (no zoom), the follow geometry first; a zoom's word is measured as the card is at its peak. if (card) for (const k of Array.from(card.children) as HTMLElement[]) k.style.transform = ""; const geo = follow && doc.querySelector("[data-post-flow]") ? measureFollow(doc) : null; + // THE JOIN: the carried post opens where the item before's post sat (measured in its frame). + const jm = joinMeasure.current; + if (geo && jm && jm.anchor !== null) { + const c = card?.getBoundingClientRect(); + const w = doc.querySelector("[data-post-words]")?.getBoundingClientRect(); + if (c && w) (geo as Record<string, unknown>).joinAnchor = { y: Math.round((jm.anchor / (jm.A.width / c.width) - (w.top - c.top)) * 100) / 100 }; + } setFollowGeo(geo); const route = follow && geo ? followPath(follow, geo) : null; const list = Array.isArray(entry.fx) ? (entry.fx as Array<Record<string, unknown>>) : []; @@ -541,7 +606,26 @@ export default function PostItemPlayer({ const doc = readFrame.current?.contentDocument; if (doc) applyZoom(doc, live, zf, hl, boxes.current); }, [live, zf, hl]); + useEffect(() => { + if (joinReady) onFrameLoad(); + }, [joinReady, onFrameLoad]); const followNow = useMemo(() => (follow ? followStateAt(follow, followRoute, s) : null), [follow, followRoute, s]); + // The join's frame (post-join.mjs joinFrameAt): this card's box, the item before's card riding it, the slots. + const jp = joinOn && joinMeasure.current && s < joinSecs ? Math.max(0, s / joinSecs) : null; + const [ownBox, setOwnBox] = useState<Rect | null>(null); + useEffect(() => { + const doc = readFrame.current?.contentDocument; + 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(); + 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; + const joinEnds = useMemo(() => (joinFrom ? endMediaOf(joinFrom.plan as never, { stepAt, mediaTimeAt }) : []), [joinFrom]); useEffect(() => { const doc = readFrame.current?.contentDocument; if (doc && follow && doc.querySelector("[data-post-follow]")) applyFollowState(followNow, doc); @@ -553,6 +637,8 @@ export default function PostItemPlayer({ ref={wrap} data-post-play={entry.id} data-post-layout={layout.mode} + data-post-panel={layout.panel ?? undefined} + data-post-join={joinOn ? (jp !== null ? String(Math.round(jp * 100) / 100) : "done") : undefined} data-post-step={reading ? "read" : current?.kind ?? "held"} data-post-s={String(Math.round(s * 100) / 100)} data-post-narrated={mix ? "1" : undefined} @@ -587,6 +673,23 @@ export default function PostItemPlayer({ className="absolute inset-0 border-0" style={{ width: box.width, height: box.height, visibility: mediaPhase ? "hidden" : "visible" }} /> + {joinOn && s < joinSecs + 0.2 && ( + // THE JOIN: the item before's card as it ended, riding the container (the build: its shot) and fading out. + <iframe + title={`post ${joinFrom!.entry.id} (as it ended)`} + ref={joinFrame} + onLoad={onJoinLoad} + src={pageUrlOf(joinFrom!.entry.id, "read")} + data-post-join-frame={joinFrom!.entry.id} + className="absolute left-0 top-0 border-0" + style={{ + width: box.width, height: box.height, transformOrigin: "0 0", zIndex: 2, + opacity: jframe ? jframe.from.op : 0, + transform: jframe ? `translate(${jframe.R.x - joinMeasure.current!.A.x * jframe.from.s}px, ${jframe.R.y - joinMeasure.current!.A.y * jframe.from.s}px) scale(${jframe.from.s})` : "none", + clipPath: jframe ? `inset(${joinMeasure.current!.A.y}px ${box.width - joinMeasure.current!.A.x - joinMeasure.current!.A.width}px ${Math.max(0, box.height - joinMeasure.current!.A.y - Math.min(joinMeasure.current!.A.height, jframe.R.height / jframe.from.s))}px ${joinMeasure.current!.A.x}px)` : "none", + }} + /> + )} {layout.mode === "stack" && ( <iframe title={`post ${entry.id} (media)`} @@ -602,10 +705,14 @@ export default function PostItemPlayer({ // THE PANEL (post-thread.mjs panelSchedule): a context post's attachment over the slot while it is on screen. <PanelShows project={project} shows={plan.panel.shows} fade={plan.panel.fade} slot={layout.slot} box={box} s={s} /> )} + {jframe && joinFrom && ( + // THE JOIN: what the item before ended on in its slot, fading out (the same attachment is held, not drawn twice). + <JoinEnds project={project} ends={joinEnds} layout={postLayout(joinFrom.entry, box)} box={box} op={jframe.slotFrom < 1 || !shown || joinEnds[0]?.m?.src !== shown.items[0]?.src ? 1 - jframe.e : 0} /> + )} {shown && layout.slot && (layout.mode === "side" || mediaPhase) && ( <> {stepBoxes(shown, layout.slot).map((b: { x: number; y: number; width: number; height: number }, j: number) => ( - <MediaEl key={`${plan.steps.indexOf(shown)}:${j}`} project={project} m={shown.items[j]} box={box} b={b} step={shown} s={s} playing={playing} inStep={inStep} mix={mix} speed={speed} /> + <MediaEl key={`${plan.steps.indexOf(shown)}:${j}`} joinOp={jframe && !(joinEnds.length === 1 && joinEnds[0].m.src === shown.items[j]?.src) ? Math.min(1, Math.max(0, (jframe.e - 0.35) / 0.65)) : 1} project={project} m={shown.items[j]} box={box} b={b} step={shown} s={s} playing={playing} inStep={inStep} mix={mix} speed={speed} /> ))} {cue && ( <div diff --git a/umtool/e2e/thread-scenes.spec.ts b/umtool/e2e/thread-scenes.spec.ts @@ -0,0 +1,125 @@ +import { test, expect, type Page } from "@playwright/test"; +import { copyFileSync, existsSync, readFileSync, rmSync, writeFileSync } from "node:fs"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; +import * as urls from "./urls"; + +// --------------------------------------------------------------------------- +// THREAD SCENES (report-to-video/post-join.mjs, post-conversation.mjs, post-item.mjs postLayout; knobs.md, "The join", +// "Manual threads", "Wide attachments"; operator, 4 Nov, mid-6: "I'd like a thread-like smooth transition here rather +// than a cut", "do all of them chronologically as if a thread", "for these super wide images a top-bottom layout"): +// - a run whose items switch layout (a card beside a video, then a card alone) JOINS in Play: the item before's card +// as it ended in a frame of its own riding the morph, this card's box eased into its own; +// - a manual thread (thread.group) stacks unlinked posts as one scene, each reply saying what it answers; +// - a wide attachment is laid at full width above the card. +// Fixture: e2e/fixtures/post-narration-fixture.mjs's items, rewritten here. +// +// THREAD_SCENES_SHOTS=<dir> screenshots there +// --------------------------------------------------------------------------- + +const HERE = path.dirname(fileURLToPath(import.meta.url)); +const REPORTS = path.join(HERE, "..", ".e2e-song", "reports"); +const DIR = path.join(REPORTS, "post-narration-fixture"); +const MANIFEST = path.join(DIR, "video.manifest.json"); +const PROJECT = "reports/post-narration-fixture"; +const SHOTS = process.env.THREAD_SCENES_SHOTS ?? null; + +const ROOT_TEXT = "Many have questioned my methods in dealing with the whole mess, and I will say it once more for everyone."; +const REPLY = "I can't help but feel like I've failed everyone, they all got exactly what they wanted out of it."; +const ROOT = { id: "11", author: "Narr Subject", handle: "narrsubject", date: "2026-10-30T06:00:00.000Z", text: ROOT_TEXT }; + +function takeOf(pieces: string[]) { + let at = 0; + const parts = pieces.map((text, pi) => { + const seconds = Math.round((text.split(/\s+/).length / 3) * 100) / 100; + if (pi) at += 0.6; + const p = { n: pi + 1, para: pi * 100, text, start: Math.round(at * 100) / 100, seconds }; + at += seconds; + return p; + }); + return { file: "narration/posts/11/take-1.orpheus-zac.wav", engine: "orpheus", voice: "leo+zac", seconds: Math.round(at * 100) / 100, script: pieces.join("\n\n"), parts }; +} + +test.beforeAll(() => { + if (!existsSync(`${MANIFEST}.pristine`)) copyFileSync(MANIFEST, `${MANIFEST}.pristine`); +}); +test.beforeEach(() => { + test.setTimeout(120_000); + copyFileSync(`${MANIFEST}.pristine`, MANIFEST); + rmSync(path.join(DIR, "revisions"), { recursive: true, force: true }); + rmSync(path.join(DIR, "notes.json"), { force: true }); + const m = JSON.parse(readFileSync(MANIFEST, "utf8")); + const byId = (id: string) => m.timeline.find((x: { id: string }) => x.id === id); + const narr = (e: Record<string, unknown>, text: string, pieces: string[]) => Object.assign(e, { text, narration: { script: text, takes: [takeOf(pieces)], pick: 0 } }); + // A run that switches layout: his root beside its video, then his reply under it, a card alone. + const root = narr(byId("p-11"), ROOT_TEXT, [ROOT_TEXT]); + root.date = ROOT.date; + const reply = narr(byId("p-12"), REPLY, [REPLY]); + delete reply.media; + reply.date = "2026-10-30T07:00:00.000Z"; + reply.parents = [ROOT]; + // A manual thread: a post he answered (shown), then two of his, unlinked on X. + const opener: Record<string, unknown> = { ...structuredClone(reply), id: "p-21", post: "othchan-x/21", author: "Movail", handle: "movail_two", text: "Ready for more lessons?", date: "2026-10-30T08:00:00.000Z", thread: { group: "lessons" } }; + delete opener.parents; + delete opener.narration; + const g1: Record<string, unknown> = narr({ ...structuredClone(reply), id: "p-22", post: "narrchan-x/22", date: "2026-10-30T09:00:00.000Z", thread: { group: "lessons" } }, "It wobbles, oh my word.", ["It wobbles, oh my word."]); + delete g1.parents; + const g2 = narr({ ...structuredClone(reply), id: "p-23", post: "narrchan-x/23", date: "2026-10-30T09:05:00.000Z", thread: { group: "lessons" }, parents: [{ id: "21", author: "Movail", handle: "movail_two", date: "2026-10-30T08:00:00.000Z", text: "Ready for more lessons?" }] }, "It wobbles, I cannot even.", ["It wobbles, I cannot even."]); + // A wide attachment. + const wide = narr({ ...structuredClone(byId("p-13")), id: "p-31", post: "narrchan-x/31", parents: undefined, media: [{ src: "posts-media/narrchan-x/12/12_1.png", kind: "image", width: 692, height: 141 }] }, "If anything happens I am holding them accountable.", ["If anything happens I am holding them accountable."]); + delete wide.parents; + m.timeline = [root, reply, opener, g1, g2, wide]; + writeFileSync(MANIFEST, JSON.stringify(m, null, 2) + "\n"); +}); + +async function playAt(page: Page, id: string, at: number) { + await page.goto(urls.playHref(PROJECT, { bare: true, clip: id, at })); + const player = page.locator(`[data-post-play="${id}"]`); + await expect(player).toBeVisible({ timeout: 15_000 }); + const frame = page.frameLocator('[data-post-card-frame="read"]'); + await expect(frame.locator("body")).toHaveAttribute("data-post-ready", "1", { timeout: 15_000 }); + await expect.poll(async () => Math.abs(Number(await player.getAttribute("data-post-s")) - at)).toBeLessThan(0.3); + return { player, frame }; +} + +test("THE JOIN in Play: his reply (a card alone) opens on his root as it ended beside its video -- the item before's card in a frame of its own riding the morph, this card's box eased from that one's -- and is its own once the join is over", async ({ page }) => { + await page.setViewportSize({ width: 1366, height: 1000 }); + { + const { player, frame } = await playAt(page, "p-12", 0.25); + await expect(page.locator('[data-post-join-frame="p-11"]')).toHaveCount(1); + await expect.poll(async () => player.getAttribute("data-post-join")).toMatch(/^0\.\d+$/); + // The page knows where the item before's card was; its own card moved and scaled toward its own box. + await expect(frame.locator("body")).toHaveAttribute("data-join", /"A":\{/); + await expect.poll(async () => frame.locator("[data-post-card]").evaluate((el) => (el as HTMLElement).style.transform)).toMatch(/translate\(.*scale\(/); + // The carried root is drawn as his post was (head and words), the join's anchor. + await expect(frame.locator('[data-thread-tile="parent:0"]')).toHaveAttribute("data-join-anchor", ""); + if (SHOTS) await page.screenshot({ path: path.join(SHOTS, "join-mid.png") }); + } + { + const { player, frame } = await playAt(page, "p-12", 1.5); + await expect.poll(async () => player.getAttribute("data-post-join")).toBe("done"); + await expect.poll(async () => frame.locator("[data-post-card]").evaluate((el) => (el as HTMLElement).style.transform)).not.toMatch(/scale\(/); + if (SHOTS) await page.screenshot({ path: path.join(SHOTS, "join-after.png") }); + } +}); + +test("A MANUAL THREAD (thread.group): the post he answered, then two of his unlinked on X, one scene -- every earlier post kept on screen, each reply saying what it answers", async ({ page }) => { + await page.setViewportSize({ width: 1366, height: 1000 }); + const { frame } = await playAt(page, "p-23", 2.5); + await expect(frame.locator('[data-thread-slot="conv:22"]')).toHaveAttribute("data-thread-scene", "keep"); + await expect(frame.locator('[data-thread-slot="parent:0"]')).toHaveCount(1); + // His last reply answers the post three tiles up: "replying to @movail_two" (blurred: a private account). + await expect(frame.locator('[data-thread-slot="post"] [data-thread-rel="branch"]')).toContainText("replying to"); + if (SHOTS) await page.screenshot({ path: path.join(SHOTS, "group.png") }); +}); + +test("A WIDE ATTACHMENT (692×141) is laid at full width above the card, never a side panel", async ({ page }) => { + await page.setViewportSize({ width: 1366, height: 1000 }); + const { player, frame } = await playAt(page, "p-31", 1); + await expect(player).toHaveAttribute("data-post-panel", "top"); + const slot = await frame.locator("[data-post-slot]").boundingBox(); + const card = await frame.locator("[data-post-card]").boundingBox(); + expect(slot && card && slot.y + slot.height <= card.y + 1).toBe(true); + expect(slot && card && slot.width > card.width).toBe(true); + if (SHOTS) await page.screenshot({ path: path.join(SHOTS, "wide.png") }); +}); diff --git a/umtool/report-to-video/package.json b/umtool/report-to-video/package.json @@ -73,6 +73,7 @@ "./post-slurs": "./post-slurs.mjs", "./post-thread": "./post-thread.mjs", "./post-conversation": "./post-conversation.mjs", + "./post-join": "./post-join.mjs", "./post-render": "./post-render.mjs", "./word-zoom": "./word-zoom.mjs", "./read-follow": "./read-follow.mjs", diff --git a/umtool/report-to-video/post-item.mjs b/umtool/report-to-video/post-item.mjs @@ -960,7 +960,8 @@ export function nameHtml(who, { redact, cls = "" }) { * phase?: "read"|"media", parentShotUrl?: string|null, transparent?: boolean, avatars?: Record<string, string>, * 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 }} o + * 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 */ 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); diff --git a/umtool/report-to-video/post-join.mjs b/umtool/report-to-video/post-join.mjs @@ -96,8 +96,12 @@ export const joinProgressAt = (join, s) => (join && fin(join.seconds) && s < joi * WHAT THE ITEM BEFORE ENDED ON in its slot, pure: `[{ m, i, t, scope }]` -- the attachments up at its last frame * (`t` a video's or a GIF's source second there; a context post's on the panel over its own: `scope`). * `stepAt` / `mediaTimeAt` are post-item.mjs's (passed: this module imports none of it). + * + * @param {Record<string, any> | null} plan + * @param {{ stepAt: (plan: any, s: number) => any, mediaTimeAt: (step: any, s: number) => number | null, fps?: number }} o + * @returns {Array<{ m: Record<string, any>, i: number, t: number, scope?: string, step?: any }>} */ -export function endMediaOf(plan, { stepAt, mediaTimeAt, fps = 30 } = {}) { +export function endMediaOf(plan, { stepAt, mediaTimeAt, fps = 30 }) { if (!plan) return []; const last = Math.max(0, plan.total - 1 / fps); const show = [...(plan.panel?.shows ?? [])].reverse().find((sh) => sh.t0 <= last && sh.t1 >= last - 1e-6); @@ -121,7 +125,15 @@ export function applyJoinState(p, doc = document) { const card = doc.querySelector("[data-post-card]"); if (!body || !card) return; const raw = body.getAttribute("data-join"); - const bg = doc.querySelector("[data-join-bg]"); + let bg = doc.querySelector("[data-join-bg]"); + // A page drawn without the join's layer (Play's: the card route's page): its container's well made here, as the card's. + if (!bg && raw && p !== null && p !== undefined) { + const cs = getComputedStyle(card); + bg = doc.createElement("div"); + bg.setAttribute("data-join-bg", ""); + bg.setAttribute("style", `position:absolute;display:none;background:${cs.backgroundColor};border:${cs.borderTopWidth} solid ${cs.borderTopColor};border-radius:${cs.borderTopLeftRadius}`); + card.parentNode.insertBefore(bg, card); + } const from = doc.querySelector("[data-join-from]"); const slotFrom = doc.querySelector("[data-join-slot-from]"); const slot = doc.querySelector("[data-post-slot]");