Production-ready animations, transitions, backgrounds, and scenes for Remotion
TypeScript ai-agentsclaude-codedemo-videomcpmcp-servermodel-context-protocolmotion-designproduct-demoreactremotionshadcnvideo
fix: build
kapishdima57c8908e4608
diff --git a/src/remotion/Root.tsx b/src/remotion/Root.tsxnew file mode 100644index 00000000..b4780933--- /dev/null+++ b/src/remotion/Root.tsx@@ -0,0 +1,42 @@+import { Composition, registerRoot } from "remotion";+import {+ GitHubStars,+ type GitHubStarsProps,+ SAMPLE_STARGAZERS,+} from "@/registry/remocn/github-stars";++/**+ * Sample props so the composition validates + renders standalone in the Remotion+ * bundle (Studio / pre-render). Real renders override these via `inputProps`.+ */+const DEFAULT_PROPS: GitHubStarsProps = {+ repo: "remotion-dev/remotion",+ totalStars: 24813,+ stargazers: SAMPLE_STARGAZERS,+ orientation: "horizontal",+ accentColor: "#ffbb00",+ speed: 1,+ theme: "light",+};++/**+ * Bundle root. Declares the single `github-stars` composition at full native+ * horizontal quality (1280×720 / 30fps / 300 frames). The server overrides+ * width/height per orientation at render time (see lib/server/render.ts) — one+ * composition, no duplicate vertical entry.+ */+export function RemotionRoot() {+ return (+ <Composition+ id="github-stars"+ component={GitHubStars}+ durationInFrames={300}+ fps={30}+ width={1280}+ height={720}+ defaultProps={DEFAULT_PROPS}+ />+ );+}++registerRoot(RemotionRoot);diff --git a/src/remotion/canvas-spike-root.tsx b/src/remotion/canvas-spike-root.tsxnew file mode 100644index 00000000..a1cea43c--- /dev/null+++ b/src/remotion/canvas-spike-root.tsx@@ -0,0 +1,127 @@+import { loadFont } from "@remotion/google-fonts/Geist";+import type { ComponentType } from "react";+import {+ AbsoluteFill,+ Composition,+ isHtmlInCanvasSupported,+ registerRoot,+} from "remotion";+import { AsciiRenderExampleScene } from "@/components/docs/examples/ascii-render-example";+import { CameraLensExampleScene } from "@/components/docs/examples/camera-lens-example";+import { CrtScreenExampleScene } from "@/components/docs/examples/crt-screen-example";+import { DisplacementExampleScene } from "@/components/docs/examples/displacement-example";+import { EmberBurnExampleScene } from "@/components/docs/examples/ember-burn-example";+import { GlitchCutExampleScene } from "@/components/docs/examples/glitch-cut-example";+import { GridWaveExampleScene } from "@/components/docs/examples/grid-wave-example";+import { HalftonePrintExampleScene } from "@/components/docs/examples/halftone-print-example";+import { HologramExampleScene } from "@/components/docs/examples/hologram-example";+import { ParticleDissolveExampleScene } from "@/components/docs/examples/particle-dissolve-example";+import { PixelateRegionExampleScene } from "@/components/docs/examples/pixelate-region-example";+import { SecurityCamExampleScene } from "@/components/docs/examples/security-cam-example";+import { SustainedGlitchExampleScene } from "@/components/docs/examples/sustained-glitch-example";+import { UnderwaterRippleExampleScene } from "@/components/docs/examples/underwater-ripple-example";+import { VhsFilterExampleScene } from "@/components/docs/examples/vhs-filter-example";+import type { ComponentConfig } from "@/lib/customizer-config";+import { asciiRenderConfig } from "@/registry/remocn/ascii-render/config";+import { cameraLensConfig } from "@/registry/remocn/camera-lens/config";+import { crtScreenConfig } from "@/registry/remocn/crt-screen/config";+import { displacementConfig } from "@/registry/remocn/displacement/config";+import { emberBurnConfig } from "@/registry/remocn/ember-burn/config";+import { glitchCutConfig } from "@/registry/remocn/glitch-cut/config";+import { gridWaveConfig } from "@/registry/remocn/grid-wave/config";+import { halftonePrintConfig } from "@/registry/remocn/halftone-print/config";+import { hologramConfig } from "@/registry/remocn/hologram/config";+import { particleDissolveConfig } from "@/registry/remocn/particle-dissolve/config";+import { pixelateRegionConfig } from "@/registry/remocn/pixelate-region/config";+import { securityCamConfig } from "@/registry/remocn/security-cam/config";+import { sustainedGlitchConfig } from "@/registry/remocn/sustained-glitch/config";+import { underwaterRippleConfig } from "@/registry/remocn/underwater-ripple/config";+import { vhsFilterConfig } from "@/registry/remocn/vhs-filter/config";++const { fontFamily: GEIST } = loadFont();++if (typeof document !== "undefined") {+ console.log(+ `[canvas-spike] htmlInCanvasSupported=${isHtmlInCanvasSupported()}`,+ );+ console.log(`[canvas-spike] userAgent=${navigator.userAgent}`);+}++const SCENES: Record<+ string,+ { Scene: ComponentType; config: ComponentConfig }+> = {+ "glitch-cut": { Scene: GlitchCutExampleScene, config: glitchCutConfig },+ "ember-burn": { Scene: EmberBurnExampleScene, config: emberBurnConfig },+ "particle-dissolve": {+ Scene: ParticleDissolveExampleScene,+ config: particleDissolveConfig,+ },+ "grid-wave": { Scene: GridWaveExampleScene, config: gridWaveConfig },+ displacement: {+ Scene: DisplacementExampleScene,+ config: displacementConfig,+ },+ "vhs-filter": { Scene: VhsFilterExampleScene, config: vhsFilterConfig },+ "crt-screen": { Scene: CrtScreenExampleScene, config: crtScreenConfig },+ "sustained-glitch": {+ Scene: SustainedGlitchExampleScene,+ config: sustainedGlitchConfig,+ },+ "pixelate-region": {+ Scene: PixelateRegionExampleScene,+ config: pixelateRegionConfig,+ },+ "ascii-render": { Scene: AsciiRenderExampleScene, config: asciiRenderConfig },+ "halftone-print": {+ Scene: HalftonePrintExampleScene,+ config: halftonePrintConfig,+ },+ "underwater-ripple": {+ Scene: UnderwaterRippleExampleScene,+ config: underwaterRippleConfig,+ },+ "camera-lens": { Scene: CameraLensExampleScene, config: cameraLensConfig },+ "security-cam": { Scene: SecurityCamExampleScene, config: securityCamConfig },+ hologram: { Scene: HologramExampleScene, config: hologramConfig },+};++function makeStage(Scene: ComponentType) {+ return function CanvasSpikeStage() {+ return (+ <AbsoluteFill+ style={{+ backgroundColor: "#0a0a0a",+ ["--font-geist-sans" as string]: GEIST,+ fontFamily: GEIST,+ }}+ >+ <Scene />+ </AbsoluteFill>+ );+ };+}++const STAGES: Record<string, ReturnType<typeof makeStage>> = Object.fromEntries(+ Object.entries(SCENES).map(([id, entry]) => [id, makeStage(entry.Scene)]),+);++export function CanvasSpikeRoot() {+ return (+ <>+ {Object.entries(SCENES).map(([id, entry]) => (+ <Composition+ key={id}+ id={id}+ component={STAGES[id]}+ durationInFrames={entry.config.durationInFrames}+ fps={entry.config.fps}+ width={entry.config.compositionWidth}+ height={entry.config.compositionHeight}+ />+ ))}+ </>+ );+}++registerRoot(CanvasSpikeRoot);diff --git a/src/remotion/demos-entry.ts b/src/remotion/demos-entry.tsnew file mode 100644index 00000000..48f1df2e--- /dev/null+++ b/src/remotion/demos-entry.ts@@ -0,0 +1,5 @@+// Bundler entry for the demos render script (scripts/render-demos.mts).+// Importing the root runs `registerRoot(DemosRoot)`. Kept separate from+// index.ts so the github-stars server bundle and the demos bundle don't collide+// (a bundle registers exactly one root). Side-effect-only by design.+import "./demos-root";diff --git a/src/remotion/demos-root.tsx b/src/remotion/demos-root.tsxnew file mode 100644index 00000000..fc239635--- /dev/null+++ b/src/remotion/demos-root.tsx@@ -0,0 +1,94 @@+import { loadFont } from "@remotion/google-fonts/Geist";+import type { ComponentType } from "react";+import { AbsoluteFill, Composition, Loop, registerRoot } from "remotion";+import { examples } from "@/components/docs/examples";+import { aiExamples } from "@/components/docs/examples/ai";+import { blockExamples } from "@/components/docs/examples/blocks";++/**+ * Every renderable scene: the ui-tier `examples` (keyed `<name>-example`) plus+ * the composition `blockExamples` (keyed `<name>-flow`). Key namespaces don't+ * overlap, and both records share the timing/scene shape this root consumes.+ */+const ALL_SCENES = { ...examples, ...blockExamples, ...aiExamples };++/**+ * Demos bundle root. Auto-declares one Remotion composition per docs example+ * (the `examples` record is the single source of truth for timing + scene), so+ * `scripts/render-demos.mts` can render every example to an mp4. Kept separate+ * from `Root.tsx`/`index.ts` (the github-stars server bundle) — that entry is+ * untouched; this one is bundled only by the demos render script.+ *+ * Two fidelity bridges make the mp4 match the on-site @remotion/player preview:+ * - white stage background (= `--card` light = the `.surface-card` the preview+ * sits on); self-painting scenes (e.g. blur-in) just cover it.+ * - Geist loaded via @remotion/google-fonts, exposed as `--font-geist-sans` so+ * the CSS var the scenes reference resolves to the real face (the site gets+ * this from next/font, which doesn't exist in a standalone Remotion bundle).+ */++const { fontFamily: GEIST } = loadFont();++interface StageProps {+ // Remotion requires composition props to extend Record<string, unknown>.+ [key: string]: unknown;+ /** One animation cycle, in frames (from the example's `durationInFrames`). */+ loopFrames: number;+ /** Repeat the cycle this many times (CLI `--loops`, default 1). */+ loops: number;+}++/**+ * Bind each example's scene at bundle time via closure — components are not+ * JSON-serializable, so they can't ride through `defaultProps`/`inputProps`.+ * Only the numeric loop knobs cross that boundary.+ */+function makeStage(Example: ComponentType) {+ return function DemoStage({ loopFrames }: StageProps) {+ return (+ <AbsoluteFill+ style={{+ backgroundColor: "#ffffff",+ ["--font-geist-sans" as string]: GEIST,+ fontFamily: GEIST,+ }}+ >+ <Loop durationInFrames={loopFrames}>+ <Example />+ </Loop>+ </AbsoluteFill>+ );+ };+}++// Stable component reference per composition (don't re-create inside render).+const STAGES: Record<string, ReturnType<typeof makeStage>> = Object.fromEntries(+ Object.entries(ALL_SCENES).map(([id, entry]) => [+ id,+ makeStage(entry.Component),+ ]),+);++export function DemosRoot() {+ return (+ <>+ {Object.entries(ALL_SCENES).map(([id, entry]) => (+ <Composition+ key={id}+ id={id}+ component={STAGES[id]}+ durationInFrames={entry.durationInFrames}+ fps={entry.fps}+ width={entry.width}+ height={entry.height}+ defaultProps={{ loopFrames: entry.durationInFrames, loops: 1 }}+ calculateMetadata={({ props }) => ({+ durationInFrames: props.loopFrames * Math.max(1, props.loops),+ })}+ />+ ))}+ </>+ );+}++registerRoot(DemosRoot);diff --git a/src/remotion/hero-bg-root.tsx b/src/remotion/hero-bg-root.tsxnew file mode 100644index 00000000..5eb51ed8--- /dev/null+++ b/src/remotion/hero-bg-root.tsx@@ -0,0 +1,50 @@+import { AbsoluteFill, Composition, registerRoot } from "remotion";+import {+ ShaderWarp,+ type ShaderWarpProps,+} from "@/registry/remocn/shader-warp";++export const HERO_BG_WIDTH = 1200;+export const HERO_BG_HEIGHT = 630;+export const HERO_BG_FPS = 30;+export const HERO_BG_DURATION = 300;++export const HERO_BG_COLORS = ["#000d14", "#001929", "#00263d", "#00355a"];++export const HERO_BG_DEFAULTS: ShaderWarpProps = {+ colors: HERO_BG_COLORS,+ proportion: 0.5,+ softness: 0.15,+ distortion: 0.2,+ swirl: 0.4,+ swirlIterations: 10,+ shape: "checks",+ shapeScale: 0.5,+ scale: 1,+ rotation: 0,+};++export function HeroBgScene(props: ShaderWarpProps) {+ const colors = props.colors ?? HERO_BG_COLORS;+ return (+ <AbsoluteFill style={{ backgroundColor: colors[0] }}>+ <ShaderWarp {...props} />+ </AbsoluteFill>+ );+}++export function HeroBgRoot() {+ return (+ <Composition+ id="hero-bg"+ component={HeroBgScene}+ durationInFrames={HERO_BG_DURATION}+ fps={HERO_BG_FPS}+ width={HERO_BG_WIDTH}+ height={HERO_BG_HEIGHT}+ defaultProps={HERO_BG_DEFAULTS}+ />+ );+}++registerRoot(HeroBgRoot);diff --git a/src/remotion/index.ts b/src/remotion/index.tsnew file mode 100644index 00000000..84502a19--- /dev/null+++ b/src/remotion/index.ts@@ -0,0 +1,4 @@+// Bundler entry point. Importing Root runs `registerRoot(RemotionRoot)`, which+// is what `@remotion/bundler` (and the Remotion CLI) look for. Keep this file+// side-effect-only so the entry stays a stable, single source of truth.+import "./Root";diff --git a/src/remotion/not-found-root.tsx b/src/remotion/not-found-root.tsxnew file mode 100644index 00000000..a86406f4--- /dev/null+++ b/src/remotion/not-found-root.tsx@@ -0,0 +1,24 @@+import { Composition, registerRoot } from "remotion";+import {+ NOT_FOUND_DURATION,+ NOT_FOUND_FPS,+ NOT_FOUND_HEIGHT,+ NOT_FOUND_WIDTH,+ NotFoundScene,+} from "./not-found-scene";++export function NotFoundRoot() {+ return (+ <Composition+ id="not-found"+ component={NotFoundScene}+ durationInFrames={NOT_FOUND_DURATION}+ fps={NOT_FOUND_FPS}+ width={NOT_FOUND_WIDTH}+ height={NOT_FOUND_HEIGHT}+ defaultProps={{ theme: "dark" as const }}+ />+ );+}++registerRoot(NotFoundRoot);diff --git a/src/remotion/not-found-scene.tsx b/src/remotion/not-found-scene.tsxnew file mode 100644index 00000000..67a0b83b--- /dev/null+++ b/src/remotion/not-found-scene.tsx@@ -0,0 +1,90 @@+import { loadFont } from "@remotion/google-fonts/Manrope";+import { linearTiming, TransitionSeries } from "@remotion/transitions";+import { AbsoluteFill } from "remotion";+import { swirlDissolve } from "@/registry/remocn/swirl-dissolve";++const { fontFamily } = loadFont("normal", {+ weights: ["600"],+ subsets: ["latin"],+});++export type NotFoundTheme = "light" | "dark";++export type NotFoundSceneProps = {+ [key: string]: unknown;+ theme: NotFoundTheme;+};++const PALETTE = {+ dark: {+ backdrop: "#111115",+ text: "#eeeeee",+ swirl: ["#1b1926", "#463c5e", "#d4b3ff"],+ },+ light: {+ backdrop: "#ffffff",+ text: "#0a0a0a",+ swirl: ["#f3eefb", "#cdb9ef", "#8266b8"],+ },+} satisfies Record<+ NotFoundTheme,+ { backdrop: string; text: string; swirl: string[] }+>;++export const NOT_FOUND_FPS = 30;+export const NOT_FOUND_WIDTH = 1920;+export const NOT_FOUND_HEIGHT = 720;++const TRANSITION_FRAMES = 90;+const HOLD_FRAMES = 130;++export const NOT_FOUND_DURATION = HOLD_FRAMES * 2 - TRANSITION_FRAMES;++function Code({ color }: { color: string }) {+ return (+ <AbsoluteFill+ style={{+ alignItems: "center",+ justifyContent: "center",+ }}+ >+ <span+ style={{+ fontFamily,+ fontSize: 260,+ fontWeight: 600,+ letterSpacing: "-0.05em",+ color,+ }}+ >+ 404+ </span>+ </AbsoluteFill>+ );+}++export function NotFoundScene({ theme }: NotFoundSceneProps) {+ const { backdrop, text, swirl } = PALETTE[theme];++ return (+ <AbsoluteFill style={{ backgroundColor: backdrop }}>+ <TransitionSeries>+ <TransitionSeries.Sequence durationInFrames={HOLD_FRAMES}>+ <Code color={text} />+ </TransitionSeries.Sequence>+ <TransitionSeries.Transition+ timing={linearTiming({ durationInFrames: TRANSITION_FRAMES })}+ presentation={swirlDissolve({+ colors: swirl,+ colorBack: backdrop,+ bandCount: 10,+ softness: 0.35,+ })}+ />+ <TransitionSeries.Sequence durationInFrames={HOLD_FRAMES}>+ <Code color={text} />+ </TransitionSeries.Sequence>+ </TransitionSeries>+ </AbsoluteFill>+ );+}