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: the video tile plays One Take, Sand Storm and Crane Over the Head in turn
Adarsha3fb1b700e82
diff --git a/public/previews/home/catwalk-1024.avif b/public/previews/home/catwalk-1024.avifdeleted file mode 100644index a87aec29..00000000Binary files a/public/previews/home/catwalk-1024.avif and /dev/null differdiff --git a/public/previews/home/catwalk-1024.jpg b/public/previews/home/catwalk-1024.jpgdeleted file mode 100644index 81d2ea6c..00000000Binary files a/public/previews/home/catwalk-1024.jpg and /dev/null differdiff --git a/public/previews/home/catwalk-1024.mp4 b/public/previews/home/catwalk-1024.mp4deleted file mode 100644index e01197f1..00000000Binary files a/public/previews/home/catwalk-1024.mp4 and /dev/null differdiff --git a/public/previews/home/catwalk-1536.avif b/public/previews/home/catwalk-1536.avifdeleted file mode 100644index 6e17f5b2..00000000Binary files a/public/previews/home/catwalk-1536.avif and /dev/null differdiff --git a/public/previews/home/catwalk-1536.mp4 b/public/previews/home/catwalk-1536.mp4deleted file mode 100644index cfc6a715..00000000Binary files a/public/previews/home/catwalk-1536.mp4 and /dev/null differdiff --git a/public/previews/home/catwalk-2048.avif b/public/previews/home/catwalk-2048.avifdeleted file mode 100644index 69e4dc98..00000000Binary files a/public/previews/home/catwalk-2048.avif and /dev/null differdiff --git a/public/previews/home/catwalk-2048.mp4 b/public/previews/home/catwalk-2048.mp4deleted file mode 100644index cd26b637..00000000Binary files a/public/previews/home/catwalk-2048.mp4 and /dev/null differdiff --git a/public/previews/home/catwalk-640.avif b/public/previews/home/catwalk-640.avifdeleted file mode 100644index 71439827..00000000Binary files a/public/previews/home/catwalk-640.avif and /dev/null differdiff --git a/public/previews/home/catwalk-640.mp4 b/public/previews/home/catwalk-640.mp4deleted file mode 100644index 66c53cec..00000000Binary files a/public/previews/home/catwalk-640.mp4 and /dev/null differdiff --git a/public/previews/home/reel-crane-over-1024.mp4 b/public/previews/home/reel-crane-over-1024.mp4new file mode 100644index 00000000..62c3e885Binary files /dev/null and b/public/previews/home/reel-crane-over-1024.mp4 differdiff --git a/public/previews/home/reel-crane-over-640.mp4 b/public/previews/home/reel-crane-over-640.mp4new file mode 100644index 00000000..da48bff6Binary files /dev/null and b/public/previews/home/reel-crane-over-640.mp4 differdiff --git a/public/previews/home/reel-one-take-1024.avif b/public/previews/home/reel-one-take-1024.avifnew file mode 100644index 00000000..e0d71aa2Binary files /dev/null and b/public/previews/home/reel-one-take-1024.avif differdiff --git a/public/previews/home/reel-one-take-1024.jpg b/public/previews/home/reel-one-take-1024.jpgnew file mode 100644index 00000000..06bb3cc1Binary files /dev/null and b/public/previews/home/reel-one-take-1024.jpg differdiff --git a/public/previews/home/reel-one-take-1024.mp4 b/public/previews/home/reel-one-take-1024.mp4new file mode 100644index 00000000..8e80d36fBinary files /dev/null and b/public/previews/home/reel-one-take-1024.mp4 differdiff --git a/public/previews/home/reel-one-take-640.avif b/public/previews/home/reel-one-take-640.avifnew file mode 100644index 00000000..ca5878c3Binary files /dev/null and b/public/previews/home/reel-one-take-640.avif differdiff --git a/public/previews/home/reel-one-take-640.mp4 b/public/previews/home/reel-one-take-640.mp4new file mode 100644index 00000000..cadba01bBinary files /dev/null and b/public/previews/home/reel-one-take-640.mp4 differdiff --git a/public/previews/home/reel-sand-storm-1024.mp4 b/public/previews/home/reel-sand-storm-1024.mp4new file mode 100644index 00000000..737269b3Binary files /dev/null and b/public/previews/home/reel-sand-storm-1024.mp4 differdiff --git a/public/previews/home/reel-sand-storm-640.mp4 b/public/previews/home/reel-sand-storm-640.mp4new file mode 100644index 00000000..2f81c0b2Binary files /dev/null and b/public/previews/home/reel-sand-storm-640.mp4 differdiff --git a/scripts/gen-home-bento.mjs b/scripts/gen-home-bento.mjsindex 0cfea686..0372a0ca 100644--- a/scripts/gen-home-bento.mjs+++ b/scripts/gen-home-bento.mjs@@ -1,38 +1,45 @@#!/usr/bin/env node/**- * Media and data for Home's first screen (src/components/home/home-bento.tsx): its two clips and their posters in two- * widths, 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 file is a copy of a published picture or of the full-size render a- * published clip was cut from, so the tiles show exactly what the studios show, only sharper.+ * Media and data for Home's first screen (src/components/home/home-bento.tsx): the video tile's reel of clips and its+ * poster, the 3D tile's clip and its poster, each in several widths, 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 file is a+ * copy of a published picture or of the full-size render a published clip was cut from, so the tiles show exactly what+ * the studios show, only sharper.** Output (public/previews/home/):- * catwalk-{640,1024,1536,2048}.{mp4,avif} the catwalk clip at four widths, and each one's first frame as its poster- * rotation-{640,1024,1536,2048}.{mp4,avif} the turning gown (the 3D tile), the same way- * catwalk-1024.jpg, rotation-1024.jpg the 1024 px clips' first frames, for a browser without AVIF+ * reel-<name>-{640,1024}.mp4 each clip of the video tile's reel (REEL), and at 1536 and 2048 where its+ * 2048 px master is in the masters folder+ * reel-one-take-<width>.avif the reel's first clip's first frame at each of its widths: the tile's poster+ * rotation-{640,1024,1536,2048}.{mp4,avif} the turning gown (the 3D tile) at four widths, and each one's first frame+ * reel-one-take-1024.jpg, rotation-1024.jpg the 1024 px clips' first frames, for a browser without AVIF* image-4-{480,768}.avif the Image studio's example 4* ba-{before,after}-{640,960,1280}.avif Colorize's before and after (4:3)* ba-{before,after}-tall-{432,691}.avif the same pair, a 3:5 crop for the tall tile* board-{photo,film}.webp the Canvas board's photo and a frame of its film, 168 px squares- * and src/lib/home-bento.generated.ts: each file's content version, and the waveform.+ * and src/lib/home-bento.generated.ts: each file's content version, the reel (its clips in order, each one's length and+ * framing), and the waveform.*- * The clips: the published clip's own cut (scripts/eval/lib/covers.mjs: its first CLIP_SECONDS at CLIP_FPS, looped- * the same way), made again from the full-size render instead of the 512 px copy, in H.264 High (a CRF per clip,- * faststart, no sound), tagged BT.709 so every browser shows its colours the same way. Each tile picks the width its- * box needs on the screen it is on (bento-islands.tsx).+ * The reel: the video tile plays these clips one after another, each once, and crossfades into the next (after the+ * last, back to the first). Each is a stretch of its preset's full-size render: `from` (its first frame in the render)+ * and `frames` long, at CLIP_FPS, with no loop of its own. The 3D tile's clip is the published clip's own cut+ * (scripts/eval/lib/covers.mjs: its first CLIP_SECONDS at CLIP_FPS, looped the same way), made again from the full-size+ * render instead of the 512 px copy. All are H.264 High (a CRF per clip and width, faststart, no sound), tagged BT.709+ * so every browser shows their colours the same way. Each tile picks the width its box needs on the screen it is on+ * (bento-islands.tsx).*- * The posters: each clip's own first frame, decoded from the encoded file the way a browser shows it (BT.709, limited- * range), at POSTER_QUALITY: the tile shows it until its clip plays, and the clip takes over on that same frame, so the- * swap can't be seen. They are made again from the clips on every run, with or without masters.+ * The posters: the reel's first clip's and the 3D clip's own first frame, decoded from the encoded file the way a+ * browser shows it (BT.709, limited range), at POSTER_QUALITY: the tile shows it until its clip plays, and the clip+ * takes over on that same frame, so the swap can't be seen. They are made again from the clips on every run, with or without masters.** Masters: the full-size renders are not in the repo. With --masters <dir> (or FUOBE_HOME_MASTERS) the clips, their* posters and the before/after copies are made from the files in it:- * <dir>/motion-catwalk.mp4, <dir>/app-3d-rotation.mp4 the renders the published clips were cut from- * <dir>/motion-catwalk-2048.mkv, <dir>/app-3d-rotation-2048.mkv the same renders upscaled to 2048 x 1536, every frame- * (SeedVR2 7B, lossless FFV1, BT.709), for the 1536 and- * 2048 px copies+ * <dir>/<preset>.mp4 the full-size render each reel clip and the 3D clip are cut from (1024 x 768, 24 fps)+ * <dir>/<preset>-2048.mkv the same render upscaled to 2048 x 1536, every frame (SeedVR2 7B, lossless FFV1,+ * BT.709), for the 1536 and 2048 px copies: the 3D clip needs it; a reel clip without+ * one comes at 640 and 1024 only* <dir>/app-colorize-before.png, <dir>/app-colorize-after.png Colorize's pair at full size (1536 x 1152)- * Without it those files are kept as they are (and versioned), the posters are made again from the clips kept, and so- * is the rest.+ * Without it those files are kept as they are (and versioned; a reel clip in the widths it has), the posters are made+ * again from the clips kept, and so is the rest.** 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@@ -71,15 +78,28 @@ const BA_APP = "app-colorize";*/const BA_TALL = { left: 422, top: 0, width: 691, height: 1152 };/**- * The two clips: their published preset, the name of their copies here, and the CRF each width is encoded at (the- * wider copies, made from the 2048 px master, at a higher CRF: their pixels are smaller on the screen).+ * The video tile's reel, in the order it plays: each clip's preset, the name of its copies here, the stretch of its+ * render it plays (`from`, its first frame; `frames`, at CLIP_FPS), where the tile anchors it (its object-position:+ * the tile is wider than the 4:3 clip, so only its top and bottom are cropped), and the CRF each width is encoded at+ * (chosen on close crops of faces and fine detail against the render; a busy picture, such as One Take's leaves, costs+ * more bits). The stretches are the ones that hold up frame by frame at the tile's size: One Take from the arch to its+ * look back (the render's last frame), Sand Storm until the sand fills the frame, Crane Over the Head from the profile+ * to the view. The first clip's first frame is the tile's poster.*/-const CLIPS = [- { key: "motion-catwalk", name: "catwalk", crf: { 640: 24, 1024: 24, 1536: 28, 2048: 29 } },- { key: "app-3d-rotation", name: "rotation", crf: { 640: 23, 1024: 23, 1536: 27, 2048: 28 } },+export const REEL = [+ { id: "motion-one-take", name: "reel-one-take", from: 28, frames: 96, position: "50% 15%", crf: { 640: 22, 1024: 23, 1536: 27, 2048: 28 } },+ { id: "effect-sand-storm", name: "reel-sand-storm", from: 0, frames: 84, position: "50% 0%", crf: { 640: 22, 1024: 22, 1536: 26, 2048: 27 } },+ { id: "motion-crane-over-the-head", name: "reel-crane-over", from: 36, frames: 88, position: "50% 0%", crf: { 640: 22, 1024: 22, 1536: 26, 2048: 27 } },];+/**+ * The 3D tile's clip: its published preset, the name of its copies here, and the CRF each width is encoded at (the+ * wider copies, made from the 2048 px master, at a higher CRF: their pixels are smaller on the screen).+ */+const LOOPS = [{ key: "app-3d-rotation", name: "rotation", crf: { 640: 23, 1024: 23, 1536: 27, 2048: 28 } }];/** The widths each clip and its poster are made at: a tile takes the first at least as wide as its box needs. */const CLIP_WIDTHS = [640, 1024, 1536, 2048];+/** The widths a reel clip is made at from its render alone (wider ones need its 2048 px master). */+const RENDER_WIDTHS = [640, 1024];/** From this width up, a clip is made from its 2048 px master (`<key>-2048.mkv`) instead of the render itself. */const HD_FROM = 1536;/** The width of each clip's first frame as a JPEG, the poster for a browser without AVIF (BENTO_CLIP_FALLBACK). */@@ -130,6 +150,17 @@ function loopAt(src, width) {return { all: stream(looped), frames: looped.length };}+/**+ * A reel clip at `width`: `frames` frames from frame `from` of the render (at CLIP_FPS), played once, no loop. Returns+ * its y4m stream.+ */+function cutAt(src, width, from, frames) {+ const y4m = ffmpeg(["-v", "error", "-i", src, "-an", "-sn", "-dn", "-vf", `fps=${CLIP_FPS},trim=start_frame=${from}:end_frame=${from + frames},setpts=PTS-STARTPTS,scale=${width}:-2:flags=lanczos,format=yuv420p`, "-f", "yuv4mpegpipe", "-"]);+ const got = readY4m(y4m).frames.length;+ if (got !== frames) throw new Error(`${path.basename(src)} has ${got} frames from frame ${from}, not ${frames}`);+ return y4m;+}+/** H.264 High, the published clip's loop, muted, its index at the front so it starts before it has all loaded. */function encodeClipBuffer(y4m, crf) {const out = path.join(os.tmpdir(), `gen-home-bento-${process.pid}.mp4`);@@ -175,8 +206,23 @@ async function main() {const versions = {};let total = 0;// Made from the masters when there are any; without them the files already here are kept (and versioned).+ // The reel's widths: 640 and 1024 from each render, the wider ones from its 2048 px master where there is one;+ // without masters, the widths already here.+ const reelWidths = (c) =>+ CLIP_WIDTHS.filter((w) =>+ MASTERS ? RENDER_WIDTHS.includes(w) || fs.existsSync(master(`${c.id}-2048.mkv`)) : fs.existsSync(path.join(OUT_DIR, `${c.name}-${w}.mp4`)),+ );+ const reel = REEL.map((c) => ({ ...c, widths: reelWidths(c) }));+ for (const c of reel) if (!RENDER_WIDTHS.every((w) => c.widths.includes(w))) throw new Error(`${c.name} is made from the full-size renders: run with --masters <dir>`);const fromMasters = [- ...CLIPS.flatMap((c) =>+ ...reel.flatMap((c) =>+ c.widths.map((w) => ({+ name: `${c.name}-${w}.mp4`,+ clip: true,+ make: () => encodeClipBuffer(cutAt(master(RENDER_WIDTHS.includes(w) ? `${c.id}.mp4` : `${c.id}-2048.mkv`), w, c.from, c.frames), c.crf[w]),+ })),+ ),+ ...LOOPS.flatMap((c) =>CLIP_WIDTHS.map((w) => ({name: `${c.name}-${w}.mp4`,clip: true,@@ -205,8 +251,9 @@ async function main() {}if (!DRY) versions[`/previews/home/${s.name}`] = contentVersion([out]);}- // Each clip's poster, from the clip as it is now (just made, or kept).- const posters = CLIPS.flatMap((c) => CLIP_WIDTHS.map((w) => ({ name: `${c.name}-${w}.avif`, clip: `${c.name}-${w}.mp4` })));+ // Each poster, from its clip as it is now (just made, or kept): the reel's first clip's, and the 3D clip's.+ const posterSets = [{ name: reel[0].name, widths: reel[0].widths }, ...LOOPS.map((c) => ({ name: c.name, widths: CLIP_WIDTHS }))];+ const posters = posterSets.flatMap((c) => c.widths.map((w) => ({ name: `${c.name}-${w}.avif`, clip: `${c.name}-${w}.mp4` })));const jobs = [...posters.map((p) => ({...p,@@ -216,7 +263,7 @@ async function main() {},})),// For a browser without AVIF: the FALLBACK_WIDTH clip's first frame as a JPEG.- ...CLIPS.map((c) => ({+ ...posterSets.map((c) => ({name: `${c.name}-${FALLBACK_WIDTH}.jpg`,make: () => sharp(firstFrame(path.join(OUT_DIR, `${c.name}-${FALLBACK_WIDTH}.mp4`))).jpeg({ quality: 85, mozjpeg: true }).toBuffer(),})),@@ -244,12 +291,19 @@ async function main() {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+ * Home's first screen (src/components/home/home-bento.tsx): the content version of each file made for it, the video+ * tile's reel, 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)};+/** The video tile's reel, in the order it plays: each clip's preset, its copies' name, its length and its framing. */+export const HOME_BENTO_REEL = ${JSON.stringify(+ REEL.map(({ id, name, frames, position }) => ({ id, name, frames, fps: CLIP_FPS, position })),+ null,+ 2,+ )};+export const HOME_BENTO_WAVE = {src: ${JSON.stringify(WAVE_SOURCE)},source: ${JSON.stringify(source)},diff --git a/src/components/home/bento-islands.tsx b/src/components/home/bento-islands.tsxindex 3c95882b..4a60dfc8 100644--- a/src/components/home/bento-islands.tsx+++ b/src/components/home/bento-islands.tsx@@ -5,14 +5,15 @@ 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 { REEL_FADE_MS, fadeDue, nextInReel, reelProgress, reelSources, type ReelClip } from "@/lib/home-reel";import { coverWidth, pickWidth, type Sized } from "@/lib/media-pick";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.+ * The first screen's few islands (home-bento.tsx): the switch that lets it move, the video tile's reel, the 3D tile's+ * clip, 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 first screen's animations wait for it) and whether it may move now (BentoMotion). */@@ -241,6 +242,205 @@ export function BentoClip({ id, clips, progress }: { id: string; clips: Sized[];);}+/** Whether the viewer asked for less motion or less data: the reel then plays its first clip alone, and only when asked. */+const holdsStill = () => window.matchMedia("(prefers-reduced-motion: reduce)").matches || browserPlaybackEnv.saveData();++/**+ * One clip of the reel, in its own element (keyed by `k`, its place in the order the reel has played): it lets go of+ * its source when it leaves, so a clip that has played stops costing memory. `shown`: on screen; `incoming`: it fades+ * in over the clip ending, at the reel's pace.+ */+function ReelVideo({+ k,+ clip,+ src,+ loop,+ shown,+ incoming,+ register,+ onLoaded,+ onPlaying,+ onEnded,+}: {+ k: number;+ clip: ReelClip;+ src: string;+ loop: boolean;+ shown: boolean;+ incoming: boolean;+ register: (k: number, v: HTMLVideoElement | null) => void;+ onLoaded: (k: number) => void;+ onPlaying: (k: number) => void;+ onEnded: (k: number) => void;+}) {+ const ref = useRef<HTMLVideoElement>(null);+ useEffect(() => {+ const v = ref.current;+ register(k, v);+ return () => {+ register(k, null);+ releaseVideo(v);+ };+ }, [k, register]);+ return (+ <video+ ref={ref}+ src={src}+ muted+ loop={loop}+ playsInline+ preload="auto"+ style={{ objectPosition: clip.position }}+ data-clip={clip.id}+ data-max={Math.max(...clip.clips.map((c) => c.w))}+ data-ready={shown || undefined}+ data-in={incoming || undefined}+ onLoadedData={() => onLoaded(k)}+ onPlaying={() => onPlaying(k)}+ onEnded={() => onEnded(k)}+ />+ );+}++/** The latest of two places in the reel's order (each "this one has loaded / played / ended" only moves forward). */+const later = (k: number) => (prev: number) => Math.max(prev, k);++/**+ * The video tile's reel (src/lib/home-reel.ts): its clips one after another, each played once, each crossfading into+ * the next for REEL_FADE_MS as it ends, and after the last the first again. It plays by the same rules as a tile's clip+ * (BentoClip): it joins the site's playback rules once its still is painted, plays only on screen and in a visible tab,+ * pauses where it is, and each clip is the narrowest copy at least as wide as the tile needs on this screen (and as the+ * copy of the still the browser chose). The still is the first clip's first frame, and that clip shows only once it has+ * that frame: no sign, no flash, nothing moves. Only the clip playing and the one after it are loaded, the next one+ * only once the current one plays. Under reduced motion or Save-Data nothing plays by itself; a hover or keyboard focus+ * plays the first clip alone, on a loop. `progress`: a line along the bottom follows the whole reel.+ */+export function BentoReel({ id, reel, progress }: { id: string; reel: ReelClip[]; progress?: boolean }) {+ const [armed, setArmed] = useState(false);+ const [stillW, setStillW] = useState(0);+ const { ref, playing, handlers } = usePreviewPlayback<HTMLSpanElement>(id, armed ? { video: reel[0].clips[0].src } : {});+ useEffect(() => {+ const el = ref.current;+ if (!el) return;+ return afterStill(el, () => {+ setStillW(stillWidth(el));+ setArmed(true);+ });+ }, [ref]);+ const [need, setNeed] = useState(0);+ useEffect(() => {+ const el = ref.current;+ if (!el) return;+ const ro = new ResizeObserver(([e]) => setNeed(coverWidth(e.contentRect.width, e.contentRect.height, CLIP_ASPECT, window.devicePixelRatio || 1)));+ ro.observe(el);+ return () => ro.disconnect();+ }, [ref]);+ // Chosen when it first plays, and kept: each clip's copy, and whether the reel turns or its first clip loops alone.+ const [plan, setPlan] = useState<{ srcs: string[]; turns: boolean } | null>(null);+ if (playing && !plan) setPlan({ srcs: reelSources(reel, Math.max(need, stillW)), turns: reel.length > 1 && !holdsStill() });+ const turns = !!plan?.turns;++ // `seq`: how many clips have played before the one on screen (it is clip seq % n). Each element is keyed by its seq,+ // so a clip that comes round again is a new element.+ const n = reel.length;+ const [seq, setSeq] = useState(0);+ const [loaded, setLoaded] = useState(-1);+ const [started, setStarted] = useState(-1);+ const [due, setDue] = useState(-1);+ // The next clip loads once this one plays; it fades in once this one is near its end (or has ended) and it has its+ // first frame.+ const nextOn = turns && started >= seq;+ const fading = nextOn && due >= seq && loaded > seq;+ const els = useRef(new Map<number, HTMLVideoElement>());+ const [register] = useState(() => (k: number, v: HTMLVideoElement | null) => void (v ? els.current.set(k, v) : els.current.delete(k)));+ const bar = useRef<HTMLElement>(null);+ const on = useRef(handlers);+ useEffect(() => {+ on.current = handlers;+ });++ // The tile is the link: its keyboard focus plays the reel 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]);++ // Play or pause the clip on screen, and the one fading in over it; the next one waits on its first frame.+ useEffect(() => {+ const cur = els.current.get(seq);+ const next = els.current.get(seq + 1);+ if (cur) {+ if (playing) void cur.play().catch(() => {});+ else cur.pause();+ }+ if (next) {+ if (playing && fading) void next.play().catch(() => {});+ else next.pause();+ }+ }, [playing, seq, fading, plan, nextOn]);++ // Once the next clip has faded in, it takes this one's place (and this one's element goes).+ useEffect(() => {+ if (!fading) return;+ const t = window.setTimeout(() => setSeq((x) => Math.max(x, seq + 1)), REEL_FADE_MS);+ return () => clearTimeout(t);+ }, [fading, seq]);++ // A frame at a time while it plays: the line follows the reel, and the fade is due REEL_FADE_MS before a clip's end.+ useEffect(() => {+ const v = els.current.get(seq);+ const b = bar.current;+ if (!v || !playing || loaded < seq) return;+ let raf = 0;+ let marked = false;+ const tick = () => {+ if (b) b.style.transform = `scaleX(${turns ? reelProgress(seq % n, n, v.currentTime, v.duration) : v.duration > 0 ? v.currentTime / v.duration : 0})`;+ if (turns && !marked && fadeDue(v.currentTime, v.duration)) {+ marked = true;+ setDue(later(seq));+ }+ raf = requestAnimationFrame(tick);+ };+ raf = requestAnimationFrame(tick);+ return () => cancelAnimationFrame(raf);+ }, [playing, loaded, seq, turns, n]);++ const playingNow = plan ? [{ k: seq, i: seq % n }, ...(nextOn ? [{ k: seq + 1, i: nextInReel(seq % n, n) }] : [])] : [];+ return (+ <span ref={ref} aria-hidden className={s.clip} data-reel={plan ? seq % n : undefined} onPointerEnter={handlers.onPointerEnter} onPointerLeave={handlers.onPointerLeave}>+ {plan &&+ playingNow.map(({ k, i }) => (+ <ReelVideo+ key={k}+ k={k}+ clip={reel[i]}+ src={plan.srcs[i]}+ loop={!turns}+ shown={loaded >= k && (k === seq || fading)}+ incoming={k > seq}+ register={register}+ onLoaded={(x) => setLoaded(later(x))}+ onPlaying={(x) => setStarted(later(x))}+ onEnded={(x) => setDue(later(x))}+ />+ ))}+ {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;diff --git a/src/components/home/home-bento.css b/src/components/home/home-bento.cssindex a8e25533..762c6ea9 100644--- a/src/components/home/home-bento.css+++ b/src/components/home/home-bento.css@@ -545,6 +545,10 @@.hb-clip video:not([data-ready]) {opacity: 0;}+/* The video tile's reel: the next clip fades in over the one ending (REEL_FADE_MS, src/lib/home-reel.ts). */+.hb-clip video[data-in] {+ transition-duration: 0.5s;+}/* ---------------------------------------------------------------- image: a slow push in */@@ -759,7 +763,8 @@.hb-side.hb-right {right: 12px;}-/* The catwalk clip and its still: a wide, short tile crops from the bottom, so the model's head always shows. */+/* The reel's clips and its still: a wide, short tile crops from the bottom, so the head always shows (a clip framed+ otherwise sets its own object-position: HOME_BENTO_REEL). */.hb-video .hb-fill,.hb-video .hb-clip video {object-position: 50% 0%;diff --git a/src/components/home/home-bento.tsx b/src/components/home/home-bento.tsxindex 9d324e91..5772e410 100644--- a/src/components/home/home-bento.tsx+++ b/src/components/home/home-bento.tsx@@ -1,5 +1,5 @@import { ArrowRight, ArrowUpRight, ChevronsLeftRight, Play, Sparkles, Video } from "lucide-react";-import { BentoClip, BentoMotion, LiveTyping, NumbersLink } from "@/components/home/bento-islands";+import { BentoClip, BentoMotion, BentoReel, LiveTyping, NumbersLink } from "@/components/home/bento-islands";import { PausePreviews } from "@/components/home/home-islands";import { IntentLink } from "@/components/intent-link";import { CountUp } from "@/components/ui/count-up";@@ -25,7 +25,8 @@ 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.+ * takes it from lg. `position`: its object-position, where it differs from its tile's. Decorative: the tile's link+ * names it.*/function Pic({pic,@@ -33,12 +34,14 @@ function Pic({className,loading = "eager",fetchPriority,+ position,}: {pic: BentoPicture;sizes: string;className?: string;loading?: "eager" | "lazy";fetchPriority?: "high" | "low";+ position?: string;}) {return (<picture className={s.pic}>@@ -54,6 +57,7 @@ function Pic({decoding="async"draggable={false}className={cn(s.fill, className)}+ style={position ? { objectPosition: position } : undefined}/></picture>);@@ -177,8 +181,8 @@ export function HomeBento({ bento }: { bento: Bento }) {<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} clips={bento.video.clips} progress />+ <Pic pic={bento.video.poster} sizes={SIZES.video} fetchPriority="high" position={bento.video.reel[0].position} />+ <BentoReel id={bento.video.id} reel={bento.video.reel} progress /><span aria-hidden className={s.badge}><Video className="size-3.5" /> Video</span>diff --git a/src/lib/home-bento.generated.ts b/src/lib/home-bento.generated.tsindex aafec290..2ec8c16c 100644--- a/src/lib/home-bento.generated.ts+++ b/src/lib/home-bento.generated.ts@@ -1,13 +1,15 @@/**- * 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+ * Home's first screen (src/components/home/home-bento.tsx): the content version of each file made for it, the video+ * tile's reel, 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-640.mp4": "195683c9",- "/previews/home/catwalk-1024.mp4": "0cfc2824",- "/previews/home/catwalk-1536.mp4": "526f61cc",- "/previews/home/catwalk-2048.mp4": "8f301b8a",+ "/previews/home/reel-one-take-640.mp4": "175b3cd6",+ "/previews/home/reel-one-take-1024.mp4": "dd9a7c62",+ "/previews/home/reel-sand-storm-640.mp4": "79c89fa8",+ "/previews/home/reel-sand-storm-1024.mp4": "a3911fc1",+ "/previews/home/reel-crane-over-640.mp4": "34ae25b3",+ "/previews/home/reel-crane-over-1024.mp4": "a7cc281e","/previews/home/rotation-640.mp4": "3efbab2a","/previews/home/rotation-1024.mp4": "3f5507ab","/previews/home/rotation-1536.mp4": "87d3d4f1",@@ -22,15 +24,13 @@ export const HOME_BENTO_MEDIA: Record<string, string> = {"/previews/home/ba-after-1280.avif": "61952772","/previews/home/ba-after-tall-432.avif": "71f125b7","/previews/home/ba-after-tall-691.avif": "46271396",- "/previews/home/catwalk-640.avif": "a5c7089b",- "/previews/home/catwalk-1024.avif": "be920778",- "/previews/home/catwalk-1536.avif": "c71cd3dd",- "/previews/home/catwalk-2048.avif": "86ddcec3",+ "/previews/home/reel-one-take-640.avif": "e3820eec",+ "/previews/home/reel-one-take-1024.avif": "96abf153","/previews/home/rotation-640.avif": "c69b0d7b","/previews/home/rotation-1024.avif": "23d2a89b","/previews/home/rotation-1536.avif": "b3df3778","/previews/home/rotation-2048.avif": "bcc9ccc5",- "/previews/home/catwalk-1024.jpg": "11e790b3",+ "/previews/home/reel-one-take-1024.jpg": "991af346","/previews/home/rotation-1024.jpg": "61a2cbc9","/previews/home/image-4-480.avif": "5a6d07a1","/previews/home/image-4-768.avif": "ef9d1b4d",@@ -38,6 +38,31 @@ export const HOME_BENTO_MEDIA: Record<string, string> = {"/previews/home/board-film.webp": "db007869"};+/** The video tile's reel, in the order it plays: each clip's preset, its copies' name, its length and its framing. */+export const HOME_BENTO_REEL = [+ {+ "id": "motion-one-take",+ "name": "reel-one-take",+ "frames": 96,+ "fps": 24,+ "position": "50% 15%"+ },+ {+ "id": "effect-sand-storm",+ "name": "reel-sand-storm",+ "frames": 84,+ "fps": 24,+ "position": "50% 0%"+ },+ {+ "id": "motion-crane-over-the-head",+ "name": "reel-crane-over",+ "frames": 88,+ "fps": 24,+ "position": "50% 0%"+ }+];+export const HOME_BENTO_WAVE = {src: "/samples/clean-voice/clean.m4a",source: "8a1e9cfc",diff --git a/src/lib/home-bento.ts b/src/lib/home-bento.tsindex 975174ec..abe00b63 100644--- a/src/lib/home-bento.ts+++ b/src/lib/home-bento.ts@@ -11,17 +11,25 @@ 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 { HOME_BENTO_MEDIA, HOME_BENTO_REEL, HOME_BENTO_WAVE } from "@/lib/home-bento.generated";+import type { ReelClip } from "@/lib/home-reel";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 preset whose clip the 3D tile plays (no other card on Home plays it: tests/home-showcase.test.ts). */+export const BENTO_CLIPS = { threeD: "app-3d-rotation" } as const;/** Each clip's copies here (scripts/gen-home-bento.mjs): its name, and the widths it and its poster come in. */-export const BENTO_CLIP_FILES = { video: "catwalk", threeD: "rotation" } as const;+export const BENTO_CLIP_FILES = { threeD: "rotation" } as const;export const BENTO_CLIP_WIDTHS = [640, 1024, 1536, 2048] as const;+/**+ * The presets the video tile plays in turn, in this order: scripts/gen-home-bento.mjs (REEL) cuts each one's stretch+ * and frames it. The first one's first frame is the tile's poster.+ */+export const BENTO_REEL = HOME_BENTO_REEL.map((c) => c.id);+/** The video tile's id in the playback store: its own, as it plays several presets (one of them may be a card lower down). */+export const BENTO_REEL_ID = "home-reel";/** The width of the JPEG copy of each clip's first frame, for a browser without AVIF. */export const BENTO_CLIP_FALLBACK = 1024;/** The Image studio's example the image tile shows and opens with (src/lib/examples/plan.json). */@@ -64,6 +72,13 @@ export interface BentoMovingTile {clips: { src: string; w: number }[];}+/** The video tile: its id in the playback store, its poster (the first clip's first frame) and its clips in order. */+export interface BentoReelTile {+ id: string;+ poster: BentoPicture;+ reel: ReelClip[];+}+export interface BentoTile {key: BentoKey;/** The small line over the title: what kind of media, and how much of it. */@@ -96,6 +111,9 @@ export interface BentoFacts {*/export const openModelsOf = (kind: ModelDef["kind"], models: readonly ModelDef[] = MODELS) => models.filter((m) => isListed(m) && runsOn(m, "open") && m.kind === kind).length;+/** The widths a file of the copies named `name` comes in (`<name>-<width>.<ext>`), as scripts/gen-home-bento.mjs made them. */+const widthsOf = (name: string, ext: string) => BENTO_CLIP_WIDTHS.filter((w) => HOME_BENTO_MEDIA[`/previews/home/${name}-${w}.${ext}`]);+/** A file made by scripts/gen-home-bento.mjs, with its version. */function made(file: string): string {const v = HOME_BENTO_MEDIA[file];@@ -153,11 +171,10 @@ function board() {/** 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");+ if (!threeD?.video || !restore || !baV || BENTO_REEL.some((id) => !presetCover(id)?.video)) 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];@@ -169,6 +186,23 @@ export async function homeBento(f: BentoFacts) {tall: [432, 691].map((w) => ({ src: made(`/previews/home/ba-${side}-tall-${w}.avif`), w })),fallback: `/previews/presets/ba/960/${BENTO_BEFORE_AFTER}-${side}.jpg?v=${baV}`,});+ // The video tile's reel: each clip in the widths it comes in, and the first one's first frame as the poster, in its+ // widths (and a JPEG at 1024 px for a browser without AVIF).+ const reel = (): BentoReelTile => {+ const first = HOME_BENTO_REEL[0];+ return {+ id: BENTO_REEL_ID,+ poster: {+ avif: widthsOf(first.name, "avif").map((w) => ({ src: made(`/previews/home/${first.name}-${w}.avif`), w })),+ fallback: made(`/previews/home/${first.name}-${BENTO_CLIP_FALLBACK}.jpg`),+ },+ reel: HOME_BENTO_REEL.map((c) => {+ const widths = widthsOf(c.name, "mp4");+ if (!widths.length) throw new Error(`Home's video tile names ${c.name}, which scripts/gen-home-bento.mjs didn't make`);+ return { id: c.id, position: c.position, clips: widths.map((w) => ({ src: made(`/previews/home/${c.name}-${w}.mp4`), w })) };+ }),+ };+ };// A moving tile: its poster (the clip's first frame) and its clip, each in every width; for a browser without AVIF, the// 1024 px clip's first frame as a JPEG.const moving = (key: keyof typeof BENTO_CLIPS): BentoMovingTile => {@@ -206,7 +240,7 @@ export async function homeBento(f: BentoFacts) {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: moving("video"),+ video: reel(),image: {avif: [480, 768].map((w) => ({ src: made(`/previews/home/image-4-${w}.avif`), w })),fallback: example(BENTO_IMAGE_EXAMPLE.out),diff --git a/src/lib/home-reel.ts b/src/lib/home-reel.tsnew file mode 100644index 00000000..c4a1c6d1--- /dev/null+++ b/src/lib/home-reel.ts@@ -0,0 +1,31 @@+/**+ * The video tile's reel on Home's first screen (src/components/home/bento-islands.tsx, BentoReel): its clips play one+ * after another, each once, and each crossfades into the next; after the last, the first again. These are the reel's+ * rules, kept apart from the component so they can be tested (tests/home-reel.test.ts).+ */+import { pickWidth, type Sized } from "@/lib/media-pick";++/** One clip of the reel: its preset, where the tile anchors it (object-position), and its copies in each width. */+export interface ReelClip {+ id: string;+ position: string;+ clips: Sized[];+}++/** How long the crossfade from one clip into the next takes, in ms. */+export const REEL_FADE_MS = 500;++/** The clip that plays after clip `i` of `n`: the next one, and after the last the first. */+export const nextInReel = (i: number, n: number): number => (i + 1) % n;++/**+ * Each clip's copy for a box that needs `need` pixels of width: the narrowest at least that wide, or the widest it+ * has (a clip is never offered past its own size).+ */+export const reelSources = (reel: readonly ReelClip[], need: number): string[] => reel.map((c) => pickWidth(c.clips, need).src);++/** Whether the crossfade into the next clip is due: the clip at `t` of its `d` seconds is within the fade of its end. */+export const fadeDue = (t: number, d: number, fadeMs = REEL_FADE_MS): boolean => d > 0 && t >= d - fadeMs / 1000;++/** How far through the whole reel it is (0 to 1), playing clip `i` of `n` at `t` of its `d` seconds. */+export const reelProgress = (i: number, n: number, t: number, d: number): number => (i + (d > 0 ? Math.min(1, Math.max(0, t / d)) : 0)) / n;diff --git a/tests/e2e/home-bento.mjs b/tests/e2e/home-bento.mjsindex e5f3fc10..87a5bee6 100644--- a/tests/e2e/home-bento.mjs+++ b/tests/e2e/home-bento.mjs@@ -1,11 +1,12 @@// 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)+// Usage: node tests/e2e/home-bento.mjs [appUrl] [--shots <dir>] [--weight-only] [--only 1b,1c,1d,4,5] (pnpm test:e2e:home)// E2E_BROWSER=webkit or firefox: run it in that engine (tests/e2e/_browser.mjs).// 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).+// --only <ids>: run only these numbered parts (the weight, 6, always runs unless --weight-only is all that's asked).//// 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 in its own words ("Make anything:" on one line; the second line whole from 768, and on a@@ -14,10 +15,15 @@// contact sheet of them all.// 1b. Sharp at every width and pixel ratio (1x, 2x, 3x): every picture on the first screen is at least as wide as its// box shows it (object-fit: cover, times the ratio), up to the widest copy there is, and so is each clip once it-// plays. No play sign on a tile that plays by itself, at any moment from the first paint until both clips play, and-// nothing shifts as a clip takes over from its still.+// plays (up to the widest copy of that clip). No play sign on a tile that plays by itself, at any moment from the+// first paint until both tiles play, and nothing shifts as a clip takes over from its still.// 1c. The swap: each tile's still is its clip's first frame (the clip at frame 0 over it differs by under 3 levels in// 255 on average), at 390@3x and 1440@2x.+// 1d. The video tile's reel, at 390@3x and 1440@2x, light and dark: its still is One Take's first frame; it plays One+// Take, Sand Storm and Crane Over the Head in that order and back to One Take, each crossfading into the next; each+// clip framed as listed (its object-position); never more than the clip playing and the next one loaded, the next+// asked for only once the current one plays; off screen it pauses, back on screen it goes on. A picture of each+// clip in the tile (--shots). Under reduced motion a hover plays One Take alone, on a loop.// 2. Layout shift under 0.01 at 390 and 1440, through a load and a scroll to the bottom and back.// 2b. The headline holds still when its parts come late, at 390@3x, 768 and 1440@2x (Chromium): with every font file// 2.5 s late, and with the HTML in two parts (cut after the second line's first words, 1.5 s apart, by a proxy) and@@ -26,10 +32,10 @@// 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 headline is still, 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.+// 5. Pause previews stops the reel 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 420 KB (the clips' posters are encoded close to their clips' first frames, and a 3x phone or a-// 2x laptop gets the catwalk's 1536 px still). The clips are reported on their own.+// 2x laptop gets the video tile's widest still). The clips are reported on their own.// 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";@@ -39,9 +45,12 @@ import { createRequire } from "node:module";import { DESKTOP, ENGINE, 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 app = (args.find((a, i) => !a.startsWith("--") && args[i - 1] !== "--shots" && args[i - 1] !== "--only") ?? "http://localhost:3620").replace(/\/$/, "");const shotsDir = args.includes("--shots") ? args[args.indexOf("--shots") + 1] : undefined;const weightOnly = args.includes("--weight-only");+const only = args.includes("--only") ? args[args.indexOf("--only") + 1].split(",") : undefined;+/** Whether part `id` runs (all of them, unless --weight-only or --only says otherwise). */+const run = (id) => !weightOnly && (!only || only.includes(id));if (shotsDir) fs.mkdirSync(shotsDir, { recursive: true });const browser = await launch();@@ -61,8 +70,11 @@ const WIDTHS = [{ w: 1920, h: 1080 },];const TILES = ["video", "image", "audio", "threeD", "restore", "numbers", "live", "canvas"];-/** The widest copy of each clip (scripts/gen-home-bento.mjs). */+/** The widest copy of a clip (scripts/gen-home-bento.mjs), where its element doesn't say (a reel clip's data-max). */const CLIP_MAX = 2048;+/** The video tile's reel, in order, and how each clip is framed (HOME_BENTO_REEL). */+const REEL = ["motion-one-take", "effect-sand-storm", "motion-crane-over-the-head"];+const REEL_POSITION = { "motion-one-take": "50% 15%", "effect-sand-storm": "50% 0%", "motion-crane-over-the-head": "50% 0%" };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). */@@ -164,7 +176,8 @@ const sharpness = (page) =>const r = v.getBoundingClientRect();const need = Math.ceil(Math.max(r.width, (r.height * v.videoWidth) / v.videoHeight) * dpr);const what = new URL(v.currentSrc).pathname.split("/").pop();- out.push({ what, tile: v.closest("[data-tile]").dataset.tile, has: v.videoWidth, need, max: CLIP_MAX, ok: v.videoWidth >= Math.min(need, CLIP_MAX) * 0.98 });+ const max = Number(v.dataset.max) || CLIP_MAX;+ out.push({ what, tile: v.closest("[data-tile]").dataset.tile, has: v.videoWidth, need, max, ok: v.videoWidth >= Math.min(need, max) * 0.98 });}return out;}, CLIP_MAX);@@ -172,7 +185,7 @@ const sharpness = (page) =>// ------------------------------------------------------------------------------------------- 1. every widthconst shots = [];const sharpNotes = [];-if (!weightOnly)+if (run("1"))for (const who of ["guest", "owner"]) {for (const scheme of ["light", "dark"]) {for (const v of WIDTHS) {@@ -246,7 +259,7 @@ const watchSwap = () => {};// ------------------------------------------------------------------------------------------- 1b. sharp at every ratio-if (!weightOnly)+if (run("1b"))for (const v of WIDTHS)for (const dpr of [1, 2, 3]) {const ctx = await browser.newContext({ ...(v.phone ? PHONE : {}), viewport: { width: v.w, height: v.h }, deviceScaleFactor: dpr });@@ -255,7 +268,7 @@ if (!weightOnly)await open(page);// The clips start once their tile's still is up and on screen: wait until each has its first frame.await page- .waitForFunction(() => [...document.querySelectorAll("#home-bento [data-tile] video")].filter((x) => x.videoWidth > 0).length >= 2, null, { timeout: 12_000 })+ .waitForFunction(() => ["video", "threeD"].every((t) => [...document.querySelectorAll(`#home-bento [data-tile=${t}] video`)].some((x) => x.videoWidth > 0)), null, { timeout: 12_000 }).catch(() => {});await page.waitForTimeout(300);const s = await sharpness(page);@@ -263,7 +276,7 @@ if (!weightOnly)const clips = s.filter((x) => x.what.endsWith(".mp4"));check(`sharp at ${v.w}@${dpr}x: ${s.length} pictures and clips at least their box x ratio`,- bad.length === 0 && clips.length === 2,+ bad.length === 0 && new Set(clips.map((x) => x.tile)).size === 2,(bad.length ? bad : clips).map((x) => `${x.tile} ${x.what} ${x.has} for ${x.need} (max ${x.max})`).join("; "),);sharpNotes.push(`${v.w}@${dpr}x: ${s.map((x) => `${x.tile} ${x.what} ${x.has}/${x.need}`).join(", ")}`);@@ -299,7 +312,7 @@ async function swapDiff(page, tile) {for (let i = 0; i < a.length; i++) sum += Math.abs(a[i] - b[i]);return { diff: sum / a.length, withClip, still };}-if (!weightOnly)+if (run("1c"))for (const [v, dpr] of [[WIDTHS[0], 3],[WIDTHS[4], 2],@@ -307,7 +320,7 @@ if (!weightOnly)const ctx = await browser.newContext({ ...(v.phone ? PHONE : {}), viewport: { width: v.w, height: v.h }, deviceScaleFactor: dpr });const page = await ctx.newPage();await open(page);- await page.waitForFunction(() => document.querySelectorAll("#home-bento [data-tile] video[data-ready]").length >= 2, null, { timeout: 12_000 }).catch(() => {});+ await page.waitForFunction(() => ["video", "threeD"].every((t) => document.querySelector(`#home-bento [data-tile=${t}] video[data-ready]`)), null, { timeout: 12_000 }).catch(() => {});for (const tile of ["video", "threeD"]) {if (!(await page.locator(`#home-bento [data-tile=${tile}] video[data-ready]`).count())) {check(`the swap at ${v.w}@${dpr}x, ${tile}: its clip plays`, false);@@ -324,6 +337,124 @@ if (!weightOnly)await ctx.close();}+// ------------------------------------------------------------------------------------------- 1d. the reel+/**+ * Logs the video tile's reel from the first paint: the clip on screen (data-reel) each time it changes, and every+ * moment it holds more than one clip, with each one's state; the time each clip's element first asks for its file is+ * logged on the test's side (the same clock: Date.now()).+ */+const watchReel = () => {+ window.__reel = { turns: [], most: 0, both: [], playing: {}, fades: 0 };+ const look = () => {+ const span = document.querySelector("#home-bento [data-tile=video] .hb-clip");+ if (span) {+ const at = span.dataset.reel;+ const last = window.__reel.turns.at(-1);+ if (at !== undefined && last?.i !== at) window.__reel.turns.push({ i: at, t: Date.now() });+ const vids = [...span.querySelectorAll("video")];+ window.__reel.most = Math.max(window.__reel.most, vids.length);+ for (const v of vids) if (!v.paused && !window.__reel.playing[v.dataset.clip + "@" + at]) window.__reel.playing[v.dataset.clip + "@" + at] = Date.now();+ const shown = vids.filter((v) => v.hasAttribute("data-ready"));+ if (shown.length > 1) {+ const o = Number(getComputedStyle(shown.at(-1)).opacity);+ if (o > 0.05 && o < 0.95) window.__reel.fades++;+ }+ if (vids.length > 1 && window.__reel.both.length < 400) window.__reel.both.push({ t: Date.now(), clips: vids.map((v) => v.dataset.clip) });+ }+ requestAnimationFrame(look);+ };+ requestAnimationFrame(look);+};+if (run("1d")) {+ for (const [v, dpr] of [+ [WIDTHS[0], 3],+ [WIDTHS[4], 2],+ ])+ for (const scheme of ["light", "dark"]) {+ const tag = `${v.w}@${dpr}x ${scheme}`;+ const ctx = await browser.newContext({ ...(v.phone ? PHONE : {}), viewport: { width: v.w, height: v.h }, deviceScaleFactor: dpr, colorScheme: scheme });+ const page = await ctx.newPage();+ const asked = [];+ page.on("request", (r) => {+ const m = /\/previews\/home\/(reel-[a-z-]+)-(\d+)\.mp4/.exec(r.url());+ if (m) asked.push({ name: m[1], w: Number(m[2]), t: Date.now() });+ });+ await page.addInitScript(watchReel);+ await open(page);+ // The still: One Take's first frame, framed as its clip is.+ const still = await page.evaluate(() => {+ const img = document.querySelector("#home-bento [data-tile=video] picture img");+ return { src: new URL(img.currentSrc || img.src).pathname.split("/").pop(), pos: getComputedStyle(img).objectPosition };+ });+ check(`reel ${tag}: the still is One Take's first frame, framed as its clip`, /^reel-one-take-\d+\.(avif|jpg)$/.test(still.src) && still.pos === REEL_POSITION[REEL[0]], JSON.stringify(still));+ // Round the reel once and into One Take again (about 11 s), a picture of each clip as it plays.+ const seen = [];+ const deadline = Date.now() + 25_000;+ while (Date.now() < deadline) {+ const turns = await page.evaluate(() => window.__reel.turns.map((x) => x.i));+ for (const i of turns.slice(seen.length)) {+ seen.push(i);+ if (seen.length > REEL.length) continue;+ // Halfway through the clip: well after its fade in.+ await page.waitForTimeout(1600);+ const now = await page.evaluate(() => {+ const vids = [...document.querySelectorAll("#home-bento [data-tile=video] video")];+ const shown = vids.filter((x) => x.hasAttribute("data-ready"));+ const top = shown[0];+ return top ? { clip: top.dataset.clip, pos: getComputedStyle(top).objectPosition, w: top.videoWidth, paused: top.paused, t: top.currentTime } : null;+ });+ check(`reel ${tag}: clip ${Number(i) + 1} is ${REEL[i]}, playing, framed ${REEL_POSITION[REEL[i]]}`, now?.clip === REEL[i] && now.pos === REEL_POSITION[REEL[i]] && !now.paused, JSON.stringify(now));+ if (shotsDir) await page.locator("#home-bento [data-tile=video]").screenshot({ path: path.join(shotsDir, `reel-${v.w}-${scheme}-${Number(i) + 1}-${REEL[i]}.png`) });+ }+ if (seen.length > REEL.length) break;+ await page.waitForTimeout(150);+ }+ const r = await page.evaluate(() => window.__reel);+ check(`reel ${tag}: plays the clips in order and back to the first`, seen.join() === "0,1,2,0", seen.join());+ check(`reel ${tag}: each clip crossfades into the next`, r.fades >= 3, `${r.fades} frames mid-fade`);+ check(`reel ${tag}: never more than the clip playing and the next one`, r.most <= 2, String(r.most));+ // Each clip asked for only once the one before it plays; at most one ahead of the clip on screen.+ const order = asked.map((a) => a.name);+ const firstAsk = (name) => asked.find((a) => a.name === name)?.t;+ const names = REEL.map((id) => `reel-${{ "motion-one-take": "one-take", "effect-sand-storm": "sand-storm", "motion-crane-over-the-head": "crane-over" }[id]}`);+ const aheadOk = names.slice(1).every((name, i) => {+ const t = firstAsk(name);+ const prevPlays = r.playing[`${REEL[i]}@${i}`];+ return t !== undefined && prevPlays !== undefined && t >= prevPlays - 100;+ });+ check(`reel ${tag}: each clip loads only once the one before it plays`, aheadOk, `asked ${order.join(" ")}; playing ${JSON.stringify(r.playing)}`);+ const widths = [...new Set(asked.map((a) => `${a.name}-${a.w}`))];+ notes.push(`reel ${tag}: ${widths.join(", ")}`);+ // Off screen it pauses; back on screen it goes on.+ await page.evaluate(() => window.scrollTo(0, document.documentElement.scrollHeight));+ await page.waitForTimeout(900);+ const off = await page.evaluate(() => [...document.querySelectorAll("#home-bento [data-tile=video] video")].map((x) => x.paused));+ await page.evaluate(() => window.scrollTo(0, 0));+ await page.waitForTimeout(1500);+ const on = await page.evaluate(() => [...document.querySelectorAll("#home-bento [data-tile=video] video[data-ready]")].map((x) => x.paused));+ check(`reel ${tag}: pauses off screen, plays again in view`, off.length > 0 && off.every(Boolean) && on.some((p) => !p), `off ${off} on ${on}`);+ await ctx.close();+ }++ // Reduced motion: nothing plays by itself; a hover plays One Take alone, on a loop.+ const ctx = await browser.newContext({ ...DESKTOP, reducedMotion: "reduce" });+ const page = await ctx.newPage();+ const asked = [];+ page.on("request", (r) => /\/previews\/home\/reel-/.test(r.url()) && r.url().includes(".mp4") && asked.push(new URL(r.url()).pathname.split("/").pop()));+ await open(page);+ await page.waitForTimeout(2500);+ const before = asked.length;+ await page.locator("#home-bento [data-tile=video]").hover();+ await page.waitForTimeout(6500);+ const st = await page.evaluate(() => [...document.querySelectorAll("#home-bento [data-tile=video] video")].map((x) => ({ clip: x.dataset.clip, loop: x.loop, paused: x.paused })));+ check(+ "reduced motion: no reel clip until asked; a hover plays One Take alone, on a loop",+ before === 0 && st.length === 1 && st[0].clip === REEL[0] && st[0].loop && !st[0].paused && asked.every((a) => a.startsWith("reel-one-take-")),+ JSON.stringify({ before, st, asked }),+ );+ await ctx.close();+}+// ------------------------------------------------------------------------------------------- 2. layout shiftasync function cls(v) {const ctx = await browser.newContext(viewportOpts(v));@@ -354,7 +485,7 @@ async function cls(v) {await ctx.close();return { firstScreen, ...all };}-if (!weightOnly)+if (run("2"))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)));@@ -431,7 +562,7 @@ async function headlineShot(page) {return page.locator("#home-bento h1").screenshot();}-if (!weightOnly && ENGINE === "chromium") {+if (run("2b") && ENGINE === "chromium") {const sharp = createRequire(path.join(root, "package.json"))("sharp");const diff = async (a, b) => {const [x, y] = await Promise.all([a, b].map((p) => sharp(p).removeAlpha().raw().toBuffer({ resolveWithObject: true })));@@ -510,7 +641,7 @@ if (!weightOnly && ENGINE === "chromium") {}// ------------------------------------------------------------------------------------------- 3. links-if (!weightOnly) {+if (run("3")) {const ctx = await browser.newContext(DESKTOP);const page = await ctx.newPage();await open(page);@@ -540,7 +671,7 @@ if (!weightOnly) {}// ------------------------------------------------------------------------------------------- 4. reduced motion, Save-Data-if (!weightOnly) {+if (run("4")) {const ctx = await browser.newContext({ ...DESKTOP, reducedMotion: "reduce" });const page = await ctx.newPage();const clips = [];@@ -578,7 +709,7 @@ if (!weightOnly) {}// ------------------------------------------------------------------------------------------- 5. pause previews-if (!weightOnly) {+if (run("5")) {const ctx = await browser.newContext(DESKTOP);const page = await ctx.newPage();await open(page);@@ -592,7 +723,7 @@ if (!weightOnly) {return v && !v.paused && v.currentTime > 0.2;}, null, { timeout: 8000 }).catch(() => {});const before = await playing();- check("the catwalk plays by itself", !!before && !before.paused, JSON.stringify(before));+ check("the reel plays by itself", !!before && !before.paused, JSON.stringify(before));await page.getByRole("button", { name: "Pause previews" }).click();await page.waitForTimeout(400);const after = await page.evaluate(() => ({@@ -678,6 +809,7 @@ async function weight(v) {media,};}+if (weightOnly || run("6"))for (const v of [WIDTHS[0], WIDTHS[3], WIDTHS[4], WIDTHS[5]]) {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@@ -688,7 +820,7 @@ for (const v of [WIDTHS[0], WIDTHS[3], WIDTHS[4], WIDTHS[5]]) {}// ------------------------------------------------------------------------------------------- 7. composer-if (!weightOnly) {+if (run("7")) {const ctx = await browser.newContext(DESKTOP);const page = await ctx.newPage();await open(page);@@ -706,7 +838,7 @@ if (!weightOnly) {}// ------------------------------------------------------------------------------------------- 8. names and Tab order-if (!weightOnly) {+if (run("8")) {const ctx = await browser.newContext(DESKTOP);const page = await ctx.newPage();await open(page);diff --git a/tests/home-bento.test.ts b/tests/home-bento.test.tsindex 5038b93d..0bebdc78 100644--- a/tests/home-bento.test.ts+++ b/tests/home-bento.test.ts@@ -30,7 +30,7 @@ vi.mock("next/navigation", () => ({useSearchParams: () => new URLSearchParams(),}));-const { BENTO_BOARD, BENTO_CLIPS, BENTO_CLIP_WIDTHS, BENTO_HREFS, BENTO_BEFORE_AFTER, BENTO_IMAGE_EXAMPLE, livePhrases, openModelsOf } = await import("@/lib/home-bento");+const { BENTO_BOARD, BENTO_CLIPS, BENTO_CLIP_WIDTHS, BENTO_HREFS, BENTO_BEFORE_AFTER, BENTO_IMAGE_EXAMPLE, BENTO_REEL, BENTO_REEL_ID, 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");@@ -64,11 +64,8 @@ describe("Home's first screen", () => {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 in four widths, at the length of their published clips", () => {- const tiles = [- { tile: bento.video, name: "catwalk", published: "motion-catwalk", seconds: 4 },- { tile: bento.threeD, name: "rotation", published: "app-3d-rotation", seconds: 3.04 },- ];+ it("plays the turning gown in four widths, at the length of its published clip", () => {+ const tiles = [{ tile: bento.threeD, name: "rotation", published: "app-3d-rotation", seconds: 3.04 }];for (const { tile, name, published, seconds } of tiles) {expect(tile.id).toBe(published);expect(tile.clips.map((c) => c.w)).toEqual([...BENTO_CLIP_WIDTHS]);@@ -87,6 +84,26 @@ describe("Home's first screen", () => {}});+ it("plays One Take, Sand Storm and Crane Over the Head in turn, on the first one's first frame", () => {+ const v = bento.video;+ expect(v.id).toBe(BENTO_REEL_ID);+ expect(v.reel.map((c) => c.id)).toEqual(["motion-one-take", "effect-sand-storm", "motion-crane-over-the-head"]);+ expect(v.reel.map((c) => c.id)).toEqual(BENTO_REEL);+ for (const c of v.reel) {+ // At least the 640 and 1024 px copies, each a width a still or clip comes in, narrowest first.+ expect(c.clips.map((x) => x.w).slice(0, 2)).toEqual([640, 1024]);+ for (const x of c.clips) expect(BENTO_CLIP_WIDTHS).toContain(x.w);+ expect(c.position).toMatch(/^\d+% \d+%$/);+ }+ // The poster: the first clip's first frame, in the widths that clip comes in, and a JPEG at 1024 px.+ const first = v.reel[0];+ expect(v.poster.avif.map((a) => a.w)).toEqual(first.clips.map((x) => x.w));+ for (const a of v.poster.avif) expect(a.src).toMatch(new RegExp(`^/previews/home/reel-one-take-${a.w}\\.avif\\?v=`));+ expect(v.poster.fallback).toMatch(/^\/previews\/home\/reel-one-take-1024\.jpg\?v=/);+ // It is framed as its clip is: the poster's position is the first clip's, on the page.+ expect(html).toContain(`object-position:${first.position}`);+ });+it("lists every picture at its real width", async () => {const pictures: BentoPicture[] = [bento.video.poster, bento.threeD.poster, bento.image, bento.restore.before, bento.restore.after];for (const p of pictures)@@ -106,7 +123,7 @@ describe("Home's first screen", () => {expect(coverWidth(173, 173, 4 / 3, 3)).toBe(692);expect(coverWidth(569, 419, 4 / 3, 2)).toBe(1138);expect(coverWidth(476, 210, 4 / 3, 2)).toBe(952);- const clips = bento.video.clips;+ const clips = bento.threeD.clips;expect(pickWidth(clips, 300).w).toBe(640);expect(pickWidth(clips, 640).w).toBe(640);expect(pickWidth(clips, 641).w).toBe(1024);@@ -116,7 +133,14 @@ describe("Home's first screen", () => {expect(pickWidth(clips, 1728).w).toBe(2048);// Past the widest copy (its 2048 px master): the widest, never stretched further.expect(pickWidth(clips, 2400).w).toBe(2048);- for (const t of [bento.video, bento.threeD]) expect(Math.max(...t.clips.map((c) => c.w))).toBe(2048);+ expect(Math.max(...bento.threeD.clips.map((c) => c.w))).toBe(2048);+ // Each reel clip comes at least 1024 px wide (its render's own size), wider only from its 2048 px master: a 3x phone+ // (1068) gets the 1536 px copy where there is one, else the widest there is.+ for (const c of bento.video.reel) {+ const widest = Math.max(...c.clips.map((x) => x.w));+ expect(widest).toBeGreaterThanOrEqual(1024);+ expect(pickWidth(c.clips, 1068).w).toBe(widest >= 1536 ? 1536 : widest);+ }// The before/after pair covers a 3x phone (358 px wide) and the tall tile on a 2x 1920 screen.expect(Math.max(...bento.restore.after.avif.map((a) => a.w))).toBeGreaterThanOrEqual(358 * 3);expect(Math.max(...(bento.restore.after.tall ?? []).map((a) => a.w))).toBeGreaterThanOrEqual(602);@@ -217,7 +241,9 @@ describe("Home's first screen", () => {});it("plays each clip in one place on Home (the playback store keys by id)", () => {+ // The video tile plays its reel under its own id; the 3D tile's preset plays nowhere else.const ids = [+ BENTO_REEL_ID,...Object.values(BENTO_CLIPS),...[...HOME_EFFECTS, ...HOME_MOTIONS, ...HOME_REVEALS].map((r) => r.id),...HOME_BEFORE_AFTER.map((p) => p.id),diff --git a/tests/home-reel.test.ts b/tests/home-reel.test.tsnew file mode 100644index 00000000..4c57d00f--- /dev/null+++ b/tests/home-reel.test.ts@@ -0,0 +1,76 @@+import path from "node:path";+import { describe, expect, it } from "vitest";+import { HOME_BENTO_MEDIA, HOME_BENTO_REEL } from "@/lib/home-bento.generated";+import { REEL_FADE_MS, fadeDue, nextInReel, reelProgress, reelSources, type ReelClip } from "@/lib/home-reel";+import { REEL } from "../scripts/gen-home-bento.mjs";+import { mp4Seconds, mp4Size } from "./helpers/mp4-length";++/*+ * The video tile's reel on Home's first screen (src/lib/home-reel.ts, BentoReel in src/components/home/bento-islands.tsx,+ * REEL in scripts/gen-home-bento.mjs): the order it plays in, each clip's cut, and the copy it picks for a screen.+ */++const root = process.cwd();+const file = (url: string) => path.join(root, "public", url.split("?")[0]);++describe("Home's video reel", () => {+ it("plays One Take, then Sand Storm, then Crane Over the Head, then One Take again", () => {+ expect(HOME_BENTO_REEL.map((c) => c.id)).toEqual(["motion-one-take", "effect-sand-storm", "motion-crane-over-the-head"]);+ const n = HOME_BENTO_REEL.length;+ const order = [0];+ for (let i = 0; i < 6; i++) order.push(nextInReel(order.at(-1)!, n));+ expect(order).toEqual([0, 1, 2, 0, 1, 2, 0]);+ // The generated list is the script's, in the same order (run node scripts/gen-home-bento.mjs after changing REEL).+ expect(HOME_BENTO_REEL).toEqual(REEL.map(({ id, name, frames, position }) => ({ id, name, frames, fps: 24, position })));+ });++ it("cuts each clip to its stretch of the render: that many frames at 24 fps, played once", () => {+ for (const c of REEL) {+ // Inside the render (124 frames, 5.17 s), and long enough to read: 3.5 s or more.+ expect(c.from).toBeGreaterThanOrEqual(0);+ expect(c.from + c.frames).toBeLessThanOrEqual(124);+ expect(c.frames / 24).toBeGreaterThanOrEqual(3.5);+ for (const w of [640, 1024]) {+ const url = `/previews/home/${c.name}-${w}.mp4`;+ expect(HOME_BENTO_MEDIA[url], url).toBeDefined();+ expect(mp4Size(file(url))).toEqual({ w, h: (w * 3) / 4 });+ // Its own length, not the 4 s loop of a cover clip: no frames crossfaded back into its start.+ expect(mp4Seconds(file(url))).toBeCloseTo(c.frames / 24, 2);+ }+ }+ // The stretches chosen: One Take from frame 28 to its end, Sand Storm's first 84, Crane Over the Head from 36.+ expect(REEL.map((c) => [c.from, c.frames])).toEqual([+ [28, 96],+ [0, 84],+ [36, 88],+ ]);+ });++ it("picks each clip's narrowest copy at least as wide as the tile needs, else its widest", () => {+ const reel: ReelClip[] = [+ { id: "a", position: "50% 15%", clips: [640, 1024].map((w) => ({ src: `a-${w}`, w })) },+ { id: "b", position: "50% 0%", clips: [640, 1024, 1536, 2048].map((w) => ({ src: `b-${w}`, w })) },+ ];+ expect(reelSources(reel, 500)).toEqual(["a-640", "b-640"]);+ expect(reelSources(reel, 1000)).toEqual(["a-1024", "b-1024"]);+ // A 3x phone (358 px box: 1074) and a 2x laptop (567 px box: 1134): the 1536 px copy where there is one.+ expect(reelSources(reel, 1074)).toEqual(["a-1024", "b-1536"]);+ expect(reelSources(reel, 1134)).toEqual(["a-1024", "b-1536"]);+ expect(reelSources(reel, 3000)).toEqual(["a-1024", "b-2048"]);+ });++ it("starts the crossfade a fade's length before a clip's end, and follows the whole reel", () => {+ expect(REEL_FADE_MS).toBeGreaterThanOrEqual(400);+ expect(REEL_FADE_MS).toBeLessThanOrEqual(600);+ expect(fadeDue(3.4, 4)).toBe(false);+ expect(fadeDue(4 - REEL_FADE_MS / 1000, 4)).toBe(true);+ expect(fadeDue(4, 4)).toBe(true);+ // Not before its length is known.+ expect(fadeDue(0, NaN)).toBe(false);+ expect(fadeDue(0, 0)).toBe(false);+ expect(reelProgress(0, 3, 0, 4)).toBe(0);+ expect(reelProgress(1, 3, 2, 4)).toBeCloseTo(0.5, 5);+ expect(reelProgress(2, 3, 4, 4)).toBe(1);+ expect(reelProgress(1, 3, 1, NaN)).toBeCloseTo(1 / 3, 5);+ });+});diff --git a/tests/home-showcase.test.ts b/tests/home-showcase.test.tsindex a69efae0..ed80c2f9 100644--- a/tests/home-showcase.test.ts+++ b/tests/home-showcase.test.ts@@ -24,7 +24,7 @@ import {presetHref,roundedDown,} from "@/lib/home-showcase";-import { BENTO_CLIPS } from "@/lib/home-bento";+import { BENTO_CLIPS, BENTO_REEL } 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";@@ -57,7 +57,10 @@ const CLIP_PENDING = ["motion-flying"];const studioIds = HOME_STUDIOS.flatMap((s) => (s.id ? [s.id] : []));const rows = [...HOME_EFFECTS, ...HOME_MOTIONS, ...HOME_REVEALS];-/** Every preset whose clip plays on Home: the first screen's two, the rows, the before/after and the studio cards. */+/**+ * Every preset whose clip plays on Home under its own id: the 3D tile's, the rows, the before/after and the studio+ * cards. The video tile plays its reel (BENTO_REEL) under an id of its own, so a camera move in it may also have its card.+ */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[] = [];@@ -69,7 +72,7 @@ const clipSeconds = (url: string) => mp4Seconds(path.join(root, "public", url.spdescribe("Home's showcase", () => {it("names real presets, each with its cover and, where the slot plays one, its clip", () => {- for (const id of homeIds) {+ for (const id of [...homeIds, ...BENTO_REEL]) {expect(getPreset(id), id).toBeDefined();const cover = PRESET_PREVIEWS[id];expect(cover, `${id} has a real cover`).toBeDefined();