// THE CUT'S FIRST FRAME (cue-start.mjs): a page a renderer seeks to 0 draws its // init there, so whatever the cut is at its first instant must be IN init. The // instruments' column (dial, odometer, trail) was up in init and hidden by an // instant cue at 0: over a cut that opens on the intro, frame 0 showed the // gauge, the counter and the chart strip before the wordmark (rev9-a6/a7, 11 Nov). import assert from "node:assert/strict"; import { readFileSync } from "node:fs"; import path from "node:path"; import test from "node:test"; import { fileURLToPath } from "node:url"; import { estimateSchedule } from "./deck.mjs"; import { dialHtml, odometerHtml, trailHtml } from "./chrome-instruments.mjs"; import { settleFirstFrame, unseenFirstFrameCues } from "./cue-start.mjs"; import { cueList } from "./measure-draw.mjs"; import { compileCues } from "./chrome-cues.mjs"; import { statsCues } from "./chrome-stats.mjs"; const HERE = path.dirname(fileURLToPath(import.meta.url)); const MEASURE = JSON.parse(readFileSync(path.join(HERE, "fixtures", "measure-dial", "measure.json"), "utf8")); const FPS = 30; const RENDER = { width: 1920, height: 1080, fps: FPS, transition: 0.4, palette: { bg: "#0F1312", fg: "#EDF0EC", muted: "#98A29B", accent: "#22AB83", amber: "#E8A33F" }, chrome: { engine: "hyperframes", layout: "deck", deck: { dial: true, odometer: true, trail: true, qr: { show: false }, finale: { video: "side", totals: false } } }, }; const fonts = { DeckSans: "assets/DeckSans.ttf", DeckSansBold: "assets/DeckSansBold.ttf" }; /** The instruments' fixture cut, opening on the intro (selectVariant's entry: the deck hides over it). */ function introCut() { const timeline = Array.from({ length: 9 }, (_, i) => ({ type: "clip", id: `c${i + 1}`, video: "vidx", start: 10 * i, end: 10 * i + (i === 8 ? 14 : 8), cite: 1, section: 0, quote: "q", onscreen: { title: `Clip ${i + 1}` }, ...(i === 8 ? { layout: "finale" } : {}), })); timeline.unshift({ type: "intro", id: "brand-intro", style: "boot-dark", seconds: 4.75, heading: "Intro" }); const manifest = { slug: "m", title: "M", provenance: {}, render: RENDER, timeline }; const schedule = { ...estimateSchedule(manifest), measure: MEASURE }; assert.equal(schedule.segments[0].hideDeck, true, "the intro hides the deck"); return schedule; } const dataOf = (html, id) => JSON.parse(new RegExp(``, "s").exec(html)[1]); test("over an intro the instruments are hidden from frame 0: their root is down in init, with no instant cue at 0", () => { const schedule = introCut(); for (const [id, html] of [["dial", dialHtml(schedule, RENDER, { fonts })], ["odometer", odometerHtml(schedule, RENDER, { fonts })], ["trail", trailHtml(schedule, RENDER, { fonts })]]) { const data = dataOf(html, id); assert.deepEqual(data.init.rt, { autoAlpha: 0 }, `${id}: hidden at the cut's first instant`); assert.deepEqual(unseenFirstFrameCues(data, FPS), [], `${id}: no change at 0 that frame 0 cannot show`); // And up again with the deck, after the intro: the first cue on the root shows it. const first = data.cues.find((c) => c.k === "rt"); assert.ok(first.at > 4, `${id}: the column comes up after the intro (${first.at})`); assert.deepEqual(first.to, { autoAlpha: 1 }); } }); test("settleFirstFrame folds what happens at the first instant into init, and leaves every real move alone", () => { const init = { a: { autoAlpha: 1 }, b: { opacity: 0 }, c: { x: 0 } }; const shared = init.a; const cues = [ { k: "a", at: 0, dur: 0.001, from: { autoAlpha: 1 }, to: { autoAlpha: 0 } }, { k: "a", at: 0.001, dur: 0.001, from: { autoAlpha: 0 }, to: { autoAlpha: 0.5 } }, // chained after the first, still before frame 1 { k: "b", at: 0, dur: 0.4, from: { opacity: 0 }, to: { opacity: 1 } }, // a fade from 0: frame 0 is its from { k: "b", at: 0.4, dur: 0.001, from: { opacity: 1 }, to: { opacity: 0 } }, { k: "c", at: 0.5, dur: 0.001, from: { x: 0 }, to: { x: 5 } }, ]; const out = settleFirstFrame(init, cues, 30); assert.deepEqual(init.a, { autoAlpha: 0.5 }); assert.deepEqual(shared, { autoAlpha: 1 }, "an init entry is replaced, never mutated (entries may be shared)"); assert.deepEqual(out.map((c) => `${c.k}@${c.at}`), ["b@0", "b@0.4", "c@0.5"]); }); test("every cue compiler settles the first frame: cueList, compileCues, the stats panel", () => { const L = cueList(FPS); L.set("rt", { autoAlpha: 1 }); L.add("rt", 0, 0, { autoAlpha: 0 }); L.add("rt", 5, 0.45, { autoAlpha: 1 }); const built = L.build(); assert.deepEqual(built.init.rt, { autoAlpha: 0 }); assert.deepEqual(built.cues.map((c) => c.at), [5]); const cc = compileCues({ x: { autoAlpha: 0 } }, [{ k: "x", at: 0, dur: 0, to: { autoAlpha: 1 }, ease: "none" }]); assert.deepEqual(cc.init.x, { autoAlpha: 1 }); assert.equal(cc.cues.length, 0); // A stat card shown from the cut's first instant (v7gkv5w-poker-2's s0_0): up on frame 0, not frame 1. const st = statsCues({ fps: FPS, stats: { clips: [{ in: 0, out: 6, states: [{ at: 0 }, { at: 3 }] }] } }); assert.deepEqual(unseenFirstFrameCues(st, FPS), []); assert.equal(st.init.s0_0.autoAlpha, 1); });