Archilyzer · Source

archilyzer

Archilyzer
git clone https://archilyzer.pages.dev/source/archilyzer.git
Log | Files | Refs | README | LICENSE

commit 9aec9e5e46e44c7a95fe0ead250a2a8680a3af97
parent 185e537670969351a05b61e4ae63e78004e346af
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Mon,  9 Nov 2026 14:58:35 -0500

umtool: intro review fixes -- a manifest title as one line, audio-only sound route, sound stops on unmount

- introWords: title-card's default title (the manifest's) collapsed to one line and cut at 80
  code points, so a two-line title the preview drew is not refused at render time;
  the title/line length check counts code points too.
- GET /api/report/chrome/intro?sound=1&path: only wav mp3 m4a aac ogg opus flac, each
  with its content type; anything else is a 404.
- IntroCardPlayer pauses its audio when it leaves the stage.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

Diffstat:
Mcommon/lib/report/intro.mjs | 2+-
Mumtool/app/api/report/chrome/intro/route.ts | 18+++++++++++++++---
Mumtool/components/projects/review/IntroCardPlayer.tsx | 8++++++++
Mumtool/report-to-video/intro-words.test.mjs | 7+++++++
Mumtool/report-to-video/intro.mjs | 5++++-
5 files changed, 35 insertions(+), 5 deletions(-)

diff --git a/common/lib/report/intro.mjs b/common/lib/report/intro.mjs @@ -237,7 +237,7 @@ const KEYS = ["style", "ground", "mark", "sound", "seconds", "site", "swap", "ur export const INTRO_KEYS = Object.freeze([...KEYS]); /** A line of words the card draws: a string of 1 to `max` characters on one line. */ -const oneLine = (v, max) => typeof v === "string" && !!v.trim() && v.trim().length <= max && !/[\r\n]/.test(v); +const oneLine = (v, max) => typeof v === "string" && !!v.trim() && Array.from(v.trim()).length <= max && !/[\r\n]/.test(v); /** Every reason `title` / `lines` (of a `render.intro`) cannot be drawn. */ export function introWordsErrors(o) { diff --git a/umtool/app/api/report/chrome/intro/route.ts b/umtool/app/api/report/chrome/intro/route.ts @@ -34,6 +34,17 @@ export const dynamic = "force-dynamic"; const noStore = { "cache-control": "no-store" }; +/** The sound files the intro route serves, by extension, and their content types. */ +const AUDIO_TYPES: Record<string, string> = { + ".wav": "audio/wav", + ".mp3": "audio/mpeg", + ".m4a": "audio/mp4", + ".aac": "audio/aac", + ".ogg": "audio/ogg", + ".opus": "audio/ogg", + ".flac": "audio/flac", +}; + const inside = (base: string, p: string) => { const rel = path.relative(base, p); return !!rel && !rel.startsWith("..") && !path.isAbsolute(rel); @@ -61,9 +72,10 @@ export async function GET(request: Request) { const real = await realpath(path.resolve(r.project.dir, rel)).catch(() => null); if (base && real && inside(base, real)) abs = real; } - const st = abs ? await stat(abs).catch(() => null) : null; - if (!abs || !st?.isFile()) return new Response("no intro sound here", { status: 404 }); - const type = /\.mp3$/i.test(abs) ? "audio/mpeg" : /\.(m4a|aac)$/i.test(abs) ? "audio/mp4" : /\.(ogg|opus)$/i.test(abs) ? "audio/ogg" : "audio/wav"; + // Audio only, by its extension: this route never serves any other file of the project. + const type = abs ? AUDIO_TYPES[path.extname(abs).toLowerCase()] : undefined; + const st = abs && type ? await stat(abs).catch(() => null) : null; + if (!abs || !type || !st?.isFile()) return new Response("no intro sound here", { status: 404 }); return rangeResponse(request, { abs, size: st.size, headers: { "content-type": type, "accept-ranges": "bytes", "cache-control": "no-store" } }); } try { diff --git a/umtool/components/projects/review/IntroCardPlayer.tsx b/umtool/components/projects/review/IntroCardPlayer.tsx @@ -93,6 +93,14 @@ export default function IntroCardPlayer({ } else if (!a.paused) a.pause(); }, [run, at, speed]); + // Gone from the stage (another item, another slide, the editor closed): its sound stops with it. + useEffect(() => { + const a = audio.current; + return () => { + if (a && !a.paused) a.pause(); + }; + }, [page.sound]); + const scale = width > 0 ? width / page.width : 0; return ( <div diff --git a/umtool/report-to-video/intro-words.test.mjs b/umtool/report-to-video/intro-words.test.mjs @@ -61,6 +61,13 @@ test("title-card's words default to the project's title and its date; written wo assert.deepEqual(introWords({ style: "title-card" }, m), { title: m.title, lines: ["29 October 2026"] }); assert.deepEqual(introWords({ style: "title-card", title: "Mine", lines: [] }, m), { title: "Mine" }, "lines: [] is none"); assert.deepEqual(introWords({ style: "title-card" }, {}), {}, "nothing to draw: the brand alone"); + // A manifest title over two lines (or longer than a line) is ONE line of at most 80, which the build accepts. + const two = introWords({ style: "title-card" }, { title: "Part 1\nThe long version" }); + assert.equal(two.title, "Part 1 The long version"); + assert.deepEqual(introErrors({ style: "title-card", title: two.title }), []); + const long = introWords({ style: "title-card" }, { title: `${"é".repeat(78)}\n🎬🎬 tail` }); + assert.equal(Array.from(long.title).length, 80); + assert.deepEqual(introErrors({ style: "title-card", title: long.title }), []); assert.deepEqual(introWords({ style: "boot-dark" }, m), {}); assert.deepEqual(introWords({ style: "boot-dark", title: "T" }, m), { title: "T" }); // The entry the cut opens with carries them; selectVariant's door (introManifest) passes the manifest. diff --git a/umtool/report-to-video/intro.mjs b/umtool/report-to-video/intro.mjs @@ -203,7 +203,10 @@ export function introDateWords(v) { */ export function introWords(o, manifest = null) { const card = o.style === "title-card"; - const title = o.title ?? (card && typeof manifest?.title === "string" && manifest.title.trim() ? manifest.title.trim().slice(0, 80) : undefined); + // The manifest's title as ONE line of at most 80 characters (code points): a title written over two lines + // would preview but be refused by the build's own check (introErrors) at render time. + const fromManifest = card && typeof manifest?.title === "string" ? Array.from(manifest.title.replace(/\s+/g, " ").trim()).slice(0, 80).join("").trim() : ""; + const title = o.title ?? (fromManifest || undefined); const date = card ? introDateWords(manifest?.generatedOn) : null; const lines = o.lines ?? (date ? [date] : undefined); return { ...(title ? { title } : {}), ...(lines && lines.length ? { lines } : {}) };