From 3b75c221007eb21ad64bf15cc2a6729675823baf Mon Sep 17 00:00:00 2001 From: shinyobjectz Date: Fri, 4 Dec 2026 17:35:35 -0800 Subject: [PATCH] Box image: CTA read from a frame's texts together --- .../image/sdk-overlay/goal/src/packs/cut.ts | 28 +++++++++++++++---- 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/sdk/cloud/image/sdk-overlay/goal/src/packs/cut.ts b/sdk/cloud/image/sdk-overlay/goal/src/packs/cut.ts index bdc85950..8c146ec1 100644 --- a/sdk/cloud/image/sdk-overlay/goal/src/packs/cut.ts +++ b/sdk/cloud/image/sdk-overlay/goal/src/packs/cut.ts @@ -60,6 +60,21 @@ export function shown(m: Manifest | null): [string, number][] { return out } +/** what each frame from `from` (s) on shows, its texts read together in the order drawn: an end card draws its CTA as + * lines (12-04, Elfster run 4: "Make your Wishlist and organize your Gift Exchange on Elfster." over "It's free.", each + * alone under the CTA's share, and a cut ending on its CTA was failed for none) */ +export function shownTogether(m: Manifest | null, from: number): string[] { + if (!m) return [] + const fps = m.fps && m.fps > 0 ? m.fps : 30 + const out = new Set() + for (const fr of m.frames ?? []) { + if (fr.frame / fps < from) continue + const s = (fr.text ?? []).filter((t) => (t.opacity ?? 1) > 0.05).map((t) => norm(t.text ?? "")).filter(Boolean).join(" ") + if (s) out.add(s) + } + return [...out] +} + const cutJob = (j: Job) => (j.contract?.kind === "cut" ? (j.contract.cut ?? null) : null) const cutFile = (f: FileFacts) => { const c = f.contract?.kind === "cut" ? f.contract.cut : undefined @@ -117,8 +132,9 @@ export const shapePack = check({ id: "shape", text: "each cut in its export const sayPack = check({ id: "say", text: "every phrase the brief says each cut says, heard or shown", over: "file", at: ["render", "publish", "done"], needs: "words" }, async (f) => { const at = cutFile(f) if (!at?.c.say?.length) return - const { spoken, screen } = await heardOf(f) - const on = (p: string) => saidAt(spoken, p, SAY_GAP) !== null || screen.some(([s]) => onScreen(s, p, SAY_GAP)) + const { spoken } = await heardOf(f) + const together = shownTogether(f.manifest, 0) + const on = (p: string) => saidAt(spoken, p, SAY_GAP) !== null || together.some((s) => onScreen(s, p, SAY_GAP)) const missing = at.c.say.filter((p) => p.every !== false && !on(norm(p.text))) if (missing.length) found({ says: `never says or shows: ${missing.map((m) => `"${m.text}"`).join(", ")}` }) }) @@ -143,7 +159,7 @@ export const ctaPack = check({ id: "cta", text: "each cut ends on the const at = cutFile(f) const cta = at?.c.cta if (!cta) return - const { times, screen } = await heardOf(f) + const { times } = await heardOf(f) const within = cta.within ?? CTA_WITHIN const end = f.seconds ?? times[times.length - 1]?.end ?? 0 const last = times.filter((w) => w.end >= end - within).map((w) => norm(w.text)) @@ -155,7 +171,7 @@ export const ctaPack = check({ id: "cta", text: "each cut ends on the const heard = lines.map((l) => share(l, last)) const best = Math.max(0, ...heard) const line = best > 0 ? lines[heard.indexOf(best)] : cta.text - const shownLate = screen.some(([s, t]) => t >= end - within && lines.some((l) => share(l, s.split(" ")) >= CTA_SHARE)) + const shownLate = shownTogether(f.manifest, end - within).some((s) => lines.some((l) => share(l, s.split(" ")) >= CTA_SHARE)) if (best < CTA_SHARE && !shownLate) found({ says: `no CTA in its last ${within.toFixed(0)} s (${(best * 100).toFixed(0)}% of the nearest one's words heard there): "${line}"`, seconds: [Math.max(0, end - within), end] }) }) @@ -165,10 +181,10 @@ export const sayOncePack = check({ id: "say-once", text: "each phrase one c const once = (c?.say ?? []).filter((p) => p.every === false) if (!c || !once.length) return const cuts = j.files.filter((f) => cutOf(c, f.path)) - const heard = await Promise.all(cuts.map(heardOf)) + const heard = await Promise.all(cuts.map(async (f) => ({ ...(await heardOf(f)), together: shownTogether(f.manifest, 0) }))) for (const p of once) { const n = norm(p.text) - const by = heard.some(({ spoken, screen }) => saidAt(spoken, n, SAY_GAP) !== null || screen.some(([s]) => onScreen(s, n, SAY_GAP))) + const by = heard.some(({ spoken, together }) => saidAt(spoken, n, SAY_GAP) !== null || together.some((s) => onScreen(s, n, SAY_GAP))) if (!by) found({ says: `no cut says or shows "${p.text}" (brief: "${p.from}")` }) } })