commit 73832af3735675b9a9d22232829dbe2d6b4c30fe
parent 52425e315c573c872ab4e787a9f6dcedff860e31
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Thu, 5 Nov 2026 10:22:40 -0500
umtool: picture-only posts drawn as their message -- the picture in its own card, a context post's own beat before the read; a long read alone keeps large text
A post whose words are only @mentions and links, with an attachment (an item, a post it answers, the post it
quotes), is picture-only (post-picture.mjs isPictureOnly; `pictureOnly` on the item, parents[i], quoted; the cut's
render.posts.pictureReply {on, image, min, max}). Its picture is drawn inside its card where its words would be
(pictureHtml: the card's width, aspect and crop kept), its mention small; never in the slot (slotMediaOf,
mediaSteps, panelSchedule skip it). A picture-only context post the read does not read, before its first piece,
gets its own beat (post-thread.mjs pictureBeats): revealed, lit and alone for its GIF's own length (an image 2 s,
1.5-4 s), the read's start moved by it (the take untouched), his own attachment entering with his words; read-follow
frames it as a piece. The build lays the GIF over its still where the card is full and still (measurePics); Play's
card plays it; the post bench has a picture-only block with the knob; posts set-item pictureOnly= /
parent.<i>.pictureOnly= / quoted.pictureOnly=. A long post on a card alone, following, is drawn at a reading size
(POST_LONG_READ_SIZE) and panned, never shrunk to fit.
(operator, 5 Nov: the "It's time to stop" gif "shows while Obvious is speaking rather than it being a picture-only
response like the MW post"; "bigger text for the novel")
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
12 files changed, 733 insertions(+), 84 deletions(-)
diff --git a/umtool/app/api/report/post-item/route.ts b/umtool/app/api/report/post-item/route.ts
@@ -258,6 +258,9 @@ export async function GET(request: Request) {
redaction,
// THE JOIN (post-join.mjs): the post the item before ended on drawn as it drew its post (Play lays the morph).
join: followOn && found.ctx.join && found.prev?.type === "post" ? joinCarry(found.prev as Entry, found.prevCtx, cutRender, { width: w, height: h }) : null,
+ // PICTURE-ONLY posts (post-picture.mjs): each picture in its own card -- a GIF or a video playing there.
+ mediaUrl: (src: string) => `${base}&file=${encodeURIComponent(src)}`,
+ livePics: true,
});
return new Response(html, { headers: { "content-type": "text/html; charset=utf-8", ...noStore } });
}
diff --git a/umtool/components/projects/PostBench.tsx b/umtool/components/projects/PostBench.tsx
@@ -7,7 +7,7 @@ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import { buttonVariants } from "@/components/ui/button";
import { cn } from "@/lib/utils";
import { postBenchHref } from "@/lib/hrefs";
-import { POST_HOLD, POST_MEDIA_MIN_SPAN, POST_PARAPHRASE_MAX, contextReadSeconds, postItemPlan, readingSeconds, ruleSeconds, panelEntry } from "umtool-report-to-video/post-item";
+import { POST_HOLD, POST_MEDIA_MIN_SPAN, POST_PARAPHRASE_MAX, contextReadSeconds, ownPictureOnly, postItemPlan, readingSeconds, refPictureOnly, ruleSeconds, panelEntry } from "umtool-report-to-video/post-item";
import PostItemPlayer, { type PostPlan } from "./review/PostItemPlayer";
import PostFollowPanel from "./PostFollowPanel";
import PostThreadPanel from "./PostThreadPanel";
@@ -46,8 +46,15 @@ import { sceneEntry } from "umtool-report-to-video/post-media-scene";
type Blur = { on: boolean; strength?: number; boxes?: number[][]; label?: string | false; band?: Band; style?: "blur" | "black" | "pixelate" };
type Media = Record<string, unknown> & { src: string; kind: string; seconds?: number; start?: number; end?: number; mute?: boolean; crop?: number[]; push?: boolean; words?: string; audio?: boolean; width?: number; height?: number; blur?: Blur };
-type Ref = Record<string, unknown> & { author?: string; handle?: string; text?: string; paraphrase?: string };
-type Entry = Record<string, unknown> & { id: string; media?: Media[]; hold?: number; mediaLayout?: string; redact?: boolean; quoted?: Ref; parents?: Ref[] };
+type Ref = Record<string, unknown> & { author?: string; handle?: string; text?: string; paraphrase?: string; media?: Media[]; pictureOnly?: boolean };
+type Entry = Record<string, unknown> & { id: string; media?: Media[]; hold?: number; mediaLayout?: string; redact?: boolean; quoted?: Ref; parents?: Ref[]; pictureOnly?: boolean };
+/** A post with its `pictureOnly` knob set (undefined: the rule, post-picture.mjs). */
+const withPictureOnly = <T extends Record<string, unknown>>(p: T, v: boolean | undefined): T => {
+ const out = { ...p } as Record<string, unknown>;
+ if (v === undefined) delete out.pictureOnly;
+ else out.pictureOnly = v;
+ return out as T;
+};
const r2 = (v: number) => Math.round(v * 100) / 100;
/** A context post with its paraphrase set (undefined: none, its own words). */
@@ -210,9 +217,11 @@ export default function PostBench({
},
]),
),
- ...(e.quoted && typeof e.quoted === "object" ? { quoted: { paraphrase: e.quoted.paraphrase?.trim() ? e.quoted.paraphrase : null } } : {}),
+ // Picture-only (post-picture.mjs): true, false, or null (the rule).
+ pictureOnly: typeof e.pictureOnly === "boolean" ? e.pictureOnly : null,
+ ...(e.quoted && typeof e.quoted === "object" ? { quoted: { paraphrase: e.quoted.paraphrase?.trim() ? e.quoted.paraphrase : null, pictureOnly: typeof e.quoted.pictureOnly === "boolean" ? e.quoted.pictureOnly : null } } : {}),
...(Array.isArray(e.parents) && e.parents.length
- ? { parents: Object.fromEntries(e.parents.map((p, i) => [i, { paraphrase: p?.paraphrase?.trim() ? p.paraphrase : null }])) }
+ ? { parents: Object.fromEntries(e.parents.map((p, i) => [i, { paraphrase: p?.paraphrase?.trim() ? p.paraphrase : null, pictureOnly: typeof p?.pictureOnly === "boolean" ? p.pictureOnly : null }])) }
: {}),
});
// The context posts the card draws: the one it quotes, the ones it answers (nearest first).
@@ -503,6 +512,45 @@ export default function PostBench({
</label>
</section>
+ {/* PICTURE-ONLY posts (post-picture.mjs): each post with an attachment, whether its picture is its message. */}
+ {(() => {
+ const rows: Array<{ key: string; label: string; post: Ref | Entry; on: boolean; auto: boolean; set: (v: boolean | undefined) => void }> = [];
+ if ((entry.media ?? []).length) rows.push({ key: "post", label: "his post", post: entry, on: ownPictureOnly(entry), auto: ownPictureOnly(withPictureOnly(entry, undefined)), set: (v) => setEntry((x) => withPictureOnly(x, v)) });
+ (entry.parents ?? []).forEach((p, i) => {
+ if (!(p?.media ?? []).length) return;
+ rows.push({ key: `parent.${i}`, label: i === 0 ? "the post it answers" : `the post that answers (${i + 1} up)`, post: p, on: refPictureOnly(p), auto: refPictureOnly(withPictureOnly(p, undefined)), set: (v) => setEntry((x) => ({ ...x, parents: (x.parents ?? []).map((q, j) => (j === i ? withPictureOnly(q, v) : q)) })) });
+ });
+ if (entry.quoted && (entry.quoted.media ?? []).length) {
+ const q = entry.quoted;
+ rows.push({ key: "quoted", label: "the post it quotes", post: q, on: refPictureOnly(q), auto: refPictureOnly(withPictureOnly(q, undefined)), set: (v) => setEntry((x) => ({ ...x, quoted: withPictureOnly(x.quoted ?? {}, v) })) });
+ }
+ if (!rows.length) return null;
+ const beats = plan.follow?.beats ?? [];
+ return (
+ <section className="rounded border border-[var(--color-line)] bg-[var(--color-panel)] p-3" data-post-bench-picture="">
+ <h2 className="micro mb-2">picture-only</h2>
+ <p className="m-0 mb-2 text-text-2">A post of only @mentions and links with an attachment says it with its picture: drawn in its own card where its words would be, never beside the card; a post it answers or quotes gets its own beat before the read.</p>
+ {rows.map((r) => {
+ const beat = beats.find((b) => b.scope === (r.key === "post" ? "post" : r.key.replace(".", ":")));
+ return (
+ <label key={r.key} className="mt-1 flex flex-wrap items-center gap-2" data-post-bench-picture-row={r.key} data-picture-only={r.on ? "1" : "0"}>
+ <span className="min-w-[12rem]">{r.label}: <b>{r.on ? "picture-only" : "words and a picture"}</b>{beat ? ` (its beat ${r2(beat.t1 - beat.t0)} s before the read)` : ""}</span>
+ <select
+ value={typeof r.post.pictureOnly === "boolean" ? (r.post.pictureOnly ? "on" : "off") : "auto"}
+ onChange={(e) => r.set(e.target.value === "on" ? true : e.target.value === "off" ? false : undefined)}
+ data-post-bench-picture-knob={r.key}
+ >
+ <option value="auto">auto ({r.auto ? "picture-only" : "not"})</option>
+ <option value="on">picture-only</option>
+ <option value="off">not picture-only</option>
+ </select>
+ </label>
+ );
+ })}
+ </section>
+ );
+ })()}
+
{combo && (
<PostComboPanel
project={project}
diff --git a/umtool/components/projects/review/PostItemPlayer.tsx b/umtool/components/projects/review/PostItemPlayer.tsx
@@ -111,6 +111,8 @@ export type NarrationSchedule = { at: number; seconds: number; takeSeconds?: num
/** The plan's read-follow (read-follow.mjs followSchedule). */
export type FollowPlan = {
join?: { seconds: number };
+ /** PICTURE-ONLY context posts' beats before the read (post-thread.mjs pictureBeats). */
+ beats?: Array<{ scope: string; t0: number; t1: number }>;
dim: number;
ease: number;
readEnd: number;
@@ -131,6 +133,8 @@ export type PanelShow = { scope: string; media: Array<Record<string, unknown> &
export type PostPlan = {
panel?: { fade: number; shows: PanelShow[] };
+ /** PICTURE-ONLY posts (post-picture.mjs): each picture drawn in its own card (Play: the card's page plays it). */
+ pics?: Array<{ scope: string; media: PanelShow["media"] }>;
/** Its own attachments come in at this item second, with his own post (post-item.mjs ownMediaEnterAt). */
enter?: number;
reading: number;
@@ -211,6 +215,7 @@ export function postItemAssets({ project, take = null, entry, plan, box, publish
}
}
for (const sh of plan.panel?.shows ?? []) for (const m of sh.media) files.push(postFileUrl(project, m.src));
+ for (const pc of plan.pics ?? []) for (const m of pc.media) files.push(postFileUrl(project, m.src));
if (joinFrom) for (const x of endMediaOf(joinFrom.plan as never, { stepAt, mediaTimeAt }) as Array<{ m: { src?: unknown } }>) if (x.m.src) files.push(postFileUrl(project, String(x.m.src)));
return { id: entry.id, docs: [...new Set(docs)], files: [...new Set(files)] };
}
@@ -1100,6 +1105,8 @@ export default function PostItemPlayer({
setProgressState(progAt && progFrac !== null ? { ...progAt, frac: progFrac, opacity: op } : null, doc);
}, [progress, progAt, progFrac, s, layout.mode, plan.steps]);
const src = shown && inStep ? mediaTimeAt(shown, s) : null;
+ // A PICTURE-ONLY context post's BEAT (post-picture.mjs): the one being shown alone before the read, if any.
+ const beatNow = (plan.follow?.beats ?? []).find((b) => s >= b.t0 && s < b.t1) ?? null;
const cue = wordsRel && src !== null ? (cues[wordsRel] ?? []).find((c) => src >= c.start && src < c.end) ?? null : null;
return (
<div
@@ -1107,6 +1114,8 @@ export default function PostItemPlayer({
data-post-play={entry.id}
data-post-layout={layout.mode}
data-post-panel={layout.panel ?? undefined}
+ data-post-pics={plan.pics?.length ? plan.pics.map((p) => p.scope).join(" ") : undefined}
+ data-post-beat={beatNow ? beatNow.scope : undefined}
data-post-join={joinOn ? (jp !== null ? String(Math.round(jp * 100) / 100) : "done") : undefined}
data-post-step={reading ? "read" : current?.kind ?? "held"}
data-post-s={String(Math.round(s * 100) / 100)}
diff --git a/umtool/lib/report/manifest.mjs b/umtool/lib/report/manifest.mjs
@@ -2402,13 +2402,13 @@ export async function insertEntries(dir, afterId, specs, { token = null, op = "i
}
/** The knobs of a post item a write may set (post-item.mjs; knobs.md, "A post item"). */
-export const POST_ITEM_KNOBS = Object.freeze(["hold", "mediaLayout", "panel", "redact", "follow", "thread", "scene", "progress"]);
+export const POST_ITEM_KNOBS = Object.freeze(["hold", "mediaLayout", "panel", "redact", "follow", "thread", "scene", "progress", "pictureOnly"]);
/** A post item attachment's knobs: its trim, its sound, its crop, the push-in, its transcript, its censoring blur. */
export const POST_MEDIA_KNOBS = Object.freeze(["start", "end", "mute", "crop", "push", "words", "blur", "enter"]);
/** A context post's knobs (`quoted`, `parents[i]`): the operator's paraphrase of its words. */
-export const POST_CONTEXT_KNOBS = Object.freeze(["paraphrase", "ref", "media", "transcript"]);
+export const POST_CONTEXT_KNOBS = Object.freeze(["paraphrase", "ref", "media", "transcript", "pictureOnly"]);
/** The fields a context post (a parent, a linked post) is given by hand (`parent.<i>=<ref>`, post-item.mjs refErrors). */
-const POST_REF_FIELDS = Object.freeze(["id", "author", "handle", "badge", "date", "text", "url", "media", "paraphrase", "transcript", "via"]);
+const POST_REF_FIELDS = Object.freeze(["id", "author", "handle", "badge", "date", "text", "url", "media", "paraphrase", "transcript", "via", "pictureOnly"]);
/**
* SET A POST ITEM's KNOBS (the post bench, `umtool posts set-item`): `patch`
@@ -2515,6 +2515,11 @@ export async function updatePostItem(dir, id, patch, { token = null } = {}) {
if (cp.media !== null && !Array.isArray(cp.media)) throw new Error(`${what}.media is a list of attachments (or null: none)`);
set(ref, "media", cp.media?.length ? cp.media : null);
}
+ // Picture-only (post-picture.mjs): true, false, or null (the rule).
+ if ("pictureOnly" in cp) {
+ if (cp.pictureOnly !== null && typeof cp.pictureOnly !== "boolean") throw new Error(`${what}.pictureOnly is true or false (or null: the rule)`);
+ set(ref, "pictureOnly", cp.pictureOnly);
+ }
if ("transcript" in cp) {
if (cp.transcript !== null && typeof cp.transcript !== "string") throw new Error(`${what}.transcript is the words read off its picture (or null)`);
set(ref, "transcript", typeof cp.transcript === "string" && cp.transcript.trim() ? cp.transcript.trim() : null);
diff --git a/umtool/lib/report/postsCli.mjs b/umtool/lib/report/postsCli.mjs
@@ -110,7 +110,8 @@ export const POSTS_USAGE = [
" [panel=auto|side|top|bottom] [media.add=<posts-media/…file>] [media.<i>=off]",
" [parent.<i>=<json ref>|@<file.json>|off] [parent.<i>.media=<file>[,<file>…]|off]",
" [link.add=<json ref>|@<file.json>] [link.<i>=<json ref>|off] [link.<i>.media=<file>|off] [link.<i>.transcript=\"…\"|off]",
- " [thread.group=<name>|off] [thread.map=auto|on|off|map|label|both] [--json]",
+ " [thread.group=<name>|off] [thread.map=auto|on|off|map|label|both]",
+ " [pictureOnly=on|off|auto] [parent.<i>.pictureOnly=on|off|auto] [quoted.pictureOnly=on|off|auto] [--json]",
" a post item's knobs (the post bench's writer, updatePostItem): its hold, its images' grid, the blur of other authors,",
" an attachment's trim, sound, crop (fractions of its picture) and push-in; fit=read[:linger] (a narrated post: its",
" video cut to its best part for the read, `posts fit`). quoted.paraphrase / parent.<i>.paraphrase (nearest first):",
@@ -137,6 +138,9 @@ export const POSTS_USAGE = [
" thread.group=<name>: a MANUAL THREAD -- consecutive items of one group are one scene (timeline threads --write",
" gathers them in date order). thread.map: the BRANCH MAP drawn when the scene changes branch (post-branch-map.mjs).",
" panel=: where the attachments sit -- beside the card, or at full width above (top) or below it (a wide one: auto).",
+ " pictureOnly=: a PICTURE-ONLY post (post-picture.mjs) -- its attachment drawn in its own card where its words would",
+ " be, never in the slot; a post it answers or quotes that is one gets its own beat before the read. auto: a post",
+ " whose words are only @mentions and links, with an attachment; on / off force it (parent.<i>., quoted. for those).",
...ROLES_LINES,
...REREAD_LINES,
" umtool posts set-item | roles | narrate | reread | fx <project> … --in-take <take> A TAKE-SCOPED EDIT: the same",
@@ -848,7 +852,7 @@ const fileArg = (raw, k) => {
};
/** The ref keys a context post may carry (post-item.mjs refErrors). */
-const REF_KEYS = ["id", "author", "handle", "badge", "date", "text", "url", "media", "paraphrase", "transcript", "via"];
+const REF_KEYS = ["id", "author", "handle", "badge", "date", "text", "url", "media", "paraphrase", "transcript", "via", "pictureOnly"];
/** A context post given on the command line: JSON, or `@<file>.json`. Its `media` may name project files. */
const refArg = (raw, k) => {
@@ -958,7 +962,16 @@ export function postItemPatchOf(pairs) {
else if (/^links?\.\d+$/.test(k)) (((out.links ??= {})[k.split(".")[1]] ??= {}).ref = OFF.has(v) ? null : refArg(raw, k));
else if (/^links?\.\d+\.media$/.test(k)) (((out.links ??= {})[k.split(".")[1]] ??= {}).media = OFF.has(v) || v === "" ? null : raw.split(",").map((f) => fileArg(f, k)));
else if (/^links?\.\d+\.transcript$/.test(k)) (((out.links ??= {})[k.split(".")[1]] ??= {}).transcript = OFF.has(v) || raw.trim() === "" ? null : raw);
- else if (k === "quoted.paraphrase") out.quoted = { paraphrase: paraphraseOf(raw) };
+ else if (k === "quoted.paraphrase") out.quoted = { ...(out.quoted ?? {}), paraphrase: paraphraseOf(raw) };
+ // PICTURE-ONLY (post-picture.mjs): on, off, or auto (the rule: only @mentions and links, with an attachment).
+ else if (k === "pictureOnly" || k === "quoted.pictureOnly" || /^parents?\.\d+\.pictureOnly$/.test(k)) {
+ const v = raw.trim().toLowerCase();
+ if (!["on", "off", "auto", "true", "false", ""].includes(v)) throw new CliError(`${k}= takes on, off or auto`);
+ const val = v === "on" || v === "true" ? true : v === "off" || v === "false" ? false : null;
+ if (k === "pictureOnly") out.pictureOnly = val;
+ else if (k === "quoted.pictureOnly") out.quoted = { ...(out.quoted ?? {}), pictureOnly: val };
+ else ((out.parents ??= {})[k.split(".")[1]] ??= {}).pictureOnly = val;
+ }
else if (/^parents?\.\d+\.paraphrase$/.test(k)) ((out.parents ??= {})[k.split(".")[1]] ??= {}).paraphrase = paraphraseOf(raw);
else if (/^media\.\d+\.blur(\.(strength|label|boxes|band|style))?$/.test(k)) {
// The censoring blur (post-censor.mjs): on|off, its strength, its label (off: none), its boxes (x,y,w,h;…|off),
@@ -990,7 +1003,7 @@ export function postItemPatchOf(pairs) {
}
} else {
const m = /^media\.(\d+)\.(start|end|mute|crop|push|trim|enter)$/.exec(k);
- if (!m) throw new CliError(`${pair}: not a post item knob (hold=, layout=, panel=, redact=, scene=, follow=, follow.dim|ease=, thread=, thread.parent|quoted|carry|reveal|shrink|dim|seconds|pan|group|map=, media.add=, media.<i>=off, media.<i>.start|end|mute|crop|push|trim|enter=, media.<i>.blur[.strength|.label|.boxes|.band|.style]=, media.<i>.censor=, quoted.paraphrase=, parent.<i>=<ref>|off, parent.<i>.media=, parent.<i>.paraphrase=, link.add=, link.<i>=<ref>|off, link.<i>.media=, link.<i>.transcript=)`);
+ if (!m) throw new CliError(`${pair}: not a post item knob (hold=, layout=, panel=, redact=, scene=, follow=, follow.dim|ease=, thread=, thread.parent|quoted|carry|reveal|shrink|dim|seconds|pan|group|map=, media.add=, media.<i>=off, media.<i>.start|end|mute|crop|push|trim|enter=, media.<i>.blur[.strength|.label|.boxes|.band|.style]=, media.<i>.censor=, quoted.paraphrase=, parent.<i>=<ref>|off, parent.<i>.media=, parent.<i>.paraphrase=, pictureOnly=, parent.<i>.pictureOnly=, quoted.pictureOnly=, link.add=, link.<i>=<ref>|off, link.<i>.media=, link.<i>.transcript=)`);
const media = (out.media ??= {});
const one = (media[m[1]] ??= {});
if (m[2] === "start" || m[2] === "end") one[m[2]] = OFF.has(v) || v === "" ? null : Number(raw);
diff --git a/umtool/report-to-video/post-item.mjs b/umtool/report-to-video/post-item.mjs
@@ -33,10 +33,11 @@ import {
isNarrated, narrationSchedule, postNarrationFiles, postNarrationKnobs, validatePostNarration,
} from "./post-narration.mjs";
import { BAR_CSS, barsHtml, hasMarks, projectRedactOf, redactEntry, redactSceneRef, redactionOn, validatePostsRender } from "./post-redact.mjs";
-import { blurErrors } from "./post-censor.mjs";
+import { blurErrors, blurOn } from "./post-censor.mjs";
import { WORD_ZOOM_HIGHLIGHT_ALPHA, cardTokens, cardWordsOf, findMatch, targetTextOf, validatePostFx } from "./word-zoom.mjs";
import { FOLLOW_MIN_SIZE, followBlocks, followKnobs, followSchedule, scopeBlocks, validatePostFollow } from "./read-follow.mjs";
-import { panelSchedule, validatePostThread } from "./post-thread.mjs";
+import { panelSchedule, pictureBeats, threadLayout, validatePostThread } from "./post-thread.mjs";
+import { isPictureOnly, pictureBeatSeconds, pictureMediaOf, pictureRuleEntry, validatePictureOnly, validatePictureReplyRender } from "./post-picture.mjs";
import { joinLayerHtml, validatePostJoin, validatePostJoinRender } from "./post-join.mjs";
import { validatePostLinkVisit, validatePostLinkVisitRender, visitsEnd } from "./post-link-visit.mjs";
import { progressErrors } from "./post-progress.mjs";
@@ -123,6 +124,11 @@ export const refMediaOf = (ref) => (Array.isArray(ref?.media) ? ref.media.filter
/** Whether a context post is drawn at all: it has words, or an attachment (an image-only reply). */
export const refShown = (ref) => !!contextText(ref).trim() || refMediaOf(ref).length > 0;
+/** Whether the item's OWN post is picture-only (post-picture.mjs): its attachment drawn in its card, never in the slot. */
+export const ownPictureOnly = (entry) => isPictureOnly(entry, { text: cardText(entry) });
+/** Whether a context post (a parent, the quoted post) is picture-only (post-picture.mjs). */
+export const refPictureOnly = (ref) => isPictureOnly(ref);
+
/** Seconds to read the post itself (the rule above, its first line). */
export function readSeconds(entry) {
return clamp(POST_READ.lead + wordCount(cardText(entry)) / POST_READ.wps, POST_READ.min, POST_READ.max);
@@ -145,11 +151,16 @@ export function contextReadSeconds(ref) {
return clamp(wordCount(contextText(ref)) / POST_READ.wps, POST_CONTEXT_READ.min, POST_CONTEXT_READ.max);
}
-/** The whole reading time: the post and its context. */
-export function readingSeconds(entry) {
- let s = readSeconds(entry);
- for (const p of parentsOf(entry)) s += contextReadSeconds(p);
- if (isObj(entry?.quoted)) s += contextReadSeconds(entry.quoted);
+/**
+ * The whole reading time: the post and its context. A PICTURE-ONLY post (post-picture.mjs) is its picture's beat
+ * instead of its words' reading (`render`: the cut's rule).
+ */
+export function readingSeconds(entry, render = undefined) {
+ const e = pictureRuleEntry(entry, render);
+ const ctx = (p) => (refPictureOnly(p) ? pictureBeatSeconds(refMediaOf(p), render) : contextReadSeconds(p));
+ let s = ownPictureOnly(e) ? pictureBeatSeconds(pictureMediaOf(e), render) : readSeconds(e);
+ for (const p of parentsOf(e)) s += ctx(p);
+ if (isObj(e?.quoted)) s += ctx(e.quoted);
return round3(s);
}
@@ -175,9 +186,9 @@ export function mediaSeconds(m) {
return POST_IMAGE_SECONDS;
}
-/** The attachments as they play: a grid of the images (mediaLayout "grid", 2-4 of them) is one step. */
+/** The attachments as they play: a grid of the images (mediaLayout "grid", 2-4 of them) is one step. A picture-only post's are in its card (post-picture.mjs): none. */
export function mediaSteps(entry) {
- const media = Array.isArray(entry?.media) ? entry.media.filter(isObj).slice(0, POST_MEDIA_MAX) : [];
+ const media = Array.isArray(entry?.media) && !ownPictureOnly(entry) ? entry.media.filter(isObj).slice(0, POST_MEDIA_MAX) : [];
const indexed = media.map((m, i) => ({ ...m, i }));
const images = indexed.filter((m) => m.kind === "image");
if (entry?.mediaLayout === "grid" && images.length >= 2) {
@@ -273,14 +284,20 @@ export function postItemPlan(entry, render = undefined, { prev = null, scene = n
* @param {Record<string, any> | null} [mediaScene]
*/
function planOf(entry, render, hold, prev = null, scene = null, mediaScene = null, join = null) {
+ // PICTURE-ONLY posts (post-picture.mjs): the cut's rule laid on (off: none is).
+ entry = pictureRuleEntry(entry, render);
const narrated = isNarrated(entry);
const k = postNarrationKnobs(entry, render);
// THE JOIN (post-join.mjs) comes first: the read starts after it (the item a join's seconds longer).
- const pre = join && fin(join.seconds) ? join.seconds : 0;
+ const joinPre = join && fin(join.seconds) ? join.seconds : 0;
+ // Then a PICTURE-ONLY context post's BEAT (post-thread.mjs pictureBeats): shown alone, the read after it -- its
+ // start moved, the take never re-made. Looked for only when a context post is picture-only.
+ const beats = narrated && followKnobs(entry, render).on && hasPictureContext(entry) ? pictureBeats(entry, render, threadLayout(entry, render, { prev, scene }), joinPre) : [];
+ const pre = round3(joinPre + (beats.length ? beats[beats.length - 1].t1 - joinPre : 0));
const sch = narrated ? narrationSchedule(entry, render, { pre }) : null;
// Its read-follow (read-follow.mjs): each block's start on the item's clock -- null when it is off. `prev`: the
// item before it in the cut (post-thread.mjs: a parent that is that item is carried in, not cut to).
- const follow = followSchedule(entry, render, { hold, narration: sch, prev, scene, mediaScene, join });
+ const follow = followSchedule(entry, render, { hold, narration: sch, prev, scene, mediaScene, join, ...(beats.length ? { beats } : {}) });
const extra = { ...(sch ? { narration: sch } : {}), ...(follow ? { follow } : {}) };
if (sch && k.attach === "after") {
const voiceOnly = round3(sch.at + sch.seconds + k.tail);
@@ -289,9 +306,10 @@ function planOf(entry, render, hold, prev = null, scene = null, mediaScene = nul
const total = hold ?? round3(voiceOnly + media + (all.length ? 0 : k.linger));
const plan = planSteps(all, voiceOnly, total);
const panel = follow ? panelSchedule(entry, follow, total) : null;
- return { ...plan, reading: round3(Math.min(voiceOnly, total)), total, ...extra, ...(panel ? { panel } : {}) };
+ const pics = picturesOf(entry, follow);
+ return { ...plan, reading: round3(Math.min(voiceOnly, total)), total, ...extra, ...(panel ? { panel } : {}), ...(pics.length ? { pics } : {}) };
}
- const span = sch ? round3(sch.at + sch.seconds + k.tail + k.linger) : readingSeconds(entry);
+ const span = sch ? round3(sch.at + sch.seconds + k.tail + k.linger) : readingSeconds(entry, render);
// ITS OWN ATTACHMENTS come in with ITS OWN POST (ownMediaEnterAt): a thread read's parents and quotes first, his
// attachment when his words begin -- a video starts there, its sound too, its trim fitted to what is left.
const enter = ownMediaEnterAt(entry, follow, { mediaScene });
@@ -322,7 +340,29 @@ function planOf(entry, render, hold, prev = null, scene = null, mediaScene = nul
}
// A CONTEXT POST's attachment (post-thread.mjs panelSchedule): over the slot while it is on screen.
const panel = follow ? panelSchedule(entry, follow, total) : null;
- return { ...plan, reading: 0, total, ...extra, ...(panel ? { panel } : {}), ...(enter > 0 && plan.steps.length ? { enter } : {}) };
+ // A PICTURE-ONLY post's picture in its card (post-picture.mjs): the posts that have one, for the build's overlay.
+ const inCard = picturesOf(entry, follow);
+ return { ...plan, reading: 0, total, ...extra, ...(panel ? { panel } : {}), ...(enter > 0 && plan.steps.length ? { enter } : {}), ...(inCard.length ? { pics: inCard } : {}) };
+}
+
+/** Whether any context post of the item (a parent, the quoted post) is picture-only. */
+const hasPictureContext = (entry) => parentsOf(entry).some(refPictureOnly) || (isObj(entry?.quoted) && refPictureOnly(entry.quoted));
+
+/**
+ * THE PICTURES IN CARDS (post-picture.mjs), pure: `[{ scope, media }]` -- each picture-only post the card draws
+ * (his own: "post"; a parent: "parent:<i>"; the quoted post: "quoted") with its attachments, the first drawn in its
+ * card. The build plays a GIF's or a video's over its place while its card is at full size and still; Play plays it
+ * in the card. A threaded card's hidden tile draws none.
+ */
+export function picturesOf(entry, follow = null) {
+ const hidden = new Set((follow?.thread?.tiles ?? []).filter((t) => t.mode === "hidden").map((t) => t.scope));
+ const out = [];
+ if (ownPictureOnly(entry)) out.push({ scope: "post", media: pictureMediaOf(entry) });
+ parentsOf(entry).forEach((p, i) => {
+ if (refPictureOnly(p) && !hidden.has(`parent:${i}`)) out.push({ scope: `parent:${i}`, media: pictureMediaOf(p) });
+ });
+ if (isObj(entry?.quoted) && refPictureOnly(entry.quoted) && !hidden.has("quoted")) out.push({ scope: "quoted", media: pictureMediaOf(entry.quoted) });
+ return out;
}
/** Where an item's own attachments may come in (`media[0].enter`): with its own post (the default), or with the item. */
@@ -350,7 +390,9 @@ export function ownMediaEnterAt(entry, follow, { mediaScene = null } = {}) {
const post = blocks.filter((b) => b.scope === "post");
if (!post.length) return 0;
const at = Math.min(...post.map((b) => b.start));
- return blocks.some((b) => b.scope !== "post" && b.start < at - 1e-6) ? round3(at) : 0;
+ // A picture-only context post's BEAT before his words (post-picture.mjs) is a piece read before them too.
+ const beat = (follow.beats ?? []).some((b) => fin(b.t0) && b.t0 < at - 1e-6);
+ return beat || blocks.some((b) => b.scope !== "post" && b.start < at - 1e-6) ? round3(at) : 0;
}
/** Steps placed from `at0`, cut at `total` (postItemPlan's walk). */
@@ -589,6 +631,8 @@ export function validatePostItem(e) {
errors.push(...validatePostLinkVisit(e));
// Its progress bar (post-progress.mjs): auto, on or off (absent: the cut's).
errors.push(...progressErrors(e.progress, `timeline ${e?.id ?? "?"}.progress`));
+ // Picture-only (post-picture.mjs): its own, a parent's, the quoted post's -- true or false.
+ errors.push(...validatePictureOnly(e));
return errors;
}
@@ -628,7 +672,7 @@ export function validatePostItems(manifest) {
const errors = [];
const tl = Array.isArray(manifest?.timeline) ? manifest.timeline : [];
for (const e of tl) if (e?.type === "post") errors.push(...validatePostItem(e));
- errors.push(...validatePostsRender(manifest?.render), ...validatePostSceneRender(manifest?.render), ...validatePostPanelRender(manifest?.render), ...validatePostJoinRender(manifest?.render), ...validatePostLinkVisitRender(manifest?.render), ...validatePostMapRender(manifest?.render));
+ errors.push(...validatePostsRender(manifest?.render), ...validatePostSceneRender(manifest?.render), ...validatePostPanelRender(manifest?.render), ...validatePostJoinRender(manifest?.render), ...validatePostLinkVisitRender(manifest?.render), ...validatePostMapRender(manifest?.render), ...validatePictureReplyRender(manifest?.render));
// A word zoom on a word the project's list blanks (the corpus's and a post's markup are checked by the build).
const own = { terms: projectRedactOf(manifest?.render) };
for (const e of tl) if (e?.type === "post") errors.push(...fxRedactionErrors(e, own));
@@ -692,6 +736,17 @@ const CHAR_EM = 0.5;
const LINE = 1.32;
/** The text sizes tried, largest first, in px of a 1080-high frame (scaled to the box). */
export const POST_TEXT_SIZES = Object.freeze([46, 42, 38, 34, 30, 27, 24, 22, 20, 18]);
+/**
+ * A LONG READ's words on a card ALONE (operator, 5 Nov, mid-15's "novel": "bigger text for the novel"): px of a
+ * 1080-high landscape frame. Words that do not fit the card at any size of POST_TEXT_SIZES, read with read-follow (it
+ * pans them), are drawn at this size -- never shrunk to fit; beside an attachment they keep FOLLOW_MIN_SIZE.
+ */
+export const POST_LONG_READ_SIZE = 36;
+/** The size a following card alone draws words that do not fit (POST_LONG_READ_SIZE scaled), else null. */
+export function longReadSize(L, { width, height }, follow, fits = L.fits) {
+ if (!follow || L.mode !== "text" || fits || width < height) return null;
+ return Math.round(POST_LONG_READ_SIZE * (height / 1080));
+}
/** Below this size the words beside an attachment are too small: the card reads first, then the attachments play large. */
export const POST_SIDE_MIN = 26;
@@ -790,9 +845,10 @@ export const POST_PANEL_DEFAULTS = Object.freeze({ wide: 2.0, place: "top" });
/** What the slot shows over the item: its own attachments, else the context posts' (post-thread.mjs panelSchedule). */
export function slotMediaOf(entry) {
- const own = Array.isArray(entry?.media) ? entry.media.filter(isObj) : [];
+ // A picture-only post's attachment is drawn in its card (post-picture.mjs), never in the slot.
+ const own = Array.isArray(entry?.media) && !ownPictureOnly(entry) ? entry.media.filter(isObj) : [];
if (own.length) return own;
- const refs = [...[...parentsOf(entry)].reverse(), ...(isObj(entry?.quoted) ? [entry.quoted] : []), ...linksOf(entry)];
+ const refs = [...[...parentsOf(entry)].reverse(), ...(isObj(entry?.quoted) ? [entry.quoted] : []), ...linksOf(entry)].filter((r) => !refPictureOnly(r));
return refs.flatMap(refMediaOf);
}
@@ -812,6 +868,8 @@ export function panelOf(entry, rule = null) {
/** The item with the CUT's wide-attachment rule laid on (`panel` set when the cut's rule differs from the defaults'). */
export function panelEntry(entry, render) {
+ // PICTURE-ONLY posts (post-picture.mjs): the cut's rule laid on first (off: none is) -- the entry as it is, else.
+ entry = pictureRuleEntry(entry, render);
const rule = isObj(render?.posts?.panel) ? render.posts.panel : null;
if (!rule || !isObj(entry) || POST_PANELS.includes(entry.panel)) return entry;
const p = panelOf(entry, rule);
@@ -985,6 +1043,39 @@ export function nameHtml(who, { redact, cls = "" }) {
}
/**
+ * A PICTURE-ONLY post's picture in its card (post-picture.mjs): its first attachment where its words would be, at the
+ * column's `width` (its aspect and crop kept, at most `maxH` tall), `[data-post-pic="<scope>"]`. An image is drawn by
+ * the page (a censored one blurred whole); a GIF's or a video's still (`posters`: src → url) -- the build plays it
+ * over that place while the card is still (post-render.mjs) -- or, `live` (Play), the video itself, looping. With no
+ * `mediaUrl` (src → url) its place only. More than one attachment: "+N" over its corner.
+ */
+/**
+ * @param {string} scope
+ * @param {Array<Record<string, any>>} media
+ * @param {{ width: number, maxH: number, k: number, mediaUrl?: ((src: string) => string) | null, posters?: Record<string, string>, live?: boolean, line?: string }} o
+ */
+export function pictureHtml(scope, media, { width, maxH, k, mediaUrl = null, posters = {}, live = false, line = "#333" }) {
+ const m = media[0];
+ if (!m) return "";
+ const crop = Array.isArray(m.crop) && m.crop.length === 4 ? m.crop : null;
+ const iw = (fin(m.width) ? m.width : 16) * (crop ? crop[2] : 1);
+ const ih = (fin(m.height) ? m.height : 9) * (crop ? crop[3] : 1);
+ const sc = Math.min(Math.max(2, width) / iw, Math.max(2, maxH) / ih);
+ const w = Math.max(2, Math.floor((iw * sc) / 2) * 2);
+ const h = Math.max(2, Math.floor((ih * sc) / 2) * 2);
+ const url = typeof mediaUrl === "function" ? mediaUrl(m.src) : null;
+ const moving = m.kind === "gif" || m.kind === "video";
+ // The source scaled so its crop fills the box, moved so the crop's corner is the box's.
+ const fw = crop ? w / crop[2] : w;
+ const fh = crop ? h / crop[3] : h;
+ const pos = `width:${Math.round(fw)}px;height:${Math.round(fh)}px;${crop ? `margin-left:${-Math.round(crop[0] * fw)}px;margin-top:${-Math.round(crop[1] * fh)}px;` : ""}${blurOn(m) ? `filter:blur(${Math.round(26 * k)}px);` : ""}`;
+ const src = moving ? (live ? url : posters[m.src] ?? null) : url;
+ const inner = !src ? "" : moving && live ? `<video src="${esc(src)}" muted loop playsinline autoplay preload="auto" style="${pos}display:block"></video>` : `<img src="${esc(src)}" alt="" style="${pos}display:block">`;
+ const more = media.length > 1 ? `<span class="picmore">+${media.length - 1}</span>` : "";
+ return `<div class="tpic" data-post-pic="${esc(scope)}" data-pic-kind="${esc(m.kind)}" data-pic-src="${esc(m.src)}" style="width:${w}px;height:${h}px;border-color:${line}">${inner}${more}</div>`;
+}
+
+/**
* The card's HTML: one page `width` × `height` (the box the item fills), the
* card drawn in the deck's palette and faces, the attachments' slot left as a
* well for the media to be laid into (the build overlays the files; Play the
@@ -1012,9 +1103,11 @@ export function nameHtml(who, { redact, cls = "" }) {
* highlight?: { scope: string, from: number, to: number, color: string } | null,
* redaction?: { terms: Array<{term: string, wholeWord?: boolean}>, markup?: Record<string, any> } | null, follow?: boolean,
* thread?: { tiles?: Array<{ scope: string, mode: string }> } | null,
- * join?: { A?: { x: number, y: number, width: number, height: number }, slotA?: Record<string, number> | null, fromUrl?: string | null, size?: number | null, same?: boolean, plain?: boolean, headSize?: number | null } | null }} o
+ * join?: { A?: { x: number, y: number, width: number, height: number }, slotA?: Record<string, number> | null, fromUrl?: string | null, size?: number | null, same?: boolean, plain?: boolean, headSize?: number | null } | null,
+ * mediaUrl?: ((src: string) => string) | null, posters?: Record<string, string>, livePics?: boolean }} o
+ * `mediaUrl`, `posters`, `livePics`: a PICTURE-ONLY post's picture in its card (pictureHtml).
*/
-export function postCardHtml(entry, { width, height, palette = {}, fonts = {}, phase = "read", parentShotUrl = null, transparent = false, avatars = {}, highlight = null, redaction = null, follow = false, thread = null, join = null }) {
+export function postCardHtml(entry, { width, height, palette = {}, fonts = {}, phase = "read", parentShotUrl = null, transparent = false, avatars = {}, highlight = null, redaction = null, follow = false, thread = null, join = null, mediaUrl = null, posters = {}, livePics = false }) {
const hlOf = (scope) => (highlight && highlight.scope === scope ? highlight : null);
// THREADED (post-thread.mjs): the conversation as a column of tiles -- `thread` the layout's tiles
// (threadLayout, or the plan's follow.thread), each `{ scope, mode }`; a hidden one is not drawn.
@@ -1025,6 +1118,11 @@ export function postCardHtml(entry, { width, height, palette = {}, fonts = {}, p
// mapped on the words as written (the plan's are), whose indices the redaction's bars keep.
const fmap = follow ? followBlocks(entry) : null;
const blk = (scope) => (fmap ? scopeBlocks(fmap, scope) : null);
+ // PICTURE-ONLY posts (post-picture.mjs), judged on the words as written (before any bar is drawn over them).
+ const picOwn = ownPictureOnly(entry);
+ const picPar = parentsOf(entry).map(refPictureOnly);
+ const picQ = isObj(entry.quoted) && refPictureOnly(entry.quoted);
+ const anyPic = picOwn || picQ || picPar.some(Boolean);
// AS PUBLISHED (post-redact.mjs): every redacted match drawn as a bar, its letters never in the page. The
// marks keep the text's length and its spaces, so the card's word indices (a word zoom's) are the original's.
entry = redactEntry(entry, redaction);
@@ -1034,12 +1132,18 @@ export function postCardHtml(entry, { width, height, palette = {}, fonts = {}, p
const k = height / 1080;
// Following, the words never shrink below a readable size to fit: the card pans them instead.
const followMin = Math.round(FOLLOW_MIN_SIZE * k);
- const size = follow ? Math.max(L.size, followMin) : L.size;
+ // A LONG READ on a card alone: at a reading size, panned -- never shrunk to fit (longReadSize).
+ const longRead = longReadSize(L, { width, height }, follow);
+ const size = follow ? Math.max(L.size, longRead ?? followMin) : L.size;
const authors = cardAuthors(entry);
const blurred = authors.filter((a) => a.redact && a.handle).map((a) => a.handle);
const red = (where) => authors.find((a) => a.where === where)?.redact ?? false;
const cardBg = mixHex(pal.bg, pal.fg, 0.07);
const line = mixHex(pal.bg, pal.fg, 0.18);
+ // A picture-only post's picture where its words would be; its mention-only words small, as X's reply-to line.
+ const picIn = (scope, ref, w, maxH) => pictureHtml(scope, pictureMediaOf(ref), { width: w, maxH, k, mediaUrl, posters, live: livePics, line });
+ const menSize = Math.round(22 * k);
+ const ownPicMax = Math.max(Math.round(140 * k), L.card.height - 2 * L.pad - Math.round(250 * k) - Math.min(2, parentsOf(entry).length) * Math.round(130 * k) - (isObj(entry.quoted) ? Math.round(170 * k) : 0));
const own = { author: entry.author, handle: entry.handle };
const ownRed = red("author");
const strip = phase === "media" && L.mode === "stack";
@@ -1059,7 +1163,7 @@ export function postCardHtml(entry, { width, height, palette = {}, fonts = {}, p
const r = red(`parents[${i}]`);
const subject = !r && subjectsOf(entry).some((h) => String(h).toLowerCase() === String(p.handle ?? "").replace(/^@/, "").toLowerCase());
ctx.push(
- `<div class="parent" data-post-parent="${i}"${r ? ' data-redacted=""' : ""}>${avatarHtml(p, { redact: r, size: Math.round(44 * k), accent: subject ? pal.accent : undefined, img: pic(p) })}<div class="pbody"><div class="phead">${nameHtml(p, { redact: r })}<span class="pdate">${esc(cardDate(p.date).split(" · ")[0])}</span>${paraLabel(p)}</div><div class="ptext"${isParaphrased(p) ? ' data-post-paraphrase=""' : ""}>${wordsHtml(contextText(p) || (p.url ? "(not archived)" : ""), blurred, contextText(p) ? `parent:${i}` : null, hlOf(`parent:${i}`), blk(`parent:${i}`))}</div></div></div>`,
+ `<div class="parent" data-post-parent="${i}"${r ? ' data-redacted=""' : ""}>${avatarHtml(p, { redact: r, size: Math.round(44 * k), accent: subject ? pal.accent : undefined, img: pic(p) })}<div class="pbody"><div class="phead">${nameHtml(p, { redact: r })}<span class="pdate">${esc(cardDate(p.date).split(" · ")[0])}</span>${paraLabel(p)}</div><div class="ptext${picPar[i] ? " pmen" : ""}"${isParaphrased(p) ? ' data-post-paraphrase=""' : ""}>${wordsHtml(contextText(p) || (p.url ? "(not archived)" : ""), blurred, contextText(p) ? `parent:${i}` : null, hlOf(`parent:${i}`), blk(`parent:${i}`))}</div>${picPar[i] ? picIn(`parent:${i}`, p, L.card.width - 2 * L.pad - Math.round(58 * k), Math.round(240 * k)) : ""}</div></div>`,
);
}
if (!parents.length && parentShotUrl) ctx.push(`<div class="pshot" data-post-parent-shot=""><img src="${esc(parentShotUrl)}" alt=""></div>`);
@@ -1068,14 +1172,14 @@ export function postCardHtml(entry, { width, height, palette = {}, fonts = {}, p
}
const q = isObj(entry.quoted) ? entry.quoted : null;
const quoted = q
- ? `<div class="quoted" data-post-quoted=""${red("quoted") ? ' data-redacted=""' : ""}><div class="phead">${avatarHtml(q, { redact: red("quoted"), size: Math.round(30 * k), img: pic(q) })}${nameHtml(q, { redact: red("quoted") })}<span class="pdate">${esc(cardDate(q.date).split(" · ")[0])}</span>${paraLabel(q)}</div><div class="qtext"${isParaphrased(q) ? ' data-post-paraphrase=""' : ""}>${wordsHtml(contextText(q), blurred, "quoted", hlOf("quoted"), blk("quoted"))}</div></div>`
+ ? `<div class="quoted" data-post-quoted=""${red("quoted") ? ' data-redacted=""' : ""}><div class="phead">${avatarHtml(q, { redact: red("quoted"), size: Math.round(30 * k), img: pic(q) })}${nameHtml(q, { redact: red("quoted") })}<span class="pdate">${esc(cardDate(q.date).split(" · ")[0])}</span>${paraLabel(q)}</div><div class="qtext${picQ ? " pmen" : ""}"${isParaphrased(q) ? ' data-post-paraphrase=""' : ""}>${wordsHtml(contextText(q), blurred, "quoted", hlOf("quoted"), blk("quoted"))}</div>${picQ ? picIn("quoted", q, L.card.width - 2 * L.pad - Math.round(34 * k), Math.round(280 * k)) : ""}</div>`
: "";
const repost = entry.repostedBy
? `<div class="repost" data-post-repost="">↻ ${esc(str(entry.repostedBy.author) || `@${entry.repostedBy.handle}`)} reposted</div>`
: "";
const head = `<div class="head"${ownRed ? ' data-redacted=""' : ""}>${avatarHtml(own, { redact: ownRed, size: Math.round(64 * k), accent: ownRed ? undefined : pal.accent, img: pic(own) })}<div class="hwho">${nameHtml(own, { redact: ownRed, cls: "big" })}<div class="date">${esc(cardDate(entry.date))}</div></div><div class="mark">${esc(PLATFORM_NAME[entry.platform] ?? "")}</div></div>`;
// A card alone (text, or a stack's reading) is as tall as its words, centred in its box; beside the attachments, the box's height.
- const card = (box) => `<div class="card" data-post-card="${esc(entry.id)}" style="left:${box.x}px;${L.mode === "side" ? `top:${box.y}px;height:${box.height}px` : `top:${box.y + box.height / 2}px;transform:translateY(-50%);max-height:${box.height}px`};width:${box.width}px">${repost}${ctx.length ? `<div class="context">${ctx.join("")}</div>` : ""}${head}<div class="words" data-post-words="" style="font-size:${size}px">${follow ? `<div class="wflow" data-post-flow="">${wordsHtml(cardText(entry), blurred, "post", hlOf("post"), blk("post"))}</div><div class="wfade" data-post-fade="top"></div><div class="wfade" data-post-fade="bottom"></div>` : wordsHtml(cardText(entry), blurred, "post", hlOf("post"))}</div>${quoted}${counts ? `<div class="counts" data-post-counts="">${counts}</div>` : ""}</div>`;
+ const card = (box) => `<div class="card" data-post-card="${esc(entry.id)}" style="left:${box.x}px;${L.mode === "side" ? `top:${box.y}px;height:${box.height}px` : `top:${box.y + box.height / 2}px;transform:translateY(-50%);max-height:${box.height}px`};width:${box.width}px">${repost}${ctx.length ? `<div class="context">${ctx.join("")}</div>` : ""}${head}<div class="words${picOwn ? " pmen" : ""}" data-post-words="" style="font-size:${picOwn ? menSize : size}px">${follow ? `<div class="wflow" data-post-flow="">${wordsHtml(cardText(entry), blurred, "post", hlOf("post"), blk("post"))}</div><div class="wfade" data-post-fade="top"></div><div class="wfade" data-post-fade="bottom"></div>` : wordsHtml(cardText(entry), blurred, "post", hlOf("post"))}</div>${picOwn ? picIn("post", entry, L.card.width - 2 * L.pad, ownPicMax) : ""}${quoted}${counts ? `<div class="counts" data-post-counts="">${counts}</div>` : ""}</div>`;
const stripHtml = L.strip
? `<div class="strip" data-post-strip="" style="left:${L.strip.x}px;top:${L.strip.y}px;width:${L.strip.width}px;height:${L.strip.height}px">${avatarHtml(own, { redact: ownRed, size: Math.round(56 * k), accent: ownRed ? undefined : pal.accent, img: pic(own) })}<div class="hwho">${nameHtml(own, { redact: ownRed, cls: "big" })}<div class="date">${esc(cardDate(entry.date))}</div></div><div class="sline">${wordsHtml(cardText(entry).split("\n")[0].slice(0, 140) + (cardText(entry).length > 140 ? "…" : ""), blurred)}</div></div>`
: "";
@@ -1131,10 +1235,12 @@ export function postCardHtml(entry, { width, height, palette = {}, fonts = {}, p
const size = sizeFor(words || " ", innerW - av - Math.round(16 * k), innerH - 90 * k);
for (const kk of cut(scope) ?? []) cutCss.push(`[data-thread-tile="${scope}"] [data-post-block="${kk}"]`);
const med = refMediaOf(p);
+ // PICTURE-ONLY (post-picture.mjs): its picture in this tile, not a chip naming what the slot shows.
+ const pictured = refPictureOnly(p);
const chip = med.length ? `<span class="plabel" data-thread-media="${med.length}">${med[0].kind === "image" ? (med.length > 1 ? `${med.length} photos` : "photo") : med[0].kind}</span>` : "";
const rel = relationHtml(t0(scope));
tileHtml.push(
- `<div class="tslot" data-thread-slot="${scope}"><div class="tile tparent" data-thread-tile="${scope}" data-thread-mode="${mode}" ${attr}${r ? ' data-redacted=""' : ""}>${avatarHtml(p, { redact: r, size: av, accent: subject ? pal.accent : undefined, img: pic(p) })}<div class="pbody">${rel}<div class="phead">${nameHtml(p, { redact: r, cls: "big" })}<span class="pdate">${esc(cardDate(p.date).split(" · ")[0])}</span>${mode === "excerpt" ? '<span class="plabel" data-thread-excerpt="">excerpt</span>' : ""}${scope.startsWith("linked:") ? '<span class="plabel" data-thread-linked="">linked</span>' : ""}${chip}${paraLabel(p)}</div>${words ? `<div class="ptext tt"${isParaphrased(p) ? ' data-post-paraphrase=""' : ""} style="font-size:${size}px">${wordsHtml(words, blurred, scope, hlOf(scope), blk(scope))}</div>` : ""}</div></div></div>`,
+ `<div class="tslot" data-thread-slot="${scope}"><div class="tile tparent" data-thread-tile="${scope}" data-thread-mode="${mode}" ${attr}${r ? ' data-redacted=""' : ""}>${avatarHtml(p, { redact: r, size: av, accent: subject ? pal.accent : undefined, img: pic(p) })}<div class="pbody">${rel}<div class="phead">${nameHtml(p, { redact: r, cls: "big" })}<span class="pdate">${esc(cardDate(p.date).split(" · ")[0])}</span>${mode === "excerpt" ? '<span class="plabel" data-thread-excerpt="">excerpt</span>' : ""}${scope.startsWith("linked:") ? '<span class="plabel" data-thread-linked="">linked</span>' : ""}${pictured ? "" : chip}${paraLabel(p)}</div>${words ? `<div class="ptext tt${pictured ? " pmen" : ""}"${isParaphrased(p) ? ' data-post-paraphrase=""' : ""} style="font-size:${pictured ? menSize : size}px">${wordsHtml(words, blurred, scope, hlOf(scope), blk(scope))}</div>` : ""}${pictured ? picIn(scope, p, innerW - av - Math.round(16 * k), Math.round(innerH * 0.6)) : ""}</div></div></div>`,
);
};
for (let i = parents.length - 1; i >= 0; i -= 1) refTile(`parent:${i}`, parents[i], `parents[${i}]`, `data-post-parent="${i}"`);
@@ -1148,17 +1254,19 @@ export function postCardHtml(entry, { width, height, palette = {}, fonts = {}, p
const qsize = sizeFor(contextText(q), innerW - Math.round(36 * k), innerH - 140 * k);
for (const kk of cut("quoted") ?? []) cutCss.push(`[data-thread-tile="quoted"] [data-post-block="${kk}"]`);
const label = qabove ? '<span class="plabel" data-thread-quoted-label="">quoted</span>' : "";
- quotedTile = `<div class="tslot" data-thread-slot="quoted"${qabove ? ' data-thread-above=""' : ""}><div class="tile quoted${qabove ? " tabove" : ""}" data-thread-tile="quoted" data-thread-mode="${qmode}" data-post-quoted=""${red("quoted") ? ' data-redacted=""' : ""}><div class="phead">${avatarHtml(q, { redact: red("quoted"), size: Math.round((qabove ? 44 : 36) * k), img: pic(q) })}${nameHtml(q, { redact: red("quoted"), cls: qabove ? "big" : "" })}<span class="pdate">${esc(cardDate(q.date).split(" · ")[0])}</span>${label}${qmode === "excerpt" ? '<span class="plabel" data-thread-excerpt="">excerpt</span>' : ""}${paraLabel(q)}</div><div class="qtext tt"${isParaphrased(q) ? ' data-post-paraphrase=""' : ""} style="font-size:${qabove ? qsize : Math.round(qsize * 0.9)}px">${wordsHtml(contextText(q), blurred, "quoted", hlOf("quoted"), blk("quoted"))}</div></div></div>`;
+ quotedTile = `<div class="tslot" data-thread-slot="quoted"${qabove ? ' data-thread-above=""' : ""}><div class="tile quoted${qabove ? " tabove" : ""}" data-thread-tile="quoted" data-thread-mode="${qmode}" data-post-quoted=""${red("quoted") ? ' data-redacted=""' : ""}><div class="phead">${avatarHtml(q, { redact: red("quoted"), size: Math.round((qabove ? 44 : 36) * k), img: pic(q) })}${nameHtml(q, { redact: red("quoted"), cls: qabove ? "big" : "" })}<span class="pdate">${esc(cardDate(q.date).split(" · ")[0])}</span>${label}${qmode === "excerpt" ? '<span class="plabel" data-thread-excerpt="">excerpt</span>' : ""}${paraLabel(q)}</div><div class="qtext tt${picQ ? " pmen" : ""}"${isParaphrased(q) ? ' data-post-paraphrase=""' : ""} style="font-size:${picQ ? menSize : qabove ? qsize : Math.round(qsize * 0.9)}px">${wordsHtml(contextText(q), blurred, "quoted", hlOf("quoted"), blk("quoted"))}</div>${picQ ? picIn("quoted", q, innerW - Math.round(36 * k), Math.round(innerH * (qabove ? 0.6 : 0.4))) : ""}</div></div>`;
}
if (qabove && quotedTile) {
tileHtml.push(quotedTile);
quotedTile = "";
}
const own = cardText(entry);
- const psize = own.trim() ? sizeFor(own, innerW, innerH - 170 * k) : size;
+ // A LONG READ alone (longReadSize): his words at a reading size, panned, when they do not fit his tile.
+ const pfit = fitSize(own, innerW, innerH - 170 * k, k);
+ const psize = own.trim() ? Math.max(followMin, pfit.size, pfit.fits ? 0 : longReadSize(L, { width, height }, true, false) ?? 0) : size;
const lead = !parents.length && (parentShotUrl || entry.replyingTo) ? ctx.join("") : "";
tileHtml.push(
- `<div class="tslot" data-thread-slot="post"><div class="tile tpost" data-thread-tile="post">${repost}${lead}${relationHtml(t0("post"))}${head}<div class="twords" style="font-size:${psize}px">${wordsHtml(own, blurred, "post", hlOf("post"), blk("post"))}</div>${quotedTile}${counts ? `<div class="counts" data-post-counts="">${counts}</div>` : ""}</div></div>`,
+ `<div class="tslot" data-thread-slot="post"><div class="tile tpost" data-thread-tile="post">${repost}${lead}${relationHtml(t0("post"))}${head}<div class="twords${picOwn ? " pmen" : ""}" style="font-size:${picOwn ? menSize : psize}px">${wordsHtml(own, blurred, "post", hlOf("post"), blk("post"))}</div>${picOwn ? picIn("post", entry, innerW, Math.round(innerH * 0.62)) : ""}${quotedTile}${counts ? `<div class="counts" data-post-counts="">${counts}</div>` : ""}</div></div>`,
);
// THE SCENE (post-conversation.mjs): the posts the run left on screen, drawn as they were -- never read (no
// blocks, no word spans), their words redacted by the same terms, their authors blurred by their own item's rule.
@@ -1188,7 +1296,7 @@ export function postCardHtml(entry, { width, height, palette = {}, fonts = {}, p
// part reads (links are never read: post-narration.mjs dropUrls).
const tc = threaded ? threadCard(L.card) : null;
const body = strip ? `${stripHtml}${slot}` : `${tc ? tc.html : card(L.card)}${slot}`;
- const minSize = tc ? size : follow ? followMin : Math.round(POST_TEXT_SIZES[POST_TEXT_SIZES.length - 1] * k);
+ const minSize = tc ? size : follow ? longRead ?? followMin : Math.round(POST_TEXT_SIZES[POST_TEXT_SIZES.length - 1] * k);
// A status link is marked (`data-link`, post-link-visit.mjs) only when it names a post the card draws -- a link to
// anything else draws as it always did.
const drawnIds = new Set([...parentsOf(entry).map((p) => str(p.id)), str(entry?.quoted?.id), ...linksOf(entry).map((l) => str(l.id))].filter(Boolean));
@@ -1237,7 +1345,10 @@ b, .name, .mark { font-family: 'PostSansBold', sans-serif; font-weight: 400; }
.counts b { color: ${pal.fg}; }
.redact { filter: blur(${Math.round(9 * k)}px); color: ${pal.muted}; }
.avatar.redact { background: ${rgbaOf(pal.muted, 0.6)} !important; }
-.slot { background: ${rgbaOf("#000000", 0.32)}; border-radius: ${Math.round(14 * k)}px; }${follow ? `
+.slot { background: ${rgbaOf("#000000", 0.32)}; border-radius: ${Math.round(14 * k)}px; }${anyPic ? `
+.tpic { position: relative; overflow: hidden; flex: none; border: 1px solid; border-radius: ${Math.round(14 * k)}px; background: ${rgbaOf("#000000", 0.35)}; margin-top: ${Math.round(10 * k)}px; }
+.picmore { position: absolute; right: ${Math.round(10 * k)}px; bottom: ${Math.round(10 * k)}px; padding: ${Math.round(2 * k)}px ${Math.round(10 * k)}px; border-radius: ${Math.round(8 * k)}px; background: ${rgbaOf("#000000", 0.6)}; color: #fff; font-size: ${Math.round(20 * k)}px; }
+.pmen, .tile .tt.pmen, .twords.pmen { color: ${pal.muted}; line-height: 1.3; }` : ""}${follow ? `
.words { position: relative; }
.wflow { will-change: transform; }
.wfade { position: absolute; left: 0; right: 0; height: 1.5em; pointer-events: none; opacity: 0; }
@@ -1303,9 +1414,10 @@ export function cardWordsSize(entry, { width, height }, { follow = false, thread
const own = cardText(entry);
const innerW = L.card.width - 2 * L.pad;
const innerH = L.card.height - 2 * L.pad;
- return own.trim() ? Math.max(followMin, fitSize(own, innerW, innerH - 170 * k, k).size) : Math.max(L.size, followMin);
+ const f = fitSize(own, innerW, innerH - 170 * k, k);
+ return own.trim() ? Math.max(followMin, f.size, f.fits ? 0 : longReadSize(L, { width, height }, true, false) ?? 0) : Math.max(L.size, followMin);
}
- return follow ? Math.max(L.size, followMin) : L.size;
+ return follow ? Math.max(L.size, longReadSize(L, { width, height }, true) ?? followMin) : L.size;
}
/**
diff --git a/umtool/report-to-video/post-picture.mjs b/umtool/report-to-video/post-picture.mjs
@@ -0,0 +1,134 @@
+// PICTURE-ONLY POSTS (umtool/docs/report-video.md, "Picture-only posts"; operator, 5 Nov, walking the Mr. Obvious mid
+// cut at 26:53: "the "It's time to stop" gif shows while Obvious is speaking rather than it being a picture-only
+// response like the MW post, we need to handle this because it's a standard type of post"; and, of Kirsche's reply
+// that is only a picture of another post: "better inserted inline in Kirsche's message, almost as if it's text,
+// becuase it's treated like such").
+//
+// A post whose words are nothing but @mentions and links -- "@ObviousRises" and a GIF -- says what it says WITH its
+// picture. Such a post (an item, a post it answers, the post it quotes) is PICTURE-ONLY:
+//
+// - its attachment is drawn INSIDE its own card, where its words would be (the card's width, its aspect kept, a
+// GIF or a video playing), in the thread's column like any post -- never in the side slot, never while another
+// post's read plays; its mention-only words are drawn small, as the reply-to line X shows;
+// - in a thread read, a picture-only context post the read does not read gets its own BEAT before the read:
+// lit and shown alone (a GIF or a video its own length, clamped; an image `image` s), the read starting after
+// it -- the take is never re-made: the read's start moves (the item's clock gains the beat, as a join's);
+// - an item that is picture-only and not narrated lasts its beat.
+//
+// THE KNOBS: `pictureOnly: true | false` on an item, on `parents[i]`, on `quoted` (absent: the rule above), and the
+// cut's `render.posts.pictureReply: { on, image, min, max }` (on: the rule at all; the beat's length).
+//
+// PURE and dependency-free: the plan, the card, the build, Play, the bench and the writers all read it from here.
+
+const isObj = (v) => !!v && typeof v === "object" && !Array.isArray(v);
+const fin = (v) => typeof v === "number" && Number.isFinite(v);
+const str = (v) => (typeof v === "string" ? v : "");
+const r3 = (v) => Math.round(v * 1000) / 1000;
+const clamp = (v, lo, hi) => Math.min(hi, Math.max(lo, v));
+
+/** The cut's rule (`render.posts.pictureReply`): on; an image's beat; a GIF's or a video's own length clamped to [min, max]. */
+export const PICTURE_REPLY_DEFAULTS = Object.freeze({ on: true, image: 2, min: 1.5, max: 4 });
+export const PICTURE_REPLY_LIMITS = Object.freeze({ image: [0.5, 8], min: [0.5, 8], max: [0.5, 12] });
+
+/** A word that is not words: an @mention, a link (a bare domain link too: pic.x.com/…, t.co/…). */
+const MENTION_RE = /^[(\[]?@[A-Za-z0-9_.]{1,64}[)\],.:;!?]*$/;
+const URL_RE = /^(?:https?:\/\/\S+|(?:www\.|pic\.(?:x|twitter)\.com\/|t\.co\/)\S*)$/i;
+
+/** Whether `text` has no words but @mentions and links (whitespace aside). An empty text has none. */
+export function onlyMentions(text) {
+ return str(text).split(/\s+/).filter(Boolean).every((w) => MENTION_RE.test(w) || URL_RE.test(w));
+}
+
+/** A post's attachments (an item's `media`, a context post's), the drawable ones. */
+export const pictureMediaOf = (post) => (Array.isArray(post?.media) ? post.media.filter((m) => isObj(m) && typeof m.src === "string" && ["image", "gif", "video"].includes(m.kind)) : []);
+
+/**
+ * Whether a post -- an item, a context post (a parent, the quoted post) -- is PICTURE-ONLY: its own `pictureOnly`
+ * (true needs an attachment), else its words (its paraphrase, when it has one: then it has words) are only @mentions
+ * and links AND it carries at least one attachment. `text`: the words its card shows (cardText / contextText).
+ * @param {Record<string, any> | null | undefined} post
+ * @param {{ text?: string }} [o]
+ */
+export function isPictureOnly(post, { text = undefined } = {}) {
+ if (!isObj(post)) return false;
+ if (post.pictureOnly === false) return false;
+ if (!pictureMediaOf(post).length) return false;
+ if (post.pictureOnly === true) return true;
+ if (str(post.paraphrase).trim()) return false;
+ return onlyMentions(text === undefined ? str(post.text) : text);
+}
+
+/** The cut's picture-reply rule (`render.posts.pictureReply`), over the defaults. */
+export function pictureReplyKnobs(render) {
+ const v = isObj(render?.posts) && isObj(render.posts.pictureReply) ? render.posts.pictureReply : {};
+ const out = { ...PICTURE_REPLY_DEFAULTS };
+ if (typeof v.on === "boolean") out.on = v.on;
+ for (const k of ["image", "min", "max"]) if (fin(v[k])) out[k] = v[k];
+ if (out.max < out.min) out.max = out.min;
+ return out;
+}
+
+/** Every reason `render.posts.pictureReply` cannot be built. */
+export function validatePictureReplyRender(render) {
+ const v = isObj(render?.posts) ? render.posts.pictureReply : undefined;
+ if (v === undefined) return [];
+ if (!isObj(v)) return ["render.posts.pictureReply must be { on?, image?, min?, max? } (picture-only posts)"];
+ const errors = Object.keys(v).filter((k) => !(k in PICTURE_REPLY_DEFAULTS)).map((k) => `render.posts.pictureReply.${k} is not a picture-reply knob (on, image, min, max)`);
+ if (v.on !== undefined && typeof v.on !== "boolean") errors.push("render.posts.pictureReply.on must be true or false");
+ for (const k of ["image", "min", "max"]) {
+ const [lo, hi] = PICTURE_REPLY_LIMITS[k];
+ if (v[k] !== undefined && !(fin(v[k]) && v[k] >= lo && v[k] <= hi)) errors.push(`render.posts.pictureReply.${k} must be ${lo}–${hi} seconds`);
+ }
+ if (fin(v.min) && fin(v.max) && v.max < v.min) errors.push("render.posts.pictureReply.max must be at least its min");
+ return errors;
+}
+
+/** A post item's `pictureOnly` knobs' errors (its own, each parent's, the quoted post's). */
+export function validatePictureOnly(e) {
+ const w = `timeline ${e?.id ?? "?"}`;
+ const errors = [];
+ const check = (v, where) => {
+ if (v !== undefined && typeof v !== "boolean") errors.push(`${w}.${where} must be true or false (absent: a post of only @mentions and links with an attachment is picture-only)`);
+ };
+ check(e?.pictureOnly, "pictureOnly");
+ (Array.isArray(e?.parents) ? e.parents : []).forEach((p, i) => check(p?.pictureOnly, `parents[${i}].pictureOnly`));
+ if (isObj(e?.quoted)) check(e.quoted.pictureOnly, "quoted.pictureOnly");
+ return errors;
+}
+
+/**
+ * The item with the CUT's rule laid on: with `render.posts.pictureReply.on` false, every post that does not say
+ * otherwise is not picture-only (`pictureOnly: false` set where it is absent); else the item as it is.
+ */
+export function pictureRuleEntry(entry, render) {
+ if (!isObj(entry) || pictureReplyKnobs(render).on) return entry;
+ const off = (p) => (isObj(p) && p.pictureOnly === undefined ? { ...p, pictureOnly: false } : p);
+ return {
+ ...off(entry),
+ ...(Array.isArray(entry.parents) ? { parents: entry.parents.map(off) } : {}),
+ ...(isObj(entry.quoted) ? { quoted: off(entry.quoted) } : {}),
+ };
+}
+
+/** One attachment's own length (a GIF's pass, a video's trimmed span), else null (an image). */
+function ownLength(m) {
+ if (m?.kind !== "gif" && m?.kind !== "video") return null;
+ const len = fin(m.seconds) && m.seconds > 0 ? m.seconds : null;
+ const from = fin(m.start) ? Math.max(0, m.start) : 0;
+ const to = fin(m.end) ? m.end : len;
+ return fin(to) && to > from ? Math.min(to, len ?? to) - from : null;
+}
+
+/**
+ * A picture-only post's BEAT, seconds: its attachments' own lengths (a GIF's pass, a video's span; an image the
+ * rule's `image`), together, clamped to the rule's [min, max].
+ * @param {Array<Record<string, any>>} media
+ * @param {Record<string, any>} [render]
+ */
+export function pictureBeatSeconds(media, render = undefined) {
+ const k = pictureReplyKnobs(render);
+ const list = (Array.isArray(media) ? media : []).filter(isObj);
+ if (!list.length) return 0;
+ const sum = list.reduce((n, m) => n + (ownLength(m) ?? k.image), 0);
+ return r3(clamp(sum, k.min, k.max));
+}
diff --git a/umtool/report-to-video/post-picture.test.mjs b/umtool/report-to-video/post-picture.test.mjs
@@ -0,0 +1,130 @@
+// lane/picture-replies: PICTURE-ONLY posts (post-picture.mjs) -- a post of only @mentions and links with an
+// attachment is drawn as its picture in its own card, never in the slot; a context post's beat comes before the read.
+import assert from "node:assert/strict";
+import { test } from "node:test";
+import { isPictureOnly, onlyMentions, pictureBeatSeconds, pictureReplyKnobs, pictureRuleEntry, validatePictureOnly, validatePictureReplyRender } from "./post-picture.mjs";
+import { mediaSteps, panelEntry, postCardHtml, postItemPlan, postLayout, readingSeconds, slotMediaOf, validatePostItem, validatePostItems } from "./post-item.mjs";
+import { pictureBeats, threadLayout } from "./post-thread.mjs";
+
+const at = (h, m = 0) => `2026-11-02T${String(h).padStart(2, "0")}:${String(m).padStart(2, "0")}:00.000Z`;
+const GIF = { src: "posts-media/furri-x/9/9_1.mp4", kind: "gif", width: 480, height: 270, seconds: 2.53 };
+const IMG = { src: "posts-media/kir-x/7/7_1.jpg", kind: "image", width: 1127, height: 500 };
+const VID = { src: "posts-media/subj-x/1/1_1.mp4", kind: "video", width: 1080, height: 1200, seconds: 46.3, audio: true };
+const WORDS = "then don't antagonize me, that's something the community needs to learn, the worst thing you can do with me is antagonize me";
+const base = (o = {}) => ({ type: "post", id: "p-1", post: "subj-x/1", platform: "x", author: "Subject", handle: "subject", date: at(21, 5), text: WORDS, ...o });
+const narrate = (e, text = e.text) => ({ ...e, narration: { script: text, pick: 0, takes: [{ file: "narration/posts/1/take-1.wav", engine: "orpheus", voice: "zac", seconds: 8, script: text, parts: [{ n: 1, para: 0, text, start: 0, seconds: 8, role: "post" }] }] } });
+const gifParent = { id: "9", author: "Furri", handle: "furri", date: at(20, 58), text: "@subject", media: [GIF] };
+const R = { postNarration: { lead: 0.25 } };
+
+test("DETECTION: words of only @mentions and links, with an attachment, are picture-only -- the knob forces or denies it", () => {
+ assert.equal(onlyMentions("@ObviousRises"), true);
+ assert.equal(onlyMentions(" @a @b_c https://t.co/xyz pic.x.com/abc "), true);
+ assert.equal(onlyMentions("@ObviousRises lol"), false);
+ assert.equal(isPictureOnly({ text: "@ObviousRises", media: [GIF] }), true);
+ assert.equal(isPictureOnly({ text: "", media: [IMG] }), true);
+ assert.equal(isPictureOnly({ text: "@ObviousRises", media: [] }), false, "no attachment: a mention, not a picture");
+ assert.equal(isPictureOnly({ text: "@a look at this", media: [IMG] }), false);
+ assert.equal(isPictureOnly({ text: "@a", media: [IMG], pictureOnly: false }), false);
+ assert.equal(isPictureOnly({ text: "@a look at this", media: [IMG], pictureOnly: true }), true);
+ assert.equal(isPictureOnly({ text: "@a", media: [], pictureOnly: true }), false, "forced with nothing to draw: not");
+ assert.equal(isPictureOnly({ text: "@a", media: [IMG], paraphrase: "He posts a screenshot." }), false, "a paraphrase is words");
+});
+
+test("THE BEAT: a GIF's or a video's own length, an image the rule's 2 s, clamped to 1.5–4 s; the cut's knobs over it", () => {
+ assert.equal(pictureBeatSeconds([GIF]), 2.53);
+ assert.equal(pictureBeatSeconds([{ ...GIF, seconds: 0.8 }]), 1.5);
+ assert.equal(pictureBeatSeconds([VID]), 4);
+ assert.equal(pictureBeatSeconds([IMG]), 2);
+ assert.equal(pictureBeatSeconds([IMG], { posts: { pictureReply: { image: 3, max: 5 } } }), 3);
+ assert.deepEqual(pictureReplyKnobs(undefined), { on: true, image: 2, min: 1.5, max: 4 });
+});
+
+test("A PICTURE-ONLY PARENT (furri's '@subject' and a GIF): its own beat before his read, drawn in its card in full, never in the slot -- the read moved, the take untouched", () => {
+ const e = narrate(base({ parents: [gifParent], media: [VID] }));
+ const L = threadLayout(e, R);
+ assert.deepEqual(L.tiles.map((t) => [t.scope, t.mode, !!t.pic]), [["parent:0", "full", true], ["post", "full", false]]);
+ assert.deepEqual(pictureBeats(e, R, L, 0), [{ scope: "parent:0", t0: 0, t1: 2.53 }]);
+ const plan = postItemPlan(e, R);
+ assert.equal(plan.narration.at, 0.25 + 2.53, "the read starts after the beat (and the lead)");
+ assert.deepEqual(plan.follow.beats, [{ scope: "parent:0", t0: 0, t1: 2.53 }]);
+ assert.equal(plan.panel, undefined, "the GIF is never in the slot");
+ assert.deepEqual(plan.pics.map((p) => p.scope), ["parent:0"]);
+ // His own video comes in with his words, not under the GIF's beat.
+ assert.equal(plan.enter, plan.narration.at);
+ assert.equal(plan.steps[0].at, plan.narration.at);
+ // The GIF's tile in full through its beat, small as his read comes; his post revealed for it.
+ const row = (sc) => plan.follow.thread.tiles.find((t) => t.scope === sc);
+ assert.deepEqual([row("parent:0").from, row("parent:0").to, row("parent:0").t0], [[1, 1], [0.62, 0.5], 2.38]);
+ assert.deepEqual([row("post").from, row("post").to, row("post").t0], [[1, 0], [1, 1], 2.38]);
+ // The take's parts are its own: the item is a beat longer.
+ const off = postItemPlan(narrate(base({ parents: [{ ...gifParent, pictureOnly: false }], media: [VID] })), R);
+ assert.equal(Math.round((plan.total - off.total) * 1000) / 1000, 2.53);
+ assert.deepEqual(e.narration.takes[0].parts[0].start, 0);
+ // The card draws the GIF's place in the parent's tile, its mention small.
+ const html = postCardHtml(e, { width: 1920, height: 1080, follow: true, thread: plan.follow.thread, mediaUrl: (s) => `file:///p/${s}`, posters: { [GIF.src]: "file:///p/still.png" } });
+ assert.match(html, /data-thread-tile="parent:0"[^]*class="ptext tt pmen"[^]*data-post-pic="parent:0" data-pic-kind="gif"[^]*src="file:\/\/\/p\/still.png"/);
+ assert.doesNotMatch(html, /data-thread-media=/, "no chip pointing at the slot");
+});
+
+test("THE CUT's RULE OFF (render.posts.pictureReply.on false): the plan as before -- context, the GIF in the slot", () => {
+ const e = narrate(base({ parents: [gifParent], media: [VID] }));
+ const r = { ...R, posts: { pictureReply: { on: false } } };
+ const plan = postItemPlan(e, r);
+ const denied = postItemPlan(narrate(base({ parents: [{ ...gifParent, pictureOnly: false }], media: [VID] })), R);
+ assert.deepEqual(plan, denied);
+ assert.equal(plan.pics, undefined);
+ assert.ok(plan.panel?.shows?.some((s) => s.scope === "parent:0"));
+ assert.equal(pictureRuleEntry(e, r).parents[0].pictureOnly, false);
+ assert.equal(panelEntry(e, r).parents[0].pictureOnly, false);
+ assert.equal(pictureRuleEntry(e, R), e, "on: the entry itself");
+});
+
+test("NOT PICTURE-ONLY: a post with words and a picture plays as before (no key, no beat, its attachment in the slot)", () => {
+ const e = narrate(base({ media: [IMG], parents: [{ id: "8", author: "A", handle: "a", date: at(20), text: "@subject what do you mean by that exactly", media: [GIF] }] }));
+ const plan = postItemPlan(e, R);
+ assert.equal(plan.pics, undefined);
+ assert.equal(plan.follow.beats, undefined);
+ assert.deepEqual(plan, postItemPlan(e, { ...R, posts: { pictureReply: { on: false } } }));
+ assert.equal(slotMediaOf(e)[0], IMG);
+ assert.equal(postLayout(e, { width: 1920, height: 1080 }).mode, "side");
+});
+
+test("A PICTURE-ONLY ITEM (Kirsche's '@subject' and a screenshot): its picture in its card at the card's width, no slot; not narrated, it lasts its beat", () => {
+ const e = base({ id: "p-7", post: "kir-x/7", author: "Kir", handle: "kir", text: "@ObviousRises", media: [IMG], panel: "side" });
+ assert.deepEqual(validatePostItem(e), []);
+ assert.deepEqual(mediaSteps(e), []);
+ assert.deepEqual(slotMediaOf(e), []);
+ const L = postLayout(e, { width: 1920, height: 1080 });
+ assert.equal(L.mode, "text");
+ const plan = postItemPlan(e);
+ assert.equal(plan.total, 2);
+ assert.deepEqual(plan.steps, []);
+ assert.deepEqual(plan.pics, [{ scope: "post", media: [IMG] }]);
+ const html = postCardHtml(e, { width: 1920, height: 1080, mediaUrl: (s) => `file:///p/${s}` });
+ assert.match(html, /class="words pmen" data-post-words="" style="font-size:22px"/);
+ const m = /data-post-pic="post" data-pic-kind="image" data-pic-src="[^"]+" style="width:(\d+)px;height:(\d+)px/.exec(html);
+ assert.ok(m, "the picture drawn in the card");
+ assert.ok(Number(m[1]) > 900 && Math.abs(Number(m[1]) / Number(m[2]) - 1127 / 500) < 0.02, "at the card's width, its aspect kept");
+ assert.match(html, /<img src="file:\/\/\/p\/posts-media\/kir-x\/7\/7_1.jpg"/);
+ // Narrated (its read reads the words on the picture): the read's length, as before.
+ const n = narrate(e, "It's amazing how much discourse is just pretending not to understand things.");
+ assert.equal(postItemPlan(n, R).total, postItemPlan({ ...n, pictureOnly: false, media: [] }, R).total);
+ assert.equal(readingSeconds(base({ parents: [gifParent] })), readingSeconds(base()) + 2.53);
+});
+
+test("A PICTURE-ONLY QUOTED post the read does not read: above his post, its own beat", () => {
+ const e = narrate(base({ quoted: { id: "5", author: "Q", handle: "q", date: at(19), text: "", media: [IMG] } }));
+ const L = threadLayout(e, R);
+ assert.deepEqual(L.tiles.map((t) => [t.scope, t.mode, !!t.above]), [["quoted", "full", true], ["post", "full", false]]);
+ const plan = postItemPlan(e, R);
+ assert.deepEqual(plan.follow.beats, [{ scope: "quoted", t0: 0, t1: 2 }]);
+ assert.equal(plan.narration.at, 2.25);
+});
+
+test("THE KNOBS are refused in the build's words", () => {
+ assert.deepEqual(validatePictureOnly({ id: "p-1", pictureOnly: "yes", parents: [{ pictureOnly: 1 }], quoted: { pictureOnly: null } }).length, 3);
+ assert.deepEqual(validatePictureOnly({ id: "p-1", pictureOnly: true, parents: [{ pictureOnly: false }] }), []);
+ assert.deepEqual(validatePictureReplyRender({ posts: { pictureReply: { on: true, image: 2, min: 1, max: 4 } } }), []);
+ assert.equal(validatePictureReplyRender({ posts: { pictureReply: { on: "x", nope: 1, image: 99, min: 3, max: 2 } } }).length, 4);
+ assert.ok(validatePostItems({ render: { posts: { pictureReply: "on" } }, timeline: [] }).some((x) => /pictureReply/.test(x)));
+});
diff --git a/umtool/report-to-video/post-render.mjs b/umtool/report-to-video/post-render.mjs
@@ -101,7 +101,7 @@ export function clockJoinExpr(base, d, seconds) {
return `${num(base)}+${num(d)}*(1-${e})`;
}
-export function postSegmentArgs({ entry, box, plan, layout, cards, files, render, place = [], encode = [], captions = [], fontfile = null, outPath, narration = null, zooms = [], follow = null, panelFiles = [], join = null, map = null, captionFx = [], clock = null, slams = [], slamHitList = [], progress = null }) {
+export function postSegmentArgs({ entry, box, plan, layout, cards, files, render, place = [], encode = [], captions = [], fontfile = null, outPath, narration = null, zooms = [], follow = null, panelFiles = [], join = null, map = null, captionFx = [], clock = null, slams = [], slamHitList = [], progress = null, pics = [] }) {
const fps = render.fps ?? 30;
const T = plan.total;
const inputs = [];
@@ -128,6 +128,24 @@ export function postSegmentArgs({ entry, box, plan, layout, cards, files, render
parts.push(`[${cur}][rf]overlay=x=${follow.clip.x}:y=${follow.clip.y}:eof_action=repeat[${next}]`);
cur = next;
}
+ // PICTURE-ONLY posts' GIFs and videos (post-picture.mjs, measurePics): played over their stills in their cards
+ // while the card is still, looped and silent, fading back to the still -- under the zooms, captions and slams.
+ pics.forEach((pc, pi) => {
+ const { m, box: b, t0, t1, file } = pc;
+ if (!file || !(t1 > t0)) return;
+ const label = `pic${pi}`;
+ const raw = blurOn(m) ? `${label}r` : label;
+ const crop = Array.isArray(m.crop) ? `crop=iw*${num(m.crop[2])}:ih*${num(m.crop[3])}:iw*${num(m.crop[0])}:ih*${num(m.crop[1])},` : "";
+ const from = Number.isFinite(m.start) && m.start > 0 ? m.start : 0;
+ const len = t1 - t0;
+ const k = add(["-stream_loop", "-1", ...(from > 0 ? ["-ss", num(from)] : []), "-t", num(len + 0.1), "-i", file]);
+ const fadeAt = Math.max(0, len - POST_PIC_FADE);
+ parts.push(`[${k}:v]${crop}scale=${b.width}:${b.height},setsar=1,fps=${fps},format=rgba${t1 < T - 0.05 ? `,fade=t=out:st=${num(fadeAt)}:d=${num(Math.min(POST_PIC_FADE, len))}:alpha=1` : ""},setpts=PTS-STARTPTS+${num(t0)}/TB[${raw}]`);
+ if (raw !== label) parts.push(...blurFilters(raw, label, m, b));
+ const next = `b${++n}`;
+ parts.push(`[${cur}][${label}]overlay=x=${b.x}:y=${b.y}:eof_action=pass:enable='between(t,${num(t0)},${num(t1)})'[${next}]`);
+ cur = next;
+ });
if (layout.mode === "stack" && cards.media && plan.steps.length) {
const mi = add(["-loop", "1", "-framerate", String(fps), "-t", num(T), "-i", cards.media]);
parts.push(`[${mi}:v]scale=${box.width}:${box.height},setsar=1,fps=${fps}[mc]`);
@@ -423,7 +441,7 @@ export async function loadChromium() {
* stack layout. The page is a file beside them, so its faces and the parent
* shot load from disk (an about:blank page may not read file: urls).
*/
-export async function renderPostCards(entry, { box, render, dir, manifestDir, layout, avatars = {}, zooms = [], redaction = null, follow = null, total = 0, joinFrom = null, captions = [], clock = null, obstacles = [], slams = [], progress = null }) {
+export async function renderPostCards(entry, { box, render, dir, manifestDir, layout, avatars = {}, zooms = [], redaction = null, follow = null, total = 0, joinFrom = null, captions = [], clock = null, obstacles = [], slams = [], progress = null, pics = [], cardPics = null }) {
await mkdir(dir, { recursive: true });
const fonts = {
regular: render.fontRegular ? pathToFileURL(render.fontRegular).href : "",
@@ -509,12 +527,13 @@ export async function renderPostCards(entry, { box, render, dir, manifestDir, la
}
// THE CLOCK (post-clock.mjs), shot before the read's frames: over a join, where it opens decides the shot the
// card opens on (joinClockOf: carried on from the item before's clock, or that one laid in the shot, fading).
- if (clock) out.clock = await shootClock(browser, entry, { box, render, dir, fonts, parentShotUrl, avatars, clock, redaction, follow, total });
+ if (clock) out.clock = await shootClock(browser, entry, { box, render, dir, fonts, parentShotUrl, avatars, clock, redaction, follow, total, cardPics });
if (join) {
const jc = joinClockOf({ from: out.joinFrom?.clock ?? null, own: out.clock?.at ?? null, k: box.height / 1080 });
if (jc.bake && out.joinFrom?.pngClock) join.fromUrl = pathToFileURL(out.joinFrom.pngClock).href;
if (out.clock) out.clock.join = { seconds: follow.join.seconds, from: jc.move, fadeIn: jc.fadeIn };
}
+ let picPath = null;
for (const phase of phases) {
const html = postCardHtml(entry, {
width: box.width, height: box.height, palette: render.palette, fonts, phase, parentShotUrl,
@@ -524,6 +543,8 @@ export async function renderPostCards(entry, { box, render, dir, manifestDir, la
thread: follow?.thread ?? null,
redaction,
...(join && phase === "read" ? { join } : {}),
+ // PICTURE-ONLY posts (post-picture.mjs): their pictures in their cards, the files and the GIFs' stills.
+ ...(cardPics ?? {}),
});
const file = path.join(dir, `${phase}.html`);
await writeFile(file, html, "utf8");
@@ -554,20 +575,24 @@ export async function renderPostCards(entry, { box, render, dir, manifestDir, la
// THE INVARIANT (read-follow.mjs readInViewErrors): what each part reads is in view, whole and lit, in the
// frames as they are shot -- or, with none shot, in the page as drawn.
const fpath = out.follow?.path ?? followPath(follow, geo);
+ picPath = fpath;
out.inView = readInViewErrors(follow, geo, shotStateAt(follow, fpath, fps, !!out.follow), { total, id: entry.id });
}
+ // PICTURE-ONLY posts' GIFs and videos (post-picture.mjs): where each is drawn while its card is at full size
+ // and still -- the build plays it over that place then (the page draws its still the rest of the time).
+ if (phase === "read" && pics.some(movingPic)) out.pics = await measurePics(page, { pics, follow, path: picPath, total, fps: render.fps ?? 30, joined: !!join });
}
await ctx.close();
- if (zooms.length) out.zooms = await shootZooms(browser, entry, { box, render, dir, fonts, parentShotUrl, avatars, zooms, redaction, follow });
+ if (zooms.length) out.zooms = await shootZooms(browser, entry, { box, render, dir, fonts, parentShotUrl, avatars, zooms, redaction, follow, cardPics });
// The progress bar (post-progress.mjs): along the card's foot, short of the clock on its line.
if (progress) {
const k = box.height / 1080;
const cb = out.clock?.box ? { x: out.clock.box.x + Math.round(240 * k), y: out.clock.box.y, width: out.clock.box.width - Math.round(240 * k), height: out.clock.box.height } : null;
- out.progress = await shootProgress(browser, entry, { box, render, dir, fonts, parentShotUrl, avatars, progress, redaction, follow, total, avoid: cb ? [cb] : [] });
+ out.progress = await shootProgress(browser, entry, { box, render, dir, fonts, parentShotUrl, avatars, progress, redaction, follow, total, avoid: cb ? [cb] : [], cardPics });
}
// A caption covers none of the attachments (`obstacles`: their boxes) nor the clock.
- if (captions.length) out.captions = await shootCaptions(browser, entry, { box, render, dir, fonts, parentShotUrl, avatars, captions, redaction, follow, obstacles: [...obstacles, ...(out.clock ? [out.clock.box] : [])] });
- if (slams.length) out.slams = await shootSlams(browser, entry, { box, render, dir, fonts, parentShotUrl, avatars, slams, redaction, follow });
+ if (captions.length) out.captions = await shootCaptions(browser, entry, { box, render, dir, fonts, parentShotUrl, avatars, captions, redaction, follow, obstacles: [...obstacles, ...(out.clock ? [out.clock.box] : [])], cardPics });
+ if (slams.length) out.slams = await shootSlams(browser, entry, { box, render, dir, fonts, parentShotUrl, avatars, slams, redaction, follow, cardPics });
} finally {
await browser.close();
}
@@ -634,6 +659,78 @@ export async function shootFollow(page, { follow, total, fps, box, dir, geo = nu
return { list, clip, shots: shots.size, frames, geo, path: path0 };
}
+/** A picture-only post whose picture moves (a GIF, a video): the build plays it in its card. */
+const movingPic = (p) => p?.media?.[0]?.kind === "gif" || p?.media?.[0]?.kind === "video";
+
+/**
+ * WHERE A PICTURE-ONLY POST's GIF OR VIDEO PLAYS (post-picture.mjs), measured on the card's page: `[{ scope, m, box,
+ * t0, t1 }]` -- each span of the item, at least POST_PIC_MIN_SPAN s, through which its card's tile is at full size
+ * and strength and its picture's place does not move (no pan, no join, no shrink); the page's still is what shows
+ * the rest of the time. A card with no read-follow is still: the whole item.
+ */
+export async function measurePics(page, { pics, follow, path: fpath = null, total, fps, joined = false }) {
+ const rectOf = (scope) => page.evaluate((sc) => {
+ const el = document.querySelector(`[data-post-pic="${sc}"]`);
+ if (!el) return null;
+ const r = el.getBoundingClientRect();
+ const win = document.querySelector("[data-post-words]")?.getBoundingClientRect() ?? null;
+ return { x: r.left, y: r.top, width: r.width, height: r.height, w0: el.offsetWidth, h0: el.offsetHeight, win: win ? { top: win.top, bottom: win.bottom } : null };
+ }, scope);
+ const out = [];
+ const moving = pics.filter(movingPic);
+ if (!follow) {
+ for (const p of moving) {
+ const r = await rectOf(p.scope);
+ if (r) out.push({ scope: p.scope, m: p.media[0], box: evenBox(r), t0: 0, t1: r3(total) });
+ }
+ return out;
+ }
+ const runs = followRuns(follow, fpath ?? followPath(follow, await page.evaluate(measureFollow)), total, fps);
+ const samples = new Map(moving.map((p) => [p.scope, []]));
+ let frame = 0;
+ for (const run of runs) {
+ await page.evaluate(applyFollowState, run.st);
+ if (joined) await page.evaluate(applyJoinState, run.st.join ?? null);
+ for (const p of moving) {
+ const r = await rectOf(p.scope);
+ const st = run.st.tiles?.[p.scope] ?? [1, 1];
+ const full = !!r && st[0] >= 0.999 && st[1] >= 0.999 && Math.abs(r.width - r.w0) < 0.6 && Math.abs(r.height - r.h0) < 0.6;
+ const inView = !!r && (!r.win || (r.y >= r.win.top - 0.5 && r.y + r.height <= r.win.bottom + 0.5));
+ samples.get(p.scope).push({ f0: frame, f1: frame + run.n, ok: full && inView, r });
+ }
+ frame += run.n;
+ }
+ await page.evaluate(applyFollowState, null);
+ if (joined) await page.evaluate(applyJoinState, null);
+ for (const p of moving) {
+ let cur = null;
+ const close = () => {
+ if (cur && (cur.f1 - cur.f0) / fps >= POST_PIC_MIN_SPAN) out.push({ scope: p.scope, m: p.media[0], box: evenBox(cur.r), t0: r3(cur.f0 / fps), t1: r3(Math.min(total, cur.f1 / fps)) });
+ cur = null;
+ };
+ for (const sm of samples.get(p.scope)) {
+ const same = cur && Math.abs(sm.r.x - cur.r.x) < 0.6 && Math.abs(sm.r.y - cur.r.y) < 0.6;
+ if (!sm.ok) close();
+ else if (same) cur.f1 = sm.f1;
+ else {
+ close();
+ cur = { f0: sm.f0, f1: sm.f1, r: sm.r };
+ }
+ }
+ close();
+ }
+ return out;
+}
+
+/** The shortest span a picture-only post's GIF is played over its still (s). */
+export const POST_PIC_MIN_SPAN = 0.3;
+/** Its fade back to the still at a span's end (s). */
+export const POST_PIC_FADE = 0.25;
+/** The drawing of a picture-only post (postSegmentKeyOf `pics`): bump it when the card draws one differently. */
+export const POST_PICTURE_DRAW_V = 1;
+
+const evenBox = (r) => ({ x: Math.round(r.x), y: Math.round(r.y), width: Math.max(2, Math.round(r.width / 2) * 2), height: Math.max(2, Math.round(r.height / 2) * 2) });
+
/**
* THE BRANCH MAP's FRAMES (post-branch-map.mjs): the map alone on a transparent page, each distinct state (its
* strength, its light's place) shot once over its span, a concat list holding each for its frames; `{ list, x, y,
@@ -703,14 +800,14 @@ export const zoomShotScale = (zooms) => Math.min(4, Math.max(2, Math.ceil(Math.m
* and the region shot plain and with the zoom's highlight under the words.
* `zooms`: `[{ i, scope, from, to, scale, highlight }]`.
*/
-async function shootZooms(browser, entry, { box, render, dir, fonts, parentShotUrl, avatars, zooms, redaction = null, follow = null }) {
+async function shootZooms(browser, entry, { box, render, dir, fonts, parentShotUrl, avatars, zooms, redaction = null, follow = null, cardPics = null }) {
const k = zoomShotScale(zooms);
const ctx = await browser.newContext({ viewport: { width: box.width, height: box.height }, deviceScaleFactor: k, offline: true, serviceWorkers: "block" });
const page = await ctx.newPage();
const av = Object.fromEntries(Object.entries(avatars).map(([h, f]) => [h, pathToFileURL(f).href]));
const load = async (name, highlight) => {
const file = path.join(dir, `${name}.html`);
- await writeFile(file, postCardHtml(entry, { width: box.width, height: box.height, palette: render.palette, fonts, phase: "read", parentShotUrl, avatars: av, highlight, redaction, follow: !!follow, thread: follow?.thread ?? null }), "utf8");
+ await writeFile(file, postCardHtml(entry, { width: box.width, height: box.height, palette: render.palette, fonts, phase: "read", parentShotUrl, avatars: av, highlight, redaction, follow: !!follow, thread: follow?.thread ?? null, ...(cardPics ?? {}) }), "utf8");
await page.goto(pathToFileURL(file).href, { waitUntil: "load" });
await page.waitForSelector("body[data-post-ready='1']", { timeout: 15000 });
};
@@ -785,7 +882,7 @@ async function shootZooms(browser, entry, { box, render, dir, fonts, parentShotU
* frame over the caption's span: its `track`, which the chip rides.
* `captions`: captionPlan's. Returns `[{ ...caption, chip, mark, slide, track, placed }]`.
*/
-export async function shootCaptions(browser, entry, { box, render, dir, fonts, parentShotUrl, avatars, captions, redaction = null, follow = null, obstacles: fixed = [] }) {
+export async function shootCaptions(browser, entry, { box, render, dir, fonts, parentShotUrl, avatars, captions, redaction = null, follow = null, obstacles: fixed = [], cardPics = null }) {
const fps = render.fps ?? 30;
const k = box.height / 1080;
const ctx = await browser.newContext({ viewport: { width: box.width, height: box.height }, deviceScaleFactor: 1, offline: true, serviceWorkers: "block" });
@@ -794,7 +891,7 @@ export async function shootCaptions(browser, entry, { box, render, dir, fonts, p
const out = [];
try {
const file = path.join(dir, "caption.html");
- await writeFile(file, postCardHtml(entry, { width: box.width, height: box.height, palette: render.palette, fonts, phase: "read", parentShotUrl, avatars: av, redaction, follow: !!follow, thread: follow?.thread ?? null }), "utf8");
+ await writeFile(file, postCardHtml(entry, { width: box.width, height: box.height, palette: render.palette, fonts, phase: "read", parentShotUrl, avatars: av, redaction, follow: !!follow, thread: follow?.thread ?? null, ...(cardPics ?? {}) }), "utf8");
await page.goto(pathToFileURL(file).href, { waitUntil: "load" });
await page.waitForSelector("body[data-post-ready='1']", { timeout: 15000 });
await page.evaluate(() => document.fonts.ready.then(() => true));
@@ -908,7 +1005,7 @@ async function clockPlaceOn(page, { follow, total, size, k }) {
* holding each for its frames. `slams`: slamPlan's. Returns `[{ ...slam,
* list, t0, t3, layout, size, shots }]`.
*/
-export async function shootSlams(browser, entry, { box, render, dir, fonts, parentShotUrl, avatars, slams, redaction = null, follow = null }) {
+export async function shootSlams(browser, entry, { box, render, dir, fonts, parentShotUrl, avatars, slams, redaction = null, follow = null, cardPics = null }) {
const fps = render.fps ?? 30;
const k = box.height / 1080;
const ctx = await browser.newContext({ viewport: { width: box.width, height: box.height }, deviceScaleFactor: 1, offline: true, serviceWorkers: "block" });
@@ -917,7 +1014,7 @@ export async function shootSlams(browser, entry, { box, render, dir, fonts, pare
const out = [];
try {
const file = path.join(dir, "slam.html");
- await writeFile(file, postCardHtml(entry, { width: box.width, height: box.height, palette: render.palette, fonts, phase: "read", parentShotUrl, avatars: av, redaction, follow: !!follow, thread: follow?.thread ?? null }), "utf8");
+ await writeFile(file, postCardHtml(entry, { width: box.width, height: box.height, palette: render.palette, fonts, phase: "read", parentShotUrl, avatars: av, redaction, follow: !!follow, thread: follow?.thread ?? null, ...(cardPics ?? {}) }), "utf8");
await page.goto(pathToFileURL(file).href, { waitUntil: "load" });
await page.waitForSelector("body[data-post-ready='1']", { timeout: 15000 });
await page.evaluate(() => document.fonts.ready.then(() => true));
@@ -1026,14 +1123,14 @@ export async function shootSlams(browser, entry, { box, render, dir, fonts, pare
* its start, middle and end, the place covering fewest words), then its track and its fill shot alone on a clear
* page. `{ track, fill, x, y, width, height, place, covers, plan }`.
*/
-export async function shootProgress(browser, entry, { box, render, dir, fonts, parentShotUrl, avatars, progress, redaction = null, follow = null, total = 0, avoid = [] }) {
+export async function shootProgress(browser, entry, { box, render, dir, fonts, parentShotUrl, avatars, progress, redaction = null, follow = null, total = 0, avoid = [], cardPics = null }) {
const k = box.height / 1080;
const ctx = await browser.newContext({ viewport: { width: box.width, height: box.height }, deviceScaleFactor: 1, offline: true, serviceWorkers: "block" });
const page = await ctx.newPage();
const av = Object.fromEntries(Object.entries(avatars).map(([h, f]) => [h, pathToFileURL(f).href]));
try {
const file = path.join(dir, "progress.html");
- await writeFile(file, postCardHtml(entry, { width: box.width, height: box.height, palette: render.palette, fonts, phase: "read", parentShotUrl, avatars: av, redaction, follow: !!follow, thread: follow?.thread ?? null }), "utf8");
+ await writeFile(file, postCardHtml(entry, { width: box.width, height: box.height, palette: render.palette, fonts, phase: "read", parentShotUrl, avatars: av, redaction, follow: !!follow, thread: follow?.thread ?? null, ...(cardPics ?? {}) }), "utf8");
await page.goto(pathToFileURL(file).href, { waitUntil: "load" });
await page.waitForSelector("body[data-post-ready='1']", { timeout: 15000 });
const css = progressCss({ height: box.height, palette: render.palette });
@@ -1077,7 +1174,7 @@ export async function shootProgress(browser, entry, { box, render, dir, fonts, p
* once) and a concat list holding each for its frames, the last to the end.
* `{ list, x, y, place, covers, shots }`.
*/
-export async function shootClock(browser, entry, { box, render, dir, fonts, parentShotUrl, avatars, clock, redaction = null, follow = null, total = 0 }) {
+export async function shootClock(browser, entry, { box, render, dir, fonts, parentShotUrl, avatars, clock, redaction = null, follow = null, total = 0, cardPics = null }) {
const fps = render.fps ?? 30;
const k = box.height / 1080;
const ctx = await browser.newContext({ viewport: { width: box.width, height: box.height }, deviceScaleFactor: 1, offline: true, serviceWorkers: "block" });
@@ -1085,7 +1182,7 @@ export async function shootClock(browser, entry, { box, render, dir, fonts, pare
const av = Object.fromEntries(Object.entries(avatars).map(([h, f]) => [h, pathToFileURL(f).href]));
try {
const file = path.join(dir, "clock.html");
- await writeFile(file, postCardHtml(entry, { width: box.width, height: box.height, palette: render.palette, fonts, phase: "read", parentShotUrl, avatars: av, redaction, follow: !!follow, thread: follow?.thread ?? null }), "utf8");
+ await writeFile(file, postCardHtml(entry, { width: box.width, height: box.height, palette: render.palette, fonts, phase: "read", parentShotUrl, avatars: av, redaction, follow: !!follow, thread: follow?.thread ?? null, ...(cardPics ?? {}) }), "utf8");
await page.goto(pathToFileURL(file).href, { waitUntil: "load" });
await page.waitForSelector("body[data-post-ready='1']", { timeout: 15000 });
const face = clockFace(clock.to, clock.zone);
@@ -1238,6 +1335,8 @@ export function postSegmentKeyOf({ entry, redaction = null, box, place = [], ren
// clock (where this one's starts) and its parent's shot.
...(from ? { joinFrom: { entry: from.entry, follow: from.plan.follow ?? null, total: from.plan.total, media: from.media.map((x) => [x.m.src, x.t, x.box]), fadeIn: from.fadeIn, jv: POST_JOIN_DRAW_V, clock: from.clock ?? null, ...(from.carry ? { carry: from.carry } : {}), ...(Number.isFinite(from.anchorY) ? { anchorY: from.anchorY } : {}) } } : {}),
...(plan.panel ? { panel: plan.panel } : {}),
+ // PICTURE-ONLY posts (post-picture.mjs): the pictures drawn in their cards -- only an item that has one.
+ ...(plan.pics ? { pics: { v: POST_PICTURE_DRAW_V, list: plan.pics } } : {}),
// Its own attachment entering with his own post (post-item.mjs ownMediaEnterAt): only an item that reads
// something before its post carries it -- every other keeps its key.
...(plan.enter > 0 ? { enter: { at: plan.enter, fade: POST_ENTER_FADE } } : {}),
@@ -1327,6 +1426,11 @@ export async function buildPostSegment(entry, { render, outDir, manifestDir, box
for (const [i, f] of panelFiles.flat().entries()) {
if (!(await stat(f).catch(() => null))) throw new Error(`${entry.id}: a context post's attachment is not on disk: ${f} (${i})`);
}
+ // PICTURE-ONLY posts' pictures (post-picture.mjs, plan.pics): files of the project, drawn in their cards.
+ const picFiles = (plan.pics ?? []).flatMap((p) => p.media.map((m) => path.resolve(manifestDir, m.src)));
+ for (const f of picFiles) {
+ if (!(await stat(f).catch(() => null))) throw new Error(`${entry.id}: a picture-only post's attachment is not on disk: ${f}`);
+ }
const wordFiles = (entry.media ?? []).map((m) => (typeof m.words === "string" ? path.resolve(manifestDir, m.words) : null));
// Its narration's picked take (post-narration.mjs): a file of the project, levelled by its measured loudness.
const take = isNarrated(entry) ? pickedTake(entry) : null;
@@ -1334,7 +1438,7 @@ export async function buildPostSegment(entry, { render, outDir, manifestDir, box
if (takeFile && !(await stat(takeFile).catch(() => null))) throw new Error(`${entry.id}: its narration take is not on disk: ${takeFile} (${take.file})`);
// The slurs its take SAYS, covered (post-slurs.mjs): a public render never plays one -- without word timings it is refused.
const bleeps = take ? takeSlurBleeps(entry, take, redaction) : null;
- const stamps = await Promise.all([...files, ...panelFiles.flat(), ...(from?.media ?? []).map((x) => x.file), ...wordFiles.filter(Boolean), ...Object.values(avatars), ...(takeFile ? [takeFile] : []), ...(entry.parentShot ? [path.resolve(manifestDir, entry.parentShot)] : []), ...(typeof from?.entry?.parentShot === "string" ? [path.resolve(manifestDir, from.entry.parentShot)] : [])].map(async (f) => {
+ const stamps = await Promise.all([...files, ...panelFiles.flat(), ...picFiles.filter((f) => !files.includes(f)), ...(from?.media ?? []).map((x) => x.file), ...wordFiles.filter(Boolean), ...Object.values(avatars), ...(takeFile ? [takeFile] : []), ...(entry.parentShot ? [path.resolve(manifestDir, entry.parentShot)] : []), ...(typeof from?.entry?.parentShot === "string" ? [path.resolve(manifestDir, from.entry.parentShot)] : [])].map(async (f) => {
const st = await stat(f).catch(() => null);
return st ? `${f}:${st.size}:${Math.round(st.mtimeMs)}` : `${f}:-`;
}));
@@ -1371,7 +1475,27 @@ export async function buildPostSegment(entry, { render, outDir, manifestDir, box
const clk = clockPlan(entry, render, prev);
// Its progress bar (post-progress.mjs): the read's span on the item's clock (a long read's, auto).
const prog = progressPlan(entry, render, plan, { stack: layout.mode === "stack" });
- const cards = await renderPostCards(entry, { box, render, dir: cardDir, manifestDir, layout, avatars, zooms: zoomPlan, redaction, follow: plan.follow ?? null, total: plan.total, joinFrom: from, captions: capPlan, clock: clk, obstacles: layout.slot ? plan.steps.flatMap((st) => stepBoxes(st, layout.slot)) : [], slams: slPlan, progress: prog });
+ // PICTURE-ONLY posts (post-picture.mjs): the page draws each picture in its card -- an image itself, a GIF's or a
+ // video's first frame (its still; the encode plays it over that place while the card is still).
+ let cardPics = null;
+ if (plan.pics?.length) {
+ await mkdir(cardDir, { recursive: true });
+ const posters = {};
+ for (const [pi, pc] of plan.pics.entries()) {
+ const m = pc.media[0];
+ if (m?.kind !== "gif" && m?.kind !== "video") continue;
+ const still = path.join(cardDir, `pic-${pi}.png`);
+ const from = Number.isFinite(m.start) && m.start > 0 ? m.start : 0;
+ try {
+ await exec(ffmpeg, ["-nostdin", "-v", "error", "-y", "-ss", String(from), "-i", path.resolve(manifestDir, m.src), "-frames:v", "1", still], { maxBuffer: 1 << 24 });
+ posters[m.src] = pathToFileURL(still).href;
+ } catch (err) {
+ throw new Error(`${entry.id}: the still of a picture-only post's ${m.kind} could not be made (${m.src}): ${String(err?.stderr ?? err?.message ?? err).trim()}`);
+ }
+ }
+ cardPics = { mediaUrl: (src) => pathToFileURL(path.resolve(manifestDir, src)).href, posters };
+ }
+ const cards = await renderPostCards(entry, { box, render, dir: cardDir, manifestDir, layout, avatars, zooms: zoomPlan, pics: plan.pics ?? [], cardPics, redaction, follow: plan.follow ?? null, total: plan.total, joinFrom: from, captions: capPlan, clock: clk, obstacles: layout.slot ? plan.steps.flatMap((st) => stepBoxes(st, layout.slot)) : [], slams: slPlan, progress: prog });
// NO HIDDEN TEXT IS EVER NARRATED (operator, 4 Nov): a part whose words are not in view, whole and lit, while it
// is said -- or a context post drawn over its context size -- refuses the build (READ_IN_VIEW=warn: a note).
// A part read off a linked post's picture is on screen only while the panel shows it (post-thread.mjs panelReadErrors).
@@ -1405,7 +1529,7 @@ export async function buildPostSegment(entry, { render, outDir, manifestDir, box
const lufs = Number.isFinite(take.lufs) ? take.lufs : await measureLufsOf(takeFile, { exec, ffmpeg });
narration = { file: takeFile, gainDb: narrationLevelDb(lufs, plan.narration.lufs), lufs, ...(bleeps ? { bleeps } : {}) };
}
- const argv = postSegmentArgs({ entry, box, plan, layout, cards, files, render, place, encode, captions, fontfile: render.fontBold ?? render.fontRegular ?? null, outPath: tmp, narration, zooms, follow: cards.follow ?? null, panelFiles, map: cards.map ?? null, join: from && cards.joinFrom ? { seconds: plan.follow.join.seconds, fadeIn: from.fadeIn, from: from.media } : null, captionFx: cards.captions ?? [], clock: cards.clock ? { ...cards.clock, until: layout.mode === "stack" && plan.steps.length ? plan.steps[0].at : plan.total } : null, slams: cards.slams ?? [], slamHitList: (cards.slams ?? []).flatMap((sl) => slamHits(sl.fx, sl.span).map((h) => ({ ...h, gain: h.gain * sl.fx.volume }))), progress: cards.progress ?? null });
+ const argv = postSegmentArgs({ entry, box, plan, layout, cards, files, render, place, encode, captions, fontfile: render.fontBold ?? render.fontRegular ?? null, outPath: tmp, narration, zooms, follow: cards.follow ?? null, panelFiles, map: cards.map ?? null, join: from && cards.joinFrom ? { seconds: plan.follow.join.seconds, fadeIn: from.fadeIn, from: from.media } : null, captionFx: cards.captions ?? [], clock: cards.clock ? { ...cards.clock, until: layout.mode === "stack" && plan.steps.length ? plan.steps[0].at : plan.total } : null, slams: cards.slams ?? [], slamHitList: (cards.slams ?? []).flatMap((sl) => slamHits(sl.fx, sl.span).map((h) => ({ ...h, gain: h.gain * sl.fx.volume }))), progress: cards.progress ?? null, pics: (cards.pics ?? []).map((pc) => ({ ...pc, file: path.resolve(manifestDir, pc.m.src) })) });
try {
await exec(ffmpeg, argv, { maxBuffer: 1 << 24 });
} catch (err) {
@@ -1424,6 +1548,10 @@ export async function buildPostSegment(entry, { render, outDir, manifestDir, box
? `${entry.id}: post item ${plan.total.toFixed(1)} s, narrated (${take.file}: ${plan.narration.seconds.toFixed(1)} s from ${plan.narration.at} s, muffled to ${plan.narration.voiceEnd.toFixed(1)} s)`
: `${entry.id}: post item ${plan.total.toFixed(1)} s (${layout.mode}: ${plan.reading.toFixed(1)} s to read${plan.steps.length ? `, ${plan.steps.length} attachment step(s)` : ""})`,
});
+ for (const pc of plan.pics ?? []) {
+ const shown = (cards.pics ?? []).filter((x) => x.scope === pc.scope);
+ emit("note", { message: `${entry.id}: picture-only ${pc.scope === "post" ? "post" : pc.scope} -- its ${pc.media[0]?.kind ?? "picture"} drawn in its card${shown.length ? `, played ${shown.map((x) => `${x.t0}–${x.t1} s`).join(", ")}` : ""}${(plan.follow?.beats ?? []).filter((b) => b.scope === pc.scope).map((b) => `, its beat ${b.t0}–${b.t1} s before the read`).join("")}` });
+ }
if (cards.follow) emit("note", { message: `${entry.id}: read-follow -- ${plan.follow.blocks.filter((b) => b.start !== null).length} block(s) read, ${cards.follow.path.segments.length ? `the words panned ${cards.follow.path.segments.length} time(s) over ${Math.round(cards.follow.path.max)} px` : "no pan (the words fit)"}; ${cards.follow.shots} shot(s) for ${cards.follow.frames} frames` });
if (cards.progress) emit("note", { message: `${entry.id}: progress bar over the read ${prog.from}–${prog.to} s (${prog.mode}${prog.ticks.length ? `, ${prog.ticks.length + 1} parts ticked` : ""}), ${cards.progress.place === "foot" ? "along the card's foot" : "under the card"}${cards.progress.covers ? ` -- WARNING: over ${cards.progress.covers} word(s)` : ""}` });
if (cards.clock) emit("note", { message: `${entry.id}: clock ${clockFace(clk.to, clk.zone).time} ${clockFace(clk.to, clk.zone).date} (${clk.mode === "none" ? "shown" : clk.mode === "rewind" ? "rewound" : "run forward"}${clk.mode === "none" ? "" : ` from the item before, ${clk.gap / 60000 | 0} min`}), ${cards.clock.place}${cards.clock.covers ? ` -- WARNING: over ${cards.clock.covers} word(s)` : ""}` });
diff --git a/umtool/report-to-video/post-thread-scenes.test.mjs b/umtool/report-to-video/post-thread-scenes.test.mjs
@@ -84,12 +84,16 @@ test("THE READ IN DATE ORDER (operator, 4 Nov: D): a quoted take older than the
assert.deepEqual(readInViewErrors(plan.follow, geo, shotStateAt(plan.follow, followPath(plan.follow, geo), 30), { total: plan.total, id: e.id }), []);
});
-test("AN IMAGE-ONLY REPLY is a tile (its head and a chip), never read; a parent's attachment is a file the lint checks", () => {
+test("AN IMAGE-ONLY REPLY is a tile, never read -- picture-only (post-picture.mjs): its picture in its tile, in full; `pictureOnly: false`: its head and a chip, as context; a parent's attachment is a file the lint checks", () => {
const e = narrate(base({ parents: [ref("9", "furri", "", 19, { media: [{ src: "posts-media/f/9/9_1.jpg", kind: "image", width: 600, height: 800 }] }), ref("1", "subject", ROOT, 17)] }), [[base().text]]);
assert.deepEqual(validatePostItem(e), []);
const L = threadLayout(e);
- assert.deepEqual(L.tiles.map((t) => [t.scope, t.mode]), [["parent:1", "context"], ["parent:0", "context"], ["post", "full"]]);
- const html = postCardHtml(e, { width: 1600, height: 900, follow: true, thread: L });
+ assert.deepEqual(L.tiles.map((t) => [t.scope, t.mode]), [["parent:1", "context"], ["parent:0", "full"], ["post", "full"]]);
+ assert.match(postCardHtml(e, { width: 1600, height: 900, follow: true, thread: L }), /data-post-parent="0"[^>]*>.*data-post-pic="parent:0"/s);
+ const off = { ...e, parents: [{ ...e.parents[0], pictureOnly: false }, e.parents[1]] };
+ const L0 = threadLayout(off);
+ assert.deepEqual(L0.tiles.map((t) => [t.scope, t.mode]), [["parent:1", "context"], ["parent:0", "context"], ["post", "full"]]);
+ const html = postCardHtml(off, { width: 1600, height: 900, follow: true, thread: L0 });
assert.match(html, /data-post-parent="0"[^>]*>.*data-thread-media="1">photo</s);
assert.deepEqual(validatePostItem({ ...e, parents: [{ media: [{ src: "/abs.jpg", kind: "image" }] }] }).length > 0, true);
});
diff --git a/umtool/report-to-video/post-thread.mjs b/umtool/report-to-video/post-thread.mjs
@@ -54,6 +54,7 @@ import { normWord, scriptWordsOf } from "./word-zoom.mjs";
import { followKnobs } from "./read-follow.mjs";
import { planContext } from "./post-conversation.mjs";
import { branchMapOf, mapKnobs, mapTimes } from "./post-branch-map.mjs";
+import { isPictureOnly, pictureBeatSeconds } from "./post-picture.mjs";
/** What a context tile may be. */
export const THREAD_MODES = Object.freeze(["auto", "full", "excerpt", "context", "carry", "hidden"]);
@@ -308,12 +309,14 @@ export function threadLayout(entry, render = undefined, { prev = null, scene = n
if (!refShown(parents[i])) continue;
let mode = parentKnob(k, i);
const isRead = read.has(scope);
+ // A PICTURE-ONLY post (post-picture.mjs): its picture drawn in its tile, in full -- its own beat, not context.
+ const pic = isPictureOnly(parents[i]);
if (mode === "auto") {
const carry = k.carry === true || (k.carry === "auto" && !!prevId && String(parents[i].id ?? "") === prevId);
- mode = isRead ? "full" : carry ? "carry" : "context";
+ mode = isRead ? "full" : carry ? "carry" : pic ? "full" : "context";
}
if (mode === "carry" && isRead) mode = "full";
- tiles.push({ scope, mode, read: isRead });
+ tiles.push({ scope, mode, read: isRead, ...(pic ? { pic: true } : {}) });
}
// THE QUOTED POST (operator, 4 Nov: the quote read first while it sat under his words -- "the card opens
// scrolled down"): read BEFORE his words, it is its own tile ABOVE his post, read in full and lit, then
@@ -321,10 +324,13 @@ export function threadLayout(entry, render = undefined, { prev = null, scene = n
const postAt = roles.findIndex((r) => r.role === "post");
const quotedFirst = roles.findIndex((r) => r.role === "quoted");
const quotedAt = quotedFirst >= 0 && (postAt < 0 || quotedFirst < postAt) ? "above" : "inside";
- const post = { scope: "post", mode: "full", read: read.has("post") };
- if (isObj(entry?.quoted) && contextText(entry.quoted).trim()) {
- const m = k.quoted === "auto" ? (read.has("quoted") ? "full" : "context") : k.quoted;
- const q = { scope: "quoted", mode: m, read: read.has("quoted"), ...(quotedAt === "above" && m !== "hidden" && m !== "context" ? { above: true } : {}) };
+ const post = { scope: "post", mode: "full", read: read.has("post"), ...(isPictureOnly(entry, { text: cardText(entry) }) ? { pic: true } : {}) };
+ const qpic = isObj(entry?.quoted) && isPictureOnly(entry.quoted);
+ if (isObj(entry?.quoted) && (contextText(entry.quoted).trim() || qpic)) {
+ const m = k.quoted === "auto" ? (read.has("quoted") ? "full" : qpic ? "full" : "context") : k.quoted;
+ // A picture-only quoted post the read does not read has its beat before the read: above his post, like a parent.
+ const above = (quotedAt === "above" || (qpic && !read.has("quoted"))) && m !== "hidden" && m !== "context";
+ const q = { scope: "quoted", mode: m, read: read.has("quoted"), ...(above ? { above: true } : {}), ...(qpic ? { pic: true } : {}) };
if (q.above) tiles.push(q, post);
else tiles.push(post, q);
} else tiles.push(post);
@@ -349,6 +355,34 @@ export function threadLayout(entry, render = undefined, { prev = null, scene = n
return { on, tiles: scened, roles, quotedAt: quotedAtOut, ...(map ? { map } : {}) };
}
+/**
+ * THE BEATS of a threaded card's PICTURE-ONLY context posts (post-picture.mjs), pure: `[{ scope, t0, t1 }]` -- each
+ * picture-only parent or quoted post drawn in full that the read does not read, standing before the read's first
+ * piece, lit and shown alone for its beat (pictureBeatSeconds) from item second `at0` (the join's end), one after
+ * another; the read starts after the last (postItemPlan moves its start: the take is never re-made). One standing
+ * between two read pieces has no beat (drawn in its card, it gives way with the piece after it). Empty: none.
+ *
+ * @param {Record<string, any>} entry
+ * @param {Record<string, any> | undefined} render
+ * @param {{ on: boolean, tiles: Array<Record<string, any>> } | null} layout threadLayout's
+ * @param {number} [at0]
+ */
+export function pictureBeats(entry, render, layout, at0 = 0) {
+ if (!layout?.on) return [];
+ const tiles = layout.tiles ?? [];
+ const firstRead = tiles.findIndex((t) => t.read);
+ const out = [];
+ let t = fin(at0) ? at0 : 0;
+ tiles.forEach((tile, i) => {
+ if (!tile.pic || tile.read || tile.mode !== "full" || tile.scope === "post" || (firstRead >= 0 && i > firstRead)) return;
+ const secs = pictureBeatSeconds(refMediaOf(refOfScope(entry, tile.scope)), render);
+ if (!(secs > 0)) return;
+ out.push({ scope: tile.scope, t0: r3(t), t1: r3(t + secs) });
+ t += secs;
+ });
+ return out;
+}
+
/** The id a tile of `entry` draws (a parent's, his post's, a quoted or linked post's; null: none known). */
export function tileIdOf(entry, t) {
if (t.scope === "post") return shownIdOf(entry) || null;
@@ -558,17 +592,19 @@ export function threadReadErrors(entry, render = undefined, { prev = null, scene
* (each `{ scope, part, start }`); `roles`: the parts' roles; `layout`:
* threadLayout's. Null when the card is not threaded.
*/
-export function threadSchedule(entry, render, { layout, blocks, lead = 0.4 }) {
+export function threadSchedule(entry, render, { layout, blocks, lead = 0.4, beats = [] }) {
if (!layout?.on) return null;
const k = threadKnobs(entry, render);
const roles = layout.roles;
// Each read piece's start on the item's clock: its first block's start.
const startOfPart = new Map();
for (const b of blocks) if (b.part !== null && b.start !== null && !startOfPart.has(b.part)) startOfPart.set(b.part, b.start);
- const pieces = readPieces(entry, roles).map((p) => {
+ // A PICTURE-ONLY context post's BEAT (pictureBeats) is a piece of its own, before the read's first.
+ const beatOf = new Map((Array.isArray(beats) ? beats : []).map((b) => [b.scope, b]));
+ const pieces = [...beatOf.values()].map((b) => ({ role: b.scope, parts: [], start: b.t0, beat: true })).concat(readPieces(entry, roles).map((p) => {
const ts = p.parts.map((n) => startOfPart.get(n)).filter(fin);
return { ...p, start: ts.length ? Math.min(...ts) : null };
- }).filter((p) => p.start !== null && p.role);
+ }).filter((p) => p.start !== null && p.role));
// A tile's pieces (a quoted post inside his post's tile: the post tile shows for both; above it, its own).
const above = layout.quotedAt === "above";
const firstRead = (scope) => pieces.find((p) => p.role === scope || (scope === "post" && p.role === "quoted" && !above))?.start ?? null;
@@ -621,6 +657,24 @@ export function threadSchedule(entry, render, { layout, blocks, lead = 0.4 }) {
row.to = small;
Object.assign(row, win(first.start));
}
+ } else if (t.pic && !t.read) {
+ // PICTURE-ONLY (post-picture.mjs): its beat is its read -- revealed for it when something came before, in full
+ // through it, small and dim as the next piece starts; with no beat, it gives way with the piece after it.
+ const beat = beatOf.get(t.scope) ?? null;
+ const at = layout.tiles.indexOf(t);
+ const T = beat ? after(t.scope) : pieces.find((p) => !p.beat && layout.tiles.findIndex((x) => x.scope === p.role || (p.role === "quoted" && x.scope === "post" && !above)) > at)?.start ?? null;
+ const own = t.scope !== "quoted" || !!t.above;
+ if (beat && own && revealed(t.scope, beat.t0)) {
+ row.from = t.fromScene ?? [1, 0];
+ row.to = [1, 1];
+ Object.assign(row, win(beat.t0));
+ if (T !== null) row.then = { to: small, ...win(T) };
+ } else if (T !== null) {
+ row.to = own ? small : [1, k.dim];
+ Object.assign(row, win(T));
+ }
+ row.pic = true;
+ if (beat) row.beat = { t0: beat.t0, t1: beat.t1 };
} else if (t.read) {
// Read: in full while it is read, then small and dim (a quoted post only dims) as the next piece starts.
const T = after(t.scope);
@@ -835,14 +889,18 @@ export function refOfScope(entry, scope) {
export function panelSchedule(entry, follow, total, { lead = 0.4 } = {}) {
const th = follow?.thread;
if (!th) return null;
- const own = Array.isArray(entry?.media) && entry.media.length > 0;
+ // His own attachments in the slot (a picture-only post's are in his card: post-picture.mjs).
+ const own = Array.isArray(entry?.media) && entry.media.length > 0 && !isPictureOnly(entry, { text: cardText(entry) });
const startOf = (scope) => {
const ts = (follow.blocks ?? []).filter((b) => b.scope === scope && fin(b.start)).map((b) => b.start);
return ts.length ? Math.min(...ts) : null;
};
const cand = [];
for (const row of th.tiles ?? []) {
- const media = refMediaOf(refOfScope(entry, row.scope));
+ const ref = refOfScope(entry, row.scope);
+ // A PICTURE-ONLY post's picture is in its own card (post-picture.mjs), never in the slot.
+ if (isPictureOnly(ref)) continue;
+ const media = refMediaOf(ref);
if (!media.length) continue;
const s = startOf(row.scope);
const on = row.read && s !== null ? s - lead : row.from?.[1] > 0 ? 0 : row.t0;
diff --git a/umtool/report-to-video/read-follow.mjs b/umtool/report-to-video/read-follow.mjs
@@ -340,7 +340,7 @@ const wordsIn = (t) => scriptWordsOf(t).length;
*
* @param {{ hold?: number | null, narration?: Record<string, any> | null, prev?: Record<string, any> | null, scene?: Record<string, any> | null, mediaScene?: Record<string, any> | null, join?: { seconds: number } | null }} [o]
*/
-export function followSchedule(entry, render = undefined, { hold = null, narration = undefined, prev = null, scene = null, mediaScene = null, join = null } = {}) {
+export function followSchedule(entry, render = undefined, { hold = null, narration = undefined, prev = null, scene = null, mediaScene = null, join = null, beats = [] } = {}) {
const k = followKnobs(entry, render);
if (!k.on) return null;
const map = followBlocks(entry);
@@ -396,13 +396,15 @@ export function followSchedule(entry, render = undefined, { hold = null, narrati
// A MEDIA SCENE (post-media-scene.mjs): the scene's earlier messages above the card's own tiles -- a narrated
// item's on its thread read's schedule, an un-narrated one's on the scene's.
const layout = ms ? sceneLayout(base, entry, ms) : base;
- const own = !layout?.on ? null : base ? threadSchedule(entry, render, { layout, blocks, lead: FOLLOW_PAN.lead }) : sceneSchedule(threadKnobs(entry, render), { layout, blocks, lead: FOLLOW_PAN.lead });
+ // PICTURE-ONLY context posts' BEATS (post-thread.mjs pictureBeats, post-picture.mjs): pieces of their own before the read.
+ const beatsOn = base && Array.isArray(beats) && beats.length ? beats : [];
+ const own = !layout?.on ? null : base ? threadSchedule(entry, render, { layout, blocks, lead: FOLLOW_PAN.lead, beats: beatsOn }) : sceneSchedule(threadKnobs(entry, render), { layout, blocks, lead: FOLLOW_PAN.lead });
const thread0 = ms ? sceneRows(own, layout) : own;
// LINK VISITS (post-link-visit.mjs): a link in the words visited -- the pointer, the click, the post opened.
const visits = thread0 && isNarrated(entry) ? linkVisits(entry, thread0, blocks, render) : [];
const thread = visits.length ? visitRows(thread0, visits) : thread0;
// THE JOIN (post-join.mjs): its first seconds morph from the item before as it ended.
- return { dim: k.dim, ease: k.ease, readEnd, source: map.source, blocks, ...(thread ? { thread } : {}), ...(visits.length ? { visits } : {}), ...(join && fin(join.seconds) ? { join: { seconds: join.seconds } } : {}) };
+ return { dim: k.dim, ease: k.ease, readEnd, source: map.source, blocks, ...(thread ? { thread } : {}), ...(visits.length ? { visits } : {}), ...(join && fin(join.seconds) ? { join: { seconds: join.seconds } } : {}), ...(thread && beatsOn.length ? { beats: beatsOn } : {}) };
}
/** The block being read at item second `s` (its k), or null (before the read's first block, or none). */
@@ -492,7 +494,10 @@ export function threadPath(follow, geo) {
if (max < 1) return Math.round((max / 2) * 100) / 100;
return Math.round(clamp(want, 0, max) * 100) / 100;
};
- const read = (follow.blocks ?? []).filter((b) => b.start !== null && geo.blocks?.[b.k]).sort((a, b) => a.start - b.start || a.k - b.k);
+ // A PICTURE-ONLY post's BEAT (post-picture.mjs) is framed as a piece read: its tile, for its beat.
+ const beatBlocks = (Array.isArray(follow.beats) ? follow.beats : []).filter((b) => geo?.tiles?.[b.scope]).map((b) => ({ scope: b.scope, start: b.t0, end: b.t1, k: null, beat: true }));
+ const read = [...beatBlocks, ...(follow.blocks ?? []).filter((b) => b.start !== null && geo.blocks?.[b.k]).sort((a, b) => a.start - b.start || a.k - b.k)];
+ const boxOf = (g, b) => (b.beat ? g.tiles[b.scope] : g.blocks[b.k]);
// The opening frame: a carried post (or the scene's post the item before ended on) framed as the item before
// left it; else the first block's place.
const carry = (th.tiles ?? []).find((t) => t.mode === "carry") ?? (th.tiles ?? []).find((t) => t.mode === "scene" && t.wasPost);
@@ -512,7 +517,7 @@ export function threadPath(follow, geo) {
const g = at(read[0].start - lead + span);
// The first post read, whole when it fits the window; else its first block a margin from the top.
const tile = g.tiles[tileScopeOf(read[0].scope)];
- off = placed(g, tile && tile.bottom - tile.top <= H - m ? tile.top - Math.min(m / 2, tile.top) : g.blocks[read[0].k].top - m);
+ off = placed(g, tile && tile.bottom - tile.top <= H - m ? tile.top - Math.min(m / 2, tile.top) : boxOf(g, read[0]).top - m);
} else off = placed(g0, 0);
const start = off;
const segments = [];
@@ -533,7 +538,7 @@ export function threadPath(follow, geo) {
if (i === 0 && !carry) return;
const g = at(b.start - lead + span);
maxSeen = Math.max(maxSeen, g.C - H);
- const bb = g.blocks[b.k];
+ const bb = boxOf(g, b);
if (first) {
// A new piece: its tile under a strip of the one it answers, the block itself in view.
const tile = g.tiles[tileScopeOf(b.scope)];