// MODULE CONFIG → MANIFEST (release 39): a project's `module-config.json` // -- the modules a video wants, written in the design's vocabulary // (MODULES-DESIGN.md) by whoever planned the cut -- as a merge patch over // its manifest, in the modules' homes. PURE: the config and the manifest // in, `{ patch, unmapped, notes }` out. `umtool modules apply` writes the // patch (as a take's `--patch`, or through the writers onto the project). // // config.preset -> preset (the look preset, presets.mjs) // modules.subtitle -> render.chrome.deck.subtitle // modules.qr -> render.chrome.deck.qr // modules.counter.series -> render.chrome.deck.counter.series (+ show, position, showAt) // modules.counter.marks -> each clip's marks (`claim` / `claims`, the series' id as verdict, `at`) // modules.stamp -> render.chrome.factcheck.stamp (`series..label` -> the series' stampLabel) // modules.rail -> render.chrome.deck.pip (spacing, pitch) + deck.markers (nodes and markers) // modules.section-title -> render.chrome.deck.sectionTitle (true, or first, size, opacity, fade, color) // modules.chapter[] -> render.chrome.chapter.list // modules.pair[] -> render.chrome.pair.pairs // modules.status[] -> render.chrome.status.items // modules.intro -> render.intro // modules.finale -> render.chrome.deck.finale (+ `atClip`: the clips from it on take layout "finale") // // Everything that has no home is said in `unmapped`, one sentence each with // the config path -- nothing is dropped silently. import { VERDICTS } from "yt-dlp-transcript-common/lib/report/verdicts.mjs"; import { mergePatch } from "../montage-styles.mjs"; import { MARKER_LIMITS, SECTION_TITLE_DEFAULTS, SECTION_TITLE_LIMITS } from "./settings.mjs"; import { CHAPTER_LIMITS, DATE_RE, PAIR_LIMITS, STATUS_LIMITS } from "./story-settings.mjs"; const isObj = (v) => v !== null && typeof v === "object" && !Array.isArray(v); const clone = (v) => JSON.parse(JSON.stringify(v)); const chars = (s) => [...String(s)].length; const fit = (s, max) => (chars(s) <= max ? String(s) : `${[...String(s)].slice(0, max - 1).join("").trimEnd()}…`); const SERIES_KEYS = ["id", "label", "color", "stampLabel", "tallyLabel", "showAt", "shape", "unit"]; const STAMP_KEYS = ["show", "seconds", "position", "scale", "motion", "opacity"]; const FINALE_KEYS = ["video", "motion", "totals", "statsTitle", "railLabels", "pips", "timelineShare", "claims"]; const INTRO_KEYS = ["style", "ground", "mark", "seconds", "site", "swap", "url", "urlPlace", "brand", "suffix", "projectUrl"]; /** * @param {Record} config a module-config.json * @param {Record} manifest the project's manifest (its timeline names the clips) * @returns {{ patch: Record, unmapped: string[], notes: string[] }} */ export function moduleConfigToManifest(config, manifest) { if (!isObj(config)) throw new Error("a module config is an object { preset?, modules }"); if (!isObj(manifest) || !Array.isArray(manifest.timeline)) throw new Error("the manifest has no timeline"); const mods = isObj(config.modules) ? config.modules : {}; const unmapped = []; const notes = []; const say = (where, why) => unmapped.push(`${where}: ${why}`); const timeline = clone(manifest.timeline); const ids = timeline.map((e) => e?.id); const has = (id) => typeof id === "string" && ids.includes(id); // The timeline's ids named in words, as whole words, in the order they stand. const idsIn = (text) => { const out = []; for (const m of String(text).matchAll(/[A-Za-z0-9][A-Za-z0-9_.:-]*/g)) { const t = m[0].replace(/[.:]+$/, ""); if (has(t) && !out.includes(t)) out.push(t); } return out; }; const prev = (id) => { const i = ids.indexOf(id); return i > 0 ? ids[i - 1] : null; }; const chrome = {}; const deck = {}; const render = {}; const patch = {}; let timelineChanged = false; for (const k of Object.keys(config)) { if (!["preset", "modules", "project", "intent", "notes", "note", "$comment", "draftEquivalent"].includes(k)) say(k, "not a module-config key"); } if (typeof config.preset === "string" && config.preset) patch.preset = config.preset; for (const [id, v] of Object.entries(mods)) { const at = `modules.${id}`; switch (id) { case "shell": { for (const k of Object.keys(v ?? {})) { say(`${at}.${k}`, "the deck has no cut-wide title or subtitle (each clip's own is on screen); left out -- the manifest's title is unchanged"); } break; } case "subtitle": { const s = {}; for (const [k, x] of Object.entries(v ?? {})) { if (k === "parts" || k === "dateFormat") s[k] = x; else say(`${at}.${k}`, "not a subtitle setting (parts, dateFormat)"); } if (Object.keys(s).length) deck.subtitle = s; break; } case "qr": { const q = {}; for (const [k, x] of Object.entries(v ?? {})) { if (["links", "show", "size"].includes(k)) q[k] = x; else say(`${at}.${k}`, "not a QR setting (links, show, size)"); } if (Object.keys(q).length) deck.qr = q; break; } case "counter": counterOf(v, at, { deck, timeline, has, say, notes, mods, setChanged: () => { timelineChanged = true; } }); break; case "stamp": { const s = {}; for (const [k, x] of Object.entries(v ?? {})) { if (STAMP_KEYS.includes(k)) s[k] = x; else if (k !== "series") say(`${at}.${k}`, `not a stamp setting (${STAMP_KEYS.join(", ")})`); } if (Object.keys(s).length) chrome.factcheck = { ...(chrome.factcheck ?? {}), stamp: s }; if (isObj(v?.series)) { for (const [sid, sv] of Object.entries(v.series)) { const series = deck.counter?.series?.find((x) => x.id === sid); if (!series) { say(`${at}.series.${sid}`, "no counter series has this id"); continue; } if (typeof sv?.label === "string") series.stampLabel = sv.label; for (const k of Object.keys(sv ?? {})) if (k !== "label") say(`${at}.series.${sid}.${k}`, "a stamp names a series' word only (label)"); } } break; } case "rail": railOf(v, at, { deck, has, prev, say, notes }); break; case "section-title": { // The current section's name under the rail: true, or its settings. if (typeof v === "boolean") { deck.sectionTitle = v; break; } if (!isObj(v)) { say(at, "must be true, false or { first, size, opacity, fade, color }"); break; } const s = {}; for (const [k, x] of Object.entries(v)) { if (k === "first" && typeof x === "string") { const one = x.replace(/\s+/g, " ").trim(); if (chars(one) > SECTION_TITLE_LIMITS.first) say(`${at}.first`, `shortened to ${SECTION_TITLE_LIMITS.first} characters`); s.first = fit(one, SECTION_TITLE_LIMITS.first); } else if (Object.hasOwn(SECTION_TITLE_DEFAULTS, k)) s[k] = x; else say(`${at}.${k}`, `not a section title setting (${Object.keys(SECTION_TITLE_DEFAULTS).join(", ")})`); } deck.sectionTitle = s; break; } case "chapter": { const list = []; (Array.isArray(v) ? v : []).forEach((c, i) => { const w = `${at}[${i}]`; const clip = c?.atClip ?? c?.at ?? c?.clip; if (!has(clip)) { say(w, `its clip ${clip ?? "(none)"} is not in the timeline: left out`); return; } if (list.some((x) => x.at === clip)) { say(w, `a chapter already opens ${clip}: left out`); return; } const ch = { at: clip, title: fit(c.title ?? "", CHAPTER_LIMITS.title) }; if (!c.title) { say(w, "has no title: left out"); return; } if (chars(c.title) > CHAPTER_LIMITS.title) say(`${w}.title`, `shortened to ${CHAPTER_LIMITS.title} characters`); if (c.subtitle) { ch.subtitle = fit(c.subtitle, CHAPTER_LIMITS.subtitle); if (chars(c.subtitle) > CHAPTER_LIMITS.subtitle) say(`${w}.subtitle`, `shortened to ${CHAPTER_LIMITS.subtitle} characters`); } if (c.date !== undefined) { if (DATE_RE.test(String(c.date))) ch.date = c.date; else say(`${w}.date`, `"${c.date}" is not YYYY, YYYY-MM or YYYY-MM-DD: left out`); } for (const k of Object.keys(c)) if (!["atClip", "at", "clip", "title", "subtitle", "date"].includes(k)) say(`${w}.${k}`, "not a chapter field"); list.push(ch); }); if (list.length > CHAPTER_LIMITS.list) say(at, `${list.length} chapters: the first ${CHAPTER_LIMITS.list} kept`); if (list.length) chrome.chapter = { list: list.slice(0, CHAPTER_LIMITS.list) }; break; } case "pair": { const pairs = []; (Array.isArray(v) ? v : []).forEach((p, i) => { const w = `${at}[${i}]`; const side = (s, name) => { if (!isObj(s) || !has(s.clip)) { say(`${w}.${name}`, `its clip ${s?.clip ?? "(none)"} is not in the timeline`); return null; } const out = { clip: s.clip }; if (s.date !== undefined) { if (DATE_RE.test(String(s.date))) out.date = s.date; else say(`${w}.${name}.date`, `"${s.date}" is not YYYY, YYYY-MM or YYYY-MM-DD: left out`); } for (const k of Object.keys(s)) if (!["clip", "date", "label"].includes(k)) say(`${w}.${name}.${k}`, "not a pair side field"); if (typeof s.label === "string") out.label = fit(s.label, PAIR_LIMITS.label); return out; }; const then = side(p?.then, "then"); const now = side(p?.now, "now"); if (!then || !now) { say(w, "left out (a pair needs both clips in the timeline)"); return; } const pr = { then, now }; if (p.caption) { pr.caption = fit(p.caption, PAIR_LIMITS.caption); if (chars(p.caption) > PAIR_LIMITS.caption) say(`${w}.caption`, `shortened to ${PAIR_LIMITS.caption} characters`); } if (p.topic) { pr.topic = fit(p.topic, PAIR_LIMITS.topic); if (chars(p.topic) > PAIR_LIMITS.topic) say(`${w}.topic`, `shortened to ${PAIR_LIMITS.topic} characters`); } if (p.style !== undefined) { const st = { split: "split", card: "then→now", "then→now": "then→now", "then-now": "then→now" }[p.style]; if (st) pr.style = st; else say(`${w}.style`, `"${p.style}" is not split or then→now: the pair takes the module's`); } if (Array.isArray(p.also)) { const also = p.also.filter((a) => { if (!has(a?.clip)) { say(`${w}.also`, `${a?.clip} is not in the timeline: left out`); return false; } return true; }).map((a) => ({ clip: a.clip, side: a.side === "then" ? "then" : "now", ...(DATE_RE.test(String(a.date ?? "")) ? { date: a.date } : {}) })); if (also.length) pr.also = also.slice(0, PAIR_LIMITS.also); } for (const k of Object.keys(p)) { if (!["then", "now", "caption", "topic", "style", "also"].includes(k)) say(`${w}.${k}`, "not drawn (a pair draws its dates, topic and caption)"); } pairs.push(pr); }); if (pairs.length > PAIR_LIMITS.pairs) say(at, `${pairs.length} pairs: the first ${PAIR_LIMITS.pairs} kept`); if (pairs.length) chrome.pair = { pairs: pairs.slice(0, PAIR_LIMITS.pairs) }; break; } case "status": { const items = []; (Array.isArray(v) ? v : []).forEach((it, i) => { const w = `${at}[${i}]`; if (!it?.item) { say(w, "has no item: left out"); return; } const sideOf = (s, name) => { if (s === undefined || s === null) return undefined; if (typeof s === "string") { if (chars(s) > STATUS_LIMITS.text) say(`${w}.${name}`, `shortened to ${STATUS_LIMITS.text} characters`); return fit(s, STATUS_LIMITS.text); } if (!isObj(s)) { say(`${w}.${name}`, "not words or an object: left out"); return undefined; } const out = {}; if (s.clip !== undefined) { if (has(s.clip)) out.clip = s.clip; else say(`${w}.${name}.clip`, `${s.clip} is not in the timeline: left out`); } if (s.date !== undefined) { if (DATE_RE.test(String(s.date))) out.date = s.date; else say(`${w}.${name}.date`, `"${s.date}" is not YYYY, YYYY-MM or YYYY-MM-DD: left out`); } const words = s.text ?? s.summary; if (words) { out.text = fit(words, STATUS_LIMITS.text); if (chars(words) > STATUS_LIMITS.text) say(`${w}.${name}.${s.text ? "text" : "summary"}`, `shortened to ${STATUS_LIMITS.text} characters`); } for (const k of Object.keys(s)) if (!["clip", "date", "text", "summary"].includes(k)) say(`${w}.${name}.${k}`, "not drawn (a status side draws its date and words)"); return out; }; const row = { item: fit(it.item, STATUS_LIMITS.item) }; if (chars(it.item) > STATUS_LIMITS.item) say(`${w}.item`, `shortened to ${STATUS_LIMITS.item} characters`); const a = sideOf(it.announced, "announced"); const o = sideOf(it.outcome, "outcome"); if (a !== undefined) row.announced = a; if (o !== undefined) row.outcome = o; let ev = []; if (Array.isArray(it.evidence)) { ev = it.evidence.filter((c) => has(c)); for (const c of it.evidence) if (!has(c)) say(`${w}.evidence`, `${c} is not in the timeline: left out`); } // Words that name clips ("28 Oct x01: …", "2026-09-30 (n02)"): the // timeline's ids read out of them, as the row's evidence. const read = []; for (const [k, words] of [["evidence", it.evidence], ["announced", it.announced], ["outcome", it.outcome]]) { if (typeof words !== "string") continue; const found = idsIn(words).filter((c) => !ev.includes(c) && !read.includes(c)); if (found.length) { read.push(...found); say(`${w}.${k}`, `words: the clips ${found.join(", ")} read out of them as evidence`); } if (k === "evidence" && !found.length) say(`${w}.evidence`, "words naming no clip in the timeline: left out"); } ev = [...ev, ...read]; if (ev.length) row.evidence = ev.slice(0, STATUS_LIMITS.evidence); for (const k of Object.keys(it)) if (!["item", "announced", "outcome", "evidence"].includes(k)) say(`${w}.${k}`, "not drawn (a row draws its item, announcement and outcome)"); const named = [row.announced?.clip, row.outcome?.clip, ...(row.evidence ?? [])].filter(Boolean); if (!named.length) { say(w, "names no clip in the timeline: left out (it would never be shown)"); return; } items.push(row); }); if (items.length > STATUS_LIMITS.items) say(at, `${items.length} items: the first ${STATUS_LIMITS.items} kept`); if (items.length) chrome.status = { items: items.slice(0, STATUS_LIMITS.items) }; break; } case "intro": { const intro = {}; for (const [k, x] of Object.entries(v ?? {})) { if (INTRO_KEYS.includes(k)) intro[k] = x; else say(`${at}.${k}`, "not an intro setting"); } if (Object.keys(intro).length) render.intro = intro; break; } case "finale": finaleOf(v, at, { deck, timeline, has, say, mods, setChanged: () => { timelineChanged = true; } }); break; case "feed": { const posts = [...(Array.isArray(v?.posts) ? v.posts : []), ...(Array.isArray(v?.items) ? v.items : [])]; say(at, `${posts.length} post(s): a post joins the cut through \`umtool posts add

