Archilyzer · Source

archilyzer

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

commit 32a75a7eed175b464a21a450c0e05440eb7f4ccb
parent db0a620f98c66bb552718bb8be8ea21fa775d22e
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Mon, 26 Oct 2026 23:14:38 -0400

report-to-video: the finale's frames reused by their keys too

The finale is a window of the cut: frame n is cut time from + n/fps, its
own smoothstep ease modelled only as the page writes it. Its cue times and
its window's start go on the cue grid (times within 2 ms of main on the
Huck cut's 181 finale cues), so a finale moved by an earlier change
assembles from its last render instead of rendering 3,000 frames again.

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

Diffstat:
Mumtool/report-to-video/chrome-finale.mjs | 14+++++++++-----
Mumtool/report-to-video/compose-chrome.mjs | 2+-
Mumtool/report-to-video/deck-claims.test.mjs | 4+++-
Mumtool/report-to-video/finale.test.mjs | 4++--
Mumtool/report-to-video/frame-keys.mjs | 25+++++++++++++++++++------
5 files changed, 34 insertions(+), 15 deletions(-)

diff --git a/umtool/report-to-video/chrome-finale.mjs b/umtool/report-to-video/chrome-finale.mjs @@ -22,7 +22,7 @@ // in place. Either way the page fades out through the dissolve after the run. // // The timeline is cues, each stating its from (chrome-deck.mjs says why). -import { finaleRail, pageDuration, resolveDeck } from "./deck.mjs"; +import { cueTime, cueTimeAfter, finaleRail, pageDuration, resolveDeck } from "./deck.mjs"; import { finaleClaimsMarkup } from "./chrome-claims.mjs"; import { mix, rgba, shapeCss, subtitleMarkup } from "./chrome-deck.mjs"; import { resolveFactcheck, tallyFinals, tallyOf, tallyVerdicts, VERDICT_SHAPES } from "./factcheck.mjs"; @@ -139,7 +139,9 @@ export function finaleCues(schedule, render, L = finaleLayout(schedule, render)) const init = {}; const put = (k, v) => { init[k] = { ...(init[k] ?? {}), ...v }; }; const ev = []; - const add = (k, at, dur, to, ease, why) => ev.push({ k, at: r4(at), dur: r4(Math.max(INSTANT, dur)), to, ease, why }); + // Cue times on the sub-frame grid (deck.mjs cueTime), durations to 4 places. + const fps = Number(schedule.fps ?? render.fps ?? 30); + const add = (k, at, dur, to, ease, why) => ev.push({ k, at: cueTime(at, fps), dur: r4(Math.max(INSTANT, dur)), to, ease, why }); const ft = L.foot.track, bt = L.rail.track; // From a rect the footer drew to this one: a uniform scale, centres matched @@ -277,14 +279,14 @@ export function finaleCues(schedule, render, L = finaleLayout(schedule, render)) const free = freeAt.get(e.k) ?? -Infinity; if (at < free) { const end = at + dur; - at = r4(free); + at = cueTimeAfter(free, fps); dur = r4(Math.max(INSTANT, end - at)); } const cur = state[e.k] ?? (state[e.k] = {}); const from = {}; for (const p of Object.keys(e.to)) from[p] = cur[p] ?? (p.startsWith("scale") || p === "opacity" || p === "autoAlpha" ? 1 : 0); Object.assign(cur, e.to); - freeAt.set(e.k, r4(at + dur)); + freeAt.set(e.k, at + dur); cues.push({ k: e.k, at, dur, from, to: e.to, ease: e.ease, why: e.why }); } return { init, cues }; @@ -446,7 +448,9 @@ export function finaleHtml(schedule, render, window, opts = {}) { : null; const data = { - from: r4(from), dur, init, + // The window's first second on the cue grid too: a frame-aligned start, + // so a moved finale's frames are seeked to exactly the moved times. + from: cueTime(from, fps), dur, init, cues: cues.map(({ why, ...c }) => c), }; const json = JSON.stringify(data).replace(/</g, "\\u003c"); diff --git a/umtool/report-to-video/compose-chrome.mjs b/umtool/report-to-video/compose-chrome.mjs @@ -1096,7 +1096,7 @@ export async function composeChrome({ // Each frame's key (frame-keys.mjs), for a whole-cut page it models: a // render that is not cached whole captures only the frames no render on // disk has drawn. - const fk = keyed && sequence && wholeCut && !windowed && !preview && FRAME_KEY_REGIONS[region] + const fk = keyed && sequence && ((wholeCut && !windowed) || region === "finale") && !preview && FRAME_KEY_REGIONS[region] ? frameKeys({ html, region, assets, fps: rate, frames, version: hf.version }) : null; if (keyed && sequence) { diff --git a/umtool/report-to-video/deck-claims.test.mjs b/umtool/report-to-video/deck-claims.test.mjs @@ -338,6 +338,8 @@ const BEFORE = { // Huck cut's 1,539 deck cues against main: the same elements, values, // eases and durations, every time within 4 ms. (Was 4966f5f6904d7c91e8c3bd64b16763b8.) deck: "d56d6f45c667dea15c0fec5675dbcc95", - finale: "e4cb165d4e3b816c0d648240cac91eb1", + // Likewise the finale's (its 181 cues on the Huck cut: times within 2 ms, + // its window's start on the grid). Was e4cb165d4e3b816c0d648240cac91eb1. + finale: "afc1b75858e0c19a73e3d9549bc1f474", built: "c6a44e98fce846811cbf87d449e6b40d", }; diff --git a/umtool/report-to-video/finale.test.mjs b/umtool/report-to-video/finale.test.mjs @@ -8,7 +8,7 @@ import assert from "node:assert/strict"; import test from "node:test"; -import { deckChoreography, deckSchedule, estimateSchedule, validateChrome } from "./deck.mjs"; +import { cueTime, deckChoreography, deckSchedule, estimateSchedule, validateChrome } from "./deck.mjs"; import { deckHtml } from "./chrome-deck.mjs"; import { finaleCues, finaleHtml, finaleLayout } from "./chrome-finale.mjs"; import { @@ -192,7 +192,7 @@ test("the page: the large rail, the totals at their final counts, the stats, the assert.ok(cues.every((c) => Object.keys(c.to).every((p) => p in c.from))); const hole = cues.find((c) => c.k === "hole"); assert.equal(hole.ease, "smoothstep"); - assert.equal(hole.at, s.finale.at); + assert.equal(hole.at, cueTime(s.finale.at, 30), "on the cue grid (deck.mjs cueTime)"); assert.equal(hole.dur, FINALE_MOTION.grow); // The region: the whole frame, a window from `at` to the end. const reg = finaleRegions(r, "/tmp/x", s)[0]; diff --git a/umtool/report-to-video/frame-keys.mjs b/umtool/report-to-video/frame-keys.mjs @@ -53,6 +53,12 @@ export const FRAME_KEY_REGIONS = Object.freeze({ // The feed plans its cues IN the page, from the heights its cards measure // (chrome-feed.mjs): keyed by its EVENTS instead (feedFrameKeys). feed: { data: "feed-data", omit: ["window", "total", "ids", "posts", "visibility"], events: true }, + // The finale is a window of the cut by design: its frame n is cut time + // `from` + n / fps, and its one ease of its own is the page's smoothstep. + finale: { + data: "finale-data", omit: ["init", "cues", "from", "dur"], offset: "from", + eases: { smoothstep: { page: "const EASES = { smoothstep: (p) => p * p * (3 - 2 * p) };", fn: (p) => p * p * (3 - 2 * p) } }, + }, }); /** @@ -119,6 +125,9 @@ export function staticKey({ html, region, assets = [], fps, version, frames = nu // the 4-decimal grid makes deckHtml "window" [0, r4(total)]: the identity). if (data.window && !(data.window.from === 0 && frames != null && Math.abs(data.window.dur - frames / fps) < 1 / fps)) return null; if (spec.events ? !(Array.isArray(data.posts) && Array.isArray(data.visibility) && data.grid > 0) : !data.init || !Array.isArray(data.cues)) return null; + if (spec.offset && !Number.isFinite(data[spec.offset])) return null; + // A page's own eases are modelled only as the page writes them. + for (const e of Object.values(spec.eases ?? {})) if (!html.includes(e.page)) return null; // Every data-duration is the page's own (the root and its one clip). const durs = [...html.matchAll(/data-duration="([^"]*)"/g)].map((m) => m[1]); if (!durs.length || durs.some((d) => d !== durs[0])) return null; @@ -144,9 +153,12 @@ export function frameKeys({ html, region, assets = [], fps, frames, version }) { const sk = staticKey({ html, region, assets, fps, version, frames }); if (!sk) return null; if (FRAME_KEY_REGIONS[region].events) return feedFrameKeys({ html, sk, fps, frames }); - const { data } = splitData(html, FRAME_KEY_REGIONS[region].data); + const spec = FRAME_KEY_REGIONS[region]; + const { data } = splitData(html, spec.data); const init = data.init; const cues = data.cues; + const t0 = spec.offset ? Number(data[spec.offset]) : 0; + const ease = (name) => spec.eases?.[name]?.fn ?? easeOf(name); // Slots: one per (element, property), each with its cues in time order. const slots = new Map(); @@ -176,7 +188,8 @@ export function frameKeys({ html, region, assets = [], fps, frames, version }) { const from = c.from?.[s.p]; const to = c.to[s.p]; if (!okValue(from) || !okValue(to) || !okValue(held)) return null; - if (from !== held && !(from === undefined && held === undefined)) return null; + // (Nothing held -- the CSS default -- takes the from the page states for it.) + if (held !== undefined && from !== held) return null; if (c.at < freeAt - 1e-9) return null; held = to; freeAt = c.at + c.dur; @@ -197,7 +210,7 @@ export function frameKeys({ html, region, assets = [], fps, frames, version }) { if (t >= end - 1e-9) return `e${repr(to)}`; const u = Math.max(0, (t - cur.at) / cur.dur); if (typeof from === "number" && typeof to === "number") { - return `r${gsapRound(from + (to - from) * easeOf(cur.ease)(u))}`; + return `r${gsapRound(from + (to - from) * ease(cur.ease)(u))}`; } // A string in flight: the cue and its own clock, to the microsecond. return `x${JSON.stringify([from, to, cur.ease, cur.dur])}@${(t - cur.at).toFixed(6)}`; @@ -212,12 +225,12 @@ export function frameKeys({ html, region, assets = [], fps, frames, version }) { }; const cur = new Map(); for (const s of slots.values()) { - const v = valueAt(s, 0); + const v = valueAt(s, t0); cur.set(s.id, v); xor(sha1(`${s.id}\u0001${v}`)); } // Per frame, the slots that may move: those with a cue starting by it or running at it. - const frameOf = (t) => Math.ceil(t * fps - 1e-6); + const frameOf = (t) => Math.ceil((t - t0) * fps - 1e-6); const touch = new Map(); // frame -> slots const push = (f, s) => { if (f < 0 || f >= frames) return; @@ -234,7 +247,7 @@ export function frameKeys({ html, region, assets = [], fps, frames, version }) { } const out = new Array(frames); for (let f = 0; f < frames; f += 1) { - const t = f / fps; + const t = t0 + f / fps; for (const s of touch.get(f) ?? []) { const v = valueAt(s, t); const was = cur.get(s.id);