Production-ready animations, transitions, backgrounds, and scenes for Remotion
TypeScript ai-agentsclaude-codedemo-videomcpmcp-servermodel-context-protocolmotion-designproduct-demoreactremotionshadcnvideo
// Builds launch-pieces.generated.ts: every component whose docs page was
// added in the Remocn 3 release commits, in docs sidebar order, with the
// sidebar title of its category and its demo length from config.ts.
// Run from the repo root: bun src/remotion/release-demo/generate-pieces.mts
import { execFileSync } from "node:child_process";
import { existsSync, readFileSync, writeFileSync } from "node:fs";
import path from "node:path";
/** Launch Pack and Design Review. */
const RELEASE_COMMITS = ["fe6aa3d5", "d99519ef"];
const OUT = "src/remotion/release-demo/launch-pieces.generated.ts";
const addedPages = RELEASE_COMMITS.flatMap((commit) =>
execFileSync(
"git",
["show", "--name-status", "--format=", commit, "--", "content/docs"],
{ encoding: "utf8" },
)
.split("\n")
.filter((l) => l.startsWith("A\t") && l.endsWith(".mdx"))
.map((l) => l.split("\t")[1]),
);
const readJson = (file: string) =>
existsSync(file) ? JSON.parse(readFileSync(file, "utf8")) : {};
type Piece = {
name: string;
component: string;
title: string;
category: string;
frames: number;
motion: number;
order: number;
};
const pieces = new Map<string, Piece>();
for (const page of addedPages) {
const category = page.split("/")[2];
const source = existsSync(page) ? readFileSync(page, "utf8") : "";
const name = source.match(/^component:\s*"?([\w-]+)"?/m)?.[1];
if (!name || pieces.has(name)) continue;
const config = `registry/remocn/${name}/config.ts`;
if (!existsSync(config)) continue;
const configSource = readFileSync(config, "utf8");
const component = configSource.match(/componentName:\s*"(\w+)"/)?.[1];
const frames = configSource.match(/durationInFrames:\s*(\d+)/)?.[1];
if (!component || !frames) continue;
// Own motion from the docs frontmatter; the config length adds a hold.
const motion = Number(source.match(/^length:\s*"?(\d+)"?/m)?.[1] ?? frames);
const meta = readJson(path.join("content/docs", category, "meta.json"));
const order = (meta.pages ?? []).indexOf(name);
pieces.set(name, {
name,
component,
category,
title: meta.title ?? category,
frames: Number(frames),
motion,
order: order === -1 ? Number.MAX_SAFE_INTEGER : order,
});
}
const sorted = [...pieces.values()].sort(
(a, b) =>
a.category.localeCompare(b.category) ||
a.order - b.order ||
a.name.localeCompare(b.name),
);
const lines = [
"// Generated by generate-pieces.mts from the docs pages added in the",
"// Remocn 3 release (Launch Pack + Design Review). Do not hand-edit.",
'import type { ComponentType } from "react";',
...sorted.map(
(p, i) =>
`import { ${p.component} as C${i} } from "@/registry/remocn/${p.name}";`,
),
"",
"export type LaunchPiece = {",
" name: string;",
" /** Docs sidebar title of the piece's category. */",
" category: string;",
" /** Demo length from the piece's config, in frames at 30fps. */",
" frames: number;",
" /** Frames of the piece's own motion (docs `length`), without the hold. */",
" motion: number;",
" // biome-ignore lint/suspicious/noExplicitAny: every piece has its own props",
" component: ComponentType<any>;",
"};",
"",
"export const LAUNCH_PIECES: LaunchPiece[] = [",
...sorted.map(
(p, i) =>
` { name: "${p.name}", category: "${p.title}", frames: ${p.frames}, motion: ${p.motion}, component: C${i} },`,
),
"];",
"",
];
writeFileSync(OUT, lines.join("\n"));
console.log(`${sorted.length} pieces → ${OUT}`);