commit 956f43a84d1f226734413bbdde5c6930535def11
parent 757a391cd718924fd28117bdf26ee216a8c4b3df
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Fri, 23 Oct 2026 01:03:46 -0400
umtool: the siteOrigin decision blocks only when a QR the cut draws is built from the origin
lint.mjs originQrsOf runs qrsOf (the build's deckQrUrl, qrUrlFor, postQrUrl)
with a probe origin and keeps the codes built from it; qrsOf takes metaOf for
the deck's qr.links "original", honours posts.qr false, and tags each code
with its id and source. report.mjs deadOriginQrsOf reads each uncited deck
clip's webpageUrl from its cue file; a missing origin is a defect only when a
code depends on it, a set dead origin still blocks. The sentence names the
count, the first ids and the fix. originUnused is replaced.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
3 files changed, 328 insertions(+), 36 deletions(-)
diff --git a/umtool/lib/projects/report.mjs b/umtool/lib/projects/report.mjs
@@ -18,7 +18,8 @@ import { resolveVideoDirSync } from "yt-dlp-transcript-common/lib/videoDir-serve
import { deliverablesState, finishCommand, outDirState, leftoversOf } from "../report/storage.mjs";
import { CHANNELS_DIR, inside } from "../paths.mjs";
import { channelName, cleanTitle } from "umtool-report-to-video/attribution";
-import { teaserTitle } from "umtool-report-to-video/deck";
+import { deckOn, resolveDeck, teaserTitle } from "umtool-report-to-video/deck";
+import { originQrsOf } from "umtool-report-to-video/lint";
import { DRAFTS_REVIEW_FILE, NARRATION_REVIEW_FILE } from "umtool-report-to-video/drafts-review";
/**
@@ -91,20 +92,72 @@ const DEAD_ORIGIN =
export const isDeadOrigin = (o) => !o || typeof o !== "string" || DEAD_ORIGIN.test(o);
+const originSet = (m) => typeof m?.provenance?.siteOrigin === "string" && m.provenance.siteOrigin.trim() !== "";
+
/**
- * A cut with NO siteOrigin whose every clip carries its own `citeUrl` (release
- * 36: a site-less reactions cut links each clip's platform page), with no
- * card and no post that would need the archive: no QR is built from the
- * origin, so its absence is not a defect. A dead origin that IS set (localhost)
- * still is one.
+ * The QR codes this cut draws from `provenance.siteOrigin`, when that origin is
+ * missing or dead -- `[]` when it is live, since then none of them is wrong.
+ *
+ * WHICH codes is the build's own rule, not a guess here: lint.mjs originQrsOf
+ * runs qrsOf (deckQrUrl, qrUrlFor, postQrUrl). A clip with a `citeUrl` links
+ * that; under the deck with `qr.links: "original"` a clip links its record's
+ * page (`webpageUrl`, read from its cue file -- the record the build reads),
+ * and only one whose record names none falls back to the archive; no code is
+ * drawn with `render.qr: false`, the deck's `qr.show: false`, or for a `src`
+ * clip with no `citeUrl`; a rail card links `provenance.qrLink` before the
+ * origin.
+ *
+ * @returns {Promise<{ where: string, id: string|null, source: "entry"|"post" }[]>}
*/
-export const originUnused = (m) => {
- if (m?.provenance?.siteOrigin) return false;
- const tl = Array.isArray(m?.timeline) ? m.timeline : [];
- const clips = tl.filter((e) => e?.type === "clip");
- return clips.length > 0 && clips.every((c) => typeof c.citeUrl === "string" && /^https?:\/\//.test(c.citeUrl)) && !tl.some((e) => e?.type === "card") && !(Array.isArray(m?.posts) && m.posts.length);
-};
-const originDead = (m) => isDeadOrigin(m?.provenance?.siteOrigin) && !originUnused(m);
+export async function deadOriginQrsOf(dir, m, { channelsDir = null } = {}) {
+ if (!m || !isDeadOrigin(m.provenance?.siteOrigin)) return [];
+ const render = m.render ?? {};
+ let metaOf = null;
+ if (deckOn(render) && resolveDeck(render).qr?.show && resolveDeck(render).qr?.links === "original") {
+ const root = channelsDir ?? channelsDirFor(dir, m, { shadowExists: await hasShadowChannels(dir) });
+ const metas = new Map();
+ for (const e of clipsOf(m)) {
+ if (e.citeUrl || e.src != null || !e.video) continue;
+ const file = cuePathFor(m, e, root);
+ const doc = file ? await readCues(file) : null;
+ metas.set(e, doc?.webpageUrl ? { webpageUrl: doc.webpageUrl } : null);
+ }
+ metaOf = (e) => metas.get(e) ?? null;
+ }
+ return originQrsOf(m, { metaOf });
+}
+
+/**
+ * Is the QR origin a defect? A SET origin that is dead (localhost, a LAN
+ * address) always is: it is the archive the cut names, whatever links it
+ * today. A MISSING one only when a code the cut draws is built from it
+ * (`qrs`, deadOriginQrsOf) -- a cut whose every code links something of its
+ * own (a citeUrl, a record's page, qrLink) or that draws none needs no origin.
+ */
+export const originDeadFor = (m, qrs) => (originSet(m) ? isDeadOrigin(m.provenance.siteOrigin) : qrs.length > 0);
+
+/** Up to three ids, then how many more: "`a`, `b`, `c` and 4 more". */
+const someIds = (ids) =>
+ ids.slice(0, 3).map((id) => `\`${id}\``).join(", ") + (ids.length > 3 ? ` and ${ids.length - 3} more` : "");
+
+/** The siteOrigin decision's sentence: how many codes, the first few, the fix. */
+export function deadOriginWhy(m, qrs) {
+ const origin = m?.provenance?.siteOrigin;
+ const n = qrs.length;
+ const codes = `${n} QR code${n === 1 ? "" : "s"}`;
+ const ids = someIds(qrs.map((q) => (q.source === "post" ? `post ${q.id ?? "?"}` : q.id ?? "?")));
+ const types = new Map((m?.timeline ?? []).filter((e) => e?.id).map((e) => [e.id, e.type]));
+ const entries = qrs.filter((q) => q.source === "entry");
+ const fixes = [originSet(m) ? "set provenance.siteOrigin to the public archive" : "set provenance.siteOrigin"];
+ if (entries.some((q) => types.get(q.id) === "clip")) fixes.push("give those clips a citeUrl");
+ // A rail tile that is not a clip's (a card's, a still's) links qrLink first.
+ if (entries.some((q) => types.get(q.id) !== "clip")) fixes.push("set provenance.qrLink for the rail's other tiles");
+ if (qrs.some((q) => q.source === "post")) fixes.push("give those posts a siteUrl");
+ const fix = fixes.length > 1 ? `${fixes.slice(0, -1).join(", ")}, or ${fixes[fixes.length - 1]}` : fixes[0];
+ if (!originSet(m)) return `missing — ${codes} in this cut would encode \`undefined/?v=…\` (${ids}): ${fix}`;
+ if (!n) return `\`${origin}\` — resolves to nothing on anyone else's phone, and it is the archive this cut names: ${fix}`;
+ return `\`${origin}\` — ${codes} in this cut (${ids}) resolve to nothing on anyone else's phone: ${fix}`;
+}
const stat0 = (p) => stat(p).then((s) => s, () => null);
@@ -671,6 +724,10 @@ export async function summariseReport(ctx) {
const sourcesDead = src.rows.filter((r) => r.availability && !r.availability.ok && r.availability.state !== "no-cues").length;
const sourcesMissing = src.rows.filter((r) => r.cues === "missing").length;
const cueGaps = src.rows.filter((r) => r.coverageGap).length;
+ // The codes a missing or dead origin would break (deadOriginQrsOf): the
+ // same cue files sourcesOf just read, memoised.
+ const deadOriginQrs = m ? await deadOriginQrsOf(dir, m) : [];
+ const originDead = m ? originDeadFor(m, deadOriginQrs) : false;
const state = !m
? "draft"
@@ -697,7 +754,7 @@ export async function summariseReport(ctx) {
if (build.built) facts.push(`${(build.finalSize / 1e6).toFixed(0)} MB`);
const flags = [];
- if (originDead(m)) flags.push("dead QR origin");
+ if (originDead) flags.push("dead QR origin");
if (!m?.provenance?.channelSlug) flags.push("no channelSlug");
if (build.stale) flags.push("older than its manifest");
if (sourcesDead) flags.push(`${sourcesDead} dead source${sourcesDead === 1 ? "" : "s"}`);
@@ -741,12 +798,13 @@ export async function summariseReport(ctx) {
...(sourcesMissing ? { "sources-missing": String(sourcesMissing) } : {}),
...(cueGaps ? { "cue-gaps": String(cueGaps) } : {}),
...(build.built ? { built: "1", "final-bytes": String(build.finalSize + build.fullSize) } : {}),
- ...(originDead(m) ? { "dead-origin": "1" } : {}),
+ ...(originDead ? { "dead-origin": "1" } : {}),
},
// Kept for the project page and the decisions pass, so neither re-reads.
manifest: m,
build,
sources: src,
+ deadOriginQrs,
};
}
@@ -841,16 +899,12 @@ export async function reportDecisions(ctx, summary) {
(await stat(path.join(dir, "make-shadow-channels.sh")).then(() => true, () => false));
// --- the manifest itself -------------------------------------------------
- const origin = m.provenance?.siteOrigin;
- if (originDead(m)) {
- add(
- "manifest-invalid",
- "provenance.siteOrigin",
- origin
- ? `\`${origin}\` — every QR in this cut resolves to nothing on anyone else's phone`
- : "missing — every QR in this cut encodes `undefined/?v=…`",
- "blocking",
- );
+ // Only the codes that are built from the origin: a cut whose every code
+ // links something of its own (or that draws none) is not blocked by a
+ // missing one. A set origin that is dead blocks whatever links it.
+ const deadOriginQrs = s.deadOriginQrs ?? (await deadOriginQrsOf(dir, m, { channelsDir }));
+ if (originDeadFor(m, deadOriginQrs)) {
+ add("manifest-invalid", "provenance.siteOrigin", deadOriginWhy(m, deadOriginQrs), "blocking");
}
if (!m.provenance?.channelSlug) {
add(
diff --git a/umtool/lib/report/siteorigin-check.test.mjs b/umtool/lib/report/siteorigin-check.test.mjs
@@ -0,0 +1,198 @@
+// The QR-origin check (lane siteorigin-check): `manifest-invalid` on
+// `provenance.siteOrigin` is raised only when a QR the cut draws is built from
+// a missing or dead origin -- the build's own link rules (lint.mjs
+// originQrsOf over deckQrUrl / qrUrlFor / postQrUrl), with the deck's
+// `qr.links: "original"` reading each clip's record page from its cue file.
+// A set origin that is dead still blocks whatever links it.
+//
+// Run with: pnpm test:scripts
+import assert from "node:assert/strict";
+import { mkdir, mkdtemp, rm, writeFile } from "node:fs/promises";
+import { tmpdir } from "node:os";
+import path from "node:path";
+import test from "node:test";
+
+import { originQrsOf } from "umtool-report-to-video/lint";
+import { decisionsFor, summarise } from "../projects/core.mjs";
+import { walkProjects } from "../projects/walk.mjs";
+
+const RENDER = { width: 1920, height: 1080, fps: 30, transition: 0.5 };
+const DECK = (deck = {}) => ({ ...RENDER, chrome: { engine: "hyperframes", layout: "deck", deck } });
+const clip = (id, extra = {}) => ({ type: "clip", id, video: `vid-${id}`, start: 10, end: 20, cite: 10, ...extra });
+const cited = (id) => clip(id, { citeUrl: `https://archive.example/?v=chan%2Fvid-${id}&t=10` });
+
+/** A reports root and a channels dir; each clip's cue file names `pages[id]` (or no page). */
+async function fixture() {
+ const root = await mkdtemp(path.join(tmpdir(), "siteorigin-"));
+ const channelsDir = path.join(root, "channels");
+ const reportsRoot = path.join(root, "reports");
+ await mkdir(reportsRoot, { recursive: true });
+ /**
+ * @param {string} slug
+ * @param {{ provenance?: object, render?: object, timeline: any[], posts?: any[], pages?: Record<string, string|null> }} o
+ */
+ const project = async (slug, { provenance = {}, render = RENDER, timeline, posts, pages = {} }) => {
+ for (const e of timeline.filter((x) => x.type === "clip" && x.video)) {
+ const dir = path.join(channelsDir, "chan", "data", e.video);
+ await mkdir(dir, { recursive: true });
+ const page = Object.hasOwn(pages, e.id) ? pages[e.id] : `https://www.youtube.com/watch?v=${e.video}`;
+ await writeFile(
+ path.join(dir, "transcript.cues.json"),
+ JSON.stringify({ title: e.video, duration: 60, ...(page ? { webpageUrl: page } : {}), cues: [{ start: 0, end: 60, text: "A whole sentence." }] }),
+ );
+ }
+ const dir = path.join(reportsRoot, slug);
+ await mkdir(dir, { recursive: true });
+ const m = {
+ schemaVersion: 1, slug, title: slug,
+ provenance: { channelSlug: "chan", channelsDir: path.relative(dir, channelsDir), ...provenance },
+ render, timeline, ...(posts ? { posts } : {}),
+ };
+ await writeFile(path.join(dir, "video.manifest.json"), JSON.stringify(m, null, 2));
+ return m;
+ };
+ /** The project's siteOrigin decisions and whether its card carries the flag. */
+ const check = async (slug) => {
+ const [ref] = (await walkProjects(reportsRoot)).filter((p) => p.id === slug);
+ assert.ok(ref, `no project ${slug}`);
+ const ds = (await decisionsFor(ref, reportsRoot)).filter((d) => d.target === "provenance.siteOrigin");
+ const s = await summarise(ref, reportsRoot);
+ return { ds, flagged: s.flags.includes("dead QR origin"), attr: s.attrs["dead-origin"] ?? null };
+ };
+ return { root, project, check, done: () => rm(root, { recursive: true, force: true }) };
+}
+
+test("every clip with a citeUrl: no origin is needed, so no decision and no flag", async () => {
+ const f = await fixture();
+ try {
+ await f.project("all-cited", { timeline: [cited("a"), cited("b"), cited("c")] });
+ assert.deepEqual(await f.check("all-cited"), { ds: [], flagged: false, attr: null });
+ // A card beside them under the CORNER code draws nothing, so it needs nothing either.
+ await f.project("cited-and-card", { timeline: [cited("a"), { type: "card", id: "k1", seconds: 3 }] });
+ assert.deepEqual((await f.check("cited-and-card")).ds, []);
+ } finally {
+ await f.done();
+ }
+});
+
+test("the deck with qr.links \"original\": a clip whose record names its page links that; one whose record names none falls back and blocks", async () => {
+ const f = await fixture();
+ try {
+ const render = DECK({ qr: { links: "original" } });
+ // Posts with no origin link themselves (postQrUrl), so they need none either.
+ const posts = [{ id: "p1", attachTo: "a", url: "https://bsky.app/profile/x/post/abc", date: "2026-01-01", text: "t", platform: "bluesky" }];
+ await f.project("original", { render, timeline: [clip("a"), clip("b"), { type: "teaser", id: "t1", seconds: 3 }], posts });
+ assert.deepEqual(await f.check("original"), { ds: [], flagged: false, attr: null });
+
+ await f.project("original-gap", { render, timeline: [clip("a"), clip("nopage")], pages: { nopage: null } });
+ const { ds, flagged, attr } = await f.check("original-gap");
+ assert.equal(ds.length, 1);
+ assert.equal(ds[0].severity, "blocking");
+ assert.match(ds[0].why, /^missing — 1 QR code in this cut would encode `undefined\/\?v=…` \(`nopage`\)/);
+ assert.match(ds[0].why, /set provenance\.siteOrigin, or give those clips a citeUrl$/);
+ assert.equal(flagged, true);
+ assert.equal(attr, "1");
+ } finally {
+ await f.done();
+ }
+});
+
+test("one clip without a citeUrl and no origin: blocking, naming that clip and the fix", async () => {
+ const f = await fixture();
+ try {
+ await f.project("one-uncited", { timeline: [cited("a"), clip("bare"), cited("c")] });
+ const { ds, flagged } = await f.check("one-uncited");
+ assert.equal(ds.length, 1);
+ assert.equal(ds[0].kind, "manifest-invalid");
+ assert.equal(ds[0].severity, "blocking");
+ assert.equal(
+ ds[0].why,
+ "missing — 1 QR code in this cut would encode `undefined/?v=…` (`bare`): set provenance.siteOrigin, or give those clips a citeUrl",
+ );
+ assert.equal(flagged, true);
+
+ // Many: the first three by id, then how many more.
+ await f.project("many-uncited", { timeline: ["a", "b", "c", "d", "e"].map((id) => clip(id)) });
+ const [d] = (await f.check("many-uncited")).ds;
+ assert.match(d.why, /^missing — 5 QR codes in this cut would encode `undefined\/\?v=…` \(`a`, `b`, `c` and 2 more\)/);
+ } finally {
+ await f.done();
+ }
+});
+
+test("no QR at all -- render.qr false, the deck's qr.show false, a src clip -- needs no origin", async () => {
+ const f = await fixture();
+ try {
+ await f.project("qr-off", { render: { ...RENDER, qr: false }, timeline: [clip("a"), clip("b")] });
+ assert.deepEqual(await f.check("qr-off"), { ds: [], flagged: false, attr: null });
+ await f.project("deck-qr-off", { render: DECK({ qr: { show: false } }), timeline: [clip("a")] });
+ assert.deepEqual((await f.check("deck-qr-off")).ds, []);
+ await f.project("src-clip", { timeline: [{ type: "clip", id: "s1", src: "media/local.mp4", start: 0, end: 5 }, cited("a")] });
+ assert.deepEqual((await f.check("src-clip")).ds, []);
+ } finally {
+ await f.done();
+ }
+});
+
+test("a rail card with no qrLink and no origin: blocking, the card named and qrLink offered; a qrLink settles it", async () => {
+ const f = await fixture();
+ try {
+ const render = { ...RENDER, rail: { qrSize: 132 } };
+ const timeline = [cited("a"), { type: "card", id: "k1", seconds: 3, heading: "A card" }];
+ await f.project("rail-card", { render, timeline });
+ const { ds } = await f.check("rail-card");
+ assert.equal(ds.length, 1);
+ assert.equal(ds[0].severity, "blocking");
+ assert.match(ds[0].why, /\(`k1`\): set provenance\.siteOrigin, or set provenance\.qrLink for the rail's other tiles$/);
+
+ await f.project("rail-card-qrlink", { render, timeline, provenance: { qrLink: "https://archive.example/?q=x" } });
+ assert.deepEqual((await f.check("rail-card-qrlink")).ds, []);
+ } finally {
+ await f.done();
+ }
+});
+
+test("a SET origin that is dead still blocks, whatever links it; a live one never does", async () => {
+ const f = await fixture();
+ try {
+ await f.project("localhost-cited", { provenance: { siteOrigin: "http://localhost:3000" }, timeline: [cited("a")] });
+ const [d] = (await f.check("localhost-cited")).ds;
+ assert.equal(d.severity, "blocking");
+ assert.match(d.why, /^`http:\/\/localhost:3000` — resolves to nothing on anyone else's phone/);
+
+ await f.project("localhost-bare", { provenance: { siteOrigin: "http://localhost:3000" }, timeline: [clip("a"), clip("b")] });
+ const [e] = (await f.check("localhost-bare")).ds;
+ assert.match(e.why, /^`http:\/\/localhost:3000` — 2 QR codes in this cut \(`a`, `b`\) resolve to nothing/);
+ assert.match(e.why, /set provenance\.siteOrigin to the public archive, or give those clips a citeUrl$/);
+
+ await f.project("live", { provenance: { siteOrigin: "https://archive.example" }, timeline: [clip("a")] });
+ assert.deepEqual(await f.check("live"), { ds: [], flagged: false, attr: null });
+ } finally {
+ await f.done();
+ }
+});
+
+test("originQrsOf is the build's rules run on a probe origin: which codes, by entry", () => {
+ const timeline = [cited("a"), clip("b"), { type: "card", id: "k1", seconds: 3 }, { type: "image", id: "i1", src: "x.png", citeUrl: "https://e.test/i1" }];
+ const ids = (m, o) => originQrsOf(m, o).map((q) => q.id);
+ // The corner code: the uncited clip only (a card draws none, a still links its citeUrl).
+ assert.deepEqual(ids({ render: RENDER, provenance: {}, timeline }), ["b"]);
+ // The rail: a card's and a still's tile are qrLink ?? siteOrigin (qrUrlFor).
+ assert.deepEqual(ids({ render: { ...RENDER, rail: {} }, provenance: {}, timeline }), ["b", "k1", "i1"]);
+ // The deck, site links: the uncited clip; "original" with its record's page: none.
+ assert.deepEqual(ids({ render: DECK(), provenance: {}, timeline }), ["b"]);
+ const page = () => ({ webpageUrl: "https://www.youtube.com/watch?v=x" });
+ assert.deepEqual(ids({ render: DECK({ qr: { links: "original" } }), provenance: {}, timeline }, { metaOf: page }), []);
+ // A post under "archive" depends on the origin only when one is set (else it links itself).
+ const posts = [{ id: "p1", attachTo: "a", url: "https://bsky.app/profile/x/post/abc" }];
+ assert.deepEqual(originQrsOf({ render: DECK(), provenance: {}, timeline: [cited("a")], posts }), []);
+ assert.deepEqual(
+ originQrsOf({ render: DECK(), provenance: { siteOrigin: "http://localhost:3000" }, timeline: [cited("a")], posts }).map((q) => q.source),
+ ["post"],
+ );
+ // ...and not at all with the posts' codes off.
+ assert.deepEqual(
+ originQrsOf({ render: DECK({ posts: { qr: false } }), provenance: { siteOrigin: "http://localhost:3000" }, timeline: [cited("a")], posts }),
+ [],
+ );
+});
diff --git a/umtool/report-to-video/lint.mjs b/umtool/report-to-video/lint.mjs
@@ -142,14 +142,21 @@ function postQrUrlForLint(post, provenance, links) {
}
/**
- * Every QR the cut will draw, as `{ where, url, px, perModule }` -- `px` the
- * drawn width on the frame, or null for the corner code, which is `perModule`
- * native pixels per module, unresized.
+ * Every QR the cut will draw, as `{ where, id, source, url, px, perModule }`
+ * -- `id` the timeline entry's (or the post's), `source` "entry" or "post",
+ * `px` the drawn width on the frame, or null for the corner code, which is
+ * `perModule` native pixels per module, unresized.
+ *
+ * `metaOf(entry)` is a clip's record metadata (`{ webpageUrl }`) when the
+ * caller has it: under the deck's `qr.links: "original"` a clip with no
+ * `citeUrl` links its record's own page, and falls back to the archive link
+ * only when the record names none (deckQrUrl). Without it the archive link is
+ * measured, as before.
*
* @param {any} manifest a cut, as selectVariant returns it
- * @param {{ only?: string|null }} [opts]
+ * @param {{ only?: string|null, metaOf?: ((entry: any) => ({ webpageUrl?: string|null } | null)) | null }} [opts]
*/
-export function qrsOf(manifest, { only = null } = {}) {
+export function qrsOf(manifest, { only = null, metaOf = null } = {}) {
const render = manifest.render ?? {};
const provenance = manifest.provenance ?? {};
const timeline = (manifest.timeline ?? []).filter((e) => e && (!only || e.id === only));
@@ -158,15 +165,16 @@ export function qrsOf(manifest, { only = null } = {}) {
const d = resolveDeck(render);
if (d.qr?.show) {
for (const e of timeline) {
- const url = deckQrUrl(e, provenance, { links: d.qr.links });
- if (url) out.push({ where: `timeline ${e.id} (the deck's QR)`, url, px: Number(d.qr.size) });
+ const url = deckQrUrl(e, provenance, { links: d.qr.links, meta: metaOf?.(e) ?? null });
+ if (url) out.push({ where: `timeline ${e.id} (the deck's QR)`, id: e.id, source: "entry", url, px: Number(d.qr.size) });
}
}
- if (d.posts?.show && Array.isArray(manifest.posts)) {
+ // `posts.qr: false` draws no code on any post card.
+ if (d.posts?.show && d.posts.qr !== false && Array.isArray(manifest.posts)) {
for (const p of manifest.posts) {
if (!p || (only && p.attachTo !== only)) continue;
const url = postQrUrlForLint(p, provenance, d.posts.links);
- if (url) out.push({ where: `posts ${p.id ?? "?"} (its QR)`, url, px: Number(d.posts.qrSize) });
+ if (url) out.push({ where: `posts ${p.id ?? "?"} (its QR)`, id: p.id ?? null, source: "post", url, px: Number(d.posts.qrSize) });
}
}
return out;
@@ -178,7 +186,7 @@ export function qrsOf(manifest, { only = null } = {}) {
const px = Number(render.rail.qrSize ?? 132);
for (const e of timeline) {
const url = qrUrlFor(e, provenance);
- if (url) out.push({ where: `timeline ${e.id} (its rail QR)`, url, px });
+ if (url) out.push({ where: `timeline ${e.id} (its rail QR)`, id: e.id, source: "entry", url, px });
}
return out;
}
@@ -194,11 +202,43 @@ export function qrsOf(manifest, { only = null } = {}) {
} else if (e.type === "image" && e.citeUrl) {
url = e.citeUrl;
}
- if (url) out.push({ where: `timeline ${e.id} (its corner QR)`, url, px: null, perModule: scale });
+ if (url) out.push({ where: `timeline ${e.id} (its corner QR)`, id: e.id, source: "entry", url, px: null, perModule: scale });
}
return out;
}
+// A stand-in archive origin no real link starts with: what originQrsOf puts in
+// `provenance.siteOrigin` to see which links the real rules build from it.
+const ORIGIN_PROBE = "https://site-origin.probe.invalid";
+
+/**
+ * The QRs the cut draws whose link is built from `provenance.siteOrigin`: the
+ * ones an absent origin turns into `undefined/?v=…` (or, a rail card's, an
+ * empty code) and a localhost one into a link that resolves nowhere. Every
+ * other code links something of its own -- a clip's `citeUrl`, its record's
+ * page under the deck's `qr.links: "original"`, a still's `citeUrl`, a card's
+ * `provenance.qrLink` -- or is not drawn (`render.qr: false`, the deck's
+ * `qr.show: false`, a `src` clip with no `citeUrl`, `posts.qr: false`).
+ *
+ * Not a second copy of the link rules: it runs qrsOf -- the build's own
+ * deckQrUrl, qrUrlFor and postQrUrl -- with the origin set to a probe, and
+ * keeps the codes whose link begins with it. A post is the one exception: with
+ * NO origin its code links the post itself (postQrUrl), so a post depends on
+ * the origin only when one is set.
+ *
+ * @param {any} manifest
+ * @param {{ only?: string|null, metaOf?: ((entry: any) => ({ webpageUrl?: string|null } | null)) | null }} [opts]
+ * @returns {{ where: string, id: string|null, source: "entry"|"post" }[]}
+ */
+export function originQrsOf(manifest, { only = null, metaOf = null } = {}) {
+ const provenance = manifest?.provenance ?? {};
+ const origin = typeof provenance.siteOrigin === "string" ? provenance.siteOrigin.trim() : "";
+ const probe = { ...manifest, provenance: { ...provenance, siteOrigin: ORIGIN_PROBE } };
+ return qrsOf(probe, { only, metaOf })
+ .filter((q) => String(q.url).startsWith(ORIGIN_PROBE) && (origin || q.source !== "post"))
+ .map(({ where, id, source }) => ({ where, id, source }));
+}
+
/**
* Every picture the cut reads from beside the manifest, as `{ where, src }`.
* Posts' shots and logos only under the deck, the one place posts are drawn.