// The measure-dial fixture (lane scale-dial): a SMALL measure slice for the // instruments' tests, stills and e2e, cut from a real slice -- `umtool // measure` on a copy of the weight project (the producer's output: real // ledger rows, the cut's own seconds): // // node umtool/report-to-video/fixtures/measure-dial/make.mjs // // Keeps the rows named in ROWS -- every kind the dial, the odometer and the // trail draw: stated weights with and without a qualifier, remembered // weights, goals (a loss goal resolved against its run's start), loss claims, // the "under 300" claims -- with the state after each, every `t` respread // over a 62 s cut (one every 1.75 s from 2 s), the quotes dropped; `totals` // as the slice has them (the whole record). Deterministic: the same input // writes the same file. import { readFileSync, writeFileSync } from "node:fs"; import path from "node:path"; import { fileURLToPath } from "node:url"; const ROWS = [ "w06", "w07", "w18", "w21", "w26", "w27", "w34", "w35", "w51", "w53", "w54", "w55", "w59", "w60", "w61", "w64", "w74", "w75", "w76", "w77", "w78", "w79", "w85", "w86", "w87", "w89", "w93", "w101", "w102", "w107", "w110", "w115", "w116", "w118", ]; const STEP = 1.75; const FIRST = 2; const src = process.argv[2]; if (!src) { console.error("usage: make.mjs "); process.exit(2); } const M = JSON.parse(readFileSync(src, "utf8")); const keep = new Set(ROWS); const idx = M.events.map((e, i) => [e, i]).filter(([e]) => keep.has(e.row)); const missing = ROWS.filter((r) => !idx.some(([e]) => e.row === r)); if (missing.length) throw new Error(`rows not in the slice: ${missing.join(", ")}`); const r2 = (v) => Math.round(v * 100) / 100; const slim = (e) => { const { quote: _q, ...rest } = e; return rest; }; const events = idx.map(([e], n) => ({ ...slim(e), t: r2(FIRST + n * STEP) })); // The state after each kept event: the slice's state after it (state[i + 1] // follows events[i]), its goal ids and promises left out. const stateOf = (s, t) => { const { goals: _g, promises: _p, diet: _d, ...rest } = s; return { ...rest, t }; }; const state = [stateOf(M.state[0], 0), ...idx.map(([, i], n) => stateOf(M.state[i + 1], events[n].t))]; const out = { version: M.version, unit: M.unit, scale: M.scale, asOfRender: M.asOfRender, scopes: M.scopes, events, hidden: [], state, totals: M.totals, _fixture: "measure-dial: 34 rows of the weight project's measure slice (umtool measure on a copy, 5 Nov 2026), respread over a 62 s cut. make.mjs writes it.", }; const file = path.join(path.dirname(fileURLToPath(import.meta.url)), "measure.json"); writeFileSync(file, JSON.stringify(out) + "\n"); console.log(`${file}: ${events.length} events, ${state.length} states`);