/ --attach \` (it needs its captured screenshot), not a module setting`); break; } default: say(at, "no module by this name"); } } if (Object.keys(deck).length) chrome.deck = deck; if (Object.keys(chrome).length) { // A counter's series replace the fact-check verdicts' relabels and the // tally's settings: the two are not set together. if (deck.counter && isObj(manifest.render?.chrome?.factcheck)) { const f = manifest.render.chrome.factcheck; if (f.verdicts !== undefined || f.tally !== undefined) { chrome.factcheck = { ...(chrome.factcheck ?? {}), ...(f.verdicts !== undefined ? { verdicts: null } : {}), ...(f.tally !== undefined ? { tally: null } : {}) }; notes.push("render.chrome.factcheck.verdicts / tally removed: the counter's series replace them"); } } render.chrome = chrome; } if (Object.keys(render).length) patch.render = render; if (timelineChanged) patch.timeline = timeline; return { patch, unmapped, notes }; } /** The counter: its series and settings, and each clip's marks naming a series. */ function counterOf(v, at, { deck, timeline, has, say, notes, setChanged }) { if (!isObj(v)) { say(at, "must be an object"); return; } const counter = {}; const series = []; (Array.isArray(v.series) ? v.series : []).forEach((s, i) => { const w = `${at}.series[${i}]`; if (!isObj(s) || typeof s.id !== "string") { say(w, "has no id: left out"); return; } const out = {}; for (const [k, x] of Object.entries(s)) { if (["label", "stampLabel", "tallyLabel", "unit"].includes(k) && typeof x === "string" && chars(x) > 24) { out[k] = fit(x, 24); say(`${w}.${k}`, "shortened to 24 characters"); } else if (SERIES_KEYS.includes(k)) out[k] = x; else if (k === "optional") notes.push(`${w}.optional: a series is drawn whether or not it counts anything; kept as an ordinary series`); else if (k !== "$comment") say(`${w}.${k}`, "not a series field"); } series.push(out); }); if (series.length) counter.series = series; for (const k of ["show", "position", "showAt"]) if (v[k] !== undefined) counter[k] = v[k]; for (const k of Object.keys(v)) { if (["series", "marks", "show", "position", "showAt"].includes(k)) continue; if (k === "notCounted") notes.push(`${at}.notCounted: ${v.notCounted.length} clip(s) the plan does not count -- informational, nothing drawn`); else if (k === "legacyVerdicts" || k === "draft1Mapping") notes.push(`${at}.${k}: read to move the draft's verdict marks onto the series`); else say(`${at}.${k}`, "not a counter setting"); } if (Object.keys(counter).length) deck.counter = counter; // The marks: each clip's marks, as the config says, its series by id. const legacy = { ...(isObj(v.legacyVerdicts) ? v.legacyVerdicts : {}), ...(isObj(v.draft1Mapping) ? v.draft1Mapping : {}) }; const toSeries = Object.fromEntries(Object.entries(legacy).map(([sid, verdict]) => [verdict, sid])); const ids = new Set(series.map((s) => s.id)); const byClip = new Map(); (Array.isArray(v.marks) ? v.marks : []).forEach((m, i) => { const w = `${at}.marks[${i}]`; const clip = m?.clip; if (!has(clip)) { say(w, `its clip ${clip ?? "(none)"} is not in the timeline: left out`); return; } const sid = m.counter ?? m.verdict; if (!ids.has(sid)) { say(w, `${sid} is not one of the counter's series: left out`); return; } if (!byClip.has(clip)) byClip.set(clip, []); byClip.get(clip).push({ series: sid, ...(typeof m.at === "number" ? { at: m.at } : {}) }); for (const k of Object.keys(m)) if (!["clip", "counter", "verdict", "at", "note"].includes(k)) say(`${w}.${k}`, "not a mark field (clip, counter, at)"); }); if (!series.length) return; for (const e of timeline) { if (!isObj(e)) continue; const had = Array.isArray(e.claims) ? e.claims : e.claim ? [e.claim] : []; const want = byClip.get(e.id); let next; if (want) { next = want.map((m, k) => { // The knobs a mark already had at that second (hold, stamp, label, …) stay. const old = had.find((h) => h.at === m.at) ?? (want.length === 1 ? had[0] : null) ?? {}; const { id: _i, verdict: _v, at: _a, ...knobs } = old; // A second mark at the same second counts but does not stamp (two // stamps at once would overlap; the build refuses that). const twin = want.slice(0, k).some((x) => x.at === m.at); return { id: want.length === 1 ? e.id : `${e.id}-${m.series}`, verdict: m.series, ...(m.at !== undefined ? { at: m.at } : {}), ...knobs, ...(twin ? { stamp: false } : {}), }; }); if (want.some((m, k) => want.slice(0, k).some((x) => x.at === m.at))) { notes.push(`${at}.marks (${e.id}): marks at the same second -- the later ones count without a stamp of their own`); } } else if (had.length) { // A mark the config does not list: onto its series by the draft's mapping, else off. next = had.flatMap((h) => { if (ids.has(h.verdict)) return [h]; const sid = toSeries[h.verdict]; if (sid) return [{ ...h, verdict: sid }]; say(`timeline ${e.id}`, `its mark ${h.id} (${h.verdict}) names no series and the config lists no mark for the clip: removed`); return []; }); } else continue; const same = JSON.stringify(next) === JSON.stringify(had); if (same) continue; delete e.claim; delete e.claims; if (next.length === 1) e.claim = next[0]; else if (next.length > 1) e.claims = next; setChanged(); } if (VERDICTS.some((x) => ids.has(x))) notes.push(`${at}: a series named after a verdict takes that verdict's defaults`); } /** The rail: spacing and pitch, and its nodes and markers as the deck's markers. */ function railOf(v, at, { deck, has, prev, say, notes }) { if (!isObj(v)) { say(at, "must be an object"); return; } const pip = {}; if (v.spacing !== undefined) { if (["even", "time", "pitch"].includes(v.spacing)) pip.spacing = v.spacing; else say(`${at}.spacing`, `"${v.spacing}" is not even, time or pitch`); } if (v.pitch !== undefined) pip.pitch = v.pitch; if (v.color !== undefined) pip.color = v.color; if (Object.keys(pip).length) deck.pip = pip; const markers = []; const add = (after, label, w) => { if (!after) { say(w, "falls before the first clip: the deck's markers stand between two clips -- left out"); return; } if (!has(after)) { say(w, `its clip ${after} is not in the timeline: left out`); return; } if (markers.some((m) => m.after === after)) { say(w, `a marker already stands after ${after}: left out`); return; } if (typeof label !== "string" || !label.trim()) { say(w, "has no label: left out"); return; } const one = label.replace(/\s+/g, " ").trim(); if (chars(one) > MARKER_LIMITS.label) say(`${w}.label`, `shortened to ${MARKER_LIMITS.label} characters`); markers.push({ after, label: fit(one, MARKER_LIMITS.label), w }); }; (Array.isArray(v.markers) ? v.markers : []).forEach((m, i) => add(m?.after, m?.label, `${at}.markers[${i}]`)); const dated = []; (Array.isArray(v.nodes) ? v.nodes : []).forEach((n, i) => { const w = `${at}.nodes[${i}]`; if (!isObj(n)) { say(w, "not a node"); return; } if (n.after) add(n.after, n.label, w); else if (n.atClip ?? n.clip ?? n.fromClip) { const clip = n.atClip ?? n.clip ?? n.fromClip; if (!has(clip)) { say(w, `its clip ${clip} is not in the timeline: left out`); return; } add(prev(clip), n.label, w); } else if (Array.isArray(n.clips)) { say(w, "a node over a list of clips (a year) has no one place on the deck's track: left out"); return; } else { say(w, "names no clip: left out"); return; } if (n.date) dated.push(w); for (const k of Object.keys(n)) if (!["after", "atClip", "clip", "fromClip", "label", "date", "year", "clips"].includes(k)) say(`${w}.${k}`, "not drawn"); }); if (dated.length) notes.push(`${at}.nodes: ${dated.length} node date(s) not drawn -- a marker carries its label only`); if (v.by !== undefined) say(`${at}.by`, `the rail is not grouped by ${v.by}; the pips are one per clip`); for (const k of Object.keys(v)) if (!["spacing", "pitch", "color", "markers", "nodes", "by"].includes(k)) say(`${at}.${k}`, "not a rail setting"); if (markers.length > MARKER_LIMITS.count) { for (const m of markers.slice(MARKER_LIMITS.count)) say(m.w, `past the deck's ${MARKER_LIMITS.count} markers: left out`); } if (markers.length) deck.markers = markers.slice(0, MARKER_LIMITS.count).map(({ w: _w, ...m }) => m); } /** The finale: its settings, its stats (a counter total counted from the marks), its first clip. */ function finaleOf(v, at, { deck, timeline, has, say, mods, setChanged }) { if (!isObj(v)) { say(at, "must be an object"); return; } const f = {}; for (const k of FINALE_KEYS) if (v[k] !== undefined) f[k] = v[k]; const marks = Array.isArray(mods.counter?.marks) ? mods.counter.marks.filter((m) => has(m?.clip)) : []; const total = (sid) => marks.filter((m) => (m.counter ?? m.verdict) === sid).length; if (Array.isArray(v.stats)) { f.stats = v.stats.map((s, i) => { const w = `${at}.stats[${i}]`; const out = { label: typeof s.label === "string" && chars(s.label) > 32 ? fit(s.label, 32) : s.label }; if (out.label !== s.label) say(`${w}.label`, "shortened to 32 characters"); if (typeof s.note === "string" && chars(s.note) > 60) say(`${w}.note`, "shortened to 60 characters"); let value = s.value; const ref = typeof value === "string" ? /^counter\.totals\.(.+)$/.exec(value) : null; if (ref) value = String(total(ref[1])); else if (value === undefined && s.counter) value = String(total(s.counter)); if (ref || (s.value === undefined && s.counter)) say(`${w}.value`, `a counter total, counted from the config's marks in this timeline: ${value} (fixed at apply time)`); out.value = typeof value === "number" ? String(value) : value; if (s.note) out.note = fit(s.note, 60); for (const k of Object.keys(s)) if (!["label", "value", "note", "counter", "color"].includes(k)) say(`${w}.${k}`, "not a stat field"); if (s.color) out.color = s.color; return out; }); } for (const k of Object.keys(v)) { if (FINALE_KEYS.includes(k) || ["stats", "deps", "atClip"].includes(k)) continue; say(`${at}.${k}`, "not a finale setting"); } if (Object.keys(f).length) deck.finale = f; if (v.atClip !== undefined) { if (!has(v.atClip)) { say(`${at}.atClip`, `${v.atClip} is not in the timeline: no finale run`); return; } const from = timeline.findIndex((e) => e?.id === v.atClip); for (const e of timeline.slice(from)) { if (isObj(e) && e.type === "clip" && e.layout !== "finale") { e.layout = "finale"; setChanged(); } } } } /** The patch over a manifest: what `umtool modules apply` writes (preset → manifest → patch). */ export function applyModuleConfig(manifest, config) { const { patch, unmapped, notes } = moduleConfigToManifest(config, manifest); return { manifest: mergePatch(manifest, patch), patch, unmapped, notes }; }