Archilyzer · Source

archilyzer

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

commit d3d85cdb078cd51156ca4a24321bcf641e19a3ae
parent c86b4e9c1fe54597483184de8e654b859d081797
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Tue,  3 Nov 2026 16:47:53 -0500

umtool: read-follow in Play and on the post bench -- Play lights and pans the card page live on the plan's follow (the same states the build shoots); the bench shows the block map (each block, its text, the part that reads it and when -- click to go there, the one being read marked) and this post's follow knobs (the cut's / on / off, dim, ease)

The card page route draws the blocks and the flow when the post follows;
PostItemPlayer measures the page's geometry once it is drawn (measureFollow),
works out the pan's path and sets followStateAt(s) each tick
(data-post-follow-block / -offset / -pans on the player); a word zoom's word is
measured as the card is at the zoom's peak. The bench saves `follow` with its
other knobs.

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

Diffstat:
Mumtool/app/api/report/post-item/route.ts | 3+++
Mumtool/components/projects/PostBench.tsx | 4++++
Aumtool/components/projects/PostFollowPanel.tsx | 133+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mumtool/components/projects/review/PostItemPlayer.tsx | 36+++++++++++++++++++++++++++++++++++-
4 files changed, 175 insertions(+), 1 deletion(-)

diff --git a/umtool/app/api/report/post-item/route.ts b/umtool/app/api/report/post-item/route.ts @@ -7,6 +7,7 @@ import { withEditNotes } from "@/lib/report/guard"; import { StaleToken, StructureRefused, manifestToken, updatePostFx, updatePostItem, updatePostNarration } from "@/lib/report/manifest.mjs"; import { pickedTake } from "umtool-report-to-video/post-narration"; import { scriptWordTimes } from "umtool-report-to-video/word-zoom"; +import { followKnobs } from "umtool-report-to-video/read-follow"; import { recognizedOf, takeWordSources, wordsFileOf } from "@/lib/report/postFxCli.mjs"; import { rangeResponse, resolveReport } from "@/lib/report/serve.mjs"; import { resolveTakeManifest } from "@/lib/report/takeManifest.mjs"; @@ -163,6 +164,8 @@ export async function GET(request: Request) { fonts: { regular: `${base}&font=regular`, bold: `${base}&font=bold` }, phase: q.get("phase") === "media" ? "media" : "read", parentShotUrl: parentShot, + // Its read-follow (read-follow.mjs): the blocks and the flow Play lights and pans, as the build's page has them. + follow: q.get("phase") !== "media" && followKnobs(found.item, (found.manifest.render ?? render) as Record<string, unknown>).on, }); return new Response(html, { headers: { "content-type": "text/html; charset=utf-8", ...noStore } }); } diff --git a/umtool/components/projects/PostBench.tsx b/umtool/components/projects/PostBench.tsx @@ -8,6 +8,7 @@ import { cn } from "@/lib/utils"; import { postBenchHref } from "@/lib/hrefs"; import { POST_HOLD, POST_MEDIA_MIN_SPAN, POST_PARAPHRASE_MAX, contextReadSeconds, postItemPlan, readingSeconds, ruleSeconds } from "umtool-report-to-video/post-item"; import PostItemPlayer, { type PostPlan } from "./review/PostItemPlayer"; +import PostFollowPanel from "./PostFollowPanel"; import PostNarrationPanel from "./PostNarrationPanel"; import PostZoomPanel from "./PostZoomPanel"; import { wordZoomTimes, zoomSpan } from "umtool-report-to-video/word-zoom"; @@ -130,6 +131,8 @@ export default function PostBench({ hold: typeof e.hold === "number" ? e.hold : null, mediaLayout: e.mediaLayout ?? null, redact: typeof e.redact === "boolean" ? e.redact : null, + // Its read-follow (read-follow.mjs): false is off; its knobs, each null when it is the cut's. + follow: e.follow === false ? false : e.follow && typeof e.follow === "object" ? { on: null, dim: null, ease: null, ...(e.follow as Record<string, unknown>) } : null, media: Object.fromEntries( (e.media ?? []).map((m, i) => [ i, @@ -292,6 +295,7 @@ export default function PostBench({ setToken(t); }} /> + <PostFollowPanel entry={entry} plan={plan} render={render} s={s} setS={setS} setEntry={(f) => setEntry((e) => f(e) as Entry)} /> <PostNarrationPanel project={project} entry={entry} diff --git a/umtool/components/projects/PostFollowPanel.tsx b/umtool/components/projects/PostFollowPanel.tsx @@ -0,0 +1,133 @@ +"use client"; + +import { useMemo } from "react"; +import { FOLLOW_DEFAULTS, FOLLOW_LIMITS, cardScopes, followBlockAt, followKnobs } from "umtool-report-to-video/read-follow"; +import { cardWordsOf } from "umtool-report-to-video/word-zoom"; +import type { PostPlan } from "./review/PostItemPlayer"; + +// --------------------------------------------------------------------------- +// A POST's READ-FOLLOW ON THE BENCH (report-to-video/read-follow.mjs; knobs.md, +// "Read-follow"): the BLOCK MAP -- each block of the card's words, which text +// it is in, the part of the read that reads it and when (click: the playhead +// there), the one being read marked -- and this post's knobs: follow on, off or +// the cut's, the other blocks' dim, the ease. The knobs are the bench's draft +// (its Save writes them, as hold and redact). +// --------------------------------------------------------------------------- + +type Entry = Record<string, unknown> & { id: string }; +type Follow = false | { on?: boolean; dim?: number; ease?: number } | undefined; + +const SCOPE_NAME = (s: string) => (s === "post" ? "post" : s === "quoted" ? "quoted" : s.replace("parent:", "parent ")); + +export default function PostFollowPanel({ + entry, plan, render, s, setS, setEntry, +}: { + entry: Entry; + plan: PostPlan; + render: Record<string, unknown>; + s: number; + setS: (s: number) => void; + setEntry: (f: (e: Entry) => Entry) => void; +}) { + const follow = plan.follow ?? null; + const own = entry.follow as Follow; + const k = followKnobs(entry, render) as { on: boolean; dim: number; ease: number }; + const cutOn = (followKnobs({}, render) as { on: boolean }).on; + const mode = own === false ? "off" : own && typeof own === "object" && own.on === true ? "on" : "auto"; + const texts = useMemo(() => new Map(cardScopes(entry).map((sc: { scope: string; text: string }) => [sc.scope, cardWordsOf(sc.text)])), [entry]); + const cur = follow ? followBlockAt(follow, s) : null; + const setOwn = (next: Follow) => + setEntry((e) => { + const out = { ...e }; + if (next === undefined || (typeof next === "object" && !Object.keys(next).length)) delete out.follow; + else out.follow = next; + return out; + }); + const knob = (key: "dim" | "ease", v: string) => { + const base = own && typeof own === "object" ? { ...own } : {}; + if (v === "") delete base[key]; + else base[key] = Number(v); + setOwn(base); + }; + const read = follow ? follow.blocks.filter((b) => b.start !== null).length : 0; + return ( + <section className="rounded border border-[var(--color-line)] bg-[var(--color-panel)] p-3 text-[12px]" data-post-follow-panel=""> + <div className="mb-2 flex flex-wrap items-center gap-2"> + <h2 className="micro m-0">read-follow</h2> + <select + value={mode} + onChange={(e) => setOwn(e.target.value === "off" ? false : e.target.value === "on" ? { ...(own && typeof own === "object" ? own : {}), on: true } : own && typeof own === "object" ? (({ on: _on, ...rest }) => rest)(own) : undefined)} + data-post-follow-mode="" + aria-label="read-follow on this post" + > + <option value="auto">the cut&apos;s ({cutOn ? "on" : "off"})</option> + <option value="on">on</option> + <option value="off">off</option> + </select> + <label className="flex items-center gap-1"> + dim + <input + type="number" + min={FOLLOW_LIMITS.dim[0]} + max={FOLLOW_LIMITS.dim[1]} + step={0.05} + className="w-16" + value={own && typeof own === "object" && typeof own.dim === "number" ? own.dim : ""} + placeholder={String(k.dim ?? FOLLOW_DEFAULTS.dim)} + onChange={(e) => knob("dim", e.target.value)} + data-post-follow-dim="" + /> + </label> + <label className="flex items-center gap-1"> + ease + <input + type="number" + min={FOLLOW_LIMITS.ease[0]} + max={FOLLOW_LIMITS.ease[1]} + step={0.05} + className="w-16" + value={own && typeof own === "object" && typeof own.ease === "number" ? own.ease : ""} + placeholder={String(k.ease ?? FOLLOW_DEFAULTS.ease)} + onChange={(e) => knob("ease", e.target.value)} + data-post-follow-ease="" + /> + s + </label> + </div> + {!follow ? ( + <p className="m-0 text-text-2">off: the card shows its words as they are, shrunk to fit.</p> + ) : ( + <> + <p className="m-0 mb-1 text-text-2" data-post-follow-summary=""> + {follow.blocks.length} block{follow.blocks.length === 1 ? "" : "s"}, {read} read + {follow.source === "take" ? " (the take's parts)" : follow.source === "script" ? " (the script's parts, timed by words)" : " (the reading rule)"}; the read ends at {follow.readEnd.toFixed(1)} s + </p> + <ol className="m-0 max-h-56 list-none space-y-0.5 overflow-auto p-0" data-post-follow-map=""> + {follow.blocks.map((b) => { + const words = texts.get(b.scope) ?? []; + const head = words.slice(b.from, Math.min(b.to + 1, b.from + 8)).join(" "); + return ( + <li key={b.k} data-post-follow-row={b.k} data-current={cur === b.k ? "1" : undefined} className={cur === b.k ? "rounded bg-white/10" : ""}> + <button + type="button" + disabled={b.start === null} + className="flex w-full gap-2 px-1 text-left disabled:opacity-60" + onClick={() => b.start !== null && setS(b.start)} + title={b.start === null ? "no part reads it: dimmed while the read runs" : `part ${b.part! + 1}`} + > + <span className="w-12 shrink-0 font-mono tabular-nums">{b.start === null ? "—" : `${b.start.toFixed(1)}s`}</span> + <span className="w-14 shrink-0 text-text-2">{SCOPE_NAME(b.scope)}</span> + <span className="min-w-0 truncate"> + {head} + {b.to + 1 - b.from > 8 ? "…" : ""} + </span> + </button> + </li> + ); + })} + </ol> + </> + )} + </section> + ); +} 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 { dryGainAt, mixPhaseAt, pickedTake, wetGainAt } from "umtool-report-to-video/post-narration"; +import { applyFollowState, followPath, followStateAt, measureFollow } from "umtool-report-to-video/read-follow"; import { WORD_ZOOM_HIGHLIGHT_ALPHA, findMatch, highlightAt, resolveWordZoom, targetScope, targetTextOf, wordZoomTimes, zoomAt, zoomProgressAt, zoomSpan, zoomWindow } from "umtool-report-to-video/word-zoom"; // --------------------------------------------------------------------------- @@ -23,6 +24,11 @@ import { WORD_ZOOM_HIGHLIGHT_ALPHA, findMatch, highlightAt, resolveWordZoom, tar // card's contents scaled toward the word's box (measured in the card page: its // `data-w` spans) inside the card, which clips them, its highlight fading in // under the word -- the card page's own elements transformed, nothing redrawn. +// +// READ-FOLLOW (read-follow.mjs) plays live on the plan's `follow`: the card +// page carries the read's blocks and its flow; the pan's path is worked out +// from the page's geometry once it is drawn, and each tick sets the state at +// the item's second (followStateAt -- the build's frames are the same states). // --------------------------------------------------------------------------- type Rect = { x: number; y: number; width: number; height: number }; @@ -69,11 +75,21 @@ function applyZoom(doc: Document, z: LiveZoom | null, zf: number, hl: number, bo /** A narrated item's mix on its clock (post-narration.mjs narrationSchedule). */ export type NarrationSchedule = { at: number; seconds: number; takeSeconds?: number; rate?: number; voiceEnd: number; rampEnd: number; wet: number; lowpassHz: number; duck: boolean; attach?: string; lufs?: number }; +/** The plan's read-follow (read-follow.mjs followSchedule). */ +export type FollowPlan = { + dim: number; + ease: number; + readEnd: number; + source: string; + blocks: Array<{ k: number; scope: string; from: number; to: number; part: number | null; start: number | null; end: number | null }>; +}; + export type PostPlan = { reading: number; total: number; held: number; narration?: NarrationSchedule; + follow?: FollowPlan; steps: Array<{ kind: string; at: number; @@ -323,10 +339,19 @@ export default function PostItemPlayer({ 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]); + // ---- read-follow, live: the page's geometry measured once it is drawn, the path from it ---- + const follow = plan.follow ?? null; + const [followGeo, setFollowGeo] = useState<ReturnType<typeof measureFollow>>(null); + const followRoute = useMemo(() => (follow && followGeo ? followPath(follow, followGeo) : null), [follow, followGeo]); const measure = useCallback(() => { const doc = readFrame.current?.contentDocument; if (!doc || doc.body?.getAttribute("data-post-ready") !== "1") return false; const card = doc.querySelector("[data-post-card]") as HTMLElement | null; + // 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; + setFollowGeo(geo); + const route = follow && geo ? followPath(follow, geo) : null; const list = Array.isArray(entry.fx) ? (entry.fx as Array<Record<string, unknown>>) : []; if (!card || !list.length) { setZooms([]); @@ -350,6 +375,7 @@ export default function PostItemPlayer({ const m = findMatch(targetTextOf(entry, fx.target) ?? "", fx.match, fx.occurrence); if (m.error) return; const scope = targetScope(fx.target); + if (follow) applyFollowState(followStateAt(follow, route, zoomSpan(fx0, t.t).t1), doc); let x0 = Infinity, y0 = Infinity, x1 = -Infinity, y1 = -Infinity; for (let w = m.from; w <= m.to; w += 1) { const el = doc.querySelector(`[data-w="${scope}:${w}"]`); @@ -361,7 +387,7 @@ export default function PostItemPlayer({ }); setZooms(out); return true; - }, [entry, zoomTimes, box.height]); + }, [entry, zoomTimes, box.height, follow]); const onFrameLoad = useCallback(() => { let tries = 0; const tick = () => { @@ -381,6 +407,11 @@ export default function PostItemPlayer({ const doc = readFrame.current?.contentDocument; if (doc) applyZoom(doc, live, zf, hl, boxes.current); }, [live, zf, hl]); + const followNow = useMemo(() => (follow ? followStateAt(follow, followRoute, s) : null), [follow, followRoute, s]); + useEffect(() => { + const doc = readFrame.current?.contentDocument; + if (doc && follow && doc.querySelector("[data-post-follow]")) applyFollowState(followNow, 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; return ( @@ -398,6 +429,9 @@ export default function PostItemPlayer({ data-post-zooms={zooms.length ? String(zooms.length) : undefined} data-post-zoom={zooms.length ? String(Math.round(zf * 100) / 100) : undefined} data-post-zoom-fx={live ? String(live.i) : undefined} + data-post-follow-block={followNow?.current !== null && followNow?.current !== undefined ? String(followNow.current) : undefined} + data-post-follow-offset={followNow && followRoute?.segments.length ? String(Math.round(followNow.offset)) : undefined} + data-post-follow-pans={followRoute ? String(followRoute.segments.length) : undefined} className="pointer-events-none absolute inset-0 overflow-hidden" > {mix && voiceTake && (