// THE STACKED VERTICAL DECK'S PAGE (vertical-deck.mjs): the deck's shell, in // 9:16. One HyperFrames page over the whole frame, transparent but for what it // draws -- the rail under the top band (the section's name, its progress // segments, "2 / 5"), each segment's source block above the bottom band (the // QR, channel · title · date · time; a post item's big date line and who // posted it), the tally's cells when the cut counts, the site's wordmark dim in // the bottom band -- and, for a twocrop clip, the source line over the rail at // the top, the one-row strip of the instruments between its crops and the QR // small and low-left. // // The schedule is the landscape deck's (deck.mjs deckSchedule: the same // segments, the same handovers, the same stamps); only where things stand is // this page's. The pictures (the footage, the crops, a post's card) are the // segments' own; the instruments are their own pages in the panel. // // PURE, as the other pages: a schedule and a render block in, an HTML string // out (measure-draw.mjs pageHtml, its cue interpreter -- every state a block // shown over exactly its span, so a frame whose words did not move keys as the // frame before it). import { deckChoreography, pipSegments, railOffStyle, resolveDeck, resolveSectionTitle, stackedCounterOn } from "./deck.mjs"; import { mix, rgba } from "./chrome-deck.mjs"; import { resolveCounter } from "./counter.mjs"; import { tallyLabelOf, tallyOf, tallySteps } from "./factcheck.mjs"; import { resolveDial, resolveOdometer } from "./instruments.mjs"; import { cueList, esc, fmtSigned, fmtWeight, INSTANT, measureTrack, pageHtml, r4 } from "./measure-draw.mjs"; import { stackedGeometry } from "./vertical-deck.mjs"; const HEX_RE = /^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/; /** The deck's text motion in the stacked deck: a block out, the next in (the landscape deck's `motion`). */ const swap = (deck) => ({ out: deck.motion?.out ?? 0.3, in: deck.motion?.in ?? 0.45 }); /** * The rail's sections: the markers (`deck.markers`, each after a pip's clip) * split the pipped segments; the first is `sectionTitle.first`'s. Each * `{ label, color, pips: [segment index…] }`, and `of` the section of each * pipped segment. One section (no markers): the clips' count is the rail. */ export function stackedSections(schedule, render) { const d = resolveDeck(render); const pal = render?.palette ?? {}; const st = resolveSectionTitle(render); const pipped = pipSegments(schedule); const byColor = d.pip?.color === "section"; const hexOf = (key, fallback) => (typeof key === "string" && HEX_RE.test(key) ? key : (key && pal[key]) || fallback); const after = new Map((Array.isArray(d.markers) ? d.markers : []) .filter((m) => m && typeof m.after === "string" && m.level !== 2) .map((m) => [m.after, m])); const sections = [{ label: st?.first ?? "", color: byColor ? hexOf(d.pip?.sectionColor0, pal.accent ?? "#22AB83") : pal.accent ?? "#22AB83", pips: [] }]; pipped.forEach((s, j) => { sections[sections.length - 1].pips.push(j); const m = after.get(s.id); if (m && j < pipped.length - 1) { sections.push({ label: String(m.label ?? "").trim(), color: byColor ? hexOf(m.color, pal.fg ?? "#ffffff") : pal.accent ?? "#22AB83", pips: [] }); } }); const of = []; sections.forEach((sec, i) => sec.pips.forEach((j) => { of[j] = i; })); return { sections, of, pipped }; } /** When each pipped segment takes the rail: the first at 0, each after it at its handover (its start plus half the join). */ function railTimes(schedule) { const D = Number(schedule.transition) || 0; return pipSegments(schedule).map((s, j) => (j === 0 ? 0 : r4(s.start + D / 2))); } /** The site's name the bottom band's wordmark says: its host's first label ("jeralyzer.pages.dev" → "JERALYZER"). */ export function wordmarkOf(provenance) { const o = String(provenance?.siteOrigin ?? "").trim(); if (!o) return ""; try { return new URL(o).hostname.split(".")[0].toUpperCase(); } catch { return ""; } } /** The values a twocrop clip's strip shows at `t`: what he says he weighs, what he says he has lost, NET. */ function stripCells(M, render) { if (!M) return []; const track = measureTrack(M); const dial = resolveDial(render); const odo = resolveOdometer(render); const at = (list, t) => [...list].reverse().find((x) => x.t <= t + 1e-6) ?? list[0] ?? null; const cells = []; if (dial) cells.push({ label: dial.label, value: (t) => { const c = at(track.current, t); return Number.isFinite(c?.value) ? `${c.qualifier ?? ""}${fmtWeight(c.value)}` : "NOT YET"; } }); if (odo) cells.push({ label: odo.label.replace(/^POUNDS /, ""), value: (t) => fmtWeight(at(track.lost, t)?.total ?? 0) }); if (odo?.net) { cells.push({ label: "NET", value: (t) => { const n = at(track.net, t)?.net; const f = typeof n?.from === "number" ? n.from : n?.from?.value; const to = typeof n?.to === "number" ? n.to : n?.to?.value; return Number.isFinite(f) && Number.isFinite(to) ? fmtSigned(to - f) : "—"; } }); } const times = [...new Set([0, ...track.current.map((x) => x.t), ...track.lost.map((x) => x.t), ...track.net.map((x) => x.t)])].sort((a, b) => a - b); return cells.map((c) => ({ label: c.label, runs: times.map((t) => ({ t, text: c.value(t) })).filter((r, i, all) => i === 0 || r.text !== all[i - 1].text) })); } /** * The stacked deck's page for the whole cut (or a window of it). `qrSrcs` = * `{ : "assets/qrNN.png" }`; `fonts` the deck's faces by name * (DeckSans, DeckSansBold, MeasureDisplay, MeasureCond); `site` the * wordmark's words. */ export function stackedDeckHtml(schedule, render, opts = {}) { const deck = resolveDeck(render); const pal = { bg: "#0F1312", fg: "#EDF0EC", muted: "#98A29B", accent: "#22AB83", amber: "#E8A33F", ...(render?.palette ?? {}) }; const tally = tallyOf(schedule, render); const g = stackedGeometry(render, { counter: stackedCounterOn(render) }); const W = g.W, H = g.H; const u = W / 1080; const px = (v) => Math.round(v * u); const fps = schedule.fps ?? render.fps ?? 30; const fonts = opts.fonts ?? {}; const qrSrcs = opts.qrSrcs ?? {}; const from = Number(opts.from ?? 0); const total = schedule.total; const dur = opts.duration != null ? Number(opts.duration) : r4(total - from); if (!(dur > 0)) throw new Error(`deck: nothing to render from ${from}s of a ${total}s cut`); const windowed = from > 0 || Math.abs(dur - total) > 1e-6; const D = Number(schedule.transition) || 0; const m = swap(deck); const segs = schedule.segments ?? []; const display = fonts.MeasureDisplay ? "'MeasureDisplay', 'DeckSansBold', sans-serif" : "'DeckSansBold', sans-serif"; const cond = fonts.MeasureCond ? "'MeasureCond', 'DeckSans', sans-serif" : "'DeckSans', sans-serif"; const card = mix(pal.bg, pal.fg, 0.06); const rule = mix(pal.bg, pal.fg, 0.16); const L = cueList(fps); // ---- the page's visibility: the deck's own (away over a card, a teaser, the finale) ---- L.set("rt", { autoAlpha: 1 }); for (const v of deckChoreography(schedule, render).visibility) { const [a, b] = v.at; L.add("rt", a, Math.max(INSTANT, b - a), { autoAlpha: v.hide ? 0 : 1 }, v.hide ? "power1.in" : "power2.out"); } // ---- each segment's span on the deck: from its handover in to the next one's ---- const handIn = (i) => (i === 0 ? 0 : r4(segs[i].start + D / 2)); const handOut = (i) => (i + 1 < segs.length ? r4(segs[i + 1].start + D / 2) : total); const twocrop = (s) => s?.vlayout === "twocrop"; const show = (k, i, { fade = true } = {}) => { const a = handIn(i); const b = handOut(i); L.set(k, { autoAlpha: a <= 0 ? 1 : 0 }); if (a > 0) L.add(k, a, fade ? m.in : INSTANT, { autoAlpha: 1 }, "power2.out"); if (b < total - 1e-6) L.add(k, Math.max(a + INSTANT, b - (fade ? m.out : 0)), fade ? m.out : INSTANT, { autoAlpha: 0 }, "power1.in"); }; // ---- the rail: the section's name, its progress, "2 / 5" -- and a twocrop clip's own over its source line ---- const { sections, of, pipped } = stackedSections(schedule, render); const times = railTimes(schedule); const many = sections.length > 1; const railBars = (pre) => sections.map((sec, i) => `
`).join(""); const railLabels = (pre, cls) => sections.map((sec, i) => `
${esc(sec.label)}
`).join(""); const counts = many ? sections.map((_, i) => `
${i + 1} / ${sections.length}
`).join("") : pipped.map((_, j) => `
${j + 1} / ${pipped.length}
`).join(""); // The fills and the labels: a section filled to its share as each of its clips takes the rail, the ones before full. for (const pre of ["r", "t"]) { sections.forEach((_, i) => { L.set(`${pre}f${i}`, { scaleX: 0, transformOrigin: "0% 50%" }); L.set(`${pre}l${i}`, { autoAlpha: 0 }); }); } (many ? sections : pipped).forEach((_, i) => L.set(`rc${i}`, { autoAlpha: 0 })); let curSec = null; pipped.forEach((_, j) => { const s = of[j]; const sec = sections[s]; const share = (sec.pips.indexOf(j) + 1) / sec.pips.length; const t = times[j]; for (const pre of ["r", "t"]) { if (curSec !== null && curSec !== s) { L.add(`${pre}f${curSec}`, t, 0.35, { scaleX: 1 }, "power2.out"); L.add(`${pre}l${curSec}`, t, 0.25, { autoAlpha: 0 }, "power1.in"); } L.add(`${pre}f${s}`, t, t <= 0 ? INSTANT : 0.5, { scaleX: r4(share) }, "power2.inOut"); if (curSec !== s) L.add(`${pre}l${s}`, t, t <= 0 ? INSTANT : 0.3, { autoAlpha: 1 }, "power2.out"); } const ck = many ? s : j; const prevCk = many ? curSec : j - 1; if (prevCk !== null && prevCk >= 0 && prevCk !== ck) L.add(`rc${prevCk}`, t, INSTANT, { autoAlpha: 0 }); if (prevCk !== ck) L.add(`rc${ck}`, t, INSTANT, { autoAlpha: 1 }); curSec = s; }); // The rail itself: up but over a twocrop clip, whose own stands over its source line. L.set("rail", { autoAlpha: 1 }); L.set("top2", { autoAlpha: 0 }); segs.forEach((s, i) => { if (!twocrop(s)) return; L.add("rail", handIn(i) - m.out, m.out, { autoAlpha: 0 }, "power1.in"); L.add("top2", handIn(i), m.in, { autoAlpha: 1 }, "power2.out"); if (handOut(i) < total - 1e-6) { L.add("top2", handOut(i) - m.out, m.out, { autoAlpha: 0 }, "power1.in"); L.add("rail", handOut(i), m.in, { autoAlpha: 1 }, "power2.out"); } }); // ---- each segment's source block ---- const blocks = []; const tops = []; const strips = []; const smallQrs = []; const M = schedule.measure && Array.isArray(schedule.measure.state) ? schedule.measure : null; const cellsAll = stripCells(M, render); segs.forEach((s, i) => { if (s.hideDeck) return; const qr = qrSrcs[s.id] ?? null; const k = `s${i}`; if (twocrop(s)) { // The source line over the rail at the top; the QR small and low-left; the instruments' strip between the crops. const v = s.vsource ?? {}; tops.push(`
${esc(v.channel || s.title || "")}${esc([v.date, v.clock].filter(Boolean).join(" · "))}
`); show(`${k}t`, i); if (qr) { smallQrs.push(``); show(`${k}q`, i); } if (cellsAll.length) { const cells = cellsAll.map((c, ci) => { const runs = c.runs.map((r, ri) => `
${esc(r.text)}
`).join(""); c.runs.forEach((r, ri) => { const a = r.t; const b = c.runs[ri + 1]?.t ?? Infinity; L.set(`${k}c${ci}r${ri}`, { autoAlpha: a <= 0 && b > 0 ? 1 : 0 }); if (a > 0) L.add(`${k}c${ci}r${ri}`, a, INSTANT, { autoAlpha: 1 }); if (Number.isFinite(b)) L.add(`${k}c${ci}r${ri}`, b, INSTANT, { autoAlpha: 0 }); }); return `
${esc(c.label)}
${runs}
`; }).join(""); strips.push(`
${cells}
`); show(`${k}x`, i); } return; } let words; if (s.type === "post") { words = `
${esc(s.title ?? "")}
${esc(s.subtitle ?? "")}
`; } else if (s.vsource) { const v = s.vsource; words = `
${esc(v.channel)}
${esc(v.title)}
${esc([v.date, v.clock].filter(Boolean).join(" · "))}
`; } else { words = `
${esc(s.title ?? "")}
${esc(s.subtitle ?? "")}
`; } const html = `
${qr ? `` : ""}
${words}
`; blocks.push(html); show(k, i); }); // ---- the tally: a cell per verdict the cut counts, its count over its label; under a post item's card ---- let tallyHtml = ""; if (tally?.length) { const byId = resolveCounter(render).byId ?? {}; const steps = tallySteps(schedule.factcheck?.stamps ?? [], tally); const cells = tally.map((v, ci) => { const vr = byId[v] ?? {}; const color = HEX_RE.test(vr.color ?? "") ? vr.color : pal.accent; const runs = [{ at: 0, n: 0 }, ...steps.filter((x) => x.verdict === v).map((x) => ({ at: x.at, n: x.count }))]; const nums = runs.map((r, ri) => { const kk = `tn${ci}r${ri}`; const b = runs[ri + 1]?.at ?? Infinity; L.set(kk, { autoAlpha: r.at <= 0 && b > 0 ? 1 : 0 }); if (r.at > 0) L.add(kk, r.at, INSTANT, { autoAlpha: 1 }); if (Number.isFinite(b)) L.add(kk, b, INSTANT, { autoAlpha: 0 }); return `
${r.n}
`; }).join(""); const label = tallyLabelOf(vr) ?? vr.label ?? v; return `
${esc(label)}
${nums}
`; }).join(""); tallyHtml = `
${cells}
`; // Under a post item's card while it is up; over the source block otherwise. const dy = g.post.counters.y - (g.counters?.y ?? g.post.counters.y); L.set("tal", { y: 0 }); segs.forEach((s, i) => { if (s.type !== "post" || !dy) return; L.add("tal", handIn(i) - m.out, m.out + m.in, { y: dy }, "power2.inOut"); if (handOut(i) < total - 1e-6) L.add("tal", handOut(i) - m.out, m.out + m.in, { y: 0 }, "power2.inOut"); }); // Over a twocrop clip its row would stand on crop two: it stands down (its strip carries the numbers). L.set("talv", { autoAlpha: 1 }); segs.forEach((s, i) => { if (!twocrop(s)) return; L.add("talv", handIn(i) - m.out, m.out, { autoAlpha: 0 }, "power1.in"); if (handOut(i) < total - 1e-6) L.add("talv", handOut(i), m.in, { autoAlpha: 1 }, "power2.out"); }); } const site = typeof opts.site === "string" ? opts.site : ""; const { init, cues } = L.build(); const sq = g.source.qr; const st = g.source.text; const tq = g.twocrop.qr; const t2 = g.twocrop.top; const strip = g.twocrop.strip; const ct = g.counters ?? { x: g.safe.x0, y: g.source.y - px(100), width: g.safe.x1 - g.safe.x0, height: px(80) }; const css = ` #rt { position: absolute; inset: 0; } .rail, .top2 { position: absolute; left: ${g.rail.x}px; top: ${g.rail.y}px; width: ${g.rail.width}px; height: ${g.rail.height}px; } .top2 { top: ${t2.y}px; height: ${t2.height}px; } .rlab, .rcount, .tlab2 { position: absolute; top: 0; height: ${g.rail.label}px; line-height: ${g.rail.label}px; white-space: nowrap; overflow: hidden; } .rlab { left: 0; right: ${px(130)}px; font-family: ${display}; font-size: ${px(40)}px; letter-spacing: 0.06em; text-transform: uppercase; text-overflow: ellipsis; } .rcount { right: 0; font-family: 'DeckSans', sans-serif; font-size: ${px(24)}px; color: ${pal.muted}; font-variant-numeric: tabular-nums; } .bars { position: absolute; left: 0; right: 0; bottom: 0; height: ${g.rail.bar}px; display: flex; gap: ${px(8)}px; } .bar { position: relative; height: 100%; border-radius: ${px(2)}px; overflow: hidden; } .fill { position: absolute; inset: 0; } .top2 .bars { bottom: ${px(4)}px; right: ${px(260)}px; } .tlab2 { top: auto; bottom: ${px(-8)}px; right: 0; width: ${px(250)}px; text-align: right; font-family: ${display}; font-size: ${px(30)}px; letter-spacing: 0.06em; text-transform: uppercase; text-overflow: ellipsis; } .tline { position: absolute; left: 0; top: 0; right: 0; height: ${px(44)}px; line-height: ${px(44)}px; white-space: nowrap; overflow: hidden; } .tch { font-family: 'DeckSansBold', sans-serif; font-size: ${px(30)}px; color: ${pal.fg}; margin-right: ${px(16)}px; } .tdt { font-family: 'DeckSans', sans-serif; font-size: ${px(27)}px; color: ${pal.accent}; font-variant-numeric: tabular-nums; } .src { position: absolute; left: ${g.source.x}px; top: ${g.source.y}px; width: ${g.source.width}px; height: ${g.source.height}px; border-top: ${Math.max(1, px(2))}px solid ${rule}; } .src .qr { position: absolute; left: 0; top: ${sq.y - g.source.y}px; width: ${sq.size}px; height: ${sq.size}px; border-radius: ${px(8)}px; image-rendering: pixelated; box-shadow: 0 0 0 1px ${rgba(pal.fg, 0.25)}; } .src .words { position: absolute; left: ${st.x - g.source.x}px; top: ${st.y - g.source.y}px; width: ${st.width}px; height: ${st.height}px; display: flex; flex-direction: column; justify-content: center; gap: ${px(6)}px; } .src .words.noqr { left: 0; width: ${g.source.width}px; } .src .ch { font-family: 'DeckSansBold', sans-serif; font-size: ${px(32)}px; color: ${pal.fg}; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .src .ti { font-family: 'DeckSans', sans-serif; font-size: ${px(28)}px; color: ${mix(pal.muted, pal.fg, 0.45)}; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .src .dt { font-family: 'DeckSans', sans-serif; font-size: ${px(28)}px; color: ${pal.accent}; font-variant-numeric: tabular-nums; white-space: nowrap; } .src .pdate { font-family: ${display}; font-size: ${px(56)}px; line-height: 1; color: ${pal.fg}; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .src .pwho { font-family: 'DeckSans', sans-serif; font-size: ${px(28)}px; color: ${mix(pal.muted, pal.fg, 0.45)}; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .qrs { position: absolute; left: ${tq.x}px; top: ${tq.y}px; width: ${tq.size}px; height: ${tq.size}px; border-radius: ${px(6)}px; opacity: 0.9; image-rendering: pixelated; } .strip { position: absolute; left: 0; top: ${strip.y}px; width: ${W}px; height: ${strip.height}px; background: ${card}; border-top: 1px solid ${rule}; border-bottom: 1px solid ${rule}; display: grid; padding: 0 ${W - g.safe.x1}px 0 ${g.safe.x0}px; } .scell { position: relative; display: flex; flex-direction: column; justify-content: center; gap: ${px(4)}px; padding-left: ${px(20)}px; border-left: 1px solid ${rule}; } .scell:first-child { padding-left: 0; border-left: 0; } .scell .sl { font-family: ${cond}; font-size: ${px(21)}px; letter-spacing: 0.08em; color: ${pal.muted}; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .scell .svs { position: relative; height: ${px(42)}px; } .scell .sv { position: absolute; left: 0; top: 0; font-family: ${display}; font-size: ${px(38)}px; line-height: ${px(42)}px; color: ${pal.fg}; white-space: nowrap; } .talv { position: absolute; inset: 0; } .tally { position: absolute; left: ${ct.x}px; top: ${ct.y}px; width: ${ct.width}px; height: ${ct.height}px; display: flex; gap: ${px(12)}px; } .tcell { position: relative; flex: 0 1 ${px(230)}px; border: 1px solid; border-radius: ${px(10)}px; background: ${rgba(pal.bg, 0.85)}; display: flex; flex-direction: column; justify-content: center; padding: 0 ${px(16)}px; } .tlab { font-family: ${cond}; font-size: ${px(20)}px; letter-spacing: 0.08em; color: ${pal.muted}; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .tnums { position: relative; height: ${px(40)}px; } .tnum { position: absolute; left: 0; top: 0; font-family: ${display}; font-size: ${px(36)}px; line-height: ${px(40)}px; font-variant-numeric: tabular-nums; } .mark { position: absolute; left: ${g.wordmark.x}px; top: ${g.wordmark.y}px; font-family: ${display}; font-size: ${g.wordmark.size}px; letter-spacing: 0.12em; color: ${mix(pal.bg, pal.fg, 0.24)}; white-space: nowrap; }`; const body = `
${railLabels("r", "rlab")}${counts}
${railBars("r")}
${tops.join("")}
${railBars("t")}
${railLabels("t", "tlab2")}
${blocks.join("")} ${strips.join("")} ${smallQrs.join("")} ${tallyHtml} ${site ? `
${esc(site)}
` : ""}
`; return pageHtml({ id: "deck", W, H, fps, fonts, gsap: opts.gsap, data: { total: r4(total), window: windowed ? { from: r4(from), dur: r4(dur) } : null, init, cues }, css, body, }); }