The open creative studio on ComfyUI: images, video, 3D and audio on open weights, on your own GPU or the cloud. Camera motions, effects, apps, Cinema, Layers, Image to 3D and an AI agent.
TypeScript ai-videocomfyuicreative-toolsgenerative-aiideogramimage-generationimage-to-3dimage-to-videoltx-videominimax-h3nextjsopen-sourceopen-weightsqwen-imagetext-to-imagevideo-generationwan
Home: a first screen that shows every kind of media
Adarsh09ec6b75a798
diff --git a/package.json b/package.jsonindex f909c46c..47d0398a 100644--- a/package.json+++ b/package.json@@ -15,6 +15,7 @@"test": "vitest run","test:e2e:comfyui": "node tests/e2e/comfyui-selftest.mjs","test:e2e:library": "node tests/e2e/library-flows.mjs",+ "test:e2e:home": "node tests/e2e/home-bento.mjs","test:e2e:mobile": "node tests/e2e/no-horizontal-scroll.mjs","test:e2e:shell": "node tests/e2e/shell.mjs","test:e2e:tabs": "node tests/e2e/instant-tabs.mjs",diff --git a/public/previews/home/ba-after-640.avif b/public/previews/home/ba-after-640.avifnew file mode 100644index 00000000..39f08510Binary files /dev/null and b/public/previews/home/ba-after-640.avif differdiff --git a/public/previews/home/ba-after-960.avif b/public/previews/home/ba-after-960.avifnew file mode 100644index 00000000..5127d3daBinary files /dev/null and b/public/previews/home/ba-after-960.avif differdiff --git a/public/previews/home/ba-after-tall-360.avif b/public/previews/home/ba-after-tall-360.avifnew file mode 100644index 00000000..07278d28Binary files /dev/null and b/public/previews/home/ba-after-tall-360.avif differdiff --git a/public/previews/home/ba-after-tall-576.avif b/public/previews/home/ba-after-tall-576.avifnew file mode 100644index 00000000..ea58f463Binary files /dev/null and b/public/previews/home/ba-after-tall-576.avif differdiff --git a/public/previews/home/ba-before-640.avif b/public/previews/home/ba-before-640.avifnew file mode 100644index 00000000..17205b8aBinary files /dev/null and b/public/previews/home/ba-before-640.avif differdiff --git a/public/previews/home/ba-before-960.avif b/public/previews/home/ba-before-960.avifnew file mode 100644index 00000000..cc6326faBinary files /dev/null and b/public/previews/home/ba-before-960.avif differdiff --git a/public/previews/home/ba-before-tall-360.avif b/public/previews/home/ba-before-tall-360.avifnew file mode 100644index 00000000..a1aa2ae1Binary files /dev/null and b/public/previews/home/ba-before-tall-360.avif differdiff --git a/public/previews/home/ba-before-tall-576.avif b/public/previews/home/ba-before-tall-576.avifnew file mode 100644index 00000000..a7048325Binary files /dev/null and b/public/previews/home/ba-before-tall-576.avif differdiff --git a/public/previews/home/board-film.webp b/public/previews/home/board-film.webpnew file mode 100644index 00000000..8f48d9d4Binary files /dev/null and b/public/previews/home/board-film.webp differdiff --git a/public/previews/home/board-photo.webp b/public/previews/home/board-photo.webpnew file mode 100644index 00000000..3a388f60Binary files /dev/null and b/public/previews/home/board-photo.webp differdiff --git a/public/previews/home/catwalk-512.avif b/public/previews/home/catwalk-512.avifnew file mode 100644index 00000000..9688f848Binary files /dev/null and b/public/previews/home/catwalk-512.avif differdiff --git a/public/previews/home/image-4-480.avif b/public/previews/home/image-4-480.avifnew file mode 100644index 00000000..1a3b32e1Binary files /dev/null and b/public/previews/home/image-4-480.avif differdiff --git a/public/previews/home/image-4-768.avif b/public/previews/home/image-4-768.avifnew file mode 100644index 00000000..8ce05a72Binary files /dev/null and b/public/previews/home/image-4-768.avif differdiff --git a/scripts/gen-home-bento.mjs b/scripts/gen-home-bento.mjsnew file mode 100644index 00000000..bddeea0f--- /dev/null+++ b/scripts/gen-home-bento.mjs@@ -0,0 +1,138 @@+#!/usr/bin/env node+/**+ * Stills and data for Home's first screen (src/components/home/home-bento.tsx): small AVIF copies of pictures the site+ * already publishes, and the Audio tile's waveform, read from the Audio studio's own sample. Nothing is rendered: every+ * picture is a resized copy of a published one, so the tiles show exactly what the studios show.+ *+ * Output:+ * public/previews/home/catwalk-512.avif the catwalk clip's poster (its first frame), the video tile's still+ * public/previews/home/image-4-{480,768}.avif the Image studio's example 4+ * public/previews/home/ba-{before,after}-{640,960}.avif Colorize's before and after (4:3)+ * public/previews/home/ba-{before,after}-tall-{360,576}.avif the same pair, a 3:5 crop for the tall tile+ * public/previews/home/board-{photo,film}.webp the Canvas board's photo and a frame of its film, 168 px squares+ * src/lib/home-bento.generated.ts each file's content version, and the waveform+ *+ * The waveform: the Clean up voice sample decoded to 8 kHz mono, its loudness (RMS) in WAVE_BARS equal slices, scaled+ * so the loudest is 1, with a floor of WAVE_FLOOR so a pause still shows a bar. It is keyed by the sample's own+ * version, so a new sample needs a new run (tests/home-bento.test.ts checks it).+ *+ * Run: node scripts/gen-home-bento.mjs make every file and the generated module+ * node scripts/gen-home-bento.mjs --dry-run make and measure, write nothing+ * Needs ffmpeg on PATH (or FUOBE_FFMPEG).+ */+import { spawnSync } from "node:child_process";+import fs from "node:fs";+import path from "node:path";+import { fileURLToPath } from "node:url";+import sharp from "sharp";+import { contentVersion } from "./eval/lib/covers.mjs";++const ROOT = path.join(path.dirname(fileURLToPath(import.meta.url)), "..");+const PUBLIC = path.join(ROOT, "public");+const OUT_DIR = path.join(PUBLIC, "previews", "home");+const OUT_TS = path.join(ROOT, "src", "lib", "home-bento.generated.ts");+const DRY = process.argv.includes("--dry-run");++export const WAVE_BARS = 48;+export const WAVE_FLOOR = 0.12;+const WAVE_SOURCE = "/samples/clean-voice/clean.m4a";++/** The app the before/after tile shows (BENTO_BEFORE_AFTER in src/lib/home-bento.ts). */+const BA_APP = "app-colorize";+/**+ * The before/after tile is wide on a phone and a tablet (the 4:3 pair) and tall from lg: there it takes a 3:5 crop of+ * the 1280 pair around the subject, so it is never stretched past its own pixels and her face stays in the frame.+ */+const BA_TALL = { left: 352, top: 0, width: 576, height: 960 };+/** The Canvas board's two pictures (src/lib/home-bento.ts, BENTO_BOARD): the photo going in and a frame of the film. */+const BOARD_THUMBS = [+ { name: "board-photo.webp", from: "/examples/effect-pearl-earring/1/in-image.jpg" },+ { name: "board-film.webp", from: "/previews/presets/peak/effect-pearl-earring.jpg" },+];+/** Each copy: its name under previews/home, the published file it comes from, its width, and a crop where it has one. */+const STILLS = [+ { name: "catwalk-512.avif", from: "/previews/presets/motion-catwalk.jpg", width: 512 },+ { name: "image-4-480.avif", from: "/examples/image/4/out.jpg", width: 480 },+ { name: "image-4-768.avif", from: "/examples/image/4/out.jpg", width: 768 },+ ...["before", "after"].flatMap((side) => [+ ...[640, 960].map((width) => ({ name: `ba-${side}-${width}.avif`, from: `/previews/presets/ba/1280/${BA_APP}-${side}.jpg`, width })),+ ...[360, 576].map((width) => ({ name: `ba-${side}-tall-${width}.avif`, from: `/previews/presets/ba/1280/${BA_APP}-${side}.jpg`, width, crop: BA_TALL })),+ ]),+];+/** AVIF quality: the copies sit under a dark shade and are never shown larger than their own pixels. */+const QUALITY = 55;+/** The board's pictures show at 36 to 56 px: a 168 px square covers them on a 3x screen. */+const THUMB = 168;++const ffmpeg = (args) => {+ const r = spawnSync(process.env.FUOBE_FFMPEG ?? "ffmpeg", args, { maxBuffer: 64 << 20 });+ if (r.error?.code === "ENOENT") throw new Error("gen-home-bento needs ffmpeg on PATH");+ if (r.status !== 0) throw new Error(`ffmpeg failed: ${String(r.stderr).trim().split("\n").at(-1)}`);+ return r.stdout;+};++/** The sample's loudness in `bars` slices, 0..1, the loudest 1, none under `floor`. */+export function waveform(samples, bars = WAVE_BARS, floor = WAVE_FLOOR) {+ const per = Math.floor(samples.length / bars);+ const rms = Array.from({ length: bars }, (_, i) => {+ let sum = 0;+ for (let j = i * per; j < (i + 1) * per; j++) sum += samples[j] * samples[j];+ return Math.sqrt(sum / per);+ });+ const max = Math.max(...rms) || 1;+ return rms.map((r) => Math.max(floor, Math.round((r / max) * 1000) / 1000));+}++function readWave() {+ const raw = ffmpeg(["-v", "error", "-i", path.join(PUBLIC, WAVE_SOURCE), "-ac", "1", "-ar", "8000", "-f", "s16le", "-"]);+ const samples = new Int16Array(raw.buffer, raw.byteOffset, Math.floor(raw.length / 2));+ return { wave: waveform(Array.from(samples, (s) => s / 32768)), seconds: samples.length / 8000 };+}++async function main() {+ if (!DRY) fs.mkdirSync(OUT_DIR, { recursive: true });+ const versions = {};+ let total = 0;+ const jobs = [+ ...STILLS.map((s) => ({+ ...s,+ make: () => {+ const img = sharp(path.join(PUBLIC, s.from));+ return (s.crop ? img.extract(s.crop) : img).resize(s.width).avif({ quality: QUALITY, effort: 6 }).toBuffer();+ },+ })),+ ...BOARD_THUMBS.map((s) => ({ ...s, make: () => sharp(path.join(PUBLIC, s.from)).resize(THUMB, THUMB, { fit: "cover", position: "attention" }).webp({ quality: 72 }).toBuffer() })),+ ];+ for (const s of jobs) {+ const buf = await s.make();+ total += buf.length;+ const out = path.join(OUT_DIR, s.name);+ console.log(`${s.name} ${(buf.length / 1024).toFixed(1)} KB`);+ if (DRY) continue;+ // Only a changed picture is written, so its version (and URL) stays the same run to run.+ if (!fs.existsSync(out) || !fs.readFileSync(out).equals(buf)) fs.writeFileSync(out, buf);+ versions[`/previews/home/${s.name}`] = contentVersion([out]);+ }+ const { wave, seconds } = readWave();+ console.log(`stills ${(total / 1024).toFixed(1)} KB · waveform ${wave.length} bars over ${seconds.toFixed(2)} s`);+ if (DRY) return;+ const source = contentVersion([path.join(PUBLIC, WAVE_SOURCE)]);+ const body = `/**+ * Home's first screen (src/components/home/home-bento.tsx): the content version of each still made for it, and the+ * Audio tile's waveform, read from the Clean up voice sample (its version is \`wave.source\`). Generated by+ * scripts/gen-home-bento.mjs: run it again rather than editing.+ */+export const HOME_BENTO_MEDIA: Record<string, string> = ${JSON.stringify(versions, null, 2)};++export const HOME_BENTO_WAVE = {+ src: ${JSON.stringify(WAVE_SOURCE)},+ source: ${JSON.stringify(source)},+ seconds: ${Math.round(seconds * 100) / 100},+ bars: ${JSON.stringify(wave)},+};+`;+ fs.writeFileSync(OUT_TS, body);+ console.log(`wrote ${path.relative(ROOT, OUT_TS)}`);+}++if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) await main();diff --git a/src/app/(studio)/page.tsx b/src/app/(studio)/page.tsxindex 5fd78cec..516144d9 100644--- a/src/app/(studio)/page.tsx+++ b/src/app/(studio)/page.tsx@@ -6,10 +6,10 @@ import {LiveEditSection,MotionsSection,OpenSourceSection,- ShowcaseWall,StartSection,StudiosSection,} from "@/components/home/home-sections";+import { HomeBento } from "@/components/home/home-bento";import { HomeView } from "@/components/home-view";import { GoalRow } from "@/components/nav/goal-row";import { ASSIST_SUGGESTIONS } from "@/lib/assist";@@ -33,7 +33,7 @@ function goalTapNames(): Record<string, string> {/*** The catalog stays on the server: Home gets slim cards, the numbers it quotes (each computed, lib/home-showcase.ts),- * and what Start and the first-run guide cost. The sections under the wall are server components.+ * and what Start and the first-run guide cost. The first screen and the sections under the composer are server components.*/export default async function Page() {const home = await homeShowcase();@@ -43,7 +43,7 @@ export default async function Page() {chips={HOME_TRY}assist={{ label: "Plan a perfume ad with Assist", href: `/assist?prompt=${encodeURIComponent(ASSIST_SUGGESTIONS[0])}` }}goals={<GoalRow names={goalTapNames()} />}- wall={<ShowcaseWall wall={home.wall} />}+ bento={<HomeBento bento={home.bento} />}prices={starterPriceLine()}quotes={startQuotes()}>diff --git a/src/components/home-view.tsx b/src/components/home-view.tsxindex ee37074f..4f7ddd9e 100644--- a/src/components/home-view.tsx+++ b/src/components/home-view.tsx@@ -117,8 +117,8 @@ function FirstRunScript() {}/**- * "New creation" (the top bar, the Create sheet) opens Home with ?new=1: the composer starts empty and takes the- * focus, and the flag leaves the address. It reads the URL, so it sits under Suspense.+ * "New creation" (the top bar, the Create sheet) opens Home with ?new=1: the composer starts empty, comes into view+ * and takes the focus, and the flag leaves the address. It reads the URL, so it sits under Suspense.*/function NewCreation({ onNew }: { onNew: () => void }) {const router = useRouter();@@ -132,15 +132,16 @@ function NewCreation({ onNew }: { onNew: () => void }) {}/**- * Home: what Fuobe is, the composer, a few prompts to try, then the wall of real covers (`wall`) right under them.- * The sections below (`children`) are rendered on the server, so their words and pictures ship no script.+ * Home: the first screen (`bento`: the headline over a tile for every kind of media), then what Fuobe is, the+ * composer, a few prompts to try and the goals. The sections below (`children`) are rendered on the server, so their+ * words and pictures ship no script.*/export function HomeView({openModels,chips,assist,goals,- wall,+ bento,children,prices,quotes,@@ -152,7 +153,8 @@ export function HomeView({assist: { label: string; href: string };/** The goal row (each goal opens a band of its studios, one-tap presets and tools), right under the composer. */goals?: React.ReactNode;- wall: React.ReactNode;+ /** The first screen, above everything else: it holds the page's only h1 (home-bento.tsx). */+ bento?: React.ReactNode;children: React.ReactNode;/** What a first paid image and clip cost, for the first-run guide. */prices?: string;@@ -187,7 +189,7 @@ export function HomeView({const visitor = status?.viewer;// Only the studio's owner can use Assist: its chip takes the last Try chip's place once the owner is known.const owner = useIsOwner();- // A Try chip's prompt fills two lines on a phone and scrolls past that, so the chips and the wall under the+ // A Try chip's prompt fills two lines on a phone and scrolls past that, so the chips and the goals under the// composer stay where the thumb is; typing lets it grow again.const [chipFilled, setChipFilled] = useState(false);useEffect(() => {@@ -224,9 +226,13 @@ export function HomeView({const runsFor = status && mode.id !== "live" ? startLine(status, quotes?.[mode.id as "image" | "video" | "edit"], engine, mode.id as "image" | "video" | "edit") : null;const openModel = mode.id === "live" ? undefined : quotes?.[mode.id as "image" | "video" | "edit"]?.open?.name;const focusComposer = () => requestAnimationFrame(() => box.current?.focus());+ // The composer sits under the first screen: it comes into view, then takes the focus without the page jumping again.const startOver = useCallback(() => {setPrompt("");- requestAnimationFrame(() => box.current?.focus());+ requestAnimationFrame(() => {+ box.current?.scrollIntoView({ block: "center" });+ box.current?.focus({ preventScroll: true });+ });}, []);// A Try chip: its mode and prompt go in, the caret goes to the end, and nothing runs until Start.const tryChip = (c: TryChip) => {@@ -249,7 +255,8 @@ export function HomeView({<Suspense fallback={null}><NewCreation onNew={startOver} /></Suspense>- <div className="flex flex-col items-center pt-[3vh] text-center">+ {bento}+ <div className="mt-10 flex flex-col items-center text-center sm:mt-14"><ahref={FUOBE_REPO}target="_blank"@@ -266,9 +273,9 @@ export function HomeView({</span></span></a>- <h1 className="font-heading text-display text-balance sm:text-[44px]">+ <h2 className="font-heading text-[26px] leading-tight text-balance sm:text-[32px]"><span className="inline-block">A complete AI studio.</span> <span className="inline-block">Open source.</span>- </h1>+ </h2><p className="mt-2 text-[15px] text-pretty text-muted-foreground">{/* Before the status: the words a public studio's visitors get (the owner's own install corrects them in a moment). */}{!status || visitor || engineMode === "open"@@ -293,7 +300,6 @@ export function HomeView({}}ref={box}rows={2}- autoFocusaria-label="Describe what to create"placeholder={mode.placeholder}className={cn(@@ -331,7 +337,7 @@ export function HomeView({</div></div></div>- {/* Its line's height is kept from the first paint, so the chips and the wall under it don't move when it fills in. */}+ {/* Its line's height is kept from the first paint, so the chips and the goals under it don’t move when it fills in. */}{visitor && openModel && !visitor.gpu.connected ? (<p className="mt-2 min-h-[18px] text-[12px] text-muted-foreground">{visitor.kind === "guest" ? (@@ -437,8 +443,6 @@ export function HomeView({</div>)}- {wall}-{recent.data?.length ? (<Row title="Recent" href="/library" className="mt-12 sm:mt-16"><RecentStrip items={recent.data.slice(0, 6)} />diff --git a/src/components/home/bento-islands.tsx b/src/components/home/bento-islands.tsxnew file mode 100644index 00000000..efa4acb0--- /dev/null+++ b/src/components/home/bento-islands.tsx@@ -0,0 +1,312 @@+"use client";++import { Play, Zap } from "lucide-react";+import { useEffect, useRef, useState, useSyncExternalStore } from "react";+import { useNavUi } from "@/components/nav/nav-ui";+import { usePreviewPlayback, usePreviewsPaused } from "@/components/preset-preview";+import type { BentoPicture } from "@/lib/home-bento";+import { releaseVideo } from "@/lib/media-release";+import { browserPlaybackEnv } from "@/lib/preview-playback";+import { s } from "./home-bento-classes";++/*+ * The first screen's few islands (home-bento.tsx): the switch that lets it move, its two clips, the typing on the live+ * tile and the numbers tile's launcher. Everything else on it is HTML from the server.+ */++/** Whether the page has loaded (the clips wait for it) and whether the first screen may move now (BentoMotion). */+const motion = (() => {+ let loaded = false;+ let play = false;+ const subs = new Set<() => void>();+ const emit = () => subs.forEach((f) => f());+ return {+ subscribe(f: () => void) {+ subs.add(f);+ return () => void subs.delete(f);+ },+ loaded: () => loaded,+ play: () => play,+ setLoaded() {+ if (loaded) return;+ loaded = true;+ emit();+ },+ setPlay(b: boolean) {+ if (play === b) return;+ play = b;+ emit();+ },+ };+})();++const useLoaded = () => useSyncExternalStore(motion.subscribe, motion.loaded, () => false);+const usePlay = () => useSyncExternalStore(motion.subscribe, motion.play, () => false);++/** Runs `cb` once the page has loaded and the browser is idle: the first screen's stills come first. */+function afterLoad(cb: () => void): () => void {+ let id = 0;+ let cancelled = false;+ const idle = () => {+ if (cancelled) return;+ if (typeof requestIdleCallback === "function") id = requestIdleCallback(cb, { timeout: 2000 });+ else id = window.setTimeout(cb, 200);+ };+ if (document.readyState === "complete") idle();+ else window.addEventListener("load", idle, { once: true });+ return () => {+ cancelled = true;+ window.removeEventListener("load", idle);+ if (typeof cancelIdleCallback === "function") cancelIdleCallback(id);+ clearTimeout(id);+ };+}++/**+ * Lets the first screen move: data-play="1" on the section while it is at least 15 % on screen, the tab is visible, the+ * page has loaded and previews aren't paused (Pause previews); "0" once one of those stops holding, so every animation+ * freezes where it is. Under reduced motion or Save-Data it is never set, and everything rests on its still frame.+ */+export function BentoMotion({ target }: { target: string }) {+ const paused = usePreviewsPaused();+ useEffect(() => {+ const el = document.getElementById(target);+ if (!el) return;+ const reduced = window.matchMedia("(prefers-reduced-motion: reduce)");+ let inView = false;+ let loaded = motion.loaded();+ const update = () => {+ const on = loaded && inView && !document.hidden && !paused && !reduced.matches && !browserPlaybackEnv.saveData();+ if (on) el.dataset.play = "1";+ else if (el.dataset.play) el.dataset.play = "0";+ motion.setPlay(on);+ };+ const io = new IntersectionObserver(+ ([e]) => {+ inView = e.isIntersecting && e.intersectionRatio >= 0.15;+ update();+ },+ { threshold: [0, 0.15, 0.3] },+ );+ io.observe(el);+ const cancel = afterLoad(() => {+ loaded = true;+ motion.setLoaded();+ update();+ });+ document.addEventListener("visibilitychange", update);+ reduced.addEventListener("change", update);+ return () => {+ cancel();+ io.disconnect();+ document.removeEventListener("visibilitychange", update);+ reduced.removeEventListener("change", update);+ };+ }, [paused, target]);+ return null;+}++/**+ * A tile's clip, over its still: it joins the site's playback rules (preset-preview.tsx) once the page has loaded, so+ * it plays in view, at most a few at once, never under reduced motion, Save-Data or Pause previews, and a hover or+ * keyboard focus on its tile still plays it. Its source is set only when it first plays. Once started it stays mounted+ * and pauses on its frame. `progress`: a line along the bottom follows the clip; `glyph`: a play sign until it plays.+ */+export function BentoClip({ id, clip, progress, glyph }: { id: string; clip: string; progress?: boolean; glyph?: boolean }) {+ const loaded = useLoaded();+ const { ref, playing, handlers } = usePreviewPlayback<HTMLSpanElement>(id, loaded ? { video: clip } : {});+ const [started, setStarted] = useState(false);+ if (playing && !started) setStarted(true);+ const [ready, setReady] = useState(false);+ const video = useRef<HTMLVideoElement>(null);+ const bar = useRef<HTMLElement>(null);+ const on = useRef(handlers);+ useEffect(() => {+ on.current = handlers;+ });++ // The tile is the link: its keyboard focus plays the clip as a card's does.+ useEffect(() => {+ const a = ref.current?.closest("a");+ if (!a) return;+ const focus = () => on.current.onFocus({ currentTarget: a } as unknown as React.FocusEvent);+ const blur = () => on.current.onBlur();+ a.addEventListener("focus", focus);+ a.addEventListener("blur", blur);+ return () => {+ a.removeEventListener("focus", focus);+ a.removeEventListener("blur", blur);+ };+ }, [ref]);++ useEffect(() => {+ const v = video.current;+ if (!v) return;+ if (playing) void v.play().catch(() => {});+ else v.pause();+ }, [playing, started]);++ // The line follows the clip itself, a frame at a time while it plays: it can't drift from it.+ useEffect(() => {+ const v = video.current;+ const b = bar.current;+ if (!v || !b || !playing || !ready) return;+ let raf = 0;+ const tick = () => {+ if (v.duration > 0) b.style.transform = `scaleX(${v.currentTime / v.duration})`;+ raf = requestAnimationFrame(tick);+ };+ raf = requestAnimationFrame(tick);+ return () => cancelAnimationFrame(raf);+ }, [playing, ready]);++ useEffect(() => {+ const v = video.current;+ return () => releaseVideo(v);+ }, [started]);++ return (+ <span ref={ref} aria-hidden className={s.clip} onPointerEnter={handlers.onPointerEnter} onPointerLeave={handlers.onPointerLeave}>+ {started && <video ref={video} src={clip} muted loop playsInline preload="auto" data-ready={ready || undefined} onLoadedData={() => setReady(true)} />}+ {glyph && (+ <span className={s.playGlyph} data-on={(playing && ready) || undefined}>+ <Play className="size-6" fill="#fff" stroke="#fff" />+ </span>+ )}+ {progress && (+ <span className={s.progress}>+ <i ref={bar} />+ </span>+ )}+ </span>+ );+}++/** How long each part of the live tile's loop takes, in ms. */+const TYPE_MS = 55;+const FADE_MS = 320;+const HOLD_MS = 1400;+const BACK_MS = 250;++/**+ * The live tile: the Live edit session's own words typed one character at a time, each phrase followed by the picture+ * it made (a 320 ms crossfade), held, then the next phrase in its place; after the last, back to the first picture and+ * round again. Before the page moves (and under reduced motion) it shows the first picture and the first phrase whole.+ * The later pictures are fetched only when it first plays, while the first phrase holds.+ */+export function LiveTyping({ frames, phrases, sizes }: { frames: BentoPicture[]; phrases: string[]; sizes: string }) {+ const play = usePlay();+ const [text, setText] = useState(phrases[0]);+ const [shown, setShown] = useState(0);+ const [back, setBack] = useState(false);+ // The later pictures are asked for once it first plays: they load while the first phrase holds.+ const [fetched, setFetched] = useState(false);+ if (play && !fetched) setFetched(true);+ // The first phrase is already shown whole, so the loop starts at its end: its picture fades in, then phrase two types.+ const begun = useRef(false);+ const step = useRef({ phrase: 0, char: phrases[0].length, phase: "type" as "type" | "fade" | "hold" | "back" });++ useEffect(() => {+ if (!play) return;+ const st = step.current;+ let t = 0;+ const run = () => {+ const phrase = phrases[st.phrase];+ if (st.phase === "type") {+ if (st.char < phrase.length) {+ st.char += 1;+ setText(phrase.slice(0, st.char));+ t = window.setTimeout(run, TYPE_MS);+ return;+ }+ st.phase = "fade";+ setBack(false);+ setShown(st.phrase + 1);+ t = window.setTimeout(run, FADE_MS);+ return;+ }+ if (st.phase === "fade") {+ st.phase = "hold";+ t = window.setTimeout(run, HOLD_MS);+ return;+ }+ // The last phrase stays in the field until the next one's first character replaces it: it is never empty.+ if (st.phase === "hold") {+ if (st.phrase + 1 < phrases.length) {+ st.phrase += 1;+ st.char = 0;+ st.phase = "type";+ t = window.setTimeout(run, TYPE_MS);+ return;+ }+ st.phase = "back";+ setBack(true);+ setShown(0);+ t = window.setTimeout(run, BACK_MS + 400);+ return;+ }+ st.phrase = 0;+ st.char = 0;+ st.phase = "type";+ t = window.setTimeout(run, TYPE_MS);+ };+ // The first time, the first phrase holds a moment while the next pictures load; after that it carries on where it stopped.+ const wait = !begun.current ? HOLD_MS : st.phase === "type" ? TYPE_MS : 0;+ begun.current = true;+ t = window.setTimeout(run, wait);+ return () => clearTimeout(t);+ // The loop picks up where it stopped when the tile plays again.+ // eslint-disable-next-line react-hooks/exhaustive-deps+ }, [play]);++ return (+ <>+ {frames.map((f, i) =>+ i === 0 || fetched ? (+ <picture key={i} className={s.pic}>+ <source type="image/avif" srcSet={f.avif.map((a) => `${a.src} ${a.w}w`).join(", ")} sizes={sizes} />+ <img+ src={f.fallback}+ alt=""+ width={512}+ height={384}+ fetchPriority="low"+ decoding="async"+ draggable={false}+ className={`${s.fill} ${s.frame}`}+ data-on={i <= shown || undefined}+ data-back={back || undefined}+ />+ </picture>+ ) : null,+ )}+ <span aria-hidden className={s.pill}>+ <Zap className="size-3.5" />+ <span className={s.typed}>+ <span>{text}</span>+ </span>+ <span className={s.caret} />+ </span>+ </>+ );+}++/**+ * The numbers tile: a link to the Studios section, which opens every studio where it can (the launcher on a desktop,+ * the Studios sheet on a phone) instead. A modified click still follows the link.+ */+export function NumbersLink({ children, ...props }: React.ComponentProps<"a">) {+ const { openStudios } = useNavUi();+ return (+ <a+ {...props}+ onClick={(e) => {+ if (e.button !== 0 || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) return;+ e.preventDefault();+ openStudios();+ }}+ >+ {children}+ </a>+ );+}diff --git a/src/components/home/home-bento-classes.ts b/src/components/home/home-bento-classes.tsnew file mode 100644index 00000000..1d135cee--- /dev/null+++ b/src/components/home/home-bento-classes.ts@@ -0,0 +1,8 @@+/**+ * The class names of Home's first screen (home-bento.css), each with its hb- prefix. The sheet is global, as every+ * stylesheet in this app is (next.config.ts runs each .css file through Tailwind as plain CSS), so the prefix keeps its+ * names to itself.+ */+const NAMES = ["aside","audio","badge","before","bento","big","board","box","canvas","caret","clip","copy","corner","cta","edges","figures","fill","filmMark","foot","frame","grid","h1","head","image","kenburns","left","line1","line2","live","meta","node","nodeLabel","numbers","numbersFoot","numbersLine","out","pic","pill","playGlyph","playhead","progress","restore","right","shade","side","split","step","three","tile","title","tsx","typed","video","wave"] as const;++export const s = Object.fromEntries(NAMES.map((n) => [n, `hb-${n.replace(/[A-Z]/g, (c) => "-" + c.toLowerCase())}`])) as Record<(typeof NAMES)[number], string>;diff --git a/src/components/home/home-bento.css b/src/components/home/home-bento.cssnew file mode 100644index 00000000..9453b4e9--- /dev/null+++ b/src/components/home/home-bento.css@@ -0,0 +1,1028 @@+/*+ * Home's first screen (home-bento.tsx): a headline over a grid of tiles, one per kind of media. The sheet is global,+ * as every stylesheet here is, so each class starts with hb- (home-bento-classes.ts).+ *+ * Layout: grid areas per width, so every tile's box comes from the grid (aspect ratios on a phone, fixed rows on a+ * tablet, a height that fills the screen from lg), never from its media: nothing moves when a picture or clip loads.+ *+ * Motion: nothing moves until BentoMotion (bento-islands.tsx) sets data-play on the section: "1" while it is on+ * screen, the page has loaded and previews aren't paused; "0" once paused or scrolled away (the animations freeze where+ * they are). Without it (before load, reduced motion, Save-Data) every tile rests on its still frame.+ *+ * Accent: every glow, line, caret, dot and edge is the theme's --primary.+ */++.hb-bento {+ --bento-gap: 12px;+ --bento-accent: var(--primary);+ --bento-glow: color-mix(in oklch, var(--primary) 30%, transparent);+ --bento-head: 0px;+ /* PageShell's top padding is 48 px from md: the grid starts 24 px under the bar, as the design does. */+ scroll-margin-top: 1rem;+}+@media (min-width: 768px) {+ .hb-bento {+ margin-top: -1.5rem;+ }+}+@media (min-width: 1024px) {+ .hb-bento {+ --bento-gap: 14px;+ --bento-head: 6.5rem;+ }+}++/* ---------------------------------------------------------------- headline */++.hb-head {+ display: flex;+ align-items: flex-end;+ justify-content: space-between;+ gap: 2rem;+ margin-bottom: 16px;+}+@media (min-width: 768px) {+ .hb-head {+ margin-bottom: 20px;+ }+}+.hb-h1 {+ font-family: var(--font-heading);+ font-weight: 400;+ font-size: 30px;+ line-height: 1.06;+ letter-spacing: -0.01em;+ text-wrap: balance;+ margin: 0;+}+/* Two lines from md: "Make anything:" over the rest, which keeps to one line. */+@media (min-width: 768px) {+ .hb-h1 {+ font-size: 40px;+ line-height: 1.04;+ }+ .hb-line1,+ .hb-line2 {+ display: block;+ }+ .hb-line2 {+ white-space: nowrap;+ }+}+@media (min-width: 1024px) {+ .hb-h1 {+ font-size: 46px;+ }+}+@media (min-width: 1280px) {+ .hb-h1 {+ font-size: 50px;+ }+}+.hb-line2 {+ font-style: italic;+ color: color-mix(in oklch, var(--primary) 85%, var(--foreground));+}+.dark .hb-line2 {+ color: #b9adff;+}+.hb-aside {+ display: none;+ max-width: 340px;+ margin: 0 0 6px;+ font-size: 14px;+ line-height: 1.45;+ text-align: right;+ color: var(--muted-foreground);+ text-wrap: pretty;+}+@media (min-width: 1280px) {+ .hb-aside {+ display: block;+ }+}++/* ---------------------------------------------------------------- grid */++.hb-grid {+ display: grid;+ gap: var(--bento-gap);+ grid-template-columns: repeat(2, minmax(0, 1fr));+ grid-template-areas:+ "video video"+ "image three"+ "restore restore"+ "live audio"+ "canvas canvas"+ "numbers numbers";+}+@media (max-width: 767.98px) {+ .hb-video {+ aspect-ratio: 3 / 2;+ }+ .hb-image,+ .hb-three,+ .hb-live,+ .hb-audio {+ aspect-ratio: 1;+ }+ .hb-restore {+ aspect-ratio: 2 / 1;+ }+ .hb-canvas {+ aspect-ratio: 16 / 9;+ }+}+@media (min-width: 768px) {+ .hb-grid {+ grid-template-columns: repeat(3, minmax(0, 1fr));+ grid-template-rows: repeat(4, 210px) auto;+ grid-template-areas:+ "video video image"+ "video video three"+ "restore restore audio"+ "live canvas canvas"+ "numbers numbers numbers";+ }+}+@media (min-width: 1024px) {+ .hb-grid {+ grid-template-columns: repeat(4, minmax(0, 1fr));+ grid-template-rows: repeat(3, minmax(0, 1fr));+ height: clamp(520px, calc(var(--content-h) - var(--bento-head) - 6.5rem), 760px);+ grid-template-areas:+ "video video image audio"+ "video video three restore"+ "numbers live canvas restore";+ }+}+.hb-video {+ grid-area: video;+}+.hb-image {+ grid-area: image;+}+.hb-audio {+ grid-area: audio;+}+.hb-three {+ grid-area: three;+}+.hb-restore {+ grid-area: restore;+}+.hb-numbers {+ grid-area: numbers;+}+.hb-live {+ grid-area: live;+}+.hb-canvas {+ grid-area: canvas;+}++/* ---------------------------------------------------------------- a tile */++.hb-tile {+ position: relative;+ isolation: isolate;+ display: block;+ min-width: 0;+ overflow: hidden;+ border-radius: 14px;+ border: 1px solid rgb(255 255 255 / 8%);+ background: var(--media);+ color: #fff;+ text-decoration: none;+ /* Transparent, so the box-shadow ring shows; forced colours (Windows High Contrast) paint it instead. */+ outline: 2px solid transparent;+ outline-offset: 2px;+ container-type: inline-size;+ transition:+ border-color 0.25s ease,+ transform 0.25s ease,+ box-shadow 0.15s ease;+ -webkit-tap-highlight-color: transparent;+}+@media (hover: hover) {+ .hb-tile:hover {+ border-color: rgb(255 255 255 / 26%);+ transform: translateY(-2px);+ }+}+.hb-tile:focus-visible {+ box-shadow:+ 0 0 0 2px var(--background),+ 0 0 0 4px var(--ring);+}+@media (forced-colors: active) {+ .hb-tile:focus-visible {+ outline-color: CanvasText;+ }+}+.hb-fill {+ position: absolute;+ inset: 0;+ width: 100%;+ height: 100%;+ object-fit: cover;+ display: block;+}+.hb-pic {+ position: absolute;+ inset: 0;+ display: block;+}+/* White words read at 4.5:1 over any frame: the lower part of each tile is shaded. */+.hb-shade {+ position: absolute;+ inset: auto 0 0;+ height: 62%;+ background: linear-gradient(to top, rgb(0 0 0 / 90%), rgb(0 0 0 / 55%) 45%, transparent);+ pointer-events: none;+}+.hb-copy {+ position: absolute;+ left: 14px;+ right: 14px;+ bottom: 12px;+ pointer-events: none;+ text-shadow: 0 1px 2px rgb(0 0 0 / 35%);+}+.hb-meta {+ display: block;+ font-size: 10.5px;+ font-weight: 500;+ line-height: 1.35;+ letter-spacing: 0.08em;+ text-transform: uppercase;+ color: rgb(255 255 255 / 80%);+}+.hb-title {+ display: block;+ margin-top: 3px;+ font-family: var(--font-heading);+ font-size: 20px;+ line-height: 1.08;+ letter-spacing: -0.01em;+ text-wrap: balance;+}+.hb-cta {+ display: none;+ margin-top: 8px;+ align-items: center;+ gap: 6px;+ font-size: 13px;+ font-weight: 500;+ color: rgb(255 255 255 / 85%);+ transition: color 0.2s ease;+}+.hb-cta svg {+ transition: transform 0.2s ease;+}+.hb-tile:hover .hb-cta,+.hb-tile:focus-visible .hb-cta {+ color: #fff;+}+.hb-tile:hover .hb-cta svg,+.hb-tile:focus-visible .hb-cta svg {+ transform: translateX(2px);+}+/* A small tile (a phone's square) has no room for the link's words: an arrow in its corner says it opens. */+.hb-corner {+ position: absolute;+ top: 10px;+ right: 10px;+ display: grid;+ place-items: center;+ width: 26px;+ height: 26px;+ border-radius: 999px;+ background: rgb(0 0 0 / 45%);+ color: #fff;+ pointer-events: none;+}+/* A narrow tile (a phone's square) keeps to its title: the small line would wrap over the picture. */+@container (max-width: 199.98px) {+ .hb-meta {+ display: none;+ }+}+@container (min-width: 250px) {+ .hb-title {+ font-size: 24px;+ }+}+@container (min-width: 220px) {+ .hb-copy {+ left: 18px;+ right: 18px;+ bottom: 16px;+ }+ .hb-meta {+ font-size: 11px;+ }+ .hb-cta {+ display: inline-flex;+ }+ .hb-corner {+ display: none;+ }+}+@container (min-width: 360px) {+ .hb-title {+ font-size: 28px;+ }+}+@container (min-width: 460px) {+ .hb-copy {+ left: 26px;+ right: 26px;+ bottom: 26px;+ }+ .hb-video .hb-title {+ font-size: 40px;+ }+ .hb-meta.hb-big {+ font-size: 13px;+ letter-spacing: 0.02em;+ text-transform: none;+ }+}+@container (min-width: 540px) {+ .hb-video .hb-title {+ font-size: 44px;+ }+}++/*+ * From lg every tile's box is fixed by the grid, so a tile can be measured both ways: a short one (1024 x 768) drops+ * its small line over the title, and the canvas tile draws its board smaller, so nothing overlaps.+ */+@media (min-width: 1024px) {+ .hb-tile {+ container-type: size;+ }+}+@container (max-height: 200px) {+ .hb-meta {+ display: none;+ }+ .hb-board {+ width: min(200px, 100% - 28px);+ }+ .hb-node-label {+ font-size: 10px;+ }+}++/* ---------------------------------------------------------------- video */++.hb-badge {+ position: absolute;+ top: 14px;+ left: 14px;+ display: inline-flex;+ align-items: center;+ gap: 7px;+ height: 28px;+ padding: 0 11px;+ border-radius: 999px;+ background: rgb(13 13 15 / 72%);+ font-size: 11px;+ font-weight: 500;+ letter-spacing: 0.08em;+ text-transform: uppercase;+ pointer-events: none;+}+.hb-play-glyph {+ position: absolute;+ left: 50%;+ top: 42%;+ display: grid;+ place-items: center;+ width: 64px;+ height: 64px;+ margin: -32px 0 0 -32px;+ border-radius: 999px;+ background: rgb(13 13 15 / 55%);+ border: 1px solid rgb(255 255 255 / 35%);+ backdrop-filter: blur(6px);+ pointer-events: none;+ transition: opacity 0.4s ease;+}+.hb-play-glyph svg {+ margin-left: 3px;+}+.hb-play-glyph[data-on] {+ opacity: 0;+}+@container (min-width: 460px) {+ .hb-play-glyph {+ width: 76px;+ height: 76px;+ margin: -38px 0 0 -38px;+ }+}+.hb-progress {+ position: absolute;+ inset: auto 0 0;+ height: 3px;+ background: rgb(255 255 255 / 16%);+ pointer-events: none;+}+.hb-progress > i {+ display: block;+ height: 100%;+ background: var(--bento-accent);+ transform: scaleX(0);+ transform-origin: left;+ box-shadow: 0 0 10px var(--bento-glow);+}+.hb-clip {+ position: absolute;+ inset: 0;+}+.hb-clip video {+ position: absolute;+ inset: 0;+ width: 100%;+ height: 100%;+ object-fit: cover;+ transition: opacity 0.2s ease;+}+.hb-clip video:not([data-ready]) {+ opacity: 0;+}++/* ---------------------------------------------------------------- image: a slow push in */++.hb-kenburns {+ transform-origin: 50% 40%;+}+.hb-bento[data-play] .hb-kenburns {+ animation: bento-ken 16s ease-in-out infinite alternate;+ animation-play-state: paused;+}+.hb-bento[data-play="1"] .hb-kenburns {+ animation-play-state: running;+}+@keyframes bento-ken {+ from {+ transform: scale(1);+ }+ to {+ transform: scale(1.06);+ }+}++/* ---------------------------------------------------------------- audio: the sample's own loudness */++.hb-audio {+ background:+ radial-gradient(ellipse 85% 60% at 50% 32%, var(--bento-glow), transparent 72%),+ var(--media);+}+.hb-wave {+ position: absolute;+ left: 14px;+ right: 14px;+ top: 14%;+ height: 40%;+ display: flex;+ align-items: center;+ gap: 2px;+}+@container (min-width: 220px) {+ .hb-wave {+ left: 18px;+ right: 18px;+ top: 12%;+ }+}+.hb-wave > i {+ flex: 1 1 0;+ min-width: 1px;+ height: calc(var(--h) * 100%);+ border-radius: 2px;+ background: var(--bento-accent);+ opacity: 0.7;+}+.dark .hb-wave > i {+ background: color-mix(in oklch, var(--bento-accent) 70%, white);+}+.hb-bento[data-play] .hb-wave > i {+ opacity: 0.45;+ animation: bento-bar var(--wave-s, 8s) linear infinite;+ animation-delay: var(--d);+ animation-play-state: paused;+}+.hb-bento[data-play="1"] .hb-wave > i {+ animation-play-state: running;+}+@keyframes bento-bar {+ 0% {+ opacity: 1;+ transform: scaleY(1.06);+ }+ 3% {+ opacity: 1;+ transform: scaleY(0.94);+ }+ 7% {+ opacity: 1;+ transform: scaleY(1.04);+ }+ 14%,+ 100% {+ opacity: 0.45;+ transform: scaleY(1);+ }+}+.hb-playhead {+ position: absolute;+ inset: -8% 0;+ pointer-events: none;+ transform: translateX(-100%);+ opacity: 0;+}+.hb-playhead::after {+ content: "";+ position: absolute;+ top: 0;+ bottom: 0;+ right: 0;+ width: 2px;+ border-radius: 2px;+ background: #fff;+ box-shadow: 0 0 10px var(--bento-glow);+}+.hb-bento[data-play] .hb-playhead {+ opacity: 1;+ animation: bento-sweep var(--wave-s, 8s) linear infinite;+ animation-play-state: paused;+}+.hb-bento[data-play="1"] .hb-playhead {+ animation-play-state: running;+}+@keyframes bento-sweep {+ from {+ transform: translateX(-100%);+ }+ to {+ transform: translateX(0);+ }+}++/* ---------------------------------------------------------------- 3D: the clip turns the model on its own disc */++.hb-three .hb-shade {+ height: 45%;+}++/* ---------------------------------------------------------------- restore: a split that sweeps */++.hb-before {+ clip-path: inset(0 50% 0 0);+}+/* The line moves by transform, across the tile's own width (cqw: the tile is a container), so it never lays out again. */+.hb-split {+ position: absolute;+ top: 0;+ bottom: 0;+ left: 0;+ transform: translateX(50cqw);+ width: 2px;+ margin-left: -1px;+ background: #fff;+ box-shadow: 0 0 10px rgb(0 0 0 / 50%);+ pointer-events: none;+}+.hb-split > span {+ position: absolute;+ top: 40%;+ left: 50%;+ display: grid;+ place-items: center;+ width: 30px;+ height: 30px;+ margin: -15px 0 0 -15px;+ border-radius: 999px;+ background: #fff;+ color: #0d0d0f;+}+.hb-bento[data-play] .hb-before {+ animation: bento-wipe 9s ease-in-out infinite;+ animation-play-state: paused;+}+.hb-bento[data-play] .hb-split {+ animation: bento-split 9s ease-in-out infinite;+ animation-play-state: paused;+}+.hb-bento[data-play="1"] .hb-before,+.hb-bento[data-play="1"] .hb-split {+ animation-play-state: running;+}+@keyframes bento-wipe {+ 0%,+ 100% {+ clip-path: inset(0 50% 0 0);+ }+ 25% {+ clip-path: inset(0 28% 0 0);+ }+ 75% {+ clip-path: inset(0 72% 0 0);+ }+}+@keyframes bento-split {+ 0%,+ 100% {+ transform: translateX(50cqw);+ }+ 25% {+ transform: translateX(72cqw);+ }+ 75% {+ transform: translateX(28cqw);+ }+}+.hb-side {+ position: absolute;+ top: 12px;+ height: 24px;+ display: inline-flex;+ align-items: center;+ padding: 0 9px;+ border-radius: 999px;+ background: rgb(13 13 15 / 78%);+ font-size: 10.5px;+ font-weight: 500;+ letter-spacing: 0.08em;+ text-transform: uppercase;+ pointer-events: none;+}+.hb-side.hb-left {+ left: 12px;+}+.hb-side.hb-right {+ right: 12px;+}+/* The pair's framing: a phone's and a tablet's wide tile keeps her face in its upper half; from lg the tall crop is centred on her. */+.hb-restore .hb-fill {+ object-position: 50% 12%;+}+@media (min-width: 1024px) {+ .hb-restore .hb-fill {+ object-position: 50% 30%;+ }+}++/* ---------------------------------------------------------------- numbers */++.hb-numbers {+ display: flex;+ flex-direction: column;+ justify-content: space-between;+ gap: 14px;+ padding: 18px 18px 16px;+ background:+ linear-gradient(150deg, var(--bento-glow) 0%, transparent 62%),+ var(--media);+}+.hb-figures {+ display: grid;+ grid-template-columns: repeat(3, minmax(0, 1fr));+ gap: 10px;+ margin: 0;+}+.hb-figures > div {+ min-width: 0;+}+.hb-figures dd {+ margin: 0;+ font-family: var(--font-heading);+ font-size: clamp(30px, 17cqw, 54px);+ line-height: 1;+ font-variant-numeric: tabular-nums;+}+.hb-figures dt {+ margin-top: 4px;+ font-size: 12.5px;+ line-height: 1.3;+ color: rgb(255 255 255 / 78%);+}+.hb-figures > div {+ display: flex;+ flex-direction: column-reverse;+ justify-content: flex-end;+}+.hb-numbers-line {+ font-size: 13px;+ line-height: 1.45;+ color: rgb(255 255 255 / 72%);+ text-wrap: pretty;+}+.hb-numbers .hb-cta {+ display: flex;+ width: fit-content;+ margin-top: 6px;+}+.hb-numbers-line {+ display: block;+}+@media (min-width: 768px) and (max-width: 1023.98px) {+ .hb-numbers {+ flex-direction: row;+ align-items: flex-end;+ padding: 20px 24px;+ }+ .hb-figures {+ flex: 1 1 auto;+ max-width: 420px;+ }+ .hb-numbers-foot {+ max-width: 260px;+ text-align: right;+ }+ .hb-numbers-foot .hb-cta {+ margin-left: auto;+ }+}+/*+ * From lg the tile is a small square: each figure is a row, its number then its word on one line, the numbers as large+ * as the tile's height lets them be. The extra line shows only on a tile tall enough for it (1920 x 1080).+ */+@media (min-width: 1024px) {+ .hb-numbers {+ gap: 8px;+ }+ .hb-figures {+ grid-template-columns: auto minmax(0, 1fr);+ /* Each word comes before its number in the markup: dense puts the number back in its own row. */+ grid-auto-flow: row dense;+ align-items: baseline;+ column-gap: 10px;+ row-gap: clamp(2px, 2.5cqh, 8px);+ }+ .hb-figures > div {+ display: contents;+ }+ .hb-figures dd {+ grid-column: 1;+ font-size: clamp(26px, 19cqh, 48px);+ text-align: right;+ }+ .hb-figures dt {+ grid-column: 2;+ margin: 0;+ font-size: 13.5px;+ white-space: nowrap;+ overflow: hidden;+ text-overflow: ellipsis;+ }+ .hb-numbers-line {+ display: none;+ }+}+@container (min-height: 236px) {+ .hb-numbers-line {+ display: block;+ }+}++/* ---------------------------------------------------------------- live edit */++.hb-pill {+ position: absolute;+ top: 12px;+ left: 12px;+ max-width: calc(100% - 24px);+ /* A field, never an empty capsule: it keeps its width between phrases. */+ min-width: min(calc(100% - 24px), 150px);+ display: inline-flex;+ align-items: center;+ gap: 7px;+ height: 32px;+ padding: 0 11px;+ border-radius: 999px;+ background: rgb(13 13 15 / 82%);+ border: 1px solid rgb(255 255 255 / 16%);+ font-size: 12.5px;+ pointer-events: none;+}+.hb-pill > svg {+ flex: none;+ color: var(--bento-accent);+}+.dark .hb-pill > svg {+ color: color-mix(in oklch, var(--bento-accent) 60%, white);+}+/* The words: their end (where the caret is) always shows; a phrase longer than the pill slides left, as a field does. */+.hb-typed {+ display: flex;+ justify-content: flex-end;+ min-width: 0;+ margin-left: -8px;+ padding-left: 8px;+ overflow: hidden;+ white-space: nowrap;+ mask-image: linear-gradient(to right, transparent, #000 8px);+}+.hb-caret {+ flex: none;+ width: 2px;+ height: 15px;+ margin-left: 1px;+ background: var(--bento-accent);+}+.dark .hb-caret {+ background: color-mix(in oklch, var(--bento-accent) 55%, white);+}+/* The caret always shows; it blinks only while the tile plays. */+.hb-bento[data-play] .hb-caret {+ animation: bento-blink 1s step-end infinite;+ animation-play-state: paused;+}+.hb-bento[data-play="1"] .hb-caret {+ animation-play-state: running;+}+@keyframes bento-blink {+ 50% {+ opacity: 0;+ }+}+.hb-frame {+ transition: opacity 0.32s ease;+}+.hb-frame:not([data-on]) {+ opacity: 0;+}+.hb-frame[data-back] {+ transition-duration: 0.25s;+}++/* ---------------------------------------------------------------- canvas: the board, drawn */++.hb-canvas {+ background-color: var(--media);+ background-image: radial-gradient(rgb(255 255 255 / 9%) 1px, transparent 1px);+ background-size: 14px 14px;+}+/*+ * The board keeps its plan's shape (home-bento.tsx, BOARD: 260 x 88) and sits centred in the space above the tile's+ * words (the words take about 78 px at the foot of the tile).+ */+.hb-board {+ position: absolute;+ left: 50%;+ top: calc((100% - 78px) / 2);+ translate: -50% -50%;+ width: min(250px, 100% - 24px);+ aspect-ratio: 260 / 88;+ pointer-events: none;+}+@container (min-width: 440px) {+ .hb-board {+ width: 300px;+ }+}+.hb-node {+ position: absolute;+ display: block;+}+.hb-box {+ position: relative;+ display: block;+ aspect-ratio: 1;+ overflow: hidden;+ border-radius: 9px;+ background: #222228;+ border: 1px solid rgb(255 255 255 / 18%);+}+.hb-box img {+ position: absolute;+ inset: 0;+ width: 100%;+ height: 100%;+ object-fit: cover;+}+.hb-box.hb-out {+ border-color: var(--bento-accent);+ box-shadow: 0 0 16px var(--bento-glow);+}+.hb-film-mark {+ position: absolute;+ right: 4px;+ bottom: 4px;+ display: grid;+ place-items: center;+ width: 16px;+ height: 16px;+ border-radius: 999px;+ background: rgb(0 0 0 / 55%);+ color: #fff;+}+.hb-node-label {+ display: block;+ margin: 4px -10px 0;+ font-size: 10.5px;+ line-height: 1.2;+ color: rgb(255 255 255 / 82%);+ text-align: center;+ white-space: nowrap;+ overflow: hidden;+ text-overflow: ellipsis;+}+.hb-step {+ position: absolute;+ display: flex;+ align-items: center;+ gap: 5px;+ padding: 0 6px;+ border-radius: 7px;+ background: #222228;+ border: 1px solid rgb(255 255 255 / 18%);+ font-size: 10.5px;+ line-height: 1;+ color: rgb(255 255 255 / 88%);+ white-space: nowrap;+ overflow: hidden;+}+.hb-step > span {+ overflow: hidden;+ text-overflow: ellipsis;+}+.hb-step svg {+ flex: none;+ color: color-mix(in oklch, var(--bento-accent) 55%, white);+}+/* A narrow tile keeps the steps words whole: the icons step aside. */+@container (max-width: 259.98px) {+ .hb-step svg {+ display: none;+ }+}+.hb-edges {+ position: absolute;+ inset: 0;+ width: 100%;+ height: 100%;+ overflow: visible;+}+.hb-edges path {+ fill: none;+ stroke: var(--bento-accent);+ stroke-width: 1.6;+ opacity: 0.6;+}+.dark .hb-edges path {+ stroke: color-mix(in oklch, var(--bento-accent) 70%, white);+}+.hb-bento[data-play] .hb-edges path {+ opacity: 1;+ stroke-dasharray: 4 5;+ animation: bento-flow 1.2s linear infinite;+ animation-play-state: paused;+}+.hb-bento[data-play="1"] .hb-edges path {+ animation-play-state: running;+}+@keyframes bento-flow {+ to {+ stroke-dashoffset: -18;+ }+}++/* ---------------------------------------------------------------- the line under the grid */++.hb-foot {+ margin-top: 12px;+ display: flex;+ align-items: center;+ justify-content: space-between;+ gap: 12px;+ font-size: 12px;+ color: var(--muted-foreground);+}++/* Reduced motion: whatever data-play says, nothing moves by itself, and a hover doesn't lift a tile. */+@media (prefers-reduced-motion: reduce) {+ .hb-tile,+ .hb-frame,+ .hb-play-glyph {+ transition: none;+ }+ .hb-tile:hover {+ transform: none;+ }+ .hb-bento .hb-kenburns,+ .hb-bento .hb-wave > i,+ .hb-bento .hb-playhead,+ .hb-bento .hb-before,+ .hb-bento .hb-split,+ .hb-bento .hb-caret,+ .hb-bento .hb-edges path {+ animation: none !important;+ }+}diff --git a/src/components/home/home-bento.tsx b/src/components/home/home-bento.tsxnew file mode 100644index 00000000..9d7a0b78--- /dev/null+++ b/src/components/home/home-bento.tsx@@ -0,0 +1,239 @@+import { ArrowRight, ArrowUpRight, ChevronsLeftRight, Play, Sparkles, Video } from "lucide-react";+import { BentoClip, BentoMotion, LiveTyping, NumbersLink } from "@/components/home/bento-islands";+import { PausePreviews } from "@/components/home/home-islands";+import { IntentLink } from "@/components/intent-link";+import type { BentoPicture, BentoTile, HomeBento as Bento } from "@/lib/home-bento";+import { cn } from "@/lib/utils";+import { s } from "./home-bento-classes";+import "./home-bento.css";++/** How wide each tile's picture shows, per width (the grid's columns: home-bento.css). */+const SIZES = {+ video: "(min-width: 1024px) 562px, (min-width: 768px) 466px, 100vw",+ square: "(min-width: 1024px) 274px, (min-width: 768px) 227px, 50vw",+ /** The before/after tile: wide (its 4:3 pair) below lg; from lg it is tall and takes the pair's 3:5 crop (`tall`). */+ wide: "(min-width: 768px) 466px, 100vw",+ tall: "290px",+};+/** From lg the before/after tile is tall (home-bento.css). */+const TALL_MEDIA = "(min-width: 1024px)";++/**+ * A picture in AVIF where the browser takes it, its published JPEG or WebP where not; a picture with a `tall` crop+ * takes it from lg. Decorative: the tile's link names it.+ */+function Pic({+ pic,+ sizes,+ className,+ loading = "eager",+ fetchPriority,+}: {+ pic: BentoPicture;+ sizes: string;+ className?: string;+ loading?: "eager" | "lazy";+ fetchPriority?: "high" | "low";+}) {+ return (+ <picture className={s.pic}>+ {pic.tall && <source media={TALL_MEDIA} type="image/avif" srcSet={pic.tall.map((a) => `${a.src} ${a.w}w`).join(", ")} sizes={SIZES.tall} />}+ <source type="image/avif" srcSet={pic.avif.map((a) => `${a.src} ${a.w}w`).join(", ")} sizes={sizes} />+ <img+ src={pic.fallback}+ alt=""+ width={pic.avif.at(-1)!.w}+ height={Math.round((pic.avif.at(-1)!.w * 3) / 4)}+ loading={loading}+ fetchPriority={fetchPriority}+ decoding="async"+ draggable={false}+ className={cn(s.fill, className)}+ />+ </picture>+ );+}++/** A tile's words: its kind and how much of it, its title, and where it opens (or, on a small tile, an arrow). */+function Copy({ tile, bigMeta }: { tile: BentoTile; bigMeta?: boolean }) {+ return (+ <>+ <span aria-hidden className={s.shade} />+ <span aria-hidden className={s.copy}>+ {tile.meta && <span className={cn(s.meta, bigMeta && s.big)}>{tile.meta}</span>}+ <span className={s.title}>{tile.title}</span>+ <span className={s.cta}>+ {tile.cta} <ArrowRight className="size-3.5" />+ </span>+ </span>+ <span aria-hidden className={s.corner}>+ <ArrowUpRight className="size-3.5" />+ </span>+ </>+ );+}++/** One tile: the whole of it is one link, named by its kind, title and where it goes. */+function Tile({ tile, area, children, bigMeta }: { tile: BentoTile; area: string; children?: React.ReactNode; bigMeta?: boolean }) {+ return (+ <IntentLink href={tile.href} aria-label={tile.label} data-tile={tile.key} className={cn(s.tile, area)}>+ {children}+ <Copy tile={tile} bigMeta={bigMeta} />+ </IntentLink>+ );+}++/**+ * The canvas tile's board, drawn as the board itself runs: the photo goes in, the scene is set, the effect makes the+ * film, which comes out with a frame of the real film in it. Laid out on a 260 x 88 plan (BOARD), scaled to the tile:+ * the two steps stacked between the photo and the film, joined by curved links.+ */+const BOARD = { w: 260, h: 88, pic: { w: 52, y: 10 }, step: { x: 70, w: 120, h: 28, y: [4, 50] }, filmX: 208 } as const;+const pct = (v: number, of: number) => `${((v / of) * 100).toFixed(3)}%`;++/** One of the board's two pictures (its photo, its film), with its label under it. */+function BoardPicture({ style, node, out }: { style: React.CSSProperties; node: Bento["canvas"]["photo"]; out?: boolean }) {+ return (+ <span className={s.node} style={style}>+ <span className={cn(s.box, out && s.out)}>+ {/* eslint-disable-next-line @next/next/no-img-element */}+ <img src={node.thumb} alt="" width={168} height={168} decoding="async" fetchPriority="low" draggable={false} />+ {out && (+ <span className={s.filmMark}>+ <Play className="size-2.5" fill="currentColor" />+ </span>+ )}+ </span>+ <span className={s.nodeLabel}>{node.label}</span>+ </span>+ );+}++function CanvasBoard({ board }: { board: Bento["canvas"] }) {+ const { w, h, pic, step, filmX } = BOARD;+ const picBox = (x: number): React.CSSProperties => ({ left: pct(x, w), top: pct(pic.y, h), width: pct(pic.w, w) });+ const picMid = pic.y + pic.w / 2;+ const stepMid = (i: number) => step.y[i] + step.h / 2;+ const stepX = step.x + step.w / 2;+ const links = [+ `M${pic.w} ${picMid} C${pic.w + 14} ${picMid} ${step.x - 14} ${stepMid(0)} ${step.x} ${stepMid(0)}`,+ `M${stepX} ${step.y[0] + step.h} V${step.y[1]}`,+ `M${step.x + step.w} ${stepMid(1)} C${step.x + step.w + 14} ${stepMid(1)} ${filmX - 14} ${picMid} ${filmX} ${picMid}`,+ ];+ return (+ <span aria-hidden className={s.board}>+ <svg className={s.edges} viewBox={`0 0 ${w} ${h}`} preserveAspectRatio="none">+ {links.map((d) => (+ <path key={d} d={d} vectorEffect="non-scaling-stroke" />+ ))}+ </svg>+ <BoardPicture style={picBox(0)} node={board.photo} />+ {board.steps.map((n, i) => (+ <span key={n.id} className={s.step} style={{ left: pct(step.x, w), top: pct(step.y[i], h), width: pct(step.w, w), height: pct(step.h, h) }}>+ {i === 0 ? <Sparkles className="size-3" /> : <Video className="size-3" />}+ <span>{n.label}</span>+ </span>+ ))}+ <BoardPicture style={picBox(filmX)} node={board.film} out />+ </span>+ );+}++/**+ * Home's first screen: the page's headline over a grid of tiles, one per kind of media Fuobe makes, each a real+ * picture, clip or sound from the studio it opens. A server component: the words, numbers, links and stills are all+ * in the HTML; the clips, the typing, the motion switch and the numbers tile's launcher are small islands+ * (bento-islands.tsx). Nothing in it depends on who is looking.+ */+export function HomeBento({ bento }: { bento: Bento }) {+ const { tiles } = bento;+ return (+ <section id="home-bento" aria-labelledby="home-bento-title" className={s.bento}>+ <div className={s.head}>+ <h1 id="home-bento-title" className={s.h1}>+ <span className={s.line1}>Make anything:</span> <span className={s.line2}>From an idea to a finished film, in one place.</span>+ </h1>+ <p className={s.aside}>Film, stills, sound, 3D, live edits and whole pipelines. Each tile opens the studio that makes it.</p>+ </div>++ <div className={s.grid}>+ <Tile tile={tiles.video} area={s.video} bigMeta>+ <Pic pic={bento.video.poster} sizes={SIZES.video} fetchPriority="high" />+ <BentoClip id={bento.video.id} clip={bento.video.clip} progress glyph />+ <span aria-hidden className={s.badge}>+ <Video className="size-3.5" /> Video+ </span>+ </Tile>++ <Tile tile={tiles.image} area={s.image}>+ <Pic pic={bento.image} sizes={SIZES.square} className={s.kenburns} fetchPriority="low" />+ </Tile>++ <Tile tile={tiles.audio} area={s.audio}>+ <span aria-hidden className={s.wave} style={{ "--wave-s": `${bento.wave.seconds}s` } as React.CSSProperties}>+ {bento.wave.bars.map((h, i) => (+ <i key={i} style={{ "--h": h, "--d": `${((i / bento.wave.bars.length) * bento.wave.seconds).toFixed(3)}s` } as React.CSSProperties} />+ ))}+ <span className={s.playhead} />+ </span>+ </Tile>++ <Tile tile={tiles.threeD} area={s.three}>+ {/* eslint-disable-next-line @next/next/no-img-element */}+ <img src={bento.threeD.poster} alt="" width={512} height={384} loading="eager" fetchPriority="low" decoding="async" draggable={false} className={s.fill} />+ <BentoClip id={bento.threeD.id} clip={bento.threeD.clip} />+ </Tile>++ <Tile tile={tiles.restore} area={s.restore}>+ <Pic pic={bento.restore.after} sizes={SIZES.wide} fetchPriority="low" />+ <Pic pic={bento.restore.before} sizes={SIZES.wide} className={s.before} fetchPriority="low" />+ <span aria-hidden className={s.split}>+ <span>+ <ChevronsLeftRight className="size-4" />+ </span>+ </span>+ <span aria-hidden className={cn(s.side, s.left)}>+ Before+ </span>+ <span aria-hidden className={cn(s.side, s.right)}>+ After+ </span>+ </Tile>++ <NumbersLink href={tiles.numbers.href} aria-label={tiles.numbers.label} aria-haspopup="dialog" data-tile="numbers" className={cn(s.tile, s.numbers)}>+ <dl aria-hidden className={s.figures}>+ {bento.numbers.map((n) => (+ <div key={n.label}>+ <dt>{n.label}</dt>+ <dd>{n.value}</dd>+ </div>+ ))}+ </dl>+ <span aria-hidden className={s.numbersFoot}>+ <span className={s.numbersLine}>{bento.numbersLine}</span>{" "}+ <span className={s.cta}>+ {tiles.numbers.cta} <ArrowRight className="size-3.5" />+ </span>+ </span>+ </NumbersLink>++ <Tile tile={tiles.live} area={s.live}>+ <LiveTyping frames={bento.live.frames} phrases={bento.live.phrases} sizes={SIZES.square} />+ </Tile>++ <Tile tile={tiles.canvas} area={s.canvas}>+ <CanvasBoard board={bento.canvas} />+ </Tile>+ </div>++ <div className={s.foot}>+ <p className="min-w-0">+ <span className="sm:hidden">Rendered locally on ComfyUI, on one RTX 5090.</span>+ <span className="max-sm:hidden">Every preview on this page was rendered locally on ComfyUI, on one RTX 5090.</span>+ </p>+ <PausePreviews className="[@media(pointer:coarse)]:min-h-11 [@media(pointer:coarse)]:min-w-11" />+ </div>+ <BentoMotion target="home-bento" />+ </section>+ );+}diff --git a/src/components/home/home-islands.tsx b/src/components/home/home-islands.tsxindex 458adb6f..848bb947 100644--- a/src/components/home/home-islands.tsx+++ b/src/components/home/home-islands.tsx@@ -26,7 +26,7 @@ export function HomeRail({ className, children }: { className?: string; children}/** Stops every preview playing by itself, on every page, for this visit; a hover still plays one. */-export function PausePreviews() {+export function PausePreviews({ className }: { className?: string }) {const paused = usePreviewsPaused();const Icon = paused ? Play : Pause;const label = paused ? "Play previews" : "Pause previews";@@ -37,7 +37,10 @@ export function PausePreviews() {aria-label={label}title={label}// 44 px to tap: its hit area reaches past its 28 px circle.- className="relative inline-flex size-7 shrink-0 items-center justify-center gap-1.5 rounded-full border text-[12px] text-muted-foreground transition-colors after:absolute after:-inset-2 after:content-[''] hover:bg-accent hover:text-foreground sm:w-[8.5rem]"+ className={cn(+ "relative inline-flex size-7 shrink-0 items-center justify-center gap-1.5 rounded-full border text-[12px] text-muted-foreground transition-colors after:absolute after:-inset-2 after:content-[''] hover:bg-accent hover:text-foreground sm:w-[8.5rem]",+ className,+ )}><Icon className="size-3" /><span className="max-sm:hidden">{label}</span>diff --git a/src/components/home/home-sections.tsx b/src/components/home/home-sections.tsxindex f9cb105d..27ae6f51 100644--- a/src/components/home/home-sections.tsx+++ b/src/components/home/home-sections.tsx@@ -31,6 +31,7 @@ import { studioCount } from "@/lib/nav-model";import { staggered } from "@/lib/preview-playback";import { cn } from "@/lib/utils";import { plainTagline } from "@/lib/plain-tagline";+import type { PresetCardData } from "@/lib/preset-cards";/** Home's sections under the wall. Server components: their words, numbers and links ship as HTML, and only the@@ -156,7 +157,7 @@ export function ShowcaseWall({label = "What Fuobe makes",foot = true,}: {- wall: readonly { id: string; kind: string; caption: string; href: string; card: HomeShowcase["wall"][number]["card"] }[];+ wall: readonly { id: string; kind: string; caption: string; href: string; card: PresetCardData }[];label?: string;foot?: boolean;}) {diff --git a/src/lib/home-bento.generated.ts b/src/lib/home-bento.generated.tsnew file mode 100644index 00000000..c7a2a8d0--- /dev/null+++ b/src/lib/home-bento.generated.ts@@ -0,0 +1,27 @@+/**+ * Home's first screen (src/components/home/home-bento.tsx): the content version of each still made for it, and the+ * Audio tile's waveform, read from the Clean up voice sample (its version is `wave.source`). Generated by+ * scripts/gen-home-bento.mjs: run it again rather than editing.+ */+export const HOME_BENTO_MEDIA: Record<string, string> = {+ "/previews/home/catwalk-512.avif": "35a5ee32",+ "/previews/home/image-4-480.avif": "5a6d07a1",+ "/previews/home/image-4-768.avif": "ef9d1b4d",+ "/previews/home/ba-before-640.avif": "2c0698c9",+ "/previews/home/ba-before-960.avif": "68bab1a7",+ "/previews/home/ba-before-tall-360.avif": "8def3f0c",+ "/previews/home/ba-before-tall-576.avif": "8e2686ce",+ "/previews/home/ba-after-640.avif": "85e66bec",+ "/previews/home/ba-after-960.avif": "9b17b907",+ "/previews/home/ba-after-tall-360.avif": "403e1563",+ "/previews/home/ba-after-tall-576.avif": "29994802",+ "/previews/home/board-photo.webp": "47432641",+ "/previews/home/board-film.webp": "db007869"+};++export const HOME_BENTO_WAVE = {+ src: "/samples/clean-voice/clean.m4a",+ source: "8a1e9cfc",+ seconds: 8,+ bars: [0.442,0.504,0.279,0.12,0.141,0.64,0.655,0.757,0.12,1,0.441,0.189,0.903,0.725,0.549,0.147,0.336,0.482,0.415,0.58,0.711,0.12,0.12,0.702,0.451,0.439,0.201,0.12,0.12,0.805,0.555,0.738,0.777,0.759,0.339,0.429,0.524,0.488,0.634,0.973,0.931,0.329,0.737,0.718,0.61,0.388,0.491,0.527],+};diff --git a/src/lib/home-bento.ts b/src/lib/home-bento.tsnew file mode 100644index 00000000..7e7dcc8c--- /dev/null+++ b/src/lib/home-bento.ts@@ -0,0 +1,203 @@+/**+ * Home's first screen: a grid of every kind of media Fuobe makes, each tile a real picture, clip or sound from the+ * studio it opens (src/components/home/home-bento.tsx). Every number is read from the catalog and every picture is a+ * published file with its content version, so nothing here is typed in twice (tests/home-bento.test.ts).+ */+import "server-only";+import fs from "node:fs/promises";+import path from "node:path";+import { MODELS, getPreset, isListed } from "@/lib/catalog";+import { getTemplate } from "@/lib/catalog/canvas";+import { runsOn } from "@/lib/catalog/engines";+import type { ModelDef } from "@/lib/catalog/types";+import { EXAMPLE_MEDIA } from "@/lib/examples/media.generated";+import { HOME_BENTO_MEDIA, HOME_BENTO_WAVE } from "@/lib/home-bento.generated";+import type { Demo } from "@/lib/live/demo";+import { presetCover } from "@/lib/preset-covers";+import { PRESET_BEFORE_AFTER } from "@/lib/preset-before-after.generated";+import { templateCover } from "@/lib/template-covers";++/** The preset whose clip each moving tile plays (no other card on Home plays these: tests/home-showcase.test.ts). */+export const BENTO_CLIPS = { video: "motion-catwalk", threeD: "app-3d-rotation" } as const;+/** The Image studio's example the image tile shows and opens with (src/lib/examples/plan.json). */+export const BENTO_IMAGE_EXAMPLE = { id: "image.4", out: "/examples/image/4/out.jpg" };+/** The app the before/after tile shows and opens: black and white to colour reads at a glance. */+export const BENTO_BEFORE_AFTER = "app-colorize";+/** The Canvas board the canvas tile draws: the same film as /canvas's "What's a canvas?". */+export const BENTO_BOARD = "effect-chain-pearl-earring";+/** The Live edit steps the live tile plays: the session's first three changes (Home's Live edit section plays them all). */+export const BENTO_LIVE_STEPS = ["s0", "s1", "s2", "s3"];++/** Where each tile goes. Each label is the navigation's name for the place (or the app's own). */+export const BENTO_HREFS = {+ video: "/cinema",+ image: `/image?example=${BENTO_IMAGE_EXAMPLE.id}`,+ audio: "/audio",+ threeD: "/image-to-3d",+ restore: `/apps/${BENTO_BEFORE_AFTER}`,+ numbers: "#home-studios",+ live: "/live-edit?from=home",+ canvas: "/canvas",+} as const;++export type BentoKey = keyof typeof BENTO_HREFS;++/**+ * A picture in two widths: AVIF for the browsers that take it, the published JPEG for the rest. `tall`: a portrait+ * crop of it for a tile that is tall from lg (home-bento.tsx), so the picture is never stretched past its own pixels.+ */+export interface BentoPicture {+ avif: { src: string; w: number }[];+ fallback: string;+ tall?: { src: string; w: number }[];+}++export interface BentoTile {+ key: BentoKey;+ /** The small line over the title: what kind of media, and how much of it. */+ meta: string;+ title: string;+ /** The link's own words (the place it opens). */+ cta: string;+ href: string;+ /** What a screen reader reads for the whole tile. */+ label: string;+}++/** The numbers Home's first screen quotes, each from the catalog. */+export interface BentoFacts {+ /** Studios, counted as the navigation counts them (its Studios badge and the launcher say the same number). */+ studios: number;+ apps: number;+ effectsAndMotions: number;+ motions: number;+ openModels: number;+ imageModels: number;+ videoModels: number;+ models3d: number;+ soundTools: number;+}++/**+ * Open models a visitor can pick, of one kind (Home is the same page for everyone, and everyone runs open models). The+ * same test as modelCounts().open (src/lib/catalog/counts.ts), so the kinds add up to its total.+ */+export const openModelsOf = (kind: ModelDef["kind"], models: readonly ModelDef[] = MODELS) => models.filter((m) => isListed(m) && runsOn(m, "open") && m.kind === kind).length;++/** A file made by scripts/gen-home-bento.mjs, with its version. */+function made(file: string): string {+ const v = HOME_BENTO_MEDIA[file];+ if (!v) throw new Error(`Home's first screen names ${file}, which scripts/gen-home-bento.mjs didn't make`);+ return `${file}?v=${v}`;+}++/** A published example file with its version (src/lib/examples/media.generated.ts). */+function example(file: string): string {+ const m = EXAMPLE_MEDIA[file];+ if (!m) throw new Error(`Home's first screen names ${file}, which isn't a published example file`);+ return `${file}?v=${m.v}`;+}++/** The phrase typed before each step of the Live edit session, in its own words: every `type` since the last step. */+export function livePhrases(demo: Pick<Demo, "script">, steps = BENTO_LIVE_STEPS): string[] {+ const out: string[] = [];+ let typed = "";+ for (const s of demo.script) {+ if (s.type === "type") typed += s.text;+ else if (s.type === "frame" && !s.live && steps.includes(s.frame) && s.frame !== steps[0]) {+ out.push(typed.replace(/^[,\s]+/, ""));+ typed = "";+ }+ }+ return out;+}++async function readDemo(): Promise<Demo> {+ return JSON.parse(await fs.readFile(path.join(process.cwd(), "public", "previews", "live-edit", "demo.json"), "utf8")) as Demo;+}++/**+ * What the canvas tile draws: the board's nodes in order (its photo, its steps, its film), each with its label; the+ * photo and the film show the board's own pictures (scripts/gen-home-bento.mjs makes their small copies).+ */+function board() {+ const t = getTemplate(BENTO_BOARD);+ if (!t || !templateCover("canvas", BENTO_BOARD)) throw new Error(`Home's canvas tile names ${BENTO_BOARD}, which has no board or cover`);+ const nodes = t.build("open").nodes.map((n) => ({+ id: n.id,+ label: n.data.label ?? n.id,+ kind: n.type === "image-input" ? ("photo" as const) : n.type === "output" ? ("film" as const) : ("step" as const),+ }));+ const photo = nodes.find((n) => n.kind === "photo");+ const film = nodes.find((n) => n.kind === "film");+ const steps = nodes.filter((n) => n.kind === "step");+ if (!photo || !film || steps.length !== 2) throw new Error(`Home's canvas tile draws a photo, two steps and a film; ${BENTO_BOARD} has another shape`);+ return {+ photo: { ...photo, thumb: made("/previews/home/board-photo.webp") },+ steps,+ film: { ...film, thumb: made("/previews/home/board-film.webp") },+ };+}++/** Everything the first screen shows, computed once per build with the rest of Home (homeShowcase). */+export async function homeBento(f: BentoFacts) {+ const video = presetCover(BENTO_CLIPS.video);+ const threeD = presetCover(BENTO_CLIPS.threeD);+ const restore = getPreset(BENTO_BEFORE_AFTER);+ const baV = PRESET_BEFORE_AFTER[BENTO_BEFORE_AFTER];+ if (!video?.video || !threeD?.video || !restore || !baV) throw new Error("Home's first screen names a clip or an app without its published media");+ const demo = await readDemo();+ const frame = (id: string) => {+ const fr = demo.frames[id];+ if (!fr?.small || !fr.mid || !fr.webp) throw new Error(`Home's live tile names frame ${id}, which the Live edit session doesn't have`);+ return { avif: [{ src: fr.small, w: 512 }, { src: fr.mid, w: 768 }], fallback: fr.webp } satisfies BentoPicture;+ };+ const restoreSide = (side: "before" | "after"): BentoPicture => ({+ avif: [640, 960].map((w) => ({ src: made(`/previews/home/ba-${side}-${w}.avif`), w })),+ tall: [360, 576].map((w) => ({ src: made(`/previews/home/ba-${side}-tall-${w}.avif`), w })),+ fallback: `/previews/presets/ba/960/${BENTO_BEFORE_AFTER}-${side}.jpg?v=${baV}`,+ });+ const tile = (key: BentoKey, kind: string, meta: string, title: string, cta: string): BentoTile => ({+ key,+ meta,+ title,+ cta,+ href: BENTO_HREFS[key],+ label: `${kind}: ${title}. ${cta}`,+ });+ return {+ facts: f,+ tiles: {+ video: tile("video", "Video", `${f.videoModels} video models · ${f.motions} camera moves`, "Films, ads and shorts", "Open Cinema Studio"),+ image: tile("image", "Image", `Image · ${f.imageModels} models`, "Portraits and campaigns", "Open Image"),+ audio: tile("audio", "Audio", `Audio · ${f.soundTools} sound tools`, "Voice, music, sound effects", "Open Audio"),+ threeD: tile("threeD", "3D", `3D · ${f.models3d} models`, "Spin it in 3D", "Open Image to 3D"),+ restore: tile("restore", "Before and after", `One of ${f.apps} apps`, "Bring an old photo to color", `Open ${restore.name}`),+ numbers: {+ ...tile("numbers", "Studios", "", "Every studio, app and effect", "All studios"),+ // Read as the numbers it shows, and say that it opens the list of studios in place.+ label: `${f.studios} studios, ${f.apps} apps, ${f.effectsAndMotions} effects and camera moves. Opens all studios`,+ },+ live: tile("live", "Live edit", "Live edit", "Type it, watch it change", "Open Live edit"),+ canvas: tile("canvas", "Canvas", "Canvas", "Chain any step, end to end", "Open Canvas"),+ },+ video: { id: BENTO_CLIPS.video, poster: { avif: [{ src: made("/previews/home/catwalk-512.avif"), w: 512 }], fallback: video.poster } satisfies BentoPicture, clip: video.video },+ image: {+ avif: [480, 768].map((w) => ({ src: made(`/previews/home/image-4-${w}.avif`), w })),+ fallback: example(BENTO_IMAGE_EXAMPLE.out),+ } satisfies BentoPicture,+ threeD: { id: BENTO_CLIPS.threeD, poster: threeD.poster, clip: threeD.video },+ restore: { before: restoreSide("before"), after: restoreSide("after") },+ wave: { bars: HOME_BENTO_WAVE.bars, seconds: HOME_BENTO_WAVE.seconds },+ live: { frames: BENTO_LIVE_STEPS.map(frame), phrases: livePhrases(demo) },+ canvas: board(),+ numbers: [+ { value: f.studios, label: "studios" },+ { value: f.apps, label: "apps" },+ { value: f.effectsAndMotions, label: "effects & moves" },+ ],+ numbersLine: `Plus ${f.openModels} open models for pictures, video, sound and 3D.`,+ };+}++export type HomeBento = Awaited<ReturnType<typeof homeBento>>;diff --git a/src/lib/home-showcase.ts b/src/lib/home-showcase.tsindex 1e4d4448..5bed9104 100644--- a/src/lib/home-showcase.ts+++ b/src/lib/home-showcase.ts@@ -1,5 +1,5 @@/**- * What Home shows below the composer: which presets, studios, models and skills, and every number it quotes, read+ * What Home shows: which presets, studios, models and skills, and every number it quotes, read* from the catalog, the ComfyUI manifest and the skills folder, never typed in. Server only: the page gets slim* cards and strings, and the catalog stays here (tests/home-showcase.test.ts checks every id and number).*/@@ -13,6 +13,8 @@ import { CAMERA_MOVES } from "@/lib/catalog/cinema";import { TEMPLATES } from "@/lib/catalog/marketing";import type { ModelDef } from "@/lib/catalog/types";import type { Manifest } from "@/lib/comfy";+import { homeBento, openModelsOf } from "@/lib/home-bento";+import { studioCount } from "@/lib/nav-model";import { HUB_MODES } from "@/lib/hubs";import { modelHref } from "@/lib/palette-index";import { cacheLife } from "next/cache";@@ -21,8 +23,8 @@ import { PRESET_BEFORE_AFTER } from "@/lib/preset-before-after.generated";import { onPeak, thumbOf, type PresetCardData } from "@/lib/preset-cards";/**- * The wall under the composer: the first pictures a visitor sees, each with what it does, in a line that fits a- * phone's tile (HOME_CAPTION_MAX.wall).+ * Captions and kinds for these presets' tiles elsewhere (a studio's row of examples reads them: studio-examples.ts), in+ * a line that fits a phone's tile (HOME_CAPTION_MAX.wall). Home itself opens on its first screen's grid (home-bento.ts).*/export const HOME_WALL = [{ id: "motion-crane-up", kind: "Camera motion", caption: "Rises over a pink lake" },@@ -104,7 +106,8 @@ export const HOME_STUDIOS: { href: string; id?: string; line: (f: HomeFacts) =>{ href: "/mixed-media", id: "effect-paper", line: (f) => `Redraw a clip as collage, paper or paint, in ${f.mixedLooks} looks.` },{ href: "/motion-control", id: "motion-static", line: () => "Give anyone the moves from any clip." },{ href: "/audio", id: "app-clean-up-voice", line: () => "Voices, music and sound for any clip, made or split apart." },- { href: "/image-to-3d", id: "app-3d-rotation", line: () => "A photo or a sentence to a 3D model you can spin." },+ // The collectible figure: the first screen's 3D tile plays the turning gown (home-bento.ts), and a clip plays in one place.+ { href: "/image-to-3d", id: "app-3d-figure", line: () => "A photo or a sentence to a 3D model you can spin." },];/** Destinations with a section of their own on Home, so they aren't pills as well. */@@ -143,8 +146,8 @@ export const HOME_NEW_OPEN = [];/**- * The chips under the composer. Each fills it with a prompt that looks like a cover on this page (Glam, FPV Drone- * and Crane Up on the wall, Relight under Apps); nothing runs until Start. Whoever runs the studio gets Assist's chip in+ * The chips under the composer. Each fills it with a prompt that looks like a picture on this page (the gold sequins+ * on the first screen, Relight under Apps); nothing runs until Start. Whoever runs the studio gets Assist's chip in* place of the last (home-view.tsx): only the owner can use Assist.*/export const HOME_TRY = [@@ -202,7 +205,7 @@ export function homeCard(id: string): PresetCardData {export const presetHref = (id: string) => (id.startsWith("app-") ? `/apps/${id}` : `/video?preset=${id}`);const navItems = (label: string) => NAV.find((g) => g.label === label)?.items ?? [];-const navLabel = (href: string) => [...navItems("Create"), ...navItems("Studios")].find((i) => i.href === href)?.label ?? href;+export const navLabel = (href: string) => [...navItems("Create"), ...navItems("Studios")].find((i) => i.href === href)?.label ?? href;/** The navigation's places to create, but Home. */export const homeDestinations = () => [...navItems("Create"), ...navItems("Studios")].filter((i) => i.href !== "/");@@ -260,7 +263,7 @@ async function readSkills() {const captioned = ({ id, caption }: { id: string; caption: string }) => ({ card: homeCard(id), caption });/**- * Everything Home shows below the composer, computed once per build (the page stays prerendered): all of it changes+ * Everything Home shows, from its first screen down, computed once per build (the page stays prerendered): all of it changes* only with a deploy, so it's kept for as long as Next keeps anything ("max").*/export async function homeShowcase() {@@ -289,9 +292,20 @@ export async function homeShowcase() {audioTools: HUB_MODES.audio.length,skills: skills.count,};+ const bento = await homeBento({+ studios: studioCount(),+ apps: facts.apps,+ effectsAndMotions: facts.effects + facts.motions,+ motions: facts.motions,+ openModels: facts.openModels,+ imageModels: openModelsOf("image"),+ videoModels: openModelsOf("video"),+ models3d: openModelsOf("model3d"),+ soundTools: facts.audioTools,+ });return {facts,- wall: HOME_WALL.map((t) => ({ ...t, card: homeCard(t.id), href: presetHref(t.id) })),+ bento,effects: HOME_EFFECTS.map(captioned),motions: HOME_MOTIONS.map(captioned),reveals: HOME_REVEALS.map(captioned),diff --git a/tests/__snapshots__/home-studios.html b/tests/__snapshots__/home-studios.htmlindex 6ad7d89d..d80eed06 100644--- a/tests/__snapshots__/home-studios.html+++ b/tests/__snapshots__/home-studios.html@@ -160,7 +160,7 @@<a class="group/studio flex min-w-0 flex-col gap-2 rounded-xl outline-none focus-visible:ring-2 focus-visible:ring-ring" href="/image-to-3d"><div class="relative isolate aspect-[4/3] overflow-hidden rounded-lg bg-muted"><div class="absolute inset-0 ease-out motion-safe:transition-transform motion-safe:duration-[400ms] motion-safe:group-hover/studio:scale-[1.03]">-<img src="/previews/presets/peak/app-3d-rotation.jpg?v=011b454a" srcSet="/previews/presets/peak/thumbs/app-3d-rotation.jpg?v=011b454a 320w, /previews/presets/peak/app-3d-rotation.jpg?v=011b454a 512w" sizes="(min-width: 1024px) 25vw, (min-width: 640px) 50vw, 64vw" alt="" width="512" height="384" draggable="false" loading="lazy" decoding="async" class="absolute inset-0 size-full object-cover" aria-hidden="true"/>+<img src="/previews/presets/peak/app-3d-figure.jpg?v=3754dbe0" srcSet="/previews/presets/peak/thumbs/app-3d-figure.jpg?v=3754dbe0 320w, /previews/presets/peak/app-3d-figure.jpg?v=3754dbe0 512w" sizes="(min-width: 1024px) 25vw, (min-width: 640px) 50vw, 64vw" alt="" width="512" height="384" draggable="false" loading="lazy" decoding="async" class="absolute inset-0 size-full object-cover" aria-hidden="true"/></div></div><div class="min-w-0 px-0.5">diff --git a/tests/e2e/home-bento.mjs b/tests/e2e/home-bento.mjsnew file mode 100644index 00000000..67e4f6a1--- /dev/null+++ b/tests/e2e/home-bento.mjs@@ -0,0 +1,410 @@+// Home's first screen in a real browser (src/components/home/home-bento.tsx). Run it on a production server+// (`next build`, then `next start -p <port>`): the weight and layout-shift numbers mean little on a dev server.+//+// Usage: node tests/e2e/home-bento.mjs [appUrl] [--shots <dir>] [--weight-only] (pnpm test:e2e:home)+// E2E_OWNER_PASSWORD: the studio's password, when it has one; the owner's pass signs in with it. Without one the+// studio is the owner's, and the guest's pass is skipped.+// --weight-only: only measure what the first screen downloads (to compare another build, such as main's).+//+// 1. Every width (390, 768, 1024, 1280, 1440, 1920), light and dark, as a guest and as the owner: no sideways scroll,+// one h1, the headline (two lines from 768, its second line whole), and the first screen holds what it should+// (a phone: the video tile and the three under it; from 1024: all eight). A picture of each (--shots), and a contact+// sheet of them all.+// 2. Layout shift under 0.01 at 390 and 1440, through a load and a scroll to the bottom and back.+// 3. Every tile's link answers 200, and the numbers tile opens every studio (the launcher; a phone's sheet).+// 4. Reduced motion and Save-Data: no clip is fetched or played, nothing moves by itself (the split rests at 50 %, the+// live words stay), and the tiles keep their stills.+// 5. Pause previews stops the catwalk and freezes every animation; pressed again, they go on.+// 6. Weight: what the page downloads before `load` (clips aside), at 390 and 1440, reported; the first screen's own+// stills stay under 280 KB.+// 7. The composer: /?new=1 brings it into view with the focus; a plain visit stays at the top (no autofocus jump).+// 8. Every tile is a named link, and Tab reaches them in the grid's reading order with a visible ring.+import assert from "node:assert/strict";+import fs from "node:fs";+import path from "node:path";+import { createRequire } from "node:module";+import { DESKTOP, launch, PHONE, root } from "./_browser.mjs";++const args = process.argv.slice(2);+const app = (args.find((a, i) => !a.startsWith("--") && args[i - 1] !== "--shots") ?? "http://localhost:3620").replace(/\/$/, "");+const shotsDir = args.includes("--shots") ? args[args.indexOf("--shots") + 1] : undefined;+const weightOnly = args.includes("--weight-only");+if (shotsDir) fs.mkdirSync(shotsDir, { recursive: true });++const browser = await launch();+const failures = [];+const notes = [];+const check = (name, ok, detail = "") => {+ console.log(`${ok ? "ok " : "FAIL"} ${name}${detail ? ` (${detail})` : ""}`);+ if (!ok) failures.push(`${name} ${detail}`);+};++const WIDTHS = [+ { w: 390, h: 844, phone: true },+ { w: 768, h: 1024 },+ { w: 1024, h: 768 },+ { w: 1280, h: 800 },+ { w: 1440, h: 900 },+ { w: 1920, h: 1080 },+];+const TILES = ["video", "image", "audio", "threeD", "restore", "numbers", "live", "canvas"];+const HEADLINE = "Make anything: From an idea to a finished film, in one place.";++/** A context as `who`; null when that viewer can't be had here (a guest needs a studio with a password). */+async function context(who, opts) {+ const ctx = await browser.newContext(opts);+ if (who === "owner" && process.env.E2E_OWNER_PASSWORD) {+ const r = await ctx.request.post(`${app}/api/auth/login`, { data: { password: process.env.E2E_OWNER_PASSWORD } });+ assert.ok(r.ok(), "the owner signs in");+ }+ if (who === "guest" && !process.env.E2E_OWNER_PASSWORD) {+ await ctx.close();+ return null;+ }+ return ctx;+}++const viewportOpts = (v, extra = {}) => ({+ ...(v.phone ? PHONE : {}),+ viewport: { width: v.w, height: v.h },+ deviceScaleFactor: v.phone ? 3 : v.w >= 1440 ? 2 : 1,+ ...extra,+});++async function open(page, url = "/") {+ await page.goto(app + url, { waitUntil: "load", timeout: 90_000 });+ await page.locator("#home-bento h1").waitFor({ timeout: 20_000 });+}++/** The first screen's layout, read in the page. */+const layout = (page) =>+ page.evaluate((tiles) => {+ const box = (el) => {+ const r = el.getBoundingClientRect();+ return { top: r.top, bottom: r.bottom, left: r.left, right: r.right, w: r.width, h: r.height };+ };+ const h1 = document.querySelector("#home-bento h1");+ const line2 = h1.querySelector("span:last-child");+ const lh = parseFloat(getComputedStyle(h1).lineHeight);+ return {+ h1s: document.querySelectorAll("h1").length,+ text: h1.textContent.replace(/\s+/g, " ").trim(),+ h1Lines: Math.round(h1.getBoundingClientRect().height / lh),+ line2Lines: Math.round(line2.getBoundingClientRect().height / lh),+ line2Italic: getComputedStyle(line2).fontStyle,+ line2Color: getComputedStyle(line2).color,+ scroll: [document.documentElement.scrollWidth, document.documentElement.clientWidth],+ vh: innerHeight,+ tiles: Object.fromEntries(tiles.map((t) => [t, box(document.querySelector(`#home-bento [data-tile="${t}"]`))])),+ dark: document.documentElement.classList.contains("dark"),+ };+ }, TILES);++// ------------------------------------------------------------------------------------------- 1. every width+const shots = [];+if (!weightOnly)+ for (const who of ["guest", "owner"]) {+ for (const scheme of ["light", "dark"]) {+ for (const v of WIDTHS) {+ const ctx = await context(who, viewportOpts(v, { colorScheme: scheme }));+ if (!ctx) {+ if (scheme === "light" && v.w === 390) console.log("- (skipped: the guest pass needs a studio with a password, E2E_OWNER_PASSWORD)");+ continue;+ }+ const page = await ctx.newPage();+ await open(page);+ await page.waitForTimeout(1500);+ const l = await layout(page);+ const tag = `${who} ${scheme} ${v.w}`;+ check(`${tag}: no sideways scroll`, l.scroll[0] === l.scroll[1], l.scroll.join(" vs "));+ check(`${tag}: one h1, the headline`, l.h1s === 1 && l.text === HEADLINE, `${l.h1s} · ${l.text}`);+ check(`${tag}: theme`, l.dark === (scheme === "dark"));+ if (v.w >= 768) check(`${tag}: headline on two lines, the second whole and italic`, l.h1Lines === 2 && l.line2Lines === 1 && l.line2Italic === "italic", `${l.h1Lines}/${l.line2Lines}`);+ if (v.phone) {+ const bottom = l.vh - 64;+ const first = ["video", "image", "threeD", "restore"];+ const out = first.filter((t) => l.tiles[t].top < 0 || l.tiles[t].bottom > bottom);+ check(`${tag}: the video tile and three more on the first screen`, out.length === 0, first.map((t) => `${t} ${Math.round(l.tiles[t].bottom)}`).join(", ") + ` ≤ ${bottom}`);+ check(`${tag}: every tile at least 44 px to tap`, TILES.every((t) => l.tiles[t].w >= 44 && l.tiles[t].h >= 44));+ }+ if (v.w >= 1024) {+ const out = TILES.filter((t) => l.tiles[t].bottom > l.vh || l.tiles[t].top < 0);+ check(`${tag}: all eight tiles on the first screen`, out.length === 0, out.join(", "));+ }+ if (shotsDir) {+ const f = path.join(shotsDir, `${who}-${scheme}-${v.w}.png`);+ await page.screenshot({ path: f });+ shots.push({ f, who, scheme, w: v.w });+ }+ await ctx.close();+ }+ }+ }++// ------------------------------------------------------------------------------------------- 2. layout shift+async function cls(v) {+ const ctx = await browser.newContext(viewportOpts(v));+ const page = await ctx.newPage();+ await page.addInitScript(() => {+ window.__cls = 0;+ window.__shifts = [];+ new PerformanceObserver((list) => {+ for (const e of list.getEntries())+ if (!e.hadRecentInput) {+ window.__cls += e.value;+ window.__shifts.push({ v: e.value, at: Math.round(e.startTime), nodes: (e.sources ?? []).map((s) => s.node?.id || s.node?.className?.toString?.().slice(0, 60) || s.node?.nodeName) });+ }+ }).observe({ type: "layout-shift", buffered: true });+ });+ await open(page);+ await page.waitForTimeout(2500);+ const firstScreen = await page.evaluate(() => window.__cls);+ // Down the page and back, a screen at a time (the sections under it are laid out as they come near).+ const height = await page.evaluate(() => document.documentElement.scrollHeight);+ for (let y = 0; y < height; y += v.h * 0.8) {+ await page.evaluate((y) => window.scrollTo(0, y), y);+ await page.waitForTimeout(120);+ }+ await page.evaluate(() => window.scrollTo(0, 0));+ await page.waitForTimeout(800);+ const all = await page.evaluate(() => ({ cls: window.__cls, shifts: window.__shifts }));+ await ctx.close();+ return { firstScreen, ...all };+}+if (!weightOnly)+ for (const v of [WIDTHS[0], WIDTHS[4]]) {+ const r = await cls(v);+ check(`layout shift at ${v.w}: first screen ${r.firstScreen.toFixed(4)}, whole page ${r.cls.toFixed(4)}`, r.firstScreen < 0.01, JSON.stringify(r.shifts.slice(0, 4)));+ notes.push(`CLS ${v.w}: first screen ${r.firstScreen.toFixed(4)}, through a scroll ${r.cls.toFixed(4)}`);+ }++// ------------------------------------------------------------------------------------------- 3. links+if (!weightOnly) {+ const ctx = await browser.newContext(DESKTOP);+ const page = await ctx.newPage();+ await open(page);+ const hrefs = await page.$$eval("#home-bento [data-tile]", (as) => as.map((a) => [a.dataset.tile, a.getAttribute("href")]));+ check("eight tiles, in the grid's reading order", hrefs.map((h) => h[0]).join() === TILES.join(), hrefs.map((h) => h[0]).join());+ for (const [tile, href] of hrefs) {+ if (href.startsWith("#")) {+ check(`${tile}: ${href} is on the page`, (await page.locator(href).count()) === 1);+ continue;+ }+ const r = await ctx.request.get(app + href, { maxRedirects: 5 });+ check(`${tile}: ${href} answers ${r.status()}`, r.status() === 200);+ }+ await page.locator('#home-bento [data-tile="numbers"]').click();+ await page.waitForTimeout(600);+ check("the numbers tile opens every studio (the launcher)", (await page.locator('section[aria-label="All studios"]:visible').count()) > 0 && page.url() === `${app}/`, page.url());+ await ctx.close();++ const phone = await browser.newContext(PHONE);+ const pp = await phone.newPage();+ await open(pp);+ await pp.locator('#home-bento [data-tile="numbers"]').scrollIntoViewIfNeeded();+ await pp.locator('#home-bento [data-tile="numbers"]').click();+ await pp.waitForTimeout(700);+ check("on a phone, the numbers tile opens the Studios sheet", (await pp.locator('[role="dialog"]:visible').count()) > 0);+ await phone.close();+}++// ------------------------------------------------------------------------------------------- 4. reduced motion, Save-Data+if (!weightOnly) {+ const ctx = await browser.newContext({ ...DESKTOP, reducedMotion: "reduce" });+ const page = await ctx.newPage();+ const clips = [];+ page.on("request", (r) => r.url().includes(".mp4") && clips.push(r.url()));+ await open(page);+ await page.waitForTimeout(3000);+ const pill = () => page.locator("#home-bento [data-tile=live]").innerText();+ const a = await pill();+ await page.waitForTimeout(1000);+ const b = await pill();+ const state = await page.evaluate(() => ({+ play: document.getElementById("home-bento").dataset.play ?? null,+ videos: [...document.querySelectorAll("#home-bento video")].filter((v) => v.getAttribute("src") && !v.paused).length,+ split: getComputedStyle(document.querySelector("#home-bento [data-tile=restore] picture:nth-of-type(2) img")).clipPath,+ }));+ check("reduced motion: nothing moves by itself", state.play === null && state.videos === 0 && clips.length === 0, JSON.stringify({ ...state, clips: clips.length }));+ check("reduced motion: the split rests at 50 %", /inset\(0(px)? 50%/.test(state.split), state.split);+ check("reduced motion: the live words stay", a === b, `${JSON.stringify(a)} / ${JSON.stringify(b)}`);+ await ctx.close();++ const sd = await browser.newContext(DESKTOP);+ await sd.addInitScript(() => Object.defineProperty(navigator, "connection", { value: { saveData: true, effectiveType: "4g", addEventListener() {} }, configurable: true }));+ const sp = await sd.newPage();+ const cdp = await sd.newCDPSession(sp);+ await cdp.send("Network.enable");+ await cdp.send("Network.setExtraHTTPHeaders", { headers: { "Save-Data": "on" } });+ const sdClips = [];+ sp.on("request", (r) => r.url().includes(".mp4") && sdClips.push(r.url()));+ await open(sp);+ await sp.waitForTimeout(3500);+ const sdPlay = await sp.evaluate(() => document.getElementById("home-bento").dataset.play ?? null);+ check("Save-Data: no clip fetched, nothing moves", sdClips.length === 0 && sdPlay === null, `${sdClips.length} clips, play=${sdPlay}`);+ await sd.close();+}++// ------------------------------------------------------------------------------------------- 5. pause previews+if (!weightOnly) {+ const ctx = await browser.newContext(DESKTOP);+ const page = await ctx.newPage();+ await open(page);+ const playing = () =>+ page.evaluate(() => {+ const v = document.querySelector("#home-bento [data-tile=video] video");+ return v ? { paused: v.paused, t: v.currentTime } : null;+ });+ await page.waitForFunction(() => {+ const v = document.querySelector("#home-bento [data-tile=video] video");+ return v && !v.paused && v.currentTime > 0.2;+ }, null, { timeout: 8000 }).catch(() => {});+ const before = await playing();+ check("the catwalk plays by itself after load", !!before && !before.paused, JSON.stringify(before));+ await page.getByRole("button", { name: "Pause previews" }).click();+ await page.waitForTimeout(400);+ const after = await page.evaluate(() => ({+ v: document.querySelector("#home-bento [data-tile=video] video")?.paused,+ play: document.getElementById("home-bento").dataset.play,+ running: document.getElementById("home-bento").getAnimations({ subtree: true }).filter((a) => a.playState === "running").length,+ }));+ check("Pause previews stops the clip and freezes the tiles", after.v === true && after.play === "0" && after.running === 0, JSON.stringify(after));+ const live1 = await page.locator("#home-bento [data-tile=live]").innerText();+ await page.waitForTimeout(800);+ check("paused, the live words stop", live1 === (await page.locator("#home-bento [data-tile=live]").innerText()));+ await page.getByRole("button", { name: "Play previews" }).click();+ await page.waitForTimeout(1500);+ const again = await page.evaluate(() => ({+ v: document.querySelector("#home-bento [data-tile=video] video")?.paused,+ play: document.getElementById("home-bento").dataset.play,+ }));+ check("Play previews starts them again", again.v === false && again.play === "1", JSON.stringify(again));+ await ctx.close();+}++// ------------------------------------------------------------------------------------------- 6. weight+async function weight(v) {+ const ctx = await browser.newContext(viewportOpts(v));+ const page = await ctx.newPage();+ const cdp = await ctx.newCDPSession(page);+ await cdp.send("Network.enable");+ await cdp.send("Network.setCacheDisabled", { cacheDisabled: true });+ const reqs = new Map();+ let loaded = false;+ cdp.on("Network.responseReceived", (e) => reqs.set(e.requestId, { url: e.response.url, type: e.type, mime: e.response.mimeType, bytes: 0, done: false }));+ cdp.on("Network.loadingFinished", (e) => {+ const r = reqs.get(e.requestId);+ if (r && !loaded) Object.assign(r, { bytes: e.encodedDataLength, done: true });+ });+ await page.goto(app + "/", { waitUntil: "load", timeout: 90_000 });+ loaded = true;+ await page.waitForTimeout(300);+ const by = {};+ let total = 0;+ let own = 0;+ const media = [];+ // The first screen's own pictures: the tiles' stills (anything else is the page's, below it).+ const ownUrls = new Set(await page.evaluate(() => [...document.querySelectorAll("#home-bento img")].map((i) => new URL(i.currentSrc || i.src, location.href).pathname)));+ for (const r of reqs.values()) {+ if (!r.done || r.mime.startsWith("video/")) continue;+ const kind = r.type === "Document" ? "html" : r.type === "Stylesheet" ? "css" : r.type === "Script" ? "js" : r.type === "Font" ? "fonts" : r.type === "Image" ? "images" : "other";+ by[kind] = (by[kind] ?? 0) + r.bytes;+ total += r.bytes;+ const pathname = new URL(r.url).pathname;+ if (kind === "images" && ownUrls.has(pathname)) {+ own += r.bytes;+ media.push(`${pathname} ${(r.bytes / 1024).toFixed(1)}`);+ }+ }+ await ctx.close();+ const kb = (n) => `${(n / 1024).toFixed(0)} KB`;+ return { total, own, line: `${v.w}@${viewportOpts(v).deviceScaleFactor}x: ${kb(total)} (${Object.entries(by).map(([k, n]) => `${k} ${kb(n)}`).join(", ")}); the first screen's own stills ${kb(own)}`, media };+}+for (const v of [WIDTHS[0], WIDTHS[4]]) {+ const r = await weight(v);+ // The whole page's total is reported (main's own script and fonts are most of it: compare with --weight-only on+ // main's build); the first screen's own stills have a budget of their own.+ check(`weight before load, clips aside: ${r.line}`, weightOnly || r.own < 280 * 1024);+ notes.push(`weight ${r.line}`);+ notes.push(` first screen's stills: ${r.media.join(" · ")}`);+}++// ------------------------------------------------------------------------------------------- 7. composer+if (!weightOnly) {+ const ctx = await browser.newContext(DESKTOP);+ const page = await ctx.newPage();+ await open(page);+ await page.waitForTimeout(1500);+ check("a plain visit stays at the top (no autofocus jump)", (await page.evaluate(() => scrollY)) === 0);+ await open(page, "/?new=1");+ await page.waitForTimeout(1500);+ const c = await page.evaluate(() => {+ const t = document.querySelector('textarea[aria-label="Describe what to create"]');+ const r = t.getBoundingClientRect();+ return { focused: document.activeElement === t, inView: r.top >= 0 && r.bottom <= innerHeight };+ });+ check("New creation (?new=1) brings the composer into view with the focus", c.focused && c.inView, JSON.stringify(c));+ await ctx.close();+}++// ------------------------------------------------------------------------------------------- 8. names and Tab order+if (!weightOnly) {+ const ctx = await browser.newContext(DESKTOP);+ const page = await ctx.newPage();+ await open(page);+ const names = await page.$$eval("#home-bento a", (as) => as.map((a) => a.getAttribute("aria-label") ?? a.textContent.trim()));+ check("every link on the first screen has a name", names.length === 8 && names.every((n) => n && n.length > 5), names.join(" | "));+ await page.locator("#home-bento h1").click();+ const order = [];+ for (let i = 0; i < 8; i++) {+ await page.keyboard.press("Tab");+ order.push(await page.evaluate(() => document.activeElement?.dataset?.tile ?? document.activeElement?.tagName));+ }+ check("Tab reaches the tiles in reading order", order.join() === TILES.join(), order.join());+ await page.keyboard.press("Shift+Tab");+ const ring = await page.evaluate(() => getComputedStyle(document.activeElement).boxShadow);+ check("a focused tile shows its ring", ring && ring !== "none", ring);+ if (shotsDir) await page.screenshot({ path: path.join(shotsDir, "focus-ring-1440.png"), clip: { x: 0, y: 0, width: 1440, height: 900 } });+ await ctx.close();+}++await browser.close();++// ------------------------------------------------------------------------------------------- contact sheet+if (shotsDir && shots.length) {+ const sharp = createRequire(path.join(root, "package.json"))("sharp");+ const W = 480;+ const tiles = await Promise.all(+ shots.map(async (s) => {+ const { data, info } = await sharp(s.f).resize({ width: W }).png().toBuffer({ resolveWithObject: true });+ return { ...s, buf: data, h: info.height };+ }),+ );+ const rows = [];+ for (const who of ["guest", "owner"])+ for (const scheme of ["light", "dark"]) {+ const row = tiles.filter((t) => t.who === who && t.scheme === scheme);+ if (row.length) rows.push(row);+ }+ const rowH = rows.map((r) => Math.max(...r.map((t) => t.h)));+ const cols = Math.max(...rows.map((r) => r.length));+ const pad = 12;+ const composite = [];+ let y = pad;+ rows.forEach((r, i) => {+ r.forEach((t, j) => composite.push({ input: t.buf, left: pad + j * (W + pad), top: y }));+ y += rowH[i] + pad;+ });+ await sharp({ create: { width: pad + cols * (W + pad), height: y, channels: 3, background: "#777" } })+ .composite(composite)+ .jpeg({ quality: 82 })+ .toFile(path.join(shotsDir, "contact-sheet.jpg"));+ console.log(`contact sheet: ${path.join(shotsDir, "contact-sheet.jpg")}`);+}++console.log("\n" + notes.join("\n"));+if (failures.length) {+ console.log(`\n${failures.length} failed:\n- ${failures.join("\n- ")}`);+ process.exit(1);+}+console.log("\nall passed");diff --git a/tests/home-bento.test.ts b/tests/home-bento.test.tsnew file mode 100644index 00000000..ab6ba5c7--- /dev/null+++ b/tests/home-bento.test.ts@@ -0,0 +1,208 @@+import { spawnSync } from "node:child_process";+import fs from "node:fs";+import path from "node:path";+import { QueryClient, QueryClientProvider } from "@tanstack/react-query";+import { createElement } from "react";+import { renderToStaticMarkup } from "react-dom/server";+import { describe, expect, it, vi } from "vitest";+import { APPS, EFFECTS, MODELS, MOTIONS, getPreset, modelCounts } from "@/lib/catalog";+import { getTemplate } from "@/lib/catalog/canvas";+import { FORBIDDEN_WORDS } from "@/lib/examples/catalog";+import { HUB_MODES } from "@/lib/hubs";+import { studioCount } from "@/lib/nav-model";+import { HOME_BENTO_MEDIA, HOME_BENTO_WAVE } from "@/lib/home-bento.generated";+import { contentVersion } from "../scripts/eval/lib/covers.mjs";+import { mp4Seconds } from "./helpers/mp4-length";++/*+ * Home's first screen (src/components/home/home-bento.tsx, src/lib/home-bento.ts): every tile's media is a published+ * file with its version, every link goes somewhere real, every number is the catalog's, the words a visitor reads are+ * plain, and none of its clips plays anywhere else on Home.+ */++vi.mock("next/cache", () => ({ cacheLife: () => {} }));+vi.mock("next/navigation", () => ({+ useRouter: () => ({ prefetch: () => {}, push: () => {}, replace: () => {}, back: () => {}, refresh: () => {} }),+ usePathname: () => "/",+ useSearchParams: () => new URLSearchParams(),+}));++const { BENTO_BOARD, BENTO_CLIPS, BENTO_HREFS, BENTO_BEFORE_AFTER, BENTO_IMAGE_EXAMPLE, livePhrases, openModelsOf } = await import("@/lib/home-bento");+const { HOME_BEFORE_AFTER, HOME_EFFECTS, HOME_MOTIONS, HOME_REVEALS, HOME_STUDIOS, homeShowcase, navLabel } = await import("@/lib/home-showcase");+const { HomeBento } = await import("@/components/home/home-bento");++const root = process.cwd();+const file = (url: string) => path.join(root, "public", url.split("?")[0]);+const exists = (url: string) => (fs.statSync(file(url), { throwIfNoEntry: false })?.size ?? 0) > 0;+const versioned = /^\/[^?]+\?v=[0-9a-f]{8}$/;++const home = await homeShowcase();+const bento = home.bento;+const html = renderToStaticMarkup(createElement(QueryClientProvider, { client: new QueryClient() }, createElement(HomeBento, { bento })));+/** Every media URL the first screen names. */+const urls = [...new Set([...JSON.stringify(bento).matchAll(/"(\/(?:previews|examples|samples)\/[^"]*)"/g)].map((m) => m[1]))];++describe("Home's first screen", () => {+ it("shows only published files, each with its content version", () => {+ expect(urls.length).toBeGreaterThan(15);+ for (const u of urls) {+ expect(u, u).toMatch(versioned);+ expect(exists(u), u).toBe(true);+ }+ // The stills made for it are the ones scripts/gen-home-bento.mjs listed, at those versions.+ for (const [f, v] of Object.entries(HOME_BENTO_MEDIA)) {+ expect(contentVersion([file(f)]), f).toBe(v);+ expect(urls).toContain(`${f}?v=${v}`);+ }+ // And the page's HTML asks for them as listed (no URL without its version).+ for (const m of html.matchAll(/(?:src|srcSet)="([^"]+)"/g)) for (const part of m[1].split(", ")) expect(part.split(" ")[0], part).toMatch(versioned);+ });++ it("plays the catwalk and the turning gown, at the length of their published clips", () => {+ expect(bento.video.clip).toMatch(/^\/previews\/presets\/motion-catwalk\.mp4\?v=/);+ expect(bento.threeD.clip).toMatch(/^\/previews\/presets\/app-3d-rotation\.mp4\?v=/);+ expect(mp4Seconds(file(bento.video.clip))).toBeCloseTo(4, 1);+ expect(mp4Seconds(file(bento.threeD.clip))).toBeCloseTo(3.04, 1);+ });++ it("opens a real page from every tile, named by the navigation or the catalog", () => {+ const route = (href: string) => {+ const seg = href.split(/[?#]/)[0].replace(/^\//, "");+ return fs.existsSync(path.join(root, "src", "app", "(studio)", seg, "page.tsx"));+ };+ for (const href of [BENTO_HREFS.video, BENTO_HREFS.image, BENTO_HREFS.audio, BENTO_HREFS.threeD, BENTO_HREFS.live, BENTO_HREFS.canvas]) expect(route(href), href).toBe(true);+ expect(fs.existsSync(path.join(root, "src", "app", "(studio)", "apps", "[id]", "page.tsx"))).toBe(true);+ expect(APPS.some((a) => a.id === BENTO_BEFORE_AFTER)).toBe(true);+ const plan = JSON.parse(fs.readFileSync(path.join(root, "src", "lib", "examples", "plan.json"), "utf8")) as { id: string; surface: string; output?: string }[];+ expect(plan.find((r) => r.id === BENTO_IMAGE_EXAMPLE.id)).toMatchObject({ surface: "studio:image", output: BENTO_IMAGE_EXAMPLE.out });+ expect(BENTO_HREFS.numbers).toBe("#home-studios");+ expect(fs.readFileSync(path.join(root, "src", "components", "home", "home-sections.tsx"), "utf8")).toContain('id="home-studios"');+ // The words each link ends on are the place's own name.+ const t = bento.tiles;+ expect(t.video.cta).toBe(`Open ${navLabel("/cinema")}`);+ expect(t.image.cta).toBe(`Open ${navLabel("/image")}`);+ expect(t.audio.cta).toBe(`Open ${navLabel("/audio")}`);+ expect(t.threeD.cta).toBe(`Open ${navLabel("/image-to-3d")}`);+ expect(t.live.cta).toBe(`Open ${navLabel("/live-edit")}`);+ expect(t.canvas.cta).toBe(`Open ${navLabel("/canvas")}`);+ expect(t.restore.cta).toBe(`Open ${getPreset(BENTO_BEFORE_AFTER)!.name}`);+ });++ it("makes every tile one link with a name, in the grid's reading order", () => {+ const links = [...html.matchAll(/<a [^>]*>/g)].map((m) => m[0]);+ const tiles = links.filter((a) => a.includes("data-tile="));+ expect(tiles.map((a) => /data-tile="([^"]+)"/.exec(a)![1])).toEqual(["video", "image", "audio", "threeD", "restore", "numbers", "live", "canvas"]);+ for (const a of tiles) {+ const label = /aria-label="([^"]+)"/.exec(a)?.[1];+ expect(label, a).toBeTruthy();+ expect(label!.length).toBeGreaterThan(10);+ }+ const KINDS = { video: "Video", image: "Image", audio: "Audio", threeD: "3D", restore: "Before and after", live: "Live edit", canvas: "Canvas" };+ for (const [key, kind] of Object.entries(KINDS)) {+ const t = bento.tiles[key as keyof typeof KINDS];+ expect(t.label).toBe(`${kind}: ${t.title}. ${t.cta}`);+ }+ // The numbers tile opens the studios list in place, and says so.+ expect(bento.tiles.numbers.label).toBe(`${bento.numbers[0].value} studios, ${bento.numbers[1].value} apps, ${bento.numbers[2].value} effects and camera moves. Opens all studios`);+ expect(tiles.find((a) => a.includes('data-tile="numbers"'))).toContain('aria-haspopup="dialog"');+ // No link or button inside a tile: the whole tile is the one target.+ for (const chunk of html.split("data-tile=").slice(1)) expect(chunk.split("</a>")[0]).not.toMatch(/<(a|button)\b/);+ // The page's only h1: the headline.+ expect(html.match(/<h1\b/g)).toHaveLength(1);+ expect(html.replace(/<[^>]+>/g, "")).toContain("Make anything: From an idea to a finished film, in one place.");+ });++ it("quotes the catalog's numbers, never typed in", () => {+ const f = bento.facts;+ const open = (kind: string) => MODELS.filter((m) => !m.hidden && (m.engine === "open" || m.engines?.includes("open")) && m.kind === kind).length;+ // The same studio count as the navigation's Studios badge and the launcher it opens.+ expect(f.studios).toBe(studioCount());+ expect(f.apps).toBe(APPS.length);+ expect(f.effectsAndMotions).toBe(EFFECTS.length + MOTIONS.length);+ expect(f.motions).toBe(MOTIONS.length);+ expect(f.openModels).toBe(modelCounts().open);+ expect([f.imageModels, f.videoModels, f.models3d]).toEqual([open("image"), open("video"), open("model3d")]);+ expect(openModelsOf("image")).toBe(open("image"));+ expect(f.soundTools).toBe(HUB_MODES.audio.length);+ expect(bento.numbers.map((n) => n.value)).toEqual([f.studios, f.apps, f.effectsAndMotions]);+ // No number in the components' own words: every one comes from the facts.+ for (const src of ["home-bento.tsx", "bento-islands.tsx"]) {+ const text = fs.readFileSync(path.join(root, "src", "components", "home", src), "utf8");+ const words = [...text.matchAll(/>([^<>{}]*[A-Za-z][^<>{}]*)</g)].map((m) => m[1]).filter((w) => !/[(){}=?;|&]/.test(w));+ for (const w of words) expect(w.replace(/RTX 5090|3D/g, ""), `${src}: "${w}"`).not.toMatch(/\d/);+ }+ const lib = fs.readFileSync(path.join(root, "src", "lib", "home-bento.ts"), "utf8");+ for (const m of lib.matchAll(/tile\("[a-zA-Z]+", "([^"]*)", (?:`([^`]*)`|"([^"]*)"), "([^"]*)", (?:`([^`]*)`|"([^"]*)")\)/g))+ for (const w of m.slice(1).filter(Boolean)) expect(w.replace(/\$\{[^}]+\}/g, "").replace(/3D/g, ""), w).not.toMatch(/\d/);+ });++ it("reads plainly: no model or maker names, no status or prompt words", () => {+ const visible = html+ .replace(/<[^>]+>/g, " ")+ .replace(/'|"|&/g, " ")+ .replace(/\s+/g, " ");+ const labels = [...html.matchAll(/aria-label="([^"]+)"/g)].map((m) => m[1]);+ const texts = [visible.replace(/Rendered locally on ComfyUI, on one RTX 5090\.|Every preview on this page was rendered locally on ComfyUI, on one RTX 5090\./g, ""), ...labels];+ const WORDS = new Set(["Relight", "Runway", "Canvas", "Image", "Audio", "Video"]);+ const names = [...new Set(MODELS.flatMap((m) => [m.name, m.vendor]).filter((n): n is string => !!n && n.trim().length >= 3 && !WORDS.has(n)))];+ const status = /\b(unverified|not checked|todo|tbd|test|placeholder|demo|preview made with|gpu|comfy|lora|checkpoint)\b/i;+ for (const t of texts) {+ for (const bad of FORBIDDEN_WORDS) expect(t, String(bad)).not.toMatch(bad);+ expect(t).not.toMatch(status);+ for (const n of names) expect(new RegExp(`\\b${n.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}\\b`).test(t), `names ${n}: ${t}`).toBe(false);+ }+ });++ it("plays each clip in one place on Home (the playback store keys by id)", () => {+ const ids = [+ ...Object.values(BENTO_CLIPS),+ ...[...HOME_EFFECTS, ...HOME_MOTIONS, ...HOME_REVEALS].map((r) => r.id),+ ...HOME_BEFORE_AFTER.map((p) => p.id),+ ...HOME_STUDIOS.flatMap((s) => (s.id ? [s.id] : [])),+ ];+ expect(new Set(ids).size).toBe(ids.length);+ expect(HOME_STUDIOS.find((s) => s.href === "/image-to-3d")?.id).toBe("app-3d-figure");+ expect(home).not.toHaveProperty("wall");+ });++ it("draws the Audio tile from the sample's own loudness", () => {+ expect(bento.wave.bars).toHaveLength(48);+ for (const b of bento.wave.bars) {+ expect(b).toBeGreaterThanOrEqual(0.12);+ expect(b).toBeLessThanOrEqual(1);+ }+ expect(Math.max(...bento.wave.bars)).toBe(1);+ // Made from the sample as it is now: a new sample needs node scripts/gen-home-bento.mjs again.+ expect(contentVersion([file(HOME_BENTO_WAVE.src)])).toBe(HOME_BENTO_WAVE.source);+ const ffmpeg = spawnSync("ffmpeg", ["-v", "error", "-i", file(HOME_BENTO_WAVE.src), "-ac", "1", "-ar", "8000", "-f", "s16le", "-"], { maxBuffer: 64 << 20 });+ if (ffmpeg.status === 0) {+ const samples = new Int16Array(ffmpeg.stdout.buffer, ffmpeg.stdout.byteOffset, Math.floor(ffmpeg.stdout.length / 2));+ expect(samples.length / 8000).toBeCloseTo(HOME_BENTO_WAVE.seconds, 1);+ }+ });++ it("types the Live edit session's own words before the pictures they made", () => {+ const demo = JSON.parse(fs.readFileSync(path.join(root, "public", "previews", "live-edit", "demo.json"), "utf8"));+ const phrases = livePhrases(demo);+ expect(bento.live.phrases).toEqual(phrases);+ expect(phrases).toEqual(["evening makeup, deep red lips", "hair down, side-swept waves", "big gold hoop earrings"]);+ const typed = demo.script.filter((s: { type: string }) => s.type === "type").map((s: { text: string }) => s.text).join("");+ for (const p of phrases) expect(typed).toContain(p);+ expect(bento.live.frames).toHaveLength(4);+ for (const [i, f] of bento.live.frames.entries()) {+ const fr = demo.frames[`s${i}`];+ expect(f.avif.map((a) => a.src)).toEqual([fr.small, fr.mid]);+ expect(f.fallback).toBe(fr.webp);+ }+ });++ it("draws the Canvas board as the template builds it: its photo, two steps, its film", () => {+ const graph = getTemplate(BENTO_BOARD)!.build("open");+ const { photo, steps, film } = bento.canvas;+ expect([photo, ...steps, film].map((n) => n.label).sort()).toEqual(graph.nodes.map((n) => n.data.label).sort());+ expect(graph.nodes.find((n) => n.id === photo.id)?.type).toBe("image-input");+ expect(graph.nodes.find((n) => n.id === film.id)?.type).toBe("output");+ expect(photo.thumb).toMatch(/^\/previews\/home\/board-photo\.webp\?v=/);+ expect(film.thumb).toMatch(/^\/previews\/home\/board-film\.webp\?v=/);+ });+});diff --git a/tests/home-showcase.test.ts b/tests/home-showcase.test.tsindex c706c5fe..a9b5fde4 100644--- a/tests/home-showcase.test.ts+++ b/tests/home-showcase.test.ts@@ -24,6 +24,7 @@ import {presetHref,roundedDown,} from "@/lib/home-showcase";+import { BENTO_CLIPS } from "@/lib/home-bento";import { PRESET_BEFORE_AFTER } from "@/lib/preset-before-after.generated";import { onPeak, thumbOf } from "@/lib/preset-cards";import { PRESET_PEAKS } from "@/lib/preset-peaks.generated";@@ -46,8 +47,8 @@ const exists = (url: string) => (fs.statSync(path.join(root, "public", url.split/** Covers the reviews turned down: no real cover yet, or white bars at the sides (and Text Edit's white edge). */const NO_COVER = ["app-fuobe-angles", "app-talking-photo", "motion-dolly-zoom-out", "motion-buckle-up"];const WHITE_BARS = ["app-dance", "app-simlife", "app-game-dump", "app-japanese-show", "app-comic-book", "app-banana-eating", "app-change-background", "effect-boiling-point", "effect-color-rain", "app-text-edit"];-/** Studio cards that rest on a still: Marketing's product shot and Image to 3D's turntable shot. */-const STILLS = ["app-macroshot-product", "app-3d-rotation"];+/** Studio cards that rest on a still: Marketing's product shot. */+const STILLS = ["app-macroshot-product"];/*** Slots whose clip was taken down with the still it was made from (Flying's eagle had three wings): the card rests* on its new still until the new clip is published. Take an id out when its clip is back.@@ -56,7 +57,8 @@ const CLIP_PENDING = ["motion-flying"];const studioIds = HOME_STUDIOS.flatMap((s) => (s.id ? [s.id] : []));const rows = [...HOME_EFFECTS, ...HOME_MOTIONS, ...HOME_REVEALS];-const homeIds = [...HOME_WALL.map((t) => t.id), ...rows.map((r) => r.id), ...HOME_BEFORE_AFTER.map((p) => p.id), ...studioIds];+/** Every preset whose clip plays on Home: the first screen's two, the rows, the before/after and the studio cards. */+const homeIds = [...Object.values(BENTO_CLIPS), ...rows.map((r) => r.id), ...HOME_BEFORE_AFTER.map((p) => p.id), ...studioIds];/** Effects whose first frame is the strong one, so their card rests on the poster as the camera motions' do (none now). */const ON_POSTER: string[] = [];/** The frames at a clip cover's end crossfaded into its first ones (LOOP_FADE at 24 fps, scripts/eval/lib/covers.mjs). */@@ -89,7 +91,7 @@ describe("Home's showcase", () => {it("rests effects and apps on their peak frame, cut and listed; camera motions on their poster", async () => {const home = await homeShowcase();const rowCards = [...home.effects, ...home.motions, ...home.reveals].map((r) => r.card);- const cards = [...home.wall.map((t) => t.card), ...rowCards, ...home.studios.flatMap((s) => (s.card ? [s.card] : []))];+ const cards = [...rowCards, ...home.studios.flatMap((s) => (s.card ? [s.card] : []))];for (const c of cards) {const peaked = !!PRESET_PEAKS[c.id];expect(!!c.preview.rest, c.id).toBe(peaked);@@ -121,7 +123,7 @@ describe("Home's showcase", () => {expect(exists(p.thumb), p.thumb).toBe(true);expect(p.tags).toHaveLength(2);}- // Every cover URL Home gives (the wall, the rows, the before/after, the studios' cards) carries its version (?v=),+ // Every cover URL Home gives (the first screen, the rows, the before/after, the studios' cards) carries its version (?v=),// and so does each small copy a tile asks for (thumbOf): a cover made again shows at once.const urls = [...JSON.stringify(home).matchAll(/"(\/previews\/[^"]*)"/g)].map((m) => m[1]);const stills = cards.flatMap((c) => [c.preview.poster, ...(c.preview.rest ? [c.preview.rest.src] : [])]);@@ -143,10 +145,10 @@ describe("Home's showcase", () => {expect(from, id).toBeLessThanOrEqual(at);}// The preset header rests on the same frame (onPeak), and a preset without one keeps its poster.- const effect = home.wall.find((t) => t.id === "effect-outfit-switch")!.card;+ const effect = home.effects.find((r) => r.card.id === "effect-nature-bloom")!.card;expect(onPeak({ ...effect, preview: { ...effect.preview, rest: undefined } }).preview.rest).toEqual(effect.preview.rest);- const glam = home.wall.find((t) => t.id === "motion-glam")!.card;- expect(onPeak(glam)).toBe(glam);+ const dolly = home.motions.find((r) => r.card.id === "motion-dolly-in")!.card;+ expect(onPeak(dolly)).toBe(dolly);});it("gives every card a short line that fits whole: a phone's wall tile, two lines of a row's card", async () => {@@ -161,7 +163,6 @@ describe("Home's showcase", () => {expect(presetHref("motion-glam")).toBe("/video?preset=motion-glam");expect(presetHref("app-relight")).toBe("/apps/app-relight");const home = await homeShowcase();- for (const t of home.wall) expect(t.href).toBe(presetHref(t.id));for (const p of home.beforeAfter) expect(p.href).toBe(`/apps/${p.id}`);const routes = new Set(NAV.flatMap((g) => g.items.map((i) => i.href)));for (const s of home.studios) expect(routes.has(s.href), s.href).toBe(true);