Production-ready animations, transitions, backgrounds, and scenes for Remotion
TypeScript ai-agentsclaude-codedemo-videomcpmcp-servermodel-context-protocolmotion-designproduct-demoreactremotionshadcnvideo
feat: privacy tearm
kapishdimaf1de41f87994
diff --git a/app/(home)/components/header-nav.tsx b/app/(home)/components/header-nav.tsxindex 5b5b8413..21d416d7 100644--- a/app/(home)/components/header-nav.tsx+++ b/app/(home)/components/header-nav.tsx@@ -103,7 +103,7 @@ export function NavFooter({className?: string;}) {return (- <nav className={cn("flex gap-6", className)}>+ <nav className={cn("flex flex-wrap gap-x-6 gap-y-2", className)}>{links.map((link) => {const external = link.href.startsWith("http");const linkClassName =diff --git a/app/(home)/components/site-footer.tsx b/app/(home)/components/site-footer.tsxindex 0805ed08..05e16b08 100644--- a/app/(home)/components/site-footer.tsx+++ b/app/(home)/components/site-footer.tsx@@ -1,13 +1,21 @@-import { FOOTER_NAV } from "@/config/site";+import { FOOTER_NAV, SUPPORT_EMAIL } from "@/config/site";import { NavFooter } from "./header-nav";export function SiteFooter() {return (<div className="section"><footer className="flex flex-col items-start justify-between gap-4 border-t border-border pt-8 pb-12 text-sm text-muted-foreground md:flex-row md:items-center">- <span suppressHydrationWarning>- © {new Date().getFullYear()} remocn — MIT licensed- </span>+ <div className="flex flex-col gap-1">+ <span suppressHydrationWarning>+ © {new Date().getFullYear()} remocn — MIT licensed+ </span>+ <a+ href={`mailto:${SUPPORT_EMAIL}`}+ className="w-fit transition-colors hover:text-foreground focus-visible:text-foreground focus-visible:outline-none"+ >+ {SUPPORT_EMAIL}+ </a>+ </div><NavFooter links={FOOTER_NAV} /></footer></div>diff --git a/app/(home)/legal/page.tsx b/app/(home)/legal/page.tsxnew file mode 100644index 00000000..696940de--- /dev/null+++ b/app/(home)/legal/page.tsx@@ -0,0 +1,193 @@+import type { Metadata } from "next";+import { GITHUB_URL, SUPPORT_EMAIL } from "@/config/site";++const DESCRIPTION =+ "How remocn handles your data, and the terms that apply to the site, the free components, and paid products.";++export const metadata: Metadata = {+ title: "Privacy & Terms",+ description: DESCRIPTION,+ alternates: { canonical: "/legal" },+ openGraph: {+ type: "website",+ url: "/legal",+ siteName: "Remocn",+ title: "Privacy & Terms · remocn",+ description: DESCRIPTION,+ locale: "en_US",+ images: [+ {+ url: "/hero.png",+ width: 1200,+ height: 675,+ alt: "Privacy & Terms · remocn",+ },+ ],+ },+ twitter: {+ card: "summary_large_image",+ title: "Privacy & Terms · remocn",+ description: DESCRIPTION,+ images: ["/hero.png"],+ },+};++const LAST_UPDATED = "July 24, 2026";++export default function LegalPage() {+ return (+ <>+ <section className="pt-24 pb-10 sm:pt-28">+ <div className="section">+ <h1 className="text-4xl font-semibold leading-[1.05] tracking-tight text-foreground sm:text-5xl">+ Privacy & Terms+ </h1>+ <p className="mt-4 max-w-2xl text-balance text-base leading-relaxed text-muted-foreground sm:text-lg">+ How remocn handles your data, and the terms that apply when you use+ the site or buy something. Last updated {LAST_UPDATED}.+ </p>+ </div>+ </section>++ <section className="pb-24">+ <div className="section">+ <div className="typeset typeset-docs max-w-3xl">+ <p>+ remocn (“we”) operates{" "}+ <a href="https://remocn.dev">remocn.dev</a> — an open-source+ registry of video components for Remotion. If anything on this+ page is unclear, email us at{" "}+ <a href={`mailto:${SUPPORT_EMAIL}`}>{SUPPORT_EMAIL}</a>.+ </p>++ <h2 id="privacy">Privacy Policy</h2>++ <h3>What we collect</h3>+ <p>+ The site has no accounts and no sign-up. You can browse the docs,+ copy components, and use everything on the site without giving us+ any personal data.+ </p>+ <ul>+ <li>+ <strong>Usage analytics.</strong> We use{" "}+ <a href="https://openpanel.dev">OpenPanel</a> to collect+ anonymous usage data: pages visited, referrer, browser and+ device type, and coarse location (country level). This tells us+ which components people actually use. We do not use advertising+ trackers, we do not build cross-site profiles, and we never+ sell data.+ </li>+ <li>+ <strong>Local preferences.</strong> Your theme choice (light or+ dark) is stored in your browser's localStorage and never+ leaves your device.+ </li>+ <li>+ <strong>Server logs.</strong> Our hosting infrastructure keeps+ standard access logs (IP address, requested URL, timestamp) for+ security and operations. They are rotated automatically and not+ used for anything else.+ </li>+ </ul>++ <h3>Payments</h3>+ <p>+ Paid products are sold through{" "}+ <a href="https://creem.io">Creem</a>, our merchant of record.+ Creem runs the checkout and handles payment processing,+ invoicing, and taxes. Your card details go directly to Creem and+ its payment processors — they never touch our servers. After a+ purchase we receive only what is needed to deliver it: your email+ address, the product, and the order details. How Creem handles+ your data is described in{" "}+ <a href="https://www.creem.io/privacy">Creem's privacy+ policy</a>.+ </p>++ <h3>Third-party services</h3>+ <ul>+ <li>+ <a href="https://openpanel.dev">OpenPanel</a> — anonymous usage+ analytics.+ </li>+ <li>+ <a href="https://creem.io">Creem</a> — checkout and payments,+ as merchant of record.+ </li>+ <li>+ <a href={GITHUB_URL}>GitHub</a> — source code, issues, and+ sponsorships. Anything you do there is governed by+ GitHub's own terms.+ </li>+ </ul>++ <h3>Your data</h3>+ <p>+ We keep order emails for as long as we need them to provide+ support and meet legal obligations. To ask what we hold about+ you, or to have it deleted, email{" "}+ <a href={`mailto:${SUPPORT_EMAIL}`}>{SUPPORT_EMAIL}</a> and we+ will sort it out.+ </p>++ <h2 id="terms">Terms of Service</h2>++ <h3>The site and free components</h3>+ <p>+ The free components in the registry are released under the{" "}+ <a href={`${GITHUB_URL}/blob/main/LICENSE`}>MIT license</a>. You+ can copy them, modify them, and ship them in personal or+ commercial projects without attribution. The site and the+ components are provided “as is”, without warranty of+ any kind.+ </p>++ <h3>Paid products</h3>+ <p>+ Some products are paid. Unless a product states otherwise at+ purchase, buying it grants you a non-exclusive license to use it+ in any number of your own projects, commercial ones included.+ What it does not grant is the right to redistribute or resell+ the product itself — for example republishing the components in+ another registry, template marketplace, or paid bundle.+ </p>++ <h3>Purchases and refunds</h3>+ <p>+ Purchases are processed by Creem as merchant of record, so the+ sale itself is also subject to the terms Creem presents at+ checkout. If a product is broken or not as described, email{" "}+ <a href={`mailto:${SUPPORT_EMAIL}`}>{SUPPORT_EMAIL}</a> within 14+ days of purchase and we will fix it or refund you.+ </p>++ <h3>Liability</h3>+ <p>+ To the maximum extent permitted by law, we are not liable for+ indirect or consequential damages arising from your use of the+ site or its products, and our total liability is limited to the+ amount you paid us in the twelve months before the claim. Free+ products come with no liability at all — they are yours to own,+ audit, and modify.+ </p>++ <h3>Changes</h3>+ <p>+ We may update this page as the project evolves — for example+ when new products or services launch. The date at the top+ reflects the latest revision, and continued use of the site+ after a change means you accept it.+ </p>++ <h3>Contact</h3>+ <p>+ For anything related to privacy, purchases, or these terms:{" "}+ <a href={`mailto:${SUPPORT_EMAIL}`}>{SUPPORT_EMAIL}</a>.+ </p>+ </div>+ </div>+ </section>+ </>+ );+}diff --git a/app/sitemap.ts b/app/sitemap.tsindex b6c1d548..db288af3 100644--- a/app/sitemap.ts+++ b/app/sitemap.ts@@ -46,6 +46,12 @@ export default async function sitemap(): Promise<MetadataRoute.Sitemap> {changeFrequency: "weekly",priority: 0.6,},+ {+ url: `${SITE_URL}/legal`,+ lastModified: now,+ changeFrequency: "yearly",+ priority: 0.3,+ },];const docRoutes: MetadataRoute.Sitemap = source.getPages().map((page) => ({diff --git a/config/site.ts b/config/site.tsindex 23dc2e3a..03964f62 100644--- a/config/site.ts+++ b/config/site.ts@@ -9,6 +9,8 @@ export const MINT = "#A1EEBD";export const GITHUB_URL = "https://github.com/Remocn/remocn";+export const SUPPORT_EMAIL = "[email protected]";+/** Canonical example install command shown on the landing page. */export const INSTALL_COMMAND = "npx shadcn@latest add remocn/soft-blur-in";@@ -83,4 +85,5 @@ export const FOOTER_NAV: NavLink[] = [{ href: "/showcases", label: "Showcases" },{ href: GITHUB_URL, label: "GitHub" },{ href: "/sponsors", label: "Sponsors" },+ { href: "/legal", label: "Privacy & Terms" },];diff --git a/scripts/21st/generate.mts b/scripts/21st/generate.mtsnew file mode 100644index 00000000..9b7cbf43--- /dev/null+++ b/scripts/21st/generate.mts@@ -0,0 +1,397 @@+import { existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from "node:fs";+import path from "node:path";+import { fileURLToPath } from "node:url";+import registry from "@/registry/__index__";++const here = path.dirname(fileURLToPath(import.meta.url));+const root = path.resolve(here, "..", "..");+const outRoot = path.join(root, "out", "21st");+const publishRoot = path.join(outRoot, "publish");++const REMOTION_VERSION = "4.0.473";+const rootPkg = JSON.parse(readFileSync(path.join(root, "package.json"), "utf8"));+const versionOf = (dep: string): string => {+ const v = rootPkg.dependencies?.[dep] ?? rootPkg.devDependencies?.[dep];+ if (!v) throw new Error(`Unknown npm dep version for ${dep}`);+ return v;+};++interface ManifestItem {+ name: string;+ type: string;+ title: string;+ description: string;+ dependencies?: string[];+ registryDependencies?: string[];+ files: { path: string; type: string }[];+}++const sectionOf = new Map<string, string>();+const docsDir = path.join(root, "content", "docs");+for (const dir of readdirSync(docsDir, { withFileTypes: true })) {+ if (!dir.isDirectory()) continue;+ const metaPath = path.join(docsDir, dir.name, "meta.json");+ if (!existsSync(metaPath)) continue;+ const meta = JSON.parse(readFileSync(metaPath, "utf8"));+ for (const page of meta.pages ?? []) {+ if (typeof page === "string" && page !== "index") sectionOf.set(page, dir.name);+ }+}++const TAGS: Record<string, string[]> = {+ typography: ["remotion", "typography", "text-animation", "video"],+ effects: ["remotion", "effect", "animation", "video"],+ transitions: ["remotion", "transition", "animation", "video"],+ shaders: ["remotion", "background", "shader", "video"],+ social: ["remotion", "social", "animation", "video"],+ layout: ["remotion", "layout", "animation", "video"],+ compositions: ["remotion", "scene", "animation", "video"],+ ai: ["remotion", "ai", "animation", "video"],+ "ui-blocks": ["remotion", "ui", "animation", "video"],+ icons: ["remotion", "icon", "lucide", "animation", "video"],+};+const DEFAULT_TAGS = ["remotion", "animation", "video"];++interface ParsedImports {+ named: Map<string, Set<string>>;+ rest: string[];+}++function splitImports(code: string): { imports: ParsedImports; body: string } {+ const named = new Map<string, Set<string>>();+ const rest: string[] = [];+ const importRe = /import\s+(type\s+)?{([\s\S]*?)}\s+from\s+"([^"]+)";?\n?/g;+ const otherImportRe = /import\s+[^{}\n]*?\s+from\s+"[^"]+";?\n?/g;+ let body = code.replace(/^"use client";\n*/g, "");+ body = body.replace(importRe, (_m, typeOnly, specs: string, mod: string) => {+ if (mod === "@/lib/remocn-icons") return "";+ const set = named.get(mod) ?? new Set<string>();+ for (const raw of specs.split(",")) {+ const spec = raw.trim().replace(/\s+/g, " ");+ if (!spec) continue;+ set.add(typeOnly ? `type ${spec.replace(/^type /, "")}` : spec);+ }+ named.set(mod, set);+ return "";+ });+ body = body.replace(otherImportRe, (m) => {+ rest.push(m.trim());+ return "";+ });+ return { imports: { named, rest }, body: body.replace(/^\n+/, "") };+}++function mergeIconWithCore(iconCode: string, coreCode: string): string {+ const icon = splitImports(iconCode);+ const core = splitImports(coreCode);+ const named = new Map<string, Set<string>>();+ for (const src of [core.imports.named, icon.imports.named]) {+ for (const [mod, specs] of src) {+ const set = named.get(mod) ?? new Set<string>();+ for (const s of specs) {+ if (set.has(s.replace(/^type /, ""))) continue;+ if (s.startsWith("type ") || !set.has(`type ${s}`)) set.add(s);+ if (!s.startsWith("type ") && set.has(`type ${s}`)) set.delete(`type ${s}`), set.add(s);+ }+ named.set(mod, set);+ }+ }+ const importLines = [...named.entries()].map(+ ([mod, specs]) => `import { ${[...specs].sort().join(", ")} } from "${mod}";`,+ );+ const rest = [...new Set([...core.imports.rest, ...icon.imports.rest])];+ return `"use client";\n\n${[...importLines, ...rest].join("\n")}\n\n${core.body}\n${icon.body}`;+}++function demoSource(opts: {+ slug: string;+ exportName: string;+ props: Record<string, unknown>;+ width: number;+ height: number;+ fps: number;+ durationInFrames: number;+ background: string;+}): string {+ const { slug, exportName, props, width, height, fps, durationInFrames, background } = opts;+ const initialFrame = Math.min(Math.floor(durationInFrames * 0.66), durationInFrames - 1);+ const propsLiteral = JSON.stringify(props, null, 2).replace(/"([A-Za-z_$][A-Za-z0-9_$]*)":/g, "$1:");+ return `"use client";++import { Player, type PlayerRef } from "@remotion/player";+import { useEffect, useRef } from "react";+import { ${exportName} } from "./${slug}";++const DEFAULT_PROPS = ${propsLiteral} as const;++function DemoComposition() {+ return <${exportName} {...DEFAULT_PROPS} />;+}++export default function Demo() {+ const playerRef = useRef<PlayerRef>(null);++ useEffect(() => {+ let attempts = 0;+ const MAX_ATTEMPTS = 40;+ const id = setInterval(() => {+ const player = playerRef.current;+ if (player && !player.isPlaying()) player.play();+ attempts += 1;+ if (player?.isPlaying() || attempts >= MAX_ATTEMPTS) clearInterval(id);+ }, 250);+ return () => clearInterval(id);+ }, []);++ return (+ <Player+ ref={playerRef}+ component={DemoComposition}+ durationInFrames={${durationInFrames}}+ fps={${fps}}+ compositionWidth={${width}}+ compositionHeight={${height}}+ initialFrame={${initialFrame}}+ controls+ loop+ acknowledgeRemotionLicense+ style={{ width: "100%", background: ${JSON.stringify(background)} }}+ />+ );+}+`;+}++const coreCode = readFileSync(+ path.join(root, "registry", "remocn-icons", "icons-core", "index.ts"),+ "utf8",+);++const skipped: { slug: string; reason: string }[] = [];+const generated: {+ slug: string;+ exportName: string;+ modPath: string;+ width: number;+ height: number;+ fps: number;+ durationInFrames: number;+ background: string;+ props: Record<string, unknown>;+}[] = [];++const transpiler = new Bun.Transpiler({ loader: "tsx" });++for (const ns of ["remocn", "remocn-icons"] as const) {+ const manifest = JSON.parse(+ readFileSync(path.join(root, "registry", ns, "registry.json"), "utf8"),+ );+ for (const item of manifest.items as ManifestItem[]) {+ if (item.type !== "registry:component") continue;+ const slug = item.name;+ const entry = registry[slug];+ if (!entry) {+ skipped.push({ slug, reason: "no preview entry in __index__" });+ continue;+ }+ const loadSrc = entry.load.toString();+ const modMatch = loadSrc.match(/import\("([^"]+)"\)/);+ const exportMatch = loadSrc.match(/m\.([A-Za-z0-9_$]+)/);+ if (!modMatch || !exportMatch) {+ skipped.push({ slug, reason: "unparseable __index__ load" });+ continue;+ }+ const modPath = modMatch[1];+ const exportName = exportMatch[1];+ if (!modPath.startsWith("@/registry/")) {+ skipped.push({ slug, reason: `site wrapper preview (${modPath})` });+ continue;+ }+ const regDeps = item.registryDependencies ?? [];+ const nonCoreDeps = regDeps.filter((d) => d !== "@remocn/icons-core");+ if (nonCoreDeps.length > 0) {+ skipped.push({ slug, reason: `registry deps: ${nonCoreDeps.join(", ")}` });+ continue;+ }+ const srcFile = path.join(root, "registry", ns, item.files[0].path);+ if (!existsSync(srcFile)) {+ skipped.push({ slug, reason: `source not found: ${item.files[0].path}` });+ continue;+ }++ let code = readFileSync(srcFile, "utf8");+ if (regDeps.includes("@remocn/icons-core")) {+ code = mergeIconWithCore(code, coreCode);+ }+ if (code.includes("@/")) {+ skipped.push({ slug, reason: "unresolved @/ import after transform" });+ continue;+ }++ const config = entry.config;+ const backdrop = config.previewBackdrop;+ const background =+ backdrop && (backdrop.type === "color" || backdrop.type === "gradient")+ ? backdrop.value+ : "#ffffff";+ const props: Record<string, unknown> = {};+ for (const [key, ctrl] of Object.entries(config.controls)) {+ const numericSelect =+ ctrl.type === "select" &&+ /^\d+(\.\d+)?$/.test(ctrl.default) &&+ ctrl.options.every((o) => /^\d+(\.\d+)?$/.test(o));+ props[key] = numericSelect ? Number(ctrl.default) : ctrl.default;+ }+ const isIcon = regDeps.includes("@remocn/icons-core");+ let width = config.compositionWidth;+ let height = config.compositionHeight;+ if (isIcon && "size" in config.controls) {+ width = 480;+ height = 480;+ props.size = 480;+ }+ const demo = demoSource({+ slug,+ exportName,+ props,+ width,+ height,+ fps: config.fps,+ durationInFrames: config.durationInFrames,+ background,+ });++ try {+ transpiler.transformSync(code);+ transpiler.transformSync(demo);+ } catch (err) {+ skipped.push({ slug, reason: `transpile failed: ${String(err).slice(0, 120)}` });+ continue;+ }++ const importedPkgs = new Set<string>(item.dependencies ?? []);+ for (const m of code.matchAll(/(?:from\s+|import\s*\(\s*)"([^".@/][^"]*|@[^"]+)"/g)) {+ const spec = m[1];+ if (spec.startsWith("@/") || spec.startsWith(".")) continue;+ const parts = spec.split("/");+ importedPkgs.add(spec.startsWith("@") ? `${parts[0]}/${parts[1]}` : parts[0]);+ }+ importedPkgs.delete("react");+ importedPkgs.delete("react-dom");+ const npmDeps: Record<string, string> = { "@remotion/player": REMOTION_VERSION };+ let missingDep: string | null = null;+ for (const dep of importedPkgs) {+ try {+ npmDeps[dep] = dep.startsWith("@remotion/") || dep === "remotion" ? REMOTION_VERSION : versionOf(dep);+ } catch {+ missingDep = dep;+ break;+ }+ }+ if (missingDep) {+ skipped.push({ slug, reason: `unknown npm dep: ${missingDep}` });+ continue;+ }++ const dir = path.join(publishRoot, slug);+ mkdirSync(dir, { recursive: true });+ writeFileSync(path.join(dir, `${slug}.tsx`), code);+ writeFileSync(path.join(dir, "demo.tsx"), demo);+ writeFileSync(+ path.join(dir, "package.json"),+ `${JSON.stringify({ name: `remocn-21st-${slug}`, private: true, dependencies: npmDeps }, null, 2)}\n`,+ );+ writeFileSync(+ path.join(dir, "meta.json"),+ `${JSON.stringify(+ {+ name: item.title,+ slug,+ description: item.description,+ tags: (TAGS[sectionOf.get(slug) ?? (ns === "remocn-icons" ? "icons" : "")] ?? DEFAULT_TAGS).slice(0, 5),+ },+ null,+ 2,+ )}\n`,+ );+ generated.push({+ slug,+ exportName,+ modPath,+ width,+ height,+ fps: config.fps,+ durationInFrames: config.durationInFrames,+ background,+ props,+ });+ }+}++const coverImports = generated+ .map((g) => `import { ${g.exportName} as C_${g.slug.replace(/-/g, "_")} } from "${g.modPath}";`)+ .join("\n");+const coverComps = generated+ .map((g) => {+ const comp = `C_${g.slug.replace(/-/g, "_")}`;+ return ` <Composition+ id="${g.slug}"+ component={makeStage(${comp}, ${JSON.stringify(g.background)}, PROPS[${JSON.stringify(g.slug)}])}+ durationInFrames={${g.durationInFrames}}+ fps={${g.fps}}+ width={${g.width}}+ height={${g.height}}+ />`;+ })+ .join("\n");+const coverProps: Record<string, unknown> = {};+for (const g of generated) {+ coverProps[g.slug] = g.props;+}++writeFileSync(+ path.join(outRoot, "covers-root.tsx"),+ `import { loadFont } from "@remotion/google-fonts/Geist";+import type { ComponentType } from "react";+import { AbsoluteFill, Composition, registerRoot } from "remotion";+${coverImports}++const { fontFamily: GEIST } = loadFont();+const PROPS: Record<string, Record<string, unknown>> = ${JSON.stringify(coverProps, null, 2)};++function makeStage(Comp: ComponentType<any>, background: string, props: Record<string, unknown>) {+ return function Stage() {+ return (+ <AbsoluteFill+ style={{+ background,+ ["--font-geist-sans" as string]: GEIST,+ fontFamily: GEIST,+ }}+ >+ <Comp {...props} />+ </AbsoluteFill>+ );+ };+}++export function CoversRoot() {+ return (+ <>+${coverComps}+ </>+ );+}++registerRoot(CoversRoot);+`,+);++writeFileSync(+ path.join(outRoot, "generated.json"),+ `${JSON.stringify({ generated: generated.map((g) => g.slug), skipped }, null, 2)}\n`,+);++console.log(`generated: ${generated.length}`);+console.log(`skipped: ${skipped.length}`);+for (const s of skipped) console.log(` ${s.slug}: ${s.reason}`);diff --git a/scripts/21st/publish.mts b/scripts/21st/publish.mtsnew file mode 100644index 00000000..d025b575--- /dev/null+++ b/scripts/21st/publish.mts@@ -0,0 +1,132 @@+import { existsSync, readFileSync, readdirSync, writeFileSync } from "node:fs";+import path from "node:path";+import { fileURLToPath } from "node:url";++const here = path.dirname(fileURLToPath(import.meta.url));+const root = path.resolve(here, "..", "..");+const outRoot = path.join(root, "out", "21st");+const publishRoot = path.join(outRoot, "publish");+const resultsPath = path.join(outRoot, "results.json");++interface PublishResult {+ slug: string;+ status: "draft" | "failed";+ editor_url?: string;+ error?: string;+}++const CONCURRENCY = 3;++function loadResults(): Record<string, PublishResult> {+ if (!existsSync(resultsPath)) return {};+ return JSON.parse(readFileSync(resultsPath, "utf8"));+}++function saveResults(results: Record<string, PublishResult>) {+ writeFileSync(resultsPath, `${JSON.stringify(results, null, 2)}\n`);+}++function writeChecklist(results: Record<string, PublishResult>) {+ const drafts = Object.values(results).filter((r) => r.status === "draft");+ const failedList = Object.values(results).filter((r) => r.status === "failed");+ const lines = [+ "# 21st.dev CLI Review checklist",+ "",+ `Drafts: ${drafts.length} | Failed: ${failedList.length}`,+ "",+ ...drafts.map((r) => `- [ ] ${r.slug} — ${r.editor_url}`),+ ];+ if (failedList.length) {+ lines.push("", "## Failed", "", ...failedList.map((r) => `- ${r.slug}: ${r.error}`));+ }+ writeFileSync(path.join(outRoot, "checklist.md"), `${lines.join("\n")}\n`);+}++async function publishOne(slug: string): Promise<PublishResult> {+ const dir = path.join(publishRoot, slug);+ const meta = JSON.parse(readFileSync(path.join(dir, "meta.json"), "utf8"));+ const args = [+ "publish",+ `${slug}.tsx`,+ "--description",+ meta.description,+ "--demo",+ "demo.tsx",+ "--name",+ meta.name,+ "--slug",+ slug,+ "--tags",+ meta.tags.join(","),+ "--registry",+ "ui",+ "--no-open",+ ];+ if (existsSync(path.join(dir, "cover.png"))) {+ args.splice(2, 0, "--preview", "cover.png");+ }+ const proc = Bun.spawn(["21st", ...args], {+ cwd: dir,+ env: { ...process.env, CI: "1" },+ stdout: "pipe",+ stderr: "pipe",+ });+ const [stdout, stderr, exitCode] = await Promise.all([+ new Response(proc.stdout).text(),+ new Response(proc.stderr).text(),+ proc.exited,+ ]);+ const jsonLine = stdout+ .split("\n")+ .reverse()+ .find((l) => l.trim().startsWith("{"));+ if (jsonLine) {+ try {+ const parsed = JSON.parse(jsonLine);+ if (parsed.state === "draft" && parsed.editor_url) {+ return { slug, status: "draft", editor_url: parsed.editor_url };+ }+ } catch {}+ }+ const tail = `${stdout}\n${stderr}`.trim().split("\n").slice(-3).join(" | ").slice(0, 300);+ return { slug, status: "failed", error: `exit ${exitCode}: ${tail}` };+}++async function main() {+ const only = process.argv.includes("--only")+ ? process.argv[process.argv.indexOf("--only") + 1]?.split(",")+ : null;+ const results = loadResults();+ const all = readdirSync(publishRoot, { withFileTypes: true })+ .filter((d) => d.isDirectory())+ .map((d) => d.name);+ const queue = (only ?? all).filter((slug) => results[slug]?.status !== "draft");+ console.log(`publishing ${queue.length} components (of ${all.length})`);++ let index = 0;+ let done = 0;+ async function worker() {+ while (index < queue.length) {+ const slug = queue[index];+ index += 1;+ const result = await publishOne(slug);+ results[slug] = result;+ done += 1;+ saveResults(results);+ writeChecklist(results);+ console.log(+ `[${done}/${queue.length}] ${slug}: ${result.status}${result.status === "failed" ? ` (${result.error})` : ""}`,+ );+ }+ }+ await Promise.all(Array.from({ length: CONCURRENCY }, worker));++ const failedCount = Object.values(results).filter((r) => r.status === "failed").length;+ console.log(`done. drafts: ${Object.values(results).filter((r) => r.status === "draft").length}, failed: ${failedCount}`);+ console.log(`checklist: ${path.join(outRoot, "checklist.md")}`);+}++main().catch((err) => {+ console.error(err);+ process.exit(1);+});diff --git a/scripts/21st/render-covers.mts b/scripts/21st/render-covers.mtsnew file mode 100644index 00000000..abefe009--- /dev/null+++ b/scripts/21st/render-covers.mts@@ -0,0 +1,83 @@+import { existsSync, readFileSync } from "node:fs";+import path from "node:path";+import { fileURLToPath } from "node:url";+import { bundle } from "@remotion/bundler";+import { ensureBrowser, renderStill, selectComposition } from "@remotion/renderer";+import { tsconfigWebpackAlias } from "../tsconfig-webpack-alias.mts";++const here = path.dirname(fileURLToPath(import.meta.url));+const root = path.resolve(here, "..", "..");+const outRoot = path.join(root, "out", "21st");++async function main() {+ const { generated } = JSON.parse(readFileSync(path.join(outRoot, "generated.json"), "utf8")) as {+ generated: string[];+ };+ const only = process.argv.includes("--only")+ ? process.argv[process.argv.indexOf("--only") + 1]?.split(",")+ : null;+ const slugs = (only ?? generated).filter((slug) => {+ const output = path.join(outRoot, "publish", slug, "cover.png");+ return only ? true : !existsSync(output);+ });+ if (slugs.length === 0) {+ console.log("all covers already rendered");+ return;+ }++ await ensureBrowser();+ const tsAliases = tsconfigWebpackAlias(root);+ console.log(`Bundling covers root for ${slugs.length} covers…`);+ const serveUrl = await bundle({+ entryPoint: path.join(outRoot, "covers-root.tsx"),+ webpackOverride: (config) => {+ const existing = Object.entries(config.resolve?.alias ?? {}).map(([name, alias]) => ({+ name: name.replace(/\$$/, ""),+ alias: alias as string,+ onlyModule: name.endsWith("$"),+ }));+ return {+ ...config,+ resolve: {+ ...config.resolve,+ alias: [...existing, ...tsAliases],+ },+ };+ },+ });+ console.log("Bundle ready.");++ const failed: { slug: string; error: string }[] = [];+ let done = 0;+ for (const slug of slugs) {+ const output = path.join(outRoot, "publish", slug, "cover.png");+ try {+ const composition = await selectComposition({ serveUrl, id: slug });+ const frame = Math.min(+ Math.floor(composition.durationInFrames * 0.66),+ composition.durationInFrames - 1,+ );+ await renderStill({+ composition,+ serveUrl,+ output,+ frame,+ chromiumOptions: { gl: "swangle" },+ timeoutInMilliseconds: 60000,+ });+ } catch (err) {+ failed.push({ slug, error: String(err).slice(0, 200) });+ }+ done += 1;+ if (done % 10 === 0 || done === slugs.length) console.log(`covers: ${done}/${slugs.length}`);+ }+ if (failed.length) {+ console.log(`FAILED (${failed.length}):`);+ for (const f of failed) console.log(` ${f.slug}: ${f.error}`);+ }+}++main().catch((err) => {+ console.error(err);+ process.exit(1);+});