Archilyzer · Source

archilyzer

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

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

umtool: a LINK VISIT -- a status link in a drawn post's words to a post the card draws (the quote, a linked post, a post it answers): a pointer glides to the link, clicks (a ripple), and the linked post opens as it comes in -- or, read earlier (a thread read in date order), is lit again, full, for its hold (render.posts.linkVisit, item linkVisit=false); a linked post shown, not read, is hidden until its click; the build and Play draw it (post-link-visit.mjs)

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

Diffstat:
Mumtool/components/projects/review/PostItemPlayer.tsx | 4++++
Mumtool/report-to-video/package.json | 1+
Mumtool/report-to-video/post-item.mjs | 14+++++++++++---
Aumtool/report-to-video/post-link-visit.mjs | 220+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mumtool/report-to-video/post-render.mjs | 4++++
Mumtool/report-to-video/post-thread-scenes.test.mjs | 32++++++++++++++++++++++++++++++++
Mumtool/report-to-video/post-thread.mjs | 7+++++++
Mumtool/report-to-video/read-follow.mjs | 20+++++++++++++++-----
8 files changed, 294 insertions(+), 8 deletions(-)

diff --git a/umtool/components/projects/review/PostItemPlayer.tsx b/umtool/components/projects/review/PostItemPlayer.tsx @@ -3,6 +3,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 { applyVisitState } from "umtool-report-to-video/post-link-visit"; 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"; @@ -629,6 +630,9 @@ export default function PostItemPlayer({ useEffect(() => { const doc = readFrame.current?.contentDocument; if (doc && follow && doc.querySelector("[data-post-follow]")) applyFollowState(followNow, doc); + // A LINK VISIT (post-link-visit.mjs): the pointer and its click, as the build draws them. + const visits = (follow as { visits?: unknown[] } | null)?.visits; + if (doc && visits?.length) applyVisitState({ visits, st: followNow?.visit ?? null }, doc); }, [follow, followNow, followGeo]); 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; diff --git a/umtool/report-to-video/package.json b/umtool/report-to-video/package.json @@ -74,6 +74,7 @@ "./post-thread": "./post-thread.mjs", "./post-conversation": "./post-conversation.mjs", "./post-join": "./post-join.mjs", + "./post-link-visit": "./post-link-visit.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 @@ -38,6 +38,7 @@ import { WORD_ZOOM_HIGHLIGHT_ALPHA, cardTokens, cardWordsOf, findMatch, targetTe import { FOLLOW_MIN_SIZE, followBlocks, followSchedule, scopeBlocks, validatePostFollow } from "./read-follow.mjs"; import { panelSchedule, validatePostThread } from "./post-thread.mjs"; import { joinLayerHtml, validatePostJoin, validatePostJoinRender } from "./post-join.mjs"; +import { validatePostLinkVisit, validatePostLinkVisitRender, visitsEnd } from "./post-link-visit.mjs"; import { validatePostScene, validatePostSceneRender } from "./post-media-scene.mjs"; /** The platforms a post item may come from (deck.mjs POST_PLATFORMS). */ @@ -303,7 +304,8 @@ function planOf(entry, render, hold, prev = null, scene = null, mediaScene = nul const share = pics.length ? Math.max(POST_PICTURE_MIN, (span - videos) / pics.length) : 0; const steps = all.map((s) => (s.kind === "video" ? s : { ...s, seconds: round3(share) })); const media = round3(steps.reduce((n, s) => n + s.seconds, 0)); - const total = hold ?? round3(Math.max(span, media)); + // A LINK VISIT (post-link-visit.mjs) lit after the read runs on its hold: the item holds it. + const total = hold ?? round3(Math.max(span, media, follow?.visits ? visitsEnd(follow.visits) : 0)); const plan = planSteps(steps, 0, total); // A video shorter than the read: looped to the end, or (the default) its last frame held. const last = plan.steps[plan.steps.length - 1]; @@ -549,6 +551,8 @@ export function validatePostItem(e) { errors.push(...validatePostScene(e)); // Its join with the item before (post-join.mjs): false (a cut) or { seconds }. errors.push(...validatePostJoin(e)); + // Its link visit (post-link-visit.mjs): false (none). + errors.push(...validatePostLinkVisit(e)); return errors; } @@ -587,7 +591,7 @@ export function validatePostItems(manifest) { const errors = []; const tl = Array.isArray(manifest?.timeline) ? manifest.timeline : []; for (const e of tl) if (e?.type === "post") errors.push(...validatePostItem(e)); - errors.push(...validatePostsRender(manifest?.render), ...validatePostSceneRender(manifest?.render), ...validatePostPanelRender(manifest?.render), ...validatePostJoinRender(manifest?.render)); + errors.push(...validatePostsRender(manifest?.render), ...validatePostSceneRender(manifest?.render), ...validatePostPanelRender(manifest?.render), ...validatePostJoinRender(manifest?.render), ...validatePostLinkVisitRender(manifest?.render)); // A word zoom on a word the project's list blanks (the corpus's and a post's markup are checked by the build). const own = { terms: projectRedactOf(manifest?.render) }; for (const e of tl) if (e?.type === "post") errors.push(...fxRedactionErrors(e, own)); @@ -886,7 +890,11 @@ export function wordsHtml(text, blurred, scope = null, hl = null, blocks = null) const word = (t) => esc(t) .replace(/@([A-Za-z0-9_]{1,30})/g, (m, h) => (set.has(h.toLowerCase()) ? `<span class="redact">@${"x".repeat(Math.max(4, Math.min(12, h.length)))}</span>` : `<span class="mention">${m}</span>`)) - .replace(/https?:\/\/\S+/g, (u) => `<span class="link">${u.length > 48 ? `${u.slice(0, 46)}…` : u}</span>`); + .replace(/https?:\/\/\S+/g, (u) => { + // A status link names its post (post-link-visit.mjs: the pointer finds it by `data-link`). + const id = /(?:x|twitter)\.com\/[^/\s]+\/status(?:es)?\/(\d{5,25})/i.exec(u)?.[1]; + return `<span class="link"${id ? ` data-link="${id}"` : ""}>${u.length > 48 ? `${u.slice(0, 46)}…` : u}</span>`; + }); if (!scope) return word(str(text)).replace(/\n/g, "<br>"); // `blocks` (read-follow.mjs scopeBlocks): runs of words wrapped `data-post-block="<k>"`, the read's blocks. const opens = new Map((blocks ?? []).map((b) => [b.from, b.k])); diff --git a/umtool/report-to-video/post-link-visit.mjs b/umtool/report-to-video/post-link-visit.mjs @@ -0,0 +1,220 @@ +// A LINK VISIT (umtool/docs/report-video.md, "Link visits"; operator, 4 Nov: "is the linked post read? If not can we +// have our transition visit it with a mouse click visual?", "show the post at the link being referred to since it's +// context"): a post's words hold a status link to a post the card draws -- the post it quotes (`quoted`, via a link), +// a post its words link to (`links[]`), a post it answers -- and the card VISITS it: a pointer glides to the link in +// the words, clicks (a ripple), and the linked post opens -- revealed then if it comes in after the link (its read, or +// a linked post shown, not read); lit again (an accent ring, at full strength) for `hold` s if it is on screen +// already (read earlier: a thread read in date order reads an older post first). +// +// render.posts.linkVisit = { on?: true, hold?: 1.4 } the cut's +// timeline[i].linkVisit = false one item's: none +// +// PURE (but the page functions, self-contained): the plan carries `follow.visits`, the state at a second carries +// `visit` (which, and how far its pointer and its ripple are), and the build and Play draw the same with +// applyVisitState after applyFollowState. + +import { statusIdOf, tileIdOf } from "./post-thread.mjs"; +import { cardText, linksOf, parentsOf } from "./post-item.mjs"; + +const isObj = (v) => !!v && typeof v === "object" && !Array.isArray(v); +const fin = (v) => typeof v === "number" && Number.isFinite(v); +const str = (v) => (typeof v === "string" ? v : ""); +const r3 = (v) => Math.round(v * 1000) / 1000; + +export const VISIT_DEFAULTS = Object.freeze({ on: true, hold: 1.4 }); +/** The pointer's glide (s), the click's ripple (s) -- the opening lands at the click's end. */ +export const VISIT_TIMES = Object.freeze({ move: 0.75, click: 0.3 }); + +/** One item's visit knobs. */ +export function visitKnobs(entry, render = undefined) { + const r = isObj(render?.posts?.linkVisit) ? render.posts.linkVisit : {}; + const k = { ...VISIT_DEFAULTS, ...(typeof r.on === "boolean" ? { on: r.on } : {}), ...(fin(r.hold) ? { hold: r.hold } : {}) }; + return entry?.linkVisit === false ? { ...k, on: false } : k; +} + +/** Every reason the cut's or an item's link-visit knob cannot be built. */ +export function validatePostLinkVisit(e) { + return e?.linkVisit === undefined || e.linkVisit === false ? [] : [`timeline ${e?.id ?? "?"}.linkVisit must be false (no link visit); absent: the cut's`]; +} +export function validatePostLinkVisitRender(render) { + const v = render?.posts?.linkVisit; + if (v === undefined) return []; + if (!isObj(v)) return ["render.posts.linkVisit must be { on?, hold? }"]; + const errors = Object.keys(v).filter((k) => !(k in VISIT_DEFAULTS)).map((k) => `render.posts.linkVisit.${k} is not a link-visit knob (on, hold)`); + if (v.on !== undefined && typeof v.on !== "boolean") errors.push("render.posts.linkVisit.on must be true or false"); + if (v.hold !== undefined && !(fin(v.hold) && v.hold >= 0.4 && v.hold <= 5)) errors.push("render.posts.linkVisit.hold must be 0.4–5 seconds"); + return errors; +} + +/** The text a tile draws (its words, as the card's wordsHtml marks a link in them). */ +function textOfScope(entry, scope) { + if (scope === "post") return cardText(entry); + if (scope === "quoted") return str(entry?.quoted?.text); + const m = /^(parent|linked):(\d)$/.exec(scope); + if (!m) return ""; + return str((m[1] === "parent" ? parentsOf(entry) : linksOf(entry))[Number(m[2])]?.text); +} + +/** + * THE VISITS of a planned card, pure: `[{ from, to, id, at, open, hold }]` -- the tile whose words hold the link + * (`from`), the tile it opens (`to`, the post with that `id`), the second the click lands (`at`), and whether the + * linked post OPENS there (`open`: it comes in then) or is lit again for `hold`. `thread`: the plan's (threadSchedule); + * `blocks`: read-follow's scheduled blocks. A visit needs its link on screen before the click (its tile in, by then). + */ +export function linkVisits(entry, thread, blocks, render = undefined) { + const k = visitKnobs(entry, render); + if (!k.on || !thread?.tiles?.length) return []; + const rows = thread.tiles; + const rowOf = (scope) => rows.find((r) => r.scope === scope) ?? null; + const idOf = (r) => (r.mode === "scene" ? r.scope.slice(5) : tileIdOf(entry, r)); + const shownAt = (r) => (r.from?.[1] > 0 ? 0 : fin(r.t1) ? r.t1 : 0); + const out = []; + // A quoted post the archive kept without its id: the status link in the words that names its author. + const handleOf = (u) => /(?:x|twitter)\.com\/([^/\s]+)\/status/i.exec(u)?.[1]?.toLowerCase() ?? null; + for (const to of rows) { + if (to.mode === "hidden" || to.mode === "scene") continue; + const own = idOf(to); + const qh = to.scope === "quoted" && !own ? str(entry?.quoted?.handle).replace(/^@/, "").toLowerCase() : ""; + if (!own && !qh) continue; + for (const from of rows) { + if (from === to || from.mode === "hidden" || from.mode === "scene") continue; + const urls = [...textOfScope(entry, from.scope).matchAll(/https?:\/\/\S+/g)].map((m) => m[0]); + const hit = urls.find((u) => (own ? statusIdOf(u) === own : handleOf(u) === qh && !!statusIdOf(u))); + if (!hit) continue; + const id = statusIdOf(hit); + const fromIn = shownAt(from); + // It comes in after the link is on screen: the click opens it (its reveal). + const reveal = to.from?.[1] === 0 && fin(to.t0) && to.t0 >= fromIn + VISIT_TIMES.move + VISIT_TIMES.click - 1e-6; + if (reveal) { + out.push({ from: from.scope, to: to.scope, id, at: r3(to.t0), open: true, hold: 0 }); + break; + } + // On screen already: lit again once the link's words are read (the block holding it), else his read's end. + const linkBlocks = (blocks ?? []).filter((b) => b.scope === from.scope && fin(b.start)); + const last = linkBlocks.sort((a, b) => a.start - b.start).pop(); + const at = last && fin(last.end) ? last.end : null; + if (at === null || at < fromIn + VISIT_TIMES.move + VISIT_TIMES.click) continue; + // A post its words link to, shown but not read: it is not on screen until the click opens it. + if (to.scope.startsWith("linked:") && to.mode === "context") { + out.push({ from: from.scope, to: to.scope, id, at: r3(at), open: true, hold: 0, reveal: true }); + break; + } + out.push({ from: from.scope, to: to.scope, id, at: r3(at), open: false, hold: k.hold }); + break; + } + } + return out.sort((a, b) => a.at - b.at); +} + +/** The latest a visit runs to (its lit hold's end): the plan holds the item at least that long. */ +export const visitsEnd = (visits) => Math.max(0, ...(visits ?? []).map((v) => v.at + (v.hold ?? 0) + 0.2)); + +/** + * THE VISIT's STATE at item second `s`, pure: `{ i, move, click, ring }` (null: none up) -- which visit, its pointer's + * glide (0..1), its ripple (0..1), the linked tile's ring (0..1: lit again, faded in and out). + */ +export function visitStateAt(visits, s) { + for (let i = 0; i < (visits ?? []).length; i += 1) { + const v = visits[i]; + const t0 = v.at - VISIT_TIMES.click - VISIT_TIMES.move; + const end = v.at + Math.max(0.35, v.hold ?? 0); + if (s < t0 || s > end) continue; + const move = Math.min(1, Math.max(0, (s - t0) / VISIT_TIMES.move)); + const click = s < v.at - VISIT_TIMES.click ? 0 : Math.min(1, (s - (v.at - VISIT_TIMES.click)) / (VISIT_TIMES.click + 0.25)); + let ring = 0; + if (!v.open && s >= v.at) { + const into = s - v.at; + ring = Math.min(1, into / 0.25, Math.max(0, (v.hold - into) / 0.35)); + } + return { i, move: r3(move), click: r3(click), ring: r3(Math.max(0, ring)) }; + } + return null; +} + +/** + * IN THE PAGE (self-contained: the build passes it to page.evaluate; Play calls it on its frame's document): the + * pointer and its ripple over the link (`[data-thread-tile="<from>"] [data-link="<id>"]`, where it is now -- after the + * follow state), and the linked tile's ring. `arg`: `{ visits, st }` -- the plan's, visitStateAt's (null: none). + */ +export function applyVisitState(arg, doc = document) { + const visits = arg && arg.visits; + const st = arg && arg.st; + let ptr = doc.querySelector("[data-visit-pointer]"); + let rip = doc.querySelector("[data-visit-ripple]"); + for (const el of Array.from(doc.querySelectorAll("[data-visit-ring]"))) el.removeAttribute("data-visit-ring"); + for (const el of Array.from(doc.querySelectorAll("[data-thread-tile][style*='box-shadow']"))) el.style.boxShadow = ""; + if (!st || !visits || !visits[st.i]) { + if (ptr) ptr.style.display = "none"; + if (rip) rip.style.display = "none"; + return; + } + const v = visits[st.i]; + const link = doc.querySelector(`[data-thread-tile="${v.from}"] [data-link="${v.id}"]`) ?? doc.querySelector(`[data-link="${v.id}"]`); + const card = doc.querySelector("[data-post-card]"); + if (!ptr) { + ptr = doc.createElement("div"); + ptr.setAttribute("data-visit-pointer", ""); + ptr.innerHTML = '<svg width="34" height="34" viewBox="0 0 24 24"><path d="M4 2 L4 20 L9 15 L12.5 22 L15.5 20.6 L12 13.8 L19 13.8 Z" fill="#fff" stroke="#111" stroke-width="1.4" stroke-linejoin="round"/></svg>'; + ptr.setAttribute("style", "position:absolute;z-index:20;pointer-events:none;display:none;filter:drop-shadow(0 2px 3px rgba(0,0,0,.5))"); + doc.body.appendChild(ptr); + } + if (!rip) { + rip = doc.createElement("div"); + rip.setAttribute("data-visit-ripple", ""); + rip.setAttribute("style", "position:absolute;z-index:19;pointer-events:none;display:none;border-radius:50%;border:3px solid #ffcf33"); + doc.body.appendChild(rip); + } + if (!link || !card) { + ptr.style.display = "none"; + rip.style.display = "none"; + return; + } + const r = link.getBoundingClientRect(); + const c = card.getBoundingClientRect(); + const tx = r.left + Math.min(r.width * 0.5, 60); + const ty = r.top + r.height * 0.55; + // From the card's lower right toward the link, eased. + const sx = c.right - 40; + const sy = c.bottom - 30; + const e = st.move < 0.5 ? 4 * st.move ** 3 : 1 - (-2 * st.move + 2) ** 3 / 2; + const fade = st.click >= 1 ? Math.max(0, 1 - (st.ring > 0 ? 0 : 1)) : 1; + ptr.style.display = st.move > 0 && fade > 0 ? "block" : "none"; + ptr.style.left = `${sx + (tx - sx) * e - 4}px`; + ptr.style.top = `${sy + (ty - sy) * e - 2}px`; + ptr.style.transform = st.click > 0 && st.click < 0.4 ? "scale(0.86)" : ""; + if (st.click > 0 && st.click < 1) { + const d = 12 + st.click * 52; + rip.style.display = "block"; + rip.style.width = `${d}px`; + rip.style.height = `${d}px`; + rip.style.left = `${tx - d / 2}px`; + rip.style.top = `${ty - d / 2}px`; + rip.style.opacity = String(1 - st.click); + } else rip.style.display = "none"; + link.setAttribute("data-visit-ring", ""); + if (st.ring > 0) { + const tile = doc.querySelector(`[data-thread-tile="${v.to}"]`); + if (tile) { + tile.style.boxShadow = `0 0 0 3px rgba(255, 207, 51, ${st.ring}), 0 0 24px rgba(255, 207, 51, ${st.ring * 0.4})`; + tile.style.borderRadius = "12px"; + tile.setAttribute("data-visit-ring", ""); + } + } +} + +/** + * The thread's rows with the visits laid on (pure, a copy): a linked post shown, not read, hidden until its click and + * opened then (to its context size); a post lit again for its hold (`pulse`: full size and strength over it, eased in + * and out -- tileStateAt's). + */ +export function visitRows(thread, visits) { + if (!thread || !visits?.length) return thread; + const tiles = thread.tiles.map((r) => { + const v = visits.find((x) => x.to === r.scope); + if (!v) return r; + if (v.reveal) return { ...r, from: [thread.shrink, 0], to: [thread.shrink, thread.dim], t0: r3(Math.max(0, v.at - 0.05)), t1: r3(v.at + 0.35) }; + if (!v.open) return { ...r, pulse: { t0: r3(v.at), t1: r3(v.at + 0.3), t2: r3(v.at + Math.max(0.35, v.hold - 0.3)), t3: r3(v.at + Math.max(0.65, v.hold)) } }; + return r; + }); + return { ...thread, tiles }; +} diff --git a/umtool/report-to-video/post-render.mjs b/umtool/report-to-video/post-render.mjs @@ -27,6 +27,7 @@ import { blurFilters, blurOn, censorEntry, labelFilter } from "./post-censor.mjs import { sceneEntry } from "./post-media-scene.mjs"; import { panelReadErrors } from "./post-thread.mjs"; import { applyJoinState, endMediaOf } from "./post-join.mjs"; +import { applyVisitState } from "./post-link-visit.mjs"; import { WORD_ZOOM_DEFAULTS, findMatch, overlappingZooms, resolveWordZoom, targetScope, targetTextOf, wordZoomTimes, zoomSpan, zoomTarget, zoompanExprs } from "./word-zoom.mjs"; const r3 = (v) => Math.round(v * 1000) / 1000; @@ -439,11 +440,14 @@ export async function shootFollow(page, { follow, total, fps, box, dir, geo = nu const file = path.join(fdir, `f-${String(shots.size).padStart(5, "0")}.png`); await page.evaluate(applyFollowState, run.st); if (joined) await page.evaluate(applyJoinState, run.st.join ?? null); + // A LINK VISIT (post-link-visit.mjs): the pointer and its click over the link where the state puts it. + if (follow.visits?.length) await page.evaluate(applyVisitState, { visits: follow.visits, st: run.st.visit ?? null }); await page.screenshot({ path: file, clip }); shots.set(run.key, file); } await page.evaluate(applyFollowState, null); if (joined) await page.evaluate(applyJoinState, null); + if (follow.visits?.length) await page.evaluate(applyVisitState, { visits: follow.visits, st: null }); const q = (f) => `'${f.replace(/'/g, "'\\''")}'`; const lines = ["ffconcat version 1.0"]; for (const run of runs) lines.push(`file ${q(shots.get(run.key))}`, `duration ${(run.n / fps).toFixed(6)}`); diff --git a/umtool/report-to-video/post-thread-scenes.test.mjs b/umtool/report-to-video/post-thread-scenes.test.mjs @@ -247,3 +247,35 @@ test("THE JOIN (operator, 4 Nov: \"a thread-like smooth transition here rather t const vplan = { total: 10, steps: [{ kind: "video", at: 0, seconds: 9.6, srcFrom: 0, srcTo: 9.6, items: [{ i: 0, src: "v.mp4", kind: "video", seconds: 9.6 }] }] }; assert.deepEqual(endMediaOf(vplan, { stepAt, mediaTimeAt }).map((x) => [x.m.src, x.t]), [["v.mp4", 9.48]]); }); + +import { linkVisits, visitStateAt } from "./post-link-visit.mjs"; + +test("A LINK VISIT: his reply ends \"Here's my take on it. <link>\" to his own take, read first (in date order) -- once the link is read the pointer clicks it and the take is lit again, full, for its hold; the item holds it", () => { + const takeText = "Here is my take on the whole situation, in two points."; + const kirsche = "I hate watching people defend the very tactics that lead to that happening."; + const words = "Kirsche you're wrong on this one, strawb seems like a traitor.\n\nHere's my take on it.\n\nhttps://x.com/subject/status/2115473673671020640"; + const e = narrate(base({ date: at(19), text: words, quoted: { author: "Subject", handle: "subject", date: at(16), text: takeText }, parents: [ref("2115500212617703691", "kirsche", kirsche, 17)] }), [[takeText], [kirsche], ["Kirsche you're wrong on this one, strawb seems like a traitor.\n\nHere's my take on it."]]); + const plan = postItemPlan(e, { postNarration: { lead: 0.4 } }); + assert.deepEqual(plan.follow.visits.map((v) => [v.from, v.to, v.id, v.open]), [["post", "quoted", "2115473673671020640", false]]); + const v = plan.follow.visits[0]; + assert.ok(plan.total >= v.at + v.hold, "the item holds the visit"); + const st = visitStateAt(plan.follow.visits, v.at + 0.6); + assert.equal(st.ring, 1); + const row = plan.follow.thread.tiles.find((t) => t.scope === "quoted"); + assert.deepEqual(followStateAt(plan.follow, null, v.at + 0.6).tiles.quoted.slice(0, 2), [1, 1]); + assert.ok(row.pulse); + const html = postCardHtml(e, { width: 1600, height: 900, follow: true, thread: plan.follow.thread }); + assert.match(html, /<span class="link" data-link="2115473673671020640">/); + const geo = fakeGeo(plan, { H: 400 }); + assert.deepEqual(readInViewErrors(plan.follow, geo, shotStateAt(plan.follow, followPath(plan.follow, geo), 30), { total: plan.total, id: e.id }), []); +}); + +test("A LINK VISIT that OPENS: SaberXVeritas's \"this you? <link>\", then the linked post read -- the click lands as it comes in", () => { + const link = { id: "2116805001309823299", handle: "Infinity_Virus_", author: "Infinity", date: at(8), text: "Ya try to be civil and they go insane" }; + const saber = ref("5", "SaberXVeritas", "this you? https://x.com/Infinity_Virus_/status/2116805001309823299", 9); + const e = narrate(base({ parents: [saber], links: [link] }), [["this you?", "parent:0"], ["Ya try to be civil and they go insane", "linked:0"], [base().text, "post"]], { roles: true }); + const plan = postItemPlan(e, { postNarration: { lead: 0.4 } }); + assert.deepEqual(plan.follow.visits.map((v) => [v.from, v.to, v.open]), [["parent:0", "linked:0", true]]); + const row = plan.follow.thread.tiles.find((t) => t.scope === "linked:0"); + assert.equal(plan.follow.visits[0].at, row.t0); +}); diff --git a/umtool/report-to-video/post-thread.mjs b/umtool/report-to-video/post-thread.mjs @@ -630,6 +630,12 @@ export function tileStateAt(row, s) { }; let v = step(row.from, row.to, row.t0, row.t1); if (row.then && s > row.then.t0) v = step(row.to, row.then.to, row.then.t0, row.then.t1); + // A LINK VISIT (post-link-visit.mjs): lit again -- full size and strength over its hold, eased in and out. + const p = row.pulse; + if (p && s > p.t0 && s < p.t3) { + const w = s < p.t1 ? ease((s - p.t0) / Math.max(1e-6, p.t1 - p.t0)) : s > p.t2 ? 1 - ease((s - p.t2) / Math.max(1e-6, p.t3 - p.t2)) : 1; + v = [mix(v[0], 1, w), mix(v[1], 1, w)]; + } return [Math.round(v[0] * 1000) / 1000, Math.round(v[1] * 1000) / 1000]; } @@ -646,6 +652,7 @@ export function threadTimes(thread) { for (const row of thread?.tiles ?? []) { if (row.t1 > row.t0) out.add(row.t0).add(row.t1); if (row.then) out.add(row.then.t0).add(row.then.t1); + if (row.pulse) out.add(row.pulse.t0).add(row.pulse.t1).add(row.pulse.t2).add(row.pulse.t3); } return [...out].sort((a, b) => a - b); } diff --git a/umtool/report-to-video/read-follow.mjs b/umtool/report-to-video/read-follow.mjs @@ -48,6 +48,7 @@ import { isNarrated, narrationSchedule, partStartOnItem, pickedTake, scriptParts import { cardTokens, easeOf, normWord, scriptWordsOf } from "./word-zoom.mjs"; import { partRoles, threadGeoAt, threadKnobs, threadLayout, threadSchedule, threadStateAt } from "./post-thread.mjs"; import { sceneLayout, sceneRows, sceneSchedule } from "./post-media-scene.mjs"; +import { linkVisits, visitRows, visitStateAt } from "./post-link-visit.mjs"; export const FOLLOW_DEFAULTS = Object.freeze({ on: true, dim: 0.65, ease: 0.25 }); export const FOLLOW_LIMITS = Object.freeze({ dim: [0.2, 1], ease: [0, 2] }); @@ -395,9 +396,12 @@ export function followSchedule(entry, render = undefined, { hold = null, narrati // item's on its thread read's schedule, an un-narrated one's on the scene's. const layout = ms ? sceneLayout(base, entry, ms) : base; const own = !layout?.on ? null : base ? threadSchedule(entry, render, { layout, blocks, lead: FOLLOW_PAN.lead }) : sceneSchedule(threadKnobs(entry, render), { layout, blocks, lead: FOLLOW_PAN.lead }); - const thread = ms ? sceneRows(own, layout) : own; + const thread0 = ms ? sceneRows(own, layout) : own; + // LINK VISITS (post-link-visit.mjs): a link in the words visited -- the pointer, the click, the post opened. + const visits = thread0 && isNarrated(entry) ? linkVisits(entry, thread0, blocks, render) : []; + const thread = visits.length ? visitRows(thread0, visits) : thread0; // THE JOIN (post-join.mjs): its first seconds morph from the item before as it ended. - return { dim: k.dim, ease: k.ease, readEnd, source: map.source, blocks, ...(thread ? { thread } : {}), ...(join && fin(join.seconds) ? { join: { seconds: join.seconds } } : {}) }; + return { dim: k.dim, ease: k.ease, readEnd, source: map.source, blocks, ...(thread ? { thread } : {}), ...(visits.length ? { visits } : {}), ...(join && fin(join.seconds) ? { join: { seconds: join.seconds } } : {}) }; } /** The block being read at item second `s` (its k), or null (before the read's first block, or none). */ @@ -586,7 +590,7 @@ const ramp = (s, a, d) => (d <= 0 ? (s >= a ? 1 : 0) : easeOf("inOut", (s - a) / * @param {Record<string, any> | null} follow * @param {Record<string, any> | null} path * @param {number} s - * @returns {{ op: Record<string, number>, offset: number, fadeTop: number, fadeBottom: number, current: any, tiles?: Record<string, number[]>, join?: number }} + * @returns {{ op: Record<string, number>, offset: number, fadeTop: number, fadeBottom: number, current: any, tiles?: Record<string, number[]>, join?: number, visit?: { i: number, move: number, click: number, ring: number } }} */ export function followStateAt(follow, path, s) { const op = {}; @@ -611,7 +615,11 @@ export function followStateAt(follow, path, s) { const edge = 24; const current = read.length ? followBlockAt(follow, s) ?? read[0].k : null; // THE JOIN (post-join.mjs): its progress while the card morphs from the item before's. + /** @type {Record<string, any>} */ const jp = follow.join && fin(follow.join.seconds) && s < follow.join.seconds - 1e-6 ? { join: Math.round((Math.max(0, s) / follow.join.seconds) * 1000) / 1000 } : {}; + // A LINK VISIT (post-link-visit.mjs): the pointer, its click, the linked post's ring. + const vs = follow.visits?.length ? visitStateAt(follow.visits, s) : null; + if (vs) jp.visit = vs; if (follow.thread) { // THREADED (post-thread.mjs): each tile's scale and opacity, with its full height (the page sets its slot's). const ts = threadStateAt(follow.thread, s); @@ -648,7 +656,7 @@ export function followStateAt(follow, path, s) { } /** A state's key: two frames with the same key draw the same card (the build shoots each key once). */ -export const followStateKey = (st) => JSON.stringify([st.op, st.offset, st.fadeTop, st.fadeBottom, ...(st.tiles ? [st.tiles] : []), ...(st.join !== undefined ? [st.join] : [])]); +export const followStateKey = (st) => JSON.stringify([st.op, st.offset, st.fadeTop, st.fadeBottom, ...(st.tiles ? [st.tiles] : []), ...(st.join !== undefined ? [st.join] : []), ...(st.visit ? [st.visit] : [])]); /** * Whether a state draws the card PAGE AS DRAWN (no state applied): nothing @@ -661,7 +669,7 @@ export const followStateKey = (st) => JSON.stringify([st.op, st.offset, st.fadeT */ export function isDrawnState(st) { if (!st) return true; - if (fin(st.join)) return false; + if (fin(st.join) || st.visit) return false; if (Object.values(st.op ?? {}).some((o) => fin(o) && o < 0.9995)) return false; if (fin(st.offset) && Math.abs(st.offset) >= 0.5) return false; if ((st.fadeTop ?? 0) > 0 || (st.fadeBottom ?? 0) > 0) return false; @@ -786,6 +794,8 @@ export function readInViewErrors(follow, geo, stateAt, { total = null, id = "?" const lim = ctxMode ? (row.scope === "quoted" && th.quotedAt !== "above" ? [1, th.dim] : [th.shrink, th.dim]) : row.to; const from = ctxMode ? 0 : row.t1 + 0.05; for (let s = from; s <= end + 1e-9; s += 0.1) { + // Lit again by a link visit (post-link-visit.mjs): its hold is the visit's, not a read's. + if (row.pulse && s > row.pulse.t0 - 1e-6 && s < row.pulse.t3 + 1e-6) continue; const v = look(r3(s)); const sc = v.scaleOf(row.scope); const op = v.opOf(row.scope);