A Claude Code skill that reverse-engineers any animation frame by frame, then proves the copy moves the same.
// A static file server for site/, so the video page, its clips and the example pages share one origin.
// bun video/scripts/serve.ts [--port 4700]
// The video is at /video/, the examples at /public/examples/<name>/.
import { createReadStream, existsSync, statSync } from "node:fs";
import { createServer, type Server } from "node:http";
import { extname, join, normalize } from "node:path";
import { fileURLToPath } from "node:url";
export const SITE = join(import.meta.dirname, "..", "..");
const TYPES: Record<string, string> = {
".html": "text/html; charset=utf-8",
".js": "text/javascript; charset=utf-8",
".mjs": "text/javascript; charset=utf-8",
".css": "text/css; charset=utf-8",
".json": "application/json",
".svg": "image/svg+xml",
".png": "image/png",
".jpg": "image/jpeg",
".webp": "image/webp",
".avif": "image/avif",
".woff2": "font/woff2",
".mp3": "audio/mpeg",
".mp4": "video/mp4",
".glb": "model/gltf-binary",
".wasm": "application/wasm",
};
/** Serves site/ on `port`; resolves once it is listening. */
export function serve(port: number): Promise<Server> {
const server = createServer((req, res) => {
let path = decodeURIComponent(new URL(req.url ?? "/", "http://localhost").pathname);
if (path.endsWith("/")) path += "index.html";
const file = normalize(join(SITE, path));
if (!file.startsWith(SITE) || !existsSync(file) || !statSync(file).isFile()) {
res.writeHead(404).end("not found");
return;
}
res.writeHead(200, { "content-type": TYPES[extname(file)] ?? "application/octet-stream", "cache-control": "max-age=3600" });
createReadStream(file).pipe(res);
});
return new Promise((resolve) => server.listen(port, () => resolve(server)));
}
if (process.argv[1] === fileURLToPath(import.meta.url)) {
const i = process.argv.indexOf("--port");
const port = i > 0 ? Number(process.argv[i + 1]) : 4700;
await serve(port);
console.log(`http://localhost:${port}/video/`);
}