// THE PAIR (module `pair`, region `pair`): then and now -- two clips on one // subject, each with its date (`render.chrome.pair`). As "split" a strip in // the footage box, THEN on one side and NOW on the other, the side playing // lit and the pair's caption under them; as "then→now" a card with both // dates and an arrow over the pair's first seconds. chrome-story.mjs writes // the page; story-settings.mjs holds its rules. import path from "node:path"; import { pairGeometry, pairHtml, pairSchedule, resolvePair } from "../chrome-story.mjs"; import { assertRegion, defineModule } from "./contract.mjs"; import { DATE_FORMATS, PAIR_DEFAULTS, PAIR_LIMITS, PAIR_POSITIONS, PAIR_STYLES, validatePair } from "./story-settings.mjs"; export default defineModule({ id: "pair", version: 1, z: 52, kind: "overlay-whole", slot: "footage", // Its form in the stacked vertical deck (vertical-deck.mjs). vertical: { slot: "picture" }, title: "Then and now", summary: "Two clips on one subject, each with its date: a then | now strip (or a then→now card) with the pair's caption.", configKey: "render.chrome.pair", defaults: PAIR_DEFAULTS, validate: (v) => validatePair(v), resolve: resolvePair, ui: [ { key: "style", type: "enum", options: PAIR_STYLES, label: "Style", default: "split" }, { key: "position", type: "enum", options: PAIR_POSITIONS, label: "Strip at", default: "bottom" }, { key: "dateFormat", type: "enum", options: DATE_FORMATS, label: "Dates", default: "long" }, { key: "labels.then", type: "text", label: "Then label", default: "Then" }, { key: "labels.now", type: "text", label: "Now label", default: "Now" }, { key: "seconds", type: "number", min: PAIR_LIMITS.seconds[0], max: PAIR_LIMITS.seconds[1], step: 0.5, label: "Card seconds (then→now)", default: 4 }, { key: "pairs", type: "list", label: "Pairs", item: [ { key: "then.clip", type: "clip", label: "Then clip" }, { key: "then.date", type: "date", label: "Then date" }, { key: "now.clip", type: "clip", label: "Now clip" }, { key: "now.date", type: "date", label: "Now date" }, { key: "topic", type: "text", label: "Topic" }, { key: "caption", type: "text", label: "Caption" }, { key: "style", type: "enum", options: PAIR_STYLES, label: "Style (this pair)" }, ] }, ], docs: { heading: "Then and now (pair)", intro: "Two clips on one subject, each with its date (`render.chrome.pair`, chrome-story.mjs). The footage is not split -- two clips never play at once: \"split\" is a strip in the footage box, THEN on one side and NOW on the other, the side playing lit, up while either clip plays; \"then→now\" a card with both dates over the pair's first `seconds`. A pair whose clips the cut does not play is not drawn.", rows: [ ["`chrome.pair.pairs[]`", `1–${PAIR_LIMITS.pairs} \`{then: {clip, date?, label?}, now: {clip, date?, label?}, caption? ≤${PAIR_LIMITS.caption}, topic? ≤${PAIR_LIMITS.topic}, style?, also?: [{clip, side, date?}]}\` -- a date YYYY, YYYY-MM or YYYY-MM-DD; \`also\` more clips on a side (≤${PAIR_LIMITS.also})`, "`umtool modules apply
--config module-config.json` · `umtool look
pair='{…}'`"], ["`chrome.pair.style`", "`split` · `then→now` · default `split` (a pair's own `style` wins)", "`umtool look
pair.style=then→now`"], ["`chrome.pair.position`, `.dateFormat`, `.seconds`", "`bottom` `top` · `long` `year` `iso` · 1–10 s · default `bottom`, `long`, 4", "`umtool look
pair.position=top`"], ["`chrome.pair.labels`", "`{then, now}` ≤16 each · default Then, Now", "`umtool look
pair.labels='{\"then\":\"2012\"}'`"], ], }, region: "pair", workers: "narrow", noun: "the pair strip's", on: (schedule, render) => !!schedule?.segments && pairSchedule(schedule, render).length > 0, check: (schedule, render) => (pairSchedule(schedule, render).length ? null : "the pair region needs render.chrome.pair with a pair whose clips the cut plays"), async page(ctx) { const fonts = await ctx.fonts({ regular: "DeckSans", bold: "DeckSansBold" }, { strict: true }); return pairHtml(ctx.schedule, ctx.render, { fonts, from: ctx.from, duration: ctx.duration }); }, regions(schedule, { render, outDir, frames = null }) { return [assertRegion({ name: "pair", frames: frames ?? path.join(outDir, "chrome", "pair-frames"), ...pairGeometry(render, { feed: schedule.layout === "feed" }), })]; }, preview: (_slice, { render }) => ({ region: "pair", geometry: pairGeometry(render) }), // Its page is its live preview: Play the cut seeks it in the cut's seconds (contract.mjs, PLAY). play: { clock: "cut", ready: "pair:ready" }, // A cue interpreter: each pair an item, so a changed caption recaptures only its frames. frameKeys: { data: "pair-data", omit: ["init", "cues", "window", "total", "ids"] }, });