// What instruments.spec.ts previews: the Play cut (play-cut-fixture.mjs) with the // measure's instruments on -- `deck.dial`, `deck.odometer`, `deck.trail` -- and // a BUILT schedule (out/sourced/schedule.json, the estimate's own timings) that // carries a measure slice, as the build writes one for a cut with a measure // ledger (the producer is lane measure-ledger's; until it lands the slice is // written here). The chrome preview without `estimate` reads that schedule; // Play the cut composes on the estimate's, which carries the measure once the // producer puts it there. Six rows of the instruments' fixture // (report-to-video/fixtures/measure-dial/measure.json), each at a second of // the cut, with the state after it: // // c01 +0.6 w07 stated >240 c01 +1.2 w21 remembered ≈390 // c02 +0.4 w27 goal 250 c02 +1.0 w64 lost 31 (run 6) // c04 +0.2 w115 stated <300 c04 +0.6 w118 stated 291.5 // // Real ledger rows (the weight project's measure slice), the fixture cut's seconds. import { readFileSync, writeFileSync, mkdirSync } from "node:fs"; import path from "node:path"; import { fileURLToPath } from "node:url"; const HERE = path.dirname(fileURLToPath(import.meta.url)); const MEASURE = path.join(HERE, "..", "..", "report-to-video", "fixtures", "measure-dial", "measure.json"); /** The rows, and where each lands: [row, clip, seconds into the clip]. */ export const INSTRUMENT_ROWS = Object.freeze([ ["w07", "c01", 0.6], ["w21", "c01", 1.2], ["w27", "c02", 0.4], ["w64", "c02", 1.0], ["w115", "c04", 0.2], ["w118", "c04", 0.6], ]); export async function makeInstrumentsFixture({ reports, deckManifest, cachedWindow, makePlayCutFixture, name = "instruments-fixture" }) { const { estimateSchedule } = await import("../../report-to-video/deck.mjs"); const { dir } = makePlayCutFixture({ reports, deckManifest, cachedWindow, name, title: "The Instruments Fixture", chrome: { deck: { dial: true, odometer: true, trail: true }, // The tally's word fitted to its cell, as play-modules-fixture's. factcheck: { verdicts: { CORROBORATED: { label: "Seizures", tallyLabel: "Seized", color: "#6fa8dc" } }, stamp: { seconds: 1 } }, }, }); const file = path.join(dir, "video.manifest.json"); const manifest = JSON.parse(readFileSync(file, "utf8")); const schedule = estimateSchedule(manifest); const M = JSON.parse(readFileSync(MEASURE, "utf8")); const startOf = new Map(schedule.segments.map((s) => [s.id, s.start])); const r3 = (v) => Math.round(v * 1000) / 1000; const events = []; const state = [{ ...M.state[0], t: 0 }]; for (const [row, clip, at] of INSTRUMENT_ROWS) { const i = M.events.findIndex((e) => e.row === row); if (i < 0) throw new Error(`instruments-fixture: ${row} is not in ${MEASURE}`); const t = r3(startOf.get(clip) + at); events.push({ ...M.events[i], t, segment: clip }); state.push({ ...M.state[i + 1], t }); } const measure = { ...M, events, state, _fixture: "instruments-fixture: six rows of measure-dial's fixture at seconds of the Play cut" }; mkdirSync(path.join(dir, "out", "sourced"), { recursive: true }); writeFileSync(path.join(dir, "out", "sourced", "schedule.json"), JSON.stringify({ ...schedule, measure }, null, 2) + "\n"); return { dir, schedule: { ...schedule, measure } }; }