// THE ANALYSIS ITEM (module `analysis`, a segment): an ending built from the // ledger -- a chart of a named run of his weights, a pace table, a status row // and one reading line -- inserted into the cut as a timeline entry of its own // (`{ type: "analysis" }`, analysis-plan.mjs). chrome-analysis.mjs writes the // page; the build encodes its frames into segments/.mp4 with the sound of // the clip it names under it, or silence (build-video's buildAnalysisSegment). import { analysisContext, analysisProblems, analysisSeconds, validateAnalysisEntries } from "../analysis-plan.mjs"; import { attributionParts } from "../attribution.mjs"; import { deckQrUrl, resolveDeck } from "../deck.mjs"; import { defineModule } from "./contract.mjs"; import { instrumentFonts } from "./instruments-shared.mjs"; export { analysisContext, analysisWarnings, validateAnalysisEntries } from "../analysis-plan.mjs"; /** * The audio clip's citation parts and QR link: the clip at the audio's start -- with the source's metadata when the * build has it (`meta`), else the entry's own words. Null without audio. */ export function analysisSource(entry, manifest, meta = null) { const a = entry?.audio; if (!a) return null; const clip = (manifest?.timeline ?? []).find((e) => e?.id === a.clip && e.type === "clip"); if (!clip) return null; const at = { ...clip, cite: Number(a.start), start: Number(a.start) }; const links = resolveDeck(manifest?.render ?? {}).qr?.links; return { parts: attributionParts(at, meta ?? {}, manifest?.provenance ?? {}, manifest?.render?.channelNames), url: deckQrUrl(at, manifest?.provenance ?? {}, { ...(links ? { links } : {}), meta }), }; } export default defineModule({ id: "analysis", version: 1, z: 0, kind: "segment", slot: "full", title: "Analysis", summary: "An ending built from the ledger: a chart of a named run of his weights, a pace table, a status row and one reading line, as its own segment.", validate: (_value, { manifest }) => validateAnalysisEntries(manifest), docs: { heading: "Analysis item", intro: "A timeline entry `{ type: \"analysis\", … }` (analysis-plan.mjs; [report-video.md](report-video.md#the-analysis-item)): a full-frame ending drawn from the LEDGER -- a chart of a named run of his weights (`series`: rows, or a span; a delta resolved against the run's start), a shaded `band`, `marks`, a `pace` table whose pounds and days are computed, `status` rows and ONE `reading` -- the line drawing in, the rows landing; with `audio` a clip's sound under it (its citation and QR on the page, its picture not), else silent for `seconds` (7, at most 8). Every figure traces to a ledger row (the dashed line too: `mark: {row}`); a bound (\"< 300\") is drawn hollow and a pace row ending on one says it in words (\"MORE THAN 10.5 lb lost\", \"AT MOST 8.5 lb lost\"); a number typed into the words is a lint warning.", rows: [ ["an `analysis` entry", "`title`, `kicker`, `series`, `band`, `marks`, `pace`, `status`, `reading`, `footnote`, `mark`, `audio?`, `seconds?`", "`umtool timeline

[--take ] add-analysis @` · `set-analysis @` (or the JSON itself)"], ], }, region: "analysis", workers: "wide", noun: "the analysis item's", entry(manifest, segment) { const e = (manifest.timeline ?? []).find((x) => x.id === segment && x.type === "analysis") ?? null; if (!e) return null; const errors = analysisProblems(e, analysisContext(manifest)).errors; if (errors.length) throw new Error(errors.join("; ")); return e; }, seconds: (entry) => analysisSeconds(entry), names: ({ preview, entry }) => ({ project: `analysis-${preview ? "preview-" : ""}${entry.id}`, stem: `analysis-${entry.id}` }), async page(ctx) { const { analysisHtml, analysisCite, ANALYSIS_BOX } = await import("../chrome-analysis.mjs"); const fonts = await instrumentFonts(ctx); const src = analysisSource(ctx.entry, ctx.manifest, ctx.context?.meta ?? null); let qrSrc = null; if (src?.url) { const byUrl = await ctx.qrs([src.url], Math.round((ANALYSIS_BOX.qr * (Number(ctx.render.width) || 1920)) / 1280)); qrSrc = byUrl.get(src.url) ?? null; } return analysisHtml(ctx.entry, analysisContext(ctx.manifest), { fonts, cite: src ? analysisCite(src.parts) : null, qrSrc }); }, // A cue interpreter: a changed item recaptures only the frames its change is on. frameKeys: { data: "analysis-data", omit: ["init", "cues"] }, });