commit fa8ce0c25bef3f33f003dccaa0bd28164969134b
parent 3efe3a4dca37eff51611e9afc60baaf8bb6b3af6
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Wed, 11 Nov 2026 13:21:30 -0500
umtool posts: an author's picture is found in every channels tree the project reads, not the shadow alone
A project with a .shadow-channels/ (or provenance.channelsDir) holds the
channels' posts but never their _avatars/, and `posts avatars`, `posts reel`
and `timeline insert post:` read the store from that tree only
(postsCli.mjs channelsDirFor; postReel.mjs archiveAvatarsFor and root(c)), so
quartering-diet's cards drew "T" and "S" while the corpus held both pictures
("copied 0 picture(s) ... no picture yet for @thequartering, @madamsavvy").
archiveAvatarStores now reads each channel's store in the shadow and the
corpus behind it (channelsLayersFor; the newest of two pictures wins), a
channel with no store in a tree is noted and skipped, and `posts avatars`
says which stores it read and where it found no _avatars/, naming each
author as the card draws them. `posts avatar <p> <handle>` and
deck.promise.speakers match a handle without regard to case or `@`, the
picture kept under the drawn spelling. Test: postAvatarStores.test.mjs.
Co-Authored-By: Claude <noreply@anthropic.com>
Diffstat:
4 files changed, 256 insertions(+), 39 deletions(-)
diff --git a/umtool/lib/report/postAvatarStores.test.mjs b/umtool/lib/report/postAvatarStores.test.mjs
@@ -0,0 +1,140 @@
+// The archive's authors' pictures found where they are (postReel.mjs
+// archiveAvatarStores, `umtool posts avatars`, `umtool posts avatar`):
+// a project whose channels tree is a SHADOW (posts copied in, no _avatars/)
+// reads the corpus's stores behind it; a channel with no store at all does
+// not end the search; the store's "TheSubject" is the card's "thesubject"
+// (quartering-diet rev 9, 11 Nov: "copied 0 picture(s) … no picture yet for
+// @thequartering, @madamsavvy" while the corpus held both).
+//
+// Temp dirs under UMTOOL_TEST_TMP when set (a scratch dir off /tmp), else the
+// system's.
+import assert from "node:assert/strict";
+import { mkdtempSync } from "node:fs";
+import { mkdir, readFile, rm, writeFile } from "node:fs/promises";
+import { tmpdir } from "node:os";
+import path from "node:path";
+import { after, test } from "node:test";
+
+const BASE = process.env.UMTOOL_TEST_TMP || tmpdir();
+await mkdir(BASE, { recursive: true });
+const ROOT = mkdtempSync(path.join(BASE, "umtool-post-avatar-stores-"));
+after(() => rm(ROOT, { recursive: true, force: true }));
+const CORPUS = path.join(ROOT, "corpus-channels");
+const REPORTS = path.join(ROOT, "reports");
+// The corpus is CHANNELS_DIR, read when paths.mjs loads: set before the imports.
+process.env.CHANNELS_DIR = CORPUS;
+delete process.env.CHANNELS_FALLBACK;
+const reel = await import("./postReel.mjs");
+const { postsCommand } = await import("./postsCli.mjs");
+
+// First-listed channel: posts only, no posts-media/ anywhere. Then a store keyed
+// "TheSubject" (as X printed it) and one keyed "MadamOther".
+const CHANNELS = ["first-x", "subj-X", "other-x"];
+
+async function store(tree, slug, doc) {
+ const dir = path.join(tree, slug, "posts-media", "_avatars");
+ await mkdir(dir, { recursive: true });
+ for (const a of Object.values(doc)) await writeFile(path.join(dir, a.file), "picture");
+ await writeFile(path.join(dir, "avatars.json"), JSON.stringify(doc, null, 2));
+}
+async function posts(tree, slug) {
+ await mkdir(path.join(tree, slug, "posts"), { recursive: true });
+ await writeFile(path.join(tree, slug, "posts", "2026-10.jsonl"), "");
+}
+
+const item = (slug, id, handle) => ({
+ type: "post", id: `p-${id}`, post: `${slug}/${id}`, platform: "x", author: handle.toUpperCase(), handle,
+ date: `2026-10-2${id}T10:00:00.000Z`, text: `post ${id}`,
+});
+
+async function project(name) {
+ const dir = path.join(REPORTS, name);
+ const shadow = path.join(dir, ".shadow-channels");
+ for (const c of CHANNELS) await posts(shadow, c);
+ await writeFile(path.join(dir, "video.manifest.json"), JSON.stringify({
+ schemaVersion: 1, slug: name, title: name, provenance: { siteOrigin: "", channelSlug: "subj-X", channelsDir: ".shadow-channels" },
+ render: { width: 1920, height: 1080, fps: 30, palette: { bg: "#000000", fg: "#ffffff", muted: "#888888", accent: "#c8752a" } },
+ // The first card spells the author in lower case, as a mention does.
+ timeline: [item("first-x", "1", "thesubject"), item("subj-X", "2", "TheSubject"), item("other-x", "3", "MadamOther")],
+ }, null, 2));
+ return { id: name, dir, shadow };
+}
+const manifest = async (p) => JSON.parse(await readFile(path.join(p.dir, "video.manifest.json"), "utf8"));
+const cli = async (args) => {
+ const lines = [];
+ const errs = [];
+ const code = await postsCommand(args, { root: REPORTS, out: (s) => lines.push(s), err: (s) => errs.push(s) });
+ return { code, out: lines.join("\n"), err: errs.join("\n") };
+};
+
+for (const c of CHANNELS) await posts(CORPUS, c);
+await store(CORPUS, "subj-X", {
+ TheSubject: { file: "TheSubject.png", url: "https://pbs.twimg.com/a.png", capturedAt: "2026-11-07T00:00:00Z" },
+ MadamOther: { file: "MadamOther.jpg", capturedAt: "2026-11-01T00:00:00Z" },
+});
+await store(CORPUS, "other-x", { MadamOther: { file: "MadamOther.jpg", url: "https://pbs.twimg.com/b.jpg", capturedAt: "2026-11-07T00:00:00Z" } });
+
+test("archiveAvatarStores: every tree, every channel; a missing _avatars/ is noted and skipped; keys any case", async () => {
+ const p = await project("unit");
+ const { store: got, searched } = await reel.archiveAvatarStores([p.shadow, CORPUS], CHANNELS);
+ assert.deepEqual([...got.keys()].sort(), ["madamother", "thesubject"]);
+ assert.equal(got.get("thesubject").handle, "TheSubject");
+ // The newest of two stores' pictures of one author.
+ assert.equal(got.get("madamother").file, path.join(CORPUS, "other-x", "posts-media", "_avatars", "MadamOther.jpg"));
+ assert.deepEqual(searched.map((s) => `${s.channel}@${s.tree === CORPUS ? "corpus" : "shadow"}:${s.state}`), [
+ "first-x@shadow:none", "first-x@corpus:none", "subj-X@shadow:none", "subj-X@corpus:read", "other-x@shadow:none", "other-x@corpus:read",
+ ]);
+ const said = reel.avatarStoresSaid(searched);
+ assert.equal(said.length, 3);
+ assert.match(said[0], /^first-x: no _avatars\/ in .*\.shadow-channels or .*corpus-channels$/);
+ assert.match(said[1], /^subj-X: 2 picture\(s\) in .*corpus-channels\/subj-X\/posts-media\/_avatars; no _avatars\/ in .*\.shadow-channels$/);
+ // One tree, as a string, as before.
+ assert.equal((await reel.archiveAvatars(CORPUS, ["subj-X"])).size, 2);
+});
+
+test("posts avatars: a shadow-channels project copies the corpus's pictures, names the stores it searched", async () => {
+ const p = await project("shadowed");
+ const r = await cli(["avatars", "shadowed"]);
+ assert.equal(r.code, 0, r.err);
+ assert.match(r.out, /^copied 2 picture\(s\) from subj-X \+ other-x's stores: /, r.out);
+ assert.doesNotMatch(r.out, /no picture yet/, r.out);
+ assert.match(r.out, /first-x: no _avatars\//);
+ const m = await manifest(p);
+ assert.equal(m.postAvatars.TheSubject.src, "posts-media/_avatars/TheSubject.png");
+ assert.equal(m.postAvatars.TheSubject.source, "archive");
+ assert.equal(m.postAvatars.MadamOther.url, "https://pbs.twimg.com/b.jpg");
+ await readFile(path.join(p.dir, "posts-media", "_avatars", "TheSubject.png"));
+ // Again: nothing more to copy, and nobody without one.
+ const again = await cli(["avatars", "shadowed", "--json"]);
+ const j = JSON.parse(again.out);
+ assert.deepEqual(j.copied, {});
+ assert.deepEqual(j.without, []);
+ assert.ok(j.stores.some((s) => s.channel === "first-x" && s.state === "none"));
+});
+
+test("posts avatars: no store anywhere says so, and names the author as the card draws them", async () => {
+ const p = await project("bare");
+ const m0 = await manifest(p);
+ m0.timeline = [item("first-x", "1", "NoPicture")];
+ await writeFile(path.join(p.dir, "video.manifest.json"), JSON.stringify(m0, null, 2));
+ const r = await cli(["avatars", "bare"]);
+ assert.equal(r.code, 0, r.err);
+ assert.match(r.out, /^copied 0 picture\(s\) from no store/);
+ assert.match(r.out, /no picture yet for @NoPicture /);
+});
+
+test("posts avatar: a handle in any case sets and clears the drawn author's picture", async () => {
+ const p = await project("manual");
+ const pic = path.join(ROOT, "manual.png");
+ await writeFile(pic, "picture");
+ assert.equal((await cli(["avatar", "manual", "@madamother", pic])).code, 0);
+ let m = await manifest(p);
+ assert.deepEqual(m.postAvatars, { MadamOther: { src: "posts-media/_avatars/MadamOther-manual.png", source: "manual" } });
+ // The archive's never replaces it.
+ assert.equal((await cli(["avatars", "manual"])).code, 0);
+ m = await manifest(p);
+ assert.equal(m.postAvatars.MadamOther.source, "manual");
+ assert.equal(m.postAvatars.TheSubject.source, "archive");
+ assert.equal((await cli(["avatar", "manual", "MADAMOTHER", "off"])).code, 0);
+ assert.equal((await manifest(p)).postAvatars.MadamOther, undefined);
+});
diff --git a/umtool/lib/report/postReel.mjs b/umtool/lib/report/postReel.mjs
@@ -330,32 +330,92 @@ async function copyInto(projectDir, from, rel) {
/**
* The archive's pictures (each channel's posts-media/_avatars/avatars.json,
* the editor's capture-posts store: `{ <handle>: { file, url, capturedAt } }`),
- * by handle key, the newest when two channels hold one.
+ * by handle key -- the handle without `@`, LOWERCASED: the store keys a
+ * picture by the handle as X printed it ("TheQuartering"), a card or a
+ * mention may spell it otherwise ("@thequartering") -- the newest when two
+ * stores hold one.
*
- * @returns {Promise<Map<string, { handle: string, file: string, url: string | null, capturedAt: string | null }>>}
+ * `layers` is one channels tree or the trees a project reads, in order
+ * (projects/report.mjs channelsLayersFor: its own `.shadow-channels/` or
+ * `provenance.channelsDir`, then the corpus behind it). EVERY tree's store of
+ * EVERY channel is read -- not only the project's own tree, nor the first
+ * tree that holds the channel's posts: a shadow is made by copying a
+ * channel's `posts/` (and a capture or two), never its `_avatars/`, so the
+ * pictures are in the corpus while the posts are in the shadow
+ * (quartering-diet rev 9, 11 Nov: the shadow held the three channels' posts
+ * and none of their stores, `posts avatars` read the shadow alone and copied
+ * 0 of the two pictures the corpus had -- "no picture yet for
+ * @thequartering, @madamsavvy"). A channel with no store in one tree -- or in
+ * any -- is noted in `searched` and skipped, never the end of the search.
+ *
+ * @param {string | string[]} layers
+ * @param {string[]} channels
+ * @returns {Promise<{ store: Map<string, { handle: string, file: string, url: string | null, capturedAt: string | null }>,
+ * searched: Array<{ channel: string, tree: string, dir: string, state: "read" | "none" | "unreadable", pictures: number }> }>}
*/
-export async function archiveAvatars(channelsDir, channels) {
- const out = new Map();
+export async function archiveAvatarStores(layers, channels) {
+ const trees = [...new Set((Array.isArray(layers) ? layers : [layers]).filter((d) => typeof d === "string" && d).map((d) => path.resolve(d)))];
+ const store = new Map();
+ const searched = [];
for (const slug of channels) {
- const dir = path.join(channelsDir, slug, "posts-media", ARCHIVE_AVATARS_DIR);
- let doc;
- try {
- doc = JSON.parse(await readFile(path.join(dir, ARCHIVE_AVATARS_FILE), "utf8"));
- } catch {
- continue;
- }
- if (!doc || typeof doc !== "object" || Array.isArray(doc)) continue;
- for (const [h, a] of Object.entries(doc)) {
- if (!a || typeof a !== "object" || typeof a.file !== "string" || a.file.includes("/") || a.file.includes("\\") || !AVATAR_EXT_RE.test(a.file)) continue;
- const file = path.join(dir, a.file);
- if (!(await stat(file).catch(() => null))?.isFile()) continue;
- const had = out.get(handleKey(h));
- const at = typeof a.capturedAt === "string" ? a.capturedAt : null;
- if (had && (had.capturedAt ?? "") >= (at ?? "")) continue;
- out.set(handleKey(h), { handle: h.replace(/^@/, ""), file, url: typeof a.url === "string" ? a.url : null, capturedAt: at });
+ for (const tree of trees) {
+ const dir = path.join(tree, slug, "posts-media", ARCHIVE_AVATARS_DIR);
+ let doc;
+ try {
+ doc = JSON.parse(await readFile(path.join(dir, ARCHIVE_AVATARS_FILE), "utf8"));
+ } catch (e) {
+ searched.push({ channel: slug, tree, dir, state: e?.code === "ENOENT" || e?.code === "ENOTDIR" ? "none" : "unreadable", pictures: 0 });
+ continue;
+ }
+ if (!doc || typeof doc !== "object" || Array.isArray(doc)) {
+ searched.push({ channel: slug, tree, dir, state: "unreadable", pictures: 0 });
+ continue;
+ }
+ let pictures = 0;
+ for (const [h, a] of Object.entries(doc)) {
+ if (!a || typeof a !== "object" || typeof a.file !== "string" || a.file.includes("/") || a.file.includes("\\") || !AVATAR_EXT_RE.test(a.file)) continue;
+ const file = path.join(dir, a.file);
+ if (!(await stat(file).catch(() => null))?.isFile()) continue;
+ pictures += 1;
+ const k = handleKey(h);
+ const had = store.get(k);
+ const at = typeof a.capturedAt === "string" ? a.capturedAt : null;
+ if (had && (had.capturedAt ?? "") >= (at ?? "")) continue;
+ store.set(k, { handle: h.replace(/^@/, ""), file, url: typeof a.url === "string" ? a.url : null, capturedAt: at });
+ }
+ searched.push({ channel: slug, tree, dir, state: "read", pictures });
}
}
- return out;
+ return { store, searched };
+}
+
+/** The archive's pictures alone (archiveAvatarStores' `store`); `layers` one channels tree or several. */
+export async function archiveAvatars(layers, channels) {
+ return (await archiveAvatarStores(layers, channels)).store;
+}
+
+/**
+ * What archiveAvatarStores searched, in words, one line per channel: each
+ * store it read (and how many pictures it holds), and each tree that had
+ * none -- so "no picture" says WHERE it looked. PURE.
+ *
+ * @param {Array<{ channel: string, tree: string, dir: string, state: string, pictures: number }>} searched
+ * @returns {string[]}
+ */
+export function avatarStoresSaid(searched) {
+ const by = new Map();
+ for (const s of searched ?? []) {
+ if (!by.has(s.channel)) by.set(s.channel, []);
+ by.get(s.channel).push(s);
+ }
+ const lines = [];
+ for (const [channel, rows] of by) {
+ const said = rows.filter((r) => r.state === "read").map((r) => `${r.pictures} picture(s) in ${r.dir}`);
+ const none = rows.filter((r) => r.state !== "read");
+ if (none.length) said.push(`no ${ARCHIVE_AVATARS_DIR}/ in ${none.map((r) => `${r.tree}${r.state === "unreadable" ? ` (${ARCHIVE_AVATARS_FILE} unreadable)` : ""}`).join(" or ")}`);
+ lines.push(`${channel}: ${said.join("; ")}`);
+ }
+ return lines;
}
/** Every handle an entry's card draws UNBLURRED (a redacted author never gets a picture). */
@@ -482,9 +542,9 @@ export async function postsReel(project, o) {
entries.push(made.entry);
dropped += made.dropped;
}
- // The authors' pictures: the archive's, for every author the cards draw unblurred that the cut has none of.
- const store = new Map();
- for (const c of channels) for (const [k, v] of await archiveAvatars(await root(c), [c])) if (!store.has(k)) store.set(k, v);
+ // The authors' pictures: the archive's, for every author the cards draw unblurred that the cut has none of --
+ // from every tree's store (the project's, the corpus behind it), not only the tree its posts were read from.
+ const store = await archiveAvatars(layers, channels);
const avatars = store.size ? await avatarsToCopy(manifest, entries, store, o.dryRun ? async (_f, rel) => rel : (from, rel) => copyInto(project.dir, from, rel)) : {};
const summary = { channels, channelsDir, archived: index.size, selected: picked.length, already, added: entries.length, droppedMedia: dropped, avatars: Object.keys(avatars) };
if (o.dryRun) return { ...summary, entries, dryRun: true, result: null, editNotes: null };
@@ -548,8 +608,8 @@ export async function postItemFromArchive(project, manifest, slug, postId, { id
* @param {{ channelsDir?: string | null }} [o]
*/
export async function archiveAvatarsFor(project, manifest, channels, entries, { channelsDir = null } = {}) {
- const dir = channelsDir ?? channelsDirFor(project.dir, manifest);
- const store = await archiveAvatars(dir, channels);
+ // Every tree the project reads (its own, the corpus behind it): a shadow copies posts, not the stores.
+ const store = await archiveAvatars(channelsDir ?? channelsLayersFor(project.dir, manifest), channels);
if (!store.size) return {};
return avatarsToCopy(manifest, entries, store, (from, rel) => copyInto(project.dir, from, rel));
}
diff --git a/umtool/lib/report/postsCli.mjs b/umtool/lib/report/postsCli.mjs
@@ -1319,8 +1319,14 @@ async function avatarCommand(projectArg, rest, { root, json, out }) {
else for (const [h, a] of Object.entries(map)) out(`@${h} ${a.src} (${a.source ?? "manual"}${a.capturedAt ? `, captured ${String(a.capturedAt).slice(0, 10)}` : ""})`);
return 0;
}
- const h = String(handle).replace(/^@/, "");
- if (!/^[A-Za-z0-9_.-]{1,64}$/.test(h)) throw new CliError(`"${handle}" is not a handle`);
+ const typed = String(handle).replace(/^@/, "");
+ if (!/^[A-Za-z0-9_.-]{1,64}$/.test(typed)) throw new CliError(`"${handle}" is not a handle`);
+ // Matched without regard to case (post-avatars.mjs handleKey): "thequartering" sets the picture of the
+ // author the cards draw as "TheQuartering", and is kept under that spelling (the first card's).
+ const { handleKey } = await import("umtool-report-to-video/post-avatars");
+ const { shownHandles } = await import("./postReel.mjs");
+ const drawnAs = ((await readManifest(project.dir))?.timeline ?? []).flatMap((e) => shownHandles(e)).map((x) => String(x).replace(/^@/, "")).find((x) => handleKey(x) === handleKey(typed));
+ const h = drawnAs && /^[A-Za-z0-9_.-]{1,64}$/.test(drawnAs) ? drawnAs : typed;
if (!file) throw new CliError(`name the picture: umtool posts avatar ${project.id} ${h} <image-file> (or off)`);
if (OFF.has(String(file).toLowerCase())) {
const { result, editNotes } = await withEditNotes(project, async () => setPostAvatar(project.dir, h, null, { token: await manifestToken(project.dir) }));
@@ -1354,10 +1360,13 @@ async function avatarsCommand(projectArg, { root, json, dryRun, out }) {
const project = await projectOf(projectArg, root);
const manifest = await readManifest(project.dir);
if (!manifest) throw new CliError(`${project.id} has no manifest`);
- const { archiveAvatars, avatarsToCopy, postChannelsOf, shownHandles } = await import("./postReel.mjs");
- const { channelsDirFor } = await import("../projects/report.mjs");
+ const { archiveAvatarStores, avatarStoresSaid, avatarsToCopy, postChannelsOf, shownHandles } = await import("./postReel.mjs");
+ const { channelsLayersFor } = await import("../projects/report.mjs");
+ const { handleKey } = await import("umtool-report-to-video/post-avatars");
const channels = postChannelsOf(manifest);
- const store = await archiveAvatars(channelsDirFor(project.dir, manifest), channels);
+ // Every tree the project reads -- its own (.shadow-channels/, provenance.channelsDir) and the corpus behind
+ // it: a shadow copies a channel's posts, never its _avatars/ (postReel.mjs archiveAvatarStores).
+ const { store, searched } = await archiveAvatarStores(channelsLayersFor(project.dir, manifest), channels);
const pics = store.size
? await avatarsToCopy(manifest, [], store, dryRun ? async (_f, rel) => rel : async (from, rel) => {
const to = path.join(project.dir, ...rel.split("/"));
@@ -1366,16 +1375,21 @@ async function avatarsCommand(projectArg, { root, json, dryRun, out }) {
return rel;
})
: {};
- const drawn = [...new Set((manifest.timeline ?? []).flatMap((e) => shownHandles(e)).map((h) => h.toLowerCase()))];
- const have = Object.keys(manifest.postAvatars ?? {}).map((h) => h.toLowerCase());
- const without = drawn.filter((h) => !have.includes(h) && !Object.keys(pics).some((p) => p.toLowerCase() === h));
+ // The authors drawn, compared by handle key (no @, any case), each said as its first card spells it.
+ const drawnAs = new Map();
+ for (const h of (manifest.timeline ?? []).flatMap((e) => shownHandles(e))) if (!drawnAs.has(handleKey(h))) drawnAs.set(handleKey(h), String(h).replace(/^@/, ""));
+ const have = new Set([...Object.keys(manifest.postAvatars ?? {}), ...Object.keys(pics)].map(handleKey));
+ const without = [...drawnAs].filter(([k]) => !have.has(k)).map(([, h]) => h);
let result = null;
if (!dryRun && Object.keys(pics).length) ({ result } = await withEditNotes(project, async () => addArchiveAvatars(project.dir, pics, { token: await manifestToken(project.dir) })));
if (json) {
- out(JSON.stringify({ ok: true, dryRun, channels, copied: pics, without, snapshot: result?.snapshot ?? null }, null, 2));
+ out(JSON.stringify({ ok: true, dryRun, channels, stores: searched, copied: pics, without, snapshot: result?.snapshot ?? null }, null, 2));
return 0;
}
- out(`${dryRun ? "would copy" : "copied"} ${Object.keys(pics).length} picture(s) from ${channels.join(" + ") || "no channel"}'s store${Object.keys(pics).length ? `: ${Object.keys(pics).map((h) => `@${h}`).join(", ")}` : ""}`);
+ const read = [...new Set(searched.filter((s) => s.state === "read").map((s) => s.channel))];
+ out(`${dryRun ? "would copy" : "copied"} ${Object.keys(pics).length} picture(s) from ${read.length ? `${read.join(" + ")}'s store${read.length > 1 ? "s" : ""}` : "no store"}${Object.keys(pics).length ? `: ${Object.keys(pics).map((h) => `@${h}`).join(", ")}` : ""}`);
+ if (!channels.length) out(" the cut has no post item from a posts channel (post: \"<channel>/<postId>\") -- no store to read");
+ for (const line of avatarStoresSaid(searched)) out(` ${line}`);
if (without.length) out(` no picture yet for ${without.map((h) => `@${h}`).join(", ")} (pnpm ops capture-posts … "avatars": true, or umtool posts avatar ${project.id} <handle> <image>)`);
return 0;
}
diff --git a/umtool/report-to-video/modules/promise.mjs b/umtool/report-to-video/modules/promise.mjs
@@ -9,7 +9,7 @@ import path from "node:path";
import { promiseHtml } from "../chrome-measure-extras.mjs";
import { measureOf, promiseStates } from "../measure-extras.mjs";
-import { avatarEntryOf } from "../post-avatars.mjs";
+import { avatarEntryOf, handleKey } from "../post-avatars.mjs";
import { measureExtraModule } from "./measure-extras-module.mjs";
import { PROMISE_CHECKS, resolveMeasureExtra } from "./measure-extras-settings.mjs";
@@ -27,10 +27,13 @@ async function speakerOpts(ctx) {
for (const s of m?.state ?? []) for (const p of s?.promises ?? []) for (const c of p?.claims ?? []) if (c?.speaker) speakers.add(c.speaker);
const handles = {};
const avatars = {};
+ // A speaker's settings matched as a handle is -- without @, without regard to case -- so
+ // `speakers.MadamSavvy` serves the measure's "madamsavvy" (post-avatars.mjs handleKey).
+ const spCfg = (sp) => cfg?.speakers?.[sp] ?? Object.entries(cfg?.speakers ?? {}).find(([k]) => handleKey(k) === handleKey(sp))?.[1];
for (const sp of speakers) {
- const want = cfg?.speakers?.[sp]?.handle ?? sp;
+ const want = spCfg(sp)?.handle ?? sp;
const entry = avatarEntryOf(ctx.manifest, want) ?? avatarEntryOf(ctx.manifest, sp);
- handles[sp] = String(cfg?.speakers?.[sp]?.handle ?? entry?.[0] ?? sp).replace(/^@/, "");
+ handles[sp] = String(spCfg(sp)?.handle ?? entry?.[0] ?? sp).replace(/^@/, "");
if (entry?.[1]?.src && ctx.manifestDir) {
const src = path.resolve(ctx.manifestDir, entry[1].src);
const url = await ctx.asset(src, `avatar-${sp.replace(/[^A-Za-z0-9_-]/g, "_")}${path.extname(src) || ".jpg"}`).catch(() => null);