Skip to content

🎥 Make videos programmatically with React

add prettier

Jonny Burger1f60cb6862bf
diff --git a/packages/it-tests/src/templates/validate-templates.test.ts b/packages/it-tests/src/templates/validate-templates.test.ts
index dd7fbad970..1276c9aa0d 100644
--- a/packages/it-tests/src/templates/validate-templates.test.ts
+++ b/packages/it-tests/src/templates/validate-templates.test.ts
@@ -91,7 +91,7 @@ describe('Templates should be valid', () => {
/(remotion\sstudio)|(next dev)|(react-router dev)|(tsx watch)|(tsx src\/studio)|(bun studio\.ts)/,
);
expect(scripts.build).toMatch(
- /(remotion\sbundle)|(react-router build)|(next\sbuild)|(tsx src\/render)|(tsc \&\& vite build)/,
+ /(remotion\sbundle)|(react-router build)|(next\sbuild)|(tsx src\/render)|(tsc \&\& vite build)|(bun build\.ts)/,
);
});
diff --git a/packages/template-vercel/.prettierrc b/packages/template-vercel/.prettierrc
index 565d21bc8f..37d5071748 100644
--- a/packages/template-vercel/.prettierrc
+++ b/packages/template-vercel/.prettierrc
@@ -1,4 +1,5 @@
{
- "useTabs": true,
- "singleQuote": false
+ "useTabs": false,
+ "bracketSpacing": true,
+ "tabWidth": 2
}
diff --git a/packages/template-vercel/src/app/api/render/helpers.ts b/packages/template-vercel/src/app/api/render/helpers.ts
index 0b758b0173..09f6a1a670 100644
--- a/packages/template-vercel/src/app/api/render/helpers.ts
+++ b/packages/template-vercel/src/app/api/render/helpers.ts
@@ -3,38 +3,38 @@ import { readFile } from "fs/promises";
import path from "path";
export const createDisposableSandbox = async (
- options: Parameters<typeof Sandbox.create>[0],
+ options: Parameters<typeof Sandbox.create>[0],
): Promise<Sandbox & AsyncDisposable> => {
- const sandbox = await Sandbox.create(options);
- return Object.assign(sandbox, {
- [Symbol.asyncDispose]: async () => {
- await sandbox.stop().catch(() => {});
- },
- });
+ const sandbox = await Sandbox.create(options);
+ return Object.assign(sandbox, {
+ [Symbol.asyncDispose]: async () => {
+ await sandbox.stop().catch(() => {});
+ },
+ });
};
export const createDisposableWriter = (
- writer: WritableStreamDefaultWriter<Uint8Array>,
+ writer: WritableStreamDefaultWriter<Uint8Array>,
): WritableStreamDefaultWriter<Uint8Array> & AsyncDisposable => {
- return Object.assign(writer, {
- [Symbol.asyncDispose]: async () => {
- await writer.close();
- },
- });
+ return Object.assign(writer, {
+ [Symbol.asyncDispose]: async () => {
+ await writer.close();
+ },
+ });
};
export type RenderProgress =
- | { type: "phase"; phase: string; progress: number; subtitle?: string }
- | { type: "done"; url: string; size: number }
- | { type: "error"; message: string };
+ | { type: "phase"; phase: string; progress: number; subtitle?: string }
+ | { type: "done"; url: string; size: number }
+ | { type: "error"; message: string };
export type OnProgressFn = (message: RenderProgress) => Promise<void>;
export function formatSSE(message: RenderProgress): string {
- return `data: ${JSON.stringify(message)}\n\n`;
+ return `data: ${JSON.stringify(message)}\n\n`;
}
export async function getRenderScript(): Promise<Buffer> {
- const renderScriptPath = path.join(process.cwd(), "render.ts");
- return readFile(renderScriptPath);
+ const renderScriptPath = path.join(process.cwd(), "render.ts");
+ return readFile(renderScriptPath);
}
diff --git a/packages/template-vercel/src/app/api/render/render.ts b/packages/template-vercel/src/app/api/render/render.ts
index 754283bc35..892c7b3df3 100644
--- a/packages/template-vercel/src/app/api/render/render.ts
+++ b/packages/template-vercel/src/app/api/render/render.ts
@@ -4,77 +4,77 @@ import { BUILD_DIR } from "../../../../build-dir.mjs";
import type { RenderConfig } from "../../../../render";
export type RenderInSandboxProgress =
- | { type: "render-progress"; progress: number }
- | { type: "uploading" }
- | { type: "done"; url: string; size: number };
+ | { type: "render-progress"; progress: number }
+ | { type: "uploading" }
+ | { type: "done"; url: string; size: number };
export async function renderInSandbox({
- sandbox,
- inputProps,
- onProgress,
+ sandbox,
+ inputProps,
+ onProgress,
}: {
- sandbox: Sandbox & AsyncDisposable;
- inputProps: Record<string, unknown>;
- onProgress: (progress: RenderInSandboxProgress) => Promise<void>;
+ sandbox: Sandbox & AsyncDisposable;
+ inputProps: Record<string, unknown>;
+ onProgress: (progress: RenderInSandboxProgress) => Promise<void>;
}): Promise<void> {
- // Use the local bundle copied to the sandbox
- const serveUrl = `/vercel/sandbox/${BUILD_DIR}`;
+ // Use the local bundle copied to the sandbox
+ const serveUrl = `/vercel/sandbox/${BUILD_DIR}`;
- const renderId = crypto.randomUUID();
- const blobToken = process.env.BLOB_READ_WRITE_TOKEN;
- if (!blobToken) {
- throw new Error("BLOB_READ_WRITE_TOKEN is not set");
- }
+ const renderId = crypto.randomUUID();
+ const blobToken = process.env.BLOB_READ_WRITE_TOKEN;
+ if (!blobToken) {
+ throw new Error("BLOB_READ_WRITE_TOKEN is not set");
+ }
- const renderConfig: RenderConfig = {
- serveUrl,
- compositionId: COMP_NAME,
- inputProps,
- blobToken,
- blobPath: `renders/${renderId}.mp4`,
- };
+ const renderConfig: RenderConfig = {
+ serveUrl,
+ compositionId: COMP_NAME,
+ inputProps,
+ blobToken,
+ blobPath: `renders/${renderId}.mp4`,
+ };
- // Run the render script
- const renderCmd = await sandbox.runCommand({
- cmd: "node",
- args: ["--strip-types", "render.ts", JSON.stringify(renderConfig)],
- detached: true,
- });
+ // Run the render script
+ const renderCmd = await sandbox.runCommand({
+ cmd: "node",
+ args: ["--strip-types", "render.ts", JSON.stringify(renderConfig)],
+ detached: true,
+ });
- let doneUrl: string | null = null;
- let doneSize: number | null = null;
+ let doneUrl: string | null = null;
+ let doneSize: number | null = null;
- for await (const log of renderCmd.logs()) {
- if (log.stream === "stdout") {
- try {
- const message = JSON.parse(log.data);
- if (message.type === "progress") {
- await onProgress({
- type: "render-progress",
- progress: message.progress,
- });
- } else if (message.type === "uploading") {
- await onProgress({ type: "uploading" });
- } else if (message.type === "done") {
- doneUrl = message.url;
- doneSize = message.size;
- }
- } catch {
- // Not JSON, ignore
- }
- }
- }
+ for await (const log of renderCmd.logs()) {
+ if (log.stream === "stdout") {
+ try {
+ const message = JSON.parse(log.data);
+ if (message.type === "progress") {
+ await onProgress({
+ type: "render-progress",
+ progress: message.progress,
+ });
+ } else if (message.type === "uploading") {
+ await onProgress({ type: "uploading" });
+ } else if (message.type === "done") {
+ doneUrl = message.url;
+ doneSize = message.size;
+ }
+ } catch {
+ // Not JSON, ignore
+ }
+ }
+ }
- const renderResult = await renderCmd.wait();
- if (renderResult.exitCode !== 0) {
- const stderr = await renderResult.stderr();
- const stdout = await renderResult.stdout();
- throw new Error(`Render failed: ${stderr} ${stdout}`);
- }
+ const renderResult = await renderCmd.wait();
+ if (renderResult.exitCode !== 0) {
+ const stderr = await renderResult.stderr();
+ const stdout = await renderResult.stdout();
+ throw new Error(`Render failed: ${stderr} ${stdout}`);
+ }
- if (!doneUrl || doneSize === null) {
- throw new Error("Render script did not return upload result");
- }
+ if (!doneUrl || doneSize === null) {
+ throw new Error("Render script did not return upload result");
+ }
- await onProgress({ type: "done", url: doneUrl, size: doneSize });
+ await onProgress({ type: "done", url: doneUrl, size: doneSize });
}
diff --git a/packages/template-vercel/src/app/api/render/route.ts b/packages/template-vercel/src/app/api/render/route.ts
index c110520dae..1cede1996a 100644
--- a/packages/template-vercel/src/app/api/render/route.ts
+++ b/packages/template-vercel/src/app/api/render/route.ts
@@ -1,59 +1,67 @@
import { waitUntil } from "@vercel/functions";
import { RenderRequest } from "../../../../types/schema";
import {
- createDisposableWriter,
- formatSSE,
- type RenderProgress,
+ createDisposableWriter,
+ formatSSE,
+ type RenderProgress,
} from "./helpers";
import { reuseOrCreateSandbox } from "./sandbox/reuse-or-create-sandbox";
import { renderInSandbox } from "./render";
export async function POST(req: Request) {
- const encoder = new TextEncoder();
- const stream = new TransformStream();
- const writer = stream.writable.getWriter();
+ const encoder = new TextEncoder();
+ const stream = new TransformStream();
+ const writer = stream.writable.getWriter();
- const send = async (message: RenderProgress) => {
- await writer.write(encoder.encode(formatSSE(message)));
- };
+ const send = async (message: RenderProgress) => {
+ await writer.write(encoder.encode(formatSSE(message)));
+ };
- const runRender = async () => {
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
- await using _writer = createDisposableWriter(writer);
+ const runRender = async () => {
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
+ await using _writer = createDisposableWriter(writer);
- try {
- const payload = await req.json();
- const body = RenderRequest.parse(payload);
+ try {
+ const payload = await req.json();
+ const body = RenderRequest.parse(payload);
- await using sandbox = await reuseOrCreateSandbox(send);
- const renderingPhase = "Rendering video...";
- await send({ type: "phase", phase: renderingPhase, progress: 0 });
- await renderInSandbox({
- sandbox,
- inputProps: body.inputProps,
- onProgress: async (update) => {
- if (update.type === "render-progress") {
- await send({ type: "phase", phase: renderingPhase, progress: update.progress });
- } else if (update.type === "uploading") {
- await send({ type: "phase", phase: "Uploading video...", progress: 1 });
- } else if (update.type === "done") {
- await send({ type: "done", url: update.url, size: update.size });
- }
- },
- });
- } catch (err) {
- console.log(err);
- await send({ type: "error", message: (err as Error).message });
- }
- };
+ await using sandbox = await reuseOrCreateSandbox(send);
+ const renderingPhase = "Rendering video...";
+ await send({ type: "phase", phase: renderingPhase, progress: 0 });
+ await renderInSandbox({
+ sandbox,
+ inputProps: body.inputProps,
+ onProgress: async (update) => {
+ if (update.type === "render-progress") {
+ await send({
+ type: "phase",
+ phase: renderingPhase,
+ progress: update.progress,
+ });
+ } else if (update.type === "uploading") {
+ await send({
+ type: "phase",
+ phase: "Uploading video...",
+ progress: 1,
+ });
+ } else if (update.type === "done") {
+ await send({ type: "done", url: update.url, size: update.size });
+ }
+ },
+ });
+ } catch (err) {
+ console.log(err);
+ await send({ type: "error", message: (err as Error).message });
+ }
+ };
- waitUntil(runRender());
+ waitUntil(runRender());
- return new Response(stream.readable, {
- headers: {
- "Content-Type": "text/event-stream",
- "Cache-Control": "no-cache",
- Connection: "keep-alive",
- },
- });
+ return new Response(stream.readable, {
+ headers: {
+ "Content-Type": "text/event-stream",
+ "Cache-Control": "no-cache",
+ Connection: "keep-alive",
+ },
+ });
}
diff --git a/packages/template-vercel/src/app/api/render/sandbox/add-bundle.ts b/packages/template-vercel/src/app/api/render/sandbox/add-bundle.ts
index 81ae1138e9..bf4503b028 100644
--- a/packages/template-vercel/src/app/api/render/sandbox/add-bundle.ts
+++ b/packages/template-vercel/src/app/api/render/sandbox/add-bundle.ts
@@ -6,73 +6,73 @@ import { existsSync } from "fs";
import { execSync } from "child_process";
export const addBundleToSandbox = async (
- sandbox: Sandbox & AsyncDisposable,
+ sandbox: Sandbox & AsyncDisposable,
) => {
- await ensureLocalBundle();
- const bundleFiles = await getRemotionBundleFiles();
+ await ensureLocalBundle();
+ const bundleFiles = await getRemotionBundleFiles();
- const dirs = new Set<string>();
- for (const file of bundleFiles) {
- const dir = path.dirname(file.path);
- if (dir && dir !== ".") {
- dirs.add(dir);
- }
- }
+ const dirs = new Set<string>();
+ for (const file of bundleFiles) {
+ const dir = path.dirname(file.path);
+ if (dir && dir !== ".") {
+ dirs.add(dir);
+ }
+ }
- for (const dir of Array.from(dirs).sort()) {
- await sandbox.mkDir(BUILD_DIR + "/" + dir);
- }
+ for (const dir of Array.from(dirs).sort()) {
+ await sandbox.mkDir(BUILD_DIR + "/" + dir);
+ }
- await sandbox.writeFiles(
- bundleFiles.map((file) => ({
- path: BUILD_DIR + "/" + file.path,
- content: file.content,
- })),
- );
+ await sandbox.writeFiles(
+ bundleFiles.map((file) => ({
+ path: BUILD_DIR + "/" + file.path,
+ content: file.content,
+ })),
+ );
};
async function getRemotionBundleFiles(): Promise<
- { path: string; content: Buffer }[]
+ { path: string; content: Buffer }[]
> {
- const bundleDir = path.join(process.cwd(), BUILD_DIR);
+ const bundleDir = path.join(process.cwd(), BUILD_DIR);
- const remotionDir = bundleDir;
+ const remotionDir = bundleDir;
- const files: { path: string; content: Buffer }[] = [];
+ const files: { path: string; content: Buffer }[] = [];
- async function readDirRecursive(dir: string, basePath: string = "") {
- const entries = await readdir(dir, { withFileTypes: true });
- for (const entry of entries) {
- const fullPath = path.join(dir, entry.name);
- const relativePath = path.join(basePath, entry.name);
- if (entry.isDirectory()) {
- await readDirRecursive(fullPath, relativePath);
- } else {
- const content = await readFile(fullPath);
- files.push({ path: relativePath, content });
- }
- }
- }
+ async function readDirRecursive(dir: string, basePath: string = "") {
+ const entries = await readdir(dir, { withFileTypes: true });
+ for (const entry of entries) {
+ const fullPath = path.join(dir, entry.name);
+ const relativePath = path.join(basePath, entry.name);
+ if (entry.isDirectory()) {
+ await readDirRecursive(fullPath, relativePath);
+ } else {
+ const content = await readFile(fullPath);
+ files.push({ path: relativePath, content });
+ }
+ }
+ }
- await readDirRecursive(remotionDir);
- return files;
+ await readDirRecursive(remotionDir);
+ return files;
}
async function ensureLocalBundle(): Promise<void> {
- if (process.env.VERCEL) {
- return;
- }
+ if (process.env.VERCEL) {
+ return;
+ }
- const bundleDir = path.join(process.cwd(), BUILD_DIR);
- if (!existsSync(bundleDir)) {
- try {
- execSync(`node_modules/.bin/remotion bundle --out-dir ./${BUILD_DIR}`, {
- cwd: process.cwd(),
- stdio: "pipe",
- });
- } catch (e) {
- const stderr = (e as { stderr?: Buffer }).stderr?.toString() ?? "";
- throw new Error(`Remotion bundle failed: ${stderr}`);
- }
- }
+ const bundleDir = path.join(process.cwd(), BUILD_DIR);
+ if (!existsSync(bundleDir)) {
+ try {
+ execSync(`node_modules/.bin/remotion bundle --out-dir ./${BUILD_DIR}`, {
+ cwd: process.cwd(),
+ stdio: "pipe",
+ });
+ } catch (e) {
+ const stderr = (e as { stderr?: Buffer }).stderr?.toString() ?? "";
+ throw new Error(`Remotion bundle failed: ${stderr}`);
+ }
+ }
}
diff --git a/packages/template-vercel/src/app/api/render/sandbox/create-sandbox.ts b/packages/template-vercel/src/app/api/render/sandbox/create-sandbox.ts
index f81d9317c8..2c1563acfd 100644
--- a/packages/template-vercel/src/app/api/render/sandbox/create-sandbox.ts
+++ b/packages/template-vercel/src/app/api/render/sandbox/create-sandbox.ts
@@ -6,89 +6,89 @@ import { installJsDependencies } from "./install-js-dependencies";
import { installBrowser } from "./install-browser";
export async function createSandbox({
- onProgress,
+ onProgress,
}: {
- onProgress: OnProgressFn;
+ onProgress: OnProgressFn;
}): Promise<Sandbox & AsyncDisposable> {
- const sandbox = await createDisposableSandbox({
- runtime: "node24",
- timeout: 5 * 60 * 1000,
- });
+ const sandbox = await createDisposableSandbox({
+ runtime: "node24",
+ timeout: 5 * 60 * 1000,
+ });
- const preparingPhase = "Preparing machine...";
- const preparingSubtitle = process.env.VERCEL
- ? "This only needs to be done once."
- : "This is only needed during development.";
+ const preparingPhase = "Preparing machine...";
+ const preparingSubtitle = process.env.VERCEL
+ ? "This only needs to be done once."
+ : "This is only needed during development.";
- // Preparation has 3 stages with weights:
- // - System dependencies: 60%
- // - Copying bundle: 20%
- // - Downloading browser: 20%
- const WEIGHT_SYS_DEPS = 0.6;
- const WEIGHT_BUNDLE = 0.2;
- const WEIGHT_BROWSER = 0.2;
+ // Preparation has 3 stages with weights:
+ // - System dependencies: 60%
+ // - Copying bundle: 20%
+ // - Downloading browser: 20%
+ const WEIGHT_SYS_DEPS = 0.6;
+ const WEIGHT_BUNDLE = 0.2;
+ const WEIGHT_BROWSER = 0.2;
- await onProgress({
- type: "phase",
- phase: preparingPhase,
- subtitle: preparingSubtitle,
- progress: 0,
- });
+ await onProgress({
+ type: "phase",
+ phase: preparingPhase,
+ subtitle: preparingSubtitle,
+ progress: 0,
+ });
- // Stage 1: Install system dependencies (60%)
- await installSystemDependencies({
- sandbox,
- onProgress: async (stageProgress: number) => {
- await onProgress({
- type: "phase",
- phase: preparingPhase,
- subtitle: preparingSubtitle,
- progress: stageProgress * WEIGHT_SYS_DEPS,
- });
- },
- });
+ // Stage 1: Install system dependencies (60%)
+ await installSystemDependencies({
+ sandbox,
+ onProgress: async (stageProgress: number) => {
+ await onProgress({
+ type: "phase",
+ phase: preparingPhase,
+ subtitle: preparingSubtitle,
+ progress: stageProgress * WEIGHT_SYS_DEPS,
+ });
+ },
+ });
- await onProgress({
- type: "phase",
- phase: "Adding Remotion video to Sandbox...",
- progress: 0,
- subtitle: preparingSubtitle,
- });
+ await onProgress({
+ type: "phase",
+ phase: "Adding Remotion video to Sandbox...",
+ progress: 0,
+ subtitle: preparingSubtitle,
+ });
- // Stage 2: Copy Remotion bundle (20%)
- await addBundleToSandbox(sandbox);
+ // Stage 2: Copy Remotion bundle (20%)
+ await addBundleToSandbox(sandbox);
- await onProgress({
- type: "phase",
- phase: preparingPhase,
- subtitle: preparingSubtitle,
- progress: WEIGHT_SYS_DEPS + WEIGHT_BUNDLE,
- });
+ await onProgress({
+ type: "phase",
+ phase: preparingPhase,
+ subtitle: preparingSubtitle,
+ progress: WEIGHT_SYS_DEPS + WEIGHT_BUNDLE,
+ });
- // Install renderer and blob SDK
- await installJsDependencies({ sandbox });
+ // Install renderer and blob SDK
+ await installJsDependencies({ sandbox });
- // Stage 3: Download browser (20%)
- await installBrowser({
- sandbox,
- onProgress: async (browserProgress: number) => {
- await onProgress({
- type: "phase",
- phase: preparingPhase,
- subtitle: preparingSubtitle,
- progress:
- WEIGHT_SYS_DEPS + WEIGHT_BUNDLE + browserProgress * WEIGHT_BROWSER,
- });
- },
- });
+ // Stage 3: Download browser (20%)
+ await installBrowser({
+ sandbox,
+ onProgress: async (browserProgress: number) => {
+ await onProgress({
+ type: "phase",
+ phase: preparingPhase,
+ subtitle: preparingSubtitle,
+ progress:
+ WEIGHT_SYS_DEPS + WEIGHT_BUNDLE + browserProgress * WEIGHT_BROWSER,
+ });
+ },
+ });
- const renderScript = await getRenderScript();
- await sandbox.writeFiles([
- {
- path: "render.ts",
- content: renderScript,
- },
- ]);
+ const renderScript = await getRenderScript();
+ await sandbox.writeFiles([
+ {
+ path: "render.ts",
+ content: renderScript,
+ },
+ ]);
- return sandbox;
+ return sandbox;
}
diff --git a/packages/template-vercel/src/app/api/render/sandbox/install-browser.ts b/packages/template-vercel/src/app/api/render/sandbox/install-browser.ts
index 015fd5928d..c9cde1f613 100644
--- a/packages/template-vercel/src/app/api/render/sandbox/install-browser.ts
+++ b/packages/template-vercel/src/app/api/render/sandbox/install-browser.ts
@@ -3,49 +3,49 @@ import path from "path";
import { readFile } from "fs/promises";
async function getEnsureBrowserScript(): Promise<Buffer> {
- const scriptPath = path.join(process.cwd(), "ensure-browser.ts");
- return readFile(scriptPath);
+ const scriptPath = path.join(process.cwd(), "ensure-browser.ts");
+ return readFile(scriptPath);
}
export async function installBrowser({
- sandbox,
- onProgress,
+ sandbox,
+ onProgress,
}: {
- sandbox: Sandbox;
- onProgress: (progress: number) => Promise<void>;
+ sandbox: Sandbox;
+ onProgress: (progress: number) => Promise<void>;
}): Promise<void> {
- const ensureBrowserScript = await getEnsureBrowserScript();
- await sandbox.writeFiles([
- {
- path: "ensure-browser.ts",
- content: ensureBrowserScript,
- },
- ]);
+ const ensureBrowserScript = await getEnsureBrowserScript();
+ await sandbox.writeFiles([
+ {
+ path: "ensure-browser.ts",
+ content: ensureBrowserScript,
+ },
+ ]);
- const ensureBrowserCmd = await sandbox.runCommand({
- cmd: "node",
- args: ["--strip-types", "ensure-browser.ts"],
- detached: true,
- });
+ const ensureBrowserCmd = await sandbox.runCommand({
+ cmd: "node",
+ args: ["--strip-types", "ensure-browser.ts"],
+ detached: true,
+ });
- for await (const log of ensureBrowserCmd.logs()) {
- if (log.stream === "stdout") {
- try {
- const message = JSON.parse(log.data);
- if (message.type === "browser-progress") {
- await onProgress(message.percent ?? 0);
- continue;
- }
- } catch {
- // Not JSON, ignore
- }
- }
- }
+ for await (const log of ensureBrowserCmd.logs()) {
+ if (log.stream === "stdout") {
+ try {
+ const message = JSON.parse(log.data);
+ if (message.type === "browser-progress") {
+ await onProgress(message.percent ?? 0);
+ continue;
+ }
+ } catch {
+ // Not JSON, ignore
+ }
+ }
+ }
- const ensureBrowserResult = await ensureBrowserCmd.wait();
- if (ensureBrowserResult.exitCode !== 0) {
- throw new Error(
- `ensure-browser failed: ${await ensureBrowserResult.stderr()} ${await ensureBrowserResult.stdout()}`,
- );
- }
+ const ensureBrowserResult = await ensureBrowserCmd.wait();
+ if (ensureBrowserResult.exitCode !== 0) {
+ throw new Error(
+ `ensure-browser failed: ${await ensureBrowserResult.stderr()} ${await ensureBrowserResult.stdout()}`,
+ );
+ }
}
diff --git a/packages/template-vercel/src/app/api/render/sandbox/install-js-dependencies.ts b/packages/template-vercel/src/app/api/render/sandbox/install-js-dependencies.ts
index c5f2803a44..bcc91806ce 100644
--- a/packages/template-vercel/src/app/api/render/sandbox/install-js-dependencies.ts
+++ b/packages/template-vercel/src/app/api/render/sandbox/install-js-dependencies.ts
@@ -2,23 +2,23 @@ import { Sandbox } from "@vercel/sandbox";
import { VERSION } from "remotion/version";
export async function installJsDependencies({
- sandbox,
+ sandbox,
}: {
- sandbox: Sandbox;
+ sandbox: Sandbox;
}): Promise<void> {
- const installCmd = await sandbox.runCommand({
- cmd: "pnpm",
- args: [`i`, `@remotion/renderer@${VERSION}`, `@vercel/blob`],
- detached: true,
- });
+ const installCmd = await sandbox.runCommand({
+ cmd: "pnpm",
+ args: [`i`, `@remotion/renderer@${VERSION}`, `@vercel/blob`],
+ detached: true,
+ });
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
- for await (const _log of installCmd.logs()) {
- // Consume logs without displaying
- }
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
+ for await (const _log of installCmd.logs()) {
+ // Consume logs without displaying
+ }
- const installResult = await installCmd.wait();
- if (installResult.exitCode !== 0) {
- throw new Error(`pnpm install failed: ${await installResult.stderr()}`);
- }
+ const installResult = await installCmd.wait();
+ if (installResult.exitCode !== 0) {
+ throw new Error(`pnpm install failed: ${await installResult.stderr()}`);
+ }
}
diff --git a/packages/template-vercel/src/app/api/render/sandbox/install-system-dependencies.ts b/packages/template-vercel/src/app/api/render/sandbox/install-system-dependencies.ts
index c865a02440..02e88662c3 100644
--- a/packages/template-vercel/src/app/api/render/sandbox/install-system-dependencies.ts
+++ b/packages/template-vercel/src/app/api/render/sandbox/install-system-dependencies.ts
@@ -1,51 +1,51 @@
import { Sandbox } from "@vercel/sandbox";
export async function installSystemDependencies({
- sandbox,
- onProgress,
+ sandbox,
+ onProgress,
}: {
- sandbox: Sandbox;
- onProgress: (progress: number) => Promise<void>;
+ sandbox: Sandbox;
+ onProgress: (progress: number) => Promise<void>;
}): Promise<void> {
- const sysInstallCmd = await sandbox.runCommand({
- cmd: "sudo",
- args: [
- "dnf",
- "install",
- "-y",
- "nss",
- "atk",
- "at-spi2-atk",
- "cups-libs",
- "libdrm",
- "libXcomposite",
- "libXdamage",
- "libXrandr",
- "mesa-libgbm",
- "alsa-lib",
- "pango",
- "gtk3",
- ],
- detached: true,
- });
+ const sysInstallCmd = await sandbox.runCommand({
+ cmd: "sudo",
+ args: [
+ "dnf",
+ "install",
+ "-y",
+ "nss",
+ "atk",
+ "at-spi2-atk",
+ "cups-libs",
+ "libdrm",
+ "libXcomposite",
+ "libXdamage",
+ "libXrandr",
+ "mesa-libgbm",
+ "alsa-lib",
+ "pango",
+ "gtk3",
+ ],
+ detached: true,
+ });
- // We empirically tested how many lines are printed to stdout when installing the system dependencies:
- const EXPECTED_SYS_INSTALL_LINES = 272;
- let sysInstallLineCount = 0;
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
- for await (const _log of sysInstallCmd.logs()) {
- sysInstallLineCount++;
- const stageProgress = Math.min(
- sysInstallLineCount / EXPECTED_SYS_INSTALL_LINES,
- 1,
- );
- await onProgress(stageProgress);
- }
+ // We empirically tested how many lines are printed to stdout when installing the system dependencies:
+ const EXPECTED_SYS_INSTALL_LINES = 272;
+ let sysInstallLineCount = 0;
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
+ for await (const _log of sysInstallCmd.logs()) {
+ sysInstallLineCount++;
+ const stageProgress = Math.min(
+ sysInstallLineCount / EXPECTED_SYS_INSTALL_LINES,
+ 1,
+ );
+ await onProgress(stageProgress);
+ }
- const sysInstallResult = await sysInstallCmd.wait();
- if (sysInstallResult.exitCode !== 0) {
- throw new Error(
- `System dependencies install failed: ${await sysInstallResult.stderr()}`,
- );
- }
+ const sysInstallResult = await sysInstallCmd.wait();
+ if (sysInstallResult.exitCode !== 0) {
+ throw new Error(
+ `System dependencies install failed: ${await sysInstallResult.stderr()}`,
+ );
+ }
}
diff --git a/packages/template-vercel/src/app/api/render/sandbox/reuse-or-create-sandbox.ts b/packages/template-vercel/src/app/api/render/sandbox/reuse-or-create-sandbox.ts
index 91bf18f316..f164827015 100644
--- a/packages/template-vercel/src/app/api/render/sandbox/reuse-or-create-sandbox.ts
+++ b/packages/template-vercel/src/app/api/render/sandbox/reuse-or-create-sandbox.ts
@@ -6,55 +6,55 @@ import { getCachedSnapshot, saveSnapshotCache } from "./snapshots";
const TIMEOUT = 5 * 60 * 1000;
export async function reuseOrCreateSandbox(
- onProgress: OnProgressFn,
+ onProgress: OnProgressFn,
): Promise<Sandbox & AsyncDisposable> {
- // Check for a cached snapshot (production only)
- const cachedSnapshotId = await getCachedSnapshot();
-
- if (cachedSnapshotId) {
- await onProgress({
- type: "phase",
- phase: "Creating sandbox...",
- progress: 0,
- });
-
- try {
- return await createDisposableSandbox({
- source: { type: "snapshot", snapshotId: cachedSnapshotId },
- timeout: TIMEOUT,
- });
- } catch {
- // Snapshot may have been deleted or is invalid, fall through to full setup
- }
- }
-
- await onProgress({
- type: "phase",
- phase: "Creating sandbox...",
- progress: 0,
- });
-
- const setupSandboxInstance = await createSandbox({ onProgress });
-
- // In production, snapshot the sandbox and create a new one from it
- if (process.env.VERCEL) {
- const snapshot = await setupSandboxInstance.snapshot();
- // snapshot() shuts down the sandbox, so we don't need to stop it
- // Snapshots expire after 7 days
- const expiresAt = new Date(Date.now() + 7 * 24 * 60 * 60 * 1000);
- await saveSnapshotCache(snapshot.snapshotId, expiresAt);
-
- await onProgress({
- type: "phase",
- phase: "Creating sandbox...",
- progress: 0,
- });
-
- return await createDisposableSandbox({
- source: { type: "snapshot", snapshotId: snapshot.snapshotId },
- timeout: TIMEOUT,
- });
- }
-
- return setupSandboxInstance;
+ // Check for a cached snapshot (production only)
+ const cachedSnapshotId = await getCachedSnapshot();
+
+ if (cachedSnapshotId) {
+ await onProgress({
+ type: "phase",
+ phase: "Creating sandbox...",
+ progress: 0,
+ });
+
+ try {
+ return await createDisposableSandbox({
+ source: { type: "snapshot", snapshotId: cachedSnapshotId },
+ timeout: TIMEOUT,
+ });
+ } catch {
+ // Snapshot may have been deleted or is invalid, fall through to full setup
+ }
+ }
+
+ await onProgress({
+ type: "phase",
+ phase: "Creating sandbox...",
+ progress: 0,
+ });
+
+ const setupSandboxInstance = await createSandbox({ onProgress });
+
+ // In production, snapshot the sandbox and create a new one from it
+ if (process.env.VERCEL) {
+ const snapshot = await setupSandboxInstance.snapshot();
+ // snapshot() shuts down the sandbox, so we don't need to stop it
+ // Snapshots expire after 7 days
+ const expiresAt = new Date(Date.now() + 7 * 24 * 60 * 60 * 1000);
+ await saveSnapshotCache(snapshot.snapshotId, expiresAt);
+
+ await onProgress({
+ type: "phase",
+ phase: "Creating sandbox...",
+ progress: 0,
+ });
+
+ return await createDisposableSandbox({
+ source: { type: "snapshot", snapshotId: snapshot.snapshotId },
+ timeout: TIMEOUT,
+ });
+ }
+
+ return setupSandboxInstance;
}
diff --git a/packages/template-vercel/src/app/api/render/sandbox/snapshots.ts b/packages/template-vercel/src/app/api/render/sandbox/snapshots.ts
index 28bf6beb11..c732c371cd 100644
--- a/packages/template-vercel/src/app/api/render/sandbox/snapshots.ts
+++ b/packages/template-vercel/src/app/api/render/sandbox/snapshots.ts
@@ -1,44 +1,44 @@
import { head, put } from "@vercel/blob";
type SnapshotCache = {
- snapshotId: string;
- expiresAt: string;
+ snapshotId: string;
+ expiresAt: string;
};
const SNAPSHOT_BLOB_KEY = `snapshot-cache/${process.env.VERCEL_DEPLOYMENT_ID ?? "local"}.json`;
export async function getCachedSnapshot(): Promise<string | null> {
- if (!process.env.VERCEL) {
- return null;
- }
-
- try {
- const metadata = await head(SNAPSHOT_BLOB_KEY);
- const response = await fetch(metadata.url);
- const cache: SnapshotCache = await response.json();
-
- if (new Date(cache.expiresAt) < new Date()) {
- return null;
- }
-
- return cache.snapshotId;
- } catch {
- return null;
- }
+ if (!process.env.VERCEL) {
+ return null;
+ }
+
+ try {
+ const metadata = await head(SNAPSHOT_BLOB_KEY);
+ const response = await fetch(metadata.url);
+ const cache: SnapshotCache = await response.json();
+
+ if (new Date(cache.expiresAt) < new Date()) {
+ return null;
+ }
+
+ return cache.snapshotId;
+ } catch {
+ return null;
+ }
}
export async function saveSnapshotCache(
- snapshotId: string,
- expiresAt: Date,
+ snapshotId: string,
+ expiresAt: Date,
): Promise<void> {
- const cache: SnapshotCache = {
- snapshotId,
- expiresAt: expiresAt.toISOString(),
- };
-
- await put(SNAPSHOT_BLOB_KEY, JSON.stringify(cache), {
- access: "public",
- contentType: "application/json",
- addRandomSuffix: false,
- });
+ const cache: SnapshotCache = {
+ snapshotId,
+ expiresAt: expiresAt.toISOString(),
+ };
+
+ await put(SNAPSHOT_BLOB_KEY, JSON.stringify(cache), {
+ access: "public",
+ contentType: "application/json",
+ addRandomSuffix: false,
+ });
}
diff --git a/packages/template-vercel/src/app/layout.tsx b/packages/template-vercel/src/app/layout.tsx
index 87253e7921..421a8ae215 100644
--- a/packages/template-vercel/src/app/layout.tsx
+++ b/packages/template-vercel/src/app/layout.tsx
@@ -2,24 +2,24 @@ import "../../styles/global.css";
import { Metadata, Viewport } from "next";
export const metadata: Metadata = {
- title: "Remotion rendering on Vercel Sandbox",
- description: "Remotion rendering on Vercel Sandbox",
+ title: "Remotion rendering on Vercel Sandbox",
+ description: "Remotion rendering on Vercel Sandbox",
};
export const viewport: Viewport = {
- width: "device-width",
- initialScale: 1,
- maximumScale: 1,
+ width: "device-width",
+ initialScale: 1,
+ maximumScale: 1,
};
export default function RootLayout({
- children,
+ children,
}: {
- children: React.ReactNode;
+ children: React.ReactNode;
}) {
- return (
- <html lang="en">
- <body className="bg-background">{children}</body>
- </html>
- );
+ return (
+ <html lang="en">
+ <body className="bg-background">{children}</body>
+ </html>
+ );
}
diff --git a/packages/template-vercel/src/app/page.tsx b/packages/template-vercel/src/app/page.tsx
index 9f5ac56089..cdfc8b9e1d 100644
--- a/packages/template-vercel/src/app/page.tsx
+++ b/packages/template-vercel/src/app/page.tsx
@@ -5,12 +5,12 @@ import type { NextPage } from "next";
import { useMemo, useState } from "react";
import { z } from "zod";
import {
- defaultMyCompProps,
- CompositionProps,
- DURATION_IN_FRAMES,
- VIDEO_FPS,
- VIDEO_HEIGHT,
- VIDEO_WIDTH,
+ defaultMyCompProps,
+ CompositionProps,
+ DURATION_IN_FRAMES,
+ VIDEO_FPS,
+ VIDEO_HEIGHT,
+ VIDEO_WIDTH,
} from "../../types/constants";
import { RenderControls } from "../components/RenderControls";
import { Spacing } from "../components/Spacing";
@@ -18,46 +18,46 @@ import { Tips } from "../components/Tips";
import { Main } from "../remotion/MyComp/Main";
const Home: NextPage = () => {
- const [text, setText] = useState<string>(defaultMyCompProps.title);
+ const [text, setText] = useState<string>(defaultMyCompProps.title);
- const inputProps: z.infer<typeof CompositionProps> = useMemo(() => {
- return {
- title: text,
- };
- }, [text]);
+ const inputProps: z.infer<typeof CompositionProps> = useMemo(() => {
+ return {
+ title: text,
+ };
+ }, [text]);
- return (
- <div>
- <div className="max-w-screen-md m-auto mb-5 px-4">
- <div className="overflow-hidden rounded-geist shadow-[0_0_200px_rgba(0,0,0,0.15)] mb-10 mt-16">
- <Player
- component={Main}
- inputProps={inputProps}
- durationInFrames={DURATION_IN_FRAMES}
- fps={VIDEO_FPS}
- compositionHeight={VIDEO_HEIGHT}
- compositionWidth={VIDEO_WIDTH}
- style={{
- width: "100%",
- }}
- controls
- autoPlay
- loop
- />
- </div>
- <RenderControls
- text={text}
- setText={setText}
- inputProps={inputProps}
- ></RenderControls>
- <Spacing></Spacing>
- <Spacing></Spacing>
- <Spacing></Spacing>
- <Spacing></Spacing>
- <Tips></Tips>
- </div>
- </div>
- );
+ return (
+ <div>
+ <div className="max-w-screen-md m-auto mb-5 px-4">
+ <div className="overflow-hidden rounded-geist shadow-[0_0_200px_rgba(0,0,0,0.15)] mb-10 mt-16">
+ <Player
+ component={Main}
+ inputProps={inputProps}
+ durationInFrames={DURATION_IN_FRAMES}
+ fps={VIDEO_FPS}
+ compositionHeight={VIDEO_HEIGHT}
+ compositionWidth={VIDEO_WIDTH}
+ style={{
+ width: "100%",
+ }}
+ controls
+ autoPlay
+ loop
+ />
+ </div>
+ <RenderControls
+ text={text}
+ setText={setText}
+ inputProps={inputProps}
+ ></RenderControls>
+ <Spacing></Spacing>
+ <Spacing></Spacing>
+ <Spacing></Spacing>
+ <Spacing></Spacing>
+ <Tips></Tips>
+ </div>
+ </div>
+ );
};
export default Home;
diff --git a/packages/template-vercel/src/components/AlignEnd.tsx b/packages/template-vercel/src/components/AlignEnd.tsx
index adbe3258d6..7ff7ad53bf 100644
--- a/packages/template-vercel/src/components/AlignEnd.tsx
+++ b/packages/template-vercel/src/components/AlignEnd.tsx
@@ -1,7 +1,7 @@
import React from "react";
export const AlignEnd: React.FC<{
- children: React.ReactNode;
+ children: React.ReactNode;
}> = ({ children }) => {
- return <div className="self-end">{children}</div>;
+ return <div className="self-end">{children}</div>;
};
diff --git a/packages/template-vercel/src/components/Button.tsx b/packages/template-vercel/src/components/Button.tsx
index a5d601cd36..4f924f335d 100644
--- a/packages/template-vercel/src/components/Button.tsx
+++ b/packages/template-vercel/src/components/Button.tsx
@@ -4,36 +4,36 @@ import { Spinner } from "./Spinner";
import { cn } from "../lib/utils";
const ButtonForward: React.ForwardRefRenderFunction<
- HTMLButtonElement,
- {
- onClick?: () => void;
- disabled?: boolean;
- children: React.ReactNode;
- loading?: boolean;
- secondary?: boolean;
- }
+ HTMLButtonElement,
+ {
+ onClick?: () => void;
+ disabled?: boolean;
+ children: React.ReactNode;
+ loading?: boolean;
+ secondary?: boolean;
+ }
> = ({ onClick, disabled, children, loading, secondary }, ref) => {
- return (
- <button
- ref={ref}
- className={cn(
- "border-foreground border rounded-geist bg-foreground text-background px-geist-half font-geist h-10 font-medium transition-all duration-150 ease-in-out inline-flex items-center appearance-none text-sm hover:bg-background hover:text-foreground hover:border-focused-border-color disabled:bg-button-disabled-color disabled:text-disabled-text-color disabled:border-unfocused-border-color disabled:cursor-not-allowed",
- secondary
- ? "bg-background text-foreground border-unfocused-border-color"
- : undefined,
- )}
- onClick={onClick}
- disabled={disabled}
- >
- {loading && (
- <>
- <Spinner size={20}></Spinner>
- <Spacing></Spacing>
- </>
- )}
- {children}
- </button>
- );
+ return (
+ <button
+ ref={ref}
+ className={cn(
+ "border-foreground border rounded-geist bg-foreground text-background px-geist-half font-geist h-10 font-medium transition-all duration-150 ease-in-out inline-flex items-center appearance-none text-sm hover:bg-background hover:text-foreground hover:border-focused-border-color disabled:bg-button-disabled-color disabled:text-disabled-text-color disabled:border-unfocused-border-color disabled:cursor-not-allowed",
+ secondary
+ ? "bg-background text-foreground border-unfocused-border-color"
+ : undefined,
+ )}
+ onClick={onClick}
+ disabled={disabled}
+ >
+ {loading && (
+ <>
+ <Spinner size={20}></Spinner>
+ <Spacing></Spacing>
+ </>
+ )}
+ {children}
+ </button>
+ );
};
export const Button = forwardRef(ButtonForward);
diff --git a/packages/template-vercel/src/components/Container.tsx b/packages/template-vercel/src/components/Container.tsx
index 9d521645dd..19cbcb59e5 100644
--- a/packages/template-vercel/src/components/Container.tsx
+++ b/packages/template-vercel/src/components/Container.tsx
@@ -1,11 +1,11 @@
import React from "react";
export const InputContainer: React.FC<{
- children: React.ReactNode;
+ children: React.ReactNode;
}> = ({ children }) => {
- return (
- <div className="border border-unfocused-border-color p-geist rounded-geist bg-background flex flex-col">
- {children}
- </div>
- );
+ return (
+ <div className="border border-unfocused-border-color p-geist rounded-geist bg-background flex flex-col">
+ {children}
+ </div>
+ );
};
diff --git a/packages/template-vercel/src/components/DownloadButton.tsx b/packages/template-vercel/src/components/DownloadButton.tsx
index 22eeee3a75..0ffa9576ba 100644
--- a/packages/template-vercel/src/components/DownloadButton.tsx
+++ b/packages/template-vercel/src/components/DownloadButton.tsx
@@ -4,49 +4,49 @@ import { Button } from "./Button";
import { Spacing } from "./Spacing";
const Megabytes: React.FC<{
- sizeInBytes: number;
+ sizeInBytes: number;
}> = ({ sizeInBytes }) => {
- const megabytes = Intl.NumberFormat("en", {
- notation: "compact",
- style: "unit",
- unit: "byte",
- unitDisplay: "narrow",
- }).format(sizeInBytes);
- return <span className="opacity-60">{megabytes}</span>;
+ const megabytes = Intl.NumberFormat("en", {
+ notation: "compact",
+ style: "unit",
+ unit: "byte",
+ unitDisplay: "narrow",
+ }).format(sizeInBytes);
+ return <span className="opacity-60">{megabytes}</span>;
};
export const DownloadButton: React.FC<{
- state: State;
- undo: () => void;
+ state: State;
+ undo: () => void;
}> = ({ state, undo }) => {
- if (state.status !== "done") {
- throw new Error("Download button should not be rendered when not done");
- }
+ if (state.status !== "done") {
+ throw new Error("Download button should not be rendered when not done");
+ }
- return (
- <div className="flex">
- <Button secondary onClick={undo}>
- <UndoIcon></UndoIcon>
- </Button>
- <Spacing></Spacing>
- <a href={state.url}>
- <Button>
- Download video
- <Spacing></Spacing>
- <Megabytes sizeInBytes={state.size}></Megabytes>
- </Button>
- </a>
- </div>
- );
+ return (
+ <div className="flex">
+ <Button secondary onClick={undo}>
+ <UndoIcon></UndoIcon>
+ </Button>
+ <Spacing></Spacing>
+ <a href={state.url}>
+ <Button>
+ Download video
+ <Spacing></Spacing>
+ <Megabytes sizeInBytes={state.size}></Megabytes>
+ </Button>
+ </a>
+ </div>
+ );
};
const UndoIcon: React.FC = () => {
- return (
- <svg height="1em" viewBox="0 0 512 512">
- <path
- fill="var(--foreground)"
- d="M48.5 224H40c-13.3 0-24-10.7-24-24V72c0-9.7 5.8-18.5 14.8-22.2s19.3-1.7 26.2 5.2L98.6 96.6c87.6-86.5 228.7-86.2 315.8 1c87.5 87.5 87.5 229.3 0 316.8s-229.3 87.5-316.8 0c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0c62.5 62.5 163.8 62.5 226.3 0s62.5-163.8 0-226.3c-62.2-62.2-162.7-62.5-225.3-1L185 183c6.9 6.9 8.9 17.2 5.2 26.2s-12.5 14.8-22.2 14.8H48.5z"
- />
- </svg>
- );
+ return (
+ <svg height="1em" viewBox="0 0 512 512">
+ <path
+ fill="var(--foreground)"
+ d="M48.5 224H40c-13.3 0-24-10.7-24-24V72c0-9.7 5.8-18.5 14.8-22.2s19.3-1.7 26.2 5.2L98.6 96.6c87.6-86.5 228.7-86.2 315.8 1c87.5 87.5 87.5 229.3 0 316.8s-229.3 87.5-316.8 0c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0c62.5 62.5 163.8 62.5 226.3 0s62.5-163.8 0-226.3c-62.2-62.2-162.7-62.5-225.3-1L185 183c6.9 6.9 8.9 17.2 5.2 26.2s-12.5 14.8-22.2 14.8H48.5z"
+ />
+ </svg>
+ );
};
diff --git a/packages/template-vercel/src/components/Error.tsx b/packages/template-vercel/src/components/Error.tsx
index 32309b732c..28020e53c2 100644
--- a/packages/template-vercel/src/components/Error.tsx
+++ b/packages/template-vercel/src/components/Error.tsx
@@ -1,25 +1,25 @@
import React from "react";
export const ErrorComp: React.FC<{
- message: string;
+ message: string;
}> = ({ message }) => {
- return (
- <div className="text-geist-error font-geist py-geist-half">
- <svg
- fill="none"
- shapeRendering="geometricPrecision"
- stroke="currentColor"
- strokeLinecap="round"
- strokeLinejoin="round"
- strokeWidth="2"
- viewBox="0 0 24 24"
- className="h-5 align-text-bottom mr-1.5 inline"
- >
- <circle cx="12" cy="12" r="10" fill="var(--geist-fill)"></circle>
- <path d="M12 8v4" stroke="currentColor"></path>
- <path d="M12 16h.01" stroke="currentColor"></path>
- </svg>
- <strong>Error:</strong> {message}
- </div>
- );
+ return (
+ <div className="text-geist-error font-geist py-geist-half">
+ <svg
+ fill="none"
+ shapeRendering="geometricPrecision"
+ stroke="currentColor"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth="2"
+ viewBox="0 0 24 24"
+ className="h-5 align-text-bottom mr-1.5 inline"
+ >
+ <circle cx="12" cy="12" r="10" fill="var(--geist-fill)"></circle>
+ <path d="M12 8v4" stroke="currentColor"></path>
+ <path d="M12 16h.01" stroke="currentColor"></path>
+ </svg>
+ <strong>Error:</strong> {message}
+ </div>
+ );
};
diff --git a/packages/template-vercel/src/components/Input.tsx b/packages/template-vercel/src/components/Input.tsx
index db948c75dd..d6dcc0434d 100644
--- a/packages/template-vercel/src/components/Input.tsx
+++ b/packages/template-vercel/src/components/Input.tsx
@@ -1,24 +1,24 @@
import React, { useCallback } from "react";
export const Input: React.FC<{
- text: string;
- setText: React.Dispatch<React.SetStateAction<string>>;
- disabled?: boolean;
+ text: string;
+ setText: React.Dispatch<React.SetStateAction<string>>;
+ disabled?: boolean;
}> = ({ text, setText, disabled }) => {
- const onChange: React.ChangeEventHandler<HTMLInputElement> = useCallback(
- (e) => {
- setText(e.currentTarget.value);
- },
- [setText],
- );
+ const onChange: React.ChangeEventHandler<HTMLInputElement> = useCallback(
+ (e) => {
+ setText(e.currentTarget.value);
+ },
+ [setText],
+ );
- return (
- <input
- className="leading-[1.7] block w-full rounded-geist bg-background p-geist-half text-foreground text-sm border border-unfocused-border-color transition-colors duration-150 ease-in-out focus:border-focused-border-color outline-none"
- disabled={disabled}
- name="title"
- value={text}
- onChange={onChange}
- />
- );
+ return (
+ <input
+ className="leading-[1.7] block w-full rounded-geist bg-background p-geist-half text-foreground text-sm border border-unfocused-border-color transition-colors duration-150 ease-in-out focus:border-focused-border-color outline-none"
+ disabled={disabled}
+ name="title"
+ value={text}
+ onChange={onChange}
+ />
+ );
};
diff --git a/packages/template-vercel/src/components/ProgressBar.tsx b/packages/template-vercel/src/components/ProgressBar.tsx
index b5003b317e..7eac570836 100644
--- a/packages/template-vercel/src/components/ProgressBar.tsx
+++ b/packages/template-vercel/src/components/ProgressBar.tsx
@@ -1,22 +1,19 @@
import React, { useMemo } from "react";
export const ProgressBar: React.FC<{
- progress: number;
+ progress: number;
}> = ({ progress }) => {
- const fill: React.CSSProperties = useMemo(() => {
- return {
- width: `${progress * 100}%`,
- };
- }, [progress]);
+ const fill: React.CSSProperties = useMemo(() => {
+ return {
+ width: `${progress * 100}%`,
+ };
+ }, [progress]);
- return (
- <div>
- <div className="w-full h-2.5 rounded-md overflow-hidden appearance-none bg-unfocused-border-color mt-2.5 mb-6">
- <div
- className="bg-foreground h-2.5"
- style={fill}
- ></div>
- </div>
- </div>
- );
+ return (
+ <div>
+ <div className="w-full h-2.5 rounded-md overflow-hidden appearance-none bg-unfocused-border-color mt-2.5 mb-6">
+ <div className="bg-foreground h-2.5" style={fill}></div>
+ </div>
+ </div>
+ );
};
diff --git a/packages/template-vercel/src/components/RenderControls.tsx b/packages/template-vercel/src/components/RenderControls.tsx
index 858800a56d..5398c80f6e 100644
--- a/packages/template-vercel/src/components/RenderControls.tsx
+++ b/packages/template-vercel/src/components/RenderControls.tsx
@@ -11,64 +11,77 @@ import { COMP_NAME, CompositionProps } from "../../types/constants";
import { useRendering } from "../helpers/use-rendering";
export const RenderControls: React.FC<{
- text: string;
- setText: React.Dispatch<React.SetStateAction<string>>;
- inputProps: z.infer<typeof CompositionProps>;
+ text: string;
+ setText: React.Dispatch<React.SetStateAction<string>>;
+ inputProps: z.infer<typeof CompositionProps>;
}> = ({ text, setText, inputProps }) => {
- const { renderMedia, state, undo } = useRendering(COMP_NAME, inputProps);
+ const { renderMedia, state, undo } = useRendering(COMP_NAME, inputProps);
- return (
- <InputContainer>
- {state.status === "init" ||
- state.status === "invoking" ||
- state.status === "error" ? (
- <>
- <Input
- disabled={state.status === "invoking"}
- setText={setText}
- text={text}
- ></Input>
- <Spacing></Spacing>
- <AlignEnd>
- <Button
- disabled={state.status === "invoking"}
- loading={state.status === "invoking"}
- onClick={renderMedia}
- >
- Render video
- </Button>
- </AlignEnd>
- {state.status === "invoking" ? (
- <>
- <Spacing></Spacing>
- <div style={{ fontSize: 14, lineHeight: 1.5, minHeight: "2.5em", marginBottom: 8 }}>
- <div style={{ color: "#666" }}>
- {state.phase}
- {state.progress > 0 && state.progress < 1
- ? ` ${Math.round(state.progress * 100)}%`
- : null}
- </div>
- <div style={{ color: "#999", fontSize: 12, visibility: state.subtitle ? "visible" : "hidden" }}>
- {state.subtitle ?? "\u00A0"}
- </div>
- </div>
- <ProgressBar progress={state.progress} />
- </>
- ) : null}
- {state.status === "error" ? (
- <ErrorComp message={state.error.message}></ErrorComp>
- ) : null}
- </>
- ) : null}
- {state.status === "done" ? (
- <>
- <ProgressBar progress={1} />
- <Spacing></Spacing>
- <AlignEnd>
- <DownloadButton undo={undo} state={state}></DownloadButton>
- </AlignEnd>
- </>
- ) : null}
- </InputContainer>
- );
+ return (
+ <InputContainer>
+ {state.status === "init" ||
+ state.status === "invoking" ||
+ state.status === "error" ? (
+ <>
+ <Input
+ disabled={state.status === "invoking"}
+ setText={setText}
+ text={text}
+ ></Input>
+ <Spacing></Spacing>
+ <AlignEnd>
+ <Button
+ disabled={state.status === "invoking"}
+ loading={state.status === "invoking"}
+ onClick={renderMedia}
+ >
+ Render video
+ </Button>
+ </AlignEnd>
+ {state.status === "invoking" ? (
+ <>
+ <Spacing></Spacing>
+ <div
+ style={{
+ fontSize: 14,
+ lineHeight: 1.5,
+ minHeight: "2.5em",
+ marginBottom: 8,
+ }}
+ >
+ <div style={{ color: "#666" }}>
+ {state.phase}
+ {state.progress > 0 && state.progress < 1
+ ? ` ${Math.round(state.progress * 100)}%`
+ : null}
+ </div>
+ <div
+ style={{
+ color: "#999",
+ fontSize: 12,
+ visibility: state.subtitle ? "visible" : "hidden",
+ }}
+ >
+ {state.subtitle ?? "\u00A0"}
+ </div>
+ </div>
+ <ProgressBar progress={state.progress} />
+ </>
+ ) : null}
+ {state.status === "error" ? (
+ <ErrorComp message={state.error.message}></ErrorComp>
+ ) : null}
+ </>
+ ) : null}
+ {state.status === "done" ? (
+ <>
+ <ProgressBar progress={1} />
+ <Spacing></Spacing>
+ <AlignEnd>
+ <DownloadButton undo={undo} state={state}></DownloadButton>
+ </AlignEnd>
+ </>
+ ) : null}
+ </InputContainer>
+ );
};
diff --git a/packages/template-vercel/src/components/Spacing.tsx b/packages/template-vercel/src/components/Spacing.tsx
index 29b5d1428f..c901cfdadb 100644
--- a/packages/template-vercel/src/components/Spacing.tsx
+++ b/packages/template-vercel/src/components/Spacing.tsx
@@ -1,5 +1,5 @@
import React from "react";
export const Spacing: React.FC = () => {
- return <div className="w-geist-quarter h-geist-quarter" />;
+ return <div className="w-geist-quarter h-geist-quarter" />;
};
diff --git a/packages/template-vercel/src/components/Spinner.tsx b/packages/template-vercel/src/components/Spinner.tsx
index 33a03b00f5..405f2260c1 100644
--- a/packages/template-vercel/src/components/Spinner.tsx
+++ b/packages/template-vercel/src/components/Spinner.tsx
@@ -7,40 +7,40 @@ const lines = 12;
const width = viewBox * 0.08;
const { path } = makeRect({
- height: viewBox * 0.24,
- width,
- cornerRadius: width / 2,
+ height: viewBox * 0.24,
+ width,
+ cornerRadius: width / 2,
});
const translated = translatePath(path, viewBox / 2 - width / 2, viewBox * 0.03);
export const Spinner: React.FC<{
- size: number;
+ size: number;
}> = ({ size }) => {
- const style = useMemo(() => {
- return {
- width: size,
- height: size,
- };
- }, [size]);
+ const style = useMemo(() => {
+ return {
+ width: size,
+ height: size,
+ };
+ }, [size]);
- return (
- <svg style={style} viewBox={`0 0 ${viewBox} ${viewBox}`}>
- {new Array(lines).fill(true).map((_, index) => {
- return (
- <path
- className="animate-spinner"
- style={{
- rotate: `${(index * Math.PI * 2) / lines}rad`,
- transformOrigin: "center center",
- animationDelay: `${index * 0.1 - lines * 0.1}s`,
- }}
- key={index}
- d={translated}
- fill="var(--foreground)"
- ></path>
- );
- })}
- </svg>
- );
+ return (
+ <svg style={style} viewBox={`0 0 ${viewBox} ${viewBox}`}>
+ {new Array(lines).fill(true).map((_, index) => {
+ return (
+ <path
+ className="animate-spinner"
+ style={{
+ rotate: `${(index * Math.PI * 2) / lines}rad`,
+ transformOrigin: "center center",
+ animationDelay: `${index * 0.1 - lines * 0.1}s`,
+ }}
+ key={index}
+ d={translated}
+ fill="var(--foreground)"
+ ></path>
+ );
+ })}
+ </svg>
+ );
};
diff --git a/packages/template-vercel/src/components/Tips.tsx b/packages/template-vercel/src/components/Tips.tsx
index c0ab9b727e..3f88e15754 100644
--- a/packages/template-vercel/src/components/Tips.tsx
+++ b/packages/template-vercel/src/components/Tips.tsx
@@ -1,53 +1,53 @@
import React from "react";
const Tip: React.FC<{
- title: React.ReactNode;
- description: React.ReactNode;
- href: string;
+ title: React.ReactNode;
+ description: React.ReactNode;
+ href: string;
}> = ({ title, description, href }) => {
- return (
- <a href={href} target="_blank" rel="noreferrer" className="flex-1">
- <div className="transition-transform duration-200 ease-in-out p-2.5 group hover:-translate-y-0.5">
- <div className="flex flex-row items-center justify-start">
- <h4 className="my-3 font-bold text-foreground">{title}</h4>
- <div className="flex-1"></div>
- <svg
- className="opacity-0 transition-opacity duration-200 ease-in-out group-hover:opacity-100"
- height="1em"
- viewBox="0 0 448 512"
- >
- <path
- fill="var(--foreground)"
- d="M438.6 278.6c12.5-12.5 12.5-32.8 0-45.3l-160-160c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L338.8 224 32 224c-17.7 0-32 14.3-32 32s14.3 32 32 32l306.7 0L233.4 393.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0l160-160z"
- />
- </svg>
- </div>
- <p className="text-sm leading-normal text-subtitle mb-6">
- {description}
- </p>
- </div>
- </a>
- );
+ return (
+ <a href={href} target="_blank" rel="noreferrer" className="flex-1">
+ <div className="transition-transform duration-200 ease-in-out p-2.5 group hover:-translate-y-0.5">
+ <div className="flex flex-row items-center justify-start">
+ <h4 className="my-3 font-bold text-foreground">{title}</h4>
+ <div className="flex-1"></div>
+ <svg
+ className="opacity-0 transition-opacity duration-200 ease-in-out group-hover:opacity-100"
+ height="1em"
+ viewBox="0 0 448 512"
+ >
+ <path
+ fill="var(--foreground)"
+ d="M438.6 278.6c12.5-12.5 12.5-32.8 0-45.3l-160-160c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L338.8 224 32 224c-17.7 0-32 14.3-32 32s14.3 32 32 32l306.7 0L233.4 393.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0l160-160z"
+ />
+ </svg>
+ </div>
+ <p className="text-sm leading-normal text-subtitle mb-6">
+ {description}
+ </p>
+ </div>
+ </a>
+ );
};
export const Tips: React.FC = () => {
- return (
- <div className="flex flex-col md:flex-row font-geist">
- <Tip
- href="https://www.remotion.dev/docs/the-fundamentals"
- title="Learn Remotion"
- description="Learn how to customize this video written in React."
- ></Tip>
- <Tip
- href="https://github.com/remotion-dev/template-vercel"
- title="See source"
- description="Visit the GitHub repository for this app."
- ></Tip>
- <Tip
- href="https://remotion.dev/discord"
- title="Join the community"
- description="Chat with others builders on Discord."
- ></Tip>
- </div>
- );
+ return (
+ <div className="flex flex-col md:flex-row font-geist">
+ <Tip
+ href="https://www.remotion.dev/docs/the-fundamentals"
+ title="Learn Remotion"
+ description="Learn how to customize this video written in React."
+ ></Tip>
+ <Tip
+ href="https://github.com/remotion-dev/template-vercel"
+ title="See source"
+ description="Visit the GitHub repository for this app."
+ ></Tip>
+ <Tip
+ href="https://remotion.dev/discord"
+ title="Join the community"
+ description="Chat with others builders on Discord."
+ ></Tip>
+ </div>
+ );
};
diff --git a/packages/template-vercel/src/helpers/api-response.ts b/packages/template-vercel/src/helpers/api-response.ts
index 3f80cd99ad..d4da4ce786 100644
--- a/packages/template-vercel/src/helpers/api-response.ts
+++ b/packages/template-vercel/src/helpers/api-response.ts
@@ -2,35 +2,35 @@ import { NextResponse } from "next/server";
import { z, ZodType } from "zod";
export type ApiResponse<Res> =
- | {
- type: "error";
- message: string;
- }
- | {
- type: "success";
- data: Res;
- };
+ | {
+ type: "error";
+ message: string;
+ }
+ | {
+ type: "success";
+ data: Res;
+ };
export const executeApi =
- <Res, Req extends ZodType>(
- schema: Req,
- handler: (req: Request, body: z.infer<Req>) => Promise<Res>,
- ) =>
- async (req: Request) => {
- try {
- const payload = await req.json();
- const parsed = schema.parse(payload);
- const data = await handler(req, parsed);
- return NextResponse.json({
- type: "success",
- data: data,
- });
- } catch (err) {
- return NextResponse.json(
- { type: "error", message: (err as Error).message },
- {
- status: 500,
- },
- );
- }
- };
+ <Res, Req extends ZodType>(
+ schema: Req,
+ handler: (req: Request, body: z.infer<Req>) => Promise<Res>,
+ ) =>
+ async (req: Request) => {
+ try {
+ const payload = await req.json();
+ const parsed = schema.parse(payload);
+ const data = await handler(req, parsed);
+ return NextResponse.json({
+ type: "success",
+ data: data,
+ });
+ } catch (err) {
+ return NextResponse.json(
+ { type: "error", message: (err as Error).message },
+ {
+ status: 500,
+ },
+ );
+ }
+ };
diff --git a/packages/template-vercel/src/helpers/use-rendering.ts b/packages/template-vercel/src/helpers/use-rendering.ts
index 92be868281..3fd6783a98 100644
--- a/packages/template-vercel/src/helpers/use-rendering.ts
+++ b/packages/template-vercel/src/helpers/use-rendering.ts
@@ -4,111 +4,111 @@ import { CompositionProps } from "../../types/constants";
import { SSEMessage } from "../../types/schema";
export type State =
- | {
- status: "init";
- }
- | {
- status: "invoking";
- phase: string;
- progress: number;
- subtitle: string | null;
- }
- | {
- status: "error";
- error: Error;
- }
- | {
- url: string;
- size: number;
- status: "done";
- };
+ | {
+ status: "init";
+ }
+ | {
+ status: "invoking";
+ phase: string;
+ progress: number;
+ subtitle: string | null;
+ }
+ | {
+ status: "error";
+ error: Error;
+ }
+ | {
+ url: string;
+ size: number;
+ status: "done";
+ };
export const useRendering = (
- id: string,
- inputProps: z.infer<typeof CompositionProps>,
+ id: string,
+ inputProps: z.infer<typeof CompositionProps>,
) => {
- const [state, setState] = useState<State>({
- status: "init",
- });
+ const [state, setState] = useState<State>({
+ status: "init",
+ });
- const renderMedia = useCallback(async () => {
- setState({
- status: "invoking",
- phase: "Starting...",
- progress: 0,
- subtitle: null,
- });
+ const renderMedia = useCallback(async () => {
+ setState({
+ status: "invoking",
+ phase: "Starting...",
+ progress: 0,
+ subtitle: null,
+ });
- try {
- const response = await fetch("/api/render", {
- method: "POST",
- headers: { "content-type": "application/json" },
- body: JSON.stringify({ id, inputProps }),
- });
+ try {
+ const response = await fetch("/api/render", {
+ method: "POST",
+ headers: { "content-type": "application/json" },
+ body: JSON.stringify({ id, inputProps }),
+ });
- if (!response.ok || !response.body) {
- throw new Error("Failed to start render");
- }
+ if (!response.ok || !response.body) {
+ throw new Error("Failed to start render");
+ }
- const reader = response.body.getReader();
- const decoder = new TextDecoder();
- let buffer = "";
+ const reader = response.body.getReader();
+ const decoder = new TextDecoder();
+ let buffer = "";
- while (true) {
- const { done, value } = await reader.read();
- if (done) break;
+ while (true) {
+ const { done, value } = await reader.read();
+ if (done) break;
- buffer += decoder.decode(value, { stream: true });
- const lines = buffer.split("\n\n");
- buffer = lines.pop() || "";
+ buffer += decoder.decode(value, { stream: true });
+ const lines = buffer.split("\n\n");
+ buffer = lines.pop() || "";
- for (const line of lines) {
- if (!line.startsWith("data: ")) continue;
+ for (const line of lines) {
+ if (!line.startsWith("data: ")) continue;
- const json = line.slice(6);
- const message = JSON.parse(json) as SSEMessage;
+ const json = line.slice(6);
+ const message = JSON.parse(json) as SSEMessage;
- if (message.type === "phase") {
- setState((prev) => {
- if (prev.status !== "invoking") return prev;
- return {
- ...prev,
- phase: message.phase,
- progress: message.progress,
- subtitle: message.subtitle ?? null,
- };
- });
- } else if (message.type === "done") {
- setState({
- status: "done",
- url: message.url,
- size: message.size,
- });
- } else if (message.type === "error") {
- setState({
- status: "error",
- error: new Error(message.message),
- });
- }
- }
- }
- } catch (err) {
- setState({
- status: "error",
- error: err as Error,
- });
- }
- }, [id, inputProps]);
+ if (message.type === "phase") {
+ setState((prev) => {
+ if (prev.status !== "invoking") return prev;
+ return {
+ ...prev,
+ phase: message.phase,
+ progress: message.progress,
+ subtitle: message.subtitle ?? null,
+ };
+ });
+ } else if (message.type === "done") {
+ setState({
+ status: "done",
+ url: message.url,
+ size: message.size,
+ });
+ } else if (message.type === "error") {
+ setState({
+ status: "error",
+ error: new Error(message.message),
+ });
+ }
+ }
+ }
+ } catch (err) {
+ setState({
+ status: "error",
+ error: err as Error,
+ });
+ }
+ }, [id, inputProps]);
- const undo = useCallback(() => {
- setState({ status: "init" });
- }, []);
+ const undo = useCallback(() => {
+ setState({ status: "init" });
+ }, []);
- return useMemo(() => {
- return {
- renderMedia,
- state,
- undo,
- };
- }, [renderMedia, state, undo]);
+ return useMemo(() => {
+ return {
+ renderMedia,
+ state,
+ undo,
+ };
+ }, [renderMedia, state, undo]);
};
diff --git a/packages/template-vercel/src/lib/utils.ts b/packages/template-vercel/src/lib/utils.ts
index 3200be2844..a5ef193506 100644
--- a/packages/template-vercel/src/lib/utils.ts
+++ b/packages/template-vercel/src/lib/utils.ts
@@ -2,5 +2,5 @@ import { clsx, type ClassValue } from "clsx";
import { twMerge } from "tailwind-merge";
export function cn(...inputs: ClassValue[]) {
- return twMerge(clsx(inputs));
+ return twMerge(clsx(inputs));
}
diff --git a/packages/template-vercel/src/remotion/MyComp/Main.tsx b/packages/template-vercel/src/remotion/MyComp/Main.tsx
index 4c063ee365..cf23037a59 100644
--- a/packages/template-vercel/src/remotion/MyComp/Main.tsx
+++ b/packages/template-vercel/src/remotion/MyComp/Main.tsx
@@ -1,10 +1,10 @@
import { z } from "zod";
import {
- AbsoluteFill,
- Sequence,
- spring,
- useCurrentFrame,
- useVideoConfig,
+ AbsoluteFill,
+ Sequence,
+ spring,
+ useCurrentFrame,
+ useVideoConfig,
} from "remotion";
import { CompositionProps } from "../../../types/constants";
import { NextLogo } from "./NextLogo";
@@ -13,46 +13,46 @@ import { Rings } from "./Rings";
import { TextFade } from "./TextFade";
loadFont("normal", {
- subsets: ["latin"],
- weights: ["400", "700"],
+ subsets: ["latin"],
+ weights: ["400", "700"],
});
export const Main = ({ title }: z.infer<typeof CompositionProps>) => {
- const frame = useCurrentFrame();
- const { fps } = useVideoConfig();
+ const frame = useCurrentFrame();
+ const { fps } = useVideoConfig();
- const transitionStart = 2 * fps;
- const transitionDuration = 1 * fps;
+ const transitionStart = 2 * fps;
+ const transitionDuration = 1 * fps;
- const logoOut = spring({
- fps,
- frame,
- config: {
- damping: 200,
- },
- durationInFrames: transitionDuration,
- delay: transitionStart,
- });
+ const logoOut = spring({
+ fps,
+ frame,
+ config: {
+ damping: 200,
+ },
+ durationInFrames: transitionDuration,
+ delay: transitionStart,
+ });
- return (
- <AbsoluteFill className="bg-white">
- <Sequence durationInFrames={transitionStart + transitionDuration}>
- <Rings outProgress={logoOut}></Rings>
- <AbsoluteFill className="justify-center items-center">
- <NextLogo outProgress={logoOut}></NextLogo>
- </AbsoluteFill>
- </Sequence>
- <Sequence from={transitionStart + transitionDuration / 2}>
- <TextFade>
- <h1
- className="text-[70px] font-bold"
- style={{
- fontFamily,
- }}
- >
- {title}
- </h1>
- </TextFade>
- </Sequence>
- </AbsoluteFill>
- );
+ return (
+ <AbsoluteFill className="bg-white">
+ <Sequence durationInFrames={transitionStart + transitionDuration}>
+ <Rings outProgress={logoOut}></Rings>
+ <AbsoluteFill className="justify-center items-center">
+ <NextLogo outProgress={logoOut}></NextLogo>
+ </AbsoluteFill>
+ </Sequence>
+ <Sequence from={transitionStart + transitionDuration / 2}>
+ <TextFade>
+ <h1
+ className="text-[70px] font-bold"
+ style={{
+ fontFamily,
+ }}
+ >
+ {title}
+ </h1>
+ </TextFade>
+ </Sequence>
+ </AbsoluteFill>
+ );
};
diff --git a/packages/template-vercel/src/remotion/MyComp/NextLogo.tsx b/packages/template-vercel/src/remotion/MyComp/NextLogo.tsx
index a3bc9b7a98..b7f87f6bf2 100644
--- a/packages/template-vercel/src/remotion/MyComp/NextLogo.tsx
+++ b/packages/template-vercel/src/remotion/MyComp/NextLogo.tsx
@@ -3,120 +3,120 @@ import React, { useMemo } from "react";
import { interpolate, spring, useCurrentFrame, useVideoConfig } from "remotion";
const nStroke =
- "M149.508 157.52L69.142 54H54V125.97H66.1136V69.3836L139.999 164.845C143.333 162.614 146.509 160.165 149.508 157.52Z";
+ "M149.508 157.52L69.142 54H54V125.97H66.1136V69.3836L139.999 164.845C143.333 162.614 146.509 160.165 149.508 157.52Z";
export const NextLogo: React.FC<{
- outProgress: number;
+ outProgress: number;
}> = ({ outProgress }) => {
- const { fps } = useVideoConfig();
- const frame = useCurrentFrame();
+ const { fps } = useVideoConfig();
+ const frame = useCurrentFrame();
- const evolve1 = spring({
- fps,
- frame,
- config: {
- damping: 200,
- },
- });
- const evolve2 = spring({
- fps,
- frame: frame - 15,
- config: {
- damping: 200,
- },
- });
- const evolve3 = spring({
- fps,
- frame: frame - 30,
- config: {
- damping: 200,
- mass: 3,
- },
- durationInFrames: 30,
- });
+ const evolve1 = spring({
+ fps,
+ frame,
+ config: {
+ damping: 200,
+ },
+ });
+ const evolve2 = spring({
+ fps,
+ frame: frame - 15,
+ config: {
+ damping: 200,
+ },
+ });
+ const evolve3 = spring({
+ fps,
+ frame: frame - 30,
+ config: {
+ damping: 200,
+ mass: 3,
+ },
+ durationInFrames: 30,
+ });
- const style: React.CSSProperties = useMemo(() => {
- return {
- height: 140,
- borderRadius: 70,
- scale: String(1 - outProgress),
- };
- }, [outProgress]);
+ const style: React.CSSProperties = useMemo(() => {
+ return {
+ height: 140,
+ borderRadius: 70,
+ scale: String(1 - outProgress),
+ };
+ }, [outProgress]);
- const firstPath = `M 60.0568 54 v 71.97`;
- const secondPath = `M 63.47956 56.17496 L 144.7535 161.1825`;
- const thirdPath = `M 121 54 L 121 126`;
+ const firstPath = `M 60.0568 54 v 71.97`;
+ const secondPath = `M 63.47956 56.17496 L 144.7535 161.1825`;
+ const thirdPath = `M 121 54 L 121 126`;
- const evolution1 = evolvePath(evolve1, firstPath);
- const evolution2 = evolvePath(evolve2, secondPath);
- const evolution3 = evolvePath(
- interpolate(evolve3, [0, 1], [0, 0.7]),
- thirdPath,
- );
+ const evolution1 = evolvePath(evolve1, firstPath);
+ const evolution2 = evolvePath(evolve2, secondPath);
+ const evolution3 = evolvePath(
+ interpolate(evolve3, [0, 1], [0, 0.7]),
+ thirdPath,
+ );
- return (
- <svg style={style} fill="none" viewBox="0 0 180 180">
- <mask
- height="180"
- id="mask"
- className="[mask-type:alpha]"
- width="180"
- x="0"
- y="0"
- >
- <circle cx="90" cy="90" fill="black" r="90"></circle>
- </mask>
- <mask id="n-mask" className="[mask-type:alpha]">
- <path d={nStroke} fill="black"></path>
- </mask>
- <g mask="url(#mask)">
- <circle cx="90" cy="90" fill="black" r="90"></circle>
- <g stroke="url(#gradient0)" mask="url(#n-mask)">
- <path
- strokeWidth="12.1136"
- d={firstPath}
- strokeDasharray={evolution1.strokeDasharray}
- strokeDashoffset={evolution1.strokeDashoffset}
- ></path>
- <path
- strokeWidth={12.1136}
- d={secondPath}
- strokeDasharray={evolution2.strokeDasharray}
- strokeDashoffset={evolution2.strokeDashoffset}
- ></path>
- </g>
- <path
- stroke="url(#gradient1)"
- d={thirdPath}
- strokeDasharray={evolution3.strokeDasharray}
- strokeDashoffset={evolution3.strokeDashoffset}
- strokeWidth="12"
- ></path>
- </g>
- <defs>
- <linearGradient
- gradientUnits="userSpaceOnUse"
- id="gradient0"
- x1="109"
- x2="144.5"
- y1="116.5"
- y2="160.5"
- >
- <stop stopColor="white"></stop>
- <stop offset="1" stopColor="white" stopOpacity="0"></stop>
- </linearGradient>
- <linearGradient
- gradientUnits="userSpaceOnUse"
- id="gradient1"
- x1="121"
- x2="120.799"
- y1="54"
- y2="106.875"
- >
- <stop stopColor="white"></stop>
- <stop offset="1" stopColor="white" stopOpacity="0"></stop>
- </linearGradient>
- </defs>
- </svg>
- );
+ return (
+ <svg style={style} fill="none" viewBox="0 0 180 180">
+ <mask
+ height="180"
+ id="mask"
+ className="[mask-type:alpha]"
+ width="180"
+ x="0"
+ y="0"
+ >
+ <circle cx="90" cy="90" fill="black" r="90"></circle>
+ </mask>
+ <mask id="n-mask" className="[mask-type:alpha]">
+ <path d={nStroke} fill="black"></path>
+ </mask>
+ <g mask="url(#mask)">
+ <circle cx="90" cy="90" fill="black" r="90"></circle>
+ <g stroke="url(#gradient0)" mask="url(#n-mask)">
+ <path
+ strokeWidth="12.1136"
+ d={firstPath}
+ strokeDasharray={evolution1.strokeDasharray}
+ strokeDashoffset={evolution1.strokeDashoffset}
+ ></path>
+ <path
+ strokeWidth={12.1136}
+ d={secondPath}
+ strokeDasharray={evolution2.strokeDasharray}
+ strokeDashoffset={evolution2.strokeDashoffset}
+ ></path>
+ </g>
+ <path
+ stroke="url(#gradient1)"
+ d={thirdPath}
+ strokeDasharray={evolution3.strokeDasharray}
+ strokeDashoffset={evolution3.strokeDashoffset}
+ strokeWidth="12"
+ ></path>
+ </g>
+ <defs>
+ <linearGradient
+ gradientUnits="userSpaceOnUse"
+ id="gradient0"
+ x1="109"
+ x2="144.5"
+ y1="116.5"
+ y2="160.5"
+ >
+ <stop stopColor="white"></stop>
+ <stop offset="1" stopColor="white" stopOpacity="0"></stop>
+ </linearGradient>
+ <linearGradient
+ gradientUnits="userSpaceOnUse"
+ id="gradient1"
+ x1="121"
+ x2="120.799"
+ y1="54"
+ y2="106.875"
+ >
+ <stop stopColor="white"></stop>
+ <stop offset="1" stopColor="white" stopOpacity="0"></stop>
+ </linearGradient>
+ </defs>
+ </svg>
+ );
};
diff --git a/packages/template-vercel/src/remotion/MyComp/Rings.tsx b/packages/template-vercel/src/remotion/MyComp/Rings.tsx
index f9eadcb954..8e27bae856 100644
--- a/packages/template-vercel/src/remotion/MyComp/Rings.tsx
+++ b/packages/template-vercel/src/remotion/MyComp/Rings.tsx
@@ -2,55 +2,55 @@ import React from "react";
import { AbsoluteFill, interpolateColors, useVideoConfig } from "remotion";
const RadialGradient: React.FC<{
- radius: number;
- color: string;
+ radius: number;
+ color: string;
}> = ({ radius, color }) => {
- const height = radius * 2;
- const width = radius * 2;
+ const height = radius * 2;
+ const width = radius * 2;
- return (
- <AbsoluteFill
- style={{
- justifyContent: "center",
- alignItems: "center",
- }}
- >
- <div
- style={{
- height,
- width,
- backgroundColor: color,
- }}
- className="rounded-[50%] absolute shadow-[0px_0px_100px_rgba(0,0,0,0.05)]"
- ></div>
- </AbsoluteFill>
- );
+ return (
+ <AbsoluteFill
+ style={{
+ justifyContent: "center",
+ alignItems: "center",
+ }}
+ >
+ <div
+ style={{
+ height,
+ width,
+ backgroundColor: color,
+ }}
+ className="rounded-[50%] absolute shadow-[0px_0px_100px_rgba(0,0,0,0.05)]"
+ ></div>
+ </AbsoluteFill>
+ );
};
export const Rings: React.FC<{
- outProgress: number;
+ outProgress: number;
}> = ({ outProgress }) => {
- const scale = 1 / (1 - outProgress);
- const { height } = useVideoConfig();
+ const scale = 1 / (1 - outProgress);
+ const { height } = useVideoConfig();
- return (
- <AbsoluteFill
- style={{
- transform: `scale(${scale})`,
- }}
- >
- {new Array(5)
- .fill(true)
- .map((_, i) => {
- return (
- <RadialGradient
- key={i}
- radius={height * 0.3 * i}
- color={interpolateColors(i, [0, 4], ["#fff", "#fff"])}
- />
- );
- })
- .reverse()}
- </AbsoluteFill>
- );
+ return (
+ <AbsoluteFill
+ style={{
+ transform: `scale(${scale})`,
+ }}
+ >
+ {new Array(5)
+ .fill(true)
+ .map((_, i) => {
+ return (
+ <RadialGradient
+ key={i}
+ radius={height * 0.3 * i}
+ color={interpolateColors(i, [0, 4], ["#fff", "#fff"])}
+ />
+ );
+ })
+ .reverse()}
+ </AbsoluteFill>
+ );
};
diff --git a/packages/template-vercel/src/remotion/MyComp/TextFade.tsx b/packages/template-vercel/src/remotion/MyComp/TextFade.tsx
index cedb24d6fb..1b71930a0b 100644
--- a/packages/template-vercel/src/remotion/MyComp/TextFade.tsx
+++ b/packages/template-vercel/src/remotion/MyComp/TextFade.tsx
@@ -1,45 +1,45 @@
import React, { useMemo } from "react";
import {
- AbsoluteFill,
- interpolate,
- spring,
- useCurrentFrame,
- useVideoConfig,
+ AbsoluteFill,
+ interpolate,
+ spring,
+ useCurrentFrame,
+ useVideoConfig,
} from "remotion";
export const TextFade: React.FC<{
- children: React.ReactNode;
+ children: React.ReactNode;
}> = ({ children }) => {
- const { fps } = useVideoConfig();
- const frame = useCurrentFrame();
+ const { fps } = useVideoConfig();
+ const frame = useCurrentFrame();
- const progress = spring({
- fps,
- frame,
- config: {
- damping: 200,
- },
- durationInFrames: 80,
- });
+ const progress = spring({
+ fps,
+ frame,
+ config: {
+ damping: 200,
+ },
+ durationInFrames: 80,
+ });
- const rightStop = interpolate(progress, [0, 1], [200, 0]);
+ const rightStop = interpolate(progress, [0, 1], [200, 0]);
- const leftStop = Math.max(0, rightStop - 60);
+ const leftStop = Math.max(0, rightStop - 60);
- const maskImage = `linear-gradient(-45deg, transparent ${leftStop}%, black ${rightStop}%)`;
+ const maskImage = `linear-gradient(-45deg, transparent ${leftStop}%, black ${rightStop}%)`;
- const content: React.CSSProperties = useMemo(() => {
- return {
- maskImage,
- WebkitMaskImage: maskImage,
- };
- }, [maskImage]);
+ const content: React.CSSProperties = useMemo(() => {
+ return {
+ maskImage,
+ WebkitMaskImage: maskImage,
+ };
+ }, [maskImage]);
- return (
- <AbsoluteFill>
- <AbsoluteFill className="justify-center items-center">
- <div style={content}>{children}</div>
- </AbsoluteFill>
- </AbsoluteFill>
- );
+ return (
+ <AbsoluteFill>
+ <AbsoluteFill className="justify-center items-center">
+ <div style={content}>{children}</div>
+ </AbsoluteFill>
+ </AbsoluteFill>
+ );
};
diff --git a/packages/template-vercel/src/remotion/Root.tsx b/packages/template-vercel/src/remotion/Root.tsx
index 7c1cc22162..83276274db 100644
--- a/packages/template-vercel/src/remotion/Root.tsx
+++ b/packages/template-vercel/src/remotion/Root.tsx
@@ -1,38 +1,38 @@
import { Composition } from "remotion";
import { Main } from "./MyComp/Main";
import {
- COMP_NAME,
- defaultMyCompProps,
- DURATION_IN_FRAMES,
- VIDEO_FPS,
- VIDEO_HEIGHT,
- VIDEO_WIDTH,
+ COMP_NAME,
+ defaultMyCompProps,
+ DURATION_IN_FRAMES,
+ VIDEO_FPS,
+ VIDEO_HEIGHT,
+ VIDEO_WIDTH,
} from "../../types/constants";
import { NextLogo } from "./MyComp/NextLogo";
export const RemotionRoot: React.FC = () => {
- return (
- <>
- <Composition
- id={COMP_NAME}
- component={Main}
- durationInFrames={DURATION_IN_FRAMES}
- fps={VIDEO_FPS}
- width={VIDEO_WIDTH}
- height={VIDEO_HEIGHT}
- defaultProps={defaultMyCompProps}
- />
- <Composition
- id="NextLogo"
- component={NextLogo}
- durationInFrames={300}
- fps={30}
- width={140}
- height={140}
- defaultProps={{
- outProgress: 0,
- }}
- />
- </>
- );
+ return (
+ <>
+ <Composition
+ id={COMP_NAME}
+ component={Main}
+ durationInFrames={DURATION_IN_FRAMES}
+ fps={VIDEO_FPS}
+ width={VIDEO_WIDTH}
+ height={VIDEO_HEIGHT}
+ defaultProps={defaultMyCompProps}
+ />
+ <Composition
+ id="NextLogo"
+ component={NextLogo}
+ durationInFrames={300}
+ fps={30}
+ width={140}
+ height={140}
+ defaultProps={{
+ outProgress: 0,
+ }}
+ />
+ </>
+ );
};
diff --git a/tsconfig.json b/tsconfig.json
index 3a00eda423..5869c92a93 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -189,6 +189,9 @@
{
"path": "./packages/template-recorder"
},
+ {
+ "path": "./packages/template-vercel"
+ },
{
"path": "./packages/studio"
},