Production-ready animations, transitions, backgrounds, and scenes for Remotion
TypeScript ai-agentsclaude-codedemo-videomcpmcp-servermodel-context-protocolmotion-designproduct-demoreactremotionshadcnvideo
feat: captions tab with 31 transcript-driven caption styles (REM-734) (#289)
KapishDimadbe525bbd663
diff --git a/app/(home)/components/hero-badge.tsx b/app/(home)/components/hero-badge.tsxindex f5011613..c11d5043 100644--- a/app/(home)/components/hero-badge.tsx+++ b/app/(home)/components/hero-badge.tsx@@ -5,7 +5,7 @@ import Link from "next/link";import { Badge } from "@/components/ui/badge";import { useTrackEvent } from "@/lib/analytics";-const HERO_BADGE_HREF = "/changelog#2026-09-26-motion-graphics";+const HERO_BADGE_HREF = "/docs/captions/getting-started/introduction";export function HeroBadge() {const trackEvent = useTrackEvent();@@ -27,7 +27,7 @@ export function HeroBadge() {}><span className="font-semibold text-foreground">Introducing</span>- <span className="text-foreground">Motion Graphics</span>+ <span className="text-foreground">Captions</span><ArrowRightclassName="size-3 transition-transform group-hover:translate-x-0.5"aria-hidden="true"diff --git a/app/docs/layout.tsx b/app/docs/layout.tsxindex a2230d58..3fbad808 100644--- a/app/docs/layout.tsx+++ b/app/docs/layout.tsx@@ -23,8 +23,15 @@ export default async function Layout({ children }: { children: ReactNode }) {// `withNewBadges`), then split it into the Components / Primitives tab trees// (see `splitDocsTree`). Both run on the server; `DocsShell` picks the tree// matching the active tab by pathname so each category owns its own sidebar.- const { components, primitives, shaders, filters, templates, icons } =- splitDocsTree(withNewBadges(source.pageTree));+ const {+ components,+ primitives,+ shaders,+ filters,+ captions,+ templates,+ icons,+ } = splitDocsTree(withNewBadges(source.pageTree));return (// fumadocs search + sidebar context lives here (docs-only) instead of the@@ -42,6 +49,7 @@ export default async function Layout({ children }: { children: ReactNode }) {primitivesTree={primitives}shadersTree={shaders}filtersTree={filters}+ captionsTree={captions}templatesTree={templates}iconsTree={icons}componentCount={componentCount}diff --git a/app/llms-components.txt/route.ts b/app/llms-components.txt/route.tsindex 0bee1dbb..5095dd59 100644--- a/app/llms-components.txt/route.ts+++ b/app/llms-components.txt/route.ts@@ -62,7 +62,9 @@ export function GET() {"time on top when the element should stay on screen after it settles. `state-driven` means the","component renders purely from its `state` prop and has no duration of its own. `sustained` means","the component wraps a scene and lasts exactly as long as that scene does — budget no frames for",- "it and pass it no `state`.",+ "it and pass it no `state`. `transcript-driven` means the component renders from a timed",+ "transcript (`captions: Caption[]`) and has no duration of its own — the `Sequence` must last at",+ "least until the last word's `endMs`.","`Vibe` is the tonal tag; match it to the brand rather than mixing freely.",];diff --git a/bun.lock b/bun.lockindex 12f6a82e..eab8a38a 100644--- a/bun.lock+++ b/bun.lock@@ -15,6 +15,7 @@"@openpanel/sdk": "^1.3.1","@paper-design/shaders-react": "0.0.76","@remotion/bundler": "4.0.530",+ "@remotion/captions": "4.0.530","@remotion/google-fonts": "4.0.530","@remotion/paths": "4.0.530","@remotion/player": "4.0.530",diff --git a/components/docs/docs-shell.tsx b/components/docs/docs-shell.tsxindex 791a8eda..7671222a 100644--- a/components/docs/docs-shell.tsx+++ b/components/docs/docs-shell.tsx@@ -44,6 +44,7 @@ export function DocsShell({primitivesTree,shadersTree,filtersTree,+ captionsTree,templatesTree,iconsTree,componentCount,@@ -53,6 +54,7 @@ export function DocsShell({primitivesTree: Root;shadersTree: Root;filtersTree: Root;+ captionsTree: Root;templatesTree: Root;iconsTree: Root;componentCount: number;@@ -81,6 +83,7 @@ export function DocsShell({primitives: primitivesTree,shaders: shadersTree,filters: filtersTree,+ captions: captionsTree,templates: templatesTree,icons: iconsTree,};diff --git a/components/docs/examples/caption-active-pop-example.tsx b/components/docs/examples/caption-active-pop-example.tsxnew file mode 100644index 00000000..25c9f1c9--- /dev/null+++ b/components/docs/examples/caption-active-pop-example.tsx@@ -0,0 +1,96 @@+"use client";++import { AbsoluteFill, useVideoConfig } from "remotion";+import { previewCaptions } from "@/components/docs/examples/caption-fixture";+import { CaptionActivePop } from "@/registry/remocn/caption-active-pop";++interface CaptionActivePopExampleProps {+ captions?: string;+ fontSize?: number;+ fontWeight?: number;+ color?: string;+ activeColor?: string;+ popScale?: number;+ combineTokensWithinMilliseconds?: number;+ holdMs?: number;+ shadow?: boolean;+}++export function CaptionActivePopExampleScene({+ captions,+ fontSize,+ fontWeight,+ color,+ activeColor,+ popScale,+ combineTokensWithinMilliseconds,+ holdMs,+ shadow,+}: CaptionActivePopExampleProps) {+ const { width, height } = useVideoConfig();+ return (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: height * 0.1,+ paddingInline: width * 0.1,+ }}+ >+ <CaptionActivePop+ captions={previewCaptions(captions)}+ fontSize={fontSize}+ fontWeight={fontWeight}+ color={color}+ activeColor={activeColor}+ popScale={popScale}+ combineTokensWithinMilliseconds={combineTokensWithinMilliseconds}+ holdMs={holdMs}+ shadow={shadow}+ />+ </AbsoluteFill>+ );+}++export const captionActivePopExampleCode = (+ values: Record<string, unknown>,+): string => {+ const fontSize = (values.fontSize as number) ?? 64;+ const fontWeight = (values.fontWeight as number) ?? 800;+ const color = (values.color as string) ?? "#ffffff";+ const activeColor = (values.activeColor as string) ?? "#facc15";+ const popScale = (values.popScale as number) ?? 1.12;+ const combine = (values.combineTokensWithinMilliseconds as number) ?? 1200;+ const holdMs = (values.holdMs as number) ?? 600;+ const shadow = (values.shadow as boolean) ?? true;+ const extra = [+ popScale !== 1.12 ? ` popScale={${popScale}}` : null,+ combine !== 1200+ ? ` combineTokensWithinMilliseconds={${combine}}`+ : null,+ holdMs !== 600 ? ` holdMs={${holdMs}}` : null,+ shadow ? null : " shadow={false}",+ ].filter(Boolean);+ return `import { AbsoluteFill } from "remotion";+import { CaptionActivePop } from "@/components/remocn/caption-active-pop";+import captions from "./captions.json";++export const MyScene = () => (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: 108,+ paddingInline: 192,+ }}+ >+ <CaptionActivePop+ captions={captions}+ fontSize={${fontSize}}+ fontWeight={${fontWeight}}+ color="${color}"+ activeColor="${activeColor}"+${extra.length > 0 ? `${extra.join("\n")}\n` : ""} />+ </AbsoluteFill>+);`;+};diff --git a/components/docs/examples/caption-blur-in-example.tsx b/components/docs/examples/caption-blur-in-example.tsxnew file mode 100644index 00000000..e08335ea--- /dev/null+++ b/components/docs/examples/caption-blur-in-example.tsx@@ -0,0 +1,91 @@+"use client";++import { AbsoluteFill, useVideoConfig } from "remotion";+import { previewCaptions } from "@/components/docs/examples/caption-fixture";+import { CaptionBlurIn } from "@/registry/remocn/caption-blur-in";++interface CaptionBlurInExampleProps {+ captions?: string;+ fontSize?: number;+ fontWeight?: number;+ color?: string;+ blur?: number;+ combineTokensWithinMilliseconds?: number;+ holdMs?: number;+ shadow?: boolean;+}++export function CaptionBlurInExampleScene({+ captions,+ fontSize,+ fontWeight,+ color,+ blur,+ combineTokensWithinMilliseconds,+ holdMs,+ shadow,+}: CaptionBlurInExampleProps) {+ const { width, height } = useVideoConfig();+ return (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: height * 0.1,+ paddingInline: width * 0.1,+ }}+ >+ <CaptionBlurIn+ captions={previewCaptions(captions)}+ fontSize={fontSize}+ fontWeight={fontWeight}+ color={color}+ blur={blur}+ combineTokensWithinMilliseconds={combineTokensWithinMilliseconds}+ holdMs={holdMs}+ shadow={shadow}+ />+ </AbsoluteFill>+ );+}++export const captionBlurInExampleCode = (+ values: Record<string, unknown>,+): string => {+ const fontSize = (values.fontSize as number) ?? 64;+ const fontWeight = (values.fontWeight as number) ?? 800;+ const color = (values.color as string) ?? "#ffffff";+ const blur = (values.blur as number) ?? 12;+ const combine = (values.combineTokensWithinMilliseconds as number) ?? 1200;+ const holdMs = (values.holdMs as number) ?? 600;+ const shadow = (values.shadow as boolean) ?? true;+ const extra = [+ blur !== 12 ? ` blur={${blur}}` : null,+ combine !== 1200+ ? ` combineTokensWithinMilliseconds={${combine}}`+ : null,+ holdMs !== 600 ? ` holdMs={${holdMs}}` : null,+ shadow ? null : " shadow={false}",+ ].filter(Boolean);+ return `import { AbsoluteFill } from "remotion";+import { CaptionBlurIn } from "@/components/remocn/caption-blur-in";+import captions from "./captions.json";++export const MyScene = () => (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: 108,+ paddingInline: 192,+ }}+ >+ <CaptionBlurIn+ captions={captions}+ fontSize={${fontSize}}+ fontWeight={${fontWeight}}+ color="${color}"+${extra.length > 0 ? `${extra.join("\n")}\n` : ""} />+ </AbsoluteFill>+);`;+};diff --git a/components/docs/examples/caption-bounce-in-example.tsx b/components/docs/examples/caption-bounce-in-example.tsxnew file mode 100644index 00000000..981d3f96--- /dev/null+++ b/components/docs/examples/caption-bounce-in-example.tsx@@ -0,0 +1,91 @@+"use client";++import { AbsoluteFill, useVideoConfig } from "remotion";+import { previewCaptions } from "@/components/docs/examples/caption-fixture";+import { CaptionBounceIn } from "@/registry/remocn/caption-bounce-in";++interface CaptionBounceInExampleProps {+ captions?: string;+ fontSize?: number;+ fontWeight?: number;+ color?: string;+ bounce?: number;+ combineTokensWithinMilliseconds?: number;+ holdMs?: number;+ shadow?: boolean;+}++export function CaptionBounceInExampleScene({+ captions,+ fontSize,+ fontWeight,+ color,+ bounce,+ combineTokensWithinMilliseconds,+ holdMs,+ shadow,+}: CaptionBounceInExampleProps) {+ const { width, height } = useVideoConfig();+ return (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: height * 0.1,+ paddingInline: width * 0.1,+ }}+ >+ <CaptionBounceIn+ captions={previewCaptions(captions)}+ fontSize={fontSize}+ fontWeight={fontWeight}+ color={color}+ bounce={bounce}+ combineTokensWithinMilliseconds={combineTokensWithinMilliseconds}+ holdMs={holdMs}+ shadow={shadow}+ />+ </AbsoluteFill>+ );+}++export const captionBounceInExampleCode = (+ values: Record<string, unknown>,+): string => {+ const fontSize = (values.fontSize as number) ?? 64;+ const fontWeight = (values.fontWeight as number) ?? 800;+ const color = (values.color as string) ?? "#ffffff";+ const bounce = (values.bounce as number) ?? 0.6;+ const combine = (values.combineTokensWithinMilliseconds as number) ?? 1200;+ const holdMs = (values.holdMs as number) ?? 600;+ const shadow = (values.shadow as boolean) ?? true;+ const extra = [+ bounce !== 0.6 ? ` bounce={${bounce}}` : null,+ combine !== 1200+ ? ` combineTokensWithinMilliseconds={${combine}}`+ : null,+ holdMs !== 600 ? ` holdMs={${holdMs}}` : null,+ shadow ? null : " shadow={false}",+ ].filter(Boolean);+ return `import { AbsoluteFill } from "remotion";+import { CaptionBounceIn } from "@/components/remocn/caption-bounce-in";+import captions from "./captions.json";++export const MyScene = () => (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: 108,+ paddingInline: 192,+ }}+ >+ <CaptionBounceIn+ captions={captions}+ fontSize={${fontSize}}+ fontWeight={${fontWeight}}+ color="${color}"+${extra.length > 0 ? `${extra.join("\n")}\n` : ""} />+ </AbsoluteFill>+);`;+};diff --git a/components/docs/examples/caption-cube-example.tsx b/components/docs/examples/caption-cube-example.tsxnew file mode 100644index 00000000..41eb6597--- /dev/null+++ b/components/docs/examples/caption-cube-example.tsx@@ -0,0 +1,98 @@+"use client";++import { AbsoluteFill, useVideoConfig } from "remotion";+import { previewCaptions } from "@/components/docs/examples/caption-fixture";+import { CaptionCube } from "@/registry/remocn/caption-cube";++interface CaptionCubeExampleProps {+ captions?: string;+ fontSize?: number;+ fontWeight?: number;+ color?: string;+ tintActive?: boolean;+ activeColor?: string;+ combineTokensWithinMilliseconds?: number;+ holdMs?: number;+ shadow?: boolean;+}++export function CaptionCubeExampleScene({+ captions,+ fontSize,+ fontWeight,+ color,+ tintActive,+ activeColor,+ combineTokensWithinMilliseconds,+ holdMs,+ shadow,+}: CaptionCubeExampleProps) {+ const { width, height } = useVideoConfig();+ return (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: height * 0.1,+ paddingInline: width * 0.1,+ }}+ >+ <CaptionCube+ captions={previewCaptions(captions)}+ fontSize={fontSize}+ fontWeight={fontWeight}+ color={color}+ tintActive={tintActive}+ activeColor={activeColor}+ combineTokensWithinMilliseconds={combineTokensWithinMilliseconds}+ holdMs={holdMs}+ shadow={shadow}+ />+ </AbsoluteFill>+ );+}++export const captionCubeExampleCode = (+ values: Record<string, unknown>,+): string => {+ const fontSize = (values.fontSize as number) ?? 64;+ const fontWeight = (values.fontWeight as number) ?? 800;+ const color = (values.color as string) ?? "#ffffff";+ const tintActive = (values.tintActive as boolean) ?? false;+ const activeColor = (values.activeColor as string) ?? "#facc15";+ const combine = (values.combineTokensWithinMilliseconds as number) ?? 800;+ const holdMs = (values.holdMs as number) ?? 600;+ const shadow = (values.shadow as boolean) ?? true;+ const extra = [+ tintActive ? " tintActive" : null,+ tintActive && activeColor !== "#facc15"+ ? ` activeColor="${activeColor}"`+ : null,+ combine !== 800+ ? ` combineTokensWithinMilliseconds={${combine}}`+ : null,+ holdMs !== 600 ? ` holdMs={${holdMs}}` : null,+ shadow ? null : " shadow={false}",+ ].filter(Boolean);+ return `import { AbsoluteFill } from "remotion";+import { CaptionCube } from "@/components/remocn/caption-cube";+import captions from "./captions.json";++export const MyScene = () => (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: 108,+ paddingInline: 192,+ }}+ >+ <CaptionCube+ captions={captions}+ fontSize={${fontSize}}+ fontWeight={${fontWeight}}+ color="${color}"+${extra.length > 0 ? `${extra.join("\n")}\n` : ""} />+ </AbsoluteFill>+);`;+};diff --git a/components/docs/examples/caption-dim-progress-example.tsx b/components/docs/examples/caption-dim-progress-example.tsxnew file mode 100644index 00000000..c4ca1d87--- /dev/null+++ b/components/docs/examples/caption-dim-progress-example.tsx@@ -0,0 +1,91 @@+"use client";++import { AbsoluteFill, useVideoConfig } from "remotion";+import { previewCaptions } from "@/components/docs/examples/caption-fixture";+import { CaptionDimProgress } from "@/registry/remocn/caption-dim-progress";++interface CaptionDimProgressExampleProps {+ captions?: string;+ fontSize?: number;+ fontWeight?: number;+ color?: string;+ dimOpacity?: number;+ combineTokensWithinMilliseconds?: number;+ holdMs?: number;+ shadow?: boolean;+}++export function CaptionDimProgressExampleScene({+ captions,+ fontSize,+ fontWeight,+ color,+ dimOpacity,+ combineTokensWithinMilliseconds,+ holdMs,+ shadow,+}: CaptionDimProgressExampleProps) {+ const { width, height } = useVideoConfig();+ return (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: height * 0.1,+ paddingInline: width * 0.1,+ }}+ >+ <CaptionDimProgress+ captions={previewCaptions(captions)}+ fontSize={fontSize}+ fontWeight={fontWeight}+ color={color}+ dimOpacity={dimOpacity}+ combineTokensWithinMilliseconds={combineTokensWithinMilliseconds}+ holdMs={holdMs}+ shadow={shadow}+ />+ </AbsoluteFill>+ );+}++export const captionDimProgressExampleCode = (+ values: Record<string, unknown>,+): string => {+ const fontSize = (values.fontSize as number) ?? 64;+ const fontWeight = (values.fontWeight as number) ?? 800;+ const color = (values.color as string) ?? "#ffffff";+ const dimOpacity = (values.dimOpacity as number) ?? 0.35;+ const combine = (values.combineTokensWithinMilliseconds as number) ?? 1200;+ const holdMs = (values.holdMs as number) ?? 600;+ const shadow = (values.shadow as boolean) ?? true;+ const extra = [+ dimOpacity !== 0.35 ? ` dimOpacity={${dimOpacity}}` : null,+ combine !== 1200+ ? ` combineTokensWithinMilliseconds={${combine}}`+ : null,+ holdMs !== 600 ? ` holdMs={${holdMs}}` : null,+ shadow ? null : " shadow={false}",+ ].filter(Boolean);+ return `import { AbsoluteFill } from "remotion";+import { CaptionDimProgress } from "@/components/remocn/caption-dim-progress";+import captions from "./captions.json";++export const MyScene = () => (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: 108,+ paddingInline: 192,+ }}+ >+ <CaptionDimProgress+ captions={captions}+ fontSize={${fontSize}}+ fontWeight={${fontWeight}}+ color="${color}"+${extra.length > 0 ? `${extra.join("\n")}\n` : ""} />+ </AbsoluteFill>+);`;+};diff --git a/components/docs/examples/caption-drop-example.tsx b/components/docs/examples/caption-drop-example.tsxnew file mode 100644index 00000000..bad36525--- /dev/null+++ b/components/docs/examples/caption-drop-example.tsx@@ -0,0 +1,91 @@+"use client";++import { AbsoluteFill, useVideoConfig } from "remotion";+import { previewCaptions } from "@/components/docs/examples/caption-fixture";+import { CaptionDrop } from "@/registry/remocn/caption-drop";++interface CaptionDropExampleProps {+ captions?: string;+ fontSize?: number;+ fontWeight?: number;+ color?: string;+ bounce?: number;+ combineTokensWithinMilliseconds?: number;+ holdMs?: number;+ shadow?: boolean;+}++export function CaptionDropExampleScene({+ captions,+ fontSize,+ fontWeight,+ color,+ bounce,+ combineTokensWithinMilliseconds,+ holdMs,+ shadow,+}: CaptionDropExampleProps) {+ const { width, height } = useVideoConfig();+ return (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: height * 0.1,+ paddingInline: width * 0.1,+ }}+ >+ <CaptionDrop+ captions={previewCaptions(captions)}+ fontSize={fontSize}+ fontWeight={fontWeight}+ color={color}+ bounce={bounce}+ combineTokensWithinMilliseconds={combineTokensWithinMilliseconds}+ holdMs={holdMs}+ shadow={shadow}+ />+ </AbsoluteFill>+ );+}++export const captionDropExampleCode = (+ values: Record<string, unknown>,+): string => {+ const fontSize = (values.fontSize as number) ?? 64;+ const fontWeight = (values.fontWeight as number) ?? 800;+ const color = (values.color as string) ?? "#ffffff";+ const bounce = (values.bounce as number) ?? 0.6;+ const combine = (values.combineTokensWithinMilliseconds as number) ?? 1200;+ const holdMs = (values.holdMs as number) ?? 600;+ const shadow = (values.shadow as boolean) ?? true;+ const extra = [+ bounce !== 0.6 ? ` bounce={${bounce}}` : null,+ combine !== 1200+ ? ` combineTokensWithinMilliseconds={${combine}}`+ : null,+ holdMs !== 600 ? ` holdMs={${holdMs}}` : null,+ shadow ? null : " shadow={false}",+ ].filter(Boolean);+ return `import { AbsoluteFill } from "remotion";+import { CaptionDrop } from "@/components/remocn/caption-drop";+import captions from "./captions.json";++export const MyScene = () => (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: 108,+ paddingInline: 192,+ }}+ >+ <CaptionDrop+ captions={captions}+ fontSize={${fontSize}}+ fontWeight={${fontWeight}}+ color="${color}"+${extra.length > 0 ? `${extra.join("\n")}\n` : ""} />+ </AbsoluteFill>+);`;+};diff --git a/components/docs/examples/caption-emoji-example.tsx b/components/docs/examples/caption-emoji-example.tsxnew file mode 100644index 00000000..d399b4c1--- /dev/null+++ b/components/docs/examples/caption-emoji-example.tsx@@ -0,0 +1,108 @@+"use client";++import { AbsoluteFill, useVideoConfig } from "remotion";+import { previewCaptions } from "@/components/docs/examples/caption-fixture";+import { CaptionEmoji } from "@/registry/remocn/caption-emoji";++export const CAPTION_EMOJI_PREVIEW_MAP: Record<string, string> = {+ thing: "👀",+ lose: "📉",+ three: "⏱️",+ captions: "💬",+ sound: "🔇",+};++interface CaptionEmojiExampleProps {+ captions?: string;+ fontSize?: number;+ fontWeight?: number;+ color?: string;+ emojiSize?: number;+ combineTokensWithinMilliseconds?: number;+ holdMs?: number;+ shadow?: boolean;+}++export function CaptionEmojiExampleScene({+ captions,+ fontSize,+ fontWeight,+ color,+ emojiSize,+ combineTokensWithinMilliseconds,+ holdMs,+ shadow,+}: CaptionEmojiExampleProps) {+ const { width, height } = useVideoConfig();+ return (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: height * 0.1,+ paddingInline: width * 0.1,+ }}+ >+ <CaptionEmoji+ captions={previewCaptions(captions)}+ emoji={CAPTION_EMOJI_PREVIEW_MAP}+ fontSize={fontSize}+ fontWeight={fontWeight}+ color={color}+ emojiSize={emojiSize}+ combineTokensWithinMilliseconds={combineTokensWithinMilliseconds}+ holdMs={holdMs}+ shadow={shadow}+ />+ </AbsoluteFill>+ );+}++export const captionEmojiExampleCode = (+ values: Record<string, unknown>,+): string => {+ const fontSize = (values.fontSize as number) ?? 64;+ const fontWeight = (values.fontWeight as number) ?? 800;+ const color = (values.color as string) ?? "#ffffff";+ const emojiSize = (values.emojiSize as number) ?? 0.9;+ const combine = (values.combineTokensWithinMilliseconds as number) ?? 1200;+ const holdMs = (values.holdMs as number) ?? 600;+ const shadow = (values.shadow as boolean) ?? true;+ const extra = [+ emojiSize !== 0.9 ? ` emojiSize={${emojiSize}}` : null,+ combine !== 1200+ ? ` combineTokensWithinMilliseconds={${combine}}`+ : null,+ holdMs !== 600 ? ` holdMs={${holdMs}}` : null,+ shadow ? null : " shadow={false}",+ ].filter(Boolean);+ const map = Object.entries(CAPTION_EMOJI_PREVIEW_MAP)+ .map(([word, glyph]) => ` ${word}: "${glyph}",`)+ .join("\n");+ return `import { AbsoluteFill } from "remotion";+import { CaptionEmoji } from "@/components/remocn/caption-emoji";+import captions from "./captions.json";++const emoji = {+${map}+};++export const MyScene = () => (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: 108,+ paddingInline: 192,+ }}+ >+ <CaptionEmoji+ captions={captions}+ emoji={emoji}+ fontSize={${fontSize}}+ fontWeight={${fontWeight}}+ color="${color}"+${extra.length > 0 ? `${extra.join("\n")}\n` : ""} />+ </AbsoluteFill>+);`;+};diff --git a/components/docs/examples/caption-fixture.ts b/components/docs/examples/caption-fixture.tsnew file mode 100644index 00000000..072f5629--- /dev/null+++ b/components/docs/examples/caption-fixture.ts@@ -0,0 +1,75 @@+import type { Caption } from "@remotion/captions";++const word = (text: string, startMs: number, endMs: number): Caption => ({+ text,+ startMs,+ endMs,+ timestampMs: Math.round((startMs + endMs) / 2),+ confidence: 0.97,+});++export const CAPTION_FIXTURE: Caption[] = [+ word(" So", 300, 460),+ word(" here's", 460, 700),+ word(" the", 700, 820),+ word(" thing.", 820, 1240),+ word(" Most", 1700, 1960),+ word(" demo", 1960, 2240),+ word(" videos", 2240, 2680),+ word(" lose", 2680, 2960),+ word(" people", 2960, 3320),+ word(" in", 3320, 3420),+ word(" the", 3420, 3520),+ word(" first", 3520, 3820),+ word(" three", 3820, 4100),+ word(" seconds.", 4100, 4780),+ word(" Captions", 5400, 5920),+ word(" keep", 5920, 6140),+ word(" them", 6140, 6300),+ word(" watching,", 6300, 6860),+ word(" even", 6960, 7180),+ word(" with", 7180, 7320),+ word(" the", 7320, 7420),+ word(" sound", 7420, 7760),+ word(" off.", 7760, 8300),+];++export const CAPTION_FIXTURE_TEXT = CAPTION_FIXTURE.map((c) =>+ c.text.trim(),+).join(" ");++const LEAD_IN_MS = 300;++export function captionsFromText(text: string): Caption[] {+ const words = text.split(/\s+/).filter(Boolean);+ let cursor = LEAD_IN_MS;+ return words.map((w) => {+ const startMs = cursor;+ const endMs = startMs + 160 + w.length * 45;+ const pause = /[.!?]$/.test(w) ? 420 : /[,;:]$/.test(w) ? 140 : 0;+ cursor = endMs + pause;+ return word(` ${w}`, startMs, endMs);+ });+}++export function previewCaptions(text: string | undefined): Caption[] {+ if (text === undefined || text.trim() === CAPTION_FIXTURE_TEXT) {+ return CAPTION_FIXTURE;+ }+ return captionsFromText(text);+}++export function previewTailMs(holdMs: unknown): number {+ return Math.max(1000, (typeof holdMs === "number" ? holdMs : 600) + 400);+}++export function previewCaptionsDuration(+ text: string | undefined,+ fps: number,+ tailMs = 1000,+): number {+ const captions = previewCaptions(text);+ const last = captions[captions.length - 1];+ const endMs = (last ? last.endMs : 0) + tailMs;+ return Math.max(fps, Math.ceil((endMs / 1000) * fps));+}diff --git a/components/docs/examples/caption-handwrite-example.tsx b/components/docs/examples/caption-handwrite-example.tsxnew file mode 100644index 00000000..a0a44293--- /dev/null+++ b/components/docs/examples/caption-handwrite-example.tsx@@ -0,0 +1,91 @@+"use client";++import { AbsoluteFill, useVideoConfig } from "remotion";+import { previewCaptions } from "@/components/docs/examples/caption-fixture";+import { CaptionHandwrite } from "@/registry/remocn/caption-handwrite";++interface CaptionHandwriteExampleProps {+ captions?: string;+ fontSize?: number;+ fontWeight?: number;+ color?: string;+ wobble?: number;+ combineTokensWithinMilliseconds?: number;+ holdMs?: number;+ shadow?: boolean;+}++export function CaptionHandwriteExampleScene({+ captions,+ fontSize,+ fontWeight,+ color,+ wobble,+ combineTokensWithinMilliseconds,+ holdMs,+ shadow,+}: CaptionHandwriteExampleProps) {+ const { width, height } = useVideoConfig();+ return (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: height * 0.1,+ paddingInline: width * 0.1,+ }}+ >+ <CaptionHandwrite+ captions={previewCaptions(captions)}+ fontSize={fontSize}+ fontWeight={fontWeight}+ color={color}+ wobble={wobble}+ combineTokensWithinMilliseconds={combineTokensWithinMilliseconds}+ holdMs={holdMs}+ shadow={shadow}+ />+ </AbsoluteFill>+ );+}++export const captionHandwriteExampleCode = (+ values: Record<string, unknown>,+): string => {+ const fontSize = (values.fontSize as number) ?? 64;+ const fontWeight = (values.fontWeight as number) ?? 800;+ const color = (values.color as string) ?? "#ffffff";+ const wobble = (values.wobble as number) ?? 1;+ const combine = (values.combineTokensWithinMilliseconds as number) ?? 1200;+ const holdMs = (values.holdMs as number) ?? 600;+ const shadow = (values.shadow as boolean) ?? true;+ const extra = [+ wobble !== 1 ? ` wobble={${wobble}}` : null,+ combine !== 1200+ ? ` combineTokensWithinMilliseconds={${combine}}`+ : null,+ holdMs !== 600 ? ` holdMs={${holdMs}}` : null,+ shadow ? null : " shadow={false}",+ ].filter(Boolean);+ return `import { AbsoluteFill } from "remotion";+import { CaptionHandwrite } from "@/components/remocn/caption-handwrite";+import captions from "./captions.json";++export const MyScene = () => (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: 108,+ paddingInline: 192,+ }}+ >+ <CaptionHandwrite+ captions={captions}+ fontSize={${fontSize}}+ fontWeight={${fontWeight}}+ color="${color}"+${extra.length > 0 ? `${extra.join("\n")}\n` : ""} />+ </AbsoluteFill>+);`;+};diff --git a/components/docs/examples/caption-highlight-box-example.tsx b/components/docs/examples/caption-highlight-box-example.tsxnew file mode 100644index 00000000..46fb774c--- /dev/null+++ b/components/docs/examples/caption-highlight-box-example.tsx@@ -0,0 +1,106 @@+"use client";++import { AbsoluteFill, useVideoConfig } from "remotion";+import { previewCaptions } from "@/components/docs/examples/caption-fixture";+import { CaptionHighlightBox } from "@/registry/remocn/caption-highlight-box";++interface CaptionHighlightBoxExampleProps {+ captions?: string;+ fontSize?: number;+ fontWeight?: number;+ color?: string;+ activeColor?: string;+ boxColor?: string;+ boxRadius?: number;+ boxPadding?: number;+ combineTokensWithinMilliseconds?: number;+ holdMs?: number;+ shadow?: boolean;+}++export function CaptionHighlightBoxExampleScene({+ captions,+ fontSize,+ fontWeight,+ color,+ activeColor,+ boxColor,+ boxRadius,+ boxPadding,+ combineTokensWithinMilliseconds,+ holdMs,+ shadow,+}: CaptionHighlightBoxExampleProps) {+ const { width, height } = useVideoConfig();+ return (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: height * 0.1,+ paddingInline: width * 0.1,+ }}+ >+ <CaptionHighlightBox+ captions={previewCaptions(captions)}+ fontSize={fontSize}+ fontWeight={fontWeight}+ color={color}+ activeColor={activeColor}+ boxColor={boxColor}+ boxRadius={boxRadius}+ boxPadding={boxPadding}+ combineTokensWithinMilliseconds={combineTokensWithinMilliseconds}+ holdMs={holdMs}+ shadow={shadow}+ />+ </AbsoluteFill>+ );+}++export const captionHighlightBoxExampleCode = (+ values: Record<string, unknown>,+): string => {+ const fontSize = (values.fontSize as number) ?? 64;+ const fontWeight = (values.fontWeight as number) ?? 800;+ const color = (values.color as string) ?? "#ffffff";+ const activeColor = (values.activeColor as string) ?? "#0a0a0a";+ const boxColor = (values.boxColor as string) ?? "#facc15";+ const boxRadius = (values.boxRadius as number) ?? 0.16;+ const boxPadding = (values.boxPadding as number) ?? 0.14;+ const combine = (values.combineTokensWithinMilliseconds as number) ?? 1200;+ const holdMs = (values.holdMs as number) ?? 600;+ const shadow = (values.shadow as boolean) ?? true;+ const extra = [+ boxRadius !== 0.16 ? ` boxRadius={${boxRadius}}` : null,+ boxPadding !== 0.14 ? ` boxPadding={${boxPadding}}` : null,+ combine !== 1200+ ? ` combineTokensWithinMilliseconds={${combine}}`+ : null,+ holdMs !== 600 ? ` holdMs={${holdMs}}` : null,+ shadow ? null : " shadow={false}",+ ].filter(Boolean);+ return `import { AbsoluteFill } from "remotion";+import { CaptionHighlightBox } from "@/components/remocn/caption-highlight-box";+import captions from "./captions.json";++export const MyScene = () => (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: 108,+ paddingInline: 192,+ }}+ >+ <CaptionHighlightBox+ captions={captions}+ fontSize={${fontSize}}+ fontWeight={${fontWeight}}+ color="${color}"+ activeColor="${activeColor}"+ boxColor="${boxColor}"+${extra.length > 0 ? `${extra.join("\n")}\n` : ""} />+ </AbsoluteFill>+);`;+};diff --git a/components/docs/examples/caption-karaoke-example.tsx b/components/docs/examples/caption-karaoke-example.tsxnew file mode 100644index 00000000..c701a39b--- /dev/null+++ b/components/docs/examples/caption-karaoke-example.tsx@@ -0,0 +1,91 @@+"use client";++import { AbsoluteFill, useVideoConfig } from "remotion";+import { previewCaptions } from "@/components/docs/examples/caption-fixture";+import { CaptionKaraoke } from "@/registry/remocn/caption-karaoke";++interface CaptionKaraokeExampleProps {+ captions?: string;+ fontSize?: number;+ fontWeight?: number;+ color?: string;+ activeColor?: string;+ combineTokensWithinMilliseconds?: number;+ holdMs?: number;+ shadow?: boolean;+}++export function CaptionKaraokeExampleScene({+ captions,+ fontSize,+ fontWeight,+ color,+ activeColor,+ combineTokensWithinMilliseconds,+ holdMs,+ shadow,+}: CaptionKaraokeExampleProps) {+ const { width, height } = useVideoConfig();+ return (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: height * 0.1,+ paddingInline: width * 0.1,+ }}+ >+ <CaptionKaraoke+ captions={previewCaptions(captions)}+ fontSize={fontSize}+ fontWeight={fontWeight}+ color={color}+ activeColor={activeColor}+ combineTokensWithinMilliseconds={combineTokensWithinMilliseconds}+ holdMs={holdMs}+ shadow={shadow}+ />+ </AbsoluteFill>+ );+}++export const captionKaraokeExampleCode = (+ values: Record<string, unknown>,+): string => {+ const fontSize = (values.fontSize as number) ?? 64;+ const fontWeight = (values.fontWeight as number) ?? 800;+ const color = (values.color as string) ?? "#ffffff";+ const activeColor = (values.activeColor as string) ?? "#facc15";+ const combine = (values.combineTokensWithinMilliseconds as number) ?? 1200;+ const holdMs = (values.holdMs as number) ?? 600;+ const shadow = (values.shadow as boolean) ?? true;+ const extra = [+ combine !== 1200+ ? ` combineTokensWithinMilliseconds={${combine}}`+ : null,+ holdMs !== 600 ? ` holdMs={${holdMs}}` : null,+ shadow ? null : " shadow={false}",+ ].filter(Boolean);+ return `import { AbsoluteFill } from "remotion";+import { CaptionKaraoke } from "@/components/remocn/caption-karaoke";+import captions from "./captions.json";++export const MyScene = () => (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: 108,+ paddingInline: 192,+ }}+ >+ <CaptionKaraoke+ captions={captions}+ fontSize={${fontSize}}+ fontWeight={${fontWeight}}+ color="${color}"+ activeColor="${activeColor}"+${extra.length > 0 ? `${extra.join("\n")}\n` : ""} />+ </AbsoluteFill>+);`;+};diff --git a/components/docs/examples/caption-knockout-example.tsx b/components/docs/examples/caption-knockout-example.tsxnew file mode 100644index 00000000..800ff47a--- /dev/null+++ b/components/docs/examples/caption-knockout-example.tsx@@ -0,0 +1,102 @@+"use client";++import { AbsoluteFill, useCurrentFrame, useVideoConfig } from "remotion";+import { previewCaptions } from "@/components/docs/examples/caption-fixture";+import { CaptionKnockout } from "@/registry/remocn/caption-knockout";++interface CaptionKnockoutExampleProps {+ captions?: string;+ fontSize?: number;+ fontWeight?: number;+ plateColor?: string;+ upcomingOpacity?: number;+ combineTokensWithinMilliseconds?: number;+ holdMs?: number;+}++const STRIPE_PX = 36;+const STRIPE_PERIOD_X = (STRIPE_PX * 2) / Math.cos((25 * Math.PI) / 180);++export function CaptionKnockoutExampleScene({+ captions,+ fontSize,+ fontWeight,+ plateColor,+ upcomingOpacity,+ combineTokensWithinMilliseconds,+ holdMs,+}: CaptionKnockoutExampleProps) {+ const frame = useCurrentFrame();+ const { width, height } = useVideoConfig();+ return (+ <AbsoluteFill style={{ overflow: "hidden" }}>+ <div+ style={{+ position: "absolute",+ inset: -STRIPE_PERIOD_X,+ backgroundImage: `repeating-linear-gradient(115deg, #262626 0px, #262626 ${STRIPE_PX}px, #525252 ${STRIPE_PX}px, #525252 ${STRIPE_PX * 2}px)`,+ transform: `translateX(${(frame * 1.5) % STRIPE_PERIOD_X}px)`,+ }}+ />+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: height * 0.1,+ paddingInline: width * 0.1,+ }}+ >+ <CaptionKnockout+ captions={previewCaptions(captions)}+ fontSize={fontSize}+ fontWeight={fontWeight}+ plateColor={plateColor}+ upcomingOpacity={upcomingOpacity}+ combineTokensWithinMilliseconds={combineTokensWithinMilliseconds}+ holdMs={holdMs}+ />+ </AbsoluteFill>+ </AbsoluteFill>+ );+}++export const captionKnockoutExampleCode = (+ values: Record<string, unknown>,+): string => {+ const fontSize = (values.fontSize as number) ?? 64;+ const fontWeight = (values.fontWeight as number) ?? 800;+ const plateColor = (values.plateColor as string) ?? "#ffffff";+ const upcomingOpacity = (values.upcomingOpacity as number) ?? 0.15;+ const combine = (values.combineTokensWithinMilliseconds as number) ?? 1200;+ const holdMs = (values.holdMs as number) ?? 600;+ const extra = [+ upcomingOpacity !== 0.15+ ? ` upcomingOpacity={${upcomingOpacity}}`+ : null,+ combine !== 1200+ ? ` combineTokensWithinMilliseconds={${combine}}`+ : null,+ holdMs !== 600 ? ` holdMs={${holdMs}}` : null,+ ].filter(Boolean);+ return `import { AbsoluteFill } from "remotion";+import { CaptionKnockout } from "@/components/remocn/caption-knockout";+import captions from "./captions.json";++export const MyScene = () => (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: 108,+ paddingInline: 192,+ }}+ >+ <CaptionKnockout+ captions={captions}+ fontSize={${fontSize}}+ fontWeight={${fontWeight}}+ plateColor="${plateColor}"+${extra.length > 0 ? `${extra.join("\n")}\n` : ""} />+ </AbsoluteFill>+);`;+};diff --git a/components/docs/examples/caption-label-maker-example.tsx b/components/docs/examples/caption-label-maker-example.tsxnew file mode 100644index 00000000..e1d57102--- /dev/null+++ b/components/docs/examples/caption-label-maker-example.tsx@@ -0,0 +1,86 @@+"use client";++import { AbsoluteFill, useVideoConfig } from "remotion";+import { previewCaptions } from "@/components/docs/examples/caption-fixture";+import { CaptionLabelMaker } from "@/registry/remocn/caption-label-maker";++interface CaptionLabelMakerExampleProps {+ captions?: string;+ fontSize?: number;+ fontWeight?: number;+ color?: string;+ tapeColor?: string;+ combineTokensWithinMilliseconds?: number;+ holdMs?: number;+}++export function CaptionLabelMakerExampleScene({+ captions,+ fontSize,+ fontWeight,+ color,+ tapeColor,+ combineTokensWithinMilliseconds,+ holdMs,+}: CaptionLabelMakerExampleProps) {+ const { width, height } = useVideoConfig();+ return (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: height * 0.1,+ paddingInline: width * 0.1,+ }}+ >+ <CaptionLabelMaker+ captions={previewCaptions(captions)}+ fontSize={fontSize}+ fontWeight={fontWeight}+ color={color}+ tapeColor={tapeColor}+ combineTokensWithinMilliseconds={combineTokensWithinMilliseconds}+ holdMs={holdMs}+ />+ </AbsoluteFill>+ );+}++export const captionLabelMakerExampleCode = (+ values: Record<string, unknown>,+): string => {+ const fontSize = (values.fontSize as number) ?? 64;+ const fontWeight = (values.fontWeight as number) ?? 800;+ const color = (values.color as string) ?? "#ffffff";+ const tapeColor = (values.tapeColor as string) ?? "#18181b";+ const combine = (values.combineTokensWithinMilliseconds as number) ?? 1000;+ const holdMs = (values.holdMs as number) ?? 600;+ const extra = [+ combine !== 1000+ ? ` combineTokensWithinMilliseconds={${combine}}`+ : null,+ holdMs !== 600 ? ` holdMs={${holdMs}}` : null,+ ].filter(Boolean);+ return `import { AbsoluteFill } from "remotion";+import { CaptionLabelMaker } from "@/components/remocn/caption-label-maker";+import captions from "./captions.json";++export const MyScene = () => (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: 108,+ paddingInline: 192,+ }}+ >+ <CaptionLabelMaker+ captions={captions}+ fontSize={${fontSize}}+ fontWeight={${fontWeight}}+ color="${color}"+ tapeColor="${tapeColor}"+${extra.length > 0 ? `${extra.join("\n")}\n` : ""} />+ </AbsoluteFill>+);`;+};diff --git a/components/docs/examples/caption-marker-example.tsx b/components/docs/examples/caption-marker-example.tsxnew file mode 100644index 00000000..727a3cdd--- /dev/null+++ b/components/docs/examples/caption-marker-example.tsx@@ -0,0 +1,102 @@+"use client";++import { AbsoluteFill, useVideoConfig } from "remotion";+import { previewCaptions } from "@/components/docs/examples/caption-fixture";+import { CaptionMarker } from "@/registry/remocn/caption-marker";++const PREVIEW_KEYWORDS = ["thing", "lose", "three", "captions", "sound"];++interface CaptionMarkerExampleProps {+ captions?: string;+ fontSize?: number;+ fontWeight?: number;+ color?: string;+ markerColor?: string;+ markerTextColor?: string;+ combineTokensWithinMilliseconds?: number;+ holdMs?: number;+ shadow?: boolean;+}++export function CaptionMarkerExampleScene({+ captions,+ fontSize,+ fontWeight,+ color,+ markerColor,+ markerTextColor,+ combineTokensWithinMilliseconds,+ holdMs,+ shadow,+}: CaptionMarkerExampleProps) {+ const { width, height } = useVideoConfig();+ return (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: height * 0.1,+ paddingInline: width * 0.1,+ }}+ >+ <CaptionMarker+ captions={previewCaptions(captions)}+ keywords={PREVIEW_KEYWORDS}+ fontSize={fontSize}+ fontWeight={fontWeight}+ color={color}+ markerColor={markerColor}+ markerTextColor={markerTextColor}+ combineTokensWithinMilliseconds={combineTokensWithinMilliseconds}+ holdMs={holdMs}+ shadow={shadow}+ />+ </AbsoluteFill>+ );+}++export const captionMarkerExampleCode = (+ values: Record<string, unknown>,+): string => {+ const fontSize = (values.fontSize as number) ?? 64;+ const fontWeight = (values.fontWeight as number) ?? 800;+ const color = (values.color as string) ?? "#ffffff";+ const markerColor = (values.markerColor as string) ?? "#facc15";+ const markerTextColor = (values.markerTextColor as string) ?? "#0a0a0a";+ const combine = (values.combineTokensWithinMilliseconds as number) ?? 1200;+ const holdMs = (values.holdMs as number) ?? 600;+ const shadow = (values.shadow as boolean) ?? true;+ const extra = [+ markerTextColor !== "#0a0a0a"+ ? ` markerTextColor="${markerTextColor}"`+ : null,+ combine !== 1200+ ? ` combineTokensWithinMilliseconds={${combine}}`+ : null,+ holdMs !== 600 ? ` holdMs={${holdMs}}` : null,+ shadow ? null : " shadow={false}",+ ].filter(Boolean);+ return `import { AbsoluteFill } from "remotion";+import { CaptionMarker } from "@/components/remocn/caption-marker";+import captions from "./captions.json";++export const MyScene = () => (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: 108,+ paddingInline: 192,+ }}+ >+ <CaptionMarker+ captions={captions}+ keywords={[${PREVIEW_KEYWORDS.map((k) => `"${k}"`).join(", ")}]}+ fontSize={${fontSize}}+ fontWeight={${fontWeight}}+ color="${color}"+ markerColor="${markerColor}"+${extra.length > 0 ? `${extra.join("\n")}\n` : ""} />+ </AbsoluteFill>+);`;+};diff --git a/components/docs/examples/caption-outline-example.tsx b/components/docs/examples/caption-outline-example.tsxnew file mode 100644index 00000000..e1544923--- /dev/null+++ b/components/docs/examples/caption-outline-example.tsx@@ -0,0 +1,96 @@+"use client";++import { AbsoluteFill, useVideoConfig } from "remotion";+import { previewCaptions } from "@/components/docs/examples/caption-fixture";+import { CaptionOutline } from "@/registry/remocn/caption-outline";++interface CaptionOutlineExampleProps {+ captions?: string;+ fontSize?: number;+ fontWeight?: number;+ color?: string;+ activeColor?: string;+ strokeColor?: string;+ strokeWidth?: number;+ combineTokensWithinMilliseconds?: number;+ holdMs?: number;+}++export function CaptionOutlineExampleScene({+ captions,+ fontSize,+ fontWeight,+ color,+ activeColor,+ strokeColor,+ strokeWidth,+ combineTokensWithinMilliseconds,+ holdMs,+}: CaptionOutlineExampleProps) {+ const { width, height } = useVideoConfig();+ return (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: height * 0.1,+ paddingInline: width * 0.1,+ }}+ >+ <CaptionOutline+ captions={previewCaptions(captions)}+ fontSize={fontSize}+ fontWeight={fontWeight}+ color={color}+ activeColor={activeColor}+ strokeColor={strokeColor}+ strokeWidth={strokeWidth}+ combineTokensWithinMilliseconds={combineTokensWithinMilliseconds}+ holdMs={holdMs}+ />+ </AbsoluteFill>+ );+}++export const captionOutlineExampleCode = (+ values: Record<string, unknown>,+): string => {+ const fontSize = (values.fontSize as number) ?? 64;+ const fontWeight = (values.fontWeight as number) ?? 800;+ const color = (values.color as string) ?? "#ffffff";+ const activeColor = (values.activeColor as string) ?? "#facc15";+ const strokeColor = (values.strokeColor as string) ?? "#000000";+ const strokeWidth = (values.strokeWidth as number) ?? 0.12;+ const combine = (values.combineTokensWithinMilliseconds as number) ?? 1200;+ const holdMs = (values.holdMs as number) ?? 600;+ const extra = [+ strokeColor !== "#000000" ? ` strokeColor="${strokeColor}"` : null,+ strokeWidth !== 0.12 ? ` strokeWidth={${strokeWidth}}` : null,+ combine !== 1200+ ? ` combineTokensWithinMilliseconds={${combine}}`+ : null,+ holdMs !== 600 ? ` holdMs={${holdMs}}` : null,+ ].filter(Boolean);+ return `import { AbsoluteFill } from "remotion";+import { CaptionOutline } from "@/components/remocn/caption-outline";+import captions from "./captions.json";++export const MyScene = () => (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: 108,+ paddingInline: 192,+ }}+ >+ <CaptionOutline+ captions={captions}+ fontSize={${fontSize}}+ fontWeight={${fontWeight}}+ color="${color}"+ activeColor="${activeColor}"+${extra.length > 0 ? `${extra.join("\n")}\n` : ""} />+ </AbsoluteFill>+);`;+};diff --git a/components/docs/examples/caption-prosody-example.tsx b/components/docs/examples/caption-prosody-example.tsxnew file mode 100644index 00000000..f30c11ed--- /dev/null+++ b/components/docs/examples/caption-prosody-example.tsx@@ -0,0 +1,101 @@+"use client";++import { AbsoluteFill, useVideoConfig } from "remotion";+import { previewCaptions } from "@/components/docs/examples/caption-fixture";+import { CaptionProsody } from "@/registry/remocn/caption-prosody";++interface CaptionProsodyExampleProps {+ captions?: string;+ fontSize?: number;+ fontWeight?: number;+ color?: string;+ activeColor?: string;+ minScale?: number;+ maxScale?: number;+ combineTokensWithinMilliseconds?: number;+ holdMs?: number;+ shadow?: boolean;+}++export function CaptionProsodyExampleScene({+ captions,+ fontSize,+ fontWeight,+ color,+ activeColor,+ minScale,+ maxScale,+ combineTokensWithinMilliseconds,+ holdMs,+ shadow,+}: CaptionProsodyExampleProps) {+ const { width, height } = useVideoConfig();+ return (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: height * 0.1,+ paddingInline: width * 0.1,+ }}+ >+ <CaptionProsody+ captions={previewCaptions(captions)}+ fontSize={fontSize}+ fontWeight={fontWeight}+ color={color}+ activeColor={activeColor}+ minScale={minScale}+ maxScale={maxScale}+ combineTokensWithinMilliseconds={combineTokensWithinMilliseconds}+ holdMs={holdMs}+ shadow={shadow}+ />+ </AbsoluteFill>+ );+}++export const captionProsodyExampleCode = (+ values: Record<string, unknown>,+): string => {+ const fontSize = (values.fontSize as number) ?? 64;+ const fontWeight = (values.fontWeight as number) ?? 800;+ const color = (values.color as string) ?? "#ffffff";+ const activeColor = (values.activeColor as string) ?? "#facc15";+ const minScale = (values.minScale as number) ?? 0.75;+ const maxScale = (values.maxScale as number) ?? 1.6;+ const combine = (values.combineTokensWithinMilliseconds as number) ?? 1200;+ const holdMs = (values.holdMs as number) ?? 600;+ const shadow = (values.shadow as boolean) ?? true;+ const extra = [+ minScale !== 0.75 ? ` minScale={${minScale}}` : null,+ maxScale !== 1.6 ? ` maxScale={${maxScale}}` : null,+ combine !== 1200+ ? ` combineTokensWithinMilliseconds={${combine}}`+ : null,+ holdMs !== 600 ? ` holdMs={${holdMs}}` : null,+ shadow ? null : " shadow={false}",+ ].filter(Boolean);+ return `import { AbsoluteFill } from "remotion";+import { CaptionProsody } from "@/components/remocn/caption-prosody";+import captions from "./captions.json";++export const MyScene = () => (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: 108,+ paddingInline: 192,+ }}+ >+ <CaptionProsody+ captions={captions}+ fontSize={${fontSize}}+ fontWeight={${fontWeight}}+ color="${color}"+ activeColor="${activeColor}"+${extra.length > 0 ? `${extra.join("\n")}\n` : ""} />+ </AbsoluteFill>+);`;+};diff --git a/components/docs/examples/caption-redact-example.tsx b/components/docs/examples/caption-redact-example.tsxnew file mode 100644index 00000000..44827ad4--- /dev/null+++ b/components/docs/examples/caption-redact-example.tsx@@ -0,0 +1,91 @@+"use client";++import { AbsoluteFill, useVideoConfig } from "remotion";+import { previewCaptions } from "@/components/docs/examples/caption-fixture";+import { CaptionRedact } from "@/registry/remocn/caption-redact";++interface CaptionRedactExampleProps {+ captions?: string;+ fontSize?: number;+ fontWeight?: number;+ color?: string;+ barColor?: string;+ combineTokensWithinMilliseconds?: number;+ holdMs?: number;+ shadow?: boolean;+}++export function CaptionRedactExampleScene({+ captions,+ fontSize,+ fontWeight,+ color,+ barColor,+ combineTokensWithinMilliseconds,+ holdMs,+ shadow,+}: CaptionRedactExampleProps) {+ const { width, height } = useVideoConfig();+ return (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: height * 0.1,+ paddingInline: width * 0.1,+ }}+ >+ <CaptionRedact+ captions={previewCaptions(captions)}+ fontSize={fontSize}+ fontWeight={fontWeight}+ color={color}+ barColor={barColor}+ combineTokensWithinMilliseconds={combineTokensWithinMilliseconds}+ holdMs={holdMs}+ shadow={shadow}+ />+ </AbsoluteFill>+ );+}++export const captionRedactExampleCode = (+ values: Record<string, unknown>,+): string => {+ const fontSize = (values.fontSize as number) ?? 64;+ const fontWeight = (values.fontWeight as number) ?? 800;+ const color = (values.color as string) ?? "#ffffff";+ const barColor = (values.barColor as string) ?? "#0a0a0a";+ const combine = (values.combineTokensWithinMilliseconds as number) ?? 1200;+ const holdMs = (values.holdMs as number) ?? 600;+ const shadow = (values.shadow as boolean) ?? true;+ const extra = [+ combine !== 1200+ ? ` combineTokensWithinMilliseconds={${combine}}`+ : null,+ holdMs !== 600 ? ` holdMs={${holdMs}}` : null,+ shadow ? null : " shadow={false}",+ ].filter(Boolean);+ return `import { AbsoluteFill } from "remotion";+import { CaptionRedact } from "@/components/remocn/caption-redact";+import captions from "./captions.json";++export const MyScene = () => (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: 108,+ paddingInline: 192,+ }}+ >+ <CaptionRedact+ captions={captions}+ fontSize={${fontSize}}+ fontWeight={${fontWeight}}+ color="${color}"+ barColor="${barColor}"+${extra.length > 0 ? `${extra.join("\n")}\n` : ""} />+ </AbsoluteFill>+);`;+};diff --git a/components/docs/examples/caption-rise-example.tsx b/components/docs/examples/caption-rise-example.tsxnew file mode 100644index 00000000..330fb161--- /dev/null+++ b/components/docs/examples/caption-rise-example.tsx@@ -0,0 +1,86 @@+"use client";++import { AbsoluteFill, useVideoConfig } from "remotion";+import { previewCaptions } from "@/components/docs/examples/caption-fixture";+import { CaptionRise } from "@/registry/remocn/caption-rise";++interface CaptionRiseExampleProps {+ captions?: string;+ fontSize?: number;+ fontWeight?: number;+ color?: string;+ combineTokensWithinMilliseconds?: number;+ holdMs?: number;+ shadow?: boolean;+}++export function CaptionRiseExampleScene({+ captions,+ fontSize,+ fontWeight,+ color,+ combineTokensWithinMilliseconds,+ holdMs,+ shadow,+}: CaptionRiseExampleProps) {+ const { width, height } = useVideoConfig();+ return (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: height * 0.1,+ paddingInline: width * 0.1,+ }}+ >+ <CaptionRise+ captions={previewCaptions(captions)}+ fontSize={fontSize}+ fontWeight={fontWeight}+ color={color}+ combineTokensWithinMilliseconds={combineTokensWithinMilliseconds}+ holdMs={holdMs}+ shadow={shadow}+ />+ </AbsoluteFill>+ );+}++export const captionRiseExampleCode = (+ values: Record<string, unknown>,+): string => {+ const fontSize = (values.fontSize as number) ?? 64;+ const fontWeight = (values.fontWeight as number) ?? 800;+ const color = (values.color as string) ?? "#ffffff";+ const combine = (values.combineTokensWithinMilliseconds as number) ?? 1200;+ const holdMs = (values.holdMs as number) ?? 600;+ const shadow = (values.shadow as boolean) ?? true;+ const extra = [+ combine !== 1200+ ? ` combineTokensWithinMilliseconds={${combine}}`+ : null,+ holdMs !== 600 ? ` holdMs={${holdMs}}` : null,+ shadow ? null : " shadow={false}",+ ].filter(Boolean);+ return `import { AbsoluteFill } from "remotion";+import { CaptionRise } from "@/components/remocn/caption-rise";+import captions from "./captions.json";++export const MyScene = () => (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: 108,+ paddingInline: 192,+ }}+ >+ <CaptionRise+ captions={captions}+ fontSize={${fontSize}}+ fontWeight={${fontWeight}}+ color="${color}"+${extra.length > 0 ? `${extra.join("\n")}\n` : ""} />+ </AbsoluteFill>+);`;+};diff --git a/components/docs/examples/caption-scramble-example.tsx b/components/docs/examples/caption-scramble-example.tsxnew file mode 100644index 00000000..e48a3737--- /dev/null+++ b/components/docs/examples/caption-scramble-example.tsx@@ -0,0 +1,91 @@+"use client";++import { AbsoluteFill, useVideoConfig } from "remotion";+import { previewCaptions } from "@/components/docs/examples/caption-fixture";+import { CaptionScramble } from "@/registry/remocn/caption-scramble";++interface CaptionScrambleExampleProps {+ captions?: string;+ fontSize?: number;+ fontWeight?: number;+ color?: string;+ glyphColor?: string;+ combineTokensWithinMilliseconds?: number;+ holdMs?: number;+ shadow?: boolean;+}++export function CaptionScrambleExampleScene({+ captions,+ fontSize,+ fontWeight,+ color,+ glyphColor,+ combineTokensWithinMilliseconds,+ holdMs,+ shadow,+}: CaptionScrambleExampleProps) {+ const { width, height } = useVideoConfig();+ return (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: height * 0.1,+ paddingInline: width * 0.1,+ }}+ >+ <CaptionScramble+ captions={previewCaptions(captions)}+ fontSize={fontSize}+ fontWeight={fontWeight}+ color={color}+ glyphColor={glyphColor}+ combineTokensWithinMilliseconds={combineTokensWithinMilliseconds}+ holdMs={holdMs}+ shadow={shadow}+ />+ </AbsoluteFill>+ );+}++export const captionScrambleExampleCode = (+ values: Record<string, unknown>,+): string => {+ const fontSize = (values.fontSize as number) ?? 64;+ const fontWeight = (values.fontWeight as number) ?? 800;+ const color = (values.color as string) ?? "#ffffff";+ const glyphColor = (values.glyphColor as string) ?? "#a3a3a3";+ const combine = (values.combineTokensWithinMilliseconds as number) ?? 1200;+ const holdMs = (values.holdMs as number) ?? 600;+ const shadow = (values.shadow as boolean) ?? true;+ const extra = [+ glyphColor !== "#a3a3a3" ? ` glyphColor="${glyphColor}"` : null,+ combine !== 1200+ ? ` combineTokensWithinMilliseconds={${combine}}`+ : null,+ holdMs !== 600 ? ` holdMs={${holdMs}}` : null,+ shadow ? null : " shadow={false}",+ ].filter(Boolean);+ return `import { AbsoluteFill } from "remotion";+import { CaptionScramble } from "@/components/remocn/caption-scramble";+import captions from "./captions.json";++export const MyScene = () => (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: 108,+ paddingInline: 192,+ }}+ >+ <CaptionScramble+ captions={captions}+ fontSize={${fontSize}}+ fontWeight={${fontWeight}}+ color="${color}"+${extra.length > 0 ? `${extra.join("\n")}\n` : ""} />+ </AbsoluteFill>+);`;+};diff --git a/components/docs/examples/caption-slice-example.tsx b/components/docs/examples/caption-slice-example.tsxnew file mode 100644index 00000000..5f8dbbeb--- /dev/null+++ b/components/docs/examples/caption-slice-example.tsx@@ -0,0 +1,91 @@+"use client";++import { AbsoluteFill, useVideoConfig } from "remotion";+import { previewCaptions } from "@/components/docs/examples/caption-fixture";+import { CaptionSlice } from "@/registry/remocn/caption-slice";++interface CaptionSliceExampleProps {+ captions?: string;+ fontSize?: number;+ fontWeight?: number;+ color?: string;+ distance?: number;+ combineTokensWithinMilliseconds?: number;+ holdMs?: number;+ shadow?: boolean;+}++export function CaptionSliceExampleScene({+ captions,+ fontSize,+ fontWeight,+ color,+ distance,+ combineTokensWithinMilliseconds,+ holdMs,+ shadow,+}: CaptionSliceExampleProps) {+ const { width, height } = useVideoConfig();+ return (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: height * 0.1,+ paddingInline: width * 0.1,+ }}+ >+ <CaptionSlice+ captions={previewCaptions(captions)}+ fontSize={fontSize}+ fontWeight={fontWeight}+ color={color}+ distance={distance}+ combineTokensWithinMilliseconds={combineTokensWithinMilliseconds}+ holdMs={holdMs}+ shadow={shadow}+ />+ </AbsoluteFill>+ );+}++export const captionSliceExampleCode = (+ values: Record<string, unknown>,+): string => {+ const fontSize = (values.fontSize as number) ?? 64;+ const fontWeight = (values.fontWeight as number) ?? 800;+ const color = (values.color as string) ?? "#ffffff";+ const distance = (values.distance as number) ?? 0.6;+ const combine = (values.combineTokensWithinMilliseconds as number) ?? 1200;+ const holdMs = (values.holdMs as number) ?? 600;+ const shadow = (values.shadow as boolean) ?? true;+ const extra = [+ distance !== 0.6 ? ` distance={${distance}}` : null,+ combine !== 1200+ ? ` combineTokensWithinMilliseconds={${combine}}`+ : null,+ holdMs !== 600 ? ` holdMs={${holdMs}}` : null,+ shadow ? null : " shadow={false}",+ ].filter(Boolean);+ return `import { AbsoluteFill } from "remotion";+import { CaptionSlice } from "@/components/remocn/caption-slice";+import captions from "./captions.json";++export const MyScene = () => (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: 108,+ paddingInline: 192,+ }}+ >+ <CaptionSlice+ captions={captions}+ fontSize={${fontSize}}+ fontWeight={${fontWeight}}+ color="${color}"+${extra.length > 0 ? `${extra.join("\n")}\n` : ""} />+ </AbsoluteFill>+);`;+};diff --git a/components/docs/examples/caption-slot-example.tsx b/components/docs/examples/caption-slot-example.tsxnew file mode 100644index 00000000..d585e7dd--- /dev/null+++ b/components/docs/examples/caption-slot-example.tsx@@ -0,0 +1,86 @@+"use client";++import { AbsoluteFill, useVideoConfig } from "remotion";+import { previewCaptions } from "@/components/docs/examples/caption-fixture";+import { CaptionSlot } from "@/registry/remocn/caption-slot";++interface CaptionSlotExampleProps {+ captions?: string;+ fontSize?: number;+ fontWeight?: number;+ color?: string;+ combineTokensWithinMilliseconds?: number;+ holdMs?: number;+ shadow?: boolean;+}++export function CaptionSlotExampleScene({+ captions,+ fontSize,+ fontWeight,+ color,+ combineTokensWithinMilliseconds,+ holdMs,+ shadow,+}: CaptionSlotExampleProps) {+ const { width, height } = useVideoConfig();+ return (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: height * 0.1,+ paddingInline: width * 0.1,+ }}+ >+ <CaptionSlot+ captions={previewCaptions(captions)}+ fontSize={fontSize}+ fontWeight={fontWeight}+ color={color}+ combineTokensWithinMilliseconds={combineTokensWithinMilliseconds}+ holdMs={holdMs}+ shadow={shadow}+ />+ </AbsoluteFill>+ );+}++export const captionSlotExampleCode = (+ values: Record<string, unknown>,+): string => {+ const fontSize = (values.fontSize as number) ?? 64;+ const fontWeight = (values.fontWeight as number) ?? 800;+ const color = (values.color as string) ?? "#ffffff";+ const combine = (values.combineTokensWithinMilliseconds as number) ?? 800;+ const holdMs = (values.holdMs as number) ?? 600;+ const shadow = (values.shadow as boolean) ?? true;+ const extra = [+ combine !== 800+ ? ` combineTokensWithinMilliseconds={${combine}}`+ : null,+ holdMs !== 600 ? ` holdMs={${holdMs}}` : null,+ shadow ? null : " shadow={false}",+ ].filter(Boolean);+ return `import { AbsoluteFill } from "remotion";+import { CaptionSlot } from "@/components/remocn/caption-slot";+import captions from "./captions.json";++export const MyScene = () => (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: 108,+ paddingInline: 192,+ }}+ >+ <CaptionSlot+ captions={captions}+ fontSize={${fontSize}}+ fontWeight={${fontWeight}}+ color="${color}"+${extra.length > 0 ? `${extra.join("\n")}\n` : ""} />+ </AbsoluteFill>+);`;+};diff --git a/components/docs/examples/caption-speaker-example.tsx b/components/docs/examples/caption-speaker-example.tsxnew file mode 100644index 00000000..d6b565ac--- /dev/null+++ b/components/docs/examples/caption-speaker-example.tsx@@ -0,0 +1,167 @@+"use client";++import { AbsoluteFill, useVideoConfig } from "remotion";+import { captionsFromText } from "@/components/docs/examples/caption-fixture";+import type { SpeakerCaption } from "@/lib/remocn/caption-core";+import { CaptionSpeaker } from "@/registry/remocn/caption-speaker";++const line = (+ speaker: string,+ text: string,+ startMs: number,+ endMs: number,+): SpeakerCaption => ({+ text,+ startMs,+ endMs,+ timestampMs: Math.round((startMs + endMs) / 2),+ confidence: 0.96,+ speaker,+});++export const CAPTION_DIALOGUE_FIXTURE: SpeakerCaption[] = [+ line("host", " So", 300, 460),+ line("host", " what", 460, 640),+ line("host", " made", 640, 860),+ line("host", " you", 860, 980),+ line("host", " add", 980, 1180),+ line("host", " captions?", 1180, 1800),+ line("guest", " Most", 2300, 2560),+ line("guest", " people", 2560, 2900),+ line("guest", " watch", 2900, 3160),+ line("guest", " with", 3160, 3280),+ line("guest", " the", 3280, 3380),+ line("guest", " sound", 3380, 3720),+ line("guest", " off.", 3720, 4240),+ line("host", " Really?", 4800, 5400),+ line("guest", " Almost", 5800, 6140),+ line("guest", " everyone.", 6140, 6760),+ line("guest", " Captions", 7000, 7480),+ line("guest", " keep", 7480, 7700),+ line("guest", " them", 7700, 7860),+ line("guest", " watching.", 7860, 8400),+];++const DIALOGUE_TEXT = CAPTION_DIALOGUE_FIXTURE.map((c) => c.text.trim()).join(+ " ",+);++function alternateSpeakers(text: string): SpeakerCaption[] {+ let speaker = "host";+ return captionsFromText(text).map((caption) => {+ const current = { ...caption, speaker };+ if (/[.!?]$/.test(caption.text.trim())) {+ speaker = speaker === "host" ? "guest" : "host";+ }+ return current;+ });+}++export function speakerPreviewCaptions(+ text: string | undefined,+): SpeakerCaption[] {+ if (text === undefined || text.trim() === DIALOGUE_TEXT) {+ return CAPTION_DIALOGUE_FIXTURE;+ }+ return alternateSpeakers(text);+}++export function speakerPreviewDuration(+ text: string | undefined,+ fps: number,+ tailMs = 1000,+): number {+ const captions = speakerPreviewCaptions(text);+ const last = captions[captions.length - 1];+ const endMs = (last ? last.endMs : 0) + tailMs;+ return Math.max(fps, Math.ceil((endMs / 1000) * fps));+}++interface CaptionSpeakerExampleProps {+ captions?: string;+ fontSize?: number;+ fontWeight?: number;+ color?: string;+ upcomingOpacity?: number;+ combineTokensWithinMilliseconds?: number;+ holdMs?: number;+ shadow?: boolean;+}++export function CaptionSpeakerExampleScene({+ captions,+ fontSize,+ fontWeight,+ color,+ upcomingOpacity,+ combineTokensWithinMilliseconds,+ holdMs,+ shadow,+}: CaptionSpeakerExampleProps) {+ const { width, height } = useVideoConfig();+ return (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: height * 0.1,+ paddingInline: width * 0.1,+ }}+ >+ <CaptionSpeaker+ captions={speakerPreviewCaptions(captions)}+ fontSize={fontSize}+ fontWeight={fontWeight}+ color={color}+ upcomingOpacity={upcomingOpacity}+ combineTokensWithinMilliseconds={combineTokensWithinMilliseconds}+ holdMs={holdMs}+ shadow={shadow}+ />+ </AbsoluteFill>+ );+}++export const captionSpeakerExampleCode = (+ values: Record<string, unknown>,+): string => {+ const fontSize = (values.fontSize as number) ?? 64;+ const fontWeight = (values.fontWeight as number) ?? 800;+ const color = (values.color as string) ?? "#ffffff";+ const upcomingOpacity = (values.upcomingOpacity as number) ?? 0.4;+ const combine = (values.combineTokensWithinMilliseconds as number) ?? 1200;+ const holdMs = (values.holdMs as number) ?? 600;+ const shadow = (values.shadow as boolean) ?? true;+ const extra = [+ color !== "#ffffff" ? ` color="${color}"` : null,+ upcomingOpacity !== 0.4+ ? ` upcomingOpacity={${upcomingOpacity}}`+ : null,+ combine !== 1200+ ? ` combineTokensWithinMilliseconds={${combine}}`+ : null,+ holdMs !== 600 ? ` holdMs={${holdMs}}` : null,+ shadow ? null : " shadow={false}",+ ].filter(Boolean);+ return `import { AbsoluteFill } from "remotion";+import { CaptionSpeaker } from "@/components/remocn/caption-speaker";+import captions from "./captions.json";++export const MyScene = () => (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: 108,+ paddingInline: 192,+ }}+ >+ <CaptionSpeaker+ captions={captions}+ speakerColors={{ host: "#facc15", guest: "#38bdf8" }}+ fontSize={${fontSize}}+ fontWeight={${fontWeight}}+${extra.length > 0 ? `${extra.join("\n")}\n` : ""} />+ </AbsoluteFill>+);`;+};diff --git a/components/docs/examples/caption-split-flap-example.tsx b/components/docs/examples/caption-split-flap-example.tsxnew file mode 100644index 00000000..73b5d53f--- /dev/null+++ b/components/docs/examples/caption-split-flap-example.tsx@@ -0,0 +1,86 @@+"use client";++import { AbsoluteFill, useVideoConfig } from "remotion";+import { previewCaptions } from "@/components/docs/examples/caption-fixture";+import { CaptionSplitFlap } from "@/registry/remocn/caption-split-flap";++interface CaptionSplitFlapExampleProps {+ captions?: string;+ fontSize?: number;+ fontWeight?: number;+ color?: string;+ tileColor?: string;+ combineTokensWithinMilliseconds?: number;+ holdMs?: number;+}++export function CaptionSplitFlapExampleScene({+ captions,+ fontSize,+ fontWeight,+ color,+ tileColor,+ combineTokensWithinMilliseconds,+ holdMs,+}: CaptionSplitFlapExampleProps) {+ const { width, height } = useVideoConfig();+ return (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: height * 0.1,+ paddingInline: width * 0.08,+ }}+ >+ <CaptionSplitFlap+ captions={previewCaptions(captions)}+ fontSize={fontSize}+ fontWeight={fontWeight}+ color={color}+ tileColor={tileColor}+ combineTokensWithinMilliseconds={combineTokensWithinMilliseconds}+ holdMs={holdMs}+ />+ </AbsoluteFill>+ );+}++export const captionSplitFlapExampleCode = (+ values: Record<string, unknown>,+): string => {+ const fontSize = (values.fontSize as number) ?? 56;+ const fontWeight = (values.fontWeight as number) ?? 800;+ const color = (values.color as string) ?? "#ffffff";+ const tileColor = (values.tileColor as string) ?? "#111111";+ const combine = (values.combineTokensWithinMilliseconds as number) ?? 1000;+ const holdMs = (values.holdMs as number) ?? 600;+ const extra = [+ combine !== 1000+ ? ` combineTokensWithinMilliseconds={${combine}}`+ : null,+ holdMs !== 600 ? ` holdMs={${holdMs}}` : null,+ ].filter(Boolean);+ return `import { AbsoluteFill } from "remotion";+import { CaptionSplitFlap } from "@/components/remocn/caption-split-flap";+import captions from "./captions.json";++export const MyScene = () => (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: 108,+ paddingInline: 154,+ }}+ >+ <CaptionSplitFlap+ captions={captions}+ fontSize={${fontSize}}+ fontWeight={${fontWeight}}+ color="${color}"+ tileColor="${tileColor}"+${extra.length > 0 ? `${extra.join("\n")}\n` : ""} />+ </AbsoluteFill>+);`;+};diff --git a/components/docs/examples/caption-stack-example.tsx b/components/docs/examples/caption-stack-example.tsxnew file mode 100644index 00000000..52d010d2--- /dev/null+++ b/components/docs/examples/caption-stack-example.tsx@@ -0,0 +1,111 @@+"use client";++import { AbsoluteFill, useVideoConfig } from "remotion";+import {+ CAPTION_FIXTURE_TEXT,+ previewCaptions,+} from "@/components/docs/examples/caption-fixture";+import { CaptionStack } from "@/registry/remocn/caption-stack";++const PREVIEW_KEYWORDS = ["thing", "lose", "three", "captions", "sound"];++interface CaptionStackExampleProps {+ captions?: string;+ fontSize?: number;+ fontWeight?: number;+ color?: string;+ emphasisColor?: string;+ emphasisScale?: number;+ combineTokensWithinMilliseconds?: number;+ holdMs?: number;+ shadow?: boolean;+}++export function CaptionStackExampleScene({+ captions,+ fontSize,+ fontWeight,+ color,+ emphasisColor,+ emphasisScale,+ combineTokensWithinMilliseconds,+ holdMs,+ shadow,+}: CaptionStackExampleProps) {+ const { width, height } = useVideoConfig();+ return (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: height * 0.1,+ paddingInline: width * 0.1,+ }}+ >+ <CaptionStack+ captions={previewCaptions(captions)}+ keywords={+ captions === undefined || captions.trim() === CAPTION_FIXTURE_TEXT+ ? PREVIEW_KEYWORDS+ : undefined+ }+ fontSize={fontSize}+ fontWeight={fontWeight}+ color={color}+ emphasisColor={emphasisColor}+ emphasisScale={emphasisScale}+ combineTokensWithinMilliseconds={combineTokensWithinMilliseconds}+ holdMs={holdMs}+ shadow={shadow}+ />+ </AbsoluteFill>+ );+}++export const captionStackExampleCode = (+ values: Record<string, unknown>,+): string => {+ const fontSize = (values.fontSize as number) ?? 64;+ const fontWeight = (values.fontWeight as number) ?? 800;+ const color = (values.color as string) ?? "#ffffff";+ const emphasisColor = (values.emphasisColor as string) ?? "#facc15";+ const emphasisScale = (values.emphasisScale as number) ?? 1.7;+ const combine = (values.combineTokensWithinMilliseconds as number) ?? 1600;+ const holdMs = (values.holdMs as number) ?? 600;+ const shadow = (values.shadow as boolean) ?? true;+ const keywordsLine =+ typeof values.captions !== "string" ||+ values.captions.trim() === CAPTION_FIXTURE_TEXT+ ? ` keywords={[${PREVIEW_KEYWORDS.map((k) => `"${k}"`).join(", ")}]}\n`+ : "";+ const extra = [+ emphasisScale !== 1.7 ? ` emphasisScale={${emphasisScale}}` : null,+ combine !== 1600+ ? ` combineTokensWithinMilliseconds={${combine}}`+ : null,+ holdMs !== 600 ? ` holdMs={${holdMs}}` : null,+ shadow ? null : " shadow={false}",+ ].filter(Boolean);+ return `import { AbsoluteFill } from "remotion";+import { CaptionStack } from "@/components/remocn/caption-stack";+import captions from "./captions.json";++export const MyScene = () => (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: 108,+ paddingInline: 192,+ }}+ >+ <CaptionStack+ captions={captions}+${keywordsLine} fontSize={${fontSize}}+ fontWeight={${fontWeight}}+ color="${color}"+ emphasisColor="${emphasisColor}"+${extra.length > 0 ? `${extra.join("\n")}\n` : ""} />+ </AbsoluteFill>+);`;+};diff --git a/components/docs/examples/caption-stamp-example.tsx b/components/docs/examples/caption-stamp-example.tsxnew file mode 100644index 00000000..c9d4ec79--- /dev/null+++ b/components/docs/examples/caption-stamp-example.tsx@@ -0,0 +1,111 @@+"use client";++import { AbsoluteFill, useVideoConfig } from "remotion";+import {+ CAPTION_FIXTURE_TEXT,+ previewCaptions,+} from "@/components/docs/examples/caption-fixture";+import { CaptionStamp } from "@/registry/remocn/caption-stamp";++const PREVIEW_KEYWORDS = ["thing", "lose", "three", "captions", "sound"];++interface CaptionStampExampleProps {+ captions?: string;+ fontSize?: number;+ fontWeight?: number;+ color?: string;+ stampColor?: string;+ texture?: boolean;+ combineTokensWithinMilliseconds?: number;+ holdMs?: number;+ shadow?: boolean;+}++export function CaptionStampExampleScene({+ captions,+ fontSize,+ fontWeight,+ color,+ stampColor,+ texture,+ combineTokensWithinMilliseconds,+ holdMs,+ shadow,+}: CaptionStampExampleProps) {+ const { width, height } = useVideoConfig();+ return (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: height * 0.1,+ paddingInline: width * 0.1,+ }}+ >+ <CaptionStamp+ captions={previewCaptions(captions)}+ keywords={+ captions === undefined || captions.trim() === CAPTION_FIXTURE_TEXT+ ? PREVIEW_KEYWORDS+ : undefined+ }+ fontSize={fontSize}+ fontWeight={fontWeight}+ color={color}+ stampColor={stampColor}+ texture={texture}+ combineTokensWithinMilliseconds={combineTokensWithinMilliseconds}+ holdMs={holdMs}+ shadow={shadow}+ />+ </AbsoluteFill>+ );+}++export const captionStampExampleCode = (+ values: Record<string, unknown>,+): string => {+ const fontSize = (values.fontSize as number) ?? 64;+ const fontWeight = (values.fontWeight as number) ?? 800;+ const color = (values.color as string) ?? "#ffffff";+ const stampColor = (values.stampColor as string) ?? "#ef4444";+ const texture = (values.texture as boolean) ?? true;+ const combine = (values.combineTokensWithinMilliseconds as number) ?? 1200;+ const holdMs = (values.holdMs as number) ?? 600;+ const shadow = (values.shadow as boolean) ?? true;+ const keywordsLine =+ typeof values.captions !== "string" ||+ values.captions.trim() === CAPTION_FIXTURE_TEXT+ ? ` keywords={[${PREVIEW_KEYWORDS.map((k) => `"${k}"`).join(", ")}]}\n`+ : "";+ const extra = [+ texture ? null : " texture={false}",+ combine !== 1200+ ? ` combineTokensWithinMilliseconds={${combine}}`+ : null,+ holdMs !== 600 ? ` holdMs={${holdMs}}` : null,+ shadow ? null : " shadow={false}",+ ].filter(Boolean);+ return `import { AbsoluteFill } from "remotion";+import { CaptionStamp } from "@/components/remocn/caption-stamp";+import captions from "./captions.json";++export const MyScene = () => (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: 108,+ paddingInline: 192,+ }}+ >+ <CaptionStamp+ captions={captions}+${keywordsLine} fontSize={${fontSize}}+ fontWeight={${fontWeight}}+ color="${color}"+ stampColor="${stampColor}"+${extra.length > 0 ? `${extra.join("\n")}\n` : ""} />+ </AbsoluteFill>+);`;+};diff --git a/components/docs/examples/caption-subtitle-example.tsx b/components/docs/examples/caption-subtitle-example.tsxnew file mode 100644index 00000000..50d1e743--- /dev/null+++ b/components/docs/examples/caption-subtitle-example.tsx@@ -0,0 +1,96 @@+"use client";++import { AbsoluteFill, useVideoConfig } from "remotion";+import { previewCaptions } from "@/components/docs/examples/caption-fixture";+import { CaptionSubtitle } from "@/registry/remocn/caption-subtitle";++interface CaptionSubtitleExampleProps {+ captions?: string;+ fontSize?: number;+ fontWeight?: number;+ color?: string;+ combineTokensWithinMilliseconds?: number;+ holdMs?: number;+ box?: boolean;+ boxColor?: string;+ boxOpacity?: number;+}++export function CaptionSubtitleExampleScene({+ captions,+ fontSize,+ fontWeight,+ color,+ combineTokensWithinMilliseconds,+ holdMs,+ box,+ boxColor,+ boxOpacity,+}: CaptionSubtitleExampleProps) {+ const { width, height } = useVideoConfig();+ return (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: height * 0.1,+ paddingInline: width * 0.2,+ }}+ >+ <CaptionSubtitle+ captions={previewCaptions(captions)}+ fontSize={fontSize}+ fontWeight={fontWeight}+ color={color}+ combineTokensWithinMilliseconds={combineTokensWithinMilliseconds}+ holdMs={holdMs}+ box={box}+ boxColor={boxColor}+ boxOpacity={boxOpacity}+ />+ </AbsoluteFill>+ );+}++export const captionSubtitleExampleCode = (+ values: Record<string, unknown>,+): string => {+ const fontSize = (values.fontSize as number) ?? 44;+ const fontWeight = (values.fontWeight as number) ?? 600;+ const color = (values.color as string) ?? "#ffffff";+ const combine = (values.combineTokensWithinMilliseconds as number) ?? 2500;+ const holdMs = (values.holdMs as number) ?? 600;+ const box = (values.box as boolean) ?? true;+ const boxColor = (values.boxColor as string) ?? "#000000";+ const boxOpacity = (values.boxOpacity as number) ?? 0.72;+ const extra = [+ combine !== 2500+ ? ` combineTokensWithinMilliseconds={${combine}}`+ : null,+ holdMs !== 600 ? ` holdMs={${holdMs}}` : null,+ box ? null : " box={false}",+ box && boxColor !== "#000000" ? ` boxColor="${boxColor}"` : null,+ box && boxOpacity !== 0.72 ? ` boxOpacity={${boxOpacity}}` : null,+ ].filter(Boolean);+ return `import { AbsoluteFill } from "remotion";+import { CaptionSubtitle } from "@/components/remocn/caption-subtitle";+import captions from "./captions.json";++export const MyScene = () => (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: 108,+ paddingInline: 384,+ }}+ >+ <CaptionSubtitle+ captions={captions}+ fontSize={${fontSize}}+ fontWeight={${fontWeight}}+ color="${color}"+${extra.length > 0 ? `${extra.join("\n")}\n` : ""} />+ </AbsoluteFill>+);`;+};diff --git a/components/docs/examples/caption-teleprompter-example.tsx b/components/docs/examples/caption-teleprompter-example.tsxnew file mode 100644index 00000000..0d4bad7d--- /dev/null+++ b/components/docs/examples/caption-teleprompter-example.tsx@@ -0,0 +1,106 @@+"use client";++import { AbsoluteFill, useVideoConfig } from "remotion";+import { previewCaptions } from "@/components/docs/examples/caption-fixture";+import { CaptionTeleprompter } from "@/registry/remocn/caption-teleprompter";++interface CaptionTeleprompterExampleProps {+ captions?: string;+ fontSize?: number;+ fontWeight?: number;+ color?: string;+ visibleLines?: number;+ pastOpacity?: number;+ futureOpacity?: number;+ upcomingOpacity?: number;+ combineTokensWithinMilliseconds?: number;+ holdMs?: number;+ shadow?: boolean;+}++export function CaptionTeleprompterExampleScene({+ captions,+ fontSize,+ fontWeight,+ color,+ visibleLines,+ pastOpacity,+ futureOpacity,+ upcomingOpacity,+ combineTokensWithinMilliseconds,+ holdMs,+ shadow,+}: CaptionTeleprompterExampleProps) {+ const { width } = useVideoConfig();+ return (+ <AbsoluteFill+ style={{+ justifyContent: "center",+ alignItems: "stretch",+ paddingInline: width * 0.1,+ }}+ >+ <CaptionTeleprompter+ captions={previewCaptions(captions)}+ fontSize={fontSize}+ fontWeight={fontWeight}+ color={color}+ visibleLines={visibleLines}+ pastOpacity={pastOpacity}+ futureOpacity={futureOpacity}+ upcomingOpacity={upcomingOpacity}+ combineTokensWithinMilliseconds={combineTokensWithinMilliseconds}+ holdMs={holdMs}+ shadow={shadow}+ />+ </AbsoluteFill>+ );+}++export const captionTeleprompterExampleCode = (+ values: Record<string, unknown>,+): string => {+ const fontSize = (values.fontSize as number) ?? 64;+ const fontWeight = (values.fontWeight as number) ?? 800;+ const color = (values.color as string) ?? "#ffffff";+ const visibleLines = (values.visibleLines as number) ?? 3;+ const pastOpacity = (values.pastOpacity as number) ?? 0.35;+ const futureOpacity = (values.futureOpacity as number) ?? 0.35;+ const upcomingOpacity = (values.upcomingOpacity as number) ?? 0.55;+ const combine = (values.combineTokensWithinMilliseconds as number) ?? 1500;+ const holdMs = (values.holdMs as number) ?? 600;+ const shadow = (values.shadow as boolean) ?? true;+ const extra = [+ visibleLines !== 3 ? ` visibleLines={${visibleLines}}` : null,+ pastOpacity !== 0.35 ? ` pastOpacity={${pastOpacity}}` : null,+ futureOpacity !== 0.35 ? ` futureOpacity={${futureOpacity}}` : null,+ upcomingOpacity !== 0.55+ ? ` upcomingOpacity={${upcomingOpacity}}`+ : null,+ combine !== 1500+ ? ` combineTokensWithinMilliseconds={${combine}}`+ : null,+ holdMs !== 600 ? ` holdMs={${holdMs}}` : null,+ shadow ? null : " shadow={false}",+ ].filter(Boolean);+ return `import { AbsoluteFill } from "remotion";+import { CaptionTeleprompter } from "@/components/remocn/caption-teleprompter";+import captions from "./captions.json";++export const MyScene = () => (+ <AbsoluteFill+ style={{+ justifyContent: "center",+ alignItems: "stretch",+ paddingInline: 192,+ }}+ >+ <CaptionTeleprompter+ captions={captions}+ fontSize={${fontSize}}+ fontWeight={${fontWeight}}+ color="${color}"+${extra.length > 0 ? `${extra.join("\n")}\n` : ""} />+ </AbsoluteFill>+);`;+};diff --git a/components/docs/examples/caption-timeline-example.tsx b/components/docs/examples/caption-timeline-example.tsxnew file mode 100644index 00000000..2719dcd4--- /dev/null+++ b/components/docs/examples/caption-timeline-example.tsx@@ -0,0 +1,101 @@+"use client";++import { AbsoluteFill, useVideoConfig } from "remotion";+import { previewCaptions } from "@/components/docs/examples/caption-fixture";+import { CaptionTimeline } from "@/registry/remocn/caption-timeline";++interface CaptionTimelineExampleProps {+ captions?: string;+ fontSize?: number;+ fontWeight?: number;+ color?: string;+ playheadColor?: string;+ width?: number;+ pxPerSecond?: number;+ playheadPosition?: number;+ upcomingOpacity?: number;+ shadow?: boolean;+}++export function CaptionTimelineExampleScene({+ captions,+ fontSize,+ fontWeight,+ color,+ playheadColor,+ width,+ pxPerSecond,+ playheadPosition,+ upcomingOpacity,+ shadow,+}: CaptionTimelineExampleProps) {+ const { height } = useVideoConfig();+ return (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: height * 0.1,+ }}+ >+ <CaptionTimeline+ captions={previewCaptions(captions)}+ fontSize={fontSize}+ fontWeight={fontWeight}+ color={color}+ playheadColor={playheadColor}+ width={width}+ pxPerSecond={pxPerSecond}+ playheadPosition={playheadPosition}+ upcomingOpacity={upcomingOpacity}+ shadow={shadow}+ />+ </AbsoluteFill>+ );+}++export const captionTimelineExampleCode = (+ values: Record<string, unknown>,+): string => {+ const fontSize = (values.fontSize as number) ?? 64;+ const fontWeight = (values.fontWeight as number) ?? 800;+ const color = (values.color as string) ?? "#ffffff";+ const playheadColor = (values.playheadColor as string) ?? "#facc15";+ const width = (values.width as number) ?? 1100;+ const pxPerSecond = (values.pxPerSecond as number) ?? 260;+ const playheadPosition = (values.playheadPosition as number) ?? 0.35;+ const upcomingOpacity = (values.upcomingOpacity as number) ?? 0.4;+ const shadow = (values.shadow as boolean) ?? true;+ const extra = [+ pxPerSecond !== 260 ? ` pxPerSecond={${pxPerSecond}}` : null,+ playheadPosition !== 0.35+ ? ` playheadPosition={${playheadPosition}}`+ : null,+ upcomingOpacity !== 0.4+ ? ` upcomingOpacity={${upcomingOpacity}}`+ : null,+ shadow ? null : " shadow={false}",+ ].filter(Boolean);+ return `import { AbsoluteFill } from "remotion";+import { CaptionTimeline } from "@/components/remocn/caption-timeline";+import captions from "./captions.json";++export const MyScene = () => (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: 108,+ }}+ >+ <CaptionTimeline+ captions={captions}+ width={${width}}+ fontSize={${fontSize}}+ fontWeight={${fontWeight}}+ color="${color}"+ playheadColor="${playheadColor}"+${extra.length > 0 ? `${extra.join("\n")}\n` : ""} />+ </AbsoluteFill>+);`;+};diff --git a/components/docs/examples/caption-typewriter-example.tsx b/components/docs/examples/caption-typewriter-example.tsxnew file mode 100644index 00000000..2398b378--- /dev/null+++ b/components/docs/examples/caption-typewriter-example.tsx@@ -0,0 +1,91 @@+"use client";++import { AbsoluteFill, useVideoConfig } from "remotion";+import { previewCaptions } from "@/components/docs/examples/caption-fixture";+import { CaptionTypewriter } from "@/registry/remocn/caption-typewriter";++interface CaptionTypewriterExampleProps {+ captions?: string;+ fontSize?: number;+ fontWeight?: number;+ color?: string;+ combineTokensWithinMilliseconds?: number;+ holdMs?: number;+ caret?: boolean;+ shadow?: boolean;+}++export function CaptionTypewriterExampleScene({+ captions,+ fontSize,+ fontWeight,+ color,+ combineTokensWithinMilliseconds,+ holdMs,+ caret,+ shadow,+}: CaptionTypewriterExampleProps) {+ const { width, height } = useVideoConfig();+ return (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: height * 0.1,+ paddingInline: width * 0.1,+ }}+ >+ <CaptionTypewriter+ captions={previewCaptions(captions)}+ fontSize={fontSize}+ fontWeight={fontWeight}+ color={color}+ combineTokensWithinMilliseconds={combineTokensWithinMilliseconds}+ holdMs={holdMs}+ caret={caret}+ shadow={shadow}+ />+ </AbsoluteFill>+ );+}++export const captionTypewriterExampleCode = (+ values: Record<string, unknown>,+): string => {+ const fontSize = (values.fontSize as number) ?? 64;+ const fontWeight = (values.fontWeight as number) ?? 800;+ const color = (values.color as string) ?? "#ffffff";+ const combine = (values.combineTokensWithinMilliseconds as number) ?? 1200;+ const holdMs = (values.holdMs as number) ?? 600;+ const caret = (values.caret as boolean) ?? true;+ const shadow = (values.shadow as boolean) ?? true;+ const extra = [+ combine !== 1200+ ? ` combineTokensWithinMilliseconds={${combine}}`+ : null,+ holdMs !== 600 ? ` holdMs={${holdMs}}` : null,+ caret ? null : " caret={false}",+ shadow ? null : " shadow={false}",+ ].filter(Boolean);+ return `import { AbsoluteFill } from "remotion";+import { CaptionTypewriter } from "@/components/remocn/caption-typewriter";+import captions from "./captions.json";++export const MyScene = () => (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: 108,+ paddingInline: 192,+ }}+ >+ <CaptionTypewriter+ captions={captions}+ fontSize={${fontSize}}+ fontWeight={${fontWeight}}+ color="${color}"+${extra.length > 0 ? `${extra.join("\n")}\n` : ""} />+ </AbsoluteFill>+);`;+};diff --git a/components/docs/examples/caption-underline-example.tsx b/components/docs/examples/caption-underline-example.tsxnew file mode 100644index 00000000..f6988962--- /dev/null+++ b/components/docs/examples/caption-underline-example.tsx@@ -0,0 +1,103 @@+"use client";++import { AbsoluteFill, useVideoConfig } from "remotion";+import { previewCaptions } from "@/components/docs/examples/caption-fixture";+import { CaptionUnderline } from "@/registry/remocn/caption-underline";++interface CaptionUnderlineExampleProps {+ captions?: string;+ fontSize?: number;+ fontWeight?: number;+ color?: string;+ underlineColor?: string;+ thickness?: number;+ underlineOffset?: number;+ combineTokensWithinMilliseconds?: number;+ holdMs?: number;+ shadow?: boolean;+}++export function CaptionUnderlineExampleScene({+ captions,+ fontSize,+ fontWeight,+ color,+ underlineColor,+ thickness,+ underlineOffset,+ combineTokensWithinMilliseconds,+ holdMs,+ shadow,+}: CaptionUnderlineExampleProps) {+ const { width, height } = useVideoConfig();+ return (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: height * 0.1,+ paddingInline: width * 0.1,+ }}+ >+ <CaptionUnderline+ captions={previewCaptions(captions)}+ fontSize={fontSize}+ fontWeight={fontWeight}+ color={color}+ underlineColor={underlineColor}+ thickness={thickness}+ underlineOffset={underlineOffset}+ combineTokensWithinMilliseconds={combineTokensWithinMilliseconds}+ holdMs={holdMs}+ shadow={shadow}+ />+ </AbsoluteFill>+ );+}++export const captionUnderlineExampleCode = (+ values: Record<string, unknown>,+): string => {+ const fontSize = (values.fontSize as number) ?? 64;+ const fontWeight = (values.fontWeight as number) ?? 800;+ const color = (values.color as string) ?? "#ffffff";+ const underlineColor = (values.underlineColor as string) ?? "#facc15";+ const thickness = (values.thickness as number) ?? 0.08;+ const underlineOffset = (values.underlineOffset as number) ?? 0.02;+ const combine = (values.combineTokensWithinMilliseconds as number) ?? 1200;+ const holdMs = (values.holdMs as number) ?? 600;+ const shadow = (values.shadow as boolean) ?? true;+ const extra = [+ thickness !== 0.08 ? ` thickness={${thickness}}` : null,+ underlineOffset !== 0.02+ ? ` underlineOffset={${underlineOffset}}`+ : null,+ combine !== 1200+ ? ` combineTokensWithinMilliseconds={${combine}}`+ : null,+ holdMs !== 600 ? ` holdMs={${holdMs}}` : null,+ shadow ? null : " shadow={false}",+ ].filter(Boolean);+ return `import { AbsoluteFill } from "remotion";+import { CaptionUnderline } from "@/components/remocn/caption-underline";+import captions from "./captions.json";++export const MyScene = () => (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: 108,+ paddingInline: 192,+ }}+ >+ <CaptionUnderline+ captions={captions}+ fontSize={${fontSize}}+ fontWeight={${fontWeight}}+ color="${color}"+ underlineColor="${underlineColor}"+${extra.length > 0 ? `${extra.join("\n")}\n` : ""} />+ </AbsoluteFill>+);`;+};diff --git a/components/docs/examples/caption-weight-example.tsx b/components/docs/examples/caption-weight-example.tsxnew file mode 100644index 00000000..380b0bcb--- /dev/null+++ b/components/docs/examples/caption-weight-example.tsx@@ -0,0 +1,96 @@+"use client";++import { AbsoluteFill, useVideoConfig } from "remotion";+import { previewCaptions } from "@/components/docs/examples/caption-fixture";+import { CaptionWeight } from "@/registry/remocn/caption-weight";++interface CaptionWeightExampleProps {+ captions?: string;+ fontSize?: number;+ fontWeight?: number;+ activeWeight?: number;+ color?: string;+ combineTokensWithinMilliseconds?: number;+ holdMs?: number;+ shadow?: boolean;+}++export function CaptionWeightExampleScene({+ captions,+ fontSize,+ fontWeight,+ activeWeight,+ color,+ combineTokensWithinMilliseconds,+ holdMs,+ shadow,+}: CaptionWeightExampleProps) {+ const { width, height } = useVideoConfig();+ return (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: height * 0.1,+ paddingInline: width * 0.1,+ }}+ >+ <CaptionWeight+ captions={previewCaptions(captions)}+ fontSize={fontSize}+ fontWeight={fontWeight}+ activeWeight={activeWeight}+ color={color}+ combineTokensWithinMilliseconds={combineTokensWithinMilliseconds}+ holdMs={holdMs}+ shadow={shadow}+ />+ </AbsoluteFill>+ );+}++export const captionWeightExampleCode = (+ values: Record<string, unknown>,+): string => {+ const fontSize = (values.fontSize as number) ?? 64;+ const fontWeight = (values.fontWeight as number) ?? 400;+ const activeWeight = (values.activeWeight as number) ?? 900;+ const color = (values.color as string) ?? "#ffffff";+ const combine = (values.combineTokensWithinMilliseconds as number) ?? 1200;+ const holdMs = (values.holdMs as number) ?? 600;+ const shadow = (values.shadow as boolean) ?? true;+ const extra = [+ combine !== 1200+ ? ` combineTokensWithinMilliseconds={${combine}}`+ : null,+ holdMs !== 600 ? ` holdMs={${holdMs}}` : null,+ shadow ? null : " shadow={false}",+ ].filter(Boolean);+ return `import { loadVariableFont } from "@remotion/google-fonts/Inter";+import { AbsoluteFill } from "remotion";+import { CaptionWeight } from "@/components/remocn/caption-weight";+import captions from "./captions.json";++const { fontFamily } = loadVariableFont("normal", { subsets: ["latin"] });++export const MyScene = () => (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: 108,+ paddingInline: 192,+ }}+ >+ <div style={{ fontFamily }}>+ <CaptionWeight+ captions={captions}+ fontSize={${fontSize}}+ fontWeight={${fontWeight}}+ activeWeight={${activeWeight}}+ color="${color}"+${extra.length > 0 ? `${extra.join("\n")}\n` : ""} />+ </div>+ </AbsoluteFill>+);`;+};diff --git a/components/docs/examples/caption-word-pop-example.tsx b/components/docs/examples/caption-word-pop-example.tsxnew file mode 100644index 00000000..894f1409--- /dev/null+++ b/components/docs/examples/caption-word-pop-example.tsx@@ -0,0 +1,74 @@+"use client";++import { AbsoluteFill } from "remotion";+import { previewCaptions } from "@/components/docs/examples/caption-fixture";+import { CaptionWordPop } from "@/registry/remocn/caption-word-pop";++interface CaptionWordPopExampleProps {+ captions?: string;+ fontSize?: number;+ fontWeight?: number;+ color?: string;+ popScale?: number;+ combineTokensWithinMilliseconds?: number;+ holdMs?: number;+ shadow?: boolean;+}++export function CaptionWordPopExampleScene({+ captions,+ fontSize,+ fontWeight,+ color,+ popScale,+ combineTokensWithinMilliseconds,+ holdMs,+ shadow,+}: CaptionWordPopExampleProps) {+ return (+ <AbsoluteFill style={{ justifyContent: "center", alignItems: "center" }}>+ <CaptionWordPop+ captions={previewCaptions(captions)}+ fontSize={fontSize}+ fontWeight={fontWeight}+ color={color}+ popScale={popScale}+ combineTokensWithinMilliseconds={combineTokensWithinMilliseconds}+ holdMs={holdMs}+ shadow={shadow}+ />+ </AbsoluteFill>+ );+}++export const captionWordPopExampleCode = (+ values: Record<string, unknown>,+): string => {+ const fontSize = (values.fontSize as number) ?? 96;+ const fontWeight = (values.fontWeight as number) ?? 800;+ const color = (values.color as string) ?? "#ffffff";+ const popScale = (values.popScale as number) ?? 0.6;+ const combine = (values.combineTokensWithinMilliseconds as number) ?? 0;+ const holdMs = (values.holdMs as number) ?? 600;+ const shadow = (values.shadow as boolean) ?? true;+ const extra = [+ popScale !== 0.6 ? ` popScale={${popScale}}` : null,+ combine !== 0 ? ` combineTokensWithinMilliseconds={${combine}}` : null,+ holdMs !== 600 ? ` holdMs={${holdMs}}` : null,+ shadow ? null : " shadow={false}",+ ].filter(Boolean);+ return `import { AbsoluteFill } from "remotion";+import { CaptionWordPop } from "@/components/remocn/caption-word-pop";+import captions from "./captions.json";++export const MyScene = () => (+ <AbsoluteFill style={{ justifyContent: "center", alignItems: "center" }}>+ <CaptionWordPop+ captions={captions}+ fontSize={${fontSize}}+ fontWeight={${fontWeight}}+ color="${color}"+${extra.length > 0 ? `${extra.join("\n")}\n` : ""} />+ </AbsoluteFill>+);`;+};diff --git a/content/changelog/2026-10-08-captions.mdx b/content/changelog/2026-10-08-captions.mdxnew file mode 100644index 00000000..257631b7--- /dev/null+++ b/content/changelog/2026-10-08-captions.mdx@@ -0,0 +1,44 @@+---+title: Captions+date: 2026-10-08+---++A new Captions tab with thirty-one subtitle styles that follow a real voiceover. Each one reads a timed transcript in the `Caption` shape from `@remotion/captions`, splits it into short pages, and animates every word the moment it is spoken. Whisper, the OpenAI API, ElevenLabs or an existing `.srt` file all produce that transcript, and [Get a transcript](/docs/captions/getting-started/get-a-transcript) has a recipe for each. Every style renders only its text block, so you place it yourself, and [Positioning](/docs/captions/getting-started/positioning) has the safe zones for landscape and vertical video.++<ChangelogPreview name="caption-karaoke" />++### New components++- [Karaoke](/docs/captions/components/caption-karaoke) — each word fills with colour left to right exactly as it is spoken, with the whole phrase readable before the voice reaches it.+- [Highlight Box](/docs/captions/components/caption-highlight-box) — a solid box travels behind the word being spoken, sliding from word to word as the voice moves on.+- [Active Pop](/docs/captions/components/caption-active-pop) — the spoken word turns to the accent colour and springs up in scale, then settles back.+- [Underline](/docs/captions/components/caption-underline) — a bar slides under the word being spoken while the text itself stays untouched.+- [Dim Progress](/docs/captions/components/caption-dim-progress) — the whole phrase sits dimmed and each word brightens as it is spoken, with no motion at all.+- [Weight](/docs/captions/components/caption-weight) — the spoken word swells from a light weight to a heavy one without shifting the line.+- [Outline](/docs/captions/components/caption-outline) — heavy-stroked captions that stay readable over any footage, with the spoken word switching to a contrast colour.+- [Word Pop](/docs/captions/components/caption-word-pop) — one large word at a time, each popping in on a spring.+- [Bounce In](/docs/captions/components/caption-bounce-in) — each word springs into place with a little overshoot and the phrase builds word by word.+- [Blur In](/docs/captions/components/caption-blur-in) — each word resolves out of a soft blur, for captions that arrive quietly.+- [Rise](/docs/captions/components/caption-rise) — each word slides up out of a mask at its baseline, with no bounce and no scale.+- [Typewriter](/docs/captions/components/caption-typewriter) — each word types out at the pace it is spoken, with a caret that blinks through pauses.+- [Scramble](/docs/captions/components/caption-scramble) — each word arrives as random glyphs and decodes left to right into the real letters.+- [Slot](/docs/captions/components/caption-slot) — one short line at a time, each new phrase rolling up as the previous one rolls out.+- [Stack](/docs/captions/components/caption-stack) — kinetic captions stacked a couple of words per line, with each page's keyword set large on its own line.+- [Subtitle](/docs/captions/components/caption-subtitle) — classic broadcast subtitles on a translucent plate, with no word-level animation.+- [Marker](/docs/captions/components/caption-marker) — the words that matter get a highlighter swipe the moment they are spoken.+- [Emoji](/docs/captions/components/caption-emoji) — an emoji pops up above a chosen word when it is spoken and stays until the phrase leaves.+- [Speaker](/docs/captions/components/caption-speaker) — dialogue captions where every phrase takes its speaker's colour.+- [Prosody](/docs/captions/components/caption-prosody) — word size follows the delivery, so drawn-out words land large and rushed words stay small.+- [Timeline](/docs/captions/components/caption-timeline) — the whole transcript slides under a fixed playhead on a time strip, so every pause shows up as space.+- [Teleprompter](/docs/captions/components/caption-teleprompter) — the transcript scrolls through a short window with the current line centred.+- [Split Flap](/docs/captions/components/caption-split-flap) — every letter clatters through a few characters on its own flap tile before landing, like a departure board.+- [Label Maker](/docs/captions/components/caption-label-maker) — each phrase is punched letter by letter into a strip of embossing tape.+- [Drop](/docs/captions/components/caption-drop) — each word falls into place and bounces, and the phrase drops out of frame when the speaker pauses.+- [Stamp](/docs/captions/components/caption-stamp) — the words that matter slam down as a rubber stamp.+- [Handwrite](/docs/captions/components/caption-handwrite) — each word is inked in by hand at the pace it is spoken.+- [Redact](/docs/captions/components/caption-redact) — the phrase starts blacked out and each bar pulls away as its word is spoken.+- [Knockout](/docs/captions/components/caption-knockout) — a solid plate with the words cut clean through it, so the footage shows through the letters.+- [Slice](/docs/captions/components/caption-slice) — each word arrives cut in two, the halves sliding in from opposite sides and locking together.+- [Cube](/docs/captions/components/caption-cube) — each new phrase turns into view as the next face of a 3D cube.++<ChangelogPreview name="caption-highlight-box" />diff --git a/content/docs/captions/components/caption-active-pop.mdx b/content/docs/captions/components/caption-active-pop.mdxnew file mode 100644index 00000000..f0198cd0--- /dev/null+++ b/content/docs/captions/components/caption-active-pop.mdx@@ -0,0 +1,120 @@+---+title: Active Pop+description: The word being spoken turns to the accent colour and springs up in scale, then settles back as the voice moves on+component: caption-active-pop+vibe: social+length: transcript-driven+useWhen:+ - "A talking head or voiceover needs the everyday short-form caption look — the full phrase on screen with the spoken word lifting out of it."+ - "You want the active word marked without covering the footage behind it with a solid shape."+avoidWhen:+ - "One word should own the whole frame at a time — use `caption-word-pop`."+ - "The highlight has to read over busy footage from across the room — use `caption-highlight-box`."+ - "There is no voiceover and the text is scripted — use `word-stream`."+---++<ComponentPreview name="caption-active-pop" />++<InstallBlock name="caption-active-pop" />++## Usage++`CaptionActivePop` shows the whole page in the base colour. The word being+spoken switches to `activeColor` and springs up to `popScale`, then eases back+down and returns to the base colour once the next word takes over. The scale is+a transform, so the neighbouring words never shift.++It renders only the text block, so place it inside your own `AbsoluteFill`. See+[Positioning](/docs/captions/getting-started/positioning) for safe placements+and [Get a transcript](/docs/captions/getting-started/get-a-transcript) for+producing `captions.json`.++```tsx+import { AbsoluteFill } from "remotion";+import { CaptionActivePop } from "@/components/remocn/caption-active-pop";+import captions from "./captions.json";++export const MyScene = () => (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: 108,+ paddingInline: 192,+ }}+ >+ <CaptionActivePop captions={captions} />+ </AbsoluteFill>+);+```++<PropsTable title="Props"+ rows={[+ {+ name: "captions",+ type: "Caption[]",+ default: "—",+ description:+ "The timed transcript, in the `Caption` shape from `@remotion/captions`. Times are relative to the start of the surrounding `Sequence`.",+ },+ {+ name: "combineTokensWithinMilliseconds",+ type: "number",+ default: "1200",+ description:+ "How much speech one page may span before the next word starts a new page. Pages also break at the end of a sentence and on any pause of at least `holdMs` (300 ms minimum).",+ },+ {+ name: "holdMs",+ type: "number",+ default: "600",+ description:+ "How long a page stays after its last word when the next page is not already due. It fades out at the end of the hold instead of hanging through the pause.",+ },+ {+ name: "fontSize",+ type: "number",+ default: "64",+ description: "Font size in pixels.",+ },+ {+ name: "fontWeight",+ type: "number",+ default: "800",+ description: "Font weight. The font itself is inherited.",+ },+ {+ name: "color",+ type: "string",+ default: "\"#ffffff\"",+ description: "Colour of every word that is not being spoken.",+ },+ {+ name: "activeColor",+ type: "string",+ default: "\"#facc15\"",+ description: "Colour of the word being spoken.",+ },+ {+ name: "popScale",+ type: "number",+ default: "1.12",+ description:+ "How large the spoken word grows. Keep it modest — past about 1.25 the word starts to crowd its neighbours.",+ },+ {+ name: "shadow",+ type: "boolean",+ default: "true",+ description:+ "A tight text shadow that keeps the caption legible over bright footage.",+ },+ {+ name: "className",+ type: "string",+ default: "—",+ description:+ "Classes for the text block — width, font family, `uppercase`.",+ },+ ]}+/>diff --git a/content/docs/captions/components/caption-blur-in.mdx b/content/docs/captions/components/caption-blur-in.mdxnew file mode 100644index 00000000..15d9ad9f--- /dev/null+++ b/content/docs/captions/components/caption-blur-in.mdx@@ -0,0 +1,112 @@+---+title: Blur In+description: Each word resolves out of a soft blur the moment it is spoken, for captions that arrive quietly+component: caption-blur-in+vibe: premium+length: transcript-driven+useWhen:+ - "Calm narration, a product film or a launch video where the captions should feel considered rather than loud — words come into focus instead of jumping in."+ - "The voice and the text should arrive together without drawing the eye away from the footage — the motion is all softness, no travel."+avoidWhen:+ - "The video is short-form and high-energy — use `caption-bounce-in`, which gives each word a springy hop."+ - "You want crisp, editorial motion with a hard edge — use `caption-rise`, which slides words up from a baseline mask."+ - "The viewer should be able to read the whole phrase ahead of the voice — use `caption-karaoke`, which shows the full page and fills it as it is spoken."+---++<ComponentPreview name="caption-blur-in" />++<InstallBlock name="caption-blur-in" />++## Usage++`CaptionBlurIn` takes a timed transcript and renders only the text block, so+place it inside your own `AbsoluteFill`. Every word stays hidden until its own+start time, then resolves from a blur into sharp focus while it fades up. The+space for the whole phrase is reserved from the first word, so the line never+reflows as it builds. See [Positioning](/docs/captions/getting-started/positioning)+for safe placements and [Get a transcript](/docs/captions/getting-started/get-a-transcript)+for producing `captions.json`.++```tsx+import { AbsoluteFill } from "remotion";+import { CaptionBlurIn } from "@/components/remocn/caption-blur-in";+import captions from "./captions.json";++export const MyScene = () => (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: 108,+ paddingInline: 192,+ }}+ >+ <CaptionBlurIn captions={captions} />+ </AbsoluteFill>+);+```++<PropsTable title="Props"+ rows={[+ {+ name: "captions",+ type: "Caption[]",+ default: "—",+ description:+ "The timed transcript, in the `Caption` shape from `@remotion/captions`. Times are relative to the start of the surrounding `Sequence`.",+ },+ {+ name: "blur",+ type: "number",+ default: "12",+ description:+ "Blur radius in pixels each word starts from before it comes into focus.",+ },+ {+ name: "combineTokensWithinMilliseconds",+ type: "number",+ default: "1200",+ description:+ "How much speech one page may span before the next word starts a new page. Pages also break at the end of a sentence and on any pause of at least `holdMs` (300 ms minimum).",+ },+ {+ name: "holdMs",+ type: "number",+ default: "600",+ description:+ "How long a page stays after its last word when the next page is not already due. It fades out at the end of the hold instead of hanging through the pause.",+ },+ {+ name: "fontSize",+ type: "number",+ default: "64",+ description: "Font size in pixels.",+ },+ {+ name: "fontWeight",+ type: "number",+ default: "800",+ description: "Font weight. The font itself is inherited.",+ },+ {+ name: "color",+ type: "string",+ default: "\"#ffffff\"",+ description: "Text colour.",+ },+ {+ name: "shadow",+ type: "boolean",+ default: "true",+ description:+ "A tight text shadow that keeps the caption legible over bright footage.",+ },+ {+ name: "className",+ type: "string",+ default: "—",+ description:+ "Classes for the text block — width, font family, `uppercase`.",+ },+ ]}+/>diff --git a/content/docs/captions/components/caption-bounce-in.mdx b/content/docs/captions/components/caption-bounce-in.mdxnew file mode 100644index 00000000..8696966b--- /dev/null+++ b/content/docs/captions/components/caption-bounce-in.mdx@@ -0,0 +1,112 @@+---+title: Bounce In+description: Each word springs up into place with a little overshoot the moment it is spoken, and the phrase builds word by word+component: caption-bounce-in+vibe: playful+length: transcript-driven+useWhen:+ - "Short-form video with an energetic voice — each word lands with a small hop, so the captions feel as lively as the delivery."+ - "The viewer should hear and see each word arrive together — nothing is on screen before it is said, and the line builds in place without shifting."+avoidWhen:+ - "The tone is calm or premium and a bounce would feel cheap — use `caption-blur-in`, which resolves each word out of focus instead."+ - "The video is editorial or brand-led and wants clean, confident motion — use `caption-rise`, which slides words up from a baseline mask with no overshoot."+ - "There is no voiceover and the words are scripted on-screen copy — use `word-stream`."+---++<ComponentPreview name="caption-bounce-in" />++<InstallBlock name="caption-bounce-in" />++## Usage++`CaptionBounceIn` takes a timed transcript and renders only the text block, so+place it inside your own `AbsoluteFill`. Every word stays hidden until its own+start time, then springs up from just below its slot. The space for the whole+phrase is reserved from the first word, so the line never reflows as it builds.+See [Positioning](/docs/captions/getting-started/positioning) for safe placements+and [Get a transcript](/docs/captions/getting-started/get-a-transcript) for+producing `captions.json`.++```tsx+import { AbsoluteFill } from "remotion";+import { CaptionBounceIn } from "@/components/remocn/caption-bounce-in";+import captions from "./captions.json";++export const MyScene = () => (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: 108,+ paddingInline: 192,+ }}+ >+ <CaptionBounceIn captions={captions} />+ </AbsoluteFill>+);+```++<PropsTable title="Props"+ rows={[+ {+ name: "captions",+ type: "Caption[]",+ default: "—",+ description:+ "The timed transcript, in the `Caption` shape from `@remotion/captions`. Times are relative to the start of the surrounding `Sequence`.",+ },+ {+ name: "bounce",+ type: "number",+ default: "0.6",+ description:+ "How much each word overshoots before it settles, from 0 (lands without overshoot) to 1 (a pronounced hop).",+ },+ {+ name: "combineTokensWithinMilliseconds",+ type: "number",+ default: "1200",+ description:+ "How much speech one page may span before the next word starts a new page. Pages also break at the end of a sentence and on any pause of at least `holdMs` (300 ms minimum).",+ },+ {+ name: "holdMs",+ type: "number",+ default: "600",+ description:+ "How long a page stays after its last word when the next page is not already due. It fades out at the end of the hold instead of hanging through the pause.",+ },+ {+ name: "fontSize",+ type: "number",+ default: "64",+ description: "Font size in pixels.",+ },+ {+ name: "fontWeight",+ type: "number",+ default: "800",+ description: "Font weight. The font itself is inherited.",+ },+ {+ name: "color",+ type: "string",+ default: "\"#ffffff\"",+ description: "Text colour.",+ },+ {+ name: "shadow",+ type: "boolean",+ default: "true",+ description:+ "A tight text shadow that keeps the caption legible over bright footage.",+ },+ {+ name: "className",+ type: "string",+ default: "—",+ description:+ "Classes for the text block — width, font family, `uppercase`.",+ },+ ]}+/>diff --git a/content/docs/captions/components/caption-cube.mdx b/content/docs/captions/components/caption-cube.mdxnew file mode 100644index 00000000..06d85fcc--- /dev/null+++ b/content/docs/captions/components/caption-cube.mdx@@ -0,0 +1,122 @@+---+title: Cube+description: Each new phrase turns into view as the next face of a 3D cube, the previous phrase rotating up and away on a horizontal hinge+component: caption-cube+vibe: playful+length: transcript-driven+useWhen:+ - "Punchy social or explainer video where each phrase change should feel like a physical beat — the caption turns over with the speaker instead of swapping."+ - "Space is tight and the caption must stay one line tall, with all the motion happening at the phrase boundary rather than word by word."+avoidWhen:+ - "The phrase change should be a flat roll with no depth — use `caption-slot`."+ - "Pages are long or need two lines — the cube turns a single line; use `caption-subtitle`."+ - "The viewer should see which word is being spoken — use `caption-karaoke` or `caption-active-pop`."+---++<ComponentPreview name="caption-cube" />++<InstallBlock name="caption-cube" />++## Usage++`CaptionCube` moves at the page level. Every page is a face of a cube hinged+along the line: when the next phrase starts, the cube turns, the old phrase+rotating up and away while the new one comes round from below. After a silence+the line turns away on its own and the next phrase turns in fresh. Words inside+a page stay still; switch on `tintActive` to colour the word being spoken.++The cube turns one line, so the text never wraps. The default+`combineTokensWithinMilliseconds` of 800 keeps pages to three or four words;+raise it only if the longest phrase still fits your frame on one line.++The component renders only the text block. See [Positioning](/docs/captions/getting-started/positioning)+for safe placements and [Get a transcript](/docs/captions/getting-started/get-a-transcript)+for producing `captions.json`.++```tsx+import { AbsoluteFill } from "remotion";+import { CaptionCube } from "@/components/remocn/caption-cube";+import captions from "./captions.json";++export const MyScene = () => (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: 108,+ paddingInline: 192,+ }}+ >+ <CaptionCube captions={captions} />+ </AbsoluteFill>+);+```++<PropsTable title="Props"+ rows={[+ {+ name: "captions",+ type: "Caption[]",+ default: "—",+ description:+ "The timed transcript, in the `Caption` shape from `@remotion/captions`. Times are relative to the start of the surrounding `Sequence`.",+ },+ {+ name: "combineTokensWithinMilliseconds",+ type: "number",+ default: "800",+ description:+ "How much speech one page may span before the next word starts a new page. Pages also break at the end of a sentence and on any pause of at least `holdMs` (300 ms minimum).",+ },+ {+ name: "holdMs",+ type: "number",+ default: "600",+ description:+ "How long a page stays after its last word when the next page is not already due. It turns away at the end of the hold instead of hanging through the pause.",+ },+ {+ name: "fontSize",+ type: "number",+ default: "64",+ description: "Font size in pixels.",+ },+ {+ name: "fontWeight",+ type: "number",+ default: "800",+ description: "Font weight. The font itself is inherited.",+ },+ {+ name: "color",+ type: "string",+ default: "\"#ffffff\"",+ description: "Text colour.",+ },+ {+ name: "tintActive",+ type: "boolean",+ default: "false",+ description: "Colour the word being spoken with `activeColor`.",+ },+ {+ name: "activeColor",+ type: "string",+ default: "\"#facc15\"",+ description: "Colour of the spoken word when `tintActive` is on.",+ },+ {+ name: "shadow",+ type: "boolean",+ default: "true",+ description:+ "A tight text shadow that keeps the caption legible over bright footage.",+ },+ {+ name: "className",+ type: "string",+ default: "—",+ description: "Classes for the text block — font family, `uppercase`.",+ },+ ]}+/>diff --git a/content/docs/captions/components/caption-dim-progress.mdx b/content/docs/captions/components/caption-dim-progress.mdxnew file mode 100644index 00000000..325360fa--- /dev/null+++ b/content/docs/captions/components/caption-dim-progress.mdx@@ -0,0 +1,111 @@+---+title: Dim Progress+description: The whole phrase sits on screen dimmed and each word brightens the moment it is spoken, with no motion at all+component: caption-dim-progress+vibe: clean+length: transcript-driven+useWhen:+ - "Captions have to be read rather than watched — tutorials, explainers, accessibility-first edits where nothing should move."+ - "You want the viewer to read ahead while still seeing exactly where the voice is, without a colour or an animation competing with the footage."+avoidWhen:+ - "You want the position of the voice to feel physical, filling through each word at speaking pace — use `caption-karaoke`."+ - "You want a coloured marker that travels from word to word — use `caption-underline` or `caption-highlight-box`."+ - "The phrase should stay completely static, with no per-word change at all — use `caption-subtitle`."+---++<ComponentPreview name="caption-dim-progress" />++<InstallBlock name="caption-dim-progress" />++## Usage++`CaptionDimProgress` shows the whole page at once with every upcoming word+dimmed. As the voice reaches a word it brightens to full strength and stays+there, so the bright part of the line is always what has been said. Nothing+moves and nothing changes colour, which keeps the captions calm over busy+footage. The component renders only the text block, so place it inside your own+`AbsoluteFill` — see [Positioning](/docs/captions/getting-started/positioning).++```tsx+import { AbsoluteFill } from "remotion";+import { CaptionDimProgress } from "@/components/remocn/caption-dim-progress";+import captions from "./captions.json";++export const MyScene = () => (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: 108,+ paddingInline: 192,+ }}+ >+ <CaptionDimProgress captions={captions} dimOpacity={0.35} />+ </AbsoluteFill>+);+```++<PropsTable title="Props"+ rows={[+ {+ name: "captions",+ type: "Caption[]",+ default: "—",+ description:+ "The timed transcript, in the `Caption` shape from `@remotion/captions`. Times are relative to the start of the surrounding `Sequence`.",+ },+ {+ name: "combineTokensWithinMilliseconds",+ type: "number",+ default: "1200",+ description:+ "How much speech one page may span before the next word starts a new page. Pages also break at the end of a sentence and on any pause of at least `holdMs` (300 ms minimum).",+ },+ {+ name: "holdMs",+ type: "number",+ default: "600",+ description:+ "How long a page stays after its last word when the next page is not already due. It fades out at the end of the hold.",+ },+ {+ name: "dimOpacity",+ type: "number",+ default: "0.35",+ description:+ "Opacity of words the voice has not reached yet. Each word brightens to full over about 90ms as it is spoken.",+ },+ {+ name: "fontSize",+ type: "number",+ default: "64",+ description: "Font size in pixels.",+ },+ {+ name: "fontWeight",+ type: "number",+ default: "800",+ description: "Font weight. The font itself is inherited.",+ },+ {+ name: "color",+ type: "string",+ default: "\"#ffffff\"",+ description: "Text colour, the same for spoken and upcoming words.",+ },+ {+ name: "shadow",+ type: "boolean",+ default: "true",+ description:+ "A tight text shadow that keeps the caption legible over bright footage.",+ },+ {+ name: "className",+ type: "string",+ default: "—",+ description:+ "Classes for the text block — width, font family, `uppercase`.",+ },+ ]}+/>diff --git a/content/docs/captions/components/caption-drop.mdx b/content/docs/captions/components/caption-drop.mdxnew file mode 100644index 00000000..5a1cf3ef--- /dev/null+++ b/content/docs/captions/components/caption-drop.mdx@@ -0,0 +1,117 @@+---+title: Drop+description: Each word falls into place from above and bounces as it lands the moment it is spoken, and the whole phrase drops out of frame when the speaker pauses+component: caption-drop+vibe: playful+length: transcript-driven+useWhen:+ - "Short-form or playful video where the captions should have weight — words land with a bounce and a slight tilt that settles, like they were dropped onto the line."+ - "Pauses should be felt — instead of fading, the phrase falls out of frame word by word when the speaker stops."+avoidWhen:+ - "You want words to pop up from below with a small hop rather than fall from above — use `caption-bounce-in`."+ - "The tone is calm, premium or editorial — use `caption-blur-in` or `caption-rise`."+ - "There is no voiceover and the words are scripted on-screen copy — use `word-stream`."+---++<ComponentPreview name="caption-drop" />++<InstallBlock name="caption-drop" />++## Usage++`CaptionDrop` takes a timed transcript and renders only the text block, so place+it inside your own `AbsoluteFill`. Every word stays hidden until its own start+time, then falls from above with a little random tilt and bounces as it lands.+The space for the whole phrase is reserved from the first word, so the line+never reflows. When the speaker pauses long enough for the page to leave, the+words fall out downward one after another instead of fading. See+[Positioning](/docs/captions/getting-started/positioning) for safe placements+and [Get a transcript](/docs/captions/getting-started/get-a-transcript) for+producing `captions.json`.++```tsx+import { AbsoluteFill } from "remotion";+import { CaptionDrop } from "@/components/remocn/caption-drop";+import captions from "./captions.json";++export const MyScene = () => (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: 108,+ paddingInline: 192,+ }}+ >+ <CaptionDrop captions={captions} />+ </AbsoluteFill>+);+```++Words fall from about one and a half lines above their slot, so leave that much+room above the block if something sits directly over it.++<PropsTable title="Props"+ rows={[+ {+ name: "captions",+ type: "Caption[]",+ default: "—",+ description:+ "The timed transcript, in the `Caption` shape from `@remotion/captions`. Times are relative to the start of the surrounding `Sequence`.",+ },+ {+ name: "bounce",+ type: "number",+ default: "0.6",+ description:+ "How much each word bounces on landing, from 0 (settles without bouncing) to 1 (a lively rebound).",+ },+ {+ name: "combineTokensWithinMilliseconds",+ type: "number",+ default: "1200",+ description:+ "How much speech one page may span before the next word starts a new page. Pages also break at the end of a sentence and on any pause of at least `holdMs` (300 ms minimum).",+ },+ {+ name: "holdMs",+ type: "number",+ default: "600",+ description:+ "How long a page stays after its last word when the next page is not already due. At the end of the hold the words fall out of frame.",+ },+ {+ name: "fontSize",+ type: "number",+ default: "64",+ description: "Font size in pixels.",+ },+ {+ name: "fontWeight",+ type: "number",+ default: "800",+ description: "Font weight. The font itself is inherited.",+ },+ {+ name: "color",+ type: "string",+ default: "\"#ffffff\"",+ description: "Text colour.",+ },+ {+ name: "shadow",+ type: "boolean",+ default: "true",+ description:+ "A tight text shadow that keeps the caption legible over bright footage.",+ },+ {+ name: "className",+ type: "string",+ default: "—",+ description:+ "Classes for the text block — width, font family, `uppercase`.",+ },+ ]}+/>diff --git a/content/docs/captions/components/caption-emoji.mdx b/content/docs/captions/components/caption-emoji.mdxnew file mode 100644index 00000000..4bb299cd--- /dev/null+++ b/content/docs/captions/components/caption-emoji.mdx@@ -0,0 +1,129 @@+---+title: Emoji+description: An emoji pops up above a chosen word the moment it is spoken and stays until the phrase leaves+component: caption-emoji+vibe: playful+length: transcript-driven+useWhen:+ - "Short-form social video where a few words deserve a visual punchline — an emoji lands on the beat the word is said."+ - "You want playful emphasis that adds to the text instead of restyling it, so the caption stays readable."+avoidWhen:+ - "The video is a calm explainer or a product walkthrough — use `caption-subtitle`, which keeps attention on the words."+ - "You want the spoken word itself to stand out rather than an add-on above it — use `caption-active-pop`."+ - "You want the key words marked inside the line rather than decorated — use `caption-marker`."+---++<ComponentPreview name="caption-emoji" />++<InstallBlock name="caption-emoji" />++## Usage++`CaptionEmoji` takes a timed transcript and a map from words to emoji, and+renders only the text block, so place it inside your own `AbsoluteFill`. See+[Positioning](/docs/captions/getting-started/positioning) for safe placements and+[Get a transcript](/docs/captions/getting-started/get-a-transcript) for producing+`captions.json`.++Keys in `emoji` match whole spoken words, ignoring case and punctuation, so+`sound` also fires on "Sound." in the transcript. The emoji sits above its word+without moving the line, so keep pages to a single line — the default page+window does — or an emoji on the second line will overlap the first.++```tsx+import { AbsoluteFill } from "remotion";+import { CaptionEmoji } from "@/components/remocn/caption-emoji";+import captions from "./captions.json";++const emoji = {+ thing: "👀",+ lose: "📉",+ three: "⏱️",+ captions: "💬",+ sound: "🔇",+};++export const MyScene = () => (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: 108,+ paddingInline: 192,+ }}+ >+ <CaptionEmoji captions={captions} emoji={emoji} />+ </AbsoluteFill>+);+```++<PropsTable title="Props"+ rows={[+ {+ name: "captions",+ type: "Caption[]",+ default: "—",+ description:+ "The timed transcript, in the `Caption` shape from `@remotion/captions`. Times are relative to the start of the surrounding `Sequence`.",+ },+ {+ name: "emoji",+ type: "Record<string, string>",+ default: "{}",+ description:+ "Word to emoji. Matched per spoken word, ignoring case and punctuation.",+ },+ {+ name: "emojiSize",+ type: "number",+ default: "0.9",+ description: "Emoji size relative to the caption font size, in em.",+ },+ {+ name: "combineTokensWithinMilliseconds",+ type: "number",+ default: "1200",+ description:+ "How much speech one page may span before the next word starts a new page. Pages also break at the end of a sentence and on any pause of at least `holdMs` (300 ms minimum).",+ },+ {+ name: "holdMs",+ type: "number",+ default: "600",+ description:+ "How long a page stays after its last word when the next page is not already due. It fades out at the end of the hold.",+ },+ {+ name: "fontSize",+ type: "number",+ default: "64",+ description: "Font size in pixels.",+ },+ {+ name: "fontWeight",+ type: "number",+ default: "800",+ description: "Font weight. The font itself is inherited.",+ },+ {+ name: "color",+ type: "string",+ default: "\"#ffffff\"",+ description: "Text colour.",+ },+ {+ name: "shadow",+ type: "boolean",+ default: "true",+ description:+ "A tight text shadow that keeps the caption legible over bright footage.",+ },+ {+ name: "className",+ type: "string",+ default: "—",+ description:+ "Classes for the text block — width, font family, `uppercase`.",+ },+ ]}+/>diff --git a/content/docs/captions/components/caption-handwrite.mdx b/content/docs/captions/components/caption-handwrite.mdxnew file mode 100644index 00000000..9caf4810--- /dev/null+++ b/content/docs/captions/components/caption-handwrite.mdx@@ -0,0 +1,126 @@+---+title: Handwrite+description: Each word is inked in by hand from left to right at the pace it is spoken, every word sitting at its own slight angle+component: caption-handwrite+vibe: paper+length: transcript-driven+useWhen:+ - "A personal, journal-like video — vlog, founder story, voice memo — where the captions should feel written by the speaker rather than typeset."+ - "The speaker's pace matters: a drawn-out word is inked slowly and a quick one in a flick, so the writing follows the voice."+avoidWhen:+ - "There is no voiceover and the handwritten line is scripted on-screen copy — use `handwrite`."+ - "You want the reveal to read as typed rather than written — use `caption-typewriter`."+ - "The captions should stay plain and readable at small sizes over busy footage — use `caption-subtitle`."+---++<ComponentPreview name="caption-handwrite" />++<InstallBlock name="caption-handwrite" />++## Usage++`CaptionHandwrite` takes a timed transcript and renders only the text block, so+place it inside your own `AbsoluteFill`. Each word stays invisible, with its+space already reserved, until it is spoken. Then ink runs across it from left to+right behind a soft leading edge, taking as long as the word itself, with a+200 ms floor so short words are still written rather than flashed. Every word+gets its own small tilt and baseline lift, and every letter its own slant, so+the line never looks set in type. `wobble` scales all of that, and `0` writes+perfectly straight.++The effect reads best in a handwriting face. The font is inherited, so load+one with `@remotion/google-fonts` and set it on a wrapper. See+[Positioning](/docs/captions/getting-started/positioning) for safe placements+and [Get a transcript](/docs/captions/getting-started/get-a-transcript) for+producing `captions.json`.++```tsx+import { loadFont } from "@remotion/google-fonts/Caveat";+import { AbsoluteFill } from "remotion";+import { CaptionHandwrite } from "@/components/remocn/caption-handwrite";+import captions from "./captions.json";++const { fontFamily } = loadFont("normal", {+ subsets: ["latin"],+ weights: ["700"],+});++export const MyScene = () => (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: 108,+ paddingInline: 192,+ fontFamily,+ }}+ >+ <CaptionHandwrite captions={captions} fontSize={80} fontWeight={700} />+ </AbsoluteFill>+);+```++<PropsTable title="Props"+ rows={[+ {+ name: "captions",+ type: "Caption[]",+ default: "—",+ description:+ "The timed transcript, in the `Caption` shape from `@remotion/captions`. Times are relative to the start of the surrounding `Sequence`.",+ },+ {+ name: "wobble",+ type: "number",+ default: "1",+ description:+ "Scales the per-word tilt and baseline lift and the per-letter slant. `0` is straight, `2` is a loose scrawl.",+ },+ {+ name: "combineTokensWithinMilliseconds",+ type: "number",+ default: "1200",+ description:+ "How much speech one page may span before the next word starts a new page. Pages also break at the end of a sentence and on any pause of at least `holdMs` (300 ms minimum).",+ },+ {+ name: "holdMs",+ type: "number",+ default: "600",+ description:+ "How long a page stays after its last word when the next page is not already due. It fades out at the end of the hold instead of hanging through the pause.",+ },+ {+ name: "fontSize",+ type: "number",+ default: "64",+ description: "Font size in pixels.",+ },+ {+ name: "fontWeight",+ type: "number",+ default: "800",+ description: "Font weight. The font itself is inherited.",+ },+ {+ name: "color",+ type: "string",+ default: "\"#ffffff\"",+ description: "Ink colour.",+ },+ {+ name: "shadow",+ type: "boolean",+ default: "true",+ description:+ "A tight text shadow that keeps the writing legible over bright footage.",+ },+ {+ name: "className",+ type: "string",+ default: "—",+ description:+ "Classes for the text block — width, font family, `uppercase`.",+ },+ ]}+/>diff --git a/content/docs/captions/components/caption-highlight-box.mdx b/content/docs/captions/components/caption-highlight-box.mdxnew file mode 100644index 00000000..d455db4f--- /dev/null+++ b/content/docs/captions/components/caption-highlight-box.mdx@@ -0,0 +1,133 @@+---+title: Highlight Box+description: A solid box travels behind the word being spoken, sliding from word to word as the voice moves on+component: caption-highlight-box+vibe: social+length: transcript-driven+useWhen:+ - "Short-form video where the caption has to be read at a glance — a solid block behind the spoken word is the loudest way to say where the voice is."+ - "The footage is busy or bright and the active word needs its own background to stay readable."+avoidWhen:+ - "You want the voice's progress inside each word rather than a jump from word to word — use `caption-karaoke`."+ - "A solid block would fight the picture and colour alone is enough — use `caption-active-pop`."+ - "There is no voiceover and the text is scripted — use `word-stream`."+---++<ComponentPreview name="caption-highlight-box" />++<InstallBlock name="caption-highlight-box" />++## Usage++`CaptionHighlightBox` shows the whole page and moves a rounded box behind the+word being spoken. When the voice reaches the next word the box slides and+resizes onto it instead of popping, so the eye follows one shape across the+line. The text sitting on the box switches to `activeColor` as the box arrives.++It renders only the text block, so place it inside your own `AbsoluteFill`. See+[Positioning](/docs/captions/getting-started/positioning) for safe placements+and [Get a transcript](/docs/captions/getting-started/get-a-transcript) for+producing `captions.json`.++```tsx+import { AbsoluteFill } from "remotion";+import { CaptionHighlightBox } from "@/components/remocn/caption-highlight-box";+import captions from "./captions.json";++export const MyScene = () => (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: 108,+ paddingInline: 192,+ }}+ >+ <CaptionHighlightBox captions={captions} boxColor="#facc15" />+ </AbsoluteFill>+);+```++<PropsTable title="Props"+ rows={[+ {+ name: "captions",+ type: "Caption[]",+ default: "—",+ description:+ "The timed transcript, in the `Caption` shape from `@remotion/captions`. Times are relative to the start of the surrounding `Sequence`.",+ },+ {+ name: "combineTokensWithinMilliseconds",+ type: "number",+ default: "1200",+ description:+ "How much speech one page may span before the next word starts a new page. Pages also break at the end of a sentence and on any pause of at least `holdMs` (300 ms minimum).",+ },+ {+ name: "holdMs",+ type: "number",+ default: "600",+ description:+ "How long a page stays after its last word when the next page is not already due. It fades out at the end of the hold instead of hanging through the pause.",+ },+ {+ name: "fontSize",+ type: "number",+ default: "64",+ description: "Font size in pixels.",+ },+ {+ name: "fontWeight",+ type: "number",+ default: "800",+ description: "Font weight. The font itself is inherited.",+ },+ {+ name: "color",+ type: "string",+ default: "\"#ffffff\"",+ description: "Colour of the words off the box.",+ },+ {+ name: "activeColor",+ type: "string",+ default: "\"#0a0a0a\"",+ description:+ "Colour of the word sitting on the box. Pick something that contrasts with `boxColor`.",+ },+ {+ name: "boxColor",+ type: "string",+ default: "\"#facc15\"",+ description: "Fill of the travelling box.",+ },+ {+ name: "boxRadius",+ type: "number",+ default: "0.16",+ description: "Corner radius of the box, in em of the font size.",+ },+ {+ name: "boxPadding",+ type: "number",+ default: "0.14",+ description:+ "How far the box extends past the word on each side, in em of the font size.",+ },+ {+ name: "shadow",+ type: "boolean",+ default: "true",+ description:+ "A tight text shadow on the words off the box, so they stay legible over bright footage.",+ },+ {+ name: "className",+ type: "string",+ default: "—",+ description:+ "Classes for the text block — width, font family, `uppercase`.",+ },+ ]}+/>diff --git a/content/docs/captions/components/caption-karaoke.mdx b/content/docs/captions/components/caption-karaoke.mdxnew file mode 100644index 00000000..075d9226--- /dev/null+++ b/content/docs/captions/components/caption-karaoke.mdx@@ -0,0 +1,107 @@+---+title: Karaoke+description: Each word fills with colour left to right exactly as it is spoken, with the whole phrase readable before the voice reaches it+component: caption-karaoke+vibe: social+length: transcript-driven+useWhen:+ - "A voiceover or talking head needs captions and the viewer should be able to read ahead — the full phrase is on screen, the fill only shows where the voice is."+ - "The pace of the speech is part of the point — a slow word fills slowly and a quick one snaps, so the captions carry the rhythm of the delivery."+avoidWhen:+ - "There is no voiceover and the text is scripted — use `word-stream`, which paces phrases with its own timing."+ - "You want letters typed out on their own clock rather than following a recording — use `typewriter`."+---++<ComponentPreview name="caption-karaoke" />++<InstallBlock name="caption-karaoke" />++## Usage++`CaptionKaraoke` takes a timed transcript and renders only the text block, so+place it inside your own `AbsoluteFill`. See [Positioning](/docs/captions/getting-started/positioning)+for safe placements and [Get a transcript](/docs/captions/getting-started/get-a-transcript)+for producing `captions.json`.++```tsx+import { AbsoluteFill } from "remotion";+import { CaptionKaraoke } from "@/components/remocn/caption-karaoke";+import captions from "./captions.json";++export const MyScene = () => (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: 108,+ paddingInline: 192,+ }}+ >+ <CaptionKaraoke captions={captions} />+ </AbsoluteFill>+);+```++<PropsTable title="Props"+ rows={[+ {+ name: "captions",+ type: "Caption[]",+ default: "—",+ description:+ "The timed transcript, in the `Caption` shape from `@remotion/captions`. Times are relative to the start of the surrounding `Sequence`.",+ },+ {+ name: "combineTokensWithinMilliseconds",+ type: "number",+ default: "1200",+ description:+ "How much speech one page may span before the next word starts a new page. Pages also break at the end of a sentence and on any pause of at least `holdMs` (300 ms minimum).",+ },+ {+ name: "holdMs",+ type: "number",+ default: "600",+ description:+ "How long a page stays after its last word when the next page is not already due. It fades out at the end of the hold instead of hanging through the pause.",+ },+ {+ name: "fontSize",+ type: "number",+ default: "64",+ description: "Font size in pixels.",+ },+ {+ name: "fontWeight",+ type: "number",+ default: "800",+ description: "Font weight. The font itself is inherited.",+ },+ {+ name: "color",+ type: "string",+ default: "\"#ffffff\"",+ description: "Colour of words the voice has not reached yet.",+ },+ {+ name: "activeColor",+ type: "string",+ default: "\"#facc15\"",+ description: "Colour that fills each word as it is spoken.",+ },+ {+ name: "shadow",+ type: "boolean",+ default: "true",+ description:+ "A tight text shadow that keeps the caption legible over bright footage.",+ },+ {+ name: "className",+ type: "string",+ default: "—",+ description:+ "Classes for the text block — width, font family, `uppercase`.",+ },+ ]}+/>diff --git a/content/docs/captions/components/caption-knockout.mdx b/content/docs/captions/components/caption-knockout.mdxnew file mode 100644index 00000000..f1242363--- /dev/null+++ b/content/docs/captions/components/caption-knockout.mdx@@ -0,0 +1,118 @@+---+title: Knockout+description: A solid plate with the words cut clean through it, each word punching out the moment it is spoken so the footage shows through the letters+component: caption-knockout+vibe: premium+length: transcript-driven+useWhen:+ - "The footage is worth seeing and you want the caption to frame it rather than cover it — the letters are windows onto whatever plays behind them."+ - "A bold, graphic caption for brand or launch video where a block of colour is part of the look, with the speech punching holes through it as it goes."+avoidWhen:+ - "The footage behind is flat or the same tone as the plate — the holes vanish; use `caption-subtitle`, whose plate carries solid text."+ - "The viewer should read ahead of the voice in plain type — use `caption-karaoke` or `caption-dim-progress`."+ - "You want a box that follows the spoken word instead of a plate behind the whole phrase — use `caption-highlight-box`."+---++<ComponentPreview name="caption-knockout" />++<InstallBlock name="caption-knockout" />++## Usage++`CaptionKnockout` draws one solid plate behind the phrase and cuts the words+out of it. A cut is a real hole: whatever sits behind the caption in your+composition shows through the letters, so put it over footage, a shader or a+moving background. Words the voice has not reached yet are still mostly+plate; each one punches through the moment it is spoken.++The cut is an SVG mask, so any `plateColor` works, light or dark. The holes are+drawn with the font inherited from the caption, so load your typeface the same+way you would for any other caption style.++The component renders only the text block. See [Positioning](/docs/captions/getting-started/positioning)+for safe placements and [Get a transcript](/docs/captions/getting-started/get-a-transcript)+for producing `captions.json`.++```tsx+import { AbsoluteFill } from "remotion";+import { CaptionKnockout } from "@/components/remocn/caption-knockout";+import captions from "./captions.json";++export const MyScene = () => (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: 108,+ paddingInline: 192,+ }}+ >+ <CaptionKnockout captions={captions} />+ </AbsoluteFill>+);+```++<PropsTable title="Props"+ rows={[+ {+ name: "captions",+ type: "Caption[]",+ default: "—",+ description:+ "The timed transcript, in the `Caption` shape from `@remotion/captions`. Times are relative to the start of the surrounding `Sequence`.",+ },+ {+ name: "combineTokensWithinMilliseconds",+ type: "number",+ default: "1200",+ description:+ "How much speech one page may span before the next word starts a new page. Pages also break at the end of a sentence and on any pause of at least `holdMs` (300 ms minimum).",+ },+ {+ name: "holdMs",+ type: "number",+ default: "600",+ description:+ "How long a page stays after its last word when the next page is not already due. It fades out at the end of the hold instead of hanging through the pause.",+ },+ {+ name: "fontSize",+ type: "number",+ default: "64",+ description: "Font size in pixels.",+ },+ {+ name: "fontWeight",+ type: "number",+ default: "800",+ description:+ "Font weight. Heavy weights cut wider holes and show more of the footage.",+ },+ {+ name: "plateColor",+ type: "string",+ default: "\"#ffffff\"",+ description: "Colour of the plate the words are cut out of.",+ },+ {+ name: "upcomingOpacity",+ type: "number",+ default: "0.15",+ description:+ "How far a word the voice has not reached yet already shows through, from 0 (solid plate) to 1 (fully cut).",+ },+ {+ name: "radius",+ type: "number",+ default: "0.16",+ description: "Corner radius of the plate, in em.",+ },+ {+ name: "className",+ type: "string",+ default: "—",+ description:+ "Classes for the text block — width, font family, `uppercase`.",+ },+ ]}+/>diff --git a/content/docs/captions/components/caption-label-maker.mdx b/content/docs/captions/components/caption-label-maker.mdxnew file mode 100644index 00000000..bf310245--- /dev/null+++ b/content/docs/captions/components/caption-label-maker.mdx@@ -0,0 +1,109 @@+---+title: Label Maker+description: Each phrase is punched letter by letter into a strip of embossing tape at the pace it is spoken, the tape feeding out as the words arrive+component: caption-label-maker+vibe: paper+length: transcript-driven+useWhen:+ - "A handmade, analog or DIY video wants captions with a physical object behind them — the tape is the legibility, so it reads over any footage."+ - "The voice should feel like it is being written down — letters are pressed one at a time, so slow words punch slowly and quick ones rattle out."+avoidWhen:+ - "You want typed characters with a caret and no surface behind them — use `caption-typewriter`."+ - "The video is clean or premium and a craft object would feel off-brand — use `caption-rise` or `caption-subtitle`."+ - "Pages run long — a label is one line, so keep phrases short or use `caption-subtitle`, which balances two lines."+---++<ComponentPreview name="caption-label-maker" />++<InstallBlock name="caption-label-maker" />++## Usage++`CaptionLabelMaker` takes a timed transcript and renders only the text block, so+place it inside your own `AbsoluteFill`. Each page is a single strip of tape,+tilted slightly. Letters are punched one by one across each word's duration,+with a small press on every letter, and the tape grows from left to right with+them. The space for the whole label is reserved when the page starts, so the+strip never shifts. See [Positioning](/docs/captions/getting-started/positioning)+for safe placements and [Get a transcript](/docs/captions/getting-started/get-a-transcript)+for producing `captions.json`.++```tsx+import { AbsoluteFill } from "remotion";+import { CaptionLabelMaker } from "@/components/remocn/caption-label-maker";+import captions from "./captions.json";++export const MyScene = () => (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: 108,+ paddingInline: 192,+ }}+ >+ <CaptionLabelMaker captions={captions} />+ </AbsoluteFill>+);+```++A label never wraps, so the default page window is shorter than other styles.+Embossing tape reads best with a heavy, slightly condensed font and+`className="uppercase"`.++<PropsTable title="Props"+ rows={[+ {+ name: "captions",+ type: "Caption[]",+ default: "—",+ description:+ "The timed transcript, in the `Caption` shape from `@remotion/captions`. Times are relative to the start of the surrounding `Sequence`.",+ },+ {+ name: "tapeColor",+ type: "string",+ default: "\"#18181b\"",+ description: "Colour of the embossing tape.",+ },+ {+ name: "combineTokensWithinMilliseconds",+ type: "number",+ default: "1000",+ description:+ "How much speech one page may span before the next word starts a new page. Pages also break at the end of a sentence and on any pause of at least `holdMs` (300 ms minimum).",+ },+ {+ name: "holdMs",+ type: "number",+ default: "600",+ description:+ "How long a page stays after its last word when the next page is not already due. It fades out at the end of the hold instead of hanging through the pause.",+ },+ {+ name: "fontSize",+ type: "number",+ default: "64",+ description: "Font size in pixels.",+ },+ {+ name: "fontWeight",+ type: "number",+ default: "800",+ description: "Font weight. The font itself is inherited.",+ },+ {+ name: "color",+ type: "string",+ default: "\"#ffffff\"",+ description: "Colour of the embossed letters.",+ },+ {+ name: "className",+ type: "string",+ default: "—",+ description:+ "Classes for the text block — font family, `uppercase`.",+ },+ ]}+/>diff --git a/content/docs/captions/components/caption-marker.mdx b/content/docs/captions/components/caption-marker.mdxnew file mode 100644index 00000000..41c80c29--- /dev/null+++ b/content/docs/captions/components/caption-marker.mdx@@ -0,0 +1,133 @@+---+title: Marker+description: Plain captions where the words that matter get a highlighter swipe the moment they are spoken+component: caption-marker+vibe: paper+length: transcript-driven+useWhen:+ - "Talking-head or explainer video where a few words carry the point — the marker lands on exactly those words, in time with the voice, and leaves the rest calm."+ - "You want the hand-made feel of a highlighter pen on top of an ordinary, readable caption line."+avoidWhen:+ - "Every word should be marked as it is spoken, not just the keywords — use `caption-highlight-box`, whose box travels across the whole phrase."+ - "There is no voiceover and the highlighted line is scripted on-screen copy — use `marker-highlight`."+ - "You want the spoken position shown on every word without singling any out — use `caption-karaoke`."+---++<ComponentPreview name="caption-marker" />++<InstallBlock name="caption-marker" />++## Usage++`CaptionMarker` takes a timed transcript and renders only the text block, so+place it inside your own `AbsoluteFill`. Words read as a plain caption line+until a word from `keywords` is spoken. Then a slightly tilted highlighter band+draws behind it from left to right, taking as long as the word itself, and the+covered letters switch to `markerTextColor` so they stay readable on the band.+The band stays until the page leaves. Without `keywords`, nothing is marked.+See [Positioning](/docs/captions/getting-started/positioning) for safe+placements and [Get a transcript](/docs/captions/getting-started/get-a-transcript)+for producing `captions.json`.++```tsx+import { AbsoluteFill } from "remotion";+import { CaptionMarker } from "@/components/remocn/caption-marker";+import captions from "./captions.json";++export const MyScene = () => (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: 108,+ paddingInline: 192,+ }}+ >+ <CaptionMarker+ captions={captions}+ keywords={["thing", "lose", "three", "captions", "sound"]}+ />+ </AbsoluteFill>+);+```++Keywords match whole words, ignoring case and punctuation, so `"sound"` also+catches `Sound,` and `sound.` in the transcript.++<PropsTable title="Props"+ rows={[+ {+ name: "captions",+ type: "Caption[]",+ default: "—",+ description:+ "The timed transcript, in the `Caption` shape from `@remotion/captions`. Times are relative to the start of the surrounding `Sequence`.",+ },+ {+ name: "keywords",+ type: "string[]",+ default: "—",+ description:+ "Words that get the highlighter. Matched per word, ignoring case and punctuation. When omitted, no word is marked.",+ },+ {+ name: "markerColor",+ type: "string",+ default: "\"#facc15\"",+ description: "Colour of the highlighter band.",+ },+ {+ name: "markerTextColor",+ type: "string",+ default: "\"#0a0a0a\"",+ description:+ "Colour of the letters the band has covered, so a marked word stays readable.",+ },+ {+ name: "combineTokensWithinMilliseconds",+ type: "number",+ default: "1200",+ description:+ "How much speech one page may span before the next word starts a new page. Pages also break at the end of a sentence and on any pause of at least `holdMs` (300 ms minimum).",+ },+ {+ name: "holdMs",+ type: "number",+ default: "600",+ description:+ "How long a page stays after its last word when the next page is not already due. It fades out at the end of the hold instead of hanging through the pause.",+ },+ {+ name: "fontSize",+ type: "number",+ default: "64",+ description: "Font size in pixels.",+ },+ {+ name: "fontWeight",+ type: "number",+ default: "800",+ description: "Font weight. The font itself is inherited.",+ },+ {+ name: "color",+ type: "string",+ default: "\"#ffffff\"",+ description: "Colour of unmarked words.",+ },+ {+ name: "shadow",+ type: "boolean",+ default: "true",+ description:+ "A tight text shadow that keeps unmarked words legible over bright footage. It fades out under a word as the band covers it.",+ },+ {+ name: "className",+ type: "string",+ default: "—",+ description:+ "Classes for the text block — width, font family, `uppercase`.",+ },+ ]}+/>diff --git a/content/docs/captions/components/caption-outline.mdx b/content/docs/captions/components/caption-outline.mdxnew file mode 100644index 00000000..d2950e63--- /dev/null+++ b/content/docs/captions/components/caption-outline.mdx@@ -0,0 +1,132 @@+---+title: Outline+description: Heavy-stroked captions that stay readable over any footage, with the spoken word switching to a contrast colour and nothing else moving+component: caption-outline+vibe: social+length: transcript-driven+useWhen:+ - "Captions sit over busy, bright or fast-cut footage — the thick outline keeps every word readable without a plate or a shadow."+ - "You want the bold YouTube Shorts caption look where the spoken word is marked by colour alone, so the eye can read along without anything jumping."+avoidWhen:+ - "The spoken word should also spring in scale — use `caption-active-pop`, the motion counterpart of this style."+ - "The tone is calm or editorial and a heavy outline would shout — use `caption-subtitle`."+ - "The marker should be a box travelling behind the spoken word rather than a colour change — use `caption-highlight-box`."+---++<ComponentPreview name="caption-outline" />++<InstallBlock name="caption-outline" />++## Usage++`CaptionOutline` takes a timed transcript and renders only the text block, so+place it inside your own `AbsoluteFill`. Every letter carries a heavy stroke+painted under its fill, and the word being spoken switches to `activeColor`.+Nothing scales or moves inside the page, which keeps the line rock-steady for+reading. See [Positioning](/docs/captions/getting-started/positioning) for safe+placements and [Get a transcript](/docs/captions/getting-started/get-a-transcript)+for producing `captions.json`.++```tsx+import { AbsoluteFill } from "remotion";+import { CaptionOutline } from "@/components/remocn/caption-outline";+import captions from "./captions.json";++export const MyScene = () => (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: 108,+ paddingInline: 192,+ }}+ >+ <CaptionOutline captions={captions} />+ </AbsoluteFill>+);+```++The look is at its strongest in caps with a heavy display face. Load one with+`@remotion/google-fonts` and pass `className="uppercase"` along with it.++```tsx+import { loadFont } from "@remotion/google-fonts/Anton";++const { fontFamily } = loadFont();++export const Caps = () => (+ <div style={{ fontFamily }}>+ <CaptionOutline captions={captions} className="uppercase" fontWeight={400} />+ </div>+);+```++<PropsTable title="Props"+ rows={[+ {+ name: "captions",+ type: "Caption[]",+ default: "—",+ description:+ "The timed transcript, in the `Caption` shape from `@remotion/captions`. Times are relative to the start of the surrounding `Sequence`.",+ },+ {+ name: "activeColor",+ type: "string",+ default: "\"#facc15\"",+ description: "Fill colour of the word being spoken.",+ },+ {+ name: "strokeColor",+ type: "string",+ default: "\"#000000\"",+ description: "Colour of the outline around every letter.",+ },+ {+ name: "strokeWidth",+ type: "number",+ default: "0.12",+ description:+ "How far the outline reaches outside each letter, in em. The stroke is painted under the fill, so it never eats into the letterforms.",+ },+ {+ name: "combineTokensWithinMilliseconds",+ type: "number",+ default: "1200",+ description:+ "How much speech one page may span before the next word starts a new page. Pages also break at the end of a sentence and on any pause of at least `holdMs` (300 ms minimum).",+ },+ {+ name: "holdMs",+ type: "number",+ default: "600",+ description:+ "How long a page stays after its last word when the next page is not already due. It fades out at the end of the hold instead of hanging through the pause.",+ },+ {+ name: "fontSize",+ type: "number",+ default: "64",+ description: "Font size in pixels.",+ },+ {+ name: "fontWeight",+ type: "number",+ default: "800",+ description: "Font weight. The font itself is inherited.",+ },+ {+ name: "color",+ type: "string",+ default: "\"#ffffff\"",+ description: "Fill colour of words that are not being spoken.",+ },+ {+ name: "className",+ type: "string",+ default: "—",+ description:+ "Classes for the text block — width, font family, `uppercase`.",+ },+ ]}+/>diff --git a/content/docs/captions/components/caption-prosody.mdx b/content/docs/captions/components/caption-prosody.mdxnew file mode 100644index 00000000..1d8c464d--- /dev/null+++ b/content/docs/captions/components/caption-prosody.mdx@@ -0,0 +1,130 @@+---+title: Prosody+description: Word size follows the delivery, so drawn-out words land large and rushed words stay small, and the rhythm of the voice is visible with the sound off+component: caption-prosody+vibe: playful+length: transcript-driven+useWhen:+ - "The way something is said matters as much as what is said — a slow, stretched word reads as emphasis and a quick aside shrinks, so the captions carry the speaker's rhythm without audio."+ - "You want expressive kinetic type that comes from the recording itself rather than from a hand-picked keyword list."+avoidWhen:+ - "You want to choose which word is emphasised yourself — use `caption-stack`, which enlarges the keywords you pass."+ - "The captions should read calmly at one size — use `caption-karaoke` or `caption-subtitle`."+ - "There is no voiceover and the text is scripted — use `word-stream`."+---++<ComponentPreview name="caption-prosody" />++<InstallBlock name="caption-prosody" />++## Usage++`CaptionProsody` sizes every word by how long the speaker spent on each of its+letters, measured against the rest of the page. A word held twice as long as+the page's typical pace grows to `maxScale`, one said twice as fast shrinks to+`minScale`, and everything in between scales smoothly. Sizes are fixed when a+page starts, so the line never reflows: words then appear at the moment they+are spoken, and the word being spoken takes `activeColor`.++The effect comes straight from the transcript timing, so it is only as+expressive as the timestamps are precise — word-level timestamps from+whisper.cpp or the OpenAI API work best. The component renders only the text+block; see [Positioning](/docs/captions/getting-started/positioning) and+[Get a transcript](/docs/captions/getting-started/get-a-transcript).++```tsx+import { AbsoluteFill } from "remotion";+import { CaptionProsody } from "@/components/remocn/caption-prosody";+import captions from "./captions.json";++export const MyScene = () => (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: 108,+ paddingInline: 192,+ }}+ >+ <CaptionProsody captions={captions} />+ </AbsoluteFill>+);+```++<PropsTable title="Props"+ rows={[+ {+ name: "captions",+ type: "Caption[]",+ default: "—",+ description:+ "The timed transcript, in the `Caption` shape from `@remotion/captions`. Times are relative to the start of the surrounding `Sequence`.",+ },+ {+ name: "minScale",+ type: "number",+ default: "0.75",+ description:+ "Size of a word said twice as fast as the page's typical pace, relative to `fontSize`.",+ },+ {+ name: "maxScale",+ type: "number",+ default: "1.6",+ description:+ "Size of a word held twice as long as the page's typical pace, relative to `fontSize`.",+ },+ {+ name: "combineTokensWithinMilliseconds",+ type: "number",+ default: "1200",+ description:+ "How much speech one page may span before the next word starts a new page. Pages also break at the end of a sentence and on any pause of at least `holdMs` (300 ms minimum).",+ },+ {+ name: "holdMs",+ type: "number",+ default: "600",+ description:+ "How long a page stays after its last word when the next page is not already due. It fades out at the end of the hold.",+ },+ {+ name: "fontSize",+ type: "number",+ default: "64",+ description: "Base font size in pixels; a word at the typical pace renders at this size.",+ },+ {+ name: "fontWeight",+ type: "number",+ default: "800",+ description: "Font weight. The font itself is inherited.",+ },+ {+ name: "color",+ type: "string",+ default: "\"#ffffff\"",+ description: "Colour of every word that is not being spoken right now.",+ },+ {+ name: "activeColor",+ type: "string",+ default: "\"#facc15\"",+ description: "Colour of the word being spoken.",+ },+ {+ name: "shadow",+ type: "boolean",+ default: "true",+ description:+ "A tight text shadow that keeps the caption legible over bright footage.",+ },+ {+ name: "className",+ type: "string",+ default: "—",+ description:+ "Classes for the text block — width, font family, `uppercase`.",+ },+ ]}+/>diff --git a/content/docs/captions/components/caption-redact.mdx b/content/docs/captions/components/caption-redact.mdxnew file mode 100644index 00000000..741e2486--- /dev/null+++ b/content/docs/captions/components/caption-redact.mdx@@ -0,0 +1,117 @@+---+title: Redact+description: The whole phrase starts blacked out like a declassified file, and each bar pulls away the moment its word is spoken+component: caption-redact+vibe: tech+length: transcript-driven+useWhen:+ - "Investigative, true-crime or reveal-style storytelling where the line should feel withheld until the speaker says it out loud."+ - "You want the viewer to see the shape and length of the whole phrase up front, with the words uncovered in time with the voice."+avoidWhen:+ - "The phrase should be readable before the voice reaches it — use `caption-dim-progress`, which shows every word dimmed instead of hidden."+ - "Words should decode rather than uncover — use `caption-scramble`."+ - "Part of the picture needs hiding for privacy, not the caption — use `pixelate-region`."+---++<ComponentPreview name="caption-redact" />++<InstallBlock name="caption-redact" />++## Usage++`CaptionRedact` takes a timed transcript and renders only the text block, so+place it inside your own `AbsoluteFill`. When a page appears, every word is+hidden under a solid bar sized to it. As each word is spoken its bar retracts+from the left edge toward the right, taking as long as the word itself with a+180 ms floor, and the text underneath is uncovered behind it. Bars for words+the voice has not reached stay in place, so the page reads like a document+being declassified line by line. See+[Positioning](/docs/captions/getting-started/positioning) for safe placements+and [Get a transcript](/docs/captions/getting-started/get-a-transcript) for+producing `captions.json`.++```tsx+import { AbsoluteFill } from "remotion";+import { CaptionRedact } from "@/components/remocn/caption-redact";+import captions from "./captions.json";++export const MyScene = () => (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: 108,+ paddingInline: 192,+ }}+ >+ <CaptionRedact captions={captions} />+ </AbsoluteFill>+);+```++The bars are opaque on purpose, so they read over any footage. On very dark+footage, set `barColor` to a light value so the redaction stays visible.++<PropsTable title="Props"+ rows={[+ {+ name: "captions",+ type: "Caption[]",+ default: "—",+ description:+ "The timed transcript, in the `Caption` shape from `@remotion/captions`. Times are relative to the start of the surrounding `Sequence`.",+ },+ {+ name: "barColor",+ type: "string",+ default: "\"#0a0a0a\"",+ description: "Colour of the redaction bars.",+ },+ {+ name: "combineTokensWithinMilliseconds",+ type: "number",+ default: "1200",+ description:+ "How much speech one page may span before the next word starts a new page. Pages also break at the end of a sentence and on any pause of at least `holdMs` (300 ms minimum).",+ },+ {+ name: "holdMs",+ type: "number",+ default: "600",+ description:+ "How long a page stays after its last word when the next page is not already due. It fades out at the end of the hold instead of hanging through the pause.",+ },+ {+ name: "fontSize",+ type: "number",+ default: "64",+ description: "Font size in pixels.",+ },+ {+ name: "fontWeight",+ type: "number",+ default: "800",+ description: "Font weight. The font itself is inherited.",+ },+ {+ name: "color",+ type: "string",+ default: "\"#ffffff\"",+ description: "Colour of the uncovered words.",+ },+ {+ name: "shadow",+ type: "boolean",+ default: "true",+ description:+ "A tight text shadow that keeps uncovered words legible over bright footage.",+ },+ {+ name: "className",+ type: "string",+ default: "—",+ description:+ "Classes for the text block — width, font family, `uppercase`.",+ },+ ]}+/>diff --git a/content/docs/captions/components/caption-rise.mdx b/content/docs/captions/components/caption-rise.mdxnew file mode 100644index 00000000..80abff5f--- /dev/null+++ b/content/docs/captions/components/caption-rise.mdx@@ -0,0 +1,105 @@+---+title: Rise+description: Each word slides up out of a mask at its baseline the moment it is spoken, with no bounce and no scale+component: caption-rise+vibe: clean+length: transcript-driven+useWhen:+ - "Editorial video, interviews or a brand film where the captions should feel typeset — words rise into a fixed line with a confident ease-out and nothing extra."+ - "You want motion that reads as precise rather than playful — each word is revealed by a hard mask edge instead of a fade or a spring."+avoidWhen:+ - "The video is playful short-form and wants energy — use `caption-bounce-in`."+ - "The tone is soft and dreamy rather than crisp — use `caption-blur-in`, which resolves each word out of focus."+ - "The text is a scripted title with no voiceover — use `per-word-crossfade` or `word-stream`."+---++<ComponentPreview name="caption-rise" />++<InstallBlock name="caption-rise" />++## Usage++`CaptionRise` takes a timed transcript and renders only the text block, so+place it inside your own `AbsoluteFill`. Every word sits in its own mask and+rises into place from below its baseline at its own start time. The space for+the whole phrase is reserved from the first word, so the line never reflows as+it builds. See [Positioning](/docs/captions/getting-started/positioning) for+safe placements and [Get a transcript](/docs/captions/getting-started/get-a-transcript)+for producing `captions.json`.++```tsx+import { AbsoluteFill } from "remotion";+import { CaptionRise } from "@/components/remocn/caption-rise";+import captions from "./captions.json";++export const MyScene = () => (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: 108,+ paddingInline: 192,+ }}+ >+ <CaptionRise captions={captions} />+ </AbsoluteFill>+);+```++<PropsTable title="Props"+ rows={[+ {+ name: "captions",+ type: "Caption[]",+ default: "—",+ description:+ "The timed transcript, in the `Caption` shape from `@remotion/captions`. Times are relative to the start of the surrounding `Sequence`.",+ },+ {+ name: "combineTokensWithinMilliseconds",+ type: "number",+ default: "1200",+ description:+ "How much speech one page may span before the next word starts a new page. Pages also break at the end of a sentence and on any pause of at least `holdMs` (300 ms minimum).",+ },+ {+ name: "holdMs",+ type: "number",+ default: "600",+ description:+ "How long a page stays after its last word when the next page is not already due. It fades out at the end of the hold instead of hanging through the pause.",+ },+ {+ name: "fontSize",+ type: "number",+ default: "64",+ description: "Font size in pixels.",+ },+ {+ name: "fontWeight",+ type: "number",+ default: "800",+ description: "Font weight. The font itself is inherited.",+ },+ {+ name: "color",+ type: "string",+ default: "\"#ffffff\"",+ description: "Text colour.",+ },+ {+ name: "shadow",+ type: "boolean",+ default: "true",+ description:+ "A tight text shadow that keeps the caption legible over bright footage. It sits inside the word mask, so it is clipped with the word while it rises.",+ },+ {+ name: "className",+ type: "string",+ default: "—",+ description:+ "Classes for the text block — width, font family, `uppercase`.",+ },+ ]}+/>diff --git a/content/docs/captions/components/caption-scramble.mdx b/content/docs/captions/components/caption-scramble.mdxnew file mode 100644index 00000000..909a57c4--- /dev/null+++ b/content/docs/captions/components/caption-scramble.mdx@@ -0,0 +1,117 @@+---+title: Scramble+description: Each word arrives as random glyphs at the moment it is spoken and decodes left to right into the real letters+component: caption-scramble+vibe: tech+length: transcript-driven+useWhen:+ - "The video is about software, security, AI or data and the captions should feel like a terminal decoding the voice as it speaks."+ - "You want each word to land with a little texture but the phrase to settle into plain, readable type a moment later."+avoidWhen:+ - "The tone is calm or editorial and the glyph noise would read as a glitch — use `caption-rise` or `caption-blur-in`."+ - "You want characters to appear one by one in order rather than decode from noise — use `caption-typewriter`."+ - "The text is scripted on-screen copy with no voiceover behind it — use `word-stream`."+---++<ComponentPreview name="caption-scramble" />++<InstallBlock name="caption-scramble" />++## Usage++`CaptionScramble` keeps each word hidden until the voice reaches it. The word+then appears as random glyphs that resolve into the real letters from left to+right, taking as long as the word is spoken for, capped at 300ms, so short words+snap and long ones decode visibly. The glyphs re-roll every two frames and are+seeded from the frame, so every render is identical. The real word reserves its+space from the start, so the line never shifts while it builds. The component+renders only the text block, so place it inside your own `AbsoluteFill` — see+[Positioning](/docs/captions/getting-started/positioning).++```tsx+import { AbsoluteFill } from "remotion";+import { CaptionScramble } from "@/components/remocn/caption-scramble";+import captions from "./captions.json";++export const MyScene = () => (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: 108,+ paddingInline: 192,+ }}+ >+ <CaptionScramble captions={captions} />+ </AbsoluteFill>+);+```++A monospaced font keeps the decoding glyphs exactly as wide as the letters they+replace. With a proportional font the glyphs can run slightly past the word for a+frame or two while it resolves.++<PropsTable title="Props"+ rows={[+ {+ name: "captions",+ type: "Caption[]",+ default: "—",+ description:+ "The timed transcript, in the `Caption` shape from `@remotion/captions`. Times are relative to the start of the surrounding `Sequence`.",+ },+ {+ name: "combineTokensWithinMilliseconds",+ type: "number",+ default: "1200",+ description:+ "How much speech one page may span before the next word starts a new page. Pages also break at the end of a sentence and on any pause of at least `holdMs` (300 ms minimum).",+ },+ {+ name: "holdMs",+ type: "number",+ default: "600",+ description:+ "How long a page stays after its last word when the next page is not already due. It fades out at the end of the hold.",+ },+ {+ name: "glyphColor",+ type: "string",+ default: "\"#a3a3a3\"",+ description:+ "Colour of the glyphs that have not resolved yet. Resolved letters use `color`.",+ },+ {+ name: "fontSize",+ type: "number",+ default: "64",+ description: "Font size in pixels.",+ },+ {+ name: "fontWeight",+ type: "number",+ default: "800",+ description: "Font weight. The font itself is inherited.",+ },+ {+ name: "color",+ type: "string",+ default: "\"#ffffff\"",+ description: "Colour of resolved letters.",+ },+ {+ name: "shadow",+ type: "boolean",+ default: "true",+ description:+ "A tight text shadow that keeps the caption legible over bright footage.",+ },+ {+ name: "className",+ type: "string",+ default: "—",+ description:+ "Classes for the text block — width, font family, `uppercase`.",+ },+ ]}+/>diff --git a/content/docs/captions/components/caption-slice.mdx b/content/docs/captions/components/caption-slice.mdxnew file mode 100644index 00000000..b8b0582d--- /dev/null+++ b/content/docs/captions/components/caption-slice.mdx@@ -0,0 +1,114 @@+---+title: Slice+description: Each word arrives cut in two, the top half sliding in from the left and the bottom from the right, locking together the moment it is spoken+component: caption-slice+vibe: tech+length: transcript-driven+useWhen:+ - "Tech, product or launch video where the captions should feel engineered — every word assembles itself on cue instead of fading in."+ - "You want word-by-word arrival with a sharp, horizontal energy that stays out of the subject's way vertically."+avoidWhen:+ - "The arrival should be soft and quiet — use `caption-blur-in`."+ - "Words should land with playful overshoot — use `caption-bounce-in`."+ - "You want a clean editorial reveal with no sideways motion — use `caption-rise`."+---++<ComponentPreview name="caption-slice" />++<InstallBlock name="caption-slice" />++## Usage++`CaptionSlice` builds the phrase word by word as it is spoken. Each word is cut+horizontally through the middle of the line: at the moment the voice reaches+it, the top half slides in from the left and the bottom half from the right,+and the two lock into one clean word. Words the voice has not reached yet keep+their space, so the line never shifts as it builds.++The component renders only the text block. See [Positioning](/docs/captions/getting-started/positioning)+for safe placements and [Get a transcript](/docs/captions/getting-started/get-a-transcript)+for producing `captions.json`.++```tsx+import { AbsoluteFill } from "remotion";+import { CaptionSlice } from "@/components/remocn/caption-slice";+import captions from "./captions.json";++export const MyScene = () => (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: 108,+ paddingInline: 192,+ }}+ >+ <CaptionSlice captions={captions} />+ </AbsoluteFill>+);+```++<PropsTable title="Props"+ rows={[+ {+ name: "captions",+ type: "Caption[]",+ default: "—",+ description:+ "The timed transcript, in the `Caption` shape from `@remotion/captions`. Times are relative to the start of the surrounding `Sequence`.",+ },+ {+ name: "combineTokensWithinMilliseconds",+ type: "number",+ default: "1200",+ description:+ "How much speech one page may span before the next word starts a new page. Pages also break at the end of a sentence and on any pause of at least `holdMs` (300 ms minimum).",+ },+ {+ name: "holdMs",+ type: "number",+ default: "600",+ description:+ "How long a page stays after its last word when the next page is not already due. It fades out at the end of the hold instead of hanging through the pause.",+ },+ {+ name: "fontSize",+ type: "number",+ default: "64",+ description: "Font size in pixels.",+ },+ {+ name: "fontWeight",+ type: "number",+ default: "800",+ description: "Font weight. The font itself is inherited.",+ },+ {+ name: "color",+ type: "string",+ default: "\"#ffffff\"",+ description: "Text colour.",+ },+ {+ name: "distance",+ type: "number",+ default: "0.6",+ description:+ "How far each half starts from its final place, in em. Larger values read as a harder cut.",+ },+ {+ name: "shadow",+ type: "boolean",+ default: "true",+ description:+ "A tight text shadow that keeps the caption legible over bright footage.",+ },+ {+ name: "className",+ type: "string",+ default: "—",+ description:+ "Classes for the text block — width, font family, `uppercase`.",+ },+ ]}+/>diff --git a/content/docs/captions/components/caption-slot.mdx b/content/docs/captions/components/caption-slot.mdxnew file mode 100644index 00000000..c309b948--- /dev/null+++ b/content/docs/captions/components/caption-slot.mdx@@ -0,0 +1,117 @@+---+title: Slot+description: One short line at a time, each new phrase rolling up into place as the previous one rolls out the top+component: caption-slot+vibe: playful+length: transcript-driven+useWhen:+ - "Fast talking-head or social video where the caption should keep moving with the speaker without words animating individually."+ - "Space is tight — the caption is always exactly one line tall, so it never grows into the subject or the platform UI."+avoidWhen:+ - "The viewer should see which word is being spoken — use `caption-karaoke` or `caption-active-pop`."+ - "Long, calm sentences that need to stay readable as a whole — use `caption-subtitle`."+ - "There is no voiceover and the phrases are scripted — use `word-stream`."+---++<ComponentPreview name="caption-slot" />++<InstallBlock name="caption-slot" />++## Usage++`CaptionSlot` moves at the page level, not the word level. The caption sits in+a window exactly one line tall: when the next phrase starts, it rolls up into+the window while the previous phrase rolls out the top, like a slot-machine+reel. After a silence the line rolls out upward on its own and the next one+rolls in from below.++The line never wraps, so keep pages short. The default+`combineTokensWithinMilliseconds` of 800 gives three or four words per page;+raise it only if your font and frame still fit the longest phrase on one line.++The component renders only the text block. See [Positioning](/docs/captions/getting-started/positioning)+for safe placements and [Get a transcript](/docs/captions/getting-started/get-a-transcript)+for producing `captions.json`.++```tsx+import { AbsoluteFill } from "remotion";+import { CaptionSlot } from "@/components/remocn/caption-slot";+import captions from "./captions.json";++export const MyScene = () => (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: 108,+ paddingInline: 192,+ }}+ >+ <CaptionSlot captions={captions} />+ </AbsoluteFill>+);+```++<PropsTable title="Props"+ rows={[+ {+ name: "captions",+ type: "Caption[]",+ default: "—",+ description:+ "The timed transcript, in the `Caption` shape from `@remotion/captions`. Times are relative to the start of the surrounding `Sequence`.",+ },+ {+ name: "combineTokensWithinMilliseconds",+ type: "number",+ default: "800",+ description:+ "How much speech one page may span. Kept low so every page fits on a single line. Pages also break at the end of a sentence and on any pause of at least `holdMs` (300 ms minimum).",+ },+ {+ name: "holdMs",+ type: "number",+ default: "600",+ description:+ "How long a line stays after its last word when the next one is not already due. It rolls out upward at the end of the hold.",+ },+ {+ name: "fontSize",+ type: "number",+ default: "64",+ description: "Font size in pixels.",+ },+ {+ name: "fontWeight",+ type: "number",+ default: "800",+ description: "Font weight. The font itself is inherited.",+ },+ {+ name: "color",+ type: "string",+ default: "\"#ffffff\"",+ description: "Text colour.",+ },+ {+ name: "activeColor",+ type: "string",+ default: "—",+ description:+ "Optional tint for the word being spoken. Leave it unset for a single-colour line.",+ },+ {+ name: "shadow",+ type: "boolean",+ default: "true",+ description:+ "A tight text shadow that keeps the caption legible over bright footage.",+ },+ {+ name: "className",+ type: "string",+ default: "—",+ description: "Classes for the text block — font family, `uppercase`.",+ },+ ]}+/>diff --git a/content/docs/captions/components/caption-speaker.mdx b/content/docs/captions/components/caption-speaker.mdxnew file mode 100644index 00000000..70d051d2--- /dev/null+++ b/content/docs/captions/components/caption-speaker.mdx@@ -0,0 +1,134 @@+---+title: Speaker+description: Dialogue captions where every phrase takes its speaker's colour, so a conversation reads like a script+component: caption-speaker+vibe: social+length: transcript-driven+useWhen:+ - "An interview, podcast clip or two-person demo where the viewer has to know who is talking without seeing their mouth."+ - "Your transcript already has speaker labels from diarization and you want them to carry through to the screen."+avoidWhen:+ - "Only one person speaks — use `caption-karaoke`, which spends the colour on the voice's progress instead."+ - "You want plain, neutral subtitles for an explainer — use `caption-subtitle`."+ - "There is no voiceover and the text is scripted — use `word-stream`."+---++<ComponentPreview name="caption-speaker" />++<InstallBlock name="caption-speaker" />++## Usage++`CaptionSpeaker` reads the same `Caption[]` as every caption style, with one+extra optional field per word, `speaker`. A page never mixes two speakers: a+change of speaker always starts a new page, which then renders in that+speaker's colour. Words the voice has not reached yet sit dimmed and come up to+full strength as they are said.++Colours are assigned automatically in the order speakers first appear. Pin them+with `speakerColors` so the same person keeps the same colour across videos.+Words with no `speaker` use `color`. The component renders only the text block,+so place it inside your own `AbsoluteFill` — see+[Positioning](/docs/captions/getting-started/positioning).++```tsx+import { AbsoluteFill } from "remotion";+import { CaptionSpeaker } from "@/components/remocn/caption-speaker";+import captions from "./captions.json";++export const MyScene = () => (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: 108,+ paddingInline: 192,+ }}+ >+ <CaptionSpeaker+ captions={captions}+ speakerColors={{ host: "#facc15", guest: "#38bdf8" }}+ />+ </AbsoluteFill>+);+```++Speaker labels come from diarization in your speech-to-text service. ElevenLabs+Speech-to-Text with diarization turned on labels every word with a+`speaker_id`. Convert the response with the recipe in+[Get a transcript](/docs/captions/getting-started/get-a-transcript), then add+each word's label to the caption that starts at the same time, as `speaker`.+Any label works — `"host"`, `"speaker_0"`, a name — as long as it stays the+same for the same person.++<PropsTable title="Props"+ rows={[+ {+ name: "captions",+ type: "(Caption & { speaker?: string })[]",+ default: "—",+ description:+ "The timed transcript, in the `Caption` shape from `@remotion/captions`, with an optional `speaker` label per word. Times are relative to the start of the surrounding `Sequence`.",+ },+ {+ name: "speakerColors",+ type: "Record<string, string>",+ default: "—",+ description:+ "Colour per speaker label. Speakers left out get the next colour of the built-in palette, in order of first appearance.",+ },+ {+ name: "upcomingOpacity",+ type: "number",+ default: "0.4",+ description:+ "Opacity of words the voice has not reached yet. Each word comes up to full strength over 100ms as it is spoken.",+ },+ {+ name: "combineTokensWithinMilliseconds",+ type: "number",+ default: "1200",+ description:+ "How much speech one page may span before the next word starts a new page. Pages also break at the end of a sentence, on a change of speaker and on any pause of at least `holdMs` (300 ms minimum).",+ },+ {+ name: "holdMs",+ type: "number",+ default: "600",+ description:+ "How long a page stays after its last word when the next page is not already due. It fades out at the end of the hold.",+ },+ {+ name: "fontSize",+ type: "number",+ default: "64",+ description: "Font size in pixels.",+ },+ {+ name: "fontWeight",+ type: "number",+ default: "800",+ description: "Font weight. The font itself is inherited.",+ },+ {+ name: "color",+ type: "string",+ default: "\"#ffffff\"",+ description: "Colour of words that carry no `speaker` label.",+ },+ {+ name: "shadow",+ type: "boolean",+ default: "true",+ description:+ "A tight text shadow that keeps the caption legible over bright footage.",+ },+ {+ name: "className",+ type: "string",+ default: "—",+ description:+ "Classes for the text block — width, font family, `uppercase`.",+ },+ ]}+/>diff --git a/content/docs/captions/components/caption-split-flap.mdx b/content/docs/captions/components/caption-split-flap.mdxnew file mode 100644index 00000000..12aa34c4--- /dev/null+++ b/content/docs/captions/components/caption-split-flap.mdx@@ -0,0 +1,111 @@+---+title: Split Flap+description: Every letter sits on its own flap tile and clatters through a few characters before landing the moment the word is spoken, like a station departure board+component: caption-split-flap+vibe: tech+length: transcript-driven+useWhen:+ - "A launch, travel or tech video wants a mechanical, announcement-board feel — each word arrives as tiles flipping into place on cue."+ - "The phrase should be readable as a board from the start — blank tiles hold the place of every upcoming word, so the layout never moves."+avoidWhen:+ - "You want letters to decode in place without tiles or a board look — use `caption-scramble`."+ - "The captions sit over a busy talking head for a long video and should stay quiet — use `caption-subtitle`."+ - "The text is scripted on-screen copy with no voiceover — use `typewriter` or `word-stream`."+---++<ComponentPreview name="caption-split-flap" />++<InstallBlock name="caption-split-flap" />++## Usage++`CaptionSplitFlap` takes a timed transcript and renders only the text block, so+place it inside your own `AbsoluteFill`. The page appears as a row of blank+tiles, one per letter. When a word is spoken, its tiles fold through a few+random characters from left to right and settle on the real letters. Spaces stay+gaps, not tiles, and long pages wrap only between words. The tiles are the+legibility treatment, so there is no shadow to toggle. See+[Positioning](/docs/captions/getting-started/positioning) for safe placements+and [Get a transcript](/docs/captions/getting-started/get-a-transcript) for+producing `captions.json`.++```tsx+import { AbsoluteFill } from "remotion";+import { CaptionSplitFlap } from "@/components/remocn/caption-split-flap";+import captions from "./captions.json";++export const MyScene = () => (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: 108,+ paddingInline: 154,+ }}+ >+ <CaptionSplitFlap captions={captions} />+ </AbsoluteFill>+);+```++Tiles are a fixed width, so a board row grows with the letter count. The default+page window is shorter than other styles to keep a page on one row; lower+`fontSize` or `combineTokensWithinMilliseconds` if your pages wrap.++<PropsTable title="Props"+ rows={[+ {+ name: "captions",+ type: "Caption[]",+ default: "—",+ description:+ "The timed transcript, in the `Caption` shape from `@remotion/captions`. Times are relative to the start of the surrounding `Sequence`.",+ },+ {+ name: "tileColor",+ type: "string",+ default: "\"#111111\"",+ description: "Colour of the flap tiles behind every letter.",+ },+ {+ name: "combineTokensWithinMilliseconds",+ type: "number",+ default: "1000",+ description:+ "How much speech one page may span before the next word starts a new page. Pages also break at the end of a sentence and on any pause of at least `holdMs` (300 ms minimum).",+ },+ {+ name: "holdMs",+ type: "number",+ default: "600",+ description:+ "How long a page stays after its last word when the next page is not already due. It fades out at the end of the hold instead of hanging through the pause.",+ },+ {+ name: "fontSize",+ type: "number",+ default: "56",+ description:+ "Font size in pixels. Tiles are sized from it, so it sets the size of the whole board.",+ },+ {+ name: "fontWeight",+ type: "number",+ default: "800",+ description: "Font weight. The font itself is inherited.",+ },+ {+ name: "color",+ type: "string",+ default: "\"#ffffff\"",+ description: "Colour of the letters on the tiles.",+ },+ {+ name: "className",+ type: "string",+ default: "—",+ description:+ "Classes for the text block — width, font family, `uppercase`.",+ },+ ]}+/>diff --git a/content/docs/captions/components/caption-stack.mdx b/content/docs/captions/components/caption-stack.mdxnew file mode 100644index 00000000..ad5717f6--- /dev/null+++ b/content/docs/captions/components/caption-stack.mdx@@ -0,0 +1,132 @@+---+title: Stack+description: Kinetic captions stacked a couple of words per line, with the keyword of each page set large on its own line+component: caption-stack+vibe: playful+length: transcript-driven+useWhen:+ - "Short-form video where the captions are part of the design — each page reads as a small typographic poster, and the word that matters is the biggest thing on it."+ - "You know which words carry the message and want them to land harder than the rest — pass them as `keywords` and each one takes a line of its own."+avoidWhen:+ - "The voice should be followed one word at a time in the middle of the frame — use `caption-word-pop`."+ - "Captions must sit quietly in the bottom third and never grow taller than a line or two — use `caption-subtitle`."+ - "Every word should arrive the same way with no hierarchy — use `caption-bounce-in`, which builds a single line in place."+---++<ComponentPreview name="caption-stack" />++<InstallBlock name="caption-stack" />++## Usage++`CaptionStack` takes a timed transcript and renders only the text block, so+place it inside your own `AbsoluteFill`. Each page is laid out once as centered+lines of about two words, and every word rises into its slot at the moment it+is spoken. A word listed in `keywords` breaks out onto its own line at+`emphasisScale` times the font size. Without `keywords`, the longest word on+each page takes that role. See [Positioning](/docs/captions/getting-started/positioning)+for safe placements and [Get a transcript](/docs/captions/getting-started/get-a-transcript)+for producing `captions.json`.++```tsx+import { AbsoluteFill } from "remotion";+import { CaptionStack } from "@/components/remocn/caption-stack";+import captions from "./captions.json";++export const MyScene = () => (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: 108,+ paddingInline: 192,+ }}+ >+ <CaptionStack+ captions={captions}+ keywords={["thing", "lose", "three", "captions", "sound"]}+ />+ </AbsoluteFill>+);+```++Keywords match whole words, ignoring case and punctuation, so `"sound"` also+catches `Sound,` and `sound.` in the transcript.++<PropsTable title="Props"+ rows={[+ {+ name: "captions",+ type: "Caption[]",+ default: "—",+ description:+ "The timed transcript, in the `Caption` shape from `@remotion/captions`. Times are relative to the start of the surrounding `Sequence`.",+ },+ {+ name: "keywords",+ type: "string[]",+ default: "—",+ description:+ "Words that get their own enlarged line. Matched per word, ignoring case and punctuation. When omitted, the longest word on each page is emphasised instead.",+ },+ {+ name: "emphasisScale",+ type: "number",+ default: "1.7",+ description:+ "Font size of an emphasised line relative to `fontSize`. It is a real font size, so the stack is laid out once and never reflows.",+ },+ {+ name: "emphasisColor",+ type: "string",+ default: "\"#facc15\"",+ description: "Colour of the emphasised word.",+ },+ {+ name: "combineTokensWithinMilliseconds",+ type: "number",+ default: "1600",+ description:+ "How much speech one page may span before the next word starts a new page. Pages also break at the end of a sentence and on any pause of at least `holdMs` (300 ms minimum).",+ },+ {+ name: "holdMs",+ type: "number",+ default: "600",+ description:+ "How long a page stays after its last word when the next page is not already due. It fades out at the end of the hold instead of hanging through the pause.",+ },+ {+ name: "fontSize",+ type: "number",+ default: "64",+ description: "Font size of the regular lines in pixels.",+ },+ {+ name: "fontWeight",+ type: "number",+ default: "800",+ description: "Font weight. The font itself is inherited.",+ },+ {+ name: "color",+ type: "string",+ default: "\"#ffffff\"",+ description: "Colour of the regular words.",+ },+ {+ name: "shadow",+ type: "boolean",+ default: "true",+ description:+ "A tight text shadow that keeps the caption legible over bright footage.",+ },+ {+ name: "className",+ type: "string",+ default: "—",+ description:+ "Classes for the text block — width, font family, `uppercase`.",+ },+ ]}+/>diff --git a/content/docs/captions/components/caption-stamp.mdx b/content/docs/captions/components/caption-stamp.mdxnew file mode 100644index 00000000..7ecf00f4--- /dev/null+++ b/content/docs/captions/components/caption-stamp.mdx@@ -0,0 +1,135 @@+---+title: Stamp+description: Plain captions where the words that matter slam down as a rubber stamp the moment they are spoken+component: caption-stamp+vibe: playful+length: transcript-driven+useWhen:+ - "A punchy explainer or reaction video where one word per phrase should land with impact — the stamp hits on exactly that word, in time with the voice."+ - "You want a hand-made, printed accent on top of an ordinary readable caption line, with no keyword list needed to get started."+avoidWhen:+ - "The emphasis should feel drawn rather than struck — use `caption-marker`, which swipes a highlighter behind the keyword."+ - "Every word should get the accent as it is spoken, not one per phrase — use `caption-active-pop`."+ - "The keyword should grow out of the layout instead of landing on top of it — use `caption-stack`."+---++<ComponentPreview name="caption-stamp" />++<InstallBlock name="caption-stamp" />++## Usage++`CaptionStamp` takes a timed transcript and renders only the text block, so+place it inside your own `AbsoluteFill`. Words read as a plain caption line+until a keyword is spoken. Then the word slams down in `stampColor` inside a+thin stamp frame, dropping from almost twice its size in under a tenth of a+second, settling at its own slight angle and leaving a rough, speckled ink+print. Without `keywords`, the longest word on each page is stamped, so the+style works on a raw transcript. See+[Positioning](/docs/captions/getting-started/positioning) for safe placements+and [Get a transcript](/docs/captions/getting-started/get-a-transcript) for+producing `captions.json`.++```tsx+import { AbsoluteFill } from "remotion";+import { CaptionStamp } from "@/components/remocn/caption-stamp";+import captions from "./captions.json";++export const MyScene = () => (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: 108,+ paddingInline: 192,+ }}+ >+ <CaptionStamp+ captions={captions}+ keywords={["thing", "lose", "three", "captions", "sound"]}+ />+ </AbsoluteFill>+);+```++Keywords match whole words, ignoring case and punctuation. The stamp frame sits+over the word without taking up extra room, so the line never shifts when it+lands.++<PropsTable title="Props"+ rows={[+ {+ name: "captions",+ type: "Caption[]",+ default: "—",+ description:+ "The timed transcript, in the `Caption` shape from `@remotion/captions`. Times are relative to the start of the surrounding `Sequence`.",+ },+ {+ name: "keywords",+ type: "string[]",+ default: "—",+ description:+ "Words that get stamped. Matched per word, ignoring case and punctuation. When omitted, the longest word on each page is stamped.",+ },+ {+ name: "stampColor",+ type: "string",+ default: "\"#ef4444\"",+ description: "Ink colour of the stamped word and its frame.",+ },+ {+ name: "texture",+ type: "boolean",+ default: "true",+ description:+ "Roughens the stamp edges and knocks small speckles out of the ink, like a real rubber stamp.",+ },+ {+ name: "combineTokensWithinMilliseconds",+ type: "number",+ default: "1200",+ description:+ "How much speech one page may span before the next word starts a new page. Pages also break at the end of a sentence and on any pause of at least `holdMs` (300 ms minimum).",+ },+ {+ name: "holdMs",+ type: "number",+ default: "600",+ description:+ "How long a page stays after its last word when the next page is not already due. It fades out at the end of the hold instead of hanging through the pause.",+ },+ {+ name: "fontSize",+ type: "number",+ default: "64",+ description: "Font size in pixels.",+ },+ {+ name: "fontWeight",+ type: "number",+ default: "800",+ description: "Font weight. The font itself is inherited.",+ },+ {+ name: "color",+ type: "string",+ default: "\"#ffffff\"",+ description: "Colour of the words that are not stamped.",+ },+ {+ name: "shadow",+ type: "boolean",+ default: "true",+ description:+ "A tight text shadow that keeps the plain words legible over bright footage.",+ },+ {+ name: "className",+ type: "string",+ default: "—",+ description:+ "Classes for the text block — width, font family, `uppercase`.",+ },+ ]}+/>diff --git a/content/docs/captions/components/caption-subtitle.mdx b/content/docs/captions/components/caption-subtitle.mdxnew file mode 100644index 00000000..d6d48ad9--- /dev/null+++ b/content/docs/captions/components/caption-subtitle.mdx@@ -0,0 +1,123 @@+---+title: Subtitle+description: Classic broadcast subtitles, a whole phrase on a translucent plate, with no word-level animation at all+component: caption-subtitle+vibe: clean+length: transcript-driven+useWhen:+ - "Explainers, interviews and talking heads where the captions should be read, not watched — the accessibility-first option."+ - "Long sentences and dense information, where a full phrase on screen reads faster than words arriving one at a time."+avoidWhen:+ - "Short-form social video that needs the caption to carry energy — use `caption-karaoke` or `caption-active-pop`."+ - "One short line at a time that keeps moving with the speaker — use `caption-slot`."+ - "On-screen copy with no voiceover — use `word-stream`."+---++<ComponentPreview name="caption-subtitle" />++<InstallBlock name="caption-subtitle" />++## Usage++`CaptionSubtitle` is the subtitle you know from broadcast and streaming: a+whole phrase at a time, balanced across its lines, sitting on a tight+translucent plate that follows each line rather than one big box. Nothing+animates inside a phrase. A new phrase replaces the previous one on a hard+cut, and only fades in or out around silences.++Keep subtitles to two lines. The component wraps and balances its lines but+does not limit them, so give the block a width that fits two lines of your+longest phrase, or lower `combineTokensWithinMilliseconds` for shorter phrases.++The component renders only the text block. See [Positioning](/docs/captions/getting-started/positioning)+for safe placements and [Get a transcript](/docs/captions/getting-started/get-a-transcript)+for producing `captions.json`.++```tsx+import { AbsoluteFill } from "remotion";+import { CaptionSubtitle } from "@/components/remocn/caption-subtitle";+import captions from "./captions.json";++export const MyScene = () => (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: 108,+ paddingInline: 384,+ }}+ >+ <CaptionSubtitle captions={captions} />+ </AbsoluteFill>+);+```++<PropsTable title="Props"+ rows={[+ {+ name: "captions",+ type: "Caption[]",+ default: "—",+ description:+ "The timed transcript, in the `Caption` shape from `@remotion/captions`. Times are relative to the start of the surrounding `Sequence`.",+ },+ {+ name: "combineTokensWithinMilliseconds",+ type: "number",+ default: "2500",+ description:+ "How much speech one subtitle may span. Sized for a full phrase. Subtitles also break at the end of a sentence and on any pause of at least `holdMs` (300 ms minimum).",+ },+ {+ name: "holdMs",+ type: "number",+ default: "600",+ description:+ "How long a subtitle stays after its last word when the next one is not already due. It fades out at the end of the hold.",+ },+ {+ name: "fontSize",+ type: "number",+ default: "44",+ description: "Font size in pixels.",+ },+ {+ name: "fontWeight",+ type: "number",+ default: "600",+ description: "Font weight. The font itself is inherited.",+ },+ {+ name: "color",+ type: "string",+ default: "\"#ffffff\"",+ description: "Text colour.",+ },+ {+ name: "box",+ type: "boolean",+ default: "true",+ description:+ "Draw a translucent plate behind each line. When off, a text shadow keeps the subtitle legible instead.",+ },+ {+ name: "boxColor",+ type: "string",+ default: "\"#000000\"",+ description: "Colour of the plate.",+ },+ {+ name: "boxOpacity",+ type: "number",+ default: "0.72",+ description: "Opacity of the plate, from 0 to 1.",+ },+ {+ name: "className",+ type: "string",+ default: "—",+ description:+ "Classes for the text block — width, font family.",+ },+ ]}+/>diff --git a/content/docs/captions/components/caption-teleprompter.mdx b/content/docs/captions/components/caption-teleprompter.mdxnew file mode 100644index 00000000..5bfd55ff--- /dev/null+++ b/content/docs/captions/components/caption-teleprompter.mdx@@ -0,0 +1,136 @@+---+title: Teleprompter+description: The whole transcript scrolls smoothly through a short window with the current line centred, past lines fading above and the next line waiting below+component: caption-teleprompter+vibe: clean+length: transcript-driven+useWhen:+ - "The speech is long and continuous — an explainer, a talk, a narrated walkthrough — and the viewer benefits from seeing the line before and the line after."+ - "You want calm, reading-first captions that never cut or pop, only glide from one line to the next."+avoidWhen:+ - "You want one phrase at a time that replaces the last — use `caption-subtitle` for broadcast-style pages or `caption-slot` for a one-line roll."+ - "The captions should feel energetic and social — use `caption-karaoke` or `caption-highlight-box`."+ - "There is no voiceover and the text is scripted — use `word-stream`."+---++<ComponentPreview name="caption-teleprompter" />++<InstallBlock name="caption-teleprompter" />++## Usage++`CaptionTeleprompter` turns the transcript into lines — the same paging every+caption style uses, with `combineTokensWithinMilliseconds` setting how much+speech one line holds — and stacks all of them in a window `visibleLines` tall.+As each line starts, the stack glides so that line sits in the middle of the+window. Inside the current line, words the voice has not reached yet are+dimmed to `upcomingOpacity`; the lines above and below rest at `pastOpacity`+and `futureOpacity`, and the window fades out at its top and bottom edges.++Nothing ever leaves the screen: the teleprompter stays for the whole+transcript, so `holdMs` only decides how long a silence must be to start a new+line. The window takes the width you give it and wraps long lines, so place it+inside a container with the width you want — see+[Positioning](/docs/captions/getting-started/positioning) and+[Get a transcript](/docs/captions/getting-started/get-a-transcript).++```tsx+import { AbsoluteFill } from "remotion";+import { CaptionTeleprompter } from "@/components/remocn/caption-teleprompter";+import captions from "./captions.json";++export const MyScene = () => (+ <AbsoluteFill+ style={{+ justifyContent: "center",+ alignItems: "stretch",+ paddingInline: 192,+ }}+ >+ <CaptionTeleprompter captions={captions} />+ </AbsoluteFill>+);+```++<PropsTable title="Props"+ rows={[+ {+ name: "captions",+ type: "Caption[]",+ default: "—",+ description:+ "The timed transcript, in the `Caption` shape from `@remotion/captions`. Times are relative to the start of the surrounding `Sequence`.",+ },+ {+ name: "visibleLines",+ type: "number",+ default: "3",+ description:+ "Height of the window, in lines. The current line always sits in the middle.",+ },+ {+ name: "pastOpacity",+ type: "number",+ default: "0.35",+ description: "Opacity of lines that have already been spoken.",+ },+ {+ name: "futureOpacity",+ type: "number",+ default: "0.35",+ description: "Opacity of lines still to come.",+ },+ {+ name: "upcomingOpacity",+ type: "number",+ default: "0.55",+ description:+ "Opacity of words in the current line that the voice has not reached yet.",+ },+ {+ name: "combineTokensWithinMilliseconds",+ type: "number",+ default: "1500",+ description:+ "How much speech one line may span before the next word starts a new line. Lines also break at the end of a sentence and on any pause of at least `holdMs` (300 ms minimum).",+ },+ {+ name: "holdMs",+ type: "number",+ default: "600",+ description:+ "The pause length that starts a new line. Lines never fade out — the teleprompter stays on screen for the whole transcript.",+ },+ {+ name: "fontSize",+ type: "number",+ default: "64",+ description: "Font size in pixels.",+ },+ {+ name: "fontWeight",+ type: "number",+ default: "800",+ description: "Font weight. The font itself is inherited.",+ },+ {+ name: "color",+ type: "string",+ default: "\"#ffffff\"",+ description: "Text colour.",+ },+ {+ name: "shadow",+ type: "boolean",+ default: "true",+ description:+ "A tight text shadow that keeps the caption legible over bright footage.",+ },+ {+ name: "className",+ type: "string",+ default: "—",+ description: "Classes for the window — width, font family, `uppercase`.",+ },+ ]}+/>diff --git a/content/docs/captions/components/caption-timeline.mdx b/content/docs/captions/components/caption-timeline.mdxnew file mode 100644index 00000000..1a9dc018--- /dev/null+++ b/content/docs/captions/components/caption-timeline.mdx@@ -0,0 +1,139 @@+---+title: Timeline+description: The whole transcript laid out on a scrolling time strip that slides under a fixed playhead, so every pause shows up as space between words+component: caption-timeline+vibe: tech+length: transcript-driven+useWhen:+ - "The video is about audio, editing or timing — a podcast clip, a voice tool, a recording workflow — and the captions should look like a track being played back."+ - "You want the viewer to see the rhythm of the speech, with pauses as gaps and upcoming words visible ahead of the playhead."+avoidWhen:+ - "The captions need to be read comfortably for a long time — a moving strip is harder to follow; use `caption-subtitle` or `caption-teleprompter`."+ - "You want one short phrase at a time rather than a continuous strip — use `caption-karaoke` or `caption-slot`."+ - "There is no voiceover and the text is scripted — use `word-stream`."+---++<ComponentPreview name="caption-timeline" />++<InstallBlock name="caption-timeline" />++## Usage++`CaptionTimeline` places every word of the transcript on a horizontal strip at+a position proportional to when it is spoken, `pxPerSecond` apart, and scrolls+the strip so the current moment sits under a fixed playhead. A pause in the+speech becomes empty space on the strip; when words come faster than the strip+can fit them, they are pushed apart so they never overlap. Words ahead of the+playhead are dimmed to `upcomingOpacity` and light up as the playhead reaches+them, and both ends of the strip fade out.++The strip is not paged, so `combineTokensWithinMilliseconds` and `holdMs` have+no effect, and it stays on screen for the whole transcript. Give it a fixed+`width` in composition pixels and place it yourself — see+[Positioning](/docs/captions/getting-started/positioning) and+[Get a transcript](/docs/captions/getting-started/get-a-transcript).++```tsx+import { AbsoluteFill } from "remotion";+import { CaptionTimeline } from "@/components/remocn/caption-timeline";+import captions from "./captions.json";++export const MyScene = () => (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: 108,+ }}+ >+ <CaptionTimeline captions={captions} width={1600} />+ </AbsoluteFill>+);+```++<PropsTable title="Props"+ rows={[+ {+ name: "captions",+ type: "Caption[]",+ default: "—",+ description:+ "The timed transcript, in the `Caption` shape from `@remotion/captions`. Times are relative to the start of the surrounding `Sequence`.",+ },+ {+ name: "width",+ type: "number",+ default: "1100",+ description: "Width of the visible strip in composition pixels.",+ },+ {+ name: "pxPerSecond",+ type: "number",+ default: "260",+ description:+ "How far apart one second of speech is on the strip — also the scroll speed during pauses.",+ },+ {+ name: "playheadPosition",+ type: "number",+ default: "0.35",+ description:+ "Where the playhead sits across the strip, from 0 (left edge) to 1 (right edge).",+ },+ {+ name: "playheadColor",+ type: "string",+ default: "\"#facc15\"",+ description: "Colour of the playhead line.",+ },+ {+ name: "upcomingOpacity",+ type: "number",+ default: "0.4",+ description: "Opacity of words the playhead has not reached yet.",+ },+ {+ name: "fontSize",+ type: "number",+ default: "64",+ description: "Font size in pixels.",+ },+ {+ name: "fontWeight",+ type: "number",+ default: "800",+ description: "Font weight. The font itself is inherited.",+ },+ {+ name: "color",+ type: "string",+ default: "\"#ffffff\"",+ description: "Text colour.",+ },+ {+ name: "shadow",+ type: "boolean",+ default: "true",+ description:+ "A tight text shadow that keeps the caption legible over bright footage.",+ },+ {+ name: "combineTokensWithinMilliseconds",+ type: "number",+ default: "—",+ description: "Accepted for API parity with other caption styles; unused, since the strip is not paged.",+ },+ {+ name: "holdMs",+ type: "number",+ default: "—",+ description: "Accepted for API parity with other caption styles; unused, since the strip never leaves the screen.",+ },+ {+ name: "className",+ type: "string",+ default: "—",+ description: "Classes for the strip — font family, `uppercase`.",+ },+ ]}+/>diff --git a/content/docs/captions/components/caption-typewriter.mdx b/content/docs/captions/components/caption-typewriter.mdxnew file mode 100644index 00000000..f50dd022--- /dev/null+++ b/content/docs/captions/components/caption-typewriter.mdx@@ -0,0 +1,115 @@+---+title: Typewriter+description: Each word types out character by character at the pace it is spoken, with a caret that blinks while the speaker pauses+component: caption-typewriter+vibe: tech+length: transcript-driven+useWhen:+ - "A voiceover walks through a terminal, an editor or a technical product, and the captions should feel typed rather than printed."+ - "The delivery has deliberate pauses you want the viewer to feel — the caret blinks in the gaps and starts typing again with the next word."+avoidWhen:+ - "The text is scripted on-screen copy with no recording behind it — use `typewriter`, which types on its own clock."+ - "The viewer should be able to read ahead of the voice — use `caption-karaoke`, which shows the whole phrase and fills it as it is spoken."+ - "The video needs calm, broadcast-style subtitles — use `caption-subtitle`."+---++<ComponentPreview name="caption-typewriter" />++<InstallBlock name="caption-typewriter" />++## Usage++`CaptionTypewriter` types each word out while it is being said: the characters+of a word are spread across that word's duration, so a drawn-out word types+slowly and a quick one snaps in. Characters that have not been typed yet still+hold their space, so the line never shifts as it builds. The caret sits after+the last typed character, steady while a word is being typed and blinking+through pauses and holds.++The component renders only the text block. See [Positioning](/docs/captions/getting-started/positioning)+for safe placements and [Get a transcript](/docs/captions/getting-started/get-a-transcript)+for producing `captions.json`.++```tsx+import { AbsoluteFill } from "remotion";+import { CaptionTypewriter } from "@/components/remocn/caption-typewriter";+import captions from "./captions.json";++export const MyScene = () => (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: 108,+ paddingInline: 192,+ }}+ >+ <CaptionTypewriter captions={captions} className="font-mono" />+ </AbsoluteFill>+);+```++<PropsTable title="Props"+ rows={[+ {+ name: "captions",+ type: "Caption[]",+ default: "—",+ description:+ "The timed transcript, in the `Caption` shape from `@remotion/captions`. Times are relative to the start of the surrounding `Sequence`.",+ },+ {+ name: "combineTokensWithinMilliseconds",+ type: "number",+ default: "1200",+ description:+ "How much speech one page may span before the next word starts a new page. Pages also break at the end of a sentence and on any pause of at least `holdMs` (300 ms minimum).",+ },+ {+ name: "holdMs",+ type: "number",+ default: "600",+ description:+ "How long a page stays after its last word when the next page is not already due. The caret keeps blinking through the hold, then the page fades out.",+ },+ {+ name: "fontSize",+ type: "number",+ default: "64",+ description: "Font size in pixels.",+ },+ {+ name: "fontWeight",+ type: "number",+ default: "800",+ description: "Font weight. The font itself is inherited.",+ },+ {+ name: "color",+ type: "string",+ default: "\"#ffffff\"",+ description: "Colour of the typed text and the caret.",+ },+ {+ name: "caret",+ type: "boolean",+ default: "true",+ description:+ "Show a caret after the last typed character — steady while typing, blinking while the speaker pauses.",+ },+ {+ name: "shadow",+ type: "boolean",+ default: "true",+ description:+ "A tight text shadow that keeps the caption legible over bright footage.",+ },+ {+ name: "className",+ type: "string",+ default: "—",+ description:+ "Classes for the text block — width, font family, `uppercase`.",+ },+ ]}+/>diff --git a/content/docs/captions/components/caption-underline.mdx b/content/docs/captions/components/caption-underline.mdxnew file mode 100644index 00000000..14d5bb0c--- /dev/null+++ b/content/docs/captions/components/caption-underline.mdx@@ -0,0 +1,123 @@+---+title: Underline+description: A bar slides under the word being spoken, travelling from word to word while the text itself stays untouched+component: caption-underline+vibe: clean+length: transcript-driven+useWhen:+ - "You want to show where the voice is with the lightest possible mark — the words keep their colour and only a thin bar moves beneath them."+ - "The brand colour should carry the captions without flooding the text, such as a single accent line under otherwise neutral type."+avoidWhen:+ - "You want the active word itself to be loud, on a solid plate that travels with the voice — use `caption-highlight-box`."+ - "You want no moving mark at all, just upcoming words dimmed until they are spoken — use `caption-dim-progress`."+ - "Only chosen keywords should get a mark, drawn on as they are said — use `caption-marker`."+---++<ComponentPreview name="caption-underline" />++<InstallBlock name="caption-underline" />++## Usage++`CaptionUnderline` shows the whole page and keeps a single bar under the word+being spoken. When the voice moves on, the bar slides across to the next word+and stretches or shrinks to its width, so the eye follows one continuous mark+rather than a flicker of separate ones. On the first word of a page the bar+grows in from the left. The component renders only the text block, so place it+inside your own `AbsoluteFill` — see [Positioning](/docs/captions/getting-started/positioning).++```tsx+import { AbsoluteFill } from "remotion";+import { CaptionUnderline } from "@/components/remocn/caption-underline";+import captions from "./captions.json";++export const MyScene = () => (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: 108,+ paddingInline: 192,+ }}+ >+ <CaptionUnderline captions={captions} underlineColor="#facc15" />+ </AbsoluteFill>+);+```++<PropsTable title="Props"+ rows={[+ {+ name: "captions",+ type: "Caption[]",+ default: "—",+ description:+ "The timed transcript, in the `Caption` shape from `@remotion/captions`. Times are relative to the start of the surrounding `Sequence`.",+ },+ {+ name: "combineTokensWithinMilliseconds",+ type: "number",+ default: "1200",+ description:+ "How much speech one page may span before the next word starts a new page. Pages also break at the end of a sentence and on any pause of at least `holdMs` (300 ms minimum).",+ },+ {+ name: "holdMs",+ type: "number",+ default: "600",+ description:+ "How long a page stays after its last word when the next page is not already due. It fades out at the end of the hold.",+ },+ {+ name: "underlineColor",+ type: "string",+ default: "\"#facc15\"",+ description: "Colour of the bar under the active word.",+ },+ {+ name: "thickness",+ type: "number",+ default: "0.08",+ description: "Bar thickness in em, so it scales with the font size.",+ },+ {+ name: "underlineOffset",+ type: "number",+ default: "0.02",+ description:+ "Gap in em between the bottom of the word's line box and the bar. Negative values pull it up toward the baseline.",+ },+ {+ name: "fontSize",+ type: "number",+ default: "64",+ description: "Font size in pixels.",+ },+ {+ name: "fontWeight",+ type: "number",+ default: "800",+ description: "Font weight. The font itself is inherited.",+ },+ {+ name: "color",+ type: "string",+ default: "\"#ffffff\"",+ description: "Text colour. It does not change as words are spoken.",+ },+ {+ name: "shadow",+ type: "boolean",+ default: "true",+ description:+ "A tight text shadow that keeps the caption legible over bright footage.",+ },+ {+ name: "className",+ type: "string",+ default: "—",+ description:+ "Classes for the text block — width, font family, `uppercase`.",+ },+ ]}+/>diff --git a/content/docs/captions/components/caption-weight.mdx b/content/docs/captions/components/caption-weight.mdxnew file mode 100644index 00000000..33f5fc04--- /dev/null+++ b/content/docs/captions/components/caption-weight.mdx@@ -0,0 +1,120 @@+---+title: Weight+description: The word being spoken swells from a light weight to a heavy one and relaxes as the voice moves on, with no layout shift+component: caption-weight+vibe: premium+length: transcript-driven+useWhen:+ - "You want captions that follow the voice with typography alone — no colour change, no box, just the active word gaining weight."+ - "The brand leans on a single variable typeface and a weight shift is the most on-brand emphasis available."+avoidWhen:+ - "You need emphasis that reads at a glance on small vertical screens — use `caption-active-pop`, which adds colour and scale."+ - "The font has only one or two static weights — the ramp will step. Use `caption-karaoke`, which works with any font."+ - "There is no voiceover and the text is scripted — use `word-stream`."+---++<ComponentPreview name="caption-weight" />++<InstallBlock name="caption-weight" />++## Usage++`CaptionWeight` takes a timed transcript and renders only the text block, so+place it inside your own `AbsoluteFill`. See [Positioning](/docs/captions/getting-started/positioning)+for safe placements and [Get a transcript](/docs/captions/getting-started/get-a-transcript)+for producing `captions.json`.++Each word reserves the width of its heaviest weight, so the line never moves+while a word gains weight. The ramp is only as smooth as the weights your font+has: a variable font interpolates every step, a static family snaps to the+nearest loaded weight. With `@remotion/google-fonts`, load the variable+version of the family so every weight in between exists.++```tsx+import { loadVariableFont } from "@remotion/google-fonts/Inter";+import { AbsoluteFill } from "remotion";+import { CaptionWeight } from "@/components/remocn/caption-weight";+import captions from "./captions.json";++const { fontFamily } = loadVariableFont("normal", { subsets: ["latin"] });++export const MyScene = () => (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: 108,+ paddingInline: 192,+ }}+ >+ <div style={{ fontFamily }}>+ <CaptionWeight captions={captions} />+ </div>+ </AbsoluteFill>+);+```++<PropsTable title="Props"+ rows={[+ {+ name: "captions",+ type: "Caption[]",+ default: "—",+ description:+ "The timed transcript, in the `Caption` shape from `@remotion/captions`. Times are relative to the start of the surrounding `Sequence`.",+ },+ {+ name: "combineTokensWithinMilliseconds",+ type: "number",+ default: "1200",+ description:+ "How much speech one page may span before the next word starts a new page. Pages also break at the end of a sentence and on any pause of at least `holdMs` (300 ms minimum).",+ },+ {+ name: "holdMs",+ type: "number",+ default: "600",+ description:+ "How long a page stays after its last word when the next page is not already due. It fades out at the end of the hold.",+ },+ {+ name: "fontSize",+ type: "number",+ default: "64",+ description: "Font size in pixels.",+ },+ {+ name: "fontWeight",+ type: "number",+ default: "400",+ description: "Resting weight of every word that is not being spoken.",+ },+ {+ name: "activeWeight",+ type: "number",+ default: "900",+ description:+ "Weight the spoken word ramps to over about 150ms, then relaxes from when the next word starts.",+ },+ {+ name: "color",+ type: "string",+ default: "\"#ffffff\"",+ description: "Text colour.",+ },+ {+ name: "shadow",+ type: "boolean",+ default: "true",+ description:+ "A tight text shadow that keeps the caption legible over bright footage.",+ },+ {+ name: "className",+ type: "string",+ default: "—",+ description:+ "Classes for the text block — width, font family, `uppercase`.",+ },+ ]}+/>diff --git a/content/docs/captions/components/caption-word-pop.mdx b/content/docs/captions/components/caption-word-pop.mdxnew file mode 100644index 00000000..c5cb9a8a--- /dev/null+++ b/content/docs/captions/components/caption-word-pop.mdx@@ -0,0 +1,107 @@+---+title: Word Pop+description: One large word at a time, each popping in on a spring the moment it is spoken+component: caption-word-pop+vibe: playful+length: transcript-driven+useWhen:+ - "Punchy short-form talking heads where every word should hit — one word fills the centre of the frame and the next replaces it on the beat."+ - "Fast speech where a full phrase would flicker past too quickly to read anyway."+avoidWhen:+ - "The viewer needs to read ahead of the voice — use `caption-karaoke`, which keeps the whole phrase on screen."+ - "Long or reading-heavy content such as explainers and interviews — use `caption-subtitle`."+ - "Punchy scripted words with no recording behind them — use `zoom-words`."+---++<ComponentPreview name="caption-word-pop" />++<InstallBlock name="caption-word-pop" />++## Usage++`CaptionWordPop` puts one word on screen at a time. Each word pops in from+`popScale` on a spring with a small overshoot and is replaced the moment the+next word is spoken. After the last word of a sentence it holds, then fades out+instead of hanging through the pause.++It renders only the text block. One-word captions read best in the middle of the+frame, where the eye already is — see [Positioning](/docs/captions/getting-started/positioning)+for the centred recipe and [Get a transcript](/docs/captions/getting-started/get-a-transcript)+for producing `captions.json`.++```tsx+import { AbsoluteFill } from "remotion";+import { CaptionWordPop } from "@/components/remocn/caption-word-pop";+import captions from "./captions.json";++export const MyScene = () => (+ <AbsoluteFill style={{ justifyContent: "center", alignItems: "center" }}>+ <CaptionWordPop captions={captions} />+ </AbsoluteFill>+);+```++<PropsTable title="Props"+ rows={[+ {+ name: "captions",+ type: "Caption[]",+ default: "—",+ description:+ "The timed transcript, in the `Caption` shape from `@remotion/captions`. Times are relative to the start of the surrounding `Sequence`.",+ },+ {+ name: "combineTokensWithinMilliseconds",+ type: "number",+ default: "0",+ description:+ "How much speech one page may span. At 0 every word is its own page; raise it to pop two or three short words in together.",+ },+ {+ name: "holdMs",+ type: "number",+ default: "600",+ description:+ "How long a word stays after it ends when the next word is not already due. It fades out at the end of the hold instead of hanging through the pause.",+ },+ {+ name: "fontSize",+ type: "number",+ default: "96",+ description: "Font size in pixels.",+ },+ {+ name: "fontWeight",+ type: "number",+ default: "800",+ description: "Font weight. The font itself is inherited.",+ },+ {+ name: "color",+ type: "string",+ default: "\"#ffffff\"",+ description: "Text colour.",+ },+ {+ name: "popScale",+ type: "number",+ default: "0.6",+ description:+ "The scale each word starts from before the spring carries it to full size.",+ },+ {+ name: "shadow",+ type: "boolean",+ default: "true",+ description:+ "A tight text shadow that keeps the caption legible over bright footage.",+ },+ {+ name: "className",+ type: "string",+ default: "—",+ description:+ "Classes for the text block — width, font family, `uppercase`.",+ },+ ]}+/>diff --git a/content/docs/captions/components/meta.json b/content/docs/captions/components/meta.jsonnew file mode 100644index 00000000..a74d83d1--- /dev/null+++ b/content/docs/captions/components/meta.json@@ -0,0 +1,38 @@+{+ "title": "Captions",+ "collapsible": false,+ "pages": [+ "caption-karaoke",+ "caption-highlight-box",+ "caption-active-pop",+ "caption-underline",+ "caption-dim-progress",+ "caption-weight",+ "caption-outline",+ "caption-prosody",+ "caption-word-pop",+ "caption-bounce-in",+ "caption-blur-in",+ "caption-rise",+ "caption-slice",+ "caption-drop",+ "caption-typewriter",+ "caption-handwrite",+ "caption-scramble",+ "caption-split-flap",+ "caption-label-maker",+ "caption-redact",+ "caption-knockout",+ "caption-slot",+ "caption-cube",+ "caption-stack",+ "caption-subtitle",+ "caption-teleprompter",+ "caption-timeline",+ "caption-marker",+ "caption-stamp",+ "caption-emoji",+ "caption-speaker"+ ],+ "icon": "ClosedCaptionIcon"+}diff --git a/content/docs/captions/getting-started/get-a-transcript.mdx b/content/docs/captions/getting-started/get-a-transcript.mdxnew file mode 100644index 00000000..15a00bac--- /dev/null+++ b/content/docs/captions/getting-started/get-a-transcript.mdx@@ -0,0 +1,141 @@+---+title: Get a transcript+description: Turn a voiceover into the timed Caption array every caption component reads+---++Every caption reads `Caption[]` from `@remotion/captions`, one entry per word with its start and end time in milliseconds. Pick whichever speech-to-text source you already use; each recipe below ends with the same array.++Transcription runs once, outside the video. Save the result as JSON next to your composition and render from that file.++## whisper.cpp, locally++Free and offline. `@remotion/install-whisper-cpp` downloads whisper.cpp and a model, then transcribes a 16 kHz WAV file.++```bash+npx remotion add @remotion/install-whisper-cpp+npx remotion ffmpeg -i voiceover.mp4 -ar 16000 voiceover.wav -y+```++```ts+import path from "node:path";+import {+ downloadWhisperModel,+ installWhisperCpp,+ toCaptions,+ transcribe,+} from "@remotion/install-whisper-cpp";++const whisperPath = path.join(process.cwd(), "whisper.cpp");++await installWhisperCpp({ to: whisperPath, version: "1.5.5" });+await downloadWhisperModel({ model: "medium.en", folder: whisperPath });++const whisperCppOutput = await transcribe({+ model: "medium.en",+ whisperPath,+ whisperCppVersion: "1.5.5",+ inputPath: path.join(process.cwd(), "voiceover.wav"),+ tokenLevelTimestamps: true,+});++const { captions } = toCaptions({ whisperCppOutput });+```++## OpenAI Whisper API++Request `verbose_json` with word timestamps, then convert the response.++```bash+npx remotion add @remotion/openai-whisper+```++```ts+import fs from "node:fs";+import OpenAI from "openai";+import { openAiWhisperApiToCaptions } from "@remotion/openai-whisper";++const openai = new OpenAI();++const transcription = await openai.audio.transcriptions.create({+ file: fs.createReadStream("voiceover.mp3"),+ model: "whisper-1",+ response_format: "verbose_json",+ timestamp_granularities: ["word"],+});++const { captions } = openAiWhisperApiToCaptions({ transcription });+```++## ElevenLabs++Pass the JSON returned by ElevenLabs Speech-to-Text, either the API response or a segmented JSON export.++```bash+npx remotion add @remotion/elevenlabs+```++```ts+import fs from "node:fs";+import { elevenLabsTranscriptToCaptions } from "@remotion/elevenlabs";++const transcript = JSON.parse(fs.readFileSync("transcript.json", "utf8"));++const { captions } = elevenLabsTranscriptToCaptions({ transcript });+```++## Existing subtitles++Already have an `.srt` file? Parse it directly.++```ts+import fs from "node:fs";+import { parseSrt } from "@remotion/captions";++const { captions } = parseSrt({+ input: fs.readFileSync("voiceover.srt", "utf8"),+});+```++An `.srt` file times whole lines, not single words, so styles that animate the active word move one line at a time.++## Save and load++Write the array to disk once:++```ts+fs.writeFileSync("src/captions.json", JSON.stringify(captions, null, 2));+```++Then import it where you render:++```tsx+import captions from "./captions.json";+import { CaptionKaraoke } from "@/components/remocn/caption-karaoke";++export const Subtitles = () => <CaptionKaraoke captions={captions} />;+```++For long transcripts, keep the JSON in `public/` and fetch it in `calculateMetadata`, so it stays out of your bundle and sets the duration at the same time.++```tsx+import type { Caption } from "@remotion/captions";+import { type CalculateMetadataFunction, staticFile } from "remotion";++type Props = { captions: Caption[] };++const FPS = 30;+const HOLD_MS = 600;++export const calculateMetadata: CalculateMetadataFunction<Props> = async ({+ props,+}) => {+ const response = await fetch(staticFile("captions.json"));+ const captions: Caption[] = await response.json();+ const last = captions[captions.length - 1];++ return {+ durationInFrames: Math.ceil(((last.endMs + HOLD_MS) / 1000) * FPS),+ props: { ...props, captions },+ };+};+```diff --git a/content/docs/captions/getting-started/introduction.mdx b/content/docs/captions/getting-started/introduction.mdxnew file mode 100644index 00000000..aabf6583--- /dev/null+++ b/content/docs/captions/getting-started/introduction.mdx@@ -0,0 +1,142 @@+---+title: Introduction+description: Subtitles rendered from a timed transcript, word by word, in sync with a real voiceover+---++A caption takes a transcript with a start and end time on every word and turns it into an animated text block that follows the voice. It groups the words into short pages, shows one page at a time, and animates the word being spoken right now.++```tsx+import captions from "./captions.json";+import { CaptionKaraoke } from "@/components/remocn/caption-karaoke";++export const Subtitles = () => <CaptionKaraoke captions={captions} />;+```++## Captions are not typography++[Word Stream](/docs/typography/word-stream), [Typewriter](/docs/typography/typewriter) and [Per-Word Crossfade](/docs/typography/per-word-crossfade) animate text you script yourself, on timing they invent. A caption has no timing of its own: every word lands when the speaker says it, because the transcript says so. That is what `length: transcript-driven` means in the docs metadata.++Reach for typography when the words are on-screen copy. Reach for a caption when the words are someone talking.++## Installation++Install the caption runtime with the Remotion CLI first. It installs the version that matches your `remotion`, which is why the registry items do not pin it.++```bash+npx remotion add @remotion/captions+```++Then add a caption style.++```bash+npx shadcn@latest add @remocn/caption-karaoke+```++## The shared API++Every `caption-*` component accepts the same base props, so switching styles is a one-line change.++<PropsTable title="Base props"+ rows={[+ {+ name: "captions",+ type: "Caption[]",+ default: "—",+ description:+ "Timed words from @remotion/captions, each one { text, startMs, endMs, timestampMs, confidence }.",+ },+ {+ name: "combineTokensWithinMilliseconds",+ type: "number",+ default: "per style",+ description:+ "How much speech one page holds. Higher values put more words on a page. A page also ends at the end of a sentence and on any pause of at least holdMs (300 ms minimum).",+ },+ {+ name: "holdMs",+ type: "number",+ default: "600",+ description:+ "A page leaves this long after its last word ends, or when the next page starts, whichever comes first.",+ },+ {+ name: "fontSize",+ type: "number",+ default: "per style",+ description: "Font size in composition pixels.",+ },+ {+ name: "fontWeight",+ type: "number",+ default: "per style",+ description: "Font weight.",+ },+ {+ name: "color",+ type: "string",+ default: "per style",+ description: "Text color.",+ },+ {+ name: "className",+ type: "string",+ default: "—",+ description: "Classes on the text block.",+ },+ ]}+/>++On top of these, each style adds its own props, such as the color of the active word.++[Get a transcript](/docs/captions/getting-started/get-a-transcript) shows how to produce `captions` from an audio file.++## Composition length++A caption runs as long as the transcript does. Size the composition from the last word with `calculateMetadata`, plus the hold, so the video never cuts the final page short.++```tsx+import { Composition } from "remotion";+import captions from "./captions.json";+import { Subtitles } from "./subtitles";++const FPS = 30;+const HOLD_MS = 600;++export const RemotionRoot = () => (+ <Composition+ id="Subtitles"+ component={Subtitles}+ fps={FPS}+ width={1080}+ height={1920}+ durationInFrames={1}+ calculateMetadata={() => ({+ durationInFrames: Math.ceil(+ ((captions[captions.length - 1].endMs + HOLD_MS) / 1000) * FPS,+ ),+ })}+ />+);+```++## Placement++A caption renders only its text block. It does not position itself in the frame, so you decide where the block sits. [Positioning](/docs/captions/getting-started/positioning) has the safe zones for landscape and vertical video.++## Fonts and casing++A caption inherits its font, so it matches the rest of your video. Load a typeface with `@remotion/google-fonts` and set it on a wrapper, or pass a font class through `className`.++```tsx+import { loadFont } from "@remotion/google-fonts/Montserrat";++const { fontFamily } = loadFont("normal", { weights: ["800"] });++export const Subtitles = () => (+ <div style={{ fontFamily }}>+ <CaptionKaraoke captions={captions} />+ </div>+);+```++Text keeps the casing of the transcript. Add `className="uppercase"` when a style reads better in caps.diff --git a/content/docs/captions/getting-started/meta.json b/content/docs/captions/getting-started/meta.jsonnew file mode 100644index 00000000..1a6138c6--- /dev/null+++ b/content/docs/captions/getting-started/meta.json@@ -0,0 +1,6 @@+{+ "title": "Getting Started",+ "collapsible": false,+ "pages": ["introduction", "get-a-transcript", "positioning"],+ "icon": "Rocket01Icon"+}diff --git a/content/docs/captions/getting-started/positioning.mdx b/content/docs/captions/getting-started/positioning.mdxnew file mode 100644index 00000000..faa305fc--- /dev/null+++ b/content/docs/captions/getting-started/positioning.mdx@@ -0,0 +1,70 @@+---+title: Positioning+description: Where to put the caption block in landscape and vertical video, with safe-zone numbers+---++A caption renders only its text block and never positions itself. Wrap it in an `AbsoluteFill` and place it there, so one caption style works in any frame.++## Keep the block still++Pick one position and keep it for the whole video. Viewers find the caption once and read it from the same place; a block that jumps between pages makes them search for it every time.++## Landscape, 16:9++Use the bottom third, centered, with the block no wider than 80% of the frame. In a 1920×1080 composition, that is 108px off the bottom edge and a maximum width of 1536px.++```tsx+import { AbsoluteFill } from "remotion";++export const Subtitles = () => (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: 108,+ }}+ >+ <div style={{ maxWidth: 1536, textAlign: "center" }}>+ <CaptionKaraoke captions={captions} />+ </div>+ </AbsoluteFill>+);+```++## Vertical, 9:16++TikTok, Reels and Shorts cover the bottom of the frame with the description and account name, and the right edge with the like, comment and share column. Keep the caption above the first and clear of the second.++In a 1080×1920 composition, put the block 540px off the bottom edge (28% of the height) with 160px of padding on both sides, which leaves a 760px-wide column in the middle.++```tsx+import { AbsoluteFill } from "remotion";++export const Subtitles = () => (+ <AbsoluteFill+ style={{+ justifyContent: "flex-end",+ alignItems: "center",+ paddingBottom: 540,+ paddingLeft: 160,+ paddingRight: 160,+ }}+ >+ <div style={{ maxWidth: 760, textAlign: "center" }}>+ <CaptionKaraoke captions={captions} />+ </div>+ </AbsoluteFill>+);+```++## Center++Styles that show one word at a time read best in the middle of the frame, where the eye already is. Center the block on both axes.++```tsx+<AbsoluteFill style={{ justifyContent: "center", alignItems: "center" }}>+ <CaptionKaraoke captions={captions} />+</AbsoluteFill>+```++A centered caption covers the subject, so keep it for talking-head footage where the face sits higher or for videos with no subject behind the text.diff --git a/content/docs/captions/meta.json b/content/docs/captions/meta.jsonnew file mode 100644index 00000000..d1ef9b64--- /dev/null+++ b/content/docs/captions/meta.json@@ -0,0 +1,6 @@+{+ "title": "Captions",+ "collapsible": false,+ "pages": ["getting-started", "components"],+ "icon": "ClosedCaptionIcon"+}diff --git a/content/docs/meta.json b/content/docs/meta.jsonindex 8ecc715a..bfb9bad8 100644--- a/content/docs/meta.json+++ b/content/docs/meta.json@@ -9,6 +9,7 @@"ui","shaders","filters",+ "captions","icons","ui-blocks","ai",diff --git a/content/docs/typography/marker-highlight.mdx b/content/docs/typography/marker-highlight.mdxindex 2b5d093d..da0fe8c6 100644--- a/content/docs/typography/marker-highlight.mdx+++ b/content/docs/typography/marker-highlight.mdx@@ -12,6 +12,7 @@ avoidWhen:- "You want a subtle color-only emphasis with no visible background — use `inline-highlight` for a clean color-shift with no marker block."- "The entire sentence is new text that needs to enter the scene — both highlight components are emphasis tools, not entrances; use `mask-reveal-up` or `per-word-crossfade` for full reveals."- "The scene tone is minimal or premium and a bold painted marker would clash — use `inline-highlight` for a quieter callout."+ - "The emphasis should land the moment a speaker says the word — use `caption-marker`, which swipes keywords from a timed transcript."---<ComponentPreview name="marker-highlight" />diff --git a/content/docs/typography/per-word-crossfade.mdx b/content/docs/typography/per-word-crossfade.mdxindex c460a35e..57a797f1 100644--- a/content/docs/typography/per-word-crossfade.mdx+++ b/content/docs/typography/per-word-crossfade.mdx@@ -12,6 +12,7 @@ avoidWhen:- "The transition should be a single-block fade with no word-level staging — use `fade-through` for a unified opacity swap instead."- "You want the incoming words to build upward or slide in rather than drift-and-fade — use `line-by-line-slide` or `mask-reveal-up` for directional entrances."- "There is no outgoing text (first entrance only) — use `micro-scale-fade` or `per-character-rise` for a standalone reveal without a `fromText`."+ - "The phrases are spoken subtitles timed to audio — use `caption-subtitle` or another caption style, which pages a real transcript."---<ComponentPreview name="per-word-crossfade" />diff --git a/content/docs/typography/typewriter.mdx b/content/docs/typography/typewriter.mdxindex 0189cdc8..0680ae1c 100644--- a/content/docs/typography/typewriter.mdx+++ b/content/docs/typography/typewriter.mdx@@ -12,6 +12,7 @@ avoidWhen:- "The text is long — typing a paragraph at a readable speed eats far more frames than a viewer will wait; use `staggered-fade-up` or `blur-out-up` instead."- "You want a designed, weighted entrance (springy, blurred, kinetic) — typing reads as plain/utilitarian; reach for `tracking-in` or `kinetic-center-build`."- "Multiple lines should reveal together — typing is inherently sequential and single-stream."+ - "The text is a transcript of someone speaking — use `caption-typewriter`, which types each word at the pace it was said."---<ComponentPreview name="typewriter" />diff --git a/content/docs/typography/word-stream.mdx b/content/docs/typography/word-stream.mdxindex df74f3fb..98cd2332 100644--- a/content/docs/typography/word-stream.mdx+++ b/content/docs/typography/word-stream.mdx@@ -12,6 +12,7 @@ avoidWhen:- "There is only one static phrase to reveal — use `per-word-crossfade` for a single calm word-by-word entrance."- "You need a two-state before/after text swap rather than a stream — use `value-swap` or `strikethrough-replace`."- "The text is a multi-line paragraph — use `line-by-line-slide` or `mask-reveal-up` for line-level reveals."+ - "The words follow a real voiceover — use `caption-karaoke` or another style from the Captions tab, which times every word from a transcript instead of inventing the pace."---<ComponentPreview name="word-stream" />diff --git a/content/docs/typography/zoom-words.mdx b/content/docs/typography/zoom-words.mdxindex 041e5fe7..71d23dcc 100644--- a/content/docs/typography/zoom-words.mdx+++ b/content/docs/typography/zoom-words.mdx@@ -12,6 +12,7 @@ avoidWhen:- "The whole phrase must fit the frame at rest — use `per-word-crossfade` or `word-stream`."- "You need character-by-character typing with a caret — use `typewriter`."- "The camera language should be a real 2.5D move over a scene rather than a text close-up — use `stage`."+ - "One spoken word at a time from a voiceover — use `caption-word-pop`, which follows the transcript timing."---<ComponentPreview name="zoom-words" />diff --git a/lib/customizer-config.ts b/lib/customizer-config.tsindex e9ea2df5..994db7af 100644--- a/lib/customizer-config.ts+++ b/lib/customizer-config.ts@@ -153,7 +153,7 @@ export function resolveSchema(schema: InteractivitySchema,): InteractivitySchema {const out: InteractivitySchema = { ...schema, ...SHARED_CONTROLS };- if (NO_SHARED_SPEED.has(slug)) {+ if (NO_SHARED_SPEED.has(slug) || slug.startsWith("caption-")) {delete out.speed;return out;}@@ -162,10 +162,24 @@ export function resolveSchema(return out;}+function captionsToText(captions: readonly unknown[] | undefined): string {+ return (captions ?? [])+ .map((caption) =>+ caption &&+ typeof caption === "object" &&+ "text" in caption &&+ typeof caption.text === "string"+ ? caption.text.trim()+ : "",+ )+ .filter(Boolean)+ .join(" ");+}+/*** Converts one schema field into the customizer's internal control shape.* Returns null for field types the docs customizer does not render- * (`hidden`, transform fields, captions, …).+ * (`hidden`, transform fields, …).*/export function schemaFieldToControl(field: InteractivitySchemaField,@@ -196,6 +210,12 @@ export function schemaFieldToControl(default: field.default,label: field.description ?? "",};+ case "remotion-captions":+ return {+ type: "text",+ default: captionsToText(field.default),+ label: field.description ?? "",+ };case "boolean":return {type: "boolean",diff --git a/lib/docs-meta.test.ts b/lib/docs-meta.test.tsindex d95df605..fa14c926 100644--- a/lib/docs-meta.test.ts+++ b/lib/docs-meta.test.ts@@ -16,6 +16,7 @@ const UNDOCUMENTED: Record<string, string> = {"stop-motion": "shared lib behind the paper tier","scene-motion": "shared motion vocabulary lib","canvas-presentation": "shared html-in-canvas scaffolding lib",+ "caption-core": "shared caption paging and timing lib",brush: "ribbon primitive consumed by the ink marks, not used on its own","select-item": "folds into the select page","dropdown-menu-item": "folds into the dropdown-menu page",@@ -144,7 +145,12 @@ describe("component pages carry selection metadata", () => {const offenders = componentPages.filter((p) => {const length = p.frontmatter.length;- if (length === "state-driven" || length === "sustained") return false;+ if (+ length === "state-driven" ||+ length === "sustained" ||+ length === "transcript-driven"+ )+ return false;return !(typeof length === "number" &&Number.isInteger(length) &&diff --git a/lib/docs-schema.ts b/lib/docs-schema.tsindex a1375a15..a2a95192 100644--- a/lib/docs-schema.ts+++ b/lib/docs-schema.ts@@ -20,6 +20,7 @@ export const componentMetaSchema = z.object({z.int().positive(),z.literal("state-driven"),z.literal("sustained"),+ z.literal("transcript-driven"),]).optional(),useWhen: z.array(z.string()).optional(),diff --git a/lib/docs-tabs.test.ts b/lib/docs-tabs.test.tsindex fba125cb..f4dcb766 100644--- a/lib/docs-tabs.test.ts+++ b/lib/docs-tabs.test.ts@@ -42,6 +42,23 @@ const tree: Root = {},],},+ {+ type: "folder",+ name: "Captions",+ children: [+ {+ type: "folder",+ name: "Getting Started",+ children: [+ {+ type: "page",+ name: "Introduction",+ url: "/docs/captions/getting-started/introduction",+ },+ ],+ },+ ],+ },{type: "folder",name: "Templates",@@ -88,10 +105,23 @@ describe("splitDocsTree", () => {expect(urls.some((url) => url.startsWith("/docs/icons"))).toBe(false);expect(urls.some((url) => url.startsWith("/docs/shaders"))).toBe(false);expect(urls.some((url) => url.startsWith("/docs/filters"))).toBe(false);+ expect(urls.some((url) => url.startsWith("/docs/captions"))).toBe(false);expect(urls.some((url) => url.startsWith("/docs/templates"))).toBe(false);expect(urls.some((url) => url.startsWith("/docs/ui"))).toBe(false);});+ it("routes captions pages only into the captions branch", () => {+ const { captions, filters } = splitDocsTree(tree);+ expect(collectUrls(captions.children)).toEqual([+ "/docs/captions/getting-started/introduction",+ ]);+ expect(+ collectUrls(filters.children).some((url) =>+ url.startsWith("/docs/captions"),+ ),+ ).toBe(false);+ });+it("keeps shaders, templates, and icons in separate branches", () => {const { shaders, templates, icons } = splitDocsTree(tree);expect(@@ -110,12 +140,20 @@ describe("splitDocsTree", () => {});it("gives every branch a distinct, stable $id", () => {- const { components, primitives, shaders, filters, templates, icons } =- splitDocsTree(tree);+ const {+ components,+ primitives,+ shaders,+ filters,+ captions,+ templates,+ icons,+ } = splitDocsTree(tree);expect(components.$id).toBe("docs-tab-components");expect(primitives.$id).toBe("docs-tab-primitives");expect(shaders.$id).toBe("docs-tab-shaders");expect(filters.$id).toBe("docs-tab-filters");+ expect(captions.$id).toBe("docs-tab-captions");expect(templates.$id).toBe("docs-tab-templates");expect(icons.$id).toBe("docs-tab-icons");expect(@@ -124,10 +162,11 @@ describe("splitDocsTree", () => {primitives.$id,shaders.$id,filters.$id,+ captions.$id,templates.$id,icons.$id,]).size,- ).toBe(6);+ ).toBe(7);});it("does not mutate the source tree", () => {@@ -139,9 +178,17 @@ describe("splitDocsTree", () => {});describe("getActiveDocsTab", () => {- it("places Templates immediately after Filters", () => {+ it("places Captions after Filters and Templates after Captions", () => {const labels = DOCS_TABS.map((tab) => tab.label);- expect(labels.indexOf("Templates")).toBe(labels.indexOf("Filters") + 1);+ expect(labels.indexOf("Captions")).toBe(labels.indexOf("Filters") + 1);+ expect(labels.indexOf("Templates")).toBe(labels.indexOf("Captions") + 1);+ });++ it("selects the captions tab for captions paths", () => {+ expect(getActiveDocsTab("/docs/captions")).toBe("captions");+ expect(+ getActiveDocsTab("/docs/captions/getting-started/introduction"),+ ).toBe("captions");});it("selects the templates tab for template paths", () => {diff --git a/lib/docs-tabs.ts b/lib/docs-tabs.tsindex 4d0e0a10..21106b80 100644--- a/lib/docs-tabs.ts+++ b/lib/docs-tabs.ts@@ -10,6 +10,7 @@ export type DocsTabId =| "primitives"| "shaders"| "filters"+ | "captions"| "templates"| "icons";@@ -37,6 +38,11 @@ export const DOCS_TABS: DocsTab[] = [label: "Filters",href: "/docs/filters/getting-started/introduction",},+ {+ id: "captions",+ label: "Captions",+ href: "/docs/captions/getting-started/introduction",+ },{id: "templates",label: "Templates",@@ -76,6 +82,14 @@ function isFiltersPath(pathname: string): boolean {);}+const CAPTIONS_PREFIX = "/docs/captions";++function isCaptionsPath(pathname: string): boolean {+ return (+ pathname === CAPTIONS_PREFIX || pathname.startsWith(`${CAPTIONS_PREFIX}/`)+ );+}+const TEMPLATES_PREFIX = "/docs/templates";function isTemplatesPath(pathname: string): boolean {@@ -93,6 +107,7 @@ function isIconsPath(pathname: string): boolean {export function getActiveDocsTab(pathname: string): DocsTabId {if (isShadersPath(pathname)) return "shaders";if (isFiltersPath(pathname)) return "filters";+ if (isCaptionsPath(pathname)) return "captions";if (isTemplatesPath(pathname)) return "templates";if (isIconsPath(pathname)) return "icons";if (isPrimitivesPath(pathname)) return "primitives";@@ -134,6 +149,7 @@ function sectionNodeMatcher(prefix: string): (node: Node) => boolean {const isShadersNode = sectionNodeMatcher(SHADERS_PREFIX);const isFiltersNode = sectionNodeMatcher(FILTERS_PREFIX);+const isCaptionsNode = sectionNodeMatcher(CAPTIONS_PREFIX);const isTemplatesNode = sectionNodeMatcher(TEMPLATES_PREFIX);const isIconsNode = sectionNodeMatcher(ICONS_PREFIX);@@ -173,6 +189,7 @@ export function splitDocsTree(tree: Root): {primitives: Root;shaders: Root;filters: Root;+ captions: Root;templates: Root;icons: Root;} {@@ -185,6 +202,7 @@ export function splitDocsTree(tree: Root): {!isPrimitivesNode(node) &&!isShadersNode(node) &&!isFiltersNode(node) &&+ !isCaptionsNode(node) &&!isTemplatesNode(node) &&!isIconsNode(node),),@@ -204,6 +222,11 @@ export function splitDocsTree(tree: Root): {$id: "docs-tab-filters",children: hoistPrimitives(tree.children.filter(isFiltersNode)),},+ captions: {+ ...tree,+ $id: "docs-tab-captions",+ children: hoistPrimitives(tree.children.filter(isCaptionsNode)),+ },templates: {...tree,$id: "docs-tab-templates",diff --git a/lib/get-llm-text.ts b/lib/get-llm-text.tsindex 91a8e742..32d7e30c 100644--- a/lib/get-llm-text.ts+++ b/lib/get-llm-text.ts@@ -7,7 +7,7 @@ export const SITE_URL = "https://remocn.dev";type DocPage = InferPageType<typeof source>;export function formatLength(- length: number | "state-driven" | "sustained",+ length: number | "state-driven" | "sustained" | "transcript-driven",): string {return typeof length === "string" ? length : `${length}f @ 30fps`;}diff --git a/package.json b/package.jsonindex 2c629fe0..0900f96f 100644--- a/package.json+++ b/package.json@@ -54,6 +54,7 @@"@openpanel/sdk": "^1.3.1","@paper-design/shaders-react": "0.0.76","@remotion/bundler": "4.0.530",+ "@remotion/captions": "4.0.530","@remotion/google-fonts": "4.0.530","@remotion/paths": "4.0.530","@remotion/player": "4.0.530",diff --git a/registry-artifacts/caption-active-pop.json b/registry-artifacts/caption-active-pop.jsonnew file mode 100644index 00000000..e426b4c8--- /dev/null+++ b/registry-artifacts/caption-active-pop.json@@ -0,0 +1,17 @@+{+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",+ "name": "caption-active-pop",+ "title": "Caption Active Pop",+ "description": "The word being spoken turns to the accent colour and springs up in scale, then settles back as the voice moves on.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "registry/remocn/caption-active-pop/index.tsx",+ "content": "\"use client\";\n\nimport { Fragment } from \"react\";\nimport {\n Easing,\n interpolate,\n interpolateColors,\n spring,\n useVideoConfig,\n} from \"remotion\";\nimport {\n type CaptionBaseProps,\n DEFAULT_HOLD_MS,\n getExitWindowMs,\n groupCaptionWords,\n useCaptions,\n} from \"@/lib/remocn/caption-core\";\n\nexport interface CaptionActivePopProps extends CaptionBaseProps {\n activeColor?: string;\n popScale?: number;\n shadow?: boolean;\n}\n\nconst ENTER_MS = 160;\nconst EXIT_MS = 220;\nconst RISE_EM = 0.14;\nconst LEGIBILITY_SHADOW =\n \"0 2px 3px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.35)\";\n\nconst POP_SPRING = { damping: 12, stiffness: 220, mass: 0.6 };\nconst RELEASE_SPRING = { damping: 20, stiffness: 200, mass: 0.6 };\n\nconst enterEasing = Easing.bezier(0.2, 0.8, 0.2, 1);\n\nconst clamp = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n} as const;\n\nexport function CaptionActivePop({\n captions,\n combineTokensWithinMilliseconds = 1200,\n holdMs = DEFAULT_HOLD_MS,\n fontSize = 64,\n fontWeight = 800,\n color = \"#ffffff\",\n activeColor = \"#facc15\",\n popScale = 1.12,\n shadow = true,\n className,\n}: CaptionActivePopProps) {\n const { fps } = useVideoConfig();\n const state = useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs,\n });\n if (!state) return null;\n\n const enter = interpolate(\n state.previous ? ENTER_MS : state.sinceStartMs,\n [0, ENTER_MS],\n [0, 1],\n {\n ...clamp,\n easing: enterEasing,\n },\n );\n const exit = state.endsInSilence\n ? interpolate(\n state.untilEndMs,\n [0, getExitWindowMs(state, EXIT_MS)],\n [0, 1],\n clamp,\n )\n : 1;\n\n const words = groupCaptionWords(state.tokens);\n const activeWord = words.findIndex((word) =>\n word.some(({ index }) => index === state.activeIndex),\n );\n const toFrames = (ms: number) => (ms / 1000) * fps;\n\n const emphasis = (w: number): number => {\n if (activeWord < 0 || w > activeWord) return 0;\n const startMs = words[w][0].token.fromMs;\n if (w === activeWord) {\n return spring({\n frame: toFrames(state.timeMs - startMs),\n fps,\n config: POP_SPRING,\n });\n }\n if (w < activeWord - 1) return 0;\n const releaseMs = words[w + 1][0].token.fromMs;\n const peak = spring({\n frame: toFrames(releaseMs - startMs),\n fps,\n config: POP_SPRING,\n });\n const release = spring({\n frame: toFrames(state.timeMs - releaseMs),\n fps,\n config: RELEASE_SPRING,\n });\n return peak * (1 - release);\n };\n\n return (\n <div\n className={className}\n style={{\n fontSize,\n fontWeight,\n color,\n lineHeight: 1.2,\n textAlign: \"center\",\n opacity: Math.min(enter, exit),\n transform: `translateY(${(1 - enter) * RISE_EM}em)`,\n }}\n >\n {words.map((word, w) => {\n const amount = emphasis(w);\n return (\n <Fragment key={`${state.pageIndex}-${word[0].index}`}>\n {w > 0 && \" \"}\n <span\n style={{\n position: \"relative\",\n zIndex: w === activeWord ? 1 : 0,\n display: \"inline-block\",\n whiteSpace: \"nowrap\",\n transform: `scale(${1 + (popScale - 1) * amount})`,\n transformOrigin: \"50% 60%\",\n color: interpolateColors(\n Math.min(1, Math.max(0, amount)),\n [0, 1],\n [color, activeColor],\n ),\n textShadow: shadow ? LEGIBILITY_SHADOW : undefined,\n }}\n >\n {word.map(({ index, token }) => (\n <span key={index}>{token.text}</span>\n ))}\n </span>\n </Fragment>\n );\n })}\n </div>\n );\n}\n",+ "type": "registry:component",+ "target": "components/remocn/caption-active-pop.tsx"+ }+ ],+ "type": "registry:component"+}diff --git a/registry-artifacts/caption-blur-in.json b/registry-artifacts/caption-blur-in.jsonnew file mode 100644index 00000000..9534686b--- /dev/null+++ b/registry-artifacts/caption-blur-in.json@@ -0,0 +1,17 @@+{+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",+ "name": "caption-blur-in",+ "title": "Caption Blur In",+ "description": "Each word resolves out of a soft blur the moment it is spoken, for captions that arrive quietly.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "registry/remocn/caption-blur-in/index.tsx",+ "content": "\"use client\";\n\nimport { Fragment } from \"react\";\nimport { Easing, interpolate } from \"remotion\";\nimport {\n type CaptionBaseProps,\n DEFAULT_HOLD_MS,\n getExitWindowMs,\n groupCaptionWords,\n useCaptions,\n} from \"@/lib/remocn/caption-core\";\n\nexport interface CaptionBlurInProps extends CaptionBaseProps {\n blur?: number;\n shadow?: boolean;\n}\n\nconst EXIT_MS = 220;\nconst RESOLVE_MS = 220;\nconst LEGIBILITY_SHADOW =\n \"0 2px 3px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.35)\";\n\nconst resolveEasing = Easing.bezier(0.25, 0.6, 0.3, 1);\n\nexport function CaptionBlurIn({\n captions,\n combineTokensWithinMilliseconds = 1200,\n holdMs = DEFAULT_HOLD_MS,\n fontSize = 64,\n fontWeight = 800,\n color = \"#ffffff\",\n blur = 12,\n shadow = true,\n className,\n}: CaptionBlurInProps) {\n const state = useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs,\n });\n if (!state) return null;\n\n const exit = state.endsInSilence\n ? interpolate(\n state.untilEndMs,\n [0, getExitWindowMs(state, EXIT_MS)],\n [0, 1],\n {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n },\n )\n : 1;\n\n return (\n <div\n className={className}\n style={{\n fontSize,\n fontWeight,\n color,\n lineHeight: 1.2,\n textAlign: \"center\",\n opacity: exit,\n }}\n >\n {groupCaptionWords(state.tokens).map((word, w) => (\n <Fragment key={`${state.pageIndex}-${word[0].index}`}>\n {w > 0 && \" \"}\n <span style={{ display: \"inline-block\", whiteSpace: \"nowrap\" }}>\n {word.map(({ index, token }) => {\n const sinceMs = state.timeMs - token.fromMs;\n const p =\n sinceMs < 0\n ? 0\n : interpolate(sinceMs, [0, RESOLVE_MS], [0, 1], {\n easing: resolveEasing,\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n });\n const radius = (1 - p) * blur;\n return (\n <span\n key={index}\n style={{\n display: \"inline-block\",\n opacity: p,\n filter: radius > 0.01 ? `blur(${radius}px)` : undefined,\n textShadow: shadow ? LEGIBILITY_SHADOW : undefined,\n }}\n >\n {token.text}\n </span>\n );\n })}\n </span>\n </Fragment>\n ))}\n </div>\n );\n}\n",+ "type": "registry:component",+ "target": "components/remocn/caption-blur-in.tsx"+ }+ ],+ "type": "registry:component"+}diff --git a/registry-artifacts/caption-bounce-in.json b/registry-artifacts/caption-bounce-in.jsonnew file mode 100644index 00000000..4f78c236--- /dev/null+++ b/registry-artifacts/caption-bounce-in.json@@ -0,0 +1,17 @@+{+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",+ "name": "caption-bounce-in",+ "title": "Caption Bounce In",+ "description": "Each word springs up into place with a little overshoot the moment it is spoken, and the phrase builds word by word.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "registry/remocn/caption-bounce-in/index.tsx",+ "content": "\"use client\";\n\nimport { Fragment } from \"react\";\nimport { interpolate, spring, useVideoConfig } from \"remotion\";\nimport {\n type CaptionBaseProps,\n DEFAULT_HOLD_MS,\n getExitWindowMs,\n groupCaptionWords,\n useCaptions,\n} from \"@/lib/remocn/caption-core\";\n\nexport interface CaptionBounceInProps extends CaptionBaseProps {\n bounce?: number;\n shadow?: boolean;\n}\n\nconst EXIT_MS = 220;\nconst FADE_IN_MS = 90;\nconst DROP_EM = 0.35;\nconst START_SCALE = 0.7;\nconst LEGIBILITY_SHADOW =\n \"0 2px 3px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.35)\";\n\nexport function CaptionBounceIn({\n captions,\n combineTokensWithinMilliseconds = 1200,\n holdMs = DEFAULT_HOLD_MS,\n fontSize = 64,\n fontWeight = 800,\n color = \"#ffffff\",\n bounce = 0.6,\n shadow = true,\n className,\n}: CaptionBounceInProps) {\n const { fps } = useVideoConfig();\n const state = useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs,\n });\n if (!state) return null;\n\n const damping = interpolate(bounce, [0, 1], [22, 7], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n });\n const exit = state.endsInSilence\n ? interpolate(\n state.untilEndMs,\n [0, getExitWindowMs(state, EXIT_MS)],\n [0, 1],\n {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n },\n )\n : 1;\n\n return (\n <div\n className={className}\n style={{\n fontSize,\n fontWeight,\n color,\n lineHeight: 1.2,\n textAlign: \"center\",\n opacity: exit,\n }}\n >\n {groupCaptionWords(state.tokens).map((word, w) => (\n <Fragment key={`${state.pageIndex}-${word[0].index}`}>\n {w > 0 && \" \"}\n <span style={{ display: \"inline-block\", whiteSpace: \"nowrap\" }}>\n {word.map(({ index, token }) => {\n const sinceMs = state.timeMs - token.fromMs;\n const arrived = sinceMs >= 0;\n const p = arrived\n ? spring({\n frame: (sinceMs / 1000) * fps,\n fps,\n config: { damping, stiffness: 220, mass: 0.6 },\n })\n : 0;\n const opacity = arrived\n ? interpolate(sinceMs, [0, FADE_IN_MS], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n })\n : 0;\n return (\n <span\n key={index}\n style={{\n display: \"inline-block\",\n opacity,\n transform: `translateY(${(1 - p) * DROP_EM}em) scale(${\n START_SCALE + (1 - START_SCALE) * p\n })`,\n transformOrigin: \"50% 80%\",\n textShadow: shadow ? LEGIBILITY_SHADOW : undefined,\n }}\n >\n {token.text}\n </span>\n );\n })}\n </span>\n </Fragment>\n ))}\n </div>\n );\n}\n",+ "type": "registry:component",+ "target": "components/remocn/caption-bounce-in.tsx"+ }+ ],+ "type": "registry:component"+}diff --git a/registry-artifacts/caption-core.json b/registry-artifacts/caption-core.jsonnew file mode 100644index 00000000..aa791176--- /dev/null+++ b/registry-artifacts/caption-core.json@@ -0,0 +1,16 @@+{+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",+ "name": "caption-core",+ "title": "Caption Core",+ "description": "The timing engine every caption style shares: pages a timed transcript, finds the word being spoken and how far into it the voice is, and decides when a page leaves the screen.",+ "dependencies": ["remotion", "@remotion/captions"],+ "files": [+ {+ "path": "registry/remocn/caption-core/index.ts",+ "content": "import {\n type Caption,\n createTikTokStyleCaptions,\n type TikTokPage,\n} from \"@remotion/captions\";\nimport { useLayoutEffect, useMemo, useRef, useState } from \"react\";\nimport { useCurrentFrame, useVideoConfig } from \"remotion\";\n\nexport type SpeakerCaption = Caption & { speaker?: string };\n\nexport interface CaptionBaseProps {\n captions: Caption[];\n combineTokensWithinMilliseconds?: number;\n holdMs?: number;\n fontSize?: number;\n fontWeight?: number;\n color?: string;\n className?: string;\n}\n\nexport const DEFAULT_HOLD_MS = 600;\nexport const MIN_SILENCE_BREAK_MS = 300;\n\nexport interface CaptionPageWindow {\n page: TikTokPage;\n index: number;\n speaker: string | undefined;\n startMs: number;\n speechEndMs: number;\n endMs: number;\n endsInSilence: boolean;\n}\n\nexport type CaptionTokenStatus = \"upcoming\" | \"active\" | \"spoken\";\n\nexport interface CaptionTokenState {\n text: string;\n spaceBefore: boolean;\n fromMs: number;\n toMs: number;\n progress: number;\n status: CaptionTokenStatus;\n}\n\nexport interface CaptionPreviousPage {\n page: TikTokPage;\n pageIndex: number;\n tokens: CaptionTokenState[];\n}\n\nexport interface CaptionsState {\n page: TikTokPage;\n pageIndex: number;\n speaker: string | undefined;\n timeMs: number;\n activeIndex: number;\n tokens: CaptionTokenState[];\n sinceStartMs: number;\n untilEndMs: number;\n holdRoomMs: number;\n endsInSilence: boolean;\n previous: CaptionPreviousPage | null;\n}\n\nexport interface CaptionPagingOptions {\n combineTokensWithinMilliseconds: number;\n holdMs?: number;\n}\n\nconst SENTENCE_END = /[.!?…][\"')\\]]*$/;\n\nfunction markPageBreaks(captions: SpeakerCaption[]): Caption[] {\n return captions.map((caption, i) => {\n if (caption.pageBreakAfter !== undefined) return caption;\n const next = captions[i + 1];\n const speakerChanges =\n next !== undefined && next.speaker !== caption.speaker;\n return speakerChanges || SENTENCE_END.test(caption.text.trim())\n ? { ...caption, pageBreakAfter: true }\n : caption;\n });\n}\n\nexport function buildCaptionPages(\n captions: SpeakerCaption[],\n {\n combineTokensWithinMilliseconds,\n holdMs = DEFAULT_HOLD_MS,\n }: CaptionPagingOptions,\n): CaptionPageWindow[] {\n if (captions.length === 0) return [];\n const { pages } = createTikTokStyleCaptions({\n captions: markPageBreaks(captions),\n combineTokensWithinMilliseconds,\n breakOnSilenceAfterMilliseconds: Math.max(holdMs, MIN_SILENCE_BREAK_MS),\n });\n const speakers = new Map<number, string | undefined>();\n for (const caption of captions) {\n if (!speakers.has(caption.startMs)) {\n speakers.set(caption.startMs, caption.speaker);\n }\n }\n const spoken = pages.filter((page) => page.tokens.length > 0);\n return spoken.map((page, index) => {\n const last = page.tokens[page.tokens.length - 1];\n const speechEndMs = last ? last.toMs : page.startMs;\n const heldUntil = speechEndMs + Math.max(0, holdMs);\n const next = spoken[index + 1];\n const endsInSilence = !next || next.startMs > heldUntil;\n const endMs = endsInSilence\n ? heldUntil\n : Math.max(page.startMs, next.startMs);\n return {\n page,\n index,\n speaker: speakers.get(page.tokens[0].fromMs),\n startMs: page.startMs,\n speechEndMs,\n endMs,\n endsInSilence,\n };\n });\n}\n\nfunction findWindowIndex(windows: CaptionPageWindow[], timeMs: number): number {\n let lo = 0;\n let hi = windows.length - 1;\n let found = -1;\n while (lo <= hi) {\n const mid = (lo + hi) >> 1;\n if (windows[mid].startMs <= timeMs) {\n found = mid;\n lo = mid + 1;\n } else {\n hi = mid - 1;\n }\n }\n if (found === -1) return -1;\n return timeMs < windows[found].endMs ? found : -1;\n}\n\nfunction tokenProgress(fromMs: number, toMs: number, timeMs: number): number {\n if (timeMs < fromMs) return 0;\n if (toMs <= fromMs) return 1;\n return Math.min(1, (timeMs - fromMs) / (toMs - fromMs));\n}\n\nfunction getTokenStates(\n page: TikTokPage,\n timeMs: number,\n): { activeIndex: number; tokens: CaptionTokenState[] } {\n let activeIndex = -1;\n page.tokens.forEach((token, i) => {\n if (token.fromMs <= timeMs) activeIndex = i;\n });\n const tokens = page.tokens.map(\n (token, i): CaptionTokenState => ({\n text: token.text.trim(),\n spaceBefore: i > 0 && /^\\s/.test(token.text),\n fromMs: token.fromMs,\n toMs: token.toMs,\n progress: tokenProgress(token.fromMs, token.toMs, timeMs),\n status:\n i < activeIndex ? \"spoken\" : i === activeIndex ? \"active\" : \"upcoming\",\n }),\n );\n return { activeIndex, tokens };\n}\n\nexport function getCaptionsState(\n windows: CaptionPageWindow[],\n timeMs: number,\n): CaptionsState | null {\n const found = findWindowIndex(windows, timeMs);\n if (found === -1) return null;\n const window = windows[found];\n const { activeIndex, tokens } = getTokenStates(window.page, timeMs);\n const before = found > 0 ? windows[found - 1] : null;\n const previous =\n before && !before.endsInSilence\n ? {\n page: before.page,\n pageIndex: before.index,\n tokens: getTokenStates(before.page, before.endMs).tokens,\n }\n : null;\n return {\n page: window.page,\n pageIndex: window.index,\n speaker: window.speaker,\n timeMs,\n activeIndex,\n tokens,\n sinceStartMs: timeMs - window.startMs,\n untilEndMs: window.endMs - timeMs,\n holdRoomMs: window.endMs - window.speechEndMs,\n endsInSilence: window.endsInSilence,\n previous,\n };\n}\n\nexport function getExitWindowMs(state: CaptionsState, exitMs: number): number {\n return Math.max(1, Math.min(exitMs, state.holdRoomMs));\n}\n\nexport function groupCaptionWords(\n tokens: CaptionTokenState[],\n): { index: number; token: CaptionTokenState }[][] {\n const words: { index: number; token: CaptionTokenState }[][] = [];\n tokens.forEach((token, index) => {\n const current = words[words.length - 1];\n if (!current || token.spaceBefore) {\n words.push([{ index, token }]);\n } else {\n current.push({ index, token });\n }\n });\n return words;\n}\n\nexport function normalizeCaptionWord(text: string): string {\n return text\n .toLowerCase()\n .replace(/[\\u2018\\u2019]/g, \"'\")\n .replace(/[^\\p{L}\\p{N}']/gu, \"\");\n}\n\nexport function createKeywordMatcher(\n keywords: readonly string[] = [],\n): (text: string) => boolean {\n const set = new Set(keywords.map(normalizeCaptionWord).filter(Boolean));\n return (text) => set.has(normalizeCaptionWord(text));\n}\n\nexport function captionWordText(word: { token: CaptionTokenState }[]): string {\n return word.map(({ token }) => token.text).join(\"\");\n}\n\nexport interface CaptionWordRect {\n left: number;\n top: number;\n width: number;\n height: number;\n}\n\nfunction sameRects(a: CaptionWordRect[], b: CaptionWordRect[]): boolean {\n return (\n a.length === b.length &&\n a.every(\n (r, i) =>\n r.left === b[i].left &&\n r.top === b[i].top &&\n r.width === b[i].width &&\n r.height === b[i].height,\n )\n );\n}\n\nexport function useCaptionWordRects(\n pageIndex: number,\n count: number,\n): {\n wordRef: (index: number) => (el: HTMLElement | null) => void;\n rects: CaptionWordRect[] | null;\n} {\n const elements = useRef<(HTMLElement | null)[]>([]);\n const [measured, setMeasured] = useState<{\n pageIndex: number;\n rects: CaptionWordRect[];\n } | null>(null);\n\n useLayoutEffect(() => {\n if (pageIndex === -1) return;\n const rects = elements.current.slice(0, count).map((el) =>\n el\n ? {\n left: el.offsetLeft,\n top: el.offsetTop,\n width: el.offsetWidth,\n height: el.offsetHeight,\n }\n : { left: 0, top: 0, width: 0, height: 0 },\n );\n setMeasured((prev) =>\n prev && prev.pageIndex === pageIndex && sameRects(prev.rects, rects)\n ? prev\n : { pageIndex, rects },\n );\n });\n\n return {\n wordRef: (index) => (el) => {\n elements.current[index] = el;\n },\n rects: measured && measured.pageIndex === pageIndex ? measured.rects : null,\n };\n}\n\nexport function useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs = DEFAULT_HOLD_MS,\n}: {\n captions: SpeakerCaption[];\n combineTokensWithinMilliseconds: number;\n holdMs?: number;\n}): CaptionsState | null {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const windows = useMemo(\n () =>\n buildCaptionPages(captions, { combineTokensWithinMilliseconds, holdMs }),\n [captions, combineTokensWithinMilliseconds, holdMs],\n );\n return getCaptionsState(windows, (frame / fps) * 1000);\n}\n",+ "type": "registry:lib",+ "target": "lib/remocn/caption-core.ts"+ }+ ],+ "type": "registry:lib"+}diff --git a/registry-artifacts/caption-cube.json b/registry-artifacts/caption-cube.jsonnew file mode 100644index 00000000..71149b9f--- /dev/null+++ b/registry-artifacts/caption-cube.json@@ -0,0 +1,17 @@+{+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",+ "name": "caption-cube",+ "title": "Caption Cube",+ "description": "Each new phrase turns into view as the next face of a 3D cube, the previous phrase rotating up and away on a horizontal hinge.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "registry/remocn/caption-cube/index.tsx",+ "content": "\"use client\";\n\nimport { type CSSProperties, Fragment } from \"react\";\nimport { Easing, interpolate } from \"remotion\";\nimport {\n type CaptionBaseProps,\n type CaptionTokenState,\n DEFAULT_HOLD_MS,\n getExitWindowMs,\n groupCaptionWords,\n useCaptions,\n} from \"@/lib/remocn/caption-core\";\n\nexport interface CaptionCubeProps extends CaptionBaseProps {\n tintActive?: boolean;\n activeColor?: string;\n shadow?: boolean;\n}\n\nconst LINE_HEIGHT = 1.3;\nconst DEPTH_EM = LINE_HEIGHT / 2;\nconst TURN_MS = 320;\nconst EXIT_MS = 280;\nconst PERSPECTIVE_EM = 10;\nconst LEGIBILITY_SHADOW =\n \"0 2px 3px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.35)\";\n\nconst turnEasing = Easing.bezier(0.65, 0, 0.35, 1);\nconst exitEasing = Easing.bezier(0.7, 0, 0.84, 0);\n\nfunction CubeFace({\n tokens,\n activeIndex,\n activeColor,\n angle,\n before,\n style,\n}: {\n tokens: CaptionTokenState[];\n activeIndex: number;\n activeColor: string | undefined;\n angle: number;\n before: string;\n style?: CSSProperties;\n}) {\n const facing = Math.max(0, Math.cos((angle * Math.PI) / 180));\n return (\n <div\n style={{\n whiteSpace: \"nowrap\",\n backfaceVisibility: \"hidden\",\n WebkitBackfaceVisibility: \"hidden\",\n opacity: 0.35 + 0.65 * facing,\n transform: `${before}rotateX(${angle}deg) translateZ(${DEPTH_EM}em)`,\n ...style,\n }}\n >\n {groupCaptionWords(tokens).map((word, w) => (\n <Fragment key={word[0].index}>\n {w > 0 && \" \"}\n {word.map(({ index, token }) => (\n <span\n key={index}\n style={{\n color:\n activeColor !== undefined && index === activeIndex\n ? activeColor\n : undefined,\n }}\n >\n {token.text}\n </span>\n ))}\n </Fragment>\n ))}\n </div>\n );\n}\n\nexport function CaptionCube({\n captions,\n combineTokensWithinMilliseconds = 800,\n holdMs = DEFAULT_HOLD_MS,\n fontSize = 64,\n fontWeight = 800,\n color = \"#ffffff\",\n tintActive = false,\n activeColor = \"#facc15\",\n shadow = true,\n className,\n}: CaptionCubeProps) {\n const state = useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs,\n });\n if (!state) return null;\n\n const turnMs = Math.max(\n 1,\n Math.min(TURN_MS, state.sinceStartMs + state.untilEndMs),\n );\n const turn = interpolate(state.sinceStartMs, [0, turnMs], [0, 1], {\n easing: turnEasing,\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n });\n const exitProgress = state.endsInSilence\n ? exitEasing(\n Math.min(\n 1,\n Math.max(0, 1 - state.untilEndMs / getExitWindowMs(state, EXIT_MS)),\n ),\n )\n : 0;\n const currentAngle = (turn - 1) * 90 + exitProgress * 90;\n\n return (\n <div\n className={className}\n style={{\n position: \"relative\",\n fontSize,\n fontWeight,\n color,\n lineHeight: LINE_HEIGHT,\n height: `${LINE_HEIGHT}em`,\n textAlign: \"center\",\n textShadow: shadow ? LEGIBILITY_SHADOW : undefined,\n perspective: `${PERSPECTIVE_EM}em`,\n }}\n >\n <div\n style={{\n position: \"relative\",\n height: \"100%\",\n transformStyle: \"preserve-3d\",\n transform: `translateZ(${-DEPTH_EM}em)`,\n }}\n >\n {state.previous && turn < 1 ? (\n <CubeFace\n key={`page-${state.previous.pageIndex}`}\n tokens={state.previous.tokens}\n activeIndex={-1}\n activeColor={undefined}\n angle={turn * 90}\n before=\"translateX(-50%) \"\n style={{ position: \"absolute\", top: 0, left: \"50%\" }}\n />\n ) : null}\n <CubeFace\n key={`page-${state.pageIndex}`}\n tokens={state.tokens}\n activeIndex={state.activeIndex}\n activeColor={tintActive ? activeColor : undefined}\n angle={currentAngle}\n before=\"\"\n />\n </div>\n </div>\n );\n}\n",+ "type": "registry:component",+ "target": "components/remocn/caption-cube.tsx"+ }+ ],+ "type": "registry:component"+}diff --git a/registry-artifacts/caption-dim-progress.json b/registry-artifacts/caption-dim-progress.jsonnew file mode 100644index 00000000..1bbe9a2b--- /dev/null+++ b/registry-artifacts/caption-dim-progress.json@@ -0,0 +1,17 @@+{+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",+ "name": "caption-dim-progress",+ "title": "Caption Dim Progress",+ "description": "The whole phrase sits on screen dimmed and each word brightens the moment it is spoken, with no motion at all.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "registry/remocn/caption-dim-progress/index.tsx",+ "content": "\"use client\";\n\nimport { Fragment } from \"react\";\nimport { Easing, interpolate } from \"remotion\";\nimport {\n type CaptionBaseProps,\n DEFAULT_HOLD_MS,\n getExitWindowMs,\n groupCaptionWords,\n useCaptions,\n} from \"@/lib/remocn/caption-core\";\n\nexport interface CaptionDimProgressProps extends CaptionBaseProps {\n dimOpacity?: number;\n shadow?: boolean;\n}\n\nconst ENTER_MS = 160;\nconst EXIT_MS = 220;\nconst RISE_EM = 0.14;\nconst BRIGHTEN_MS = 90;\nconst LEGIBILITY_SHADOW =\n \"0 2px 3px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.35)\";\n\nconst enterEasing = Easing.bezier(0.2, 0.8, 0.2, 1);\n\nconst clamp = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n} as const;\n\nexport function CaptionDimProgress({\n captions,\n combineTokensWithinMilliseconds = 1200,\n holdMs = DEFAULT_HOLD_MS,\n fontSize = 64,\n fontWeight = 800,\n color = \"#ffffff\",\n dimOpacity = 0.35,\n shadow = true,\n className,\n}: CaptionDimProgressProps) {\n const state = useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs,\n });\n if (!state) return null;\n\n const enter = interpolate(\n state.previous ? ENTER_MS : state.sinceStartMs,\n [0, ENTER_MS],\n [0, 1],\n {\n ...clamp,\n easing: enterEasing,\n },\n );\n const exit = state.endsInSilence\n ? interpolate(\n state.untilEndMs,\n [0, getExitWindowMs(state, EXIT_MS)],\n [0, 1],\n clamp,\n )\n : 1;\n\n return (\n <div\n className={className}\n style={{\n fontSize,\n fontWeight,\n color,\n lineHeight: 1.2,\n textAlign: \"center\",\n opacity: Math.min(enter, exit),\n transform: `translateY(${(1 - enter) * RISE_EM}em)`,\n }}\n >\n {groupCaptionWords(state.tokens).map((word, w) => (\n <Fragment key={`${state.pageIndex}-${word[0].index}`}>\n {w > 0 && \" \"}\n <span style={{ display: \"inline-block\", whiteSpace: \"nowrap\" }}>\n {word.map(({ index, token }) => (\n <span\n key={index}\n style={{\n opacity: interpolate(\n state.timeMs - token.fromMs,\n [0, BRIGHTEN_MS],\n [dimOpacity, 1],\n clamp,\n ),\n textShadow: shadow ? LEGIBILITY_SHADOW : undefined,\n }}\n >\n {token.text}\n </span>\n ))}\n </span>\n </Fragment>\n ))}\n </div>\n );\n}\n",+ "type": "registry:component",+ "target": "components/remocn/caption-dim-progress.tsx"+ }+ ],+ "type": "registry:component"+}diff --git a/registry-artifacts/caption-drop.json b/registry-artifacts/caption-drop.jsonnew file mode 100644index 00000000..81f687c6--- /dev/null+++ b/registry-artifacts/caption-drop.json@@ -0,0 +1,17 @@+{+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",+ "name": "caption-drop",+ "title": "Caption Drop",+ "description": "Each word falls into place from above and bounces as it lands the moment it is spoken, and the whole phrase drops out of frame when the speaker pauses.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "registry/remocn/caption-drop/index.tsx",+ "content": "\"use client\";\n\nimport { Fragment } from \"react\";\nimport { interpolate, random, spring, useVideoConfig } from \"remotion\";\nimport {\n type CaptionBaseProps,\n DEFAULT_HOLD_MS,\n getExitWindowMs,\n groupCaptionWords,\n useCaptions,\n} from \"@/lib/remocn/caption-core\";\n\nexport interface CaptionDropProps extends CaptionBaseProps {\n bounce?: number;\n shadow?: boolean;\n}\n\nconst EXIT_MS = 360;\nconst EXIT_STAGGER_MS = 120;\nconst FADE_IN_MS = 80;\nconst FALL_EM = 1.4;\nconst EXIT_FALL_EM = 1.8;\nconst MAX_TILT_DEG = 6;\nconst LEGIBILITY_SHADOW =\n \"0 2px 3px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.35)\";\n\nconst clamp = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n} as const;\n\nexport function CaptionDrop({\n captions,\n combineTokensWithinMilliseconds = 1200,\n holdMs = DEFAULT_HOLD_MS,\n fontSize = 64,\n fontWeight = 800,\n color = \"#ffffff\",\n bounce = 0.6,\n shadow = true,\n className,\n}: CaptionDropProps) {\n const { fps } = useVideoConfig();\n const state = useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs,\n });\n if (!state) return null;\n\n const damping = interpolate(bounce, [0, 1], [20, 6], clamp);\n const words = groupCaptionWords(state.tokens);\n const exitWindow = getExitWindowMs(state, EXIT_MS);\n const exitElapsed = state.endsInSilence\n ? Math.max(0, exitWindow - state.untilEndMs)\n : 0;\n const stagger = Math.min(EXIT_STAGGER_MS, exitWindow * 0.4);\n const fallSpan = Math.max(1, exitWindow - stagger);\n\n return (\n <div\n className={className}\n style={{\n fontSize,\n fontWeight,\n color,\n lineHeight: 1.2,\n textAlign: \"center\",\n }}\n >\n {words.map((word, w) => {\n const first = word[0];\n const sinceMs = state.timeMs - first.token.fromMs;\n const arrived = sinceMs >= 0;\n const landed = arrived\n ? spring({\n frame: (sinceMs / 1000) * fps,\n fps,\n config: { damping, stiffness: 180, mass: 0.7 },\n })\n : 0;\n const fadeIn = arrived\n ? interpolate(sinceMs, [0, FADE_IN_MS], [0, 1], clamp)\n : 0;\n const tilt =\n (random(`${state.pageIndex}-${first.index}-tilt`) * 2 - 1) *\n MAX_TILT_DEG;\n const delay = words.length > 1 ? (w / (words.length - 1)) * stagger : 0;\n const out = state.endsInSilence\n ? Math.min(1, Math.max(0, (exitElapsed - delay) / fallSpan))\n : 0;\n const gravity = out * out;\n const y = -(1 - landed) * FALL_EM + gravity * EXIT_FALL_EM;\n const rotate = tilt * (1 - landed) - tilt * 0.6 * gravity;\n return (\n <Fragment key={`${state.pageIndex}-${first.index}`}>\n {w > 0 && \" \"}\n <span\n style={{\n display: \"inline-block\",\n whiteSpace: \"nowrap\",\n opacity: fadeIn * (1 - out ** 1.5),\n transform: `translateY(${y}em) rotate(${rotate}deg)`,\n transformOrigin: \"50% 100%\",\n textShadow: shadow ? LEGIBILITY_SHADOW : undefined,\n }}\n >\n {word.map(({ index, token }) => (\n <span key={index}>{token.text}</span>\n ))}\n </span>\n </Fragment>\n );\n })}\n </div>\n );\n}\n",+ "type": "registry:component",+ "target": "components/remocn/caption-drop.tsx"+ }+ ],+ "type": "registry:component"+}diff --git a/registry-artifacts/caption-emoji.json b/registry-artifacts/caption-emoji.jsonnew file mode 100644index 00000000..5af7c2c3--- /dev/null+++ b/registry-artifacts/caption-emoji.json@@ -0,0 +1,17 @@+{+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",+ "name": "caption-emoji",+ "title": "Caption Emoji",+ "description": "An emoji pops up above a chosen word the moment it is spoken and stays until the phrase leaves.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "registry/remocn/caption-emoji/index.tsx",+ "content": "\"use client\";\n\nimport { Fragment } from \"react\";\nimport { Easing, interpolate, spring, useVideoConfig } from \"remotion\";\nimport {\n type CaptionBaseProps,\n captionWordText,\n DEFAULT_HOLD_MS,\n getExitWindowMs,\n groupCaptionWords,\n normalizeCaptionWord,\n useCaptions,\n} from \"@/lib/remocn/caption-core\";\n\nexport interface CaptionEmojiProps extends CaptionBaseProps {\n emoji?: Record<string, string>;\n emojiSize?: number;\n shadow?: boolean;\n}\n\nconst ENTER_MS = 160;\nconst EXIT_MS = 220;\nconst RISE_EM = 0.14;\nconst LEGIBILITY_SHADOW =\n \"0 2px 3px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.35)\";\n\nconst POP_SPRING = { damping: 9, stiffness: 180, mass: 0.6 };\n\nconst enterEasing = Easing.bezier(0.2, 0.8, 0.2, 1);\n\nconst clamp = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n} as const;\n\nexport function CaptionEmoji({\n captions,\n combineTokensWithinMilliseconds = 1200,\n holdMs = DEFAULT_HOLD_MS,\n fontSize = 64,\n fontWeight = 800,\n color = \"#ffffff\",\n emoji = {},\n emojiSize = 0.9,\n shadow = true,\n className,\n}: CaptionEmojiProps) {\n const { fps } = useVideoConfig();\n const state = useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs,\n });\n if (!state) return null;\n\n const enter = interpolate(\n state.previous ? ENTER_MS : state.sinceStartMs,\n [0, ENTER_MS],\n [0, 1],\n {\n ...clamp,\n easing: enterEasing,\n },\n );\n const exit = state.endsInSilence\n ? interpolate(\n state.untilEndMs,\n [0, getExitWindowMs(state, EXIT_MS)],\n [0, 1],\n clamp,\n )\n : 1;\n\n const lookup = new Map(\n Object.entries(emoji).map(([word, glyph]) => [\n normalizeCaptionWord(word),\n glyph,\n ]),\n );\n\n return (\n <div\n className={className}\n style={{\n fontSize,\n fontWeight,\n color,\n lineHeight: 1.2,\n textAlign: \"center\",\n opacity: Math.min(enter, exit),\n transform: `translateY(${(1 - enter) * RISE_EM}em)`,\n }}\n >\n {groupCaptionWords(state.tokens).map((word, w) => {\n const first = word[0].token;\n const glyph = lookup.get(normalizeCaptionWord(captionWordText(word)));\n const pop =\n glyph && first.status !== \"upcoming\"\n ? spring({\n frame: ((state.timeMs - first.fromMs) / 1000) * fps,\n fps,\n config: POP_SPRING,\n })\n : 0;\n return (\n <Fragment key={`${state.pageIndex}-${word[0].index}`}>\n {w > 0 && \" \"}\n <span\n style={{\n position: \"relative\",\n display: \"inline-block\",\n whiteSpace: \"nowrap\",\n textShadow: shadow ? LEGIBILITY_SHADOW : undefined,\n }}\n >\n {glyph && pop > 0 && (\n <span\n aria-hidden\n style={{\n position: \"absolute\",\n left: \"50%\",\n bottom: \"92%\",\n fontSize: `${emojiSize}em`,\n lineHeight: 1,\n textShadow: \"none\",\n transformOrigin: \"50% 100%\",\n transform: `translateX(-50%) rotate(${14 - 20 * pop}deg) scale(${pop})`,\n }}\n >\n {glyph}\n </span>\n )}\n {word.map(({ index, token }) => (\n <span key={index}>{token.text}</span>\n ))}\n </span>\n </Fragment>\n );\n })}\n </div>\n );\n}\n",+ "type": "registry:component",+ "target": "components/remocn/caption-emoji.tsx"+ }+ ],+ "type": "registry:component"+}diff --git a/registry-artifacts/caption-handwrite.json b/registry-artifacts/caption-handwrite.jsonnew file mode 100644index 00000000..41c62193--- /dev/null+++ b/registry-artifacts/caption-handwrite.json@@ -0,0 +1,17 @@+{+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",+ "name": "caption-handwrite",+ "title": "Caption Handwrite",+ "description": "Each word is inked in by hand from left to right at the pace it is spoken, every word sitting at its own slight angle.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "registry/remocn/caption-handwrite/index.tsx",+ "content": "\"use client\";\n\nimport { Fragment } from \"react\";\nimport { Easing, interpolate, random } from \"remotion\";\nimport {\n type CaptionBaseProps,\n captionWordText,\n DEFAULT_HOLD_MS,\n getExitWindowMs,\n groupCaptionWords,\n useCaptions,\n} from \"@/lib/remocn/caption-core\";\n\nexport interface CaptionHandwriteProps extends CaptionBaseProps {\n wobble?: number;\n shadow?: boolean;\n}\n\nconst ENTER_MS = 160;\nconst EXIT_MS = 220;\nconst MIN_WRITE_MS = 200;\nconst EDGE_PERCENT = 22;\nconst MASK_PAD_EM = 0.4;\nconst LEGIBILITY_SHADOW =\n \"0 2px 3px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.35)\";\n\nconst enterEasing = Easing.bezier(0.2, 0.8, 0.2, 1);\n\nconst clamp = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n} as const;\n\nexport function CaptionHandwrite({\n captions,\n combineTokensWithinMilliseconds = 1200,\n holdMs = DEFAULT_HOLD_MS,\n fontSize = 64,\n fontWeight = 800,\n color = \"#ffffff\",\n wobble = 1,\n shadow = true,\n className,\n}: CaptionHandwriteProps) {\n const state = useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs,\n });\n if (!state) return null;\n\n const enter = interpolate(\n state.previous ? ENTER_MS : state.sinceStartMs,\n [0, ENTER_MS],\n [0, 1],\n { ...clamp, easing: enterEasing },\n );\n const exit = state.endsInSilence\n ? interpolate(\n state.untilEndMs,\n [0, getExitWindowMs(state, EXIT_MS)],\n [0, 1],\n clamp,\n )\n : 1;\n const textShadow = shadow ? LEGIBILITY_SHADOW : undefined;\n\n return (\n <div\n className={className}\n style={{\n fontSize,\n fontWeight,\n color,\n lineHeight: 1.2,\n textAlign: \"center\",\n opacity: Math.min(enter, exit),\n }}\n >\n {groupCaptionWords(state.tokens).map((word, w) => {\n const text = captionWordText(word);\n const fromMs = word[0].token.fromMs;\n const toMs = word[word.length - 1].token.toMs;\n const writeMs = Math.max(toMs - fromMs, MIN_WRITE_MS);\n const written = interpolate(\n state.timeMs - fromMs,\n [0, writeMs],\n [0, 1],\n clamp,\n );\n const seed = `caption-handwrite-${state.pageIndex}-${word[0].index}`;\n const tilt = (random(`${seed}-tilt`) * 3 - 1.5) * wobble;\n const lift = (random(`${seed}-lift`) * 0.08 - 0.04) * wobble;\n const head = written * (100 + EDGE_PERCENT);\n const stop = (percent: number): string =>\n `calc(${MASK_PAD_EM}em + (100% - ${MASK_PAD_EM * 2}em) * ${percent / 100})`;\n const mask =\n written > 0 && written < 1\n ? `linear-gradient(90deg, #000 ${stop(head - EDGE_PERCENT)}, transparent ${stop(head)})`\n : undefined;\n return (\n <Fragment key={`${state.pageIndex}-${word[0].index}`}>\n {w > 0 && \" \"}\n <span\n style={{\n display: \"inline-block\",\n whiteSpace: \"nowrap\",\n opacity: written > 0 ? 1 : 0,\n padding: `${MASK_PAD_EM}em`,\n margin: `-${MASK_PAD_EM}em`,\n transform: `translateY(${lift}em) rotate(${tilt}deg)`,\n WebkitMaskImage: mask,\n maskImage: mask,\n textShadow,\n }}\n >\n {Array.from(text).map((char, c) => (\n <span\n key={c}\n style={{\n display: \"inline-block\",\n whiteSpace: \"pre\",\n transform: `rotate(${(random(`${seed}-${c}`) * 6 - 3) * wobble}deg)`,\n }}\n >\n {char}\n </span>\n ))}\n </span>\n </Fragment>\n );\n })}\n </div>\n );\n}\n",+ "type": "registry:component",+ "target": "components/remocn/caption-handwrite.tsx"+ }+ ],+ "type": "registry:component"+}diff --git a/registry-artifacts/caption-highlight-box.json b/registry-artifacts/caption-highlight-box.jsonnew file mode 100644index 00000000..510efc84--- /dev/null+++ b/registry-artifacts/caption-highlight-box.json@@ -0,0 +1,17 @@+{+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",+ "name": "caption-highlight-box",+ "title": "Caption Highlight Box",+ "description": "A solid box travels behind the word being spoken, sliding from word to word as the voice moves on.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "registry/remocn/caption-highlight-box/index.tsx",+ "content": "\"use client\";\n\nimport { Fragment } from \"react\";\nimport { Easing, interpolate, interpolateColors } from \"remotion\";\nimport {\n type CaptionBaseProps,\n DEFAULT_HOLD_MS,\n getExitWindowMs,\n groupCaptionWords,\n useCaptions,\n useCaptionWordRects,\n} from \"@/lib/remocn/caption-core\";\n\nexport interface CaptionHighlightBoxProps extends CaptionBaseProps {\n activeColor?: string;\n boxColor?: string;\n boxRadius?: number;\n boxPadding?: number;\n shadow?: boolean;\n}\n\nconst ENTER_MS = 160;\nconst EXIT_MS = 220;\nconst RISE_EM = 0.14;\nconst TRAVEL_MS = 120;\n\nconst enterEasing = Easing.bezier(0.2, 0.8, 0.2, 1);\nconst travelEasing = Easing.bezier(0.3, 0, 0.2, 1);\n\nconst clamp = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n} as const;\n\nfunction legibilityShadow(strength: number): string | undefined {\n if (strength <= 0) return undefined;\n return `0 2px 3px rgba(0, 0, 0, ${0.5 * strength}), 0 4px 16px rgba(0, 0, 0, ${0.35 * strength})`;\n}\n\nfunction mix(a: number, b: number, t: number): number {\n return a + (b - a) * t;\n}\n\nexport function CaptionHighlightBox({\n captions,\n combineTokensWithinMilliseconds = 1200,\n holdMs = DEFAULT_HOLD_MS,\n fontSize = 64,\n fontWeight = 800,\n color = \"#ffffff\",\n activeColor = \"#0a0a0a\",\n boxColor = \"#facc15\",\n boxRadius = 0.16,\n boxPadding = 0.14,\n shadow = true,\n className,\n}: CaptionHighlightBoxProps) {\n const state = useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs,\n });\n const words = state ? groupCaptionWords(state.tokens) : [];\n const pageIndex = state ? state.pageIndex : -1;\n const { wordRef, rects } = useCaptionWordRects(pageIndex, words.length);\n\n if (!state) return null;\n\n const enter = interpolate(\n state.previous ? ENTER_MS : state.sinceStartMs,\n [0, ENTER_MS],\n [0, 1],\n {\n ...clamp,\n easing: enterEasing,\n },\n );\n const exit = state.endsInSilence\n ? interpolate(\n state.untilEndMs,\n [0, getExitWindowMs(state, EXIT_MS)],\n [0, 1],\n clamp,\n )\n : 1;\n\n const activeWord = words.findIndex((word) =>\n word.some(({ index }) => index === state.activeIndex),\n );\n const travel =\n activeWord >= 0\n ? interpolate(\n state.timeMs - words[activeWord][0].token.fromMs,\n [0, TRAVEL_MS],\n [0, 1],\n { ...clamp, easing: travelEasing },\n )\n : 0;\n\n const target = rects && activeWord >= 0 ? rects[activeWord] : null;\n const origin = rects && activeWord > 0 ? rects[activeWord - 1] : null;\n const padX = boxPadding * fontSize;\n const padY = boxPadding * 0.3 * fontSize;\n const box = target\n ? {\n left: origin ? mix(origin.left, target.left, travel) : target.left,\n top: origin ? mix(origin.top, target.top, travel) : target.top,\n width: origin ? mix(origin.width, target.width, travel) : target.width,\n height: origin\n ? mix(origin.height, target.height, travel)\n : target.height,\n opacity: origin ? 1 : travel,\n }\n : null;\n\n const coverage = (w: number): number => {\n if (!box) return 0;\n if (w === activeWord) {\n return origin ? interpolate(travel, [0.3, 0.8], [0, 1], clamp) : travel;\n }\n if (origin && w === activeWord - 1) {\n return 1 - interpolate(travel, [0.2, 0.7], [0, 1], clamp);\n }\n return 0;\n };\n\n return (\n <div\n className={className}\n style={{\n position: \"relative\",\n isolation: \"isolate\",\n fontSize,\n fontWeight,\n color,\n lineHeight: 1.2,\n textAlign: \"center\",\n opacity: Math.min(enter, exit),\n transform: `translateY(${(1 - enter) * RISE_EM}em)`,\n }}\n >\n {box && (\n <span\n aria-hidden\n style={{\n position: \"absolute\",\n left: box.left - padX,\n top: box.top - padY,\n width: box.width + padX * 2,\n height: box.height + padY * 2,\n borderRadius: boxRadius * fontSize,\n background: boxColor,\n opacity: box.opacity,\n }}\n />\n )}\n {words.map((word, w) => {\n const covered = coverage(w);\n return (\n <Fragment key={`${state.pageIndex}-${word[0].index}`}>\n {w > 0 && \" \"}\n <span\n ref={wordRef(w)}\n style={{\n position: \"relative\",\n display: \"inline-block\",\n whiteSpace: \"nowrap\",\n color: interpolateColors(covered, [0, 1], [color, activeColor]),\n textShadow: legibilityShadow(shadow ? 1 - covered : 0),\n }}\n >\n {word.map(({ index, token }) => (\n <span key={index}>{token.text}</span>\n ))}\n </span>\n </Fragment>\n );\n })}\n </div>\n );\n}\n",+ "type": "registry:component",+ "target": "components/remocn/caption-highlight-box.tsx"+ }+ ],+ "type": "registry:component"+}diff --git a/registry-artifacts/caption-karaoke.json b/registry-artifacts/caption-karaoke.jsonnew file mode 100644index 00000000..77ccfb9b--- /dev/null+++ b/registry-artifacts/caption-karaoke.json@@ -0,0 +1,17 @@+{+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",+ "name": "caption-karaoke",+ "title": "Caption Karaoke",+ "description": "Transcript captions where each word fills with colour left to right exactly as it is spoken, the whole phrase readable before the voice reaches it.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "registry/remocn/caption-karaoke/index.tsx",+ "content": "\"use client\";\n\nimport { Fragment } from \"react\";\nimport { Easing, interpolate } from \"remotion\";\nimport {\n type CaptionBaseProps,\n DEFAULT_HOLD_MS,\n getExitWindowMs,\n groupCaptionWords,\n useCaptions,\n} from \"@/lib/remocn/caption-core\";\n\nexport interface CaptionKaraokeProps extends CaptionBaseProps {\n activeColor?: string;\n shadow?: boolean;\n}\n\nconst ENTER_MS = 160;\nconst EXIT_MS = 220;\nconst RISE_EM = 0.14;\nconst LEGIBILITY_SHADOW =\n \"0 2px 3px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.35)\";\n\nconst enterEasing = Easing.bezier(0.2, 0.8, 0.2, 1);\n\nexport function CaptionKaraoke({\n captions,\n combineTokensWithinMilliseconds = 1200,\n holdMs = DEFAULT_HOLD_MS,\n fontSize = 64,\n fontWeight = 800,\n color = \"#ffffff\",\n activeColor = \"#facc15\",\n shadow = true,\n className,\n}: CaptionKaraokeProps) {\n const state = useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs,\n });\n if (!state) return null;\n\n const enter = interpolate(\n state.previous ? ENTER_MS : state.sinceStartMs,\n [0, ENTER_MS],\n [0, 1],\n {\n easing: enterEasing,\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n },\n );\n const exit = state.endsInSilence\n ? interpolate(\n state.untilEndMs,\n [0, getExitWindowMs(state, EXIT_MS)],\n [0, 1],\n {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n },\n )\n : 1;\n\n return (\n <div\n className={className}\n style={{\n fontSize,\n fontWeight,\n color,\n lineHeight: 1.2,\n textAlign: \"center\",\n opacity: Math.min(enter, exit),\n transform: `translateY(${(1 - enter) * RISE_EM}em)`,\n }}\n >\n {groupCaptionWords(state.tokens).map((word, w) => (\n <Fragment key={`${state.pageIndex}-${word[0].index}`}>\n {w > 0 && \" \"}\n <span style={{ display: \"inline-block\", whiteSpace: \"nowrap\" }}>\n {word.map(({ index, token }) => (\n <span\n key={index}\n style={{ position: \"relative\", display: \"inline-block\" }}\n >\n <span\n style={{ textShadow: shadow ? LEGIBILITY_SHADOW : undefined }}\n >\n {token.text}\n </span>\n <span\n aria-hidden\n style={{\n position: \"absolute\",\n inset: 0,\n color: activeColor,\n clipPath: `inset(0 ${(1 - token.progress) * 100}% 0 0)`,\n }}\n >\n {token.text}\n </span>\n </span>\n ))}\n </span>\n </Fragment>\n ))}\n </div>\n );\n}\n",+ "type": "registry:component",+ "target": "components/remocn/caption-karaoke.tsx"+ }+ ],+ "type": "registry:component"+}diff --git a/registry-artifacts/caption-knockout.json b/registry-artifacts/caption-knockout.jsonnew file mode 100644index 00000000..80ef5383--- /dev/null+++ b/registry-artifacts/caption-knockout.json@@ -0,0 +1,17 @@+{+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",+ "name": "caption-knockout",+ "title": "Caption Knockout",+ "description": "A solid plate with the words cut clean through it, each word punching out the moment it is spoken so the footage shows through the letters.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "registry/remocn/caption-knockout/index.tsx",+ "content": "\"use client\";\n\nimport { Fragment, useId } from \"react\";\nimport { Easing, interpolate } from \"remotion\";\nimport {\n type CaptionBaseProps,\n type CaptionTokenState,\n DEFAULT_HOLD_MS,\n getExitWindowMs,\n groupCaptionWords,\n useCaptions,\n useCaptionWordRects,\n} from \"@/lib/remocn/caption-core\";\n\nexport interface CaptionKnockoutProps extends Omit<CaptionBaseProps, \"color\"> {\n plateColor?: string;\n upcomingOpacity?: number;\n radius?: number;\n}\n\nconst ENTER_MS = 160;\nconst EXIT_MS = 220;\nconst RISE_EM = 0.14;\nconst PUNCH_MS = 120;\nconst PAD_Y_EM = 0.22;\nconst PAD_X_EM = 0.42;\n\nconst enterEasing = Easing.bezier(0.2, 0.8, 0.2, 1);\nconst punchEasing = Easing.bezier(0.2, 0.8, 0.2, 1);\n\nconst clamp = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n} as const;\n\nfunction holeFill(\n token: CaptionTokenState,\n timeMs: number,\n upcomingOpacity: number,\n): string {\n const since = timeMs - token.fromMs;\n const hole =\n since < 0\n ? upcomingOpacity\n : interpolate(since, [0, PUNCH_MS], [upcomingOpacity, 1], {\n ...clamp,\n easing: punchEasing,\n });\n const level = Math.round(255 * (1 - Math.min(1, Math.max(0, hole))));\n return `rgb(${level}, ${level}, ${level})`;\n}\n\nexport function CaptionKnockout({\n captions,\n combineTokensWithinMilliseconds = 1200,\n holdMs = DEFAULT_HOLD_MS,\n fontSize = 64,\n fontWeight = 800,\n plateColor = \"#ffffff\",\n upcomingOpacity = 0.15,\n radius = 0.16,\n className,\n}: CaptionKnockoutProps) {\n const maskId = `caption-knockout-${useId().replace(/[^a-zA-Z0-9-]/g, \"\")}`;\n const state = useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs,\n });\n const words = state ? groupCaptionWords(state.tokens) : [];\n const { wordRef, rects } = useCaptionWordRects(\n state ? state.pageIndex : -1,\n words.length,\n );\n if (!state) return null;\n\n const enter = interpolate(\n state.previous ? ENTER_MS : state.sinceStartMs,\n [0, ENTER_MS],\n [0, 1],\n { ...clamp, easing: enterEasing },\n );\n const exit = state.endsInSilence\n ? interpolate(\n state.untilEndMs,\n [0, getExitWindowMs(state, EXIT_MS)],\n [0, 1],\n clamp,\n )\n : 1;\n\n return (\n <div\n className={className}\n style={{\n position: \"relative\",\n fontSize,\n fontWeight,\n lineHeight: 1.2,\n textAlign: \"center\",\n padding: `${PAD_Y_EM}em ${PAD_X_EM}em`,\n opacity: Math.min(enter, exit),\n transform: `translateY(${(1 - enter) * RISE_EM}em)`,\n }}\n >\n {rects && (\n <svg\n aria-hidden\n width=\"100%\"\n height=\"100%\"\n style={{\n position: \"absolute\",\n inset: 0,\n width: \"100%\",\n height: \"100%\",\n overflow: \"visible\",\n }}\n >\n <defs>\n <mask\n id={maskId}\n maskUnits=\"userSpaceOnUse\"\n x=\"0\"\n y=\"0\"\n width=\"100%\"\n height=\"100%\"\n >\n <rect width=\"100%\" height=\"100%\" fill=\"#ffffff\" />\n {words.map((word, w) => {\n const rect = rects[w];\n if (!rect) return null;\n return (\n <text\n key={`${state.pageIndex}-${word[0].index}`}\n x={rect.left}\n y={rect.top + rect.height / 2}\n dominantBaseline=\"central\"\n >\n {word.map(({ index, token }) => (\n <tspan\n key={index}\n fill={holeFill(token, state.timeMs, upcomingOpacity)}\n >\n {token.text}\n </tspan>\n ))}\n </text>\n );\n })}\n </mask>\n </defs>\n <rect\n width=\"100%\"\n height=\"100%\"\n rx={radius * fontSize}\n fill={plateColor}\n mask={`url(#${maskId})`}\n />\n </svg>\n )}\n {words.map((word, w) => (\n <Fragment key={`${state.pageIndex}-${word[0].index}`}>\n {w > 0 && \" \"}\n <span\n ref={wordRef(w)}\n style={{\n display: \"inline-block\",\n whiteSpace: \"nowrap\",\n color: \"transparent\",\n }}\n >\n {word.map(({ index, token }) => (\n <span key={index}>{token.text}</span>\n ))}\n </span>\n </Fragment>\n ))}\n </div>\n );\n}\n",+ "type": "registry:component",+ "target": "components/remocn/caption-knockout.tsx"+ }+ ],+ "type": "registry:component"+}diff --git a/registry-artifacts/caption-label-maker.json b/registry-artifacts/caption-label-maker.jsonnew file mode 100644index 00000000..4e1a4e85--- /dev/null+++ b/registry-artifacts/caption-label-maker.json@@ -0,0 +1,17 @@+{+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",+ "name": "caption-label-maker",+ "title": "Caption Label Maker",+ "description": "Each phrase is punched letter by letter into a strip of embossing tape at the pace it is spoken, the tape feeding out as the words arrive.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "registry/remocn/caption-label-maker/index.tsx",+ "content": "\"use client\";\n\nimport { type CSSProperties, Fragment } from \"react\";\nimport { Easing, interpolate } from \"remotion\";\nimport {\n type CaptionBaseProps,\n captionWordText,\n DEFAULT_HOLD_MS,\n getExitWindowMs,\n groupCaptionWords,\n useCaptions,\n} from \"@/lib/remocn/caption-core\";\n\nexport interface CaptionLabelMakerProps extends CaptionBaseProps {\n tapeColor?: string;\n}\n\nconst ENTER_MS = 160;\nconst EXIT_MS = 220;\nconst RISE_EM = 0.14;\nconst PRESS_MS = 50;\nconst PRESS_SCALE = 0.92;\nconst TILT_DEG = -1.5;\nconst PAD_Y = 0.16;\nconst LEAD_EM = 0.42;\nconst RADIUS = 0.16;\nconst EMBOSS = \"0 1px 0 rgba(0, 0, 0, 0.55)\";\nconst RELIEF =\n \"inset 0 1px 0 rgba(255, 255, 255, 0.14), inset 0 -1px 0 rgba(0, 0, 0, 0.5)\";\n\nconst enterEasing = Easing.bezier(0.2, 0.8, 0.2, 1);\n\nconst clamp = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n} as const;\n\nfunction revealedCount(\n count: number,\n fromMs: number,\n toMs: number,\n timeMs: number,\n): number {\n if (timeMs < fromMs) return 0;\n const duration = Math.max(toMs - fromMs, 1);\n return Math.min(\n count,\n Math.floor(((timeMs - fromMs) / duration) * count) + 1,\n );\n}\n\nexport function CaptionLabelMaker({\n captions,\n combineTokensWithinMilliseconds = 1000,\n holdMs = DEFAULT_HOLD_MS,\n fontSize = 64,\n fontWeight = 800,\n color = \"#ffffff\",\n tapeColor = \"#18181b\",\n className,\n}: CaptionLabelMakerProps) {\n const state = useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs,\n });\n if (!state) return null;\n\n const enter = interpolate(\n state.previous ? ENTER_MS : state.sinceStartMs,\n [0, ENTER_MS],\n [0, 1],\n { ...clamp, easing: enterEasing },\n );\n const exit = state.endsInSilence\n ? interpolate(\n state.untilEndMs,\n [0, getExitWindowMs(state, EXIT_MS)],\n [0, 1],\n clamp,\n )\n : 1;\n\n const segment: CSSProperties = {\n display: \"inline-block\",\n verticalAlign: \"top\",\n background: tapeColor,\n paddingBlock: `${PAD_Y}em`,\n paddingRight: 1,\n marginRight: -1,\n boxShadow: RELIEF,\n };\n\n const words = groupCaptionWords(state.tokens).map((word) => {\n const chars = Array.from(captionWordText(word));\n const fromMs = word[0].token.fromMs;\n const toMs = word[word.length - 1].token.toMs;\n return {\n key: `${state.pageIndex}-${word[0].index}`,\n chars,\n fromMs,\n toMs,\n revealed: revealedCount(chars.length, fromMs, toMs, state.timeMs),\n };\n });\n const last = words[words.length - 1];\n const finished = last !== undefined && last.revealed === last.chars.length;\n\n return (\n <div\n className={className}\n style={{\n fontSize,\n fontWeight,\n color,\n lineHeight: 1.1,\n textAlign: \"center\",\n opacity: Math.min(enter, exit),\n transform: `translateY(${(1 - enter) * RISE_EM}em)`,\n }}\n >\n <span\n style={{\n display: \"inline-block\",\n whiteSpace: \"nowrap\",\n transform: `rotate(${TILT_DEG}deg)`,\n filter: \"drop-shadow(0 2px 4px rgba(0, 0, 0, 0.35))\",\n }}\n >\n <span\n style={{\n ...segment,\n width: `${LEAD_EM}em`,\n borderRadius: `${RADIUS}em 0 0 ${RADIUS}em`,\n }}\n >\n {\"\\u00a0\"}\n </span>\n {words.map((word, w) => {\n const duration = Math.max(word.toMs - word.fromMs, 1);\n return (\n <Fragment key={word.key}>\n {w > 0 && (\n <span\n style={{\n ...segment,\n visibility: word.revealed > 0 ? \"visible\" : \"hidden\",\n }}\n >\n {\"\\u00a0\"}\n </span>\n )}\n {word.chars.map((char, c) => {\n const pressedAt =\n word.fromMs + (c / word.chars.length) * duration;\n const press = interpolate(\n state.timeMs - pressedAt,\n [0, PRESS_MS],\n [PRESS_SCALE, 1],\n clamp,\n );\n return (\n <span\n key={c}\n style={{\n ...segment,\n visibility: c < word.revealed ? \"visible\" : \"hidden\",\n }}\n >\n <span\n style={{\n display: \"inline-block\",\n transform: `scale(${press})`,\n textShadow: EMBOSS,\n }}\n >\n {char}\n </span>\n </span>\n );\n })}\n </Fragment>\n );\n })}\n <span\n style={{\n ...segment,\n width: `${LEAD_EM}em`,\n borderRadius: `0 ${RADIUS}em ${RADIUS}em 0`,\n visibility: finished ? \"visible\" : \"hidden\",\n }}\n >\n {\"\\u00a0\"}\n </span>\n </span>\n </div>\n );\n}\n",+ "type": "registry:component",+ "target": "components/remocn/caption-label-maker.tsx"+ }+ ],+ "type": "registry:component"+}diff --git a/registry-artifacts/caption-marker.json b/registry-artifacts/caption-marker.jsonnew file mode 100644index 00000000..60b27513--- /dev/null+++ b/registry-artifacts/caption-marker.json@@ -0,0 +1,17 @@+{+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",+ "name": "caption-marker",+ "title": "Caption Marker",+ "description": "Plain captions where the words that matter get a highlighter swipe the moment they are spoken.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "registry/remocn/caption-marker/index.tsx",+ "content": "\"use client\";\n\nimport { Fragment } from \"react\";\nimport { Easing, interpolate } from \"remotion\";\nimport {\n type CaptionBaseProps,\n captionWordText,\n createKeywordMatcher,\n DEFAULT_HOLD_MS,\n getExitWindowMs,\n groupCaptionWords,\n useCaptions,\n} from \"@/lib/remocn/caption-core\";\n\nexport interface CaptionMarkerProps extends CaptionBaseProps {\n keywords?: string[];\n markerColor?: string;\n markerTextColor?: string;\n shadow?: boolean;\n}\n\nconst ENTER_MS = 160;\nconst EXIT_MS = 220;\nconst RISE_EM = 0.14;\nconst MIN_DRAW_MS = 220;\nconst PAD_EM = 0.12;\nconst RADIUS_EM = 0.18;\nconst TILT_DEG = -1;\nconst BAND_TOP = \"12%\";\nconst BAND_BOTTOM = \"2%\";\n\nconst enterEasing = Easing.bezier(0.2, 0.8, 0.2, 1);\nconst drawEasing = Easing.bezier(0.25, 1, 0.5, 1);\n\nconst clamp = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n} as const;\n\nfunction legibilityShadow(strength: number): string | undefined {\n if (strength <= 0) return undefined;\n return `0 2px 3px rgba(0, 0, 0, ${0.5 * strength}), 0 4px 16px rgba(0, 0, 0, ${0.35 * strength})`;\n}\n\nexport function CaptionMarker({\n captions,\n combineTokensWithinMilliseconds = 1200,\n holdMs = DEFAULT_HOLD_MS,\n fontSize = 64,\n fontWeight = 800,\n color = \"#ffffff\",\n keywords,\n markerColor = \"#facc15\",\n markerTextColor = \"#0a0a0a\",\n shadow = true,\n className,\n}: CaptionMarkerProps) {\n const state = useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs,\n });\n if (!state) return null;\n\n const isKeyword = createKeywordMatcher(keywords);\n const enter = interpolate(\n state.previous ? ENTER_MS : state.sinceStartMs,\n [0, ENTER_MS],\n [0, 1],\n {\n ...clamp,\n easing: enterEasing,\n },\n );\n const exit = state.endsInSilence\n ? interpolate(\n state.untilEndMs,\n [0, getExitWindowMs(state, EXIT_MS)],\n [0, 1],\n clamp,\n )\n : 1;\n const baseShadow = shadow ? 1 : 0;\n\n return (\n <div\n className={className}\n style={{\n fontSize,\n fontWeight,\n color,\n lineHeight: 1.2,\n textAlign: \"center\",\n opacity: Math.min(enter, exit),\n transform: `translateY(${(1 - enter) * RISE_EM}em)`,\n }}\n >\n {groupCaptionWords(state.tokens).map((word, w) => {\n const key = `${state.pageIndex}-${word[0].index}`;\n const text = word.map(({ index, token }) => (\n <span key={index}>{token.text}</span>\n ));\n if (!isKeyword(captionWordText(word))) {\n return (\n <Fragment key={key}>\n {w > 0 && \" \"}\n <span\n style={{\n display: \"inline-block\",\n whiteSpace: \"nowrap\",\n textShadow: legibilityShadow(baseShadow),\n }}\n >\n {text}\n </span>\n </Fragment>\n );\n }\n const fromMs = word[0].token.fromMs;\n const toMs = word[word.length - 1].token.toMs;\n const drawMs = Math.max(toMs - fromMs, MIN_DRAW_MS);\n const drawn = interpolate(state.timeMs - fromMs, [0, drawMs], [0, 1], {\n ...clamp,\n easing: drawEasing,\n });\n const hidden = `${(1 - drawn) * 100}%`;\n return (\n <Fragment key={key}>\n {w > 0 && \" \"}\n <span\n style={{\n position: \"relative\",\n display: \"inline-block\",\n whiteSpace: \"nowrap\",\n padding: `0 ${PAD_EM}em`,\n margin: `0 -${PAD_EM}em`,\n }}\n >\n <span\n aria-hidden\n style={{\n position: \"absolute\",\n left: 0,\n right: 0,\n top: BAND_TOP,\n bottom: BAND_BOTTOM,\n background: markerColor,\n borderRadius: `${RADIUS_EM}em`,\n transform: `rotate(${TILT_DEG}deg)`,\n clipPath: `inset(0 ${hidden} 0 0 round ${RADIUS_EM}em)`,\n }}\n />\n <span\n style={{\n position: \"relative\",\n textShadow: legibilityShadow(baseShadow * (1 - drawn)),\n }}\n >\n {text}\n </span>\n <span\n aria-hidden\n style={{\n position: \"absolute\",\n inset: 0,\n padding: `0 ${PAD_EM}em`,\n color: markerTextColor,\n clipPath: `inset(${BAND_TOP} ${hidden} ${BAND_BOTTOM} 0)`,\n }}\n >\n {text}\n </span>\n </span>\n </Fragment>\n );\n })}\n </div>\n );\n}\n",+ "type": "registry:component",+ "target": "components/remocn/caption-marker.tsx"+ }+ ],+ "type": "registry:component"+}diff --git a/registry-artifacts/caption-outline.json b/registry-artifacts/caption-outline.jsonnew file mode 100644index 00000000..7b03bcbd--- /dev/null+++ b/registry-artifacts/caption-outline.json@@ -0,0 +1,17 @@+{+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",+ "name": "caption-outline",+ "title": "Caption Outline",+ "description": "Heavy-stroked captions that stay readable over any footage, with the spoken word switching to a contrast colour and nothing else moving.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "registry/remocn/caption-outline/index.tsx",+ "content": "\"use client\";\n\nimport { Fragment } from \"react\";\nimport { Easing, interpolate, interpolateColors } from \"remotion\";\nimport {\n type CaptionBaseProps,\n captionWordText,\n DEFAULT_HOLD_MS,\n getExitWindowMs,\n groupCaptionWords,\n useCaptions,\n} from \"@/lib/remocn/caption-core\";\n\nexport interface CaptionOutlineProps extends CaptionBaseProps {\n activeColor?: string;\n strokeColor?: string;\n strokeWidth?: number;\n}\n\nconst ENTER_MS = 160;\nconst EXIT_MS = 220;\nconst RISE_EM = 0.14;\nconst SWITCH_MS = 70;\n\nconst enterEasing = Easing.bezier(0.2, 0.8, 0.2, 1);\n\nconst clamp = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n} as const;\n\nexport function CaptionOutline({\n captions,\n combineTokensWithinMilliseconds = 1200,\n holdMs = DEFAULT_HOLD_MS,\n fontSize = 64,\n fontWeight = 800,\n color = \"#ffffff\",\n activeColor = \"#facc15\",\n strokeColor = \"#000000\",\n strokeWidth = 0.12,\n className,\n}: CaptionOutlineProps) {\n const state = useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs,\n });\n if (!state) return null;\n\n const enter = interpolate(\n state.previous ? ENTER_MS : state.sinceStartMs,\n [0, ENTER_MS],\n [0, 1],\n {\n ...clamp,\n easing: enterEasing,\n },\n );\n const exit = state.endsInSilence\n ? interpolate(\n state.untilEndMs,\n [0, getExitWindowMs(state, EXIT_MS)],\n [0, 1],\n clamp,\n )\n : 1;\n\n const words = groupCaptionWords(state.tokens);\n const activeWord = words.findIndex((word) =>\n word.some(({ index }) => index === state.activeIndex),\n );\n const activeSince =\n activeWord >= 0 ? state.timeMs - words[activeWord][0].token.fromMs : 0;\n const highlight = (w: number): number => {\n if (w === activeWord) {\n return interpolate(activeSince, [0, SWITCH_MS], [0, 1], clamp);\n }\n if (w === activeWord - 1) {\n return 1 - interpolate(activeSince, [0, SWITCH_MS], [0, 1], clamp);\n }\n return 0;\n };\n\n return (\n <div\n className={className}\n style={{\n fontSize,\n fontWeight,\n color,\n lineHeight: 1.2,\n textAlign: \"center\",\n WebkitTextStroke: `${strokeWidth * 2}em ${strokeColor}`,\n paintOrder: \"stroke fill\",\n opacity: Math.min(enter, exit),\n transform: `translateY(${(1 - enter) * RISE_EM}em)`,\n }}\n >\n {words.map((word, w) => (\n <Fragment key={`${state.pageIndex}-${word[0].index}`}>\n {w > 0 && \" \"}\n <span\n style={{\n display: \"inline-block\",\n whiteSpace: \"nowrap\",\n color: interpolateColors(\n highlight(w),\n [0, 1],\n [color, activeColor],\n ),\n }}\n >\n {captionWordText(word)}\n </span>\n </Fragment>\n ))}\n </div>\n );\n}\n",+ "type": "registry:component",+ "target": "components/remocn/caption-outline.tsx"+ }+ ],+ "type": "registry:component"+}diff --git a/registry-artifacts/caption-prosody.json b/registry-artifacts/caption-prosody.jsonnew file mode 100644index 00000000..fde90dc3--- /dev/null+++ b/registry-artifacts/caption-prosody.json@@ -0,0 +1,17 @@+{+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",+ "name": "caption-prosody",+ "title": "Caption Prosody",+ "description": "Word size follows the delivery, so drawn-out words land large and rushed words stay small, and the rhythm of the voice is visible with the sound off.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "registry/remocn/caption-prosody/index.tsx",+ "content": "\"use client\";\n\nimport { Fragment } from \"react\";\nimport { Easing, interpolate } from \"remotion\";\nimport {\n type CaptionBaseProps,\n type CaptionTokenState,\n captionWordText,\n DEFAULT_HOLD_MS,\n getExitWindowMs,\n groupCaptionWords,\n useCaptions,\n} from \"@/lib/remocn/caption-core\";\n\nexport interface CaptionProsodyProps extends CaptionBaseProps {\n minScale?: number;\n maxScale?: number;\n activeColor?: string;\n shadow?: boolean;\n}\n\nconst EXIT_MS = 220;\nconst WORD_IN_MS = 180;\nconst RISE_EM = 0.2;\nconst LEGIBILITY_SHADOW =\n \"0 2px 3px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.35)\";\n\nconst appearEasing = Easing.bezier(0.2, 0.8, 0.2, 1);\n\nconst clamp = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n} as const;\n\nfunction letterCount(text: string): number {\n return Math.max(1, text.match(/[\\p{L}\\p{N}]/gu)?.length ?? 0);\n}\n\nfunction median(values: number[]): number {\n const sorted = [...values].sort((a, b) => a - b);\n const mid = sorted.length >> 1;\n return sorted.length % 2 === 1\n ? sorted[mid]\n : (sorted[mid - 1] + sorted[mid]) / 2;\n}\n\nexport function getProsodyScales(\n words: { token: CaptionTokenState }[][],\n minScale: number,\n maxScale: number,\n): number[] {\n const paces = words.map((word) => {\n const fromMs = word[0].token.fromMs;\n const toMs = word[word.length - 1].token.toMs;\n return Math.max(0, toMs - fromMs) / letterCount(captionWordText(word));\n });\n const typical = median(paces);\n if (!(typical > 0)) return words.map(() => 1);\n return paces.map((pace) => {\n const t = Math.max(-1, Math.min(1, Math.log2(Math.max(pace, 1) / typical)));\n return t >= 0 ? 1 + t * (maxScale - 1) : 1 + t * (1 - minScale);\n });\n}\n\nexport function CaptionProsody({\n captions,\n combineTokensWithinMilliseconds = 1200,\n holdMs = DEFAULT_HOLD_MS,\n fontSize = 64,\n fontWeight = 800,\n color = \"#ffffff\",\n minScale = 0.75,\n maxScale = 1.6,\n activeColor = \"#facc15\",\n shadow = true,\n className,\n}: CaptionProsodyProps) {\n const state = useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs,\n });\n if (!state) return null;\n\n const exit = state.endsInSilence\n ? interpolate(\n state.untilEndMs,\n [0, getExitWindowMs(state, EXIT_MS)],\n [0, 1],\n clamp,\n )\n : 1;\n const words = groupCaptionWords(state.tokens);\n const scales = getProsodyScales(words, minScale, maxScale);\n\n return (\n <div\n className={className}\n style={{\n fontSize,\n fontWeight,\n color,\n lineHeight: 1.1,\n textAlign: \"center\",\n opacity: exit,\n }}\n >\n {words.map((word, w) => {\n const appear = interpolate(\n state.timeMs - word[0].token.fromMs,\n [0, WORD_IN_MS],\n [0, 1],\n { ...clamp, easing: appearEasing },\n );\n const active = word.some(({ index }) => index === state.activeIndex);\n return (\n <Fragment key={`${state.pageIndex}-${word[0].index}`}>\n {w > 0 && \" \"}\n <span\n style={{\n display: \"inline-block\",\n whiteSpace: \"nowrap\",\n fontSize: `${scales[w]}em`,\n color: active ? activeColor : color,\n opacity: appear,\n transform: `translateY(${(1 - appear) * RISE_EM}em)`,\n textShadow: shadow ? LEGIBILITY_SHADOW : undefined,\n }}\n >\n {captionWordText(word)}\n </span>\n </Fragment>\n );\n })}\n </div>\n );\n}\n",+ "type": "registry:component",+ "target": "components/remocn/caption-prosody.tsx"+ }+ ],+ "type": "registry:component"+}diff --git a/registry-artifacts/caption-redact.json b/registry-artifacts/caption-redact.jsonnew file mode 100644index 00000000..38f5c0e4--- /dev/null+++ b/registry-artifacts/caption-redact.json@@ -0,0 +1,17 @@+{+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",+ "name": "caption-redact",+ "title": "Caption Redact",+ "description": "The whole phrase starts blacked out like a declassified file, and each bar pulls away the moment its word is spoken.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "registry/remocn/caption-redact/index.tsx",+ "content": "\"use client\";\n\nimport { Fragment } from \"react\";\nimport { Easing, interpolate } from \"remotion\";\nimport {\n type CaptionBaseProps,\n captionWordText,\n DEFAULT_HOLD_MS,\n getExitWindowMs,\n groupCaptionWords,\n useCaptions,\n} from \"@/lib/remocn/caption-core\";\n\nexport interface CaptionRedactProps extends CaptionBaseProps {\n barColor?: string;\n shadow?: boolean;\n}\n\nconst ENTER_MS = 160;\nconst EXIT_MS = 220;\nconst RISE_EM = 0.14;\nconst MIN_REVEAL_MS = 180;\nconst OVERHANG_EM = 0.06;\nconst RADIUS_EM = 0.06;\nconst BAR_TOP = \"14%\";\nconst BAR_BOTTOM = \"6%\";\nconst LEGIBILITY_SHADOW =\n \"0 2px 3px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.35)\";\n\nconst enterEasing = Easing.bezier(0.2, 0.8, 0.2, 1);\nconst revealEasing = Easing.inOut(Easing.cubic);\n\nconst clamp = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n} as const;\n\nexport function CaptionRedact({\n captions,\n combineTokensWithinMilliseconds = 1200,\n holdMs = DEFAULT_HOLD_MS,\n fontSize = 64,\n fontWeight = 800,\n color = \"#ffffff\",\n barColor = \"#0a0a0a\",\n shadow = true,\n className,\n}: CaptionRedactProps) {\n const state = useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs,\n });\n if (!state) return null;\n\n const enter = interpolate(\n state.previous ? ENTER_MS : state.sinceStartMs,\n [0, ENTER_MS],\n [0, 1],\n { ...clamp, easing: enterEasing },\n );\n const exit = state.endsInSilence\n ? interpolate(\n state.untilEndMs,\n [0, getExitWindowMs(state, EXIT_MS)],\n [0, 1],\n clamp,\n )\n : 1;\n const textShadow = shadow ? LEGIBILITY_SHADOW : undefined;\n\n return (\n <div\n className={className}\n style={{\n fontSize,\n fontWeight,\n color,\n lineHeight: 1.2,\n textAlign: \"center\",\n opacity: Math.min(enter, exit),\n transform: `translateY(${(1 - enter) * RISE_EM}em)`,\n }}\n >\n {groupCaptionWords(state.tokens).map((word, w) => {\n const fromMs = word[0].token.fromMs;\n const toMs = word[word.length - 1].token.toMs;\n const revealMs = Math.max(toMs - fromMs, MIN_REVEAL_MS);\n const revealed = interpolate(\n state.timeMs - fromMs,\n [0, revealMs],\n [0, 1],\n { ...clamp, easing: revealEasing },\n );\n return (\n <Fragment key={`${state.pageIndex}-${word[0].index}`}>\n {w > 0 && \" \"}\n <span\n style={{\n position: \"relative\",\n display: \"inline-block\",\n whiteSpace: \"nowrap\",\n }}\n >\n <span\n style={{\n textShadow,\n visibility: revealed > 0 ? \"visible\" : \"hidden\",\n clipPath:\n revealed >= 1\n ? undefined\n : `inset(-50% ${(1 - revealed) * 100}% -50% -50%)`,\n }}\n >\n {captionWordText(word)}\n </span>\n {revealed < 1 && (\n <span\n aria-hidden\n style={{\n position: \"absolute\",\n left: `-${OVERHANG_EM}em`,\n right: `-${OVERHANG_EM}em`,\n top: BAR_TOP,\n bottom: BAR_BOTTOM,\n background: barColor,\n borderRadius: `${RADIUS_EM}em`,\n transformOrigin: \"right center\",\n transform: `scaleX(${1 - revealed})`,\n }}\n />\n )}\n </span>\n </Fragment>\n );\n })}\n </div>\n );\n}\n",+ "type": "registry:component",+ "target": "components/remocn/caption-redact.tsx"+ }+ ],+ "type": "registry:component"+}diff --git a/registry-artifacts/caption-rise.json b/registry-artifacts/caption-rise.jsonnew file mode 100644index 00000000..0b274e0a--- /dev/null+++ b/registry-artifacts/caption-rise.json@@ -0,0 +1,17 @@+{+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",+ "name": "caption-rise",+ "title": "Caption Rise",+ "description": "Each word slides up out of a mask at its baseline the moment it is spoken, with no bounce and no scale.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "registry/remocn/caption-rise/index.tsx",+ "content": "\"use client\";\n\nimport { Fragment } from \"react\";\nimport { Easing, interpolate } from \"remotion\";\nimport {\n type CaptionBaseProps,\n DEFAULT_HOLD_MS,\n getExitWindowMs,\n groupCaptionWords,\n useCaptions,\n} from \"@/lib/remocn/caption-core\";\n\nexport interface CaptionRiseProps extends CaptionBaseProps {\n shadow?: boolean;\n}\n\nconst EXIT_MS = 220;\nconst RISE_MS = 260;\nconst START_EM = 1.6;\nconst CLIP = \"inset(-0.2em -0.6em -0.35em -0.6em)\";\nconst LEGIBILITY_SHADOW =\n \"0 2px 3px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.35)\";\n\nconst riseEasing = Easing.bezier(0.16, 1, 0.3, 1);\n\nexport function CaptionRise({\n captions,\n combineTokensWithinMilliseconds = 1200,\n holdMs = DEFAULT_HOLD_MS,\n fontSize = 64,\n fontWeight = 800,\n color = \"#ffffff\",\n shadow = true,\n className,\n}: CaptionRiseProps) {\n const state = useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs,\n });\n if (!state) return null;\n\n const exit = state.endsInSilence\n ? interpolate(\n state.untilEndMs,\n [0, getExitWindowMs(state, EXIT_MS)],\n [0, 1],\n {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n },\n )\n : 1;\n\n return (\n <div\n className={className}\n style={{\n fontSize,\n fontWeight,\n color,\n lineHeight: 1.2,\n textAlign: \"center\",\n opacity: exit,\n }}\n >\n {groupCaptionWords(state.tokens).map((word, w) => (\n <Fragment key={`${state.pageIndex}-${word[0].index}`}>\n {w > 0 && \" \"}\n <span style={{ display: \"inline-block\", whiteSpace: \"nowrap\" }}>\n {word.map(({ index, token }) => {\n const sinceMs = state.timeMs - token.fromMs;\n const p =\n sinceMs < 0\n ? 0\n : interpolate(sinceMs, [0, RISE_MS], [0, 1], {\n easing: riseEasing,\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n });\n return (\n <span\n key={index}\n style={{\n display: \"inline-block\",\n clipPath: CLIP,\n }}\n >\n <span\n style={{\n display: \"inline-block\",\n opacity: sinceMs < 0 ? 0 : 1,\n transform: `translateY(${(1 - p) * START_EM}em)`,\n textShadow: shadow ? LEGIBILITY_SHADOW : undefined,\n }}\n >\n {token.text}\n </span>\n </span>\n );\n })}\n </span>\n </Fragment>\n ))}\n </div>\n );\n}\n",+ "type": "registry:component",+ "target": "components/remocn/caption-rise.tsx"+ }+ ],+ "type": "registry:component"+}diff --git a/registry-artifacts/caption-scramble.json b/registry-artifacts/caption-scramble.jsonnew file mode 100644index 00000000..77c33f56--- /dev/null+++ b/registry-artifacts/caption-scramble.json@@ -0,0 +1,17 @@+{+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",+ "name": "caption-scramble",+ "title": "Caption Scramble",+ "description": "Each word arrives as random glyphs at the moment it is spoken and decodes left to right into the real letters.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "registry/remocn/caption-scramble/index.tsx",+ "content": "\"use client\";\n\nimport { Fragment } from \"react\";\nimport { Easing, interpolate, random, useVideoConfig } from \"remotion\";\nimport {\n type CaptionBaseProps,\n DEFAULT_HOLD_MS,\n getExitWindowMs,\n groupCaptionWords,\n useCaptions,\n} from \"@/lib/remocn/caption-core\";\n\nexport interface CaptionScrambleProps extends CaptionBaseProps {\n glyphColor?: string;\n shadow?: boolean;\n}\n\nconst ENTER_MS = 160;\nconst EXIT_MS = 220;\nconst RISE_EM = 0.14;\nconst MAX_RESOLVE_MS = 300;\nconst FRAMES_PER_ROLL = 2;\nconst GLYPHS = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789#%&*/+=\";\nconst LEGIBILITY_SHADOW =\n \"0 2px 3px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.35)\";\n\nconst enterEasing = Easing.bezier(0.2, 0.8, 0.2, 1);\n\nconst clamp = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n} as const;\n\nfunction resolveProgress(sinceMs: number, fromMs: number, toMs: number) {\n const duration = Math.min(toMs - fromMs, MAX_RESOLVE_MS);\n if (duration <= 0) return 1;\n return Math.min(1, sinceMs / duration);\n}\n\nexport function CaptionScramble({\n captions,\n combineTokensWithinMilliseconds = 1200,\n holdMs = DEFAULT_HOLD_MS,\n fontSize = 64,\n fontWeight = 800,\n color = \"#ffffff\",\n glyphColor = \"#a3a3a3\",\n shadow = true,\n className,\n}: CaptionScrambleProps) {\n const { fps } = useVideoConfig();\n const state = useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs,\n });\n if (!state) return null;\n\n const enter = interpolate(\n state.previous ? ENTER_MS : state.sinceStartMs,\n [0, ENTER_MS],\n [0, 1],\n {\n ...clamp,\n easing: enterEasing,\n },\n );\n const exit = state.endsInSilence\n ? interpolate(\n state.untilEndMs,\n [0, getExitWindowMs(state, EXIT_MS)],\n [0, 1],\n clamp,\n )\n : 1;\n const step = Math.floor(((state.timeMs / 1000) * fps) / FRAMES_PER_ROLL);\n const textShadow = shadow ? LEGIBILITY_SHADOW : undefined;\n\n return (\n <div\n className={className}\n style={{\n fontSize,\n fontWeight,\n color,\n lineHeight: 1.2,\n textAlign: \"center\",\n opacity: Math.min(enter, exit),\n transform: `translateY(${(1 - enter) * RISE_EM}em)`,\n }}\n >\n {groupCaptionWords(state.tokens).map((word, w) => (\n <Fragment key={`${state.pageIndex}-${word[0].index}`}>\n {w > 0 && \" \"}\n <span style={{ display: \"inline-block\", whiteSpace: \"nowrap\" }}>\n {word.map(({ index, token }) => {\n const sinceMs = state.timeMs - token.fromMs;\n if (sinceMs < 0) {\n return (\n <span key={index} style={{ opacity: 0 }}>\n {token.text}\n </span>\n );\n }\n const progress = resolveProgress(\n sinceMs,\n token.fromMs,\n token.toMs,\n );\n if (progress >= 1) {\n return (\n <span key={index} style={{ textShadow }}>\n {token.text}\n </span>\n );\n }\n const chars = Array.from(token.text);\n const resolved = Math.floor(progress * chars.length);\n return (\n <span\n key={index}\n style={{ position: \"relative\", display: \"inline-block\" }}\n >\n <span style={{ color: \"transparent\" }}>{token.text}</span>\n <span\n aria-hidden\n style={{\n position: \"absolute\",\n left: 0,\n right: 0,\n top: 0,\n whiteSpace: \"nowrap\",\n clipPath: \"inset(-50% 0 -50% 0)\",\n textShadow,\n }}\n >\n <span>{chars.slice(0, resolved).join(\"\")}</span>\n <span style={{ color: glyphColor }}>\n {chars\n .slice(resolved)\n .map((char, c) =>\n /\\s/.test(char)\n ? char\n : GLYPHS[\n Math.floor(\n random(\n `${state.pageIndex}-${index}-${resolved + c}-${step}`,\n ) * GLYPHS.length,\n )\n ],\n )\n .join(\"\")}\n </span>\n </span>\n </span>\n );\n })}\n </span>\n </Fragment>\n ))}\n </div>\n );\n}\n",+ "type": "registry:component",+ "target": "components/remocn/caption-scramble.tsx"+ }+ ],+ "type": "registry:component"+}diff --git a/registry-artifacts/caption-slice.json b/registry-artifacts/caption-slice.jsonnew file mode 100644index 00000000..571124dc--- /dev/null+++ b/registry-artifacts/caption-slice.json@@ -0,0 +1,17 @@+{+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",+ "name": "caption-slice",+ "title": "Caption Slice",+ "description": "Each word arrives cut in two, the top half sliding in from the left and the bottom from the right, locking together the moment it is spoken.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "registry/remocn/caption-slice/index.tsx",+ "content": "\"use client\";\n\nimport { Fragment } from \"react\";\nimport { Easing, interpolate } from \"remotion\";\nimport {\n type CaptionBaseProps,\n DEFAULT_HOLD_MS,\n getExitWindowMs,\n groupCaptionWords,\n useCaptions,\n} from \"@/lib/remocn/caption-core\";\n\nexport interface CaptionSliceProps extends CaptionBaseProps {\n distance?: number;\n shadow?: boolean;\n}\n\nconst SLIDE_MS = 240;\nconst FADE_MS = 90;\nconst EXIT_MS = 220;\nconst LEGIBILITY_SHADOW =\n \"0 2px 3px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.35)\";\nconst TOP_HALF = \"inset(-0.5em -0.5em 50% -0.5em)\";\nconst BOTTOM_HALF = \"inset(50% -0.5em -0.5em -0.5em)\";\n\nconst slideEasing = Easing.bezier(0.16, 1, 0.3, 1);\n\nconst clamp = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n} as const;\n\nexport function CaptionSlice({\n captions,\n combineTokensWithinMilliseconds = 1200,\n holdMs = DEFAULT_HOLD_MS,\n fontSize = 64,\n fontWeight = 800,\n color = \"#ffffff\",\n distance = 0.6,\n shadow = true,\n className,\n}: CaptionSliceProps) {\n const state = useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs,\n });\n if (!state) return null;\n\n const exit = state.endsInSilence\n ? interpolate(\n state.untilEndMs,\n [0, getExitWindowMs(state, EXIT_MS)],\n [0, 1],\n clamp,\n )\n : 1;\n const textShadow = shadow ? LEGIBILITY_SHADOW : undefined;\n\n return (\n <div\n className={className}\n style={{\n fontSize,\n fontWeight,\n color,\n lineHeight: 1.2,\n textAlign: \"center\",\n opacity: exit,\n }}\n >\n {groupCaptionWords(state.tokens).map((word, w) => (\n <Fragment key={`${state.pageIndex}-${word[0].index}`}>\n {w > 0 && \" \"}\n <span style={{ display: \"inline-block\", whiteSpace: \"nowrap\" }}>\n {word.map(({ index, token }) => {\n const sinceMs = state.timeMs - token.fromMs;\n if (sinceMs < 0) {\n return (\n <span\n key={index}\n style={{ display: \"inline-block\", color: \"transparent\" }}\n >\n {token.text}\n </span>\n );\n }\n const slide = interpolate(sinceMs, [0, SLIDE_MS], [0, 1], {\n ...clamp,\n easing: slideEasing,\n });\n if (slide >= 1) {\n return (\n <span\n key={index}\n style={{ display: \"inline-block\", textShadow }}\n >\n {token.text}\n </span>\n );\n }\n const opacity = interpolate(sinceMs, [0, FADE_MS], [0, 1], clamp);\n const offset = (1 - slide) * distance;\n return (\n <span\n key={index}\n style={{ position: \"relative\", display: \"inline-block\" }}\n >\n <span style={{ color: \"transparent\" }}>{token.text}</span>\n <span\n aria-hidden\n style={{\n position: \"absolute\",\n inset: 0,\n whiteSpace: \"nowrap\",\n clipPath: TOP_HALF,\n opacity,\n transform: `translateX(${-offset}em)`,\n textShadow,\n }}\n >\n {token.text}\n </span>\n <span\n aria-hidden\n style={{\n position: \"absolute\",\n inset: 0,\n whiteSpace: \"nowrap\",\n clipPath: BOTTOM_HALF,\n opacity,\n transform: `translateX(${offset}em)`,\n textShadow,\n }}\n >\n {token.text}\n </span>\n </span>\n );\n })}\n </span>\n </Fragment>\n ))}\n </div>\n );\n}\n",+ "type": "registry:component",+ "target": "components/remocn/caption-slice.tsx"+ }+ ],+ "type": "registry:component"+}diff --git a/registry-artifacts/caption-slot.json b/registry-artifacts/caption-slot.jsonnew file mode 100644index 00000000..8a9cfed5--- /dev/null+++ b/registry-artifacts/caption-slot.json@@ -0,0 +1,17 @@+{+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",+ "name": "caption-slot",+ "title": "Caption Slot",+ "description": "One short line at a time, each new phrase rolling up into place as the previous one rolls out the top.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "registry/remocn/caption-slot/index.tsx",+ "content": "\"use client\";\n\nimport { type CSSProperties, Fragment } from \"react\";\nimport { Easing, interpolate } from \"remotion\";\nimport {\n type CaptionBaseProps,\n type CaptionTokenState,\n DEFAULT_HOLD_MS,\n getExitWindowMs,\n groupCaptionWords,\n useCaptions,\n} from \"@/lib/remocn/caption-core\";\n\nexport interface CaptionSlotProps extends CaptionBaseProps {\n activeColor?: string;\n shadow?: boolean;\n}\n\nconst LINE_HEIGHT = 1.3;\nconst CLIP_MARGIN_EM = 0.2;\nconst TRAVEL_EM = LINE_HEIGHT + CLIP_MARGIN_EM * 2;\nconst ROLL_MS = 260;\nconst EXIT_MS = 220;\nconst LEGIBILITY_SHADOW =\n \"0 2px 3px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.35)\";\n\nconst rollIn = Easing.bezier(0.16, 1, 0.3, 1);\nconst rollOut = Easing.bezier(0.7, 0, 0.84, 0);\n\nfunction SlotLine({\n tokens,\n activeIndex,\n activeColor,\n style,\n}: {\n tokens: CaptionTokenState[];\n activeIndex: number;\n activeColor?: string;\n style: CSSProperties;\n}) {\n return (\n <div style={{ whiteSpace: \"nowrap\", ...style }}>\n {groupCaptionWords(tokens).map((word, w) => (\n <Fragment key={word[0].index}>\n {w > 0 && \" \"}\n {word.map(({ index, token }) => (\n <span\n key={index}\n style={{\n color:\n activeColor !== undefined && index === activeIndex\n ? activeColor\n : undefined,\n }}\n >\n {token.text}\n </span>\n ))}\n </Fragment>\n ))}\n </div>\n );\n}\n\nexport function CaptionSlot({\n captions,\n combineTokensWithinMilliseconds = 800,\n holdMs = DEFAULT_HOLD_MS,\n fontSize = 64,\n fontWeight = 800,\n color = \"#ffffff\",\n activeColor,\n shadow = true,\n className,\n}: CaptionSlotProps) {\n const state = useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs,\n });\n if (!state) return null;\n\n const roll = interpolate(state.sinceStartMs, [0, ROLL_MS], [0, 1], {\n easing: rollIn,\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n });\n const exitProgress = Math.min(\n 1,\n Math.max(0, 1 - state.untilEndMs / getExitWindowMs(state, EXIT_MS)),\n );\n const exit = state.endsInSilence ? rollOut(exitProgress) : 0;\n\n return (\n <div\n className={className}\n style={{\n position: \"relative\",\n fontSize,\n fontWeight,\n color,\n lineHeight: LINE_HEIGHT,\n height: `${LINE_HEIGHT}em`,\n textAlign: \"center\",\n textShadow: shadow ? LEGIBILITY_SHADOW : undefined,\n clipPath: `inset(-${CLIP_MARGIN_EM}em -100000px)`,\n }}\n >\n {state.previous && roll < 1 ? (\n <SlotLine\n key={`page-${state.previous.pageIndex}`}\n tokens={state.previous.tokens}\n activeIndex={-1}\n style={{\n position: \"absolute\",\n top: 0,\n left: \"50%\",\n transform: `translate(-50%, ${-roll * TRAVEL_EM}em)`,\n }}\n />\n ) : null}\n <SlotLine\n key={`page-${state.pageIndex}`}\n tokens={state.tokens}\n activeIndex={state.activeIndex}\n activeColor={activeColor}\n style={{\n transform: `translateY(${(1 - roll - exit) * TRAVEL_EM}em)`,\n }}\n />\n </div>\n );\n}\n",+ "type": "registry:component",+ "target": "components/remocn/caption-slot.tsx"+ }+ ],+ "type": "registry:component"+}diff --git a/registry-artifacts/caption-speaker.json b/registry-artifacts/caption-speaker.jsonnew file mode 100644index 00000000..37a32d46--- /dev/null+++ b/registry-artifacts/caption-speaker.json@@ -0,0 +1,17 @@+{+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",+ "name": "caption-speaker",+ "title": "Caption Speaker",+ "description": "Dialogue captions where every phrase takes its speaker's colour, so a conversation reads like a script.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "registry/remocn/caption-speaker/index.tsx",+ "content": "\"use client\";\n\nimport { Fragment, useMemo } from \"react\";\nimport { Easing, interpolate } from \"remotion\";\nimport {\n type CaptionBaseProps,\n DEFAULT_HOLD_MS,\n getExitWindowMs,\n groupCaptionWords,\n type SpeakerCaption,\n useCaptions,\n} from \"@/lib/remocn/caption-core\";\n\nexport interface CaptionSpeakerProps extends CaptionBaseProps {\n captions: SpeakerCaption[];\n speakerColors?: Record<string, string>;\n upcomingOpacity?: number;\n shadow?: boolean;\n}\n\nconst SPEAKER_PALETTE = [\"#facc15\", \"#38bdf8\", \"#f472b6\", \"#4ade80\"];\n\nconst ENTER_MS = 160;\nconst EXIT_MS = 220;\nconst RISE_EM = 0.14;\nconst REVEAL_MS = 100;\nconst LEGIBILITY_SHADOW =\n \"0 2px 3px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.35)\";\n\nconst enterEasing = Easing.bezier(0.2, 0.8, 0.2, 1);\n\nconst clamp = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n} as const;\n\nexport function CaptionSpeaker({\n captions,\n combineTokensWithinMilliseconds = 1200,\n holdMs = DEFAULT_HOLD_MS,\n fontSize = 64,\n fontWeight = 800,\n color = \"#ffffff\",\n speakerColors,\n upcomingOpacity = 0.4,\n shadow = true,\n className,\n}: CaptionSpeakerProps) {\n const state = useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs,\n });\n const autoColors = useMemo(() => {\n const pinned = new Set(Object.values(speakerColors ?? {}));\n const free = SPEAKER_PALETTE.filter((c) => !pinned.has(c));\n const palette = free.length > 0 ? free : SPEAKER_PALETTE;\n const assigned = new Map<string, string>();\n for (const caption of captions) {\n const { speaker } = caption;\n if (\n speaker === undefined ||\n speakerColors?.[speaker] !== undefined ||\n assigned.has(speaker)\n ) {\n continue;\n }\n assigned.set(speaker, palette[assigned.size % palette.length]);\n }\n return assigned;\n }, [captions, speakerColors]);\n if (!state) return null;\n\n const enter = interpolate(\n state.previous ? ENTER_MS : state.sinceStartMs,\n [0, ENTER_MS],\n [0, 1],\n {\n ...clamp,\n easing: enterEasing,\n },\n );\n const exit = state.endsInSilence\n ? interpolate(\n state.untilEndMs,\n [0, getExitWindowMs(state, EXIT_MS)],\n [0, 1],\n clamp,\n )\n : 1;\n\n const { speaker } = state;\n const speakerColor =\n speaker === undefined\n ? color\n : (speakerColors?.[speaker] ?? autoColors.get(speaker) ?? color);\n\n return (\n <div\n className={className}\n style={{\n fontSize,\n fontWeight,\n color: speakerColor,\n lineHeight: 1.2,\n textAlign: \"center\",\n opacity: Math.min(enter, exit),\n transform: `translateY(${(1 - enter) * RISE_EM}em)`,\n }}\n >\n {groupCaptionWords(state.tokens).map((word, w) => (\n <Fragment key={`${state.pageIndex}-${word[0].index}`}>\n {w > 0 && \" \"}\n <span\n style={{\n display: \"inline-block\",\n whiteSpace: \"nowrap\",\n textShadow: shadow ? LEGIBILITY_SHADOW : undefined,\n }}\n >\n {word.map(({ index, token }) => (\n <span\n key={index}\n style={{\n opacity: interpolate(\n state.timeMs - token.fromMs,\n [0, REVEAL_MS],\n [upcomingOpacity, 1],\n clamp,\n ),\n }}\n >\n {token.text}\n </span>\n ))}\n </span>\n </Fragment>\n ))}\n </div>\n );\n}\n",+ "type": "registry:component",+ "target": "components/remocn/caption-speaker.tsx"+ }+ ],+ "type": "registry:component"+}diff --git a/registry-artifacts/caption-split-flap.json b/registry-artifacts/caption-split-flap.jsonnew file mode 100644index 00000000..613b287a--- /dev/null+++ b/registry-artifacts/caption-split-flap.json@@ -0,0 +1,17 @@+{+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",+ "name": "caption-split-flap",+ "title": "Caption Split Flap",+ "description": "Every letter sits on its own flap tile and clatters through a few characters before landing the moment the word is spoken, like a station departure board.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "registry/remocn/caption-split-flap/index.tsx",+ "content": "\"use client\";\n\nimport { type CSSProperties, Fragment } from \"react\";\nimport { Easing, interpolate, random } from \"remotion\";\nimport {\n type CaptionBaseProps,\n captionWordText,\n DEFAULT_HOLD_MS,\n getExitWindowMs,\n groupCaptionWords,\n useCaptions,\n} from \"@/lib/remocn/caption-core\";\n\nexport interface CaptionSplitFlapProps extends CaptionBaseProps {\n tileColor?: string;\n}\n\nconst ENTER_MS = 160;\nconst EXIT_MS = 220;\nconst RISE_EM = 0.14;\nconst FLIP_MS = 60;\nconst MIN_SETTLE_MS = 350;\nconst TILE_W = 0.78;\nconst TILE_H = 1.2;\nconst TILE_GAP = 0.06;\nconst GLYPH_SCALE = 0.8;\nconst RADIUS = 0.08;\nconst GLYPHS = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\";\n\nconst enterEasing = Easing.bezier(0.2, 0.8, 0.2, 1);\n\nconst clamp = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n} as const;\n\ninterface FlapFrame {\n current: string;\n next: string;\n progress: number | null;\n}\n\nfunction flapFrame(\n target: string,\n seed: string,\n index: number,\n count: number,\n fromMs: number,\n windowMs: number,\n timeMs: number,\n): FlapFrame {\n const flips = 3 + Math.floor(random(`${seed}-flips`) * 4);\n const share = count > 1 ? index / (count - 1) : 1;\n const endMs = fromMs + windowMs * (0.55 + 0.45 * share);\n const flipMs = Math.min(FLIP_MS, (endMs - fromMs) / flips);\n const startMs = endMs - flips * flipMs;\n if (timeMs < startMs) return { current: \"\", next: \"\", progress: null };\n if (timeMs >= endMs) return { current: target, next: target, progress: null };\n const glyphAt = (k: number): string => {\n if (k <= 0) return \"\";\n if (k >= flips) return target;\n return GLYPHS[Math.floor(random(`${seed}-${k}`) * GLYPHS.length)];\n };\n const elapsed = (timeMs - startMs) / flipMs;\n const k = Math.floor(elapsed);\n return { current: glyphAt(k), next: glyphAt(k + 1), progress: elapsed - k };\n}\n\nconst TOP_HALF = \"inset(0 0 50% 0)\";\nconst BOTTOM_HALF = \"inset(50% 0 0 0)\";\n\nfunction Leaf({\n char,\n tileColor,\n clipPath,\n transform,\n brightness = 1,\n}: {\n char: string;\n tileColor: string;\n clipPath?: string;\n transform?: string;\n brightness?: number;\n}) {\n const style: CSSProperties = {\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n background: tileColor,\n borderRadius: `${RADIUS}em`,\n clipPath,\n transform,\n transformOrigin: \"50% 50%\",\n filter: brightness < 1 ? `brightness(${brightness})` : undefined,\n };\n return (\n <span style={style}>\n <span style={{ fontSize: `${GLYPH_SCALE}em`, lineHeight: 1 }}>\n {char}\n </span>\n </span>\n );\n}\n\nfunction Tile({ frame, tileColor }: { frame: FlapFrame; tileColor: string }) {\n const perspective = `perspective(${TILE_H * 4}em)`;\n const { current, next, progress } = frame;\n return (\n <span\n style={{\n position: \"relative\",\n display: \"inline-block\",\n width: `${TILE_W}em`,\n height: `${TILE_H}em`,\n flexShrink: 0,\n }}\n >\n {progress === null ? (\n <Leaf char={current} tileColor={tileColor} />\n ) : (\n <>\n <Leaf char={next} tileColor={tileColor} clipPath={TOP_HALF} />\n <Leaf char={current} tileColor={tileColor} clipPath={BOTTOM_HALF} />\n {progress < 0.5 ? (\n <Leaf\n char={current}\n tileColor={tileColor}\n clipPath={TOP_HALF}\n transform={`${perspective} rotateX(${-180 * progress}deg)`}\n brightness={1 - 0.7 * progress}\n />\n ) : (\n <Leaf\n char={next}\n tileColor={tileColor}\n clipPath={BOTTOM_HALF}\n transform={`${perspective} rotateX(${180 * (1 - progress)}deg)`}\n brightness={0.65 + 0.7 * (progress - 0.5)}\n />\n )}\n </>\n )}\n <span\n aria-hidden\n style={{\n position: \"absolute\",\n left: 0,\n right: 0,\n top: \"50%\",\n height: \"max(1px, 0.025em)\",\n transform: \"translateY(-50%)\",\n background: \"rgba(0, 0, 0, 0.6)\",\n }}\n />\n </span>\n );\n}\n\nexport function CaptionSplitFlap({\n captions,\n combineTokensWithinMilliseconds = 1000,\n holdMs = DEFAULT_HOLD_MS,\n fontSize = 56,\n fontWeight = 800,\n color = \"#ffffff\",\n tileColor = \"#111111\",\n className,\n}: CaptionSplitFlapProps) {\n const state = useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs,\n });\n if (!state) return null;\n\n const enter = interpolate(\n state.previous ? ENTER_MS : state.sinceStartMs,\n [0, ENTER_MS],\n [0, 1],\n { ...clamp, easing: enterEasing },\n );\n const exit = state.endsInSilence\n ? interpolate(\n state.untilEndMs,\n [0, getExitWindowMs(state, EXIT_MS)],\n [0, 1],\n clamp,\n )\n : 1;\n\n return (\n <div\n className={className}\n style={{\n fontSize,\n fontWeight,\n color,\n lineHeight: TILE_H + 0.24,\n textAlign: \"center\",\n opacity: Math.min(enter, exit),\n transform: `translateY(${(1 - enter) * RISE_EM}em)`,\n }}\n >\n {groupCaptionWords(state.tokens).map((word, w) => {\n const first = word[0];\n const fromMs = first.token.fromMs;\n const toMs = word[word.length - 1].token.toMs;\n const windowMs = Math.max(toMs - fromMs, MIN_SETTLE_MS);\n const chars = Array.from(captionWordText(word));\n return (\n <Fragment key={`${state.pageIndex}-${first.index}`}>\n {w > 0 && \" \"}\n <span\n style={{\n display: \"inline-flex\",\n gap: `${TILE_GAP}em`,\n verticalAlign: \"top\",\n paddingInline: `${TILE_GAP}em`,\n }}\n >\n {chars.map((char, c) => (\n <Tile\n key={c}\n tileColor={tileColor}\n frame={flapFrame(\n char,\n `${state.pageIndex}-${first.index}-${c}`,\n c,\n chars.length,\n fromMs,\n windowMs,\n state.timeMs,\n )}\n />\n ))}\n </span>\n </Fragment>\n );\n })}\n </div>\n );\n}\n",+ "type": "registry:component",+ "target": "components/remocn/caption-split-flap.tsx"+ }+ ],+ "type": "registry:component"+}diff --git a/registry-artifacts/caption-stack.json b/registry-artifacts/caption-stack.jsonnew file mode 100644index 00000000..d609a1a4--- /dev/null+++ b/registry-artifacts/caption-stack.json@@ -0,0 +1,17 @@+{+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",+ "name": "caption-stack",+ "title": "Caption Stack",+ "description": "Kinetic captions stacked a couple of words per line, with the keyword of each page set large on its own line.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "registry/remocn/caption-stack/index.tsx",+ "content": "\"use client\";\n\nimport { Fragment } from \"react\";\nimport { Easing, interpolate } from \"remotion\";\nimport {\n type CaptionBaseProps,\n captionWordText,\n createKeywordMatcher,\n DEFAULT_HOLD_MS,\n getExitWindowMs,\n groupCaptionWords,\n normalizeCaptionWord,\n useCaptions,\n} from \"@/lib/remocn/caption-core\";\n\nexport interface CaptionStackProps extends CaptionBaseProps {\n keywords?: string[];\n emphasisScale?: number;\n emphasisColor?: string;\n shadow?: boolean;\n}\n\ntype CaptionWord = ReturnType<typeof groupCaptionWords>[number];\n\ninterface StackLine {\n words: CaptionWord[];\n emphasis: boolean;\n}\n\nconst WORDS_PER_LINE = 2;\nconst EXIT_MS = 220;\nconst FADE_IN_MS = 120;\nconst RISE_MS = 220;\nconst RISE_EM = 0.3;\nconst LEGIBILITY_SHADOW =\n \"0 2px 3px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.35)\";\n\nconst riseEasing = Easing.bezier(0.2, 0.8, 0.2, 1);\n\nconst clamp = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n} as const;\n\nfunction buildLines(\n words: CaptionWord[],\n isEmphasis: (word: CaptionWord, index: number) => boolean,\n): StackLine[] {\n const lines: StackLine[] = [];\n let current: CaptionWord[] = [];\n const flush = () => {\n if (current.length > 0) {\n lines.push({ words: current, emphasis: false });\n current = [];\n }\n };\n words.forEach((word, i) => {\n if (isEmphasis(word, i)) {\n flush();\n lines.push({ words: [word], emphasis: true });\n return;\n }\n current.push(word);\n if (current.length >= WORDS_PER_LINE) flush();\n });\n flush();\n return lines;\n}\n\nfunction longestWordIndex(words: CaptionWord[]): number {\n let longest = -1;\n let longestLength = 0;\n words.forEach((word, i) => {\n const length = normalizeCaptionWord(captionWordText(word)).length;\n if (length > longestLength) {\n longest = i;\n longestLength = length;\n }\n });\n return longest;\n}\n\nexport function CaptionStack({\n captions,\n combineTokensWithinMilliseconds = 1600,\n holdMs = DEFAULT_HOLD_MS,\n fontSize = 64,\n fontWeight = 800,\n color = \"#ffffff\",\n keywords,\n emphasisScale = 1.7,\n emphasisColor = \"#facc15\",\n shadow = true,\n className,\n}: CaptionStackProps) {\n const state = useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs,\n });\n if (!state) return null;\n\n const words = groupCaptionWords(state.tokens);\n const hasKeywords = keywords !== undefined && keywords.length > 0;\n const isKeyword = createKeywordMatcher(keywords);\n const longest = hasKeywords ? -1 : longestWordIndex(words);\n const lines = buildLines(words, (word, i) =>\n hasKeywords ? isKeyword(captionWordText(word)) : i === longest,\n );\n\n const exit = state.endsInSilence\n ? interpolate(\n state.untilEndMs,\n [0, getExitWindowMs(state, EXIT_MS)],\n [0, 1],\n clamp,\n )\n : 1;\n\n return (\n <div\n className={className}\n style={{\n fontSize,\n fontWeight,\n color,\n lineHeight: 1,\n textAlign: \"center\",\n opacity: exit,\n }}\n >\n {lines.map((line) => (\n <div\n key={`${state.pageIndex}-${line.words[0][0].index}`}\n style={{\n fontSize: line.emphasis ? `${emphasisScale}em` : undefined,\n color: line.emphasis ? emphasisColor : undefined,\n }}\n >\n {line.words.map((word, w) => {\n const sinceMs = state.timeMs - word[0].token.fromMs;\n const arrived = sinceMs >= 0;\n const rise = arrived\n ? interpolate(sinceMs, [0, RISE_MS], [0, 1], {\n ...clamp,\n easing: riseEasing,\n })\n : 0;\n const opacity = arrived\n ? interpolate(sinceMs, [0, FADE_IN_MS], [0, 1], clamp)\n : 0;\n return (\n <Fragment key={word[0].index}>\n {w > 0 && \" \"}\n <span\n style={{\n display: \"inline-block\",\n whiteSpace: \"nowrap\",\n opacity,\n transform: `translateY(${(1 - rise) * RISE_EM}em)`,\n textShadow: shadow ? LEGIBILITY_SHADOW : undefined,\n }}\n >\n {word.map(({ index, token }) => (\n <span key={index}>{token.text}</span>\n ))}\n </span>\n </Fragment>\n );\n })}\n </div>\n ))}\n </div>\n );\n}\n",+ "type": "registry:component",+ "target": "components/remocn/caption-stack.tsx"+ }+ ],+ "type": "registry:component"+}diff --git a/registry-artifacts/caption-stamp.json b/registry-artifacts/caption-stamp.jsonnew file mode 100644index 00000000..18933eb8--- /dev/null+++ b/registry-artifacts/caption-stamp.json@@ -0,0 +1,17 @@+{+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",+ "name": "caption-stamp",+ "title": "Caption Stamp",+ "description": "Plain captions where the words that matter slam down as a rubber stamp the moment they are spoken.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "registry/remocn/caption-stamp/index.tsx",+ "content": "\"use client\";\n\nimport { Fragment, useId } from \"react\";\nimport { Easing, interpolate, random } from \"remotion\";\nimport {\n type CaptionBaseProps,\n captionWordText,\n createKeywordMatcher,\n DEFAULT_HOLD_MS,\n getExitWindowMs,\n groupCaptionWords,\n normalizeCaptionWord,\n useCaptions,\n} from \"@/lib/remocn/caption-core\";\n\nexport interface CaptionStampProps extends CaptionBaseProps {\n keywords?: string[];\n stampColor?: string;\n texture?: boolean;\n shadow?: boolean;\n}\n\nconst ENTER_MS = 160;\nconst EXIT_MS = 220;\nconst RISE_EM = 0.14;\nconst SLAM_MS = 90;\nconst SETTLE_MS = 170;\nconst INK_MS = 50;\nconst PAD_EM = 0.16;\nconst BORDER_EM = 0.06;\nconst RADIUS_EM = 0.08;\nconst LEGIBILITY_SHADOW =\n \"0 2px 3px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.35)\";\n\nconst enterEasing = Easing.bezier(0.2, 0.8, 0.2, 1);\nconst slamEasing = Easing.in(Easing.quad);\nconst settleEasing = Easing.out(Easing.quad);\n\nconst clamp = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n} as const;\n\nfunction stampScale(sinceMs: number): number {\n if (sinceMs <= SLAM_MS) {\n return interpolate(sinceMs, [0, SLAM_MS], [1.8, 0.96], {\n ...clamp,\n easing: slamEasing,\n });\n }\n return interpolate(sinceMs, [SLAM_MS, SETTLE_MS], [0.96, 1], {\n ...clamp,\n easing: settleEasing,\n });\n}\n\nexport function CaptionStamp({\n captions,\n combineTokensWithinMilliseconds = 1200,\n holdMs = DEFAULT_HOLD_MS,\n fontSize = 64,\n fontWeight = 800,\n color = \"#ffffff\",\n keywords,\n stampColor = \"#ef4444\",\n texture = true,\n shadow = true,\n className,\n}: CaptionStampProps) {\n const filterId = `caption-stamp-${useId().replace(/[^a-zA-Z0-9_-]/g, \"\")}`;\n const state = useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs,\n });\n if (!state) return null;\n\n const enter = interpolate(\n state.previous ? ENTER_MS : state.sinceStartMs,\n [0, ENTER_MS],\n [0, 1],\n { ...clamp, easing: enterEasing },\n );\n const exit = state.endsInSilence\n ? interpolate(\n state.untilEndMs,\n [0, getExitWindowMs(state, EXIT_MS)],\n [0, 1],\n clamp,\n )\n : 1;\n\n const words = groupCaptionWords(state.tokens);\n const isKeyword = createKeywordMatcher(keywords);\n const byKeyword = keywords !== undefined && keywords.length > 0;\n let longest = -1;\n let longestLength = 0;\n if (!byKeyword) {\n words.forEach((word, w) => {\n const length = normalizeCaptionWord(captionWordText(word)).length;\n if (length > longestLength) {\n longest = w;\n longestLength = length;\n }\n });\n }\n const textShadow = shadow ? LEGIBILITY_SHADOW : undefined;\n\n return (\n <div\n className={className}\n style={{\n position: \"relative\",\n fontSize,\n fontWeight,\n color,\n lineHeight: 1.2,\n textAlign: \"center\",\n opacity: Math.min(enter, exit),\n transform: `translateY(${(1 - enter) * RISE_EM}em)`,\n }}\n >\n {texture && (\n <svg\n aria-hidden\n width={0}\n height={0}\n style={{ position: \"absolute\", overflow: \"hidden\" }}\n >\n <filter id={filterId} x=\"-10%\" y=\"-20%\" width=\"120%\" height=\"140%\">\n <feTurbulence\n type=\"fractalNoise\"\n baseFrequency=\"0.45\"\n numOctaves={2}\n seed={4}\n result=\"warp\"\n />\n <feDisplacementMap\n in=\"SourceGraphic\"\n in2=\"warp\"\n scale={fontSize * 0.035}\n xChannelSelector=\"R\"\n yChannelSelector=\"G\"\n result=\"rough\"\n />\n <feTurbulence\n type=\"fractalNoise\"\n baseFrequency=\"0.8\"\n numOctaves={1}\n seed={9}\n result=\"grain\"\n />\n <feColorMatrix\n in=\"grain\"\n type=\"matrix\"\n values=\"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -10 6.8\"\n result=\"holes\"\n />\n <feComposite in=\"rough\" in2=\"holes\" operator=\"in\" />\n </filter>\n </svg>\n )}\n {words.map((word, w) => {\n const key = `${state.pageIndex}-${word[0].index}`;\n const text = captionWordText(word);\n const stamped = byKeyword ? isKeyword(text) : w === longest;\n if (!stamped) {\n return (\n <Fragment key={key}>\n {w > 0 && \" \"}\n <span\n style={{\n display: \"inline-block\",\n whiteSpace: \"nowrap\",\n textShadow,\n }}\n >\n {text}\n </span>\n </Fragment>\n );\n }\n const sinceMs = state.timeMs - word[0].token.fromMs;\n const rotation =\n -8 + random(`caption-stamp-${state.pageIndex}-${word[0].index}`) * 5;\n return (\n <Fragment key={key}>\n {w > 0 && \" \"}\n <span\n style={{\n position: \"relative\",\n display: \"inline-block\",\n whiteSpace: \"nowrap\",\n }}\n >\n <span\n style={{\n opacity: interpolate(\n sinceMs,\n [SLAM_MS * 0.6, SLAM_MS],\n [1, 0],\n clamp,\n ),\n textShadow,\n }}\n >\n {text}\n </span>\n {sinceMs >= 0 && (\n <span\n aria-hidden\n style={{\n position: \"absolute\",\n left: `-${PAD_EM}em`,\n right: `-${PAD_EM}em`,\n top: \"8%\",\n bottom: \"4%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n lineHeight: 1,\n color: stampColor,\n border: `${BORDER_EM}em solid ${stampColor}`,\n borderRadius: `${RADIUS_EM}em`,\n opacity: interpolate(sinceMs, [0, INK_MS], [0, 1], clamp),\n transform: `rotate(${rotation}deg) scale(${stampScale(sinceMs)})`,\n filter: texture ? `url(#${filterId})` : undefined,\n }}\n >\n {text}\n </span>\n )}\n </span>\n </Fragment>\n );\n })}\n </div>\n );\n}\n",+ "type": "registry:component",+ "target": "components/remocn/caption-stamp.tsx"+ }+ ],+ "type": "registry:component"+}diff --git a/registry-artifacts/caption-subtitle.json b/registry-artifacts/caption-subtitle.jsonnew file mode 100644index 00000000..5e1aeb08--- /dev/null+++ b/registry-artifacts/caption-subtitle.json@@ -0,0 +1,17 @@+{+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",+ "name": "caption-subtitle",+ "title": "Caption Subtitle",+ "description": "Classic broadcast subtitles, a whole phrase on a translucent plate, with no word-level animation at all.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "registry/remocn/caption-subtitle/index.tsx",+ "content": "\"use client\";\n\nimport { interpolate } from \"remotion\";\nimport {\n type CaptionBaseProps,\n DEFAULT_HOLD_MS,\n getExitWindowMs,\n useCaptions,\n} from \"@/lib/remocn/caption-core\";\n\nexport interface CaptionSubtitleProps extends CaptionBaseProps {\n box?: boolean;\n boxColor?: string;\n boxOpacity?: number;\n}\n\nconst ENTER_MS = 120;\nconst EXIT_MS = 160;\nconst LEGIBILITY_SHADOW =\n \"0 2px 3px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.35)\";\n\nexport function CaptionSubtitle({\n captions,\n combineTokensWithinMilliseconds = 2500,\n holdMs = DEFAULT_HOLD_MS,\n fontSize = 44,\n fontWeight = 600,\n color = \"#ffffff\",\n box = true,\n boxColor = \"#000000\",\n boxOpacity = 0.72,\n className,\n}: CaptionSubtitleProps) {\n const state = useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs,\n });\n if (!state) return null;\n\n const enter = state.previous\n ? 1\n : interpolate(state.sinceStartMs, [0, ENTER_MS], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n });\n const exit = state.endsInSilence\n ? interpolate(\n state.untilEndMs,\n [0, getExitWindowMs(state, EXIT_MS)],\n [0, 1],\n {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n },\n )\n : 1;\n const opacityPercent = Math.round(Math.min(1, Math.max(0, boxOpacity)) * 100);\n\n return (\n <div\n className={className}\n style={{\n fontSize,\n fontWeight,\n color,\n lineHeight: 1.4,\n textAlign: \"center\",\n textWrap: \"balance\",\n opacity: Math.min(enter, exit),\n }}\n >\n <span\n style={\n box\n ? {\n backgroundColor: `color-mix(in srgb, ${boxColor} ${opacityPercent}%, transparent)`,\n padding: \"0.06em 0.36em\",\n borderRadius: \"0.16em\",\n boxDecorationBreak: \"clone\",\n WebkitBoxDecorationBreak: \"clone\",\n }\n : { textShadow: LEGIBILITY_SHADOW }\n }\n >\n {state.page.text}\n </span>\n </div>\n );\n}\n",+ "type": "registry:component",+ "target": "components/remocn/caption-subtitle.tsx"+ }+ ],+ "type": "registry:component"+}diff --git a/registry-artifacts/caption-teleprompter.json b/registry-artifacts/caption-teleprompter.jsonnew file mode 100644index 00000000..e15ef58c--- /dev/null+++ b/registry-artifacts/caption-teleprompter.json@@ -0,0 +1,17 @@+{+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",+ "name": "caption-teleprompter",+ "title": "Caption Teleprompter",+ "description": "The whole transcript scrolls smoothly through a short window with the current line centred, past lines fading above and the next line waiting below.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "registry/remocn/caption-teleprompter/index.tsx",+ "content": "\"use client\";\n\nimport type { TikTokPage } from \"@remotion/captions\";\nimport { Fragment, useMemo } from \"react\";\nimport { Easing, interpolate, useCurrentFrame, useVideoConfig } from \"remotion\";\nimport {\n buildCaptionPages,\n type CaptionBaseProps,\n DEFAULT_HOLD_MS,\n useCaptionWordRects,\n} from \"@/lib/remocn/caption-core\";\n\nexport interface CaptionTeleprompterProps extends CaptionBaseProps {\n visibleLines?: number;\n pastOpacity?: number;\n futureOpacity?: number;\n upcomingOpacity?: number;\n shadow?: boolean;\n}\n\ninterface PrompterWord {\n key: number;\n text: string;\n fromMs: number;\n}\n\nconst LINE_HEIGHT = 1.3;\nconst LINE_GAP_EM = 0.2;\nconst SCROLL_MS = 320;\nconst LIGHT_MS = 80;\nconst EDGE_FADE_LINES = 0.66;\n\nfunction edgeFade(visibleLines: number): string | undefined {\n const fadeLines = Math.min(\n EDGE_FADE_LINES,\n Math.max(0, visibleLines - 1) / 3,\n );\n if (fadeLines <= 0) return undefined;\n const pct = (fadeLines / visibleLines) * 100;\n return `linear-gradient(to bottom, transparent, #000 ${pct}%, #000 ${100 - pct}%, transparent)`;\n}\nconst LEGIBILITY_SHADOW =\n \"0 2px 3px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.35)\";\n\nconst scrollEasing = Easing.bezier(0.45, 0, 0.2, 1);\n\nconst clamp = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n} as const;\n\nfunction lineWords(page: TikTokPage): PrompterWord[] {\n const words: PrompterWord[] = [];\n page.tokens.forEach((token, i) => {\n const last = words[words.length - 1];\n if (last && !/^\\s/.test(token.text)) {\n last.text += token.text;\n } else {\n words.push({ key: i, text: token.text.trim(), fromMs: token.fromMs });\n }\n });\n return words;\n}\n\nexport function CaptionTeleprompter({\n captions,\n combineTokensWithinMilliseconds = 1500,\n holdMs = DEFAULT_HOLD_MS,\n fontSize = 64,\n fontWeight = 800,\n color = \"#ffffff\",\n visibleLines = 3,\n pastOpacity = 0.35,\n futureOpacity = 0.35,\n upcomingOpacity = 0.55,\n shadow = true,\n className,\n}: CaptionTeleprompterProps) {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const timeMs = (frame / fps) * 1000;\n const lines = useMemo(\n () =>\n buildCaptionPages(captions, {\n combineTokensWithinMilliseconds,\n holdMs,\n }).map((line) => ({ ...line, words: lineWords(line.page) })),\n [captions, combineTokensWithinMilliseconds, holdMs],\n );\n const { wordRef: lineRef, rects } = useCaptionWordRects(0, lines.length);\n\n const step = (LINE_HEIGHT + LINE_GAP_EM) * fontSize;\n const windowHeight = visibleLines * step;\n const center = (i: number): number => {\n const rect = rects?.[i];\n return rect\n ? rect.top + rect.height / 2\n : i * step + (LINE_HEIGHT * fontSize) / 2;\n };\n\n const scrollMsAt = (i: number): number => {\n const before =\n i > 0\n ? lines[i].startMs - lines[i - 1].startMs\n : Number.POSITIVE_INFINITY;\n const after =\n i < lines.length - 1\n ? lines[i + 1].startMs - lines[i].startMs\n : Number.POSITIVE_INFINITY;\n return Math.max(1, Math.min(SCROLL_MS, before, after));\n };\n let k = -1;\n lines.forEach((line, i) => {\n if (line.startMs - scrollMsAt(i) / 2 <= timeMs) k = i;\n });\n const scrollMs = k > 0 ? scrollMsAt(k) : SCROLL_MS;\n const progress =\n k <= 0\n ? 1\n : interpolate(\n timeMs - (lines[k].startMs - scrollMs / 2),\n [0, scrollMs],\n [0, 1],\n { ...clamp, easing: scrollEasing },\n );\n const focus = Math.max(k, 0);\n const centerY =\n lines.length === 0\n ? 0\n : k <= 0\n ? center(0)\n : center(k - 1) + (center(k) - center(k - 1)) * progress;\n\n return (\n <div\n className={className}\n style={{\n position: \"relative\",\n height: windowHeight,\n fontSize,\n fontWeight,\n color,\n textAlign: \"center\",\n overflow: \"hidden\",\n maskImage: edgeFade(visibleLines),\n WebkitMaskImage: edgeFade(visibleLines),\n }}\n >\n <div\n style={{\n position: \"absolute\",\n left: 0,\n right: 0,\n top: 0,\n transform: `translateY(${windowHeight / 2 - centerY}px)`,\n }}\n >\n {lines.map((line, i) => {\n const weight =\n i === focus ? progress : i === focus - 1 ? 1 - progress : 0;\n const rest = i < focus ? pastOpacity : futureOpacity;\n return (\n <div\n key={line.index}\n ref={lineRef(i)}\n style={{\n lineHeight: LINE_HEIGHT,\n marginBottom: `${LINE_GAP_EM}em`,\n textShadow: shadow ? LEGIBILITY_SHADOW : undefined,\n }}\n >\n {line.words.map((word, w) => {\n const lit = interpolate(\n timeMs - word.fromMs,\n [-LIGHT_MS, 0],\n [upcomingOpacity, 1],\n clamp,\n );\n return (\n <Fragment key={word.key}>\n {w > 0 && \" \"}\n <span style={{ opacity: rest + (lit - rest) * weight }}>\n {word.text}\n </span>\n </Fragment>\n );\n })}\n </div>\n );\n })}\n </div>\n </div>\n );\n}\n",+ "type": "registry:component",+ "target": "components/remocn/caption-teleprompter.tsx"+ }+ ],+ "type": "registry:component"+}diff --git a/registry-artifacts/caption-timeline.json b/registry-artifacts/caption-timeline.jsonnew file mode 100644index 00000000..9dd7edea--- /dev/null+++ b/registry-artifacts/caption-timeline.json@@ -0,0 +1,17 @@+{+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",+ "name": "caption-timeline",+ "title": "Caption Timeline",+ "description": "The whole transcript laid out on a scrolling time strip that slides under a fixed playhead, so every pause shows up as space between words.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "registry/remocn/caption-timeline/index.tsx",+ "content": "\"use client\";\n\nimport type { Caption } from \"@remotion/captions\";\nimport { useLayoutEffect, useMemo, useRef, useState } from \"react\";\nimport { interpolate, useCurrentFrame, useVideoConfig } from \"remotion\";\nimport type { CaptionBaseProps } from \"@/lib/remocn/caption-core\";\n\nexport interface CaptionTimelineProps extends CaptionBaseProps {\n width?: number;\n pxPerSecond?: number;\n playheadPosition?: number;\n playheadColor?: string;\n upcomingOpacity?: number;\n shadow?: boolean;\n}\n\ninterface TimelineWord {\n id: number;\n text: string;\n startMs: number;\n endMs: number;\n}\n\nconst LINE_HEIGHT = 1.3;\nconst GAP_EM = 0.32;\nconst LIGHT_MS = 80;\nconst EDGE_FADE =\n \"linear-gradient(to right, transparent, #000 12%, #000 88%, transparent)\";\nconst LEGIBILITY_SHADOW =\n \"0 2px 3px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.35)\";\n\nconst clamp = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n} as const;\n\nexport function getTimelineWords(captions: Caption[]): TimelineWord[] {\n const words: TimelineWord[] = [];\n for (const caption of captions) {\n if (caption.text.trim() === \"\") continue;\n const last = words[words.length - 1];\n if (last && !/^\\s/.test(caption.text)) {\n last.text += caption.text;\n last.endMs = caption.endMs;\n } else {\n words.push({\n id: words.length,\n text: caption.text.trim(),\n startMs: caption.startMs,\n endMs: caption.endMs,\n });\n }\n }\n return words;\n}\n\nexport function layoutTimeline(\n words: TimelineWord[],\n widths: number[],\n pxPerSecond: number,\n gap: number,\n): number[] {\n const xs: number[] = [];\n words.forEach((word, i) => {\n const ideal = (word.startMs / 1000) * pxPerSecond;\n xs.push(i === 0 ? ideal : Math.max(ideal, xs[i - 1] + widths[i - 1] + gap));\n });\n return xs;\n}\n\nexport function timelineOffset(\n words: TimelineWord[],\n xs: number[],\n timeMs: number,\n pxPerSecond: number,\n): number {\n if (words.length === 0) return (timeMs / 1000) * pxPerSecond;\n let i = -1;\n while (i + 1 < words.length && words[i + 1].startMs <= timeMs) i++;\n if (i === -1) {\n return xs[0] - ((words[0].startMs - timeMs) / 1000) * pxPerSecond;\n }\n const next = words[i + 1];\n if (!next) {\n return xs[i] + ((timeMs - words[i].startMs) / 1000) * pxPerSecond;\n }\n const span = next.startMs - words[i].startMs;\n const t = span > 0 ? (timeMs - words[i].startMs) / span : 1;\n return xs[i] + (xs[i + 1] - xs[i]) * t;\n}\n\nfunction sameWidths(a: number[], b: number[]): boolean {\n return a.length === b.length && a.every((w, i) => w === b[i]);\n}\n\nexport function CaptionTimeline({\n captions,\n fontSize = 64,\n fontWeight = 800,\n color = \"#ffffff\",\n width = 1100,\n pxPerSecond = 260,\n playheadPosition = 0.35,\n playheadColor = \"#facc15\",\n upcomingOpacity = 0.4,\n shadow = true,\n className,\n}: CaptionTimelineProps) {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const timeMs = (frame / fps) * 1000;\n const words = useMemo(() => getTimelineWords(captions), [captions]);\n const elements = useRef<(HTMLSpanElement | null)[]>([]);\n const [widths, setWidths] = useState<number[]>([]);\n\n useLayoutEffect(() => {\n const measured = words.map((_, i) => elements.current[i]?.offsetWidth ?? 0);\n setWidths((prev) => (sameWidths(prev, measured) ? prev : measured));\n });\n\n const gap = fontSize * GAP_EM;\n const resolved =\n widths.length === words.length\n ? widths\n : words.map((word) => word.text.length * fontSize * 0.55);\n const xs = layoutTimeline(words, resolved, pxPerSecond, gap);\n const playheadX = width * playheadPosition;\n const offset = timelineOffset(words, xs, timeMs, pxPerSecond);\n const thickness = Math.max(2, Math.round(fontSize * 0.04));\n\n if (words.length === 0) return null;\n\n return (\n <div\n className={className}\n style={{\n position: \"relative\",\n width,\n height: `${LINE_HEIGHT}em`,\n fontSize,\n fontWeight,\n color,\n lineHeight: LINE_HEIGHT,\n }}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n overflow: \"hidden\",\n maskImage: EDGE_FADE,\n WebkitMaskImage: EDGE_FADE,\n }}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n transform: `translateX(${playheadX - offset}px)`,\n }}\n >\n {words.map((word, i) => (\n <span\n key={word.id}\n ref={(el) => {\n elements.current[i] = el;\n }}\n style={{\n position: \"absolute\",\n left: xs[i],\n top: 0,\n whiteSpace: \"nowrap\",\n opacity: interpolate(\n timeMs - word.startMs,\n [-LIGHT_MS, 0],\n [upcomingOpacity, 1],\n clamp,\n ),\n textShadow: shadow ? LEGIBILITY_SHADOW : undefined,\n }}\n >\n {word.text}\n </span>\n ))}\n </div>\n </div>\n <div\n aria-hidden\n style={{\n position: \"absolute\",\n top: \"8%\",\n bottom: \"8%\",\n left: playheadX - thickness / 2,\n width: thickness,\n borderRadius: thickness,\n background: playheadColor,\n }}\n />\n </div>\n );\n}\n",+ "type": "registry:component",+ "target": "components/remocn/caption-timeline.tsx"+ }+ ],+ "type": "registry:component"+}diff --git a/registry-artifacts/caption-typewriter.json b/registry-artifacts/caption-typewriter.jsonnew file mode 100644index 00000000..7897de82--- /dev/null+++ b/registry-artifacts/caption-typewriter.json@@ -0,0 +1,17 @@+{+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",+ "name": "caption-typewriter",+ "title": "Caption Typewriter",+ "description": "Each word types out character by character at the pace it is spoken, with a caret that blinks while the speaker pauses.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "registry/remocn/caption-typewriter/index.tsx",+ "content": "\"use client\";\n\nimport { Fragment } from \"react\";\nimport { interpolate } from \"remotion\";\nimport {\n type CaptionBaseProps,\n DEFAULT_HOLD_MS,\n getExitWindowMs,\n groupCaptionWords,\n useCaptions,\n} from \"@/lib/remocn/caption-core\";\n\nexport interface CaptionTypewriterProps extends CaptionBaseProps {\n caret?: boolean;\n shadow?: boolean;\n}\n\nconst EXIT_MS = 220;\nconst BLINK_MS = 500;\nconst LEGIBILITY_SHADOW =\n \"0 2px 3px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.35)\";\nconst CARET_SHADOW = \"0 2px 6px rgba(0, 0, 0, 0.45)\";\n\nfunction typedCount(text: string, progress: number): number {\n const length = Array.from(text).length;\n return Math.min(length, Math.ceil(progress * length));\n}\n\nexport function CaptionTypewriter({\n captions,\n combineTokensWithinMilliseconds = 1200,\n holdMs = DEFAULT_HOLD_MS,\n fontSize = 64,\n fontWeight = 800,\n color = \"#ffffff\",\n caret = true,\n shadow = true,\n className,\n}: CaptionTypewriterProps) {\n const state = useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs,\n });\n if (!state) return null;\n\n const exit = state.endsInSilence\n ? interpolate(\n state.untilEndMs,\n [0, getExitWindowMs(state, EXIT_MS)],\n [0, 1],\n {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n },\n )\n : 1;\n\n const active = state.tokens[state.activeIndex];\n const typing = active !== undefined && active.progress < 1;\n const idleMs = active ? state.timeMs - active.toMs : 0;\n const caretOn = typing || Math.floor(idleMs / BLINK_MS) % 2 === 0;\n\n return (\n <div\n className={className}\n style={{\n fontSize,\n fontWeight,\n color,\n lineHeight: 1.2,\n textAlign: \"center\",\n opacity: exit,\n }}\n >\n {groupCaptionWords(state.tokens).map((word, w) => (\n <Fragment key={`${state.pageIndex}-${word[0].index}`}>\n {w > 0 && \" \"}\n <span style={{ display: \"inline-block\", whiteSpace: \"nowrap\" }}>\n {word.map(({ index, token }) => {\n const chars = Array.from(token.text);\n const typed = typedCount(token.text, token.progress);\n return (\n <Fragment key={index}>\n <span\n style={{\n textShadow: shadow ? LEGIBILITY_SHADOW : undefined,\n }}\n >\n {chars.slice(0, typed).join(\"\")}\n </span>\n {caret && index === state.activeIndex ? (\n <span style={{ position: \"relative\" }}>\n <span\n style={{\n position: \"absolute\",\n left: \"0.03em\",\n top: \"0.1em\",\n bottom: \"0.1em\",\n width: \"0.07em\",\n backgroundColor: color,\n boxShadow: shadow ? CARET_SHADOW : undefined,\n opacity: caretOn ? 1 : 0,\n }}\n />\n </span>\n ) : null}\n <span aria-hidden style={{ color: \"transparent\" }}>\n {chars.slice(typed).join(\"\")}\n </span>\n </Fragment>\n );\n })}\n </span>\n </Fragment>\n ))}\n </div>\n );\n}\n",+ "type": "registry:component",+ "target": "components/remocn/caption-typewriter.tsx"+ }+ ],+ "type": "registry:component"+}diff --git a/registry-artifacts/caption-underline.json b/registry-artifacts/caption-underline.jsonnew file mode 100644index 00000000..d3b09f5b--- /dev/null+++ b/registry-artifacts/caption-underline.json@@ -0,0 +1,17 @@+{+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",+ "name": "caption-underline",+ "title": "Caption Underline",+ "description": "A bar slides under the word being spoken, travelling from word to word while the text itself stays untouched.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "registry/remocn/caption-underline/index.tsx",+ "content": "\"use client\";\n\nimport { Fragment } from \"react\";\nimport { Easing, interpolate } from \"remotion\";\nimport {\n type CaptionBaseProps,\n DEFAULT_HOLD_MS,\n getExitWindowMs,\n groupCaptionWords,\n useCaptions,\n useCaptionWordRects,\n} from \"@/lib/remocn/caption-core\";\n\nexport interface CaptionUnderlineProps extends CaptionBaseProps {\n underlineColor?: string;\n thickness?: number;\n underlineOffset?: number;\n shadow?: boolean;\n}\n\nconst ENTER_MS = 160;\nconst EXIT_MS = 220;\nconst RISE_EM = 0.14;\nconst TRAVEL_MS = 120;\nconst LEGIBILITY_SHADOW =\n \"0 2px 3px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.35)\";\n\nconst enterEasing = Easing.bezier(0.2, 0.8, 0.2, 1);\nconst travelEasing = Easing.bezier(0.3, 0, 0.2, 1);\n\nconst clamp = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n} as const;\n\nfunction mix(a: number, b: number, t: number): number {\n return a + (b - a) * t;\n}\n\nexport function CaptionUnderline({\n captions,\n combineTokensWithinMilliseconds = 1200,\n holdMs = DEFAULT_HOLD_MS,\n fontSize = 64,\n fontWeight = 800,\n color = \"#ffffff\",\n underlineColor = \"#facc15\",\n thickness = 0.08,\n underlineOffset = 0.02,\n shadow = true,\n className,\n}: CaptionUnderlineProps) {\n const state = useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs,\n });\n const words = state ? groupCaptionWords(state.tokens) : [];\n const pageIndex = state ? state.pageIndex : -1;\n const { wordRef, rects } = useCaptionWordRects(pageIndex, words.length);\n\n if (!state) return null;\n\n const enter = interpolate(\n state.previous ? ENTER_MS : state.sinceStartMs,\n [0, ENTER_MS],\n [0, 1],\n {\n ...clamp,\n easing: enterEasing,\n },\n );\n const exit = state.endsInSilence\n ? interpolate(\n state.untilEndMs,\n [0, getExitWindowMs(state, EXIT_MS)],\n [0, 1],\n clamp,\n )\n : 1;\n\n const activeWord = words.findIndex((word) =>\n word.some(({ index }) => index === state.activeIndex),\n );\n const travel =\n activeWord >= 0\n ? interpolate(\n state.timeMs - words[activeWord][0].token.fromMs,\n [0, TRAVEL_MS],\n [0, 1],\n { ...clamp, easing: travelEasing },\n )\n : 0;\n\n const target = rects && activeWord >= 0 ? rects[activeWord] : null;\n const origin = rects && activeWord > 0 ? rects[activeWord - 1] : null;\n const barHeight = thickness * fontSize;\n const gap = underlineOffset * fontSize;\n const bar = target\n ? origin\n ? {\n left: mix(origin.left, target.left, travel),\n top: mix(\n origin.top + origin.height,\n target.top + target.height,\n travel,\n ),\n width: mix(origin.width, target.width, travel),\n opacity: 1,\n }\n : {\n left: target.left,\n top: target.top + target.height,\n width: target.width * travel,\n opacity: travel,\n }\n : null;\n\n return (\n <div\n className={className}\n style={{\n position: \"relative\",\n fontSize,\n fontWeight,\n color,\n lineHeight: 1.2,\n textAlign: \"center\",\n opacity: Math.min(enter, exit),\n transform: `translateY(${(1 - enter) * RISE_EM}em)`,\n }}\n >\n {words.map((word, w) => (\n <Fragment key={`${state.pageIndex}-${word[0].index}`}>\n {w > 0 && \" \"}\n <span\n ref={wordRef(w)}\n style={{\n position: \"relative\",\n display: \"inline-block\",\n whiteSpace: \"nowrap\",\n textShadow: shadow ? LEGIBILITY_SHADOW : undefined,\n }}\n >\n {word.map(({ index, token }) => (\n <span key={index}>{token.text}</span>\n ))}\n </span>\n </Fragment>\n ))}\n {bar && (\n <span\n aria-hidden\n style={{\n position: \"absolute\",\n left: bar.left,\n top: bar.top + gap,\n width: bar.width,\n height: barHeight,\n borderRadius: barHeight / 2,\n background: underlineColor,\n opacity: bar.opacity,\n }}\n />\n )}\n </div>\n );\n}\n",+ "type": "registry:component",+ "target": "components/remocn/caption-underline.tsx"+ }+ ],+ "type": "registry:component"+}diff --git a/registry-artifacts/caption-weight.json b/registry-artifacts/caption-weight.jsonnew file mode 100644index 00000000..acc12613--- /dev/null+++ b/registry-artifacts/caption-weight.json@@ -0,0 +1,17 @@+{+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",+ "name": "caption-weight",+ "title": "Caption Weight",+ "description": "The word being spoken swells from a light weight to a heavy one and relaxes as the voice moves on, with no layout shift.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "registry/remocn/caption-weight/index.tsx",+ "content": "\"use client\";\n\nimport { Fragment } from \"react\";\nimport { Easing, interpolate } from \"remotion\";\nimport {\n type CaptionBaseProps,\n captionWordText,\n DEFAULT_HOLD_MS,\n getExitWindowMs,\n groupCaptionWords,\n useCaptions,\n} from \"@/lib/remocn/caption-core\";\n\nexport interface CaptionWeightProps extends CaptionBaseProps {\n activeWeight?: number;\n shadow?: boolean;\n}\n\nconst ENTER_MS = 160;\nconst EXIT_MS = 220;\nconst RISE_EM = 0.14;\nconst RAMP_MS = 150;\nconst RELEASE_MS = 220;\nconst LEGIBILITY_SHADOW =\n \"0 2px 3px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.35)\";\n\nconst enterEasing = Easing.bezier(0.2, 0.8, 0.2, 1);\nconst rampEasing = Easing.bezier(0.2, 0.8, 0.3, 1);\nconst releaseEasing = Easing.bezier(0.4, 0, 0.2, 1);\n\nconst clamp = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n} as const;\n\nexport function CaptionWeight({\n captions,\n combineTokensWithinMilliseconds = 1200,\n holdMs = DEFAULT_HOLD_MS,\n fontSize = 64,\n fontWeight = 400,\n activeWeight = 900,\n color = \"#ffffff\",\n shadow = true,\n className,\n}: CaptionWeightProps) {\n const state = useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs,\n });\n if (!state) return null;\n\n const enter = interpolate(\n state.previous ? ENTER_MS : state.sinceStartMs,\n [0, ENTER_MS],\n [0, 1],\n {\n ...clamp,\n easing: enterEasing,\n },\n );\n const exit = state.endsInSilence\n ? interpolate(\n state.untilEndMs,\n [0, getExitWindowMs(state, EXIT_MS)],\n [0, 1],\n clamp,\n )\n : 1;\n\n const words = groupCaptionWords(state.tokens);\n const activeWord = words.findIndex((word) =>\n word.some(({ index }) => index === state.activeIndex),\n );\n\n const emphasis = (w: number): number => {\n if (activeWord < 0 || w > activeWord) return 0;\n const startMs = words[w][0].token.fromMs;\n const rise = interpolate(state.timeMs - startMs, [0, RAMP_MS], [0, 1], {\n ...clamp,\n easing: rampEasing,\n });\n if (w === activeWord) return rise;\n const releaseMs = words[w + 1][0].token.fromMs;\n const peak = interpolate(releaseMs - startMs, [0, RAMP_MS], [0, 1], {\n ...clamp,\n easing: rampEasing,\n });\n const release = interpolate(\n state.timeMs - releaseMs,\n [0, RELEASE_MS],\n [0, 1],\n { ...clamp, easing: releaseEasing },\n );\n return peak * (1 - release);\n };\n\n return (\n <div\n className={className}\n style={{\n fontSize,\n fontWeight,\n color,\n lineHeight: 1.2,\n textAlign: \"center\",\n opacity: Math.min(enter, exit),\n transform: `translateY(${(1 - enter) * RISE_EM}em)`,\n }}\n >\n {words.map((word, w) => {\n const weight = fontWeight + (activeWeight - fontWeight) * emphasis(w);\n return (\n <Fragment key={`${state.pageIndex}-${word[0].index}`}>\n {w > 0 && \" \"}\n <span style={{ display: \"inline-grid\", whiteSpace: \"nowrap\" }}>\n <span\n aria-hidden\n style={{\n gridArea: \"1 / 1\",\n fontWeight: Math.max(fontWeight, activeWeight),\n visibility: \"hidden\",\n }}\n >\n {captionWordText(word)}\n </span>\n <span\n style={{\n gridArea: \"1 / 1\",\n justifySelf: \"center\",\n fontWeight: weight,\n textShadow: shadow ? LEGIBILITY_SHADOW : undefined,\n }}\n >\n {word.map(({ index, token }) => (\n <span key={index}>{token.text}</span>\n ))}\n </span>\n </span>\n </Fragment>\n );\n })}\n </div>\n );\n}\n",+ "type": "registry:component",+ "target": "components/remocn/caption-weight.tsx"+ }+ ],+ "type": "registry:component"+}diff --git a/registry-artifacts/caption-word-pop.json b/registry-artifacts/caption-word-pop.jsonnew file mode 100644index 00000000..88a5328e--- /dev/null+++ b/registry-artifacts/caption-word-pop.json@@ -0,0 +1,17 @@+{+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",+ "name": "caption-word-pop",+ "title": "Caption Word Pop",+ "description": "One large word at a time, each popping in on a spring the moment it is spoken.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "registry/remocn/caption-word-pop/index.tsx",+ "content": "\"use client\";\n\nimport { Fragment } from \"react\";\nimport { interpolate, spring, useVideoConfig } from \"remotion\";\nimport {\n type CaptionBaseProps,\n DEFAULT_HOLD_MS,\n getExitWindowMs,\n groupCaptionWords,\n useCaptions,\n} from \"@/lib/remocn/caption-core\";\n\nexport interface CaptionWordPopProps extends CaptionBaseProps {\n popScale?: number;\n shadow?: boolean;\n}\n\nconst FADE_MS = 50;\nconst EXIT_MS = 180;\nconst LEGIBILITY_SHADOW =\n \"0 2px 3px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.35)\";\n\nconst POP_SPRING = { damping: 11, stiffness: 240, mass: 0.6 };\n\nconst clamp = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n} as const;\n\nexport function CaptionWordPop({\n captions,\n combineTokensWithinMilliseconds = 0,\n holdMs = DEFAULT_HOLD_MS,\n fontSize = 96,\n fontWeight = 800,\n color = \"#ffffff\",\n popScale = 0.6,\n shadow = true,\n className,\n}: CaptionWordPopProps) {\n const { fps } = useVideoConfig();\n const state = useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs,\n });\n if (!state) return null;\n\n const pop = spring({\n frame: (state.sinceStartMs / 1000) * fps,\n fps,\n config: POP_SPRING,\n });\n const fadeIn = state.previous\n ? 1\n : interpolate(state.sinceStartMs, [0, FADE_MS], [0, 1], clamp);\n const exit = state.endsInSilence\n ? interpolate(\n state.untilEndMs,\n [0, getExitWindowMs(state, EXIT_MS)],\n [0, 1],\n clamp,\n )\n : 1;\n\n return (\n <div\n className={className}\n style={{\n fontSize,\n fontWeight,\n color,\n lineHeight: 1.1,\n textAlign: \"center\",\n opacity: Math.min(fadeIn, exit),\n transform: `scale(${popScale + (1 - popScale) * pop})`,\n textShadow: shadow ? LEGIBILITY_SHADOW : undefined,\n }}\n >\n {groupCaptionWords(state.tokens).map((word, w) => (\n <Fragment key={`${state.pageIndex}-${word[0].index}`}>\n {w > 0 && \" \"}\n <span style={{ display: \"inline-block\", whiteSpace: \"nowrap\" }}>\n {word.map(({ index, token }) => (\n <span key={index}>{token.text}</span>\n ))}\n </span>\n </Fragment>\n ))}\n </div>\n );\n}\n",+ "type": "registry:component",+ "target": "components/remocn/caption-word-pop.tsx"+ }+ ],+ "type": "registry:component"+}diff --git a/registry-artifacts/elements/animated-bar-chart.json b/registry-artifacts/elements/animated-bar-chart.jsonindex 02dce19f..933077dc 100644--- a/registry-artifacts/elements/animated-bar-chart.json+++ b/registry-artifacts/elements/animated-bar-chart.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [],"dimensions": {"width": 1000,@@ -9,6 +10,7 @@},"displayName": "Animated Bar Chart","durationInFrames": 90,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "animated-bar-chart","sourceCode": "import { Interactive, Sequence, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface AnimatedBarChartProps {\n data?: number[];\n labels?: string[];\n width?: number;\n height?: number;\n barColor?: string;\n gap?: number;\n staggerFrames?: number;\n speed?: number;\n className?: string;\n}\n\nfunction AnimatedBarChartBase({\n data = [35, 60, 45, 80, 55, 70, 90, 65],\n labels,\n width = 1000,\n height = 500,\n barColor = \"#0ea5e9\",\n gap = 16,\n staggerFrames = 6,\n speed = 1,\n className,\n}: AnimatedBarChartProps) {\n const frame = useCurrentFrame() * speed;\n const { fps } = useVideoConfig();\n\n const padding = 60;\n const labelSpace = labels ? 40 : 0;\n const innerWidth = width - padding * 2;\n const innerHeight = height - padding * 2 - labelSpace;\n const max = Math.max(...data);\n const barWidth = (innerWidth - gap * (data.length - 1)) / data.length;\n const baseY = padding + innerHeight;\n\n return (\n <div\n className={className}\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n fontFamily:\n \"var(--font-geist-sans), -apple-system, BlinkMacSystemFont, sans-serif\",\n }}\n >\n <svg width={width} height={height} viewBox={`0 0 ${width} ${height}`}>\n {/* Baseline */}\n <line\n x1={padding}\n x2={padding + innerWidth}\n y1={baseY}\n y2={baseY}\n stroke=\"#27272a\"\n strokeWidth={2}\n />\n\n {data.map((value, index) => {\n const targetHeight = (value / max) * innerHeight;\n const x = padding + index * (barWidth + gap);\n const y = baseY - targetHeight;\n\n const scaleY = spring({\n frame: frame - index * staggerFrames,\n fps,\n config: { damping: 12, stiffness: 100, mass: 0.8 },\n from: 0,\n to: 1,\n });\n\n return (\n <g key={index}>\n <rect\n x={x}\n y={y}\n width={barWidth}\n height={targetHeight}\n rx={6}\n fill={barColor}\n style={{\n scale: `1 ${scaleY}`,\n transformOrigin: `${x + barWidth / 2}px ${baseY}px`,\n transformBox: \"fill-box\",\n filter: `drop-shadow(0 4px 16px ${barColor}55)`,\n }}\n />\n {labels?.[index] && (\n <text\n x={x + barWidth / 2}\n y={baseY + 28}\n fill=\"#a1a1aa\"\n fontSize={16}\n textAnchor=\"middle\"\n style={{\n opacity: scaleY,\n fontFamily:\n \"var(--font-geist-sans), -apple-system, BlinkMacSystemFont, sans-serif\",\n }}\n >\n {labels[index]}\n </text>\n )}\n </g>\n );\n })}\n </svg>\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n barColor: {\n type: \"color\",\n default: \"#0ea5e9\",\n description: \"Bar color\",\n },\n gap: {\n type: \"number\",\n min: 0,\n max: 80,\n step: 2,\n default: 16,\n description: \"Gap\",\n hiddenFromList: false,\n },\n staggerFrames: {\n type: \"number\",\n min: 0,\n max: 30,\n step: 1,\n default: 6,\n description: \"Stagger frames\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 1000,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 500,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"barColor\",\"gap\",\"staggerFrames\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n barColor: \"#0ea5e9\",\n gap: 16,\n staggerFrames: 6,\n speed: 1,\n};\n\ntype AnimatedBarChartElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof AnimatedBarChartBase>;\n\nconst AnimatedBarChartInner = forwardRef<\n HTMLDivElement,\n AnimatedBarChartElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 1000, height = 500, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<AnimatedBarChart>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <AnimatedBarChartBase\n {...(componentProps as unknown as ComponentProps<typeof AnimatedBarChartBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const AnimatedBarChart = Interactive.withSchema({\n Component: AnimatedBarChartInner,\n componentName: \"<AnimatedBarChart>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/animated-line-chart.json b/registry-artifacts/elements/animated-line-chart.jsonindex 6bc8e631..aad64db2 100644--- a/registry-artifacts/elements/animated-line-chart.json+++ b/registry-artifacts/elements/animated-line-chart.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [],"dimensions": {"width": 1000,@@ -9,6 +10,7 @@},"displayName": "Animated Line Chart","durationInFrames": 90,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "animated-line-chart","sourceCode": "import { Interactive, Sequence, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface AnimatedLineChartProps {\n data?: number[];\n width?: number;\n height?: number;\n strokeColor?: string;\n strokeWidth?: number;\n gridColor?: string;\n showDot?: boolean;\n speed?: number;\n className?: string;\n}\n\nfunction AnimatedLineChartBase({\n data = [12, 19, 8, 15, 22, 18, 28, 25, 32],\n width = 1000,\n height = 500,\n strokeColor = \"#22c55e\",\n strokeWidth = 4,\n gridColor = \"#27272a\",\n showDot = true,\n speed = 1,\n className,\n}: AnimatedLineChartProps) {\n const frame = useCurrentFrame() * speed;\n const { fps, durationInFrames } = useVideoConfig();\n\n const padding = 60;\n const innerWidth = width - padding * 2;\n const innerHeight = height - padding * 2;\n\n const min = Math.min(...data);\n const max = Math.max(...data);\n const range = max - min || 1;\n\n const points = data.map((value, index) => {\n const x = padding + (index / (data.length - 1)) * innerWidth;\n const y = padding + innerHeight - ((value - min) / range) * innerHeight;\n return { x, y };\n });\n\n // Analytical path length: sum of segment distances\n let pathLength = 0;\n for (let i = 1; i < points.length; i++) {\n const dx = points[i].x - points[i - 1].x;\n const dy = points[i].y - points[i - 1].y;\n pathLength += Math.sqrt(dx * dx + dy * dy);\n }\n\n const d = points\n .map((p, i) => `${i === 0 ? \"M\" : \"L\"}${p.x.toFixed(2)},${p.y.toFixed(2)}`)\n .join(\" \");\n\n // Spring-driven progress: smooth, no bounce. Matches the \"smooth\" preset\n // from remotion-best-practices/timing.md.\n const progress = spring({\n frame,\n fps,\n durationInFrames: Math.round(durationInFrames * 0.85),\n config: { damping: 200 },\n });\n\n const dashOffset = pathLength * (1 - progress);\n\n // Find dot position along the path at current progress\n const targetLen = pathLength * progress;\n let traveled = 0;\n let dotX = points[0].x;\n let dotY = points[0].y;\n for (let i = 1; i < points.length; i++) {\n const dx = points[i].x - points[i - 1].x;\n const dy = points[i].y - points[i - 1].y;\n const segLen = Math.sqrt(dx * dx + dy * dy);\n if (traveled + segLen >= targetLen) {\n const t = (targetLen - traveled) / segLen;\n dotX = points[i - 1].x + dx * t;\n dotY = points[i - 1].y + dy * t;\n break;\n }\n traveled += segLen;\n dotX = points[i].x;\n dotY = points[i].y;\n }\n\n const gridRows = 4;\n const gridCols = data.length - 1;\n\n return (\n <div\n className={className}\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n fontFamily:\n \"var(--font-geist-sans), -apple-system, BlinkMacSystemFont, sans-serif\",\n }}\n >\n <svg\n width={width}\n height={height}\n viewBox={`0 0 ${width} ${height}`}\n style={{ overflow: \"visible\" }}\n >\n {/* Horizontal grid */}\n {Array.from({ length: gridRows + 1 }).map((_, i) => {\n const y = padding + (i / gridRows) * innerHeight;\n return (\n <line\n key={`h-${i}`}\n x1={padding}\n x2={padding + innerWidth}\n y1={y}\n y2={y}\n stroke={gridColor}\n strokeWidth={1}\n />\n );\n })}\n {/* Vertical grid */}\n {Array.from({ length: gridCols + 1 }).map((_, i) => {\n const x = padding + (i / gridCols) * innerWidth;\n return (\n <line\n key={`v-${i}`}\n x1={x}\n x2={x}\n y1={padding}\n y2={padding + innerHeight}\n stroke={gridColor}\n strokeWidth={1}\n />\n );\n })}\n {/* Axis */}\n <line\n x1={padding}\n x2={padding}\n y1={padding}\n y2={padding + innerHeight}\n stroke={gridColor}\n strokeWidth={2}\n />\n <line\n x1={padding}\n x2={padding + innerWidth}\n y1={padding + innerHeight}\n y2={padding + innerHeight}\n stroke={gridColor}\n strokeWidth={2}\n />\n\n {/* Animated line */}\n <path\n d={d}\n fill=\"none\"\n stroke={strokeColor}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeDasharray={pathLength}\n strokeDashoffset={dashOffset}\n style={{\n filter: `drop-shadow(0 0 12px ${strokeColor}55)`,\n }}\n />\n\n {showDot && progress > 0 && progress < 1 && (\n <circle\n cx={dotX}\n cy={dotY}\n r={strokeWidth * 2}\n fill={strokeColor}\n style={{\n filter: `drop-shadow(0 0 8px ${strokeColor})`,\n }}\n />\n )}\n </svg>\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n strokeColor: {\n type: \"color\",\n default: \"#22c55e\",\n description: \"Stroke color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 16,\n step: 1,\n default: 4,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n gridColor: {\n type: \"color\",\n default: \"#27272a\",\n description: \"Grid color\",\n },\n showDot: {\n type: \"boolean\",\n default: true,\n description: \"Show leading dot\",\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 1000,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 500,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"strokeColor\",\"strokeWidth\",\"gridColor\",\"showDot\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n strokeColor: \"#22c55e\",\n strokeWidth: 4,\n gridColor: \"#27272a\",\n showDot: true,\n speed: 1,\n};\n\ntype AnimatedLineChartElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof AnimatedLineChartBase>;\n\nconst AnimatedLineChartInner = forwardRef<\n HTMLDivElement,\n AnimatedLineChartElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 1000, height = 500, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<AnimatedLineChart>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <AnimatedLineChartBase\n {...(componentProps as unknown as ComponentProps<typeof AnimatedLineChartBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const AnimatedLineChart = Interactive.withSchema({\n Component: AnimatedLineChartInner,\n componentName: \"<AnimatedLineChart>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/ascii-render.json b/registry-artifacts/elements/ascii-render.jsonindex 209c93da..68b8b734 100644--- a/registry-artifacts/elements/ascii-render.json+++ b/registry-artifacts/elements/ascii-render.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/transitions",@@ -11,6 +12,7 @@"dimensions": null,"displayName": "ASCII Render","durationInFrames": 90,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "ascii-render","sourceCode": "import { AbsoluteFill, Interactive, Sequence, isHtmlInCanvasSupported, useCurrentFrame, useDelayRender, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport React, { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\nimport { type TransitionPresentation, type TransitionPresentationComponentProps } from \"@remotion/transitions\";\n\nconst QUAD = new Float32Array([-1, -1, 1, -1, -1, 1, 1, 1]);\n\nconst VERTEX_SHADER = `#version 300 es\nin vec2 a_pos;\nout vec2 v_uv;\nvoid main() {\n v_uv = vec2(a_pos.x * 0.5 + 0.5, 0.5 - a_pos.y * 0.5);\n gl_Position = vec4(a_pos, 0.0, 1.0);\n}`;\n\nconst LAYER: React.CSSProperties = {\n position: \"absolute\",\n inset: 0,\n width: \"100%\",\n height: \"100%\",\n};\n\nconst OUTPUT_LAYER: React.CSSProperties = { ...LAYER, pointerEvents: \"none\" };\n\nconst isCanvasTransitionSupported = (): boolean =>\n isHtmlInCanvasSupported();\n\nconst isCanvasFilterSupported = (): boolean => isHtmlInCanvasSupported();\n\ntype SceneShaderFrame<Props> = {\n gl: WebGL2RenderingContext;\n uniform: (name: string) => WebGLUniformLocation | null;\n width: number;\n height: number;\n progress: number;\n passedProps: Props;\n};\n\ntype SceneShaderDrawParams<Props> = {\n from: OffscreenCanvas | null;\n to: OffscreenCanvas | null;\n width: number;\n height: number;\n progress: number;\n passedProps: Props;\n};\n\ntype SceneShaderInstance<Props> = {\n draw: (params: SceneShaderDrawParams<Props>) => void;\n clear: () => void;\n cleanup: () => void;\n};\n\ntype SceneShader<Props> = (\n canvas: OffscreenCanvas,\n) => SceneShaderInstance<Props>;\n\ntype SceneFilterFrame<Props> = {\n gl: WebGL2RenderingContext;\n uniform: (name: string) => WebGLUniformLocation | null;\n width: number;\n height: number;\n frame: number;\n time: number;\n passedProps: Props;\n};\n\ntype SceneFilterDrawParams<Props> = {\n scene: OffscreenCanvas | null;\n width: number;\n height: number;\n frame: number;\n time: number;\n passedProps: Props;\n};\n\ntype SceneFilterInstance<Props> = {\n draw: (params: SceneFilterDrawParams<Props>) => void;\n clear: () => void;\n cleanup: () => void;\n};\n\ntype SceneFilter<Props> = (\n canvas: OffscreenCanvas,\n) => SceneFilterInstance<Props>;\n\nfunction compileShader(\n gl: WebGL2RenderingContext,\n source: string,\n type: GLenum,\n): WebGLShader {\n const shader = gl.createShader(type);\n if (!shader) {\n throw new Error(\"canvas-presentation: failed to create shader\");\n }\n gl.shaderSource(shader, source);\n gl.compileShader(shader);\n if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {\n const log = gl.getShaderInfoLog(shader);\n gl.deleteShader(shader);\n throw new Error(`canvas-presentation: failed to compile shader: ${log}`);\n }\n return shader;\n}\n\nfunction createProgram(\n gl: WebGL2RenderingContext,\n fragment: string,\n): WebGLProgram {\n const program = gl.createProgram();\n if (!program) {\n throw new Error(\"canvas-presentation: failed to create program\");\n }\n const vs = compileShader(gl, VERTEX_SHADER, gl.VERTEX_SHADER);\n const fs = compileShader(gl, fragment, gl.FRAGMENT_SHADER);\n gl.attachShader(program, vs);\n gl.attachShader(program, fs);\n gl.linkProgram(program);\n gl.deleteShader(vs);\n gl.deleteShader(fs);\n if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {\n const log = gl.getProgramInfoLog(program);\n gl.deleteProgram(program);\n throw new Error(`canvas-presentation: failed to link program: ${log}`);\n }\n return program;\n}\n\nfunction createSceneTexture(gl: WebGL2RenderingContext): WebGLTexture {\n const texture = gl.createTexture();\n if (!texture) {\n throw new Error(\"canvas-presentation: failed to create texture\");\n }\n gl.bindTexture(gl.TEXTURE_2D, texture);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);\n gl.texImage2D(\n gl.TEXTURE_2D,\n 0,\n gl.RGBA,\n 1,\n 1,\n 0,\n gl.RGBA,\n gl.UNSIGNED_BYTE,\n new Uint8Array([0, 0, 0, 0]),\n );\n return texture;\n}\n\nfunction createQuadSurface(canvas: OffscreenCanvas, fragment: string) {\n const gl = canvas.getContext(\"webgl2\", { premultipliedAlpha: true });\n if (!gl) {\n throw new Error(\"canvas-presentation: WebGL2 is unavailable\");\n }\n\n const program = createProgram(gl, fragment);\n const vao = gl.createVertexArray();\n gl.bindVertexArray(vao);\n const buffer = gl.createBuffer();\n gl.bindBuffer(gl.ARRAY_BUFFER, buffer);\n gl.bufferData(gl.ARRAY_BUFFER, QUAD, gl.STATIC_DRAW);\n const aPos = gl.getAttribLocation(program, \"a_pos\");\n gl.enableVertexAttribArray(aPos);\n gl.vertexAttribPointer(aPos, 2, gl.FLOAT, false, 0, 0);\n\n const locations = new Map<string, WebGLUniformLocation | null>();\n const uniform = (name: string) => {\n const cached = locations.get(name);\n if (cached !== undefined) {\n return cached;\n }\n const location = gl.getUniformLocation(program, name);\n locations.set(name, location);\n return location;\n };\n\n const clear = () => {\n gl.clearColor(0, 0, 0, 0);\n gl.clear(gl.COLOR_BUFFER_BIT);\n };\n\n const textures: WebGLTexture[] = [];\n const createTexture = () => {\n const texture = createSceneTexture(gl);\n textures.push(texture);\n return texture;\n };\n\n const begin = (width: number, height: number) => {\n gl.viewport(0, 0, width, height);\n clear();\n gl.useProgram(program);\n gl.bindVertexArray(vao);\n };\n\n const bindScene = (\n image: OffscreenCanvas | null,\n texture: WebGLTexture,\n unit: number,\n name: string,\n ) => {\n gl.activeTexture(gl.TEXTURE0 + unit);\n gl.bindTexture(gl.TEXTURE_2D, texture);\n if (image) {\n gl.texImage2D(\n gl.TEXTURE_2D,\n 0,\n gl.RGBA,\n gl.RGBA,\n gl.UNSIGNED_BYTE,\n image,\n );\n }\n gl.uniform1i(uniform(name), unit);\n };\n\n const draw = () => gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);\n\n const cleanup = () => {\n gl.deleteProgram(program);\n for (const texture of textures) {\n gl.deleteTexture(texture);\n }\n gl.deleteBuffer(buffer);\n gl.deleteVertexArray(vao);\n };\n\n return {\n gl,\n uniform,\n clear,\n createTexture,\n begin,\n bindScene,\n draw,\n cleanup,\n };\n}\n\nfunction makeSceneShader<Props extends Record<string, unknown>>(\n fragment: string,\n setUniforms?: (frame: SceneShaderFrame<Props>) => void,\n): SceneShader<Props> {\n return (canvas) => {\n const surface = createQuadSurface(canvas, fragment);\n const fromTexture = surface.createTexture();\n const toTexture = surface.createTexture();\n\n return {\n clear: surface.clear,\n cleanup: surface.cleanup,\n draw: ({ from, to, width, height, progress, passedProps }) => {\n surface.begin(width, height);\n surface.bindScene(from, fromTexture, 0, \"u_from\");\n surface.bindScene(to, toTexture, 1, \"u_to\");\n\n surface.gl.uniform1f(surface.uniform(\"u_progress\"), progress);\n surface.gl.uniform1f(surface.uniform(\"u_aspect\"), width / height);\n setUniforms?.({\n gl: surface.gl,\n uniform: surface.uniform,\n width,\n height,\n progress,\n passedProps,\n });\n\n surface.draw();\n },\n };\n };\n}\n\nfunction makeFilterShader<Props extends Record<string, unknown>>(\n fragment: string,\n setUniforms?: (frame: SceneFilterFrame<Props>) => void,\n): SceneFilter<Props> {\n return (canvas) => {\n const surface = createQuadSurface(canvas, fragment);\n const sceneTexture = surface.createTexture();\n\n return {\n clear: surface.clear,\n cleanup: surface.cleanup,\n draw: ({ scene, width, height, frame, time, passedProps }) => {\n surface.begin(width, height);\n surface.bindScene(scene, sceneTexture, 0, \"u_scene\");\n\n surface.gl.uniform1f(surface.uniform(\"u_frame\"), frame);\n surface.gl.uniform1f(surface.uniform(\"u_time\"), time);\n surface.gl.uniform1f(surface.uniform(\"u_aspect\"), width / height);\n setUniforms?.({\n gl: surface.gl,\n uniform: surface.uniform,\n width,\n height,\n frame,\n time,\n passedProps,\n });\n\n surface.draw();\n },\n };\n };\n}\n\nconst transferred = new WeakMap<HTMLCanvasElement, OffscreenCanvas>();\n\nfunction takeOffscreen(canvas: HTMLCanvasElement): OffscreenCanvas {\n const existing = transferred.get(canvas);\n if (existing) {\n return existing;\n }\n const created = canvas.transferControlToOffscreen();\n transferred.set(canvas, created);\n return created;\n}\n\nfunction makeCanvasComponent<Props extends Record<string, unknown>>(\n shader: SceneShader<Props>,\n): React.FC<TransitionPresentationComponentProps<Props>> {\n return function CanvasScenePresentation({\n children,\n presentationProgress,\n presentationDirection,\n passedProps,\n onElementImage,\n onUnmount,\n bothEnteringAndExiting,\n }) {\n const layoutRef = React.useRef<HTMLCanvasElement | null>(null);\n const outputRef = React.useRef<HTMLCanvasElement | null>(null);\n const captureRef = React.useRef<OffscreenCanvas | null>(null);\n const captureContextRef =\n React.useRef<OffscreenCanvasRenderingContext2D | null>(null);\n const outputSurfaceRef = React.useRef<OffscreenCanvas | null>(null);\n const instanceRef = React.useRef<SceneShaderInstance<Props> | null>(null);\n const passedPropsRef = React.useRef(passedProps);\n passedPropsRef.current = passedProps;\n const onElementImageRef = React.useRef(onElementImage);\n onElementImageRef.current = onElementImage;\n const onUnmountRef = React.useRef(onUnmount);\n onUnmountRef.current = onUnmount;\n\n const { delayRender, continueRender } = useDelayRender();\n const passThrough =\n bothEnteringAndExiting && presentationDirection === \"exiting\";\n\n const drawRef = React.useRef<\n (\n prevImage: OffscreenCanvas | null,\n nextImage: OffscreenCanvas | null,\n progress: number,\n ) => void\n >(() => undefined);\n drawRef.current = (prevImage, nextImage, progress) => {\n const instance = instanceRef.current;\n if (!instance) {\n return;\n }\n const handle = delayRender(\"canvas-presentation: paint\");\n const to = prevImage;\n const from = nextImage;\n const width = from?.width ?? to?.width ?? 0;\n const height = from?.height ?? to?.height ?? 0;\n if (width === 0 || height === 0) {\n instance.clear();\n continueRender(handle);\n return;\n }\n instance.draw({\n from,\n to,\n width,\n height,\n progress: !to ? 0 : !from ? 1 : progress,\n passedProps: passedPropsRef.current,\n });\n continueRender(handle);\n };\n\n const draw = React.useCallback(\n (\n prevImage: OffscreenCanvas | null,\n nextImage: OffscreenCanvas | null,\n progress: number,\n ) => drawRef.current(prevImage, nextImage, progress),\n [],\n );\n\n React.useLayoutEffect(() => {\n if (passThrough) {\n return;\n }\n const layout = layoutRef.current;\n const output = outputRef.current;\n if (!layout || !output) {\n return;\n }\n const capture = takeOffscreen(layout);\n const context = capture.getContext(\"2d\");\n if (!context) {\n throw new Error(\"canvas-presentation: failed to acquire a 2D context\");\n }\n const surface = takeOffscreen(output);\n captureRef.current = capture;\n captureContextRef.current = context;\n outputSurfaceRef.current = surface;\n instanceRef.current = shader(surface);\n\n return () => {\n instanceRef.current?.cleanup();\n instanceRef.current = null;\n captureRef.current = null;\n captureContextRef.current = null;\n outputSurfaceRef.current = null;\n };\n }, [passThrough, shader]);\n\n React.useLayoutEffect(() => {\n if (passThrough) {\n return;\n }\n const layout = layoutRef.current;\n if (!layout) {\n return;\n }\n layout.layoutSubtree = true;\n const handlePaint = () => {\n const scene = layout.firstElementChild;\n const capture = captureRef.current;\n const context = captureContextRef.current;\n if (!scene || !capture || !context) {\n return;\n }\n const elementImage = layout.captureElementImage(scene);\n try {\n context.reset();\n context.drawElementImage(elementImage, 0, 0);\n } finally {\n elementImage.close();\n }\n onElementImageRef.current(capture, draw);\n };\n layout.addEventListener(\"paint\", handlePaint);\n return () => layout.removeEventListener(\"paint\", handlePaint);\n }, [passThrough, draw]);\n\n React.useLayoutEffect(() => {\n if (passThrough) {\n return;\n }\n const layout = layoutRef.current;\n if (!layout) {\n return;\n }\n const observer = new ResizeObserver(([entry]) => {\n const capture = captureRef.current;\n const surface = outputSurfaceRef.current;\n if (!capture || !surface) {\n return;\n }\n const width = entry.devicePixelContentBoxSize[0].inlineSize;\n const height = entry.devicePixelContentBoxSize[0].blockSize;\n capture.width = width;\n capture.height = height;\n surface.width = width;\n surface.height = height;\n layout.requestPaint?.();\n });\n observer.observe(layout, { box: \"device-pixel-content-box\" });\n return () => observer.disconnect();\n }, [passThrough]);\n\n // biome-ignore lint/correctness/useExhaustiveDependencies: presentationProgress is the intentional trigger — a new progress value is what schedules the next paint\n React.useLayoutEffect(() => {\n if (passThrough) {\n return;\n }\n layoutRef.current?.requestPaint?.();\n }, [passThrough, presentationProgress]);\n\n React.useLayoutEffect(() => {\n if (passThrough) {\n return;\n }\n return () => onUnmountRef.current();\n }, [passThrough]);\n\n if (passThrough) {\n return <>{children}</>;\n }\n\n return (\n <AbsoluteFill>\n <canvas ref={layoutRef} style={LAYER}>\n {children}\n </canvas>\n <canvas ref={outputRef} style={OUTPUT_LAYER} />\n </AbsoluteFill>\n );\n };\n}\n\ntype CanvasFilterProps = {\n children: React.ReactNode;\n};\n\nfunction makeFilterComponent<Props extends Record<string, unknown>>(\n shader: SceneFilter<Props>,\n): React.FC<Props & CanvasFilterProps> {\n return function CanvasSceneFilter(props) {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const { delayRender, continueRender } = useDelayRender();\n\n const layoutRef = React.useRef<HTMLCanvasElement | null>(null);\n const outputRef = React.useRef<HTMLCanvasElement | null>(null);\n const captureRef = React.useRef<OffscreenCanvas | null>(null);\n const captureContextRef =\n React.useRef<OffscreenCanvasRenderingContext2D | null>(null);\n const outputSurfaceRef = React.useRef<OffscreenCanvas | null>(null);\n const instanceRef = React.useRef<SceneFilterInstance<Props> | null>(null);\n\n const passedPropsRef = React.useRef(props);\n passedPropsRef.current = props;\n const frameRef = React.useRef(frame);\n frameRef.current = frame;\n const timeRef = React.useRef(frame / fps);\n timeRef.current = frame / fps;\n\n React.useLayoutEffect(() => {\n const layout = layoutRef.current;\n const output = outputRef.current;\n if (!layout || !output) {\n return;\n }\n const capture = takeOffscreen(layout);\n const context = capture.getContext(\"2d\");\n if (!context) {\n throw new Error(\"canvas-presentation: failed to acquire a 2D context\");\n }\n const surface = takeOffscreen(output);\n captureRef.current = capture;\n captureContextRef.current = context;\n outputSurfaceRef.current = surface;\n instanceRef.current = shader(surface);\n\n return () => {\n instanceRef.current?.cleanup();\n instanceRef.current = null;\n captureRef.current = null;\n captureContextRef.current = null;\n outputSurfaceRef.current = null;\n };\n }, [shader]);\n\n React.useLayoutEffect(() => {\n const layout = layoutRef.current;\n if (!layout) {\n return;\n }\n layout.layoutSubtree = true;\n const handlePaint = () => {\n const scene = layout.firstElementChild;\n const capture = captureRef.current;\n const context = captureContextRef.current;\n const instance = instanceRef.current;\n if (!scene || !capture || !context || !instance) {\n return;\n }\n const elementImage = layout.captureElementImage(scene);\n try {\n context.reset();\n context.drawElementImage(elementImage, 0, 0);\n } finally {\n elementImage.close();\n }\n if (capture.width === 0 || capture.height === 0) {\n instance.clear();\n return;\n }\n instance.draw({\n scene: capture,\n width: capture.width,\n height: capture.height,\n frame: frameRef.current,\n time: timeRef.current,\n passedProps: passedPropsRef.current,\n });\n };\n layout.addEventListener(\"paint\", handlePaint);\n return () => layout.removeEventListener(\"paint\", handlePaint);\n }, []);\n\n React.useLayoutEffect(() => {\n const layout = layoutRef.current;\n if (!layout) {\n return;\n }\n const observer = new ResizeObserver(([entry]) => {\n const capture = captureRef.current;\n const surface = outputSurfaceRef.current;\n if (!capture || !surface) {\n return;\n }\n const width = entry.devicePixelContentBoxSize[0].inlineSize;\n const height = entry.devicePixelContentBoxSize[0].blockSize;\n capture.width = width;\n capture.height = height;\n surface.width = width;\n surface.height = height;\n layout.requestPaint?.();\n });\n observer.observe(layout, { box: \"device-pixel-content-box\" });\n return () => observer.disconnect();\n }, []);\n\n React.useLayoutEffect(() => {\n const layout = layoutRef.current;\n if (!layout) {\n return;\n }\n const handle = delayRender(\"canvas-presentation: filter paint\");\n const settle = () => continueRender(handle);\n layout.addEventListener(\"paint\", settle, { once: true });\n layout.requestPaint?.();\n return () => {\n layout.removeEventListener(\"paint\", settle);\n continueRender(handle);\n };\n });\n\n return (\n <AbsoluteFill>\n <canvas ref={layoutRef} style={LAYER}>\n {props.children}\n </canvas>\n <canvas ref={outputRef} style={OUTPUT_LAYER} />\n </AbsoluteFill>\n );\n };\n}\n\ntype CanvasPresentationOptions<Props extends Record<string, unknown>> = {\n shader: SceneShader<Props>;\n fallback: React.FC<TransitionPresentationComponentProps<Props>>;\n};\n\nfunction makeCanvasPresentation<Props extends Record<string, unknown>>({\n shader,\n fallback: Fallback,\n}: CanvasPresentationOptions<Props>): (\n props: Props,\n) => TransitionPresentation<Props> {\n const Canvas = makeCanvasComponent(shader);\n\n const Presentation: React.FC<TransitionPresentationComponentProps<Props>> = (\n props,\n ) =>\n isCanvasTransitionSupported() ? (\n <Canvas {...props} />\n ) : (\n <Fallback {...props} />\n );\n\n return (props) => ({ component: Presentation, props });\n}\n\ntype CanvasFilterOptions<Props extends Record<string, unknown>> = {\n shader: SceneFilter<Props>;\n fallback: React.FC<Props & CanvasFilterProps>;\n};\n\nfunction makeCanvasFilter<Props extends Record<string, unknown>>({\n shader,\n fallback: Fallback,\n}: CanvasFilterOptions<Props>): React.FC<Props & CanvasFilterProps> {\n const Canvas = makeFilterComponent(shader);\n\n return function CanvasFilter(props) {\n return isCanvasFilterSupported() ? (\n <Canvas {...props} />\n ) : (\n <Fallback {...props} />\n );\n };\n}\n\ntype AsciiRenderProps = {\n glyphSize?: number;\n charset?: string;\n colored?: boolean;\n ink?: string;\n intensity?: number;\n};\n\nconst DEFAULTS = {\n glyphSize: 26,\n charset: \" .:-=+*#%@\",\n colored: false,\n ink: \"#9dff9d\",\n intensity: 1,\n};\n\nconst GLYPH_ASPECT = 0.545;\nconst ATLAS_CELL_W = 24;\nconst ATLAS_CELL_H = 44;\nconst ATLAS_FONT =\n 'ui-monospace, SFMono-Regular, Menlo, Consolas, \"Liberation Mono\", monospace';\n\ntype NormalizedProps = {\n cellX: number;\n cellY: number;\n charset: string;\n colored: boolean;\n ink: string;\n intensity: number;\n};\n\nconst FRAGMENT_SHADER = `#version 300 es\nprecision highp float;\n\nuniform sampler2D u_scene;\nuniform sampler2D u_atlas;\nuniform vec2 u_cell;\nuniform float u_glyph_count;\nuniform float u_colored;\nuniform vec3 u_ink;\nuniform float u_intensity;\n\nin vec2 v_uv;\nout vec4 outColor;\n\nconst int TAPS = 3;\n\nvec4 cellAverage(vec2 center, vec2 cell) {\n vec4 sum = vec4(0.0);\n for (int y = 0; y < TAPS; y++) {\n for (int x = 0; x < TAPS; x++) {\n vec2 offset = (vec2(float(x), float(y)) + 0.5) / float(TAPS) - 0.5;\n sum += texture(u_scene, center + offset * cell);\n }\n }\n return sum / float(TAPS * TAPS);\n}\n\nvoid main() {\n vec2 cell = max(u_cell, vec2(0.001));\n vec2 origin = floor(v_uv / cell) * cell;\n vec4 sampled = cellAverage(origin + cell * 0.5, cell);\n\n float luma = dot(sampled.rgb, vec3(0.299, 0.587, 0.114));\n float index = min(floor(luma * u_glyph_count), u_glyph_count - 1.0);\n\n vec2 local = clamp((v_uv - origin) / cell, 0.008, 0.992);\n float mask =\n texture(u_atlas, vec2((index + local.x) / u_glyph_count, local.y)).r;\n\n vec3 glyph = mix(u_ink, sampled.rgb, u_colored) * mask;\n vec4 source = texture(u_scene, v_uv);\n float amount = clamp(u_intensity, 0.0, 1.0);\n\n outColor = vec4(\n mix(source.rgb, glyph, amount),\n mix(source.a, max(mask, sampled.a), amount)\n );\n}`;\n\ntype Atlas = { charset: string; texture: WebGLTexture };\n\nconst atlases = new WeakMap<WebGL2RenderingContext, Atlas>();\n\nfunction drawAtlas(charset: string): OffscreenCanvas {\n const canvas = new OffscreenCanvas(\n ATLAS_CELL_W * charset.length,\n ATLAS_CELL_H,\n );\n const context = canvas.getContext(\"2d\");\n if (!context) {\n throw new Error(\"ascii-render: failed to acquire a 2D context\");\n }\n context.fillStyle = \"#000000\";\n context.fillRect(0, 0, canvas.width, canvas.height);\n context.fillStyle = \"#ffffff\";\n context.font = `${Math.round(ATLAS_CELL_H * 0.74)}px ${ATLAS_FONT}`;\n context.textAlign = \"center\";\n context.textBaseline = \"middle\";\n for (let i = 0; i < charset.length; i++) {\n context.fillText(\n charset[i],\n i * ATLAS_CELL_W + ATLAS_CELL_W / 2,\n ATLAS_CELL_H / 2,\n );\n }\n return canvas;\n}\n\nfunction bindAtlas(gl: WebGL2RenderingContext, charset: string): void {\n gl.activeTexture(gl.TEXTURE1);\n\n let atlas = atlases.get(gl);\n if (!atlas) {\n const texture = gl.createTexture();\n if (!texture) {\n throw new Error(\"ascii-render: failed to create the glyph atlas\");\n }\n gl.bindTexture(gl.TEXTURE_2D, texture);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);\n atlas = { charset: \"\", texture };\n atlases.set(gl, atlas);\n } else {\n gl.bindTexture(gl.TEXTURE_2D, atlas.texture);\n }\n\n if (atlas.charset !== charset) {\n gl.texImage2D(\n gl.TEXTURE_2D,\n 0,\n gl.RGBA,\n gl.RGBA,\n gl.UNSIGNED_BYTE,\n drawAtlas(charset),\n );\n atlas.charset = charset;\n }\n}\n\nfunction toRgb(hex: string): [number, number, number] {\n const value = hex.replace(\"#\", \"\");\n const full =\n value.length === 3\n ? value\n .split(\"\")\n .map((c) => c + c)\n .join(\"\")\n : value;\n const int = Number.parseInt(full, 16);\n if (Number.isNaN(int)) return [1, 1, 1];\n return [\n ((int >> 16) & 255) / 255,\n ((int >> 8) & 255) / 255,\n (int & 255) / 255,\n ];\n}\n\nconst shader = makeFilterShader<NormalizedProps>(\n FRAGMENT_SHADER,\n ({ gl, uniform, passedProps }) => {\n const { cellX, cellY, charset, colored, ink, intensity } = passedProps;\n bindAtlas(gl, charset);\n gl.uniform1i(uniform(\"u_atlas\"), 1);\n gl.uniform1f(uniform(\"u_glyph_count\"), charset.length);\n gl.uniform2f(uniform(\"u_cell\"), cellX, cellY);\n gl.uniform1f(uniform(\"u_colored\"), colored ? 1 : 0);\n gl.uniform3fv(uniform(\"u_ink\"), toRgb(ink));\n gl.uniform1f(uniform(\"u_intensity\"), intensity);\n },\n);\n\nconst AsciiRenderFallback: React.FC<NormalizedProps & CanvasFilterProps> = ({\n children,\n}) => <AbsoluteFill>{children}</AbsoluteFill>;\n\nconst AsciiRenderCanvas = makeCanvasFilter<NormalizedProps>({\n shader,\n fallback: AsciiRenderFallback,\n});\n\nconst AsciiRenderBase: React.FC<AsciiRenderProps & CanvasFilterProps> = ({\n glyphSize = DEFAULTS.glyphSize,\n charset = DEFAULTS.charset,\n colored = DEFAULTS.colored,\n ink = DEFAULTS.ink,\n intensity = DEFAULTS.intensity,\n children,\n}) => {\n const { width, height } = useVideoConfig();\n const resolved = charset.length > 0 ? charset : DEFAULTS.charset;\n\n return (\n <AsciiRenderCanvas\n cellX={(glyphSize * GLYPH_ASPECT) / width}\n cellY={glyphSize / height}\n charset={resolved}\n colored={colored}\n ink={ink}\n intensity={intensity}\n >\n {children}\n </AsciiRenderCanvas>\n );\n};\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n glyphSize: {\n type: \"number\",\n min: 10,\n max: 64,\n step: 2,\n default: 26,\n description: \"Glyph size\",\n hiddenFromList: false,\n },\n charset: {\n type: \"text-content\",\n default: \" .:-=+*#%@\",\n description: \"Charset\",\n },\n colored: {\n type: \"boolean\",\n default: false,\n description: \"Source colour\",\n },\n ink: {\n type: \"color\",\n default: \"#9dff9d\",\n description: \"Ink\",\n },\n intensity: {\n type: \"number\",\n min: 0,\n max: 1,\n step: 0.05,\n default: 1,\n description: \"Intensity\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"glyphSize\",\"charset\",\"colored\",\"ink\",\"intensity\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n glyphSize: 26,\n charset: \" .:-=+*#%@\",\n colored: false,\n ink: \"#9dff9d\",\n intensity: 1,\n speed: 1,\n};\n\ntype AsciiRenderElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof AsciiRenderBase>;\n\nconst AsciiRenderInner = forwardRef<\n HTMLDivElement,\n AsciiRenderElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<AsciiRender>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <AsciiRenderBase\n {...(componentProps as unknown as ComponentProps<typeof AsciiRenderBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const AsciiRender = Interactive.withSchema({\n Component: AsciiRenderInner,\n componentName: \"<AsciiRender>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/backdrop.json b/registry-artifacts/elements/backdrop.jsonindex 4efb532b..bb7a56d4 100644--- a/registry-artifacts/elements/backdrop.json+++ b/registry-artifacts/elements/backdrop.json@@ -2,10 +2,12 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [],"dimensions": null,"displayName": "Backdrop","durationInFrames": 150,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "backdrop","sourceCode": "import { forwardRef, isValidElement, useImperativeHandle, useRef, type ComponentProps, type ReactNode } from \"react\";\nimport { AbsoluteFill, Img, Interactive, Sequence, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\n\ntype BackdropFill =\n | { type: \"color\"; value: string }\n | { type: \"gradient\"; value: string }\n | { type: \"image\"; src: string; fit?: \"cover\" | \"contain\" };\n\ninterface BackdropProps {\n fill?: BackdropFill | ReactNode;\n padding?: number;\n radius?: number;\n shadow?: string;\n children?: ReactNode;\n className?: string;\n}\n\nconst DEFAULT_FILL: BackdropFill = { type: \"color\", value: \"#0a0a0a\" };\n\nfunction FillLayer({ fill }: { fill: BackdropFill }) {\n if (fill.type === \"image\") {\n return (\n <AbsoluteFill>\n <Img\n src={fill.src}\n style={{\n width: \"100%\",\n height: \"100%\",\n objectFit: fill.fit ?? \"cover\",\n }}\n />\n </AbsoluteFill>\n );\n }\n\n return <AbsoluteFill style={{ background: fill.value }} />;\n}\n\nfunction BackdropBase({\n fill,\n padding = 4,\n radius = 1,\n shadow = \"0 20px 60px rgba(0,0,0,0.4)\",\n children,\n className,\n}: BackdropProps) {\n const { width } = useVideoConfig();\n\n const paddingPx = (padding / 100) * width;\n const radiusPx = (radius / 100) * width;\n\n const fillLayer = isValidElement(fill) ? (\n <AbsoluteFill>{fill}</AbsoluteFill>\n ) : (\n <FillLayer fill={(fill as BackdropFill | undefined) ?? DEFAULT_FILL} />\n );\n\n return (\n <AbsoluteFill className={className}>\n {fillLayer}\n {children != null && (\n <div\n style={{\n position: \"absolute\",\n inset: paddingPx,\n overflow: \"hidden\",\n borderRadius: radiusPx,\n display: \"flex\",\n ...(shadow === \"\" ? {} : { boxShadow: shadow }),\n }}\n >\n <div style={{ width: \"100%\", height: \"100%\" }}>{children}</div>\n </div>\n )}\n </AbsoluteFill>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n fillType: {\n type: \"enum\",\n default: \"gradient\",\n variants: {\n color: {},\n gradient: {},\n image: {},\n },\n description: \"Fill type\",\n },\n color: {\n type: \"color\",\n default: \"#6366f1\",\n description: \"Color\",\n },\n gradient: {\n type: \"text-content\",\n default: \"linear-gradient(135deg, #6366f1 0%, #a855f7 100%)\",\n description: \"Gradient (CSS)\",\n },\n image: {\n type: \"text-content\",\n default: \"/hero.png\",\n description: \"Image URL\",\n },\n padding: {\n type: \"number\",\n min: 0,\n max: 12,\n step: 0.5,\n default: 4,\n description: \"Padding\",\n hiddenFromList: false,\n },\n radius: {\n type: \"number\",\n min: 0,\n max: 4,\n step: 0.25,\n default: 1,\n description: \"Radius\",\n hiddenFromList: false,\n },\n shadow: {\n type: \"text-content\",\n default: \"0 20px 60px rgba(0,0,0,0.4)\",\n description: \"Shadow\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"fillType\",\"color\",\"gradient\",\"image\",\"padding\",\"radius\",\"shadow\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n fillType: \"gradient\",\n color: \"#6366f1\",\n gradient: \"linear-gradient(135deg, #6366f1 0%, #a855f7 100%)\",\n image: \"/hero.png\",\n padding: 4,\n radius: 1,\n shadow: \"0 20px 60px rgba(0,0,0,0.4)\",\n};\n\ntype BackdropElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof BackdropBase>;\n\nconst BackdropInner = forwardRef<\n HTMLDivElement,\n BackdropElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<Backdrop>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <BackdropBase\n {...(componentProps as unknown as ComponentProps<typeof BackdropBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const Backdrop = Interactive.withSchema({\n Component: BackdropInner,\n componentName: \"<Backdrop>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/bauhaus-build.json b/registry-artifacts/elements/bauhaus-build.jsonindex 2a2cff9a..96ceab4f 100644--- a/registry-artifacts/elements/bauhaus-build.json+++ b/registry-artifacts/elements/bauhaus-build.json@@ -2,10 +2,12 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [],"dimensions": null,"displayName": "Bauhaus Build","durationInFrames": 125,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "bauhaus-build","sourceCode": "import { Easing, Interactive, Sequence, random, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ntype BauhausShape =\n | \"circle\"\n | \"square\"\n | \"semicircle\"\n | \"quarter\"\n | \"bar\";\n\ntype BauhausRole = \"ink\" | \"accent\" | \"secondary\" | \"tertiary\";\n\ntype TumbleDirection = \"U\" | \"D\" | \"L\" | \"R\";\n\ntype TumbleMove = `${TumbleDirection}${\"+\" | \"-\"}`;\n\ninterface BauhausPose {\n turn: number;\n x: number;\n y: number;\n}\n\ninterface BauhausPoint {\n x: number;\n y: number;\n}\n\ninterface BauhausFootprint {\n x0: number;\n y0: number;\n x1: number;\n y1: number;\n}\n\ninterface BauhausPiece {\n id: string;\n shape: BauhausShape;\n width: number;\n height: number;\n role: BauhausRole;\n slot: BauhausPose;\n enter: readonly TumbleMove[];\n rebuild: readonly TumbleMove[];\n cue: number;\n after: readonly string[];\n}\n\ninterface BauhausStep {\n move: TumbleMove;\n from: BauhausPose;\n to: BauhausPose;\n pivot: BauhausPoint;\n spin: 1 | -1;\n}\n\ninterface BauhausFrame {\n x: number;\n y: number;\n rotation: number;\n scale: number;\n pivot: BauhausPoint | null;\n}\n\ninterface BauhausPieceFrame extends BauhausFrame {\n id: string;\n shape: BauhausShape;\n role: BauhausRole;\n width: number;\n height: number;\n visible: boolean;\n}\n\ninterface BauhausBuildProps {\n scale?: number;\n seed?: number;\n inkColor?: string;\n accentColor?: string;\n secondaryColor?: string;\n tertiaryColor?: string;\n speed?: number;\n loop?: boolean;\n className?: string;\n}\n\ninterface TumbleRule {\n direction: TumbleDirection;\n spin: 1 | -1;\n reverse: TumbleMove;\n}\n\nconst bauhausBuildDefaults = {\n scale: 1,\n seed: 1,\n inkColor: \"#1c1a17\",\n accentColor: \"#e4572e\",\n secondaryColor: \"#cbbc9f\",\n tertiaryColor: \"#7e776b\",\n speed: 1,\n loop: false,\n};\n\nconst bauhausBuildGrid = 12;\nconst bauhausBuildBand = { top: 4, bottom: 8 };\nconst bauhausBuildLength = 125;\nconst bauhausBuildTimeline = {\n lead: 22,\n beat: 6,\n rebuild: 90,\n clear: 116,\n duration: 150,\n};\n\nconst bauhausBuildPieces: readonly BauhausPiece[] = [\n {\n id: \"hill\",\n shape: \"quarter\",\n width: 4,\n height: 4,\n role: \"ink\",\n slot: { turn: 3, x: 0, y: 4 },\n enter: [\"D-\", \"R+\"],\n rebuild: [\"D-\"],\n cue: 0,\n after: [\"tile\"],\n },\n {\n id: \"tile\",\n shape: \"square\",\n width: 1,\n height: 1,\n role: \"accent\",\n slot: { turn: 0, x: 4, y: 7 },\n enter: [\"U+\", \"U+\", \"U+\", \"U+\"],\n rebuild: [\"D+\"],\n cue: 3,\n after: [\"pillar\"],\n },\n {\n id: \"pillar\",\n shape: \"bar\",\n width: 4,\n height: 1,\n role: \"ink\",\n slot: { turn: 1, x: 5, y: 4 },\n enter: [\"R+\", \"R+\"],\n rebuild: [\"U+\"],\n cue: 6,\n after: [\"sun\"],\n },\n {\n id: \"sun\",\n shape: \"circle\",\n width: 4,\n height: 4,\n role: \"accent\",\n slot: { turn: 0, x: 6, y: 4 },\n enter: [\"U+\", \"U+\"],\n rebuild: [\"U-\"],\n cue: 9,\n after: [],\n },\n {\n id: \"dome\",\n shape: \"semicircle\",\n width: 2,\n height: 2,\n role: \"secondary\",\n slot: { turn: 3, x: 1, y: 1 },\n enter: [\"R+\", \"D-\"],\n rebuild: [\"R+\"],\n cue: 12,\n after: [\"pillar\"],\n },\n {\n id: \"post\",\n shape: \"bar\",\n width: 4,\n height: 1,\n role: \"tertiary\",\n slot: { turn: 1, x: 11, y: 4 },\n enter: [\"D+\", \"D+\"],\n rebuild: [\"D-\"],\n cue: 15,\n after: [],\n },\n {\n id: \"dot\",\n shape: \"circle\",\n width: 1,\n height: 1,\n role: \"ink\",\n slot: { turn: 0, x: 11, y: 3 },\n enter: [\"D-\", \"D-\", \"D-\", \"D-\"],\n rebuild: [\"L-\"],\n cue: 18,\n after: [\"post\"],\n },\n {\n id: \"block\",\n shape: \"square\",\n width: 2,\n height: 2,\n role: \"tertiary\",\n slot: { turn: 0, x: 6, y: 10 },\n enter: [\"U+\", \"U+\", \"U+\"],\n rebuild: [\"L+\"],\n cue: 21,\n after: [\"sun\"],\n },\n {\n id: \"fan\",\n shape: \"quarter\",\n width: 2,\n height: 2,\n role: \"secondary\",\n slot: { turn: 2, x: 8, y: 10 },\n enter: [\"L-\", \"L+\", \"L+\"],\n rebuild: [\"R+\"],\n cue: 24,\n after: [\"block\"],\n },\n];\n\nconst TURN = 5;\nconst FILL = 0.8;\nconst OVERSHOOT = 0.05;\nconst SETTLE = 0.5;\n\nconst MOVES: Record<TumbleMove, TumbleRule> = {\n \"U+\": { direction: \"U\", spin: 1, reverse: \"D-\" },\n \"U-\": { direction: \"U\", spin: -1, reverse: \"D+\" },\n \"D+\": { direction: \"D\", spin: 1, reverse: \"U-\" },\n \"D-\": { direction: \"D\", spin: -1, reverse: \"U+\" },\n \"L+\": { direction: \"L\", spin: 1, reverse: \"R-\" },\n \"L-\": { direction: \"L\", spin: -1, reverse: \"R+\" },\n \"R+\": { direction: \"R\", spin: 1, reverse: \"L-\" },\n \"R-\": { direction: \"R\", spin: -1, reverse: \"L+\" },\n};\n\nconst finite = (value: number, fallback: number) =>\n Number.isFinite(value) ? value : fallback;\nconst clamp = (value: number, min = 0, max = 1) =>\n Math.min(max, Math.max(min, value));\nconst swing = Easing.bezier(0.62, 0, 0.3, 1);\nconst settle = Easing.bezier(0.45, 0, 0.55, 1);\n\nfunction seedKey(seed: number) {\n return Number.isFinite(seed) ? Math.round(seed) : 1;\n}\n\nfunction getBauhausFootprint(\n piece: Pick<BauhausPiece, \"width\" | \"height\">,\n pose: BauhausPose,\n): BauhausFootprint {\n const odd = pose.turn % 2 !== 0;\n return {\n x0: pose.x,\n y0: pose.y,\n x1: pose.x + (odd ? piece.height : piece.width),\n y1: pose.y + (odd ? piece.width : piece.height),\n };\n}\n\nfunction getTumblePivot(\n box: BauhausFootprint,\n move: TumbleMove,\n): BauhausPoint {\n const { direction, spin } = MOVES[move];\n const clockwise = spin === 1;\n switch (direction) {\n case \"R\":\n return { x: box.x1, y: clockwise ? box.y1 : box.y0 };\n case \"L\":\n return { x: box.x0, y: clockwise ? box.y0 : box.y1 };\n case \"D\":\n return { x: clockwise ? box.x0 : box.x1, y: box.y1 };\n default:\n return { x: clockwise ? box.x1 : box.x0, y: box.y0 };\n }\n}\n\nconst quarterTurn = (\n point: BauhausPoint,\n pivot: BauhausPoint,\n spin: 1 | -1,\n): BauhausPoint => ({\n x: pivot.x - spin * (point.y - pivot.y),\n y: pivot.y + spin * (point.x - pivot.x),\n});\n\nfunction tumble(\n piece: Pick<BauhausPiece, \"width\" | \"height\">,\n pose: BauhausPose,\n move: TumbleMove,\n): BauhausStep {\n const { spin } = MOVES[move];\n const box = getBauhausFootprint(piece, pose);\n const pivot = getTumblePivot(box, move);\n const a = quarterTurn({ x: box.x0, y: box.y0 }, pivot, spin);\n const b = quarterTurn({ x: box.x1, y: box.y1 }, pivot, spin);\n return {\n move,\n from: pose,\n to: {\n turn: (pose.turn + spin + 4) % 4,\n x: Math.min(a.x, b.x),\n y: Math.min(a.y, b.y),\n },\n pivot,\n spin,\n };\n}\n\nfunction getBauhausPaths(piece: BauhausPiece) {\n const walk = (from: BauhausPose, moves: readonly TumbleMove[]) => {\n const steps: BauhausStep[] = [];\n let pose = from;\n for (const move of moves) {\n const step = tumble(piece, pose, move);\n steps.push(step);\n pose = step.to;\n }\n return steps;\n };\n let start = piece.slot;\n for (let index = piece.enter.length - 1; index >= 0; index--) {\n start = tumble(piece, start, MOVES[piece.enter[index]].reverse).to;\n }\n const rebuild = walk(piece.slot, piece.rebuild);\n return {\n start,\n enter: walk(start, piece.enter),\n rebuild,\n handoff: rebuild.at(-1)?.to ?? piece.slot,\n };\n}\n\nfunction getRestOffset(\n piece: Pick<BauhausPiece, \"width\" | \"height\">,\n turn: number,\n): BauhausPoint {\n switch (turn) {\n case 1:\n return { x: piece.height, y: 0 };\n case 2:\n return { x: piece.width, y: piece.height };\n case 3:\n return { x: 0, y: piece.width };\n default:\n return { x: 0, y: 0 };\n }\n}\n\nfunction getBauhausPoseFrame(\n piece: Pick<BauhausPiece, \"width\" | \"height\">,\n pose: BauhausPose,\n): BauhausFrame {\n const offset = getRestOffset(piece, pose.turn);\n return {\n x: pose.x + offset.x,\n y: pose.y + offset.y,\n rotation: pose.turn * 90,\n scale: 1,\n pivot: null,\n };\n}\n\nfunction getBauhausStepFrame(\n piece: Pick<BauhausPiece, \"width\" | \"height\">,\n step: BauhausStep,\n progress: number,\n grow = 1,\n): BauhausFrame {\n const rest = getBauhausPoseFrame(piece, step.from);\n const angle = (step.spin * progress * Math.PI) / 2;\n const cos = Math.cos(angle);\n const sin = Math.sin(angle);\n const dx = rest.x - step.pivot.x;\n const dy = rest.y - step.pivot.y;\n return {\n x: step.pivot.x + grow * (dx * cos - dy * sin),\n y: step.pivot.y + grow * (dx * sin + dy * cos),\n rotation: rest.rotation + step.spin * progress * 90,\n scale: grow,\n pivot: step.pivot,\n };\n}\n\nfunction getTumbleDuration(\n piece: Pick<BauhausPiece, \"width\" | \"height\">,\n) {\n return TURN * Math.sqrt(Math.max(piece.width, piece.height));\n}\n\nfunction getTumbleProgress(\n elapsed: number,\n duration: number,\n landing: boolean,\n) {\n const t = clamp(elapsed / duration);\n if (!landing) return swing(t);\n if (elapsed <= duration) return (1 + OVERSHOOT) * swing(t);\n const back = clamp((elapsed - duration) / (duration * SETTLE));\n return 1 + OVERSHOOT * (1 - settle(back));\n}\n\nfunction getUnfoldScale(progress: number) {\n return 1 - (1 - clamp(progress)) ** 3;\n}\n\nfunction getPathFrame(\n piece: BauhausPiece,\n steps: readonly BauhausStep[],\n elapsed: number,\n unfold: boolean,\n): BauhausFrame {\n const duration = getTumbleDuration(piece);\n const last = steps.length - 1;\n const index = Math.min(last, Math.max(0, Math.floor(elapsed / duration)));\n const local = elapsed - index * duration;\n const landing = index === last;\n const step = steps[index];\n if (landing && local >= duration * (1 + SETTLE)) {\n return getBauhausPoseFrame(piece, step.to);\n }\n const grow = unfold && index === 0 ? getUnfoldScale(local / duration) : 1;\n const progress = getTumbleProgress(local, duration, landing);\n return getBauhausStepFrame(piece, step, progress, grow);\n}\n\nfunction getPieceMotion(\n piece: BauhausPiece,\n arrival: number,\n time: number,\n): BauhausFrame {\n const { lead, beat, rebuild } = bauhausBuildTimeline;\n const paths = getBauhausPaths(piece);\n const cue = rebuild + piece.cue;\n if (time >= cue && paths.rebuild.length > 0) {\n return getPathFrame(piece, paths.rebuild, time - cue, false);\n }\n if (paths.enter.length === 0) {\n return getBauhausPoseFrame(piece, piece.slot);\n }\n const travel = paths.enter.length * getTumbleDuration(piece);\n const start = lead + arrival * beat - travel;\n if (time < start) {\n return { ...getBauhausPoseFrame(piece, paths.start), scale: 0 };\n }\n return getPathFrame(piece, paths.enter, time - start, true);\n}\n\nfunction getBauhausBuildDuration({\n speed = bauhausBuildDefaults.speed,\n loop = bauhausBuildDefaults.loop,\n}: Pick<BauhausBuildProps, \"speed\" | \"loop\"> = {}) {\n const rate = finite(speed, 1);\n const frames = bauhausBuildTimeline.duration * (loop ? 2 : 1);\n return rate <= 0 ? 1 : Math.max(1, Math.ceil(frames / rate));\n}\n\nfunction getBauhausBuildOrder(seed = bauhausBuildDefaults.seed) {\n const key = seedKey(seed);\n const rank = (piece: BauhausPiece) =>\n random(`bauhaus-build-${key}-order-${piece.id}`);\n const placed: BauhausPiece[] = [];\n const waiting = [...bauhausBuildPieces];\n while (waiting.length > 0) {\n const ready = waiting.filter((piece) =>\n piece.after.every((id) => placed.some((done) => done.id === id)),\n );\n const next = ready.reduce((best, piece) =>\n rank(piece) < rank(best) ? piece : best,\n );\n placed.push(next);\n waiting.splice(waiting.indexOf(next), 1);\n }\n return placed;\n}\n\nfunction getBauhausBuildVariant(seed = bauhausBuildDefaults.seed) {\n const index = (((seedKey(seed) - 1) % 4) + 4) % 4;\n return { flipX: index % 2 === 1, flipY: index >= 2 };\n}\n\nfunction getPoster(scale: number, width: number, height: number) {\n const w = Math.max(1, finite(width, 1280));\n const h = Math.max(1, finite(height, 720));\n const size = Math.min(w, h) * FILL * clamp(finite(scale, 1), 0.5, 1.25);\n return { w, h, size, originX: (w - size) / 2, originY: (h - size) / 2 };\n}\n\nfunction getBauhausBuildField({\n scale = bauhausBuildDefaults.scale,\n width = 1280,\n height = 720,\n}: Pick<BauhausBuildProps, \"scale\"> & {\n width?: number;\n height?: number;\n} = {}) {\n const poster = getPoster(scale, width, height);\n const unit = poster.size / bauhausBuildGrid;\n return {\n x: 0,\n y: poster.originY + bauhausBuildBand.top * unit,\n width: poster.w,\n height: (bauhausBuildBand.bottom - bauhausBuildBand.top) * unit,\n unit,\n };\n}\n\nfunction getBauhausBuildState(\n time: number,\n {\n seed = bauhausBuildDefaults.seed,\n scale = bauhausBuildDefaults.scale,\n loop = bauhausBuildDefaults.loop,\n width = 1280,\n height = 720,\n }: Pick<BauhausBuildProps, \"seed\" | \"scale\" | \"loop\"> & {\n width?: number;\n height?: number;\n } = {},\n) {\n const { size, originX, originY } = getPoster(scale, width, height);\n const { duration } = bauhausBuildTimeline;\n const elapsed = Math.max(0, finite(time, 0));\n const folded = elapsed % (duration * 2);\n const local = loop ? Math.min(folded, duration * 2 - folded) : elapsed;\n const pieces = getBauhausBuildOrder(seed).map((piece, arrival) => {\n const motion = getPieceMotion(piece, arrival, local);\n const frame: BauhausPieceFrame = {\n id: piece.id,\n shape: piece.shape,\n role: piece.role,\n width: piece.width,\n height: piece.height,\n ...motion,\n visible: motion.scale > 0.001,\n };\n return frame;\n });\n return {\n time: local,\n size,\n unit: size / bauhausBuildGrid,\n originX,\n originY,\n ...getBauhausBuildVariant(seed),\n pieces,\n };\n}\n\nfunction getBauhausShapePath(\n shape: BauhausShape,\n width: number,\n height: number,\n) {\n const r = width / 2;\n switch (shape) {\n case \"circle\":\n return `M 0 ${r} A ${r} ${r} 0 1 1 ${width} ${r} A ${r} ${r} 0 1 1 0 ${r} Z`;\n case \"semicircle\":\n return `M 0 ${height} A ${r} ${r} 0 0 1 ${width} ${height} Z`;\n case \"quarter\":\n return `M 0 ${height} L 0 0 A ${width} ${height} 0 0 1 ${width} ${height} Z`;\n default:\n return `M 0 0 H ${width} V ${height} H 0 Z`;\n }\n}\n\nfunction BauhausBuildBase({\n scale = bauhausBuildDefaults.scale,\n seed = bauhausBuildDefaults.seed,\n inkColor = bauhausBuildDefaults.inkColor,\n accentColor = bauhausBuildDefaults.accentColor,\n secondaryColor = bauhausBuildDefaults.secondaryColor,\n tertiaryColor = bauhausBuildDefaults.tertiaryColor,\n speed = bauhausBuildDefaults.speed,\n loop = bauhausBuildDefaults.loop,\n className,\n}: BauhausBuildProps) {\n const frame = useCurrentFrame();\n const { width, height, fps } = useVideoConfig();\n const time = frame * (30 / fps) * Math.max(0, finite(speed, 1));\n const state = getBauhausBuildState(time, {\n seed,\n scale,\n loop,\n width,\n height,\n });\n const fills: Record<BauhausRole, string> = {\n ink: inkColor,\n accent: accentColor,\n secondary: secondaryColor,\n tertiary: tertiaryColor,\n };\n const mirror = `translate(${state.flipX ? width : 0} ${state.flipY ? height : 0}) scale(${state.flipX ? -1 : 1} ${state.flipY ? -1 : 1})`;\n\n return (\n <div\n className={className}\n style={{ position: \"absolute\", inset: 0, overflow: \"hidden\" }}\n >\n <svg\n width=\"100%\"\n height=\"100%\"\n viewBox={`0 0 ${width} ${height}`}\n role=\"img\"\n aria-label=\"Geometric Bauhaus composition\"\n style={{ display: \"block\" }}\n >\n <g transform={mirror}>\n {state.pieces.map((piece) =>\n piece.visible ? (\n <path\n key={piece.id}\n d={getBauhausShapePath(piece.shape, piece.width, piece.height)}\n fill={fills[piece.role]}\n transform={`translate(${state.originX + piece.x * state.unit} ${state.originY + piece.y * state.unit}) rotate(${piece.rotation}) scale(${piece.scale * state.unit})`}\n />\n ) : null,\n )}\n </g>\n </svg>\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n scale: {\n type: \"number\",\n default: 1,\n min: 0.5,\n max: 1.25,\n step: 0.05,\n description: \"Scale\",\n hiddenFromList: false,\n },\n seed: {\n type: \"number\",\n default: 1,\n min: 1,\n max: 24,\n step: 1,\n description: \"Seed\",\n hiddenFromList: false,\n },\n inkColor: {\n type: \"color\",\n default: \"#1c1a17\",\n description: \"Ink\",\n },\n accentColor: {\n type: \"color\",\n default: \"#e4572e\",\n description: \"Accent\",\n },\n secondaryColor: {\n type: \"color\",\n default: \"#cbbc9f\",\n description: \"Secondary\",\n },\n tertiaryColor: {\n type: \"color\",\n default: \"#7e776b\",\n description: \"Tertiary\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop animation\",\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"scale\",\"seed\",\"inkColor\",\"accentColor\",\"secondaryColor\",\"tertiaryColor\",\"loop\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n scale: 1,\n seed: 1,\n inkColor: \"#1c1a17\",\n accentColor: \"#e4572e\",\n secondaryColor: \"#cbbc9f\",\n tertiaryColor: \"#7e776b\",\n loop: false,\n speed: 1,\n};\n\ntype BauhausBuildElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof BauhausBuildBase>;\n\nconst BauhausBuildInner = forwardRef<\n HTMLDivElement,\n BauhausBuildElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<BauhausBuild>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <BauhausBuildBase\n {...(componentProps as unknown as ComponentProps<typeof BauhausBuildBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const BauhausBuild = Interactive.withSchema({\n Component: BauhausBuildInner,\n componentName: \"<BauhausBuild>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/blur-out-up.json b/registry-artifacts/elements/blur-out-up.jsonindex 7169284e..47d1b9a5 100644--- a/registry-artifacts/elements/blur-out-up.json+++ b/registry-artifacts/elements/blur-out-up.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [],"dimensions": {"width": 720,@@ -9,6 +10,7 @@},"displayName": "Blur Out Up","durationInFrames": 90,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "blur-out-up","sourceCode": "import { Easing, Interactive, Sequence, interpolate, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface BlurOutUpProps {\n text: string;\n staggerDelay?: number;\n fontSize?: number;\n color?: string;\n fontWeight?: number;\n speed?: number;\n className?: string;\n}\n\nfunction BlurOutUpBase({\n text,\n staggerDelay = 1,\n fontSize = 72,\n color = \"#171717\",\n fontWeight = 600,\n speed = 1,\n className,\n}: BlurOutUpProps) {\n const frame = useCurrentFrame() * speed;\n const { durationInFrames } = useVideoConfig();\n\n const words = text.split(\" \");\n\n const enterDur = 17;\n const enterTravel = 6;\n const exitDur = 14;\n const exitTravelFrom = 8;\n\n const enterEasing = Easing.bezier(0.22, 1, 0.36, 1);\n const exitEasing = Easing.bezier(0.64, 0, 0.78, 0);\n\n const enterEnd = enterDur + (words.length - 1) * staggerDelay;\n const exitStart = Math.max(\n enterEnd,\n durationInFrames - exitDur - (words.length - 1) * staggerDelay,\n );\n\n return (\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n background: \"transparent\",\n }}\n >\n <span\n className={className}\n style={{\n fontSize,\n fontWeight,\n color,\n letterSpacing: \"-0.03em\",\n fontFamily:\n \"var(--font-geist-sans), -apple-system, BlinkMacSystemFont, sans-serif\",\n }}\n >\n {words.map((word, i) => {\n const enterLocal = frame - i * staggerDelay;\n const exitLocal = frame - exitStart - i * staggerDelay;\n\n const enterP = interpolate(enterLocal, [0, enterDur], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: enterEasing,\n });\n\n const exitP = interpolate(exitLocal, [0, exitDur], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: exitEasing,\n });\n\n const opacity = enterP * (1 - exitP);\n\n const yEnter = interpolate(enterLocal, [0, enterTravel], [10, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: enterEasing,\n });\n\n const yExit = interpolate(\n exitLocal,\n [exitTravelFrom, exitDur],\n [0, -14],\n {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: exitEasing,\n },\n );\n\n const y = yEnter + yExit;\n\n const blurEnter = interpolate(enterLocal, [0, enterDur], [6, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: enterEasing,\n });\n\n const blurExit = interpolate(exitLocal, [0, exitDur], [0, 8], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: exitEasing,\n });\n\n const blur = blurEnter + blurExit;\n\n return (\n <span\n key={i}\n style={{\n display: \"inline-block\",\n marginRight: \"0.25em\",\n transformOrigin: \"50% 55%\",\n opacity,\n translate: `0 ${y}px`,\n filter: `blur(${blur}px)`,\n }}\n >\n {word}\n </span>\n );\n })}\n </span>\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n text: {\n type: \"text-content\",\n default: \"Clear in, airy out.\",\n description: \"Text\",\n },\n staggerDelay: {\n type: \"number\",\n min: 0,\n max: 8,\n step: 1,\n default: 1,\n description: \"Stagger\",\n hiddenFromList: false,\n },\n fontSize: {\n type: \"number\",\n min: 12,\n max: 160,\n step: 1,\n default: 72,\n description: \"Font size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n fontWeight: {\n type: \"enum\",\n default: \"600\",\n variants: {\n \"400\": {},\n \"500\": {},\n \"600\": {},\n \"700\": {},\n },\n description: \"Font weight\",\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 720,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 100,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"text\",\"staggerDelay\",\"fontSize\",\"color\",\"fontWeight\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n text: \"Clear in, airy out.\",\n staggerDelay: 1,\n fontSize: 72,\n color: \"#171717\",\n fontWeight: \"600\",\n speed: 1,\n};\n\ntype BlurOutUpElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof BlurOutUpBase>;\n\nconst BlurOutUpInner = forwardRef<\n HTMLDivElement,\n BlurOutUpElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 720, height = 100, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<BlurOutUp>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <BlurOutUpBase\n {...(componentProps as unknown as ComponentProps<typeof BlurOutUpBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const BlurOutUp = Interactive.withSchema({\n Component: BlurOutUpInner,\n componentName: \"<BlurOutUp>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/bottom-up-letters.json b/registry-artifacts/elements/bottom-up-letters.jsonindex 6a556dfe..c685a9a8 100644--- a/registry-artifacts/elements/bottom-up-letters.json+++ b/registry-artifacts/elements/bottom-up-letters.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [],"dimensions": {"width": 190,@@ -9,6 +10,7 @@},"displayName": "Bottom-Up Letters","durationInFrames": 60,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "bottom-up-letters","sourceCode": "import { Easing, Interactive, Sequence, interpolate, useCurrentFrame, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface BottomUpLettersProps {\n text: string;\n staggerDelay?: number;\n distance?: number;\n fontSize?: number;\n color?: string;\n fontWeight?: number;\n speed?: number;\n className?: string;\n}\n\nfunction BottomUpLettersBase({\n text,\n staggerDelay = 3,\n distance = 46,\n fontSize = 72,\n color = \"#171717\",\n fontWeight = 600,\n speed = 1,\n className,\n}: BottomUpLettersProps) {\n const frame = useCurrentFrame() * speed;\n\n const chars = Array.from(text);\n const charDurationFrames = 12;\n const charTravelFrames = 7;\n\n return (\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n background: \"transparent\",\n }}\n >\n <span\n className={className}\n style={{\n fontSize,\n fontWeight,\n color,\n letterSpacing: \"-0.05em\",\n fontFamily:\n \"var(--font-geist-sans), -apple-system, BlinkMacSystemFont, sans-serif\",\n }}\n >\n {chars.map((char, i) => {\n const local = frame - i * staggerDelay;\n const easing = Easing.bezier(0.18, 1, 0.32, 1);\n const opacity = interpolate(local, [0, charDurationFrames], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing,\n });\n const y = interpolate(local, [0, charTravelFrames], [distance, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing,\n });\n return (\n <span\n key={i}\n style={{\n display: \"inline-block\",\n whiteSpace: \"pre\",\n backfaceVisibility: \"hidden\",\n transformOrigin: \"50% 55%\",\n opacity,\n translate: `0 ${y}px`,\n }}\n >\n {char}\n </span>\n );\n })}\n </span>\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n text: {\n type: \"text-content\",\n default: \"Shift\",\n description: \"Text\",\n },\n staggerDelay: {\n type: \"number\",\n min: 1,\n max: 12,\n step: 1,\n default: 3,\n description: \"Stagger\",\n hiddenFromList: false,\n },\n distance: {\n type: \"number\",\n min: 0,\n max: 120,\n step: 1,\n default: 46,\n description: \"Distance\",\n hiddenFromList: false,\n },\n fontSize: {\n type: \"number\",\n min: 12,\n max: 160,\n step: 1,\n default: 72,\n description: \"Font size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n fontWeight: {\n type: \"enum\",\n default: \"600\",\n variants: {\n \"400\": {},\n \"500\": {},\n \"600\": {},\n \"700\": {},\n },\n description: \"Font weight\",\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 190,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 100,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"text\",\"staggerDelay\",\"distance\",\"fontSize\",\"color\",\"fontWeight\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n text: \"Shift\",\n staggerDelay: 3,\n distance: 46,\n fontSize: 72,\n color: \"#171717\",\n fontWeight: \"600\",\n speed: 1,\n};\n\ntype BottomUpLettersElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof BottomUpLettersBase>;\n\nconst BottomUpLettersInner = forwardRef<\n HTMLDivElement,\n BottomUpLettersElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 190, height = 100, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<BottomUpLetters>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <BottomUpLettersBase\n {...(componentProps as unknown as ComponentProps<typeof BottomUpLettersBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const BottomUpLetters = Interactive.withSchema({\n Component: BottomUpLettersInner,\n componentName: \"<BottomUpLetters>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/camera-lens.json b/registry-artifacts/elements/camera-lens.jsonindex 4d51bcd1..a60c532e 100644--- a/registry-artifacts/elements/camera-lens.json+++ b/registry-artifacts/elements/camera-lens.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/transitions",@@ -11,6 +12,7 @@"dimensions": null,"displayName": "Camera Lens","durationInFrames": 90,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "camera-lens","sourceCode": "import { AbsoluteFill, Interactive, Sequence, isHtmlInCanvasSupported, useCurrentFrame, useDelayRender, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport React, { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\nimport { type TransitionPresentation, type TransitionPresentationComponentProps } from \"@remotion/transitions\";\n\nconst QUAD = new Float32Array([-1, -1, 1, -1, -1, 1, 1, 1]);\n\nconst VERTEX_SHADER = `#version 300 es\nin vec2 a_pos;\nout vec2 v_uv;\nvoid main() {\n v_uv = vec2(a_pos.x * 0.5 + 0.5, 0.5 - a_pos.y * 0.5);\n gl_Position = vec4(a_pos, 0.0, 1.0);\n}`;\n\nconst LAYER: React.CSSProperties = {\n position: \"absolute\",\n inset: 0,\n width: \"100%\",\n height: \"100%\",\n};\n\nconst OUTPUT_LAYER: React.CSSProperties = { ...LAYER, pointerEvents: \"none\" };\n\nconst isCanvasTransitionSupported = (): boolean =>\n isHtmlInCanvasSupported();\n\nconst isCanvasFilterSupported = (): boolean => isHtmlInCanvasSupported();\n\ntype SceneShaderFrame<Props> = {\n gl: WebGL2RenderingContext;\n uniform: (name: string) => WebGLUniformLocation | null;\n width: number;\n height: number;\n progress: number;\n passedProps: Props;\n};\n\ntype SceneShaderDrawParams<Props> = {\n from: OffscreenCanvas | null;\n to: OffscreenCanvas | null;\n width: number;\n height: number;\n progress: number;\n passedProps: Props;\n};\n\ntype SceneShaderInstance<Props> = {\n draw: (params: SceneShaderDrawParams<Props>) => void;\n clear: () => void;\n cleanup: () => void;\n};\n\ntype SceneShader<Props> = (\n canvas: OffscreenCanvas,\n) => SceneShaderInstance<Props>;\n\ntype SceneFilterFrame<Props> = {\n gl: WebGL2RenderingContext;\n uniform: (name: string) => WebGLUniformLocation | null;\n width: number;\n height: number;\n frame: number;\n time: number;\n passedProps: Props;\n};\n\ntype SceneFilterDrawParams<Props> = {\n scene: OffscreenCanvas | null;\n width: number;\n height: number;\n frame: number;\n time: number;\n passedProps: Props;\n};\n\ntype SceneFilterInstance<Props> = {\n draw: (params: SceneFilterDrawParams<Props>) => void;\n clear: () => void;\n cleanup: () => void;\n};\n\ntype SceneFilter<Props> = (\n canvas: OffscreenCanvas,\n) => SceneFilterInstance<Props>;\n\nfunction compileShader(\n gl: WebGL2RenderingContext,\n source: string,\n type: GLenum,\n): WebGLShader {\n const shader = gl.createShader(type);\n if (!shader) {\n throw new Error(\"canvas-presentation: failed to create shader\");\n }\n gl.shaderSource(shader, source);\n gl.compileShader(shader);\n if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {\n const log = gl.getShaderInfoLog(shader);\n gl.deleteShader(shader);\n throw new Error(`canvas-presentation: failed to compile shader: ${log}`);\n }\n return shader;\n}\n\nfunction createProgram(\n gl: WebGL2RenderingContext,\n fragment: string,\n): WebGLProgram {\n const program = gl.createProgram();\n if (!program) {\n throw new Error(\"canvas-presentation: failed to create program\");\n }\n const vs = compileShader(gl, VERTEX_SHADER, gl.VERTEX_SHADER);\n const fs = compileShader(gl, fragment, gl.FRAGMENT_SHADER);\n gl.attachShader(program, vs);\n gl.attachShader(program, fs);\n gl.linkProgram(program);\n gl.deleteShader(vs);\n gl.deleteShader(fs);\n if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {\n const log = gl.getProgramInfoLog(program);\n gl.deleteProgram(program);\n throw new Error(`canvas-presentation: failed to link program: ${log}`);\n }\n return program;\n}\n\nfunction createSceneTexture(gl: WebGL2RenderingContext): WebGLTexture {\n const texture = gl.createTexture();\n if (!texture) {\n throw new Error(\"canvas-presentation: failed to create texture\");\n }\n gl.bindTexture(gl.TEXTURE_2D, texture);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);\n gl.texImage2D(\n gl.TEXTURE_2D,\n 0,\n gl.RGBA,\n 1,\n 1,\n 0,\n gl.RGBA,\n gl.UNSIGNED_BYTE,\n new Uint8Array([0, 0, 0, 0]),\n );\n return texture;\n}\n\nfunction createQuadSurface(canvas: OffscreenCanvas, fragment: string) {\n const gl = canvas.getContext(\"webgl2\", { premultipliedAlpha: true });\n if (!gl) {\n throw new Error(\"canvas-presentation: WebGL2 is unavailable\");\n }\n\n const program = createProgram(gl, fragment);\n const vao = gl.createVertexArray();\n gl.bindVertexArray(vao);\n const buffer = gl.createBuffer();\n gl.bindBuffer(gl.ARRAY_BUFFER, buffer);\n gl.bufferData(gl.ARRAY_BUFFER, QUAD, gl.STATIC_DRAW);\n const aPos = gl.getAttribLocation(program, \"a_pos\");\n gl.enableVertexAttribArray(aPos);\n gl.vertexAttribPointer(aPos, 2, gl.FLOAT, false, 0, 0);\n\n const locations = new Map<string, WebGLUniformLocation | null>();\n const uniform = (name: string) => {\n const cached = locations.get(name);\n if (cached !== undefined) {\n return cached;\n }\n const location = gl.getUniformLocation(program, name);\n locations.set(name, location);\n return location;\n };\n\n const clear = () => {\n gl.clearColor(0, 0, 0, 0);\n gl.clear(gl.COLOR_BUFFER_BIT);\n };\n\n const textures: WebGLTexture[] = [];\n const createTexture = () => {\n const texture = createSceneTexture(gl);\n textures.push(texture);\n return texture;\n };\n\n const begin = (width: number, height: number) => {\n gl.viewport(0, 0, width, height);\n clear();\n gl.useProgram(program);\n gl.bindVertexArray(vao);\n };\n\n const bindScene = (\n image: OffscreenCanvas | null,\n texture: WebGLTexture,\n unit: number,\n name: string,\n ) => {\n gl.activeTexture(gl.TEXTURE0 + unit);\n gl.bindTexture(gl.TEXTURE_2D, texture);\n if (image) {\n gl.texImage2D(\n gl.TEXTURE_2D,\n 0,\n gl.RGBA,\n gl.RGBA,\n gl.UNSIGNED_BYTE,\n image,\n );\n }\n gl.uniform1i(uniform(name), unit);\n };\n\n const draw = () => gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);\n\n const cleanup = () => {\n gl.deleteProgram(program);\n for (const texture of textures) {\n gl.deleteTexture(texture);\n }\n gl.deleteBuffer(buffer);\n gl.deleteVertexArray(vao);\n };\n\n return {\n gl,\n uniform,\n clear,\n createTexture,\n begin,\n bindScene,\n draw,\n cleanup,\n };\n}\n\nfunction makeSceneShader<Props extends Record<string, unknown>>(\n fragment: string,\n setUniforms?: (frame: SceneShaderFrame<Props>) => void,\n): SceneShader<Props> {\n return (canvas) => {\n const surface = createQuadSurface(canvas, fragment);\n const fromTexture = surface.createTexture();\n const toTexture = surface.createTexture();\n\n return {\n clear: surface.clear,\n cleanup: surface.cleanup,\n draw: ({ from, to, width, height, progress, passedProps }) => {\n surface.begin(width, height);\n surface.bindScene(from, fromTexture, 0, \"u_from\");\n surface.bindScene(to, toTexture, 1, \"u_to\");\n\n surface.gl.uniform1f(surface.uniform(\"u_progress\"), progress);\n surface.gl.uniform1f(surface.uniform(\"u_aspect\"), width / height);\n setUniforms?.({\n gl: surface.gl,\n uniform: surface.uniform,\n width,\n height,\n progress,\n passedProps,\n });\n\n surface.draw();\n },\n };\n };\n}\n\nfunction makeFilterShader<Props extends Record<string, unknown>>(\n fragment: string,\n setUniforms?: (frame: SceneFilterFrame<Props>) => void,\n): SceneFilter<Props> {\n return (canvas) => {\n const surface = createQuadSurface(canvas, fragment);\n const sceneTexture = surface.createTexture();\n\n return {\n clear: surface.clear,\n cleanup: surface.cleanup,\n draw: ({ scene, width, height, frame, time, passedProps }) => {\n surface.begin(width, height);\n surface.bindScene(scene, sceneTexture, 0, \"u_scene\");\n\n surface.gl.uniform1f(surface.uniform(\"u_frame\"), frame);\n surface.gl.uniform1f(surface.uniform(\"u_time\"), time);\n surface.gl.uniform1f(surface.uniform(\"u_aspect\"), width / height);\n setUniforms?.({\n gl: surface.gl,\n uniform: surface.uniform,\n width,\n height,\n frame,\n time,\n passedProps,\n });\n\n surface.draw();\n },\n };\n };\n}\n\nconst transferred = new WeakMap<HTMLCanvasElement, OffscreenCanvas>();\n\nfunction takeOffscreen(canvas: HTMLCanvasElement): OffscreenCanvas {\n const existing = transferred.get(canvas);\n if (existing) {\n return existing;\n }\n const created = canvas.transferControlToOffscreen();\n transferred.set(canvas, created);\n return created;\n}\n\nfunction makeCanvasComponent<Props extends Record<string, unknown>>(\n shader: SceneShader<Props>,\n): React.FC<TransitionPresentationComponentProps<Props>> {\n return function CanvasScenePresentation({\n children,\n presentationProgress,\n presentationDirection,\n passedProps,\n onElementImage,\n onUnmount,\n bothEnteringAndExiting,\n }) {\n const layoutRef = React.useRef<HTMLCanvasElement | null>(null);\n const outputRef = React.useRef<HTMLCanvasElement | null>(null);\n const captureRef = React.useRef<OffscreenCanvas | null>(null);\n const captureContextRef =\n React.useRef<OffscreenCanvasRenderingContext2D | null>(null);\n const outputSurfaceRef = React.useRef<OffscreenCanvas | null>(null);\n const instanceRef = React.useRef<SceneShaderInstance<Props> | null>(null);\n const passedPropsRef = React.useRef(passedProps);\n passedPropsRef.current = passedProps;\n const onElementImageRef = React.useRef(onElementImage);\n onElementImageRef.current = onElementImage;\n const onUnmountRef = React.useRef(onUnmount);\n onUnmountRef.current = onUnmount;\n\n const { delayRender, continueRender } = useDelayRender();\n const passThrough =\n bothEnteringAndExiting && presentationDirection === \"exiting\";\n\n const drawRef = React.useRef<\n (\n prevImage: OffscreenCanvas | null,\n nextImage: OffscreenCanvas | null,\n progress: number,\n ) => void\n >(() => undefined);\n drawRef.current = (prevImage, nextImage, progress) => {\n const instance = instanceRef.current;\n if (!instance) {\n return;\n }\n const handle = delayRender(\"canvas-presentation: paint\");\n const to = prevImage;\n const from = nextImage;\n const width = from?.width ?? to?.width ?? 0;\n const height = from?.height ?? to?.height ?? 0;\n if (width === 0 || height === 0) {\n instance.clear();\n continueRender(handle);\n return;\n }\n instance.draw({\n from,\n to,\n width,\n height,\n progress: !to ? 0 : !from ? 1 : progress,\n passedProps: passedPropsRef.current,\n });\n continueRender(handle);\n };\n\n const draw = React.useCallback(\n (\n prevImage: OffscreenCanvas | null,\n nextImage: OffscreenCanvas | null,\n progress: number,\n ) => drawRef.current(prevImage, nextImage, progress),\n [],\n );\n\n React.useLayoutEffect(() => {\n if (passThrough) {\n return;\n }\n const layout = layoutRef.current;\n const output = outputRef.current;\n if (!layout || !output) {\n return;\n }\n const capture = takeOffscreen(layout);\n const context = capture.getContext(\"2d\");\n if (!context) {\n throw new Error(\"canvas-presentation: failed to acquire a 2D context\");\n }\n const surface = takeOffscreen(output);\n captureRef.current = capture;\n captureContextRef.current = context;\n outputSurfaceRef.current = surface;\n instanceRef.current = shader(surface);\n\n return () => {\n instanceRef.current?.cleanup();\n instanceRef.current = null;\n captureRef.current = null;\n captureContextRef.current = null;\n outputSurfaceRef.current = null;\n };\n }, [passThrough, shader]);\n\n React.useLayoutEffect(() => {\n if (passThrough) {\n return;\n }\n const layout = layoutRef.current;\n if (!layout) {\n return;\n }\n layout.layoutSubtree = true;\n const handlePaint = () => {\n const scene = layout.firstElementChild;\n const capture = captureRef.current;\n const context = captureContextRef.current;\n if (!scene || !capture || !context) {\n return;\n }\n const elementImage = layout.captureElementImage(scene);\n try {\n context.reset();\n context.drawElementImage(elementImage, 0, 0);\n } finally {\n elementImage.close();\n }\n onElementImageRef.current(capture, draw);\n };\n layout.addEventListener(\"paint\", handlePaint);\n return () => layout.removeEventListener(\"paint\", handlePaint);\n }, [passThrough, draw]);\n\n React.useLayoutEffect(() => {\n if (passThrough) {\n return;\n }\n const layout = layoutRef.current;\n if (!layout) {\n return;\n }\n const observer = new ResizeObserver(([entry]) => {\n const capture = captureRef.current;\n const surface = outputSurfaceRef.current;\n if (!capture || !surface) {\n return;\n }\n const width = entry.devicePixelContentBoxSize[0].inlineSize;\n const height = entry.devicePixelContentBoxSize[0].blockSize;\n capture.width = width;\n capture.height = height;\n surface.width = width;\n surface.height = height;\n layout.requestPaint?.();\n });\n observer.observe(layout, { box: \"device-pixel-content-box\" });\n return () => observer.disconnect();\n }, [passThrough]);\n\n // biome-ignore lint/correctness/useExhaustiveDependencies: presentationProgress is the intentional trigger — a new progress value is what schedules the next paint\n React.useLayoutEffect(() => {\n if (passThrough) {\n return;\n }\n layoutRef.current?.requestPaint?.();\n }, [passThrough, presentationProgress]);\n\n React.useLayoutEffect(() => {\n if (passThrough) {\n return;\n }\n return () => onUnmountRef.current();\n }, [passThrough]);\n\n if (passThrough) {\n return <>{children}</>;\n }\n\n return (\n <AbsoluteFill>\n <canvas ref={layoutRef} style={LAYER}>\n {children}\n </canvas>\n <canvas ref={outputRef} style={OUTPUT_LAYER} />\n </AbsoluteFill>\n );\n };\n}\n\ntype CanvasFilterProps = {\n children: React.ReactNode;\n};\n\nfunction makeFilterComponent<Props extends Record<string, unknown>>(\n shader: SceneFilter<Props>,\n): React.FC<Props & CanvasFilterProps> {\n return function CanvasSceneFilter(props) {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const { delayRender, continueRender } = useDelayRender();\n\n const layoutRef = React.useRef<HTMLCanvasElement | null>(null);\n const outputRef = React.useRef<HTMLCanvasElement | null>(null);\n const captureRef = React.useRef<OffscreenCanvas | null>(null);\n const captureContextRef =\n React.useRef<OffscreenCanvasRenderingContext2D | null>(null);\n const outputSurfaceRef = React.useRef<OffscreenCanvas | null>(null);\n const instanceRef = React.useRef<SceneFilterInstance<Props> | null>(null);\n\n const passedPropsRef = React.useRef(props);\n passedPropsRef.current = props;\n const frameRef = React.useRef(frame);\n frameRef.current = frame;\n const timeRef = React.useRef(frame / fps);\n timeRef.current = frame / fps;\n\n React.useLayoutEffect(() => {\n const layout = layoutRef.current;\n const output = outputRef.current;\n if (!layout || !output) {\n return;\n }\n const capture = takeOffscreen(layout);\n const context = capture.getContext(\"2d\");\n if (!context) {\n throw new Error(\"canvas-presentation: failed to acquire a 2D context\");\n }\n const surface = takeOffscreen(output);\n captureRef.current = capture;\n captureContextRef.current = context;\n outputSurfaceRef.current = surface;\n instanceRef.current = shader(surface);\n\n return () => {\n instanceRef.current?.cleanup();\n instanceRef.current = null;\n captureRef.current = null;\n captureContextRef.current = null;\n outputSurfaceRef.current = null;\n };\n }, [shader]);\n\n React.useLayoutEffect(() => {\n const layout = layoutRef.current;\n if (!layout) {\n return;\n }\n layout.layoutSubtree = true;\n const handlePaint = () => {\n const scene = layout.firstElementChild;\n const capture = captureRef.current;\n const context = captureContextRef.current;\n const instance = instanceRef.current;\n if (!scene || !capture || !context || !instance) {\n return;\n }\n const elementImage = layout.captureElementImage(scene);\n try {\n context.reset();\n context.drawElementImage(elementImage, 0, 0);\n } finally {\n elementImage.close();\n }\n if (capture.width === 0 || capture.height === 0) {\n instance.clear();\n return;\n }\n instance.draw({\n scene: capture,\n width: capture.width,\n height: capture.height,\n frame: frameRef.current,\n time: timeRef.current,\n passedProps: passedPropsRef.current,\n });\n };\n layout.addEventListener(\"paint\", handlePaint);\n return () => layout.removeEventListener(\"paint\", handlePaint);\n }, []);\n\n React.useLayoutEffect(() => {\n const layout = layoutRef.current;\n if (!layout) {\n return;\n }\n const observer = new ResizeObserver(([entry]) => {\n const capture = captureRef.current;\n const surface = outputSurfaceRef.current;\n if (!capture || !surface) {\n return;\n }\n const width = entry.devicePixelContentBoxSize[0].inlineSize;\n const height = entry.devicePixelContentBoxSize[0].blockSize;\n capture.width = width;\n capture.height = height;\n surface.width = width;\n surface.height = height;\n layout.requestPaint?.();\n });\n observer.observe(layout, { box: \"device-pixel-content-box\" });\n return () => observer.disconnect();\n }, []);\n\n React.useLayoutEffect(() => {\n const layout = layoutRef.current;\n if (!layout) {\n return;\n }\n const handle = delayRender(\"canvas-presentation: filter paint\");\n const settle = () => continueRender(handle);\n layout.addEventListener(\"paint\", settle, { once: true });\n layout.requestPaint?.();\n return () => {\n layout.removeEventListener(\"paint\", settle);\n continueRender(handle);\n };\n });\n\n return (\n <AbsoluteFill>\n <canvas ref={layoutRef} style={LAYER}>\n {props.children}\n </canvas>\n <canvas ref={outputRef} style={OUTPUT_LAYER} />\n </AbsoluteFill>\n );\n };\n}\n\ntype CanvasPresentationOptions<Props extends Record<string, unknown>> = {\n shader: SceneShader<Props>;\n fallback: React.FC<TransitionPresentationComponentProps<Props>>;\n};\n\nfunction makeCanvasPresentation<Props extends Record<string, unknown>>({\n shader,\n fallback: Fallback,\n}: CanvasPresentationOptions<Props>): (\n props: Props,\n) => TransitionPresentation<Props> {\n const Canvas = makeCanvasComponent(shader);\n\n const Presentation: React.FC<TransitionPresentationComponentProps<Props>> = (\n props,\n ) =>\n isCanvasTransitionSupported() ? (\n <Canvas {...props} />\n ) : (\n <Fallback {...props} />\n );\n\n return (props) => ({ component: Presentation, props });\n}\n\ntype CanvasFilterOptions<Props extends Record<string, unknown>> = {\n shader: SceneFilter<Props>;\n fallback: React.FC<Props & CanvasFilterProps>;\n};\n\nfunction makeCanvasFilter<Props extends Record<string, unknown>>({\n shader,\n fallback: Fallback,\n}: CanvasFilterOptions<Props>): React.FC<Props & CanvasFilterProps> {\n const Canvas = makeFilterComponent(shader);\n\n return function CanvasFilter(props) {\n return isCanvasFilterSupported() ? (\n <Canvas {...props} />\n ) : (\n <Fallback {...props} />\n );\n };\n}\n\ntype CameraLensProps = {\n softness?: number;\n bloom?: number;\n aberration?: number;\n vignette?: number;\n distortion?: number;\n};\n\nconst DEFAULTS = {\n softness: 0.5,\n bloom: 0.5,\n aberration: 0.5,\n vignette: 0.5,\n distortion: 0.05,\n};\n\nconst FRAGMENT_SHADER = `#version 300 es\nprecision highp float;\n\nuniform sampler2D u_scene;\nuniform float u_aspect;\nuniform float u_softness;\nuniform float u_bloom;\nuniform float u_aberration;\nuniform float u_vignette;\nuniform float u_distortion;\n\nin vec2 v_uv;\nout vec4 outColor;\n\nconst int SOFT_TAPS = 6;\nconst int GLARE_TAPS = 8;\nconst float GOLDEN = 2.39996323;\n\nvec2 lensUv(vec2 direction, float distance) {\n vec2 q = direction * distance;\n q.x /= u_aspect;\n return q * 0.5 + 0.5;\n}\n\nvec2 spiral(int index, int count, float radius, float turn) {\n float angle = float(index) * GOLDEN + turn;\n float step = sqrt((float(index) + 0.5) / float(count)) * radius;\n return vec2(cos(angle) * step / u_aspect, sin(angle) * step);\n}\n\nvec4 softSample(vec2 uv, float radius) {\n vec4 sum = texture(u_scene, uv);\n if (radius <= 0.00002) {\n return sum;\n }\n for (int i = 0; i < SOFT_TAPS; i++) {\n sum += texture(u_scene, uv + spiral(i, SOFT_TAPS, radius, 0.0));\n }\n return sum / float(SOFT_TAPS + 1);\n}\n\nvoid main() {\n vec2 p = (v_uv - 0.5) * 2.0;\n p.x *= u_aspect;\n\n float span = sqrt(u_aspect * u_aspect + 1.0);\n float reach = length(p);\n float radius = reach / span;\n vec2 direction = reach > 0.0001 ? p / reach : vec2(0.0);\n\n float bend = 1.0 / (1.0 + clamp(u_distortion, 0.0, 1.0) * radius * radius);\n float focused = reach * bend;\n vec2 base = lensUv(direction, focused);\n\n float soft = u_softness * 0.011 * smoothstep(0.22, 1.0, radius);\n float split = u_aberration * 0.0035 * radius;\n\n vec4 mid = softSample(base, soft);\n float red = softSample(lensUv(direction, focused * (1.0 + split)), soft).r;\n float blue = softSample(lensUv(direction, focused * (1.0 - split)), soft).b;\n vec3 color = vec3(red, mid.g, blue);\n\n vec3 glare = vec3(0.0);\n for (int i = 0; i < GLARE_TAPS; i++) {\n vec3 tap =\n texture(u_scene, base + spiral(i, GLARE_TAPS, u_bloom * 0.026, 0.7)).rgb;\n glare += max(tap - 0.62, vec3(0.0));\n }\n color += (glare / float(GLARE_TAPS)) * u_bloom * 1.4;\n\n float falloff = pow(cos(min(radius, 1.0) * 0.55), 4.0);\n color *= mix(1.0, falloff, clamp(u_vignette, 0.0, 1.5));\n\n outColor = vec4(clamp(color, 0.0, 1.0), mid.a);\n}`;\n\nconst shader = makeFilterShader<CameraLensProps>(\n FRAGMENT_SHADER,\n ({ gl, uniform, passedProps }) => {\n const {\n softness = DEFAULTS.softness,\n bloom = DEFAULTS.bloom,\n aberration = DEFAULTS.aberration,\n vignette = DEFAULTS.vignette,\n distortion = DEFAULTS.distortion,\n } = passedProps;\n gl.uniform1f(uniform(\"u_softness\"), softness);\n gl.uniform1f(uniform(\"u_bloom\"), bloom);\n gl.uniform1f(uniform(\"u_aberration\"), aberration);\n gl.uniform1f(uniform(\"u_vignette\"), vignette);\n gl.uniform1f(uniform(\"u_distortion\"), distortion);\n },\n);\n\nconst CameraLensFallback: React.FC<CameraLensProps & CanvasFilterProps> = ({\n children,\n bloom = DEFAULTS.bloom,\n vignette = DEFAULTS.vignette,\n}) => (\n <AbsoluteFill>\n <AbsoluteFill>{children}</AbsoluteFill>\n <AbsoluteFill\n style={{\n filter: `blur(${6 * bloom}px) brightness(1.5) contrast(1.3)`,\n mixBlendMode: \"screen\",\n opacity: 0.3 * bloom,\n }}\n >\n {children}\n </AbsoluteFill>\n <AbsoluteFill\n style={{\n background:\n \"radial-gradient(ellipse 78% 76% at 50% 50%, transparent 52%, rgba(0, 0, 0, 0.5) 100%)\",\n opacity: Math.min(vignette, 1),\n }}\n />\n </AbsoluteFill>\n);\n\nconst CameraLensBase = makeCanvasFilter<CameraLensProps>({\n shader,\n fallback: CameraLensFallback,\n});\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n softness: {\n type: \"number\",\n min: 0,\n max: 2,\n step: 0.05,\n default: 0.5,\n description: \"Corner softness\",\n hiddenFromList: false,\n },\n bloom: {\n type: \"number\",\n min: 0,\n max: 2,\n step: 0.05,\n default: 0.5,\n description: \"Bloom\",\n hiddenFromList: false,\n },\n aberration: {\n type: \"number\",\n min: 0,\n max: 3,\n step: 0.1,\n default: 0.5,\n description: \"Aberration\",\n hiddenFromList: false,\n },\n vignette: {\n type: \"number\",\n min: 0,\n max: 1.5,\n step: 0.05,\n default: 0.5,\n description: \"Vignette\",\n hiddenFromList: false,\n },\n distortion: {\n type: \"number\",\n min: 0,\n max: 0.6,\n step: 0.01,\n default: 0.05,\n description: \"Distortion\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"softness\",\"bloom\",\"aberration\",\"vignette\",\"distortion\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n softness: 0.5,\n bloom: 0.5,\n aberration: 0.5,\n vignette: 0.5,\n distortion: 0.05,\n speed: 1,\n};\n\ntype CameraLensElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof CameraLensBase>;\n\nconst CameraLensInner = forwardRef<\n HTMLDivElement,\n CameraLensElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<CameraLens>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <CameraLensBase\n {...(componentProps as unknown as ComponentProps<typeof CameraLensBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const CameraLens = Interactive.withSchema({\n Component: CameraLensInner,\n componentName: \"<CameraLens>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/caption-active-pop.json b/registry-artifacts/elements/caption-active-pop.jsonnew file mode 100644index 00000000..01a2ca6d--- /dev/null+++ b/registry-artifacts/elements/caption-active-pop.json@@ -0,0 +1,21 @@+{+ "type": "remotion-element",+ "version": 1,+ "element": {+ "assets": [],+ "dependencies": [+ {+ "name": "@remotion/captions",+ "version": null+ }+ ],+ "dimensions": null,+ "displayName": "Caption Active Pop",+ "durationInFrames": 279,+ "initialProps": null,+ "installationMode": "component-owned-sequence",+ "slug": "caption-active-pop",+ "sourceCode": "import { Fragment, forwardRef, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState, type ComponentProps } from \"react\";\nimport { Easing, Interactive, Sequence, interpolate, interpolateColors, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { createTikTokStyleCaptions, type Caption, type TikTokPage } from \"@remotion/captions\";\n\ntype SpeakerCaption = Caption & { speaker?: string };\n\ninterface CaptionBaseProps {\n captions: Caption[];\n combineTokensWithinMilliseconds?: number;\n holdMs?: number;\n fontSize?: number;\n fontWeight?: number;\n color?: string;\n className?: string;\n}\n\nconst DEFAULT_HOLD_MS = 600;\nconst MIN_SILENCE_BREAK_MS = 300;\n\ninterface CaptionPageWindow {\n page: TikTokPage;\n index: number;\n speaker: string | undefined;\n startMs: number;\n speechEndMs: number;\n endMs: number;\n endsInSilence: boolean;\n}\n\ntype CaptionTokenStatus = \"upcoming\" | \"active\" | \"spoken\";\n\ninterface CaptionTokenState {\n text: string;\n spaceBefore: boolean;\n fromMs: number;\n toMs: number;\n progress: number;\n status: CaptionTokenStatus;\n}\n\ninterface CaptionPreviousPage {\n page: TikTokPage;\n pageIndex: number;\n tokens: CaptionTokenState[];\n}\n\ninterface CaptionsState {\n page: TikTokPage;\n pageIndex: number;\n speaker: string | undefined;\n timeMs: number;\n activeIndex: number;\n tokens: CaptionTokenState[];\n sinceStartMs: number;\n untilEndMs: number;\n holdRoomMs: number;\n endsInSilence: boolean;\n previous: CaptionPreviousPage | null;\n}\n\ninterface CaptionPagingOptions {\n combineTokensWithinMilliseconds: number;\n holdMs?: number;\n}\n\nconst SENTENCE_END = /[.!?…][\"')\\]]*$/;\n\nfunction markPageBreaks(captions: SpeakerCaption[]): Caption[] {\n return captions.map((caption, i) => {\n if (caption.pageBreakAfter !== undefined) return caption;\n const next = captions[i + 1];\n const speakerChanges =\n next !== undefined && next.speaker !== caption.speaker;\n return speakerChanges || SENTENCE_END.test(caption.text.trim())\n ? { ...caption, pageBreakAfter: true }\n : caption;\n });\n}\n\nfunction buildCaptionPages(\n captions: SpeakerCaption[],\n {\n combineTokensWithinMilliseconds,\n holdMs = DEFAULT_HOLD_MS,\n }: CaptionPagingOptions,\n): CaptionPageWindow[] {\n if (captions.length === 0) return [];\n const { pages } = createTikTokStyleCaptions({\n captions: markPageBreaks(captions),\n combineTokensWithinMilliseconds,\n breakOnSilenceAfterMilliseconds: Math.max(holdMs, MIN_SILENCE_BREAK_MS),\n });\n const speakers = new Map<number, string | undefined>();\n for (const caption of captions) {\n if (!speakers.has(caption.startMs)) {\n speakers.set(caption.startMs, caption.speaker);\n }\n }\n const spoken = pages.filter((page) => page.tokens.length > 0);\n return spoken.map((page, index) => {\n const last = page.tokens[page.tokens.length - 1];\n const speechEndMs = last ? last.toMs : page.startMs;\n const heldUntil = speechEndMs + Math.max(0, holdMs);\n const next = spoken[index + 1];\n const endsInSilence = !next || next.startMs > heldUntil;\n const endMs = endsInSilence\n ? heldUntil\n : Math.max(page.startMs, next.startMs);\n return {\n page,\n index,\n speaker: speakers.get(page.tokens[0].fromMs),\n startMs: page.startMs,\n speechEndMs,\n endMs,\n endsInSilence,\n };\n });\n}\n\nfunction findWindowIndex(windows: CaptionPageWindow[], timeMs: number): number {\n let lo = 0;\n let hi = windows.length - 1;\n let found = -1;\n while (lo <= hi) {\n const mid = (lo + hi) >> 1;\n if (windows[mid].startMs <= timeMs) {\n found = mid;\n lo = mid + 1;\n } else {\n hi = mid - 1;\n }\n }\n if (found === -1) return -1;\n return timeMs < windows[found].endMs ? found : -1;\n}\n\nfunction tokenProgress(fromMs: number, toMs: number, timeMs: number): number {\n if (timeMs < fromMs) return 0;\n if (toMs <= fromMs) return 1;\n return Math.min(1, (timeMs - fromMs) / (toMs - fromMs));\n}\n\nfunction getTokenStates(\n page: TikTokPage,\n timeMs: number,\n): { activeIndex: number; tokens: CaptionTokenState[] } {\n let activeIndex = -1;\n page.tokens.forEach((token, i) => {\n if (token.fromMs <= timeMs) activeIndex = i;\n });\n const tokens = page.tokens.map(\n (token, i): CaptionTokenState => ({\n text: token.text.trim(),\n spaceBefore: i > 0 && /^\\s/.test(token.text),\n fromMs: token.fromMs,\n toMs: token.toMs,\n progress: tokenProgress(token.fromMs, token.toMs, timeMs),\n status:\n i < activeIndex ? \"spoken\" : i === activeIndex ? \"active\" : \"upcoming\",\n }),\n );\n return { activeIndex, tokens };\n}\n\nfunction getCaptionsState(\n windows: CaptionPageWindow[],\n timeMs: number,\n): CaptionsState | null {\n const found = findWindowIndex(windows, timeMs);\n if (found === -1) return null;\n const window = windows[found];\n const { activeIndex, tokens } = getTokenStates(window.page, timeMs);\n const before = found > 0 ? windows[found - 1] : null;\n const previous =\n before && !before.endsInSilence\n ? {\n page: before.page,\n pageIndex: before.index,\n tokens: getTokenStates(before.page, before.endMs).tokens,\n }\n : null;\n return {\n page: window.page,\n pageIndex: window.index,\n speaker: window.speaker,\n timeMs,\n activeIndex,\n tokens,\n sinceStartMs: timeMs - window.startMs,\n untilEndMs: window.endMs - timeMs,\n holdRoomMs: window.endMs - window.speechEndMs,\n endsInSilence: window.endsInSilence,\n previous,\n };\n}\n\nfunction getExitWindowMs(state: CaptionsState, exitMs: number): number {\n return Math.max(1, Math.min(exitMs, state.holdRoomMs));\n}\n\nfunction groupCaptionWords(\n tokens: CaptionTokenState[],\n): { index: number; token: CaptionTokenState }[][] {\n const words: { index: number; token: CaptionTokenState }[][] = [];\n tokens.forEach((token, index) => {\n const current = words[words.length - 1];\n if (!current || token.spaceBefore) {\n words.push([{ index, token }]);\n } else {\n current.push({ index, token });\n }\n });\n return words;\n}\n\nfunction normalizeCaptionWord(text: string): string {\n return text\n .toLowerCase()\n .replace(/[\\u2018\\u2019]/g, \"'\")\n .replace(/[^\\p{L}\\p{N}']/gu, \"\");\n}\n\nfunction createKeywordMatcher(\n keywords: readonly string[] = [],\n): (text: string) => boolean {\n const set = new Set(keywords.map(normalizeCaptionWord).filter(Boolean));\n return (text) => set.has(normalizeCaptionWord(text));\n}\n\nfunction captionWordText(word: { token: CaptionTokenState }[]): string {\n return word.map(({ token }) => token.text).join(\"\");\n}\n\ninterface CaptionWordRect {\n left: number;\n top: number;\n width: number;\n height: number;\n}\n\nfunction sameRects(a: CaptionWordRect[], b: CaptionWordRect[]): boolean {\n return (\n a.length === b.length &&\n a.every(\n (r, i) =>\n r.left === b[i].left &&\n r.top === b[i].top &&\n r.width === b[i].width &&\n r.height === b[i].height,\n )\n );\n}\n\nfunction useCaptionWordRects(\n pageIndex: number,\n count: number,\n): {\n wordRef: (index: number) => (el: HTMLElement | null) => void;\n rects: CaptionWordRect[] | null;\n} {\n const elements = useRef<(HTMLElement | null)[]>([]);\n const [measured, setMeasured] = useState<{\n pageIndex: number;\n rects: CaptionWordRect[];\n } | null>(null);\n\n useLayoutEffect(() => {\n if (pageIndex === -1) return;\n const rects = elements.current.slice(0, count).map((el) =>\n el\n ? {\n left: el.offsetLeft,\n top: el.offsetTop,\n width: el.offsetWidth,\n height: el.offsetHeight,\n }\n : { left: 0, top: 0, width: 0, height: 0 },\n );\n setMeasured((prev) =>\n prev && prev.pageIndex === pageIndex && sameRects(prev.rects, rects)\n ? prev\n : { pageIndex, rects },\n );\n });\n\n return {\n wordRef: (index) => (el) => {\n elements.current[index] = el;\n },\n rects: measured && measured.pageIndex === pageIndex ? measured.rects : null,\n };\n}\n\nfunction useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs = DEFAULT_HOLD_MS,\n}: {\n captions: SpeakerCaption[];\n combineTokensWithinMilliseconds: number;\n holdMs?: number;\n}): CaptionsState | null {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const windows = useMemo(\n () =>\n buildCaptionPages(captions, { combineTokensWithinMilliseconds, holdMs }),\n [captions, combineTokensWithinMilliseconds, holdMs],\n );\n return getCaptionsState(windows, (frame / fps) * 1000);\n}\n\ninterface CaptionActivePopProps extends CaptionBaseProps {\n activeColor?: string;\n popScale?: number;\n shadow?: boolean;\n}\n\nconst ENTER_MS = 160;\nconst EXIT_MS = 220;\nconst RISE_EM = 0.14;\nconst LEGIBILITY_SHADOW =\n \"0 2px 3px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.35)\";\n\nconst POP_SPRING = { damping: 12, stiffness: 220, mass: 0.6 };\nconst RELEASE_SPRING = { damping: 20, stiffness: 200, mass: 0.6 };\n\nconst enterEasing = Easing.bezier(0.2, 0.8, 0.2, 1);\n\nconst clamp = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n} as const;\n\nfunction CaptionActivePopBase({\n captions,\n combineTokensWithinMilliseconds = 1200,\n holdMs = DEFAULT_HOLD_MS,\n fontSize = 64,\n fontWeight = 800,\n color = \"#ffffff\",\n activeColor = \"#facc15\",\n popScale = 1.12,\n shadow = true,\n className,\n}: CaptionActivePopProps) {\n const { fps } = useVideoConfig();\n const state = useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs,\n });\n if (!state) return null;\n\n const enter = interpolate(\n state.previous ? ENTER_MS : state.sinceStartMs,\n [0, ENTER_MS],\n [0, 1],\n {\n ...clamp,\n easing: enterEasing,\n },\n );\n const exit = state.endsInSilence\n ? interpolate(\n state.untilEndMs,\n [0, getExitWindowMs(state, EXIT_MS)],\n [0, 1],\n clamp,\n )\n : 1;\n\n const words = groupCaptionWords(state.tokens);\n const activeWord = words.findIndex((word) =>\n word.some(({ index }) => index === state.activeIndex),\n );\n const toFrames = (ms: number) => (ms / 1000) * fps;\n\n const emphasis = (w: number): number => {\n if (activeWord < 0 || w > activeWord) return 0;\n const startMs = words[w][0].token.fromMs;\n if (w === activeWord) {\n return spring({\n frame: toFrames(state.timeMs - startMs),\n fps,\n config: POP_SPRING,\n });\n }\n if (w < activeWord - 1) return 0;\n const releaseMs = words[w + 1][0].token.fromMs;\n const peak = spring({\n frame: toFrames(releaseMs - startMs),\n fps,\n config: POP_SPRING,\n });\n const release = spring({\n frame: toFrames(state.timeMs - releaseMs),\n fps,\n config: RELEASE_SPRING,\n });\n return peak * (1 - release);\n };\n\n return (\n <div\n className={className}\n style={{\n fontSize,\n fontWeight,\n color,\n lineHeight: 1.2,\n textAlign: \"center\",\n opacity: Math.min(enter, exit),\n transform: `translateY(${(1 - enter) * RISE_EM}em)`,\n }}\n >\n {words.map((word, w) => {\n const amount = emphasis(w);\n return (\n <Fragment key={`${state.pageIndex}-${word[0].index}`}>\n {w > 0 && \" \"}\n <span\n style={{\n position: \"relative\",\n zIndex: w === activeWord ? 1 : 0,\n display: \"inline-block\",\n whiteSpace: \"nowrap\",\n transform: `scale(${1 + (popScale - 1) * amount})`,\n transformOrigin: \"50% 60%\",\n color: interpolateColors(\n Math.min(1, Math.max(0, amount)),\n [0, 1],\n [color, activeColor],\n ),\n textShadow: shadow ? LEGIBILITY_SHADOW : undefined,\n }}\n >\n {word.map(({ index, token }) => (\n <span key={index}>{token.text}</span>\n ))}\n </span>\n </Fragment>\n );\n })}\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n captions: {\n type: \"remotion-captions\",\n default: [{\n text: \" So\",\n startMs: 300,\n endMs: 460,\n timestampMs: 380,\n confidence: 0.97,\n }, {\n text: \" here's\",\n startMs: 460,\n endMs: 700,\n timestampMs: 580,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 700,\n endMs: 820,\n timestampMs: 760,\n confidence: 0.97,\n }, {\n text: \" thing.\",\n startMs: 820,\n endMs: 1240,\n timestampMs: 1030,\n confidence: 0.97,\n }, {\n text: \" Most\",\n startMs: 1700,\n endMs: 1960,\n timestampMs: 1830,\n confidence: 0.97,\n }, {\n text: \" demo\",\n startMs: 1960,\n endMs: 2240,\n timestampMs: 2100,\n confidence: 0.97,\n }, {\n text: \" videos\",\n startMs: 2240,\n endMs: 2680,\n timestampMs: 2460,\n confidence: 0.97,\n }, {\n text: \" lose\",\n startMs: 2680,\n endMs: 2960,\n timestampMs: 2820,\n confidence: 0.97,\n }, {\n text: \" people\",\n startMs: 2960,\n endMs: 3320,\n timestampMs: 3140,\n confidence: 0.97,\n }, {\n text: \" in\",\n startMs: 3320,\n endMs: 3420,\n timestampMs: 3370,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 3420,\n endMs: 3520,\n timestampMs: 3470,\n confidence: 0.97,\n }, {\n text: \" first\",\n startMs: 3520,\n endMs: 3820,\n timestampMs: 3670,\n confidence: 0.97,\n }, {\n text: \" three\",\n startMs: 3820,\n endMs: 4100,\n timestampMs: 3960,\n confidence: 0.97,\n }, {\n text: \" seconds.\",\n startMs: 4100,\n endMs: 4780,\n timestampMs: 4440,\n confidence: 0.97,\n }, {\n text: \" Captions\",\n startMs: 5400,\n endMs: 5920,\n timestampMs: 5660,\n confidence: 0.97,\n }, {\n text: \" keep\",\n startMs: 5920,\n endMs: 6140,\n timestampMs: 6030,\n confidence: 0.97,\n }, {\n text: \" them\",\n startMs: 6140,\n endMs: 6300,\n timestampMs: 6220,\n confidence: 0.97,\n }, {\n text: \" watching,\",\n startMs: 6300,\n endMs: 6860,\n timestampMs: 6580,\n confidence: 0.97,\n }, {\n text: \" even\",\n startMs: 6960,\n endMs: 7180,\n timestampMs: 7070,\n confidence: 0.97,\n }, {\n text: \" with\",\n startMs: 7180,\n endMs: 7320,\n timestampMs: 7250,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 7320,\n endMs: 7420,\n timestampMs: 7370,\n confidence: 0.97,\n }, {\n text: \" sound\",\n startMs: 7420,\n endMs: 7760,\n timestampMs: 7590,\n confidence: 0.97,\n }, {\n text: \" off.\",\n startMs: 7760,\n endMs: 8300,\n timestampMs: 8030,\n confidence: 0.97,\n }],\n description: \"Transcript\",\n keyframable: false,\n },\n fontSize: {\n type: \"number\",\n min: 24,\n max: 140,\n step: 1,\n default: 64,\n description: \"Font size\",\n hiddenFromList: false,\n },\n fontWeight: {\n type: \"number\",\n min: 400,\n max: 900,\n step: 100,\n default: 800,\n description: \"Font weight\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#ffffff\",\n description: \"Text color\",\n },\n activeColor: {\n type: \"color\",\n default: \"#facc15\",\n description: \"Active word color\",\n },\n popScale: {\n type: \"number\",\n min: 1,\n max: 1.5,\n step: 0.01,\n default: 1.12,\n description: \"Pop scale\",\n hiddenFromList: false,\n },\n combineTokensWithinMilliseconds: {\n type: \"number\",\n min: 0,\n max: 3000,\n step: 100,\n default: 1200,\n description: \"Page window (ms)\",\n hiddenFromList: false,\n },\n holdMs: {\n type: \"number\",\n min: 0,\n max: 2000,\n step: 50,\n default: 600,\n description: \"Hold (ms)\",\n hiddenFromList: false,\n },\n shadow: {\n type: \"boolean\",\n default: true,\n description: \"Shadow\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"captions\",\"fontSize\",\"fontWeight\",\"color\",\"activeColor\",\"popScale\",\"combineTokensWithinMilliseconds\",\"holdMs\",\"shadow\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n captions: [{\n text: \" So\",\n startMs: 300,\n endMs: 460,\n timestampMs: 380,\n confidence: 0.97,\n }, {\n text: \" here's\",\n startMs: 460,\n endMs: 700,\n timestampMs: 580,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 700,\n endMs: 820,\n timestampMs: 760,\n confidence: 0.97,\n }, {\n text: \" thing.\",\n startMs: 820,\n endMs: 1240,\n timestampMs: 1030,\n confidence: 0.97,\n }, {\n text: \" Most\",\n startMs: 1700,\n endMs: 1960,\n timestampMs: 1830,\n confidence: 0.97,\n }, {\n text: \" demo\",\n startMs: 1960,\n endMs: 2240,\n timestampMs: 2100,\n confidence: 0.97,\n }, {\n text: \" videos\",\n startMs: 2240,\n endMs: 2680,\n timestampMs: 2460,\n confidence: 0.97,\n }, {\n text: \" lose\",\n startMs: 2680,\n endMs: 2960,\n timestampMs: 2820,\n confidence: 0.97,\n }, {\n text: \" people\",\n startMs: 2960,\n endMs: 3320,\n timestampMs: 3140,\n confidence: 0.97,\n }, {\n text: \" in\",\n startMs: 3320,\n endMs: 3420,\n timestampMs: 3370,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 3420,\n endMs: 3520,\n timestampMs: 3470,\n confidence: 0.97,\n }, {\n text: \" first\",\n startMs: 3520,\n endMs: 3820,\n timestampMs: 3670,\n confidence: 0.97,\n }, {\n text: \" three\",\n startMs: 3820,\n endMs: 4100,\n timestampMs: 3960,\n confidence: 0.97,\n }, {\n text: \" seconds.\",\n startMs: 4100,\n endMs: 4780,\n timestampMs: 4440,\n confidence: 0.97,\n }, {\n text: \" Captions\",\n startMs: 5400,\n endMs: 5920,\n timestampMs: 5660,\n confidence: 0.97,\n }, {\n text: \" keep\",\n startMs: 5920,\n endMs: 6140,\n timestampMs: 6030,\n confidence: 0.97,\n }, {\n text: \" them\",\n startMs: 6140,\n endMs: 6300,\n timestampMs: 6220,\n confidence: 0.97,\n }, {\n text: \" watching,\",\n startMs: 6300,\n endMs: 6860,\n timestampMs: 6580,\n confidence: 0.97,\n }, {\n text: \" even\",\n startMs: 6960,\n endMs: 7180,\n timestampMs: 7070,\n confidence: 0.97,\n }, {\n text: \" with\",\n startMs: 7180,\n endMs: 7320,\n timestampMs: 7250,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 7320,\n endMs: 7420,\n timestampMs: 7370,\n confidence: 0.97,\n }, {\n text: \" sound\",\n startMs: 7420,\n endMs: 7760,\n timestampMs: 7590,\n confidence: 0.97,\n }, {\n text: \" off.\",\n startMs: 7760,\n endMs: 8300,\n timestampMs: 8030,\n confidence: 0.97,\n }],\n fontSize: 64,\n fontWeight: 800,\n color: \"#ffffff\",\n activeColor: \"#facc15\",\n popScale: 1.12,\n combineTokensWithinMilliseconds: 1200,\n holdMs: 600,\n shadow: true,\n};\n\ntype CaptionActivePopElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof CaptionActivePopBase>;\n\nconst CaptionActivePopInner = forwardRef<\n HTMLDivElement,\n CaptionActivePopElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<CaptionActivePop>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <CaptionActivePopBase\n {...(componentProps as unknown as ComponentProps<typeof CaptionActivePopBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const CaptionActivePop = Interactive.withSchema({\n Component: CaptionActivePopInner,\n componentName: \"<CaptionActivePop>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"+ },+ "durationInFrames": 279+}diff --git a/registry-artifacts/elements/caption-blur-in.json b/registry-artifacts/elements/caption-blur-in.jsonnew file mode 100644index 00000000..a0fa6999--- /dev/null+++ b/registry-artifacts/elements/caption-blur-in.json@@ -0,0 +1,21 @@+{+ "type": "remotion-element",+ "version": 1,+ "element": {+ "assets": [],+ "dependencies": [+ {+ "name": "@remotion/captions",+ "version": null+ }+ ],+ "dimensions": null,+ "displayName": "Caption Blur In",+ "durationInFrames": 279,+ "initialProps": null,+ "installationMode": "component-owned-sequence",+ "slug": "caption-blur-in",+ "sourceCode": "import { Fragment, forwardRef, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState, type ComponentProps } from \"react\";\nimport { Easing, Interactive, Sequence, interpolate, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { createTikTokStyleCaptions, type Caption, type TikTokPage } from \"@remotion/captions\";\n\ntype SpeakerCaption = Caption & { speaker?: string };\n\ninterface CaptionBaseProps {\n captions: Caption[];\n combineTokensWithinMilliseconds?: number;\n holdMs?: number;\n fontSize?: number;\n fontWeight?: number;\n color?: string;\n className?: string;\n}\n\nconst DEFAULT_HOLD_MS = 600;\nconst MIN_SILENCE_BREAK_MS = 300;\n\ninterface CaptionPageWindow {\n page: TikTokPage;\n index: number;\n speaker: string | undefined;\n startMs: number;\n speechEndMs: number;\n endMs: number;\n endsInSilence: boolean;\n}\n\ntype CaptionTokenStatus = \"upcoming\" | \"active\" | \"spoken\";\n\ninterface CaptionTokenState {\n text: string;\n spaceBefore: boolean;\n fromMs: number;\n toMs: number;\n progress: number;\n status: CaptionTokenStatus;\n}\n\ninterface CaptionPreviousPage {\n page: TikTokPage;\n pageIndex: number;\n tokens: CaptionTokenState[];\n}\n\ninterface CaptionsState {\n page: TikTokPage;\n pageIndex: number;\n speaker: string | undefined;\n timeMs: number;\n activeIndex: number;\n tokens: CaptionTokenState[];\n sinceStartMs: number;\n untilEndMs: number;\n holdRoomMs: number;\n endsInSilence: boolean;\n previous: CaptionPreviousPage | null;\n}\n\ninterface CaptionPagingOptions {\n combineTokensWithinMilliseconds: number;\n holdMs?: number;\n}\n\nconst SENTENCE_END = /[.!?…][\"')\\]]*$/;\n\nfunction markPageBreaks(captions: SpeakerCaption[]): Caption[] {\n return captions.map((caption, i) => {\n if (caption.pageBreakAfter !== undefined) return caption;\n const next = captions[i + 1];\n const speakerChanges =\n next !== undefined && next.speaker !== caption.speaker;\n return speakerChanges || SENTENCE_END.test(caption.text.trim())\n ? { ...caption, pageBreakAfter: true }\n : caption;\n });\n}\n\nfunction buildCaptionPages(\n captions: SpeakerCaption[],\n {\n combineTokensWithinMilliseconds,\n holdMs = DEFAULT_HOLD_MS,\n }: CaptionPagingOptions,\n): CaptionPageWindow[] {\n if (captions.length === 0) return [];\n const { pages } = createTikTokStyleCaptions({\n captions: markPageBreaks(captions),\n combineTokensWithinMilliseconds,\n breakOnSilenceAfterMilliseconds: Math.max(holdMs, MIN_SILENCE_BREAK_MS),\n });\n const speakers = new Map<number, string | undefined>();\n for (const caption of captions) {\n if (!speakers.has(caption.startMs)) {\n speakers.set(caption.startMs, caption.speaker);\n }\n }\n const spoken = pages.filter((page) => page.tokens.length > 0);\n return spoken.map((page, index) => {\n const last = page.tokens[page.tokens.length - 1];\n const speechEndMs = last ? last.toMs : page.startMs;\n const heldUntil = speechEndMs + Math.max(0, holdMs);\n const next = spoken[index + 1];\n const endsInSilence = !next || next.startMs > heldUntil;\n const endMs = endsInSilence\n ? heldUntil\n : Math.max(page.startMs, next.startMs);\n return {\n page,\n index,\n speaker: speakers.get(page.tokens[0].fromMs),\n startMs: page.startMs,\n speechEndMs,\n endMs,\n endsInSilence,\n };\n });\n}\n\nfunction findWindowIndex(windows: CaptionPageWindow[], timeMs: number): number {\n let lo = 0;\n let hi = windows.length - 1;\n let found = -1;\n while (lo <= hi) {\n const mid = (lo + hi) >> 1;\n if (windows[mid].startMs <= timeMs) {\n found = mid;\n lo = mid + 1;\n } else {\n hi = mid - 1;\n }\n }\n if (found === -1) return -1;\n return timeMs < windows[found].endMs ? found : -1;\n}\n\nfunction tokenProgress(fromMs: number, toMs: number, timeMs: number): number {\n if (timeMs < fromMs) return 0;\n if (toMs <= fromMs) return 1;\n return Math.min(1, (timeMs - fromMs) / (toMs - fromMs));\n}\n\nfunction getTokenStates(\n page: TikTokPage,\n timeMs: number,\n): { activeIndex: number; tokens: CaptionTokenState[] } {\n let activeIndex = -1;\n page.tokens.forEach((token, i) => {\n if (token.fromMs <= timeMs) activeIndex = i;\n });\n const tokens = page.tokens.map(\n (token, i): CaptionTokenState => ({\n text: token.text.trim(),\n spaceBefore: i > 0 && /^\\s/.test(token.text),\n fromMs: token.fromMs,\n toMs: token.toMs,\n progress: tokenProgress(token.fromMs, token.toMs, timeMs),\n status:\n i < activeIndex ? \"spoken\" : i === activeIndex ? \"active\" : \"upcoming\",\n }),\n );\n return { activeIndex, tokens };\n}\n\nfunction getCaptionsState(\n windows: CaptionPageWindow[],\n timeMs: number,\n): CaptionsState | null {\n const found = findWindowIndex(windows, timeMs);\n if (found === -1) return null;\n const window = windows[found];\n const { activeIndex, tokens } = getTokenStates(window.page, timeMs);\n const before = found > 0 ? windows[found - 1] : null;\n const previous =\n before && !before.endsInSilence\n ? {\n page: before.page,\n pageIndex: before.index,\n tokens: getTokenStates(before.page, before.endMs).tokens,\n }\n : null;\n return {\n page: window.page,\n pageIndex: window.index,\n speaker: window.speaker,\n timeMs,\n activeIndex,\n tokens,\n sinceStartMs: timeMs - window.startMs,\n untilEndMs: window.endMs - timeMs,\n holdRoomMs: window.endMs - window.speechEndMs,\n endsInSilence: window.endsInSilence,\n previous,\n };\n}\n\nfunction getExitWindowMs(state: CaptionsState, exitMs: number): number {\n return Math.max(1, Math.min(exitMs, state.holdRoomMs));\n}\n\nfunction groupCaptionWords(\n tokens: CaptionTokenState[],\n): { index: number; token: CaptionTokenState }[][] {\n const words: { index: number; token: CaptionTokenState }[][] = [];\n tokens.forEach((token, index) => {\n const current = words[words.length - 1];\n if (!current || token.spaceBefore) {\n words.push([{ index, token }]);\n } else {\n current.push({ index, token });\n }\n });\n return words;\n}\n\nfunction normalizeCaptionWord(text: string): string {\n return text\n .toLowerCase()\n .replace(/[\\u2018\\u2019]/g, \"'\")\n .replace(/[^\\p{L}\\p{N}']/gu, \"\");\n}\n\nfunction createKeywordMatcher(\n keywords: readonly string[] = [],\n): (text: string) => boolean {\n const set = new Set(keywords.map(normalizeCaptionWord).filter(Boolean));\n return (text) => set.has(normalizeCaptionWord(text));\n}\n\nfunction captionWordText(word: { token: CaptionTokenState }[]): string {\n return word.map(({ token }) => token.text).join(\"\");\n}\n\ninterface CaptionWordRect {\n left: number;\n top: number;\n width: number;\n height: number;\n}\n\nfunction sameRects(a: CaptionWordRect[], b: CaptionWordRect[]): boolean {\n return (\n a.length === b.length &&\n a.every(\n (r, i) =>\n r.left === b[i].left &&\n r.top === b[i].top &&\n r.width === b[i].width &&\n r.height === b[i].height,\n )\n );\n}\n\nfunction useCaptionWordRects(\n pageIndex: number,\n count: number,\n): {\n wordRef: (index: number) => (el: HTMLElement | null) => void;\n rects: CaptionWordRect[] | null;\n} {\n const elements = useRef<(HTMLElement | null)[]>([]);\n const [measured, setMeasured] = useState<{\n pageIndex: number;\n rects: CaptionWordRect[];\n } | null>(null);\n\n useLayoutEffect(() => {\n if (pageIndex === -1) return;\n const rects = elements.current.slice(0, count).map((el) =>\n el\n ? {\n left: el.offsetLeft,\n top: el.offsetTop,\n width: el.offsetWidth,\n height: el.offsetHeight,\n }\n : { left: 0, top: 0, width: 0, height: 0 },\n );\n setMeasured((prev) =>\n prev && prev.pageIndex === pageIndex && sameRects(prev.rects, rects)\n ? prev\n : { pageIndex, rects },\n );\n });\n\n return {\n wordRef: (index) => (el) => {\n elements.current[index] = el;\n },\n rects: measured && measured.pageIndex === pageIndex ? measured.rects : null,\n };\n}\n\nfunction useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs = DEFAULT_HOLD_MS,\n}: {\n captions: SpeakerCaption[];\n combineTokensWithinMilliseconds: number;\n holdMs?: number;\n}): CaptionsState | null {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const windows = useMemo(\n () =>\n buildCaptionPages(captions, { combineTokensWithinMilliseconds, holdMs }),\n [captions, combineTokensWithinMilliseconds, holdMs],\n );\n return getCaptionsState(windows, (frame / fps) * 1000);\n}\n\ninterface CaptionBlurInProps extends CaptionBaseProps {\n blur?: number;\n shadow?: boolean;\n}\n\nconst EXIT_MS = 220;\nconst RESOLVE_MS = 220;\nconst LEGIBILITY_SHADOW =\n \"0 2px 3px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.35)\";\n\nconst resolveEasing = Easing.bezier(0.25, 0.6, 0.3, 1);\n\nfunction CaptionBlurInBase({\n captions,\n combineTokensWithinMilliseconds = 1200,\n holdMs = DEFAULT_HOLD_MS,\n fontSize = 64,\n fontWeight = 800,\n color = \"#ffffff\",\n blur = 12,\n shadow = true,\n className,\n}: CaptionBlurInProps) {\n const state = useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs,\n });\n if (!state) return null;\n\n const exit = state.endsInSilence\n ? interpolate(\n state.untilEndMs,\n [0, getExitWindowMs(state, EXIT_MS)],\n [0, 1],\n {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n },\n )\n : 1;\n\n return (\n <div\n className={className}\n style={{\n fontSize,\n fontWeight,\n color,\n lineHeight: 1.2,\n textAlign: \"center\",\n opacity: exit,\n }}\n >\n {groupCaptionWords(state.tokens).map((word, w) => (\n <Fragment key={`${state.pageIndex}-${word[0].index}`}>\n {w > 0 && \" \"}\n <span style={{ display: \"inline-block\", whiteSpace: \"nowrap\" }}>\n {word.map(({ index, token }) => {\n const sinceMs = state.timeMs - token.fromMs;\n const p =\n sinceMs < 0\n ? 0\n : interpolate(sinceMs, [0, RESOLVE_MS], [0, 1], {\n easing: resolveEasing,\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n });\n const radius = (1 - p) * blur;\n return (\n <span\n key={index}\n style={{\n display: \"inline-block\",\n opacity: p,\n filter: radius > 0.01 ? `blur(${radius}px)` : undefined,\n textShadow: shadow ? LEGIBILITY_SHADOW : undefined,\n }}\n >\n {token.text}\n </span>\n );\n })}\n </span>\n </Fragment>\n ))}\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n captions: {\n type: \"remotion-captions\",\n default: [{\n text: \" So\",\n startMs: 300,\n endMs: 460,\n timestampMs: 380,\n confidence: 0.97,\n }, {\n text: \" here's\",\n startMs: 460,\n endMs: 700,\n timestampMs: 580,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 700,\n endMs: 820,\n timestampMs: 760,\n confidence: 0.97,\n }, {\n text: \" thing.\",\n startMs: 820,\n endMs: 1240,\n timestampMs: 1030,\n confidence: 0.97,\n }, {\n text: \" Most\",\n startMs: 1700,\n endMs: 1960,\n timestampMs: 1830,\n confidence: 0.97,\n }, {\n text: \" demo\",\n startMs: 1960,\n endMs: 2240,\n timestampMs: 2100,\n confidence: 0.97,\n }, {\n text: \" videos\",\n startMs: 2240,\n endMs: 2680,\n timestampMs: 2460,\n confidence: 0.97,\n }, {\n text: \" lose\",\n startMs: 2680,\n endMs: 2960,\n timestampMs: 2820,\n confidence: 0.97,\n }, {\n text: \" people\",\n startMs: 2960,\n endMs: 3320,\n timestampMs: 3140,\n confidence: 0.97,\n }, {\n text: \" in\",\n startMs: 3320,\n endMs: 3420,\n timestampMs: 3370,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 3420,\n endMs: 3520,\n timestampMs: 3470,\n confidence: 0.97,\n }, {\n text: \" first\",\n startMs: 3520,\n endMs: 3820,\n timestampMs: 3670,\n confidence: 0.97,\n }, {\n text: \" three\",\n startMs: 3820,\n endMs: 4100,\n timestampMs: 3960,\n confidence: 0.97,\n }, {\n text: \" seconds.\",\n startMs: 4100,\n endMs: 4780,\n timestampMs: 4440,\n confidence: 0.97,\n }, {\n text: \" Captions\",\n startMs: 5400,\n endMs: 5920,\n timestampMs: 5660,\n confidence: 0.97,\n }, {\n text: \" keep\",\n startMs: 5920,\n endMs: 6140,\n timestampMs: 6030,\n confidence: 0.97,\n }, {\n text: \" them\",\n startMs: 6140,\n endMs: 6300,\n timestampMs: 6220,\n confidence: 0.97,\n }, {\n text: \" watching,\",\n startMs: 6300,\n endMs: 6860,\n timestampMs: 6580,\n confidence: 0.97,\n }, {\n text: \" even\",\n startMs: 6960,\n endMs: 7180,\n timestampMs: 7070,\n confidence: 0.97,\n }, {\n text: \" with\",\n startMs: 7180,\n endMs: 7320,\n timestampMs: 7250,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 7320,\n endMs: 7420,\n timestampMs: 7370,\n confidence: 0.97,\n }, {\n text: \" sound\",\n startMs: 7420,\n endMs: 7760,\n timestampMs: 7590,\n confidence: 0.97,\n }, {\n text: \" off.\",\n startMs: 7760,\n endMs: 8300,\n timestampMs: 8030,\n confidence: 0.97,\n }],\n description: \"Transcript\",\n keyframable: false,\n },\n fontSize: {\n type: \"number\",\n min: 24,\n max: 140,\n step: 1,\n default: 64,\n description: \"Font size\",\n hiddenFromList: false,\n },\n fontWeight: {\n type: \"number\",\n min: 400,\n max: 900,\n step: 100,\n default: 800,\n description: \"Font weight\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#ffffff\",\n description: \"Text color\",\n },\n blur: {\n type: \"number\",\n min: 0,\n max: 32,\n step: 1,\n default: 12,\n description: \"Blur (px)\",\n hiddenFromList: false,\n },\n combineTokensWithinMilliseconds: {\n type: \"number\",\n min: 0,\n max: 3000,\n step: 100,\n default: 1200,\n description: \"Page window (ms)\",\n hiddenFromList: false,\n },\n holdMs: {\n type: \"number\",\n min: 0,\n max: 2000,\n step: 50,\n default: 600,\n description: \"Hold (ms)\",\n hiddenFromList: false,\n },\n shadow: {\n type: \"boolean\",\n default: true,\n description: \"Shadow\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"captions\",\"fontSize\",\"fontWeight\",\"color\",\"blur\",\"combineTokensWithinMilliseconds\",\"holdMs\",\"shadow\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n captions: [{\n text: \" So\",\n startMs: 300,\n endMs: 460,\n timestampMs: 380,\n confidence: 0.97,\n }, {\n text: \" here's\",\n startMs: 460,\n endMs: 700,\n timestampMs: 580,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 700,\n endMs: 820,\n timestampMs: 760,\n confidence: 0.97,\n }, {\n text: \" thing.\",\n startMs: 820,\n endMs: 1240,\n timestampMs: 1030,\n confidence: 0.97,\n }, {\n text: \" Most\",\n startMs: 1700,\n endMs: 1960,\n timestampMs: 1830,\n confidence: 0.97,\n }, {\n text: \" demo\",\n startMs: 1960,\n endMs: 2240,\n timestampMs: 2100,\n confidence: 0.97,\n }, {\n text: \" videos\",\n startMs: 2240,\n endMs: 2680,\n timestampMs: 2460,\n confidence: 0.97,\n }, {\n text: \" lose\",\n startMs: 2680,\n endMs: 2960,\n timestampMs: 2820,\n confidence: 0.97,\n }, {\n text: \" people\",\n startMs: 2960,\n endMs: 3320,\n timestampMs: 3140,\n confidence: 0.97,\n }, {\n text: \" in\",\n startMs: 3320,\n endMs: 3420,\n timestampMs: 3370,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 3420,\n endMs: 3520,\n timestampMs: 3470,\n confidence: 0.97,\n }, {\n text: \" first\",\n startMs: 3520,\n endMs: 3820,\n timestampMs: 3670,\n confidence: 0.97,\n }, {\n text: \" three\",\n startMs: 3820,\n endMs: 4100,\n timestampMs: 3960,\n confidence: 0.97,\n }, {\n text: \" seconds.\",\n startMs: 4100,\n endMs: 4780,\n timestampMs: 4440,\n confidence: 0.97,\n }, {\n text: \" Captions\",\n startMs: 5400,\n endMs: 5920,\n timestampMs: 5660,\n confidence: 0.97,\n }, {\n text: \" keep\",\n startMs: 5920,\n endMs: 6140,\n timestampMs: 6030,\n confidence: 0.97,\n }, {\n text: \" them\",\n startMs: 6140,\n endMs: 6300,\n timestampMs: 6220,\n confidence: 0.97,\n }, {\n text: \" watching,\",\n startMs: 6300,\n endMs: 6860,\n timestampMs: 6580,\n confidence: 0.97,\n }, {\n text: \" even\",\n startMs: 6960,\n endMs: 7180,\n timestampMs: 7070,\n confidence: 0.97,\n }, {\n text: \" with\",\n startMs: 7180,\n endMs: 7320,\n timestampMs: 7250,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 7320,\n endMs: 7420,\n timestampMs: 7370,\n confidence: 0.97,\n }, {\n text: \" sound\",\n startMs: 7420,\n endMs: 7760,\n timestampMs: 7590,\n confidence: 0.97,\n }, {\n text: \" off.\",\n startMs: 7760,\n endMs: 8300,\n timestampMs: 8030,\n confidence: 0.97,\n }],\n fontSize: 64,\n fontWeight: 800,\n color: \"#ffffff\",\n blur: 12,\n combineTokensWithinMilliseconds: 1200,\n holdMs: 600,\n shadow: true,\n};\n\ntype CaptionBlurInElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof CaptionBlurInBase>;\n\nconst CaptionBlurInInner = forwardRef<\n HTMLDivElement,\n CaptionBlurInElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<CaptionBlurIn>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <CaptionBlurInBase\n {...(componentProps as unknown as ComponentProps<typeof CaptionBlurInBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const CaptionBlurIn = Interactive.withSchema({\n Component: CaptionBlurInInner,\n componentName: \"<CaptionBlurIn>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"+ },+ "durationInFrames": 279+}diff --git a/registry-artifacts/elements/caption-bounce-in.json b/registry-artifacts/elements/caption-bounce-in.jsonnew file mode 100644index 00000000..08b7212f--- /dev/null+++ b/registry-artifacts/elements/caption-bounce-in.json@@ -0,0 +1,21 @@+{+ "type": "remotion-element",+ "version": 1,+ "element": {+ "assets": [],+ "dependencies": [+ {+ "name": "@remotion/captions",+ "version": null+ }+ ],+ "dimensions": null,+ "displayName": "Caption Bounce In",+ "durationInFrames": 279,+ "initialProps": null,+ "installationMode": "component-owned-sequence",+ "slug": "caption-bounce-in",+ "sourceCode": "import { Fragment, forwardRef, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState, type ComponentProps } from \"react\";\nimport { Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { createTikTokStyleCaptions, type Caption, type TikTokPage } from \"@remotion/captions\";\n\ntype SpeakerCaption = Caption & { speaker?: string };\n\ninterface CaptionBaseProps {\n captions: Caption[];\n combineTokensWithinMilliseconds?: number;\n holdMs?: number;\n fontSize?: number;\n fontWeight?: number;\n color?: string;\n className?: string;\n}\n\nconst DEFAULT_HOLD_MS = 600;\nconst MIN_SILENCE_BREAK_MS = 300;\n\ninterface CaptionPageWindow {\n page: TikTokPage;\n index: number;\n speaker: string | undefined;\n startMs: number;\n speechEndMs: number;\n endMs: number;\n endsInSilence: boolean;\n}\n\ntype CaptionTokenStatus = \"upcoming\" | \"active\" | \"spoken\";\n\ninterface CaptionTokenState {\n text: string;\n spaceBefore: boolean;\n fromMs: number;\n toMs: number;\n progress: number;\n status: CaptionTokenStatus;\n}\n\ninterface CaptionPreviousPage {\n page: TikTokPage;\n pageIndex: number;\n tokens: CaptionTokenState[];\n}\n\ninterface CaptionsState {\n page: TikTokPage;\n pageIndex: number;\n speaker: string | undefined;\n timeMs: number;\n activeIndex: number;\n tokens: CaptionTokenState[];\n sinceStartMs: number;\n untilEndMs: number;\n holdRoomMs: number;\n endsInSilence: boolean;\n previous: CaptionPreviousPage | null;\n}\n\ninterface CaptionPagingOptions {\n combineTokensWithinMilliseconds: number;\n holdMs?: number;\n}\n\nconst SENTENCE_END = /[.!?…][\"')\\]]*$/;\n\nfunction markPageBreaks(captions: SpeakerCaption[]): Caption[] {\n return captions.map((caption, i) => {\n if (caption.pageBreakAfter !== undefined) return caption;\n const next = captions[i + 1];\n const speakerChanges =\n next !== undefined && next.speaker !== caption.speaker;\n return speakerChanges || SENTENCE_END.test(caption.text.trim())\n ? { ...caption, pageBreakAfter: true }\n : caption;\n });\n}\n\nfunction buildCaptionPages(\n captions: SpeakerCaption[],\n {\n combineTokensWithinMilliseconds,\n holdMs = DEFAULT_HOLD_MS,\n }: CaptionPagingOptions,\n): CaptionPageWindow[] {\n if (captions.length === 0) return [];\n const { pages } = createTikTokStyleCaptions({\n captions: markPageBreaks(captions),\n combineTokensWithinMilliseconds,\n breakOnSilenceAfterMilliseconds: Math.max(holdMs, MIN_SILENCE_BREAK_MS),\n });\n const speakers = new Map<number, string | undefined>();\n for (const caption of captions) {\n if (!speakers.has(caption.startMs)) {\n speakers.set(caption.startMs, caption.speaker);\n }\n }\n const spoken = pages.filter((page) => page.tokens.length > 0);\n return spoken.map((page, index) => {\n const last = page.tokens[page.tokens.length - 1];\n const speechEndMs = last ? last.toMs : page.startMs;\n const heldUntil = speechEndMs + Math.max(0, holdMs);\n const next = spoken[index + 1];\n const endsInSilence = !next || next.startMs > heldUntil;\n const endMs = endsInSilence\n ? heldUntil\n : Math.max(page.startMs, next.startMs);\n return {\n page,\n index,\n speaker: speakers.get(page.tokens[0].fromMs),\n startMs: page.startMs,\n speechEndMs,\n endMs,\n endsInSilence,\n };\n });\n}\n\nfunction findWindowIndex(windows: CaptionPageWindow[], timeMs: number): number {\n let lo = 0;\n let hi = windows.length - 1;\n let found = -1;\n while (lo <= hi) {\n const mid = (lo + hi) >> 1;\n if (windows[mid].startMs <= timeMs) {\n found = mid;\n lo = mid + 1;\n } else {\n hi = mid - 1;\n }\n }\n if (found === -1) return -1;\n return timeMs < windows[found].endMs ? found : -1;\n}\n\nfunction tokenProgress(fromMs: number, toMs: number, timeMs: number): number {\n if (timeMs < fromMs) return 0;\n if (toMs <= fromMs) return 1;\n return Math.min(1, (timeMs - fromMs) / (toMs - fromMs));\n}\n\nfunction getTokenStates(\n page: TikTokPage,\n timeMs: number,\n): { activeIndex: number; tokens: CaptionTokenState[] } {\n let activeIndex = -1;\n page.tokens.forEach((token, i) => {\n if (token.fromMs <= timeMs) activeIndex = i;\n });\n const tokens = page.tokens.map(\n (token, i): CaptionTokenState => ({\n text: token.text.trim(),\n spaceBefore: i > 0 && /^\\s/.test(token.text),\n fromMs: token.fromMs,\n toMs: token.toMs,\n progress: tokenProgress(token.fromMs, token.toMs, timeMs),\n status:\n i < activeIndex ? \"spoken\" : i === activeIndex ? \"active\" : \"upcoming\",\n }),\n );\n return { activeIndex, tokens };\n}\n\nfunction getCaptionsState(\n windows: CaptionPageWindow[],\n timeMs: number,\n): CaptionsState | null {\n const found = findWindowIndex(windows, timeMs);\n if (found === -1) return null;\n const window = windows[found];\n const { activeIndex, tokens } = getTokenStates(window.page, timeMs);\n const before = found > 0 ? windows[found - 1] : null;\n const previous =\n before && !before.endsInSilence\n ? {\n page: before.page,\n pageIndex: before.index,\n tokens: getTokenStates(before.page, before.endMs).tokens,\n }\n : null;\n return {\n page: window.page,\n pageIndex: window.index,\n speaker: window.speaker,\n timeMs,\n activeIndex,\n tokens,\n sinceStartMs: timeMs - window.startMs,\n untilEndMs: window.endMs - timeMs,\n holdRoomMs: window.endMs - window.speechEndMs,\n endsInSilence: window.endsInSilence,\n previous,\n };\n}\n\nfunction getExitWindowMs(state: CaptionsState, exitMs: number): number {\n return Math.max(1, Math.min(exitMs, state.holdRoomMs));\n}\n\nfunction groupCaptionWords(\n tokens: CaptionTokenState[],\n): { index: number; token: CaptionTokenState }[][] {\n const words: { index: number; token: CaptionTokenState }[][] = [];\n tokens.forEach((token, index) => {\n const current = words[words.length - 1];\n if (!current || token.spaceBefore) {\n words.push([{ index, token }]);\n } else {\n current.push({ index, token });\n }\n });\n return words;\n}\n\nfunction normalizeCaptionWord(text: string): string {\n return text\n .toLowerCase()\n .replace(/[\\u2018\\u2019]/g, \"'\")\n .replace(/[^\\p{L}\\p{N}']/gu, \"\");\n}\n\nfunction createKeywordMatcher(\n keywords: readonly string[] = [],\n): (text: string) => boolean {\n const set = new Set(keywords.map(normalizeCaptionWord).filter(Boolean));\n return (text) => set.has(normalizeCaptionWord(text));\n}\n\nfunction captionWordText(word: { token: CaptionTokenState }[]): string {\n return word.map(({ token }) => token.text).join(\"\");\n}\n\ninterface CaptionWordRect {\n left: number;\n top: number;\n width: number;\n height: number;\n}\n\nfunction sameRects(a: CaptionWordRect[], b: CaptionWordRect[]): boolean {\n return (\n a.length === b.length &&\n a.every(\n (r, i) =>\n r.left === b[i].left &&\n r.top === b[i].top &&\n r.width === b[i].width &&\n r.height === b[i].height,\n )\n );\n}\n\nfunction useCaptionWordRects(\n pageIndex: number,\n count: number,\n): {\n wordRef: (index: number) => (el: HTMLElement | null) => void;\n rects: CaptionWordRect[] | null;\n} {\n const elements = useRef<(HTMLElement | null)[]>([]);\n const [measured, setMeasured] = useState<{\n pageIndex: number;\n rects: CaptionWordRect[];\n } | null>(null);\n\n useLayoutEffect(() => {\n if (pageIndex === -1) return;\n const rects = elements.current.slice(0, count).map((el) =>\n el\n ? {\n left: el.offsetLeft,\n top: el.offsetTop,\n width: el.offsetWidth,\n height: el.offsetHeight,\n }\n : { left: 0, top: 0, width: 0, height: 0 },\n );\n setMeasured((prev) =>\n prev && prev.pageIndex === pageIndex && sameRects(prev.rects, rects)\n ? prev\n : { pageIndex, rects },\n );\n });\n\n return {\n wordRef: (index) => (el) => {\n elements.current[index] = el;\n },\n rects: measured && measured.pageIndex === pageIndex ? measured.rects : null,\n };\n}\n\nfunction useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs = DEFAULT_HOLD_MS,\n}: {\n captions: SpeakerCaption[];\n combineTokensWithinMilliseconds: number;\n holdMs?: number;\n}): CaptionsState | null {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const windows = useMemo(\n () =>\n buildCaptionPages(captions, { combineTokensWithinMilliseconds, holdMs }),\n [captions, combineTokensWithinMilliseconds, holdMs],\n );\n return getCaptionsState(windows, (frame / fps) * 1000);\n}\n\ninterface CaptionBounceInProps extends CaptionBaseProps {\n bounce?: number;\n shadow?: boolean;\n}\n\nconst EXIT_MS = 220;\nconst FADE_IN_MS = 90;\nconst DROP_EM = 0.35;\nconst START_SCALE = 0.7;\nconst LEGIBILITY_SHADOW =\n \"0 2px 3px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.35)\";\n\nfunction CaptionBounceInBase({\n captions,\n combineTokensWithinMilliseconds = 1200,\n holdMs = DEFAULT_HOLD_MS,\n fontSize = 64,\n fontWeight = 800,\n color = \"#ffffff\",\n bounce = 0.6,\n shadow = true,\n className,\n}: CaptionBounceInProps) {\n const { fps } = useVideoConfig();\n const state = useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs,\n });\n if (!state) return null;\n\n const damping = interpolate(bounce, [0, 1], [22, 7], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n });\n const exit = state.endsInSilence\n ? interpolate(\n state.untilEndMs,\n [0, getExitWindowMs(state, EXIT_MS)],\n [0, 1],\n {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n },\n )\n : 1;\n\n return (\n <div\n className={className}\n style={{\n fontSize,\n fontWeight,\n color,\n lineHeight: 1.2,\n textAlign: \"center\",\n opacity: exit,\n }}\n >\n {groupCaptionWords(state.tokens).map((word, w) => (\n <Fragment key={`${state.pageIndex}-${word[0].index}`}>\n {w > 0 && \" \"}\n <span style={{ display: \"inline-block\", whiteSpace: \"nowrap\" }}>\n {word.map(({ index, token }) => {\n const sinceMs = state.timeMs - token.fromMs;\n const arrived = sinceMs >= 0;\n const p = arrived\n ? spring({\n frame: (sinceMs / 1000) * fps,\n fps,\n config: { damping, stiffness: 220, mass: 0.6 },\n })\n : 0;\n const opacity = arrived\n ? interpolate(sinceMs, [0, FADE_IN_MS], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n })\n : 0;\n return (\n <span\n key={index}\n style={{\n display: \"inline-block\",\n opacity,\n transform: `translateY(${(1 - p) * DROP_EM}em) scale(${\n START_SCALE + (1 - START_SCALE) * p\n })`,\n transformOrigin: \"50% 80%\",\n textShadow: shadow ? LEGIBILITY_SHADOW : undefined,\n }}\n >\n {token.text}\n </span>\n );\n })}\n </span>\n </Fragment>\n ))}\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n captions: {\n type: \"remotion-captions\",\n default: [{\n text: \" So\",\n startMs: 300,\n endMs: 460,\n timestampMs: 380,\n confidence: 0.97,\n }, {\n text: \" here's\",\n startMs: 460,\n endMs: 700,\n timestampMs: 580,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 700,\n endMs: 820,\n timestampMs: 760,\n confidence: 0.97,\n }, {\n text: \" thing.\",\n startMs: 820,\n endMs: 1240,\n timestampMs: 1030,\n confidence: 0.97,\n }, {\n text: \" Most\",\n startMs: 1700,\n endMs: 1960,\n timestampMs: 1830,\n confidence: 0.97,\n }, {\n text: \" demo\",\n startMs: 1960,\n endMs: 2240,\n timestampMs: 2100,\n confidence: 0.97,\n }, {\n text: \" videos\",\n startMs: 2240,\n endMs: 2680,\n timestampMs: 2460,\n confidence: 0.97,\n }, {\n text: \" lose\",\n startMs: 2680,\n endMs: 2960,\n timestampMs: 2820,\n confidence: 0.97,\n }, {\n text: \" people\",\n startMs: 2960,\n endMs: 3320,\n timestampMs: 3140,\n confidence: 0.97,\n }, {\n text: \" in\",\n startMs: 3320,\n endMs: 3420,\n timestampMs: 3370,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 3420,\n endMs: 3520,\n timestampMs: 3470,\n confidence: 0.97,\n }, {\n text: \" first\",\n startMs: 3520,\n endMs: 3820,\n timestampMs: 3670,\n confidence: 0.97,\n }, {\n text: \" three\",\n startMs: 3820,\n endMs: 4100,\n timestampMs: 3960,\n confidence: 0.97,\n }, {\n text: \" seconds.\",\n startMs: 4100,\n endMs: 4780,\n timestampMs: 4440,\n confidence: 0.97,\n }, {\n text: \" Captions\",\n startMs: 5400,\n endMs: 5920,\n timestampMs: 5660,\n confidence: 0.97,\n }, {\n text: \" keep\",\n startMs: 5920,\n endMs: 6140,\n timestampMs: 6030,\n confidence: 0.97,\n }, {\n text: \" them\",\n startMs: 6140,\n endMs: 6300,\n timestampMs: 6220,\n confidence: 0.97,\n }, {\n text: \" watching,\",\n startMs: 6300,\n endMs: 6860,\n timestampMs: 6580,\n confidence: 0.97,\n }, {\n text: \" even\",\n startMs: 6960,\n endMs: 7180,\n timestampMs: 7070,\n confidence: 0.97,\n }, {\n text: \" with\",\n startMs: 7180,\n endMs: 7320,\n timestampMs: 7250,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 7320,\n endMs: 7420,\n timestampMs: 7370,\n confidence: 0.97,\n }, {\n text: \" sound\",\n startMs: 7420,\n endMs: 7760,\n timestampMs: 7590,\n confidence: 0.97,\n }, {\n text: \" off.\",\n startMs: 7760,\n endMs: 8300,\n timestampMs: 8030,\n confidence: 0.97,\n }],\n description: \"Transcript\",\n keyframable: false,\n },\n fontSize: {\n type: \"number\",\n min: 24,\n max: 140,\n step: 1,\n default: 64,\n description: \"Font size\",\n hiddenFromList: false,\n },\n fontWeight: {\n type: \"number\",\n min: 400,\n max: 900,\n step: 100,\n default: 800,\n description: \"Font weight\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#ffffff\",\n description: \"Text color\",\n },\n bounce: {\n type: \"number\",\n min: 0,\n max: 1,\n step: 0.05,\n default: 0.6,\n description: \"Bounce\",\n hiddenFromList: false,\n },\n combineTokensWithinMilliseconds: {\n type: \"number\",\n min: 0,\n max: 3000,\n step: 100,\n default: 1200,\n description: \"Page window (ms)\",\n hiddenFromList: false,\n },\n holdMs: {\n type: \"number\",\n min: 0,\n max: 2000,\n step: 50,\n default: 600,\n description: \"Hold (ms)\",\n hiddenFromList: false,\n },\n shadow: {\n type: \"boolean\",\n default: true,\n description: \"Shadow\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"captions\",\"fontSize\",\"fontWeight\",\"color\",\"bounce\",\"combineTokensWithinMilliseconds\",\"holdMs\",\"shadow\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n captions: [{\n text: \" So\",\n startMs: 300,\n endMs: 460,\n timestampMs: 380,\n confidence: 0.97,\n }, {\n text: \" here's\",\n startMs: 460,\n endMs: 700,\n timestampMs: 580,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 700,\n endMs: 820,\n timestampMs: 760,\n confidence: 0.97,\n }, {\n text: \" thing.\",\n startMs: 820,\n endMs: 1240,\n timestampMs: 1030,\n confidence: 0.97,\n }, {\n text: \" Most\",\n startMs: 1700,\n endMs: 1960,\n timestampMs: 1830,\n confidence: 0.97,\n }, {\n text: \" demo\",\n startMs: 1960,\n endMs: 2240,\n timestampMs: 2100,\n confidence: 0.97,\n }, {\n text: \" videos\",\n startMs: 2240,\n endMs: 2680,\n timestampMs: 2460,\n confidence: 0.97,\n }, {\n text: \" lose\",\n startMs: 2680,\n endMs: 2960,\n timestampMs: 2820,\n confidence: 0.97,\n }, {\n text: \" people\",\n startMs: 2960,\n endMs: 3320,\n timestampMs: 3140,\n confidence: 0.97,\n }, {\n text: \" in\",\n startMs: 3320,\n endMs: 3420,\n timestampMs: 3370,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 3420,\n endMs: 3520,\n timestampMs: 3470,\n confidence: 0.97,\n }, {\n text: \" first\",\n startMs: 3520,\n endMs: 3820,\n timestampMs: 3670,\n confidence: 0.97,\n }, {\n text: \" three\",\n startMs: 3820,\n endMs: 4100,\n timestampMs: 3960,\n confidence: 0.97,\n }, {\n text: \" seconds.\",\n startMs: 4100,\n endMs: 4780,\n timestampMs: 4440,\n confidence: 0.97,\n }, {\n text: \" Captions\",\n startMs: 5400,\n endMs: 5920,\n timestampMs: 5660,\n confidence: 0.97,\n }, {\n text: \" keep\",\n startMs: 5920,\n endMs: 6140,\n timestampMs: 6030,\n confidence: 0.97,\n }, {\n text: \" them\",\n startMs: 6140,\n endMs: 6300,\n timestampMs: 6220,\n confidence: 0.97,\n }, {\n text: \" watching,\",\n startMs: 6300,\n endMs: 6860,\n timestampMs: 6580,\n confidence: 0.97,\n }, {\n text: \" even\",\n startMs: 6960,\n endMs: 7180,\n timestampMs: 7070,\n confidence: 0.97,\n }, {\n text: \" with\",\n startMs: 7180,\n endMs: 7320,\n timestampMs: 7250,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 7320,\n endMs: 7420,\n timestampMs: 7370,\n confidence: 0.97,\n }, {\n text: \" sound\",\n startMs: 7420,\n endMs: 7760,\n timestampMs: 7590,\n confidence: 0.97,\n }, {\n text: \" off.\",\n startMs: 7760,\n endMs: 8300,\n timestampMs: 8030,\n confidence: 0.97,\n }],\n fontSize: 64,\n fontWeight: 800,\n color: \"#ffffff\",\n bounce: 0.6,\n combineTokensWithinMilliseconds: 1200,\n holdMs: 600,\n shadow: true,\n};\n\ntype CaptionBounceInElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof CaptionBounceInBase>;\n\nconst CaptionBounceInInner = forwardRef<\n HTMLDivElement,\n CaptionBounceInElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<CaptionBounceIn>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <CaptionBounceInBase\n {...(componentProps as unknown as ComponentProps<typeof CaptionBounceInBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const CaptionBounceIn = Interactive.withSchema({\n Component: CaptionBounceInInner,\n componentName: \"<CaptionBounceIn>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"+ },+ "durationInFrames": 279+}diff --git a/registry-artifacts/elements/caption-cube.json b/registry-artifacts/elements/caption-cube.jsonnew file mode 100644index 00000000..268fd2b4--- /dev/null+++ b/registry-artifacts/elements/caption-cube.json@@ -0,0 +1,21 @@+{+ "type": "remotion-element",+ "version": 1,+ "element": {+ "assets": [],+ "dependencies": [+ {+ "name": "@remotion/captions",+ "version": null+ }+ ],+ "dimensions": null,+ "displayName": "Caption Cube",+ "durationInFrames": 279,+ "initialProps": null,+ "installationMode": "component-owned-sequence",+ "slug": "caption-cube",+ "sourceCode": "import { Fragment, forwardRef, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState, type CSSProperties, type ComponentProps } from \"react\";\nimport { Easing, Interactive, Sequence, interpolate, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { createTikTokStyleCaptions, type Caption, type TikTokPage } from \"@remotion/captions\";\n\ntype SpeakerCaption = Caption & { speaker?: string };\n\ninterface CaptionBaseProps {\n captions: Caption[];\n combineTokensWithinMilliseconds?: number;\n holdMs?: number;\n fontSize?: number;\n fontWeight?: number;\n color?: string;\n className?: string;\n}\n\nconst DEFAULT_HOLD_MS = 600;\nconst MIN_SILENCE_BREAK_MS = 300;\n\ninterface CaptionPageWindow {\n page: TikTokPage;\n index: number;\n speaker: string | undefined;\n startMs: number;\n speechEndMs: number;\n endMs: number;\n endsInSilence: boolean;\n}\n\ntype CaptionTokenStatus = \"upcoming\" | \"active\" | \"spoken\";\n\ninterface CaptionTokenState {\n text: string;\n spaceBefore: boolean;\n fromMs: number;\n toMs: number;\n progress: number;\n status: CaptionTokenStatus;\n}\n\ninterface CaptionPreviousPage {\n page: TikTokPage;\n pageIndex: number;\n tokens: CaptionTokenState[];\n}\n\ninterface CaptionsState {\n page: TikTokPage;\n pageIndex: number;\n speaker: string | undefined;\n timeMs: number;\n activeIndex: number;\n tokens: CaptionTokenState[];\n sinceStartMs: number;\n untilEndMs: number;\n holdRoomMs: number;\n endsInSilence: boolean;\n previous: CaptionPreviousPage | null;\n}\n\ninterface CaptionPagingOptions {\n combineTokensWithinMilliseconds: number;\n holdMs?: number;\n}\n\nconst SENTENCE_END = /[.!?…][\"')\\]]*$/;\n\nfunction markPageBreaks(captions: SpeakerCaption[]): Caption[] {\n return captions.map((caption, i) => {\n if (caption.pageBreakAfter !== undefined) return caption;\n const next = captions[i + 1];\n const speakerChanges =\n next !== undefined && next.speaker !== caption.speaker;\n return speakerChanges || SENTENCE_END.test(caption.text.trim())\n ? { ...caption, pageBreakAfter: true }\n : caption;\n });\n}\n\nfunction buildCaptionPages(\n captions: SpeakerCaption[],\n {\n combineTokensWithinMilliseconds,\n holdMs = DEFAULT_HOLD_MS,\n }: CaptionPagingOptions,\n): CaptionPageWindow[] {\n if (captions.length === 0) return [];\n const { pages } = createTikTokStyleCaptions({\n captions: markPageBreaks(captions),\n combineTokensWithinMilliseconds,\n breakOnSilenceAfterMilliseconds: Math.max(holdMs, MIN_SILENCE_BREAK_MS),\n });\n const speakers = new Map<number, string | undefined>();\n for (const caption of captions) {\n if (!speakers.has(caption.startMs)) {\n speakers.set(caption.startMs, caption.speaker);\n }\n }\n const spoken = pages.filter((page) => page.tokens.length > 0);\n return spoken.map((page, index) => {\n const last = page.tokens[page.tokens.length - 1];\n const speechEndMs = last ? last.toMs : page.startMs;\n const heldUntil = speechEndMs + Math.max(0, holdMs);\n const next = spoken[index + 1];\n const endsInSilence = !next || next.startMs > heldUntil;\n const endMs = endsInSilence\n ? heldUntil\n : Math.max(page.startMs, next.startMs);\n return {\n page,\n index,\n speaker: speakers.get(page.tokens[0].fromMs),\n startMs: page.startMs,\n speechEndMs,\n endMs,\n endsInSilence,\n };\n });\n}\n\nfunction findWindowIndex(windows: CaptionPageWindow[], timeMs: number): number {\n let lo = 0;\n let hi = windows.length - 1;\n let found = -1;\n while (lo <= hi) {\n const mid = (lo + hi) >> 1;\n if (windows[mid].startMs <= timeMs) {\n found = mid;\n lo = mid + 1;\n } else {\n hi = mid - 1;\n }\n }\n if (found === -1) return -1;\n return timeMs < windows[found].endMs ? found : -1;\n}\n\nfunction tokenProgress(fromMs: number, toMs: number, timeMs: number): number {\n if (timeMs < fromMs) return 0;\n if (toMs <= fromMs) return 1;\n return Math.min(1, (timeMs - fromMs) / (toMs - fromMs));\n}\n\nfunction getTokenStates(\n page: TikTokPage,\n timeMs: number,\n): { activeIndex: number; tokens: CaptionTokenState[] } {\n let activeIndex = -1;\n page.tokens.forEach((token, i) => {\n if (token.fromMs <= timeMs) activeIndex = i;\n });\n const tokens = page.tokens.map(\n (token, i): CaptionTokenState => ({\n text: token.text.trim(),\n spaceBefore: i > 0 && /^\\s/.test(token.text),\n fromMs: token.fromMs,\n toMs: token.toMs,\n progress: tokenProgress(token.fromMs, token.toMs, timeMs),\n status:\n i < activeIndex ? \"spoken\" : i === activeIndex ? \"active\" : \"upcoming\",\n }),\n );\n return { activeIndex, tokens };\n}\n\nfunction getCaptionsState(\n windows: CaptionPageWindow[],\n timeMs: number,\n): CaptionsState | null {\n const found = findWindowIndex(windows, timeMs);\n if (found === -1) return null;\n const window = windows[found];\n const { activeIndex, tokens } = getTokenStates(window.page, timeMs);\n const before = found > 0 ? windows[found - 1] : null;\n const previous =\n before && !before.endsInSilence\n ? {\n page: before.page,\n pageIndex: before.index,\n tokens: getTokenStates(before.page, before.endMs).tokens,\n }\n : null;\n return {\n page: window.page,\n pageIndex: window.index,\n speaker: window.speaker,\n timeMs,\n activeIndex,\n tokens,\n sinceStartMs: timeMs - window.startMs,\n untilEndMs: window.endMs - timeMs,\n holdRoomMs: window.endMs - window.speechEndMs,\n endsInSilence: window.endsInSilence,\n previous,\n };\n}\n\nfunction getExitWindowMs(state: CaptionsState, exitMs: number): number {\n return Math.max(1, Math.min(exitMs, state.holdRoomMs));\n}\n\nfunction groupCaptionWords(\n tokens: CaptionTokenState[],\n): { index: number; token: CaptionTokenState }[][] {\n const words: { index: number; token: CaptionTokenState }[][] = [];\n tokens.forEach((token, index) => {\n const current = words[words.length - 1];\n if (!current || token.spaceBefore) {\n words.push([{ index, token }]);\n } else {\n current.push({ index, token });\n }\n });\n return words;\n}\n\nfunction normalizeCaptionWord(text: string): string {\n return text\n .toLowerCase()\n .replace(/[\\u2018\\u2019]/g, \"'\")\n .replace(/[^\\p{L}\\p{N}']/gu, \"\");\n}\n\nfunction createKeywordMatcher(\n keywords: readonly string[] = [],\n): (text: string) => boolean {\n const set = new Set(keywords.map(normalizeCaptionWord).filter(Boolean));\n return (text) => set.has(normalizeCaptionWord(text));\n}\n\nfunction captionWordText(word: { token: CaptionTokenState }[]): string {\n return word.map(({ token }) => token.text).join(\"\");\n}\n\ninterface CaptionWordRect {\n left: number;\n top: number;\n width: number;\n height: number;\n}\n\nfunction sameRects(a: CaptionWordRect[], b: CaptionWordRect[]): boolean {\n return (\n a.length === b.length &&\n a.every(\n (r, i) =>\n r.left === b[i].left &&\n r.top === b[i].top &&\n r.width === b[i].width &&\n r.height === b[i].height,\n )\n );\n}\n\nfunction useCaptionWordRects(\n pageIndex: number,\n count: number,\n): {\n wordRef: (index: number) => (el: HTMLElement | null) => void;\n rects: CaptionWordRect[] | null;\n} {\n const elements = useRef<(HTMLElement | null)[]>([]);\n const [measured, setMeasured] = useState<{\n pageIndex: number;\n rects: CaptionWordRect[];\n } | null>(null);\n\n useLayoutEffect(() => {\n if (pageIndex === -1) return;\n const rects = elements.current.slice(0, count).map((el) =>\n el\n ? {\n left: el.offsetLeft,\n top: el.offsetTop,\n width: el.offsetWidth,\n height: el.offsetHeight,\n }\n : { left: 0, top: 0, width: 0, height: 0 },\n );\n setMeasured((prev) =>\n prev && prev.pageIndex === pageIndex && sameRects(prev.rects, rects)\n ? prev\n : { pageIndex, rects },\n );\n });\n\n return {\n wordRef: (index) => (el) => {\n elements.current[index] = el;\n },\n rects: measured && measured.pageIndex === pageIndex ? measured.rects : null,\n };\n}\n\nfunction useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs = DEFAULT_HOLD_MS,\n}: {\n captions: SpeakerCaption[];\n combineTokensWithinMilliseconds: number;\n holdMs?: number;\n}): CaptionsState | null {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const windows = useMemo(\n () =>\n buildCaptionPages(captions, { combineTokensWithinMilliseconds, holdMs }),\n [captions, combineTokensWithinMilliseconds, holdMs],\n );\n return getCaptionsState(windows, (frame / fps) * 1000);\n}\n\ninterface CaptionCubeProps extends CaptionBaseProps {\n tintActive?: boolean;\n activeColor?: string;\n shadow?: boolean;\n}\n\nconst LINE_HEIGHT = 1.3;\nconst DEPTH_EM = LINE_HEIGHT / 2;\nconst TURN_MS = 320;\nconst EXIT_MS = 280;\nconst PERSPECTIVE_EM = 10;\nconst LEGIBILITY_SHADOW =\n \"0 2px 3px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.35)\";\n\nconst turnEasing = Easing.bezier(0.65, 0, 0.35, 1);\nconst exitEasing = Easing.bezier(0.7, 0, 0.84, 0);\n\nfunction CubeFace({\n tokens,\n activeIndex,\n activeColor,\n angle,\n before,\n style,\n}: {\n tokens: CaptionTokenState[];\n activeIndex: number;\n activeColor: string | undefined;\n angle: number;\n before: string;\n style?: CSSProperties;\n}) {\n const facing = Math.max(0, Math.cos((angle * Math.PI) / 180));\n return (\n <div\n style={{\n whiteSpace: \"nowrap\",\n backfaceVisibility: \"hidden\",\n WebkitBackfaceVisibility: \"hidden\",\n opacity: 0.35 + 0.65 * facing,\n transform: `${before}rotateX(${angle}deg) translateZ(${DEPTH_EM}em)`,\n ...style,\n }}\n >\n {groupCaptionWords(tokens).map((word, w) => (\n <Fragment key={word[0].index}>\n {w > 0 && \" \"}\n {word.map(({ index, token }) => (\n <span\n key={index}\n style={{\n color:\n activeColor !== undefined && index === activeIndex\n ? activeColor\n : undefined,\n }}\n >\n {token.text}\n </span>\n ))}\n </Fragment>\n ))}\n </div>\n );\n}\n\nfunction CaptionCubeBase({\n captions,\n combineTokensWithinMilliseconds = 800,\n holdMs = DEFAULT_HOLD_MS,\n fontSize = 64,\n fontWeight = 800,\n color = \"#ffffff\",\n tintActive = false,\n activeColor = \"#facc15\",\n shadow = true,\n className,\n}: CaptionCubeProps) {\n const state = useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs,\n });\n if (!state) return null;\n\n const turnMs = Math.max(\n 1,\n Math.min(TURN_MS, state.sinceStartMs + state.untilEndMs),\n );\n const turn = interpolate(state.sinceStartMs, [0, turnMs], [0, 1], {\n easing: turnEasing,\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n });\n const exitProgress = state.endsInSilence\n ? exitEasing(\n Math.min(\n 1,\n Math.max(0, 1 - state.untilEndMs / getExitWindowMs(state, EXIT_MS)),\n ),\n )\n : 0;\n const currentAngle = (turn - 1) * 90 + exitProgress * 90;\n\n return (\n <div\n className={className}\n style={{\n position: \"relative\",\n fontSize,\n fontWeight,\n color,\n lineHeight: LINE_HEIGHT,\n height: `${LINE_HEIGHT}em`,\n textAlign: \"center\",\n textShadow: shadow ? LEGIBILITY_SHADOW : undefined,\n perspective: `${PERSPECTIVE_EM}em`,\n }}\n >\n <div\n style={{\n position: \"relative\",\n height: \"100%\",\n transformStyle: \"preserve-3d\",\n transform: `translateZ(${-DEPTH_EM}em)`,\n }}\n >\n {state.previous && turn < 1 ? (\n <CubeFace\n key={`page-${state.previous.pageIndex}`}\n tokens={state.previous.tokens}\n activeIndex={-1}\n activeColor={undefined}\n angle={turn * 90}\n before=\"translateX(-50%) \"\n style={{ position: \"absolute\", top: 0, left: \"50%\" }}\n />\n ) : null}\n <CubeFace\n key={`page-${state.pageIndex}`}\n tokens={state.tokens}\n activeIndex={state.activeIndex}\n activeColor={tintActive ? activeColor : undefined}\n angle={currentAngle}\n before=\"\"\n />\n </div>\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n captions: {\n type: \"remotion-captions\",\n default: [{\n text: \" So\",\n startMs: 300,\n endMs: 460,\n timestampMs: 380,\n confidence: 0.97,\n }, {\n text: \" here's\",\n startMs: 460,\n endMs: 700,\n timestampMs: 580,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 700,\n endMs: 820,\n timestampMs: 760,\n confidence: 0.97,\n }, {\n text: \" thing.\",\n startMs: 820,\n endMs: 1240,\n timestampMs: 1030,\n confidence: 0.97,\n }, {\n text: \" Most\",\n startMs: 1700,\n endMs: 1960,\n timestampMs: 1830,\n confidence: 0.97,\n }, {\n text: \" demo\",\n startMs: 1960,\n endMs: 2240,\n timestampMs: 2100,\n confidence: 0.97,\n }, {\n text: \" videos\",\n startMs: 2240,\n endMs: 2680,\n timestampMs: 2460,\n confidence: 0.97,\n }, {\n text: \" lose\",\n startMs: 2680,\n endMs: 2960,\n timestampMs: 2820,\n confidence: 0.97,\n }, {\n text: \" people\",\n startMs: 2960,\n endMs: 3320,\n timestampMs: 3140,\n confidence: 0.97,\n }, {\n text: \" in\",\n startMs: 3320,\n endMs: 3420,\n timestampMs: 3370,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 3420,\n endMs: 3520,\n timestampMs: 3470,\n confidence: 0.97,\n }, {\n text: \" first\",\n startMs: 3520,\n endMs: 3820,\n timestampMs: 3670,\n confidence: 0.97,\n }, {\n text: \" three\",\n startMs: 3820,\n endMs: 4100,\n timestampMs: 3960,\n confidence: 0.97,\n }, {\n text: \" seconds.\",\n startMs: 4100,\n endMs: 4780,\n timestampMs: 4440,\n confidence: 0.97,\n }, {\n text: \" Captions\",\n startMs: 5400,\n endMs: 5920,\n timestampMs: 5660,\n confidence: 0.97,\n }, {\n text: \" keep\",\n startMs: 5920,\n endMs: 6140,\n timestampMs: 6030,\n confidence: 0.97,\n }, {\n text: \" them\",\n startMs: 6140,\n endMs: 6300,\n timestampMs: 6220,\n confidence: 0.97,\n }, {\n text: \" watching,\",\n startMs: 6300,\n endMs: 6860,\n timestampMs: 6580,\n confidence: 0.97,\n }, {\n text: \" even\",\n startMs: 6960,\n endMs: 7180,\n timestampMs: 7070,\n confidence: 0.97,\n }, {\n text: \" with\",\n startMs: 7180,\n endMs: 7320,\n timestampMs: 7250,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 7320,\n endMs: 7420,\n timestampMs: 7370,\n confidence: 0.97,\n }, {\n text: \" sound\",\n startMs: 7420,\n endMs: 7760,\n timestampMs: 7590,\n confidence: 0.97,\n }, {\n text: \" off.\",\n startMs: 7760,\n endMs: 8300,\n timestampMs: 8030,\n confidence: 0.97,\n }],\n description: \"Transcript\",\n keyframable: false,\n },\n fontSize: {\n type: \"number\",\n min: 24,\n max: 140,\n step: 1,\n default: 64,\n description: \"Font size\",\n hiddenFromList: false,\n },\n fontWeight: {\n type: \"number\",\n min: 400,\n max: 900,\n step: 100,\n default: 800,\n description: \"Font weight\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#ffffff\",\n description: \"Text color\",\n },\n tintActive: {\n type: \"boolean\",\n default: false,\n description: \"Tint active word\",\n },\n activeColor: {\n type: \"color\",\n default: \"#facc15\",\n description: \"Active color\",\n },\n combineTokensWithinMilliseconds: {\n type: \"number\",\n min: 0,\n max: 3000,\n step: 100,\n default: 800,\n description: \"Page window (ms)\",\n hiddenFromList: false,\n },\n holdMs: {\n type: \"number\",\n min: 0,\n max: 2000,\n step: 50,\n default: 600,\n description: \"Hold (ms)\",\n hiddenFromList: false,\n },\n shadow: {\n type: \"boolean\",\n default: true,\n description: \"Shadow\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"captions\",\"fontSize\",\"fontWeight\",\"color\",\"tintActive\",\"activeColor\",\"combineTokensWithinMilliseconds\",\"holdMs\",\"shadow\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n captions: [{\n text: \" So\",\n startMs: 300,\n endMs: 460,\n timestampMs: 380,\n confidence: 0.97,\n }, {\n text: \" here's\",\n startMs: 460,\n endMs: 700,\n timestampMs: 580,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 700,\n endMs: 820,\n timestampMs: 760,\n confidence: 0.97,\n }, {\n text: \" thing.\",\n startMs: 820,\n endMs: 1240,\n timestampMs: 1030,\n confidence: 0.97,\n }, {\n text: \" Most\",\n startMs: 1700,\n endMs: 1960,\n timestampMs: 1830,\n confidence: 0.97,\n }, {\n text: \" demo\",\n startMs: 1960,\n endMs: 2240,\n timestampMs: 2100,\n confidence: 0.97,\n }, {\n text: \" videos\",\n startMs: 2240,\n endMs: 2680,\n timestampMs: 2460,\n confidence: 0.97,\n }, {\n text: \" lose\",\n startMs: 2680,\n endMs: 2960,\n timestampMs: 2820,\n confidence: 0.97,\n }, {\n text: \" people\",\n startMs: 2960,\n endMs: 3320,\n timestampMs: 3140,\n confidence: 0.97,\n }, {\n text: \" in\",\n startMs: 3320,\n endMs: 3420,\n timestampMs: 3370,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 3420,\n endMs: 3520,\n timestampMs: 3470,\n confidence: 0.97,\n }, {\n text: \" first\",\n startMs: 3520,\n endMs: 3820,\n timestampMs: 3670,\n confidence: 0.97,\n }, {\n text: \" three\",\n startMs: 3820,\n endMs: 4100,\n timestampMs: 3960,\n confidence: 0.97,\n }, {\n text: \" seconds.\",\n startMs: 4100,\n endMs: 4780,\n timestampMs: 4440,\n confidence: 0.97,\n }, {\n text: \" Captions\",\n startMs: 5400,\n endMs: 5920,\n timestampMs: 5660,\n confidence: 0.97,\n }, {\n text: \" keep\",\n startMs: 5920,\n endMs: 6140,\n timestampMs: 6030,\n confidence: 0.97,\n }, {\n text: \" them\",\n startMs: 6140,\n endMs: 6300,\n timestampMs: 6220,\n confidence: 0.97,\n }, {\n text: \" watching,\",\n startMs: 6300,\n endMs: 6860,\n timestampMs: 6580,\n confidence: 0.97,\n }, {\n text: \" even\",\n startMs: 6960,\n endMs: 7180,\n timestampMs: 7070,\n confidence: 0.97,\n }, {\n text: \" with\",\n startMs: 7180,\n endMs: 7320,\n timestampMs: 7250,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 7320,\n endMs: 7420,\n timestampMs: 7370,\n confidence: 0.97,\n }, {\n text: \" sound\",\n startMs: 7420,\n endMs: 7760,\n timestampMs: 7590,\n confidence: 0.97,\n }, {\n text: \" off.\",\n startMs: 7760,\n endMs: 8300,\n timestampMs: 8030,\n confidence: 0.97,\n }],\n fontSize: 64,\n fontWeight: 800,\n color: \"#ffffff\",\n tintActive: false,\n activeColor: \"#facc15\",\n combineTokensWithinMilliseconds: 800,\n holdMs: 600,\n shadow: true,\n};\n\ntype CaptionCubeElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof CaptionCubeBase>;\n\nconst CaptionCubeInner = forwardRef<\n HTMLDivElement,\n CaptionCubeElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<CaptionCube>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <CaptionCubeBase\n {...(componentProps as unknown as ComponentProps<typeof CaptionCubeBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const CaptionCube = Interactive.withSchema({\n Component: CaptionCubeInner,\n componentName: \"<CaptionCube>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"+ },+ "durationInFrames": 279+}diff --git a/registry-artifacts/elements/caption-dim-progress.json b/registry-artifacts/elements/caption-dim-progress.jsonnew file mode 100644index 00000000..0d653e19--- /dev/null+++ b/registry-artifacts/elements/caption-dim-progress.json@@ -0,0 +1,21 @@+{+ "type": "remotion-element",+ "version": 1,+ "element": {+ "assets": [],+ "dependencies": [+ {+ "name": "@remotion/captions",+ "version": null+ }+ ],+ "dimensions": null,+ "displayName": "Caption Dim Progress",+ "durationInFrames": 279,+ "initialProps": null,+ "installationMode": "component-owned-sequence",+ "slug": "caption-dim-progress",+ "sourceCode": "import { Fragment, forwardRef, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState, type ComponentProps } from \"react\";\nimport { Easing, Interactive, Sequence, interpolate, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { createTikTokStyleCaptions, type Caption, type TikTokPage } from \"@remotion/captions\";\n\ntype SpeakerCaption = Caption & { speaker?: string };\n\ninterface CaptionBaseProps {\n captions: Caption[];\n combineTokensWithinMilliseconds?: number;\n holdMs?: number;\n fontSize?: number;\n fontWeight?: number;\n color?: string;\n className?: string;\n}\n\nconst DEFAULT_HOLD_MS = 600;\nconst MIN_SILENCE_BREAK_MS = 300;\n\ninterface CaptionPageWindow {\n page: TikTokPage;\n index: number;\n speaker: string | undefined;\n startMs: number;\n speechEndMs: number;\n endMs: number;\n endsInSilence: boolean;\n}\n\ntype CaptionTokenStatus = \"upcoming\" | \"active\" | \"spoken\";\n\ninterface CaptionTokenState {\n text: string;\n spaceBefore: boolean;\n fromMs: number;\n toMs: number;\n progress: number;\n status: CaptionTokenStatus;\n}\n\ninterface CaptionPreviousPage {\n page: TikTokPage;\n pageIndex: number;\n tokens: CaptionTokenState[];\n}\n\ninterface CaptionsState {\n page: TikTokPage;\n pageIndex: number;\n speaker: string | undefined;\n timeMs: number;\n activeIndex: number;\n tokens: CaptionTokenState[];\n sinceStartMs: number;\n untilEndMs: number;\n holdRoomMs: number;\n endsInSilence: boolean;\n previous: CaptionPreviousPage | null;\n}\n\ninterface CaptionPagingOptions {\n combineTokensWithinMilliseconds: number;\n holdMs?: number;\n}\n\nconst SENTENCE_END = /[.!?…][\"')\\]]*$/;\n\nfunction markPageBreaks(captions: SpeakerCaption[]): Caption[] {\n return captions.map((caption, i) => {\n if (caption.pageBreakAfter !== undefined) return caption;\n const next = captions[i + 1];\n const speakerChanges =\n next !== undefined && next.speaker !== caption.speaker;\n return speakerChanges || SENTENCE_END.test(caption.text.trim())\n ? { ...caption, pageBreakAfter: true }\n : caption;\n });\n}\n\nfunction buildCaptionPages(\n captions: SpeakerCaption[],\n {\n combineTokensWithinMilliseconds,\n holdMs = DEFAULT_HOLD_MS,\n }: CaptionPagingOptions,\n): CaptionPageWindow[] {\n if (captions.length === 0) return [];\n const { pages } = createTikTokStyleCaptions({\n captions: markPageBreaks(captions),\n combineTokensWithinMilliseconds,\n breakOnSilenceAfterMilliseconds: Math.max(holdMs, MIN_SILENCE_BREAK_MS),\n });\n const speakers = new Map<number, string | undefined>();\n for (const caption of captions) {\n if (!speakers.has(caption.startMs)) {\n speakers.set(caption.startMs, caption.speaker);\n }\n }\n const spoken = pages.filter((page) => page.tokens.length > 0);\n return spoken.map((page, index) => {\n const last = page.tokens[page.tokens.length - 1];\n const speechEndMs = last ? last.toMs : page.startMs;\n const heldUntil = speechEndMs + Math.max(0, holdMs);\n const next = spoken[index + 1];\n const endsInSilence = !next || next.startMs > heldUntil;\n const endMs = endsInSilence\n ? heldUntil\n : Math.max(page.startMs, next.startMs);\n return {\n page,\n index,\n speaker: speakers.get(page.tokens[0].fromMs),\n startMs: page.startMs,\n speechEndMs,\n endMs,\n endsInSilence,\n };\n });\n}\n\nfunction findWindowIndex(windows: CaptionPageWindow[], timeMs: number): number {\n let lo = 0;\n let hi = windows.length - 1;\n let found = -1;\n while (lo <= hi) {\n const mid = (lo + hi) >> 1;\n if (windows[mid].startMs <= timeMs) {\n found = mid;\n lo = mid + 1;\n } else {\n hi = mid - 1;\n }\n }\n if (found === -1) return -1;\n return timeMs < windows[found].endMs ? found : -1;\n}\n\nfunction tokenProgress(fromMs: number, toMs: number, timeMs: number): number {\n if (timeMs < fromMs) return 0;\n if (toMs <= fromMs) return 1;\n return Math.min(1, (timeMs - fromMs) / (toMs - fromMs));\n}\n\nfunction getTokenStates(\n page: TikTokPage,\n timeMs: number,\n): { activeIndex: number; tokens: CaptionTokenState[] } {\n let activeIndex = -1;\n page.tokens.forEach((token, i) => {\n if (token.fromMs <= timeMs) activeIndex = i;\n });\n const tokens = page.tokens.map(\n (token, i): CaptionTokenState => ({\n text: token.text.trim(),\n spaceBefore: i > 0 && /^\\s/.test(token.text),\n fromMs: token.fromMs,\n toMs: token.toMs,\n progress: tokenProgress(token.fromMs, token.toMs, timeMs),\n status:\n i < activeIndex ? \"spoken\" : i === activeIndex ? \"active\" : \"upcoming\",\n }),\n );\n return { activeIndex, tokens };\n}\n\nfunction getCaptionsState(\n windows: CaptionPageWindow[],\n timeMs: number,\n): CaptionsState | null {\n const found = findWindowIndex(windows, timeMs);\n if (found === -1) return null;\n const window = windows[found];\n const { activeIndex, tokens } = getTokenStates(window.page, timeMs);\n const before = found > 0 ? windows[found - 1] : null;\n const previous =\n before && !before.endsInSilence\n ? {\n page: before.page,\n pageIndex: before.index,\n tokens: getTokenStates(before.page, before.endMs).tokens,\n }\n : null;\n return {\n page: window.page,\n pageIndex: window.index,\n speaker: window.speaker,\n timeMs,\n activeIndex,\n tokens,\n sinceStartMs: timeMs - window.startMs,\n untilEndMs: window.endMs - timeMs,\n holdRoomMs: window.endMs - window.speechEndMs,\n endsInSilence: window.endsInSilence,\n previous,\n };\n}\n\nfunction getExitWindowMs(state: CaptionsState, exitMs: number): number {\n return Math.max(1, Math.min(exitMs, state.holdRoomMs));\n}\n\nfunction groupCaptionWords(\n tokens: CaptionTokenState[],\n): { index: number; token: CaptionTokenState }[][] {\n const words: { index: number; token: CaptionTokenState }[][] = [];\n tokens.forEach((token, index) => {\n const current = words[words.length - 1];\n if (!current || token.spaceBefore) {\n words.push([{ index, token }]);\n } else {\n current.push({ index, token });\n }\n });\n return words;\n}\n\nfunction normalizeCaptionWord(text: string): string {\n return text\n .toLowerCase()\n .replace(/[\\u2018\\u2019]/g, \"'\")\n .replace(/[^\\p{L}\\p{N}']/gu, \"\");\n}\n\nfunction createKeywordMatcher(\n keywords: readonly string[] = [],\n): (text: string) => boolean {\n const set = new Set(keywords.map(normalizeCaptionWord).filter(Boolean));\n return (text) => set.has(normalizeCaptionWord(text));\n}\n\nfunction captionWordText(word: { token: CaptionTokenState }[]): string {\n return word.map(({ token }) => token.text).join(\"\");\n}\n\ninterface CaptionWordRect {\n left: number;\n top: number;\n width: number;\n height: number;\n}\n\nfunction sameRects(a: CaptionWordRect[], b: CaptionWordRect[]): boolean {\n return (\n a.length === b.length &&\n a.every(\n (r, i) =>\n r.left === b[i].left &&\n r.top === b[i].top &&\n r.width === b[i].width &&\n r.height === b[i].height,\n )\n );\n}\n\nfunction useCaptionWordRects(\n pageIndex: number,\n count: number,\n): {\n wordRef: (index: number) => (el: HTMLElement | null) => void;\n rects: CaptionWordRect[] | null;\n} {\n const elements = useRef<(HTMLElement | null)[]>([]);\n const [measured, setMeasured] = useState<{\n pageIndex: number;\n rects: CaptionWordRect[];\n } | null>(null);\n\n useLayoutEffect(() => {\n if (pageIndex === -1) return;\n const rects = elements.current.slice(0, count).map((el) =>\n el\n ? {\n left: el.offsetLeft,\n top: el.offsetTop,\n width: el.offsetWidth,\n height: el.offsetHeight,\n }\n : { left: 0, top: 0, width: 0, height: 0 },\n );\n setMeasured((prev) =>\n prev && prev.pageIndex === pageIndex && sameRects(prev.rects, rects)\n ? prev\n : { pageIndex, rects },\n );\n });\n\n return {\n wordRef: (index) => (el) => {\n elements.current[index] = el;\n },\n rects: measured && measured.pageIndex === pageIndex ? measured.rects : null,\n };\n}\n\nfunction useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs = DEFAULT_HOLD_MS,\n}: {\n captions: SpeakerCaption[];\n combineTokensWithinMilliseconds: number;\n holdMs?: number;\n}): CaptionsState | null {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const windows = useMemo(\n () =>\n buildCaptionPages(captions, { combineTokensWithinMilliseconds, holdMs }),\n [captions, combineTokensWithinMilliseconds, holdMs],\n );\n return getCaptionsState(windows, (frame / fps) * 1000);\n}\n\ninterface CaptionDimProgressProps extends CaptionBaseProps {\n dimOpacity?: number;\n shadow?: boolean;\n}\n\nconst ENTER_MS = 160;\nconst EXIT_MS = 220;\nconst RISE_EM = 0.14;\nconst BRIGHTEN_MS = 90;\nconst LEGIBILITY_SHADOW =\n \"0 2px 3px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.35)\";\n\nconst enterEasing = Easing.bezier(0.2, 0.8, 0.2, 1);\n\nconst clamp = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n} as const;\n\nfunction CaptionDimProgressBase({\n captions,\n combineTokensWithinMilliseconds = 1200,\n holdMs = DEFAULT_HOLD_MS,\n fontSize = 64,\n fontWeight = 800,\n color = \"#ffffff\",\n dimOpacity = 0.35,\n shadow = true,\n className,\n}: CaptionDimProgressProps) {\n const state = useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs,\n });\n if (!state) return null;\n\n const enter = interpolate(\n state.previous ? ENTER_MS : state.sinceStartMs,\n [0, ENTER_MS],\n [0, 1],\n {\n ...clamp,\n easing: enterEasing,\n },\n );\n const exit = state.endsInSilence\n ? interpolate(\n state.untilEndMs,\n [0, getExitWindowMs(state, EXIT_MS)],\n [0, 1],\n clamp,\n )\n : 1;\n\n return (\n <div\n className={className}\n style={{\n fontSize,\n fontWeight,\n color,\n lineHeight: 1.2,\n textAlign: \"center\",\n opacity: Math.min(enter, exit),\n transform: `translateY(${(1 - enter) * RISE_EM}em)`,\n }}\n >\n {groupCaptionWords(state.tokens).map((word, w) => (\n <Fragment key={`${state.pageIndex}-${word[0].index}`}>\n {w > 0 && \" \"}\n <span style={{ display: \"inline-block\", whiteSpace: \"nowrap\" }}>\n {word.map(({ index, token }) => (\n <span\n key={index}\n style={{\n opacity: interpolate(\n state.timeMs - token.fromMs,\n [0, BRIGHTEN_MS],\n [dimOpacity, 1],\n clamp,\n ),\n textShadow: shadow ? LEGIBILITY_SHADOW : undefined,\n }}\n >\n {token.text}\n </span>\n ))}\n </span>\n </Fragment>\n ))}\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n captions: {\n type: \"remotion-captions\",\n default: [{\n text: \" So\",\n startMs: 300,\n endMs: 460,\n timestampMs: 380,\n confidence: 0.97,\n }, {\n text: \" here's\",\n startMs: 460,\n endMs: 700,\n timestampMs: 580,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 700,\n endMs: 820,\n timestampMs: 760,\n confidence: 0.97,\n }, {\n text: \" thing.\",\n startMs: 820,\n endMs: 1240,\n timestampMs: 1030,\n confidence: 0.97,\n }, {\n text: \" Most\",\n startMs: 1700,\n endMs: 1960,\n timestampMs: 1830,\n confidence: 0.97,\n }, {\n text: \" demo\",\n startMs: 1960,\n endMs: 2240,\n timestampMs: 2100,\n confidence: 0.97,\n }, {\n text: \" videos\",\n startMs: 2240,\n endMs: 2680,\n timestampMs: 2460,\n confidence: 0.97,\n }, {\n text: \" lose\",\n startMs: 2680,\n endMs: 2960,\n timestampMs: 2820,\n confidence: 0.97,\n }, {\n text: \" people\",\n startMs: 2960,\n endMs: 3320,\n timestampMs: 3140,\n confidence: 0.97,\n }, {\n text: \" in\",\n startMs: 3320,\n endMs: 3420,\n timestampMs: 3370,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 3420,\n endMs: 3520,\n timestampMs: 3470,\n confidence: 0.97,\n }, {\n text: \" first\",\n startMs: 3520,\n endMs: 3820,\n timestampMs: 3670,\n confidence: 0.97,\n }, {\n text: \" three\",\n startMs: 3820,\n endMs: 4100,\n timestampMs: 3960,\n confidence: 0.97,\n }, {\n text: \" seconds.\",\n startMs: 4100,\n endMs: 4780,\n timestampMs: 4440,\n confidence: 0.97,\n }, {\n text: \" Captions\",\n startMs: 5400,\n endMs: 5920,\n timestampMs: 5660,\n confidence: 0.97,\n }, {\n text: \" keep\",\n startMs: 5920,\n endMs: 6140,\n timestampMs: 6030,\n confidence: 0.97,\n }, {\n text: \" them\",\n startMs: 6140,\n endMs: 6300,\n timestampMs: 6220,\n confidence: 0.97,\n }, {\n text: \" watching,\",\n startMs: 6300,\n endMs: 6860,\n timestampMs: 6580,\n confidence: 0.97,\n }, {\n text: \" even\",\n startMs: 6960,\n endMs: 7180,\n timestampMs: 7070,\n confidence: 0.97,\n }, {\n text: \" with\",\n startMs: 7180,\n endMs: 7320,\n timestampMs: 7250,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 7320,\n endMs: 7420,\n timestampMs: 7370,\n confidence: 0.97,\n }, {\n text: \" sound\",\n startMs: 7420,\n endMs: 7760,\n timestampMs: 7590,\n confidence: 0.97,\n }, {\n text: \" off.\",\n startMs: 7760,\n endMs: 8300,\n timestampMs: 8030,\n confidence: 0.97,\n }],\n description: \"Transcript\",\n keyframable: false,\n },\n fontSize: {\n type: \"number\",\n min: 24,\n max: 140,\n step: 1,\n default: 64,\n description: \"Font size\",\n hiddenFromList: false,\n },\n fontWeight: {\n type: \"number\",\n min: 400,\n max: 900,\n step: 100,\n default: 800,\n description: \"Font weight\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#ffffff\",\n description: \"Text color\",\n },\n dimOpacity: {\n type: \"number\",\n min: 0,\n max: 1,\n step: 0.05,\n default: 0.35,\n description: \"Upcoming opacity\",\n hiddenFromList: false,\n },\n combineTokensWithinMilliseconds: {\n type: \"number\",\n min: 0,\n max: 3000,\n step: 100,\n default: 1200,\n description: \"Page window (ms)\",\n hiddenFromList: false,\n },\n holdMs: {\n type: \"number\",\n min: 0,\n max: 2000,\n step: 50,\n default: 600,\n description: \"Hold (ms)\",\n hiddenFromList: false,\n },\n shadow: {\n type: \"boolean\",\n default: true,\n description: \"Shadow\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"captions\",\"fontSize\",\"fontWeight\",\"color\",\"dimOpacity\",\"combineTokensWithinMilliseconds\",\"holdMs\",\"shadow\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n captions: [{\n text: \" So\",\n startMs: 300,\n endMs: 460,\n timestampMs: 380,\n confidence: 0.97,\n }, {\n text: \" here's\",\n startMs: 460,\n endMs: 700,\n timestampMs: 580,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 700,\n endMs: 820,\n timestampMs: 760,\n confidence: 0.97,\n }, {\n text: \" thing.\",\n startMs: 820,\n endMs: 1240,\n timestampMs: 1030,\n confidence: 0.97,\n }, {\n text: \" Most\",\n startMs: 1700,\n endMs: 1960,\n timestampMs: 1830,\n confidence: 0.97,\n }, {\n text: \" demo\",\n startMs: 1960,\n endMs: 2240,\n timestampMs: 2100,\n confidence: 0.97,\n }, {\n text: \" videos\",\n startMs: 2240,\n endMs: 2680,\n timestampMs: 2460,\n confidence: 0.97,\n }, {\n text: \" lose\",\n startMs: 2680,\n endMs: 2960,\n timestampMs: 2820,\n confidence: 0.97,\n }, {\n text: \" people\",\n startMs: 2960,\n endMs: 3320,\n timestampMs: 3140,\n confidence: 0.97,\n }, {\n text: \" in\",\n startMs: 3320,\n endMs: 3420,\n timestampMs: 3370,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 3420,\n endMs: 3520,\n timestampMs: 3470,\n confidence: 0.97,\n }, {\n text: \" first\",\n startMs: 3520,\n endMs: 3820,\n timestampMs: 3670,\n confidence: 0.97,\n }, {\n text: \" three\",\n startMs: 3820,\n endMs: 4100,\n timestampMs: 3960,\n confidence: 0.97,\n }, {\n text: \" seconds.\",\n startMs: 4100,\n endMs: 4780,\n timestampMs: 4440,\n confidence: 0.97,\n }, {\n text: \" Captions\",\n startMs: 5400,\n endMs: 5920,\n timestampMs: 5660,\n confidence: 0.97,\n }, {\n text: \" keep\",\n startMs: 5920,\n endMs: 6140,\n timestampMs: 6030,\n confidence: 0.97,\n }, {\n text: \" them\",\n startMs: 6140,\n endMs: 6300,\n timestampMs: 6220,\n confidence: 0.97,\n }, {\n text: \" watching,\",\n startMs: 6300,\n endMs: 6860,\n timestampMs: 6580,\n confidence: 0.97,\n }, {\n text: \" even\",\n startMs: 6960,\n endMs: 7180,\n timestampMs: 7070,\n confidence: 0.97,\n }, {\n text: \" with\",\n startMs: 7180,\n endMs: 7320,\n timestampMs: 7250,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 7320,\n endMs: 7420,\n timestampMs: 7370,\n confidence: 0.97,\n }, {\n text: \" sound\",\n startMs: 7420,\n endMs: 7760,\n timestampMs: 7590,\n confidence: 0.97,\n }, {\n text: \" off.\",\n startMs: 7760,\n endMs: 8300,\n timestampMs: 8030,\n confidence: 0.97,\n }],\n fontSize: 64,\n fontWeight: 800,\n color: \"#ffffff\",\n dimOpacity: 0.35,\n combineTokensWithinMilliseconds: 1200,\n holdMs: 600,\n shadow: true,\n};\n\ntype CaptionDimProgressElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof CaptionDimProgressBase>;\n\nconst CaptionDimProgressInner = forwardRef<\n HTMLDivElement,\n CaptionDimProgressElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<CaptionDimProgress>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <CaptionDimProgressBase\n {...(componentProps as unknown as ComponentProps<typeof CaptionDimProgressBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const CaptionDimProgress = Interactive.withSchema({\n Component: CaptionDimProgressInner,\n componentName: \"<CaptionDimProgress>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"+ },+ "durationInFrames": 279+}diff --git a/registry-artifacts/elements/caption-drop.json b/registry-artifacts/elements/caption-drop.jsonnew file mode 100644index 00000000..30dbcb9d--- /dev/null+++ b/registry-artifacts/elements/caption-drop.json@@ -0,0 +1,21 @@+{+ "type": "remotion-element",+ "version": 1,+ "element": {+ "assets": [],+ "dependencies": [+ {+ "name": "@remotion/captions",+ "version": null+ }+ ],+ "dimensions": null,+ "displayName": "Caption Drop",+ "durationInFrames": 279,+ "initialProps": null,+ "installationMode": "component-owned-sequence",+ "slug": "caption-drop",+ "sourceCode": "import { Fragment, forwardRef, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState, type ComponentProps } from \"react\";\nimport { Interactive, Sequence, interpolate, random, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { createTikTokStyleCaptions, type Caption, type TikTokPage } from \"@remotion/captions\";\n\ntype SpeakerCaption = Caption & { speaker?: string };\n\ninterface CaptionBaseProps {\n captions: Caption[];\n combineTokensWithinMilliseconds?: number;\n holdMs?: number;\n fontSize?: number;\n fontWeight?: number;\n color?: string;\n className?: string;\n}\n\nconst DEFAULT_HOLD_MS = 600;\nconst MIN_SILENCE_BREAK_MS = 300;\n\ninterface CaptionPageWindow {\n page: TikTokPage;\n index: number;\n speaker: string | undefined;\n startMs: number;\n speechEndMs: number;\n endMs: number;\n endsInSilence: boolean;\n}\n\ntype CaptionTokenStatus = \"upcoming\" | \"active\" | \"spoken\";\n\ninterface CaptionTokenState {\n text: string;\n spaceBefore: boolean;\n fromMs: number;\n toMs: number;\n progress: number;\n status: CaptionTokenStatus;\n}\n\ninterface CaptionPreviousPage {\n page: TikTokPage;\n pageIndex: number;\n tokens: CaptionTokenState[];\n}\n\ninterface CaptionsState {\n page: TikTokPage;\n pageIndex: number;\n speaker: string | undefined;\n timeMs: number;\n activeIndex: number;\n tokens: CaptionTokenState[];\n sinceStartMs: number;\n untilEndMs: number;\n holdRoomMs: number;\n endsInSilence: boolean;\n previous: CaptionPreviousPage | null;\n}\n\ninterface CaptionPagingOptions {\n combineTokensWithinMilliseconds: number;\n holdMs?: number;\n}\n\nconst SENTENCE_END = /[.!?…][\"')\\]]*$/;\n\nfunction markPageBreaks(captions: SpeakerCaption[]): Caption[] {\n return captions.map((caption, i) => {\n if (caption.pageBreakAfter !== undefined) return caption;\n const next = captions[i + 1];\n const speakerChanges =\n next !== undefined && next.speaker !== caption.speaker;\n return speakerChanges || SENTENCE_END.test(caption.text.trim())\n ? { ...caption, pageBreakAfter: true }\n : caption;\n });\n}\n\nfunction buildCaptionPages(\n captions: SpeakerCaption[],\n {\n combineTokensWithinMilliseconds,\n holdMs = DEFAULT_HOLD_MS,\n }: CaptionPagingOptions,\n): CaptionPageWindow[] {\n if (captions.length === 0) return [];\n const { pages } = createTikTokStyleCaptions({\n captions: markPageBreaks(captions),\n combineTokensWithinMilliseconds,\n breakOnSilenceAfterMilliseconds: Math.max(holdMs, MIN_SILENCE_BREAK_MS),\n });\n const speakers = new Map<number, string | undefined>();\n for (const caption of captions) {\n if (!speakers.has(caption.startMs)) {\n speakers.set(caption.startMs, caption.speaker);\n }\n }\n const spoken = pages.filter((page) => page.tokens.length > 0);\n return spoken.map((page, index) => {\n const last = page.tokens[page.tokens.length - 1];\n const speechEndMs = last ? last.toMs : page.startMs;\n const heldUntil = speechEndMs + Math.max(0, holdMs);\n const next = spoken[index + 1];\n const endsInSilence = !next || next.startMs > heldUntil;\n const endMs = endsInSilence\n ? heldUntil\n : Math.max(page.startMs, next.startMs);\n return {\n page,\n index,\n speaker: speakers.get(page.tokens[0].fromMs),\n startMs: page.startMs,\n speechEndMs,\n endMs,\n endsInSilence,\n };\n });\n}\n\nfunction findWindowIndex(windows: CaptionPageWindow[], timeMs: number): number {\n let lo = 0;\n let hi = windows.length - 1;\n let found = -1;\n while (lo <= hi) {\n const mid = (lo + hi) >> 1;\n if (windows[mid].startMs <= timeMs) {\n found = mid;\n lo = mid + 1;\n } else {\n hi = mid - 1;\n }\n }\n if (found === -1) return -1;\n return timeMs < windows[found].endMs ? found : -1;\n}\n\nfunction tokenProgress(fromMs: number, toMs: number, timeMs: number): number {\n if (timeMs < fromMs) return 0;\n if (toMs <= fromMs) return 1;\n return Math.min(1, (timeMs - fromMs) / (toMs - fromMs));\n}\n\nfunction getTokenStates(\n page: TikTokPage,\n timeMs: number,\n): { activeIndex: number; tokens: CaptionTokenState[] } {\n let activeIndex = -1;\n page.tokens.forEach((token, i) => {\n if (token.fromMs <= timeMs) activeIndex = i;\n });\n const tokens = page.tokens.map(\n (token, i): CaptionTokenState => ({\n text: token.text.trim(),\n spaceBefore: i > 0 && /^\\s/.test(token.text),\n fromMs: token.fromMs,\n toMs: token.toMs,\n progress: tokenProgress(token.fromMs, token.toMs, timeMs),\n status:\n i < activeIndex ? \"spoken\" : i === activeIndex ? \"active\" : \"upcoming\",\n }),\n );\n return { activeIndex, tokens };\n}\n\nfunction getCaptionsState(\n windows: CaptionPageWindow[],\n timeMs: number,\n): CaptionsState | null {\n const found = findWindowIndex(windows, timeMs);\n if (found === -1) return null;\n const window = windows[found];\n const { activeIndex, tokens } = getTokenStates(window.page, timeMs);\n const before = found > 0 ? windows[found - 1] : null;\n const previous =\n before && !before.endsInSilence\n ? {\n page: before.page,\n pageIndex: before.index,\n tokens: getTokenStates(before.page, before.endMs).tokens,\n }\n : null;\n return {\n page: window.page,\n pageIndex: window.index,\n speaker: window.speaker,\n timeMs,\n activeIndex,\n tokens,\n sinceStartMs: timeMs - window.startMs,\n untilEndMs: window.endMs - timeMs,\n holdRoomMs: window.endMs - window.speechEndMs,\n endsInSilence: window.endsInSilence,\n previous,\n };\n}\n\nfunction getExitWindowMs(state: CaptionsState, exitMs: number): number {\n return Math.max(1, Math.min(exitMs, state.holdRoomMs));\n}\n\nfunction groupCaptionWords(\n tokens: CaptionTokenState[],\n): { index: number; token: CaptionTokenState }[][] {\n const words: { index: number; token: CaptionTokenState }[][] = [];\n tokens.forEach((token, index) => {\n const current = words[words.length - 1];\n if (!current || token.spaceBefore) {\n words.push([{ index, token }]);\n } else {\n current.push({ index, token });\n }\n });\n return words;\n}\n\nfunction normalizeCaptionWord(text: string): string {\n return text\n .toLowerCase()\n .replace(/[\\u2018\\u2019]/g, \"'\")\n .replace(/[^\\p{L}\\p{N}']/gu, \"\");\n}\n\nfunction createKeywordMatcher(\n keywords: readonly string[] = [],\n): (text: string) => boolean {\n const set = new Set(keywords.map(normalizeCaptionWord).filter(Boolean));\n return (text) => set.has(normalizeCaptionWord(text));\n}\n\nfunction captionWordText(word: { token: CaptionTokenState }[]): string {\n return word.map(({ token }) => token.text).join(\"\");\n}\n\ninterface CaptionWordRect {\n left: number;\n top: number;\n width: number;\n height: number;\n}\n\nfunction sameRects(a: CaptionWordRect[], b: CaptionWordRect[]): boolean {\n return (\n a.length === b.length &&\n a.every(\n (r, i) =>\n r.left === b[i].left &&\n r.top === b[i].top &&\n r.width === b[i].width &&\n r.height === b[i].height,\n )\n );\n}\n\nfunction useCaptionWordRects(\n pageIndex: number,\n count: number,\n): {\n wordRef: (index: number) => (el: HTMLElement | null) => void;\n rects: CaptionWordRect[] | null;\n} {\n const elements = useRef<(HTMLElement | null)[]>([]);\n const [measured, setMeasured] = useState<{\n pageIndex: number;\n rects: CaptionWordRect[];\n } | null>(null);\n\n useLayoutEffect(() => {\n if (pageIndex === -1) return;\n const rects = elements.current.slice(0, count).map((el) =>\n el\n ? {\n left: el.offsetLeft,\n top: el.offsetTop,\n width: el.offsetWidth,\n height: el.offsetHeight,\n }\n : { left: 0, top: 0, width: 0, height: 0 },\n );\n setMeasured((prev) =>\n prev && prev.pageIndex === pageIndex && sameRects(prev.rects, rects)\n ? prev\n : { pageIndex, rects },\n );\n });\n\n return {\n wordRef: (index) => (el) => {\n elements.current[index] = el;\n },\n rects: measured && measured.pageIndex === pageIndex ? measured.rects : null,\n };\n}\n\nfunction useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs = DEFAULT_HOLD_MS,\n}: {\n captions: SpeakerCaption[];\n combineTokensWithinMilliseconds: number;\n holdMs?: number;\n}): CaptionsState | null {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const windows = useMemo(\n () =>\n buildCaptionPages(captions, { combineTokensWithinMilliseconds, holdMs }),\n [captions, combineTokensWithinMilliseconds, holdMs],\n );\n return getCaptionsState(windows, (frame / fps) * 1000);\n}\n\ninterface CaptionDropProps extends CaptionBaseProps {\n bounce?: number;\n shadow?: boolean;\n}\n\nconst EXIT_MS = 360;\nconst EXIT_STAGGER_MS = 120;\nconst FADE_IN_MS = 80;\nconst FALL_EM = 1.4;\nconst EXIT_FALL_EM = 1.8;\nconst MAX_TILT_DEG = 6;\nconst LEGIBILITY_SHADOW =\n \"0 2px 3px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.35)\";\n\nconst clamp = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n} as const;\n\nfunction CaptionDropBase({\n captions,\n combineTokensWithinMilliseconds = 1200,\n holdMs = DEFAULT_HOLD_MS,\n fontSize = 64,\n fontWeight = 800,\n color = \"#ffffff\",\n bounce = 0.6,\n shadow = true,\n className,\n}: CaptionDropProps) {\n const { fps } = useVideoConfig();\n const state = useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs,\n });\n if (!state) return null;\n\n const damping = interpolate(bounce, [0, 1], [20, 6], clamp);\n const words = groupCaptionWords(state.tokens);\n const exitWindow = getExitWindowMs(state, EXIT_MS);\n const exitElapsed = state.endsInSilence\n ? Math.max(0, exitWindow - state.untilEndMs)\n : 0;\n const stagger = Math.min(EXIT_STAGGER_MS, exitWindow * 0.4);\n const fallSpan = Math.max(1, exitWindow - stagger);\n\n return (\n <div\n className={className}\n style={{\n fontSize,\n fontWeight,\n color,\n lineHeight: 1.2,\n textAlign: \"center\",\n }}\n >\n {words.map((word, w) => {\n const first = word[0];\n const sinceMs = state.timeMs - first.token.fromMs;\n const arrived = sinceMs >= 0;\n const landed = arrived\n ? spring({\n frame: (sinceMs / 1000) * fps,\n fps,\n config: { damping, stiffness: 180, mass: 0.7 },\n })\n : 0;\n const fadeIn = arrived\n ? interpolate(sinceMs, [0, FADE_IN_MS], [0, 1], clamp)\n : 0;\n const tilt =\n (random(`${state.pageIndex}-${first.index}-tilt`) * 2 - 1) *\n MAX_TILT_DEG;\n const delay = words.length > 1 ? (w / (words.length - 1)) * stagger : 0;\n const out = state.endsInSilence\n ? Math.min(1, Math.max(0, (exitElapsed - delay) / fallSpan))\n : 0;\n const gravity = out * out;\n const y = -(1 - landed) * FALL_EM + gravity * EXIT_FALL_EM;\n const rotate = tilt * (1 - landed) - tilt * 0.6 * gravity;\n return (\n <Fragment key={`${state.pageIndex}-${first.index}`}>\n {w > 0 && \" \"}\n <span\n style={{\n display: \"inline-block\",\n whiteSpace: \"nowrap\",\n opacity: fadeIn * (1 - out ** 1.5),\n transform: `translateY(${y}em) rotate(${rotate}deg)`,\n transformOrigin: \"50% 100%\",\n textShadow: shadow ? LEGIBILITY_SHADOW : undefined,\n }}\n >\n {word.map(({ index, token }) => (\n <span key={index}>{token.text}</span>\n ))}\n </span>\n </Fragment>\n );\n })}\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n captions: {\n type: \"remotion-captions\",\n default: [{\n text: \" So\",\n startMs: 300,\n endMs: 460,\n timestampMs: 380,\n confidence: 0.97,\n }, {\n text: \" here's\",\n startMs: 460,\n endMs: 700,\n timestampMs: 580,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 700,\n endMs: 820,\n timestampMs: 760,\n confidence: 0.97,\n }, {\n text: \" thing.\",\n startMs: 820,\n endMs: 1240,\n timestampMs: 1030,\n confidence: 0.97,\n }, {\n text: \" Most\",\n startMs: 1700,\n endMs: 1960,\n timestampMs: 1830,\n confidence: 0.97,\n }, {\n text: \" demo\",\n startMs: 1960,\n endMs: 2240,\n timestampMs: 2100,\n confidence: 0.97,\n }, {\n text: \" videos\",\n startMs: 2240,\n endMs: 2680,\n timestampMs: 2460,\n confidence: 0.97,\n }, {\n text: \" lose\",\n startMs: 2680,\n endMs: 2960,\n timestampMs: 2820,\n confidence: 0.97,\n }, {\n text: \" people\",\n startMs: 2960,\n endMs: 3320,\n timestampMs: 3140,\n confidence: 0.97,\n }, {\n text: \" in\",\n startMs: 3320,\n endMs: 3420,\n timestampMs: 3370,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 3420,\n endMs: 3520,\n timestampMs: 3470,\n confidence: 0.97,\n }, {\n text: \" first\",\n startMs: 3520,\n endMs: 3820,\n timestampMs: 3670,\n confidence: 0.97,\n }, {\n text: \" three\",\n startMs: 3820,\n endMs: 4100,\n timestampMs: 3960,\n confidence: 0.97,\n }, {\n text: \" seconds.\",\n startMs: 4100,\n endMs: 4780,\n timestampMs: 4440,\n confidence: 0.97,\n }, {\n text: \" Captions\",\n startMs: 5400,\n endMs: 5920,\n timestampMs: 5660,\n confidence: 0.97,\n }, {\n text: \" keep\",\n startMs: 5920,\n endMs: 6140,\n timestampMs: 6030,\n confidence: 0.97,\n }, {\n text: \" them\",\n startMs: 6140,\n endMs: 6300,\n timestampMs: 6220,\n confidence: 0.97,\n }, {\n text: \" watching,\",\n startMs: 6300,\n endMs: 6860,\n timestampMs: 6580,\n confidence: 0.97,\n }, {\n text: \" even\",\n startMs: 6960,\n endMs: 7180,\n timestampMs: 7070,\n confidence: 0.97,\n }, {\n text: \" with\",\n startMs: 7180,\n endMs: 7320,\n timestampMs: 7250,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 7320,\n endMs: 7420,\n timestampMs: 7370,\n confidence: 0.97,\n }, {\n text: \" sound\",\n startMs: 7420,\n endMs: 7760,\n timestampMs: 7590,\n confidence: 0.97,\n }, {\n text: \" off.\",\n startMs: 7760,\n endMs: 8300,\n timestampMs: 8030,\n confidence: 0.97,\n }],\n description: \"Transcript\",\n keyframable: false,\n },\n fontSize: {\n type: \"number\",\n min: 24,\n max: 140,\n step: 1,\n default: 64,\n description: \"Font size\",\n hiddenFromList: false,\n },\n fontWeight: {\n type: \"number\",\n min: 400,\n max: 900,\n step: 100,\n default: 800,\n description: \"Font weight\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#ffffff\",\n description: \"Text color\",\n },\n bounce: {\n type: \"number\",\n min: 0,\n max: 1,\n step: 0.05,\n default: 0.6,\n description: \"Bounce\",\n hiddenFromList: false,\n },\n combineTokensWithinMilliseconds: {\n type: \"number\",\n min: 0,\n max: 3000,\n step: 100,\n default: 1200,\n description: \"Page window (ms)\",\n hiddenFromList: false,\n },\n holdMs: {\n type: \"number\",\n min: 0,\n max: 2000,\n step: 50,\n default: 600,\n description: \"Hold (ms)\",\n hiddenFromList: false,\n },\n shadow: {\n type: \"boolean\",\n default: true,\n description: \"Shadow\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"captions\",\"fontSize\",\"fontWeight\",\"color\",\"bounce\",\"combineTokensWithinMilliseconds\",\"holdMs\",\"shadow\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n captions: [{\n text: \" So\",\n startMs: 300,\n endMs: 460,\n timestampMs: 380,\n confidence: 0.97,\n }, {\n text: \" here's\",\n startMs: 460,\n endMs: 700,\n timestampMs: 580,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 700,\n endMs: 820,\n timestampMs: 760,\n confidence: 0.97,\n }, {\n text: \" thing.\",\n startMs: 820,\n endMs: 1240,\n timestampMs: 1030,\n confidence: 0.97,\n }, {\n text: \" Most\",\n startMs: 1700,\n endMs: 1960,\n timestampMs: 1830,\n confidence: 0.97,\n }, {\n text: \" demo\",\n startMs: 1960,\n endMs: 2240,\n timestampMs: 2100,\n confidence: 0.97,\n }, {\n text: \" videos\",\n startMs: 2240,\n endMs: 2680,\n timestampMs: 2460,\n confidence: 0.97,\n }, {\n text: \" lose\",\n startMs: 2680,\n endMs: 2960,\n timestampMs: 2820,\n confidence: 0.97,\n }, {\n text: \" people\",\n startMs: 2960,\n endMs: 3320,\n timestampMs: 3140,\n confidence: 0.97,\n }, {\n text: \" in\",\n startMs: 3320,\n endMs: 3420,\n timestampMs: 3370,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 3420,\n endMs: 3520,\n timestampMs: 3470,\n confidence: 0.97,\n }, {\n text: \" first\",\n startMs: 3520,\n endMs: 3820,\n timestampMs: 3670,\n confidence: 0.97,\n }, {\n text: \" three\",\n startMs: 3820,\n endMs: 4100,\n timestampMs: 3960,\n confidence: 0.97,\n }, {\n text: \" seconds.\",\n startMs: 4100,\n endMs: 4780,\n timestampMs: 4440,\n confidence: 0.97,\n }, {\n text: \" Captions\",\n startMs: 5400,\n endMs: 5920,\n timestampMs: 5660,\n confidence: 0.97,\n }, {\n text: \" keep\",\n startMs: 5920,\n endMs: 6140,\n timestampMs: 6030,\n confidence: 0.97,\n }, {\n text: \" them\",\n startMs: 6140,\n endMs: 6300,\n timestampMs: 6220,\n confidence: 0.97,\n }, {\n text: \" watching,\",\n startMs: 6300,\n endMs: 6860,\n timestampMs: 6580,\n confidence: 0.97,\n }, {\n text: \" even\",\n startMs: 6960,\n endMs: 7180,\n timestampMs: 7070,\n confidence: 0.97,\n }, {\n text: \" with\",\n startMs: 7180,\n endMs: 7320,\n timestampMs: 7250,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 7320,\n endMs: 7420,\n timestampMs: 7370,\n confidence: 0.97,\n }, {\n text: \" sound\",\n startMs: 7420,\n endMs: 7760,\n timestampMs: 7590,\n confidence: 0.97,\n }, {\n text: \" off.\",\n startMs: 7760,\n endMs: 8300,\n timestampMs: 8030,\n confidence: 0.97,\n }],\n fontSize: 64,\n fontWeight: 800,\n color: \"#ffffff\",\n bounce: 0.6,\n combineTokensWithinMilliseconds: 1200,\n holdMs: 600,\n shadow: true,\n};\n\ntype CaptionDropElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof CaptionDropBase>;\n\nconst CaptionDropInner = forwardRef<\n HTMLDivElement,\n CaptionDropElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<CaptionDrop>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <CaptionDropBase\n {...(componentProps as unknown as ComponentProps<typeof CaptionDropBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const CaptionDrop = Interactive.withSchema({\n Component: CaptionDropInner,\n componentName: \"<CaptionDrop>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"+ },+ "durationInFrames": 279+}diff --git a/registry-artifacts/elements/caption-emoji.json b/registry-artifacts/elements/caption-emoji.jsonnew file mode 100644index 00000000..d26ecff8--- /dev/null+++ b/registry-artifacts/elements/caption-emoji.json@@ -0,0 +1,21 @@+{+ "type": "remotion-element",+ "version": 1,+ "element": {+ "assets": [],+ "dependencies": [+ {+ "name": "@remotion/captions",+ "version": null+ }+ ],+ "dimensions": null,+ "displayName": "Caption Emoji",+ "durationInFrames": 279,+ "initialProps": null,+ "installationMode": "component-owned-sequence",+ "slug": "caption-emoji",+ "sourceCode": "import { Fragment, forwardRef, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState, type ComponentProps } from \"react\";\nimport { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { createTikTokStyleCaptions, type Caption, type TikTokPage } from \"@remotion/captions\";\n\ntype SpeakerCaption = Caption & { speaker?: string };\n\ninterface CaptionBaseProps {\n captions: Caption[];\n combineTokensWithinMilliseconds?: number;\n holdMs?: number;\n fontSize?: number;\n fontWeight?: number;\n color?: string;\n className?: string;\n}\n\nconst DEFAULT_HOLD_MS = 600;\nconst MIN_SILENCE_BREAK_MS = 300;\n\ninterface CaptionPageWindow {\n page: TikTokPage;\n index: number;\n speaker: string | undefined;\n startMs: number;\n speechEndMs: number;\n endMs: number;\n endsInSilence: boolean;\n}\n\ntype CaptionTokenStatus = \"upcoming\" | \"active\" | \"spoken\";\n\ninterface CaptionTokenState {\n text: string;\n spaceBefore: boolean;\n fromMs: number;\n toMs: number;\n progress: number;\n status: CaptionTokenStatus;\n}\n\ninterface CaptionPreviousPage {\n page: TikTokPage;\n pageIndex: number;\n tokens: CaptionTokenState[];\n}\n\ninterface CaptionsState {\n page: TikTokPage;\n pageIndex: number;\n speaker: string | undefined;\n timeMs: number;\n activeIndex: number;\n tokens: CaptionTokenState[];\n sinceStartMs: number;\n untilEndMs: number;\n holdRoomMs: number;\n endsInSilence: boolean;\n previous: CaptionPreviousPage | null;\n}\n\ninterface CaptionPagingOptions {\n combineTokensWithinMilliseconds: number;\n holdMs?: number;\n}\n\nconst SENTENCE_END = /[.!?…][\"')\\]]*$/;\n\nfunction markPageBreaks(captions: SpeakerCaption[]): Caption[] {\n return captions.map((caption, i) => {\n if (caption.pageBreakAfter !== undefined) return caption;\n const next = captions[i + 1];\n const speakerChanges =\n next !== undefined && next.speaker !== caption.speaker;\n return speakerChanges || SENTENCE_END.test(caption.text.trim())\n ? { ...caption, pageBreakAfter: true }\n : caption;\n });\n}\n\nfunction buildCaptionPages(\n captions: SpeakerCaption[],\n {\n combineTokensWithinMilliseconds,\n holdMs = DEFAULT_HOLD_MS,\n }: CaptionPagingOptions,\n): CaptionPageWindow[] {\n if (captions.length === 0) return [];\n const { pages } = createTikTokStyleCaptions({\n captions: markPageBreaks(captions),\n combineTokensWithinMilliseconds,\n breakOnSilenceAfterMilliseconds: Math.max(holdMs, MIN_SILENCE_BREAK_MS),\n });\n const speakers = new Map<number, string | undefined>();\n for (const caption of captions) {\n if (!speakers.has(caption.startMs)) {\n speakers.set(caption.startMs, caption.speaker);\n }\n }\n const spoken = pages.filter((page) => page.tokens.length > 0);\n return spoken.map((page, index) => {\n const last = page.tokens[page.tokens.length - 1];\n const speechEndMs = last ? last.toMs : page.startMs;\n const heldUntil = speechEndMs + Math.max(0, holdMs);\n const next = spoken[index + 1];\n const endsInSilence = !next || next.startMs > heldUntil;\n const endMs = endsInSilence\n ? heldUntil\n : Math.max(page.startMs, next.startMs);\n return {\n page,\n index,\n speaker: speakers.get(page.tokens[0].fromMs),\n startMs: page.startMs,\n speechEndMs,\n endMs,\n endsInSilence,\n };\n });\n}\n\nfunction findWindowIndex(windows: CaptionPageWindow[], timeMs: number): number {\n let lo = 0;\n let hi = windows.length - 1;\n let found = -1;\n while (lo <= hi) {\n const mid = (lo + hi) >> 1;\n if (windows[mid].startMs <= timeMs) {\n found = mid;\n lo = mid + 1;\n } else {\n hi = mid - 1;\n }\n }\n if (found === -1) return -1;\n return timeMs < windows[found].endMs ? found : -1;\n}\n\nfunction tokenProgress(fromMs: number, toMs: number, timeMs: number): number {\n if (timeMs < fromMs) return 0;\n if (toMs <= fromMs) return 1;\n return Math.min(1, (timeMs - fromMs) / (toMs - fromMs));\n}\n\nfunction getTokenStates(\n page: TikTokPage,\n timeMs: number,\n): { activeIndex: number; tokens: CaptionTokenState[] } {\n let activeIndex = -1;\n page.tokens.forEach((token, i) => {\n if (token.fromMs <= timeMs) activeIndex = i;\n });\n const tokens = page.tokens.map(\n (token, i): CaptionTokenState => ({\n text: token.text.trim(),\n spaceBefore: i > 0 && /^\\s/.test(token.text),\n fromMs: token.fromMs,\n toMs: token.toMs,\n progress: tokenProgress(token.fromMs, token.toMs, timeMs),\n status:\n i < activeIndex ? \"spoken\" : i === activeIndex ? \"active\" : \"upcoming\",\n }),\n );\n return { activeIndex, tokens };\n}\n\nfunction getCaptionsState(\n windows: CaptionPageWindow[],\n timeMs: number,\n): CaptionsState | null {\n const found = findWindowIndex(windows, timeMs);\n if (found === -1) return null;\n const window = windows[found];\n const { activeIndex, tokens } = getTokenStates(window.page, timeMs);\n const before = found > 0 ? windows[found - 1] : null;\n const previous =\n before && !before.endsInSilence\n ? {\n page: before.page,\n pageIndex: before.index,\n tokens: getTokenStates(before.page, before.endMs).tokens,\n }\n : null;\n return {\n page: window.page,\n pageIndex: window.index,\n speaker: window.speaker,\n timeMs,\n activeIndex,\n tokens,\n sinceStartMs: timeMs - window.startMs,\n untilEndMs: window.endMs - timeMs,\n holdRoomMs: window.endMs - window.speechEndMs,\n endsInSilence: window.endsInSilence,\n previous,\n };\n}\n\nfunction getExitWindowMs(state: CaptionsState, exitMs: number): number {\n return Math.max(1, Math.min(exitMs, state.holdRoomMs));\n}\n\nfunction groupCaptionWords(\n tokens: CaptionTokenState[],\n): { index: number; token: CaptionTokenState }[][] {\n const words: { index: number; token: CaptionTokenState }[][] = [];\n tokens.forEach((token, index) => {\n const current = words[words.length - 1];\n if (!current || token.spaceBefore) {\n words.push([{ index, token }]);\n } else {\n current.push({ index, token });\n }\n });\n return words;\n}\n\nfunction normalizeCaptionWord(text: string): string {\n return text\n .toLowerCase()\n .replace(/[\\u2018\\u2019]/g, \"'\")\n .replace(/[^\\p{L}\\p{N}']/gu, \"\");\n}\n\nfunction createKeywordMatcher(\n keywords: readonly string[] = [],\n): (text: string) => boolean {\n const set = new Set(keywords.map(normalizeCaptionWord).filter(Boolean));\n return (text) => set.has(normalizeCaptionWord(text));\n}\n\nfunction captionWordText(word: { token: CaptionTokenState }[]): string {\n return word.map(({ token }) => token.text).join(\"\");\n}\n\ninterface CaptionWordRect {\n left: number;\n top: number;\n width: number;\n height: number;\n}\n\nfunction sameRects(a: CaptionWordRect[], b: CaptionWordRect[]): boolean {\n return (\n a.length === b.length &&\n a.every(\n (r, i) =>\n r.left === b[i].left &&\n r.top === b[i].top &&\n r.width === b[i].width &&\n r.height === b[i].height,\n )\n );\n}\n\nfunction useCaptionWordRects(\n pageIndex: number,\n count: number,\n): {\n wordRef: (index: number) => (el: HTMLElement | null) => void;\n rects: CaptionWordRect[] | null;\n} {\n const elements = useRef<(HTMLElement | null)[]>([]);\n const [measured, setMeasured] = useState<{\n pageIndex: number;\n rects: CaptionWordRect[];\n } | null>(null);\n\n useLayoutEffect(() => {\n if (pageIndex === -1) return;\n const rects = elements.current.slice(0, count).map((el) =>\n el\n ? {\n left: el.offsetLeft,\n top: el.offsetTop,\n width: el.offsetWidth,\n height: el.offsetHeight,\n }\n : { left: 0, top: 0, width: 0, height: 0 },\n );\n setMeasured((prev) =>\n prev && prev.pageIndex === pageIndex && sameRects(prev.rects, rects)\n ? prev\n : { pageIndex, rects },\n );\n });\n\n return {\n wordRef: (index) => (el) => {\n elements.current[index] = el;\n },\n rects: measured && measured.pageIndex === pageIndex ? measured.rects : null,\n };\n}\n\nfunction useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs = DEFAULT_HOLD_MS,\n}: {\n captions: SpeakerCaption[];\n combineTokensWithinMilliseconds: number;\n holdMs?: number;\n}): CaptionsState | null {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const windows = useMemo(\n () =>\n buildCaptionPages(captions, { combineTokensWithinMilliseconds, holdMs }),\n [captions, combineTokensWithinMilliseconds, holdMs],\n );\n return getCaptionsState(windows, (frame / fps) * 1000);\n}\n\ninterface CaptionEmojiProps extends CaptionBaseProps {\n emoji?: Record<string, string>;\n emojiSize?: number;\n shadow?: boolean;\n}\n\nconst ENTER_MS = 160;\nconst EXIT_MS = 220;\nconst RISE_EM = 0.14;\nconst LEGIBILITY_SHADOW =\n \"0 2px 3px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.35)\";\n\nconst POP_SPRING = { damping: 9, stiffness: 180, mass: 0.6 };\n\nconst enterEasing = Easing.bezier(0.2, 0.8, 0.2, 1);\n\nconst clamp = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n} as const;\n\nfunction CaptionEmojiBase({\n captions,\n combineTokensWithinMilliseconds = 1200,\n holdMs = DEFAULT_HOLD_MS,\n fontSize = 64,\n fontWeight = 800,\n color = \"#ffffff\",\n emoji = {},\n emojiSize = 0.9,\n shadow = true,\n className,\n}: CaptionEmojiProps) {\n const { fps } = useVideoConfig();\n const state = useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs,\n });\n if (!state) return null;\n\n const enter = interpolate(\n state.previous ? ENTER_MS : state.sinceStartMs,\n [0, ENTER_MS],\n [0, 1],\n {\n ...clamp,\n easing: enterEasing,\n },\n );\n const exit = state.endsInSilence\n ? interpolate(\n state.untilEndMs,\n [0, getExitWindowMs(state, EXIT_MS)],\n [0, 1],\n clamp,\n )\n : 1;\n\n const lookup = new Map(\n Object.entries(emoji).map(([word, glyph]) => [\n normalizeCaptionWord(word),\n glyph,\n ]),\n );\n\n return (\n <div\n className={className}\n style={{\n fontSize,\n fontWeight,\n color,\n lineHeight: 1.2,\n textAlign: \"center\",\n opacity: Math.min(enter, exit),\n transform: `translateY(${(1 - enter) * RISE_EM}em)`,\n }}\n >\n {groupCaptionWords(state.tokens).map((word, w) => {\n const first = word[0].token;\n const glyph = lookup.get(normalizeCaptionWord(captionWordText(word)));\n const pop =\n glyph && first.status !== \"upcoming\"\n ? spring({\n frame: ((state.timeMs - first.fromMs) / 1000) * fps,\n fps,\n config: POP_SPRING,\n })\n : 0;\n return (\n <Fragment key={`${state.pageIndex}-${word[0].index}`}>\n {w > 0 && \" \"}\n <span\n style={{\n position: \"relative\",\n display: \"inline-block\",\n whiteSpace: \"nowrap\",\n textShadow: shadow ? LEGIBILITY_SHADOW : undefined,\n }}\n >\n {glyph && pop > 0 && (\n <span\n aria-hidden\n style={{\n position: \"absolute\",\n left: \"50%\",\n bottom: \"92%\",\n fontSize: `${emojiSize}em`,\n lineHeight: 1,\n textShadow: \"none\",\n transformOrigin: \"50% 100%\",\n transform: `translateX(-50%) rotate(${14 - 20 * pop}deg) scale(${pop})`,\n }}\n >\n {glyph}\n </span>\n )}\n {word.map(({ index, token }) => (\n <span key={index}>{token.text}</span>\n ))}\n </span>\n </Fragment>\n );\n })}\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n captions: {\n type: \"remotion-captions\",\n default: [{\n text: \" So\",\n startMs: 300,\n endMs: 460,\n timestampMs: 380,\n confidence: 0.97,\n }, {\n text: \" here's\",\n startMs: 460,\n endMs: 700,\n timestampMs: 580,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 700,\n endMs: 820,\n timestampMs: 760,\n confidence: 0.97,\n }, {\n text: \" thing.\",\n startMs: 820,\n endMs: 1240,\n timestampMs: 1030,\n confidence: 0.97,\n }, {\n text: \" Most\",\n startMs: 1700,\n endMs: 1960,\n timestampMs: 1830,\n confidence: 0.97,\n }, {\n text: \" demo\",\n startMs: 1960,\n endMs: 2240,\n timestampMs: 2100,\n confidence: 0.97,\n }, {\n text: \" videos\",\n startMs: 2240,\n endMs: 2680,\n timestampMs: 2460,\n confidence: 0.97,\n }, {\n text: \" lose\",\n startMs: 2680,\n endMs: 2960,\n timestampMs: 2820,\n confidence: 0.97,\n }, {\n text: \" people\",\n startMs: 2960,\n endMs: 3320,\n timestampMs: 3140,\n confidence: 0.97,\n }, {\n text: \" in\",\n startMs: 3320,\n endMs: 3420,\n timestampMs: 3370,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 3420,\n endMs: 3520,\n timestampMs: 3470,\n confidence: 0.97,\n }, {\n text: \" first\",\n startMs: 3520,\n endMs: 3820,\n timestampMs: 3670,\n confidence: 0.97,\n }, {\n text: \" three\",\n startMs: 3820,\n endMs: 4100,\n timestampMs: 3960,\n confidence: 0.97,\n }, {\n text: \" seconds.\",\n startMs: 4100,\n endMs: 4780,\n timestampMs: 4440,\n confidence: 0.97,\n }, {\n text: \" Captions\",\n startMs: 5400,\n endMs: 5920,\n timestampMs: 5660,\n confidence: 0.97,\n }, {\n text: \" keep\",\n startMs: 5920,\n endMs: 6140,\n timestampMs: 6030,\n confidence: 0.97,\n }, {\n text: \" them\",\n startMs: 6140,\n endMs: 6300,\n timestampMs: 6220,\n confidence: 0.97,\n }, {\n text: \" watching,\",\n startMs: 6300,\n endMs: 6860,\n timestampMs: 6580,\n confidence: 0.97,\n }, {\n text: \" even\",\n startMs: 6960,\n endMs: 7180,\n timestampMs: 7070,\n confidence: 0.97,\n }, {\n text: \" with\",\n startMs: 7180,\n endMs: 7320,\n timestampMs: 7250,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 7320,\n endMs: 7420,\n timestampMs: 7370,\n confidence: 0.97,\n }, {\n text: \" sound\",\n startMs: 7420,\n endMs: 7760,\n timestampMs: 7590,\n confidence: 0.97,\n }, {\n text: \" off.\",\n startMs: 7760,\n endMs: 8300,\n timestampMs: 8030,\n confidence: 0.97,\n }],\n description: \"Transcript\",\n keyframable: false,\n },\n fontSize: {\n type: \"number\",\n min: 24,\n max: 140,\n step: 1,\n default: 64,\n description: \"Font size\",\n hiddenFromList: false,\n },\n fontWeight: {\n type: \"number\",\n min: 400,\n max: 900,\n step: 100,\n default: 800,\n description: \"Font weight\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#ffffff\",\n description: \"Text color\",\n },\n emojiSize: {\n type: \"number\",\n min: 0.4,\n max: 2,\n step: 0.05,\n default: 0.9,\n description: \"Emoji size (em)\",\n hiddenFromList: false,\n },\n combineTokensWithinMilliseconds: {\n type: \"number\",\n min: 0,\n max: 3000,\n step: 100,\n default: 1200,\n description: \"Page window (ms)\",\n hiddenFromList: false,\n },\n holdMs: {\n type: \"number\",\n min: 0,\n max: 2000,\n step: 50,\n default: 600,\n description: \"Hold (ms)\",\n hiddenFromList: false,\n },\n shadow: {\n type: \"boolean\",\n default: true,\n description: \"Shadow\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"captions\",\"fontSize\",\"fontWeight\",\"color\",\"emojiSize\",\"combineTokensWithinMilliseconds\",\"holdMs\",\"shadow\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n captions: [{\n text: \" So\",\n startMs: 300,\n endMs: 460,\n timestampMs: 380,\n confidence: 0.97,\n }, {\n text: \" here's\",\n startMs: 460,\n endMs: 700,\n timestampMs: 580,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 700,\n endMs: 820,\n timestampMs: 760,\n confidence: 0.97,\n }, {\n text: \" thing.\",\n startMs: 820,\n endMs: 1240,\n timestampMs: 1030,\n confidence: 0.97,\n }, {\n text: \" Most\",\n startMs: 1700,\n endMs: 1960,\n timestampMs: 1830,\n confidence: 0.97,\n }, {\n text: \" demo\",\n startMs: 1960,\n endMs: 2240,\n timestampMs: 2100,\n confidence: 0.97,\n }, {\n text: \" videos\",\n startMs: 2240,\n endMs: 2680,\n timestampMs: 2460,\n confidence: 0.97,\n }, {\n text: \" lose\",\n startMs: 2680,\n endMs: 2960,\n timestampMs: 2820,\n confidence: 0.97,\n }, {\n text: \" people\",\n startMs: 2960,\n endMs: 3320,\n timestampMs: 3140,\n confidence: 0.97,\n }, {\n text: \" in\",\n startMs: 3320,\n endMs: 3420,\n timestampMs: 3370,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 3420,\n endMs: 3520,\n timestampMs: 3470,\n confidence: 0.97,\n }, {\n text: \" first\",\n startMs: 3520,\n endMs: 3820,\n timestampMs: 3670,\n confidence: 0.97,\n }, {\n text: \" three\",\n startMs: 3820,\n endMs: 4100,\n timestampMs: 3960,\n confidence: 0.97,\n }, {\n text: \" seconds.\",\n startMs: 4100,\n endMs: 4780,\n timestampMs: 4440,\n confidence: 0.97,\n }, {\n text: \" Captions\",\n startMs: 5400,\n endMs: 5920,\n timestampMs: 5660,\n confidence: 0.97,\n }, {\n text: \" keep\",\n startMs: 5920,\n endMs: 6140,\n timestampMs: 6030,\n confidence: 0.97,\n }, {\n text: \" them\",\n startMs: 6140,\n endMs: 6300,\n timestampMs: 6220,\n confidence: 0.97,\n }, {\n text: \" watching,\",\n startMs: 6300,\n endMs: 6860,\n timestampMs: 6580,\n confidence: 0.97,\n }, {\n text: \" even\",\n startMs: 6960,\n endMs: 7180,\n timestampMs: 7070,\n confidence: 0.97,\n }, {\n text: \" with\",\n startMs: 7180,\n endMs: 7320,\n timestampMs: 7250,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 7320,\n endMs: 7420,\n timestampMs: 7370,\n confidence: 0.97,\n }, {\n text: \" sound\",\n startMs: 7420,\n endMs: 7760,\n timestampMs: 7590,\n confidence: 0.97,\n }, {\n text: \" off.\",\n startMs: 7760,\n endMs: 8300,\n timestampMs: 8030,\n confidence: 0.97,\n }],\n fontSize: 64,\n fontWeight: 800,\n color: \"#ffffff\",\n emojiSize: 0.9,\n combineTokensWithinMilliseconds: 1200,\n holdMs: 600,\n shadow: true,\n};\n\ntype CaptionEmojiElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof CaptionEmojiBase>;\n\nconst CaptionEmojiInner = forwardRef<\n HTMLDivElement,\n CaptionEmojiElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<CaptionEmoji>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <CaptionEmojiBase\n {...(componentProps as unknown as ComponentProps<typeof CaptionEmojiBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const CaptionEmoji = Interactive.withSchema({\n Component: CaptionEmojiInner,\n componentName: \"<CaptionEmoji>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"+ },+ "durationInFrames": 279+}diff --git a/registry-artifacts/elements/caption-handwrite.json b/registry-artifacts/elements/caption-handwrite.jsonnew file mode 100644index 00000000..c048cf23--- /dev/null+++ b/registry-artifacts/elements/caption-handwrite.json@@ -0,0 +1,21 @@+{+ "type": "remotion-element",+ "version": 1,+ "element": {+ "assets": [],+ "dependencies": [+ {+ "name": "@remotion/captions",+ "version": null+ }+ ],+ "dimensions": null,+ "displayName": "Caption Handwrite",+ "durationInFrames": 279,+ "initialProps": null,+ "installationMode": "component-owned-sequence",+ "slug": "caption-handwrite",+ "sourceCode": "import { Fragment, forwardRef, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState, type ComponentProps } from \"react\";\nimport { Easing, Interactive, Sequence, interpolate, random, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { createTikTokStyleCaptions, type Caption, type TikTokPage } from \"@remotion/captions\";\n\ntype SpeakerCaption = Caption & { speaker?: string };\n\ninterface CaptionBaseProps {\n captions: Caption[];\n combineTokensWithinMilliseconds?: number;\n holdMs?: number;\n fontSize?: number;\n fontWeight?: number;\n color?: string;\n className?: string;\n}\n\nconst DEFAULT_HOLD_MS = 600;\nconst MIN_SILENCE_BREAK_MS = 300;\n\ninterface CaptionPageWindow {\n page: TikTokPage;\n index: number;\n speaker: string | undefined;\n startMs: number;\n speechEndMs: number;\n endMs: number;\n endsInSilence: boolean;\n}\n\ntype CaptionTokenStatus = \"upcoming\" | \"active\" | \"spoken\";\n\ninterface CaptionTokenState {\n text: string;\n spaceBefore: boolean;\n fromMs: number;\n toMs: number;\n progress: number;\n status: CaptionTokenStatus;\n}\n\ninterface CaptionPreviousPage {\n page: TikTokPage;\n pageIndex: number;\n tokens: CaptionTokenState[];\n}\n\ninterface CaptionsState {\n page: TikTokPage;\n pageIndex: number;\n speaker: string | undefined;\n timeMs: number;\n activeIndex: number;\n tokens: CaptionTokenState[];\n sinceStartMs: number;\n untilEndMs: number;\n holdRoomMs: number;\n endsInSilence: boolean;\n previous: CaptionPreviousPage | null;\n}\n\ninterface CaptionPagingOptions {\n combineTokensWithinMilliseconds: number;\n holdMs?: number;\n}\n\nconst SENTENCE_END = /[.!?…][\"')\\]]*$/;\n\nfunction markPageBreaks(captions: SpeakerCaption[]): Caption[] {\n return captions.map((caption, i) => {\n if (caption.pageBreakAfter !== undefined) return caption;\n const next = captions[i + 1];\n const speakerChanges =\n next !== undefined && next.speaker !== caption.speaker;\n return speakerChanges || SENTENCE_END.test(caption.text.trim())\n ? { ...caption, pageBreakAfter: true }\n : caption;\n });\n}\n\nfunction buildCaptionPages(\n captions: SpeakerCaption[],\n {\n combineTokensWithinMilliseconds,\n holdMs = DEFAULT_HOLD_MS,\n }: CaptionPagingOptions,\n): CaptionPageWindow[] {\n if (captions.length === 0) return [];\n const { pages } = createTikTokStyleCaptions({\n captions: markPageBreaks(captions),\n combineTokensWithinMilliseconds,\n breakOnSilenceAfterMilliseconds: Math.max(holdMs, MIN_SILENCE_BREAK_MS),\n });\n const speakers = new Map<number, string | undefined>();\n for (const caption of captions) {\n if (!speakers.has(caption.startMs)) {\n speakers.set(caption.startMs, caption.speaker);\n }\n }\n const spoken = pages.filter((page) => page.tokens.length > 0);\n return spoken.map((page, index) => {\n const last = page.tokens[page.tokens.length - 1];\n const speechEndMs = last ? last.toMs : page.startMs;\n const heldUntil = speechEndMs + Math.max(0, holdMs);\n const next = spoken[index + 1];\n const endsInSilence = !next || next.startMs > heldUntil;\n const endMs = endsInSilence\n ? heldUntil\n : Math.max(page.startMs, next.startMs);\n return {\n page,\n index,\n speaker: speakers.get(page.tokens[0].fromMs),\n startMs: page.startMs,\n speechEndMs,\n endMs,\n endsInSilence,\n };\n });\n}\n\nfunction findWindowIndex(windows: CaptionPageWindow[], timeMs: number): number {\n let lo = 0;\n let hi = windows.length - 1;\n let found = -1;\n while (lo <= hi) {\n const mid = (lo + hi) >> 1;\n if (windows[mid].startMs <= timeMs) {\n found = mid;\n lo = mid + 1;\n } else {\n hi = mid - 1;\n }\n }\n if (found === -1) return -1;\n return timeMs < windows[found].endMs ? found : -1;\n}\n\nfunction tokenProgress(fromMs: number, toMs: number, timeMs: number): number {\n if (timeMs < fromMs) return 0;\n if (toMs <= fromMs) return 1;\n return Math.min(1, (timeMs - fromMs) / (toMs - fromMs));\n}\n\nfunction getTokenStates(\n page: TikTokPage,\n timeMs: number,\n): { activeIndex: number; tokens: CaptionTokenState[] } {\n let activeIndex = -1;\n page.tokens.forEach((token, i) => {\n if (token.fromMs <= timeMs) activeIndex = i;\n });\n const tokens = page.tokens.map(\n (token, i): CaptionTokenState => ({\n text: token.text.trim(),\n spaceBefore: i > 0 && /^\\s/.test(token.text),\n fromMs: token.fromMs,\n toMs: token.toMs,\n progress: tokenProgress(token.fromMs, token.toMs, timeMs),\n status:\n i < activeIndex ? \"spoken\" : i === activeIndex ? \"active\" : \"upcoming\",\n }),\n );\n return { activeIndex, tokens };\n}\n\nfunction getCaptionsState(\n windows: CaptionPageWindow[],\n timeMs: number,\n): CaptionsState | null {\n const found = findWindowIndex(windows, timeMs);\n if (found === -1) return null;\n const window = windows[found];\n const { activeIndex, tokens } = getTokenStates(window.page, timeMs);\n const before = found > 0 ? windows[found - 1] : null;\n const previous =\n before && !before.endsInSilence\n ? {\n page: before.page,\n pageIndex: before.index,\n tokens: getTokenStates(before.page, before.endMs).tokens,\n }\n : null;\n return {\n page: window.page,\n pageIndex: window.index,\n speaker: window.speaker,\n timeMs,\n activeIndex,\n tokens,\n sinceStartMs: timeMs - window.startMs,\n untilEndMs: window.endMs - timeMs,\n holdRoomMs: window.endMs - window.speechEndMs,\n endsInSilence: window.endsInSilence,\n previous,\n };\n}\n\nfunction getExitWindowMs(state: CaptionsState, exitMs: number): number {\n return Math.max(1, Math.min(exitMs, state.holdRoomMs));\n}\n\nfunction groupCaptionWords(\n tokens: CaptionTokenState[],\n): { index: number; token: CaptionTokenState }[][] {\n const words: { index: number; token: CaptionTokenState }[][] = [];\n tokens.forEach((token, index) => {\n const current = words[words.length - 1];\n if (!current || token.spaceBefore) {\n words.push([{ index, token }]);\n } else {\n current.push({ index, token });\n }\n });\n return words;\n}\n\nfunction normalizeCaptionWord(text: string): string {\n return text\n .toLowerCase()\n .replace(/[\\u2018\\u2019]/g, \"'\")\n .replace(/[^\\p{L}\\p{N}']/gu, \"\");\n}\n\nfunction createKeywordMatcher(\n keywords: readonly string[] = [],\n): (text: string) => boolean {\n const set = new Set(keywords.map(normalizeCaptionWord).filter(Boolean));\n return (text) => set.has(normalizeCaptionWord(text));\n}\n\nfunction captionWordText(word: { token: CaptionTokenState }[]): string {\n return word.map(({ token }) => token.text).join(\"\");\n}\n\ninterface CaptionWordRect {\n left: number;\n top: number;\n width: number;\n height: number;\n}\n\nfunction sameRects(a: CaptionWordRect[], b: CaptionWordRect[]): boolean {\n return (\n a.length === b.length &&\n a.every(\n (r, i) =>\n r.left === b[i].left &&\n r.top === b[i].top &&\n r.width === b[i].width &&\n r.height === b[i].height,\n )\n );\n}\n\nfunction useCaptionWordRects(\n pageIndex: number,\n count: number,\n): {\n wordRef: (index: number) => (el: HTMLElement | null) => void;\n rects: CaptionWordRect[] | null;\n} {\n const elements = useRef<(HTMLElement | null)[]>([]);\n const [measured, setMeasured] = useState<{\n pageIndex: number;\n rects: CaptionWordRect[];\n } | null>(null);\n\n useLayoutEffect(() => {\n if (pageIndex === -1) return;\n const rects = elements.current.slice(0, count).map((el) =>\n el\n ? {\n left: el.offsetLeft,\n top: el.offsetTop,\n width: el.offsetWidth,\n height: el.offsetHeight,\n }\n : { left: 0, top: 0, width: 0, height: 0 },\n );\n setMeasured((prev) =>\n prev && prev.pageIndex === pageIndex && sameRects(prev.rects, rects)\n ? prev\n : { pageIndex, rects },\n );\n });\n\n return {\n wordRef: (index) => (el) => {\n elements.current[index] = el;\n },\n rects: measured && measured.pageIndex === pageIndex ? measured.rects : null,\n };\n}\n\nfunction useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs = DEFAULT_HOLD_MS,\n}: {\n captions: SpeakerCaption[];\n combineTokensWithinMilliseconds: number;\n holdMs?: number;\n}): CaptionsState | null {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const windows = useMemo(\n () =>\n buildCaptionPages(captions, { combineTokensWithinMilliseconds, holdMs }),\n [captions, combineTokensWithinMilliseconds, holdMs],\n );\n return getCaptionsState(windows, (frame / fps) * 1000);\n}\n\ninterface CaptionHandwriteProps extends CaptionBaseProps {\n wobble?: number;\n shadow?: boolean;\n}\n\nconst ENTER_MS = 160;\nconst EXIT_MS = 220;\nconst MIN_WRITE_MS = 200;\nconst EDGE_PERCENT = 22;\nconst MASK_PAD_EM = 0.4;\nconst LEGIBILITY_SHADOW =\n \"0 2px 3px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.35)\";\n\nconst enterEasing = Easing.bezier(0.2, 0.8, 0.2, 1);\n\nconst clamp = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n} as const;\n\nfunction CaptionHandwriteBase({\n captions,\n combineTokensWithinMilliseconds = 1200,\n holdMs = DEFAULT_HOLD_MS,\n fontSize = 64,\n fontWeight = 800,\n color = \"#ffffff\",\n wobble = 1,\n shadow = true,\n className,\n}: CaptionHandwriteProps) {\n const state = useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs,\n });\n if (!state) return null;\n\n const enter = interpolate(\n state.previous ? ENTER_MS : state.sinceStartMs,\n [0, ENTER_MS],\n [0, 1],\n { ...clamp, easing: enterEasing },\n );\n const exit = state.endsInSilence\n ? interpolate(\n state.untilEndMs,\n [0, getExitWindowMs(state, EXIT_MS)],\n [0, 1],\n clamp,\n )\n : 1;\n const textShadow = shadow ? LEGIBILITY_SHADOW : undefined;\n\n return (\n <div\n className={className}\n style={{\n fontSize,\n fontWeight,\n color,\n lineHeight: 1.2,\n textAlign: \"center\",\n opacity: Math.min(enter, exit),\n }}\n >\n {groupCaptionWords(state.tokens).map((word, w) => {\n const text = captionWordText(word);\n const fromMs = word[0].token.fromMs;\n const toMs = word[word.length - 1].token.toMs;\n const writeMs = Math.max(toMs - fromMs, MIN_WRITE_MS);\n const written = interpolate(\n state.timeMs - fromMs,\n [0, writeMs],\n [0, 1],\n clamp,\n );\n const seed = `caption-handwrite-${state.pageIndex}-${word[0].index}`;\n const tilt = (random(`${seed}-tilt`) * 3 - 1.5) * wobble;\n const lift = (random(`${seed}-lift`) * 0.08 - 0.04) * wobble;\n const head = written * (100 + EDGE_PERCENT);\n const stop = (percent: number): string =>\n `calc(${MASK_PAD_EM}em + (100% - ${MASK_PAD_EM * 2}em) * ${percent / 100})`;\n const mask =\n written > 0 && written < 1\n ? `linear-gradient(90deg, #000 ${stop(head - EDGE_PERCENT)}, transparent ${stop(head)})`\n : undefined;\n return (\n <Fragment key={`${state.pageIndex}-${word[0].index}`}>\n {w > 0 && \" \"}\n <span\n style={{\n display: \"inline-block\",\n whiteSpace: \"nowrap\",\n opacity: written > 0 ? 1 : 0,\n padding: `${MASK_PAD_EM}em`,\n margin: `-${MASK_PAD_EM}em`,\n transform: `translateY(${lift}em) rotate(${tilt}deg)`,\n WebkitMaskImage: mask,\n maskImage: mask,\n textShadow,\n }}\n >\n {Array.from(text).map((char, c) => (\n <span\n key={c}\n style={{\n display: \"inline-block\",\n whiteSpace: \"pre\",\n transform: `rotate(${(random(`${seed}-${c}`) * 6 - 3) * wobble}deg)`,\n }}\n >\n {char}\n </span>\n ))}\n </span>\n </Fragment>\n );\n })}\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n captions: {\n type: \"remotion-captions\",\n default: [{\n text: \" So\",\n startMs: 300,\n endMs: 460,\n timestampMs: 380,\n confidence: 0.97,\n }, {\n text: \" here's\",\n startMs: 460,\n endMs: 700,\n timestampMs: 580,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 700,\n endMs: 820,\n timestampMs: 760,\n confidence: 0.97,\n }, {\n text: \" thing.\",\n startMs: 820,\n endMs: 1240,\n timestampMs: 1030,\n confidence: 0.97,\n }, {\n text: \" Most\",\n startMs: 1700,\n endMs: 1960,\n timestampMs: 1830,\n confidence: 0.97,\n }, {\n text: \" demo\",\n startMs: 1960,\n endMs: 2240,\n timestampMs: 2100,\n confidence: 0.97,\n }, {\n text: \" videos\",\n startMs: 2240,\n endMs: 2680,\n timestampMs: 2460,\n confidence: 0.97,\n }, {\n text: \" lose\",\n startMs: 2680,\n endMs: 2960,\n timestampMs: 2820,\n confidence: 0.97,\n }, {\n text: \" people\",\n startMs: 2960,\n endMs: 3320,\n timestampMs: 3140,\n confidence: 0.97,\n }, {\n text: \" in\",\n startMs: 3320,\n endMs: 3420,\n timestampMs: 3370,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 3420,\n endMs: 3520,\n timestampMs: 3470,\n confidence: 0.97,\n }, {\n text: \" first\",\n startMs: 3520,\n endMs: 3820,\n timestampMs: 3670,\n confidence: 0.97,\n }, {\n text: \" three\",\n startMs: 3820,\n endMs: 4100,\n timestampMs: 3960,\n confidence: 0.97,\n }, {\n text: \" seconds.\",\n startMs: 4100,\n endMs: 4780,\n timestampMs: 4440,\n confidence: 0.97,\n }, {\n text: \" Captions\",\n startMs: 5400,\n endMs: 5920,\n timestampMs: 5660,\n confidence: 0.97,\n }, {\n text: \" keep\",\n startMs: 5920,\n endMs: 6140,\n timestampMs: 6030,\n confidence: 0.97,\n }, {\n text: \" them\",\n startMs: 6140,\n endMs: 6300,\n timestampMs: 6220,\n confidence: 0.97,\n }, {\n text: \" watching,\",\n startMs: 6300,\n endMs: 6860,\n timestampMs: 6580,\n confidence: 0.97,\n }, {\n text: \" even\",\n startMs: 6960,\n endMs: 7180,\n timestampMs: 7070,\n confidence: 0.97,\n }, {\n text: \" with\",\n startMs: 7180,\n endMs: 7320,\n timestampMs: 7250,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 7320,\n endMs: 7420,\n timestampMs: 7370,\n confidence: 0.97,\n }, {\n text: \" sound\",\n startMs: 7420,\n endMs: 7760,\n timestampMs: 7590,\n confidence: 0.97,\n }, {\n text: \" off.\",\n startMs: 7760,\n endMs: 8300,\n timestampMs: 8030,\n confidence: 0.97,\n }],\n description: \"Transcript\",\n keyframable: false,\n },\n fontSize: {\n type: \"number\",\n min: 24,\n max: 140,\n step: 1,\n default: 64,\n description: \"Font size\",\n hiddenFromList: false,\n },\n fontWeight: {\n type: \"number\",\n min: 400,\n max: 900,\n step: 100,\n default: 800,\n description: \"Font weight\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#ffffff\",\n description: \"Text color\",\n },\n wobble: {\n type: \"number\",\n min: 0,\n max: 2,\n step: 0.1,\n default: 1,\n description: \"Wobble\",\n hiddenFromList: false,\n },\n combineTokensWithinMilliseconds: {\n type: \"number\",\n min: 0,\n max: 3000,\n step: 100,\n default: 1200,\n description: \"Page window (ms)\",\n hiddenFromList: false,\n },\n holdMs: {\n type: \"number\",\n min: 0,\n max: 2000,\n step: 50,\n default: 600,\n description: \"Hold (ms)\",\n hiddenFromList: false,\n },\n shadow: {\n type: \"boolean\",\n default: true,\n description: \"Shadow\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"captions\",\"fontSize\",\"fontWeight\",\"color\",\"wobble\",\"combineTokensWithinMilliseconds\",\"holdMs\",\"shadow\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n captions: [{\n text: \" So\",\n startMs: 300,\n endMs: 460,\n timestampMs: 380,\n confidence: 0.97,\n }, {\n text: \" here's\",\n startMs: 460,\n endMs: 700,\n timestampMs: 580,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 700,\n endMs: 820,\n timestampMs: 760,\n confidence: 0.97,\n }, {\n text: \" thing.\",\n startMs: 820,\n endMs: 1240,\n timestampMs: 1030,\n confidence: 0.97,\n }, {\n text: \" Most\",\n startMs: 1700,\n endMs: 1960,\n timestampMs: 1830,\n confidence: 0.97,\n }, {\n text: \" demo\",\n startMs: 1960,\n endMs: 2240,\n timestampMs: 2100,\n confidence: 0.97,\n }, {\n text: \" videos\",\n startMs: 2240,\n endMs: 2680,\n timestampMs: 2460,\n confidence: 0.97,\n }, {\n text: \" lose\",\n startMs: 2680,\n endMs: 2960,\n timestampMs: 2820,\n confidence: 0.97,\n }, {\n text: \" people\",\n startMs: 2960,\n endMs: 3320,\n timestampMs: 3140,\n confidence: 0.97,\n }, {\n text: \" in\",\n startMs: 3320,\n endMs: 3420,\n timestampMs: 3370,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 3420,\n endMs: 3520,\n timestampMs: 3470,\n confidence: 0.97,\n }, {\n text: \" first\",\n startMs: 3520,\n endMs: 3820,\n timestampMs: 3670,\n confidence: 0.97,\n }, {\n text: \" three\",\n startMs: 3820,\n endMs: 4100,\n timestampMs: 3960,\n confidence: 0.97,\n }, {\n text: \" seconds.\",\n startMs: 4100,\n endMs: 4780,\n timestampMs: 4440,\n confidence: 0.97,\n }, {\n text: \" Captions\",\n startMs: 5400,\n endMs: 5920,\n timestampMs: 5660,\n confidence: 0.97,\n }, {\n text: \" keep\",\n startMs: 5920,\n endMs: 6140,\n timestampMs: 6030,\n confidence: 0.97,\n }, {\n text: \" them\",\n startMs: 6140,\n endMs: 6300,\n timestampMs: 6220,\n confidence: 0.97,\n }, {\n text: \" watching,\",\n startMs: 6300,\n endMs: 6860,\n timestampMs: 6580,\n confidence: 0.97,\n }, {\n text: \" even\",\n startMs: 6960,\n endMs: 7180,\n timestampMs: 7070,\n confidence: 0.97,\n }, {\n text: \" with\",\n startMs: 7180,\n endMs: 7320,\n timestampMs: 7250,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 7320,\n endMs: 7420,\n timestampMs: 7370,\n confidence: 0.97,\n }, {\n text: \" sound\",\n startMs: 7420,\n endMs: 7760,\n timestampMs: 7590,\n confidence: 0.97,\n }, {\n text: \" off.\",\n startMs: 7760,\n endMs: 8300,\n timestampMs: 8030,\n confidence: 0.97,\n }],\n fontSize: 64,\n fontWeight: 800,\n color: \"#ffffff\",\n wobble: 1,\n combineTokensWithinMilliseconds: 1200,\n holdMs: 600,\n shadow: true,\n};\n\ntype CaptionHandwriteElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof CaptionHandwriteBase>;\n\nconst CaptionHandwriteInner = forwardRef<\n HTMLDivElement,\n CaptionHandwriteElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<CaptionHandwrite>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <CaptionHandwriteBase\n {...(componentProps as unknown as ComponentProps<typeof CaptionHandwriteBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const CaptionHandwrite = Interactive.withSchema({\n Component: CaptionHandwriteInner,\n componentName: \"<CaptionHandwrite>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"+ },+ "durationInFrames": 279+}diff --git a/registry-artifacts/elements/caption-highlight-box.json b/registry-artifacts/elements/caption-highlight-box.jsonnew file mode 100644index 00000000..87479576--- /dev/null+++ b/registry-artifacts/elements/caption-highlight-box.json@@ -0,0 +1,21 @@+{+ "type": "remotion-element",+ "version": 1,+ "element": {+ "assets": [],+ "dependencies": [+ {+ "name": "@remotion/captions",+ "version": null+ }+ ],+ "dimensions": null,+ "displayName": "Caption Highlight Box",+ "durationInFrames": 279,+ "initialProps": null,+ "installationMode": "component-owned-sequence",+ "slug": "caption-highlight-box",+ "sourceCode": "import { Fragment, forwardRef, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState, type ComponentProps } from \"react\";\nimport { Easing, Interactive, Sequence, interpolate, interpolateColors, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { createTikTokStyleCaptions, type Caption, type TikTokPage } from \"@remotion/captions\";\n\ntype SpeakerCaption = Caption & { speaker?: string };\n\ninterface CaptionBaseProps {\n captions: Caption[];\n combineTokensWithinMilliseconds?: number;\n holdMs?: number;\n fontSize?: number;\n fontWeight?: number;\n color?: string;\n className?: string;\n}\n\nconst DEFAULT_HOLD_MS = 600;\nconst MIN_SILENCE_BREAK_MS = 300;\n\ninterface CaptionPageWindow {\n page: TikTokPage;\n index: number;\n speaker: string | undefined;\n startMs: number;\n speechEndMs: number;\n endMs: number;\n endsInSilence: boolean;\n}\n\ntype CaptionTokenStatus = \"upcoming\" | \"active\" | \"spoken\";\n\ninterface CaptionTokenState {\n text: string;\n spaceBefore: boolean;\n fromMs: number;\n toMs: number;\n progress: number;\n status: CaptionTokenStatus;\n}\n\ninterface CaptionPreviousPage {\n page: TikTokPage;\n pageIndex: number;\n tokens: CaptionTokenState[];\n}\n\ninterface CaptionsState {\n page: TikTokPage;\n pageIndex: number;\n speaker: string | undefined;\n timeMs: number;\n activeIndex: number;\n tokens: CaptionTokenState[];\n sinceStartMs: number;\n untilEndMs: number;\n holdRoomMs: number;\n endsInSilence: boolean;\n previous: CaptionPreviousPage | null;\n}\n\ninterface CaptionPagingOptions {\n combineTokensWithinMilliseconds: number;\n holdMs?: number;\n}\n\nconst SENTENCE_END = /[.!?…][\"')\\]]*$/;\n\nfunction markPageBreaks(captions: SpeakerCaption[]): Caption[] {\n return captions.map((caption, i) => {\n if (caption.pageBreakAfter !== undefined) return caption;\n const next = captions[i + 1];\n const speakerChanges =\n next !== undefined && next.speaker !== caption.speaker;\n return speakerChanges || SENTENCE_END.test(caption.text.trim())\n ? { ...caption, pageBreakAfter: true }\n : caption;\n });\n}\n\nfunction buildCaptionPages(\n captions: SpeakerCaption[],\n {\n combineTokensWithinMilliseconds,\n holdMs = DEFAULT_HOLD_MS,\n }: CaptionPagingOptions,\n): CaptionPageWindow[] {\n if (captions.length === 0) return [];\n const { pages } = createTikTokStyleCaptions({\n captions: markPageBreaks(captions),\n combineTokensWithinMilliseconds,\n breakOnSilenceAfterMilliseconds: Math.max(holdMs, MIN_SILENCE_BREAK_MS),\n });\n const speakers = new Map<number, string | undefined>();\n for (const caption of captions) {\n if (!speakers.has(caption.startMs)) {\n speakers.set(caption.startMs, caption.speaker);\n }\n }\n const spoken = pages.filter((page) => page.tokens.length > 0);\n return spoken.map((page, index) => {\n const last = page.tokens[page.tokens.length - 1];\n const speechEndMs = last ? last.toMs : page.startMs;\n const heldUntil = speechEndMs + Math.max(0, holdMs);\n const next = spoken[index + 1];\n const endsInSilence = !next || next.startMs > heldUntil;\n const endMs = endsInSilence\n ? heldUntil\n : Math.max(page.startMs, next.startMs);\n return {\n page,\n index,\n speaker: speakers.get(page.tokens[0].fromMs),\n startMs: page.startMs,\n speechEndMs,\n endMs,\n endsInSilence,\n };\n });\n}\n\nfunction findWindowIndex(windows: CaptionPageWindow[], timeMs: number): number {\n let lo = 0;\n let hi = windows.length - 1;\n let found = -1;\n while (lo <= hi) {\n const mid = (lo + hi) >> 1;\n if (windows[mid].startMs <= timeMs) {\n found = mid;\n lo = mid + 1;\n } else {\n hi = mid - 1;\n }\n }\n if (found === -1) return -1;\n return timeMs < windows[found].endMs ? found : -1;\n}\n\nfunction tokenProgress(fromMs: number, toMs: number, timeMs: number): number {\n if (timeMs < fromMs) return 0;\n if (toMs <= fromMs) return 1;\n return Math.min(1, (timeMs - fromMs) / (toMs - fromMs));\n}\n\nfunction getTokenStates(\n page: TikTokPage,\n timeMs: number,\n): { activeIndex: number; tokens: CaptionTokenState[] } {\n let activeIndex = -1;\n page.tokens.forEach((token, i) => {\n if (token.fromMs <= timeMs) activeIndex = i;\n });\n const tokens = page.tokens.map(\n (token, i): CaptionTokenState => ({\n text: token.text.trim(),\n spaceBefore: i > 0 && /^\\s/.test(token.text),\n fromMs: token.fromMs,\n toMs: token.toMs,\n progress: tokenProgress(token.fromMs, token.toMs, timeMs),\n status:\n i < activeIndex ? \"spoken\" : i === activeIndex ? \"active\" : \"upcoming\",\n }),\n );\n return { activeIndex, tokens };\n}\n\nfunction getCaptionsState(\n windows: CaptionPageWindow[],\n timeMs: number,\n): CaptionsState | null {\n const found = findWindowIndex(windows, timeMs);\n if (found === -1) return null;\n const window = windows[found];\n const { activeIndex, tokens } = getTokenStates(window.page, timeMs);\n const before = found > 0 ? windows[found - 1] : null;\n const previous =\n before && !before.endsInSilence\n ? {\n page: before.page,\n pageIndex: before.index,\n tokens: getTokenStates(before.page, before.endMs).tokens,\n }\n : null;\n return {\n page: window.page,\n pageIndex: window.index,\n speaker: window.speaker,\n timeMs,\n activeIndex,\n tokens,\n sinceStartMs: timeMs - window.startMs,\n untilEndMs: window.endMs - timeMs,\n holdRoomMs: window.endMs - window.speechEndMs,\n endsInSilence: window.endsInSilence,\n previous,\n };\n}\n\nfunction getExitWindowMs(state: CaptionsState, exitMs: number): number {\n return Math.max(1, Math.min(exitMs, state.holdRoomMs));\n}\n\nfunction groupCaptionWords(\n tokens: CaptionTokenState[],\n): { index: number; token: CaptionTokenState }[][] {\n const words: { index: number; token: CaptionTokenState }[][] = [];\n tokens.forEach((token, index) => {\n const current = words[words.length - 1];\n if (!current || token.spaceBefore) {\n words.push([{ index, token }]);\n } else {\n current.push({ index, token });\n }\n });\n return words;\n}\n\nfunction normalizeCaptionWord(text: string): string {\n return text\n .toLowerCase()\n .replace(/[\\u2018\\u2019]/g, \"'\")\n .replace(/[^\\p{L}\\p{N}']/gu, \"\");\n}\n\nfunction createKeywordMatcher(\n keywords: readonly string[] = [],\n): (text: string) => boolean {\n const set = new Set(keywords.map(normalizeCaptionWord).filter(Boolean));\n return (text) => set.has(normalizeCaptionWord(text));\n}\n\nfunction captionWordText(word: { token: CaptionTokenState }[]): string {\n return word.map(({ token }) => token.text).join(\"\");\n}\n\ninterface CaptionWordRect {\n left: number;\n top: number;\n width: number;\n height: number;\n}\n\nfunction sameRects(a: CaptionWordRect[], b: CaptionWordRect[]): boolean {\n return (\n a.length === b.length &&\n a.every(\n (r, i) =>\n r.left === b[i].left &&\n r.top === b[i].top &&\n r.width === b[i].width &&\n r.height === b[i].height,\n )\n );\n}\n\nfunction useCaptionWordRects(\n pageIndex: number,\n count: number,\n): {\n wordRef: (index: number) => (el: HTMLElement | null) => void;\n rects: CaptionWordRect[] | null;\n} {\n const elements = useRef<(HTMLElement | null)[]>([]);\n const [measured, setMeasured] = useState<{\n pageIndex: number;\n rects: CaptionWordRect[];\n } | null>(null);\n\n useLayoutEffect(() => {\n if (pageIndex === -1) return;\n const rects = elements.current.slice(0, count).map((el) =>\n el\n ? {\n left: el.offsetLeft,\n top: el.offsetTop,\n width: el.offsetWidth,\n height: el.offsetHeight,\n }\n : { left: 0, top: 0, width: 0, height: 0 },\n );\n setMeasured((prev) =>\n prev && prev.pageIndex === pageIndex && sameRects(prev.rects, rects)\n ? prev\n : { pageIndex, rects },\n );\n });\n\n return {\n wordRef: (index) => (el) => {\n elements.current[index] = el;\n },\n rects: measured && measured.pageIndex === pageIndex ? measured.rects : null,\n };\n}\n\nfunction useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs = DEFAULT_HOLD_MS,\n}: {\n captions: SpeakerCaption[];\n combineTokensWithinMilliseconds: number;\n holdMs?: number;\n}): CaptionsState | null {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const windows = useMemo(\n () =>\n buildCaptionPages(captions, { combineTokensWithinMilliseconds, holdMs }),\n [captions, combineTokensWithinMilliseconds, holdMs],\n );\n return getCaptionsState(windows, (frame / fps) * 1000);\n}\n\ninterface CaptionHighlightBoxProps extends CaptionBaseProps {\n activeColor?: string;\n boxColor?: string;\n boxRadius?: number;\n boxPadding?: number;\n shadow?: boolean;\n}\n\nconst ENTER_MS = 160;\nconst EXIT_MS = 220;\nconst RISE_EM = 0.14;\nconst TRAVEL_MS = 120;\n\nconst enterEasing = Easing.bezier(0.2, 0.8, 0.2, 1);\nconst travelEasing = Easing.bezier(0.3, 0, 0.2, 1);\n\nconst clamp = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n} as const;\n\nfunction legibilityShadow(strength: number): string | undefined {\n if (strength <= 0) return undefined;\n return `0 2px 3px rgba(0, 0, 0, ${0.5 * strength}), 0 4px 16px rgba(0, 0, 0, ${0.35 * strength})`;\n}\n\nfunction mix(a: number, b: number, t: number): number {\n return a + (b - a) * t;\n}\n\nfunction CaptionHighlightBoxBase({\n captions,\n combineTokensWithinMilliseconds = 1200,\n holdMs = DEFAULT_HOLD_MS,\n fontSize = 64,\n fontWeight = 800,\n color = \"#ffffff\",\n activeColor = \"#0a0a0a\",\n boxColor = \"#facc15\",\n boxRadius = 0.16,\n boxPadding = 0.14,\n shadow = true,\n className,\n}: CaptionHighlightBoxProps) {\n const state = useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs,\n });\n const words = state ? groupCaptionWords(state.tokens) : [];\n const pageIndex = state ? state.pageIndex : -1;\n const { wordRef, rects } = useCaptionWordRects(pageIndex, words.length);\n\n if (!state) return null;\n\n const enter = interpolate(\n state.previous ? ENTER_MS : state.sinceStartMs,\n [0, ENTER_MS],\n [0, 1],\n {\n ...clamp,\n easing: enterEasing,\n },\n );\n const exit = state.endsInSilence\n ? interpolate(\n state.untilEndMs,\n [0, getExitWindowMs(state, EXIT_MS)],\n [0, 1],\n clamp,\n )\n : 1;\n\n const activeWord = words.findIndex((word) =>\n word.some(({ index }) => index === state.activeIndex),\n );\n const travel =\n activeWord >= 0\n ? interpolate(\n state.timeMs - words[activeWord][0].token.fromMs,\n [0, TRAVEL_MS],\n [0, 1],\n { ...clamp, easing: travelEasing },\n )\n : 0;\n\n const target = rects && activeWord >= 0 ? rects[activeWord] : null;\n const origin = rects && activeWord > 0 ? rects[activeWord - 1] : null;\n const padX = boxPadding * fontSize;\n const padY = boxPadding * 0.3 * fontSize;\n const box = target\n ? {\n left: origin ? mix(origin.left, target.left, travel) : target.left,\n top: origin ? mix(origin.top, target.top, travel) : target.top,\n width: origin ? mix(origin.width, target.width, travel) : target.width,\n height: origin\n ? mix(origin.height, target.height, travel)\n : target.height,\n opacity: origin ? 1 : travel,\n }\n : null;\n\n const coverage = (w: number): number => {\n if (!box) return 0;\n if (w === activeWord) {\n return origin ? interpolate(travel, [0.3, 0.8], [0, 1], clamp) : travel;\n }\n if (origin && w === activeWord - 1) {\n return 1 - interpolate(travel, [0.2, 0.7], [0, 1], clamp);\n }\n return 0;\n };\n\n return (\n <div\n className={className}\n style={{\n position: \"relative\",\n isolation: \"isolate\",\n fontSize,\n fontWeight,\n color,\n lineHeight: 1.2,\n textAlign: \"center\",\n opacity: Math.min(enter, exit),\n transform: `translateY(${(1 - enter) * RISE_EM}em)`,\n }}\n >\n {box && (\n <span\n aria-hidden\n style={{\n position: \"absolute\",\n left: box.left - padX,\n top: box.top - padY,\n width: box.width + padX * 2,\n height: box.height + padY * 2,\n borderRadius: boxRadius * fontSize,\n background: boxColor,\n opacity: box.opacity,\n }}\n />\n )}\n {words.map((word, w) => {\n const covered = coverage(w);\n return (\n <Fragment key={`${state.pageIndex}-${word[0].index}`}>\n {w > 0 && \" \"}\n <span\n ref={wordRef(w)}\n style={{\n position: \"relative\",\n display: \"inline-block\",\n whiteSpace: \"nowrap\",\n color: interpolateColors(covered, [0, 1], [color, activeColor]),\n textShadow: legibilityShadow(shadow ? 1 - covered : 0),\n }}\n >\n {word.map(({ index, token }) => (\n <span key={index}>{token.text}</span>\n ))}\n </span>\n </Fragment>\n );\n })}\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n captions: {\n type: \"remotion-captions\",\n default: [{\n text: \" So\",\n startMs: 300,\n endMs: 460,\n timestampMs: 380,\n confidence: 0.97,\n }, {\n text: \" here's\",\n startMs: 460,\n endMs: 700,\n timestampMs: 580,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 700,\n endMs: 820,\n timestampMs: 760,\n confidence: 0.97,\n }, {\n text: \" thing.\",\n startMs: 820,\n endMs: 1240,\n timestampMs: 1030,\n confidence: 0.97,\n }, {\n text: \" Most\",\n startMs: 1700,\n endMs: 1960,\n timestampMs: 1830,\n confidence: 0.97,\n }, {\n text: \" demo\",\n startMs: 1960,\n endMs: 2240,\n timestampMs: 2100,\n confidence: 0.97,\n }, {\n text: \" videos\",\n startMs: 2240,\n endMs: 2680,\n timestampMs: 2460,\n confidence: 0.97,\n }, {\n text: \" lose\",\n startMs: 2680,\n endMs: 2960,\n timestampMs: 2820,\n confidence: 0.97,\n }, {\n text: \" people\",\n startMs: 2960,\n endMs: 3320,\n timestampMs: 3140,\n confidence: 0.97,\n }, {\n text: \" in\",\n startMs: 3320,\n endMs: 3420,\n timestampMs: 3370,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 3420,\n endMs: 3520,\n timestampMs: 3470,\n confidence: 0.97,\n }, {\n text: \" first\",\n startMs: 3520,\n endMs: 3820,\n timestampMs: 3670,\n confidence: 0.97,\n }, {\n text: \" three\",\n startMs: 3820,\n endMs: 4100,\n timestampMs: 3960,\n confidence: 0.97,\n }, {\n text: \" seconds.\",\n startMs: 4100,\n endMs: 4780,\n timestampMs: 4440,\n confidence: 0.97,\n }, {\n text: \" Captions\",\n startMs: 5400,\n endMs: 5920,\n timestampMs: 5660,\n confidence: 0.97,\n }, {\n text: \" keep\",\n startMs: 5920,\n endMs: 6140,\n timestampMs: 6030,\n confidence: 0.97,\n }, {\n text: \" them\",\n startMs: 6140,\n endMs: 6300,\n timestampMs: 6220,\n confidence: 0.97,\n }, {\n text: \" watching,\",\n startMs: 6300,\n endMs: 6860,\n timestampMs: 6580,\n confidence: 0.97,\n }, {\n text: \" even\",\n startMs: 6960,\n endMs: 7180,\n timestampMs: 7070,\n confidence: 0.97,\n }, {\n text: \" with\",\n startMs: 7180,\n endMs: 7320,\n timestampMs: 7250,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 7320,\n endMs: 7420,\n timestampMs: 7370,\n confidence: 0.97,\n }, {\n text: \" sound\",\n startMs: 7420,\n endMs: 7760,\n timestampMs: 7590,\n confidence: 0.97,\n }, {\n text: \" off.\",\n startMs: 7760,\n endMs: 8300,\n timestampMs: 8030,\n confidence: 0.97,\n }],\n description: \"Transcript\",\n keyframable: false,\n },\n fontSize: {\n type: \"number\",\n min: 24,\n max: 140,\n step: 1,\n default: 64,\n description: \"Font size\",\n hiddenFromList: false,\n },\n fontWeight: {\n type: \"number\",\n min: 400,\n max: 900,\n step: 100,\n default: 800,\n description: \"Font weight\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#ffffff\",\n description: \"Text color\",\n },\n activeColor: {\n type: \"color\",\n default: \"#0a0a0a\",\n description: \"Text on box\",\n },\n boxColor: {\n type: \"color\",\n default: \"#facc15\",\n description: \"Box color\",\n },\n boxRadius: {\n type: \"number\",\n min: 0,\n max: 0.5,\n step: 0.01,\n default: 0.16,\n description: \"Box radius (em)\",\n hiddenFromList: false,\n },\n boxPadding: {\n type: \"number\",\n min: 0,\n max: 0.4,\n step: 0.01,\n default: 0.14,\n description: \"Box padding (em)\",\n hiddenFromList: false,\n },\n combineTokensWithinMilliseconds: {\n type: \"number\",\n min: 0,\n max: 3000,\n step: 100,\n default: 1200,\n description: \"Page window (ms)\",\n hiddenFromList: false,\n },\n holdMs: {\n type: \"number\",\n min: 0,\n max: 2000,\n step: 50,\n default: 600,\n description: \"Hold (ms)\",\n hiddenFromList: false,\n },\n shadow: {\n type: \"boolean\",\n default: true,\n description: \"Shadow\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"captions\",\"fontSize\",\"fontWeight\",\"color\",\"activeColor\",\"boxColor\",\"boxRadius\",\"boxPadding\",\"combineTokensWithinMilliseconds\",\"holdMs\",\"shadow\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n captions: [{\n text: \" So\",\n startMs: 300,\n endMs: 460,\n timestampMs: 380,\n confidence: 0.97,\n }, {\n text: \" here's\",\n startMs: 460,\n endMs: 700,\n timestampMs: 580,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 700,\n endMs: 820,\n timestampMs: 760,\n confidence: 0.97,\n }, {\n text: \" thing.\",\n startMs: 820,\n endMs: 1240,\n timestampMs: 1030,\n confidence: 0.97,\n }, {\n text: \" Most\",\n startMs: 1700,\n endMs: 1960,\n timestampMs: 1830,\n confidence: 0.97,\n }, {\n text: \" demo\",\n startMs: 1960,\n endMs: 2240,\n timestampMs: 2100,\n confidence: 0.97,\n }, {\n text: \" videos\",\n startMs: 2240,\n endMs: 2680,\n timestampMs: 2460,\n confidence: 0.97,\n }, {\n text: \" lose\",\n startMs: 2680,\n endMs: 2960,\n timestampMs: 2820,\n confidence: 0.97,\n }, {\n text: \" people\",\n startMs: 2960,\n endMs: 3320,\n timestampMs: 3140,\n confidence: 0.97,\n }, {\n text: \" in\",\n startMs: 3320,\n endMs: 3420,\n timestampMs: 3370,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 3420,\n endMs: 3520,\n timestampMs: 3470,\n confidence: 0.97,\n }, {\n text: \" first\",\n startMs: 3520,\n endMs: 3820,\n timestampMs: 3670,\n confidence: 0.97,\n }, {\n text: \" three\",\n startMs: 3820,\n endMs: 4100,\n timestampMs: 3960,\n confidence: 0.97,\n }, {\n text: \" seconds.\",\n startMs: 4100,\n endMs: 4780,\n timestampMs: 4440,\n confidence: 0.97,\n }, {\n text: \" Captions\",\n startMs: 5400,\n endMs: 5920,\n timestampMs: 5660,\n confidence: 0.97,\n }, {\n text: \" keep\",\n startMs: 5920,\n endMs: 6140,\n timestampMs: 6030,\n confidence: 0.97,\n }, {\n text: \" them\",\n startMs: 6140,\n endMs: 6300,\n timestampMs: 6220,\n confidence: 0.97,\n }, {\n text: \" watching,\",\n startMs: 6300,\n endMs: 6860,\n timestampMs: 6580,\n confidence: 0.97,\n }, {\n text: \" even\",\n startMs: 6960,\n endMs: 7180,\n timestampMs: 7070,\n confidence: 0.97,\n }, {\n text: \" with\",\n startMs: 7180,\n endMs: 7320,\n timestampMs: 7250,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 7320,\n endMs: 7420,\n timestampMs: 7370,\n confidence: 0.97,\n }, {\n text: \" sound\",\n startMs: 7420,\n endMs: 7760,\n timestampMs: 7590,\n confidence: 0.97,\n }, {\n text: \" off.\",\n startMs: 7760,\n endMs: 8300,\n timestampMs: 8030,\n confidence: 0.97,\n }],\n fontSize: 64,\n fontWeight: 800,\n color: \"#ffffff\",\n activeColor: \"#0a0a0a\",\n boxColor: \"#facc15\",\n boxRadius: 0.16,\n boxPadding: 0.14,\n combineTokensWithinMilliseconds: 1200,\n holdMs: 600,\n shadow: true,\n};\n\ntype CaptionHighlightBoxElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof CaptionHighlightBoxBase>;\n\nconst CaptionHighlightBoxInner = forwardRef<\n HTMLDivElement,\n CaptionHighlightBoxElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<CaptionHighlightBox>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <CaptionHighlightBoxBase\n {...(componentProps as unknown as ComponentProps<typeof CaptionHighlightBoxBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const CaptionHighlightBox = Interactive.withSchema({\n Component: CaptionHighlightBoxInner,\n componentName: \"<CaptionHighlightBox>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"+ },+ "durationInFrames": 279+}diff --git a/registry-artifacts/elements/caption-karaoke.json b/registry-artifacts/elements/caption-karaoke.jsonnew file mode 100644index 00000000..cd04c257--- /dev/null+++ b/registry-artifacts/elements/caption-karaoke.json@@ -0,0 +1,21 @@+{+ "type": "remotion-element",+ "version": 1,+ "element": {+ "assets": [],+ "dependencies": [+ {+ "name": "@remotion/captions",+ "version": null+ }+ ],+ "dimensions": null,+ "displayName": "Caption Karaoke",+ "durationInFrames": 279,+ "initialProps": null,+ "installationMode": "component-owned-sequence",+ "slug": "caption-karaoke",+ "sourceCode": "import { Fragment, forwardRef, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState, type ComponentProps } from \"react\";\nimport { Easing, Interactive, Sequence, interpolate, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { createTikTokStyleCaptions, type Caption, type TikTokPage } from \"@remotion/captions\";\n\ntype SpeakerCaption = Caption & { speaker?: string };\n\ninterface CaptionBaseProps {\n captions: Caption[];\n combineTokensWithinMilliseconds?: number;\n holdMs?: number;\n fontSize?: number;\n fontWeight?: number;\n color?: string;\n className?: string;\n}\n\nconst DEFAULT_HOLD_MS = 600;\nconst MIN_SILENCE_BREAK_MS = 300;\n\ninterface CaptionPageWindow {\n page: TikTokPage;\n index: number;\n speaker: string | undefined;\n startMs: number;\n speechEndMs: number;\n endMs: number;\n endsInSilence: boolean;\n}\n\ntype CaptionTokenStatus = \"upcoming\" | \"active\" | \"spoken\";\n\ninterface CaptionTokenState {\n text: string;\n spaceBefore: boolean;\n fromMs: number;\n toMs: number;\n progress: number;\n status: CaptionTokenStatus;\n}\n\ninterface CaptionPreviousPage {\n page: TikTokPage;\n pageIndex: number;\n tokens: CaptionTokenState[];\n}\n\ninterface CaptionsState {\n page: TikTokPage;\n pageIndex: number;\n speaker: string | undefined;\n timeMs: number;\n activeIndex: number;\n tokens: CaptionTokenState[];\n sinceStartMs: number;\n untilEndMs: number;\n holdRoomMs: number;\n endsInSilence: boolean;\n previous: CaptionPreviousPage | null;\n}\n\ninterface CaptionPagingOptions {\n combineTokensWithinMilliseconds: number;\n holdMs?: number;\n}\n\nconst SENTENCE_END = /[.!?…][\"')\\]]*$/;\n\nfunction markPageBreaks(captions: SpeakerCaption[]): Caption[] {\n return captions.map((caption, i) => {\n if (caption.pageBreakAfter !== undefined) return caption;\n const next = captions[i + 1];\n const speakerChanges =\n next !== undefined && next.speaker !== caption.speaker;\n return speakerChanges || SENTENCE_END.test(caption.text.trim())\n ? { ...caption, pageBreakAfter: true }\n : caption;\n });\n}\n\nfunction buildCaptionPages(\n captions: SpeakerCaption[],\n {\n combineTokensWithinMilliseconds,\n holdMs = DEFAULT_HOLD_MS,\n }: CaptionPagingOptions,\n): CaptionPageWindow[] {\n if (captions.length === 0) return [];\n const { pages } = createTikTokStyleCaptions({\n captions: markPageBreaks(captions),\n combineTokensWithinMilliseconds,\n breakOnSilenceAfterMilliseconds: Math.max(holdMs, MIN_SILENCE_BREAK_MS),\n });\n const speakers = new Map<number, string | undefined>();\n for (const caption of captions) {\n if (!speakers.has(caption.startMs)) {\n speakers.set(caption.startMs, caption.speaker);\n }\n }\n const spoken = pages.filter((page) => page.tokens.length > 0);\n return spoken.map((page, index) => {\n const last = page.tokens[page.tokens.length - 1];\n const speechEndMs = last ? last.toMs : page.startMs;\n const heldUntil = speechEndMs + Math.max(0, holdMs);\n const next = spoken[index + 1];\n const endsInSilence = !next || next.startMs > heldUntil;\n const endMs = endsInSilence\n ? heldUntil\n : Math.max(page.startMs, next.startMs);\n return {\n page,\n index,\n speaker: speakers.get(page.tokens[0].fromMs),\n startMs: page.startMs,\n speechEndMs,\n endMs,\n endsInSilence,\n };\n });\n}\n\nfunction findWindowIndex(windows: CaptionPageWindow[], timeMs: number): number {\n let lo = 0;\n let hi = windows.length - 1;\n let found = -1;\n while (lo <= hi) {\n const mid = (lo + hi) >> 1;\n if (windows[mid].startMs <= timeMs) {\n found = mid;\n lo = mid + 1;\n } else {\n hi = mid - 1;\n }\n }\n if (found === -1) return -1;\n return timeMs < windows[found].endMs ? found : -1;\n}\n\nfunction tokenProgress(fromMs: number, toMs: number, timeMs: number): number {\n if (timeMs < fromMs) return 0;\n if (toMs <= fromMs) return 1;\n return Math.min(1, (timeMs - fromMs) / (toMs - fromMs));\n}\n\nfunction getTokenStates(\n page: TikTokPage,\n timeMs: number,\n): { activeIndex: number; tokens: CaptionTokenState[] } {\n let activeIndex = -1;\n page.tokens.forEach((token, i) => {\n if (token.fromMs <= timeMs) activeIndex = i;\n });\n const tokens = page.tokens.map(\n (token, i): CaptionTokenState => ({\n text: token.text.trim(),\n spaceBefore: i > 0 && /^\\s/.test(token.text),\n fromMs: token.fromMs,\n toMs: token.toMs,\n progress: tokenProgress(token.fromMs, token.toMs, timeMs),\n status:\n i < activeIndex ? \"spoken\" : i === activeIndex ? \"active\" : \"upcoming\",\n }),\n );\n return { activeIndex, tokens };\n}\n\nfunction getCaptionsState(\n windows: CaptionPageWindow[],\n timeMs: number,\n): CaptionsState | null {\n const found = findWindowIndex(windows, timeMs);\n if (found === -1) return null;\n const window = windows[found];\n const { activeIndex, tokens } = getTokenStates(window.page, timeMs);\n const before = found > 0 ? windows[found - 1] : null;\n const previous =\n before && !before.endsInSilence\n ? {\n page: before.page,\n pageIndex: before.index,\n tokens: getTokenStates(before.page, before.endMs).tokens,\n }\n : null;\n return {\n page: window.page,\n pageIndex: window.index,\n speaker: window.speaker,\n timeMs,\n activeIndex,\n tokens,\n sinceStartMs: timeMs - window.startMs,\n untilEndMs: window.endMs - timeMs,\n holdRoomMs: window.endMs - window.speechEndMs,\n endsInSilence: window.endsInSilence,\n previous,\n };\n}\n\nfunction getExitWindowMs(state: CaptionsState, exitMs: number): number {\n return Math.max(1, Math.min(exitMs, state.holdRoomMs));\n}\n\nfunction groupCaptionWords(\n tokens: CaptionTokenState[],\n): { index: number; token: CaptionTokenState }[][] {\n const words: { index: number; token: CaptionTokenState }[][] = [];\n tokens.forEach((token, index) => {\n const current = words[words.length - 1];\n if (!current || token.spaceBefore) {\n words.push([{ index, token }]);\n } else {\n current.push({ index, token });\n }\n });\n return words;\n}\n\nfunction normalizeCaptionWord(text: string): string {\n return text\n .toLowerCase()\n .replace(/[\\u2018\\u2019]/g, \"'\")\n .replace(/[^\\p{L}\\p{N}']/gu, \"\");\n}\n\nfunction createKeywordMatcher(\n keywords: readonly string[] = [],\n): (text: string) => boolean {\n const set = new Set(keywords.map(normalizeCaptionWord).filter(Boolean));\n return (text) => set.has(normalizeCaptionWord(text));\n}\n\nfunction captionWordText(word: { token: CaptionTokenState }[]): string {\n return word.map(({ token }) => token.text).join(\"\");\n}\n\ninterface CaptionWordRect {\n left: number;\n top: number;\n width: number;\n height: number;\n}\n\nfunction sameRects(a: CaptionWordRect[], b: CaptionWordRect[]): boolean {\n return (\n a.length === b.length &&\n a.every(\n (r, i) =>\n r.left === b[i].left &&\n r.top === b[i].top &&\n r.width === b[i].width &&\n r.height === b[i].height,\n )\n );\n}\n\nfunction useCaptionWordRects(\n pageIndex: number,\n count: number,\n): {\n wordRef: (index: number) => (el: HTMLElement | null) => void;\n rects: CaptionWordRect[] | null;\n} {\n const elements = useRef<(HTMLElement | null)[]>([]);\n const [measured, setMeasured] = useState<{\n pageIndex: number;\n rects: CaptionWordRect[];\n } | null>(null);\n\n useLayoutEffect(() => {\n if (pageIndex === -1) return;\n const rects = elements.current.slice(0, count).map((el) =>\n el\n ? {\n left: el.offsetLeft,\n top: el.offsetTop,\n width: el.offsetWidth,\n height: el.offsetHeight,\n }\n : { left: 0, top: 0, width: 0, height: 0 },\n );\n setMeasured((prev) =>\n prev && prev.pageIndex === pageIndex && sameRects(prev.rects, rects)\n ? prev\n : { pageIndex, rects },\n );\n });\n\n return {\n wordRef: (index) => (el) => {\n elements.current[index] = el;\n },\n rects: measured && measured.pageIndex === pageIndex ? measured.rects : null,\n };\n}\n\nfunction useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs = DEFAULT_HOLD_MS,\n}: {\n captions: SpeakerCaption[];\n combineTokensWithinMilliseconds: number;\n holdMs?: number;\n}): CaptionsState | null {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const windows = useMemo(\n () =>\n buildCaptionPages(captions, { combineTokensWithinMilliseconds, holdMs }),\n [captions, combineTokensWithinMilliseconds, holdMs],\n );\n return getCaptionsState(windows, (frame / fps) * 1000);\n}\n\ninterface CaptionKaraokeProps extends CaptionBaseProps {\n activeColor?: string;\n shadow?: boolean;\n}\n\nconst ENTER_MS = 160;\nconst EXIT_MS = 220;\nconst RISE_EM = 0.14;\nconst LEGIBILITY_SHADOW =\n \"0 2px 3px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.35)\";\n\nconst enterEasing = Easing.bezier(0.2, 0.8, 0.2, 1);\n\nfunction CaptionKaraokeBase({\n captions,\n combineTokensWithinMilliseconds = 1200,\n holdMs = DEFAULT_HOLD_MS,\n fontSize = 64,\n fontWeight = 800,\n color = \"#ffffff\",\n activeColor = \"#facc15\",\n shadow = true,\n className,\n}: CaptionKaraokeProps) {\n const state = useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs,\n });\n if (!state) return null;\n\n const enter = interpolate(\n state.previous ? ENTER_MS : state.sinceStartMs,\n [0, ENTER_MS],\n [0, 1],\n {\n easing: enterEasing,\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n },\n );\n const exit = state.endsInSilence\n ? interpolate(\n state.untilEndMs,\n [0, getExitWindowMs(state, EXIT_MS)],\n [0, 1],\n {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n },\n )\n : 1;\n\n return (\n <div\n className={className}\n style={{\n fontSize,\n fontWeight,\n color,\n lineHeight: 1.2,\n textAlign: \"center\",\n opacity: Math.min(enter, exit),\n transform: `translateY(${(1 - enter) * RISE_EM}em)`,\n }}\n >\n {groupCaptionWords(state.tokens).map((word, w) => (\n <Fragment key={`${state.pageIndex}-${word[0].index}`}>\n {w > 0 && \" \"}\n <span style={{ display: \"inline-block\", whiteSpace: \"nowrap\" }}>\n {word.map(({ index, token }) => (\n <span\n key={index}\n style={{ position: \"relative\", display: \"inline-block\" }}\n >\n <span\n style={{ textShadow: shadow ? LEGIBILITY_SHADOW : undefined }}\n >\n {token.text}\n </span>\n <span\n aria-hidden\n style={{\n position: \"absolute\",\n inset: 0,\n color: activeColor,\n clipPath: `inset(0 ${(1 - token.progress) * 100}% 0 0)`,\n }}\n >\n {token.text}\n </span>\n </span>\n ))}\n </span>\n </Fragment>\n ))}\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n captions: {\n type: \"remotion-captions\",\n default: [{\n text: \" So\",\n startMs: 300,\n endMs: 460,\n timestampMs: 380,\n confidence: 0.97,\n }, {\n text: \" here's\",\n startMs: 460,\n endMs: 700,\n timestampMs: 580,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 700,\n endMs: 820,\n timestampMs: 760,\n confidence: 0.97,\n }, {\n text: \" thing.\",\n startMs: 820,\n endMs: 1240,\n timestampMs: 1030,\n confidence: 0.97,\n }, {\n text: \" Most\",\n startMs: 1700,\n endMs: 1960,\n timestampMs: 1830,\n confidence: 0.97,\n }, {\n text: \" demo\",\n startMs: 1960,\n endMs: 2240,\n timestampMs: 2100,\n confidence: 0.97,\n }, {\n text: \" videos\",\n startMs: 2240,\n endMs: 2680,\n timestampMs: 2460,\n confidence: 0.97,\n }, {\n text: \" lose\",\n startMs: 2680,\n endMs: 2960,\n timestampMs: 2820,\n confidence: 0.97,\n }, {\n text: \" people\",\n startMs: 2960,\n endMs: 3320,\n timestampMs: 3140,\n confidence: 0.97,\n }, {\n text: \" in\",\n startMs: 3320,\n endMs: 3420,\n timestampMs: 3370,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 3420,\n endMs: 3520,\n timestampMs: 3470,\n confidence: 0.97,\n }, {\n text: \" first\",\n startMs: 3520,\n endMs: 3820,\n timestampMs: 3670,\n confidence: 0.97,\n }, {\n text: \" three\",\n startMs: 3820,\n endMs: 4100,\n timestampMs: 3960,\n confidence: 0.97,\n }, {\n text: \" seconds.\",\n startMs: 4100,\n endMs: 4780,\n timestampMs: 4440,\n confidence: 0.97,\n }, {\n text: \" Captions\",\n startMs: 5400,\n endMs: 5920,\n timestampMs: 5660,\n confidence: 0.97,\n }, {\n text: \" keep\",\n startMs: 5920,\n endMs: 6140,\n timestampMs: 6030,\n confidence: 0.97,\n }, {\n text: \" them\",\n startMs: 6140,\n endMs: 6300,\n timestampMs: 6220,\n confidence: 0.97,\n }, {\n text: \" watching,\",\n startMs: 6300,\n endMs: 6860,\n timestampMs: 6580,\n confidence: 0.97,\n }, {\n text: \" even\",\n startMs: 6960,\n endMs: 7180,\n timestampMs: 7070,\n confidence: 0.97,\n }, {\n text: \" with\",\n startMs: 7180,\n endMs: 7320,\n timestampMs: 7250,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 7320,\n endMs: 7420,\n timestampMs: 7370,\n confidence: 0.97,\n }, {\n text: \" sound\",\n startMs: 7420,\n endMs: 7760,\n timestampMs: 7590,\n confidence: 0.97,\n }, {\n text: \" off.\",\n startMs: 7760,\n endMs: 8300,\n timestampMs: 8030,\n confidence: 0.97,\n }],\n description: \"Transcript\",\n keyframable: false,\n },\n fontSize: {\n type: \"number\",\n min: 24,\n max: 140,\n step: 1,\n default: 64,\n description: \"Font size\",\n hiddenFromList: false,\n },\n fontWeight: {\n type: \"number\",\n min: 400,\n max: 900,\n step: 100,\n default: 800,\n description: \"Font weight\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#ffffff\",\n description: \"Text color\",\n },\n activeColor: {\n type: \"color\",\n default: \"#facc15\",\n description: \"Fill color\",\n },\n combineTokensWithinMilliseconds: {\n type: \"number\",\n min: 0,\n max: 3000,\n step: 100,\n default: 1200,\n description: \"Page window (ms)\",\n hiddenFromList: false,\n },\n holdMs: {\n type: \"number\",\n min: 0,\n max: 2000,\n step: 50,\n default: 600,\n description: \"Hold (ms)\",\n hiddenFromList: false,\n },\n shadow: {\n type: \"boolean\",\n default: true,\n description: \"Shadow\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"captions\",\"fontSize\",\"fontWeight\",\"color\",\"activeColor\",\"combineTokensWithinMilliseconds\",\"holdMs\",\"shadow\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n captions: [{\n text: \" So\",\n startMs: 300,\n endMs: 460,\n timestampMs: 380,\n confidence: 0.97,\n }, {\n text: \" here's\",\n startMs: 460,\n endMs: 700,\n timestampMs: 580,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 700,\n endMs: 820,\n timestampMs: 760,\n confidence: 0.97,\n }, {\n text: \" thing.\",\n startMs: 820,\n endMs: 1240,\n timestampMs: 1030,\n confidence: 0.97,\n }, {\n text: \" Most\",\n startMs: 1700,\n endMs: 1960,\n timestampMs: 1830,\n confidence: 0.97,\n }, {\n text: \" demo\",\n startMs: 1960,\n endMs: 2240,\n timestampMs: 2100,\n confidence: 0.97,\n }, {\n text: \" videos\",\n startMs: 2240,\n endMs: 2680,\n timestampMs: 2460,\n confidence: 0.97,\n }, {\n text: \" lose\",\n startMs: 2680,\n endMs: 2960,\n timestampMs: 2820,\n confidence: 0.97,\n }, {\n text: \" people\",\n startMs: 2960,\n endMs: 3320,\n timestampMs: 3140,\n confidence: 0.97,\n }, {\n text: \" in\",\n startMs: 3320,\n endMs: 3420,\n timestampMs: 3370,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 3420,\n endMs: 3520,\n timestampMs: 3470,\n confidence: 0.97,\n }, {\n text: \" first\",\n startMs: 3520,\n endMs: 3820,\n timestampMs: 3670,\n confidence: 0.97,\n }, {\n text: \" three\",\n startMs: 3820,\n endMs: 4100,\n timestampMs: 3960,\n confidence: 0.97,\n }, {\n text: \" seconds.\",\n startMs: 4100,\n endMs: 4780,\n timestampMs: 4440,\n confidence: 0.97,\n }, {\n text: \" Captions\",\n startMs: 5400,\n endMs: 5920,\n timestampMs: 5660,\n confidence: 0.97,\n }, {\n text: \" keep\",\n startMs: 5920,\n endMs: 6140,\n timestampMs: 6030,\n confidence: 0.97,\n }, {\n text: \" them\",\n startMs: 6140,\n endMs: 6300,\n timestampMs: 6220,\n confidence: 0.97,\n }, {\n text: \" watching,\",\n startMs: 6300,\n endMs: 6860,\n timestampMs: 6580,\n confidence: 0.97,\n }, {\n text: \" even\",\n startMs: 6960,\n endMs: 7180,\n timestampMs: 7070,\n confidence: 0.97,\n }, {\n text: \" with\",\n startMs: 7180,\n endMs: 7320,\n timestampMs: 7250,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 7320,\n endMs: 7420,\n timestampMs: 7370,\n confidence: 0.97,\n }, {\n text: \" sound\",\n startMs: 7420,\n endMs: 7760,\n timestampMs: 7590,\n confidence: 0.97,\n }, {\n text: \" off.\",\n startMs: 7760,\n endMs: 8300,\n timestampMs: 8030,\n confidence: 0.97,\n }],\n fontSize: 64,\n fontWeight: 800,\n color: \"#ffffff\",\n activeColor: \"#facc15\",\n combineTokensWithinMilliseconds: 1200,\n holdMs: 600,\n shadow: true,\n};\n\ntype CaptionKaraokeElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof CaptionKaraokeBase>;\n\nconst CaptionKaraokeInner = forwardRef<\n HTMLDivElement,\n CaptionKaraokeElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<CaptionKaraoke>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <CaptionKaraokeBase\n {...(componentProps as unknown as ComponentProps<typeof CaptionKaraokeBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const CaptionKaraoke = Interactive.withSchema({\n Component: CaptionKaraokeInner,\n componentName: \"<CaptionKaraoke>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"+ },+ "durationInFrames": 279+}diff --git a/registry-artifacts/elements/caption-knockout.json b/registry-artifacts/elements/caption-knockout.jsonnew file mode 100644index 00000000..7ab9dcfd--- /dev/null+++ b/registry-artifacts/elements/caption-knockout.json@@ -0,0 +1,21 @@+{+ "type": "remotion-element",+ "version": 1,+ "element": {+ "assets": [],+ "dependencies": [+ {+ "name": "@remotion/captions",+ "version": null+ }+ ],+ "dimensions": null,+ "displayName": "Caption Knockout",+ "durationInFrames": 279,+ "initialProps": null,+ "installationMode": "component-owned-sequence",+ "slug": "caption-knockout",+ "sourceCode": "import { Fragment, forwardRef, useId, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState, type ComponentProps } from \"react\";\nimport { Easing, Interactive, Sequence, interpolate, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { createTikTokStyleCaptions, type Caption, type TikTokPage } from \"@remotion/captions\";\n\ntype SpeakerCaption = Caption & { speaker?: string };\n\ninterface CaptionBaseProps {\n captions: Caption[];\n combineTokensWithinMilliseconds?: number;\n holdMs?: number;\n fontSize?: number;\n fontWeight?: number;\n color?: string;\n className?: string;\n}\n\nconst DEFAULT_HOLD_MS = 600;\nconst MIN_SILENCE_BREAK_MS = 300;\n\ninterface CaptionPageWindow {\n page: TikTokPage;\n index: number;\n speaker: string | undefined;\n startMs: number;\n speechEndMs: number;\n endMs: number;\n endsInSilence: boolean;\n}\n\ntype CaptionTokenStatus = \"upcoming\" | \"active\" | \"spoken\";\n\ninterface CaptionTokenState {\n text: string;\n spaceBefore: boolean;\n fromMs: number;\n toMs: number;\n progress: number;\n status: CaptionTokenStatus;\n}\n\ninterface CaptionPreviousPage {\n page: TikTokPage;\n pageIndex: number;\n tokens: CaptionTokenState[];\n}\n\ninterface CaptionsState {\n page: TikTokPage;\n pageIndex: number;\n speaker: string | undefined;\n timeMs: number;\n activeIndex: number;\n tokens: CaptionTokenState[];\n sinceStartMs: number;\n untilEndMs: number;\n holdRoomMs: number;\n endsInSilence: boolean;\n previous: CaptionPreviousPage | null;\n}\n\ninterface CaptionPagingOptions {\n combineTokensWithinMilliseconds: number;\n holdMs?: number;\n}\n\nconst SENTENCE_END = /[.!?…][\"')\\]]*$/;\n\nfunction markPageBreaks(captions: SpeakerCaption[]): Caption[] {\n return captions.map((caption, i) => {\n if (caption.pageBreakAfter !== undefined) return caption;\n const next = captions[i + 1];\n const speakerChanges =\n next !== undefined && next.speaker !== caption.speaker;\n return speakerChanges || SENTENCE_END.test(caption.text.trim())\n ? { ...caption, pageBreakAfter: true }\n : caption;\n });\n}\n\nfunction buildCaptionPages(\n captions: SpeakerCaption[],\n {\n combineTokensWithinMilliseconds,\n holdMs = DEFAULT_HOLD_MS,\n }: CaptionPagingOptions,\n): CaptionPageWindow[] {\n if (captions.length === 0) return [];\n const { pages } = createTikTokStyleCaptions({\n captions: markPageBreaks(captions),\n combineTokensWithinMilliseconds,\n breakOnSilenceAfterMilliseconds: Math.max(holdMs, MIN_SILENCE_BREAK_MS),\n });\n const speakers = new Map<number, string | undefined>();\n for (const caption of captions) {\n if (!speakers.has(caption.startMs)) {\n speakers.set(caption.startMs, caption.speaker);\n }\n }\n const spoken = pages.filter((page) => page.tokens.length > 0);\n return spoken.map((page, index) => {\n const last = page.tokens[page.tokens.length - 1];\n const speechEndMs = last ? last.toMs : page.startMs;\n const heldUntil = speechEndMs + Math.max(0, holdMs);\n const next = spoken[index + 1];\n const endsInSilence = !next || next.startMs > heldUntil;\n const endMs = endsInSilence\n ? heldUntil\n : Math.max(page.startMs, next.startMs);\n return {\n page,\n index,\n speaker: speakers.get(page.tokens[0].fromMs),\n startMs: page.startMs,\n speechEndMs,\n endMs,\n endsInSilence,\n };\n });\n}\n\nfunction findWindowIndex(windows: CaptionPageWindow[], timeMs: number): number {\n let lo = 0;\n let hi = windows.length - 1;\n let found = -1;\n while (lo <= hi) {\n const mid = (lo + hi) >> 1;\n if (windows[mid].startMs <= timeMs) {\n found = mid;\n lo = mid + 1;\n } else {\n hi = mid - 1;\n }\n }\n if (found === -1) return -1;\n return timeMs < windows[found].endMs ? found : -1;\n}\n\nfunction tokenProgress(fromMs: number, toMs: number, timeMs: number): number {\n if (timeMs < fromMs) return 0;\n if (toMs <= fromMs) return 1;\n return Math.min(1, (timeMs - fromMs) / (toMs - fromMs));\n}\n\nfunction getTokenStates(\n page: TikTokPage,\n timeMs: number,\n): { activeIndex: number; tokens: CaptionTokenState[] } {\n let activeIndex = -1;\n page.tokens.forEach((token, i) => {\n if (token.fromMs <= timeMs) activeIndex = i;\n });\n const tokens = page.tokens.map(\n (token, i): CaptionTokenState => ({\n text: token.text.trim(),\n spaceBefore: i > 0 && /^\\s/.test(token.text),\n fromMs: token.fromMs,\n toMs: token.toMs,\n progress: tokenProgress(token.fromMs, token.toMs, timeMs),\n status:\n i < activeIndex ? \"spoken\" : i === activeIndex ? \"active\" : \"upcoming\",\n }),\n );\n return { activeIndex, tokens };\n}\n\nfunction getCaptionsState(\n windows: CaptionPageWindow[],\n timeMs: number,\n): CaptionsState | null {\n const found = findWindowIndex(windows, timeMs);\n if (found === -1) return null;\n const window = windows[found];\n const { activeIndex, tokens } = getTokenStates(window.page, timeMs);\n const before = found > 0 ? windows[found - 1] : null;\n const previous =\n before && !before.endsInSilence\n ? {\n page: before.page,\n pageIndex: before.index,\n tokens: getTokenStates(before.page, before.endMs).tokens,\n }\n : null;\n return {\n page: window.page,\n pageIndex: window.index,\n speaker: window.speaker,\n timeMs,\n activeIndex,\n tokens,\n sinceStartMs: timeMs - window.startMs,\n untilEndMs: window.endMs - timeMs,\n holdRoomMs: window.endMs - window.speechEndMs,\n endsInSilence: window.endsInSilence,\n previous,\n };\n}\n\nfunction getExitWindowMs(state: CaptionsState, exitMs: number): number {\n return Math.max(1, Math.min(exitMs, state.holdRoomMs));\n}\n\nfunction groupCaptionWords(\n tokens: CaptionTokenState[],\n): { index: number; token: CaptionTokenState }[][] {\n const words: { index: number; token: CaptionTokenState }[][] = [];\n tokens.forEach((token, index) => {\n const current = words[words.length - 1];\n if (!current || token.spaceBefore) {\n words.push([{ index, token }]);\n } else {\n current.push({ index, token });\n }\n });\n return words;\n}\n\nfunction normalizeCaptionWord(text: string): string {\n return text\n .toLowerCase()\n .replace(/[\\u2018\\u2019]/g, \"'\")\n .replace(/[^\\p{L}\\p{N}']/gu, \"\");\n}\n\nfunction createKeywordMatcher(\n keywords: readonly string[] = [],\n): (text: string) => boolean {\n const set = new Set(keywords.map(normalizeCaptionWord).filter(Boolean));\n return (text) => set.has(normalizeCaptionWord(text));\n}\n\nfunction captionWordText(word: { token: CaptionTokenState }[]): string {\n return word.map(({ token }) => token.text).join(\"\");\n}\n\ninterface CaptionWordRect {\n left: number;\n top: number;\n width: number;\n height: number;\n}\n\nfunction sameRects(a: CaptionWordRect[], b: CaptionWordRect[]): boolean {\n return (\n a.length === b.length &&\n a.every(\n (r, i) =>\n r.left === b[i].left &&\n r.top === b[i].top &&\n r.width === b[i].width &&\n r.height === b[i].height,\n )\n );\n}\n\nfunction useCaptionWordRects(\n pageIndex: number,\n count: number,\n): {\n wordRef: (index: number) => (el: HTMLElement | null) => void;\n rects: CaptionWordRect[] | null;\n} {\n const elements = useRef<(HTMLElement | null)[]>([]);\n const [measured, setMeasured] = useState<{\n pageIndex: number;\n rects: CaptionWordRect[];\n } | null>(null);\n\n useLayoutEffect(() => {\n if (pageIndex === -1) return;\n const rects = elements.current.slice(0, count).map((el) =>\n el\n ? {\n left: el.offsetLeft,\n top: el.offsetTop,\n width: el.offsetWidth,\n height: el.offsetHeight,\n }\n : { left: 0, top: 0, width: 0, height: 0 },\n );\n setMeasured((prev) =>\n prev && prev.pageIndex === pageIndex && sameRects(prev.rects, rects)\n ? prev\n : { pageIndex, rects },\n );\n });\n\n return {\n wordRef: (index) => (el) => {\n elements.current[index] = el;\n },\n rects: measured && measured.pageIndex === pageIndex ? measured.rects : null,\n };\n}\n\nfunction useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs = DEFAULT_HOLD_MS,\n}: {\n captions: SpeakerCaption[];\n combineTokensWithinMilliseconds: number;\n holdMs?: number;\n}): CaptionsState | null {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const windows = useMemo(\n () =>\n buildCaptionPages(captions, { combineTokensWithinMilliseconds, holdMs }),\n [captions, combineTokensWithinMilliseconds, holdMs],\n );\n return getCaptionsState(windows, (frame / fps) * 1000);\n}\n\ninterface CaptionKnockoutProps extends Omit<CaptionBaseProps, \"color\"> {\n plateColor?: string;\n upcomingOpacity?: number;\n radius?: number;\n}\n\nconst ENTER_MS = 160;\nconst EXIT_MS = 220;\nconst RISE_EM = 0.14;\nconst PUNCH_MS = 120;\nconst PAD_Y_EM = 0.22;\nconst PAD_X_EM = 0.42;\n\nconst enterEasing = Easing.bezier(0.2, 0.8, 0.2, 1);\nconst punchEasing = Easing.bezier(0.2, 0.8, 0.2, 1);\n\nconst clamp = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n} as const;\n\nfunction holeFill(\n token: CaptionTokenState,\n timeMs: number,\n upcomingOpacity: number,\n): string {\n const since = timeMs - token.fromMs;\n const hole =\n since < 0\n ? upcomingOpacity\n : interpolate(since, [0, PUNCH_MS], [upcomingOpacity, 1], {\n ...clamp,\n easing: punchEasing,\n });\n const level = Math.round(255 * (1 - Math.min(1, Math.max(0, hole))));\n return `rgb(${level}, ${level}, ${level})`;\n}\n\nfunction CaptionKnockoutBase({\n captions,\n combineTokensWithinMilliseconds = 1200,\n holdMs = DEFAULT_HOLD_MS,\n fontSize = 64,\n fontWeight = 800,\n plateColor = \"#ffffff\",\n upcomingOpacity = 0.15,\n radius = 0.16,\n className,\n}: CaptionKnockoutProps) {\n const maskId = `caption-knockout-${useId().replace(/[^a-zA-Z0-9-]/g, \"\")}`;\n const state = useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs,\n });\n const words = state ? groupCaptionWords(state.tokens) : [];\n const { wordRef, rects } = useCaptionWordRects(\n state ? state.pageIndex : -1,\n words.length,\n );\n if (!state) return null;\n\n const enter = interpolate(\n state.previous ? ENTER_MS : state.sinceStartMs,\n [0, ENTER_MS],\n [0, 1],\n { ...clamp, easing: enterEasing },\n );\n const exit = state.endsInSilence\n ? interpolate(\n state.untilEndMs,\n [0, getExitWindowMs(state, EXIT_MS)],\n [0, 1],\n clamp,\n )\n : 1;\n\n return (\n <div\n className={className}\n style={{\n position: \"relative\",\n fontSize,\n fontWeight,\n lineHeight: 1.2,\n textAlign: \"center\",\n padding: `${PAD_Y_EM}em ${PAD_X_EM}em`,\n opacity: Math.min(enter, exit),\n transform: `translateY(${(1 - enter) * RISE_EM}em)`,\n }}\n >\n {rects && (\n <svg\n aria-hidden\n width=\"100%\"\n height=\"100%\"\n style={{\n position: \"absolute\",\n inset: 0,\n width: \"100%\",\n height: \"100%\",\n overflow: \"visible\",\n }}\n >\n <defs>\n <mask\n id={maskId}\n maskUnits=\"userSpaceOnUse\"\n x=\"0\"\n y=\"0\"\n width=\"100%\"\n height=\"100%\"\n >\n <rect width=\"100%\" height=\"100%\" fill=\"#ffffff\" />\n {words.map((word, w) => {\n const rect = rects[w];\n if (!rect) return null;\n return (\n <text\n key={`${state.pageIndex}-${word[0].index}`}\n x={rect.left}\n y={rect.top + rect.height / 2}\n dominantBaseline=\"central\"\n >\n {word.map(({ index, token }) => (\n <tspan\n key={index}\n fill={holeFill(token, state.timeMs, upcomingOpacity)}\n >\n {token.text}\n </tspan>\n ))}\n </text>\n );\n })}\n </mask>\n </defs>\n <rect\n width=\"100%\"\n height=\"100%\"\n rx={radius * fontSize}\n fill={plateColor}\n mask={`url(#${maskId})`}\n />\n </svg>\n )}\n {words.map((word, w) => (\n <Fragment key={`${state.pageIndex}-${word[0].index}`}>\n {w > 0 && \" \"}\n <span\n ref={wordRef(w)}\n style={{\n display: \"inline-block\",\n whiteSpace: \"nowrap\",\n color: \"transparent\",\n }}\n >\n {word.map(({ index, token }) => (\n <span key={index}>{token.text}</span>\n ))}\n </span>\n </Fragment>\n ))}\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n captions: {\n type: \"remotion-captions\",\n default: [{\n text: \" So\",\n startMs: 300,\n endMs: 460,\n timestampMs: 380,\n confidence: 0.97,\n }, {\n text: \" here's\",\n startMs: 460,\n endMs: 700,\n timestampMs: 580,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 700,\n endMs: 820,\n timestampMs: 760,\n confidence: 0.97,\n }, {\n text: \" thing.\",\n startMs: 820,\n endMs: 1240,\n timestampMs: 1030,\n confidence: 0.97,\n }, {\n text: \" Most\",\n startMs: 1700,\n endMs: 1960,\n timestampMs: 1830,\n confidence: 0.97,\n }, {\n text: \" demo\",\n startMs: 1960,\n endMs: 2240,\n timestampMs: 2100,\n confidence: 0.97,\n }, {\n text: \" videos\",\n startMs: 2240,\n endMs: 2680,\n timestampMs: 2460,\n confidence: 0.97,\n }, {\n text: \" lose\",\n startMs: 2680,\n endMs: 2960,\n timestampMs: 2820,\n confidence: 0.97,\n }, {\n text: \" people\",\n startMs: 2960,\n endMs: 3320,\n timestampMs: 3140,\n confidence: 0.97,\n }, {\n text: \" in\",\n startMs: 3320,\n endMs: 3420,\n timestampMs: 3370,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 3420,\n endMs: 3520,\n timestampMs: 3470,\n confidence: 0.97,\n }, {\n text: \" first\",\n startMs: 3520,\n endMs: 3820,\n timestampMs: 3670,\n confidence: 0.97,\n }, {\n text: \" three\",\n startMs: 3820,\n endMs: 4100,\n timestampMs: 3960,\n confidence: 0.97,\n }, {\n text: \" seconds.\",\n startMs: 4100,\n endMs: 4780,\n timestampMs: 4440,\n confidence: 0.97,\n }, {\n text: \" Captions\",\n startMs: 5400,\n endMs: 5920,\n timestampMs: 5660,\n confidence: 0.97,\n }, {\n text: \" keep\",\n startMs: 5920,\n endMs: 6140,\n timestampMs: 6030,\n confidence: 0.97,\n }, {\n text: \" them\",\n startMs: 6140,\n endMs: 6300,\n timestampMs: 6220,\n confidence: 0.97,\n }, {\n text: \" watching,\",\n startMs: 6300,\n endMs: 6860,\n timestampMs: 6580,\n confidence: 0.97,\n }, {\n text: \" even\",\n startMs: 6960,\n endMs: 7180,\n timestampMs: 7070,\n confidence: 0.97,\n }, {\n text: \" with\",\n startMs: 7180,\n endMs: 7320,\n timestampMs: 7250,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 7320,\n endMs: 7420,\n timestampMs: 7370,\n confidence: 0.97,\n }, {\n text: \" sound\",\n startMs: 7420,\n endMs: 7760,\n timestampMs: 7590,\n confidence: 0.97,\n }, {\n text: \" off.\",\n startMs: 7760,\n endMs: 8300,\n timestampMs: 8030,\n confidence: 0.97,\n }],\n description: \"Transcript\",\n keyframable: false,\n },\n fontSize: {\n type: \"number\",\n min: 24,\n max: 140,\n step: 1,\n default: 64,\n description: \"Font size\",\n hiddenFromList: false,\n },\n fontWeight: {\n type: \"number\",\n min: 400,\n max: 900,\n step: 100,\n default: 800,\n description: \"Font weight\",\n hiddenFromList: false,\n },\n plateColor: {\n type: \"color\",\n default: \"#ffffff\",\n description: \"Plate color\",\n },\n upcomingOpacity: {\n type: \"number\",\n min: 0,\n max: 1,\n step: 0.05,\n default: 0.15,\n description: \"Upcoming words\",\n hiddenFromList: false,\n },\n combineTokensWithinMilliseconds: {\n type: \"number\",\n min: 0,\n max: 3000,\n step: 100,\n default: 1200,\n description: \"Page window (ms)\",\n hiddenFromList: false,\n },\n holdMs: {\n type: \"number\",\n min: 0,\n max: 2000,\n step: 50,\n default: 600,\n description: \"Hold (ms)\",\n hiddenFromList: false,\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"captions\",\"fontSize\",\"fontWeight\",\"plateColor\",\"upcomingOpacity\",\"combineTokensWithinMilliseconds\",\"holdMs\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n captions: [{\n text: \" So\",\n startMs: 300,\n endMs: 460,\n timestampMs: 380,\n confidence: 0.97,\n }, {\n text: \" here's\",\n startMs: 460,\n endMs: 700,\n timestampMs: 580,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 700,\n endMs: 820,\n timestampMs: 760,\n confidence: 0.97,\n }, {\n text: \" thing.\",\n startMs: 820,\n endMs: 1240,\n timestampMs: 1030,\n confidence: 0.97,\n }, {\n text: \" Most\",\n startMs: 1700,\n endMs: 1960,\n timestampMs: 1830,\n confidence: 0.97,\n }, {\n text: \" demo\",\n startMs: 1960,\n endMs: 2240,\n timestampMs: 2100,\n confidence: 0.97,\n }, {\n text: \" videos\",\n startMs: 2240,\n endMs: 2680,\n timestampMs: 2460,\n confidence: 0.97,\n }, {\n text: \" lose\",\n startMs: 2680,\n endMs: 2960,\n timestampMs: 2820,\n confidence: 0.97,\n }, {\n text: \" people\",\n startMs: 2960,\n endMs: 3320,\n timestampMs: 3140,\n confidence: 0.97,\n }, {\n text: \" in\",\n startMs: 3320,\n endMs: 3420,\n timestampMs: 3370,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 3420,\n endMs: 3520,\n timestampMs: 3470,\n confidence: 0.97,\n }, {\n text: \" first\",\n startMs: 3520,\n endMs: 3820,\n timestampMs: 3670,\n confidence: 0.97,\n }, {\n text: \" three\",\n startMs: 3820,\n endMs: 4100,\n timestampMs: 3960,\n confidence: 0.97,\n }, {\n text: \" seconds.\",\n startMs: 4100,\n endMs: 4780,\n timestampMs: 4440,\n confidence: 0.97,\n }, {\n text: \" Captions\",\n startMs: 5400,\n endMs: 5920,\n timestampMs: 5660,\n confidence: 0.97,\n }, {\n text: \" keep\",\n startMs: 5920,\n endMs: 6140,\n timestampMs: 6030,\n confidence: 0.97,\n }, {\n text: \" them\",\n startMs: 6140,\n endMs: 6300,\n timestampMs: 6220,\n confidence: 0.97,\n }, {\n text: \" watching,\",\n startMs: 6300,\n endMs: 6860,\n timestampMs: 6580,\n confidence: 0.97,\n }, {\n text: \" even\",\n startMs: 6960,\n endMs: 7180,\n timestampMs: 7070,\n confidence: 0.97,\n }, {\n text: \" with\",\n startMs: 7180,\n endMs: 7320,\n timestampMs: 7250,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 7320,\n endMs: 7420,\n timestampMs: 7370,\n confidence: 0.97,\n }, {\n text: \" sound\",\n startMs: 7420,\n endMs: 7760,\n timestampMs: 7590,\n confidence: 0.97,\n }, {\n text: \" off.\",\n startMs: 7760,\n endMs: 8300,\n timestampMs: 8030,\n confidence: 0.97,\n }],\n fontSize: 64,\n fontWeight: 800,\n plateColor: \"#ffffff\",\n upcomingOpacity: 0.15,\n combineTokensWithinMilliseconds: 1200,\n holdMs: 600,\n};\n\ntype CaptionKnockoutElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof CaptionKnockoutBase>;\n\nconst CaptionKnockoutInner = forwardRef<\n HTMLDivElement,\n CaptionKnockoutElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<CaptionKnockout>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <CaptionKnockoutBase\n {...(componentProps as unknown as ComponentProps<typeof CaptionKnockoutBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const CaptionKnockout = Interactive.withSchema({\n Component: CaptionKnockoutInner,\n componentName: \"<CaptionKnockout>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"+ },+ "durationInFrames": 279+}diff --git a/registry-artifacts/elements/caption-label-maker.json b/registry-artifacts/elements/caption-label-maker.jsonnew file mode 100644index 00000000..b3099701--- /dev/null+++ b/registry-artifacts/elements/caption-label-maker.json@@ -0,0 +1,21 @@+{+ "type": "remotion-element",+ "version": 1,+ "element": {+ "assets": [],+ "dependencies": [+ {+ "name": "@remotion/captions",+ "version": null+ }+ ],+ "dimensions": null,+ "displayName": "Caption Label Maker",+ "durationInFrames": 279,+ "initialProps": null,+ "installationMode": "component-owned-sequence",+ "slug": "caption-label-maker",+ "sourceCode": "import { Fragment, forwardRef, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState, type CSSProperties, type ComponentProps } from \"react\";\nimport { Easing, Interactive, Sequence, interpolate, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { createTikTokStyleCaptions, type Caption, type TikTokPage } from \"@remotion/captions\";\n\ntype SpeakerCaption = Caption & { speaker?: string };\n\ninterface CaptionBaseProps {\n captions: Caption[];\n combineTokensWithinMilliseconds?: number;\n holdMs?: number;\n fontSize?: number;\n fontWeight?: number;\n color?: string;\n className?: string;\n}\n\nconst DEFAULT_HOLD_MS = 600;\nconst MIN_SILENCE_BREAK_MS = 300;\n\ninterface CaptionPageWindow {\n page: TikTokPage;\n index: number;\n speaker: string | undefined;\n startMs: number;\n speechEndMs: number;\n endMs: number;\n endsInSilence: boolean;\n}\n\ntype CaptionTokenStatus = \"upcoming\" | \"active\" | \"spoken\";\n\ninterface CaptionTokenState {\n text: string;\n spaceBefore: boolean;\n fromMs: number;\n toMs: number;\n progress: number;\n status: CaptionTokenStatus;\n}\n\ninterface CaptionPreviousPage {\n page: TikTokPage;\n pageIndex: number;\n tokens: CaptionTokenState[];\n}\n\ninterface CaptionsState {\n page: TikTokPage;\n pageIndex: number;\n speaker: string | undefined;\n timeMs: number;\n activeIndex: number;\n tokens: CaptionTokenState[];\n sinceStartMs: number;\n untilEndMs: number;\n holdRoomMs: number;\n endsInSilence: boolean;\n previous: CaptionPreviousPage | null;\n}\n\ninterface CaptionPagingOptions {\n combineTokensWithinMilliseconds: number;\n holdMs?: number;\n}\n\nconst SENTENCE_END = /[.!?…][\"')\\]]*$/;\n\nfunction markPageBreaks(captions: SpeakerCaption[]): Caption[] {\n return captions.map((caption, i) => {\n if (caption.pageBreakAfter !== undefined) return caption;\n const next = captions[i + 1];\n const speakerChanges =\n next !== undefined && next.speaker !== caption.speaker;\n return speakerChanges || SENTENCE_END.test(caption.text.trim())\n ? { ...caption, pageBreakAfter: true }\n : caption;\n });\n}\n\nfunction buildCaptionPages(\n captions: SpeakerCaption[],\n {\n combineTokensWithinMilliseconds,\n holdMs = DEFAULT_HOLD_MS,\n }: CaptionPagingOptions,\n): CaptionPageWindow[] {\n if (captions.length === 0) return [];\n const { pages } = createTikTokStyleCaptions({\n captions: markPageBreaks(captions),\n combineTokensWithinMilliseconds,\n breakOnSilenceAfterMilliseconds: Math.max(holdMs, MIN_SILENCE_BREAK_MS),\n });\n const speakers = new Map<number, string | undefined>();\n for (const caption of captions) {\n if (!speakers.has(caption.startMs)) {\n speakers.set(caption.startMs, caption.speaker);\n }\n }\n const spoken = pages.filter((page) => page.tokens.length > 0);\n return spoken.map((page, index) => {\n const last = page.tokens[page.tokens.length - 1];\n const speechEndMs = last ? last.toMs : page.startMs;\n const heldUntil = speechEndMs + Math.max(0, holdMs);\n const next = spoken[index + 1];\n const endsInSilence = !next || next.startMs > heldUntil;\n const endMs = endsInSilence\n ? heldUntil\n : Math.max(page.startMs, next.startMs);\n return {\n page,\n index,\n speaker: speakers.get(page.tokens[0].fromMs),\n startMs: page.startMs,\n speechEndMs,\n endMs,\n endsInSilence,\n };\n });\n}\n\nfunction findWindowIndex(windows: CaptionPageWindow[], timeMs: number): number {\n let lo = 0;\n let hi = windows.length - 1;\n let found = -1;\n while (lo <= hi) {\n const mid = (lo + hi) >> 1;\n if (windows[mid].startMs <= timeMs) {\n found = mid;\n lo = mid + 1;\n } else {\n hi = mid - 1;\n }\n }\n if (found === -1) return -1;\n return timeMs < windows[found].endMs ? found : -1;\n}\n\nfunction tokenProgress(fromMs: number, toMs: number, timeMs: number): number {\n if (timeMs < fromMs) return 0;\n if (toMs <= fromMs) return 1;\n return Math.min(1, (timeMs - fromMs) / (toMs - fromMs));\n}\n\nfunction getTokenStates(\n page: TikTokPage,\n timeMs: number,\n): { activeIndex: number; tokens: CaptionTokenState[] } {\n let activeIndex = -1;\n page.tokens.forEach((token, i) => {\n if (token.fromMs <= timeMs) activeIndex = i;\n });\n const tokens = page.tokens.map(\n (token, i): CaptionTokenState => ({\n text: token.text.trim(),\n spaceBefore: i > 0 && /^\\s/.test(token.text),\n fromMs: token.fromMs,\n toMs: token.toMs,\n progress: tokenProgress(token.fromMs, token.toMs, timeMs),\n status:\n i < activeIndex ? \"spoken\" : i === activeIndex ? \"active\" : \"upcoming\",\n }),\n );\n return { activeIndex, tokens };\n}\n\nfunction getCaptionsState(\n windows: CaptionPageWindow[],\n timeMs: number,\n): CaptionsState | null {\n const found = findWindowIndex(windows, timeMs);\n if (found === -1) return null;\n const window = windows[found];\n const { activeIndex, tokens } = getTokenStates(window.page, timeMs);\n const before = found > 0 ? windows[found - 1] : null;\n const previous =\n before && !before.endsInSilence\n ? {\n page: before.page,\n pageIndex: before.index,\n tokens: getTokenStates(before.page, before.endMs).tokens,\n }\n : null;\n return {\n page: window.page,\n pageIndex: window.index,\n speaker: window.speaker,\n timeMs,\n activeIndex,\n tokens,\n sinceStartMs: timeMs - window.startMs,\n untilEndMs: window.endMs - timeMs,\n holdRoomMs: window.endMs - window.speechEndMs,\n endsInSilence: window.endsInSilence,\n previous,\n };\n}\n\nfunction getExitWindowMs(state: CaptionsState, exitMs: number): number {\n return Math.max(1, Math.min(exitMs, state.holdRoomMs));\n}\n\nfunction groupCaptionWords(\n tokens: CaptionTokenState[],\n): { index: number; token: CaptionTokenState }[][] {\n const words: { index: number; token: CaptionTokenState }[][] = [];\n tokens.forEach((token, index) => {\n const current = words[words.length - 1];\n if (!current || token.spaceBefore) {\n words.push([{ index, token }]);\n } else {\n current.push({ index, token });\n }\n });\n return words;\n}\n\nfunction normalizeCaptionWord(text: string): string {\n return text\n .toLowerCase()\n .replace(/[\\u2018\\u2019]/g, \"'\")\n .replace(/[^\\p{L}\\p{N}']/gu, \"\");\n}\n\nfunction createKeywordMatcher(\n keywords: readonly string[] = [],\n): (text: string) => boolean {\n const set = new Set(keywords.map(normalizeCaptionWord).filter(Boolean));\n return (text) => set.has(normalizeCaptionWord(text));\n}\n\nfunction captionWordText(word: { token: CaptionTokenState }[]): string {\n return word.map(({ token }) => token.text).join(\"\");\n}\n\ninterface CaptionWordRect {\n left: number;\n top: number;\n width: number;\n height: number;\n}\n\nfunction sameRects(a: CaptionWordRect[], b: CaptionWordRect[]): boolean {\n return (\n a.length === b.length &&\n a.every(\n (r, i) =>\n r.left === b[i].left &&\n r.top === b[i].top &&\n r.width === b[i].width &&\n r.height === b[i].height,\n )\n );\n}\n\nfunction useCaptionWordRects(\n pageIndex: number,\n count: number,\n): {\n wordRef: (index: number) => (el: HTMLElement | null) => void;\n rects: CaptionWordRect[] | null;\n} {\n const elements = useRef<(HTMLElement | null)[]>([]);\n const [measured, setMeasured] = useState<{\n pageIndex: number;\n rects: CaptionWordRect[];\n } | null>(null);\n\n useLayoutEffect(() => {\n if (pageIndex === -1) return;\n const rects = elements.current.slice(0, count).map((el) =>\n el\n ? {\n left: el.offsetLeft,\n top: el.offsetTop,\n width: el.offsetWidth,\n height: el.offsetHeight,\n }\n : { left: 0, top: 0, width: 0, height: 0 },\n );\n setMeasured((prev) =>\n prev && prev.pageIndex === pageIndex && sameRects(prev.rects, rects)\n ? prev\n : { pageIndex, rects },\n );\n });\n\n return {\n wordRef: (index) => (el) => {\n elements.current[index] = el;\n },\n rects: measured && measured.pageIndex === pageIndex ? measured.rects : null,\n };\n}\n\nfunction useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs = DEFAULT_HOLD_MS,\n}: {\n captions: SpeakerCaption[];\n combineTokensWithinMilliseconds: number;\n holdMs?: number;\n}): CaptionsState | null {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const windows = useMemo(\n () =>\n buildCaptionPages(captions, { combineTokensWithinMilliseconds, holdMs }),\n [captions, combineTokensWithinMilliseconds, holdMs],\n );\n return getCaptionsState(windows, (frame / fps) * 1000);\n}\n\ninterface CaptionLabelMakerProps extends CaptionBaseProps {\n tapeColor?: string;\n}\n\nconst ENTER_MS = 160;\nconst EXIT_MS = 220;\nconst RISE_EM = 0.14;\nconst PRESS_MS = 50;\nconst PRESS_SCALE = 0.92;\nconst TILT_DEG = -1.5;\nconst PAD_Y = 0.16;\nconst LEAD_EM = 0.42;\nconst RADIUS = 0.16;\nconst EMBOSS = \"0 1px 0 rgba(0, 0, 0, 0.55)\";\nconst RELIEF =\n \"inset 0 1px 0 rgba(255, 255, 255, 0.14), inset 0 -1px 0 rgba(0, 0, 0, 0.5)\";\n\nconst enterEasing = Easing.bezier(0.2, 0.8, 0.2, 1);\n\nconst clamp = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n} as const;\n\nfunction revealedCount(\n count: number,\n fromMs: number,\n toMs: number,\n timeMs: number,\n): number {\n if (timeMs < fromMs) return 0;\n const duration = Math.max(toMs - fromMs, 1);\n return Math.min(\n count,\n Math.floor(((timeMs - fromMs) / duration) * count) + 1,\n );\n}\n\nfunction CaptionLabelMakerBase({\n captions,\n combineTokensWithinMilliseconds = 1000,\n holdMs = DEFAULT_HOLD_MS,\n fontSize = 64,\n fontWeight = 800,\n color = \"#ffffff\",\n tapeColor = \"#18181b\",\n className,\n}: CaptionLabelMakerProps) {\n const state = useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs,\n });\n if (!state) return null;\n\n const enter = interpolate(\n state.previous ? ENTER_MS : state.sinceStartMs,\n [0, ENTER_MS],\n [0, 1],\n { ...clamp, easing: enterEasing },\n );\n const exit = state.endsInSilence\n ? interpolate(\n state.untilEndMs,\n [0, getExitWindowMs(state, EXIT_MS)],\n [0, 1],\n clamp,\n )\n : 1;\n\n const segment: CSSProperties = {\n display: \"inline-block\",\n verticalAlign: \"top\",\n background: tapeColor,\n paddingBlock: `${PAD_Y}em`,\n paddingRight: 1,\n marginRight: -1,\n boxShadow: RELIEF,\n };\n\n const words = groupCaptionWords(state.tokens).map((word) => {\n const chars = Array.from(captionWordText(word));\n const fromMs = word[0].token.fromMs;\n const toMs = word[word.length - 1].token.toMs;\n return {\n key: `${state.pageIndex}-${word[0].index}`,\n chars,\n fromMs,\n toMs,\n revealed: revealedCount(chars.length, fromMs, toMs, state.timeMs),\n };\n });\n const last = words[words.length - 1];\n const finished = last !== undefined && last.revealed === last.chars.length;\n\n return (\n <div\n className={className}\n style={{\n fontSize,\n fontWeight,\n color,\n lineHeight: 1.1,\n textAlign: \"center\",\n opacity: Math.min(enter, exit),\n transform: `translateY(${(1 - enter) * RISE_EM}em)`,\n }}\n >\n <span\n style={{\n display: \"inline-block\",\n whiteSpace: \"nowrap\",\n transform: `rotate(${TILT_DEG}deg)`,\n filter: \"drop-shadow(0 2px 4px rgba(0, 0, 0, 0.35))\",\n }}\n >\n <span\n style={{\n ...segment,\n width: `${LEAD_EM}em`,\n borderRadius: `${RADIUS}em 0 0 ${RADIUS}em`,\n }}\n >\n {\"\\u00a0\"}\n </span>\n {words.map((word, w) => {\n const duration = Math.max(word.toMs - word.fromMs, 1);\n return (\n <Fragment key={word.key}>\n {w > 0 && (\n <span\n style={{\n ...segment,\n visibility: word.revealed > 0 ? \"visible\" : \"hidden\",\n }}\n >\n {\"\\u00a0\"}\n </span>\n )}\n {word.chars.map((char, c) => {\n const pressedAt =\n word.fromMs + (c / word.chars.length) * duration;\n const press = interpolate(\n state.timeMs - pressedAt,\n [0, PRESS_MS],\n [PRESS_SCALE, 1],\n clamp,\n );\n return (\n <span\n key={c}\n style={{\n ...segment,\n visibility: c < word.revealed ? \"visible\" : \"hidden\",\n }}\n >\n <span\n style={{\n display: \"inline-block\",\n transform: `scale(${press})`,\n textShadow: EMBOSS,\n }}\n >\n {char}\n </span>\n </span>\n );\n })}\n </Fragment>\n );\n })}\n <span\n style={{\n ...segment,\n width: `${LEAD_EM}em`,\n borderRadius: `0 ${RADIUS}em ${RADIUS}em 0`,\n visibility: finished ? \"visible\" : \"hidden\",\n }}\n >\n {\"\\u00a0\"}\n </span>\n </span>\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n captions: {\n type: \"remotion-captions\",\n default: [{\n text: \" So\",\n startMs: 300,\n endMs: 460,\n timestampMs: 380,\n confidence: 0.97,\n }, {\n text: \" here's\",\n startMs: 460,\n endMs: 700,\n timestampMs: 580,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 700,\n endMs: 820,\n timestampMs: 760,\n confidence: 0.97,\n }, {\n text: \" thing.\",\n startMs: 820,\n endMs: 1240,\n timestampMs: 1030,\n confidence: 0.97,\n }, {\n text: \" Most\",\n startMs: 1700,\n endMs: 1960,\n timestampMs: 1830,\n confidence: 0.97,\n }, {\n text: \" demo\",\n startMs: 1960,\n endMs: 2240,\n timestampMs: 2100,\n confidence: 0.97,\n }, {\n text: \" videos\",\n startMs: 2240,\n endMs: 2680,\n timestampMs: 2460,\n confidence: 0.97,\n }, {\n text: \" lose\",\n startMs: 2680,\n endMs: 2960,\n timestampMs: 2820,\n confidence: 0.97,\n }, {\n text: \" people\",\n startMs: 2960,\n endMs: 3320,\n timestampMs: 3140,\n confidence: 0.97,\n }, {\n text: \" in\",\n startMs: 3320,\n endMs: 3420,\n timestampMs: 3370,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 3420,\n endMs: 3520,\n timestampMs: 3470,\n confidence: 0.97,\n }, {\n text: \" first\",\n startMs: 3520,\n endMs: 3820,\n timestampMs: 3670,\n confidence: 0.97,\n }, {\n text: \" three\",\n startMs: 3820,\n endMs: 4100,\n timestampMs: 3960,\n confidence: 0.97,\n }, {\n text: \" seconds.\",\n startMs: 4100,\n endMs: 4780,\n timestampMs: 4440,\n confidence: 0.97,\n }, {\n text: \" Captions\",\n startMs: 5400,\n endMs: 5920,\n timestampMs: 5660,\n confidence: 0.97,\n }, {\n text: \" keep\",\n startMs: 5920,\n endMs: 6140,\n timestampMs: 6030,\n confidence: 0.97,\n }, {\n text: \" them\",\n startMs: 6140,\n endMs: 6300,\n timestampMs: 6220,\n confidence: 0.97,\n }, {\n text: \" watching,\",\n startMs: 6300,\n endMs: 6860,\n timestampMs: 6580,\n confidence: 0.97,\n }, {\n text: \" even\",\n startMs: 6960,\n endMs: 7180,\n timestampMs: 7070,\n confidence: 0.97,\n }, {\n text: \" with\",\n startMs: 7180,\n endMs: 7320,\n timestampMs: 7250,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 7320,\n endMs: 7420,\n timestampMs: 7370,\n confidence: 0.97,\n }, {\n text: \" sound\",\n startMs: 7420,\n endMs: 7760,\n timestampMs: 7590,\n confidence: 0.97,\n }, {\n text: \" off.\",\n startMs: 7760,\n endMs: 8300,\n timestampMs: 8030,\n confidence: 0.97,\n }],\n description: \"Transcript\",\n keyframable: false,\n },\n fontSize: {\n type: \"number\",\n min: 24,\n max: 140,\n step: 1,\n default: 64,\n description: \"Font size\",\n hiddenFromList: false,\n },\n fontWeight: {\n type: \"number\",\n min: 400,\n max: 900,\n step: 100,\n default: 800,\n description: \"Font weight\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#ffffff\",\n description: \"Letter color\",\n },\n tapeColor: {\n type: \"color\",\n default: \"#18181b\",\n description: \"Tape color\",\n },\n combineTokensWithinMilliseconds: {\n type: \"number\",\n min: 0,\n max: 3000,\n step: 100,\n default: 1000,\n description: \"Page window (ms)\",\n hiddenFromList: false,\n },\n holdMs: {\n type: \"number\",\n min: 0,\n max: 2000,\n step: 50,\n default: 600,\n description: \"Hold (ms)\",\n hiddenFromList: false,\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"captions\",\"fontSize\",\"fontWeight\",\"color\",\"tapeColor\",\"combineTokensWithinMilliseconds\",\"holdMs\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n captions: [{\n text: \" So\",\n startMs: 300,\n endMs: 460,\n timestampMs: 380,\n confidence: 0.97,\n }, {\n text: \" here's\",\n startMs: 460,\n endMs: 700,\n timestampMs: 580,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 700,\n endMs: 820,\n timestampMs: 760,\n confidence: 0.97,\n }, {\n text: \" thing.\",\n startMs: 820,\n endMs: 1240,\n timestampMs: 1030,\n confidence: 0.97,\n }, {\n text: \" Most\",\n startMs: 1700,\n endMs: 1960,\n timestampMs: 1830,\n confidence: 0.97,\n }, {\n text: \" demo\",\n startMs: 1960,\n endMs: 2240,\n timestampMs: 2100,\n confidence: 0.97,\n }, {\n text: \" videos\",\n startMs: 2240,\n endMs: 2680,\n timestampMs: 2460,\n confidence: 0.97,\n }, {\n text: \" lose\",\n startMs: 2680,\n endMs: 2960,\n timestampMs: 2820,\n confidence: 0.97,\n }, {\n text: \" people\",\n startMs: 2960,\n endMs: 3320,\n timestampMs: 3140,\n confidence: 0.97,\n }, {\n text: \" in\",\n startMs: 3320,\n endMs: 3420,\n timestampMs: 3370,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 3420,\n endMs: 3520,\n timestampMs: 3470,\n confidence: 0.97,\n }, {\n text: \" first\",\n startMs: 3520,\n endMs: 3820,\n timestampMs: 3670,\n confidence: 0.97,\n }, {\n text: \" three\",\n startMs: 3820,\n endMs: 4100,\n timestampMs: 3960,\n confidence: 0.97,\n }, {\n text: \" seconds.\",\n startMs: 4100,\n endMs: 4780,\n timestampMs: 4440,\n confidence: 0.97,\n }, {\n text: \" Captions\",\n startMs: 5400,\n endMs: 5920,\n timestampMs: 5660,\n confidence: 0.97,\n }, {\n text: \" keep\",\n startMs: 5920,\n endMs: 6140,\n timestampMs: 6030,\n confidence: 0.97,\n }, {\n text: \" them\",\n startMs: 6140,\n endMs: 6300,\n timestampMs: 6220,\n confidence: 0.97,\n }, {\n text: \" watching,\",\n startMs: 6300,\n endMs: 6860,\n timestampMs: 6580,\n confidence: 0.97,\n }, {\n text: \" even\",\n startMs: 6960,\n endMs: 7180,\n timestampMs: 7070,\n confidence: 0.97,\n }, {\n text: \" with\",\n startMs: 7180,\n endMs: 7320,\n timestampMs: 7250,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 7320,\n endMs: 7420,\n timestampMs: 7370,\n confidence: 0.97,\n }, {\n text: \" sound\",\n startMs: 7420,\n endMs: 7760,\n timestampMs: 7590,\n confidence: 0.97,\n }, {\n text: \" off.\",\n startMs: 7760,\n endMs: 8300,\n timestampMs: 8030,\n confidence: 0.97,\n }],\n fontSize: 64,\n fontWeight: 800,\n color: \"#ffffff\",\n tapeColor: \"#18181b\",\n combineTokensWithinMilliseconds: 1000,\n holdMs: 600,\n};\n\ntype CaptionLabelMakerElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof CaptionLabelMakerBase>;\n\nconst CaptionLabelMakerInner = forwardRef<\n HTMLDivElement,\n CaptionLabelMakerElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<CaptionLabelMaker>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <CaptionLabelMakerBase\n {...(componentProps as unknown as ComponentProps<typeof CaptionLabelMakerBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const CaptionLabelMaker = Interactive.withSchema({\n Component: CaptionLabelMakerInner,\n componentName: \"<CaptionLabelMaker>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"+ },+ "durationInFrames": 279+}diff --git a/registry-artifacts/elements/caption-marker.json b/registry-artifacts/elements/caption-marker.jsonnew file mode 100644index 00000000..c012a1fa--- /dev/null+++ b/registry-artifacts/elements/caption-marker.json@@ -0,0 +1,21 @@+{+ "type": "remotion-element",+ "version": 1,+ "element": {+ "assets": [],+ "dependencies": [+ {+ "name": "@remotion/captions",+ "version": null+ }+ ],+ "dimensions": null,+ "displayName": "Caption Marker",+ "durationInFrames": 279,+ "initialProps": null,+ "installationMode": "component-owned-sequence",+ "slug": "caption-marker",+ "sourceCode": "import { Fragment, forwardRef, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState, type ComponentProps } from \"react\";\nimport { Easing, Interactive, Sequence, interpolate, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { createTikTokStyleCaptions, type Caption, type TikTokPage } from \"@remotion/captions\";\n\ntype SpeakerCaption = Caption & { speaker?: string };\n\ninterface CaptionBaseProps {\n captions: Caption[];\n combineTokensWithinMilliseconds?: number;\n holdMs?: number;\n fontSize?: number;\n fontWeight?: number;\n color?: string;\n className?: string;\n}\n\nconst DEFAULT_HOLD_MS = 600;\nconst MIN_SILENCE_BREAK_MS = 300;\n\ninterface CaptionPageWindow {\n page: TikTokPage;\n index: number;\n speaker: string | undefined;\n startMs: number;\n speechEndMs: number;\n endMs: number;\n endsInSilence: boolean;\n}\n\ntype CaptionTokenStatus = \"upcoming\" | \"active\" | \"spoken\";\n\ninterface CaptionTokenState {\n text: string;\n spaceBefore: boolean;\n fromMs: number;\n toMs: number;\n progress: number;\n status: CaptionTokenStatus;\n}\n\ninterface CaptionPreviousPage {\n page: TikTokPage;\n pageIndex: number;\n tokens: CaptionTokenState[];\n}\n\ninterface CaptionsState {\n page: TikTokPage;\n pageIndex: number;\n speaker: string | undefined;\n timeMs: number;\n activeIndex: number;\n tokens: CaptionTokenState[];\n sinceStartMs: number;\n untilEndMs: number;\n holdRoomMs: number;\n endsInSilence: boolean;\n previous: CaptionPreviousPage | null;\n}\n\ninterface CaptionPagingOptions {\n combineTokensWithinMilliseconds: number;\n holdMs?: number;\n}\n\nconst SENTENCE_END = /[.!?…][\"')\\]]*$/;\n\nfunction markPageBreaks(captions: SpeakerCaption[]): Caption[] {\n return captions.map((caption, i) => {\n if (caption.pageBreakAfter !== undefined) return caption;\n const next = captions[i + 1];\n const speakerChanges =\n next !== undefined && next.speaker !== caption.speaker;\n return speakerChanges || SENTENCE_END.test(caption.text.trim())\n ? { ...caption, pageBreakAfter: true }\n : caption;\n });\n}\n\nfunction buildCaptionPages(\n captions: SpeakerCaption[],\n {\n combineTokensWithinMilliseconds,\n holdMs = DEFAULT_HOLD_MS,\n }: CaptionPagingOptions,\n): CaptionPageWindow[] {\n if (captions.length === 0) return [];\n const { pages } = createTikTokStyleCaptions({\n captions: markPageBreaks(captions),\n combineTokensWithinMilliseconds,\n breakOnSilenceAfterMilliseconds: Math.max(holdMs, MIN_SILENCE_BREAK_MS),\n });\n const speakers = new Map<number, string | undefined>();\n for (const caption of captions) {\n if (!speakers.has(caption.startMs)) {\n speakers.set(caption.startMs, caption.speaker);\n }\n }\n const spoken = pages.filter((page) => page.tokens.length > 0);\n return spoken.map((page, index) => {\n const last = page.tokens[page.tokens.length - 1];\n const speechEndMs = last ? last.toMs : page.startMs;\n const heldUntil = speechEndMs + Math.max(0, holdMs);\n const next = spoken[index + 1];\n const endsInSilence = !next || next.startMs > heldUntil;\n const endMs = endsInSilence\n ? heldUntil\n : Math.max(page.startMs, next.startMs);\n return {\n page,\n index,\n speaker: speakers.get(page.tokens[0].fromMs),\n startMs: page.startMs,\n speechEndMs,\n endMs,\n endsInSilence,\n };\n });\n}\n\nfunction findWindowIndex(windows: CaptionPageWindow[], timeMs: number): number {\n let lo = 0;\n let hi = windows.length - 1;\n let found = -1;\n while (lo <= hi) {\n const mid = (lo + hi) >> 1;\n if (windows[mid].startMs <= timeMs) {\n found = mid;\n lo = mid + 1;\n } else {\n hi = mid - 1;\n }\n }\n if (found === -1) return -1;\n return timeMs < windows[found].endMs ? found : -1;\n}\n\nfunction tokenProgress(fromMs: number, toMs: number, timeMs: number): number {\n if (timeMs < fromMs) return 0;\n if (toMs <= fromMs) return 1;\n return Math.min(1, (timeMs - fromMs) / (toMs - fromMs));\n}\n\nfunction getTokenStates(\n page: TikTokPage,\n timeMs: number,\n): { activeIndex: number; tokens: CaptionTokenState[] } {\n let activeIndex = -1;\n page.tokens.forEach((token, i) => {\n if (token.fromMs <= timeMs) activeIndex = i;\n });\n const tokens = page.tokens.map(\n (token, i): CaptionTokenState => ({\n text: token.text.trim(),\n spaceBefore: i > 0 && /^\\s/.test(token.text),\n fromMs: token.fromMs,\n toMs: token.toMs,\n progress: tokenProgress(token.fromMs, token.toMs, timeMs),\n status:\n i < activeIndex ? \"spoken\" : i === activeIndex ? \"active\" : \"upcoming\",\n }),\n );\n return { activeIndex, tokens };\n}\n\nfunction getCaptionsState(\n windows: CaptionPageWindow[],\n timeMs: number,\n): CaptionsState | null {\n const found = findWindowIndex(windows, timeMs);\n if (found === -1) return null;\n const window = windows[found];\n const { activeIndex, tokens } = getTokenStates(window.page, timeMs);\n const before = found > 0 ? windows[found - 1] : null;\n const previous =\n before && !before.endsInSilence\n ? {\n page: before.page,\n pageIndex: before.index,\n tokens: getTokenStates(before.page, before.endMs).tokens,\n }\n : null;\n return {\n page: window.page,\n pageIndex: window.index,\n speaker: window.speaker,\n timeMs,\n activeIndex,\n tokens,\n sinceStartMs: timeMs - window.startMs,\n untilEndMs: window.endMs - timeMs,\n holdRoomMs: window.endMs - window.speechEndMs,\n endsInSilence: window.endsInSilence,\n previous,\n };\n}\n\nfunction getExitWindowMs(state: CaptionsState, exitMs: number): number {\n return Math.max(1, Math.min(exitMs, state.holdRoomMs));\n}\n\nfunction groupCaptionWords(\n tokens: CaptionTokenState[],\n): { index: number; token: CaptionTokenState }[][] {\n const words: { index: number; token: CaptionTokenState }[][] = [];\n tokens.forEach((token, index) => {\n const current = words[words.length - 1];\n if (!current || token.spaceBefore) {\n words.push([{ index, token }]);\n } else {\n current.push({ index, token });\n }\n });\n return words;\n}\n\nfunction normalizeCaptionWord(text: string): string {\n return text\n .toLowerCase()\n .replace(/[\\u2018\\u2019]/g, \"'\")\n .replace(/[^\\p{L}\\p{N}']/gu, \"\");\n}\n\nfunction createKeywordMatcher(\n keywords: readonly string[] = [],\n): (text: string) => boolean {\n const set = new Set(keywords.map(normalizeCaptionWord).filter(Boolean));\n return (text) => set.has(normalizeCaptionWord(text));\n}\n\nfunction captionWordText(word: { token: CaptionTokenState }[]): string {\n return word.map(({ token }) => token.text).join(\"\");\n}\n\ninterface CaptionWordRect {\n left: number;\n top: number;\n width: number;\n height: number;\n}\n\nfunction sameRects(a: CaptionWordRect[], b: CaptionWordRect[]): boolean {\n return (\n a.length === b.length &&\n a.every(\n (r, i) =>\n r.left === b[i].left &&\n r.top === b[i].top &&\n r.width === b[i].width &&\n r.height === b[i].height,\n )\n );\n}\n\nfunction useCaptionWordRects(\n pageIndex: number,\n count: number,\n): {\n wordRef: (index: number) => (el: HTMLElement | null) => void;\n rects: CaptionWordRect[] | null;\n} {\n const elements = useRef<(HTMLElement | null)[]>([]);\n const [measured, setMeasured] = useState<{\n pageIndex: number;\n rects: CaptionWordRect[];\n } | null>(null);\n\n useLayoutEffect(() => {\n if (pageIndex === -1) return;\n const rects = elements.current.slice(0, count).map((el) =>\n el\n ? {\n left: el.offsetLeft,\n top: el.offsetTop,\n width: el.offsetWidth,\n height: el.offsetHeight,\n }\n : { left: 0, top: 0, width: 0, height: 0 },\n );\n setMeasured((prev) =>\n prev && prev.pageIndex === pageIndex && sameRects(prev.rects, rects)\n ? prev\n : { pageIndex, rects },\n );\n });\n\n return {\n wordRef: (index) => (el) => {\n elements.current[index] = el;\n },\n rects: measured && measured.pageIndex === pageIndex ? measured.rects : null,\n };\n}\n\nfunction useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs = DEFAULT_HOLD_MS,\n}: {\n captions: SpeakerCaption[];\n combineTokensWithinMilliseconds: number;\n holdMs?: number;\n}): CaptionsState | null {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const windows = useMemo(\n () =>\n buildCaptionPages(captions, { combineTokensWithinMilliseconds, holdMs }),\n [captions, combineTokensWithinMilliseconds, holdMs],\n );\n return getCaptionsState(windows, (frame / fps) * 1000);\n}\n\ninterface CaptionMarkerProps extends CaptionBaseProps {\n keywords?: string[];\n markerColor?: string;\n markerTextColor?: string;\n shadow?: boolean;\n}\n\nconst ENTER_MS = 160;\nconst EXIT_MS = 220;\nconst RISE_EM = 0.14;\nconst MIN_DRAW_MS = 220;\nconst PAD_EM = 0.12;\nconst RADIUS_EM = 0.18;\nconst TILT_DEG = -1;\nconst BAND_TOP = \"12%\";\nconst BAND_BOTTOM = \"2%\";\n\nconst enterEasing = Easing.bezier(0.2, 0.8, 0.2, 1);\nconst drawEasing = Easing.bezier(0.25, 1, 0.5, 1);\n\nconst clamp = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n} as const;\n\nfunction legibilityShadow(strength: number): string | undefined {\n if (strength <= 0) return undefined;\n return `0 2px 3px rgba(0, 0, 0, ${0.5 * strength}), 0 4px 16px rgba(0, 0, 0, ${0.35 * strength})`;\n}\n\nfunction CaptionMarkerBase({\n captions,\n combineTokensWithinMilliseconds = 1200,\n holdMs = DEFAULT_HOLD_MS,\n fontSize = 64,\n fontWeight = 800,\n color = \"#ffffff\",\n keywords,\n markerColor = \"#facc15\",\n markerTextColor = \"#0a0a0a\",\n shadow = true,\n className,\n}: CaptionMarkerProps) {\n const state = useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs,\n });\n if (!state) return null;\n\n const isKeyword = createKeywordMatcher(keywords);\n const enter = interpolate(\n state.previous ? ENTER_MS : state.sinceStartMs,\n [0, ENTER_MS],\n [0, 1],\n {\n ...clamp,\n easing: enterEasing,\n },\n );\n const exit = state.endsInSilence\n ? interpolate(\n state.untilEndMs,\n [0, getExitWindowMs(state, EXIT_MS)],\n [0, 1],\n clamp,\n )\n : 1;\n const baseShadow = shadow ? 1 : 0;\n\n return (\n <div\n className={className}\n style={{\n fontSize,\n fontWeight,\n color,\n lineHeight: 1.2,\n textAlign: \"center\",\n opacity: Math.min(enter, exit),\n transform: `translateY(${(1 - enter) * RISE_EM}em)`,\n }}\n >\n {groupCaptionWords(state.tokens).map((word, w) => {\n const key = `${state.pageIndex}-${word[0].index}`;\n const text = word.map(({ index, token }) => (\n <span key={index}>{token.text}</span>\n ));\n if (!isKeyword(captionWordText(word))) {\n return (\n <Fragment key={key}>\n {w > 0 && \" \"}\n <span\n style={{\n display: \"inline-block\",\n whiteSpace: \"nowrap\",\n textShadow: legibilityShadow(baseShadow),\n }}\n >\n {text}\n </span>\n </Fragment>\n );\n }\n const fromMs = word[0].token.fromMs;\n const toMs = word[word.length - 1].token.toMs;\n const drawMs = Math.max(toMs - fromMs, MIN_DRAW_MS);\n const drawn = interpolate(state.timeMs - fromMs, [0, drawMs], [0, 1], {\n ...clamp,\n easing: drawEasing,\n });\n const hidden = `${(1 - drawn) * 100}%`;\n return (\n <Fragment key={key}>\n {w > 0 && \" \"}\n <span\n style={{\n position: \"relative\",\n display: \"inline-block\",\n whiteSpace: \"nowrap\",\n padding: `0 ${PAD_EM}em`,\n margin: `0 -${PAD_EM}em`,\n }}\n >\n <span\n aria-hidden\n style={{\n position: \"absolute\",\n left: 0,\n right: 0,\n top: BAND_TOP,\n bottom: BAND_BOTTOM,\n background: markerColor,\n borderRadius: `${RADIUS_EM}em`,\n transform: `rotate(${TILT_DEG}deg)`,\n clipPath: `inset(0 ${hidden} 0 0 round ${RADIUS_EM}em)`,\n }}\n />\n <span\n style={{\n position: \"relative\",\n textShadow: legibilityShadow(baseShadow * (1 - drawn)),\n }}\n >\n {text}\n </span>\n <span\n aria-hidden\n style={{\n position: \"absolute\",\n inset: 0,\n padding: `0 ${PAD_EM}em`,\n color: markerTextColor,\n clipPath: `inset(${BAND_TOP} ${hidden} ${BAND_BOTTOM} 0)`,\n }}\n >\n {text}\n </span>\n </span>\n </Fragment>\n );\n })}\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n captions: {\n type: \"remotion-captions\",\n default: [{\n text: \" So\",\n startMs: 300,\n endMs: 460,\n timestampMs: 380,\n confidence: 0.97,\n }, {\n text: \" here's\",\n startMs: 460,\n endMs: 700,\n timestampMs: 580,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 700,\n endMs: 820,\n timestampMs: 760,\n confidence: 0.97,\n }, {\n text: \" thing.\",\n startMs: 820,\n endMs: 1240,\n timestampMs: 1030,\n confidence: 0.97,\n }, {\n text: \" Most\",\n startMs: 1700,\n endMs: 1960,\n timestampMs: 1830,\n confidence: 0.97,\n }, {\n text: \" demo\",\n startMs: 1960,\n endMs: 2240,\n timestampMs: 2100,\n confidence: 0.97,\n }, {\n text: \" videos\",\n startMs: 2240,\n endMs: 2680,\n timestampMs: 2460,\n confidence: 0.97,\n }, {\n text: \" lose\",\n startMs: 2680,\n endMs: 2960,\n timestampMs: 2820,\n confidence: 0.97,\n }, {\n text: \" people\",\n startMs: 2960,\n endMs: 3320,\n timestampMs: 3140,\n confidence: 0.97,\n }, {\n text: \" in\",\n startMs: 3320,\n endMs: 3420,\n timestampMs: 3370,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 3420,\n endMs: 3520,\n timestampMs: 3470,\n confidence: 0.97,\n }, {\n text: \" first\",\n startMs: 3520,\n endMs: 3820,\n timestampMs: 3670,\n confidence: 0.97,\n }, {\n text: \" three\",\n startMs: 3820,\n endMs: 4100,\n timestampMs: 3960,\n confidence: 0.97,\n }, {\n text: \" seconds.\",\n startMs: 4100,\n endMs: 4780,\n timestampMs: 4440,\n confidence: 0.97,\n }, {\n text: \" Captions\",\n startMs: 5400,\n endMs: 5920,\n timestampMs: 5660,\n confidence: 0.97,\n }, {\n text: \" keep\",\n startMs: 5920,\n endMs: 6140,\n timestampMs: 6030,\n confidence: 0.97,\n }, {\n text: \" them\",\n startMs: 6140,\n endMs: 6300,\n timestampMs: 6220,\n confidence: 0.97,\n }, {\n text: \" watching,\",\n startMs: 6300,\n endMs: 6860,\n timestampMs: 6580,\n confidence: 0.97,\n }, {\n text: \" even\",\n startMs: 6960,\n endMs: 7180,\n timestampMs: 7070,\n confidence: 0.97,\n }, {\n text: \" with\",\n startMs: 7180,\n endMs: 7320,\n timestampMs: 7250,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 7320,\n endMs: 7420,\n timestampMs: 7370,\n confidence: 0.97,\n }, {\n text: \" sound\",\n startMs: 7420,\n endMs: 7760,\n timestampMs: 7590,\n confidence: 0.97,\n }, {\n text: \" off.\",\n startMs: 7760,\n endMs: 8300,\n timestampMs: 8030,\n confidence: 0.97,\n }],\n description: \"Transcript\",\n keyframable: false,\n },\n fontSize: {\n type: \"number\",\n min: 24,\n max: 140,\n step: 1,\n default: 64,\n description: \"Font size\",\n hiddenFromList: false,\n },\n fontWeight: {\n type: \"number\",\n min: 400,\n max: 900,\n step: 100,\n default: 800,\n description: \"Font weight\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#ffffff\",\n description: \"Text color\",\n },\n markerColor: {\n type: \"color\",\n default: \"#facc15\",\n description: \"Marker color\",\n },\n markerTextColor: {\n type: \"color\",\n default: \"#0a0a0a\",\n description: \"Marked text color\",\n },\n combineTokensWithinMilliseconds: {\n type: \"number\",\n min: 0,\n max: 3000,\n step: 100,\n default: 1200,\n description: \"Page window (ms)\",\n hiddenFromList: false,\n },\n holdMs: {\n type: \"number\",\n min: 0,\n max: 2000,\n step: 50,\n default: 600,\n description: \"Hold (ms)\",\n hiddenFromList: false,\n },\n shadow: {\n type: \"boolean\",\n default: true,\n description: \"Shadow\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"captions\",\"fontSize\",\"fontWeight\",\"color\",\"markerColor\",\"markerTextColor\",\"combineTokensWithinMilliseconds\",\"holdMs\",\"shadow\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n captions: [{\n text: \" So\",\n startMs: 300,\n endMs: 460,\n timestampMs: 380,\n confidence: 0.97,\n }, {\n text: \" here's\",\n startMs: 460,\n endMs: 700,\n timestampMs: 580,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 700,\n endMs: 820,\n timestampMs: 760,\n confidence: 0.97,\n }, {\n text: \" thing.\",\n startMs: 820,\n endMs: 1240,\n timestampMs: 1030,\n confidence: 0.97,\n }, {\n text: \" Most\",\n startMs: 1700,\n endMs: 1960,\n timestampMs: 1830,\n confidence: 0.97,\n }, {\n text: \" demo\",\n startMs: 1960,\n endMs: 2240,\n timestampMs: 2100,\n confidence: 0.97,\n }, {\n text: \" videos\",\n startMs: 2240,\n endMs: 2680,\n timestampMs: 2460,\n confidence: 0.97,\n }, {\n text: \" lose\",\n startMs: 2680,\n endMs: 2960,\n timestampMs: 2820,\n confidence: 0.97,\n }, {\n text: \" people\",\n startMs: 2960,\n endMs: 3320,\n timestampMs: 3140,\n confidence: 0.97,\n }, {\n text: \" in\",\n startMs: 3320,\n endMs: 3420,\n timestampMs: 3370,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 3420,\n endMs: 3520,\n timestampMs: 3470,\n confidence: 0.97,\n }, {\n text: \" first\",\n startMs: 3520,\n endMs: 3820,\n timestampMs: 3670,\n confidence: 0.97,\n }, {\n text: \" three\",\n startMs: 3820,\n endMs: 4100,\n timestampMs: 3960,\n confidence: 0.97,\n }, {\n text: \" seconds.\",\n startMs: 4100,\n endMs: 4780,\n timestampMs: 4440,\n confidence: 0.97,\n }, {\n text: \" Captions\",\n startMs: 5400,\n endMs: 5920,\n timestampMs: 5660,\n confidence: 0.97,\n }, {\n text: \" keep\",\n startMs: 5920,\n endMs: 6140,\n timestampMs: 6030,\n confidence: 0.97,\n }, {\n text: \" them\",\n startMs: 6140,\n endMs: 6300,\n timestampMs: 6220,\n confidence: 0.97,\n }, {\n text: \" watching,\",\n startMs: 6300,\n endMs: 6860,\n timestampMs: 6580,\n confidence: 0.97,\n }, {\n text: \" even\",\n startMs: 6960,\n endMs: 7180,\n timestampMs: 7070,\n confidence: 0.97,\n }, {\n text: \" with\",\n startMs: 7180,\n endMs: 7320,\n timestampMs: 7250,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 7320,\n endMs: 7420,\n timestampMs: 7370,\n confidence: 0.97,\n }, {\n text: \" sound\",\n startMs: 7420,\n endMs: 7760,\n timestampMs: 7590,\n confidence: 0.97,\n }, {\n text: \" off.\",\n startMs: 7760,\n endMs: 8300,\n timestampMs: 8030,\n confidence: 0.97,\n }],\n fontSize: 64,\n fontWeight: 800,\n color: \"#ffffff\",\n markerColor: \"#facc15\",\n markerTextColor: \"#0a0a0a\",\n combineTokensWithinMilliseconds: 1200,\n holdMs: 600,\n shadow: true,\n};\n\ntype CaptionMarkerElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof CaptionMarkerBase>;\n\nconst CaptionMarkerInner = forwardRef<\n HTMLDivElement,\n CaptionMarkerElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<CaptionMarker>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <CaptionMarkerBase\n {...(componentProps as unknown as ComponentProps<typeof CaptionMarkerBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const CaptionMarker = Interactive.withSchema({\n Component: CaptionMarkerInner,\n componentName: \"<CaptionMarker>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"+ },+ "durationInFrames": 279+}diff --git a/registry-artifacts/elements/caption-outline.json b/registry-artifacts/elements/caption-outline.jsonnew file mode 100644index 00000000..10435612--- /dev/null+++ b/registry-artifacts/elements/caption-outline.json@@ -0,0 +1,21 @@+{+ "type": "remotion-element",+ "version": 1,+ "element": {+ "assets": [],+ "dependencies": [+ {+ "name": "@remotion/captions",+ "version": null+ }+ ],+ "dimensions": null,+ "displayName": "Caption Outline",+ "durationInFrames": 279,+ "initialProps": null,+ "installationMode": "component-owned-sequence",+ "slug": "caption-outline",+ "sourceCode": "import { Fragment, forwardRef, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState, type ComponentProps } from \"react\";\nimport { Easing, Interactive, Sequence, interpolate, interpolateColors, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { createTikTokStyleCaptions, type Caption, type TikTokPage } from \"@remotion/captions\";\n\ntype SpeakerCaption = Caption & { speaker?: string };\n\ninterface CaptionBaseProps {\n captions: Caption[];\n combineTokensWithinMilliseconds?: number;\n holdMs?: number;\n fontSize?: number;\n fontWeight?: number;\n color?: string;\n className?: string;\n}\n\nconst DEFAULT_HOLD_MS = 600;\nconst MIN_SILENCE_BREAK_MS = 300;\n\ninterface CaptionPageWindow {\n page: TikTokPage;\n index: number;\n speaker: string | undefined;\n startMs: number;\n speechEndMs: number;\n endMs: number;\n endsInSilence: boolean;\n}\n\ntype CaptionTokenStatus = \"upcoming\" | \"active\" | \"spoken\";\n\ninterface CaptionTokenState {\n text: string;\n spaceBefore: boolean;\n fromMs: number;\n toMs: number;\n progress: number;\n status: CaptionTokenStatus;\n}\n\ninterface CaptionPreviousPage {\n page: TikTokPage;\n pageIndex: number;\n tokens: CaptionTokenState[];\n}\n\ninterface CaptionsState {\n page: TikTokPage;\n pageIndex: number;\n speaker: string | undefined;\n timeMs: number;\n activeIndex: number;\n tokens: CaptionTokenState[];\n sinceStartMs: number;\n untilEndMs: number;\n holdRoomMs: number;\n endsInSilence: boolean;\n previous: CaptionPreviousPage | null;\n}\n\ninterface CaptionPagingOptions {\n combineTokensWithinMilliseconds: number;\n holdMs?: number;\n}\n\nconst SENTENCE_END = /[.!?…][\"')\\]]*$/;\n\nfunction markPageBreaks(captions: SpeakerCaption[]): Caption[] {\n return captions.map((caption, i) => {\n if (caption.pageBreakAfter !== undefined) return caption;\n const next = captions[i + 1];\n const speakerChanges =\n next !== undefined && next.speaker !== caption.speaker;\n return speakerChanges || SENTENCE_END.test(caption.text.trim())\n ? { ...caption, pageBreakAfter: true }\n : caption;\n });\n}\n\nfunction buildCaptionPages(\n captions: SpeakerCaption[],\n {\n combineTokensWithinMilliseconds,\n holdMs = DEFAULT_HOLD_MS,\n }: CaptionPagingOptions,\n): CaptionPageWindow[] {\n if (captions.length === 0) return [];\n const { pages } = createTikTokStyleCaptions({\n captions: markPageBreaks(captions),\n combineTokensWithinMilliseconds,\n breakOnSilenceAfterMilliseconds: Math.max(holdMs, MIN_SILENCE_BREAK_MS),\n });\n const speakers = new Map<number, string | undefined>();\n for (const caption of captions) {\n if (!speakers.has(caption.startMs)) {\n speakers.set(caption.startMs, caption.speaker);\n }\n }\n const spoken = pages.filter((page) => page.tokens.length > 0);\n return spoken.map((page, index) => {\n const last = page.tokens[page.tokens.length - 1];\n const speechEndMs = last ? last.toMs : page.startMs;\n const heldUntil = speechEndMs + Math.max(0, holdMs);\n const next = spoken[index + 1];\n const endsInSilence = !next || next.startMs > heldUntil;\n const endMs = endsInSilence\n ? heldUntil\n : Math.max(page.startMs, next.startMs);\n return {\n page,\n index,\n speaker: speakers.get(page.tokens[0].fromMs),\n startMs: page.startMs,\n speechEndMs,\n endMs,\n endsInSilence,\n };\n });\n}\n\nfunction findWindowIndex(windows: CaptionPageWindow[], timeMs: number): number {\n let lo = 0;\n let hi = windows.length - 1;\n let found = -1;\n while (lo <= hi) {\n const mid = (lo + hi) >> 1;\n if (windows[mid].startMs <= timeMs) {\n found = mid;\n lo = mid + 1;\n } else {\n hi = mid - 1;\n }\n }\n if (found === -1) return -1;\n return timeMs < windows[found].endMs ? found : -1;\n}\n\nfunction tokenProgress(fromMs: number, toMs: number, timeMs: number): number {\n if (timeMs < fromMs) return 0;\n if (toMs <= fromMs) return 1;\n return Math.min(1, (timeMs - fromMs) / (toMs - fromMs));\n}\n\nfunction getTokenStates(\n page: TikTokPage,\n timeMs: number,\n): { activeIndex: number; tokens: CaptionTokenState[] } {\n let activeIndex = -1;\n page.tokens.forEach((token, i) => {\n if (token.fromMs <= timeMs) activeIndex = i;\n });\n const tokens = page.tokens.map(\n (token, i): CaptionTokenState => ({\n text: token.text.trim(),\n spaceBefore: i > 0 && /^\\s/.test(token.text),\n fromMs: token.fromMs,\n toMs: token.toMs,\n progress: tokenProgress(token.fromMs, token.toMs, timeMs),\n status:\n i < activeIndex ? \"spoken\" : i === activeIndex ? \"active\" : \"upcoming\",\n }),\n );\n return { activeIndex, tokens };\n}\n\nfunction getCaptionsState(\n windows: CaptionPageWindow[],\n timeMs: number,\n): CaptionsState | null {\n const found = findWindowIndex(windows, timeMs);\n if (found === -1) return null;\n const window = windows[found];\n const { activeIndex, tokens } = getTokenStates(window.page, timeMs);\n const before = found > 0 ? windows[found - 1] : null;\n const previous =\n before && !before.endsInSilence\n ? {\n page: before.page,\n pageIndex: before.index,\n tokens: getTokenStates(before.page, before.endMs).tokens,\n }\n : null;\n return {\n page: window.page,\n pageIndex: window.index,\n speaker: window.speaker,\n timeMs,\n activeIndex,\n tokens,\n sinceStartMs: timeMs - window.startMs,\n untilEndMs: window.endMs - timeMs,\n holdRoomMs: window.endMs - window.speechEndMs,\n endsInSilence: window.endsInSilence,\n previous,\n };\n}\n\nfunction getExitWindowMs(state: CaptionsState, exitMs: number): number {\n return Math.max(1, Math.min(exitMs, state.holdRoomMs));\n}\n\nfunction groupCaptionWords(\n tokens: CaptionTokenState[],\n): { index: number; token: CaptionTokenState }[][] {\n const words: { index: number; token: CaptionTokenState }[][] = [];\n tokens.forEach((token, index) => {\n const current = words[words.length - 1];\n if (!current || token.spaceBefore) {\n words.push([{ index, token }]);\n } else {\n current.push({ index, token });\n }\n });\n return words;\n}\n\nfunction normalizeCaptionWord(text: string): string {\n return text\n .toLowerCase()\n .replace(/[\\u2018\\u2019]/g, \"'\")\n .replace(/[^\\p{L}\\p{N}']/gu, \"\");\n}\n\nfunction createKeywordMatcher(\n keywords: readonly string[] = [],\n): (text: string) => boolean {\n const set = new Set(keywords.map(normalizeCaptionWord).filter(Boolean));\n return (text) => set.has(normalizeCaptionWord(text));\n}\n\nfunction captionWordText(word: { token: CaptionTokenState }[]): string {\n return word.map(({ token }) => token.text).join(\"\");\n}\n\ninterface CaptionWordRect {\n left: number;\n top: number;\n width: number;\n height: number;\n}\n\nfunction sameRects(a: CaptionWordRect[], b: CaptionWordRect[]): boolean {\n return (\n a.length === b.length &&\n a.every(\n (r, i) =>\n r.left === b[i].left &&\n r.top === b[i].top &&\n r.width === b[i].width &&\n r.height === b[i].height,\n )\n );\n}\n\nfunction useCaptionWordRects(\n pageIndex: number,\n count: number,\n): {\n wordRef: (index: number) => (el: HTMLElement | null) => void;\n rects: CaptionWordRect[] | null;\n} {\n const elements = useRef<(HTMLElement | null)[]>([]);\n const [measured, setMeasured] = useState<{\n pageIndex: number;\n rects: CaptionWordRect[];\n } | null>(null);\n\n useLayoutEffect(() => {\n if (pageIndex === -1) return;\n const rects = elements.current.slice(0, count).map((el) =>\n el\n ? {\n left: el.offsetLeft,\n top: el.offsetTop,\n width: el.offsetWidth,\n height: el.offsetHeight,\n }\n : { left: 0, top: 0, width: 0, height: 0 },\n );\n setMeasured((prev) =>\n prev && prev.pageIndex === pageIndex && sameRects(prev.rects, rects)\n ? prev\n : { pageIndex, rects },\n );\n });\n\n return {\n wordRef: (index) => (el) => {\n elements.current[index] = el;\n },\n rects: measured && measured.pageIndex === pageIndex ? measured.rects : null,\n };\n}\n\nfunction useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs = DEFAULT_HOLD_MS,\n}: {\n captions: SpeakerCaption[];\n combineTokensWithinMilliseconds: number;\n holdMs?: number;\n}): CaptionsState | null {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const windows = useMemo(\n () =>\n buildCaptionPages(captions, { combineTokensWithinMilliseconds, holdMs }),\n [captions, combineTokensWithinMilliseconds, holdMs],\n );\n return getCaptionsState(windows, (frame / fps) * 1000);\n}\n\ninterface CaptionOutlineProps extends CaptionBaseProps {\n activeColor?: string;\n strokeColor?: string;\n strokeWidth?: number;\n}\n\nconst ENTER_MS = 160;\nconst EXIT_MS = 220;\nconst RISE_EM = 0.14;\nconst SWITCH_MS = 70;\n\nconst enterEasing = Easing.bezier(0.2, 0.8, 0.2, 1);\n\nconst clamp = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n} as const;\n\nfunction CaptionOutlineBase({\n captions,\n combineTokensWithinMilliseconds = 1200,\n holdMs = DEFAULT_HOLD_MS,\n fontSize = 64,\n fontWeight = 800,\n color = \"#ffffff\",\n activeColor = \"#facc15\",\n strokeColor = \"#000000\",\n strokeWidth = 0.12,\n className,\n}: CaptionOutlineProps) {\n const state = useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs,\n });\n if (!state) return null;\n\n const enter = interpolate(\n state.previous ? ENTER_MS : state.sinceStartMs,\n [0, ENTER_MS],\n [0, 1],\n {\n ...clamp,\n easing: enterEasing,\n },\n );\n const exit = state.endsInSilence\n ? interpolate(\n state.untilEndMs,\n [0, getExitWindowMs(state, EXIT_MS)],\n [0, 1],\n clamp,\n )\n : 1;\n\n const words = groupCaptionWords(state.tokens);\n const activeWord = words.findIndex((word) =>\n word.some(({ index }) => index === state.activeIndex),\n );\n const activeSince =\n activeWord >= 0 ? state.timeMs - words[activeWord][0].token.fromMs : 0;\n const highlight = (w: number): number => {\n if (w === activeWord) {\n return interpolate(activeSince, [0, SWITCH_MS], [0, 1], clamp);\n }\n if (w === activeWord - 1) {\n return 1 - interpolate(activeSince, [0, SWITCH_MS], [0, 1], clamp);\n }\n return 0;\n };\n\n return (\n <div\n className={className}\n style={{\n fontSize,\n fontWeight,\n color,\n lineHeight: 1.2,\n textAlign: \"center\",\n WebkitTextStroke: `${strokeWidth * 2}em ${strokeColor}`,\n paintOrder: \"stroke fill\",\n opacity: Math.min(enter, exit),\n transform: `translateY(${(1 - enter) * RISE_EM}em)`,\n }}\n >\n {words.map((word, w) => (\n <Fragment key={`${state.pageIndex}-${word[0].index}`}>\n {w > 0 && \" \"}\n <span\n style={{\n display: \"inline-block\",\n whiteSpace: \"nowrap\",\n color: interpolateColors(\n highlight(w),\n [0, 1],\n [color, activeColor],\n ),\n }}\n >\n {captionWordText(word)}\n </span>\n </Fragment>\n ))}\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n captions: {\n type: \"remotion-captions\",\n default: [{\n text: \" So\",\n startMs: 300,\n endMs: 460,\n timestampMs: 380,\n confidence: 0.97,\n }, {\n text: \" here's\",\n startMs: 460,\n endMs: 700,\n timestampMs: 580,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 700,\n endMs: 820,\n timestampMs: 760,\n confidence: 0.97,\n }, {\n text: \" thing.\",\n startMs: 820,\n endMs: 1240,\n timestampMs: 1030,\n confidence: 0.97,\n }, {\n text: \" Most\",\n startMs: 1700,\n endMs: 1960,\n timestampMs: 1830,\n confidence: 0.97,\n }, {\n text: \" demo\",\n startMs: 1960,\n endMs: 2240,\n timestampMs: 2100,\n confidence: 0.97,\n }, {\n text: \" videos\",\n startMs: 2240,\n endMs: 2680,\n timestampMs: 2460,\n confidence: 0.97,\n }, {\n text: \" lose\",\n startMs: 2680,\n endMs: 2960,\n timestampMs: 2820,\n confidence: 0.97,\n }, {\n text: \" people\",\n startMs: 2960,\n endMs: 3320,\n timestampMs: 3140,\n confidence: 0.97,\n }, {\n text: \" in\",\n startMs: 3320,\n endMs: 3420,\n timestampMs: 3370,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 3420,\n endMs: 3520,\n timestampMs: 3470,\n confidence: 0.97,\n }, {\n text: \" first\",\n startMs: 3520,\n endMs: 3820,\n timestampMs: 3670,\n confidence: 0.97,\n }, {\n text: \" three\",\n startMs: 3820,\n endMs: 4100,\n timestampMs: 3960,\n confidence: 0.97,\n }, {\n text: \" seconds.\",\n startMs: 4100,\n endMs: 4780,\n timestampMs: 4440,\n confidence: 0.97,\n }, {\n text: \" Captions\",\n startMs: 5400,\n endMs: 5920,\n timestampMs: 5660,\n confidence: 0.97,\n }, {\n text: \" keep\",\n startMs: 5920,\n endMs: 6140,\n timestampMs: 6030,\n confidence: 0.97,\n }, {\n text: \" them\",\n startMs: 6140,\n endMs: 6300,\n timestampMs: 6220,\n confidence: 0.97,\n }, {\n text: \" watching,\",\n startMs: 6300,\n endMs: 6860,\n timestampMs: 6580,\n confidence: 0.97,\n }, {\n text: \" even\",\n startMs: 6960,\n endMs: 7180,\n timestampMs: 7070,\n confidence: 0.97,\n }, {\n text: \" with\",\n startMs: 7180,\n endMs: 7320,\n timestampMs: 7250,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 7320,\n endMs: 7420,\n timestampMs: 7370,\n confidence: 0.97,\n }, {\n text: \" sound\",\n startMs: 7420,\n endMs: 7760,\n timestampMs: 7590,\n confidence: 0.97,\n }, {\n text: \" off.\",\n startMs: 7760,\n endMs: 8300,\n timestampMs: 8030,\n confidence: 0.97,\n }],\n description: \"Transcript\",\n keyframable: false,\n },\n fontSize: {\n type: \"number\",\n min: 24,\n max: 140,\n step: 1,\n default: 64,\n description: \"Font size\",\n hiddenFromList: false,\n },\n fontWeight: {\n type: \"number\",\n min: 400,\n max: 900,\n step: 100,\n default: 800,\n description: \"Font weight\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#ffffff\",\n description: \"Text color\",\n },\n activeColor: {\n type: \"color\",\n default: \"#facc15\",\n description: \"Active color\",\n },\n strokeColor: {\n type: \"color\",\n default: \"#000000\",\n description: \"Stroke color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 0,\n max: 0.3,\n step: 0.01,\n default: 0.12,\n description: \"Stroke width (em)\",\n hiddenFromList: false,\n },\n combineTokensWithinMilliseconds: {\n type: \"number\",\n min: 0,\n max: 3000,\n step: 100,\n default: 1200,\n description: \"Page window (ms)\",\n hiddenFromList: false,\n },\n holdMs: {\n type: \"number\",\n min: 0,\n max: 2000,\n step: 50,\n default: 600,\n description: \"Hold (ms)\",\n hiddenFromList: false,\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"captions\",\"fontSize\",\"fontWeight\",\"color\",\"activeColor\",\"strokeColor\",\"strokeWidth\",\"combineTokensWithinMilliseconds\",\"holdMs\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n captions: [{\n text: \" So\",\n startMs: 300,\n endMs: 460,\n timestampMs: 380,\n confidence: 0.97,\n }, {\n text: \" here's\",\n startMs: 460,\n endMs: 700,\n timestampMs: 580,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 700,\n endMs: 820,\n timestampMs: 760,\n confidence: 0.97,\n }, {\n text: \" thing.\",\n startMs: 820,\n endMs: 1240,\n timestampMs: 1030,\n confidence: 0.97,\n }, {\n text: \" Most\",\n startMs: 1700,\n endMs: 1960,\n timestampMs: 1830,\n confidence: 0.97,\n }, {\n text: \" demo\",\n startMs: 1960,\n endMs: 2240,\n timestampMs: 2100,\n confidence: 0.97,\n }, {\n text: \" videos\",\n startMs: 2240,\n endMs: 2680,\n timestampMs: 2460,\n confidence: 0.97,\n }, {\n text: \" lose\",\n startMs: 2680,\n endMs: 2960,\n timestampMs: 2820,\n confidence: 0.97,\n }, {\n text: \" people\",\n startMs: 2960,\n endMs: 3320,\n timestampMs: 3140,\n confidence: 0.97,\n }, {\n text: \" in\",\n startMs: 3320,\n endMs: 3420,\n timestampMs: 3370,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 3420,\n endMs: 3520,\n timestampMs: 3470,\n confidence: 0.97,\n }, {\n text: \" first\",\n startMs: 3520,\n endMs: 3820,\n timestampMs: 3670,\n confidence: 0.97,\n }, {\n text: \" three\",\n startMs: 3820,\n endMs: 4100,\n timestampMs: 3960,\n confidence: 0.97,\n }, {\n text: \" seconds.\",\n startMs: 4100,\n endMs: 4780,\n timestampMs: 4440,\n confidence: 0.97,\n }, {\n text: \" Captions\",\n startMs: 5400,\n endMs: 5920,\n timestampMs: 5660,\n confidence: 0.97,\n }, {\n text: \" keep\",\n startMs: 5920,\n endMs: 6140,\n timestampMs: 6030,\n confidence: 0.97,\n }, {\n text: \" them\",\n startMs: 6140,\n endMs: 6300,\n timestampMs: 6220,\n confidence: 0.97,\n }, {\n text: \" watching,\",\n startMs: 6300,\n endMs: 6860,\n timestampMs: 6580,\n confidence: 0.97,\n }, {\n text: \" even\",\n startMs: 6960,\n endMs: 7180,\n timestampMs: 7070,\n confidence: 0.97,\n }, {\n text: \" with\",\n startMs: 7180,\n endMs: 7320,\n timestampMs: 7250,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 7320,\n endMs: 7420,\n timestampMs: 7370,\n confidence: 0.97,\n }, {\n text: \" sound\",\n startMs: 7420,\n endMs: 7760,\n timestampMs: 7590,\n confidence: 0.97,\n }, {\n text: \" off.\",\n startMs: 7760,\n endMs: 8300,\n timestampMs: 8030,\n confidence: 0.97,\n }],\n fontSize: 64,\n fontWeight: 800,\n color: \"#ffffff\",\n activeColor: \"#facc15\",\n strokeColor: \"#000000\",\n strokeWidth: 0.12,\n combineTokensWithinMilliseconds: 1200,\n holdMs: 600,\n};\n\ntype CaptionOutlineElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof CaptionOutlineBase>;\n\nconst CaptionOutlineInner = forwardRef<\n HTMLDivElement,\n CaptionOutlineElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<CaptionOutline>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <CaptionOutlineBase\n {...(componentProps as unknown as ComponentProps<typeof CaptionOutlineBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const CaptionOutline = Interactive.withSchema({\n Component: CaptionOutlineInner,\n componentName: \"<CaptionOutline>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"+ },+ "durationInFrames": 279+}diff --git a/registry-artifacts/elements/caption-prosody.json b/registry-artifacts/elements/caption-prosody.jsonnew file mode 100644index 00000000..56dce9d6--- /dev/null+++ b/registry-artifacts/elements/caption-prosody.json@@ -0,0 +1,21 @@+{+ "type": "remotion-element",+ "version": 1,+ "element": {+ "assets": [],+ "dependencies": [+ {+ "name": "@remotion/captions",+ "version": null+ }+ ],+ "dimensions": null,+ "displayName": "Caption Prosody",+ "durationInFrames": 279,+ "initialProps": null,+ "installationMode": "component-owned-sequence",+ "slug": "caption-prosody",+ "sourceCode": "import { Fragment, forwardRef, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState, type ComponentProps } from \"react\";\nimport { Easing, Interactive, Sequence, interpolate, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { createTikTokStyleCaptions, type Caption, type TikTokPage } from \"@remotion/captions\";\n\ntype SpeakerCaption = Caption & { speaker?: string };\n\ninterface CaptionBaseProps {\n captions: Caption[];\n combineTokensWithinMilliseconds?: number;\n holdMs?: number;\n fontSize?: number;\n fontWeight?: number;\n color?: string;\n className?: string;\n}\n\nconst DEFAULT_HOLD_MS = 600;\nconst MIN_SILENCE_BREAK_MS = 300;\n\ninterface CaptionPageWindow {\n page: TikTokPage;\n index: number;\n speaker: string | undefined;\n startMs: number;\n speechEndMs: number;\n endMs: number;\n endsInSilence: boolean;\n}\n\ntype CaptionTokenStatus = \"upcoming\" | \"active\" | \"spoken\";\n\ninterface CaptionTokenState {\n text: string;\n spaceBefore: boolean;\n fromMs: number;\n toMs: number;\n progress: number;\n status: CaptionTokenStatus;\n}\n\ninterface CaptionPreviousPage {\n page: TikTokPage;\n pageIndex: number;\n tokens: CaptionTokenState[];\n}\n\ninterface CaptionsState {\n page: TikTokPage;\n pageIndex: number;\n speaker: string | undefined;\n timeMs: number;\n activeIndex: number;\n tokens: CaptionTokenState[];\n sinceStartMs: number;\n untilEndMs: number;\n holdRoomMs: number;\n endsInSilence: boolean;\n previous: CaptionPreviousPage | null;\n}\n\ninterface CaptionPagingOptions {\n combineTokensWithinMilliseconds: number;\n holdMs?: number;\n}\n\nconst SENTENCE_END = /[.!?…][\"')\\]]*$/;\n\nfunction markPageBreaks(captions: SpeakerCaption[]): Caption[] {\n return captions.map((caption, i) => {\n if (caption.pageBreakAfter !== undefined) return caption;\n const next = captions[i + 1];\n const speakerChanges =\n next !== undefined && next.speaker !== caption.speaker;\n return speakerChanges || SENTENCE_END.test(caption.text.trim())\n ? { ...caption, pageBreakAfter: true }\n : caption;\n });\n}\n\nfunction buildCaptionPages(\n captions: SpeakerCaption[],\n {\n combineTokensWithinMilliseconds,\n holdMs = DEFAULT_HOLD_MS,\n }: CaptionPagingOptions,\n): CaptionPageWindow[] {\n if (captions.length === 0) return [];\n const { pages } = createTikTokStyleCaptions({\n captions: markPageBreaks(captions),\n combineTokensWithinMilliseconds,\n breakOnSilenceAfterMilliseconds: Math.max(holdMs, MIN_SILENCE_BREAK_MS),\n });\n const speakers = new Map<number, string | undefined>();\n for (const caption of captions) {\n if (!speakers.has(caption.startMs)) {\n speakers.set(caption.startMs, caption.speaker);\n }\n }\n const spoken = pages.filter((page) => page.tokens.length > 0);\n return spoken.map((page, index) => {\n const last = page.tokens[page.tokens.length - 1];\n const speechEndMs = last ? last.toMs : page.startMs;\n const heldUntil = speechEndMs + Math.max(0, holdMs);\n const next = spoken[index + 1];\n const endsInSilence = !next || next.startMs > heldUntil;\n const endMs = endsInSilence\n ? heldUntil\n : Math.max(page.startMs, next.startMs);\n return {\n page,\n index,\n speaker: speakers.get(page.tokens[0].fromMs),\n startMs: page.startMs,\n speechEndMs,\n endMs,\n endsInSilence,\n };\n });\n}\n\nfunction findWindowIndex(windows: CaptionPageWindow[], timeMs: number): number {\n let lo = 0;\n let hi = windows.length - 1;\n let found = -1;\n while (lo <= hi) {\n const mid = (lo + hi) >> 1;\n if (windows[mid].startMs <= timeMs) {\n found = mid;\n lo = mid + 1;\n } else {\n hi = mid - 1;\n }\n }\n if (found === -1) return -1;\n return timeMs < windows[found].endMs ? found : -1;\n}\n\nfunction tokenProgress(fromMs: number, toMs: number, timeMs: number): number {\n if (timeMs < fromMs) return 0;\n if (toMs <= fromMs) return 1;\n return Math.min(1, (timeMs - fromMs) / (toMs - fromMs));\n}\n\nfunction getTokenStates(\n page: TikTokPage,\n timeMs: number,\n): { activeIndex: number; tokens: CaptionTokenState[] } {\n let activeIndex = -1;\n page.tokens.forEach((token, i) => {\n if (token.fromMs <= timeMs) activeIndex = i;\n });\n const tokens = page.tokens.map(\n (token, i): CaptionTokenState => ({\n text: token.text.trim(),\n spaceBefore: i > 0 && /^\\s/.test(token.text),\n fromMs: token.fromMs,\n toMs: token.toMs,\n progress: tokenProgress(token.fromMs, token.toMs, timeMs),\n status:\n i < activeIndex ? \"spoken\" : i === activeIndex ? \"active\" : \"upcoming\",\n }),\n );\n return { activeIndex, tokens };\n}\n\nfunction getCaptionsState(\n windows: CaptionPageWindow[],\n timeMs: number,\n): CaptionsState | null {\n const found = findWindowIndex(windows, timeMs);\n if (found === -1) return null;\n const window = windows[found];\n const { activeIndex, tokens } = getTokenStates(window.page, timeMs);\n const before = found > 0 ? windows[found - 1] : null;\n const previous =\n before && !before.endsInSilence\n ? {\n page: before.page,\n pageIndex: before.index,\n tokens: getTokenStates(before.page, before.endMs).tokens,\n }\n : null;\n return {\n page: window.page,\n pageIndex: window.index,\n speaker: window.speaker,\n timeMs,\n activeIndex,\n tokens,\n sinceStartMs: timeMs - window.startMs,\n untilEndMs: window.endMs - timeMs,\n holdRoomMs: window.endMs - window.speechEndMs,\n endsInSilence: window.endsInSilence,\n previous,\n };\n}\n\nfunction getExitWindowMs(state: CaptionsState, exitMs: number): number {\n return Math.max(1, Math.min(exitMs, state.holdRoomMs));\n}\n\nfunction groupCaptionWords(\n tokens: CaptionTokenState[],\n): { index: number; token: CaptionTokenState }[][] {\n const words: { index: number; token: CaptionTokenState }[][] = [];\n tokens.forEach((token, index) => {\n const current = words[words.length - 1];\n if (!current || token.spaceBefore) {\n words.push([{ index, token }]);\n } else {\n current.push({ index, token });\n }\n });\n return words;\n}\n\nfunction normalizeCaptionWord(text: string): string {\n return text\n .toLowerCase()\n .replace(/[\\u2018\\u2019]/g, \"'\")\n .replace(/[^\\p{L}\\p{N}']/gu, \"\");\n}\n\nfunction createKeywordMatcher(\n keywords: readonly string[] = [],\n): (text: string) => boolean {\n const set = new Set(keywords.map(normalizeCaptionWord).filter(Boolean));\n return (text) => set.has(normalizeCaptionWord(text));\n}\n\nfunction captionWordText(word: { token: CaptionTokenState }[]): string {\n return word.map(({ token }) => token.text).join(\"\");\n}\n\ninterface CaptionWordRect {\n left: number;\n top: number;\n width: number;\n height: number;\n}\n\nfunction sameRects(a: CaptionWordRect[], b: CaptionWordRect[]): boolean {\n return (\n a.length === b.length &&\n a.every(\n (r, i) =>\n r.left === b[i].left &&\n r.top === b[i].top &&\n r.width === b[i].width &&\n r.height === b[i].height,\n )\n );\n}\n\nfunction useCaptionWordRects(\n pageIndex: number,\n count: number,\n): {\n wordRef: (index: number) => (el: HTMLElement | null) => void;\n rects: CaptionWordRect[] | null;\n} {\n const elements = useRef<(HTMLElement | null)[]>([]);\n const [measured, setMeasured] = useState<{\n pageIndex: number;\n rects: CaptionWordRect[];\n } | null>(null);\n\n useLayoutEffect(() => {\n if (pageIndex === -1) return;\n const rects = elements.current.slice(0, count).map((el) =>\n el\n ? {\n left: el.offsetLeft,\n top: el.offsetTop,\n width: el.offsetWidth,\n height: el.offsetHeight,\n }\n : { left: 0, top: 0, width: 0, height: 0 },\n );\n setMeasured((prev) =>\n prev && prev.pageIndex === pageIndex && sameRects(prev.rects, rects)\n ? prev\n : { pageIndex, rects },\n );\n });\n\n return {\n wordRef: (index) => (el) => {\n elements.current[index] = el;\n },\n rects: measured && measured.pageIndex === pageIndex ? measured.rects : null,\n };\n}\n\nfunction useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs = DEFAULT_HOLD_MS,\n}: {\n captions: SpeakerCaption[];\n combineTokensWithinMilliseconds: number;\n holdMs?: number;\n}): CaptionsState | null {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const windows = useMemo(\n () =>\n buildCaptionPages(captions, { combineTokensWithinMilliseconds, holdMs }),\n [captions, combineTokensWithinMilliseconds, holdMs],\n );\n return getCaptionsState(windows, (frame / fps) * 1000);\n}\n\ninterface CaptionProsodyProps extends CaptionBaseProps {\n minScale?: number;\n maxScale?: number;\n activeColor?: string;\n shadow?: boolean;\n}\n\nconst EXIT_MS = 220;\nconst WORD_IN_MS = 180;\nconst RISE_EM = 0.2;\nconst LEGIBILITY_SHADOW =\n \"0 2px 3px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.35)\";\n\nconst appearEasing = Easing.bezier(0.2, 0.8, 0.2, 1);\n\nconst clamp = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n} as const;\n\nfunction letterCount(text: string): number {\n return Math.max(1, text.match(/[\\p{L}\\p{N}]/gu)?.length ?? 0);\n}\n\nfunction median(values: number[]): number {\n const sorted = [...values].sort((a, b) => a - b);\n const mid = sorted.length >> 1;\n return sorted.length % 2 === 1\n ? sorted[mid]\n : (sorted[mid - 1] + sorted[mid]) / 2;\n}\n\nfunction getProsodyScales(\n words: { token: CaptionTokenState }[][],\n minScale: number,\n maxScale: number,\n): number[] {\n const paces = words.map((word) => {\n const fromMs = word[0].token.fromMs;\n const toMs = word[word.length - 1].token.toMs;\n return Math.max(0, toMs - fromMs) / letterCount(captionWordText(word));\n });\n const typical = median(paces);\n if (!(typical > 0)) return words.map(() => 1);\n return paces.map((pace) => {\n const t = Math.max(-1, Math.min(1, Math.log2(Math.max(pace, 1) / typical)));\n return t >= 0 ? 1 + t * (maxScale - 1) : 1 + t * (1 - minScale);\n });\n}\n\nfunction CaptionProsodyBase({\n captions,\n combineTokensWithinMilliseconds = 1200,\n holdMs = DEFAULT_HOLD_MS,\n fontSize = 64,\n fontWeight = 800,\n color = \"#ffffff\",\n minScale = 0.75,\n maxScale = 1.6,\n activeColor = \"#facc15\",\n shadow = true,\n className,\n}: CaptionProsodyProps) {\n const state = useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs,\n });\n if (!state) return null;\n\n const exit = state.endsInSilence\n ? interpolate(\n state.untilEndMs,\n [0, getExitWindowMs(state, EXIT_MS)],\n [0, 1],\n clamp,\n )\n : 1;\n const words = groupCaptionWords(state.tokens);\n const scales = getProsodyScales(words, minScale, maxScale);\n\n return (\n <div\n className={className}\n style={{\n fontSize,\n fontWeight,\n color,\n lineHeight: 1.1,\n textAlign: \"center\",\n opacity: exit,\n }}\n >\n {words.map((word, w) => {\n const appear = interpolate(\n state.timeMs - word[0].token.fromMs,\n [0, WORD_IN_MS],\n [0, 1],\n { ...clamp, easing: appearEasing },\n );\n const active = word.some(({ index }) => index === state.activeIndex);\n return (\n <Fragment key={`${state.pageIndex}-${word[0].index}`}>\n {w > 0 && \" \"}\n <span\n style={{\n display: \"inline-block\",\n whiteSpace: \"nowrap\",\n fontSize: `${scales[w]}em`,\n color: active ? activeColor : color,\n opacity: appear,\n transform: `translateY(${(1 - appear) * RISE_EM}em)`,\n textShadow: shadow ? LEGIBILITY_SHADOW : undefined,\n }}\n >\n {captionWordText(word)}\n </span>\n </Fragment>\n );\n })}\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n captions: {\n type: \"remotion-captions\",\n default: [{\n text: \" So\",\n startMs: 300,\n endMs: 460,\n timestampMs: 380,\n confidence: 0.97,\n }, {\n text: \" here's\",\n startMs: 460,\n endMs: 700,\n timestampMs: 580,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 700,\n endMs: 820,\n timestampMs: 760,\n confidence: 0.97,\n }, {\n text: \" thing.\",\n startMs: 820,\n endMs: 1240,\n timestampMs: 1030,\n confidence: 0.97,\n }, {\n text: \" Most\",\n startMs: 1700,\n endMs: 1960,\n timestampMs: 1830,\n confidence: 0.97,\n }, {\n text: \" demo\",\n startMs: 1960,\n endMs: 2240,\n timestampMs: 2100,\n confidence: 0.97,\n }, {\n text: \" videos\",\n startMs: 2240,\n endMs: 2680,\n timestampMs: 2460,\n confidence: 0.97,\n }, {\n text: \" lose\",\n startMs: 2680,\n endMs: 2960,\n timestampMs: 2820,\n confidence: 0.97,\n }, {\n text: \" people\",\n startMs: 2960,\n endMs: 3320,\n timestampMs: 3140,\n confidence: 0.97,\n }, {\n text: \" in\",\n startMs: 3320,\n endMs: 3420,\n timestampMs: 3370,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 3420,\n endMs: 3520,\n timestampMs: 3470,\n confidence: 0.97,\n }, {\n text: \" first\",\n startMs: 3520,\n endMs: 3820,\n timestampMs: 3670,\n confidence: 0.97,\n }, {\n text: \" three\",\n startMs: 3820,\n endMs: 4100,\n timestampMs: 3960,\n confidence: 0.97,\n }, {\n text: \" seconds.\",\n startMs: 4100,\n endMs: 4780,\n timestampMs: 4440,\n confidence: 0.97,\n }, {\n text: \" Captions\",\n startMs: 5400,\n endMs: 5920,\n timestampMs: 5660,\n confidence: 0.97,\n }, {\n text: \" keep\",\n startMs: 5920,\n endMs: 6140,\n timestampMs: 6030,\n confidence: 0.97,\n }, {\n text: \" them\",\n startMs: 6140,\n endMs: 6300,\n timestampMs: 6220,\n confidence: 0.97,\n }, {\n text: \" watching,\",\n startMs: 6300,\n endMs: 6860,\n timestampMs: 6580,\n confidence: 0.97,\n }, {\n text: \" even\",\n startMs: 6960,\n endMs: 7180,\n timestampMs: 7070,\n confidence: 0.97,\n }, {\n text: \" with\",\n startMs: 7180,\n endMs: 7320,\n timestampMs: 7250,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 7320,\n endMs: 7420,\n timestampMs: 7370,\n confidence: 0.97,\n }, {\n text: \" sound\",\n startMs: 7420,\n endMs: 7760,\n timestampMs: 7590,\n confidence: 0.97,\n }, {\n text: \" off.\",\n startMs: 7760,\n endMs: 8300,\n timestampMs: 8030,\n confidence: 0.97,\n }],\n description: \"Transcript\",\n keyframable: false,\n },\n fontSize: {\n type: \"number\",\n min: 24,\n max: 140,\n step: 1,\n default: 64,\n description: \"Font size\",\n hiddenFromList: false,\n },\n fontWeight: {\n type: \"number\",\n min: 400,\n max: 900,\n step: 100,\n default: 800,\n description: \"Font weight\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#ffffff\",\n description: \"Text color\",\n },\n activeColor: {\n type: \"color\",\n default: \"#facc15\",\n description: \"Active word color\",\n },\n minScale: {\n type: \"number\",\n min: 0.4,\n max: 1,\n step: 0.05,\n default: 0.75,\n description: \"Rushed word scale\",\n hiddenFromList: false,\n },\n maxScale: {\n type: \"number\",\n min: 1,\n max: 2.5,\n step: 0.05,\n default: 1.6,\n description: \"Drawn-out word scale\",\n hiddenFromList: false,\n },\n combineTokensWithinMilliseconds: {\n type: \"number\",\n min: 0,\n max: 3000,\n step: 100,\n default: 1200,\n description: \"Page window (ms)\",\n hiddenFromList: false,\n },\n holdMs: {\n type: \"number\",\n min: 0,\n max: 2000,\n step: 50,\n default: 600,\n description: \"Hold (ms)\",\n hiddenFromList: false,\n },\n shadow: {\n type: \"boolean\",\n default: true,\n description: \"Shadow\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"captions\",\"fontSize\",\"fontWeight\",\"color\",\"activeColor\",\"minScale\",\"maxScale\",\"combineTokensWithinMilliseconds\",\"holdMs\",\"shadow\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n captions: [{\n text: \" So\",\n startMs: 300,\n endMs: 460,\n timestampMs: 380,\n confidence: 0.97,\n }, {\n text: \" here's\",\n startMs: 460,\n endMs: 700,\n timestampMs: 580,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 700,\n endMs: 820,\n timestampMs: 760,\n confidence: 0.97,\n }, {\n text: \" thing.\",\n startMs: 820,\n endMs: 1240,\n timestampMs: 1030,\n confidence: 0.97,\n }, {\n text: \" Most\",\n startMs: 1700,\n endMs: 1960,\n timestampMs: 1830,\n confidence: 0.97,\n }, {\n text: \" demo\",\n startMs: 1960,\n endMs: 2240,\n timestampMs: 2100,\n confidence: 0.97,\n }, {\n text: \" videos\",\n startMs: 2240,\n endMs: 2680,\n timestampMs: 2460,\n confidence: 0.97,\n }, {\n text: \" lose\",\n startMs: 2680,\n endMs: 2960,\n timestampMs: 2820,\n confidence: 0.97,\n }, {\n text: \" people\",\n startMs: 2960,\n endMs: 3320,\n timestampMs: 3140,\n confidence: 0.97,\n }, {\n text: \" in\",\n startMs: 3320,\n endMs: 3420,\n timestampMs: 3370,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 3420,\n endMs: 3520,\n timestampMs: 3470,\n confidence: 0.97,\n }, {\n text: \" first\",\n startMs: 3520,\n endMs: 3820,\n timestampMs: 3670,\n confidence: 0.97,\n }, {\n text: \" three\",\n startMs: 3820,\n endMs: 4100,\n timestampMs: 3960,\n confidence: 0.97,\n }, {\n text: \" seconds.\",\n startMs: 4100,\n endMs: 4780,\n timestampMs: 4440,\n confidence: 0.97,\n }, {\n text: \" Captions\",\n startMs: 5400,\n endMs: 5920,\n timestampMs: 5660,\n confidence: 0.97,\n }, {\n text: \" keep\",\n startMs: 5920,\n endMs: 6140,\n timestampMs: 6030,\n confidence: 0.97,\n }, {\n text: \" them\",\n startMs: 6140,\n endMs: 6300,\n timestampMs: 6220,\n confidence: 0.97,\n }, {\n text: \" watching,\",\n startMs: 6300,\n endMs: 6860,\n timestampMs: 6580,\n confidence: 0.97,\n }, {\n text: \" even\",\n startMs: 6960,\n endMs: 7180,\n timestampMs: 7070,\n confidence: 0.97,\n }, {\n text: \" with\",\n startMs: 7180,\n endMs: 7320,\n timestampMs: 7250,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 7320,\n endMs: 7420,\n timestampMs: 7370,\n confidence: 0.97,\n }, {\n text: \" sound\",\n startMs: 7420,\n endMs: 7760,\n timestampMs: 7590,\n confidence: 0.97,\n }, {\n text: \" off.\",\n startMs: 7760,\n endMs: 8300,\n timestampMs: 8030,\n confidence: 0.97,\n }],\n fontSize: 64,\n fontWeight: 800,\n color: \"#ffffff\",\n activeColor: \"#facc15\",\n minScale: 0.75,\n maxScale: 1.6,\n combineTokensWithinMilliseconds: 1200,\n holdMs: 600,\n shadow: true,\n};\n\ntype CaptionProsodyElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof CaptionProsodyBase>;\n\nconst CaptionProsodyInner = forwardRef<\n HTMLDivElement,\n CaptionProsodyElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<CaptionProsody>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <CaptionProsodyBase\n {...(componentProps as unknown as ComponentProps<typeof CaptionProsodyBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const CaptionProsody = Interactive.withSchema({\n Component: CaptionProsodyInner,\n componentName: \"<CaptionProsody>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"+ },+ "durationInFrames": 279+}diff --git a/registry-artifacts/elements/caption-redact.json b/registry-artifacts/elements/caption-redact.jsonnew file mode 100644index 00000000..5d4eba7a--- /dev/null+++ b/registry-artifacts/elements/caption-redact.json@@ -0,0 +1,21 @@+{+ "type": "remotion-element",+ "version": 1,+ "element": {+ "assets": [],+ "dependencies": [+ {+ "name": "@remotion/captions",+ "version": null+ }+ ],+ "dimensions": null,+ "displayName": "Caption Redact",+ "durationInFrames": 279,+ "initialProps": null,+ "installationMode": "component-owned-sequence",+ "slug": "caption-redact",+ "sourceCode": "import { Fragment, forwardRef, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState, type ComponentProps } from \"react\";\nimport { Easing, Interactive, Sequence, interpolate, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { createTikTokStyleCaptions, type Caption, type TikTokPage } from \"@remotion/captions\";\n\ntype SpeakerCaption = Caption & { speaker?: string };\n\ninterface CaptionBaseProps {\n captions: Caption[];\n combineTokensWithinMilliseconds?: number;\n holdMs?: number;\n fontSize?: number;\n fontWeight?: number;\n color?: string;\n className?: string;\n}\n\nconst DEFAULT_HOLD_MS = 600;\nconst MIN_SILENCE_BREAK_MS = 300;\n\ninterface CaptionPageWindow {\n page: TikTokPage;\n index: number;\n speaker: string | undefined;\n startMs: number;\n speechEndMs: number;\n endMs: number;\n endsInSilence: boolean;\n}\n\ntype CaptionTokenStatus = \"upcoming\" | \"active\" | \"spoken\";\n\ninterface CaptionTokenState {\n text: string;\n spaceBefore: boolean;\n fromMs: number;\n toMs: number;\n progress: number;\n status: CaptionTokenStatus;\n}\n\ninterface CaptionPreviousPage {\n page: TikTokPage;\n pageIndex: number;\n tokens: CaptionTokenState[];\n}\n\ninterface CaptionsState {\n page: TikTokPage;\n pageIndex: number;\n speaker: string | undefined;\n timeMs: number;\n activeIndex: number;\n tokens: CaptionTokenState[];\n sinceStartMs: number;\n untilEndMs: number;\n holdRoomMs: number;\n endsInSilence: boolean;\n previous: CaptionPreviousPage | null;\n}\n\ninterface CaptionPagingOptions {\n combineTokensWithinMilliseconds: number;\n holdMs?: number;\n}\n\nconst SENTENCE_END = /[.!?…][\"')\\]]*$/;\n\nfunction markPageBreaks(captions: SpeakerCaption[]): Caption[] {\n return captions.map((caption, i) => {\n if (caption.pageBreakAfter !== undefined) return caption;\n const next = captions[i + 1];\n const speakerChanges =\n next !== undefined && next.speaker !== caption.speaker;\n return speakerChanges || SENTENCE_END.test(caption.text.trim())\n ? { ...caption, pageBreakAfter: true }\n : caption;\n });\n}\n\nfunction buildCaptionPages(\n captions: SpeakerCaption[],\n {\n combineTokensWithinMilliseconds,\n holdMs = DEFAULT_HOLD_MS,\n }: CaptionPagingOptions,\n): CaptionPageWindow[] {\n if (captions.length === 0) return [];\n const { pages } = createTikTokStyleCaptions({\n captions: markPageBreaks(captions),\n combineTokensWithinMilliseconds,\n breakOnSilenceAfterMilliseconds: Math.max(holdMs, MIN_SILENCE_BREAK_MS),\n });\n const speakers = new Map<number, string | undefined>();\n for (const caption of captions) {\n if (!speakers.has(caption.startMs)) {\n speakers.set(caption.startMs, caption.speaker);\n }\n }\n const spoken = pages.filter((page) => page.tokens.length > 0);\n return spoken.map((page, index) => {\n const last = page.tokens[page.tokens.length - 1];\n const speechEndMs = last ? last.toMs : page.startMs;\n const heldUntil = speechEndMs + Math.max(0, holdMs);\n const next = spoken[index + 1];\n const endsInSilence = !next || next.startMs > heldUntil;\n const endMs = endsInSilence\n ? heldUntil\n : Math.max(page.startMs, next.startMs);\n return {\n page,\n index,\n speaker: speakers.get(page.tokens[0].fromMs),\n startMs: page.startMs,\n speechEndMs,\n endMs,\n endsInSilence,\n };\n });\n}\n\nfunction findWindowIndex(windows: CaptionPageWindow[], timeMs: number): number {\n let lo = 0;\n let hi = windows.length - 1;\n let found = -1;\n while (lo <= hi) {\n const mid = (lo + hi) >> 1;\n if (windows[mid].startMs <= timeMs) {\n found = mid;\n lo = mid + 1;\n } else {\n hi = mid - 1;\n }\n }\n if (found === -1) return -1;\n return timeMs < windows[found].endMs ? found : -1;\n}\n\nfunction tokenProgress(fromMs: number, toMs: number, timeMs: number): number {\n if (timeMs < fromMs) return 0;\n if (toMs <= fromMs) return 1;\n return Math.min(1, (timeMs - fromMs) / (toMs - fromMs));\n}\n\nfunction getTokenStates(\n page: TikTokPage,\n timeMs: number,\n): { activeIndex: number; tokens: CaptionTokenState[] } {\n let activeIndex = -1;\n page.tokens.forEach((token, i) => {\n if (token.fromMs <= timeMs) activeIndex = i;\n });\n const tokens = page.tokens.map(\n (token, i): CaptionTokenState => ({\n text: token.text.trim(),\n spaceBefore: i > 0 && /^\\s/.test(token.text),\n fromMs: token.fromMs,\n toMs: token.toMs,\n progress: tokenProgress(token.fromMs, token.toMs, timeMs),\n status:\n i < activeIndex ? \"spoken\" : i === activeIndex ? \"active\" : \"upcoming\",\n }),\n );\n return { activeIndex, tokens };\n}\n\nfunction getCaptionsState(\n windows: CaptionPageWindow[],\n timeMs: number,\n): CaptionsState | null {\n const found = findWindowIndex(windows, timeMs);\n if (found === -1) return null;\n const window = windows[found];\n const { activeIndex, tokens } = getTokenStates(window.page, timeMs);\n const before = found > 0 ? windows[found - 1] : null;\n const previous =\n before && !before.endsInSilence\n ? {\n page: before.page,\n pageIndex: before.index,\n tokens: getTokenStates(before.page, before.endMs).tokens,\n }\n : null;\n return {\n page: window.page,\n pageIndex: window.index,\n speaker: window.speaker,\n timeMs,\n activeIndex,\n tokens,\n sinceStartMs: timeMs - window.startMs,\n untilEndMs: window.endMs - timeMs,\n holdRoomMs: window.endMs - window.speechEndMs,\n endsInSilence: window.endsInSilence,\n previous,\n };\n}\n\nfunction getExitWindowMs(state: CaptionsState, exitMs: number): number {\n return Math.max(1, Math.min(exitMs, state.holdRoomMs));\n}\n\nfunction groupCaptionWords(\n tokens: CaptionTokenState[],\n): { index: number; token: CaptionTokenState }[][] {\n const words: { index: number; token: CaptionTokenState }[][] = [];\n tokens.forEach((token, index) => {\n const current = words[words.length - 1];\n if (!current || token.spaceBefore) {\n words.push([{ index, token }]);\n } else {\n current.push({ index, token });\n }\n });\n return words;\n}\n\nfunction normalizeCaptionWord(text: string): string {\n return text\n .toLowerCase()\n .replace(/[\\u2018\\u2019]/g, \"'\")\n .replace(/[^\\p{L}\\p{N}']/gu, \"\");\n}\n\nfunction createKeywordMatcher(\n keywords: readonly string[] = [],\n): (text: string) => boolean {\n const set = new Set(keywords.map(normalizeCaptionWord).filter(Boolean));\n return (text) => set.has(normalizeCaptionWord(text));\n}\n\nfunction captionWordText(word: { token: CaptionTokenState }[]): string {\n return word.map(({ token }) => token.text).join(\"\");\n}\n\ninterface CaptionWordRect {\n left: number;\n top: number;\n width: number;\n height: number;\n}\n\nfunction sameRects(a: CaptionWordRect[], b: CaptionWordRect[]): boolean {\n return (\n a.length === b.length &&\n a.every(\n (r, i) =>\n r.left === b[i].left &&\n r.top === b[i].top &&\n r.width === b[i].width &&\n r.height === b[i].height,\n )\n );\n}\n\nfunction useCaptionWordRects(\n pageIndex: number,\n count: number,\n): {\n wordRef: (index: number) => (el: HTMLElement | null) => void;\n rects: CaptionWordRect[] | null;\n} {\n const elements = useRef<(HTMLElement | null)[]>([]);\n const [measured, setMeasured] = useState<{\n pageIndex: number;\n rects: CaptionWordRect[];\n } | null>(null);\n\n useLayoutEffect(() => {\n if (pageIndex === -1) return;\n const rects = elements.current.slice(0, count).map((el) =>\n el\n ? {\n left: el.offsetLeft,\n top: el.offsetTop,\n width: el.offsetWidth,\n height: el.offsetHeight,\n }\n : { left: 0, top: 0, width: 0, height: 0 },\n );\n setMeasured((prev) =>\n prev && prev.pageIndex === pageIndex && sameRects(prev.rects, rects)\n ? prev\n : { pageIndex, rects },\n );\n });\n\n return {\n wordRef: (index) => (el) => {\n elements.current[index] = el;\n },\n rects: measured && measured.pageIndex === pageIndex ? measured.rects : null,\n };\n}\n\nfunction useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs = DEFAULT_HOLD_MS,\n}: {\n captions: SpeakerCaption[];\n combineTokensWithinMilliseconds: number;\n holdMs?: number;\n}): CaptionsState | null {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const windows = useMemo(\n () =>\n buildCaptionPages(captions, { combineTokensWithinMilliseconds, holdMs }),\n [captions, combineTokensWithinMilliseconds, holdMs],\n );\n return getCaptionsState(windows, (frame / fps) * 1000);\n}\n\ninterface CaptionRedactProps extends CaptionBaseProps {\n barColor?: string;\n shadow?: boolean;\n}\n\nconst ENTER_MS = 160;\nconst EXIT_MS = 220;\nconst RISE_EM = 0.14;\nconst MIN_REVEAL_MS = 180;\nconst OVERHANG_EM = 0.06;\nconst RADIUS_EM = 0.06;\nconst BAR_TOP = \"14%\";\nconst BAR_BOTTOM = \"6%\";\nconst LEGIBILITY_SHADOW =\n \"0 2px 3px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.35)\";\n\nconst enterEasing = Easing.bezier(0.2, 0.8, 0.2, 1);\nconst revealEasing = Easing.inOut(Easing.cubic);\n\nconst clamp = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n} as const;\n\nfunction CaptionRedactBase({\n captions,\n combineTokensWithinMilliseconds = 1200,\n holdMs = DEFAULT_HOLD_MS,\n fontSize = 64,\n fontWeight = 800,\n color = \"#ffffff\",\n barColor = \"#0a0a0a\",\n shadow = true,\n className,\n}: CaptionRedactProps) {\n const state = useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs,\n });\n if (!state) return null;\n\n const enter = interpolate(\n state.previous ? ENTER_MS : state.sinceStartMs,\n [0, ENTER_MS],\n [0, 1],\n { ...clamp, easing: enterEasing },\n );\n const exit = state.endsInSilence\n ? interpolate(\n state.untilEndMs,\n [0, getExitWindowMs(state, EXIT_MS)],\n [0, 1],\n clamp,\n )\n : 1;\n const textShadow = shadow ? LEGIBILITY_SHADOW : undefined;\n\n return (\n <div\n className={className}\n style={{\n fontSize,\n fontWeight,\n color,\n lineHeight: 1.2,\n textAlign: \"center\",\n opacity: Math.min(enter, exit),\n transform: `translateY(${(1 - enter) * RISE_EM}em)`,\n }}\n >\n {groupCaptionWords(state.tokens).map((word, w) => {\n const fromMs = word[0].token.fromMs;\n const toMs = word[word.length - 1].token.toMs;\n const revealMs = Math.max(toMs - fromMs, MIN_REVEAL_MS);\n const revealed = interpolate(\n state.timeMs - fromMs,\n [0, revealMs],\n [0, 1],\n { ...clamp, easing: revealEasing },\n );\n return (\n <Fragment key={`${state.pageIndex}-${word[0].index}`}>\n {w > 0 && \" \"}\n <span\n style={{\n position: \"relative\",\n display: \"inline-block\",\n whiteSpace: \"nowrap\",\n }}\n >\n <span\n style={{\n textShadow,\n visibility: revealed > 0 ? \"visible\" : \"hidden\",\n clipPath:\n revealed >= 1\n ? undefined\n : `inset(-50% ${(1 - revealed) * 100}% -50% -50%)`,\n }}\n >\n {captionWordText(word)}\n </span>\n {revealed < 1 && (\n <span\n aria-hidden\n style={{\n position: \"absolute\",\n left: `-${OVERHANG_EM}em`,\n right: `-${OVERHANG_EM}em`,\n top: BAR_TOP,\n bottom: BAR_BOTTOM,\n background: barColor,\n borderRadius: `${RADIUS_EM}em`,\n transformOrigin: \"right center\",\n transform: `scaleX(${1 - revealed})`,\n }}\n />\n )}\n </span>\n </Fragment>\n );\n })}\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n captions: {\n type: \"remotion-captions\",\n default: [{\n text: \" So\",\n startMs: 300,\n endMs: 460,\n timestampMs: 380,\n confidence: 0.97,\n }, {\n text: \" here's\",\n startMs: 460,\n endMs: 700,\n timestampMs: 580,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 700,\n endMs: 820,\n timestampMs: 760,\n confidence: 0.97,\n }, {\n text: \" thing.\",\n startMs: 820,\n endMs: 1240,\n timestampMs: 1030,\n confidence: 0.97,\n }, {\n text: \" Most\",\n startMs: 1700,\n endMs: 1960,\n timestampMs: 1830,\n confidence: 0.97,\n }, {\n text: \" demo\",\n startMs: 1960,\n endMs: 2240,\n timestampMs: 2100,\n confidence: 0.97,\n }, {\n text: \" videos\",\n startMs: 2240,\n endMs: 2680,\n timestampMs: 2460,\n confidence: 0.97,\n }, {\n text: \" lose\",\n startMs: 2680,\n endMs: 2960,\n timestampMs: 2820,\n confidence: 0.97,\n }, {\n text: \" people\",\n startMs: 2960,\n endMs: 3320,\n timestampMs: 3140,\n confidence: 0.97,\n }, {\n text: \" in\",\n startMs: 3320,\n endMs: 3420,\n timestampMs: 3370,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 3420,\n endMs: 3520,\n timestampMs: 3470,\n confidence: 0.97,\n }, {\n text: \" first\",\n startMs: 3520,\n endMs: 3820,\n timestampMs: 3670,\n confidence: 0.97,\n }, {\n text: \" three\",\n startMs: 3820,\n endMs: 4100,\n timestampMs: 3960,\n confidence: 0.97,\n }, {\n text: \" seconds.\",\n startMs: 4100,\n endMs: 4780,\n timestampMs: 4440,\n confidence: 0.97,\n }, {\n text: \" Captions\",\n startMs: 5400,\n endMs: 5920,\n timestampMs: 5660,\n confidence: 0.97,\n }, {\n text: \" keep\",\n startMs: 5920,\n endMs: 6140,\n timestampMs: 6030,\n confidence: 0.97,\n }, {\n text: \" them\",\n startMs: 6140,\n endMs: 6300,\n timestampMs: 6220,\n confidence: 0.97,\n }, {\n text: \" watching,\",\n startMs: 6300,\n endMs: 6860,\n timestampMs: 6580,\n confidence: 0.97,\n }, {\n text: \" even\",\n startMs: 6960,\n endMs: 7180,\n timestampMs: 7070,\n confidence: 0.97,\n }, {\n text: \" with\",\n startMs: 7180,\n endMs: 7320,\n timestampMs: 7250,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 7320,\n endMs: 7420,\n timestampMs: 7370,\n confidence: 0.97,\n }, {\n text: \" sound\",\n startMs: 7420,\n endMs: 7760,\n timestampMs: 7590,\n confidence: 0.97,\n }, {\n text: \" off.\",\n startMs: 7760,\n endMs: 8300,\n timestampMs: 8030,\n confidence: 0.97,\n }],\n description: \"Transcript\",\n keyframable: false,\n },\n fontSize: {\n type: \"number\",\n min: 24,\n max: 140,\n step: 1,\n default: 64,\n description: \"Font size\",\n hiddenFromList: false,\n },\n fontWeight: {\n type: \"number\",\n min: 400,\n max: 900,\n step: 100,\n default: 800,\n description: \"Font weight\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#ffffff\",\n description: \"Text color\",\n },\n barColor: {\n type: \"color\",\n default: \"#0a0a0a\",\n description: \"Bar color\",\n },\n combineTokensWithinMilliseconds: {\n type: \"number\",\n min: 0,\n max: 3000,\n step: 100,\n default: 1200,\n description: \"Page window (ms)\",\n hiddenFromList: false,\n },\n holdMs: {\n type: \"number\",\n min: 0,\n max: 2000,\n step: 50,\n default: 600,\n description: \"Hold (ms)\",\n hiddenFromList: false,\n },\n shadow: {\n type: \"boolean\",\n default: true,\n description: \"Shadow\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"captions\",\"fontSize\",\"fontWeight\",\"color\",\"barColor\",\"combineTokensWithinMilliseconds\",\"holdMs\",\"shadow\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n captions: [{\n text: \" So\",\n startMs: 300,\n endMs: 460,\n timestampMs: 380,\n confidence: 0.97,\n }, {\n text: \" here's\",\n startMs: 460,\n endMs: 700,\n timestampMs: 580,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 700,\n endMs: 820,\n timestampMs: 760,\n confidence: 0.97,\n }, {\n text: \" thing.\",\n startMs: 820,\n endMs: 1240,\n timestampMs: 1030,\n confidence: 0.97,\n }, {\n text: \" Most\",\n startMs: 1700,\n endMs: 1960,\n timestampMs: 1830,\n confidence: 0.97,\n }, {\n text: \" demo\",\n startMs: 1960,\n endMs: 2240,\n timestampMs: 2100,\n confidence: 0.97,\n }, {\n text: \" videos\",\n startMs: 2240,\n endMs: 2680,\n timestampMs: 2460,\n confidence: 0.97,\n }, {\n text: \" lose\",\n startMs: 2680,\n endMs: 2960,\n timestampMs: 2820,\n confidence: 0.97,\n }, {\n text: \" people\",\n startMs: 2960,\n endMs: 3320,\n timestampMs: 3140,\n confidence: 0.97,\n }, {\n text: \" in\",\n startMs: 3320,\n endMs: 3420,\n timestampMs: 3370,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 3420,\n endMs: 3520,\n timestampMs: 3470,\n confidence: 0.97,\n }, {\n text: \" first\",\n startMs: 3520,\n endMs: 3820,\n timestampMs: 3670,\n confidence: 0.97,\n }, {\n text: \" three\",\n startMs: 3820,\n endMs: 4100,\n timestampMs: 3960,\n confidence: 0.97,\n }, {\n text: \" seconds.\",\n startMs: 4100,\n endMs: 4780,\n timestampMs: 4440,\n confidence: 0.97,\n }, {\n text: \" Captions\",\n startMs: 5400,\n endMs: 5920,\n timestampMs: 5660,\n confidence: 0.97,\n }, {\n text: \" keep\",\n startMs: 5920,\n endMs: 6140,\n timestampMs: 6030,\n confidence: 0.97,\n }, {\n text: \" them\",\n startMs: 6140,\n endMs: 6300,\n timestampMs: 6220,\n confidence: 0.97,\n }, {\n text: \" watching,\",\n startMs: 6300,\n endMs: 6860,\n timestampMs: 6580,\n confidence: 0.97,\n }, {\n text: \" even\",\n startMs: 6960,\n endMs: 7180,\n timestampMs: 7070,\n confidence: 0.97,\n }, {\n text: \" with\",\n startMs: 7180,\n endMs: 7320,\n timestampMs: 7250,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 7320,\n endMs: 7420,\n timestampMs: 7370,\n confidence: 0.97,\n }, {\n text: \" sound\",\n startMs: 7420,\n endMs: 7760,\n timestampMs: 7590,\n confidence: 0.97,\n }, {\n text: \" off.\",\n startMs: 7760,\n endMs: 8300,\n timestampMs: 8030,\n confidence: 0.97,\n }],\n fontSize: 64,\n fontWeight: 800,\n color: \"#ffffff\",\n barColor: \"#0a0a0a\",\n combineTokensWithinMilliseconds: 1200,\n holdMs: 600,\n shadow: true,\n};\n\ntype CaptionRedactElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof CaptionRedactBase>;\n\nconst CaptionRedactInner = forwardRef<\n HTMLDivElement,\n CaptionRedactElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<CaptionRedact>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <CaptionRedactBase\n {...(componentProps as unknown as ComponentProps<typeof CaptionRedactBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const CaptionRedact = Interactive.withSchema({\n Component: CaptionRedactInner,\n componentName: \"<CaptionRedact>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"+ },+ "durationInFrames": 279+}diff --git a/registry-artifacts/elements/caption-rise.json b/registry-artifacts/elements/caption-rise.jsonnew file mode 100644index 00000000..fe365ddd--- /dev/null+++ b/registry-artifacts/elements/caption-rise.json@@ -0,0 +1,21 @@+{+ "type": "remotion-element",+ "version": 1,+ "element": {+ "assets": [],+ "dependencies": [+ {+ "name": "@remotion/captions",+ "version": null+ }+ ],+ "dimensions": null,+ "displayName": "Caption Rise",+ "durationInFrames": 279,+ "initialProps": null,+ "installationMode": "component-owned-sequence",+ "slug": "caption-rise",+ "sourceCode": "import { Fragment, forwardRef, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState, type ComponentProps } from \"react\";\nimport { Easing, Interactive, Sequence, interpolate, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { createTikTokStyleCaptions, type Caption, type TikTokPage } from \"@remotion/captions\";\n\ntype SpeakerCaption = Caption & { speaker?: string };\n\ninterface CaptionBaseProps {\n captions: Caption[];\n combineTokensWithinMilliseconds?: number;\n holdMs?: number;\n fontSize?: number;\n fontWeight?: number;\n color?: string;\n className?: string;\n}\n\nconst DEFAULT_HOLD_MS = 600;\nconst MIN_SILENCE_BREAK_MS = 300;\n\ninterface CaptionPageWindow {\n page: TikTokPage;\n index: number;\n speaker: string | undefined;\n startMs: number;\n speechEndMs: number;\n endMs: number;\n endsInSilence: boolean;\n}\n\ntype CaptionTokenStatus = \"upcoming\" | \"active\" | \"spoken\";\n\ninterface CaptionTokenState {\n text: string;\n spaceBefore: boolean;\n fromMs: number;\n toMs: number;\n progress: number;\n status: CaptionTokenStatus;\n}\n\ninterface CaptionPreviousPage {\n page: TikTokPage;\n pageIndex: number;\n tokens: CaptionTokenState[];\n}\n\ninterface CaptionsState {\n page: TikTokPage;\n pageIndex: number;\n speaker: string | undefined;\n timeMs: number;\n activeIndex: number;\n tokens: CaptionTokenState[];\n sinceStartMs: number;\n untilEndMs: number;\n holdRoomMs: number;\n endsInSilence: boolean;\n previous: CaptionPreviousPage | null;\n}\n\ninterface CaptionPagingOptions {\n combineTokensWithinMilliseconds: number;\n holdMs?: number;\n}\n\nconst SENTENCE_END = /[.!?…][\"')\\]]*$/;\n\nfunction markPageBreaks(captions: SpeakerCaption[]): Caption[] {\n return captions.map((caption, i) => {\n if (caption.pageBreakAfter !== undefined) return caption;\n const next = captions[i + 1];\n const speakerChanges =\n next !== undefined && next.speaker !== caption.speaker;\n return speakerChanges || SENTENCE_END.test(caption.text.trim())\n ? { ...caption, pageBreakAfter: true }\n : caption;\n });\n}\n\nfunction buildCaptionPages(\n captions: SpeakerCaption[],\n {\n combineTokensWithinMilliseconds,\n holdMs = DEFAULT_HOLD_MS,\n }: CaptionPagingOptions,\n): CaptionPageWindow[] {\n if (captions.length === 0) return [];\n const { pages } = createTikTokStyleCaptions({\n captions: markPageBreaks(captions),\n combineTokensWithinMilliseconds,\n breakOnSilenceAfterMilliseconds: Math.max(holdMs, MIN_SILENCE_BREAK_MS),\n });\n const speakers = new Map<number, string | undefined>();\n for (const caption of captions) {\n if (!speakers.has(caption.startMs)) {\n speakers.set(caption.startMs, caption.speaker);\n }\n }\n const spoken = pages.filter((page) => page.tokens.length > 0);\n return spoken.map((page, index) => {\n const last = page.tokens[page.tokens.length - 1];\n const speechEndMs = last ? last.toMs : page.startMs;\n const heldUntil = speechEndMs + Math.max(0, holdMs);\n const next = spoken[index + 1];\n const endsInSilence = !next || next.startMs > heldUntil;\n const endMs = endsInSilence\n ? heldUntil\n : Math.max(page.startMs, next.startMs);\n return {\n page,\n index,\n speaker: speakers.get(page.tokens[0].fromMs),\n startMs: page.startMs,\n speechEndMs,\n endMs,\n endsInSilence,\n };\n });\n}\n\nfunction findWindowIndex(windows: CaptionPageWindow[], timeMs: number): number {\n let lo = 0;\n let hi = windows.length - 1;\n let found = -1;\n while (lo <= hi) {\n const mid = (lo + hi) >> 1;\n if (windows[mid].startMs <= timeMs) {\n found = mid;\n lo = mid + 1;\n } else {\n hi = mid - 1;\n }\n }\n if (found === -1) return -1;\n return timeMs < windows[found].endMs ? found : -1;\n}\n\nfunction tokenProgress(fromMs: number, toMs: number, timeMs: number): number {\n if (timeMs < fromMs) return 0;\n if (toMs <= fromMs) return 1;\n return Math.min(1, (timeMs - fromMs) / (toMs - fromMs));\n}\n\nfunction getTokenStates(\n page: TikTokPage,\n timeMs: number,\n): { activeIndex: number; tokens: CaptionTokenState[] } {\n let activeIndex = -1;\n page.tokens.forEach((token, i) => {\n if (token.fromMs <= timeMs) activeIndex = i;\n });\n const tokens = page.tokens.map(\n (token, i): CaptionTokenState => ({\n text: token.text.trim(),\n spaceBefore: i > 0 && /^\\s/.test(token.text),\n fromMs: token.fromMs,\n toMs: token.toMs,\n progress: tokenProgress(token.fromMs, token.toMs, timeMs),\n status:\n i < activeIndex ? \"spoken\" : i === activeIndex ? \"active\" : \"upcoming\",\n }),\n );\n return { activeIndex, tokens };\n}\n\nfunction getCaptionsState(\n windows: CaptionPageWindow[],\n timeMs: number,\n): CaptionsState | null {\n const found = findWindowIndex(windows, timeMs);\n if (found === -1) return null;\n const window = windows[found];\n const { activeIndex, tokens } = getTokenStates(window.page, timeMs);\n const before = found > 0 ? windows[found - 1] : null;\n const previous =\n before && !before.endsInSilence\n ? {\n page: before.page,\n pageIndex: before.index,\n tokens: getTokenStates(before.page, before.endMs).tokens,\n }\n : null;\n return {\n page: window.page,\n pageIndex: window.index,\n speaker: window.speaker,\n timeMs,\n activeIndex,\n tokens,\n sinceStartMs: timeMs - window.startMs,\n untilEndMs: window.endMs - timeMs,\n holdRoomMs: window.endMs - window.speechEndMs,\n endsInSilence: window.endsInSilence,\n previous,\n };\n}\n\nfunction getExitWindowMs(state: CaptionsState, exitMs: number): number {\n return Math.max(1, Math.min(exitMs, state.holdRoomMs));\n}\n\nfunction groupCaptionWords(\n tokens: CaptionTokenState[],\n): { index: number; token: CaptionTokenState }[][] {\n const words: { index: number; token: CaptionTokenState }[][] = [];\n tokens.forEach((token, index) => {\n const current = words[words.length - 1];\n if (!current || token.spaceBefore) {\n words.push([{ index, token }]);\n } else {\n current.push({ index, token });\n }\n });\n return words;\n}\n\nfunction normalizeCaptionWord(text: string): string {\n return text\n .toLowerCase()\n .replace(/[\\u2018\\u2019]/g, \"'\")\n .replace(/[^\\p{L}\\p{N}']/gu, \"\");\n}\n\nfunction createKeywordMatcher(\n keywords: readonly string[] = [],\n): (text: string) => boolean {\n const set = new Set(keywords.map(normalizeCaptionWord).filter(Boolean));\n return (text) => set.has(normalizeCaptionWord(text));\n}\n\nfunction captionWordText(word: { token: CaptionTokenState }[]): string {\n return word.map(({ token }) => token.text).join(\"\");\n}\n\ninterface CaptionWordRect {\n left: number;\n top: number;\n width: number;\n height: number;\n}\n\nfunction sameRects(a: CaptionWordRect[], b: CaptionWordRect[]): boolean {\n return (\n a.length === b.length &&\n a.every(\n (r, i) =>\n r.left === b[i].left &&\n r.top === b[i].top &&\n r.width === b[i].width &&\n r.height === b[i].height,\n )\n );\n}\n\nfunction useCaptionWordRects(\n pageIndex: number,\n count: number,\n): {\n wordRef: (index: number) => (el: HTMLElement | null) => void;\n rects: CaptionWordRect[] | null;\n} {\n const elements = useRef<(HTMLElement | null)[]>([]);\n const [measured, setMeasured] = useState<{\n pageIndex: number;\n rects: CaptionWordRect[];\n } | null>(null);\n\n useLayoutEffect(() => {\n if (pageIndex === -1) return;\n const rects = elements.current.slice(0, count).map((el) =>\n el\n ? {\n left: el.offsetLeft,\n top: el.offsetTop,\n width: el.offsetWidth,\n height: el.offsetHeight,\n }\n : { left: 0, top: 0, width: 0, height: 0 },\n );\n setMeasured((prev) =>\n prev && prev.pageIndex === pageIndex && sameRects(prev.rects, rects)\n ? prev\n : { pageIndex, rects },\n );\n });\n\n return {\n wordRef: (index) => (el) => {\n elements.current[index] = el;\n },\n rects: measured && measured.pageIndex === pageIndex ? measured.rects : null,\n };\n}\n\nfunction useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs = DEFAULT_HOLD_MS,\n}: {\n captions: SpeakerCaption[];\n combineTokensWithinMilliseconds: number;\n holdMs?: number;\n}): CaptionsState | null {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const windows = useMemo(\n () =>\n buildCaptionPages(captions, { combineTokensWithinMilliseconds, holdMs }),\n [captions, combineTokensWithinMilliseconds, holdMs],\n );\n return getCaptionsState(windows, (frame / fps) * 1000);\n}\n\ninterface CaptionRiseProps extends CaptionBaseProps {\n shadow?: boolean;\n}\n\nconst EXIT_MS = 220;\nconst RISE_MS = 260;\nconst START_EM = 1.6;\nconst CLIP = \"inset(-0.2em -0.6em -0.35em -0.6em)\";\nconst LEGIBILITY_SHADOW =\n \"0 2px 3px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.35)\";\n\nconst riseEasing = Easing.bezier(0.16, 1, 0.3, 1);\n\nfunction CaptionRiseBase({\n captions,\n combineTokensWithinMilliseconds = 1200,\n holdMs = DEFAULT_HOLD_MS,\n fontSize = 64,\n fontWeight = 800,\n color = \"#ffffff\",\n shadow = true,\n className,\n}: CaptionRiseProps) {\n const state = useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs,\n });\n if (!state) return null;\n\n const exit = state.endsInSilence\n ? interpolate(\n state.untilEndMs,\n [0, getExitWindowMs(state, EXIT_MS)],\n [0, 1],\n {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n },\n )\n : 1;\n\n return (\n <div\n className={className}\n style={{\n fontSize,\n fontWeight,\n color,\n lineHeight: 1.2,\n textAlign: \"center\",\n opacity: exit,\n }}\n >\n {groupCaptionWords(state.tokens).map((word, w) => (\n <Fragment key={`${state.pageIndex}-${word[0].index}`}>\n {w > 0 && \" \"}\n <span style={{ display: \"inline-block\", whiteSpace: \"nowrap\" }}>\n {word.map(({ index, token }) => {\n const sinceMs = state.timeMs - token.fromMs;\n const p =\n sinceMs < 0\n ? 0\n : interpolate(sinceMs, [0, RISE_MS], [0, 1], {\n easing: riseEasing,\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n });\n return (\n <span\n key={index}\n style={{\n display: \"inline-block\",\n clipPath: CLIP,\n }}\n >\n <span\n style={{\n display: \"inline-block\",\n opacity: sinceMs < 0 ? 0 : 1,\n transform: `translateY(${(1 - p) * START_EM}em)`,\n textShadow: shadow ? LEGIBILITY_SHADOW : undefined,\n }}\n >\n {token.text}\n </span>\n </span>\n );\n })}\n </span>\n </Fragment>\n ))}\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n captions: {\n type: \"remotion-captions\",\n default: [{\n text: \" So\",\n startMs: 300,\n endMs: 460,\n timestampMs: 380,\n confidence: 0.97,\n }, {\n text: \" here's\",\n startMs: 460,\n endMs: 700,\n timestampMs: 580,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 700,\n endMs: 820,\n timestampMs: 760,\n confidence: 0.97,\n }, {\n text: \" thing.\",\n startMs: 820,\n endMs: 1240,\n timestampMs: 1030,\n confidence: 0.97,\n }, {\n text: \" Most\",\n startMs: 1700,\n endMs: 1960,\n timestampMs: 1830,\n confidence: 0.97,\n }, {\n text: \" demo\",\n startMs: 1960,\n endMs: 2240,\n timestampMs: 2100,\n confidence: 0.97,\n }, {\n text: \" videos\",\n startMs: 2240,\n endMs: 2680,\n timestampMs: 2460,\n confidence: 0.97,\n }, {\n text: \" lose\",\n startMs: 2680,\n endMs: 2960,\n timestampMs: 2820,\n confidence: 0.97,\n }, {\n text: \" people\",\n startMs: 2960,\n endMs: 3320,\n timestampMs: 3140,\n confidence: 0.97,\n }, {\n text: \" in\",\n startMs: 3320,\n endMs: 3420,\n timestampMs: 3370,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 3420,\n endMs: 3520,\n timestampMs: 3470,\n confidence: 0.97,\n }, {\n text: \" first\",\n startMs: 3520,\n endMs: 3820,\n timestampMs: 3670,\n confidence: 0.97,\n }, {\n text: \" three\",\n startMs: 3820,\n endMs: 4100,\n timestampMs: 3960,\n confidence: 0.97,\n }, {\n text: \" seconds.\",\n startMs: 4100,\n endMs: 4780,\n timestampMs: 4440,\n confidence: 0.97,\n }, {\n text: \" Captions\",\n startMs: 5400,\n endMs: 5920,\n timestampMs: 5660,\n confidence: 0.97,\n }, {\n text: \" keep\",\n startMs: 5920,\n endMs: 6140,\n timestampMs: 6030,\n confidence: 0.97,\n }, {\n text: \" them\",\n startMs: 6140,\n endMs: 6300,\n timestampMs: 6220,\n confidence: 0.97,\n }, {\n text: \" watching,\",\n startMs: 6300,\n endMs: 6860,\n timestampMs: 6580,\n confidence: 0.97,\n }, {\n text: \" even\",\n startMs: 6960,\n endMs: 7180,\n timestampMs: 7070,\n confidence: 0.97,\n }, {\n text: \" with\",\n startMs: 7180,\n endMs: 7320,\n timestampMs: 7250,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 7320,\n endMs: 7420,\n timestampMs: 7370,\n confidence: 0.97,\n }, {\n text: \" sound\",\n startMs: 7420,\n endMs: 7760,\n timestampMs: 7590,\n confidence: 0.97,\n }, {\n text: \" off.\",\n startMs: 7760,\n endMs: 8300,\n timestampMs: 8030,\n confidence: 0.97,\n }],\n description: \"Transcript\",\n keyframable: false,\n },\n fontSize: {\n type: \"number\",\n min: 24,\n max: 140,\n step: 1,\n default: 64,\n description: \"Font size\",\n hiddenFromList: false,\n },\n fontWeight: {\n type: \"number\",\n min: 400,\n max: 900,\n step: 100,\n default: 800,\n description: \"Font weight\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#ffffff\",\n description: \"Text color\",\n },\n combineTokensWithinMilliseconds: {\n type: \"number\",\n min: 0,\n max: 3000,\n step: 100,\n default: 1200,\n description: \"Page window (ms)\",\n hiddenFromList: false,\n },\n holdMs: {\n type: \"number\",\n min: 0,\n max: 2000,\n step: 50,\n default: 600,\n description: \"Hold (ms)\",\n hiddenFromList: false,\n },\n shadow: {\n type: \"boolean\",\n default: true,\n description: \"Shadow\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"captions\",\"fontSize\",\"fontWeight\",\"color\",\"combineTokensWithinMilliseconds\",\"holdMs\",\"shadow\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n captions: [{\n text: \" So\",\n startMs: 300,\n endMs: 460,\n timestampMs: 380,\n confidence: 0.97,\n }, {\n text: \" here's\",\n startMs: 460,\n endMs: 700,\n timestampMs: 580,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 700,\n endMs: 820,\n timestampMs: 760,\n confidence: 0.97,\n }, {\n text: \" thing.\",\n startMs: 820,\n endMs: 1240,\n timestampMs: 1030,\n confidence: 0.97,\n }, {\n text: \" Most\",\n startMs: 1700,\n endMs: 1960,\n timestampMs: 1830,\n confidence: 0.97,\n }, {\n text: \" demo\",\n startMs: 1960,\n endMs: 2240,\n timestampMs: 2100,\n confidence: 0.97,\n }, {\n text: \" videos\",\n startMs: 2240,\n endMs: 2680,\n timestampMs: 2460,\n confidence: 0.97,\n }, {\n text: \" lose\",\n startMs: 2680,\n endMs: 2960,\n timestampMs: 2820,\n confidence: 0.97,\n }, {\n text: \" people\",\n startMs: 2960,\n endMs: 3320,\n timestampMs: 3140,\n confidence: 0.97,\n }, {\n text: \" in\",\n startMs: 3320,\n endMs: 3420,\n timestampMs: 3370,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 3420,\n endMs: 3520,\n timestampMs: 3470,\n confidence: 0.97,\n }, {\n text: \" first\",\n startMs: 3520,\n endMs: 3820,\n timestampMs: 3670,\n confidence: 0.97,\n }, {\n text: \" three\",\n startMs: 3820,\n endMs: 4100,\n timestampMs: 3960,\n confidence: 0.97,\n }, {\n text: \" seconds.\",\n startMs: 4100,\n endMs: 4780,\n timestampMs: 4440,\n confidence: 0.97,\n }, {\n text: \" Captions\",\n startMs: 5400,\n endMs: 5920,\n timestampMs: 5660,\n confidence: 0.97,\n }, {\n text: \" keep\",\n startMs: 5920,\n endMs: 6140,\n timestampMs: 6030,\n confidence: 0.97,\n }, {\n text: \" them\",\n startMs: 6140,\n endMs: 6300,\n timestampMs: 6220,\n confidence: 0.97,\n }, {\n text: \" watching,\",\n startMs: 6300,\n endMs: 6860,\n timestampMs: 6580,\n confidence: 0.97,\n }, {\n text: \" even\",\n startMs: 6960,\n endMs: 7180,\n timestampMs: 7070,\n confidence: 0.97,\n }, {\n text: \" with\",\n startMs: 7180,\n endMs: 7320,\n timestampMs: 7250,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 7320,\n endMs: 7420,\n timestampMs: 7370,\n confidence: 0.97,\n }, {\n text: \" sound\",\n startMs: 7420,\n endMs: 7760,\n timestampMs: 7590,\n confidence: 0.97,\n }, {\n text: \" off.\",\n startMs: 7760,\n endMs: 8300,\n timestampMs: 8030,\n confidence: 0.97,\n }],\n fontSize: 64,\n fontWeight: 800,\n color: \"#ffffff\",\n combineTokensWithinMilliseconds: 1200,\n holdMs: 600,\n shadow: true,\n};\n\ntype CaptionRiseElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof CaptionRiseBase>;\n\nconst CaptionRiseInner = forwardRef<\n HTMLDivElement,\n CaptionRiseElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<CaptionRise>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <CaptionRiseBase\n {...(componentProps as unknown as ComponentProps<typeof CaptionRiseBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const CaptionRise = Interactive.withSchema({\n Component: CaptionRiseInner,\n componentName: \"<CaptionRise>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"+ },+ "durationInFrames": 279+}diff --git a/registry-artifacts/elements/caption-scramble.json b/registry-artifacts/elements/caption-scramble.jsonnew file mode 100644index 00000000..0b9c7d16--- /dev/null+++ b/registry-artifacts/elements/caption-scramble.json@@ -0,0 +1,21 @@+{+ "type": "remotion-element",+ "version": 1,+ "element": {+ "assets": [],+ "dependencies": [+ {+ "name": "@remotion/captions",+ "version": null+ }+ ],+ "dimensions": null,+ "displayName": "Caption Scramble",+ "durationInFrames": 279,+ "initialProps": null,+ "installationMode": "component-owned-sequence",+ "slug": "caption-scramble",+ "sourceCode": "import { Fragment, forwardRef, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState, type ComponentProps } from \"react\";\nimport { Easing, Interactive, Sequence, interpolate, random, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { createTikTokStyleCaptions, type Caption, type TikTokPage } from \"@remotion/captions\";\n\ntype SpeakerCaption = Caption & { speaker?: string };\n\ninterface CaptionBaseProps {\n captions: Caption[];\n combineTokensWithinMilliseconds?: number;\n holdMs?: number;\n fontSize?: number;\n fontWeight?: number;\n color?: string;\n className?: string;\n}\n\nconst DEFAULT_HOLD_MS = 600;\nconst MIN_SILENCE_BREAK_MS = 300;\n\ninterface CaptionPageWindow {\n page: TikTokPage;\n index: number;\n speaker: string | undefined;\n startMs: number;\n speechEndMs: number;\n endMs: number;\n endsInSilence: boolean;\n}\n\ntype CaptionTokenStatus = \"upcoming\" | \"active\" | \"spoken\";\n\ninterface CaptionTokenState {\n text: string;\n spaceBefore: boolean;\n fromMs: number;\n toMs: number;\n progress: number;\n status: CaptionTokenStatus;\n}\n\ninterface CaptionPreviousPage {\n page: TikTokPage;\n pageIndex: number;\n tokens: CaptionTokenState[];\n}\n\ninterface CaptionsState {\n page: TikTokPage;\n pageIndex: number;\n speaker: string | undefined;\n timeMs: number;\n activeIndex: number;\n tokens: CaptionTokenState[];\n sinceStartMs: number;\n untilEndMs: number;\n holdRoomMs: number;\n endsInSilence: boolean;\n previous: CaptionPreviousPage | null;\n}\n\ninterface CaptionPagingOptions {\n combineTokensWithinMilliseconds: number;\n holdMs?: number;\n}\n\nconst SENTENCE_END = /[.!?…][\"')\\]]*$/;\n\nfunction markPageBreaks(captions: SpeakerCaption[]): Caption[] {\n return captions.map((caption, i) => {\n if (caption.pageBreakAfter !== undefined) return caption;\n const next = captions[i + 1];\n const speakerChanges =\n next !== undefined && next.speaker !== caption.speaker;\n return speakerChanges || SENTENCE_END.test(caption.text.trim())\n ? { ...caption, pageBreakAfter: true }\n : caption;\n });\n}\n\nfunction buildCaptionPages(\n captions: SpeakerCaption[],\n {\n combineTokensWithinMilliseconds,\n holdMs = DEFAULT_HOLD_MS,\n }: CaptionPagingOptions,\n): CaptionPageWindow[] {\n if (captions.length === 0) return [];\n const { pages } = createTikTokStyleCaptions({\n captions: markPageBreaks(captions),\n combineTokensWithinMilliseconds,\n breakOnSilenceAfterMilliseconds: Math.max(holdMs, MIN_SILENCE_BREAK_MS),\n });\n const speakers = new Map<number, string | undefined>();\n for (const caption of captions) {\n if (!speakers.has(caption.startMs)) {\n speakers.set(caption.startMs, caption.speaker);\n }\n }\n const spoken = pages.filter((page) => page.tokens.length > 0);\n return spoken.map((page, index) => {\n const last = page.tokens[page.tokens.length - 1];\n const speechEndMs = last ? last.toMs : page.startMs;\n const heldUntil = speechEndMs + Math.max(0, holdMs);\n const next = spoken[index + 1];\n const endsInSilence = !next || next.startMs > heldUntil;\n const endMs = endsInSilence\n ? heldUntil\n : Math.max(page.startMs, next.startMs);\n return {\n page,\n index,\n speaker: speakers.get(page.tokens[0].fromMs),\n startMs: page.startMs,\n speechEndMs,\n endMs,\n endsInSilence,\n };\n });\n}\n\nfunction findWindowIndex(windows: CaptionPageWindow[], timeMs: number): number {\n let lo = 0;\n let hi = windows.length - 1;\n let found = -1;\n while (lo <= hi) {\n const mid = (lo + hi) >> 1;\n if (windows[mid].startMs <= timeMs) {\n found = mid;\n lo = mid + 1;\n } else {\n hi = mid - 1;\n }\n }\n if (found === -1) return -1;\n return timeMs < windows[found].endMs ? found : -1;\n}\n\nfunction tokenProgress(fromMs: number, toMs: number, timeMs: number): number {\n if (timeMs < fromMs) return 0;\n if (toMs <= fromMs) return 1;\n return Math.min(1, (timeMs - fromMs) / (toMs - fromMs));\n}\n\nfunction getTokenStates(\n page: TikTokPage,\n timeMs: number,\n): { activeIndex: number; tokens: CaptionTokenState[] } {\n let activeIndex = -1;\n page.tokens.forEach((token, i) => {\n if (token.fromMs <= timeMs) activeIndex = i;\n });\n const tokens = page.tokens.map(\n (token, i): CaptionTokenState => ({\n text: token.text.trim(),\n spaceBefore: i > 0 && /^\\s/.test(token.text),\n fromMs: token.fromMs,\n toMs: token.toMs,\n progress: tokenProgress(token.fromMs, token.toMs, timeMs),\n status:\n i < activeIndex ? \"spoken\" : i === activeIndex ? \"active\" : \"upcoming\",\n }),\n );\n return { activeIndex, tokens };\n}\n\nfunction getCaptionsState(\n windows: CaptionPageWindow[],\n timeMs: number,\n): CaptionsState | null {\n const found = findWindowIndex(windows, timeMs);\n if (found === -1) return null;\n const window = windows[found];\n const { activeIndex, tokens } = getTokenStates(window.page, timeMs);\n const before = found > 0 ? windows[found - 1] : null;\n const previous =\n before && !before.endsInSilence\n ? {\n page: before.page,\n pageIndex: before.index,\n tokens: getTokenStates(before.page, before.endMs).tokens,\n }\n : null;\n return {\n page: window.page,\n pageIndex: window.index,\n speaker: window.speaker,\n timeMs,\n activeIndex,\n tokens,\n sinceStartMs: timeMs - window.startMs,\n untilEndMs: window.endMs - timeMs,\n holdRoomMs: window.endMs - window.speechEndMs,\n endsInSilence: window.endsInSilence,\n previous,\n };\n}\n\nfunction getExitWindowMs(state: CaptionsState, exitMs: number): number {\n return Math.max(1, Math.min(exitMs, state.holdRoomMs));\n}\n\nfunction groupCaptionWords(\n tokens: CaptionTokenState[],\n): { index: number; token: CaptionTokenState }[][] {\n const words: { index: number; token: CaptionTokenState }[][] = [];\n tokens.forEach((token, index) => {\n const current = words[words.length - 1];\n if (!current || token.spaceBefore) {\n words.push([{ index, token }]);\n } else {\n current.push({ index, token });\n }\n });\n return words;\n}\n\nfunction normalizeCaptionWord(text: string): string {\n return text\n .toLowerCase()\n .replace(/[\\u2018\\u2019]/g, \"'\")\n .replace(/[^\\p{L}\\p{N}']/gu, \"\");\n}\n\nfunction createKeywordMatcher(\n keywords: readonly string[] = [],\n): (text: string) => boolean {\n const set = new Set(keywords.map(normalizeCaptionWord).filter(Boolean));\n return (text) => set.has(normalizeCaptionWord(text));\n}\n\nfunction captionWordText(word: { token: CaptionTokenState }[]): string {\n return word.map(({ token }) => token.text).join(\"\");\n}\n\ninterface CaptionWordRect {\n left: number;\n top: number;\n width: number;\n height: number;\n}\n\nfunction sameRects(a: CaptionWordRect[], b: CaptionWordRect[]): boolean {\n return (\n a.length === b.length &&\n a.every(\n (r, i) =>\n r.left === b[i].left &&\n r.top === b[i].top &&\n r.width === b[i].width &&\n r.height === b[i].height,\n )\n );\n}\n\nfunction useCaptionWordRects(\n pageIndex: number,\n count: number,\n): {\n wordRef: (index: number) => (el: HTMLElement | null) => void;\n rects: CaptionWordRect[] | null;\n} {\n const elements = useRef<(HTMLElement | null)[]>([]);\n const [measured, setMeasured] = useState<{\n pageIndex: number;\n rects: CaptionWordRect[];\n } | null>(null);\n\n useLayoutEffect(() => {\n if (pageIndex === -1) return;\n const rects = elements.current.slice(0, count).map((el) =>\n el\n ? {\n left: el.offsetLeft,\n top: el.offsetTop,\n width: el.offsetWidth,\n height: el.offsetHeight,\n }\n : { left: 0, top: 0, width: 0, height: 0 },\n );\n setMeasured((prev) =>\n prev && prev.pageIndex === pageIndex && sameRects(prev.rects, rects)\n ? prev\n : { pageIndex, rects },\n );\n });\n\n return {\n wordRef: (index) => (el) => {\n elements.current[index] = el;\n },\n rects: measured && measured.pageIndex === pageIndex ? measured.rects : null,\n };\n}\n\nfunction useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs = DEFAULT_HOLD_MS,\n}: {\n captions: SpeakerCaption[];\n combineTokensWithinMilliseconds: number;\n holdMs?: number;\n}): CaptionsState | null {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const windows = useMemo(\n () =>\n buildCaptionPages(captions, { combineTokensWithinMilliseconds, holdMs }),\n [captions, combineTokensWithinMilliseconds, holdMs],\n );\n return getCaptionsState(windows, (frame / fps) * 1000);\n}\n\ninterface CaptionScrambleProps extends CaptionBaseProps {\n glyphColor?: string;\n shadow?: boolean;\n}\n\nconst ENTER_MS = 160;\nconst EXIT_MS = 220;\nconst RISE_EM = 0.14;\nconst MAX_RESOLVE_MS = 300;\nconst FRAMES_PER_ROLL = 2;\nconst GLYPHS = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789#%&*/+=\";\nconst LEGIBILITY_SHADOW =\n \"0 2px 3px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.35)\";\n\nconst enterEasing = Easing.bezier(0.2, 0.8, 0.2, 1);\n\nconst clamp = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n} as const;\n\nfunction resolveProgress(sinceMs: number, fromMs: number, toMs: number) {\n const duration = Math.min(toMs - fromMs, MAX_RESOLVE_MS);\n if (duration <= 0) return 1;\n return Math.min(1, sinceMs / duration);\n}\n\nfunction CaptionScrambleBase({\n captions,\n combineTokensWithinMilliseconds = 1200,\n holdMs = DEFAULT_HOLD_MS,\n fontSize = 64,\n fontWeight = 800,\n color = \"#ffffff\",\n glyphColor = \"#a3a3a3\",\n shadow = true,\n className,\n}: CaptionScrambleProps) {\n const { fps } = useVideoConfig();\n const state = useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs,\n });\n if (!state) return null;\n\n const enter = interpolate(\n state.previous ? ENTER_MS : state.sinceStartMs,\n [0, ENTER_MS],\n [0, 1],\n {\n ...clamp,\n easing: enterEasing,\n },\n );\n const exit = state.endsInSilence\n ? interpolate(\n state.untilEndMs,\n [0, getExitWindowMs(state, EXIT_MS)],\n [0, 1],\n clamp,\n )\n : 1;\n const step = Math.floor(((state.timeMs / 1000) * fps) / FRAMES_PER_ROLL);\n const textShadow = shadow ? LEGIBILITY_SHADOW : undefined;\n\n return (\n <div\n className={className}\n style={{\n fontSize,\n fontWeight,\n color,\n lineHeight: 1.2,\n textAlign: \"center\",\n opacity: Math.min(enter, exit),\n transform: `translateY(${(1 - enter) * RISE_EM}em)`,\n }}\n >\n {groupCaptionWords(state.tokens).map((word, w) => (\n <Fragment key={`${state.pageIndex}-${word[0].index}`}>\n {w > 0 && \" \"}\n <span style={{ display: \"inline-block\", whiteSpace: \"nowrap\" }}>\n {word.map(({ index, token }) => {\n const sinceMs = state.timeMs - token.fromMs;\n if (sinceMs < 0) {\n return (\n <span key={index} style={{ opacity: 0 }}>\n {token.text}\n </span>\n );\n }\n const progress = resolveProgress(\n sinceMs,\n token.fromMs,\n token.toMs,\n );\n if (progress >= 1) {\n return (\n <span key={index} style={{ textShadow }}>\n {token.text}\n </span>\n );\n }\n const chars = Array.from(token.text);\n const resolved = Math.floor(progress * chars.length);\n return (\n <span\n key={index}\n style={{ position: \"relative\", display: \"inline-block\" }}\n >\n <span style={{ color: \"transparent\" }}>{token.text}</span>\n <span\n aria-hidden\n style={{\n position: \"absolute\",\n left: 0,\n right: 0,\n top: 0,\n whiteSpace: \"nowrap\",\n clipPath: \"inset(-50% 0 -50% 0)\",\n textShadow,\n }}\n >\n <span>{chars.slice(0, resolved).join(\"\")}</span>\n <span style={{ color: glyphColor }}>\n {chars\n .slice(resolved)\n .map((char, c) =>\n /\\s/.test(char)\n ? char\n : GLYPHS[\n Math.floor(\n random(\n `${state.pageIndex}-${index}-${resolved + c}-${step}`,\n ) * GLYPHS.length,\n )\n ],\n )\n .join(\"\")}\n </span>\n </span>\n </span>\n );\n })}\n </span>\n </Fragment>\n ))}\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n captions: {\n type: \"remotion-captions\",\n default: [{\n text: \" So\",\n startMs: 300,\n endMs: 460,\n timestampMs: 380,\n confidence: 0.97,\n }, {\n text: \" here's\",\n startMs: 460,\n endMs: 700,\n timestampMs: 580,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 700,\n endMs: 820,\n timestampMs: 760,\n confidence: 0.97,\n }, {\n text: \" thing.\",\n startMs: 820,\n endMs: 1240,\n timestampMs: 1030,\n confidence: 0.97,\n }, {\n text: \" Most\",\n startMs: 1700,\n endMs: 1960,\n timestampMs: 1830,\n confidence: 0.97,\n }, {\n text: \" demo\",\n startMs: 1960,\n endMs: 2240,\n timestampMs: 2100,\n confidence: 0.97,\n }, {\n text: \" videos\",\n startMs: 2240,\n endMs: 2680,\n timestampMs: 2460,\n confidence: 0.97,\n }, {\n text: \" lose\",\n startMs: 2680,\n endMs: 2960,\n timestampMs: 2820,\n confidence: 0.97,\n }, {\n text: \" people\",\n startMs: 2960,\n endMs: 3320,\n timestampMs: 3140,\n confidence: 0.97,\n }, {\n text: \" in\",\n startMs: 3320,\n endMs: 3420,\n timestampMs: 3370,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 3420,\n endMs: 3520,\n timestampMs: 3470,\n confidence: 0.97,\n }, {\n text: \" first\",\n startMs: 3520,\n endMs: 3820,\n timestampMs: 3670,\n confidence: 0.97,\n }, {\n text: \" three\",\n startMs: 3820,\n endMs: 4100,\n timestampMs: 3960,\n confidence: 0.97,\n }, {\n text: \" seconds.\",\n startMs: 4100,\n endMs: 4780,\n timestampMs: 4440,\n confidence: 0.97,\n }, {\n text: \" Captions\",\n startMs: 5400,\n endMs: 5920,\n timestampMs: 5660,\n confidence: 0.97,\n }, {\n text: \" keep\",\n startMs: 5920,\n endMs: 6140,\n timestampMs: 6030,\n confidence: 0.97,\n }, {\n text: \" them\",\n startMs: 6140,\n endMs: 6300,\n timestampMs: 6220,\n confidence: 0.97,\n }, {\n text: \" watching,\",\n startMs: 6300,\n endMs: 6860,\n timestampMs: 6580,\n confidence: 0.97,\n }, {\n text: \" even\",\n startMs: 6960,\n endMs: 7180,\n timestampMs: 7070,\n confidence: 0.97,\n }, {\n text: \" with\",\n startMs: 7180,\n endMs: 7320,\n timestampMs: 7250,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 7320,\n endMs: 7420,\n timestampMs: 7370,\n confidence: 0.97,\n }, {\n text: \" sound\",\n startMs: 7420,\n endMs: 7760,\n timestampMs: 7590,\n confidence: 0.97,\n }, {\n text: \" off.\",\n startMs: 7760,\n endMs: 8300,\n timestampMs: 8030,\n confidence: 0.97,\n }],\n description: \"Transcript\",\n keyframable: false,\n },\n fontSize: {\n type: \"number\",\n min: 24,\n max: 140,\n step: 1,\n default: 64,\n description: \"Font size\",\n hiddenFromList: false,\n },\n fontWeight: {\n type: \"number\",\n min: 400,\n max: 900,\n step: 100,\n default: 800,\n description: \"Font weight\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#ffffff\",\n description: \"Text color\",\n },\n glyphColor: {\n type: \"color\",\n default: \"#a3a3a3\",\n description: \"Glyph color\",\n },\n combineTokensWithinMilliseconds: {\n type: \"number\",\n min: 0,\n max: 3000,\n step: 100,\n default: 1200,\n description: \"Page window (ms)\",\n hiddenFromList: false,\n },\n holdMs: {\n type: \"number\",\n min: 0,\n max: 2000,\n step: 50,\n default: 600,\n description: \"Hold (ms)\",\n hiddenFromList: false,\n },\n shadow: {\n type: \"boolean\",\n default: true,\n description: \"Shadow\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"captions\",\"fontSize\",\"fontWeight\",\"color\",\"glyphColor\",\"combineTokensWithinMilliseconds\",\"holdMs\",\"shadow\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n captions: [{\n text: \" So\",\n startMs: 300,\n endMs: 460,\n timestampMs: 380,\n confidence: 0.97,\n }, {\n text: \" here's\",\n startMs: 460,\n endMs: 700,\n timestampMs: 580,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 700,\n endMs: 820,\n timestampMs: 760,\n confidence: 0.97,\n }, {\n text: \" thing.\",\n startMs: 820,\n endMs: 1240,\n timestampMs: 1030,\n confidence: 0.97,\n }, {\n text: \" Most\",\n startMs: 1700,\n endMs: 1960,\n timestampMs: 1830,\n confidence: 0.97,\n }, {\n text: \" demo\",\n startMs: 1960,\n endMs: 2240,\n timestampMs: 2100,\n confidence: 0.97,\n }, {\n text: \" videos\",\n startMs: 2240,\n endMs: 2680,\n timestampMs: 2460,\n confidence: 0.97,\n }, {\n text: \" lose\",\n startMs: 2680,\n endMs: 2960,\n timestampMs: 2820,\n confidence: 0.97,\n }, {\n text: \" people\",\n startMs: 2960,\n endMs: 3320,\n timestampMs: 3140,\n confidence: 0.97,\n }, {\n text: \" in\",\n startMs: 3320,\n endMs: 3420,\n timestampMs: 3370,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 3420,\n endMs: 3520,\n timestampMs: 3470,\n confidence: 0.97,\n }, {\n text: \" first\",\n startMs: 3520,\n endMs: 3820,\n timestampMs: 3670,\n confidence: 0.97,\n }, {\n text: \" three\",\n startMs: 3820,\n endMs: 4100,\n timestampMs: 3960,\n confidence: 0.97,\n }, {\n text: \" seconds.\",\n startMs: 4100,\n endMs: 4780,\n timestampMs: 4440,\n confidence: 0.97,\n }, {\n text: \" Captions\",\n startMs: 5400,\n endMs: 5920,\n timestampMs: 5660,\n confidence: 0.97,\n }, {\n text: \" keep\",\n startMs: 5920,\n endMs: 6140,\n timestampMs: 6030,\n confidence: 0.97,\n }, {\n text: \" them\",\n startMs: 6140,\n endMs: 6300,\n timestampMs: 6220,\n confidence: 0.97,\n }, {\n text: \" watching,\",\n startMs: 6300,\n endMs: 6860,\n timestampMs: 6580,\n confidence: 0.97,\n }, {\n text: \" even\",\n startMs: 6960,\n endMs: 7180,\n timestampMs: 7070,\n confidence: 0.97,\n }, {\n text: \" with\",\n startMs: 7180,\n endMs: 7320,\n timestampMs: 7250,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 7320,\n endMs: 7420,\n timestampMs: 7370,\n confidence: 0.97,\n }, {\n text: \" sound\",\n startMs: 7420,\n endMs: 7760,\n timestampMs: 7590,\n confidence: 0.97,\n }, {\n text: \" off.\",\n startMs: 7760,\n endMs: 8300,\n timestampMs: 8030,\n confidence: 0.97,\n }],\n fontSize: 64,\n fontWeight: 800,\n color: \"#ffffff\",\n glyphColor: \"#a3a3a3\",\n combineTokensWithinMilliseconds: 1200,\n holdMs: 600,\n shadow: true,\n};\n\ntype CaptionScrambleElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof CaptionScrambleBase>;\n\nconst CaptionScrambleInner = forwardRef<\n HTMLDivElement,\n CaptionScrambleElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<CaptionScramble>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <CaptionScrambleBase\n {...(componentProps as unknown as ComponentProps<typeof CaptionScrambleBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const CaptionScramble = Interactive.withSchema({\n Component: CaptionScrambleInner,\n componentName: \"<CaptionScramble>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"+ },+ "durationInFrames": 279+}diff --git a/registry-artifacts/elements/caption-slice.json b/registry-artifacts/elements/caption-slice.jsonnew file mode 100644index 00000000..f2c4e060--- /dev/null+++ b/registry-artifacts/elements/caption-slice.json@@ -0,0 +1,21 @@+{+ "type": "remotion-element",+ "version": 1,+ "element": {+ "assets": [],+ "dependencies": [+ {+ "name": "@remotion/captions",+ "version": null+ }+ ],+ "dimensions": null,+ "displayName": "Caption Slice",+ "durationInFrames": 279,+ "initialProps": null,+ "installationMode": "component-owned-sequence",+ "slug": "caption-slice",+ "sourceCode": "import { Fragment, forwardRef, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState, type ComponentProps } from \"react\";\nimport { Easing, Interactive, Sequence, interpolate, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { createTikTokStyleCaptions, type Caption, type TikTokPage } from \"@remotion/captions\";\n\ntype SpeakerCaption = Caption & { speaker?: string };\n\ninterface CaptionBaseProps {\n captions: Caption[];\n combineTokensWithinMilliseconds?: number;\n holdMs?: number;\n fontSize?: number;\n fontWeight?: number;\n color?: string;\n className?: string;\n}\n\nconst DEFAULT_HOLD_MS = 600;\nconst MIN_SILENCE_BREAK_MS = 300;\n\ninterface CaptionPageWindow {\n page: TikTokPage;\n index: number;\n speaker: string | undefined;\n startMs: number;\n speechEndMs: number;\n endMs: number;\n endsInSilence: boolean;\n}\n\ntype CaptionTokenStatus = \"upcoming\" | \"active\" | \"spoken\";\n\ninterface CaptionTokenState {\n text: string;\n spaceBefore: boolean;\n fromMs: number;\n toMs: number;\n progress: number;\n status: CaptionTokenStatus;\n}\n\ninterface CaptionPreviousPage {\n page: TikTokPage;\n pageIndex: number;\n tokens: CaptionTokenState[];\n}\n\ninterface CaptionsState {\n page: TikTokPage;\n pageIndex: number;\n speaker: string | undefined;\n timeMs: number;\n activeIndex: number;\n tokens: CaptionTokenState[];\n sinceStartMs: number;\n untilEndMs: number;\n holdRoomMs: number;\n endsInSilence: boolean;\n previous: CaptionPreviousPage | null;\n}\n\ninterface CaptionPagingOptions {\n combineTokensWithinMilliseconds: number;\n holdMs?: number;\n}\n\nconst SENTENCE_END = /[.!?…][\"')\\]]*$/;\n\nfunction markPageBreaks(captions: SpeakerCaption[]): Caption[] {\n return captions.map((caption, i) => {\n if (caption.pageBreakAfter !== undefined) return caption;\n const next = captions[i + 1];\n const speakerChanges =\n next !== undefined && next.speaker !== caption.speaker;\n return speakerChanges || SENTENCE_END.test(caption.text.trim())\n ? { ...caption, pageBreakAfter: true }\n : caption;\n });\n}\n\nfunction buildCaptionPages(\n captions: SpeakerCaption[],\n {\n combineTokensWithinMilliseconds,\n holdMs = DEFAULT_HOLD_MS,\n }: CaptionPagingOptions,\n): CaptionPageWindow[] {\n if (captions.length === 0) return [];\n const { pages } = createTikTokStyleCaptions({\n captions: markPageBreaks(captions),\n combineTokensWithinMilliseconds,\n breakOnSilenceAfterMilliseconds: Math.max(holdMs, MIN_SILENCE_BREAK_MS),\n });\n const speakers = new Map<number, string | undefined>();\n for (const caption of captions) {\n if (!speakers.has(caption.startMs)) {\n speakers.set(caption.startMs, caption.speaker);\n }\n }\n const spoken = pages.filter((page) => page.tokens.length > 0);\n return spoken.map((page, index) => {\n const last = page.tokens[page.tokens.length - 1];\n const speechEndMs = last ? last.toMs : page.startMs;\n const heldUntil = speechEndMs + Math.max(0, holdMs);\n const next = spoken[index + 1];\n const endsInSilence = !next || next.startMs > heldUntil;\n const endMs = endsInSilence\n ? heldUntil\n : Math.max(page.startMs, next.startMs);\n return {\n page,\n index,\n speaker: speakers.get(page.tokens[0].fromMs),\n startMs: page.startMs,\n speechEndMs,\n endMs,\n endsInSilence,\n };\n });\n}\n\nfunction findWindowIndex(windows: CaptionPageWindow[], timeMs: number): number {\n let lo = 0;\n let hi = windows.length - 1;\n let found = -1;\n while (lo <= hi) {\n const mid = (lo + hi) >> 1;\n if (windows[mid].startMs <= timeMs) {\n found = mid;\n lo = mid + 1;\n } else {\n hi = mid - 1;\n }\n }\n if (found === -1) return -1;\n return timeMs < windows[found].endMs ? found : -1;\n}\n\nfunction tokenProgress(fromMs: number, toMs: number, timeMs: number): number {\n if (timeMs < fromMs) return 0;\n if (toMs <= fromMs) return 1;\n return Math.min(1, (timeMs - fromMs) / (toMs - fromMs));\n}\n\nfunction getTokenStates(\n page: TikTokPage,\n timeMs: number,\n): { activeIndex: number; tokens: CaptionTokenState[] } {\n let activeIndex = -1;\n page.tokens.forEach((token, i) => {\n if (token.fromMs <= timeMs) activeIndex = i;\n });\n const tokens = page.tokens.map(\n (token, i): CaptionTokenState => ({\n text: token.text.trim(),\n spaceBefore: i > 0 && /^\\s/.test(token.text),\n fromMs: token.fromMs,\n toMs: token.toMs,\n progress: tokenProgress(token.fromMs, token.toMs, timeMs),\n status:\n i < activeIndex ? \"spoken\" : i === activeIndex ? \"active\" : \"upcoming\",\n }),\n );\n return { activeIndex, tokens };\n}\n\nfunction getCaptionsState(\n windows: CaptionPageWindow[],\n timeMs: number,\n): CaptionsState | null {\n const found = findWindowIndex(windows, timeMs);\n if (found === -1) return null;\n const window = windows[found];\n const { activeIndex, tokens } = getTokenStates(window.page, timeMs);\n const before = found > 0 ? windows[found - 1] : null;\n const previous =\n before && !before.endsInSilence\n ? {\n page: before.page,\n pageIndex: before.index,\n tokens: getTokenStates(before.page, before.endMs).tokens,\n }\n : null;\n return {\n page: window.page,\n pageIndex: window.index,\n speaker: window.speaker,\n timeMs,\n activeIndex,\n tokens,\n sinceStartMs: timeMs - window.startMs,\n untilEndMs: window.endMs - timeMs,\n holdRoomMs: window.endMs - window.speechEndMs,\n endsInSilence: window.endsInSilence,\n previous,\n };\n}\n\nfunction getExitWindowMs(state: CaptionsState, exitMs: number): number {\n return Math.max(1, Math.min(exitMs, state.holdRoomMs));\n}\n\nfunction groupCaptionWords(\n tokens: CaptionTokenState[],\n): { index: number; token: CaptionTokenState }[][] {\n const words: { index: number; token: CaptionTokenState }[][] = [];\n tokens.forEach((token, index) => {\n const current = words[words.length - 1];\n if (!current || token.spaceBefore) {\n words.push([{ index, token }]);\n } else {\n current.push({ index, token });\n }\n });\n return words;\n}\n\nfunction normalizeCaptionWord(text: string): string {\n return text\n .toLowerCase()\n .replace(/[\\u2018\\u2019]/g, \"'\")\n .replace(/[^\\p{L}\\p{N}']/gu, \"\");\n}\n\nfunction createKeywordMatcher(\n keywords: readonly string[] = [],\n): (text: string) => boolean {\n const set = new Set(keywords.map(normalizeCaptionWord).filter(Boolean));\n return (text) => set.has(normalizeCaptionWord(text));\n}\n\nfunction captionWordText(word: { token: CaptionTokenState }[]): string {\n return word.map(({ token }) => token.text).join(\"\");\n}\n\ninterface CaptionWordRect {\n left: number;\n top: number;\n width: number;\n height: number;\n}\n\nfunction sameRects(a: CaptionWordRect[], b: CaptionWordRect[]): boolean {\n return (\n a.length === b.length &&\n a.every(\n (r, i) =>\n r.left === b[i].left &&\n r.top === b[i].top &&\n r.width === b[i].width &&\n r.height === b[i].height,\n )\n );\n}\n\nfunction useCaptionWordRects(\n pageIndex: number,\n count: number,\n): {\n wordRef: (index: number) => (el: HTMLElement | null) => void;\n rects: CaptionWordRect[] | null;\n} {\n const elements = useRef<(HTMLElement | null)[]>([]);\n const [measured, setMeasured] = useState<{\n pageIndex: number;\n rects: CaptionWordRect[];\n } | null>(null);\n\n useLayoutEffect(() => {\n if (pageIndex === -1) return;\n const rects = elements.current.slice(0, count).map((el) =>\n el\n ? {\n left: el.offsetLeft,\n top: el.offsetTop,\n width: el.offsetWidth,\n height: el.offsetHeight,\n }\n : { left: 0, top: 0, width: 0, height: 0 },\n );\n setMeasured((prev) =>\n prev && prev.pageIndex === pageIndex && sameRects(prev.rects, rects)\n ? prev\n : { pageIndex, rects },\n );\n });\n\n return {\n wordRef: (index) => (el) => {\n elements.current[index] = el;\n },\n rects: measured && measured.pageIndex === pageIndex ? measured.rects : null,\n };\n}\n\nfunction useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs = DEFAULT_HOLD_MS,\n}: {\n captions: SpeakerCaption[];\n combineTokensWithinMilliseconds: number;\n holdMs?: number;\n}): CaptionsState | null {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const windows = useMemo(\n () =>\n buildCaptionPages(captions, { combineTokensWithinMilliseconds, holdMs }),\n [captions, combineTokensWithinMilliseconds, holdMs],\n );\n return getCaptionsState(windows, (frame / fps) * 1000);\n}\n\ninterface CaptionSliceProps extends CaptionBaseProps {\n distance?: number;\n shadow?: boolean;\n}\n\nconst SLIDE_MS = 240;\nconst FADE_MS = 90;\nconst EXIT_MS = 220;\nconst LEGIBILITY_SHADOW =\n \"0 2px 3px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.35)\";\nconst TOP_HALF = \"inset(-0.5em -0.5em 50% -0.5em)\";\nconst BOTTOM_HALF = \"inset(50% -0.5em -0.5em -0.5em)\";\n\nconst slideEasing = Easing.bezier(0.16, 1, 0.3, 1);\n\nconst clamp = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n} as const;\n\nfunction CaptionSliceBase({\n captions,\n combineTokensWithinMilliseconds = 1200,\n holdMs = DEFAULT_HOLD_MS,\n fontSize = 64,\n fontWeight = 800,\n color = \"#ffffff\",\n distance = 0.6,\n shadow = true,\n className,\n}: CaptionSliceProps) {\n const state = useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs,\n });\n if (!state) return null;\n\n const exit = state.endsInSilence\n ? interpolate(\n state.untilEndMs,\n [0, getExitWindowMs(state, EXIT_MS)],\n [0, 1],\n clamp,\n )\n : 1;\n const textShadow = shadow ? LEGIBILITY_SHADOW : undefined;\n\n return (\n <div\n className={className}\n style={{\n fontSize,\n fontWeight,\n color,\n lineHeight: 1.2,\n textAlign: \"center\",\n opacity: exit,\n }}\n >\n {groupCaptionWords(state.tokens).map((word, w) => (\n <Fragment key={`${state.pageIndex}-${word[0].index}`}>\n {w > 0 && \" \"}\n <span style={{ display: \"inline-block\", whiteSpace: \"nowrap\" }}>\n {word.map(({ index, token }) => {\n const sinceMs = state.timeMs - token.fromMs;\n if (sinceMs < 0) {\n return (\n <span\n key={index}\n style={{ display: \"inline-block\", color: \"transparent\" }}\n >\n {token.text}\n </span>\n );\n }\n const slide = interpolate(sinceMs, [0, SLIDE_MS], [0, 1], {\n ...clamp,\n easing: slideEasing,\n });\n if (slide >= 1) {\n return (\n <span\n key={index}\n style={{ display: \"inline-block\", textShadow }}\n >\n {token.text}\n </span>\n );\n }\n const opacity = interpolate(sinceMs, [0, FADE_MS], [0, 1], clamp);\n const offset = (1 - slide) * distance;\n return (\n <span\n key={index}\n style={{ position: \"relative\", display: \"inline-block\" }}\n >\n <span style={{ color: \"transparent\" }}>{token.text}</span>\n <span\n aria-hidden\n style={{\n position: \"absolute\",\n inset: 0,\n whiteSpace: \"nowrap\",\n clipPath: TOP_HALF,\n opacity,\n transform: `translateX(${-offset}em)`,\n textShadow,\n }}\n >\n {token.text}\n </span>\n <span\n aria-hidden\n style={{\n position: \"absolute\",\n inset: 0,\n whiteSpace: \"nowrap\",\n clipPath: BOTTOM_HALF,\n opacity,\n transform: `translateX(${offset}em)`,\n textShadow,\n }}\n >\n {token.text}\n </span>\n </span>\n );\n })}\n </span>\n </Fragment>\n ))}\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n captions: {\n type: \"remotion-captions\",\n default: [{\n text: \" So\",\n startMs: 300,\n endMs: 460,\n timestampMs: 380,\n confidence: 0.97,\n }, {\n text: \" here's\",\n startMs: 460,\n endMs: 700,\n timestampMs: 580,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 700,\n endMs: 820,\n timestampMs: 760,\n confidence: 0.97,\n }, {\n text: \" thing.\",\n startMs: 820,\n endMs: 1240,\n timestampMs: 1030,\n confidence: 0.97,\n }, {\n text: \" Most\",\n startMs: 1700,\n endMs: 1960,\n timestampMs: 1830,\n confidence: 0.97,\n }, {\n text: \" demo\",\n startMs: 1960,\n endMs: 2240,\n timestampMs: 2100,\n confidence: 0.97,\n }, {\n text: \" videos\",\n startMs: 2240,\n endMs: 2680,\n timestampMs: 2460,\n confidence: 0.97,\n }, {\n text: \" lose\",\n startMs: 2680,\n endMs: 2960,\n timestampMs: 2820,\n confidence: 0.97,\n }, {\n text: \" people\",\n startMs: 2960,\n endMs: 3320,\n timestampMs: 3140,\n confidence: 0.97,\n }, {\n text: \" in\",\n startMs: 3320,\n endMs: 3420,\n timestampMs: 3370,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 3420,\n endMs: 3520,\n timestampMs: 3470,\n confidence: 0.97,\n }, {\n text: \" first\",\n startMs: 3520,\n endMs: 3820,\n timestampMs: 3670,\n confidence: 0.97,\n }, {\n text: \" three\",\n startMs: 3820,\n endMs: 4100,\n timestampMs: 3960,\n confidence: 0.97,\n }, {\n text: \" seconds.\",\n startMs: 4100,\n endMs: 4780,\n timestampMs: 4440,\n confidence: 0.97,\n }, {\n text: \" Captions\",\n startMs: 5400,\n endMs: 5920,\n timestampMs: 5660,\n confidence: 0.97,\n }, {\n text: \" keep\",\n startMs: 5920,\n endMs: 6140,\n timestampMs: 6030,\n confidence: 0.97,\n }, {\n text: \" them\",\n startMs: 6140,\n endMs: 6300,\n timestampMs: 6220,\n confidence: 0.97,\n }, {\n text: \" watching,\",\n startMs: 6300,\n endMs: 6860,\n timestampMs: 6580,\n confidence: 0.97,\n }, {\n text: \" even\",\n startMs: 6960,\n endMs: 7180,\n timestampMs: 7070,\n confidence: 0.97,\n }, {\n text: \" with\",\n startMs: 7180,\n endMs: 7320,\n timestampMs: 7250,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 7320,\n endMs: 7420,\n timestampMs: 7370,\n confidence: 0.97,\n }, {\n text: \" sound\",\n startMs: 7420,\n endMs: 7760,\n timestampMs: 7590,\n confidence: 0.97,\n }, {\n text: \" off.\",\n startMs: 7760,\n endMs: 8300,\n timestampMs: 8030,\n confidence: 0.97,\n }],\n description: \"Transcript\",\n keyframable: false,\n },\n fontSize: {\n type: \"number\",\n min: 24,\n max: 140,\n step: 1,\n default: 64,\n description: \"Font size\",\n hiddenFromList: false,\n },\n fontWeight: {\n type: \"number\",\n min: 400,\n max: 900,\n step: 100,\n default: 800,\n description: \"Font weight\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#ffffff\",\n description: \"Text color\",\n },\n distance: {\n type: \"number\",\n min: 0.1,\n max: 2,\n step: 0.05,\n default: 0.6,\n description: \"Slide distance (em)\",\n hiddenFromList: false,\n },\n combineTokensWithinMilliseconds: {\n type: \"number\",\n min: 0,\n max: 3000,\n step: 100,\n default: 1200,\n description: \"Page window (ms)\",\n hiddenFromList: false,\n },\n holdMs: {\n type: \"number\",\n min: 0,\n max: 2000,\n step: 50,\n default: 600,\n description: \"Hold (ms)\",\n hiddenFromList: false,\n },\n shadow: {\n type: \"boolean\",\n default: true,\n description: \"Shadow\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"captions\",\"fontSize\",\"fontWeight\",\"color\",\"distance\",\"combineTokensWithinMilliseconds\",\"holdMs\",\"shadow\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n captions: [{\n text: \" So\",\n startMs: 300,\n endMs: 460,\n timestampMs: 380,\n confidence: 0.97,\n }, {\n text: \" here's\",\n startMs: 460,\n endMs: 700,\n timestampMs: 580,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 700,\n endMs: 820,\n timestampMs: 760,\n confidence: 0.97,\n }, {\n text: \" thing.\",\n startMs: 820,\n endMs: 1240,\n timestampMs: 1030,\n confidence: 0.97,\n }, {\n text: \" Most\",\n startMs: 1700,\n endMs: 1960,\n timestampMs: 1830,\n confidence: 0.97,\n }, {\n text: \" demo\",\n startMs: 1960,\n endMs: 2240,\n timestampMs: 2100,\n confidence: 0.97,\n }, {\n text: \" videos\",\n startMs: 2240,\n endMs: 2680,\n timestampMs: 2460,\n confidence: 0.97,\n }, {\n text: \" lose\",\n startMs: 2680,\n endMs: 2960,\n timestampMs: 2820,\n confidence: 0.97,\n }, {\n text: \" people\",\n startMs: 2960,\n endMs: 3320,\n timestampMs: 3140,\n confidence: 0.97,\n }, {\n text: \" in\",\n startMs: 3320,\n endMs: 3420,\n timestampMs: 3370,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 3420,\n endMs: 3520,\n timestampMs: 3470,\n confidence: 0.97,\n }, {\n text: \" first\",\n startMs: 3520,\n endMs: 3820,\n timestampMs: 3670,\n confidence: 0.97,\n }, {\n text: \" three\",\n startMs: 3820,\n endMs: 4100,\n timestampMs: 3960,\n confidence: 0.97,\n }, {\n text: \" seconds.\",\n startMs: 4100,\n endMs: 4780,\n timestampMs: 4440,\n confidence: 0.97,\n }, {\n text: \" Captions\",\n startMs: 5400,\n endMs: 5920,\n timestampMs: 5660,\n confidence: 0.97,\n }, {\n text: \" keep\",\n startMs: 5920,\n endMs: 6140,\n timestampMs: 6030,\n confidence: 0.97,\n }, {\n text: \" them\",\n startMs: 6140,\n endMs: 6300,\n timestampMs: 6220,\n confidence: 0.97,\n }, {\n text: \" watching,\",\n startMs: 6300,\n endMs: 6860,\n timestampMs: 6580,\n confidence: 0.97,\n }, {\n text: \" even\",\n startMs: 6960,\n endMs: 7180,\n timestampMs: 7070,\n confidence: 0.97,\n }, {\n text: \" with\",\n startMs: 7180,\n endMs: 7320,\n timestampMs: 7250,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 7320,\n endMs: 7420,\n timestampMs: 7370,\n confidence: 0.97,\n }, {\n text: \" sound\",\n startMs: 7420,\n endMs: 7760,\n timestampMs: 7590,\n confidence: 0.97,\n }, {\n text: \" off.\",\n startMs: 7760,\n endMs: 8300,\n timestampMs: 8030,\n confidence: 0.97,\n }],\n fontSize: 64,\n fontWeight: 800,\n color: \"#ffffff\",\n distance: 0.6,\n combineTokensWithinMilliseconds: 1200,\n holdMs: 600,\n shadow: true,\n};\n\ntype CaptionSliceElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof CaptionSliceBase>;\n\nconst CaptionSliceInner = forwardRef<\n HTMLDivElement,\n CaptionSliceElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<CaptionSlice>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <CaptionSliceBase\n {...(componentProps as unknown as ComponentProps<typeof CaptionSliceBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const CaptionSlice = Interactive.withSchema({\n Component: CaptionSliceInner,\n componentName: \"<CaptionSlice>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"+ },+ "durationInFrames": 279+}diff --git a/registry-artifacts/elements/caption-slot.json b/registry-artifacts/elements/caption-slot.jsonnew file mode 100644index 00000000..94795b61--- /dev/null+++ b/registry-artifacts/elements/caption-slot.json@@ -0,0 +1,21 @@+{+ "type": "remotion-element",+ "version": 1,+ "element": {+ "assets": [],+ "dependencies": [+ {+ "name": "@remotion/captions",+ "version": null+ }+ ],+ "dimensions": null,+ "displayName": "Caption Slot",+ "durationInFrames": 279,+ "initialProps": null,+ "installationMode": "component-owned-sequence",+ "slug": "caption-slot",+ "sourceCode": "import { Fragment, forwardRef, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState, type CSSProperties, type ComponentProps } from \"react\";\nimport { Easing, Interactive, Sequence, interpolate, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { createTikTokStyleCaptions, type Caption, type TikTokPage } from \"@remotion/captions\";\n\ntype SpeakerCaption = Caption & { speaker?: string };\n\ninterface CaptionBaseProps {\n captions: Caption[];\n combineTokensWithinMilliseconds?: number;\n holdMs?: number;\n fontSize?: number;\n fontWeight?: number;\n color?: string;\n className?: string;\n}\n\nconst DEFAULT_HOLD_MS = 600;\nconst MIN_SILENCE_BREAK_MS = 300;\n\ninterface CaptionPageWindow {\n page: TikTokPage;\n index: number;\n speaker: string | undefined;\n startMs: number;\n speechEndMs: number;\n endMs: number;\n endsInSilence: boolean;\n}\n\ntype CaptionTokenStatus = \"upcoming\" | \"active\" | \"spoken\";\n\ninterface CaptionTokenState {\n text: string;\n spaceBefore: boolean;\n fromMs: number;\n toMs: number;\n progress: number;\n status: CaptionTokenStatus;\n}\n\ninterface CaptionPreviousPage {\n page: TikTokPage;\n pageIndex: number;\n tokens: CaptionTokenState[];\n}\n\ninterface CaptionsState {\n page: TikTokPage;\n pageIndex: number;\n speaker: string | undefined;\n timeMs: number;\n activeIndex: number;\n tokens: CaptionTokenState[];\n sinceStartMs: number;\n untilEndMs: number;\n holdRoomMs: number;\n endsInSilence: boolean;\n previous: CaptionPreviousPage | null;\n}\n\ninterface CaptionPagingOptions {\n combineTokensWithinMilliseconds: number;\n holdMs?: number;\n}\n\nconst SENTENCE_END = /[.!?…][\"')\\]]*$/;\n\nfunction markPageBreaks(captions: SpeakerCaption[]): Caption[] {\n return captions.map((caption, i) => {\n if (caption.pageBreakAfter !== undefined) return caption;\n const next = captions[i + 1];\n const speakerChanges =\n next !== undefined && next.speaker !== caption.speaker;\n return speakerChanges || SENTENCE_END.test(caption.text.trim())\n ? { ...caption, pageBreakAfter: true }\n : caption;\n });\n}\n\nfunction buildCaptionPages(\n captions: SpeakerCaption[],\n {\n combineTokensWithinMilliseconds,\n holdMs = DEFAULT_HOLD_MS,\n }: CaptionPagingOptions,\n): CaptionPageWindow[] {\n if (captions.length === 0) return [];\n const { pages } = createTikTokStyleCaptions({\n captions: markPageBreaks(captions),\n combineTokensWithinMilliseconds,\n breakOnSilenceAfterMilliseconds: Math.max(holdMs, MIN_SILENCE_BREAK_MS),\n });\n const speakers = new Map<number, string | undefined>();\n for (const caption of captions) {\n if (!speakers.has(caption.startMs)) {\n speakers.set(caption.startMs, caption.speaker);\n }\n }\n const spoken = pages.filter((page) => page.tokens.length > 0);\n return spoken.map((page, index) => {\n const last = page.tokens[page.tokens.length - 1];\n const speechEndMs = last ? last.toMs : page.startMs;\n const heldUntil = speechEndMs + Math.max(0, holdMs);\n const next = spoken[index + 1];\n const endsInSilence = !next || next.startMs > heldUntil;\n const endMs = endsInSilence\n ? heldUntil\n : Math.max(page.startMs, next.startMs);\n return {\n page,\n index,\n speaker: speakers.get(page.tokens[0].fromMs),\n startMs: page.startMs,\n speechEndMs,\n endMs,\n endsInSilence,\n };\n });\n}\n\nfunction findWindowIndex(windows: CaptionPageWindow[], timeMs: number): number {\n let lo = 0;\n let hi = windows.length - 1;\n let found = -1;\n while (lo <= hi) {\n const mid = (lo + hi) >> 1;\n if (windows[mid].startMs <= timeMs) {\n found = mid;\n lo = mid + 1;\n } else {\n hi = mid - 1;\n }\n }\n if (found === -1) return -1;\n return timeMs < windows[found].endMs ? found : -1;\n}\n\nfunction tokenProgress(fromMs: number, toMs: number, timeMs: number): number {\n if (timeMs < fromMs) return 0;\n if (toMs <= fromMs) return 1;\n return Math.min(1, (timeMs - fromMs) / (toMs - fromMs));\n}\n\nfunction getTokenStates(\n page: TikTokPage,\n timeMs: number,\n): { activeIndex: number; tokens: CaptionTokenState[] } {\n let activeIndex = -1;\n page.tokens.forEach((token, i) => {\n if (token.fromMs <= timeMs) activeIndex = i;\n });\n const tokens = page.tokens.map(\n (token, i): CaptionTokenState => ({\n text: token.text.trim(),\n spaceBefore: i > 0 && /^\\s/.test(token.text),\n fromMs: token.fromMs,\n toMs: token.toMs,\n progress: tokenProgress(token.fromMs, token.toMs, timeMs),\n status:\n i < activeIndex ? \"spoken\" : i === activeIndex ? \"active\" : \"upcoming\",\n }),\n );\n return { activeIndex, tokens };\n}\n\nfunction getCaptionsState(\n windows: CaptionPageWindow[],\n timeMs: number,\n): CaptionsState | null {\n const found = findWindowIndex(windows, timeMs);\n if (found === -1) return null;\n const window = windows[found];\n const { activeIndex, tokens } = getTokenStates(window.page, timeMs);\n const before = found > 0 ? windows[found - 1] : null;\n const previous =\n before && !before.endsInSilence\n ? {\n page: before.page,\n pageIndex: before.index,\n tokens: getTokenStates(before.page, before.endMs).tokens,\n }\n : null;\n return {\n page: window.page,\n pageIndex: window.index,\n speaker: window.speaker,\n timeMs,\n activeIndex,\n tokens,\n sinceStartMs: timeMs - window.startMs,\n untilEndMs: window.endMs - timeMs,\n holdRoomMs: window.endMs - window.speechEndMs,\n endsInSilence: window.endsInSilence,\n previous,\n };\n}\n\nfunction getExitWindowMs(state: CaptionsState, exitMs: number): number {\n return Math.max(1, Math.min(exitMs, state.holdRoomMs));\n}\n\nfunction groupCaptionWords(\n tokens: CaptionTokenState[],\n): { index: number; token: CaptionTokenState }[][] {\n const words: { index: number; token: CaptionTokenState }[][] = [];\n tokens.forEach((token, index) => {\n const current = words[words.length - 1];\n if (!current || token.spaceBefore) {\n words.push([{ index, token }]);\n } else {\n current.push({ index, token });\n }\n });\n return words;\n}\n\nfunction normalizeCaptionWord(text: string): string {\n return text\n .toLowerCase()\n .replace(/[\\u2018\\u2019]/g, \"'\")\n .replace(/[^\\p{L}\\p{N}']/gu, \"\");\n}\n\nfunction createKeywordMatcher(\n keywords: readonly string[] = [],\n): (text: string) => boolean {\n const set = new Set(keywords.map(normalizeCaptionWord).filter(Boolean));\n return (text) => set.has(normalizeCaptionWord(text));\n}\n\nfunction captionWordText(word: { token: CaptionTokenState }[]): string {\n return word.map(({ token }) => token.text).join(\"\");\n}\n\ninterface CaptionWordRect {\n left: number;\n top: number;\n width: number;\n height: number;\n}\n\nfunction sameRects(a: CaptionWordRect[], b: CaptionWordRect[]): boolean {\n return (\n a.length === b.length &&\n a.every(\n (r, i) =>\n r.left === b[i].left &&\n r.top === b[i].top &&\n r.width === b[i].width &&\n r.height === b[i].height,\n )\n );\n}\n\nfunction useCaptionWordRects(\n pageIndex: number,\n count: number,\n): {\n wordRef: (index: number) => (el: HTMLElement | null) => void;\n rects: CaptionWordRect[] | null;\n} {\n const elements = useRef<(HTMLElement | null)[]>([]);\n const [measured, setMeasured] = useState<{\n pageIndex: number;\n rects: CaptionWordRect[];\n } | null>(null);\n\n useLayoutEffect(() => {\n if (pageIndex === -1) return;\n const rects = elements.current.slice(0, count).map((el) =>\n el\n ? {\n left: el.offsetLeft,\n top: el.offsetTop,\n width: el.offsetWidth,\n height: el.offsetHeight,\n }\n : { left: 0, top: 0, width: 0, height: 0 },\n );\n setMeasured((prev) =>\n prev && prev.pageIndex === pageIndex && sameRects(prev.rects, rects)\n ? prev\n : { pageIndex, rects },\n );\n });\n\n return {\n wordRef: (index) => (el) => {\n elements.current[index] = el;\n },\n rects: measured && measured.pageIndex === pageIndex ? measured.rects : null,\n };\n}\n\nfunction useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs = DEFAULT_HOLD_MS,\n}: {\n captions: SpeakerCaption[];\n combineTokensWithinMilliseconds: number;\n holdMs?: number;\n}): CaptionsState | null {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const windows = useMemo(\n () =>\n buildCaptionPages(captions, { combineTokensWithinMilliseconds, holdMs }),\n [captions, combineTokensWithinMilliseconds, holdMs],\n );\n return getCaptionsState(windows, (frame / fps) * 1000);\n}\n\ninterface CaptionSlotProps extends CaptionBaseProps {\n activeColor?: string;\n shadow?: boolean;\n}\n\nconst LINE_HEIGHT = 1.3;\nconst CLIP_MARGIN_EM = 0.2;\nconst TRAVEL_EM = LINE_HEIGHT + CLIP_MARGIN_EM * 2;\nconst ROLL_MS = 260;\nconst EXIT_MS = 220;\nconst LEGIBILITY_SHADOW =\n \"0 2px 3px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.35)\";\n\nconst rollIn = Easing.bezier(0.16, 1, 0.3, 1);\nconst rollOut = Easing.bezier(0.7, 0, 0.84, 0);\n\nfunction SlotLine({\n tokens,\n activeIndex,\n activeColor,\n style,\n}: {\n tokens: CaptionTokenState[];\n activeIndex: number;\n activeColor?: string;\n style: CSSProperties;\n}) {\n return (\n <div style={{ whiteSpace: \"nowrap\", ...style }}>\n {groupCaptionWords(tokens).map((word, w) => (\n <Fragment key={word[0].index}>\n {w > 0 && \" \"}\n {word.map(({ index, token }) => (\n <span\n key={index}\n style={{\n color:\n activeColor !== undefined && index === activeIndex\n ? activeColor\n : undefined,\n }}\n >\n {token.text}\n </span>\n ))}\n </Fragment>\n ))}\n </div>\n );\n}\n\nfunction CaptionSlotBase({\n captions,\n combineTokensWithinMilliseconds = 800,\n holdMs = DEFAULT_HOLD_MS,\n fontSize = 64,\n fontWeight = 800,\n color = \"#ffffff\",\n activeColor,\n shadow = true,\n className,\n}: CaptionSlotProps) {\n const state = useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs,\n });\n if (!state) return null;\n\n const roll = interpolate(state.sinceStartMs, [0, ROLL_MS], [0, 1], {\n easing: rollIn,\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n });\n const exitProgress = Math.min(\n 1,\n Math.max(0, 1 - state.untilEndMs / getExitWindowMs(state, EXIT_MS)),\n );\n const exit = state.endsInSilence ? rollOut(exitProgress) : 0;\n\n return (\n <div\n className={className}\n style={{\n position: \"relative\",\n fontSize,\n fontWeight,\n color,\n lineHeight: LINE_HEIGHT,\n height: `${LINE_HEIGHT}em`,\n textAlign: \"center\",\n textShadow: shadow ? LEGIBILITY_SHADOW : undefined,\n clipPath: `inset(-${CLIP_MARGIN_EM}em -100000px)`,\n }}\n >\n {state.previous && roll < 1 ? (\n <SlotLine\n key={`page-${state.previous.pageIndex}`}\n tokens={state.previous.tokens}\n activeIndex={-1}\n style={{\n position: \"absolute\",\n top: 0,\n left: \"50%\",\n transform: `translate(-50%, ${-roll * TRAVEL_EM}em)`,\n }}\n />\n ) : null}\n <SlotLine\n key={`page-${state.pageIndex}`}\n tokens={state.tokens}\n activeIndex={state.activeIndex}\n activeColor={activeColor}\n style={{\n transform: `translateY(${(1 - roll - exit) * TRAVEL_EM}em)`,\n }}\n />\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n captions: {\n type: \"remotion-captions\",\n default: [{\n text: \" So\",\n startMs: 300,\n endMs: 460,\n timestampMs: 380,\n confidence: 0.97,\n }, {\n text: \" here's\",\n startMs: 460,\n endMs: 700,\n timestampMs: 580,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 700,\n endMs: 820,\n timestampMs: 760,\n confidence: 0.97,\n }, {\n text: \" thing.\",\n startMs: 820,\n endMs: 1240,\n timestampMs: 1030,\n confidence: 0.97,\n }, {\n text: \" Most\",\n startMs: 1700,\n endMs: 1960,\n timestampMs: 1830,\n confidence: 0.97,\n }, {\n text: \" demo\",\n startMs: 1960,\n endMs: 2240,\n timestampMs: 2100,\n confidence: 0.97,\n }, {\n text: \" videos\",\n startMs: 2240,\n endMs: 2680,\n timestampMs: 2460,\n confidence: 0.97,\n }, {\n text: \" lose\",\n startMs: 2680,\n endMs: 2960,\n timestampMs: 2820,\n confidence: 0.97,\n }, {\n text: \" people\",\n startMs: 2960,\n endMs: 3320,\n timestampMs: 3140,\n confidence: 0.97,\n }, {\n text: \" in\",\n startMs: 3320,\n endMs: 3420,\n timestampMs: 3370,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 3420,\n endMs: 3520,\n timestampMs: 3470,\n confidence: 0.97,\n }, {\n text: \" first\",\n startMs: 3520,\n endMs: 3820,\n timestampMs: 3670,\n confidence: 0.97,\n }, {\n text: \" three\",\n startMs: 3820,\n endMs: 4100,\n timestampMs: 3960,\n confidence: 0.97,\n }, {\n text: \" seconds.\",\n startMs: 4100,\n endMs: 4780,\n timestampMs: 4440,\n confidence: 0.97,\n }, {\n text: \" Captions\",\n startMs: 5400,\n endMs: 5920,\n timestampMs: 5660,\n confidence: 0.97,\n }, {\n text: \" keep\",\n startMs: 5920,\n endMs: 6140,\n timestampMs: 6030,\n confidence: 0.97,\n }, {\n text: \" them\",\n startMs: 6140,\n endMs: 6300,\n timestampMs: 6220,\n confidence: 0.97,\n }, {\n text: \" watching,\",\n startMs: 6300,\n endMs: 6860,\n timestampMs: 6580,\n confidence: 0.97,\n }, {\n text: \" even\",\n startMs: 6960,\n endMs: 7180,\n timestampMs: 7070,\n confidence: 0.97,\n }, {\n text: \" with\",\n startMs: 7180,\n endMs: 7320,\n timestampMs: 7250,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 7320,\n endMs: 7420,\n timestampMs: 7370,\n confidence: 0.97,\n }, {\n text: \" sound\",\n startMs: 7420,\n endMs: 7760,\n timestampMs: 7590,\n confidence: 0.97,\n }, {\n text: \" off.\",\n startMs: 7760,\n endMs: 8300,\n timestampMs: 8030,\n confidence: 0.97,\n }],\n description: \"Transcript\",\n keyframable: false,\n },\n fontSize: {\n type: \"number\",\n min: 24,\n max: 140,\n step: 1,\n default: 64,\n description: \"Font size\",\n hiddenFromList: false,\n },\n fontWeight: {\n type: \"number\",\n min: 400,\n max: 900,\n step: 100,\n default: 800,\n description: \"Font weight\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#ffffff\",\n description: \"Text color\",\n },\n combineTokensWithinMilliseconds: {\n type: \"number\",\n min: 0,\n max: 2000,\n step: 100,\n default: 800,\n description: \"Page window (ms)\",\n hiddenFromList: false,\n },\n holdMs: {\n type: \"number\",\n min: 0,\n max: 2000,\n step: 50,\n default: 600,\n description: \"Hold (ms)\",\n hiddenFromList: false,\n },\n shadow: {\n type: \"boolean\",\n default: true,\n description: \"Shadow\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"captions\",\"fontSize\",\"fontWeight\",\"color\",\"combineTokensWithinMilliseconds\",\"holdMs\",\"shadow\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n captions: [{\n text: \" So\",\n startMs: 300,\n endMs: 460,\n timestampMs: 380,\n confidence: 0.97,\n }, {\n text: \" here's\",\n startMs: 460,\n endMs: 700,\n timestampMs: 580,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 700,\n endMs: 820,\n timestampMs: 760,\n confidence: 0.97,\n }, {\n text: \" thing.\",\n startMs: 820,\n endMs: 1240,\n timestampMs: 1030,\n confidence: 0.97,\n }, {\n text: \" Most\",\n startMs: 1700,\n endMs: 1960,\n timestampMs: 1830,\n confidence: 0.97,\n }, {\n text: \" demo\",\n startMs: 1960,\n endMs: 2240,\n timestampMs: 2100,\n confidence: 0.97,\n }, {\n text: \" videos\",\n startMs: 2240,\n endMs: 2680,\n timestampMs: 2460,\n confidence: 0.97,\n }, {\n text: \" lose\",\n startMs: 2680,\n endMs: 2960,\n timestampMs: 2820,\n confidence: 0.97,\n }, {\n text: \" people\",\n startMs: 2960,\n endMs: 3320,\n timestampMs: 3140,\n confidence: 0.97,\n }, {\n text: \" in\",\n startMs: 3320,\n endMs: 3420,\n timestampMs: 3370,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 3420,\n endMs: 3520,\n timestampMs: 3470,\n confidence: 0.97,\n }, {\n text: \" first\",\n startMs: 3520,\n endMs: 3820,\n timestampMs: 3670,\n confidence: 0.97,\n }, {\n text: \" three\",\n startMs: 3820,\n endMs: 4100,\n timestampMs: 3960,\n confidence: 0.97,\n }, {\n text: \" seconds.\",\n startMs: 4100,\n endMs: 4780,\n timestampMs: 4440,\n confidence: 0.97,\n }, {\n text: \" Captions\",\n startMs: 5400,\n endMs: 5920,\n timestampMs: 5660,\n confidence: 0.97,\n }, {\n text: \" keep\",\n startMs: 5920,\n endMs: 6140,\n timestampMs: 6030,\n confidence: 0.97,\n }, {\n text: \" them\",\n startMs: 6140,\n endMs: 6300,\n timestampMs: 6220,\n confidence: 0.97,\n }, {\n text: \" watching,\",\n startMs: 6300,\n endMs: 6860,\n timestampMs: 6580,\n confidence: 0.97,\n }, {\n text: \" even\",\n startMs: 6960,\n endMs: 7180,\n timestampMs: 7070,\n confidence: 0.97,\n }, {\n text: \" with\",\n startMs: 7180,\n endMs: 7320,\n timestampMs: 7250,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 7320,\n endMs: 7420,\n timestampMs: 7370,\n confidence: 0.97,\n }, {\n text: \" sound\",\n startMs: 7420,\n endMs: 7760,\n timestampMs: 7590,\n confidence: 0.97,\n }, {\n text: \" off.\",\n startMs: 7760,\n endMs: 8300,\n timestampMs: 8030,\n confidence: 0.97,\n }],\n fontSize: 64,\n fontWeight: 800,\n color: \"#ffffff\",\n combineTokensWithinMilliseconds: 800,\n holdMs: 600,\n shadow: true,\n};\n\ntype CaptionSlotElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof CaptionSlotBase>;\n\nconst CaptionSlotInner = forwardRef<\n HTMLDivElement,\n CaptionSlotElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<CaptionSlot>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <CaptionSlotBase\n {...(componentProps as unknown as ComponentProps<typeof CaptionSlotBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const CaptionSlot = Interactive.withSchema({\n Component: CaptionSlotInner,\n componentName: \"<CaptionSlot>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"+ },+ "durationInFrames": 279+}diff --git a/registry-artifacts/elements/caption-speaker.json b/registry-artifacts/elements/caption-speaker.jsonnew file mode 100644index 00000000..794f2b1d--- /dev/null+++ b/registry-artifacts/elements/caption-speaker.json@@ -0,0 +1,21 @@+{+ "type": "remotion-element",+ "version": 1,+ "element": {+ "assets": [],+ "dependencies": [+ {+ "name": "@remotion/captions",+ "version": null+ }+ ],+ "dimensions": null,+ "displayName": "Caption Speaker",+ "durationInFrames": 282,+ "initialProps": null,+ "installationMode": "component-owned-sequence",+ "slug": "caption-speaker",+ "sourceCode": "import { Fragment, forwardRef, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState, type ComponentProps } from \"react\";\nimport { Easing, Interactive, Sequence, interpolate, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { createTikTokStyleCaptions, type Caption, type TikTokPage } from \"@remotion/captions\";\n\ntype SpeakerCaption = Caption & { speaker?: string };\n\ninterface CaptionBaseProps {\n captions: Caption[];\n combineTokensWithinMilliseconds?: number;\n holdMs?: number;\n fontSize?: number;\n fontWeight?: number;\n color?: string;\n className?: string;\n}\n\nconst DEFAULT_HOLD_MS = 600;\nconst MIN_SILENCE_BREAK_MS = 300;\n\ninterface CaptionPageWindow {\n page: TikTokPage;\n index: number;\n speaker: string | undefined;\n startMs: number;\n speechEndMs: number;\n endMs: number;\n endsInSilence: boolean;\n}\n\ntype CaptionTokenStatus = \"upcoming\" | \"active\" | \"spoken\";\n\ninterface CaptionTokenState {\n text: string;\n spaceBefore: boolean;\n fromMs: number;\n toMs: number;\n progress: number;\n status: CaptionTokenStatus;\n}\n\ninterface CaptionPreviousPage {\n page: TikTokPage;\n pageIndex: number;\n tokens: CaptionTokenState[];\n}\n\ninterface CaptionsState {\n page: TikTokPage;\n pageIndex: number;\n speaker: string | undefined;\n timeMs: number;\n activeIndex: number;\n tokens: CaptionTokenState[];\n sinceStartMs: number;\n untilEndMs: number;\n holdRoomMs: number;\n endsInSilence: boolean;\n previous: CaptionPreviousPage | null;\n}\n\ninterface CaptionPagingOptions {\n combineTokensWithinMilliseconds: number;\n holdMs?: number;\n}\n\nconst SENTENCE_END = /[.!?…][\"')\\]]*$/;\n\nfunction markPageBreaks(captions: SpeakerCaption[]): Caption[] {\n return captions.map((caption, i) => {\n if (caption.pageBreakAfter !== undefined) return caption;\n const next = captions[i + 1];\n const speakerChanges =\n next !== undefined && next.speaker !== caption.speaker;\n return speakerChanges || SENTENCE_END.test(caption.text.trim())\n ? { ...caption, pageBreakAfter: true }\n : caption;\n });\n}\n\nfunction buildCaptionPages(\n captions: SpeakerCaption[],\n {\n combineTokensWithinMilliseconds,\n holdMs = DEFAULT_HOLD_MS,\n }: CaptionPagingOptions,\n): CaptionPageWindow[] {\n if (captions.length === 0) return [];\n const { pages } = createTikTokStyleCaptions({\n captions: markPageBreaks(captions),\n combineTokensWithinMilliseconds,\n breakOnSilenceAfterMilliseconds: Math.max(holdMs, MIN_SILENCE_BREAK_MS),\n });\n const speakers = new Map<number, string | undefined>();\n for (const caption of captions) {\n if (!speakers.has(caption.startMs)) {\n speakers.set(caption.startMs, caption.speaker);\n }\n }\n const spoken = pages.filter((page) => page.tokens.length > 0);\n return spoken.map((page, index) => {\n const last = page.tokens[page.tokens.length - 1];\n const speechEndMs = last ? last.toMs : page.startMs;\n const heldUntil = speechEndMs + Math.max(0, holdMs);\n const next = spoken[index + 1];\n const endsInSilence = !next || next.startMs > heldUntil;\n const endMs = endsInSilence\n ? heldUntil\n : Math.max(page.startMs, next.startMs);\n return {\n page,\n index,\n speaker: speakers.get(page.tokens[0].fromMs),\n startMs: page.startMs,\n speechEndMs,\n endMs,\n endsInSilence,\n };\n });\n}\n\nfunction findWindowIndex(windows: CaptionPageWindow[], timeMs: number): number {\n let lo = 0;\n let hi = windows.length - 1;\n let found = -1;\n while (lo <= hi) {\n const mid = (lo + hi) >> 1;\n if (windows[mid].startMs <= timeMs) {\n found = mid;\n lo = mid + 1;\n } else {\n hi = mid - 1;\n }\n }\n if (found === -1) return -1;\n return timeMs < windows[found].endMs ? found : -1;\n}\n\nfunction tokenProgress(fromMs: number, toMs: number, timeMs: number): number {\n if (timeMs < fromMs) return 0;\n if (toMs <= fromMs) return 1;\n return Math.min(1, (timeMs - fromMs) / (toMs - fromMs));\n}\n\nfunction getTokenStates(\n page: TikTokPage,\n timeMs: number,\n): { activeIndex: number; tokens: CaptionTokenState[] } {\n let activeIndex = -1;\n page.tokens.forEach((token, i) => {\n if (token.fromMs <= timeMs) activeIndex = i;\n });\n const tokens = page.tokens.map(\n (token, i): CaptionTokenState => ({\n text: token.text.trim(),\n spaceBefore: i > 0 && /^\\s/.test(token.text),\n fromMs: token.fromMs,\n toMs: token.toMs,\n progress: tokenProgress(token.fromMs, token.toMs, timeMs),\n status:\n i < activeIndex ? \"spoken\" : i === activeIndex ? \"active\" : \"upcoming\",\n }),\n );\n return { activeIndex, tokens };\n}\n\nfunction getCaptionsState(\n windows: CaptionPageWindow[],\n timeMs: number,\n): CaptionsState | null {\n const found = findWindowIndex(windows, timeMs);\n if (found === -1) return null;\n const window = windows[found];\n const { activeIndex, tokens } = getTokenStates(window.page, timeMs);\n const before = found > 0 ? windows[found - 1] : null;\n const previous =\n before && !before.endsInSilence\n ? {\n page: before.page,\n pageIndex: before.index,\n tokens: getTokenStates(before.page, before.endMs).tokens,\n }\n : null;\n return {\n page: window.page,\n pageIndex: window.index,\n speaker: window.speaker,\n timeMs,\n activeIndex,\n tokens,\n sinceStartMs: timeMs - window.startMs,\n untilEndMs: window.endMs - timeMs,\n holdRoomMs: window.endMs - window.speechEndMs,\n endsInSilence: window.endsInSilence,\n previous,\n };\n}\n\nfunction getExitWindowMs(state: CaptionsState, exitMs: number): number {\n return Math.max(1, Math.min(exitMs, state.holdRoomMs));\n}\n\nfunction groupCaptionWords(\n tokens: CaptionTokenState[],\n): { index: number; token: CaptionTokenState }[][] {\n const words: { index: number; token: CaptionTokenState }[][] = [];\n tokens.forEach((token, index) => {\n const current = words[words.length - 1];\n if (!current || token.spaceBefore) {\n words.push([{ index, token }]);\n } else {\n current.push({ index, token });\n }\n });\n return words;\n}\n\nfunction normalizeCaptionWord(text: string): string {\n return text\n .toLowerCase()\n .replace(/[\\u2018\\u2019]/g, \"'\")\n .replace(/[^\\p{L}\\p{N}']/gu, \"\");\n}\n\nfunction createKeywordMatcher(\n keywords: readonly string[] = [],\n): (text: string) => boolean {\n const set = new Set(keywords.map(normalizeCaptionWord).filter(Boolean));\n return (text) => set.has(normalizeCaptionWord(text));\n}\n\nfunction captionWordText(word: { token: CaptionTokenState }[]): string {\n return word.map(({ token }) => token.text).join(\"\");\n}\n\ninterface CaptionWordRect {\n left: number;\n top: number;\n width: number;\n height: number;\n}\n\nfunction sameRects(a: CaptionWordRect[], b: CaptionWordRect[]): boolean {\n return (\n a.length === b.length &&\n a.every(\n (r, i) =>\n r.left === b[i].left &&\n r.top === b[i].top &&\n r.width === b[i].width &&\n r.height === b[i].height,\n )\n );\n}\n\nfunction useCaptionWordRects(\n pageIndex: number,\n count: number,\n): {\n wordRef: (index: number) => (el: HTMLElement | null) => void;\n rects: CaptionWordRect[] | null;\n} {\n const elements = useRef<(HTMLElement | null)[]>([]);\n const [measured, setMeasured] = useState<{\n pageIndex: number;\n rects: CaptionWordRect[];\n } | null>(null);\n\n useLayoutEffect(() => {\n if (pageIndex === -1) return;\n const rects = elements.current.slice(0, count).map((el) =>\n el\n ? {\n left: el.offsetLeft,\n top: el.offsetTop,\n width: el.offsetWidth,\n height: el.offsetHeight,\n }\n : { left: 0, top: 0, width: 0, height: 0 },\n );\n setMeasured((prev) =>\n prev && prev.pageIndex === pageIndex && sameRects(prev.rects, rects)\n ? prev\n : { pageIndex, rects },\n );\n });\n\n return {\n wordRef: (index) => (el) => {\n elements.current[index] = el;\n },\n rects: measured && measured.pageIndex === pageIndex ? measured.rects : null,\n };\n}\n\nfunction useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs = DEFAULT_HOLD_MS,\n}: {\n captions: SpeakerCaption[];\n combineTokensWithinMilliseconds: number;\n holdMs?: number;\n}): CaptionsState | null {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const windows = useMemo(\n () =>\n buildCaptionPages(captions, { combineTokensWithinMilliseconds, holdMs }),\n [captions, combineTokensWithinMilliseconds, holdMs],\n );\n return getCaptionsState(windows, (frame / fps) * 1000);\n}\n\ninterface CaptionSpeakerProps extends CaptionBaseProps {\n captions: SpeakerCaption[];\n speakerColors?: Record<string, string>;\n upcomingOpacity?: number;\n shadow?: boolean;\n}\n\nconst SPEAKER_PALETTE = [\"#facc15\", \"#38bdf8\", \"#f472b6\", \"#4ade80\"];\n\nconst ENTER_MS = 160;\nconst EXIT_MS = 220;\nconst RISE_EM = 0.14;\nconst REVEAL_MS = 100;\nconst LEGIBILITY_SHADOW =\n \"0 2px 3px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.35)\";\n\nconst enterEasing = Easing.bezier(0.2, 0.8, 0.2, 1);\n\nconst clamp = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n} as const;\n\nfunction CaptionSpeakerBase({\n captions,\n combineTokensWithinMilliseconds = 1200,\n holdMs = DEFAULT_HOLD_MS,\n fontSize = 64,\n fontWeight = 800,\n color = \"#ffffff\",\n speakerColors,\n upcomingOpacity = 0.4,\n shadow = true,\n className,\n}: CaptionSpeakerProps) {\n const state = useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs,\n });\n const autoColors = useMemo(() => {\n const pinned = new Set(Object.values(speakerColors ?? {}));\n const free = SPEAKER_PALETTE.filter((c) => !pinned.has(c));\n const palette = free.length > 0 ? free : SPEAKER_PALETTE;\n const assigned = new Map<string, string>();\n for (const caption of captions) {\n const { speaker } = caption;\n if (\n speaker === undefined ||\n speakerColors?.[speaker] !== undefined ||\n assigned.has(speaker)\n ) {\n continue;\n }\n assigned.set(speaker, palette[assigned.size % palette.length]);\n }\n return assigned;\n }, [captions, speakerColors]);\n if (!state) return null;\n\n const enter = interpolate(\n state.previous ? ENTER_MS : state.sinceStartMs,\n [0, ENTER_MS],\n [0, 1],\n {\n ...clamp,\n easing: enterEasing,\n },\n );\n const exit = state.endsInSilence\n ? interpolate(\n state.untilEndMs,\n [0, getExitWindowMs(state, EXIT_MS)],\n [0, 1],\n clamp,\n )\n : 1;\n\n const { speaker } = state;\n const speakerColor =\n speaker === undefined\n ? color\n : (speakerColors?.[speaker] ?? autoColors.get(speaker) ?? color);\n\n return (\n <div\n className={className}\n style={{\n fontSize,\n fontWeight,\n color: speakerColor,\n lineHeight: 1.2,\n textAlign: \"center\",\n opacity: Math.min(enter, exit),\n transform: `translateY(${(1 - enter) * RISE_EM}em)`,\n }}\n >\n {groupCaptionWords(state.tokens).map((word, w) => (\n <Fragment key={`${state.pageIndex}-${word[0].index}`}>\n {w > 0 && \" \"}\n <span\n style={{\n display: \"inline-block\",\n whiteSpace: \"nowrap\",\n textShadow: shadow ? LEGIBILITY_SHADOW : undefined,\n }}\n >\n {word.map(({ index, token }) => (\n <span\n key={index}\n style={{\n opacity: interpolate(\n state.timeMs - token.fromMs,\n [0, REVEAL_MS],\n [upcomingOpacity, 1],\n clamp,\n ),\n }}\n >\n {token.text}\n </span>\n ))}\n </span>\n </Fragment>\n ))}\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n captions: {\n type: \"remotion-captions\",\n default: [{\n text: \" So\",\n startMs: 300,\n endMs: 460,\n timestampMs: 380,\n confidence: 0.96,\n speaker: \"host\",\n }, {\n text: \" what\",\n startMs: 460,\n endMs: 640,\n timestampMs: 550,\n confidence: 0.96,\n speaker: \"host\",\n }, {\n text: \" made\",\n startMs: 640,\n endMs: 860,\n timestampMs: 750,\n confidence: 0.96,\n speaker: \"host\",\n }, {\n text: \" you\",\n startMs: 860,\n endMs: 980,\n timestampMs: 920,\n confidence: 0.96,\n speaker: \"host\",\n }, {\n text: \" add\",\n startMs: 980,\n endMs: 1180,\n timestampMs: 1080,\n confidence: 0.96,\n speaker: \"host\",\n }, {\n text: \" captions?\",\n startMs: 1180,\n endMs: 1800,\n timestampMs: 1490,\n confidence: 0.96,\n speaker: \"host\",\n }, {\n text: \" Most\",\n startMs: 2300,\n endMs: 2560,\n timestampMs: 2430,\n confidence: 0.96,\n speaker: \"guest\",\n }, {\n text: \" people\",\n startMs: 2560,\n endMs: 2900,\n timestampMs: 2730,\n confidence: 0.96,\n speaker: \"guest\",\n }, {\n text: \" watch\",\n startMs: 2900,\n endMs: 3160,\n timestampMs: 3030,\n confidence: 0.96,\n speaker: \"guest\",\n }, {\n text: \" with\",\n startMs: 3160,\n endMs: 3280,\n timestampMs: 3220,\n confidence: 0.96,\n speaker: \"guest\",\n }, {\n text: \" the\",\n startMs: 3280,\n endMs: 3380,\n timestampMs: 3330,\n confidence: 0.96,\n speaker: \"guest\",\n }, {\n text: \" sound\",\n startMs: 3380,\n endMs: 3720,\n timestampMs: 3550,\n confidence: 0.96,\n speaker: \"guest\",\n }, {\n text: \" off.\",\n startMs: 3720,\n endMs: 4240,\n timestampMs: 3980,\n confidence: 0.96,\n speaker: \"guest\",\n }, {\n text: \" Really?\",\n startMs: 4800,\n endMs: 5400,\n timestampMs: 5100,\n confidence: 0.96,\n speaker: \"host\",\n }, {\n text: \" Almost\",\n startMs: 5800,\n endMs: 6140,\n timestampMs: 5970,\n confidence: 0.96,\n speaker: \"guest\",\n }, {\n text: \" everyone.\",\n startMs: 6140,\n endMs: 6760,\n timestampMs: 6450,\n confidence: 0.96,\n speaker: \"guest\",\n }, {\n text: \" Captions\",\n startMs: 7000,\n endMs: 7480,\n timestampMs: 7240,\n confidence: 0.96,\n speaker: \"guest\",\n }, {\n text: \" keep\",\n startMs: 7480,\n endMs: 7700,\n timestampMs: 7590,\n confidence: 0.96,\n speaker: \"guest\",\n }, {\n text: \" them\",\n startMs: 7700,\n endMs: 7860,\n timestampMs: 7780,\n confidence: 0.96,\n speaker: \"guest\",\n }, {\n text: \" watching.\",\n startMs: 7860,\n endMs: 8400,\n timestampMs: 8130,\n confidence: 0.96,\n speaker: \"guest\",\n }],\n description: \"Transcript\",\n keyframable: false,\n },\n fontSize: {\n type: \"number\",\n min: 24,\n max: 140,\n step: 1,\n default: 64,\n description: \"Font size\",\n hiddenFromList: false,\n },\n fontWeight: {\n type: \"number\",\n min: 400,\n max: 900,\n step: 100,\n default: 800,\n description: \"Font weight\",\n hiddenFromList: false,\n },\n upcomingOpacity: {\n type: \"number\",\n min: 0,\n max: 1,\n step: 0.05,\n default: 0.4,\n description: \"Upcoming opacity\",\n hiddenFromList: false,\n },\n combineTokensWithinMilliseconds: {\n type: \"number\",\n min: 0,\n max: 3000,\n step: 100,\n default: 1200,\n description: \"Page window (ms)\",\n hiddenFromList: false,\n },\n holdMs: {\n type: \"number\",\n min: 0,\n max: 2000,\n step: 50,\n default: 600,\n description: \"Hold (ms)\",\n hiddenFromList: false,\n },\n shadow: {\n type: \"boolean\",\n default: true,\n description: \"Shadow\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"captions\",\"fontSize\",\"fontWeight\",\"upcomingOpacity\",\"combineTokensWithinMilliseconds\",\"holdMs\",\"shadow\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n captions: [{\n text: \" So\",\n startMs: 300,\n endMs: 460,\n timestampMs: 380,\n confidence: 0.96,\n speaker: \"host\",\n }, {\n text: \" what\",\n startMs: 460,\n endMs: 640,\n timestampMs: 550,\n confidence: 0.96,\n speaker: \"host\",\n }, {\n text: \" made\",\n startMs: 640,\n endMs: 860,\n timestampMs: 750,\n confidence: 0.96,\n speaker: \"host\",\n }, {\n text: \" you\",\n startMs: 860,\n endMs: 980,\n timestampMs: 920,\n confidence: 0.96,\n speaker: \"host\",\n }, {\n text: \" add\",\n startMs: 980,\n endMs: 1180,\n timestampMs: 1080,\n confidence: 0.96,\n speaker: \"host\",\n }, {\n text: \" captions?\",\n startMs: 1180,\n endMs: 1800,\n timestampMs: 1490,\n confidence: 0.96,\n speaker: \"host\",\n }, {\n text: \" Most\",\n startMs: 2300,\n endMs: 2560,\n timestampMs: 2430,\n confidence: 0.96,\n speaker: \"guest\",\n }, {\n text: \" people\",\n startMs: 2560,\n endMs: 2900,\n timestampMs: 2730,\n confidence: 0.96,\n speaker: \"guest\",\n }, {\n text: \" watch\",\n startMs: 2900,\n endMs: 3160,\n timestampMs: 3030,\n confidence: 0.96,\n speaker: \"guest\",\n }, {\n text: \" with\",\n startMs: 3160,\n endMs: 3280,\n timestampMs: 3220,\n confidence: 0.96,\n speaker: \"guest\",\n }, {\n text: \" the\",\n startMs: 3280,\n endMs: 3380,\n timestampMs: 3330,\n confidence: 0.96,\n speaker: \"guest\",\n }, {\n text: \" sound\",\n startMs: 3380,\n endMs: 3720,\n timestampMs: 3550,\n confidence: 0.96,\n speaker: \"guest\",\n }, {\n text: \" off.\",\n startMs: 3720,\n endMs: 4240,\n timestampMs: 3980,\n confidence: 0.96,\n speaker: \"guest\",\n }, {\n text: \" Really?\",\n startMs: 4800,\n endMs: 5400,\n timestampMs: 5100,\n confidence: 0.96,\n speaker: \"host\",\n }, {\n text: \" Almost\",\n startMs: 5800,\n endMs: 6140,\n timestampMs: 5970,\n confidence: 0.96,\n speaker: \"guest\",\n }, {\n text: \" everyone.\",\n startMs: 6140,\n endMs: 6760,\n timestampMs: 6450,\n confidence: 0.96,\n speaker: \"guest\",\n }, {\n text: \" Captions\",\n startMs: 7000,\n endMs: 7480,\n timestampMs: 7240,\n confidence: 0.96,\n speaker: \"guest\",\n }, {\n text: \" keep\",\n startMs: 7480,\n endMs: 7700,\n timestampMs: 7590,\n confidence: 0.96,\n speaker: \"guest\",\n }, {\n text: \" them\",\n startMs: 7700,\n endMs: 7860,\n timestampMs: 7780,\n confidence: 0.96,\n speaker: \"guest\",\n }, {\n text: \" watching.\",\n startMs: 7860,\n endMs: 8400,\n timestampMs: 8130,\n confidence: 0.96,\n speaker: \"guest\",\n }],\n fontSize: 64,\n fontWeight: 800,\n upcomingOpacity: 0.4,\n combineTokensWithinMilliseconds: 1200,\n holdMs: 600,\n shadow: true,\n};\n\ntype CaptionSpeakerElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof CaptionSpeakerBase>;\n\nconst CaptionSpeakerInner = forwardRef<\n HTMLDivElement,\n CaptionSpeakerElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<CaptionSpeaker>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <CaptionSpeakerBase\n {...(componentProps as unknown as ComponentProps<typeof CaptionSpeakerBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const CaptionSpeaker = Interactive.withSchema({\n Component: CaptionSpeakerInner,\n componentName: \"<CaptionSpeaker>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"+ },+ "durationInFrames": 282+}diff --git a/registry-artifacts/elements/caption-split-flap.json b/registry-artifacts/elements/caption-split-flap.jsonnew file mode 100644index 00000000..65e291d5--- /dev/null+++ b/registry-artifacts/elements/caption-split-flap.json@@ -0,0 +1,21 @@+{+ "type": "remotion-element",+ "version": 1,+ "element": {+ "assets": [],+ "dependencies": [+ {+ "name": "@remotion/captions",+ "version": null+ }+ ],+ "dimensions": null,+ "displayName": "Caption Split Flap",+ "durationInFrames": 279,+ "initialProps": null,+ "installationMode": "component-owned-sequence",+ "slug": "caption-split-flap",+ "sourceCode": "import { Fragment, forwardRef, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState, type CSSProperties, type ComponentProps } from \"react\";\nimport { Easing, Interactive, Sequence, interpolate, random, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { createTikTokStyleCaptions, type Caption, type TikTokPage } from \"@remotion/captions\";\n\ntype SpeakerCaption = Caption & { speaker?: string };\n\ninterface CaptionBaseProps {\n captions: Caption[];\n combineTokensWithinMilliseconds?: number;\n holdMs?: number;\n fontSize?: number;\n fontWeight?: number;\n color?: string;\n className?: string;\n}\n\nconst DEFAULT_HOLD_MS = 600;\nconst MIN_SILENCE_BREAK_MS = 300;\n\ninterface CaptionPageWindow {\n page: TikTokPage;\n index: number;\n speaker: string | undefined;\n startMs: number;\n speechEndMs: number;\n endMs: number;\n endsInSilence: boolean;\n}\n\ntype CaptionTokenStatus = \"upcoming\" | \"active\" | \"spoken\";\n\ninterface CaptionTokenState {\n text: string;\n spaceBefore: boolean;\n fromMs: number;\n toMs: number;\n progress: number;\n status: CaptionTokenStatus;\n}\n\ninterface CaptionPreviousPage {\n page: TikTokPage;\n pageIndex: number;\n tokens: CaptionTokenState[];\n}\n\ninterface CaptionsState {\n page: TikTokPage;\n pageIndex: number;\n speaker: string | undefined;\n timeMs: number;\n activeIndex: number;\n tokens: CaptionTokenState[];\n sinceStartMs: number;\n untilEndMs: number;\n holdRoomMs: number;\n endsInSilence: boolean;\n previous: CaptionPreviousPage | null;\n}\n\ninterface CaptionPagingOptions {\n combineTokensWithinMilliseconds: number;\n holdMs?: number;\n}\n\nconst SENTENCE_END = /[.!?…][\"')\\]]*$/;\n\nfunction markPageBreaks(captions: SpeakerCaption[]): Caption[] {\n return captions.map((caption, i) => {\n if (caption.pageBreakAfter !== undefined) return caption;\n const next = captions[i + 1];\n const speakerChanges =\n next !== undefined && next.speaker !== caption.speaker;\n return speakerChanges || SENTENCE_END.test(caption.text.trim())\n ? { ...caption, pageBreakAfter: true }\n : caption;\n });\n}\n\nfunction buildCaptionPages(\n captions: SpeakerCaption[],\n {\n combineTokensWithinMilliseconds,\n holdMs = DEFAULT_HOLD_MS,\n }: CaptionPagingOptions,\n): CaptionPageWindow[] {\n if (captions.length === 0) return [];\n const { pages } = createTikTokStyleCaptions({\n captions: markPageBreaks(captions),\n combineTokensWithinMilliseconds,\n breakOnSilenceAfterMilliseconds: Math.max(holdMs, MIN_SILENCE_BREAK_MS),\n });\n const speakers = new Map<number, string | undefined>();\n for (const caption of captions) {\n if (!speakers.has(caption.startMs)) {\n speakers.set(caption.startMs, caption.speaker);\n }\n }\n const spoken = pages.filter((page) => page.tokens.length > 0);\n return spoken.map((page, index) => {\n const last = page.tokens[page.tokens.length - 1];\n const speechEndMs = last ? last.toMs : page.startMs;\n const heldUntil = speechEndMs + Math.max(0, holdMs);\n const next = spoken[index + 1];\n const endsInSilence = !next || next.startMs > heldUntil;\n const endMs = endsInSilence\n ? heldUntil\n : Math.max(page.startMs, next.startMs);\n return {\n page,\n index,\n speaker: speakers.get(page.tokens[0].fromMs),\n startMs: page.startMs,\n speechEndMs,\n endMs,\n endsInSilence,\n };\n });\n}\n\nfunction findWindowIndex(windows: CaptionPageWindow[], timeMs: number): number {\n let lo = 0;\n let hi = windows.length - 1;\n let found = -1;\n while (lo <= hi) {\n const mid = (lo + hi) >> 1;\n if (windows[mid].startMs <= timeMs) {\n found = mid;\n lo = mid + 1;\n } else {\n hi = mid - 1;\n }\n }\n if (found === -1) return -1;\n return timeMs < windows[found].endMs ? found : -1;\n}\n\nfunction tokenProgress(fromMs: number, toMs: number, timeMs: number): number {\n if (timeMs < fromMs) return 0;\n if (toMs <= fromMs) return 1;\n return Math.min(1, (timeMs - fromMs) / (toMs - fromMs));\n}\n\nfunction getTokenStates(\n page: TikTokPage,\n timeMs: number,\n): { activeIndex: number; tokens: CaptionTokenState[] } {\n let activeIndex = -1;\n page.tokens.forEach((token, i) => {\n if (token.fromMs <= timeMs) activeIndex = i;\n });\n const tokens = page.tokens.map(\n (token, i): CaptionTokenState => ({\n text: token.text.trim(),\n spaceBefore: i > 0 && /^\\s/.test(token.text),\n fromMs: token.fromMs,\n toMs: token.toMs,\n progress: tokenProgress(token.fromMs, token.toMs, timeMs),\n status:\n i < activeIndex ? \"spoken\" : i === activeIndex ? \"active\" : \"upcoming\",\n }),\n );\n return { activeIndex, tokens };\n}\n\nfunction getCaptionsState(\n windows: CaptionPageWindow[],\n timeMs: number,\n): CaptionsState | null {\n const found = findWindowIndex(windows, timeMs);\n if (found === -1) return null;\n const window = windows[found];\n const { activeIndex, tokens } = getTokenStates(window.page, timeMs);\n const before = found > 0 ? windows[found - 1] : null;\n const previous =\n before && !before.endsInSilence\n ? {\n page: before.page,\n pageIndex: before.index,\n tokens: getTokenStates(before.page, before.endMs).tokens,\n }\n : null;\n return {\n page: window.page,\n pageIndex: window.index,\n speaker: window.speaker,\n timeMs,\n activeIndex,\n tokens,\n sinceStartMs: timeMs - window.startMs,\n untilEndMs: window.endMs - timeMs,\n holdRoomMs: window.endMs - window.speechEndMs,\n endsInSilence: window.endsInSilence,\n previous,\n };\n}\n\nfunction getExitWindowMs(state: CaptionsState, exitMs: number): number {\n return Math.max(1, Math.min(exitMs, state.holdRoomMs));\n}\n\nfunction groupCaptionWords(\n tokens: CaptionTokenState[],\n): { index: number; token: CaptionTokenState }[][] {\n const words: { index: number; token: CaptionTokenState }[][] = [];\n tokens.forEach((token, index) => {\n const current = words[words.length - 1];\n if (!current || token.spaceBefore) {\n words.push([{ index, token }]);\n } else {\n current.push({ index, token });\n }\n });\n return words;\n}\n\nfunction normalizeCaptionWord(text: string): string {\n return text\n .toLowerCase()\n .replace(/[\\u2018\\u2019]/g, \"'\")\n .replace(/[^\\p{L}\\p{N}']/gu, \"\");\n}\n\nfunction createKeywordMatcher(\n keywords: readonly string[] = [],\n): (text: string) => boolean {\n const set = new Set(keywords.map(normalizeCaptionWord).filter(Boolean));\n return (text) => set.has(normalizeCaptionWord(text));\n}\n\nfunction captionWordText(word: { token: CaptionTokenState }[]): string {\n return word.map(({ token }) => token.text).join(\"\");\n}\n\ninterface CaptionWordRect {\n left: number;\n top: number;\n width: number;\n height: number;\n}\n\nfunction sameRects(a: CaptionWordRect[], b: CaptionWordRect[]): boolean {\n return (\n a.length === b.length &&\n a.every(\n (r, i) =>\n r.left === b[i].left &&\n r.top === b[i].top &&\n r.width === b[i].width &&\n r.height === b[i].height,\n )\n );\n}\n\nfunction useCaptionWordRects(\n pageIndex: number,\n count: number,\n): {\n wordRef: (index: number) => (el: HTMLElement | null) => void;\n rects: CaptionWordRect[] | null;\n} {\n const elements = useRef<(HTMLElement | null)[]>([]);\n const [measured, setMeasured] = useState<{\n pageIndex: number;\n rects: CaptionWordRect[];\n } | null>(null);\n\n useLayoutEffect(() => {\n if (pageIndex === -1) return;\n const rects = elements.current.slice(0, count).map((el) =>\n el\n ? {\n left: el.offsetLeft,\n top: el.offsetTop,\n width: el.offsetWidth,\n height: el.offsetHeight,\n }\n : { left: 0, top: 0, width: 0, height: 0 },\n );\n setMeasured((prev) =>\n prev && prev.pageIndex === pageIndex && sameRects(prev.rects, rects)\n ? prev\n : { pageIndex, rects },\n );\n });\n\n return {\n wordRef: (index) => (el) => {\n elements.current[index] = el;\n },\n rects: measured && measured.pageIndex === pageIndex ? measured.rects : null,\n };\n}\n\nfunction useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs = DEFAULT_HOLD_MS,\n}: {\n captions: SpeakerCaption[];\n combineTokensWithinMilliseconds: number;\n holdMs?: number;\n}): CaptionsState | null {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const windows = useMemo(\n () =>\n buildCaptionPages(captions, { combineTokensWithinMilliseconds, holdMs }),\n [captions, combineTokensWithinMilliseconds, holdMs],\n );\n return getCaptionsState(windows, (frame / fps) * 1000);\n}\n\ninterface CaptionSplitFlapProps extends CaptionBaseProps {\n tileColor?: string;\n}\n\nconst ENTER_MS = 160;\nconst EXIT_MS = 220;\nconst RISE_EM = 0.14;\nconst FLIP_MS = 60;\nconst MIN_SETTLE_MS = 350;\nconst TILE_W = 0.78;\nconst TILE_H = 1.2;\nconst TILE_GAP = 0.06;\nconst GLYPH_SCALE = 0.8;\nconst RADIUS = 0.08;\nconst GLYPHS = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\";\n\nconst enterEasing = Easing.bezier(0.2, 0.8, 0.2, 1);\n\nconst clamp = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n} as const;\n\ninterface FlapFrame {\n current: string;\n next: string;\n progress: number | null;\n}\n\nfunction flapFrame(\n target: string,\n seed: string,\n index: number,\n count: number,\n fromMs: number,\n windowMs: number,\n timeMs: number,\n): FlapFrame {\n const flips = 3 + Math.floor(random(`${seed}-flips`) * 4);\n const share = count > 1 ? index / (count - 1) : 1;\n const endMs = fromMs + windowMs * (0.55 + 0.45 * share);\n const flipMs = Math.min(FLIP_MS, (endMs - fromMs) / flips);\n const startMs = endMs - flips * flipMs;\n if (timeMs < startMs) return { current: \"\", next: \"\", progress: null };\n if (timeMs >= endMs) return { current: target, next: target, progress: null };\n const glyphAt = (k: number): string => {\n if (k <= 0) return \"\";\n if (k >= flips) return target;\n return GLYPHS[Math.floor(random(`${seed}-${k}`) * GLYPHS.length)];\n };\n const elapsed = (timeMs - startMs) / flipMs;\n const k = Math.floor(elapsed);\n return { current: glyphAt(k), next: glyphAt(k + 1), progress: elapsed - k };\n}\n\nconst TOP_HALF = \"inset(0 0 50% 0)\";\nconst BOTTOM_HALF = \"inset(50% 0 0 0)\";\n\nfunction Leaf({\n char,\n tileColor,\n clipPath,\n transform,\n brightness = 1,\n}: {\n char: string;\n tileColor: string;\n clipPath?: string;\n transform?: string;\n brightness?: number;\n}) {\n const style: CSSProperties = {\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n background: tileColor,\n borderRadius: `${RADIUS}em`,\n clipPath,\n transform,\n transformOrigin: \"50% 50%\",\n filter: brightness < 1 ? `brightness(${brightness})` : undefined,\n };\n return (\n <span style={style}>\n <span style={{ fontSize: `${GLYPH_SCALE}em`, lineHeight: 1 }}>\n {char}\n </span>\n </span>\n );\n}\n\nfunction Tile({ frame, tileColor }: { frame: FlapFrame; tileColor: string }) {\n const perspective = `perspective(${TILE_H * 4}em)`;\n const { current, next, progress } = frame;\n return (\n <span\n style={{\n position: \"relative\",\n display: \"inline-block\",\n width: `${TILE_W}em`,\n height: `${TILE_H}em`,\n flexShrink: 0,\n }}\n >\n {progress === null ? (\n <Leaf char={current} tileColor={tileColor} />\n ) : (\n <>\n <Leaf char={next} tileColor={tileColor} clipPath={TOP_HALF} />\n <Leaf char={current} tileColor={tileColor} clipPath={BOTTOM_HALF} />\n {progress < 0.5 ? (\n <Leaf\n char={current}\n tileColor={tileColor}\n clipPath={TOP_HALF}\n transform={`${perspective} rotateX(${-180 * progress}deg)`}\n brightness={1 - 0.7 * progress}\n />\n ) : (\n <Leaf\n char={next}\n tileColor={tileColor}\n clipPath={BOTTOM_HALF}\n transform={`${perspective} rotateX(${180 * (1 - progress)}deg)`}\n brightness={0.65 + 0.7 * (progress - 0.5)}\n />\n )}\n </>\n )}\n <span\n aria-hidden\n style={{\n position: \"absolute\",\n left: 0,\n right: 0,\n top: \"50%\",\n height: \"max(1px, 0.025em)\",\n transform: \"translateY(-50%)\",\n background: \"rgba(0, 0, 0, 0.6)\",\n }}\n />\n </span>\n );\n}\n\nfunction CaptionSplitFlapBase({\n captions,\n combineTokensWithinMilliseconds = 1000,\n holdMs = DEFAULT_HOLD_MS,\n fontSize = 56,\n fontWeight = 800,\n color = \"#ffffff\",\n tileColor = \"#111111\",\n className,\n}: CaptionSplitFlapProps) {\n const state = useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs,\n });\n if (!state) return null;\n\n const enter = interpolate(\n state.previous ? ENTER_MS : state.sinceStartMs,\n [0, ENTER_MS],\n [0, 1],\n { ...clamp, easing: enterEasing },\n );\n const exit = state.endsInSilence\n ? interpolate(\n state.untilEndMs,\n [0, getExitWindowMs(state, EXIT_MS)],\n [0, 1],\n clamp,\n )\n : 1;\n\n return (\n <div\n className={className}\n style={{\n fontSize,\n fontWeight,\n color,\n lineHeight: TILE_H + 0.24,\n textAlign: \"center\",\n opacity: Math.min(enter, exit),\n transform: `translateY(${(1 - enter) * RISE_EM}em)`,\n }}\n >\n {groupCaptionWords(state.tokens).map((word, w) => {\n const first = word[0];\n const fromMs = first.token.fromMs;\n const toMs = word[word.length - 1].token.toMs;\n const windowMs = Math.max(toMs - fromMs, MIN_SETTLE_MS);\n const chars = Array.from(captionWordText(word));\n return (\n <Fragment key={`${state.pageIndex}-${first.index}`}>\n {w > 0 && \" \"}\n <span\n style={{\n display: \"inline-flex\",\n gap: `${TILE_GAP}em`,\n verticalAlign: \"top\",\n paddingInline: `${TILE_GAP}em`,\n }}\n >\n {chars.map((char, c) => (\n <Tile\n key={c}\n tileColor={tileColor}\n frame={flapFrame(\n char,\n `${state.pageIndex}-${first.index}-${c}`,\n c,\n chars.length,\n fromMs,\n windowMs,\n state.timeMs,\n )}\n />\n ))}\n </span>\n </Fragment>\n );\n })}\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n captions: {\n type: \"remotion-captions\",\n default: [{\n text: \" So\",\n startMs: 300,\n endMs: 460,\n timestampMs: 380,\n confidence: 0.97,\n }, {\n text: \" here's\",\n startMs: 460,\n endMs: 700,\n timestampMs: 580,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 700,\n endMs: 820,\n timestampMs: 760,\n confidence: 0.97,\n }, {\n text: \" thing.\",\n startMs: 820,\n endMs: 1240,\n timestampMs: 1030,\n confidence: 0.97,\n }, {\n text: \" Most\",\n startMs: 1700,\n endMs: 1960,\n timestampMs: 1830,\n confidence: 0.97,\n }, {\n text: \" demo\",\n startMs: 1960,\n endMs: 2240,\n timestampMs: 2100,\n confidence: 0.97,\n }, {\n text: \" videos\",\n startMs: 2240,\n endMs: 2680,\n timestampMs: 2460,\n confidence: 0.97,\n }, {\n text: \" lose\",\n startMs: 2680,\n endMs: 2960,\n timestampMs: 2820,\n confidence: 0.97,\n }, {\n text: \" people\",\n startMs: 2960,\n endMs: 3320,\n timestampMs: 3140,\n confidence: 0.97,\n }, {\n text: \" in\",\n startMs: 3320,\n endMs: 3420,\n timestampMs: 3370,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 3420,\n endMs: 3520,\n timestampMs: 3470,\n confidence: 0.97,\n }, {\n text: \" first\",\n startMs: 3520,\n endMs: 3820,\n timestampMs: 3670,\n confidence: 0.97,\n }, {\n text: \" three\",\n startMs: 3820,\n endMs: 4100,\n timestampMs: 3960,\n confidence: 0.97,\n }, {\n text: \" seconds.\",\n startMs: 4100,\n endMs: 4780,\n timestampMs: 4440,\n confidence: 0.97,\n }, {\n text: \" Captions\",\n startMs: 5400,\n endMs: 5920,\n timestampMs: 5660,\n confidence: 0.97,\n }, {\n text: \" keep\",\n startMs: 5920,\n endMs: 6140,\n timestampMs: 6030,\n confidence: 0.97,\n }, {\n text: \" them\",\n startMs: 6140,\n endMs: 6300,\n timestampMs: 6220,\n confidence: 0.97,\n }, {\n text: \" watching,\",\n startMs: 6300,\n endMs: 6860,\n timestampMs: 6580,\n confidence: 0.97,\n }, {\n text: \" even\",\n startMs: 6960,\n endMs: 7180,\n timestampMs: 7070,\n confidence: 0.97,\n }, {\n text: \" with\",\n startMs: 7180,\n endMs: 7320,\n timestampMs: 7250,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 7320,\n endMs: 7420,\n timestampMs: 7370,\n confidence: 0.97,\n }, {\n text: \" sound\",\n startMs: 7420,\n endMs: 7760,\n timestampMs: 7590,\n confidence: 0.97,\n }, {\n text: \" off.\",\n startMs: 7760,\n endMs: 8300,\n timestampMs: 8030,\n confidence: 0.97,\n }],\n description: \"Transcript\",\n keyframable: false,\n },\n fontSize: {\n type: \"number\",\n min: 24,\n max: 120,\n step: 1,\n default: 56,\n description: \"Font size\",\n hiddenFromList: false,\n },\n fontWeight: {\n type: \"number\",\n min: 400,\n max: 900,\n step: 100,\n default: 800,\n description: \"Font weight\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#ffffff\",\n description: \"Glyph color\",\n },\n tileColor: {\n type: \"color\",\n default: \"#111111\",\n description: \"Tile color\",\n },\n combineTokensWithinMilliseconds: {\n type: \"number\",\n min: 0,\n max: 3000,\n step: 100,\n default: 1000,\n description: \"Page window (ms)\",\n hiddenFromList: false,\n },\n holdMs: {\n type: \"number\",\n min: 0,\n max: 2000,\n step: 50,\n default: 600,\n description: \"Hold (ms)\",\n hiddenFromList: false,\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"captions\",\"fontSize\",\"fontWeight\",\"color\",\"tileColor\",\"combineTokensWithinMilliseconds\",\"holdMs\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n captions: [{\n text: \" So\",\n startMs: 300,\n endMs: 460,\n timestampMs: 380,\n confidence: 0.97,\n }, {\n text: \" here's\",\n startMs: 460,\n endMs: 700,\n timestampMs: 580,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 700,\n endMs: 820,\n timestampMs: 760,\n confidence: 0.97,\n }, {\n text: \" thing.\",\n startMs: 820,\n endMs: 1240,\n timestampMs: 1030,\n confidence: 0.97,\n }, {\n text: \" Most\",\n startMs: 1700,\n endMs: 1960,\n timestampMs: 1830,\n confidence: 0.97,\n }, {\n text: \" demo\",\n startMs: 1960,\n endMs: 2240,\n timestampMs: 2100,\n confidence: 0.97,\n }, {\n text: \" videos\",\n startMs: 2240,\n endMs: 2680,\n timestampMs: 2460,\n confidence: 0.97,\n }, {\n text: \" lose\",\n startMs: 2680,\n endMs: 2960,\n timestampMs: 2820,\n confidence: 0.97,\n }, {\n text: \" people\",\n startMs: 2960,\n endMs: 3320,\n timestampMs: 3140,\n confidence: 0.97,\n }, {\n text: \" in\",\n startMs: 3320,\n endMs: 3420,\n timestampMs: 3370,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 3420,\n endMs: 3520,\n timestampMs: 3470,\n confidence: 0.97,\n }, {\n text: \" first\",\n startMs: 3520,\n endMs: 3820,\n timestampMs: 3670,\n confidence: 0.97,\n }, {\n text: \" three\",\n startMs: 3820,\n endMs: 4100,\n timestampMs: 3960,\n confidence: 0.97,\n }, {\n text: \" seconds.\",\n startMs: 4100,\n endMs: 4780,\n timestampMs: 4440,\n confidence: 0.97,\n }, {\n text: \" Captions\",\n startMs: 5400,\n endMs: 5920,\n timestampMs: 5660,\n confidence: 0.97,\n }, {\n text: \" keep\",\n startMs: 5920,\n endMs: 6140,\n timestampMs: 6030,\n confidence: 0.97,\n }, {\n text: \" them\",\n startMs: 6140,\n endMs: 6300,\n timestampMs: 6220,\n confidence: 0.97,\n }, {\n text: \" watching,\",\n startMs: 6300,\n endMs: 6860,\n timestampMs: 6580,\n confidence: 0.97,\n }, {\n text: \" even\",\n startMs: 6960,\n endMs: 7180,\n timestampMs: 7070,\n confidence: 0.97,\n }, {\n text: \" with\",\n startMs: 7180,\n endMs: 7320,\n timestampMs: 7250,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 7320,\n endMs: 7420,\n timestampMs: 7370,\n confidence: 0.97,\n }, {\n text: \" sound\",\n startMs: 7420,\n endMs: 7760,\n timestampMs: 7590,\n confidence: 0.97,\n }, {\n text: \" off.\",\n startMs: 7760,\n endMs: 8300,\n timestampMs: 8030,\n confidence: 0.97,\n }],\n fontSize: 56,\n fontWeight: 800,\n color: \"#ffffff\",\n tileColor: \"#111111\",\n combineTokensWithinMilliseconds: 1000,\n holdMs: 600,\n};\n\ntype CaptionSplitFlapElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof CaptionSplitFlapBase>;\n\nconst CaptionSplitFlapInner = forwardRef<\n HTMLDivElement,\n CaptionSplitFlapElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<CaptionSplitFlap>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <CaptionSplitFlapBase\n {...(componentProps as unknown as ComponentProps<typeof CaptionSplitFlapBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const CaptionSplitFlap = Interactive.withSchema({\n Component: CaptionSplitFlapInner,\n componentName: \"<CaptionSplitFlap>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"+ },+ "durationInFrames": 279+}diff --git a/registry-artifacts/elements/caption-stack.json b/registry-artifacts/elements/caption-stack.jsonnew file mode 100644index 00000000..b338d802--- /dev/null+++ b/registry-artifacts/elements/caption-stack.json@@ -0,0 +1,21 @@+{+ "type": "remotion-element",+ "version": 1,+ "element": {+ "assets": [],+ "dependencies": [+ {+ "name": "@remotion/captions",+ "version": null+ }+ ],+ "dimensions": null,+ "displayName": "Caption Stack",+ "durationInFrames": 279,+ "initialProps": null,+ "installationMode": "component-owned-sequence",+ "slug": "caption-stack",+ "sourceCode": "import { Fragment, forwardRef, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState, type ComponentProps } from \"react\";\nimport { Easing, Interactive, Sequence, interpolate, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { createTikTokStyleCaptions, type Caption, type TikTokPage } from \"@remotion/captions\";\n\ntype SpeakerCaption = Caption & { speaker?: string };\n\ninterface CaptionBaseProps {\n captions: Caption[];\n combineTokensWithinMilliseconds?: number;\n holdMs?: number;\n fontSize?: number;\n fontWeight?: number;\n color?: string;\n className?: string;\n}\n\nconst DEFAULT_HOLD_MS = 600;\nconst MIN_SILENCE_BREAK_MS = 300;\n\ninterface CaptionPageWindow {\n page: TikTokPage;\n index: number;\n speaker: string | undefined;\n startMs: number;\n speechEndMs: number;\n endMs: number;\n endsInSilence: boolean;\n}\n\ntype CaptionTokenStatus = \"upcoming\" | \"active\" | \"spoken\";\n\ninterface CaptionTokenState {\n text: string;\n spaceBefore: boolean;\n fromMs: number;\n toMs: number;\n progress: number;\n status: CaptionTokenStatus;\n}\n\ninterface CaptionPreviousPage {\n page: TikTokPage;\n pageIndex: number;\n tokens: CaptionTokenState[];\n}\n\ninterface CaptionsState {\n page: TikTokPage;\n pageIndex: number;\n speaker: string | undefined;\n timeMs: number;\n activeIndex: number;\n tokens: CaptionTokenState[];\n sinceStartMs: number;\n untilEndMs: number;\n holdRoomMs: number;\n endsInSilence: boolean;\n previous: CaptionPreviousPage | null;\n}\n\ninterface CaptionPagingOptions {\n combineTokensWithinMilliseconds: number;\n holdMs?: number;\n}\n\nconst SENTENCE_END = /[.!?…][\"')\\]]*$/;\n\nfunction markPageBreaks(captions: SpeakerCaption[]): Caption[] {\n return captions.map((caption, i) => {\n if (caption.pageBreakAfter !== undefined) return caption;\n const next = captions[i + 1];\n const speakerChanges =\n next !== undefined && next.speaker !== caption.speaker;\n return speakerChanges || SENTENCE_END.test(caption.text.trim())\n ? { ...caption, pageBreakAfter: true }\n : caption;\n });\n}\n\nfunction buildCaptionPages(\n captions: SpeakerCaption[],\n {\n combineTokensWithinMilliseconds,\n holdMs = DEFAULT_HOLD_MS,\n }: CaptionPagingOptions,\n): CaptionPageWindow[] {\n if (captions.length === 0) return [];\n const { pages } = createTikTokStyleCaptions({\n captions: markPageBreaks(captions),\n combineTokensWithinMilliseconds,\n breakOnSilenceAfterMilliseconds: Math.max(holdMs, MIN_SILENCE_BREAK_MS),\n });\n const speakers = new Map<number, string | undefined>();\n for (const caption of captions) {\n if (!speakers.has(caption.startMs)) {\n speakers.set(caption.startMs, caption.speaker);\n }\n }\n const spoken = pages.filter((page) => page.tokens.length > 0);\n return spoken.map((page, index) => {\n const last = page.tokens[page.tokens.length - 1];\n const speechEndMs = last ? last.toMs : page.startMs;\n const heldUntil = speechEndMs + Math.max(0, holdMs);\n const next = spoken[index + 1];\n const endsInSilence = !next || next.startMs > heldUntil;\n const endMs = endsInSilence\n ? heldUntil\n : Math.max(page.startMs, next.startMs);\n return {\n page,\n index,\n speaker: speakers.get(page.tokens[0].fromMs),\n startMs: page.startMs,\n speechEndMs,\n endMs,\n endsInSilence,\n };\n });\n}\n\nfunction findWindowIndex(windows: CaptionPageWindow[], timeMs: number): number {\n let lo = 0;\n let hi = windows.length - 1;\n let found = -1;\n while (lo <= hi) {\n const mid = (lo + hi) >> 1;\n if (windows[mid].startMs <= timeMs) {\n found = mid;\n lo = mid + 1;\n } else {\n hi = mid - 1;\n }\n }\n if (found === -1) return -1;\n return timeMs < windows[found].endMs ? found : -1;\n}\n\nfunction tokenProgress(fromMs: number, toMs: number, timeMs: number): number {\n if (timeMs < fromMs) return 0;\n if (toMs <= fromMs) return 1;\n return Math.min(1, (timeMs - fromMs) / (toMs - fromMs));\n}\n\nfunction getTokenStates(\n page: TikTokPage,\n timeMs: number,\n): { activeIndex: number; tokens: CaptionTokenState[] } {\n let activeIndex = -1;\n page.tokens.forEach((token, i) => {\n if (token.fromMs <= timeMs) activeIndex = i;\n });\n const tokens = page.tokens.map(\n (token, i): CaptionTokenState => ({\n text: token.text.trim(),\n spaceBefore: i > 0 && /^\\s/.test(token.text),\n fromMs: token.fromMs,\n toMs: token.toMs,\n progress: tokenProgress(token.fromMs, token.toMs, timeMs),\n status:\n i < activeIndex ? \"spoken\" : i === activeIndex ? \"active\" : \"upcoming\",\n }),\n );\n return { activeIndex, tokens };\n}\n\nfunction getCaptionsState(\n windows: CaptionPageWindow[],\n timeMs: number,\n): CaptionsState | null {\n const found = findWindowIndex(windows, timeMs);\n if (found === -1) return null;\n const window = windows[found];\n const { activeIndex, tokens } = getTokenStates(window.page, timeMs);\n const before = found > 0 ? windows[found - 1] : null;\n const previous =\n before && !before.endsInSilence\n ? {\n page: before.page,\n pageIndex: before.index,\n tokens: getTokenStates(before.page, before.endMs).tokens,\n }\n : null;\n return {\n page: window.page,\n pageIndex: window.index,\n speaker: window.speaker,\n timeMs,\n activeIndex,\n tokens,\n sinceStartMs: timeMs - window.startMs,\n untilEndMs: window.endMs - timeMs,\n holdRoomMs: window.endMs - window.speechEndMs,\n endsInSilence: window.endsInSilence,\n previous,\n };\n}\n\nfunction getExitWindowMs(state: CaptionsState, exitMs: number): number {\n return Math.max(1, Math.min(exitMs, state.holdRoomMs));\n}\n\nfunction groupCaptionWords(\n tokens: CaptionTokenState[],\n): { index: number; token: CaptionTokenState }[][] {\n const words: { index: number; token: CaptionTokenState }[][] = [];\n tokens.forEach((token, index) => {\n const current = words[words.length - 1];\n if (!current || token.spaceBefore) {\n words.push([{ index, token }]);\n } else {\n current.push({ index, token });\n }\n });\n return words;\n}\n\nfunction normalizeCaptionWord(text: string): string {\n return text\n .toLowerCase()\n .replace(/[\\u2018\\u2019]/g, \"'\")\n .replace(/[^\\p{L}\\p{N}']/gu, \"\");\n}\n\nfunction createKeywordMatcher(\n keywords: readonly string[] = [],\n): (text: string) => boolean {\n const set = new Set(keywords.map(normalizeCaptionWord).filter(Boolean));\n return (text) => set.has(normalizeCaptionWord(text));\n}\n\nfunction captionWordText(word: { token: CaptionTokenState }[]): string {\n return word.map(({ token }) => token.text).join(\"\");\n}\n\ninterface CaptionWordRect {\n left: number;\n top: number;\n width: number;\n height: number;\n}\n\nfunction sameRects(a: CaptionWordRect[], b: CaptionWordRect[]): boolean {\n return (\n a.length === b.length &&\n a.every(\n (r, i) =>\n r.left === b[i].left &&\n r.top === b[i].top &&\n r.width === b[i].width &&\n r.height === b[i].height,\n )\n );\n}\n\nfunction useCaptionWordRects(\n pageIndex: number,\n count: number,\n): {\n wordRef: (index: number) => (el: HTMLElement | null) => void;\n rects: CaptionWordRect[] | null;\n} {\n const elements = useRef<(HTMLElement | null)[]>([]);\n const [measured, setMeasured] = useState<{\n pageIndex: number;\n rects: CaptionWordRect[];\n } | null>(null);\n\n useLayoutEffect(() => {\n if (pageIndex === -1) return;\n const rects = elements.current.slice(0, count).map((el) =>\n el\n ? {\n left: el.offsetLeft,\n top: el.offsetTop,\n width: el.offsetWidth,\n height: el.offsetHeight,\n }\n : { left: 0, top: 0, width: 0, height: 0 },\n );\n setMeasured((prev) =>\n prev && prev.pageIndex === pageIndex && sameRects(prev.rects, rects)\n ? prev\n : { pageIndex, rects },\n );\n });\n\n return {\n wordRef: (index) => (el) => {\n elements.current[index] = el;\n },\n rects: measured && measured.pageIndex === pageIndex ? measured.rects : null,\n };\n}\n\nfunction useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs = DEFAULT_HOLD_MS,\n}: {\n captions: SpeakerCaption[];\n combineTokensWithinMilliseconds: number;\n holdMs?: number;\n}): CaptionsState | null {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const windows = useMemo(\n () =>\n buildCaptionPages(captions, { combineTokensWithinMilliseconds, holdMs }),\n [captions, combineTokensWithinMilliseconds, holdMs],\n );\n return getCaptionsState(windows, (frame / fps) * 1000);\n}\n\ninterface CaptionStackProps extends CaptionBaseProps {\n keywords?: string[];\n emphasisScale?: number;\n emphasisColor?: string;\n shadow?: boolean;\n}\n\ntype CaptionWord = ReturnType<typeof groupCaptionWords>[number];\n\ninterface StackLine {\n words: CaptionWord[];\n emphasis: boolean;\n}\n\nconst WORDS_PER_LINE = 2;\nconst EXIT_MS = 220;\nconst FADE_IN_MS = 120;\nconst RISE_MS = 220;\nconst RISE_EM = 0.3;\nconst LEGIBILITY_SHADOW =\n \"0 2px 3px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.35)\";\n\nconst riseEasing = Easing.bezier(0.2, 0.8, 0.2, 1);\n\nconst clamp = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n} as const;\n\nfunction buildLines(\n words: CaptionWord[],\n isEmphasis: (word: CaptionWord, index: number) => boolean,\n): StackLine[] {\n const lines: StackLine[] = [];\n let current: CaptionWord[] = [];\n const flush = () => {\n if (current.length > 0) {\n lines.push({ words: current, emphasis: false });\n current = [];\n }\n };\n words.forEach((word, i) => {\n if (isEmphasis(word, i)) {\n flush();\n lines.push({ words: [word], emphasis: true });\n return;\n }\n current.push(word);\n if (current.length >= WORDS_PER_LINE) flush();\n });\n flush();\n return lines;\n}\n\nfunction longestWordIndex(words: CaptionWord[]): number {\n let longest = -1;\n let longestLength = 0;\n words.forEach((word, i) => {\n const length = normalizeCaptionWord(captionWordText(word)).length;\n if (length > longestLength) {\n longest = i;\n longestLength = length;\n }\n });\n return longest;\n}\n\nfunction CaptionStackBase({\n captions,\n combineTokensWithinMilliseconds = 1600,\n holdMs = DEFAULT_HOLD_MS,\n fontSize = 64,\n fontWeight = 800,\n color = \"#ffffff\",\n keywords,\n emphasisScale = 1.7,\n emphasisColor = \"#facc15\",\n shadow = true,\n className,\n}: CaptionStackProps) {\n const state = useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs,\n });\n if (!state) return null;\n\n const words = groupCaptionWords(state.tokens);\n const hasKeywords = keywords !== undefined && keywords.length > 0;\n const isKeyword = createKeywordMatcher(keywords);\n const longest = hasKeywords ? -1 : longestWordIndex(words);\n const lines = buildLines(words, (word, i) =>\n hasKeywords ? isKeyword(captionWordText(word)) : i === longest,\n );\n\n const exit = state.endsInSilence\n ? interpolate(\n state.untilEndMs,\n [0, getExitWindowMs(state, EXIT_MS)],\n [0, 1],\n clamp,\n )\n : 1;\n\n return (\n <div\n className={className}\n style={{\n fontSize,\n fontWeight,\n color,\n lineHeight: 1,\n textAlign: \"center\",\n opacity: exit,\n }}\n >\n {lines.map((line) => (\n <div\n key={`${state.pageIndex}-${line.words[0][0].index}`}\n style={{\n fontSize: line.emphasis ? `${emphasisScale}em` : undefined,\n color: line.emphasis ? emphasisColor : undefined,\n }}\n >\n {line.words.map((word, w) => {\n const sinceMs = state.timeMs - word[0].token.fromMs;\n const arrived = sinceMs >= 0;\n const rise = arrived\n ? interpolate(sinceMs, [0, RISE_MS], [0, 1], {\n ...clamp,\n easing: riseEasing,\n })\n : 0;\n const opacity = arrived\n ? interpolate(sinceMs, [0, FADE_IN_MS], [0, 1], clamp)\n : 0;\n return (\n <Fragment key={word[0].index}>\n {w > 0 && \" \"}\n <span\n style={{\n display: \"inline-block\",\n whiteSpace: \"nowrap\",\n opacity,\n transform: `translateY(${(1 - rise) * RISE_EM}em)`,\n textShadow: shadow ? LEGIBILITY_SHADOW : undefined,\n }}\n >\n {word.map(({ index, token }) => (\n <span key={index}>{token.text}</span>\n ))}\n </span>\n </Fragment>\n );\n })}\n </div>\n ))}\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n captions: {\n type: \"remotion-captions\",\n default: [{\n text: \" So\",\n startMs: 300,\n endMs: 460,\n timestampMs: 380,\n confidence: 0.97,\n }, {\n text: \" here's\",\n startMs: 460,\n endMs: 700,\n timestampMs: 580,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 700,\n endMs: 820,\n timestampMs: 760,\n confidence: 0.97,\n }, {\n text: \" thing.\",\n startMs: 820,\n endMs: 1240,\n timestampMs: 1030,\n confidence: 0.97,\n }, {\n text: \" Most\",\n startMs: 1700,\n endMs: 1960,\n timestampMs: 1830,\n confidence: 0.97,\n }, {\n text: \" demo\",\n startMs: 1960,\n endMs: 2240,\n timestampMs: 2100,\n confidence: 0.97,\n }, {\n text: \" videos\",\n startMs: 2240,\n endMs: 2680,\n timestampMs: 2460,\n confidence: 0.97,\n }, {\n text: \" lose\",\n startMs: 2680,\n endMs: 2960,\n timestampMs: 2820,\n confidence: 0.97,\n }, {\n text: \" people\",\n startMs: 2960,\n endMs: 3320,\n timestampMs: 3140,\n confidence: 0.97,\n }, {\n text: \" in\",\n startMs: 3320,\n endMs: 3420,\n timestampMs: 3370,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 3420,\n endMs: 3520,\n timestampMs: 3470,\n confidence: 0.97,\n }, {\n text: \" first\",\n startMs: 3520,\n endMs: 3820,\n timestampMs: 3670,\n confidence: 0.97,\n }, {\n text: \" three\",\n startMs: 3820,\n endMs: 4100,\n timestampMs: 3960,\n confidence: 0.97,\n }, {\n text: \" seconds.\",\n startMs: 4100,\n endMs: 4780,\n timestampMs: 4440,\n confidence: 0.97,\n }, {\n text: \" Captions\",\n startMs: 5400,\n endMs: 5920,\n timestampMs: 5660,\n confidence: 0.97,\n }, {\n text: \" keep\",\n startMs: 5920,\n endMs: 6140,\n timestampMs: 6030,\n confidence: 0.97,\n }, {\n text: \" them\",\n startMs: 6140,\n endMs: 6300,\n timestampMs: 6220,\n confidence: 0.97,\n }, {\n text: \" watching,\",\n startMs: 6300,\n endMs: 6860,\n timestampMs: 6580,\n confidence: 0.97,\n }, {\n text: \" even\",\n startMs: 6960,\n endMs: 7180,\n timestampMs: 7070,\n confidence: 0.97,\n }, {\n text: \" with\",\n startMs: 7180,\n endMs: 7320,\n timestampMs: 7250,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 7320,\n endMs: 7420,\n timestampMs: 7370,\n confidence: 0.97,\n }, {\n text: \" sound\",\n startMs: 7420,\n endMs: 7760,\n timestampMs: 7590,\n confidence: 0.97,\n }, {\n text: \" off.\",\n startMs: 7760,\n endMs: 8300,\n timestampMs: 8030,\n confidence: 0.97,\n }],\n description: \"Transcript\",\n keyframable: false,\n },\n fontSize: {\n type: \"number\",\n min: 24,\n max: 140,\n step: 1,\n default: 64,\n description: \"Font size\",\n hiddenFromList: false,\n },\n fontWeight: {\n type: \"number\",\n min: 400,\n max: 900,\n step: 100,\n default: 800,\n description: \"Font weight\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#ffffff\",\n description: \"Text color\",\n },\n emphasisColor: {\n type: \"color\",\n default: \"#facc15\",\n description: \"Emphasis color\",\n },\n emphasisScale: {\n type: \"number\",\n min: 1,\n max: 2.5,\n step: 0.05,\n default: 1.7,\n description: \"Emphasis scale\",\n hiddenFromList: false,\n },\n combineTokensWithinMilliseconds: {\n type: \"number\",\n min: 0,\n max: 3000,\n step: 100,\n default: 1600,\n description: \"Page window (ms)\",\n hiddenFromList: false,\n },\n holdMs: {\n type: \"number\",\n min: 0,\n max: 2000,\n step: 50,\n default: 600,\n description: \"Hold (ms)\",\n hiddenFromList: false,\n },\n shadow: {\n type: \"boolean\",\n default: true,\n description: \"Shadow\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"captions\",\"fontSize\",\"fontWeight\",\"color\",\"emphasisColor\",\"emphasisScale\",\"combineTokensWithinMilliseconds\",\"holdMs\",\"shadow\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n captions: [{\n text: \" So\",\n startMs: 300,\n endMs: 460,\n timestampMs: 380,\n confidence: 0.97,\n }, {\n text: \" here's\",\n startMs: 460,\n endMs: 700,\n timestampMs: 580,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 700,\n endMs: 820,\n timestampMs: 760,\n confidence: 0.97,\n }, {\n text: \" thing.\",\n startMs: 820,\n endMs: 1240,\n timestampMs: 1030,\n confidence: 0.97,\n }, {\n text: \" Most\",\n startMs: 1700,\n endMs: 1960,\n timestampMs: 1830,\n confidence: 0.97,\n }, {\n text: \" demo\",\n startMs: 1960,\n endMs: 2240,\n timestampMs: 2100,\n confidence: 0.97,\n }, {\n text: \" videos\",\n startMs: 2240,\n endMs: 2680,\n timestampMs: 2460,\n confidence: 0.97,\n }, {\n text: \" lose\",\n startMs: 2680,\n endMs: 2960,\n timestampMs: 2820,\n confidence: 0.97,\n }, {\n text: \" people\",\n startMs: 2960,\n endMs: 3320,\n timestampMs: 3140,\n confidence: 0.97,\n }, {\n text: \" in\",\n startMs: 3320,\n endMs: 3420,\n timestampMs: 3370,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 3420,\n endMs: 3520,\n timestampMs: 3470,\n confidence: 0.97,\n }, {\n text: \" first\",\n startMs: 3520,\n endMs: 3820,\n timestampMs: 3670,\n confidence: 0.97,\n }, {\n text: \" three\",\n startMs: 3820,\n endMs: 4100,\n timestampMs: 3960,\n confidence: 0.97,\n }, {\n text: \" seconds.\",\n startMs: 4100,\n endMs: 4780,\n timestampMs: 4440,\n confidence: 0.97,\n }, {\n text: \" Captions\",\n startMs: 5400,\n endMs: 5920,\n timestampMs: 5660,\n confidence: 0.97,\n }, {\n text: \" keep\",\n startMs: 5920,\n endMs: 6140,\n timestampMs: 6030,\n confidence: 0.97,\n }, {\n text: \" them\",\n startMs: 6140,\n endMs: 6300,\n timestampMs: 6220,\n confidence: 0.97,\n }, {\n text: \" watching,\",\n startMs: 6300,\n endMs: 6860,\n timestampMs: 6580,\n confidence: 0.97,\n }, {\n text: \" even\",\n startMs: 6960,\n endMs: 7180,\n timestampMs: 7070,\n confidence: 0.97,\n }, {\n text: \" with\",\n startMs: 7180,\n endMs: 7320,\n timestampMs: 7250,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 7320,\n endMs: 7420,\n timestampMs: 7370,\n confidence: 0.97,\n }, {\n text: \" sound\",\n startMs: 7420,\n endMs: 7760,\n timestampMs: 7590,\n confidence: 0.97,\n }, {\n text: \" off.\",\n startMs: 7760,\n endMs: 8300,\n timestampMs: 8030,\n confidence: 0.97,\n }],\n fontSize: 64,\n fontWeight: 800,\n color: \"#ffffff\",\n emphasisColor: \"#facc15\",\n emphasisScale: 1.7,\n combineTokensWithinMilliseconds: 1600,\n holdMs: 600,\n shadow: true,\n};\n\ntype CaptionStackElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof CaptionStackBase>;\n\nconst CaptionStackInner = forwardRef<\n HTMLDivElement,\n CaptionStackElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<CaptionStack>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <CaptionStackBase\n {...(componentProps as unknown as ComponentProps<typeof CaptionStackBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const CaptionStack = Interactive.withSchema({\n Component: CaptionStackInner,\n componentName: \"<CaptionStack>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"+ },+ "durationInFrames": 279+}diff --git a/registry-artifacts/elements/caption-stamp.json b/registry-artifacts/elements/caption-stamp.jsonnew file mode 100644index 00000000..09973f28--- /dev/null+++ b/registry-artifacts/elements/caption-stamp.json@@ -0,0 +1,21 @@+{+ "type": "remotion-element",+ "version": 1,+ "element": {+ "assets": [],+ "dependencies": [+ {+ "name": "@remotion/captions",+ "version": null+ }+ ],+ "dimensions": null,+ "displayName": "Caption Stamp",+ "durationInFrames": 279,+ "initialProps": null,+ "installationMode": "component-owned-sequence",+ "slug": "caption-stamp",+ "sourceCode": "import { Fragment, forwardRef, useId, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState, type ComponentProps } from \"react\";\nimport { Easing, Interactive, Sequence, interpolate, random, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { createTikTokStyleCaptions, type Caption, type TikTokPage } from \"@remotion/captions\";\n\ntype SpeakerCaption = Caption & { speaker?: string };\n\ninterface CaptionBaseProps {\n captions: Caption[];\n combineTokensWithinMilliseconds?: number;\n holdMs?: number;\n fontSize?: number;\n fontWeight?: number;\n color?: string;\n className?: string;\n}\n\nconst DEFAULT_HOLD_MS = 600;\nconst MIN_SILENCE_BREAK_MS = 300;\n\ninterface CaptionPageWindow {\n page: TikTokPage;\n index: number;\n speaker: string | undefined;\n startMs: number;\n speechEndMs: number;\n endMs: number;\n endsInSilence: boolean;\n}\n\ntype CaptionTokenStatus = \"upcoming\" | \"active\" | \"spoken\";\n\ninterface CaptionTokenState {\n text: string;\n spaceBefore: boolean;\n fromMs: number;\n toMs: number;\n progress: number;\n status: CaptionTokenStatus;\n}\n\ninterface CaptionPreviousPage {\n page: TikTokPage;\n pageIndex: number;\n tokens: CaptionTokenState[];\n}\n\ninterface CaptionsState {\n page: TikTokPage;\n pageIndex: number;\n speaker: string | undefined;\n timeMs: number;\n activeIndex: number;\n tokens: CaptionTokenState[];\n sinceStartMs: number;\n untilEndMs: number;\n holdRoomMs: number;\n endsInSilence: boolean;\n previous: CaptionPreviousPage | null;\n}\n\ninterface CaptionPagingOptions {\n combineTokensWithinMilliseconds: number;\n holdMs?: number;\n}\n\nconst SENTENCE_END = /[.!?…][\"')\\]]*$/;\n\nfunction markPageBreaks(captions: SpeakerCaption[]): Caption[] {\n return captions.map((caption, i) => {\n if (caption.pageBreakAfter !== undefined) return caption;\n const next = captions[i + 1];\n const speakerChanges =\n next !== undefined && next.speaker !== caption.speaker;\n return speakerChanges || SENTENCE_END.test(caption.text.trim())\n ? { ...caption, pageBreakAfter: true }\n : caption;\n });\n}\n\nfunction buildCaptionPages(\n captions: SpeakerCaption[],\n {\n combineTokensWithinMilliseconds,\n holdMs = DEFAULT_HOLD_MS,\n }: CaptionPagingOptions,\n): CaptionPageWindow[] {\n if (captions.length === 0) return [];\n const { pages } = createTikTokStyleCaptions({\n captions: markPageBreaks(captions),\n combineTokensWithinMilliseconds,\n breakOnSilenceAfterMilliseconds: Math.max(holdMs, MIN_SILENCE_BREAK_MS),\n });\n const speakers = new Map<number, string | undefined>();\n for (const caption of captions) {\n if (!speakers.has(caption.startMs)) {\n speakers.set(caption.startMs, caption.speaker);\n }\n }\n const spoken = pages.filter((page) => page.tokens.length > 0);\n return spoken.map((page, index) => {\n const last = page.tokens[page.tokens.length - 1];\n const speechEndMs = last ? last.toMs : page.startMs;\n const heldUntil = speechEndMs + Math.max(0, holdMs);\n const next = spoken[index + 1];\n const endsInSilence = !next || next.startMs > heldUntil;\n const endMs = endsInSilence\n ? heldUntil\n : Math.max(page.startMs, next.startMs);\n return {\n page,\n index,\n speaker: speakers.get(page.tokens[0].fromMs),\n startMs: page.startMs,\n speechEndMs,\n endMs,\n endsInSilence,\n };\n });\n}\n\nfunction findWindowIndex(windows: CaptionPageWindow[], timeMs: number): number {\n let lo = 0;\n let hi = windows.length - 1;\n let found = -1;\n while (lo <= hi) {\n const mid = (lo + hi) >> 1;\n if (windows[mid].startMs <= timeMs) {\n found = mid;\n lo = mid + 1;\n } else {\n hi = mid - 1;\n }\n }\n if (found === -1) return -1;\n return timeMs < windows[found].endMs ? found : -1;\n}\n\nfunction tokenProgress(fromMs: number, toMs: number, timeMs: number): number {\n if (timeMs < fromMs) return 0;\n if (toMs <= fromMs) return 1;\n return Math.min(1, (timeMs - fromMs) / (toMs - fromMs));\n}\n\nfunction getTokenStates(\n page: TikTokPage,\n timeMs: number,\n): { activeIndex: number; tokens: CaptionTokenState[] } {\n let activeIndex = -1;\n page.tokens.forEach((token, i) => {\n if (token.fromMs <= timeMs) activeIndex = i;\n });\n const tokens = page.tokens.map(\n (token, i): CaptionTokenState => ({\n text: token.text.trim(),\n spaceBefore: i > 0 && /^\\s/.test(token.text),\n fromMs: token.fromMs,\n toMs: token.toMs,\n progress: tokenProgress(token.fromMs, token.toMs, timeMs),\n status:\n i < activeIndex ? \"spoken\" : i === activeIndex ? \"active\" : \"upcoming\",\n }),\n );\n return { activeIndex, tokens };\n}\n\nfunction getCaptionsState(\n windows: CaptionPageWindow[],\n timeMs: number,\n): CaptionsState | null {\n const found = findWindowIndex(windows, timeMs);\n if (found === -1) return null;\n const window = windows[found];\n const { activeIndex, tokens } = getTokenStates(window.page, timeMs);\n const before = found > 0 ? windows[found - 1] : null;\n const previous =\n before && !before.endsInSilence\n ? {\n page: before.page,\n pageIndex: before.index,\n tokens: getTokenStates(before.page, before.endMs).tokens,\n }\n : null;\n return {\n page: window.page,\n pageIndex: window.index,\n speaker: window.speaker,\n timeMs,\n activeIndex,\n tokens,\n sinceStartMs: timeMs - window.startMs,\n untilEndMs: window.endMs - timeMs,\n holdRoomMs: window.endMs - window.speechEndMs,\n endsInSilence: window.endsInSilence,\n previous,\n };\n}\n\nfunction getExitWindowMs(state: CaptionsState, exitMs: number): number {\n return Math.max(1, Math.min(exitMs, state.holdRoomMs));\n}\n\nfunction groupCaptionWords(\n tokens: CaptionTokenState[],\n): { index: number; token: CaptionTokenState }[][] {\n const words: { index: number; token: CaptionTokenState }[][] = [];\n tokens.forEach((token, index) => {\n const current = words[words.length - 1];\n if (!current || token.spaceBefore) {\n words.push([{ index, token }]);\n } else {\n current.push({ index, token });\n }\n });\n return words;\n}\n\nfunction normalizeCaptionWord(text: string): string {\n return text\n .toLowerCase()\n .replace(/[\\u2018\\u2019]/g, \"'\")\n .replace(/[^\\p{L}\\p{N}']/gu, \"\");\n}\n\nfunction createKeywordMatcher(\n keywords: readonly string[] = [],\n): (text: string) => boolean {\n const set = new Set(keywords.map(normalizeCaptionWord).filter(Boolean));\n return (text) => set.has(normalizeCaptionWord(text));\n}\n\nfunction captionWordText(word: { token: CaptionTokenState }[]): string {\n return word.map(({ token }) => token.text).join(\"\");\n}\n\ninterface CaptionWordRect {\n left: number;\n top: number;\n width: number;\n height: number;\n}\n\nfunction sameRects(a: CaptionWordRect[], b: CaptionWordRect[]): boolean {\n return (\n a.length === b.length &&\n a.every(\n (r, i) =>\n r.left === b[i].left &&\n r.top === b[i].top &&\n r.width === b[i].width &&\n r.height === b[i].height,\n )\n );\n}\n\nfunction useCaptionWordRects(\n pageIndex: number,\n count: number,\n): {\n wordRef: (index: number) => (el: HTMLElement | null) => void;\n rects: CaptionWordRect[] | null;\n} {\n const elements = useRef<(HTMLElement | null)[]>([]);\n const [measured, setMeasured] = useState<{\n pageIndex: number;\n rects: CaptionWordRect[];\n } | null>(null);\n\n useLayoutEffect(() => {\n if (pageIndex === -1) return;\n const rects = elements.current.slice(0, count).map((el) =>\n el\n ? {\n left: el.offsetLeft,\n top: el.offsetTop,\n width: el.offsetWidth,\n height: el.offsetHeight,\n }\n : { left: 0, top: 0, width: 0, height: 0 },\n );\n setMeasured((prev) =>\n prev && prev.pageIndex === pageIndex && sameRects(prev.rects, rects)\n ? prev\n : { pageIndex, rects },\n );\n });\n\n return {\n wordRef: (index) => (el) => {\n elements.current[index] = el;\n },\n rects: measured && measured.pageIndex === pageIndex ? measured.rects : null,\n };\n}\n\nfunction useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs = DEFAULT_HOLD_MS,\n}: {\n captions: SpeakerCaption[];\n combineTokensWithinMilliseconds: number;\n holdMs?: number;\n}): CaptionsState | null {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const windows = useMemo(\n () =>\n buildCaptionPages(captions, { combineTokensWithinMilliseconds, holdMs }),\n [captions, combineTokensWithinMilliseconds, holdMs],\n );\n return getCaptionsState(windows, (frame / fps) * 1000);\n}\n\ninterface CaptionStampProps extends CaptionBaseProps {\n keywords?: string[];\n stampColor?: string;\n texture?: boolean;\n shadow?: boolean;\n}\n\nconst ENTER_MS = 160;\nconst EXIT_MS = 220;\nconst RISE_EM = 0.14;\nconst SLAM_MS = 90;\nconst SETTLE_MS = 170;\nconst INK_MS = 50;\nconst PAD_EM = 0.16;\nconst BORDER_EM = 0.06;\nconst RADIUS_EM = 0.08;\nconst LEGIBILITY_SHADOW =\n \"0 2px 3px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.35)\";\n\nconst enterEasing = Easing.bezier(0.2, 0.8, 0.2, 1);\nconst slamEasing = Easing.in(Easing.quad);\nconst settleEasing = Easing.out(Easing.quad);\n\nconst clamp = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n} as const;\n\nfunction stampScale(sinceMs: number): number {\n if (sinceMs <= SLAM_MS) {\n return interpolate(sinceMs, [0, SLAM_MS], [1.8, 0.96], {\n ...clamp,\n easing: slamEasing,\n });\n }\n return interpolate(sinceMs, [SLAM_MS, SETTLE_MS], [0.96, 1], {\n ...clamp,\n easing: settleEasing,\n });\n}\n\nfunction CaptionStampBase({\n captions,\n combineTokensWithinMilliseconds = 1200,\n holdMs = DEFAULT_HOLD_MS,\n fontSize = 64,\n fontWeight = 800,\n color = \"#ffffff\",\n keywords,\n stampColor = \"#ef4444\",\n texture = true,\n shadow = true,\n className,\n}: CaptionStampProps) {\n const filterId = `caption-stamp-${useId().replace(/[^a-zA-Z0-9_-]/g, \"\")}`;\n const state = useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs,\n });\n if (!state) return null;\n\n const enter = interpolate(\n state.previous ? ENTER_MS : state.sinceStartMs,\n [0, ENTER_MS],\n [0, 1],\n { ...clamp, easing: enterEasing },\n );\n const exit = state.endsInSilence\n ? interpolate(\n state.untilEndMs,\n [0, getExitWindowMs(state, EXIT_MS)],\n [0, 1],\n clamp,\n )\n : 1;\n\n const words = groupCaptionWords(state.tokens);\n const isKeyword = createKeywordMatcher(keywords);\n const byKeyword = keywords !== undefined && keywords.length > 0;\n let longest = -1;\n let longestLength = 0;\n if (!byKeyword) {\n words.forEach((word, w) => {\n const length = normalizeCaptionWord(captionWordText(word)).length;\n if (length > longestLength) {\n longest = w;\n longestLength = length;\n }\n });\n }\n const textShadow = shadow ? LEGIBILITY_SHADOW : undefined;\n\n return (\n <div\n className={className}\n style={{\n position: \"relative\",\n fontSize,\n fontWeight,\n color,\n lineHeight: 1.2,\n textAlign: \"center\",\n opacity: Math.min(enter, exit),\n transform: `translateY(${(1 - enter) * RISE_EM}em)`,\n }}\n >\n {texture && (\n <svg\n aria-hidden\n width={0}\n height={0}\n style={{ position: \"absolute\", overflow: \"hidden\" }}\n >\n <filter id={filterId} x=\"-10%\" y=\"-20%\" width=\"120%\" height=\"140%\">\n <feTurbulence\n type=\"fractalNoise\"\n baseFrequency=\"0.45\"\n numOctaves={2}\n seed={4}\n result=\"warp\"\n />\n <feDisplacementMap\n in=\"SourceGraphic\"\n in2=\"warp\"\n scale={fontSize * 0.035}\n xChannelSelector=\"R\"\n yChannelSelector=\"G\"\n result=\"rough\"\n />\n <feTurbulence\n type=\"fractalNoise\"\n baseFrequency=\"0.8\"\n numOctaves={1}\n seed={9}\n result=\"grain\"\n />\n <feColorMatrix\n in=\"grain\"\n type=\"matrix\"\n values=\"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -10 6.8\"\n result=\"holes\"\n />\n <feComposite in=\"rough\" in2=\"holes\" operator=\"in\" />\n </filter>\n </svg>\n )}\n {words.map((word, w) => {\n const key = `${state.pageIndex}-${word[0].index}`;\n const text = captionWordText(word);\n const stamped = byKeyword ? isKeyword(text) : w === longest;\n if (!stamped) {\n return (\n <Fragment key={key}>\n {w > 0 && \" \"}\n <span\n style={{\n display: \"inline-block\",\n whiteSpace: \"nowrap\",\n textShadow,\n }}\n >\n {text}\n </span>\n </Fragment>\n );\n }\n const sinceMs = state.timeMs - word[0].token.fromMs;\n const rotation =\n -8 + random(`caption-stamp-${state.pageIndex}-${word[0].index}`) * 5;\n return (\n <Fragment key={key}>\n {w > 0 && \" \"}\n <span\n style={{\n position: \"relative\",\n display: \"inline-block\",\n whiteSpace: \"nowrap\",\n }}\n >\n <span\n style={{\n opacity: interpolate(\n sinceMs,\n [SLAM_MS * 0.6, SLAM_MS],\n [1, 0],\n clamp,\n ),\n textShadow,\n }}\n >\n {text}\n </span>\n {sinceMs >= 0 && (\n <span\n aria-hidden\n style={{\n position: \"absolute\",\n left: `-${PAD_EM}em`,\n right: `-${PAD_EM}em`,\n top: \"8%\",\n bottom: \"4%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n lineHeight: 1,\n color: stampColor,\n border: `${BORDER_EM}em solid ${stampColor}`,\n borderRadius: `${RADIUS_EM}em`,\n opacity: interpolate(sinceMs, [0, INK_MS], [0, 1], clamp),\n transform: `rotate(${rotation}deg) scale(${stampScale(sinceMs)})`,\n filter: texture ? `url(#${filterId})` : undefined,\n }}\n >\n {text}\n </span>\n )}\n </span>\n </Fragment>\n );\n })}\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n captions: {\n type: \"remotion-captions\",\n default: [{\n text: \" So\",\n startMs: 300,\n endMs: 460,\n timestampMs: 380,\n confidence: 0.97,\n }, {\n text: \" here's\",\n startMs: 460,\n endMs: 700,\n timestampMs: 580,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 700,\n endMs: 820,\n timestampMs: 760,\n confidence: 0.97,\n }, {\n text: \" thing.\",\n startMs: 820,\n endMs: 1240,\n timestampMs: 1030,\n confidence: 0.97,\n }, {\n text: \" Most\",\n startMs: 1700,\n endMs: 1960,\n timestampMs: 1830,\n confidence: 0.97,\n }, {\n text: \" demo\",\n startMs: 1960,\n endMs: 2240,\n timestampMs: 2100,\n confidence: 0.97,\n }, {\n text: \" videos\",\n startMs: 2240,\n endMs: 2680,\n timestampMs: 2460,\n confidence: 0.97,\n }, {\n text: \" lose\",\n startMs: 2680,\n endMs: 2960,\n timestampMs: 2820,\n confidence: 0.97,\n }, {\n text: \" people\",\n startMs: 2960,\n endMs: 3320,\n timestampMs: 3140,\n confidence: 0.97,\n }, {\n text: \" in\",\n startMs: 3320,\n endMs: 3420,\n timestampMs: 3370,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 3420,\n endMs: 3520,\n timestampMs: 3470,\n confidence: 0.97,\n }, {\n text: \" first\",\n startMs: 3520,\n endMs: 3820,\n timestampMs: 3670,\n confidence: 0.97,\n }, {\n text: \" three\",\n startMs: 3820,\n endMs: 4100,\n timestampMs: 3960,\n confidence: 0.97,\n }, {\n text: \" seconds.\",\n startMs: 4100,\n endMs: 4780,\n timestampMs: 4440,\n confidence: 0.97,\n }, {\n text: \" Captions\",\n startMs: 5400,\n endMs: 5920,\n timestampMs: 5660,\n confidence: 0.97,\n }, {\n text: \" keep\",\n startMs: 5920,\n endMs: 6140,\n timestampMs: 6030,\n confidence: 0.97,\n }, {\n text: \" them\",\n startMs: 6140,\n endMs: 6300,\n timestampMs: 6220,\n confidence: 0.97,\n }, {\n text: \" watching,\",\n startMs: 6300,\n endMs: 6860,\n timestampMs: 6580,\n confidence: 0.97,\n }, {\n text: \" even\",\n startMs: 6960,\n endMs: 7180,\n timestampMs: 7070,\n confidence: 0.97,\n }, {\n text: \" with\",\n startMs: 7180,\n endMs: 7320,\n timestampMs: 7250,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 7320,\n endMs: 7420,\n timestampMs: 7370,\n confidence: 0.97,\n }, {\n text: \" sound\",\n startMs: 7420,\n endMs: 7760,\n timestampMs: 7590,\n confidence: 0.97,\n }, {\n text: \" off.\",\n startMs: 7760,\n endMs: 8300,\n timestampMs: 8030,\n confidence: 0.97,\n }],\n description: \"Transcript\",\n keyframable: false,\n },\n fontSize: {\n type: \"number\",\n min: 24,\n max: 140,\n step: 1,\n default: 64,\n description: \"Font size\",\n hiddenFromList: false,\n },\n fontWeight: {\n type: \"number\",\n min: 400,\n max: 900,\n step: 100,\n default: 800,\n description: \"Font weight\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#ffffff\",\n description: \"Text color\",\n },\n stampColor: {\n type: \"color\",\n default: \"#ef4444\",\n description: \"Stamp color\",\n },\n texture: {\n type: \"boolean\",\n default: true,\n description: \"Ink texture\",\n },\n combineTokensWithinMilliseconds: {\n type: \"number\",\n min: 0,\n max: 3000,\n step: 100,\n default: 1200,\n description: \"Page window (ms)\",\n hiddenFromList: false,\n },\n holdMs: {\n type: \"number\",\n min: 0,\n max: 2000,\n step: 50,\n default: 600,\n description: \"Hold (ms)\",\n hiddenFromList: false,\n },\n shadow: {\n type: \"boolean\",\n default: true,\n description: \"Shadow\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"captions\",\"fontSize\",\"fontWeight\",\"color\",\"stampColor\",\"texture\",\"combineTokensWithinMilliseconds\",\"holdMs\",\"shadow\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n captions: [{\n text: \" So\",\n startMs: 300,\n endMs: 460,\n timestampMs: 380,\n confidence: 0.97,\n }, {\n text: \" here's\",\n startMs: 460,\n endMs: 700,\n timestampMs: 580,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 700,\n endMs: 820,\n timestampMs: 760,\n confidence: 0.97,\n }, {\n text: \" thing.\",\n startMs: 820,\n endMs: 1240,\n timestampMs: 1030,\n confidence: 0.97,\n }, {\n text: \" Most\",\n startMs: 1700,\n endMs: 1960,\n timestampMs: 1830,\n confidence: 0.97,\n }, {\n text: \" demo\",\n startMs: 1960,\n endMs: 2240,\n timestampMs: 2100,\n confidence: 0.97,\n }, {\n text: \" videos\",\n startMs: 2240,\n endMs: 2680,\n timestampMs: 2460,\n confidence: 0.97,\n }, {\n text: \" lose\",\n startMs: 2680,\n endMs: 2960,\n timestampMs: 2820,\n confidence: 0.97,\n }, {\n text: \" people\",\n startMs: 2960,\n endMs: 3320,\n timestampMs: 3140,\n confidence: 0.97,\n }, {\n text: \" in\",\n startMs: 3320,\n endMs: 3420,\n timestampMs: 3370,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 3420,\n endMs: 3520,\n timestampMs: 3470,\n confidence: 0.97,\n }, {\n text: \" first\",\n startMs: 3520,\n endMs: 3820,\n timestampMs: 3670,\n confidence: 0.97,\n }, {\n text: \" three\",\n startMs: 3820,\n endMs: 4100,\n timestampMs: 3960,\n confidence: 0.97,\n }, {\n text: \" seconds.\",\n startMs: 4100,\n endMs: 4780,\n timestampMs: 4440,\n confidence: 0.97,\n }, {\n text: \" Captions\",\n startMs: 5400,\n endMs: 5920,\n timestampMs: 5660,\n confidence: 0.97,\n }, {\n text: \" keep\",\n startMs: 5920,\n endMs: 6140,\n timestampMs: 6030,\n confidence: 0.97,\n }, {\n text: \" them\",\n startMs: 6140,\n endMs: 6300,\n timestampMs: 6220,\n confidence: 0.97,\n }, {\n text: \" watching,\",\n startMs: 6300,\n endMs: 6860,\n timestampMs: 6580,\n confidence: 0.97,\n }, {\n text: \" even\",\n startMs: 6960,\n endMs: 7180,\n timestampMs: 7070,\n confidence: 0.97,\n }, {\n text: \" with\",\n startMs: 7180,\n endMs: 7320,\n timestampMs: 7250,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 7320,\n endMs: 7420,\n timestampMs: 7370,\n confidence: 0.97,\n }, {\n text: \" sound\",\n startMs: 7420,\n endMs: 7760,\n timestampMs: 7590,\n confidence: 0.97,\n }, {\n text: \" off.\",\n startMs: 7760,\n endMs: 8300,\n timestampMs: 8030,\n confidence: 0.97,\n }],\n fontSize: 64,\n fontWeight: 800,\n color: \"#ffffff\",\n stampColor: \"#ef4444\",\n texture: true,\n combineTokensWithinMilliseconds: 1200,\n holdMs: 600,\n shadow: true,\n};\n\ntype CaptionStampElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof CaptionStampBase>;\n\nconst CaptionStampInner = forwardRef<\n HTMLDivElement,\n CaptionStampElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<CaptionStamp>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <CaptionStampBase\n {...(componentProps as unknown as ComponentProps<typeof CaptionStampBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const CaptionStamp = Interactive.withSchema({\n Component: CaptionStampInner,\n componentName: \"<CaptionStamp>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"+ },+ "durationInFrames": 279+}diff --git a/registry-artifacts/elements/caption-subtitle.json b/registry-artifacts/elements/caption-subtitle.jsonnew file mode 100644index 00000000..3b4a92a2--- /dev/null+++ b/registry-artifacts/elements/caption-subtitle.json@@ -0,0 +1,21 @@+{+ "type": "remotion-element",+ "version": 1,+ "element": {+ "assets": [],+ "dependencies": [+ {+ "name": "@remotion/captions",+ "version": null+ }+ ],+ "dimensions": null,+ "displayName": "Caption Subtitle",+ "durationInFrames": 279,+ "initialProps": null,+ "installationMode": "component-owned-sequence",+ "slug": "caption-subtitle",+ "sourceCode": "import { Interactive, Sequence, interpolate, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { createTikTokStyleCaptions, type Caption, type TikTokPage } from \"@remotion/captions\";\nimport { forwardRef, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState, type ComponentProps } from \"react\";\n\ntype SpeakerCaption = Caption & { speaker?: string };\n\ninterface CaptionBaseProps {\n captions: Caption[];\n combineTokensWithinMilliseconds?: number;\n holdMs?: number;\n fontSize?: number;\n fontWeight?: number;\n color?: string;\n className?: string;\n}\n\nconst DEFAULT_HOLD_MS = 600;\nconst MIN_SILENCE_BREAK_MS = 300;\n\ninterface CaptionPageWindow {\n page: TikTokPage;\n index: number;\n speaker: string | undefined;\n startMs: number;\n speechEndMs: number;\n endMs: number;\n endsInSilence: boolean;\n}\n\ntype CaptionTokenStatus = \"upcoming\" | \"active\" | \"spoken\";\n\ninterface CaptionTokenState {\n text: string;\n spaceBefore: boolean;\n fromMs: number;\n toMs: number;\n progress: number;\n status: CaptionTokenStatus;\n}\n\ninterface CaptionPreviousPage {\n page: TikTokPage;\n pageIndex: number;\n tokens: CaptionTokenState[];\n}\n\ninterface CaptionsState {\n page: TikTokPage;\n pageIndex: number;\n speaker: string | undefined;\n timeMs: number;\n activeIndex: number;\n tokens: CaptionTokenState[];\n sinceStartMs: number;\n untilEndMs: number;\n holdRoomMs: number;\n endsInSilence: boolean;\n previous: CaptionPreviousPage | null;\n}\n\ninterface CaptionPagingOptions {\n combineTokensWithinMilliseconds: number;\n holdMs?: number;\n}\n\nconst SENTENCE_END = /[.!?…][\"')\\]]*$/;\n\nfunction markPageBreaks(captions: SpeakerCaption[]): Caption[] {\n return captions.map((caption, i) => {\n if (caption.pageBreakAfter !== undefined) return caption;\n const next = captions[i + 1];\n const speakerChanges =\n next !== undefined && next.speaker !== caption.speaker;\n return speakerChanges || SENTENCE_END.test(caption.text.trim())\n ? { ...caption, pageBreakAfter: true }\n : caption;\n });\n}\n\nfunction buildCaptionPages(\n captions: SpeakerCaption[],\n {\n combineTokensWithinMilliseconds,\n holdMs = DEFAULT_HOLD_MS,\n }: CaptionPagingOptions,\n): CaptionPageWindow[] {\n if (captions.length === 0) return [];\n const { pages } = createTikTokStyleCaptions({\n captions: markPageBreaks(captions),\n combineTokensWithinMilliseconds,\n breakOnSilenceAfterMilliseconds: Math.max(holdMs, MIN_SILENCE_BREAK_MS),\n });\n const speakers = new Map<number, string | undefined>();\n for (const caption of captions) {\n if (!speakers.has(caption.startMs)) {\n speakers.set(caption.startMs, caption.speaker);\n }\n }\n const spoken = pages.filter((page) => page.tokens.length > 0);\n return spoken.map((page, index) => {\n const last = page.tokens[page.tokens.length - 1];\n const speechEndMs = last ? last.toMs : page.startMs;\n const heldUntil = speechEndMs + Math.max(0, holdMs);\n const next = spoken[index + 1];\n const endsInSilence = !next || next.startMs > heldUntil;\n const endMs = endsInSilence\n ? heldUntil\n : Math.max(page.startMs, next.startMs);\n return {\n page,\n index,\n speaker: speakers.get(page.tokens[0].fromMs),\n startMs: page.startMs,\n speechEndMs,\n endMs,\n endsInSilence,\n };\n });\n}\n\nfunction findWindowIndex(windows: CaptionPageWindow[], timeMs: number): number {\n let lo = 0;\n let hi = windows.length - 1;\n let found = -1;\n while (lo <= hi) {\n const mid = (lo + hi) >> 1;\n if (windows[mid].startMs <= timeMs) {\n found = mid;\n lo = mid + 1;\n } else {\n hi = mid - 1;\n }\n }\n if (found === -1) return -1;\n return timeMs < windows[found].endMs ? found : -1;\n}\n\nfunction tokenProgress(fromMs: number, toMs: number, timeMs: number): number {\n if (timeMs < fromMs) return 0;\n if (toMs <= fromMs) return 1;\n return Math.min(1, (timeMs - fromMs) / (toMs - fromMs));\n}\n\nfunction getTokenStates(\n page: TikTokPage,\n timeMs: number,\n): { activeIndex: number; tokens: CaptionTokenState[] } {\n let activeIndex = -1;\n page.tokens.forEach((token, i) => {\n if (token.fromMs <= timeMs) activeIndex = i;\n });\n const tokens = page.tokens.map(\n (token, i): CaptionTokenState => ({\n text: token.text.trim(),\n spaceBefore: i > 0 && /^\\s/.test(token.text),\n fromMs: token.fromMs,\n toMs: token.toMs,\n progress: tokenProgress(token.fromMs, token.toMs, timeMs),\n status:\n i < activeIndex ? \"spoken\" : i === activeIndex ? \"active\" : \"upcoming\",\n }),\n );\n return { activeIndex, tokens };\n}\n\nfunction getCaptionsState(\n windows: CaptionPageWindow[],\n timeMs: number,\n): CaptionsState | null {\n const found = findWindowIndex(windows, timeMs);\n if (found === -1) return null;\n const window = windows[found];\n const { activeIndex, tokens } = getTokenStates(window.page, timeMs);\n const before = found > 0 ? windows[found - 1] : null;\n const previous =\n before && !before.endsInSilence\n ? {\n page: before.page,\n pageIndex: before.index,\n tokens: getTokenStates(before.page, before.endMs).tokens,\n }\n : null;\n return {\n page: window.page,\n pageIndex: window.index,\n speaker: window.speaker,\n timeMs,\n activeIndex,\n tokens,\n sinceStartMs: timeMs - window.startMs,\n untilEndMs: window.endMs - timeMs,\n holdRoomMs: window.endMs - window.speechEndMs,\n endsInSilence: window.endsInSilence,\n previous,\n };\n}\n\nfunction getExitWindowMs(state: CaptionsState, exitMs: number): number {\n return Math.max(1, Math.min(exitMs, state.holdRoomMs));\n}\n\nfunction groupCaptionWords(\n tokens: CaptionTokenState[],\n): { index: number; token: CaptionTokenState }[][] {\n const words: { index: number; token: CaptionTokenState }[][] = [];\n tokens.forEach((token, index) => {\n const current = words[words.length - 1];\n if (!current || token.spaceBefore) {\n words.push([{ index, token }]);\n } else {\n current.push({ index, token });\n }\n });\n return words;\n}\n\nfunction normalizeCaptionWord(text: string): string {\n return text\n .toLowerCase()\n .replace(/[\\u2018\\u2019]/g, \"'\")\n .replace(/[^\\p{L}\\p{N}']/gu, \"\");\n}\n\nfunction createKeywordMatcher(\n keywords: readonly string[] = [],\n): (text: string) => boolean {\n const set = new Set(keywords.map(normalizeCaptionWord).filter(Boolean));\n return (text) => set.has(normalizeCaptionWord(text));\n}\n\nfunction captionWordText(word: { token: CaptionTokenState }[]): string {\n return word.map(({ token }) => token.text).join(\"\");\n}\n\ninterface CaptionWordRect {\n left: number;\n top: number;\n width: number;\n height: number;\n}\n\nfunction sameRects(a: CaptionWordRect[], b: CaptionWordRect[]): boolean {\n return (\n a.length === b.length &&\n a.every(\n (r, i) =>\n r.left === b[i].left &&\n r.top === b[i].top &&\n r.width === b[i].width &&\n r.height === b[i].height,\n )\n );\n}\n\nfunction useCaptionWordRects(\n pageIndex: number,\n count: number,\n): {\n wordRef: (index: number) => (el: HTMLElement | null) => void;\n rects: CaptionWordRect[] | null;\n} {\n const elements = useRef<(HTMLElement | null)[]>([]);\n const [measured, setMeasured] = useState<{\n pageIndex: number;\n rects: CaptionWordRect[];\n } | null>(null);\n\n useLayoutEffect(() => {\n if (pageIndex === -1) return;\n const rects = elements.current.slice(0, count).map((el) =>\n el\n ? {\n left: el.offsetLeft,\n top: el.offsetTop,\n width: el.offsetWidth,\n height: el.offsetHeight,\n }\n : { left: 0, top: 0, width: 0, height: 0 },\n );\n setMeasured((prev) =>\n prev && prev.pageIndex === pageIndex && sameRects(prev.rects, rects)\n ? prev\n : { pageIndex, rects },\n );\n });\n\n return {\n wordRef: (index) => (el) => {\n elements.current[index] = el;\n },\n rects: measured && measured.pageIndex === pageIndex ? measured.rects : null,\n };\n}\n\nfunction useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs = DEFAULT_HOLD_MS,\n}: {\n captions: SpeakerCaption[];\n combineTokensWithinMilliseconds: number;\n holdMs?: number;\n}): CaptionsState | null {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const windows = useMemo(\n () =>\n buildCaptionPages(captions, { combineTokensWithinMilliseconds, holdMs }),\n [captions, combineTokensWithinMilliseconds, holdMs],\n );\n return getCaptionsState(windows, (frame / fps) * 1000);\n}\n\ninterface CaptionSubtitleProps extends CaptionBaseProps {\n box?: boolean;\n boxColor?: string;\n boxOpacity?: number;\n}\n\nconst ENTER_MS = 120;\nconst EXIT_MS = 160;\nconst LEGIBILITY_SHADOW =\n \"0 2px 3px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.35)\";\n\nfunction CaptionSubtitleBase({\n captions,\n combineTokensWithinMilliseconds = 2500,\n holdMs = DEFAULT_HOLD_MS,\n fontSize = 44,\n fontWeight = 600,\n color = \"#ffffff\",\n box = true,\n boxColor = \"#000000\",\n boxOpacity = 0.72,\n className,\n}: CaptionSubtitleProps) {\n const state = useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs,\n });\n if (!state) return null;\n\n const enter = state.previous\n ? 1\n : interpolate(state.sinceStartMs, [0, ENTER_MS], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n });\n const exit = state.endsInSilence\n ? interpolate(\n state.untilEndMs,\n [0, getExitWindowMs(state, EXIT_MS)],\n [0, 1],\n {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n },\n )\n : 1;\n const opacityPercent = Math.round(Math.min(1, Math.max(0, boxOpacity)) * 100);\n\n return (\n <div\n className={className}\n style={{\n fontSize,\n fontWeight,\n color,\n lineHeight: 1.4,\n textAlign: \"center\",\n textWrap: \"balance\",\n opacity: Math.min(enter, exit),\n }}\n >\n <span\n style={\n box\n ? {\n backgroundColor: `color-mix(in srgb, ${boxColor} ${opacityPercent}%, transparent)`,\n padding: \"0.06em 0.36em\",\n borderRadius: \"0.16em\",\n boxDecorationBreak: \"clone\",\n WebkitBoxDecorationBreak: \"clone\",\n }\n : { textShadow: LEGIBILITY_SHADOW }\n }\n >\n {state.page.text}\n </span>\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n captions: {\n type: \"remotion-captions\",\n default: [{\n text: \" So\",\n startMs: 300,\n endMs: 460,\n timestampMs: 380,\n confidence: 0.97,\n }, {\n text: \" here's\",\n startMs: 460,\n endMs: 700,\n timestampMs: 580,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 700,\n endMs: 820,\n timestampMs: 760,\n confidence: 0.97,\n }, {\n text: \" thing.\",\n startMs: 820,\n endMs: 1240,\n timestampMs: 1030,\n confidence: 0.97,\n }, {\n text: \" Most\",\n startMs: 1700,\n endMs: 1960,\n timestampMs: 1830,\n confidence: 0.97,\n }, {\n text: \" demo\",\n startMs: 1960,\n endMs: 2240,\n timestampMs: 2100,\n confidence: 0.97,\n }, {\n text: \" videos\",\n startMs: 2240,\n endMs: 2680,\n timestampMs: 2460,\n confidence: 0.97,\n }, {\n text: \" lose\",\n startMs: 2680,\n endMs: 2960,\n timestampMs: 2820,\n confidence: 0.97,\n }, {\n text: \" people\",\n startMs: 2960,\n endMs: 3320,\n timestampMs: 3140,\n confidence: 0.97,\n }, {\n text: \" in\",\n startMs: 3320,\n endMs: 3420,\n timestampMs: 3370,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 3420,\n endMs: 3520,\n timestampMs: 3470,\n confidence: 0.97,\n }, {\n text: \" first\",\n startMs: 3520,\n endMs: 3820,\n timestampMs: 3670,\n confidence: 0.97,\n }, {\n text: \" three\",\n startMs: 3820,\n endMs: 4100,\n timestampMs: 3960,\n confidence: 0.97,\n }, {\n text: \" seconds.\",\n startMs: 4100,\n endMs: 4780,\n timestampMs: 4440,\n confidence: 0.97,\n }, {\n text: \" Captions\",\n startMs: 5400,\n endMs: 5920,\n timestampMs: 5660,\n confidence: 0.97,\n }, {\n text: \" keep\",\n startMs: 5920,\n endMs: 6140,\n timestampMs: 6030,\n confidence: 0.97,\n }, {\n text: \" them\",\n startMs: 6140,\n endMs: 6300,\n timestampMs: 6220,\n confidence: 0.97,\n }, {\n text: \" watching,\",\n startMs: 6300,\n endMs: 6860,\n timestampMs: 6580,\n confidence: 0.97,\n }, {\n text: \" even\",\n startMs: 6960,\n endMs: 7180,\n timestampMs: 7070,\n confidence: 0.97,\n }, {\n text: \" with\",\n startMs: 7180,\n endMs: 7320,\n timestampMs: 7250,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 7320,\n endMs: 7420,\n timestampMs: 7370,\n confidence: 0.97,\n }, {\n text: \" sound\",\n startMs: 7420,\n endMs: 7760,\n timestampMs: 7590,\n confidence: 0.97,\n }, {\n text: \" off.\",\n startMs: 7760,\n endMs: 8300,\n timestampMs: 8030,\n confidence: 0.97,\n }],\n description: \"Transcript\",\n keyframable: false,\n },\n fontSize: {\n type: \"number\",\n min: 16,\n max: 100,\n step: 1,\n default: 44,\n description: \"Font size\",\n hiddenFromList: false,\n },\n fontWeight: {\n type: \"number\",\n min: 400,\n max: 900,\n step: 100,\n default: 600,\n description: \"Font weight\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#ffffff\",\n description: \"Text color\",\n },\n combineTokensWithinMilliseconds: {\n type: \"number\",\n min: 0,\n max: 6000,\n step: 100,\n default: 2500,\n description: \"Page window (ms)\",\n hiddenFromList: false,\n },\n holdMs: {\n type: \"number\",\n min: 0,\n max: 2000,\n step: 50,\n default: 600,\n description: \"Hold (ms)\",\n hiddenFromList: false,\n },\n box: {\n type: \"boolean\",\n default: true,\n description: \"Box\",\n },\n boxColor: {\n type: \"color\",\n default: \"#000000\",\n description: \"Box color\",\n },\n boxOpacity: {\n type: \"number\",\n min: 0,\n max: 1,\n step: 0.02,\n default: 0.72,\n description: \"Box opacity\",\n hiddenFromList: false,\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"captions\",\"fontSize\",\"fontWeight\",\"color\",\"combineTokensWithinMilliseconds\",\"holdMs\",\"box\",\"boxColor\",\"boxOpacity\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n captions: [{\n text: \" So\",\n startMs: 300,\n endMs: 460,\n timestampMs: 380,\n confidence: 0.97,\n }, {\n text: \" here's\",\n startMs: 460,\n endMs: 700,\n timestampMs: 580,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 700,\n endMs: 820,\n timestampMs: 760,\n confidence: 0.97,\n }, {\n text: \" thing.\",\n startMs: 820,\n endMs: 1240,\n timestampMs: 1030,\n confidence: 0.97,\n }, {\n text: \" Most\",\n startMs: 1700,\n endMs: 1960,\n timestampMs: 1830,\n confidence: 0.97,\n }, {\n text: \" demo\",\n startMs: 1960,\n endMs: 2240,\n timestampMs: 2100,\n confidence: 0.97,\n }, {\n text: \" videos\",\n startMs: 2240,\n endMs: 2680,\n timestampMs: 2460,\n confidence: 0.97,\n }, {\n text: \" lose\",\n startMs: 2680,\n endMs: 2960,\n timestampMs: 2820,\n confidence: 0.97,\n }, {\n text: \" people\",\n startMs: 2960,\n endMs: 3320,\n timestampMs: 3140,\n confidence: 0.97,\n }, {\n text: \" in\",\n startMs: 3320,\n endMs: 3420,\n timestampMs: 3370,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 3420,\n endMs: 3520,\n timestampMs: 3470,\n confidence: 0.97,\n }, {\n text: \" first\",\n startMs: 3520,\n endMs: 3820,\n timestampMs: 3670,\n confidence: 0.97,\n }, {\n text: \" three\",\n startMs: 3820,\n endMs: 4100,\n timestampMs: 3960,\n confidence: 0.97,\n }, {\n text: \" seconds.\",\n startMs: 4100,\n endMs: 4780,\n timestampMs: 4440,\n confidence: 0.97,\n }, {\n text: \" Captions\",\n startMs: 5400,\n endMs: 5920,\n timestampMs: 5660,\n confidence: 0.97,\n }, {\n text: \" keep\",\n startMs: 5920,\n endMs: 6140,\n timestampMs: 6030,\n confidence: 0.97,\n }, {\n text: \" them\",\n startMs: 6140,\n endMs: 6300,\n timestampMs: 6220,\n confidence: 0.97,\n }, {\n text: \" watching,\",\n startMs: 6300,\n endMs: 6860,\n timestampMs: 6580,\n confidence: 0.97,\n }, {\n text: \" even\",\n startMs: 6960,\n endMs: 7180,\n timestampMs: 7070,\n confidence: 0.97,\n }, {\n text: \" with\",\n startMs: 7180,\n endMs: 7320,\n timestampMs: 7250,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 7320,\n endMs: 7420,\n timestampMs: 7370,\n confidence: 0.97,\n }, {\n text: \" sound\",\n startMs: 7420,\n endMs: 7760,\n timestampMs: 7590,\n confidence: 0.97,\n }, {\n text: \" off.\",\n startMs: 7760,\n endMs: 8300,\n timestampMs: 8030,\n confidence: 0.97,\n }],\n fontSize: 44,\n fontWeight: 600,\n color: \"#ffffff\",\n combineTokensWithinMilliseconds: 2500,\n holdMs: 600,\n box: true,\n boxColor: \"#000000\",\n boxOpacity: 0.72,\n};\n\ntype CaptionSubtitleElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof CaptionSubtitleBase>;\n\nconst CaptionSubtitleInner = forwardRef<\n HTMLDivElement,\n CaptionSubtitleElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<CaptionSubtitle>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <CaptionSubtitleBase\n {...(componentProps as unknown as ComponentProps<typeof CaptionSubtitleBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const CaptionSubtitle = Interactive.withSchema({\n Component: CaptionSubtitleInner,\n componentName: \"<CaptionSubtitle>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"+ },+ "durationInFrames": 279+}diff --git a/registry-artifacts/elements/caption-teleprompter.json b/registry-artifacts/elements/caption-teleprompter.jsonnew file mode 100644index 00000000..306539f7--- /dev/null+++ b/registry-artifacts/elements/caption-teleprompter.json@@ -0,0 +1,21 @@+{+ "type": "remotion-element",+ "version": 1,+ "element": {+ "assets": [],+ "dependencies": [+ {+ "name": "@remotion/captions",+ "version": null+ }+ ],+ "dimensions": null,+ "displayName": "Caption Teleprompter",+ "durationInFrames": 279,+ "initialProps": null,+ "installationMode": "component-owned-sequence",+ "slug": "caption-teleprompter",+ "sourceCode": "import { createTikTokStyleCaptions, type Caption, type TikTokPage } from \"@remotion/captions\";\nimport { Fragment, forwardRef, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState, type ComponentProps } from \"react\";\nimport { Easing, Interactive, Sequence, interpolate, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\n\ntype SpeakerCaption = Caption & { speaker?: string };\n\ninterface CaptionBaseProps {\n captions: Caption[];\n combineTokensWithinMilliseconds?: number;\n holdMs?: number;\n fontSize?: number;\n fontWeight?: number;\n color?: string;\n className?: string;\n}\n\nconst DEFAULT_HOLD_MS = 600;\nconst MIN_SILENCE_BREAK_MS = 300;\n\ninterface CaptionPageWindow {\n page: TikTokPage;\n index: number;\n speaker: string | undefined;\n startMs: number;\n speechEndMs: number;\n endMs: number;\n endsInSilence: boolean;\n}\n\ntype CaptionTokenStatus = \"upcoming\" | \"active\" | \"spoken\";\n\ninterface CaptionTokenState {\n text: string;\n spaceBefore: boolean;\n fromMs: number;\n toMs: number;\n progress: number;\n status: CaptionTokenStatus;\n}\n\ninterface CaptionPreviousPage {\n page: TikTokPage;\n pageIndex: number;\n tokens: CaptionTokenState[];\n}\n\ninterface CaptionsState {\n page: TikTokPage;\n pageIndex: number;\n speaker: string | undefined;\n timeMs: number;\n activeIndex: number;\n tokens: CaptionTokenState[];\n sinceStartMs: number;\n untilEndMs: number;\n holdRoomMs: number;\n endsInSilence: boolean;\n previous: CaptionPreviousPage | null;\n}\n\ninterface CaptionPagingOptions {\n combineTokensWithinMilliseconds: number;\n holdMs?: number;\n}\n\nconst SENTENCE_END = /[.!?…][\"')\\]]*$/;\n\nfunction markPageBreaks(captions: SpeakerCaption[]): Caption[] {\n return captions.map((caption, i) => {\n if (caption.pageBreakAfter !== undefined) return caption;\n const next = captions[i + 1];\n const speakerChanges =\n next !== undefined && next.speaker !== caption.speaker;\n return speakerChanges || SENTENCE_END.test(caption.text.trim())\n ? { ...caption, pageBreakAfter: true }\n : caption;\n });\n}\n\nfunction buildCaptionPages(\n captions: SpeakerCaption[],\n {\n combineTokensWithinMilliseconds,\n holdMs = DEFAULT_HOLD_MS,\n }: CaptionPagingOptions,\n): CaptionPageWindow[] {\n if (captions.length === 0) return [];\n const { pages } = createTikTokStyleCaptions({\n captions: markPageBreaks(captions),\n combineTokensWithinMilliseconds,\n breakOnSilenceAfterMilliseconds: Math.max(holdMs, MIN_SILENCE_BREAK_MS),\n });\n const speakers = new Map<number, string | undefined>();\n for (const caption of captions) {\n if (!speakers.has(caption.startMs)) {\n speakers.set(caption.startMs, caption.speaker);\n }\n }\n const spoken = pages.filter((page) => page.tokens.length > 0);\n return spoken.map((page, index) => {\n const last = page.tokens[page.tokens.length - 1];\n const speechEndMs = last ? last.toMs : page.startMs;\n const heldUntil = speechEndMs + Math.max(0, holdMs);\n const next = spoken[index + 1];\n const endsInSilence = !next || next.startMs > heldUntil;\n const endMs = endsInSilence\n ? heldUntil\n : Math.max(page.startMs, next.startMs);\n return {\n page,\n index,\n speaker: speakers.get(page.tokens[0].fromMs),\n startMs: page.startMs,\n speechEndMs,\n endMs,\n endsInSilence,\n };\n });\n}\n\nfunction findWindowIndex(windows: CaptionPageWindow[], timeMs: number): number {\n let lo = 0;\n let hi = windows.length - 1;\n let found = -1;\n while (lo <= hi) {\n const mid = (lo + hi) >> 1;\n if (windows[mid].startMs <= timeMs) {\n found = mid;\n lo = mid + 1;\n } else {\n hi = mid - 1;\n }\n }\n if (found === -1) return -1;\n return timeMs < windows[found].endMs ? found : -1;\n}\n\nfunction tokenProgress(fromMs: number, toMs: number, timeMs: number): number {\n if (timeMs < fromMs) return 0;\n if (toMs <= fromMs) return 1;\n return Math.min(1, (timeMs - fromMs) / (toMs - fromMs));\n}\n\nfunction getTokenStates(\n page: TikTokPage,\n timeMs: number,\n): { activeIndex: number; tokens: CaptionTokenState[] } {\n let activeIndex = -1;\n page.tokens.forEach((token, i) => {\n if (token.fromMs <= timeMs) activeIndex = i;\n });\n const tokens = page.tokens.map(\n (token, i): CaptionTokenState => ({\n text: token.text.trim(),\n spaceBefore: i > 0 && /^\\s/.test(token.text),\n fromMs: token.fromMs,\n toMs: token.toMs,\n progress: tokenProgress(token.fromMs, token.toMs, timeMs),\n status:\n i < activeIndex ? \"spoken\" : i === activeIndex ? \"active\" : \"upcoming\",\n }),\n );\n return { activeIndex, tokens };\n}\n\nfunction getCaptionsState(\n windows: CaptionPageWindow[],\n timeMs: number,\n): CaptionsState | null {\n const found = findWindowIndex(windows, timeMs);\n if (found === -1) return null;\n const window = windows[found];\n const { activeIndex, tokens } = getTokenStates(window.page, timeMs);\n const before = found > 0 ? windows[found - 1] : null;\n const previous =\n before && !before.endsInSilence\n ? {\n page: before.page,\n pageIndex: before.index,\n tokens: getTokenStates(before.page, before.endMs).tokens,\n }\n : null;\n return {\n page: window.page,\n pageIndex: window.index,\n speaker: window.speaker,\n timeMs,\n activeIndex,\n tokens,\n sinceStartMs: timeMs - window.startMs,\n untilEndMs: window.endMs - timeMs,\n holdRoomMs: window.endMs - window.speechEndMs,\n endsInSilence: window.endsInSilence,\n previous,\n };\n}\n\nfunction getExitWindowMs(state: CaptionsState, exitMs: number): number {\n return Math.max(1, Math.min(exitMs, state.holdRoomMs));\n}\n\nfunction groupCaptionWords(\n tokens: CaptionTokenState[],\n): { index: number; token: CaptionTokenState }[][] {\n const words: { index: number; token: CaptionTokenState }[][] = [];\n tokens.forEach((token, index) => {\n const current = words[words.length - 1];\n if (!current || token.spaceBefore) {\n words.push([{ index, token }]);\n } else {\n current.push({ index, token });\n }\n });\n return words;\n}\n\nfunction normalizeCaptionWord(text: string): string {\n return text\n .toLowerCase()\n .replace(/[\\u2018\\u2019]/g, \"'\")\n .replace(/[^\\p{L}\\p{N}']/gu, \"\");\n}\n\nfunction createKeywordMatcher(\n keywords: readonly string[] = [],\n): (text: string) => boolean {\n const set = new Set(keywords.map(normalizeCaptionWord).filter(Boolean));\n return (text) => set.has(normalizeCaptionWord(text));\n}\n\nfunction captionWordText(word: { token: CaptionTokenState }[]): string {\n return word.map(({ token }) => token.text).join(\"\");\n}\n\ninterface CaptionWordRect {\n left: number;\n top: number;\n width: number;\n height: number;\n}\n\nfunction sameRects(a: CaptionWordRect[], b: CaptionWordRect[]): boolean {\n return (\n a.length === b.length &&\n a.every(\n (r, i) =>\n r.left === b[i].left &&\n r.top === b[i].top &&\n r.width === b[i].width &&\n r.height === b[i].height,\n )\n );\n}\n\nfunction useCaptionWordRects(\n pageIndex: number,\n count: number,\n): {\n wordRef: (index: number) => (el: HTMLElement | null) => void;\n rects: CaptionWordRect[] | null;\n} {\n const elements = useRef<(HTMLElement | null)[]>([]);\n const [measured, setMeasured] = useState<{\n pageIndex: number;\n rects: CaptionWordRect[];\n } | null>(null);\n\n useLayoutEffect(() => {\n if (pageIndex === -1) return;\n const rects = elements.current.slice(0, count).map((el) =>\n el\n ? {\n left: el.offsetLeft,\n top: el.offsetTop,\n width: el.offsetWidth,\n height: el.offsetHeight,\n }\n : { left: 0, top: 0, width: 0, height: 0 },\n );\n setMeasured((prev) =>\n prev && prev.pageIndex === pageIndex && sameRects(prev.rects, rects)\n ? prev\n : { pageIndex, rects },\n );\n });\n\n return {\n wordRef: (index) => (el) => {\n elements.current[index] = el;\n },\n rects: measured && measured.pageIndex === pageIndex ? measured.rects : null,\n };\n}\n\nfunction useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs = DEFAULT_HOLD_MS,\n}: {\n captions: SpeakerCaption[];\n combineTokensWithinMilliseconds: number;\n holdMs?: number;\n}): CaptionsState | null {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const windows = useMemo(\n () =>\n buildCaptionPages(captions, { combineTokensWithinMilliseconds, holdMs }),\n [captions, combineTokensWithinMilliseconds, holdMs],\n );\n return getCaptionsState(windows, (frame / fps) * 1000);\n}\n\ninterface CaptionTeleprompterProps extends CaptionBaseProps {\n visibleLines?: number;\n pastOpacity?: number;\n futureOpacity?: number;\n upcomingOpacity?: number;\n shadow?: boolean;\n}\n\ninterface PrompterWord {\n key: number;\n text: string;\n fromMs: number;\n}\n\nconst LINE_HEIGHT = 1.3;\nconst LINE_GAP_EM = 0.2;\nconst SCROLL_MS = 320;\nconst LIGHT_MS = 80;\nconst EDGE_FADE_LINES = 0.66;\n\nfunction edgeFade(visibleLines: number): string | undefined {\n const fadeLines = Math.min(\n EDGE_FADE_LINES,\n Math.max(0, visibleLines - 1) / 3,\n );\n if (fadeLines <= 0) return undefined;\n const pct = (fadeLines / visibleLines) * 100;\n return `linear-gradient(to bottom, transparent, #000 ${pct}%, #000 ${100 - pct}%, transparent)`;\n}\nconst LEGIBILITY_SHADOW =\n \"0 2px 3px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.35)\";\n\nconst scrollEasing = Easing.bezier(0.45, 0, 0.2, 1);\n\nconst clamp = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n} as const;\n\nfunction lineWords(page: TikTokPage): PrompterWord[] {\n const words: PrompterWord[] = [];\n page.tokens.forEach((token, i) => {\n const last = words[words.length - 1];\n if (last && !/^\\s/.test(token.text)) {\n last.text += token.text;\n } else {\n words.push({ key: i, text: token.text.trim(), fromMs: token.fromMs });\n }\n });\n return words;\n}\n\nfunction CaptionTeleprompterBase({\n captions,\n combineTokensWithinMilliseconds = 1500,\n holdMs = DEFAULT_HOLD_MS,\n fontSize = 64,\n fontWeight = 800,\n color = \"#ffffff\",\n visibleLines = 3,\n pastOpacity = 0.35,\n futureOpacity = 0.35,\n upcomingOpacity = 0.55,\n shadow = true,\n className,\n}: CaptionTeleprompterProps) {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const timeMs = (frame / fps) * 1000;\n const lines = useMemo(\n () =>\n buildCaptionPages(captions, {\n combineTokensWithinMilliseconds,\n holdMs,\n }).map((line) => ({ ...line, words: lineWords(line.page) })),\n [captions, combineTokensWithinMilliseconds, holdMs],\n );\n const { wordRef: lineRef, rects } = useCaptionWordRects(0, lines.length);\n\n const step = (LINE_HEIGHT + LINE_GAP_EM) * fontSize;\n const windowHeight = visibleLines * step;\n const center = (i: number): number => {\n const rect = rects?.[i];\n return rect\n ? rect.top + rect.height / 2\n : i * step + (LINE_HEIGHT * fontSize) / 2;\n };\n\n const scrollMsAt = (i: number): number => {\n const before =\n i > 0\n ? lines[i].startMs - lines[i - 1].startMs\n : Number.POSITIVE_INFINITY;\n const after =\n i < lines.length - 1\n ? lines[i + 1].startMs - lines[i].startMs\n : Number.POSITIVE_INFINITY;\n return Math.max(1, Math.min(SCROLL_MS, before, after));\n };\n let k = -1;\n lines.forEach((line, i) => {\n if (line.startMs - scrollMsAt(i) / 2 <= timeMs) k = i;\n });\n const scrollMs = k > 0 ? scrollMsAt(k) : SCROLL_MS;\n const progress =\n k <= 0\n ? 1\n : interpolate(\n timeMs - (lines[k].startMs - scrollMs / 2),\n [0, scrollMs],\n [0, 1],\n { ...clamp, easing: scrollEasing },\n );\n const focus = Math.max(k, 0);\n const centerY =\n lines.length === 0\n ? 0\n : k <= 0\n ? center(0)\n : center(k - 1) + (center(k) - center(k - 1)) * progress;\n\n return (\n <div\n className={className}\n style={{\n position: \"relative\",\n height: windowHeight,\n fontSize,\n fontWeight,\n color,\n textAlign: \"center\",\n overflow: \"hidden\",\n maskImage: edgeFade(visibleLines),\n WebkitMaskImage: edgeFade(visibleLines),\n }}\n >\n <div\n style={{\n position: \"absolute\",\n left: 0,\n right: 0,\n top: 0,\n transform: `translateY(${windowHeight / 2 - centerY}px)`,\n }}\n >\n {lines.map((line, i) => {\n const weight =\n i === focus ? progress : i === focus - 1 ? 1 - progress : 0;\n const rest = i < focus ? pastOpacity : futureOpacity;\n return (\n <div\n key={line.index}\n ref={lineRef(i)}\n style={{\n lineHeight: LINE_HEIGHT,\n marginBottom: `${LINE_GAP_EM}em`,\n textShadow: shadow ? LEGIBILITY_SHADOW : undefined,\n }}\n >\n {line.words.map((word, w) => {\n const lit = interpolate(\n timeMs - word.fromMs,\n [-LIGHT_MS, 0],\n [upcomingOpacity, 1],\n clamp,\n );\n return (\n <Fragment key={word.key}>\n {w > 0 && \" \"}\n <span style={{ opacity: rest + (lit - rest) * weight }}>\n {word.text}\n </span>\n </Fragment>\n );\n })}\n </div>\n );\n })}\n </div>\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n captions: {\n type: \"remotion-captions\",\n default: [{\n text: \" So\",\n startMs: 300,\n endMs: 460,\n timestampMs: 380,\n confidence: 0.97,\n }, {\n text: \" here's\",\n startMs: 460,\n endMs: 700,\n timestampMs: 580,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 700,\n endMs: 820,\n timestampMs: 760,\n confidence: 0.97,\n }, {\n text: \" thing.\",\n startMs: 820,\n endMs: 1240,\n timestampMs: 1030,\n confidence: 0.97,\n }, {\n text: \" Most\",\n startMs: 1700,\n endMs: 1960,\n timestampMs: 1830,\n confidence: 0.97,\n }, {\n text: \" demo\",\n startMs: 1960,\n endMs: 2240,\n timestampMs: 2100,\n confidence: 0.97,\n }, {\n text: \" videos\",\n startMs: 2240,\n endMs: 2680,\n timestampMs: 2460,\n confidence: 0.97,\n }, {\n text: \" lose\",\n startMs: 2680,\n endMs: 2960,\n timestampMs: 2820,\n confidence: 0.97,\n }, {\n text: \" people\",\n startMs: 2960,\n endMs: 3320,\n timestampMs: 3140,\n confidence: 0.97,\n }, {\n text: \" in\",\n startMs: 3320,\n endMs: 3420,\n timestampMs: 3370,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 3420,\n endMs: 3520,\n timestampMs: 3470,\n confidence: 0.97,\n }, {\n text: \" first\",\n startMs: 3520,\n endMs: 3820,\n timestampMs: 3670,\n confidence: 0.97,\n }, {\n text: \" three\",\n startMs: 3820,\n endMs: 4100,\n timestampMs: 3960,\n confidence: 0.97,\n }, {\n text: \" seconds.\",\n startMs: 4100,\n endMs: 4780,\n timestampMs: 4440,\n confidence: 0.97,\n }, {\n text: \" Captions\",\n startMs: 5400,\n endMs: 5920,\n timestampMs: 5660,\n confidence: 0.97,\n }, {\n text: \" keep\",\n startMs: 5920,\n endMs: 6140,\n timestampMs: 6030,\n confidence: 0.97,\n }, {\n text: \" them\",\n startMs: 6140,\n endMs: 6300,\n timestampMs: 6220,\n confidence: 0.97,\n }, {\n text: \" watching,\",\n startMs: 6300,\n endMs: 6860,\n timestampMs: 6580,\n confidence: 0.97,\n }, {\n text: \" even\",\n startMs: 6960,\n endMs: 7180,\n timestampMs: 7070,\n confidence: 0.97,\n }, {\n text: \" with\",\n startMs: 7180,\n endMs: 7320,\n timestampMs: 7250,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 7320,\n endMs: 7420,\n timestampMs: 7370,\n confidence: 0.97,\n }, {\n text: \" sound\",\n startMs: 7420,\n endMs: 7760,\n timestampMs: 7590,\n confidence: 0.97,\n }, {\n text: \" off.\",\n startMs: 7760,\n endMs: 8300,\n timestampMs: 8030,\n confidence: 0.97,\n }],\n description: \"Transcript\",\n keyframable: false,\n },\n fontSize: {\n type: \"number\",\n min: 24,\n max: 140,\n step: 1,\n default: 64,\n description: \"Font size\",\n hiddenFromList: false,\n },\n fontWeight: {\n type: \"number\",\n min: 400,\n max: 900,\n step: 100,\n default: 800,\n description: \"Font weight\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#ffffff\",\n description: \"Text color\",\n },\n visibleLines: {\n type: \"number\",\n min: 1,\n max: 6,\n step: 1,\n default: 3,\n description: \"Visible lines\",\n hiddenFromList: false,\n },\n pastOpacity: {\n type: \"number\",\n min: 0,\n max: 1,\n step: 0.05,\n default: 0.35,\n description: \"Past line opacity\",\n hiddenFromList: false,\n },\n futureOpacity: {\n type: \"number\",\n min: 0,\n max: 1,\n step: 0.05,\n default: 0.35,\n description: \"Next line opacity\",\n hiddenFromList: false,\n },\n upcomingOpacity: {\n type: \"number\",\n min: 0,\n max: 1,\n step: 0.05,\n default: 0.55,\n description: \"Unspoken word opacity\",\n hiddenFromList: false,\n },\n combineTokensWithinMilliseconds: {\n type: \"number\",\n min: 0,\n max: 4000,\n step: 100,\n default: 1500,\n description: \"Line window (ms)\",\n hiddenFromList: false,\n },\n holdMs: {\n type: \"number\",\n min: 0,\n max: 2000,\n step: 50,\n default: 600,\n description: \"Silence break (ms)\",\n hiddenFromList: false,\n },\n shadow: {\n type: \"boolean\",\n default: true,\n description: \"Shadow\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"captions\",\"fontSize\",\"fontWeight\",\"color\",\"visibleLines\",\"pastOpacity\",\"futureOpacity\",\"upcomingOpacity\",\"combineTokensWithinMilliseconds\",\"holdMs\",\"shadow\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n captions: [{\n text: \" So\",\n startMs: 300,\n endMs: 460,\n timestampMs: 380,\n confidence: 0.97,\n }, {\n text: \" here's\",\n startMs: 460,\n endMs: 700,\n timestampMs: 580,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 700,\n endMs: 820,\n timestampMs: 760,\n confidence: 0.97,\n }, {\n text: \" thing.\",\n startMs: 820,\n endMs: 1240,\n timestampMs: 1030,\n confidence: 0.97,\n }, {\n text: \" Most\",\n startMs: 1700,\n endMs: 1960,\n timestampMs: 1830,\n confidence: 0.97,\n }, {\n text: \" demo\",\n startMs: 1960,\n endMs: 2240,\n timestampMs: 2100,\n confidence: 0.97,\n }, {\n text: \" videos\",\n startMs: 2240,\n endMs: 2680,\n timestampMs: 2460,\n confidence: 0.97,\n }, {\n text: \" lose\",\n startMs: 2680,\n endMs: 2960,\n timestampMs: 2820,\n confidence: 0.97,\n }, {\n text: \" people\",\n startMs: 2960,\n endMs: 3320,\n timestampMs: 3140,\n confidence: 0.97,\n }, {\n text: \" in\",\n startMs: 3320,\n endMs: 3420,\n timestampMs: 3370,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 3420,\n endMs: 3520,\n timestampMs: 3470,\n confidence: 0.97,\n }, {\n text: \" first\",\n startMs: 3520,\n endMs: 3820,\n timestampMs: 3670,\n confidence: 0.97,\n }, {\n text: \" three\",\n startMs: 3820,\n endMs: 4100,\n timestampMs: 3960,\n confidence: 0.97,\n }, {\n text: \" seconds.\",\n startMs: 4100,\n endMs: 4780,\n timestampMs: 4440,\n confidence: 0.97,\n }, {\n text: \" Captions\",\n startMs: 5400,\n endMs: 5920,\n timestampMs: 5660,\n confidence: 0.97,\n }, {\n text: \" keep\",\n startMs: 5920,\n endMs: 6140,\n timestampMs: 6030,\n confidence: 0.97,\n }, {\n text: \" them\",\n startMs: 6140,\n endMs: 6300,\n timestampMs: 6220,\n confidence: 0.97,\n }, {\n text: \" watching,\",\n startMs: 6300,\n endMs: 6860,\n timestampMs: 6580,\n confidence: 0.97,\n }, {\n text: \" even\",\n startMs: 6960,\n endMs: 7180,\n timestampMs: 7070,\n confidence: 0.97,\n }, {\n text: \" with\",\n startMs: 7180,\n endMs: 7320,\n timestampMs: 7250,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 7320,\n endMs: 7420,\n timestampMs: 7370,\n confidence: 0.97,\n }, {\n text: \" sound\",\n startMs: 7420,\n endMs: 7760,\n timestampMs: 7590,\n confidence: 0.97,\n }, {\n text: \" off.\",\n startMs: 7760,\n endMs: 8300,\n timestampMs: 8030,\n confidence: 0.97,\n }],\n fontSize: 64,\n fontWeight: 800,\n color: \"#ffffff\",\n visibleLines: 3,\n pastOpacity: 0.35,\n futureOpacity: 0.35,\n upcomingOpacity: 0.55,\n combineTokensWithinMilliseconds: 1500,\n holdMs: 600,\n shadow: true,\n};\n\ntype CaptionTeleprompterElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof CaptionTeleprompterBase>;\n\nconst CaptionTeleprompterInner = forwardRef<\n HTMLDivElement,\n CaptionTeleprompterElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<CaptionTeleprompter>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <CaptionTeleprompterBase\n {...(componentProps as unknown as ComponentProps<typeof CaptionTeleprompterBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const CaptionTeleprompter = Interactive.withSchema({\n Component: CaptionTeleprompterInner,\n componentName: \"<CaptionTeleprompter>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"+ },+ "durationInFrames": 279+}diff --git a/registry-artifacts/elements/caption-timeline.json b/registry-artifacts/elements/caption-timeline.jsonnew file mode 100644index 00000000..982958b1--- /dev/null+++ b/registry-artifacts/elements/caption-timeline.json@@ -0,0 +1,21 @@+{+ "type": "remotion-element",+ "version": 1,+ "element": {+ "assets": [],+ "dependencies": [+ {+ "name": "@remotion/captions",+ "version": null+ }+ ],+ "dimensions": null,+ "displayName": "Caption Timeline",+ "durationInFrames": 279,+ "initialProps": null,+ "installationMode": "component-owned-sequence",+ "slug": "caption-timeline",+ "sourceCode": "import { createTikTokStyleCaptions, type Caption, type TikTokPage } from \"@remotion/captions\";\nimport { forwardRef, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState, type ComponentProps } from \"react\";\nimport { Interactive, Sequence, interpolate, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\n\ntype SpeakerCaption = Caption & { speaker?: string };\n\ninterface CaptionBaseProps {\n captions: Caption[];\n combineTokensWithinMilliseconds?: number;\n holdMs?: number;\n fontSize?: number;\n fontWeight?: number;\n color?: string;\n className?: string;\n}\n\nconst DEFAULT_HOLD_MS = 600;\nconst MIN_SILENCE_BREAK_MS = 300;\n\ninterface CaptionPageWindow {\n page: TikTokPage;\n index: number;\n speaker: string | undefined;\n startMs: number;\n speechEndMs: number;\n endMs: number;\n endsInSilence: boolean;\n}\n\ntype CaptionTokenStatus = \"upcoming\" | \"active\" | \"spoken\";\n\ninterface CaptionTokenState {\n text: string;\n spaceBefore: boolean;\n fromMs: number;\n toMs: number;\n progress: number;\n status: CaptionTokenStatus;\n}\n\ninterface CaptionPreviousPage {\n page: TikTokPage;\n pageIndex: number;\n tokens: CaptionTokenState[];\n}\n\ninterface CaptionsState {\n page: TikTokPage;\n pageIndex: number;\n speaker: string | undefined;\n timeMs: number;\n activeIndex: number;\n tokens: CaptionTokenState[];\n sinceStartMs: number;\n untilEndMs: number;\n holdRoomMs: number;\n endsInSilence: boolean;\n previous: CaptionPreviousPage | null;\n}\n\ninterface CaptionPagingOptions {\n combineTokensWithinMilliseconds: number;\n holdMs?: number;\n}\n\nconst SENTENCE_END = /[.!?…][\"')\\]]*$/;\n\nfunction markPageBreaks(captions: SpeakerCaption[]): Caption[] {\n return captions.map((caption, i) => {\n if (caption.pageBreakAfter !== undefined) return caption;\n const next = captions[i + 1];\n const speakerChanges =\n next !== undefined && next.speaker !== caption.speaker;\n return speakerChanges || SENTENCE_END.test(caption.text.trim())\n ? { ...caption, pageBreakAfter: true }\n : caption;\n });\n}\n\nfunction buildCaptionPages(\n captions: SpeakerCaption[],\n {\n combineTokensWithinMilliseconds,\n holdMs = DEFAULT_HOLD_MS,\n }: CaptionPagingOptions,\n): CaptionPageWindow[] {\n if (captions.length === 0) return [];\n const { pages } = createTikTokStyleCaptions({\n captions: markPageBreaks(captions),\n combineTokensWithinMilliseconds,\n breakOnSilenceAfterMilliseconds: Math.max(holdMs, MIN_SILENCE_BREAK_MS),\n });\n const speakers = new Map<number, string | undefined>();\n for (const caption of captions) {\n if (!speakers.has(caption.startMs)) {\n speakers.set(caption.startMs, caption.speaker);\n }\n }\n const spoken = pages.filter((page) => page.tokens.length > 0);\n return spoken.map((page, index) => {\n const last = page.tokens[page.tokens.length - 1];\n const speechEndMs = last ? last.toMs : page.startMs;\n const heldUntil = speechEndMs + Math.max(0, holdMs);\n const next = spoken[index + 1];\n const endsInSilence = !next || next.startMs > heldUntil;\n const endMs = endsInSilence\n ? heldUntil\n : Math.max(page.startMs, next.startMs);\n return {\n page,\n index,\n speaker: speakers.get(page.tokens[0].fromMs),\n startMs: page.startMs,\n speechEndMs,\n endMs,\n endsInSilence,\n };\n });\n}\n\nfunction findWindowIndex(windows: CaptionPageWindow[], timeMs: number): number {\n let lo = 0;\n let hi = windows.length - 1;\n let found = -1;\n while (lo <= hi) {\n const mid = (lo + hi) >> 1;\n if (windows[mid].startMs <= timeMs) {\n found = mid;\n lo = mid + 1;\n } else {\n hi = mid - 1;\n }\n }\n if (found === -1) return -1;\n return timeMs < windows[found].endMs ? found : -1;\n}\n\nfunction tokenProgress(fromMs: number, toMs: number, timeMs: number): number {\n if (timeMs < fromMs) return 0;\n if (toMs <= fromMs) return 1;\n return Math.min(1, (timeMs - fromMs) / (toMs - fromMs));\n}\n\nfunction getTokenStates(\n page: TikTokPage,\n timeMs: number,\n): { activeIndex: number; tokens: CaptionTokenState[] } {\n let activeIndex = -1;\n page.tokens.forEach((token, i) => {\n if (token.fromMs <= timeMs) activeIndex = i;\n });\n const tokens = page.tokens.map(\n (token, i): CaptionTokenState => ({\n text: token.text.trim(),\n spaceBefore: i > 0 && /^\\s/.test(token.text),\n fromMs: token.fromMs,\n toMs: token.toMs,\n progress: tokenProgress(token.fromMs, token.toMs, timeMs),\n status:\n i < activeIndex ? \"spoken\" : i === activeIndex ? \"active\" : \"upcoming\",\n }),\n );\n return { activeIndex, tokens };\n}\n\nfunction getCaptionsState(\n windows: CaptionPageWindow[],\n timeMs: number,\n): CaptionsState | null {\n const found = findWindowIndex(windows, timeMs);\n if (found === -1) return null;\n const window = windows[found];\n const { activeIndex, tokens } = getTokenStates(window.page, timeMs);\n const before = found > 0 ? windows[found - 1] : null;\n const previous =\n before && !before.endsInSilence\n ? {\n page: before.page,\n pageIndex: before.index,\n tokens: getTokenStates(before.page, before.endMs).tokens,\n }\n : null;\n return {\n page: window.page,\n pageIndex: window.index,\n speaker: window.speaker,\n timeMs,\n activeIndex,\n tokens,\n sinceStartMs: timeMs - window.startMs,\n untilEndMs: window.endMs - timeMs,\n holdRoomMs: window.endMs - window.speechEndMs,\n endsInSilence: window.endsInSilence,\n previous,\n };\n}\n\nfunction getExitWindowMs(state: CaptionsState, exitMs: number): number {\n return Math.max(1, Math.min(exitMs, state.holdRoomMs));\n}\n\nfunction groupCaptionWords(\n tokens: CaptionTokenState[],\n): { index: number; token: CaptionTokenState }[][] {\n const words: { index: number; token: CaptionTokenState }[][] = [];\n tokens.forEach((token, index) => {\n const current = words[words.length - 1];\n if (!current || token.spaceBefore) {\n words.push([{ index, token }]);\n } else {\n current.push({ index, token });\n }\n });\n return words;\n}\n\nfunction normalizeCaptionWord(text: string): string {\n return text\n .toLowerCase()\n .replace(/[\\u2018\\u2019]/g, \"'\")\n .replace(/[^\\p{L}\\p{N}']/gu, \"\");\n}\n\nfunction createKeywordMatcher(\n keywords: readonly string[] = [],\n): (text: string) => boolean {\n const set = new Set(keywords.map(normalizeCaptionWord).filter(Boolean));\n return (text) => set.has(normalizeCaptionWord(text));\n}\n\nfunction captionWordText(word: { token: CaptionTokenState }[]): string {\n return word.map(({ token }) => token.text).join(\"\");\n}\n\ninterface CaptionWordRect {\n left: number;\n top: number;\n width: number;\n height: number;\n}\n\nfunction sameRects(a: CaptionWordRect[], b: CaptionWordRect[]): boolean {\n return (\n a.length === b.length &&\n a.every(\n (r, i) =>\n r.left === b[i].left &&\n r.top === b[i].top &&\n r.width === b[i].width &&\n r.height === b[i].height,\n )\n );\n}\n\nfunction useCaptionWordRects(\n pageIndex: number,\n count: number,\n): {\n wordRef: (index: number) => (el: HTMLElement | null) => void;\n rects: CaptionWordRect[] | null;\n} {\n const elements = useRef<(HTMLElement | null)[]>([]);\n const [measured, setMeasured] = useState<{\n pageIndex: number;\n rects: CaptionWordRect[];\n } | null>(null);\n\n useLayoutEffect(() => {\n if (pageIndex === -1) return;\n const rects = elements.current.slice(0, count).map((el) =>\n el\n ? {\n left: el.offsetLeft,\n top: el.offsetTop,\n width: el.offsetWidth,\n height: el.offsetHeight,\n }\n : { left: 0, top: 0, width: 0, height: 0 },\n );\n setMeasured((prev) =>\n prev && prev.pageIndex === pageIndex && sameRects(prev.rects, rects)\n ? prev\n : { pageIndex, rects },\n );\n });\n\n return {\n wordRef: (index) => (el) => {\n elements.current[index] = el;\n },\n rects: measured && measured.pageIndex === pageIndex ? measured.rects : null,\n };\n}\n\nfunction useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs = DEFAULT_HOLD_MS,\n}: {\n captions: SpeakerCaption[];\n combineTokensWithinMilliseconds: number;\n holdMs?: number;\n}): CaptionsState | null {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const windows = useMemo(\n () =>\n buildCaptionPages(captions, { combineTokensWithinMilliseconds, holdMs }),\n [captions, combineTokensWithinMilliseconds, holdMs],\n );\n return getCaptionsState(windows, (frame / fps) * 1000);\n}\n\ninterface CaptionTimelineProps extends CaptionBaseProps {\n width?: number;\n pxPerSecond?: number;\n playheadPosition?: number;\n playheadColor?: string;\n upcomingOpacity?: number;\n shadow?: boolean;\n}\n\ninterface TimelineWord {\n id: number;\n text: string;\n startMs: number;\n endMs: number;\n}\n\nconst LINE_HEIGHT = 1.3;\nconst GAP_EM = 0.32;\nconst LIGHT_MS = 80;\nconst EDGE_FADE =\n \"linear-gradient(to right, transparent, #000 12%, #000 88%, transparent)\";\nconst LEGIBILITY_SHADOW =\n \"0 2px 3px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.35)\";\n\nconst clamp = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n} as const;\n\nfunction getTimelineWords(captions: Caption[]): TimelineWord[] {\n const words: TimelineWord[] = [];\n for (const caption of captions) {\n if (caption.text.trim() === \"\") continue;\n const last = words[words.length - 1];\n if (last && !/^\\s/.test(caption.text)) {\n last.text += caption.text;\n last.endMs = caption.endMs;\n } else {\n words.push({\n id: words.length,\n text: caption.text.trim(),\n startMs: caption.startMs,\n endMs: caption.endMs,\n });\n }\n }\n return words;\n}\n\nfunction layoutTimeline(\n words: TimelineWord[],\n widths: number[],\n pxPerSecond: number,\n gap: number,\n): number[] {\n const xs: number[] = [];\n words.forEach((word, i) => {\n const ideal = (word.startMs / 1000) * pxPerSecond;\n xs.push(i === 0 ? ideal : Math.max(ideal, xs[i - 1] + widths[i - 1] + gap));\n });\n return xs;\n}\n\nfunction timelineOffset(\n words: TimelineWord[],\n xs: number[],\n timeMs: number,\n pxPerSecond: number,\n): number {\n if (words.length === 0) return (timeMs / 1000) * pxPerSecond;\n let i = -1;\n while (i + 1 < words.length && words[i + 1].startMs <= timeMs) i++;\n if (i === -1) {\n return xs[0] - ((words[0].startMs - timeMs) / 1000) * pxPerSecond;\n }\n const next = words[i + 1];\n if (!next) {\n return xs[i] + ((timeMs - words[i].startMs) / 1000) * pxPerSecond;\n }\n const span = next.startMs - words[i].startMs;\n const t = span > 0 ? (timeMs - words[i].startMs) / span : 1;\n return xs[i] + (xs[i + 1] - xs[i]) * t;\n}\n\nfunction sameWidths(a: number[], b: number[]): boolean {\n return a.length === b.length && a.every((w, i) => w === b[i]);\n}\n\nfunction CaptionTimelineBase({\n captions,\n fontSize = 64,\n fontWeight = 800,\n color = \"#ffffff\",\n width = 1100,\n pxPerSecond = 260,\n playheadPosition = 0.35,\n playheadColor = \"#facc15\",\n upcomingOpacity = 0.4,\n shadow = true,\n className,\n}: CaptionTimelineProps) {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const timeMs = (frame / fps) * 1000;\n const words = useMemo(() => getTimelineWords(captions), [captions]);\n const elements = useRef<(HTMLSpanElement | null)[]>([]);\n const [widths, setWidths] = useState<number[]>([]);\n\n useLayoutEffect(() => {\n const measured = words.map((_, i) => elements.current[i]?.offsetWidth ?? 0);\n setWidths((prev) => (sameWidths(prev, measured) ? prev : measured));\n });\n\n const gap = fontSize * GAP_EM;\n const resolved =\n widths.length === words.length\n ? widths\n : words.map((word) => word.text.length * fontSize * 0.55);\n const xs = layoutTimeline(words, resolved, pxPerSecond, gap);\n const playheadX = width * playheadPosition;\n const offset = timelineOffset(words, xs, timeMs, pxPerSecond);\n const thickness = Math.max(2, Math.round(fontSize * 0.04));\n\n if (words.length === 0) return null;\n\n return (\n <div\n className={className}\n style={{\n position: \"relative\",\n width,\n height: `${LINE_HEIGHT}em`,\n fontSize,\n fontWeight,\n color,\n lineHeight: LINE_HEIGHT,\n }}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n overflow: \"hidden\",\n maskImage: EDGE_FADE,\n WebkitMaskImage: EDGE_FADE,\n }}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n transform: `translateX(${playheadX - offset}px)`,\n }}\n >\n {words.map((word, i) => (\n <span\n key={word.id}\n ref={(el) => {\n elements.current[i] = el;\n }}\n style={{\n position: \"absolute\",\n left: xs[i],\n top: 0,\n whiteSpace: \"nowrap\",\n opacity: interpolate(\n timeMs - word.startMs,\n [-LIGHT_MS, 0],\n [upcomingOpacity, 1],\n clamp,\n ),\n textShadow: shadow ? LEGIBILITY_SHADOW : undefined,\n }}\n >\n {word.text}\n </span>\n ))}\n </div>\n </div>\n <div\n aria-hidden\n style={{\n position: \"absolute\",\n top: \"8%\",\n bottom: \"8%\",\n left: playheadX - thickness / 2,\n width: thickness,\n borderRadius: thickness,\n background: playheadColor,\n }}\n />\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n captions: {\n type: \"remotion-captions\",\n default: [{\n text: \" So\",\n startMs: 300,\n endMs: 460,\n timestampMs: 380,\n confidence: 0.97,\n }, {\n text: \" here's\",\n startMs: 460,\n endMs: 700,\n timestampMs: 580,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 700,\n endMs: 820,\n timestampMs: 760,\n confidence: 0.97,\n }, {\n text: \" thing.\",\n startMs: 820,\n endMs: 1240,\n timestampMs: 1030,\n confidence: 0.97,\n }, {\n text: \" Most\",\n startMs: 1700,\n endMs: 1960,\n timestampMs: 1830,\n confidence: 0.97,\n }, {\n text: \" demo\",\n startMs: 1960,\n endMs: 2240,\n timestampMs: 2100,\n confidence: 0.97,\n }, {\n text: \" videos\",\n startMs: 2240,\n endMs: 2680,\n timestampMs: 2460,\n confidence: 0.97,\n }, {\n text: \" lose\",\n startMs: 2680,\n endMs: 2960,\n timestampMs: 2820,\n confidence: 0.97,\n }, {\n text: \" people\",\n startMs: 2960,\n endMs: 3320,\n timestampMs: 3140,\n confidence: 0.97,\n }, {\n text: \" in\",\n startMs: 3320,\n endMs: 3420,\n timestampMs: 3370,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 3420,\n endMs: 3520,\n timestampMs: 3470,\n confidence: 0.97,\n }, {\n text: \" first\",\n startMs: 3520,\n endMs: 3820,\n timestampMs: 3670,\n confidence: 0.97,\n }, {\n text: \" three\",\n startMs: 3820,\n endMs: 4100,\n timestampMs: 3960,\n confidence: 0.97,\n }, {\n text: \" seconds.\",\n startMs: 4100,\n endMs: 4780,\n timestampMs: 4440,\n confidence: 0.97,\n }, {\n text: \" Captions\",\n startMs: 5400,\n endMs: 5920,\n timestampMs: 5660,\n confidence: 0.97,\n }, {\n text: \" keep\",\n startMs: 5920,\n endMs: 6140,\n timestampMs: 6030,\n confidence: 0.97,\n }, {\n text: \" them\",\n startMs: 6140,\n endMs: 6300,\n timestampMs: 6220,\n confidence: 0.97,\n }, {\n text: \" watching,\",\n startMs: 6300,\n endMs: 6860,\n timestampMs: 6580,\n confidence: 0.97,\n }, {\n text: \" even\",\n startMs: 6960,\n endMs: 7180,\n timestampMs: 7070,\n confidence: 0.97,\n }, {\n text: \" with\",\n startMs: 7180,\n endMs: 7320,\n timestampMs: 7250,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 7320,\n endMs: 7420,\n timestampMs: 7370,\n confidence: 0.97,\n }, {\n text: \" sound\",\n startMs: 7420,\n endMs: 7760,\n timestampMs: 7590,\n confidence: 0.97,\n }, {\n text: \" off.\",\n startMs: 7760,\n endMs: 8300,\n timestampMs: 8030,\n confidence: 0.97,\n }],\n description: \"Transcript\",\n keyframable: false,\n },\n fontSize: {\n type: \"number\",\n min: 24,\n max: 140,\n step: 1,\n default: 64,\n description: \"Font size\",\n hiddenFromList: false,\n },\n fontWeight: {\n type: \"number\",\n min: 400,\n max: 900,\n step: 100,\n default: 800,\n description: \"Font weight\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#ffffff\",\n description: \"Text color\",\n },\n playheadColor: {\n type: \"color\",\n default: \"#facc15\",\n description: \"Playhead color\",\n },\n width: {\n type: \"number\",\n min: 400,\n max: 1800,\n step: 10,\n default: 1100,\n description: \"Strip width (px)\",\n hiddenFromList: false,\n },\n pxPerSecond: {\n type: \"number\",\n min: 100,\n max: 600,\n step: 10,\n default: 260,\n description: \"Pixels per second\",\n hiddenFromList: false,\n },\n playheadPosition: {\n type: \"number\",\n min: 0.1,\n max: 0.9,\n step: 0.05,\n default: 0.35,\n description: \"Playhead position\",\n hiddenFromList: false,\n },\n upcomingOpacity: {\n type: \"number\",\n min: 0,\n max: 1,\n step: 0.05,\n default: 0.4,\n description: \"Upcoming opacity\",\n hiddenFromList: false,\n },\n shadow: {\n type: \"boolean\",\n default: true,\n description: \"Shadow\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"captions\",\"fontSize\",\"fontWeight\",\"color\",\"playheadColor\",\"width\",\"pxPerSecond\",\"playheadPosition\",\"upcomingOpacity\",\"shadow\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n captions: [{\n text: \" So\",\n startMs: 300,\n endMs: 460,\n timestampMs: 380,\n confidence: 0.97,\n }, {\n text: \" here's\",\n startMs: 460,\n endMs: 700,\n timestampMs: 580,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 700,\n endMs: 820,\n timestampMs: 760,\n confidence: 0.97,\n }, {\n text: \" thing.\",\n startMs: 820,\n endMs: 1240,\n timestampMs: 1030,\n confidence: 0.97,\n }, {\n text: \" Most\",\n startMs: 1700,\n endMs: 1960,\n timestampMs: 1830,\n confidence: 0.97,\n }, {\n text: \" demo\",\n startMs: 1960,\n endMs: 2240,\n timestampMs: 2100,\n confidence: 0.97,\n }, {\n text: \" videos\",\n startMs: 2240,\n endMs: 2680,\n timestampMs: 2460,\n confidence: 0.97,\n }, {\n text: \" lose\",\n startMs: 2680,\n endMs: 2960,\n timestampMs: 2820,\n confidence: 0.97,\n }, {\n text: \" people\",\n startMs: 2960,\n endMs: 3320,\n timestampMs: 3140,\n confidence: 0.97,\n }, {\n text: \" in\",\n startMs: 3320,\n endMs: 3420,\n timestampMs: 3370,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 3420,\n endMs: 3520,\n timestampMs: 3470,\n confidence: 0.97,\n }, {\n text: \" first\",\n startMs: 3520,\n endMs: 3820,\n timestampMs: 3670,\n confidence: 0.97,\n }, {\n text: \" three\",\n startMs: 3820,\n endMs: 4100,\n timestampMs: 3960,\n confidence: 0.97,\n }, {\n text: \" seconds.\",\n startMs: 4100,\n endMs: 4780,\n timestampMs: 4440,\n confidence: 0.97,\n }, {\n text: \" Captions\",\n startMs: 5400,\n endMs: 5920,\n timestampMs: 5660,\n confidence: 0.97,\n }, {\n text: \" keep\",\n startMs: 5920,\n endMs: 6140,\n timestampMs: 6030,\n confidence: 0.97,\n }, {\n text: \" them\",\n startMs: 6140,\n endMs: 6300,\n timestampMs: 6220,\n confidence: 0.97,\n }, {\n text: \" watching,\",\n startMs: 6300,\n endMs: 6860,\n timestampMs: 6580,\n confidence: 0.97,\n }, {\n text: \" even\",\n startMs: 6960,\n endMs: 7180,\n timestampMs: 7070,\n confidence: 0.97,\n }, {\n text: \" with\",\n startMs: 7180,\n endMs: 7320,\n timestampMs: 7250,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 7320,\n endMs: 7420,\n timestampMs: 7370,\n confidence: 0.97,\n }, {\n text: \" sound\",\n startMs: 7420,\n endMs: 7760,\n timestampMs: 7590,\n confidence: 0.97,\n }, {\n text: \" off.\",\n startMs: 7760,\n endMs: 8300,\n timestampMs: 8030,\n confidence: 0.97,\n }],\n fontSize: 64,\n fontWeight: 800,\n color: \"#ffffff\",\n playheadColor: \"#facc15\",\n width: 1100,\n pxPerSecond: 260,\n playheadPosition: 0.35,\n upcomingOpacity: 0.4,\n shadow: true,\n};\n\ntype CaptionTimelineElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof CaptionTimelineBase>;\n\nconst CaptionTimelineInner = forwardRef<\n HTMLDivElement,\n CaptionTimelineElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<CaptionTimeline>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <CaptionTimelineBase\n {...(componentProps as unknown as ComponentProps<typeof CaptionTimelineBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const CaptionTimeline = Interactive.withSchema({\n Component: CaptionTimelineInner,\n componentName: \"<CaptionTimeline>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"+ },+ "durationInFrames": 279+}diff --git a/registry-artifacts/elements/caption-typewriter.json b/registry-artifacts/elements/caption-typewriter.jsonnew file mode 100644index 00000000..e895b8c9--- /dev/null+++ b/registry-artifacts/elements/caption-typewriter.json@@ -0,0 +1,21 @@+{+ "type": "remotion-element",+ "version": 1,+ "element": {+ "assets": [],+ "dependencies": [+ {+ "name": "@remotion/captions",+ "version": null+ }+ ],+ "dimensions": null,+ "displayName": "Caption Typewriter",+ "durationInFrames": 279,+ "initialProps": null,+ "installationMode": "component-owned-sequence",+ "slug": "caption-typewriter",+ "sourceCode": "import { Fragment, forwardRef, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState, type ComponentProps } from \"react\";\nimport { Interactive, Sequence, interpolate, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { createTikTokStyleCaptions, type Caption, type TikTokPage } from \"@remotion/captions\";\n\ntype SpeakerCaption = Caption & { speaker?: string };\n\ninterface CaptionBaseProps {\n captions: Caption[];\n combineTokensWithinMilliseconds?: number;\n holdMs?: number;\n fontSize?: number;\n fontWeight?: number;\n color?: string;\n className?: string;\n}\n\nconst DEFAULT_HOLD_MS = 600;\nconst MIN_SILENCE_BREAK_MS = 300;\n\ninterface CaptionPageWindow {\n page: TikTokPage;\n index: number;\n speaker: string | undefined;\n startMs: number;\n speechEndMs: number;\n endMs: number;\n endsInSilence: boolean;\n}\n\ntype CaptionTokenStatus = \"upcoming\" | \"active\" | \"spoken\";\n\ninterface CaptionTokenState {\n text: string;\n spaceBefore: boolean;\n fromMs: number;\n toMs: number;\n progress: number;\n status: CaptionTokenStatus;\n}\n\ninterface CaptionPreviousPage {\n page: TikTokPage;\n pageIndex: number;\n tokens: CaptionTokenState[];\n}\n\ninterface CaptionsState {\n page: TikTokPage;\n pageIndex: number;\n speaker: string | undefined;\n timeMs: number;\n activeIndex: number;\n tokens: CaptionTokenState[];\n sinceStartMs: number;\n untilEndMs: number;\n holdRoomMs: number;\n endsInSilence: boolean;\n previous: CaptionPreviousPage | null;\n}\n\ninterface CaptionPagingOptions {\n combineTokensWithinMilliseconds: number;\n holdMs?: number;\n}\n\nconst SENTENCE_END = /[.!?…][\"')\\]]*$/;\n\nfunction markPageBreaks(captions: SpeakerCaption[]): Caption[] {\n return captions.map((caption, i) => {\n if (caption.pageBreakAfter !== undefined) return caption;\n const next = captions[i + 1];\n const speakerChanges =\n next !== undefined && next.speaker !== caption.speaker;\n return speakerChanges || SENTENCE_END.test(caption.text.trim())\n ? { ...caption, pageBreakAfter: true }\n : caption;\n });\n}\n\nfunction buildCaptionPages(\n captions: SpeakerCaption[],\n {\n combineTokensWithinMilliseconds,\n holdMs = DEFAULT_HOLD_MS,\n }: CaptionPagingOptions,\n): CaptionPageWindow[] {\n if (captions.length === 0) return [];\n const { pages } = createTikTokStyleCaptions({\n captions: markPageBreaks(captions),\n combineTokensWithinMilliseconds,\n breakOnSilenceAfterMilliseconds: Math.max(holdMs, MIN_SILENCE_BREAK_MS),\n });\n const speakers = new Map<number, string | undefined>();\n for (const caption of captions) {\n if (!speakers.has(caption.startMs)) {\n speakers.set(caption.startMs, caption.speaker);\n }\n }\n const spoken = pages.filter((page) => page.tokens.length > 0);\n return spoken.map((page, index) => {\n const last = page.tokens[page.tokens.length - 1];\n const speechEndMs = last ? last.toMs : page.startMs;\n const heldUntil = speechEndMs + Math.max(0, holdMs);\n const next = spoken[index + 1];\n const endsInSilence = !next || next.startMs > heldUntil;\n const endMs = endsInSilence\n ? heldUntil\n : Math.max(page.startMs, next.startMs);\n return {\n page,\n index,\n speaker: speakers.get(page.tokens[0].fromMs),\n startMs: page.startMs,\n speechEndMs,\n endMs,\n endsInSilence,\n };\n });\n}\n\nfunction findWindowIndex(windows: CaptionPageWindow[], timeMs: number): number {\n let lo = 0;\n let hi = windows.length - 1;\n let found = -1;\n while (lo <= hi) {\n const mid = (lo + hi) >> 1;\n if (windows[mid].startMs <= timeMs) {\n found = mid;\n lo = mid + 1;\n } else {\n hi = mid - 1;\n }\n }\n if (found === -1) return -1;\n return timeMs < windows[found].endMs ? found : -1;\n}\n\nfunction tokenProgress(fromMs: number, toMs: number, timeMs: number): number {\n if (timeMs < fromMs) return 0;\n if (toMs <= fromMs) return 1;\n return Math.min(1, (timeMs - fromMs) / (toMs - fromMs));\n}\n\nfunction getTokenStates(\n page: TikTokPage,\n timeMs: number,\n): { activeIndex: number; tokens: CaptionTokenState[] } {\n let activeIndex = -1;\n page.tokens.forEach((token, i) => {\n if (token.fromMs <= timeMs) activeIndex = i;\n });\n const tokens = page.tokens.map(\n (token, i): CaptionTokenState => ({\n text: token.text.trim(),\n spaceBefore: i > 0 && /^\\s/.test(token.text),\n fromMs: token.fromMs,\n toMs: token.toMs,\n progress: tokenProgress(token.fromMs, token.toMs, timeMs),\n status:\n i < activeIndex ? \"spoken\" : i === activeIndex ? \"active\" : \"upcoming\",\n }),\n );\n return { activeIndex, tokens };\n}\n\nfunction getCaptionsState(\n windows: CaptionPageWindow[],\n timeMs: number,\n): CaptionsState | null {\n const found = findWindowIndex(windows, timeMs);\n if (found === -1) return null;\n const window = windows[found];\n const { activeIndex, tokens } = getTokenStates(window.page, timeMs);\n const before = found > 0 ? windows[found - 1] : null;\n const previous =\n before && !before.endsInSilence\n ? {\n page: before.page,\n pageIndex: before.index,\n tokens: getTokenStates(before.page, before.endMs).tokens,\n }\n : null;\n return {\n page: window.page,\n pageIndex: window.index,\n speaker: window.speaker,\n timeMs,\n activeIndex,\n tokens,\n sinceStartMs: timeMs - window.startMs,\n untilEndMs: window.endMs - timeMs,\n holdRoomMs: window.endMs - window.speechEndMs,\n endsInSilence: window.endsInSilence,\n previous,\n };\n}\n\nfunction getExitWindowMs(state: CaptionsState, exitMs: number): number {\n return Math.max(1, Math.min(exitMs, state.holdRoomMs));\n}\n\nfunction groupCaptionWords(\n tokens: CaptionTokenState[],\n): { index: number; token: CaptionTokenState }[][] {\n const words: { index: number; token: CaptionTokenState }[][] = [];\n tokens.forEach((token, index) => {\n const current = words[words.length - 1];\n if (!current || token.spaceBefore) {\n words.push([{ index, token }]);\n } else {\n current.push({ index, token });\n }\n });\n return words;\n}\n\nfunction normalizeCaptionWord(text: string): string {\n return text\n .toLowerCase()\n .replace(/[\\u2018\\u2019]/g, \"'\")\n .replace(/[^\\p{L}\\p{N}']/gu, \"\");\n}\n\nfunction createKeywordMatcher(\n keywords: readonly string[] = [],\n): (text: string) => boolean {\n const set = new Set(keywords.map(normalizeCaptionWord).filter(Boolean));\n return (text) => set.has(normalizeCaptionWord(text));\n}\n\nfunction captionWordText(word: { token: CaptionTokenState }[]): string {\n return word.map(({ token }) => token.text).join(\"\");\n}\n\ninterface CaptionWordRect {\n left: number;\n top: number;\n width: number;\n height: number;\n}\n\nfunction sameRects(a: CaptionWordRect[], b: CaptionWordRect[]): boolean {\n return (\n a.length === b.length &&\n a.every(\n (r, i) =>\n r.left === b[i].left &&\n r.top === b[i].top &&\n r.width === b[i].width &&\n r.height === b[i].height,\n )\n );\n}\n\nfunction useCaptionWordRects(\n pageIndex: number,\n count: number,\n): {\n wordRef: (index: number) => (el: HTMLElement | null) => void;\n rects: CaptionWordRect[] | null;\n} {\n const elements = useRef<(HTMLElement | null)[]>([]);\n const [measured, setMeasured] = useState<{\n pageIndex: number;\n rects: CaptionWordRect[];\n } | null>(null);\n\n useLayoutEffect(() => {\n if (pageIndex === -1) return;\n const rects = elements.current.slice(0, count).map((el) =>\n el\n ? {\n left: el.offsetLeft,\n top: el.offsetTop,\n width: el.offsetWidth,\n height: el.offsetHeight,\n }\n : { left: 0, top: 0, width: 0, height: 0 },\n );\n setMeasured((prev) =>\n prev && prev.pageIndex === pageIndex && sameRects(prev.rects, rects)\n ? prev\n : { pageIndex, rects },\n );\n });\n\n return {\n wordRef: (index) => (el) => {\n elements.current[index] = el;\n },\n rects: measured && measured.pageIndex === pageIndex ? measured.rects : null,\n };\n}\n\nfunction useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs = DEFAULT_HOLD_MS,\n}: {\n captions: SpeakerCaption[];\n combineTokensWithinMilliseconds: number;\n holdMs?: number;\n}): CaptionsState | null {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const windows = useMemo(\n () =>\n buildCaptionPages(captions, { combineTokensWithinMilliseconds, holdMs }),\n [captions, combineTokensWithinMilliseconds, holdMs],\n );\n return getCaptionsState(windows, (frame / fps) * 1000);\n}\n\ninterface CaptionTypewriterProps extends CaptionBaseProps {\n caret?: boolean;\n shadow?: boolean;\n}\n\nconst EXIT_MS = 220;\nconst BLINK_MS = 500;\nconst LEGIBILITY_SHADOW =\n \"0 2px 3px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.35)\";\nconst CARET_SHADOW = \"0 2px 6px rgba(0, 0, 0, 0.45)\";\n\nfunction typedCount(text: string, progress: number): number {\n const length = Array.from(text).length;\n return Math.min(length, Math.ceil(progress * length));\n}\n\nfunction CaptionTypewriterBase({\n captions,\n combineTokensWithinMilliseconds = 1200,\n holdMs = DEFAULT_HOLD_MS,\n fontSize = 64,\n fontWeight = 800,\n color = \"#ffffff\",\n caret = true,\n shadow = true,\n className,\n}: CaptionTypewriterProps) {\n const state = useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs,\n });\n if (!state) return null;\n\n const exit = state.endsInSilence\n ? interpolate(\n state.untilEndMs,\n [0, getExitWindowMs(state, EXIT_MS)],\n [0, 1],\n {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n },\n )\n : 1;\n\n const active = state.tokens[state.activeIndex];\n const typing = active !== undefined && active.progress < 1;\n const idleMs = active ? state.timeMs - active.toMs : 0;\n const caretOn = typing || Math.floor(idleMs / BLINK_MS) % 2 === 0;\n\n return (\n <div\n className={className}\n style={{\n fontSize,\n fontWeight,\n color,\n lineHeight: 1.2,\n textAlign: \"center\",\n opacity: exit,\n }}\n >\n {groupCaptionWords(state.tokens).map((word, w) => (\n <Fragment key={`${state.pageIndex}-${word[0].index}`}>\n {w > 0 && \" \"}\n <span style={{ display: \"inline-block\", whiteSpace: \"nowrap\" }}>\n {word.map(({ index, token }) => {\n const chars = Array.from(token.text);\n const typed = typedCount(token.text, token.progress);\n return (\n <Fragment key={index}>\n <span\n style={{\n textShadow: shadow ? LEGIBILITY_SHADOW : undefined,\n }}\n >\n {chars.slice(0, typed).join(\"\")}\n </span>\n {caret && index === state.activeIndex ? (\n <span style={{ position: \"relative\" }}>\n <span\n style={{\n position: \"absolute\",\n left: \"0.03em\",\n top: \"0.1em\",\n bottom: \"0.1em\",\n width: \"0.07em\",\n backgroundColor: color,\n boxShadow: shadow ? CARET_SHADOW : undefined,\n opacity: caretOn ? 1 : 0,\n }}\n />\n </span>\n ) : null}\n <span aria-hidden style={{ color: \"transparent\" }}>\n {chars.slice(typed).join(\"\")}\n </span>\n </Fragment>\n );\n })}\n </span>\n </Fragment>\n ))}\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n captions: {\n type: \"remotion-captions\",\n default: [{\n text: \" So\",\n startMs: 300,\n endMs: 460,\n timestampMs: 380,\n confidence: 0.97,\n }, {\n text: \" here's\",\n startMs: 460,\n endMs: 700,\n timestampMs: 580,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 700,\n endMs: 820,\n timestampMs: 760,\n confidence: 0.97,\n }, {\n text: \" thing.\",\n startMs: 820,\n endMs: 1240,\n timestampMs: 1030,\n confidence: 0.97,\n }, {\n text: \" Most\",\n startMs: 1700,\n endMs: 1960,\n timestampMs: 1830,\n confidence: 0.97,\n }, {\n text: \" demo\",\n startMs: 1960,\n endMs: 2240,\n timestampMs: 2100,\n confidence: 0.97,\n }, {\n text: \" videos\",\n startMs: 2240,\n endMs: 2680,\n timestampMs: 2460,\n confidence: 0.97,\n }, {\n text: \" lose\",\n startMs: 2680,\n endMs: 2960,\n timestampMs: 2820,\n confidence: 0.97,\n }, {\n text: \" people\",\n startMs: 2960,\n endMs: 3320,\n timestampMs: 3140,\n confidence: 0.97,\n }, {\n text: \" in\",\n startMs: 3320,\n endMs: 3420,\n timestampMs: 3370,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 3420,\n endMs: 3520,\n timestampMs: 3470,\n confidence: 0.97,\n }, {\n text: \" first\",\n startMs: 3520,\n endMs: 3820,\n timestampMs: 3670,\n confidence: 0.97,\n }, {\n text: \" three\",\n startMs: 3820,\n endMs: 4100,\n timestampMs: 3960,\n confidence: 0.97,\n }, {\n text: \" seconds.\",\n startMs: 4100,\n endMs: 4780,\n timestampMs: 4440,\n confidence: 0.97,\n }, {\n text: \" Captions\",\n startMs: 5400,\n endMs: 5920,\n timestampMs: 5660,\n confidence: 0.97,\n }, {\n text: \" keep\",\n startMs: 5920,\n endMs: 6140,\n timestampMs: 6030,\n confidence: 0.97,\n }, {\n text: \" them\",\n startMs: 6140,\n endMs: 6300,\n timestampMs: 6220,\n confidence: 0.97,\n }, {\n text: \" watching,\",\n startMs: 6300,\n endMs: 6860,\n timestampMs: 6580,\n confidence: 0.97,\n }, {\n text: \" even\",\n startMs: 6960,\n endMs: 7180,\n timestampMs: 7070,\n confidence: 0.97,\n }, {\n text: \" with\",\n startMs: 7180,\n endMs: 7320,\n timestampMs: 7250,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 7320,\n endMs: 7420,\n timestampMs: 7370,\n confidence: 0.97,\n }, {\n text: \" sound\",\n startMs: 7420,\n endMs: 7760,\n timestampMs: 7590,\n confidence: 0.97,\n }, {\n text: \" off.\",\n startMs: 7760,\n endMs: 8300,\n timestampMs: 8030,\n confidence: 0.97,\n }],\n description: \"Transcript\",\n keyframable: false,\n },\n fontSize: {\n type: \"number\",\n min: 24,\n max: 140,\n step: 1,\n default: 64,\n description: \"Font size\",\n hiddenFromList: false,\n },\n fontWeight: {\n type: \"number\",\n min: 400,\n max: 900,\n step: 100,\n default: 800,\n description: \"Font weight\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#ffffff\",\n description: \"Text color\",\n },\n combineTokensWithinMilliseconds: {\n type: \"number\",\n min: 0,\n max: 3000,\n step: 100,\n default: 1200,\n description: \"Page window (ms)\",\n hiddenFromList: false,\n },\n holdMs: {\n type: \"number\",\n min: 0,\n max: 2000,\n step: 50,\n default: 600,\n description: \"Hold (ms)\",\n hiddenFromList: false,\n },\n caret: {\n type: \"boolean\",\n default: true,\n description: \"Caret\",\n },\n shadow: {\n type: \"boolean\",\n default: true,\n description: \"Shadow\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"captions\",\"fontSize\",\"fontWeight\",\"color\",\"combineTokensWithinMilliseconds\",\"holdMs\",\"caret\",\"shadow\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n captions: [{\n text: \" So\",\n startMs: 300,\n endMs: 460,\n timestampMs: 380,\n confidence: 0.97,\n }, {\n text: \" here's\",\n startMs: 460,\n endMs: 700,\n timestampMs: 580,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 700,\n endMs: 820,\n timestampMs: 760,\n confidence: 0.97,\n }, {\n text: \" thing.\",\n startMs: 820,\n endMs: 1240,\n timestampMs: 1030,\n confidence: 0.97,\n }, {\n text: \" Most\",\n startMs: 1700,\n endMs: 1960,\n timestampMs: 1830,\n confidence: 0.97,\n }, {\n text: \" demo\",\n startMs: 1960,\n endMs: 2240,\n timestampMs: 2100,\n confidence: 0.97,\n }, {\n text: \" videos\",\n startMs: 2240,\n endMs: 2680,\n timestampMs: 2460,\n confidence: 0.97,\n }, {\n text: \" lose\",\n startMs: 2680,\n endMs: 2960,\n timestampMs: 2820,\n confidence: 0.97,\n }, {\n text: \" people\",\n startMs: 2960,\n endMs: 3320,\n timestampMs: 3140,\n confidence: 0.97,\n }, {\n text: \" in\",\n startMs: 3320,\n endMs: 3420,\n timestampMs: 3370,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 3420,\n endMs: 3520,\n timestampMs: 3470,\n confidence: 0.97,\n }, {\n text: \" first\",\n startMs: 3520,\n endMs: 3820,\n timestampMs: 3670,\n confidence: 0.97,\n }, {\n text: \" three\",\n startMs: 3820,\n endMs: 4100,\n timestampMs: 3960,\n confidence: 0.97,\n }, {\n text: \" seconds.\",\n startMs: 4100,\n endMs: 4780,\n timestampMs: 4440,\n confidence: 0.97,\n }, {\n text: \" Captions\",\n startMs: 5400,\n endMs: 5920,\n timestampMs: 5660,\n confidence: 0.97,\n }, {\n text: \" keep\",\n startMs: 5920,\n endMs: 6140,\n timestampMs: 6030,\n confidence: 0.97,\n }, {\n text: \" them\",\n startMs: 6140,\n endMs: 6300,\n timestampMs: 6220,\n confidence: 0.97,\n }, {\n text: \" watching,\",\n startMs: 6300,\n endMs: 6860,\n timestampMs: 6580,\n confidence: 0.97,\n }, {\n text: \" even\",\n startMs: 6960,\n endMs: 7180,\n timestampMs: 7070,\n confidence: 0.97,\n }, {\n text: \" with\",\n startMs: 7180,\n endMs: 7320,\n timestampMs: 7250,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 7320,\n endMs: 7420,\n timestampMs: 7370,\n confidence: 0.97,\n }, {\n text: \" sound\",\n startMs: 7420,\n endMs: 7760,\n timestampMs: 7590,\n confidence: 0.97,\n }, {\n text: \" off.\",\n startMs: 7760,\n endMs: 8300,\n timestampMs: 8030,\n confidence: 0.97,\n }],\n fontSize: 64,\n fontWeight: 800,\n color: \"#ffffff\",\n combineTokensWithinMilliseconds: 1200,\n holdMs: 600,\n caret: true,\n shadow: true,\n};\n\ntype CaptionTypewriterElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof CaptionTypewriterBase>;\n\nconst CaptionTypewriterInner = forwardRef<\n HTMLDivElement,\n CaptionTypewriterElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<CaptionTypewriter>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <CaptionTypewriterBase\n {...(componentProps as unknown as ComponentProps<typeof CaptionTypewriterBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const CaptionTypewriter = Interactive.withSchema({\n Component: CaptionTypewriterInner,\n componentName: \"<CaptionTypewriter>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"+ },+ "durationInFrames": 279+}diff --git a/registry-artifacts/elements/caption-underline.json b/registry-artifacts/elements/caption-underline.jsonnew file mode 100644index 00000000..52a5f5da--- /dev/null+++ b/registry-artifacts/elements/caption-underline.json@@ -0,0 +1,21 @@+{+ "type": "remotion-element",+ "version": 1,+ "element": {+ "assets": [],+ "dependencies": [+ {+ "name": "@remotion/captions",+ "version": null+ }+ ],+ "dimensions": null,+ "displayName": "Caption Underline",+ "durationInFrames": 279,+ "initialProps": null,+ "installationMode": "component-owned-sequence",+ "slug": "caption-underline",+ "sourceCode": "import { Fragment, forwardRef, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState, type ComponentProps } from \"react\";\nimport { Easing, Interactive, Sequence, interpolate, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { createTikTokStyleCaptions, type Caption, type TikTokPage } from \"@remotion/captions\";\n\ntype SpeakerCaption = Caption & { speaker?: string };\n\ninterface CaptionBaseProps {\n captions: Caption[];\n combineTokensWithinMilliseconds?: number;\n holdMs?: number;\n fontSize?: number;\n fontWeight?: number;\n color?: string;\n className?: string;\n}\n\nconst DEFAULT_HOLD_MS = 600;\nconst MIN_SILENCE_BREAK_MS = 300;\n\ninterface CaptionPageWindow {\n page: TikTokPage;\n index: number;\n speaker: string | undefined;\n startMs: number;\n speechEndMs: number;\n endMs: number;\n endsInSilence: boolean;\n}\n\ntype CaptionTokenStatus = \"upcoming\" | \"active\" | \"spoken\";\n\ninterface CaptionTokenState {\n text: string;\n spaceBefore: boolean;\n fromMs: number;\n toMs: number;\n progress: number;\n status: CaptionTokenStatus;\n}\n\ninterface CaptionPreviousPage {\n page: TikTokPage;\n pageIndex: number;\n tokens: CaptionTokenState[];\n}\n\ninterface CaptionsState {\n page: TikTokPage;\n pageIndex: number;\n speaker: string | undefined;\n timeMs: number;\n activeIndex: number;\n tokens: CaptionTokenState[];\n sinceStartMs: number;\n untilEndMs: number;\n holdRoomMs: number;\n endsInSilence: boolean;\n previous: CaptionPreviousPage | null;\n}\n\ninterface CaptionPagingOptions {\n combineTokensWithinMilliseconds: number;\n holdMs?: number;\n}\n\nconst SENTENCE_END = /[.!?…][\"')\\]]*$/;\n\nfunction markPageBreaks(captions: SpeakerCaption[]): Caption[] {\n return captions.map((caption, i) => {\n if (caption.pageBreakAfter !== undefined) return caption;\n const next = captions[i + 1];\n const speakerChanges =\n next !== undefined && next.speaker !== caption.speaker;\n return speakerChanges || SENTENCE_END.test(caption.text.trim())\n ? { ...caption, pageBreakAfter: true }\n : caption;\n });\n}\n\nfunction buildCaptionPages(\n captions: SpeakerCaption[],\n {\n combineTokensWithinMilliseconds,\n holdMs = DEFAULT_HOLD_MS,\n }: CaptionPagingOptions,\n): CaptionPageWindow[] {\n if (captions.length === 0) return [];\n const { pages } = createTikTokStyleCaptions({\n captions: markPageBreaks(captions),\n combineTokensWithinMilliseconds,\n breakOnSilenceAfterMilliseconds: Math.max(holdMs, MIN_SILENCE_BREAK_MS),\n });\n const speakers = new Map<number, string | undefined>();\n for (const caption of captions) {\n if (!speakers.has(caption.startMs)) {\n speakers.set(caption.startMs, caption.speaker);\n }\n }\n const spoken = pages.filter((page) => page.tokens.length > 0);\n return spoken.map((page, index) => {\n const last = page.tokens[page.tokens.length - 1];\n const speechEndMs = last ? last.toMs : page.startMs;\n const heldUntil = speechEndMs + Math.max(0, holdMs);\n const next = spoken[index + 1];\n const endsInSilence = !next || next.startMs > heldUntil;\n const endMs = endsInSilence\n ? heldUntil\n : Math.max(page.startMs, next.startMs);\n return {\n page,\n index,\n speaker: speakers.get(page.tokens[0].fromMs),\n startMs: page.startMs,\n speechEndMs,\n endMs,\n endsInSilence,\n };\n });\n}\n\nfunction findWindowIndex(windows: CaptionPageWindow[], timeMs: number): number {\n let lo = 0;\n let hi = windows.length - 1;\n let found = -1;\n while (lo <= hi) {\n const mid = (lo + hi) >> 1;\n if (windows[mid].startMs <= timeMs) {\n found = mid;\n lo = mid + 1;\n } else {\n hi = mid - 1;\n }\n }\n if (found === -1) return -1;\n return timeMs < windows[found].endMs ? found : -1;\n}\n\nfunction tokenProgress(fromMs: number, toMs: number, timeMs: number): number {\n if (timeMs < fromMs) return 0;\n if (toMs <= fromMs) return 1;\n return Math.min(1, (timeMs - fromMs) / (toMs - fromMs));\n}\n\nfunction getTokenStates(\n page: TikTokPage,\n timeMs: number,\n): { activeIndex: number; tokens: CaptionTokenState[] } {\n let activeIndex = -1;\n page.tokens.forEach((token, i) => {\n if (token.fromMs <= timeMs) activeIndex = i;\n });\n const tokens = page.tokens.map(\n (token, i): CaptionTokenState => ({\n text: token.text.trim(),\n spaceBefore: i > 0 && /^\\s/.test(token.text),\n fromMs: token.fromMs,\n toMs: token.toMs,\n progress: tokenProgress(token.fromMs, token.toMs, timeMs),\n status:\n i < activeIndex ? \"spoken\" : i === activeIndex ? \"active\" : \"upcoming\",\n }),\n );\n return { activeIndex, tokens };\n}\n\nfunction getCaptionsState(\n windows: CaptionPageWindow[],\n timeMs: number,\n): CaptionsState | null {\n const found = findWindowIndex(windows, timeMs);\n if (found === -1) return null;\n const window = windows[found];\n const { activeIndex, tokens } = getTokenStates(window.page, timeMs);\n const before = found > 0 ? windows[found - 1] : null;\n const previous =\n before && !before.endsInSilence\n ? {\n page: before.page,\n pageIndex: before.index,\n tokens: getTokenStates(before.page, before.endMs).tokens,\n }\n : null;\n return {\n page: window.page,\n pageIndex: window.index,\n speaker: window.speaker,\n timeMs,\n activeIndex,\n tokens,\n sinceStartMs: timeMs - window.startMs,\n untilEndMs: window.endMs - timeMs,\n holdRoomMs: window.endMs - window.speechEndMs,\n endsInSilence: window.endsInSilence,\n previous,\n };\n}\n\nfunction getExitWindowMs(state: CaptionsState, exitMs: number): number {\n return Math.max(1, Math.min(exitMs, state.holdRoomMs));\n}\n\nfunction groupCaptionWords(\n tokens: CaptionTokenState[],\n): { index: number; token: CaptionTokenState }[][] {\n const words: { index: number; token: CaptionTokenState }[][] = [];\n tokens.forEach((token, index) => {\n const current = words[words.length - 1];\n if (!current || token.spaceBefore) {\n words.push([{ index, token }]);\n } else {\n current.push({ index, token });\n }\n });\n return words;\n}\n\nfunction normalizeCaptionWord(text: string): string {\n return text\n .toLowerCase()\n .replace(/[\\u2018\\u2019]/g, \"'\")\n .replace(/[^\\p{L}\\p{N}']/gu, \"\");\n}\n\nfunction createKeywordMatcher(\n keywords: readonly string[] = [],\n): (text: string) => boolean {\n const set = new Set(keywords.map(normalizeCaptionWord).filter(Boolean));\n return (text) => set.has(normalizeCaptionWord(text));\n}\n\nfunction captionWordText(word: { token: CaptionTokenState }[]): string {\n return word.map(({ token }) => token.text).join(\"\");\n}\n\ninterface CaptionWordRect {\n left: number;\n top: number;\n width: number;\n height: number;\n}\n\nfunction sameRects(a: CaptionWordRect[], b: CaptionWordRect[]): boolean {\n return (\n a.length === b.length &&\n a.every(\n (r, i) =>\n r.left === b[i].left &&\n r.top === b[i].top &&\n r.width === b[i].width &&\n r.height === b[i].height,\n )\n );\n}\n\nfunction useCaptionWordRects(\n pageIndex: number,\n count: number,\n): {\n wordRef: (index: number) => (el: HTMLElement | null) => void;\n rects: CaptionWordRect[] | null;\n} {\n const elements = useRef<(HTMLElement | null)[]>([]);\n const [measured, setMeasured] = useState<{\n pageIndex: number;\n rects: CaptionWordRect[];\n } | null>(null);\n\n useLayoutEffect(() => {\n if (pageIndex === -1) return;\n const rects = elements.current.slice(0, count).map((el) =>\n el\n ? {\n left: el.offsetLeft,\n top: el.offsetTop,\n width: el.offsetWidth,\n height: el.offsetHeight,\n }\n : { left: 0, top: 0, width: 0, height: 0 },\n );\n setMeasured((prev) =>\n prev && prev.pageIndex === pageIndex && sameRects(prev.rects, rects)\n ? prev\n : { pageIndex, rects },\n );\n });\n\n return {\n wordRef: (index) => (el) => {\n elements.current[index] = el;\n },\n rects: measured && measured.pageIndex === pageIndex ? measured.rects : null,\n };\n}\n\nfunction useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs = DEFAULT_HOLD_MS,\n}: {\n captions: SpeakerCaption[];\n combineTokensWithinMilliseconds: number;\n holdMs?: number;\n}): CaptionsState | null {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const windows = useMemo(\n () =>\n buildCaptionPages(captions, { combineTokensWithinMilliseconds, holdMs }),\n [captions, combineTokensWithinMilliseconds, holdMs],\n );\n return getCaptionsState(windows, (frame / fps) * 1000);\n}\n\ninterface CaptionUnderlineProps extends CaptionBaseProps {\n underlineColor?: string;\n thickness?: number;\n underlineOffset?: number;\n shadow?: boolean;\n}\n\nconst ENTER_MS = 160;\nconst EXIT_MS = 220;\nconst RISE_EM = 0.14;\nconst TRAVEL_MS = 120;\nconst LEGIBILITY_SHADOW =\n \"0 2px 3px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.35)\";\n\nconst enterEasing = Easing.bezier(0.2, 0.8, 0.2, 1);\nconst travelEasing = Easing.bezier(0.3, 0, 0.2, 1);\n\nconst clamp = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n} as const;\n\nfunction mix(a: number, b: number, t: number): number {\n return a + (b - a) * t;\n}\n\nfunction CaptionUnderlineBase({\n captions,\n combineTokensWithinMilliseconds = 1200,\n holdMs = DEFAULT_HOLD_MS,\n fontSize = 64,\n fontWeight = 800,\n color = \"#ffffff\",\n underlineColor = \"#facc15\",\n thickness = 0.08,\n underlineOffset = 0.02,\n shadow = true,\n className,\n}: CaptionUnderlineProps) {\n const state = useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs,\n });\n const words = state ? groupCaptionWords(state.tokens) : [];\n const pageIndex = state ? state.pageIndex : -1;\n const { wordRef, rects } = useCaptionWordRects(pageIndex, words.length);\n\n if (!state) return null;\n\n const enter = interpolate(\n state.previous ? ENTER_MS : state.sinceStartMs,\n [0, ENTER_MS],\n [0, 1],\n {\n ...clamp,\n easing: enterEasing,\n },\n );\n const exit = state.endsInSilence\n ? interpolate(\n state.untilEndMs,\n [0, getExitWindowMs(state, EXIT_MS)],\n [0, 1],\n clamp,\n )\n : 1;\n\n const activeWord = words.findIndex((word) =>\n word.some(({ index }) => index === state.activeIndex),\n );\n const travel =\n activeWord >= 0\n ? interpolate(\n state.timeMs - words[activeWord][0].token.fromMs,\n [0, TRAVEL_MS],\n [0, 1],\n { ...clamp, easing: travelEasing },\n )\n : 0;\n\n const target = rects && activeWord >= 0 ? rects[activeWord] : null;\n const origin = rects && activeWord > 0 ? rects[activeWord - 1] : null;\n const barHeight = thickness * fontSize;\n const gap = underlineOffset * fontSize;\n const bar = target\n ? origin\n ? {\n left: mix(origin.left, target.left, travel),\n top: mix(\n origin.top + origin.height,\n target.top + target.height,\n travel,\n ),\n width: mix(origin.width, target.width, travel),\n opacity: 1,\n }\n : {\n left: target.left,\n top: target.top + target.height,\n width: target.width * travel,\n opacity: travel,\n }\n : null;\n\n return (\n <div\n className={className}\n style={{\n position: \"relative\",\n fontSize,\n fontWeight,\n color,\n lineHeight: 1.2,\n textAlign: \"center\",\n opacity: Math.min(enter, exit),\n transform: `translateY(${(1 - enter) * RISE_EM}em)`,\n }}\n >\n {words.map((word, w) => (\n <Fragment key={`${state.pageIndex}-${word[0].index}`}>\n {w > 0 && \" \"}\n <span\n ref={wordRef(w)}\n style={{\n position: \"relative\",\n display: \"inline-block\",\n whiteSpace: \"nowrap\",\n textShadow: shadow ? LEGIBILITY_SHADOW : undefined,\n }}\n >\n {word.map(({ index, token }) => (\n <span key={index}>{token.text}</span>\n ))}\n </span>\n </Fragment>\n ))}\n {bar && (\n <span\n aria-hidden\n style={{\n position: \"absolute\",\n left: bar.left,\n top: bar.top + gap,\n width: bar.width,\n height: barHeight,\n borderRadius: barHeight / 2,\n background: underlineColor,\n opacity: bar.opacity,\n }}\n />\n )}\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n captions: {\n type: \"remotion-captions\",\n default: [{\n text: \" So\",\n startMs: 300,\n endMs: 460,\n timestampMs: 380,\n confidence: 0.97,\n }, {\n text: \" here's\",\n startMs: 460,\n endMs: 700,\n timestampMs: 580,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 700,\n endMs: 820,\n timestampMs: 760,\n confidence: 0.97,\n }, {\n text: \" thing.\",\n startMs: 820,\n endMs: 1240,\n timestampMs: 1030,\n confidence: 0.97,\n }, {\n text: \" Most\",\n startMs: 1700,\n endMs: 1960,\n timestampMs: 1830,\n confidence: 0.97,\n }, {\n text: \" demo\",\n startMs: 1960,\n endMs: 2240,\n timestampMs: 2100,\n confidence: 0.97,\n }, {\n text: \" videos\",\n startMs: 2240,\n endMs: 2680,\n timestampMs: 2460,\n confidence: 0.97,\n }, {\n text: \" lose\",\n startMs: 2680,\n endMs: 2960,\n timestampMs: 2820,\n confidence: 0.97,\n }, {\n text: \" people\",\n startMs: 2960,\n endMs: 3320,\n timestampMs: 3140,\n confidence: 0.97,\n }, {\n text: \" in\",\n startMs: 3320,\n endMs: 3420,\n timestampMs: 3370,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 3420,\n endMs: 3520,\n timestampMs: 3470,\n confidence: 0.97,\n }, {\n text: \" first\",\n startMs: 3520,\n endMs: 3820,\n timestampMs: 3670,\n confidence: 0.97,\n }, {\n text: \" three\",\n startMs: 3820,\n endMs: 4100,\n timestampMs: 3960,\n confidence: 0.97,\n }, {\n text: \" seconds.\",\n startMs: 4100,\n endMs: 4780,\n timestampMs: 4440,\n confidence: 0.97,\n }, {\n text: \" Captions\",\n startMs: 5400,\n endMs: 5920,\n timestampMs: 5660,\n confidence: 0.97,\n }, {\n text: \" keep\",\n startMs: 5920,\n endMs: 6140,\n timestampMs: 6030,\n confidence: 0.97,\n }, {\n text: \" them\",\n startMs: 6140,\n endMs: 6300,\n timestampMs: 6220,\n confidence: 0.97,\n }, {\n text: \" watching,\",\n startMs: 6300,\n endMs: 6860,\n timestampMs: 6580,\n confidence: 0.97,\n }, {\n text: \" even\",\n startMs: 6960,\n endMs: 7180,\n timestampMs: 7070,\n confidence: 0.97,\n }, {\n text: \" with\",\n startMs: 7180,\n endMs: 7320,\n timestampMs: 7250,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 7320,\n endMs: 7420,\n timestampMs: 7370,\n confidence: 0.97,\n }, {\n text: \" sound\",\n startMs: 7420,\n endMs: 7760,\n timestampMs: 7590,\n confidence: 0.97,\n }, {\n text: \" off.\",\n startMs: 7760,\n endMs: 8300,\n timestampMs: 8030,\n confidence: 0.97,\n }],\n description: \"Transcript\",\n keyframable: false,\n },\n fontSize: {\n type: \"number\",\n min: 24,\n max: 140,\n step: 1,\n default: 64,\n description: \"Font size\",\n hiddenFromList: false,\n },\n fontWeight: {\n type: \"number\",\n min: 400,\n max: 900,\n step: 100,\n default: 800,\n description: \"Font weight\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#ffffff\",\n description: \"Text color\",\n },\n underlineColor: {\n type: \"color\",\n default: \"#facc15\",\n description: \"Underline color\",\n },\n thickness: {\n type: \"number\",\n min: 0.02,\n max: 0.3,\n step: 0.01,\n default: 0.08,\n description: \"Thickness (em)\",\n hiddenFromList: false,\n },\n underlineOffset: {\n type: \"number\",\n min: -0.2,\n max: 0.4,\n step: 0.01,\n default: 0.02,\n description: \"Offset (em)\",\n hiddenFromList: false,\n },\n combineTokensWithinMilliseconds: {\n type: \"number\",\n min: 0,\n max: 3000,\n step: 100,\n default: 1200,\n description: \"Page window (ms)\",\n hiddenFromList: false,\n },\n holdMs: {\n type: \"number\",\n min: 0,\n max: 2000,\n step: 50,\n default: 600,\n description: \"Hold (ms)\",\n hiddenFromList: false,\n },\n shadow: {\n type: \"boolean\",\n default: true,\n description: \"Shadow\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"captions\",\"fontSize\",\"fontWeight\",\"color\",\"underlineColor\",\"thickness\",\"underlineOffset\",\"combineTokensWithinMilliseconds\",\"holdMs\",\"shadow\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n captions: [{\n text: \" So\",\n startMs: 300,\n endMs: 460,\n timestampMs: 380,\n confidence: 0.97,\n }, {\n text: \" here's\",\n startMs: 460,\n endMs: 700,\n timestampMs: 580,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 700,\n endMs: 820,\n timestampMs: 760,\n confidence: 0.97,\n }, {\n text: \" thing.\",\n startMs: 820,\n endMs: 1240,\n timestampMs: 1030,\n confidence: 0.97,\n }, {\n text: \" Most\",\n startMs: 1700,\n endMs: 1960,\n timestampMs: 1830,\n confidence: 0.97,\n }, {\n text: \" demo\",\n startMs: 1960,\n endMs: 2240,\n timestampMs: 2100,\n confidence: 0.97,\n }, {\n text: \" videos\",\n startMs: 2240,\n endMs: 2680,\n timestampMs: 2460,\n confidence: 0.97,\n }, {\n text: \" lose\",\n startMs: 2680,\n endMs: 2960,\n timestampMs: 2820,\n confidence: 0.97,\n }, {\n text: \" people\",\n startMs: 2960,\n endMs: 3320,\n timestampMs: 3140,\n confidence: 0.97,\n }, {\n text: \" in\",\n startMs: 3320,\n endMs: 3420,\n timestampMs: 3370,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 3420,\n endMs: 3520,\n timestampMs: 3470,\n confidence: 0.97,\n }, {\n text: \" first\",\n startMs: 3520,\n endMs: 3820,\n timestampMs: 3670,\n confidence: 0.97,\n }, {\n text: \" three\",\n startMs: 3820,\n endMs: 4100,\n timestampMs: 3960,\n confidence: 0.97,\n }, {\n text: \" seconds.\",\n startMs: 4100,\n endMs: 4780,\n timestampMs: 4440,\n confidence: 0.97,\n }, {\n text: \" Captions\",\n startMs: 5400,\n endMs: 5920,\n timestampMs: 5660,\n confidence: 0.97,\n }, {\n text: \" keep\",\n startMs: 5920,\n endMs: 6140,\n timestampMs: 6030,\n confidence: 0.97,\n }, {\n text: \" them\",\n startMs: 6140,\n endMs: 6300,\n timestampMs: 6220,\n confidence: 0.97,\n }, {\n text: \" watching,\",\n startMs: 6300,\n endMs: 6860,\n timestampMs: 6580,\n confidence: 0.97,\n }, {\n text: \" even\",\n startMs: 6960,\n endMs: 7180,\n timestampMs: 7070,\n confidence: 0.97,\n }, {\n text: \" with\",\n startMs: 7180,\n endMs: 7320,\n timestampMs: 7250,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 7320,\n endMs: 7420,\n timestampMs: 7370,\n confidence: 0.97,\n }, {\n text: \" sound\",\n startMs: 7420,\n endMs: 7760,\n timestampMs: 7590,\n confidence: 0.97,\n }, {\n text: \" off.\",\n startMs: 7760,\n endMs: 8300,\n timestampMs: 8030,\n confidence: 0.97,\n }],\n fontSize: 64,\n fontWeight: 800,\n color: \"#ffffff\",\n underlineColor: \"#facc15\",\n thickness: 0.08,\n underlineOffset: 0.02,\n combineTokensWithinMilliseconds: 1200,\n holdMs: 600,\n shadow: true,\n};\n\ntype CaptionUnderlineElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof CaptionUnderlineBase>;\n\nconst CaptionUnderlineInner = forwardRef<\n HTMLDivElement,\n CaptionUnderlineElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<CaptionUnderline>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <CaptionUnderlineBase\n {...(componentProps as unknown as ComponentProps<typeof CaptionUnderlineBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const CaptionUnderline = Interactive.withSchema({\n Component: CaptionUnderlineInner,\n componentName: \"<CaptionUnderline>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"+ },+ "durationInFrames": 279+}diff --git a/registry-artifacts/elements/caption-weight.json b/registry-artifacts/elements/caption-weight.jsonnew file mode 100644index 00000000..006eb0f1--- /dev/null+++ b/registry-artifacts/elements/caption-weight.json@@ -0,0 +1,21 @@+{+ "type": "remotion-element",+ "version": 1,+ "element": {+ "assets": [],+ "dependencies": [+ {+ "name": "@remotion/captions",+ "version": null+ }+ ],+ "dimensions": null,+ "displayName": "Caption Weight",+ "durationInFrames": 279,+ "initialProps": null,+ "installationMode": "component-owned-sequence",+ "slug": "caption-weight",+ "sourceCode": "import { Fragment, forwardRef, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState, type ComponentProps } from \"react\";\nimport { Easing, Interactive, Sequence, interpolate, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { createTikTokStyleCaptions, type Caption, type TikTokPage } from \"@remotion/captions\";\n\ntype SpeakerCaption = Caption & { speaker?: string };\n\ninterface CaptionBaseProps {\n captions: Caption[];\n combineTokensWithinMilliseconds?: number;\n holdMs?: number;\n fontSize?: number;\n fontWeight?: number;\n color?: string;\n className?: string;\n}\n\nconst DEFAULT_HOLD_MS = 600;\nconst MIN_SILENCE_BREAK_MS = 300;\n\ninterface CaptionPageWindow {\n page: TikTokPage;\n index: number;\n speaker: string | undefined;\n startMs: number;\n speechEndMs: number;\n endMs: number;\n endsInSilence: boolean;\n}\n\ntype CaptionTokenStatus = \"upcoming\" | \"active\" | \"spoken\";\n\ninterface CaptionTokenState {\n text: string;\n spaceBefore: boolean;\n fromMs: number;\n toMs: number;\n progress: number;\n status: CaptionTokenStatus;\n}\n\ninterface CaptionPreviousPage {\n page: TikTokPage;\n pageIndex: number;\n tokens: CaptionTokenState[];\n}\n\ninterface CaptionsState {\n page: TikTokPage;\n pageIndex: number;\n speaker: string | undefined;\n timeMs: number;\n activeIndex: number;\n tokens: CaptionTokenState[];\n sinceStartMs: number;\n untilEndMs: number;\n holdRoomMs: number;\n endsInSilence: boolean;\n previous: CaptionPreviousPage | null;\n}\n\ninterface CaptionPagingOptions {\n combineTokensWithinMilliseconds: number;\n holdMs?: number;\n}\n\nconst SENTENCE_END = /[.!?…][\"')\\]]*$/;\n\nfunction markPageBreaks(captions: SpeakerCaption[]): Caption[] {\n return captions.map((caption, i) => {\n if (caption.pageBreakAfter !== undefined) return caption;\n const next = captions[i + 1];\n const speakerChanges =\n next !== undefined && next.speaker !== caption.speaker;\n return speakerChanges || SENTENCE_END.test(caption.text.trim())\n ? { ...caption, pageBreakAfter: true }\n : caption;\n });\n}\n\nfunction buildCaptionPages(\n captions: SpeakerCaption[],\n {\n combineTokensWithinMilliseconds,\n holdMs = DEFAULT_HOLD_MS,\n }: CaptionPagingOptions,\n): CaptionPageWindow[] {\n if (captions.length === 0) return [];\n const { pages } = createTikTokStyleCaptions({\n captions: markPageBreaks(captions),\n combineTokensWithinMilliseconds,\n breakOnSilenceAfterMilliseconds: Math.max(holdMs, MIN_SILENCE_BREAK_MS),\n });\n const speakers = new Map<number, string | undefined>();\n for (const caption of captions) {\n if (!speakers.has(caption.startMs)) {\n speakers.set(caption.startMs, caption.speaker);\n }\n }\n const spoken = pages.filter((page) => page.tokens.length > 0);\n return spoken.map((page, index) => {\n const last = page.tokens[page.tokens.length - 1];\n const speechEndMs = last ? last.toMs : page.startMs;\n const heldUntil = speechEndMs + Math.max(0, holdMs);\n const next = spoken[index + 1];\n const endsInSilence = !next || next.startMs > heldUntil;\n const endMs = endsInSilence\n ? heldUntil\n : Math.max(page.startMs, next.startMs);\n return {\n page,\n index,\n speaker: speakers.get(page.tokens[0].fromMs),\n startMs: page.startMs,\n speechEndMs,\n endMs,\n endsInSilence,\n };\n });\n}\n\nfunction findWindowIndex(windows: CaptionPageWindow[], timeMs: number): number {\n let lo = 0;\n let hi = windows.length - 1;\n let found = -1;\n while (lo <= hi) {\n const mid = (lo + hi) >> 1;\n if (windows[mid].startMs <= timeMs) {\n found = mid;\n lo = mid + 1;\n } else {\n hi = mid - 1;\n }\n }\n if (found === -1) return -1;\n return timeMs < windows[found].endMs ? found : -1;\n}\n\nfunction tokenProgress(fromMs: number, toMs: number, timeMs: number): number {\n if (timeMs < fromMs) return 0;\n if (toMs <= fromMs) return 1;\n return Math.min(1, (timeMs - fromMs) / (toMs - fromMs));\n}\n\nfunction getTokenStates(\n page: TikTokPage,\n timeMs: number,\n): { activeIndex: number; tokens: CaptionTokenState[] } {\n let activeIndex = -1;\n page.tokens.forEach((token, i) => {\n if (token.fromMs <= timeMs) activeIndex = i;\n });\n const tokens = page.tokens.map(\n (token, i): CaptionTokenState => ({\n text: token.text.trim(),\n spaceBefore: i > 0 && /^\\s/.test(token.text),\n fromMs: token.fromMs,\n toMs: token.toMs,\n progress: tokenProgress(token.fromMs, token.toMs, timeMs),\n status:\n i < activeIndex ? \"spoken\" : i === activeIndex ? \"active\" : \"upcoming\",\n }),\n );\n return { activeIndex, tokens };\n}\n\nfunction getCaptionsState(\n windows: CaptionPageWindow[],\n timeMs: number,\n): CaptionsState | null {\n const found = findWindowIndex(windows, timeMs);\n if (found === -1) return null;\n const window = windows[found];\n const { activeIndex, tokens } = getTokenStates(window.page, timeMs);\n const before = found > 0 ? windows[found - 1] : null;\n const previous =\n before && !before.endsInSilence\n ? {\n page: before.page,\n pageIndex: before.index,\n tokens: getTokenStates(before.page, before.endMs).tokens,\n }\n : null;\n return {\n page: window.page,\n pageIndex: window.index,\n speaker: window.speaker,\n timeMs,\n activeIndex,\n tokens,\n sinceStartMs: timeMs - window.startMs,\n untilEndMs: window.endMs - timeMs,\n holdRoomMs: window.endMs - window.speechEndMs,\n endsInSilence: window.endsInSilence,\n previous,\n };\n}\n\nfunction getExitWindowMs(state: CaptionsState, exitMs: number): number {\n return Math.max(1, Math.min(exitMs, state.holdRoomMs));\n}\n\nfunction groupCaptionWords(\n tokens: CaptionTokenState[],\n): { index: number; token: CaptionTokenState }[][] {\n const words: { index: number; token: CaptionTokenState }[][] = [];\n tokens.forEach((token, index) => {\n const current = words[words.length - 1];\n if (!current || token.spaceBefore) {\n words.push([{ index, token }]);\n } else {\n current.push({ index, token });\n }\n });\n return words;\n}\n\nfunction normalizeCaptionWord(text: string): string {\n return text\n .toLowerCase()\n .replace(/[\\u2018\\u2019]/g, \"'\")\n .replace(/[^\\p{L}\\p{N}']/gu, \"\");\n}\n\nfunction createKeywordMatcher(\n keywords: readonly string[] = [],\n): (text: string) => boolean {\n const set = new Set(keywords.map(normalizeCaptionWord).filter(Boolean));\n return (text) => set.has(normalizeCaptionWord(text));\n}\n\nfunction captionWordText(word: { token: CaptionTokenState }[]): string {\n return word.map(({ token }) => token.text).join(\"\");\n}\n\ninterface CaptionWordRect {\n left: number;\n top: number;\n width: number;\n height: number;\n}\n\nfunction sameRects(a: CaptionWordRect[], b: CaptionWordRect[]): boolean {\n return (\n a.length === b.length &&\n a.every(\n (r, i) =>\n r.left === b[i].left &&\n r.top === b[i].top &&\n r.width === b[i].width &&\n r.height === b[i].height,\n )\n );\n}\n\nfunction useCaptionWordRects(\n pageIndex: number,\n count: number,\n): {\n wordRef: (index: number) => (el: HTMLElement | null) => void;\n rects: CaptionWordRect[] | null;\n} {\n const elements = useRef<(HTMLElement | null)[]>([]);\n const [measured, setMeasured] = useState<{\n pageIndex: number;\n rects: CaptionWordRect[];\n } | null>(null);\n\n useLayoutEffect(() => {\n if (pageIndex === -1) return;\n const rects = elements.current.slice(0, count).map((el) =>\n el\n ? {\n left: el.offsetLeft,\n top: el.offsetTop,\n width: el.offsetWidth,\n height: el.offsetHeight,\n }\n : { left: 0, top: 0, width: 0, height: 0 },\n );\n setMeasured((prev) =>\n prev && prev.pageIndex === pageIndex && sameRects(prev.rects, rects)\n ? prev\n : { pageIndex, rects },\n );\n });\n\n return {\n wordRef: (index) => (el) => {\n elements.current[index] = el;\n },\n rects: measured && measured.pageIndex === pageIndex ? measured.rects : null,\n };\n}\n\nfunction useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs = DEFAULT_HOLD_MS,\n}: {\n captions: SpeakerCaption[];\n combineTokensWithinMilliseconds: number;\n holdMs?: number;\n}): CaptionsState | null {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const windows = useMemo(\n () =>\n buildCaptionPages(captions, { combineTokensWithinMilliseconds, holdMs }),\n [captions, combineTokensWithinMilliseconds, holdMs],\n );\n return getCaptionsState(windows, (frame / fps) * 1000);\n}\n\ninterface CaptionWeightProps extends CaptionBaseProps {\n activeWeight?: number;\n shadow?: boolean;\n}\n\nconst ENTER_MS = 160;\nconst EXIT_MS = 220;\nconst RISE_EM = 0.14;\nconst RAMP_MS = 150;\nconst RELEASE_MS = 220;\nconst LEGIBILITY_SHADOW =\n \"0 2px 3px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.35)\";\n\nconst enterEasing = Easing.bezier(0.2, 0.8, 0.2, 1);\nconst rampEasing = Easing.bezier(0.2, 0.8, 0.3, 1);\nconst releaseEasing = Easing.bezier(0.4, 0, 0.2, 1);\n\nconst clamp = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n} as const;\n\nfunction CaptionWeightBase({\n captions,\n combineTokensWithinMilliseconds = 1200,\n holdMs = DEFAULT_HOLD_MS,\n fontSize = 64,\n fontWeight = 400,\n activeWeight = 900,\n color = \"#ffffff\",\n shadow = true,\n className,\n}: CaptionWeightProps) {\n const state = useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs,\n });\n if (!state) return null;\n\n const enter = interpolate(\n state.previous ? ENTER_MS : state.sinceStartMs,\n [0, ENTER_MS],\n [0, 1],\n {\n ...clamp,\n easing: enterEasing,\n },\n );\n const exit = state.endsInSilence\n ? interpolate(\n state.untilEndMs,\n [0, getExitWindowMs(state, EXIT_MS)],\n [0, 1],\n clamp,\n )\n : 1;\n\n const words = groupCaptionWords(state.tokens);\n const activeWord = words.findIndex((word) =>\n word.some(({ index }) => index === state.activeIndex),\n );\n\n const emphasis = (w: number): number => {\n if (activeWord < 0 || w > activeWord) return 0;\n const startMs = words[w][0].token.fromMs;\n const rise = interpolate(state.timeMs - startMs, [0, RAMP_MS], [0, 1], {\n ...clamp,\n easing: rampEasing,\n });\n if (w === activeWord) return rise;\n const releaseMs = words[w + 1][0].token.fromMs;\n const peak = interpolate(releaseMs - startMs, [0, RAMP_MS], [0, 1], {\n ...clamp,\n easing: rampEasing,\n });\n const release = interpolate(\n state.timeMs - releaseMs,\n [0, RELEASE_MS],\n [0, 1],\n { ...clamp, easing: releaseEasing },\n );\n return peak * (1 - release);\n };\n\n return (\n <div\n className={className}\n style={{\n fontSize,\n fontWeight,\n color,\n lineHeight: 1.2,\n textAlign: \"center\",\n opacity: Math.min(enter, exit),\n transform: `translateY(${(1 - enter) * RISE_EM}em)`,\n }}\n >\n {words.map((word, w) => {\n const weight = fontWeight + (activeWeight - fontWeight) * emphasis(w);\n return (\n <Fragment key={`${state.pageIndex}-${word[0].index}`}>\n {w > 0 && \" \"}\n <span style={{ display: \"inline-grid\", whiteSpace: \"nowrap\" }}>\n <span\n aria-hidden\n style={{\n gridArea: \"1 / 1\",\n fontWeight: Math.max(fontWeight, activeWeight),\n visibility: \"hidden\",\n }}\n >\n {captionWordText(word)}\n </span>\n <span\n style={{\n gridArea: \"1 / 1\",\n justifySelf: \"center\",\n fontWeight: weight,\n textShadow: shadow ? LEGIBILITY_SHADOW : undefined,\n }}\n >\n {word.map(({ index, token }) => (\n <span key={index}>{token.text}</span>\n ))}\n </span>\n </span>\n </Fragment>\n );\n })}\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n captions: {\n type: \"remotion-captions\",\n default: [{\n text: \" So\",\n startMs: 300,\n endMs: 460,\n timestampMs: 380,\n confidence: 0.97,\n }, {\n text: \" here's\",\n startMs: 460,\n endMs: 700,\n timestampMs: 580,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 700,\n endMs: 820,\n timestampMs: 760,\n confidence: 0.97,\n }, {\n text: \" thing.\",\n startMs: 820,\n endMs: 1240,\n timestampMs: 1030,\n confidence: 0.97,\n }, {\n text: \" Most\",\n startMs: 1700,\n endMs: 1960,\n timestampMs: 1830,\n confidence: 0.97,\n }, {\n text: \" demo\",\n startMs: 1960,\n endMs: 2240,\n timestampMs: 2100,\n confidence: 0.97,\n }, {\n text: \" videos\",\n startMs: 2240,\n endMs: 2680,\n timestampMs: 2460,\n confidence: 0.97,\n }, {\n text: \" lose\",\n startMs: 2680,\n endMs: 2960,\n timestampMs: 2820,\n confidence: 0.97,\n }, {\n text: \" people\",\n startMs: 2960,\n endMs: 3320,\n timestampMs: 3140,\n confidence: 0.97,\n }, {\n text: \" in\",\n startMs: 3320,\n endMs: 3420,\n timestampMs: 3370,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 3420,\n endMs: 3520,\n timestampMs: 3470,\n confidence: 0.97,\n }, {\n text: \" first\",\n startMs: 3520,\n endMs: 3820,\n timestampMs: 3670,\n confidence: 0.97,\n }, {\n text: \" three\",\n startMs: 3820,\n endMs: 4100,\n timestampMs: 3960,\n confidence: 0.97,\n }, {\n text: \" seconds.\",\n startMs: 4100,\n endMs: 4780,\n timestampMs: 4440,\n confidence: 0.97,\n }, {\n text: \" Captions\",\n startMs: 5400,\n endMs: 5920,\n timestampMs: 5660,\n confidence: 0.97,\n }, {\n text: \" keep\",\n startMs: 5920,\n endMs: 6140,\n timestampMs: 6030,\n confidence: 0.97,\n }, {\n text: \" them\",\n startMs: 6140,\n endMs: 6300,\n timestampMs: 6220,\n confidence: 0.97,\n }, {\n text: \" watching,\",\n startMs: 6300,\n endMs: 6860,\n timestampMs: 6580,\n confidence: 0.97,\n }, {\n text: \" even\",\n startMs: 6960,\n endMs: 7180,\n timestampMs: 7070,\n confidence: 0.97,\n }, {\n text: \" with\",\n startMs: 7180,\n endMs: 7320,\n timestampMs: 7250,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 7320,\n endMs: 7420,\n timestampMs: 7370,\n confidence: 0.97,\n }, {\n text: \" sound\",\n startMs: 7420,\n endMs: 7760,\n timestampMs: 7590,\n confidence: 0.97,\n }, {\n text: \" off.\",\n startMs: 7760,\n endMs: 8300,\n timestampMs: 8030,\n confidence: 0.97,\n }],\n description: \"Transcript\",\n keyframable: false,\n },\n fontSize: {\n type: \"number\",\n min: 24,\n max: 140,\n step: 1,\n default: 64,\n description: \"Font size\",\n hiddenFromList: false,\n },\n fontWeight: {\n type: \"number\",\n min: 100,\n max: 900,\n step: 100,\n default: 400,\n description: \"Resting weight\",\n hiddenFromList: false,\n },\n activeWeight: {\n type: \"number\",\n min: 100,\n max: 900,\n step: 100,\n default: 900,\n description: \"Active weight\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#ffffff\",\n description: \"Text color\",\n },\n combineTokensWithinMilliseconds: {\n type: \"number\",\n min: 0,\n max: 3000,\n step: 100,\n default: 1200,\n description: \"Page window (ms)\",\n hiddenFromList: false,\n },\n holdMs: {\n type: \"number\",\n min: 0,\n max: 2000,\n step: 50,\n default: 600,\n description: \"Hold (ms)\",\n hiddenFromList: false,\n },\n shadow: {\n type: \"boolean\",\n default: true,\n description: \"Shadow\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"captions\",\"fontSize\",\"fontWeight\",\"activeWeight\",\"color\",\"combineTokensWithinMilliseconds\",\"holdMs\",\"shadow\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n captions: [{\n text: \" So\",\n startMs: 300,\n endMs: 460,\n timestampMs: 380,\n confidence: 0.97,\n }, {\n text: \" here's\",\n startMs: 460,\n endMs: 700,\n timestampMs: 580,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 700,\n endMs: 820,\n timestampMs: 760,\n confidence: 0.97,\n }, {\n text: \" thing.\",\n startMs: 820,\n endMs: 1240,\n timestampMs: 1030,\n confidence: 0.97,\n }, {\n text: \" Most\",\n startMs: 1700,\n endMs: 1960,\n timestampMs: 1830,\n confidence: 0.97,\n }, {\n text: \" demo\",\n startMs: 1960,\n endMs: 2240,\n timestampMs: 2100,\n confidence: 0.97,\n }, {\n text: \" videos\",\n startMs: 2240,\n endMs: 2680,\n timestampMs: 2460,\n confidence: 0.97,\n }, {\n text: \" lose\",\n startMs: 2680,\n endMs: 2960,\n timestampMs: 2820,\n confidence: 0.97,\n }, {\n text: \" people\",\n startMs: 2960,\n endMs: 3320,\n timestampMs: 3140,\n confidence: 0.97,\n }, {\n text: \" in\",\n startMs: 3320,\n endMs: 3420,\n timestampMs: 3370,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 3420,\n endMs: 3520,\n timestampMs: 3470,\n confidence: 0.97,\n }, {\n text: \" first\",\n startMs: 3520,\n endMs: 3820,\n timestampMs: 3670,\n confidence: 0.97,\n }, {\n text: \" three\",\n startMs: 3820,\n endMs: 4100,\n timestampMs: 3960,\n confidence: 0.97,\n }, {\n text: \" seconds.\",\n startMs: 4100,\n endMs: 4780,\n timestampMs: 4440,\n confidence: 0.97,\n }, {\n text: \" Captions\",\n startMs: 5400,\n endMs: 5920,\n timestampMs: 5660,\n confidence: 0.97,\n }, {\n text: \" keep\",\n startMs: 5920,\n endMs: 6140,\n timestampMs: 6030,\n confidence: 0.97,\n }, {\n text: \" them\",\n startMs: 6140,\n endMs: 6300,\n timestampMs: 6220,\n confidence: 0.97,\n }, {\n text: \" watching,\",\n startMs: 6300,\n endMs: 6860,\n timestampMs: 6580,\n confidence: 0.97,\n }, {\n text: \" even\",\n startMs: 6960,\n endMs: 7180,\n timestampMs: 7070,\n confidence: 0.97,\n }, {\n text: \" with\",\n startMs: 7180,\n endMs: 7320,\n timestampMs: 7250,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 7320,\n endMs: 7420,\n timestampMs: 7370,\n confidence: 0.97,\n }, {\n text: \" sound\",\n startMs: 7420,\n endMs: 7760,\n timestampMs: 7590,\n confidence: 0.97,\n }, {\n text: \" off.\",\n startMs: 7760,\n endMs: 8300,\n timestampMs: 8030,\n confidence: 0.97,\n }],\n fontSize: 64,\n fontWeight: 400,\n activeWeight: 900,\n color: \"#ffffff\",\n combineTokensWithinMilliseconds: 1200,\n holdMs: 600,\n shadow: true,\n};\n\ntype CaptionWeightElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof CaptionWeightBase>;\n\nconst CaptionWeightInner = forwardRef<\n HTMLDivElement,\n CaptionWeightElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<CaptionWeight>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <CaptionWeightBase\n {...(componentProps as unknown as ComponentProps<typeof CaptionWeightBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const CaptionWeight = Interactive.withSchema({\n Component: CaptionWeightInner,\n componentName: \"<CaptionWeight>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"+ },+ "durationInFrames": 279+}diff --git a/registry-artifacts/elements/caption-word-pop.json b/registry-artifacts/elements/caption-word-pop.jsonnew file mode 100644index 00000000..c011f383--- /dev/null+++ b/registry-artifacts/elements/caption-word-pop.json@@ -0,0 +1,21 @@+{+ "type": "remotion-element",+ "version": 1,+ "element": {+ "assets": [],+ "dependencies": [+ {+ "name": "@remotion/captions",+ "version": null+ }+ ],+ "dimensions": null,+ "displayName": "Caption Word Pop",+ "durationInFrames": 279,+ "initialProps": null,+ "installationMode": "component-owned-sequence",+ "slug": "caption-word-pop",+ "sourceCode": "import { Fragment, forwardRef, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState, type ComponentProps } from \"react\";\nimport { Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { createTikTokStyleCaptions, type Caption, type TikTokPage } from \"@remotion/captions\";\n\ntype SpeakerCaption = Caption & { speaker?: string };\n\ninterface CaptionBaseProps {\n captions: Caption[];\n combineTokensWithinMilliseconds?: number;\n holdMs?: number;\n fontSize?: number;\n fontWeight?: number;\n color?: string;\n className?: string;\n}\n\nconst DEFAULT_HOLD_MS = 600;\nconst MIN_SILENCE_BREAK_MS = 300;\n\ninterface CaptionPageWindow {\n page: TikTokPage;\n index: number;\n speaker: string | undefined;\n startMs: number;\n speechEndMs: number;\n endMs: number;\n endsInSilence: boolean;\n}\n\ntype CaptionTokenStatus = \"upcoming\" | \"active\" | \"spoken\";\n\ninterface CaptionTokenState {\n text: string;\n spaceBefore: boolean;\n fromMs: number;\n toMs: number;\n progress: number;\n status: CaptionTokenStatus;\n}\n\ninterface CaptionPreviousPage {\n page: TikTokPage;\n pageIndex: number;\n tokens: CaptionTokenState[];\n}\n\ninterface CaptionsState {\n page: TikTokPage;\n pageIndex: number;\n speaker: string | undefined;\n timeMs: number;\n activeIndex: number;\n tokens: CaptionTokenState[];\n sinceStartMs: number;\n untilEndMs: number;\n holdRoomMs: number;\n endsInSilence: boolean;\n previous: CaptionPreviousPage | null;\n}\n\ninterface CaptionPagingOptions {\n combineTokensWithinMilliseconds: number;\n holdMs?: number;\n}\n\nconst SENTENCE_END = /[.!?…][\"')\\]]*$/;\n\nfunction markPageBreaks(captions: SpeakerCaption[]): Caption[] {\n return captions.map((caption, i) => {\n if (caption.pageBreakAfter !== undefined) return caption;\n const next = captions[i + 1];\n const speakerChanges =\n next !== undefined && next.speaker !== caption.speaker;\n return speakerChanges || SENTENCE_END.test(caption.text.trim())\n ? { ...caption, pageBreakAfter: true }\n : caption;\n });\n}\n\nfunction buildCaptionPages(\n captions: SpeakerCaption[],\n {\n combineTokensWithinMilliseconds,\n holdMs = DEFAULT_HOLD_MS,\n }: CaptionPagingOptions,\n): CaptionPageWindow[] {\n if (captions.length === 0) return [];\n const { pages } = createTikTokStyleCaptions({\n captions: markPageBreaks(captions),\n combineTokensWithinMilliseconds,\n breakOnSilenceAfterMilliseconds: Math.max(holdMs, MIN_SILENCE_BREAK_MS),\n });\n const speakers = new Map<number, string | undefined>();\n for (const caption of captions) {\n if (!speakers.has(caption.startMs)) {\n speakers.set(caption.startMs, caption.speaker);\n }\n }\n const spoken = pages.filter((page) => page.tokens.length > 0);\n return spoken.map((page, index) => {\n const last = page.tokens[page.tokens.length - 1];\n const speechEndMs = last ? last.toMs : page.startMs;\n const heldUntil = speechEndMs + Math.max(0, holdMs);\n const next = spoken[index + 1];\n const endsInSilence = !next || next.startMs > heldUntil;\n const endMs = endsInSilence\n ? heldUntil\n : Math.max(page.startMs, next.startMs);\n return {\n page,\n index,\n speaker: speakers.get(page.tokens[0].fromMs),\n startMs: page.startMs,\n speechEndMs,\n endMs,\n endsInSilence,\n };\n });\n}\n\nfunction findWindowIndex(windows: CaptionPageWindow[], timeMs: number): number {\n let lo = 0;\n let hi = windows.length - 1;\n let found = -1;\n while (lo <= hi) {\n const mid = (lo + hi) >> 1;\n if (windows[mid].startMs <= timeMs) {\n found = mid;\n lo = mid + 1;\n } else {\n hi = mid - 1;\n }\n }\n if (found === -1) return -1;\n return timeMs < windows[found].endMs ? found : -1;\n}\n\nfunction tokenProgress(fromMs: number, toMs: number, timeMs: number): number {\n if (timeMs < fromMs) return 0;\n if (toMs <= fromMs) return 1;\n return Math.min(1, (timeMs - fromMs) / (toMs - fromMs));\n}\n\nfunction getTokenStates(\n page: TikTokPage,\n timeMs: number,\n): { activeIndex: number; tokens: CaptionTokenState[] } {\n let activeIndex = -1;\n page.tokens.forEach((token, i) => {\n if (token.fromMs <= timeMs) activeIndex = i;\n });\n const tokens = page.tokens.map(\n (token, i): CaptionTokenState => ({\n text: token.text.trim(),\n spaceBefore: i > 0 && /^\\s/.test(token.text),\n fromMs: token.fromMs,\n toMs: token.toMs,\n progress: tokenProgress(token.fromMs, token.toMs, timeMs),\n status:\n i < activeIndex ? \"spoken\" : i === activeIndex ? \"active\" : \"upcoming\",\n }),\n );\n return { activeIndex, tokens };\n}\n\nfunction getCaptionsState(\n windows: CaptionPageWindow[],\n timeMs: number,\n): CaptionsState | null {\n const found = findWindowIndex(windows, timeMs);\n if (found === -1) return null;\n const window = windows[found];\n const { activeIndex, tokens } = getTokenStates(window.page, timeMs);\n const before = found > 0 ? windows[found - 1] : null;\n const previous =\n before && !before.endsInSilence\n ? {\n page: before.page,\n pageIndex: before.index,\n tokens: getTokenStates(before.page, before.endMs).tokens,\n }\n : null;\n return {\n page: window.page,\n pageIndex: window.index,\n speaker: window.speaker,\n timeMs,\n activeIndex,\n tokens,\n sinceStartMs: timeMs - window.startMs,\n untilEndMs: window.endMs - timeMs,\n holdRoomMs: window.endMs - window.speechEndMs,\n endsInSilence: window.endsInSilence,\n previous,\n };\n}\n\nfunction getExitWindowMs(state: CaptionsState, exitMs: number): number {\n return Math.max(1, Math.min(exitMs, state.holdRoomMs));\n}\n\nfunction groupCaptionWords(\n tokens: CaptionTokenState[],\n): { index: number; token: CaptionTokenState }[][] {\n const words: { index: number; token: CaptionTokenState }[][] = [];\n tokens.forEach((token, index) => {\n const current = words[words.length - 1];\n if (!current || token.spaceBefore) {\n words.push([{ index, token }]);\n } else {\n current.push({ index, token });\n }\n });\n return words;\n}\n\nfunction normalizeCaptionWord(text: string): string {\n return text\n .toLowerCase()\n .replace(/[\\u2018\\u2019]/g, \"'\")\n .replace(/[^\\p{L}\\p{N}']/gu, \"\");\n}\n\nfunction createKeywordMatcher(\n keywords: readonly string[] = [],\n): (text: string) => boolean {\n const set = new Set(keywords.map(normalizeCaptionWord).filter(Boolean));\n return (text) => set.has(normalizeCaptionWord(text));\n}\n\nfunction captionWordText(word: { token: CaptionTokenState }[]): string {\n return word.map(({ token }) => token.text).join(\"\");\n}\n\ninterface CaptionWordRect {\n left: number;\n top: number;\n width: number;\n height: number;\n}\n\nfunction sameRects(a: CaptionWordRect[], b: CaptionWordRect[]): boolean {\n return (\n a.length === b.length &&\n a.every(\n (r, i) =>\n r.left === b[i].left &&\n r.top === b[i].top &&\n r.width === b[i].width &&\n r.height === b[i].height,\n )\n );\n}\n\nfunction useCaptionWordRects(\n pageIndex: number,\n count: number,\n): {\n wordRef: (index: number) => (el: HTMLElement | null) => void;\n rects: CaptionWordRect[] | null;\n} {\n const elements = useRef<(HTMLElement | null)[]>([]);\n const [measured, setMeasured] = useState<{\n pageIndex: number;\n rects: CaptionWordRect[];\n } | null>(null);\n\n useLayoutEffect(() => {\n if (pageIndex === -1) return;\n const rects = elements.current.slice(0, count).map((el) =>\n el\n ? {\n left: el.offsetLeft,\n top: el.offsetTop,\n width: el.offsetWidth,\n height: el.offsetHeight,\n }\n : { left: 0, top: 0, width: 0, height: 0 },\n );\n setMeasured((prev) =>\n prev && prev.pageIndex === pageIndex && sameRects(prev.rects, rects)\n ? prev\n : { pageIndex, rects },\n );\n });\n\n return {\n wordRef: (index) => (el) => {\n elements.current[index] = el;\n },\n rects: measured && measured.pageIndex === pageIndex ? measured.rects : null,\n };\n}\n\nfunction useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs = DEFAULT_HOLD_MS,\n}: {\n captions: SpeakerCaption[];\n combineTokensWithinMilliseconds: number;\n holdMs?: number;\n}): CaptionsState | null {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const windows = useMemo(\n () =>\n buildCaptionPages(captions, { combineTokensWithinMilliseconds, holdMs }),\n [captions, combineTokensWithinMilliseconds, holdMs],\n );\n return getCaptionsState(windows, (frame / fps) * 1000);\n}\n\ninterface CaptionWordPopProps extends CaptionBaseProps {\n popScale?: number;\n shadow?: boolean;\n}\n\nconst FADE_MS = 50;\nconst EXIT_MS = 180;\nconst LEGIBILITY_SHADOW =\n \"0 2px 3px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.35)\";\n\nconst POP_SPRING = { damping: 11, stiffness: 240, mass: 0.6 };\n\nconst clamp = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n} as const;\n\nfunction CaptionWordPopBase({\n captions,\n combineTokensWithinMilliseconds = 0,\n holdMs = DEFAULT_HOLD_MS,\n fontSize = 96,\n fontWeight = 800,\n color = \"#ffffff\",\n popScale = 0.6,\n shadow = true,\n className,\n}: CaptionWordPopProps) {\n const { fps } = useVideoConfig();\n const state = useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs,\n });\n if (!state) return null;\n\n const pop = spring({\n frame: (state.sinceStartMs / 1000) * fps,\n fps,\n config: POP_SPRING,\n });\n const fadeIn = state.previous\n ? 1\n : interpolate(state.sinceStartMs, [0, FADE_MS], [0, 1], clamp);\n const exit = state.endsInSilence\n ? interpolate(\n state.untilEndMs,\n [0, getExitWindowMs(state, EXIT_MS)],\n [0, 1],\n clamp,\n )\n : 1;\n\n return (\n <div\n className={className}\n style={{\n fontSize,\n fontWeight,\n color,\n lineHeight: 1.1,\n textAlign: \"center\",\n opacity: Math.min(fadeIn, exit),\n transform: `scale(${popScale + (1 - popScale) * pop})`,\n textShadow: shadow ? LEGIBILITY_SHADOW : undefined,\n }}\n >\n {groupCaptionWords(state.tokens).map((word, w) => (\n <Fragment key={`${state.pageIndex}-${word[0].index}`}>\n {w > 0 && \" \"}\n <span style={{ display: \"inline-block\", whiteSpace: \"nowrap\" }}>\n {word.map(({ index, token }) => (\n <span key={index}>{token.text}</span>\n ))}\n </span>\n </Fragment>\n ))}\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n captions: {\n type: \"remotion-captions\",\n default: [{\n text: \" So\",\n startMs: 300,\n endMs: 460,\n timestampMs: 380,\n confidence: 0.97,\n }, {\n text: \" here's\",\n startMs: 460,\n endMs: 700,\n timestampMs: 580,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 700,\n endMs: 820,\n timestampMs: 760,\n confidence: 0.97,\n }, {\n text: \" thing.\",\n startMs: 820,\n endMs: 1240,\n timestampMs: 1030,\n confidence: 0.97,\n }, {\n text: \" Most\",\n startMs: 1700,\n endMs: 1960,\n timestampMs: 1830,\n confidence: 0.97,\n }, {\n text: \" demo\",\n startMs: 1960,\n endMs: 2240,\n timestampMs: 2100,\n confidence: 0.97,\n }, {\n text: \" videos\",\n startMs: 2240,\n endMs: 2680,\n timestampMs: 2460,\n confidence: 0.97,\n }, {\n text: \" lose\",\n startMs: 2680,\n endMs: 2960,\n timestampMs: 2820,\n confidence: 0.97,\n }, {\n text: \" people\",\n startMs: 2960,\n endMs: 3320,\n timestampMs: 3140,\n confidence: 0.97,\n }, {\n text: \" in\",\n startMs: 3320,\n endMs: 3420,\n timestampMs: 3370,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 3420,\n endMs: 3520,\n timestampMs: 3470,\n confidence: 0.97,\n }, {\n text: \" first\",\n startMs: 3520,\n endMs: 3820,\n timestampMs: 3670,\n confidence: 0.97,\n }, {\n text: \" three\",\n startMs: 3820,\n endMs: 4100,\n timestampMs: 3960,\n confidence: 0.97,\n }, {\n text: \" seconds.\",\n startMs: 4100,\n endMs: 4780,\n timestampMs: 4440,\n confidence: 0.97,\n }, {\n text: \" Captions\",\n startMs: 5400,\n endMs: 5920,\n timestampMs: 5660,\n confidence: 0.97,\n }, {\n text: \" keep\",\n startMs: 5920,\n endMs: 6140,\n timestampMs: 6030,\n confidence: 0.97,\n }, {\n text: \" them\",\n startMs: 6140,\n endMs: 6300,\n timestampMs: 6220,\n confidence: 0.97,\n }, {\n text: \" watching,\",\n startMs: 6300,\n endMs: 6860,\n timestampMs: 6580,\n confidence: 0.97,\n }, {\n text: \" even\",\n startMs: 6960,\n endMs: 7180,\n timestampMs: 7070,\n confidence: 0.97,\n }, {\n text: \" with\",\n startMs: 7180,\n endMs: 7320,\n timestampMs: 7250,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 7320,\n endMs: 7420,\n timestampMs: 7370,\n confidence: 0.97,\n }, {\n text: \" sound\",\n startMs: 7420,\n endMs: 7760,\n timestampMs: 7590,\n confidence: 0.97,\n }, {\n text: \" off.\",\n startMs: 7760,\n endMs: 8300,\n timestampMs: 8030,\n confidence: 0.97,\n }],\n description: \"Transcript\",\n keyframable: false,\n },\n fontSize: {\n type: \"number\",\n min: 24,\n max: 220,\n step: 1,\n default: 96,\n description: \"Font size\",\n hiddenFromList: false,\n },\n fontWeight: {\n type: \"number\",\n min: 400,\n max: 900,\n step: 100,\n default: 800,\n description: \"Font weight\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#ffffff\",\n description: \"Text color\",\n },\n popScale: {\n type: \"number\",\n min: 0.2,\n max: 1,\n step: 0.05,\n default: 0.6,\n description: \"Start scale\",\n hiddenFromList: false,\n },\n combineTokensWithinMilliseconds: {\n type: \"number\",\n min: 0,\n max: 3000,\n step: 100,\n default: 0,\n description: \"Page window (ms)\",\n hiddenFromList: false,\n },\n holdMs: {\n type: \"number\",\n min: 0,\n max: 2000,\n step: 50,\n default: 600,\n description: \"Hold (ms)\",\n hiddenFromList: false,\n },\n shadow: {\n type: \"boolean\",\n default: true,\n description: \"Shadow\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"captions\",\"fontSize\",\"fontWeight\",\"color\",\"popScale\",\"combineTokensWithinMilliseconds\",\"holdMs\",\"shadow\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n captions: [{\n text: \" So\",\n startMs: 300,\n endMs: 460,\n timestampMs: 380,\n confidence: 0.97,\n }, {\n text: \" here's\",\n startMs: 460,\n endMs: 700,\n timestampMs: 580,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 700,\n endMs: 820,\n timestampMs: 760,\n confidence: 0.97,\n }, {\n text: \" thing.\",\n startMs: 820,\n endMs: 1240,\n timestampMs: 1030,\n confidence: 0.97,\n }, {\n text: \" Most\",\n startMs: 1700,\n endMs: 1960,\n timestampMs: 1830,\n confidence: 0.97,\n }, {\n text: \" demo\",\n startMs: 1960,\n endMs: 2240,\n timestampMs: 2100,\n confidence: 0.97,\n }, {\n text: \" videos\",\n startMs: 2240,\n endMs: 2680,\n timestampMs: 2460,\n confidence: 0.97,\n }, {\n text: \" lose\",\n startMs: 2680,\n endMs: 2960,\n timestampMs: 2820,\n confidence: 0.97,\n }, {\n text: \" people\",\n startMs: 2960,\n endMs: 3320,\n timestampMs: 3140,\n confidence: 0.97,\n }, {\n text: \" in\",\n startMs: 3320,\n endMs: 3420,\n timestampMs: 3370,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 3420,\n endMs: 3520,\n timestampMs: 3470,\n confidence: 0.97,\n }, {\n text: \" first\",\n startMs: 3520,\n endMs: 3820,\n timestampMs: 3670,\n confidence: 0.97,\n }, {\n text: \" three\",\n startMs: 3820,\n endMs: 4100,\n timestampMs: 3960,\n confidence: 0.97,\n }, {\n text: \" seconds.\",\n startMs: 4100,\n endMs: 4780,\n timestampMs: 4440,\n confidence: 0.97,\n }, {\n text: \" Captions\",\n startMs: 5400,\n endMs: 5920,\n timestampMs: 5660,\n confidence: 0.97,\n }, {\n text: \" keep\",\n startMs: 5920,\n endMs: 6140,\n timestampMs: 6030,\n confidence: 0.97,\n }, {\n text: \" them\",\n startMs: 6140,\n endMs: 6300,\n timestampMs: 6220,\n confidence: 0.97,\n }, {\n text: \" watching,\",\n startMs: 6300,\n endMs: 6860,\n timestampMs: 6580,\n confidence: 0.97,\n }, {\n text: \" even\",\n startMs: 6960,\n endMs: 7180,\n timestampMs: 7070,\n confidence: 0.97,\n }, {\n text: \" with\",\n startMs: 7180,\n endMs: 7320,\n timestampMs: 7250,\n confidence: 0.97,\n }, {\n text: \" the\",\n startMs: 7320,\n endMs: 7420,\n timestampMs: 7370,\n confidence: 0.97,\n }, {\n text: \" sound\",\n startMs: 7420,\n endMs: 7760,\n timestampMs: 7590,\n confidence: 0.97,\n }, {\n text: \" off.\",\n startMs: 7760,\n endMs: 8300,\n timestampMs: 8030,\n confidence: 0.97,\n }],\n fontSize: 96,\n fontWeight: 800,\n color: \"#ffffff\",\n popScale: 0.6,\n combineTokensWithinMilliseconds: 0,\n holdMs: 600,\n shadow: true,\n};\n\ntype CaptionWordPopElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof CaptionWordPopBase>;\n\nconst CaptionWordPopInner = forwardRef<\n HTMLDivElement,\n CaptionWordPopElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<CaptionWordPop>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <CaptionWordPopBase\n {...(componentProps as unknown as ComponentProps<typeof CaptionWordPopBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const CaptionWordPop = Interactive.withSchema({\n Component: CaptionWordPopInner,\n componentName: \"<CaptionWordPop>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"+ },+ "durationInFrames": 279+}diff --git a/registry-artifacts/elements/caret-swap.json b/registry-artifacts/elements/caret-swap.jsonindex 0c039dc4..b59338de 100644--- a/registry-artifacts/elements/caret-swap.json+++ b/registry-artifacts/elements/caret-swap.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [],"dimensions": {"width": 1100,@@ -9,6 +10,7 @@},"displayName": "Caret Swap","durationInFrames": 67,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "caret-swap","sourceCode": "import { Easing, Interactive, Sequence, interpolate, useCurrentFrame, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface CaretSwapProps {\n fromText: string;\n toText: string;\n fontSize?: number;\n color?: string;\n fontWeight?: number;\n caretColor?: string;\n caretColorEnd?: string;\n swapAt?: number;\n typeSpeed?: number;\n speed?: number;\n className?: string;\n}\n\nconst CARET_LEAD = 7;\nconst EXPAND_FRAMES = 6;\nconst COLLAPSE_FRAMES = 7;\nconst IDLE_FRAMES = 7;\nconst BLINK_FRAMES = 8;\nconst CARET_WIDTH_EM = 0.08;\nconst CARET_HEIGHT_EM = 1.1;\nconst CARET_GAP_EM = 0.06;\nconst CHAR_WIDTH_EM = 0.52;\nconst TYPE_ACCEL = 0.96;\n\nfunction typeElapsed(count: number, typeSpeed: number): number {\n return (typeSpeed * (1 - TYPE_ACCEL ** count)) / (1 - TYPE_ACCEL);\n}\n\nfunction caretSwapLength(\n toText: string,\n swapAt = 20,\n typeSpeed = 1,\n): number {\n return Math.ceil(\n swapAt +\n EXPAND_FRAMES +\n COLLAPSE_FRAMES +\n IDLE_FRAMES +\n typeElapsed(Array.from(toText).length, typeSpeed),\n );\n}\n\nconst expandEasing = Easing.bezier(0.6, 0, 0.8, 0.4);\nconst collapseEasing = Easing.bezier(0.2, 0.7, 0.3, 1);\n\nfunction CaretSwapBase({\n fromText,\n toText,\n fontSize = 72,\n color = \"#171717\",\n fontWeight = 400,\n caretColor = \"#FF4DAA\",\n caretColorEnd = \"#8A5CF6\",\n swapAt = 20,\n typeSpeed = 1,\n speed = 1,\n className,\n}: CaretSwapProps) {\n const frame = useCurrentFrame() * speed;\n\n const toChars = Array.from(toText);\n const caretWidth = CARET_WIDTH_EM * fontSize;\n const caretHeight = CARET_HEIGHT_EM * fontSize;\n\n const caretVisibleAt = Math.max(swapAt - CARET_LEAD, 0);\n const expandEnd = swapAt + EXPAND_FRAMES;\n const collapseEnd = expandEnd + COLLAPSE_FRAMES;\n const typeStart = collapseEnd + IDLE_FRAMES;\n const typeEnd = typeStart + typeElapsed(toChars.length, typeSpeed);\n\n const expand = interpolate(frame, [swapAt, expandEnd], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: expandEasing,\n });\n const collapse = interpolate(frame, [expandEnd, collapseEnd], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: collapseEasing,\n });\n\n const typing = frame >= typeStart;\n let typedCount = 0;\n if (typing) {\n while (\n typedCount < toChars.length &&\n typeElapsed(typedCount, typeSpeed) <= frame - typeStart\n ) {\n typedCount++;\n }\n }\n const typed = toChars.slice(0, typedCount).join(\"\");\n\n const anchorWidthEm =\n Array.from(fromText).length * CHAR_WIDTH_EM + CARET_WIDTH_EM + CARET_GAP_EM;\n const targetShiftEm = (anchorWidthEm - toChars.length * CHAR_WIDTH_EM) / 2;\n const typeProgress = toChars.length > 0 ? typedCount / toChars.length : 0;\n const typedShift = targetShiftEm * typeProgress * fontSize;\n\n const blinkOff =\n frame >= typeEnd + BLINK_FRAMES &&\n Math.floor((frame - typeEnd) / BLINK_FRAMES) % 2 === 1;\n\n const caretStyle = {\n background: `linear-gradient(180deg, ${caretColor}, ${caretColorEnd})`,\n borderRadius: fontSize * 0.03,\n };\n\n const overlayWidth =\n frame < expandEnd\n ? `calc(${(expand * 100).toFixed(3)}% + ${((1 - expand) * caretWidth).toFixed(2)}px)`\n : `calc(${((1 - collapse) * 100).toFixed(3)}% + ${(collapse * caretWidth).toFixed(2)}px)`;\n\n const tailSolidStop =\n frame < expandEnd ? 100 - 90 * expand : 10 + 90 * collapse;\n const tailMask =\n frame >= swapAt\n ? `linear-gradient(90deg, black ${tailSolidStop.toFixed(1)}%, transparent 100%)`\n : undefined;\n\n return (\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n whiteSpace: \"nowrap\",\n background: \"transparent\",\n }}\n >\n <span\n className={className}\n style={{\n position: \"relative\",\n display: \"inline-flex\",\n alignItems: \"center\",\n fontSize,\n fontWeight,\n color,\n letterSpacing: \"-0.02em\",\n lineHeight: 1.15,\n fontFamily:\n \"var(--font-geist-sans, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif)\",\n }}\n >\n <span\n style={{\n display: \"inline-block\",\n whiteSpace: \"pre\",\n visibility: frame < expandEnd ? \"visible\" : \"hidden\",\n }}\n >\n {fromText}\n </span>\n <span\n aria-hidden\n style={{\n ...caretStyle,\n display: \"inline-block\",\n flexShrink: 0,\n width: caretWidth,\n height: caretHeight,\n marginLeft: CARET_GAP_EM * fontSize,\n visibility: \"hidden\",\n }}\n />\n {!typing && (\n <span\n aria-hidden\n style={{\n ...caretStyle,\n position: \"absolute\",\n top: \"50%\",\n transform: \"translateY(-50%)\",\n height: caretHeight,\n ...(frame < swapAt\n ? { right: 0, width: caretWidth }\n : frame < expandEnd\n ? { right: 0, width: overlayWidth }\n : { left: 0, width: overlayWidth }),\n WebkitMaskImage: tailMask,\n maskImage: tailMask,\n opacity: frame >= caretVisibleAt ? 1 : 0,\n }}\n />\n )}\n {typing && (\n <span\n style={{\n position: \"absolute\",\n left: 0,\n top: \"50%\",\n transform: `translate(${typedShift.toFixed(1)}px, -50%)`,\n display: \"inline-flex\",\n alignItems: \"center\",\n whiteSpace: \"pre\",\n }}\n >\n <span style={{ display: \"inline-block\", whiteSpace: \"pre\" }}>\n {typed}\n </span>\n <span\n aria-hidden\n style={{\n ...caretStyle,\n display: \"inline-block\",\n flexShrink: 0,\n width: caretWidth,\n height: caretHeight,\n marginLeft: CARET_GAP_EM * fontSize,\n opacity: blinkOff ? 0 : 1,\n }}\n />\n </span>\n )}\n </span>\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n fromText: {\n type: \"text-content\",\n default: \"Executing it?\",\n description: \"From text\",\n },\n toText: {\n type: \"text-content\",\n default: \"That's where everyone quits\",\n description: \"To text\",\n },\n fontSize: {\n type: \"number\",\n min: 12,\n max: 160,\n step: 1,\n default: 72,\n description: \"Font size\",\n hiddenFromList: false,\n },\n swapAt: {\n type: \"number\",\n min: 10,\n max: 120,\n step: 5,\n default: 20,\n description: \"Swap frame\",\n hiddenFromList: false,\n },\n typeSpeed: {\n type: \"number\",\n min: 1,\n max: 6,\n step: 1,\n default: 1,\n description: \"Frames / char\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n caretColor: {\n type: \"color\",\n default: \"#FF4DAA\",\n description: \"Caret top\",\n },\n caretColorEnd: {\n type: \"color\",\n default: \"#8A5CF6\",\n description: \"Caret bottom\",\n },\n fontWeight: {\n type: \"enum\",\n default: \"400\",\n variants: {\n \"400\": {},\n \"500\": {},\n \"600\": {},\n \"700\": {},\n },\n description: \"Font weight\",\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 1100,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 120,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"fromText\",\"toText\",\"fontSize\",\"swapAt\",\"typeSpeed\",\"color\",\"caretColor\",\"caretColorEnd\",\"fontWeight\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n fromText: \"Executing it?\",\n toText: \"That's where everyone quits\",\n fontSize: 72,\n swapAt: 20,\n typeSpeed: 1,\n color: \"#171717\",\n caretColor: \"#FF4DAA\",\n caretColorEnd: \"#8A5CF6\",\n fontWeight: \"400\",\n speed: 1,\n};\n\ntype CaretSwapElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof CaretSwapBase>;\n\nconst CaretSwapInner = forwardRef<\n HTMLDivElement,\n CaretSwapElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 1100, height = 120, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<CaretSwap>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <CaretSwapBase\n {...(componentProps as unknown as ComponentProps<typeof CaretSwapBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const CaretSwap = Interactive.withSchema({\n Component: CaretSwapInner,\n componentName: \"<CaretSwap>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/centered-word-build.json b/registry-artifacts/elements/centered-word-build.jsonindex 2f4d8930..6be18e7e 100644--- a/registry-artifacts/elements/centered-word-build.json+++ b/registry-artifacts/elements/centered-word-build.json@@ -2,10 +2,12 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [],"dimensions": null,"displayName": "Centered Word Build","durationInFrames": 63,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "centered-word-build","sourceCode": "import { Easing, Interactive, Sequence, interpolate, useCurrentFrame, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface CenteredWordBuildProps {\n text: string;\n fontSize?: number;\n color?: string;\n fontWeight?: number;\n wordGap?: number;\n accel?: number;\n rise?: number;\n zoomStep?: number;\n settleFrames?: number;\n exitAt?: number;\n exitFrames?: number;\n speed?: number;\n className?: string;\n}\n\nfunction revealFrame(index: number, wordGap: number, accel: number): number {\n let frame = 0;\n\n for (let step = 1; step <= index; step++) {\n // Establish two even beats before tightening the cadence.\n frame += wordGap * accel ** Math.max(step - 2, 0);\n }\n\n return Math.round(frame);\n}\n\nfunction centeredWordBuildLength(\n text: string,\n wordGap = 11,\n accel = 0.75,\n settleFrames = 9,\n exitAt = 51,\n exitFrames = 12,\n): number {\n const words = text.trim().split(/\\s+/).filter(Boolean);\n if (words.length === 0) return 0;\n\n const lastReveal = revealFrame(words.length - 1, wordGap, accel);\n return Math.max(lastReveal + settleFrames, exitAt + exitFrames);\n}\n\nconst settleEasing = Easing.bezier(0.16, 1, 0.3, 1);\n\nfunction CenteredWordBuildBase({\n text,\n fontSize = 52,\n color = \"#fff3df\",\n fontWeight = 400,\n wordGap = 11,\n accel = 0.75,\n rise = 0.18,\n zoomStep = 0.035,\n settleFrames = 9,\n exitAt = 51,\n exitFrames = 12,\n speed = 1,\n className,\n}: CenteredWordBuildProps) {\n const frame = useCurrentFrame() * speed;\n const words = text.trim().split(/\\s+/).filter(Boolean);\n\n if (words.length === 0) return null;\n\n const visibleCount = words.filter(\n (_, index) => frame >= revealFrame(index, wordGap, accel),\n ).length;\n let cameraScale = 1;\n for (let index = 1; index < visibleCount; index++) {\n const revealAt = revealFrame(index, wordGap, accel);\n cameraScale +=\n zoomStep *\n interpolate(\n frame,\n [revealAt, revealAt + Math.max(settleFrames, 0.001)],\n [0, 1],\n {\n easing: settleEasing,\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n },\n );\n }\n const exitProgress = interpolate(\n frame,\n [exitAt, exitAt + Math.max(exitFrames, 0.001)],\n [0, 1],\n {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n },\n );\n const fadeStart = -35 + exitProgress * 135;\n const fadeEnd = fadeStart + 35;\n const exitMask = `linear-gradient(90deg, transparent ${fadeStart}%, black ${fadeEnd}%)`;\n\n return (\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n overflow: \"hidden\",\n background: \"transparent\",\n }}\n >\n <span\n className={className}\n style={{\n color,\n display: \"inline-block\",\n fontFamily:\n \"var(--font-geist-sans, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif)\",\n fontSize,\n fontWeight,\n letterSpacing: \"-0.02em\",\n lineHeight: 1.1,\n whiteSpace: \"nowrap\",\n scale: `${cameraScale}`,\n opacity: exitProgress >= 1 ? 0 : 1,\n maskImage: exitProgress > 0 ? exitMask : undefined,\n WebkitMaskImage: exitProgress > 0 ? exitMask : undefined,\n maskRepeat: \"no-repeat\",\n WebkitMaskRepeat: \"no-repeat\",\n }}\n >\n {words.slice(0, visibleCount).map((word, index) => {\n const revealAt = revealFrame(index, wordGap, accel);\n const y = interpolate(\n frame,\n [revealAt, revealAt + Math.max(settleFrames, 0.001)],\n [rise * fontSize, 0],\n {\n easing: settleEasing,\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n },\n );\n\n return (\n <span\n key={index}\n style={{\n display: \"inline-block\",\n marginLeft: index > 0 ? \"0.25em\" : undefined,\n translate: `0 ${y}px`,\n }}\n >\n {word}\n </span>\n );\n })}\n </span>\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n text: {\n type: \"text-content\",\n default: \"everything we learn from\",\n description: \"Text\",\n },\n fontSize: {\n type: \"number\",\n min: 24,\n max: 160,\n step: 1,\n default: 52,\n description: \"Font size\",\n hiddenFromList: false,\n },\n wordGap: {\n type: \"number\",\n min: 4,\n max: 24,\n step: 1,\n default: 11,\n description: \"First word gaps\",\n hiddenFromList: false,\n },\n accel: {\n type: \"number\",\n min: 0.4,\n max: 1,\n step: 0.05,\n default: 0.75,\n description: \"Later gap multiplier\",\n hiddenFromList: false,\n },\n rise: {\n type: \"number\",\n min: 0,\n max: 0.5,\n step: 0.01,\n default: 0.18,\n description: \"Word rise (em)\",\n hiddenFromList: false,\n },\n zoomStep: {\n type: \"number\",\n min: 0,\n max: 0.1,\n step: 0.005,\n default: 0.035,\n description: \"Zoom / word\",\n hiddenFromList: false,\n },\n settleFrames: {\n type: \"number\",\n min: 2,\n max: 20,\n step: 1,\n default: 9,\n description: \"Rise and zoom frames\",\n hiddenFromList: false,\n },\n exitAt: {\n type: \"number\",\n min: 20,\n max: 100,\n step: 1,\n default: 51,\n description: \"Exit start frame\",\n hiddenFromList: false,\n },\n exitFrames: {\n type: \"number\",\n min: 4,\n max: 30,\n step: 1,\n default: 12,\n description: \"Exit duration\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#fff3df\",\n description: \"Color\",\n },\n fontWeight: {\n type: \"enum\",\n default: \"400\",\n variants: {\n \"400\": {},\n \"500\": {},\n \"600\": {},\n \"700\": {},\n },\n description: \"Font weight\",\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"text\",\"fontSize\",\"wordGap\",\"accel\",\"rise\",\"zoomStep\",\"settleFrames\",\"exitAt\",\"exitFrames\",\"color\",\"fontWeight\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n text: \"everything we learn from\",\n fontSize: 52,\n wordGap: 11,\n accel: 0.75,\n rise: 0.18,\n zoomStep: 0.035,\n settleFrames: 9,\n exitAt: 51,\n exitFrames: 12,\n color: \"#fff3df\",\n fontWeight: \"400\",\n speed: 1,\n};\n\ntype CenteredWordBuildElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof CenteredWordBuildBase>;\n\nconst CenteredWordBuildInner = forwardRef<\n HTMLDivElement,\n CenteredWordBuildElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<CenteredWordBuild>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <CenteredWordBuildBase\n {...(componentProps as unknown as ComponentProps<typeof CenteredWordBuildBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const CenteredWordBuild = Interactive.withSchema({\n Component: CenteredWordBuildInner,\n componentName: \"<CenteredWordBuild>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/chat-to-preview-layout.json b/registry-artifacts/elements/chat-to-preview-layout.jsonindex 4165bbb9..a94eb696 100644--- a/registry-artifacts/elements/chat-to-preview-layout.json+++ b/registry-artifacts/elements/chat-to-preview-layout.json@@ -2,10 +2,12 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [],"dimensions": null,"displayName": "Chat to Preview Layout","durationInFrames": 120,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "chat-to-preview-layout","sourceCode": "import { forwardRef, useImperativeHandle, useRef, type ComponentProps, type ReactNode } from \"react\";\nimport { Easing, Interactive, Sequence, interpolate, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\n\ninterface ChatToPreviewLayoutProps {\n chat?: ReactNode;\n preview?: ReactNode;\n startChatRatio?: number;\n endChatRatio?: number;\n speed?: number;\n className?: string;\n}\n\nconst FONT_FAMILY =\n \"var(--font-geist-sans), -apple-system, BlinkMacSystemFont, sans-serif\";\n\nfunction DefaultChat() {\n const messages = [\n { from: \"user\", text: \"Build me a landing page\" },\n { from: \"ai\", text: \"Sure — what should it feature?\" },\n { from: \"user\", text: \"Hero, pricing, footer.\" },\n { from: \"ai\", text: \"On it. Generating now...\" },\n ];\n return (\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n padding: 24,\n display: \"flex\",\n flexDirection: \"column\",\n gap: 12,\n fontFamily: FONT_FAMILY,\n background: \"#111\",\n }}\n >\n <div\n style={{\n color: \"#888\",\n fontSize: 12,\n fontWeight: 600,\n letterSpacing: \"0.08em\",\n textTransform: \"uppercase\",\n marginBottom: 8,\n }}\n >\n Chat\n </div>\n {messages.map((m, i) => (\n <div\n key={i}\n style={{\n alignSelf: m.from === \"user\" ? \"flex-end\" : \"flex-start\",\n background: m.from === \"user\" ? \"#0ea5e9\" : \"#262626\",\n color: \"white\",\n padding: \"10px 14px\",\n borderRadius: 14,\n fontSize: 14,\n maxWidth: \"85%\",\n }}\n >\n {m.text}\n </div>\n ))}\n </div>\n );\n}\n\nfunction DefaultPreview() {\n return (\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n background: \"white\",\n display: \"flex\",\n flexDirection: \"column\",\n fontFamily: FONT_FAMILY,\n }}\n >\n <div\n style={{\n height: 36,\n background: \"#f4f4f5\",\n borderBottom: \"1px solid #e4e4e7\",\n display: \"flex\",\n alignItems: \"center\",\n gap: 6,\n padding: \"0 12px\",\n }}\n >\n <div\n style={{\n width: 10,\n height: 10,\n borderRadius: 999,\n background: \"#ef4444\",\n }}\n />\n <div\n style={{\n width: 10,\n height: 10,\n borderRadius: 999,\n background: \"#f59e0b\",\n }}\n />\n <div\n style={{\n width: 10,\n height: 10,\n borderRadius: 999,\n background: \"#22c55e\",\n }}\n />\n </div>\n <div\n style={{\n flex: 1,\n padding: 32,\n display: \"flex\",\n flexDirection: \"column\",\n gap: 16,\n }}\n >\n <div\n style={{\n fontSize: 36,\n fontWeight: 700,\n letterSpacing: \"-0.03em\",\n color: \"#0a0a0a\",\n }}\n >\n Ship faster.\n </div>\n <div style={{ fontSize: 16, color: \"#71717a\", maxWidth: 360 }}>\n The fastest way to launch your idea. Built with Remotion.\n </div>\n <div\n style={{\n marginTop: 12,\n display: \"inline-flex\",\n background: \"#0a0a0a\",\n color: \"white\",\n padding: \"10px 18px\",\n borderRadius: 10,\n alignSelf: \"flex-start\",\n fontSize: 14,\n fontWeight: 600,\n }}\n >\n Get started\n </div>\n </div>\n </div>\n );\n}\n\nfunction ChatToPreviewLayoutBase({\n chat,\n preview,\n startChatRatio = 0.5,\n endChatRatio = 0.25,\n speed = 1,\n className,\n}: ChatToPreviewLayoutProps) {\n const frame = useCurrentFrame() * speed;\n const { durationInFrames } = useVideoConfig();\n\n // Apple's signature ease — slow start, dramatic settle. Replaces the older\n // symmetric bezier so the morph feels deliberate instead of mechanical.\n const APPLE_EASE = Easing.bezier(0.16, 1, 0.3, 1);\n\n const morphStart = durationInFrames * 0.1;\n const morphEnd = durationInFrames * 0.7;\n\n const ratio = interpolate(\n frame,\n [morphStart, morphEnd],\n [startChatRatio, endChatRatio],\n {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: APPLE_EASE,\n },\n );\n\n // Right (preview) panel reveal: fade in + slide left into its growing slot.\n // Anchored to the same morph window so it feels like the chat is physically\n // dragging the preview into existence.\n const previewOpacity = interpolate(frame, [morphStart, morphEnd], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: APPLE_EASE,\n });\n const previewTx = interpolate(frame, [morphStart, morphEnd], [40, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: APPLE_EASE,\n });\n\n const chatBasis = `${ratio * 100}%`;\n const previewBasis = `${(1 - ratio) * 100}%`;\n\n // Inner content min-widths. These are the lever that prevents text from\n // re-flowing inside the columns as the parent flex-basis morphs — content\n // is rendered at a fixed virtual width, then clipped by `overflow: hidden`\n // on the outer column. No reflow → no jumping characters.\n const CHAT_INNER_MIN = 520;\n const PREVIEW_INNER_MIN = 720;\n\n return (\n <div\n className={className}\n style={{\n position: \"absolute\",\n inset: 0,\n padding: 32,\n display: \"flex\",\n gap: 16,\n }}\n >\n <div\n style={{\n flexBasis: chatBasis,\n flexGrow: 0,\n flexShrink: 0,\n position: \"relative\",\n overflow: \"hidden\",\n borderRadius: 16,\n border: \"1px solid rgba(255,255,255,0.08)\",\n }}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n minWidth: CHAT_INNER_MIN,\n }}\n >\n {chat ?? <DefaultChat />}\n </div>\n </div>\n <div\n style={{\n flexBasis: previewBasis,\n flexGrow: 0,\n flexShrink: 0,\n position: \"relative\",\n overflow: \"hidden\",\n borderRadius: 16,\n border: \"1px solid rgba(255,255,255,0.08)\",\n opacity: previewOpacity,\n translate: `${previewTx}px`,\n }}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n minWidth: PREVIEW_INNER_MIN,\n }}\n >\n {preview ?? <DefaultPreview />}\n </div>\n </div>\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n startChatRatio: {\n type: \"number\",\n min: 0.1,\n max: 0.9,\n step: 0.05,\n default: 0.5,\n description: \"Start chat ratio\",\n hiddenFromList: false,\n },\n endChatRatio: {\n type: \"number\",\n min: 0.05,\n max: 0.9,\n step: 0.05,\n default: 0.25,\n description: \"End chat ratio\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"startChatRatio\",\"endChatRatio\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n startChatRatio: 0.5,\n endChatRatio: 0.25,\n speed: 1,\n};\n\ntype ChatToPreviewLayoutElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof ChatToPreviewLayoutBase>;\n\nconst ChatToPreviewLayoutInner = forwardRef<\n HTMLDivElement,\n ChatToPreviewLayoutElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<ChatToPreviewLayout>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <ChatToPreviewLayoutBase\n {...(componentProps as unknown as ComponentProps<typeof ChatToPreviewLayoutBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const ChatToPreviewLayout = Interactive.withSchema({\n Component: ChatToPreviewLayoutInner,\n componentName: \"<ChatToPreviewLayout>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/chromatic-wave.json b/registry-artifacts/elements/chromatic-wave.jsonindex eed8e46c..d35d2fc1 100644--- a/registry-artifacts/elements/chromatic-wave.json+++ b/registry-artifacts/elements/chromatic-wave.json@@ -2,10 +2,12 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [],"dimensions": null,"displayName": "Chromatic Wave","durationInFrames": 150,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "chromatic-wave","sourceCode": "import { forwardRef, useId, useImperativeHandle, useRef, type ComponentProps } from \"react\";\nimport { Interactive, Sequence, interpolate, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\n\ninterface ChromaticWaveProps {\n className?: string;\n width?: number;\n height?: number;\n headline?: string;\n kicker?: string;\n headlineFontFamily?: string;\n kickerFontFamily?: string;\n headlineFontSize?: number;\n kickerFontSize?: number;\n kickerTracking?: number;\n headlineBaselineY?: number;\n kickerBaselines?: [number, number];\n textCenterX?: number;\n fill?: string;\n background?: string;\n bandHeight?: number;\n bandCopies?: number;\n bandPitch?: number;\n mapStartY?: number;\n mapEndY?: number;\n mapTravelFrames?: number;\n waveHeight?: number;\n waveWidth?: number;\n waveSpeed?: number;\n turbulentAmount?: number;\n turbulentSize?: number;\n evolutionPerSecond?: number;\n mapBlurRadius?: number;\n mapBlurIterations?: number;\n glassDisplacement?: number;\n maxDisplacementPx?: number;\n glassPasses?: number;\n channelOrder?: (\"red\" | \"green\" | \"blue\")[];\n}\n\nfunction boxBlurSigma(radius: number, iterations: number): number {\n const w = 2 * radius + 1;\n return Math.sqrt((iterations * (w * w - 1)) / 12);\n}\n\nfunction buildMapUri({\n width,\n height,\n bandHeight,\n bandCopies,\n bandPitch,\n mapY,\n waveHeight,\n waveWidth,\n phase,\n}: {\n width: number;\n height: number;\n bandHeight: number;\n bandCopies: number;\n bandPitch: number;\n mapY: number;\n waveHeight: number;\n waveWidth: number;\n phase: number;\n}): string {\n const overhang = 120;\n const segments = 48;\n\n const bands = Array.from({ length: bandCopies }, (_, i) => {\n const top = mapY + i * bandPitch - bandHeight / 2;\n const pts = Array.from({ length: segments + 1 }, (_, s) => {\n const x = -overhang + (s / segments) * (width + overhang * 2);\n const y =\n top + Math.sin((x / waveWidth) * Math.PI * 2 + phase) * waveHeight;\n return `${x},${y}`;\n });\n const back = Array.from({ length: segments + 1 }, (_, s) => {\n const x =\n -overhang + ((segments - s) / segments) * (width + overhang * 2);\n const y =\n top +\n bandHeight +\n Math.sin((x / waveWidth) * Math.PI * 2 + phase) * waveHeight;\n return `${x},${y}`;\n });\n return `<path d=\"M${pts.join(\"L\")}L${back.join(\"L\")}Z\" fill=\"url(#g)\"/>`;\n }).join(\"\");\n\n const svg =\n `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"${width}\" height=\"${height}\">` +\n `<defs><linearGradient id=\"g\" x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\">` +\n `<stop offset=\"0\" stop-color=\"rgb(128,128,128)\"/>` +\n `<stop offset=\"0.25\" stop-color=\"rgb(0,0,0)\"/>` +\n `<stop offset=\"0.5\" stop-color=\"rgb(128,128,128)\"/>` +\n `<stop offset=\"0.75\" stop-color=\"rgb(255,255,255)\"/>` +\n `<stop offset=\"1\" stop-color=\"rgb(128,128,128)\"/>` +\n `</linearGradient></defs>` +\n `<rect width=\"${width}\" height=\"${height}\" fill=\"rgb(128,128,128)\"/>` +\n bands +\n `</svg>`;\n\n return `data:image/svg+xml;utf8,${encodeURIComponent(svg)}`;\n}\n\nfunction ChromaticWaveBase({\n className,\n width = 1920,\n height = 1080,\n headline = \"MUSIC\",\n kicker = \"APPLES\",\n headlineFontFamily = \"'Helvetica Neue', Helvetica, Arial, sans-serif\",\n kickerFontFamily = \"'Helvetica Neue', Helvetica, Arial, sans-serif\",\n headlineFontSize = 174,\n kickerFontSize = 52,\n kickerTracking = 32,\n headlineBaselineY = 601,\n kickerBaselines = [444, 670],\n textCenterX = 960,\n fill = \"#ffffff\",\n background = \"#000000\",\n bandHeight = 147.1,\n bandCopies = 7,\n bandPitch = 750,\n mapStartY = 31,\n mapEndY = 1560,\n mapTravelFrames = 150,\n waveHeight = 28,\n waveWidth = 272,\n waveSpeed = 1,\n turbulentAmount = 130,\n turbulentSize = 163,\n evolutionPerSecond = 50,\n mapBlurRadius = 13,\n mapBlurIterations = 6,\n glassDisplacement = 100,\n maxDisplacementPx = 39,\n glassPasses = 3,\n channelOrder = [\"blue\", \"green\", \"red\"],\n}: ChromaticWaveProps) {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const filterId = useId();\n const seconds = frame / fps;\n\n const mapY = interpolate(frame, [0, mapTravelFrames], [mapStartY, mapEndY], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n });\n\n const mapUri = buildMapUri({\n width,\n height,\n bandHeight,\n bandCopies,\n bandPitch,\n mapY,\n waveHeight,\n waveWidth,\n phase: seconds * waveSpeed * Math.PI * 2,\n });\n\n const mapSigma = boxBlurSigma(mapBlurRadius, mapBlurIterations);\n const evolution = seconds * evolutionPerSecond;\n\n const channelMatrix: Record<string, string> = {\n red: \"1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0\",\n green: \"0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0\",\n blue: \"0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0\",\n };\n\n const content = (\n <>\n <text\n x={textCenterX}\n y={kickerBaselines[0]}\n textAnchor=\"middle\"\n fontFamily={kickerFontFamily}\n fontSize={kickerFontSize}\n letterSpacing={kickerTracking}\n fill={fill}\n >\n {kicker}\n </text>\n <text\n x={textCenterX}\n y={headlineBaselineY}\n textAnchor=\"middle\"\n fontFamily={headlineFontFamily}\n fontWeight={700}\n fontSize={headlineFontSize}\n fill={fill}\n >\n {headline}\n </text>\n <text\n x={textCenterX}\n y={kickerBaselines[1]}\n textAnchor=\"middle\"\n fontFamily={kickerFontFamily}\n fontSize={kickerFontSize}\n letterSpacing={kickerTracking}\n fill={fill}\n >\n {kicker}\n </text>\n </>\n );\n\n return (\n <div\n className={className}\n style={{ position: \"absolute\", inset: 0, overflow: \"hidden\" }}\n >\n <svg\n width=\"100%\"\n height=\"100%\"\n viewBox={`0 0 ${width} ${height}`}\n preserveAspectRatio=\"xMidYMid meet\"\n style={{ display: \"block\" }}\n >\n <defs>\n {Array.from({ length: glassPasses }, (_, i) => {\n const depth =\n ((i + 1) / glassPasses) *\n maxDisplacementPx *\n (glassDisplacement / 100);\n return (\n <filter\n key={channelOrder[i] ?? i}\n id={`${filterId}-${i}`}\n filterUnits=\"userSpaceOnUse\"\n x=\"0\"\n y=\"0\"\n width={width}\n height={height}\n colorInterpolationFilters=\"sRGB\"\n >\n <feImage\n href={mapUri}\n x=\"0\"\n y=\"0\"\n width={width}\n height={height}\n result=\"rawMap\"\n />\n <feTurbulence\n type=\"turbulence\"\n baseFrequency={1 / Math.max(turbulentSize, 1)}\n numOctaves={1}\n seed={11}\n result=\"noise\"\n />\n <feOffset\n in=\"noise\"\n dx={evolution}\n dy={evolution * 0.4}\n result=\"noiseMoved\"\n />\n <feDisplacementMap\n in=\"rawMap\"\n in2=\"noiseMoved\"\n scale={turbulentAmount}\n xChannelSelector=\"R\"\n yChannelSelector=\"G\"\n result=\"turbulentMap\"\n />\n <feGaussianBlur\n in=\"turbulentMap\"\n stdDeviation={mapSigma}\n result=\"slopeMap\"\n />\n <feDisplacementMap\n in=\"SourceGraphic\"\n in2=\"slopeMap\"\n scale={depth}\n xChannelSelector=\"R\"\n yChannelSelector=\"R\"\n result=\"displaced\"\n />\n <feColorMatrix\n in=\"displaced\"\n type=\"matrix\"\n values={channelMatrix[channelOrder[i] ?? \"red\"]}\n />\n </filter>\n );\n })}\n </defs>\n\n <rect width={width} height={height} fill={background} />\n\n {Array.from({ length: glassPasses }, (_, i) => (\n <g\n key={channelOrder[i] ?? i}\n filter={`url(#${filterId}-${i})`}\n style={{ mixBlendMode: \"screen\" }}\n >\n {content}\n </g>\n ))}\n </svg>\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n headline: {\n type: \"text-content\",\n default: \"MUSIC\",\n description: \"Headline\",\n },\n kicker: {\n type: \"text-content\",\n default: \"APPLES\",\n description: \"Kicker\",\n },\n fill: {\n type: \"color\",\n default: \"#ffffff\",\n description: \"Fill\",\n },\n waveHeight: {\n type: \"number\",\n min: 0,\n max: 40,\n step: 1,\n default: 28,\n description: \"Wave height\",\n hiddenFromList: false,\n },\n maxDisplacementPx: {\n type: \"number\",\n min: 0,\n max: 60,\n step: 1,\n default: 39,\n description: \"Displacement (px)\",\n hiddenFromList: false,\n },\n turbulentAmount: {\n type: \"number\",\n min: 0,\n max: 200,\n step: 2,\n default: 130,\n description: \"Turbulence\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"headline\",\"kicker\",\"fill\",\"waveHeight\",\"maxDisplacementPx\",\"turbulentAmount\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n headline: \"MUSIC\",\n kicker: \"APPLES\",\n fill: \"#ffffff\",\n waveHeight: 28,\n maxDisplacementPx: 39,\n turbulentAmount: 130,\n speed: 1,\n};\n\ntype ChromaticWaveElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof ChromaticWaveBase>;\n\nconst ChromaticWaveInner = forwardRef<\n HTMLDivElement,\n ChromaticWaveElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<ChromaticWave>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <ChromaticWaveBase\n {...(componentProps as unknown as ComponentProps<typeof ChromaticWaveBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const ChromaticWave = Interactive.withSchema({\n Component: ChromaticWaveInner,\n componentName: \"<ChromaticWave>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/confetti.json b/registry-artifacts/elements/confetti.jsonindex 4c2077bf..dcd3b270 100644--- a/registry-artifacts/elements/confetti.json+++ b/registry-artifacts/elements/confetti.json@@ -2,10 +2,12 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [],"dimensions": null,"displayName": "Confetti","durationInFrames": 90,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "confetti","sourceCode": "import { AbsoluteFill, Interactive, Sequence, interpolate, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface ConfettiProps {\n /** Number of confetti pieces. */\n particleCount?: number;\n colors?: string[];\n /** Burst origin as a 0..1 fraction of the canvas. */\n originX?: number;\n originY?: number;\n /** Frame the burst fires on. */\n startFrame?: number;\n /** Lifetime of the burst, in frames. */\n lifetime?: number;\n /** Initial launch speed (px/frame at the 720px reference height). */\n power?: number;\n /** Downward acceleration (px/frame² at the 720px reference height). */\n gravity?: number;\n /** Base piece size in reference px. */\n size?: number;\n /** PRNG seed — same seed renders an identical burst every time. */\n seed?: number;\n}\n\ninterface Particle {\n angle: number;\n speed: number;\n color: string;\n size: number;\n rot0: number;\n spin: number;\n drift: number;\n}\n\nconst DEFAULT_COLORS = [\n \"#1d9bf0\",\n \"#ff5da2\",\n \"#ffd23f\",\n \"#22c55e\",\n \"#a855f7\",\n \"#ff7a45\",\n];\n\n// --- Pure helpers (unit-tested) -------------------------------------------\n\n/** Deterministic PRNG (mulberry32) — returns a function yielding [0, 1). */\nfunction mulberry32(seed: number): () => number {\n let a = seed >>> 0;\n return () => {\n a = (a + 0x6d2b79f5) | 0;\n let t = Math.imul(a ^ (a >>> 15), 1 | a);\n t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t;\n return ((t ^ (t >>> 14)) >>> 0) / 4294967296;\n };\n}\n\n/** Build a deterministic particle set for a seed (stable across renders). */\nfunction makeParticles({\n count,\n seed,\n colors,\n}: {\n count: number;\n seed: number;\n colors: string[];\n}): Particle[] {\n const rand = mulberry32(seed);\n const palette = colors.length > 0 ? colors : DEFAULT_COLORS;\n const out: Particle[] = [];\n for (let i = 0; i < count; i++) {\n const angle = rand() * Math.PI * 2;\n const speed = 0.35 + 0.65 * rand();\n out.push({\n angle,\n speed,\n color: palette[Math.floor(rand() * palette.length)],\n size: 0.7 + 0.6 * rand(),\n rot0: rand() * Math.PI * 2,\n spin: (rand() - 0.5) * 0.6,\n drift: (rand() - 0.5) * 2,\n });\n }\n return out;\n}\n\n/** Opacity envelope over a particle's lifetime: quick fade-in, slow fade-out. */\nfunction particleOpacity(tt: number, lifetime: number): number {\n if (tt < 0 || tt > lifetime) return 0;\n const fadeIn = interpolate(tt, [0, 4], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n });\n const fadeOut = interpolate(tt, [lifetime * 0.7, lifetime], [1, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n });\n return Math.min(fadeIn, fadeOut);\n}\n\n// --- Component -------------------------------------------------------------\n\nfunction ConfettiBase({\n particleCount = 140,\n colors = DEFAULT_COLORS,\n originX = 0.5,\n originY = 0.5,\n startFrame = 0,\n lifetime = 90,\n power = 17,\n gravity = 0.45,\n size = 13,\n seed = 1,\n}: ConfettiProps) {\n const frame = useCurrentFrame();\n const { width, height } = useVideoConfig();\n\n const tt = frame - startFrame;\n if (tt < 0 || tt > lifetime) return null;\n\n const sc = height / 720;\n const ox = width * originX;\n const oy = height * originY;\n const particles = makeParticles({ count: particleCount, seed, colors });\n\n return (\n <AbsoluteFill style={{ pointerEvents: \"none\" }}>\n {particles.map((p, i) => {\n const opacity = particleOpacity(tt, lifetime);\n if (opacity <= 0) return null;\n\n const vx = Math.cos(p.angle) * p.speed * power + p.drift;\n const vy = Math.sin(p.angle) * p.speed * power;\n const x = ox + vx * tt * sc;\n const y = oy + (vy * tt + 0.5 * gravity * tt * tt) * sc;\n const rot = p.rot0 + p.spin * tt;\n const flutter = Math.cos(p.rot0 + p.spin * tt * 1.6);\n const w = size * p.size * sc;\n\n return (\n <div\n key={i}\n style={{\n position: \"absolute\",\n left: x,\n top: y,\n width: w,\n height: w * 0.62,\n borderRadius: 2,\n background: p.color,\n opacity,\n translate: \"-50% -50%\",\n rotate: `${rot}rad`,\n scale: `${flutter} 1`,\n }}\n />\n );\n })}\n </AbsoluteFill>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n particleCount: {\n type: \"number\",\n min: 10,\n max: 400,\n step: 10,\n default: 140,\n description: \"Particles\",\n hiddenFromList: false,\n },\n power: {\n type: \"number\",\n min: 4,\n max: 40,\n step: 1,\n default: 17,\n description: \"Power\",\n hiddenFromList: false,\n },\n gravity: {\n type: \"number\",\n min: 0,\n max: 1.5,\n step: 0.05,\n default: 0.45,\n description: \"Gravity\",\n hiddenFromList: false,\n },\n size: {\n type: \"number\",\n min: 4,\n max: 30,\n step: 1,\n default: 13,\n description: \"Size\",\n hiddenFromList: false,\n },\n seed: {\n type: \"number\",\n min: 1,\n step: 1,\n default: 1,\n description: \"Seed\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"particleCount\",\"power\",\"gravity\",\"size\",\"seed\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n particleCount: 140,\n power: 17,\n gravity: 0.45,\n size: 13,\n seed: 1,\n speed: 1,\n};\n\ntype ConfettiElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof ConfettiBase>;\n\nconst ConfettiInner = forwardRef<\n HTMLDivElement,\n ConfettiElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<Confetti>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <ConfettiBase\n {...(componentProps as unknown as ComponentProps<typeof ConfettiBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const Confetti = Interactive.withSchema({\n Component: ConfettiInner,\n componentName: \"<Confetti>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/crt-screen.json b/registry-artifacts/elements/crt-screen.jsonindex dbee8ea3..975dacdf 100644--- a/registry-artifacts/elements/crt-screen.json+++ b/registry-artifacts/elements/crt-screen.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/transitions",@@ -11,6 +12,7 @@"dimensions": null,"displayName": "CRT Screen","durationInFrames": 90,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "crt-screen","sourceCode": "import { AbsoluteFill, Interactive, Sequence, isHtmlInCanvasSupported, useCurrentFrame, useDelayRender, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport React, { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\nimport { type TransitionPresentation, type TransitionPresentationComponentProps } from \"@remotion/transitions\";\n\nconst QUAD = new Float32Array([-1, -1, 1, -1, -1, 1, 1, 1]);\n\nconst VERTEX_SHADER = `#version 300 es\nin vec2 a_pos;\nout vec2 v_uv;\nvoid main() {\n v_uv = vec2(a_pos.x * 0.5 + 0.5, 0.5 - a_pos.y * 0.5);\n gl_Position = vec4(a_pos, 0.0, 1.0);\n}`;\n\nconst LAYER: React.CSSProperties = {\n position: \"absolute\",\n inset: 0,\n width: \"100%\",\n height: \"100%\",\n};\n\nconst OUTPUT_LAYER: React.CSSProperties = { ...LAYER, pointerEvents: \"none\" };\n\nconst isCanvasTransitionSupported = (): boolean =>\n isHtmlInCanvasSupported();\n\nconst isCanvasFilterSupported = (): boolean => isHtmlInCanvasSupported();\n\ntype SceneShaderFrame<Props> = {\n gl: WebGL2RenderingContext;\n uniform: (name: string) => WebGLUniformLocation | null;\n width: number;\n height: number;\n progress: number;\n passedProps: Props;\n};\n\ntype SceneShaderDrawParams<Props> = {\n from: OffscreenCanvas | null;\n to: OffscreenCanvas | null;\n width: number;\n height: number;\n progress: number;\n passedProps: Props;\n};\n\ntype SceneShaderInstance<Props> = {\n draw: (params: SceneShaderDrawParams<Props>) => void;\n clear: () => void;\n cleanup: () => void;\n};\n\ntype SceneShader<Props> = (\n canvas: OffscreenCanvas,\n) => SceneShaderInstance<Props>;\n\ntype SceneFilterFrame<Props> = {\n gl: WebGL2RenderingContext;\n uniform: (name: string) => WebGLUniformLocation | null;\n width: number;\n height: number;\n frame: number;\n time: number;\n passedProps: Props;\n};\n\ntype SceneFilterDrawParams<Props> = {\n scene: OffscreenCanvas | null;\n width: number;\n height: number;\n frame: number;\n time: number;\n passedProps: Props;\n};\n\ntype SceneFilterInstance<Props> = {\n draw: (params: SceneFilterDrawParams<Props>) => void;\n clear: () => void;\n cleanup: () => void;\n};\n\ntype SceneFilter<Props> = (\n canvas: OffscreenCanvas,\n) => SceneFilterInstance<Props>;\n\nfunction compileShader(\n gl: WebGL2RenderingContext,\n source: string,\n type: GLenum,\n): WebGLShader {\n const shader = gl.createShader(type);\n if (!shader) {\n throw new Error(\"canvas-presentation: failed to create shader\");\n }\n gl.shaderSource(shader, source);\n gl.compileShader(shader);\n if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {\n const log = gl.getShaderInfoLog(shader);\n gl.deleteShader(shader);\n throw new Error(`canvas-presentation: failed to compile shader: ${log}`);\n }\n return shader;\n}\n\nfunction createProgram(\n gl: WebGL2RenderingContext,\n fragment: string,\n): WebGLProgram {\n const program = gl.createProgram();\n if (!program) {\n throw new Error(\"canvas-presentation: failed to create program\");\n }\n const vs = compileShader(gl, VERTEX_SHADER, gl.VERTEX_SHADER);\n const fs = compileShader(gl, fragment, gl.FRAGMENT_SHADER);\n gl.attachShader(program, vs);\n gl.attachShader(program, fs);\n gl.linkProgram(program);\n gl.deleteShader(vs);\n gl.deleteShader(fs);\n if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {\n const log = gl.getProgramInfoLog(program);\n gl.deleteProgram(program);\n throw new Error(`canvas-presentation: failed to link program: ${log}`);\n }\n return program;\n}\n\nfunction createSceneTexture(gl: WebGL2RenderingContext): WebGLTexture {\n const texture = gl.createTexture();\n if (!texture) {\n throw new Error(\"canvas-presentation: failed to create texture\");\n }\n gl.bindTexture(gl.TEXTURE_2D, texture);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);\n gl.texImage2D(\n gl.TEXTURE_2D,\n 0,\n gl.RGBA,\n 1,\n 1,\n 0,\n gl.RGBA,\n gl.UNSIGNED_BYTE,\n new Uint8Array([0, 0, 0, 0]),\n );\n return texture;\n}\n\nfunction createQuadSurface(canvas: OffscreenCanvas, fragment: string) {\n const gl = canvas.getContext(\"webgl2\", { premultipliedAlpha: true });\n if (!gl) {\n throw new Error(\"canvas-presentation: WebGL2 is unavailable\");\n }\n\n const program = createProgram(gl, fragment);\n const vao = gl.createVertexArray();\n gl.bindVertexArray(vao);\n const buffer = gl.createBuffer();\n gl.bindBuffer(gl.ARRAY_BUFFER, buffer);\n gl.bufferData(gl.ARRAY_BUFFER, QUAD, gl.STATIC_DRAW);\n const aPos = gl.getAttribLocation(program, \"a_pos\");\n gl.enableVertexAttribArray(aPos);\n gl.vertexAttribPointer(aPos, 2, gl.FLOAT, false, 0, 0);\n\n const locations = new Map<string, WebGLUniformLocation | null>();\n const uniform = (name: string) => {\n const cached = locations.get(name);\n if (cached !== undefined) {\n return cached;\n }\n const location = gl.getUniformLocation(program, name);\n locations.set(name, location);\n return location;\n };\n\n const clear = () => {\n gl.clearColor(0, 0, 0, 0);\n gl.clear(gl.COLOR_BUFFER_BIT);\n };\n\n const textures: WebGLTexture[] = [];\n const createTexture = () => {\n const texture = createSceneTexture(gl);\n textures.push(texture);\n return texture;\n };\n\n const begin = (width: number, height: number) => {\n gl.viewport(0, 0, width, height);\n clear();\n gl.useProgram(program);\n gl.bindVertexArray(vao);\n };\n\n const bindScene = (\n image: OffscreenCanvas | null,\n texture: WebGLTexture,\n unit: number,\n name: string,\n ) => {\n gl.activeTexture(gl.TEXTURE0 + unit);\n gl.bindTexture(gl.TEXTURE_2D, texture);\n if (image) {\n gl.texImage2D(\n gl.TEXTURE_2D,\n 0,\n gl.RGBA,\n gl.RGBA,\n gl.UNSIGNED_BYTE,\n image,\n );\n }\n gl.uniform1i(uniform(name), unit);\n };\n\n const draw = () => gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);\n\n const cleanup = () => {\n gl.deleteProgram(program);\n for (const texture of textures) {\n gl.deleteTexture(texture);\n }\n gl.deleteBuffer(buffer);\n gl.deleteVertexArray(vao);\n };\n\n return {\n gl,\n uniform,\n clear,\n createTexture,\n begin,\n bindScene,\n draw,\n cleanup,\n };\n}\n\nfunction makeSceneShader<Props extends Record<string, unknown>>(\n fragment: string,\n setUniforms?: (frame: SceneShaderFrame<Props>) => void,\n): SceneShader<Props> {\n return (canvas) => {\n const surface = createQuadSurface(canvas, fragment);\n const fromTexture = surface.createTexture();\n const toTexture = surface.createTexture();\n\n return {\n clear: surface.clear,\n cleanup: surface.cleanup,\n draw: ({ from, to, width, height, progress, passedProps }) => {\n surface.begin(width, height);\n surface.bindScene(from, fromTexture, 0, \"u_from\");\n surface.bindScene(to, toTexture, 1, \"u_to\");\n\n surface.gl.uniform1f(surface.uniform(\"u_progress\"), progress);\n surface.gl.uniform1f(surface.uniform(\"u_aspect\"), width / height);\n setUniforms?.({\n gl: surface.gl,\n uniform: surface.uniform,\n width,\n height,\n progress,\n passedProps,\n });\n\n surface.draw();\n },\n };\n };\n}\n\nfunction makeFilterShader<Props extends Record<string, unknown>>(\n fragment: string,\n setUniforms?: (frame: SceneFilterFrame<Props>) => void,\n): SceneFilter<Props> {\n return (canvas) => {\n const surface = createQuadSurface(canvas, fragment);\n const sceneTexture = surface.createTexture();\n\n return {\n clear: surface.clear,\n cleanup: surface.cleanup,\n draw: ({ scene, width, height, frame, time, passedProps }) => {\n surface.begin(width, height);\n surface.bindScene(scene, sceneTexture, 0, \"u_scene\");\n\n surface.gl.uniform1f(surface.uniform(\"u_frame\"), frame);\n surface.gl.uniform1f(surface.uniform(\"u_time\"), time);\n surface.gl.uniform1f(surface.uniform(\"u_aspect\"), width / height);\n setUniforms?.({\n gl: surface.gl,\n uniform: surface.uniform,\n width,\n height,\n frame,\n time,\n passedProps,\n });\n\n surface.draw();\n },\n };\n };\n}\n\nconst transferred = new WeakMap<HTMLCanvasElement, OffscreenCanvas>();\n\nfunction takeOffscreen(canvas: HTMLCanvasElement): OffscreenCanvas {\n const existing = transferred.get(canvas);\n if (existing) {\n return existing;\n }\n const created = canvas.transferControlToOffscreen();\n transferred.set(canvas, created);\n return created;\n}\n\nfunction makeCanvasComponent<Props extends Record<string, unknown>>(\n shader: SceneShader<Props>,\n): React.FC<TransitionPresentationComponentProps<Props>> {\n return function CanvasScenePresentation({\n children,\n presentationProgress,\n presentationDirection,\n passedProps,\n onElementImage,\n onUnmount,\n bothEnteringAndExiting,\n }) {\n const layoutRef = React.useRef<HTMLCanvasElement | null>(null);\n const outputRef = React.useRef<HTMLCanvasElement | null>(null);\n const captureRef = React.useRef<OffscreenCanvas | null>(null);\n const captureContextRef =\n React.useRef<OffscreenCanvasRenderingContext2D | null>(null);\n const outputSurfaceRef = React.useRef<OffscreenCanvas | null>(null);\n const instanceRef = React.useRef<SceneShaderInstance<Props> | null>(null);\n const passedPropsRef = React.useRef(passedProps);\n passedPropsRef.current = passedProps;\n const onElementImageRef = React.useRef(onElementImage);\n onElementImageRef.current = onElementImage;\n const onUnmountRef = React.useRef(onUnmount);\n onUnmountRef.current = onUnmount;\n\n const { delayRender, continueRender } = useDelayRender();\n const passThrough =\n bothEnteringAndExiting && presentationDirection === \"exiting\";\n\n const drawRef = React.useRef<\n (\n prevImage: OffscreenCanvas | null,\n nextImage: OffscreenCanvas | null,\n progress: number,\n ) => void\n >(() => undefined);\n drawRef.current = (prevImage, nextImage, progress) => {\n const instance = instanceRef.current;\n if (!instance) {\n return;\n }\n const handle = delayRender(\"canvas-presentation: paint\");\n const to = prevImage;\n const from = nextImage;\n const width = from?.width ?? to?.width ?? 0;\n const height = from?.height ?? to?.height ?? 0;\n if (width === 0 || height === 0) {\n instance.clear();\n continueRender(handle);\n return;\n }\n instance.draw({\n from,\n to,\n width,\n height,\n progress: !to ? 0 : !from ? 1 : progress,\n passedProps: passedPropsRef.current,\n });\n continueRender(handle);\n };\n\n const draw = React.useCallback(\n (\n prevImage: OffscreenCanvas | null,\n nextImage: OffscreenCanvas | null,\n progress: number,\n ) => drawRef.current(prevImage, nextImage, progress),\n [],\n );\n\n React.useLayoutEffect(() => {\n if (passThrough) {\n return;\n }\n const layout = layoutRef.current;\n const output = outputRef.current;\n if (!layout || !output) {\n return;\n }\n const capture = takeOffscreen(layout);\n const context = capture.getContext(\"2d\");\n if (!context) {\n throw new Error(\"canvas-presentation: failed to acquire a 2D context\");\n }\n const surface = takeOffscreen(output);\n captureRef.current = capture;\n captureContextRef.current = context;\n outputSurfaceRef.current = surface;\n instanceRef.current = shader(surface);\n\n return () => {\n instanceRef.current?.cleanup();\n instanceRef.current = null;\n captureRef.current = null;\n captureContextRef.current = null;\n outputSurfaceRef.current = null;\n };\n }, [passThrough, shader]);\n\n React.useLayoutEffect(() => {\n if (passThrough) {\n return;\n }\n const layout = layoutRef.current;\n if (!layout) {\n return;\n }\n layout.layoutSubtree = true;\n const handlePaint = () => {\n const scene = layout.firstElementChild;\n const capture = captureRef.current;\n const context = captureContextRef.current;\n if (!scene || !capture || !context) {\n return;\n }\n const elementImage = layout.captureElementImage(scene);\n try {\n context.reset();\n context.drawElementImage(elementImage, 0, 0);\n } finally {\n elementImage.close();\n }\n onElementImageRef.current(capture, draw);\n };\n layout.addEventListener(\"paint\", handlePaint);\n return () => layout.removeEventListener(\"paint\", handlePaint);\n }, [passThrough, draw]);\n\n React.useLayoutEffect(() => {\n if (passThrough) {\n return;\n }\n const layout = layoutRef.current;\n if (!layout) {\n return;\n }\n const observer = new ResizeObserver(([entry]) => {\n const capture = captureRef.current;\n const surface = outputSurfaceRef.current;\n if (!capture || !surface) {\n return;\n }\n const width = entry.devicePixelContentBoxSize[0].inlineSize;\n const height = entry.devicePixelContentBoxSize[0].blockSize;\n capture.width = width;\n capture.height = height;\n surface.width = width;\n surface.height = height;\n layout.requestPaint?.();\n });\n observer.observe(layout, { box: \"device-pixel-content-box\" });\n return () => observer.disconnect();\n }, [passThrough]);\n\n // biome-ignore lint/correctness/useExhaustiveDependencies: presentationProgress is the intentional trigger — a new progress value is what schedules the next paint\n React.useLayoutEffect(() => {\n if (passThrough) {\n return;\n }\n layoutRef.current?.requestPaint?.();\n }, [passThrough, presentationProgress]);\n\n React.useLayoutEffect(() => {\n if (passThrough) {\n return;\n }\n return () => onUnmountRef.current();\n }, [passThrough]);\n\n if (passThrough) {\n return <>{children}</>;\n }\n\n return (\n <AbsoluteFill>\n <canvas ref={layoutRef} style={LAYER}>\n {children}\n </canvas>\n <canvas ref={outputRef} style={OUTPUT_LAYER} />\n </AbsoluteFill>\n );\n };\n}\n\ntype CanvasFilterProps = {\n children: React.ReactNode;\n};\n\nfunction makeFilterComponent<Props extends Record<string, unknown>>(\n shader: SceneFilter<Props>,\n): React.FC<Props & CanvasFilterProps> {\n return function CanvasSceneFilter(props) {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const { delayRender, continueRender } = useDelayRender();\n\n const layoutRef = React.useRef<HTMLCanvasElement | null>(null);\n const outputRef = React.useRef<HTMLCanvasElement | null>(null);\n const captureRef = React.useRef<OffscreenCanvas | null>(null);\n const captureContextRef =\n React.useRef<OffscreenCanvasRenderingContext2D | null>(null);\n const outputSurfaceRef = React.useRef<OffscreenCanvas | null>(null);\n const instanceRef = React.useRef<SceneFilterInstance<Props> | null>(null);\n\n const passedPropsRef = React.useRef(props);\n passedPropsRef.current = props;\n const frameRef = React.useRef(frame);\n frameRef.current = frame;\n const timeRef = React.useRef(frame / fps);\n timeRef.current = frame / fps;\n\n React.useLayoutEffect(() => {\n const layout = layoutRef.current;\n const output = outputRef.current;\n if (!layout || !output) {\n return;\n }\n const capture = takeOffscreen(layout);\n const context = capture.getContext(\"2d\");\n if (!context) {\n throw new Error(\"canvas-presentation: failed to acquire a 2D context\");\n }\n const surface = takeOffscreen(output);\n captureRef.current = capture;\n captureContextRef.current = context;\n outputSurfaceRef.current = surface;\n instanceRef.current = shader(surface);\n\n return () => {\n instanceRef.current?.cleanup();\n instanceRef.current = null;\n captureRef.current = null;\n captureContextRef.current = null;\n outputSurfaceRef.current = null;\n };\n }, [shader]);\n\n React.useLayoutEffect(() => {\n const layout = layoutRef.current;\n if (!layout) {\n return;\n }\n layout.layoutSubtree = true;\n const handlePaint = () => {\n const scene = layout.firstElementChild;\n const capture = captureRef.current;\n const context = captureContextRef.current;\n const instance = instanceRef.current;\n if (!scene || !capture || !context || !instance) {\n return;\n }\n const elementImage = layout.captureElementImage(scene);\n try {\n context.reset();\n context.drawElementImage(elementImage, 0, 0);\n } finally {\n elementImage.close();\n }\n if (capture.width === 0 || capture.height === 0) {\n instance.clear();\n return;\n }\n instance.draw({\n scene: capture,\n width: capture.width,\n height: capture.height,\n frame: frameRef.current,\n time: timeRef.current,\n passedProps: passedPropsRef.current,\n });\n };\n layout.addEventListener(\"paint\", handlePaint);\n return () => layout.removeEventListener(\"paint\", handlePaint);\n }, []);\n\n React.useLayoutEffect(() => {\n const layout = layoutRef.current;\n if (!layout) {\n return;\n }\n const observer = new ResizeObserver(([entry]) => {\n const capture = captureRef.current;\n const surface = outputSurfaceRef.current;\n if (!capture || !surface) {\n return;\n }\n const width = entry.devicePixelContentBoxSize[0].inlineSize;\n const height = entry.devicePixelContentBoxSize[0].blockSize;\n capture.width = width;\n capture.height = height;\n surface.width = width;\n surface.height = height;\n layout.requestPaint?.();\n });\n observer.observe(layout, { box: \"device-pixel-content-box\" });\n return () => observer.disconnect();\n }, []);\n\n React.useLayoutEffect(() => {\n const layout = layoutRef.current;\n if (!layout) {\n return;\n }\n const handle = delayRender(\"canvas-presentation: filter paint\");\n const settle = () => continueRender(handle);\n layout.addEventListener(\"paint\", settle, { once: true });\n layout.requestPaint?.();\n return () => {\n layout.removeEventListener(\"paint\", settle);\n continueRender(handle);\n };\n });\n\n return (\n <AbsoluteFill>\n <canvas ref={layoutRef} style={LAYER}>\n {props.children}\n </canvas>\n <canvas ref={outputRef} style={OUTPUT_LAYER} />\n </AbsoluteFill>\n );\n };\n}\n\ntype CanvasPresentationOptions<Props extends Record<string, unknown>> = {\n shader: SceneShader<Props>;\n fallback: React.FC<TransitionPresentationComponentProps<Props>>;\n};\n\nfunction makeCanvasPresentation<Props extends Record<string, unknown>>({\n shader,\n fallback: Fallback,\n}: CanvasPresentationOptions<Props>): (\n props: Props,\n) => TransitionPresentation<Props> {\n const Canvas = makeCanvasComponent(shader);\n\n const Presentation: React.FC<TransitionPresentationComponentProps<Props>> = (\n props,\n ) =>\n isCanvasTransitionSupported() ? (\n <Canvas {...props} />\n ) : (\n <Fallback {...props} />\n );\n\n return (props) => ({ component: Presentation, props });\n}\n\ntype CanvasFilterOptions<Props extends Record<string, unknown>> = {\n shader: SceneFilter<Props>;\n fallback: React.FC<Props & CanvasFilterProps>;\n};\n\nfunction makeCanvasFilter<Props extends Record<string, unknown>>({\n shader,\n fallback: Fallback,\n}: CanvasFilterOptions<Props>): React.FC<Props & CanvasFilterProps> {\n const Canvas = makeFilterComponent(shader);\n\n return function CanvasFilter(props) {\n return isCanvasFilterSupported() ? (\n <Canvas {...props} />\n ) : (\n <Fallback {...props} />\n );\n };\n}\n\ntype CrtScreenProps = {\n curvature?: number;\n scanlines?: number;\n maskScale?: number;\n vignette?: number;\n};\n\nconst DEFAULTS = {\n curvature: 1,\n scanlines: 1,\n maskScale: 2,\n vignette: 1,\n};\n\nconst FRAGMENT_SHADER = `#version 300 es\nprecision highp float;\n\nuniform sampler2D u_scene;\nuniform float u_frame;\nuniform float u_curvature;\nuniform float u_scanlines;\nuniform float u_mask_scale;\nuniform float u_vignette;\n\nin vec2 v_uv;\nout vec4 outColor;\n\nconst float PI = 3.141592653589793;\nconst float SCAN_LINES = 240.0;\n\nvec2 warpTube(vec2 uv, float k) {\n vec2 p = uv * 2.0 - 1.0;\n float x2 = p.x * p.x;\n float y2 = p.y * p.y;\n p.x *= 1.0 + k * 0.11 * y2;\n p.y *= 1.0 + k * 0.17 * x2;\n p /= 1.0 + k * 0.045;\n return p * 0.5 + 0.5;\n}\n\nvec3 phosphorMask(float x, float scale) {\n float sub = mod(floor(x / max(scale, 1.0)), 3.0);\n vec3 lit = vec3(\n step(sub, 0.5),\n step(0.5, sub) * step(sub, 1.5),\n step(1.5, sub)\n );\n return mix(vec3(0.34), vec3(1.0), lit);\n}\n\nvoid main() {\n vec2 uv = warpTube(v_uv, u_curvature);\n\n vec2 edge =\n smoothstep(vec2(0.0), vec2(0.005), uv) *\n smoothstep(vec2(0.0), vec2(0.005), 1.0 - uv);\n float inside = edge.x * edge.y;\n\n vec4 base = texture(u_scene, uv);\n\n vec3 spread = vec3(0.0);\n for (int i = -2; i <= 2; i++) {\n spread += texture(u_scene, uv + vec2(float(i) * 0.0018, 0.0)).rgb;\n }\n spread /= 5.0;\n vec3 bloom = max(spread - 0.5, vec3(0.0));\n\n vec3 color = base.rgb;\n color *= phosphorMask(gl_FragCoord.x, u_mask_scale);\n color += bloom * 0.75;\n\n float scan = mix(1.0, 0.5 + 0.5 * cos(uv.y * SCAN_LINES * PI * 2.0), 0.55);\n color *= mix(1.0, scan, clamp(u_scanlines, 0.0, 1.5));\n\n vec2 vc = uv * 2.0 - 1.0;\n float radius = length(vc * vec2(0.86, 1.0));\n color *= mix(1.0, smoothstep(1.6, 0.35, radius), clamp(u_vignette, 0.0, 1.5));\n\n color *= 1.0 + 0.012 * sin(u_frame * PI / 30.0);\n color *= inside;\n\n outColor = vec4(clamp(color, 0.0, 1.0), max(base.a, 1.0 - inside));\n}`;\n\nconst shader = makeFilterShader<CrtScreenProps>(\n FRAGMENT_SHADER,\n ({ gl, uniform, passedProps }) => {\n const {\n curvature = DEFAULTS.curvature,\n scanlines = DEFAULTS.scanlines,\n maskScale = DEFAULTS.maskScale,\n vignette = DEFAULTS.vignette,\n } = passedProps;\n gl.uniform1f(uniform(\"u_curvature\"), curvature);\n gl.uniform1f(uniform(\"u_scanlines\"), scanlines);\n gl.uniform1f(uniform(\"u_mask_scale\"), maskScale);\n gl.uniform1f(uniform(\"u_vignette\"), vignette);\n },\n);\n\nconst CrtScreenFallback: React.FC<CrtScreenProps & CanvasFilterProps> = ({\n children,\n scanlines = DEFAULTS.scanlines,\n vignette = DEFAULTS.vignette,\n}) => (\n <AbsoluteFill>\n <AbsoluteFill style={{ filter: \"saturate(1.1) contrast(1.06)\" }}>\n {children}\n </AbsoluteFill>\n <AbsoluteFill\n style={{\n background:\n \"repeating-linear-gradient(to bottom, rgba(0, 0, 0, 0.34) 0px, rgba(0, 0, 0, 0.34) 1.5px, transparent 1.5px, transparent 3px)\",\n opacity: Math.min(scanlines, 1),\n }}\n />\n <AbsoluteFill\n style={{\n background:\n \"radial-gradient(ellipse 82% 78% at 50% 50%, transparent 45%, rgba(0, 0, 0, 0.72) 100%)\",\n opacity: Math.min(vignette, 1),\n }}\n />\n </AbsoluteFill>\n);\n\nconst CrtScreenBase = makeCanvasFilter<CrtScreenProps>({\n shader,\n fallback: CrtScreenFallback,\n});\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n curvature: {\n type: \"number\",\n min: 0,\n max: 2,\n step: 0.05,\n default: 1,\n description: \"Curvature\",\n hiddenFromList: false,\n },\n scanlines: {\n type: \"number\",\n min: 0,\n max: 1.5,\n step: 0.05,\n default: 1,\n description: \"Scanlines\",\n hiddenFromList: false,\n },\n maskScale: {\n type: \"number\",\n min: 1,\n max: 6,\n step: 1,\n default: 2,\n description: \"Mask pitch\",\n hiddenFromList: false,\n },\n vignette: {\n type: \"number\",\n min: 0,\n max: 1.5,\n step: 0.05,\n default: 1,\n description: \"Vignette\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"curvature\",\"scanlines\",\"maskScale\",\"vignette\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n curvature: 1,\n scanlines: 1,\n maskScale: 2,\n vignette: 1,\n speed: 1,\n};\n\ntype CrtScreenElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof CrtScreenBase>;\n\nconst CrtScreenInner = forwardRef<\n HTMLDivElement,\n CrtScreenElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<CrtScreen>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <CrtScreenBase\n {...(componentProps as unknown as ComponentProps<typeof CrtScreenBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const CrtScreen = Interactive.withSchema({\n Component: CrtScreenInner,\n componentName: \"<CrtScreen>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/cursor-gravity.json b/registry-artifacts/elements/cursor-gravity.jsonindex 02b11500..62a5cb1e 100644--- a/registry-artifacts/elements/cursor-gravity.json+++ b/registry-artifacts/elements/cursor-gravity.json@@ -2,10 +2,12 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [],"dimensions": null,"displayName": "Cursor Gravity","durationInFrames": 151,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "cursor-gravity","sourceCode": "import { forwardRef, useImperativeHandle, useRef, type ComponentProps, type ReactNode } from \"react\";\nimport { Easing, Interactive, Sequence, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\n\ninterface CursorGravityProps {\n /** Custom content in a 300 × 88 reference-pixel slot. */\n children?: ReactNode;\n label?: string;\n /** Strength of the elastic neck and recoil, 0–1.5. */\n tension?: number;\n cursorColor?: string;\n color?: string;\n textColor?: string;\n backgroundColor?: string;\n speed?: number;\n className?: string;\n}\n\nconst cursorGravityLength = 151;\nconst DURATION = 180;\nconst finite = (value: number, fallback: number) =>\n Number.isFinite(value) ? value : fallback;\nconst clamp = (value: number) => Math.max(0, Math.min(1, value));\nconst mix = (a: number, b: number, p: number) => a + (b - a) * p;\nconst progress = (frame: number, start: number, end: number) =>\n clamp((frame - start) / (end - start));\nconst ease = Easing.bezier(0.65, 0, 0.35, 1);\nconst pullEase = Easing.bezier(0.12, 0.8, 0.22, 1);\n\n/** Complete transition plus a one-second hold, in frames at 30 fps. */\nfunction getCursorGravityDuration({\n speed = 1,\n}: Pick<CursorGravityProps, \"speed\"> = {}) {\n const rate = Math.max(0, finite(speed, 1));\n return rate === 0 ? 1 : Math.max(1, Math.ceil(DURATION / rate));\n}\n\n/** A pull advances sharply, pauses under load, then recoils before the next tug. */\nfunction pullDistance(t: number, strength: number) {\n const keys = [\n [48, 0],\n [59, 116],\n [64, 116],\n [70, 116 - 30 * strength],\n [83, 292],\n [87, 292],\n [94, 292 - 42 * strength],\n [112, 772],\n ];\n if (t <= keys[0][0]) return 0;\n for (let i = 1; i < keys.length; i++) {\n const [start, a] = keys[i - 1];\n const [end, b] = keys[i];\n if (t <= end)\n return mix(a, b, (b > a ? pullEase : ease)(progress(t, start, end)));\n }\n return 772;\n}\n\n/** Pure, resolution-aware pose. The right edge is the real composition boundary. */\nfunction getCursorGravityState(\n frame: number,\n {\n width = 1280,\n height = 720,\n tension = 1,\n }: { width?: number; height?: number; tension?: number } = {},\n) {\n const w = Math.max(1, finite(width, 1280));\n const h = Math.max(1, finite(height, 720));\n const unit = Math.min(w / 1280, h / 720);\n const t = Math.max(0, finite(frame, 0));\n const strength = Math.max(0, Math.min(1.5, finite(tension, 1)));\n const centerY = h * 0.5;\n const finalLeft = w / 2 - 150 * unit;\n const finalRight = w / 2 + 150 * unit;\n const edgeTip = w - 24 * unit;\n const distance = pullDistance(t, strength) / 772;\n const extraction = distance * (edgeTip - (finalLeft - 14 * unit));\n // The back of the button resists the first two tugs beyond the frame edge.\n const releaseTime = progress(t, 94, 132);\n // Closed-form damped spring stays continuous at fractional frames too.\n const springRelease =\n 1 -\n Math.exp(-7 * releaseTime) *\n (Math.cos(10 * releaseTime) + 0.7 * Math.sin(10 * releaseTime));\n const release = mix(springRelease, 1, ease(progress(t, 122, 132)));\n const front = mix(w + 12 * unit, finalLeft, distance);\n const right = mix(w + 312 * unit - distance * 70 * unit, finalRight, release);\n const buttonWidth = Math.max(220 * unit, right - front);\n const strain = clamp((buttonWidth / (300 * unit) - 1) / 1.3) * strength;\n const wobble =\n t < 112\n ? 0\n : Math.sin((t - 112) * 0.48) *\n Math.exp(-(t - 112) * 0.14) *\n 5 *\n unit *\n strength *\n (1 - progress(t, 132, 140));\n const y = centerY + wobble;\n const entry = ease(progress(t, 10, 39));\n const approach = ease(progress(t, 39, 48));\n const leave = ease(progress(t, 127, 151));\n const holdTip = mix(w * 0.28, edgeTip - 80 * unit, entry);\n const pullTip = edgeTip - extraction;\n const cursorX =\n t < 48 ? mix(holdTip, edgeTip, approach) : mix(pullTip, w * 0.25, leave);\n const cursorY =\n t < 39\n ? mix(h + 110 * unit, centerY + 70 * unit, entry)\n : t < 48\n ? mix(centerY + 70 * unit, centerY, approach)\n : mix(centerY, h + 110 * unit, leave);\n // Triangle points toward the edge while pulling; turns toward its exit afterward.\n const cursorAngle = t < 48 ? mix(-32, 0, approach) : mix(0, 115, leave);\n const effortPulse = (\n start: number,\n peak: number,\n hold: number,\n end: number,\n ) => ease(progress(t, start, peak)) * (1 - ease(progress(t, hold, end)));\n const cursorEffort =\n strength *\n (0.8 * effortPulse(48, 58, 64, 70) +\n effortPulse(70, 81, 87, 94) +\n 1.15 * effortPulse(94, 100, 104, 118));\n return {\n frame: t,\n unit,\n front,\n right: front + buttonWidth,\n buttonWidth,\n centerY: y,\n strain,\n neckHeight: 88 * unit * (1 - 0.58 * strain),\n bodyHeight: 88 * unit * (1 - 0.17 * strain),\n cursorX,\n cursorY,\n cursorAngle,\n cursorEffort,\n attached: t >= 48 && t <= 121,\n tetherOpacity: progress(t, 46, 49) * (1 - progress(t, 115, 122)),\n };\n}\n\n/** The tip stays fixed; the rear bows backward as each tug builds effort. */\nfunction getGravityCursorPath(effort: number) {\n const load = Math.max(0, Math.min(1.725, finite(effort, 0)));\n const shoulder = -62 - 30 * load;\n const rear = -70 - 40 * load;\n const halfHeight = 26 - 4 * load;\n return `M -5 -4 Q 3 0 -5 4\n C -24 ${11.333 - load * 3} ${shoulder + 19} ${halfHeight - 7.333} ${shoulder} ${halfHeight}\n Q ${rear} ${halfHeight + 4} ${rear} ${halfHeight - 6}\n C ${rear} 4 ${rear - 18 * load} 8 ${rear - 18 * load} 0\n C ${rear - 18 * load} -8 ${rear} -4 ${rear} ${-halfHeight + 6}\n Q ${rear} ${-halfHeight - 4} ${shoulder} ${-halfHeight}\n C ${shoulder + 19} ${-halfHeight + 7.333} -24 ${-11.333 + load * 3} -5 -4 Z`;\n}\n\n/** Rounded rectangle with a narrow leading edge: the pull deforms the surface. */\nfunction getGravityButtonPath(\n state: ReturnType<typeof getCursorGravityState>,\n) {\n const { buttonWidth: w, neckHeight, bodyHeight, unit } = state;\n const a = neckHeight / 2;\n const b = bodyHeight / 2;\n const r = Math.min(25 * unit, a * 0.9);\n const backRadius = 25 * unit;\n return `M ${r} ${-a}\n C ${w * 0.35} ${-a} ${w * 0.35} ${-b} ${w - backRadius} ${-b}\n Q ${w} ${-b} ${w} ${-b + backRadius}\n L ${w} ${b - backRadius} Q ${w} ${b} ${w - backRadius} ${b}\n C ${w * 0.35} ${b} ${w * 0.35} ${a} ${r} ${a}\n Q 0 ${a} 0 ${a - r} L 0 ${-a + r} Q 0 ${-a} ${r} ${-a} Z`;\n}\n\nfunction CursorGravityBase({\n children,\n label = \"Create something\",\n tension = 1,\n cursorColor = \"#fffaf0\",\n color = \"#fffaf0\",\n textColor = \"#32153c\",\n backgroundColor = \"#a800b7\",\n speed = 1,\n className,\n}: CursorGravityProps) {\n const frame = useCurrentFrame();\n const { width, height, fps } = useVideoConfig();\n const t = frame * (30 / fps) * Math.max(0, finite(speed, 1));\n const state = getCursorGravityState(t, { width, height, tension });\n const { unit } = state;\n // Content travels with the material, without stretching the lettering.\n const contentUnit = unit * Math.min(1, state.buttonWidth / (300 * unit));\n const contentX = state.front + state.buttonWidth - 150 * contentUnit;\n return (\n <div\n className={className}\n style={{\n position: \"absolute\",\n inset: 0,\n overflow: \"hidden\",\n backgroundColor,\n fontFamily: \"Arial, sans-serif\",\n }}\n >\n <svg\n width={width}\n height={height}\n viewBox={`0 0 ${width} ${height}`}\n aria-hidden=\"true\"\n style={{ position: \"absolute\", inset: 0 }}\n >\n <path\n d={getGravityButtonPath(state)}\n transform={`translate(${state.front} ${state.centerY})`}\n fill={color}\n />\n <path\n d={`M ${state.cursorX + 2 * unit} ${state.cursorY} Q ${mix(state.cursorX, state.front, 0.5)} ${state.centerY} ${state.front + 2 * unit} ${state.centerY}`}\n fill=\"none\"\n stroke={cursorColor}\n strokeWidth={2 * unit}\n strokeLinecap=\"round\"\n opacity={state.tetherOpacity}\n />\n </svg>\n <div\n style={{\n position: \"absolute\",\n left: 0,\n top: 0,\n width: 300,\n height: 88,\n translate: `${contentX - 150 * contentUnit}px ${state.centerY - 44 * contentUnit}px`,\n scale: contentUnit,\n transformOrigin: \"top left\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n gap: 20,\n color: textColor,\n fontWeight: 600,\n fontSize: 23,\n }}\n >\n {children ?? (\n <>\n <span\n style={{\n maxWidth: 220,\n overflow: \"hidden\",\n whiteSpace: \"nowrap\",\n textOverflow: \"ellipsis\",\n }}\n >\n {label}\n </span>\n <svg width=\"22\" height=\"22\" viewBox=\"0 0 24 24\" aria-hidden=\"true\">\n <path\n d=\"M5 12H19M13 6L19 12L13 18\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n </svg>\n </>\n )}\n </div>\n <svg\n width={190 * unit}\n height={70 * unit}\n viewBox=\"-180 -35 190 70\"\n role=\"img\"\n aria-label=\"Rounded triangular cursor\"\n style={{\n position: \"absolute\",\n left: 0,\n top: 0,\n translate: `${state.cursorX - 180 * unit}px ${state.cursorY - 35 * unit}px`,\n transform: `rotate(${state.cursorAngle}deg)`,\n transformOrigin: `${180 * unit}px ${35 * unit}px`,\n }}\n >\n <path d={getGravityCursorPath(state.cursorEffort)} fill={cursorColor} />\n </svg>\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n label: {\n type: \"text-content\",\n default: \"Create something\",\n description: \"Button label\",\n },\n tension: {\n type: \"number\",\n default: 1,\n min: 0,\n max: 1.5,\n step: 0.1,\n description: \"Pull tension\",\n hiddenFromList: false,\n },\n cursorColor: {\n type: \"color\",\n default: \"#fffaf0\",\n description: \"Cursor\",\n },\n color: {\n type: \"color\",\n default: \"#fffaf0\",\n description: \"Button\",\n },\n textColor: {\n type: \"color\",\n default: \"#32153c\",\n description: \"Button text\",\n },\n backgroundColor: {\n type: \"color\",\n default: \"#a800b7\",\n description: \"Background\",\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"label\",\"tension\",\"cursorColor\",\"color\",\"textColor\",\"backgroundColor\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n label: \"Create something\",\n tension: 1,\n cursorColor: \"#fffaf0\",\n color: \"#fffaf0\",\n textColor: \"#32153c\",\n backgroundColor: \"#a800b7\",\n speed: 1,\n};\n\ntype CursorGravityElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof CursorGravityBase>;\n\nconst CursorGravityInner = forwardRef<\n HTMLDivElement,\n CursorGravityElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<CursorGravity>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <CursorGravityBase\n {...(componentProps as unknown as ComponentProps<typeof CursorGravityBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const CursorGravity = Interactive.withSchema({\n Component: CursorGravityInner,\n componentName: \"<CursorGravity>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/drift.json b/registry-artifacts/elements/drift.jsonindex 04ae0b03..6000ed35 100644--- a/registry-artifacts/elements/drift.json+++ b/registry-artifacts/elements/drift.json@@ -2,10 +2,12 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [],"dimensions": null,"displayName": "Drift","durationInFrames": 90,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "drift","sourceCode": "import { AbsoluteFill, Interactive, Sequence, interpolate, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport React, { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface DriftProps {\n children: React.ReactNode;\n grow?: number;\n}\n\nfunction DriftBase({ children, grow = 0.035 }: DriftProps) {\n const frame = useCurrentFrame();\n const { durationInFrames } = useVideoConfig();\n const scale = interpolate(frame, [0, durationInFrames], [1, 1 + grow]);\n return <AbsoluteFill style={{ scale: `${scale}` }}>{children}</AbsoluteFill>;\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n grow: {\n type: \"number\",\n min: -0.1,\n max: 0.15,\n step: 0.005,\n default: 0.035,\n description: \"Grow\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"grow\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n grow: 0.035,\n speed: 1,\n};\n\ntype DriftElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof DriftBase>;\n\nconst DriftInner = forwardRef<\n HTMLDivElement,\n DriftElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<Drift>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <DriftBase\n {...(componentProps as unknown as ComponentProps<typeof DriftBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const Drift = Interactive.withSchema({\n Component: DriftInner,\n componentName: \"<Drift>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/echo-stack.json b/registry-artifacts/elements/echo-stack.jsonindex 43e2f992..8fb5f813 100644--- a/registry-artifacts/elements/echo-stack.json+++ b/registry-artifacts/elements/echo-stack.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/google-fonts",@@ -11,6 +12,7 @@"dimensions": null,"displayName": "Echo Stack","durationInFrames": 26,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "echo-stack","sourceCode": "import { loadFont } from \"@remotion/google-fonts/Inter\";\nimport { forwardRef, useId, useImperativeHandle, useRef, type ComponentProps } from \"react\";\nimport { Easing, Interactive, Sequence, interpolate, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\n\nconst { fontFamily: INTER } = loadFont(\"normal\", {\n weights: [\"100\", \"900\"],\n subsets: [\"latin\"],\n});\n\ntype EchoStackDirection = \"up\" | \"down\";\n\ninterface EchoStackProps {\n text?: string;\n fontSize?: number;\n fontWeight?: number;\n fontFamily?: string;\n color?: string;\n echoColor?: string;\n echoes?: number;\n echoOpacity?: number;\n strokeWidth?: number;\n direction?: EchoStackDirection;\n cycle?: number;\n speed?: number;\n className?: string;\n}\n\nconst echoStackDefaults = {\n text: \"Bold.\",\n fontSize: 170,\n fontWeight: 800,\n fontFamily: INTER,\n color: \"#fafafa\",\n echoColor: \"\",\n echoes: 3,\n echoOpacity: 0.35,\n strokeWidth: 1.5,\n direction: \"up\",\n cycle: 60,\n speed: 1,\n} satisfies Required<Omit<EchoStackProps, \"className\">>;\n\n/** Frame where the entrance has finished; the drift keeps running after it. */\nconst echoStackLength = 26;\n\n/** Distance between echo rows, in em. */\nconst echoStackPitch = 1.05;\n\n/** Echoes closer to the center than this, in pitches, hide behind the word. */\nconst HIDDEN = 0.55;\nconst MAIN = [0, 14] as const;\nconst UNFOLD = [8, 26] as const;\nconst FADE_IN = [8, 24] as const;\nconst START_SPREAD = 0.6;\nconst MAX_BLUR = 12;\n\nconst CLAMP = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n} as const;\n\nconst easeOutCubic = Easing.out(Easing.cubic);\n\nfunction finite(value: number | undefined, fallback: number) {\n return typeof value === \"number\" && Number.isFinite(value) ? value : fallback;\n}\n\nfunction smoothstep(x: number) {\n const c = Math.min(1, Math.max(0, x));\n return c * c * (3 - 2 * c);\n}\n\n/** Maps a composition frame onto the 30 fps timeline, scaled by `speed`. */\nfunction getEchoStackTime(\n frame: number,\n options: { fps?: number; speed?: number } = {},\n) {\n const fps = Math.max(1, finite(options.fps, 30));\n const speed = Math.max(0, finite(options.speed, 1));\n return (Math.max(0, finite(frame, 0)) * 30 * speed) / fps;\n}\n\n/** The main word focusing in. Blur is in reference px. */\nfunction getEchoStackMain(t: number) {\n const k = interpolate(t, [...MAIN], [0, 1], {\n ...CLAMP,\n easing: easeOutCubic,\n });\n return { blur: MAX_BLUR * (1 - k), opacity: k, scale: 1.04 - 0.04 * k };\n}\n\n/** Echo visibility at a distance from the center, in pitches, before `echoOpacity`. */\nfunction getEchoStackFade(distance: number, echoes: number) {\n const d = Math.abs(distance);\n if (d < HIDDEN) return 0;\n if (d < 1) return smoothstep((d - HIDDEN) / (1 - HIDDEN));\n const reach = Math.max(1, echoes + 0.5);\n return Math.max(0, 1 - (d - 1) / (reach - 1));\n}\n\ninterface EchoStackRow {\n /** Signed distance from the center in pitches, negative above. */\n offset: number;\n /** Row position in pitches after the unfold, negative above. */\n position: number;\n opacity: number;\n}\n\nfunction getEchoStackRows(\n t: number,\n options: {\n echoes?: number;\n echoOpacity?: number;\n cycle?: number;\n direction?: EchoStackDirection;\n } = {},\n): EchoStackRow[] {\n const echoes = Math.max(0, Math.round(finite(options.echoes, 3)));\n const echoOpacity = Math.max(0, finite(options.echoOpacity, 0.35));\n const cycle = Math.max(1, finite(options.cycle, 60));\n const sign = options.direction === \"down\" ? 1 : -1;\n const phase = sign * ((t / cycle) % 1);\n const spread = interpolate(t, [...UNFOLD], [START_SPREAD, 1], {\n ...CLAMP,\n easing: easeOutCubic,\n });\n const fadeIn = interpolate(t, [...FADE_IN], [0, 1], {\n ...CLAMP,\n easing: easeOutCubic,\n });\n const rows: EchoStackRow[] = [];\n const reach = echoes + 2;\n for (let k = -reach; k <= reach; k++) {\n const offset = k + phase;\n const opacity = echoOpacity * fadeIn * getEchoStackFade(offset, echoes);\n if (opacity <= 0) continue;\n rows.push({ offset, position: offset * spread, opacity });\n }\n return rows;\n}\n\nfunction EchoStackBase({\n text = echoStackDefaults.text,\n fontSize = echoStackDefaults.fontSize,\n fontWeight = echoStackDefaults.fontWeight,\n fontFamily = echoStackDefaults.fontFamily,\n color = echoStackDefaults.color,\n echoColor = echoStackDefaults.echoColor,\n echoes = echoStackDefaults.echoes,\n echoOpacity = echoStackDefaults.echoOpacity,\n strokeWidth = echoStackDefaults.strokeWidth,\n direction = echoStackDefaults.direction,\n cycle = echoStackDefaults.cycle,\n speed = echoStackDefaults.speed,\n className,\n}: EchoStackProps) {\n const frame = useCurrentFrame();\n const { fps, height } = useVideoConfig();\n const unit = height / 720;\n const size = fontSize * unit;\n const t = getEchoStackTime(frame, { fps, speed });\n const main = getEchoStackMain(t);\n const rows = getEchoStackRows(t, { echoes, echoOpacity, cycle, direction });\n const pitch = echoStackPitch * size;\n const outlineId = `echo-stack-${useId().replace(/[^a-zA-Z0-9_-]/g, \"\")}`;\n\n const type = {\n fontFamily,\n fontSize: size,\n lineHeight: 1,\n fontWeight,\n fontVariationSettings: `\"wght\" ${fontWeight}`,\n whiteSpace: \"pre\",\n } as const;\n\n return (\n <div\n className={className}\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n overflow: \"hidden\",\n }}\n >\n {/* Outline from the filled silhouette: the variable font's overlapping\n contours would show through a text stroke. */}\n <svg width={0} height={0} style={{ position: \"absolute\" }} aria-hidden>\n <defs>\n <filter id={outlineId}>\n <feMorphology\n in=\"SourceAlpha\"\n operator=\"erode\"\n radius={strokeWidth * unit}\n result=\"inner\"\n />\n <feComposite\n in=\"SourceAlpha\"\n in2=\"inner\"\n operator=\"out\"\n result=\"ring\"\n />\n <feFlood floodColor={echoColor || color} />\n <feComposite in2=\"ring\" operator=\"in\" />\n </filter>\n </defs>\n </svg>\n <div style={{ position: \"relative\" }}>\n {rows.map((row, i) => (\n <div\n key={i}\n aria-hidden\n style={{\n ...type,\n position: \"absolute\",\n left: \"50%\",\n top: \"50%\",\n color: echoColor || color,\n filter: `url(#${outlineId})`,\n opacity: row.opacity,\n transform: `translate(-50%, calc(-50% + ${row.position * pitch}px))`,\n }}\n >\n {text}\n </div>\n ))}\n <div\n style={{\n ...type,\n position: \"relative\",\n color,\n opacity: main.opacity,\n filter:\n main.blur > 0.05 ? `blur(${main.blur * unit}px)` : undefined,\n transform: `scale(${main.scale})`,\n }}\n >\n {text}\n </div>\n </div>\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n text: {\n type: \"text-content\",\n default: \"Bold.\",\n description: \"Text\",\n },\n color: {\n type: \"color\",\n default: \"#fafafa\",\n description: \"Text color\",\n },\n echoColor: {\n type: \"color\",\n default: \"#fafafa\",\n description: \"Echo color\",\n },\n direction: {\n type: \"enum\",\n default: \"up\",\n variants: {\n up: {},\n down: {},\n },\n description: \"Direction\",\n },\n fontSize: {\n type: \"number\",\n default: 170,\n min: 60,\n max: 300,\n step: 2,\n description: \"Font size\",\n hiddenFromList: false,\n },\n echoes: {\n type: \"number\",\n default: 3,\n min: 1,\n max: 6,\n step: 1,\n description: \"Echoes per side\",\n hiddenFromList: false,\n },\n echoOpacity: {\n type: \"number\",\n default: 0.35,\n min: 0.05,\n max: 1,\n step: 0.05,\n description: \"Echo opacity\",\n hiddenFromList: false,\n },\n cycle: {\n type: \"number\",\n default: 60,\n min: 15,\n max: 240,\n step: 5,\n description: \"Frames per row\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"text\",\"color\",\"echoColor\",\"direction\",\"fontSize\",\"echoes\",\"echoOpacity\",\"cycle\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n text: \"Bold.\",\n color: \"#fafafa\",\n echoColor: \"#fafafa\",\n direction: \"up\",\n fontSize: 170,\n echoes: 3,\n echoOpacity: 0.35,\n cycle: 60,\n speed: 1,\n};\n\ntype EchoStackElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof EchoStackBase>;\n\nconst EchoStackInner = forwardRef<\n HTMLDivElement,\n EchoStackElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<EchoStack>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <EchoStackBase\n {...(componentProps as unknown as ComponentProps<typeof EchoStackBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const EchoStack = Interactive.withSchema({\n Component: EchoStackInner,\n componentName: \"<EchoStack>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/ecosystem-constellation.json b/registry-artifacts/elements/ecosystem-constellation.jsonindex af404af2..cd992ac8 100644--- a/registry-artifacts/elements/ecosystem-constellation.json+++ b/registry-artifacts/elements/ecosystem-constellation.json@@ -2,10 +2,12 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [],"dimensions": null,"displayName": "Ecosystem Constellation","durationInFrames": 240,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "ecosystem-constellation","sourceCode": "import { forwardRef, useImperativeHandle, useRef, type ComponentProps, type ComponentType } from \"react\";\nimport { Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\n\ninterface EcosystemConstellationProps {\n satelliteCount?: number;\n centerLabel?: string;\n accentColor?: string;\n speed?: number;\n className?: string;\n}\n\nconst FONT_FAMILY =\n \"var(--font-geist-sans), -apple-system, BlinkMacSystemFont, sans-serif\";\n\n// Inline brand mark components — stylized for demo identification, drawn from\n// primitive SVG shapes only so the component stays self-contained.\n\nfunction GitHubMark() {\n return (\n <svg viewBox=\"0 0 24 24\" width={30} height={30} aria-hidden=\"true\">\n <path\n fill=\"#fff\"\n d=\"M12 .5C5.65.5.5 5.65.5 12c0 5.08 3.29 9.39 7.86 10.91.58.11.79-.25.79-.55v-2.06c-3.2.7-3.87-1.36-3.87-1.36-.52-1.33-1.27-1.69-1.27-1.69-1.04-.71.08-.7.08-.7 1.15.08 1.76 1.18 1.76 1.18 1.02 1.75 2.69 1.24 3.35.95.1-.74.4-1.24.72-1.53-2.55-.29-5.24-1.28-5.24-5.7 0-1.26.45-2.29 1.18-3.1-.12-.29-.51-1.46.11-3.05 0 0 .97-.31 3.18 1.18.92-.26 1.91-.39 2.89-.39s1.97.13 2.89.39c2.21-1.49 3.18-1.18 3.18-1.18.62 1.59.23 2.76.11 3.05.74.81 1.18 1.84 1.18 3.1 0 4.43-2.7 5.41-5.27 5.69.41.36.77 1.06.77 2.13v3.16c0 .31.21.67.8.55C20.21 21.39 23.5 17.08 23.5 12 23.5 5.65 18.35.5 12 .5z\"\n />\n </svg>\n );\n}\n\nfunction VercelMark() {\n return (\n <svg viewBox=\"0 0 24 24\" width={28} height={28} aria-hidden=\"true\">\n <path fill=\"#fff\" d=\"M12 2 L23 21 L1 21 Z\" />\n </svg>\n );\n}\n\nfunction StripeMark() {\n return (\n <svg viewBox=\"0 0 24 24\" width={28} height={28} aria-hidden=\"true\">\n <path\n fill=\"#fff\"\n d=\"M13.5 9.6c0-.6.5-.85 1.3-.85 1.15 0 2.6.35 3.75.97V6.16c-1.25-.5-2.5-.7-3.75-.7C11.7 5.46 9.6 7.06 9.6 9.7c0 4.13 5.7 3.47 5.7 5.25 0 .7-.6.93-1.45.93-1.25 0-2.85-.52-4.1-1.2v3.65c1.4.6 2.8.85 4.1.85 3.2 0 5.4-1.55 5.4-4.25-.02-4.45-5.75-3.65-5.75-5.33z\"\n />\n </svg>\n );\n}\n\nfunction SlackMark() {\n return (\n <svg viewBox=\"0 0 24 24\" width={26} height={26} aria-hidden=\"true\">\n <rect x=\"2\" y=\"10\" width=\"9\" height=\"2.5\" rx=\"1.25\" fill=\"#36C5F0\" />\n <rect x=\"13\" y=\"10\" width=\"9\" height=\"2.5\" rx=\"1.25\" fill=\"#2EB67D\" />\n <rect x=\"10\" y=\"2\" width=\"2.5\" height=\"9\" rx=\"1.25\" fill=\"#ECB22E\" />\n <rect x=\"10\" y=\"13\" width=\"2.5\" height=\"9\" rx=\"1.25\" fill=\"#E01E5A\" />\n </svg>\n );\n}\n\nfunction LinearMark() {\n return (\n <svg viewBox=\"0 0 24 24\" width={28} height={28} aria-hidden=\"true\">\n <defs>\n <linearGradient id=\"linear-grad\" x1=\"0\" x2=\"1\" y1=\"0\" y2=\"1\">\n <stop offset=\"0%\" stopColor=\"#fff\" stopOpacity=\"0.95\" />\n <stop offset=\"100%\" stopColor=\"#fff\" stopOpacity=\"0.55\" />\n </linearGradient>\n </defs>\n <circle cx=\"12\" cy=\"12\" r=\"10\" fill=\"url(#linear-grad)\" />\n <path\n d=\"M5 13 L11 19 M5 9 L15 19 M5 5 L19 19 M9 5 L19 15 M13 5 L19 11\"\n stroke=\"#0a0a0a\"\n strokeWidth=\"0.9\"\n strokeLinecap=\"round\"\n opacity=\"0.85\"\n />\n </svg>\n );\n}\n\nfunction FigmaMark() {\n return (\n <svg viewBox=\"0 0 24 24\" width={26} height={26} aria-hidden=\"true\">\n <circle cx=\"9\" cy=\"4\" r=\"3.5\" fill=\"#F24E1E\" />\n <circle cx=\"15\" cy=\"4\" r=\"3.5\" fill=\"#FF7262\" />\n <circle cx=\"9\" cy=\"11\" r=\"3.5\" fill=\"#A259FF\" />\n <circle cx=\"15\" cy=\"11\" r=\"3.5\" fill=\"#1ABCFE\" />\n <circle cx=\"9\" cy=\"18\" r=\"3.5\" fill=\"#0ACF83\" />\n </svg>\n );\n}\n\nfunction NotionMark() {\n return (\n <svg viewBox=\"0 0 24 24\" width={26} height={26} aria-hidden=\"true\">\n <rect x=\"3\" y=\"3\" width=\"18\" height=\"18\" rx=\"3\" fill=\"#fff\" />\n <path\n d=\"M8 7 V17 M8 7 L16 17 M16 7 V17\"\n stroke=\"#0a0a0a\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n fill=\"none\"\n />\n </svg>\n );\n}\n\nfunction DiscordMark() {\n return (\n <svg viewBox=\"0 0 24 24\" width={28} height={28} aria-hidden=\"true\">\n <path\n fill=\"#fff\"\n d=\"M19.5 4.7A18 18 0 0 0 15 3.3l-.2.4a16.5 16.5 0 0 0-5.6 0L9 3.3a18 18 0 0 0-4.5 1.4C2 8.7 1.4 12.5 1.7 16.3a18 18 0 0 0 5.5 2.8l.4-.6a13 13 0 0 1-2-1l.5-.4a13 13 0 0 0 11.7 0l.5.4a13 13 0 0 1-2 1l.4.6a18 18 0 0 0 5.5-2.8c.4-4.4-.6-8.2-2.7-11.6zM8.5 14c-.9 0-1.7-.9-1.7-2s.8-2 1.7-2 1.7.9 1.7 2-.8 2-1.7 2zm7 0c-.9 0-1.7-.9-1.7-2s.8-2 1.7-2 1.7.9 1.7 2-.8 2-1.7 2z\"\n />\n </svg>\n );\n}\n\ninterface SatelliteBrand {\n Logo: ComponentType;\n bg: string;\n}\n\nconst SATELLITE_BRANDS: SatelliteBrand[] = [\n { Logo: GitHubMark, bg: \"#1f1f23\" },\n { Logo: VercelMark, bg: \"#0a0a0a\" },\n { Logo: StripeMark, bg: \"#635bff\" },\n { Logo: SlackMark, bg: \"#1a1d21\" },\n { Logo: LinearMark, bg: \"#5e6ad2\" },\n { Logo: FigmaMark, bg: \"#1e1e1e\" },\n { Logo: NotionMark, bg: \"#1a1a1a\" },\n { Logo: DiscordMark, bg: \"#5865f2\" },\n];\n\nfunction EcosystemConstellationBase({\n satelliteCount = 6,\n centerLabel = \"V\",\n accentColor = \"#a855f7\",\n speed = 1,\n className,\n}: EcosystemConstellationProps) {\n const frame = useCurrentFrame() * speed;\n const { fps } = useVideoConfig();\n\n const count = Math.max(\n 3,\n Math.min(SATELLITE_BRANDS.length, Math.floor(satelliteCount)),\n );\n\n // Center pulse (0..1)\n const pulse = (Math.sin(frame / 12) + 1) / 2;\n const centerScale = 1 + pulse * 0.06;\n\n // Geometry\n const cx = 640;\n const cy = 360;\n const baseRadiusX = 230;\n const baseRadiusY = 180;\n const offscreenRadius = 1200; // 150% of width\n\n // Per-satellite assembly spring (staggered)\n const satellites = Array.from({ length: count }).map((_, i) => {\n const stagger = i * 4;\n const sp = spring({\n frame: frame - stagger,\n fps,\n config: { mass: 1.1, damping: 16, stiffness: 70 },\n durationInFrames: 50,\n });\n const radiusFactor = interpolate(sp, [0, 1], [offscreenRadius, 1]);\n\n // Slight elliptical variation per satellite\n const orbitOffset = i * 22;\n const rX = baseRadiusX + orbitOffset;\n const rY = baseRadiusY + orbitOffset * 0.7;\n // Different angular speed per orbit (slower for outer)\n const angularSpeed = 0.012 - i * 0.0008;\n const baseAngle = (i / count) * Math.PI * 2;\n const angle = baseAngle + frame * angularSpeed;\n\n // Use radiusFactor as a multiplier on the orbit radius\n const x = cx + Math.cos(angle) * rX * radiusFactor;\n const y = cy + Math.sin(angle) * rY * radiusFactor;\n\n // Data pulse: which satellite is currently \"firing\"\n const activeIdx = Math.floor(frame / 30) % count;\n const isActive = activeIdx === i;\n // Within the active 30-frame window, fade the line in/out\n const localFrame = frame - Math.floor(frame / 30) * 30;\n const lineOpacity = isActive\n ? interpolate(localFrame, [0, 8, 22, 30], [0.15, 0.9, 0.9, 0.15], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n })\n : 0.15;\n const satScale = isActive\n ? interpolate(localFrame, [0, 8, 22, 30], [1, 1.1, 1.1, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n })\n : 1;\n\n const brand = SATELLITE_BRANDS[i % SATELLITE_BRANDS.length];\n return {\n x,\n y,\n Logo: brand.Logo,\n color: brand.bg,\n lineOpacity,\n satScale,\n visible: sp > 0.02,\n };\n });\n\n return (\n <div\n className={className}\n style={{\n position: \"absolute\",\n inset: 0,\n overflow: \"hidden\",\n background: \"transparent\",\n fontFamily: FONT_FAMILY,\n }}\n >\n <svg\n width=\"100%\"\n height=\"100%\"\n viewBox=\"0 0 1280 720\"\n style={{ position: \"absolute\", inset: 0 }}\n >\n {/* Connection lines */}\n {satellites.map((s, i) => (\n <line\n key={`line-${i}`}\n x1={cx}\n y1={cy}\n x2={s.x}\n y2={s.y}\n stroke={accentColor}\n strokeWidth={2}\n strokeLinecap=\"round\"\n opacity={s.visible ? s.lineOpacity : 0}\n />\n ))}\n\n {/* Center glow */}\n <circle\n cx={cx}\n cy={cy}\n r={70 + pulse * 8}\n fill={accentColor}\n opacity={0.12}\n />\n <circle\n cx={cx}\n cy={cy}\n r={50 + pulse * 4}\n fill={accentColor}\n opacity={0.2}\n />\n </svg>\n\n {/* Center logo */}\n <div\n style={{\n position: \"absolute\",\n left: cx,\n top: cy,\n width: 96,\n height: 96,\n marginLeft: -48,\n marginTop: -48,\n borderRadius: 24,\n background: `linear-gradient(180deg, ${accentColor} 0%, ${accentColor}cc 100%)`,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n color: \"white\",\n fontWeight: 800,\n fontSize: 52,\n letterSpacing: \"-0.05em\",\n scale: `${centerScale}`,\n boxShadow: `0 0 60px ${accentColor}66, inset 0 1px 0 rgba(255,255,255,0.3)`,\n border: \"1px solid rgba(255,255,255,0.15)\",\n }}\n >\n {centerLabel}\n </div>\n\n {/* Satellites */}\n {satellites.map((s, i) => {\n const Logo = s.Logo;\n return (\n <div\n key={`sat-${i}`}\n style={{\n position: \"absolute\",\n left: s.x,\n top: s.y,\n width: 56,\n height: 56,\n marginLeft: -28,\n marginTop: -28,\n borderRadius: 14,\n background: `linear-gradient(180deg, ${s.color} 0%, ${s.color}dd 100%)`,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n scale: `${s.satScale}`,\n boxShadow: `0 8px 30px ${s.color}66, inset 0 1px 0 rgba(255,255,255,0.18)`,\n border: \"1px solid rgba(255,255,255,0.12)\",\n opacity: s.visible ? 1 : 0,\n willChange: \"transform\",\n }}\n >\n <Logo />\n </div>\n );\n })}\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n satelliteCount: {\n type: \"number\",\n min: 3,\n max: 8,\n step: 1,\n default: 6,\n description: \"Satellite count\",\n hiddenFromList: false,\n },\n centerLabel: {\n type: \"text-content\",\n default: \"V\",\n description: \"Center label\",\n },\n accentColor: {\n type: \"color\",\n default: \"#a855f7\",\n description: \"Accent color\",\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"satelliteCount\",\"centerLabel\",\"accentColor\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n satelliteCount: 6,\n centerLabel: \"V\",\n accentColor: \"#a855f7\",\n speed: 1,\n};\n\ntype EcosystemConstellationElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof EcosystemConstellationBase>;\n\nconst EcosystemConstellationInner = forwardRef<\n HTMLDivElement,\n EcosystemConstellationElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<EcosystemConstellation>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <EcosystemConstellationBase\n {...(componentProps as unknown as ComponentProps<typeof EcosystemConstellationBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const EcosystemConstellation = Interactive.withSchema({\n Component: EcosystemConstellationInner,\n componentName: \"<EcosystemConstellation>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/extrude-pop.json b/registry-artifacts/elements/extrude-pop.jsonindex 976624b8..41e83e81 100644--- a/registry-artifacts/elements/extrude-pop.json+++ b/registry-artifacts/elements/extrude-pop.json@@ -2,10 +2,12 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [],"dimensions": null,"displayName": "Extrude Pop","durationInFrames": 48,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "extrude-pop","sourceCode": "import { forwardRef, useImperativeHandle, useMemo, useRef, type ComponentProps } from \"react\";\nimport { Easing, Interactive, Sequence, interpolate, useCurrentFrame, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\n\ninterface ExtrudePopProps {\n className?: string;\n width?: number;\n height?: number;\n letter?: string;\n fontFamily?: string;\n fontWeight?: number | string;\n fontSize?: number;\n basePosition?: [number, number];\n maxTextWidth?: number;\n minimaxRadius?: number;\n extrudeAngleDeg?: number;\n extrudeSteps?: number;\n extrudeStartFrame?: number;\n extrudeEndFrame?: number;\n bodyColor?: string;\n faceColor?: string;\n}\n\nfunction ExtrudePopBase({\n className,\n width = 1920,\n height = 1080,\n letter = \"WIN\",\n fontFamily = \"'Helvetica Neue', Helvetica, Arial, sans-serif\",\n fontWeight = 700,\n fontSize = 603,\n basePosition = [959.2, 752.5],\n maxTextWidth = 1660,\n minimaxRadius = 80,\n extrudeAngleDeg = -58.6,\n extrudeSteps = 200,\n extrudeStartFrame = 0,\n extrudeEndFrame = 48,\n bodyColor = \"#e8192b\",\n faceColor = \"#ffffff\",\n}: ExtrudePopProps) {\n const frame = useCurrentFrame();\n\n const fit = useMemo(() => {\n if (typeof document === \"undefined\") return 1;\n const ctx = document.createElement(\"canvas\").getContext(\"2d\");\n if (!ctx) return 1;\n ctx.font = `${fontWeight} ${fontSize}px ${fontFamily}`;\n const measured = ctx.measureText(letter).width;\n if (measured <= 0) return 1;\n return Math.min(1, maxTextWidth / measured);\n }, [letter, fontFamily, fontWeight, fontSize, maxTextWidth]);\n\n const fitFontSize = fontSize * fit;\n const fitRadius = minimaxRadius * fit;\n\n const radius = interpolate(\n frame,\n [extrudeStartFrame, extrudeEndFrame],\n [0, fitRadius],\n {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.bezier(0.16, 1, 0.3, 1),\n },\n );\n\n const depth = radius * 2;\n\n const theta = (extrudeAngleDeg * Math.PI) / 180;\n const stepX = (depth * Math.sin(theta)) / extrudeSteps;\n const stepY = (depth * Math.cos(theta)) / extrudeSteps;\n\n const glyph = (fill: string, dx: number, dy: number, key?: string) => (\n <text\n key={key}\n x={basePosition[0] + dx}\n y={basePosition[1] + dy}\n textAnchor=\"middle\"\n fontFamily={fontFamily}\n fontWeight={fontWeight}\n fontSize={fitFontSize}\n fill={fill}\n >\n {letter}\n </text>\n );\n\n return (\n <div\n className={className}\n style={{ position: \"absolute\", inset: 0, overflow: \"hidden\" }}\n >\n <svg\n width=\"100%\"\n height=\"100%\"\n viewBox={`0 0 ${width} ${height}`}\n preserveAspectRatio=\"xMidYMid meet\"\n style={{ display: \"block\" }}\n >\n <g>\n {Array.from(\n { length: extrudeSteps + 1 },\n (_, i) => extrudeSteps - i,\n ).map((i) => glyph(bodyColor, stepX * i, stepY * i, `body-${i}`))}\n </g>\n\n {glyph(faceColor, stepX * extrudeSteps, stepY * extrudeSteps)}\n </svg>\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n letter: {\n type: \"text-content\",\n default: \"WIN\",\n description: \"Text\",\n },\n bodyColor: {\n type: \"color\",\n default: \"#e8192b\",\n description: \"Body color\",\n },\n faceColor: {\n type: \"color\",\n default: \"#ffffff\",\n description: \"Face color\",\n },\n minimaxRadius: {\n type: \"number\",\n min: 0,\n max: 200,\n step: 5,\n default: 80,\n description: \"Extrude radius\",\n hiddenFromList: false,\n },\n extrudeAngleDeg: {\n type: \"number\",\n min: -180,\n max: 180,\n step: 1,\n default: -58.6,\n description: \"Extrude angle\",\n hiddenFromList: false,\n },\n extrudeEndFrame: {\n type: \"number\",\n min: 10,\n max: 90,\n step: 1,\n default: 48,\n description: \"Extrude ends (frame)\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"letter\",\"bodyColor\",\"faceColor\",\"minimaxRadius\",\"extrudeAngleDeg\",\"extrudeEndFrame\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n letter: \"WIN\",\n bodyColor: \"#e8192b\",\n faceColor: \"#ffffff\",\n minimaxRadius: 80,\n extrudeAngleDeg: -58.6,\n extrudeEndFrame: 48,\n speed: 1,\n};\n\ntype ExtrudePopElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof ExtrudePopBase>;\n\nconst ExtrudePopInner = forwardRef<\n HTMLDivElement,\n ExtrudePopElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<ExtrudePop>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <ExtrudePopBase\n {...(componentProps as unknown as ComponentProps<typeof ExtrudePopBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const ExtrudePop = Interactive.withSchema({\n Component: ExtrudePopInner,\n componentName: \"<ExtrudePop>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/fade-through.json b/registry-artifacts/elements/fade-through.jsonindex 390127f5..a807958c 100644--- a/registry-artifacts/elements/fade-through.json+++ b/registry-artifacts/elements/fade-through.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [],"dimensions": {"width": 640,@@ -9,6 +10,7 @@},"displayName": "Fade Through","durationInFrames": 90,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "fade-through","sourceCode": "import { Easing, Interactive, Sequence, interpolate, useCurrentFrame, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface FadeThroughProps {\n fromText: string;\n toText: string;\n fontSize?: number;\n color?: string;\n fontWeight?: number;\n speed?: number;\n className?: string;\n}\n\nfunction FadeThroughBase({\n fromText,\n toText,\n fontSize = 72,\n color = \"#171717\",\n fontWeight = 600,\n speed = 1,\n className,\n}: FadeThroughProps) {\n const frame = useCurrentFrame() * speed;\n\n const exitDur = 8;\n const enterDur = 13;\n const overlapF = 1;\n const microDelayF = 2;\n\n const exitTotal = exitDur;\n const newStart = Math.max(0, exitTotal - overlapF + microDelayF);\n\n const exitEasing = Easing.bezier(0.4, 0, 1, 1);\n const enterEasing = Easing.bezier(0.2, 0, 0, 1);\n\n const fromOpacity = interpolate(frame, [0, exitDur], [1, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: exitEasing,\n });\n const fromY = interpolate(frame, [0, exitDur], [0, -4], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: exitEasing,\n });\n\n const local = frame - newStart;\n const toOpacity = interpolate(local, [0, enterDur], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: enterEasing,\n });\n const toY = interpolate(local, [0, enterDur], [6, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: enterEasing,\n });\n const toScale = interpolate(local, [0, enterDur], [0.99, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: enterEasing,\n });\n const blurVal = interpolate(local, [0, enterDur], [2, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: enterEasing,\n });\n\n const fontStack =\n \"var(--font-geist-sans), -apple-system, BlinkMacSystemFont, sans-serif\";\n\n return (\n <div\n className={className}\n style={{\n position: \"absolute\",\n inset: 0,\n background: \"transparent\",\n }}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <span\n style={{\n fontSize,\n fontWeight,\n color,\n letterSpacing: \"-0.03em\",\n fontFamily: fontStack,\n display: \"inline-block\",\n transformOrigin: \"50% 50%\",\n opacity: fromOpacity,\n translate: `0 ${fromY}px`,\n }}\n >\n {fromText}\n </span>\n </div>\n\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <span\n style={{\n fontSize,\n fontWeight,\n color,\n letterSpacing: \"-0.03em\",\n fontFamily: fontStack,\n display: \"inline-block\",\n transformOrigin: \"50% 50%\",\n opacity: toOpacity,\n translate: `0 ${toY}px`,\n scale: `${toScale}`,\n filter: `blur(${blurVal}px)`,\n }}\n >\n {toText}\n </span>\n </div>\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n fromText: {\n type: \"text-content\",\n default: \"Calm transitions.\",\n description: \"From text\",\n },\n toText: {\n type: \"text-content\",\n default: \"Fade through content.\",\n description: \"To text\",\n },\n fontSize: {\n type: \"number\",\n min: 12,\n max: 160,\n step: 1,\n default: 72,\n description: \"Font size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n fontWeight: {\n type: \"enum\",\n default: \"600\",\n variants: {\n \"400\": {},\n \"500\": {},\n \"600\": {},\n \"700\": {},\n },\n description: \"Font weight\",\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 640,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 100,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"fromText\",\"toText\",\"fontSize\",\"color\",\"fontWeight\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n fromText: \"Calm transitions.\",\n toText: \"Fade through content.\",\n fontSize: 72,\n color: \"#171717\",\n fontWeight: \"600\",\n speed: 1,\n};\n\ntype FadeThroughElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof FadeThroughBase>;\n\nconst FadeThroughInner = forwardRef<\n HTMLDivElement,\n FadeThroughElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 640, height = 100, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<FadeThrough>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <FadeThroughBase\n {...(componentProps as unknown as ComponentProps<typeof FadeThroughBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const FadeThrough = Interactive.withSchema({\n Component: FadeThroughInner,\n componentName: \"<FadeThrough>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/focus-blur-resolve.json b/registry-artifacts/elements/focus-blur-resolve.jsonindex 04d4a403..3fdaa7e5 100644--- a/registry-artifacts/elements/focus-blur-resolve.json+++ b/registry-artifacts/elements/focus-blur-resolve.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [],"dimensions": {"width": 870,@@ -9,6 +10,7 @@},"displayName": "Focus Blur Resolve","durationInFrames": 90,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "focus-blur-resolve","sourceCode": "import { Easing, Interactive, Sequence, interpolate, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface FocusBlurResolveProps {\n text: string;\n blur?: number;\n fontSize?: number;\n color?: string;\n fontWeight?: number;\n speed?: number;\n className?: string;\n}\n\nfunction FocusBlurResolveBase({\n text,\n blur = 14,\n fontSize = 72,\n color = \"#171717\",\n fontWeight = 600,\n speed = 1,\n className,\n}: FocusBlurResolveProps) {\n const frame = useCurrentFrame() * speed;\n const { durationInFrames } = useVideoConfig();\n\n const enterDur = 23;\n const exitDur = 16;\n const exitStart = Math.max(enterDur, durationInFrames - exitDur);\n\n const enterEasing = Easing.bezier(0.22, 1, 0.36, 1);\n const exitEasing = Easing.bezier(0.64, 0, 0.78, 0);\n\n const enterP = interpolate(frame, [0, enterDur], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: enterEasing,\n });\n\n const exitP = interpolate(frame, [exitStart, durationInFrames], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: exitEasing,\n });\n\n const opacity = enterP * (1 - exitP);\n\n const yEnter = interpolate(frame, [0, enterDur], [14, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: enterEasing,\n });\n\n const yExit = interpolate(frame, [exitStart, durationInFrames], [0, -10], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: exitEasing,\n });\n\n const y = yEnter + yExit;\n\n const blurEnter = interpolate(frame, [0, enterDur], [blur, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: enterEasing,\n });\n\n const blurExit = interpolate(frame, [exitStart, durationInFrames], [0, 10], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: exitEasing,\n });\n\n const blurVal = blurEnter + blurExit;\n\n const scale = interpolate(frame, [0, enterDur], [1.01, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: enterEasing,\n });\n\n return (\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n background: \"transparent\",\n }}\n >\n <span\n className={className}\n style={{\n fontSize,\n fontWeight,\n color,\n letterSpacing: \"-0.03em\",\n fontFamily:\n \"var(--font-geist-sans), -apple-system, BlinkMacSystemFont, sans-serif\",\n display: \"inline-block\",\n transformOrigin: \"50% 50%\",\n opacity,\n translate: `0 ${y}px`,\n scale: `${scale}`,\n filter: `blur(${blurVal}px)`,\n }}\n >\n {text}\n </span>\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n text: {\n type: \"text-content\",\n default: \"Focus resolves clearly.\",\n description: \"Text\",\n },\n blur: {\n type: \"number\",\n min: 1,\n max: 30,\n step: 1,\n default: 14,\n description: \"Blur\",\n hiddenFromList: false,\n },\n fontSize: {\n type: \"number\",\n min: 12,\n max: 160,\n step: 1,\n default: 72,\n description: \"Font size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n fontWeight: {\n type: \"enum\",\n default: \"600\",\n variants: {\n \"400\": {},\n \"500\": {},\n \"600\": {},\n \"700\": {},\n },\n description: \"Font weight\",\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 870,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 100,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"text\",\"blur\",\"fontSize\",\"color\",\"fontWeight\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n text: \"Focus resolves clearly.\",\n blur: 14,\n fontSize: 72,\n color: \"#171717\",\n fontWeight: \"600\",\n speed: 1,\n};\n\ntype FocusBlurResolveElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof FocusBlurResolveBase>;\n\nconst FocusBlurResolveInner = forwardRef<\n HTMLDivElement,\n FocusBlurResolveElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 870, height = 100, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<FocusBlurResolve>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <FocusBlurResolveBase\n {...(componentProps as unknown as ComponentProps<typeof FocusBlurResolveBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const FocusBlurResolve = Interactive.withSchema({\n Component: FocusBlurResolveInner,\n componentName: \"<FocusBlurResolve>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/fog-rise.json b/registry-artifacts/elements/fog-rise.jsonindex d85b0db7..ac773858 100644--- a/registry-artifacts/elements/fog-rise.json+++ b/registry-artifacts/elements/fog-rise.json@@ -2,10 +2,12 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [],"dimensions": null,"displayName": "Fog Rise","durationInFrames": 27,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "fog-rise","sourceCode": "import { Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface FogRiseProps {\n text: string;\n fontSize?: number;\n color?: string;\n fontWeight?: number;\n stagger?: number;\n blur?: number;\n tilt?: number;\n depth?: number;\n lift?: number;\n drift?: number;\n exitAt?: number;\n exitAccel?: number;\n mass?: number;\n stiffness?: number;\n damping?: number;\n spreadGap?: number;\n tracking?: number;\n resolveFrames?: number;\n fadeFrames?: number;\n speed?: number;\n className?: string;\n}\n\nfunction fogRiseLength(\n text: string,\n stagger = 5,\n resolveFrames = 22,\n): number {\n const chars = Array.from(text);\n if (chars.length === 0) return 0;\n const center = (chars.length - 1) / 2;\n const maxRing = Math.floor(center);\n return maxRing * stagger + resolveFrames;\n}\n\nfunction FogRiseBase({\n text,\n fontSize = 304,\n color = \"#004CFF\",\n fontWeight = 400,\n stagger = 5,\n blur = 0.17,\n tilt = 55,\n depth = 5,\n lift = 0.85,\n drift = 0.005,\n exitAt = 60,\n exitAccel = 0.04,\n mass = 1.3,\n stiffness = 60,\n damping = 13,\n spreadGap = 0.07,\n tracking = -0.07,\n resolveFrames = 22,\n fadeFrames = 18,\n speed = 1,\n className,\n}: FogRiseProps) {\n const frame = useCurrentFrame() * speed;\n const { fps } = useVideoConfig();\n\n const chars = Array.from(text);\n const center = (chars.length - 1) / 2;\n const minRing = chars.length % 2 === 0 ? 0.5 : 0;\n const maxRing = Math.floor(center);\n\n const converge = spring({\n frame,\n fps,\n config: { mass, stiffness, damping },\n });\n const angle = tilt * (1 - converge);\n const liftY = lift * fontSize * (1 - converge);\n const driftY = drift * fontSize * frame;\n const exitT = exitAt > 0 ? Math.max(frame - exitAt, 0) : 0;\n const exitY = 0.5 * exitAccel * exitT * exitT * fontSize;\n const gap = spreadGap * fontSize * (1 - converge);\n\n return (\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"flex-end\",\n justifyContent: \"center\",\n paddingBottom: \"6%\",\n whiteSpace: \"nowrap\",\n perspective: `${depth * fontSize}px`,\n background: \"transparent\",\n }}\n >\n <span\n className={className}\n style={{\n transform: `translateY(${liftY - driftY - exitY}px) rotateX(${-angle}deg)`,\n transformOrigin: \"50% 100%\",\n fontSize,\n fontWeight,\n color,\n letterSpacing: `${tracking}em`,\n lineHeight: 1.15,\n fontFamily:\n \"var(--font-geist-sans, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif)\",\n }}\n >\n {chars.map((char, j) => {\n const ring = Math.abs(j - center) - minRing;\n const startAt = ring * stagger;\n\n const opacity = interpolate(\n frame,\n [startAt, startAt + fadeFrames],\n [0, 1],\n { extrapolateLeft: \"clamp\", extrapolateRight: \"clamp\" },\n );\n\n const charBlur =\n blur *\n fontSize *\n interpolate(frame, [0, maxRing * stagger + resolveFrames], [1, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n });\n\n return (\n <span\n key={j}\n style={{\n display: \"inline-block\",\n whiteSpace: \"pre\",\n marginRight: j < chars.length - 1 ? gap : undefined,\n opacity,\n filter: charBlur > 0.05 ? `blur(${charBlur}px)` : undefined,\n }}\n >\n {char}\n </span>\n );\n })}\n </span>\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n text: {\n type: \"text-content\",\n default: \"Remocn\",\n description: \"Text\",\n },\n fontSize: {\n type: \"number\",\n min: 40,\n max: 560,\n step: 4,\n default: 304,\n description: \"Font size\",\n hiddenFromList: false,\n },\n stagger: {\n type: \"number\",\n min: 0,\n max: 15,\n step: 1,\n default: 5,\n description: \"Frames / ring\",\n hiddenFromList: false,\n },\n blur: {\n type: \"number\",\n min: 0,\n max: 0.5,\n step: 0.01,\n default: 0.17,\n description: \"Blur (em)\",\n hiddenFromList: false,\n },\n tilt: {\n type: \"number\",\n min: 0,\n max: 90,\n step: 5,\n default: 55,\n description: \"Start tilt (deg)\",\n hiddenFromList: false,\n },\n depth: {\n type: \"number\",\n min: 1,\n max: 8,\n step: 0.5,\n default: 5,\n description: \"Perspective depth\",\n hiddenFromList: false,\n },\n lift: {\n type: \"number\",\n min: 0,\n max: 1,\n step: 0.05,\n default: 0.85,\n description: \"Lift (em)\",\n hiddenFromList: false,\n },\n drift: {\n type: \"number\",\n min: 0,\n max: 0.012,\n step: 0.001,\n default: 0.005,\n description: \"Drift (em / frame)\",\n hiddenFromList: false,\n },\n exitAt: {\n type: \"number\",\n min: 0,\n max: 200,\n step: 5,\n default: 60,\n description: \"Exit frame\",\n hiddenFromList: false,\n },\n exitAccel: {\n type: \"number\",\n min: 0.002,\n max: 0.05,\n step: 0.002,\n default: 0.04,\n description: \"Exit accel\",\n hiddenFromList: false,\n },\n mass: {\n type: \"number\",\n min: 0.3,\n max: 3,\n step: 0.1,\n default: 1.3,\n description: \"Mass\",\n hiddenFromList: false,\n },\n stiffness: {\n type: \"number\",\n min: 30,\n max: 250,\n step: 10,\n default: 60,\n description: \"Stiffness\",\n hiddenFromList: false,\n },\n damping: {\n type: \"number\",\n min: 5,\n max: 30,\n step: 1,\n default: 13,\n description: \"Damping\",\n hiddenFromList: false,\n },\n spreadGap: {\n type: \"number\",\n min: 0,\n max: 0.3,\n step: 0.01,\n default: 0.07,\n description: \"Spread gap (em)\",\n hiddenFromList: false,\n },\n tracking: {\n type: \"number\",\n min: -0.12,\n max: 0,\n step: 0.005,\n default: -0.07,\n description: \"Tracking (em)\",\n hiddenFromList: false,\n },\n resolveFrames: {\n type: \"number\",\n min: 8,\n max: 50,\n step: 1,\n default: 22,\n description: \"Converge frames\",\n hiddenFromList: false,\n },\n fadeFrames: {\n type: \"number\",\n min: 2,\n max: 25,\n step: 1,\n default: 18,\n description: \"Fade frames\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#004CFF\",\n description: \"Color\",\n },\n fontWeight: {\n type: \"enum\",\n default: \"400\",\n variants: {\n \"400\": {},\n \"500\": {},\n \"600\": {},\n \"700\": {},\n },\n description: \"Font weight\",\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"text\",\"fontSize\",\"stagger\",\"blur\",\"tilt\",\"depth\",\"lift\",\"drift\",\"exitAt\",\"exitAccel\",\"mass\",\"stiffness\",\"damping\",\"spreadGap\",\"tracking\",\"resolveFrames\",\"fadeFrames\",\"color\",\"fontWeight\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n text: \"Remocn\",\n fontSize: 304,\n stagger: 5,\n blur: 0.17,\n tilt: 55,\n depth: 5,\n lift: 0.85,\n drift: 0.005,\n exitAt: 60,\n exitAccel: 0.04,\n mass: 1.3,\n stiffness: 60,\n damping: 13,\n spreadGap: 0.07,\n tracking: -0.07,\n resolveFrames: 22,\n fadeFrames: 18,\n color: \"#004CFF\",\n fontWeight: \"400\",\n speed: 1,\n};\n\ntype FogRiseElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof FogRiseBase>;\n\nconst FogRiseInner = forwardRef<\n HTMLDivElement,\n FogRiseElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<FogRise>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <FogRiseBase\n {...(componentProps as unknown as ComponentProps<typeof FogRiseBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const FogRise = Interactive.withSchema({\n Component: FogRiseInner,\n componentName: \"<FogRise>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/glyph-anatomy.json b/registry-artifacts/elements/glyph-anatomy.jsonindex 1c5eaf2a..cdcaaad4 100644--- a/registry-artifacts/elements/glyph-anatomy.json+++ b/registry-artifacts/elements/glyph-anatomy.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "opentype.js",@@ -15,6 +16,7 @@"dimensions": null,"displayName": "Glyph Anatomy","durationInFrames": 66,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "glyph-anatomy","sourceCode": "import { loadFont } from \"@remotion/google-fonts/Inter\";\nimport { parse, type Font } from \"opentype.js\";\nimport { forwardRef, useEffect, useImperativeHandle, useRef, useState, type ComponentProps } from \"react\";\nimport { Easing, Interactive, Sequence, continueRender, delayRender, interpolate, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\n\nconst { fontFamily: INTER } = loadFont(\"normal\", {\n weights: [\"500\"],\n subsets: [\"latin\"],\n});\n\ninterface GlyphAnatomyProps {\n text?: string;\n fontUrl?: string;\n fontSize?: number;\n color?: string;\n guideColor?: string;\n guides?: boolean;\n keepPoints?: boolean;\n speed?: number;\n className?: string;\n}\n\n/** Static Inter ExtraBold (800) from Google Fonts. */\nconst interExtraBoldTtf =\n \"https://fonts.gstatic.com/s/inter/v20/UcCO3FwrK3iLTeHuS_nVMrMxCp50SjIw2boKoduKmMEVuDyYMZg.ttf\";\n\nconst glyphAnatomyDefaults = {\n text: \"Glyph\",\n fontUrl: interExtraBoldTtf,\n fontSize: 200,\n color: \"#fafafa\",\n guideColor: \"#0d99ff\",\n guides: true,\n keepPoints: false,\n speed: 1,\n} satisfies Required<Omit<GlyphAnatomyProps, \"className\">>;\n\n/** Beats on the 30 fps clock. Letter beats shift by `letterStagger × i`. */\nconst glyphAnatomyTiming = {\n guideStart: 0,\n guideStagger: 3,\n guideDraw: 10,\n anchors: [8, 22],\n anchorPop: 4,\n pull: [18, 40],\n pullDuration: 8,\n fill: [40, 50],\n fade: [46, 58],\n letterStagger: 2,\n} as const;\n\nconst CLAMP = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n} as const;\n\nconst easeOutCubic = Easing.out(Easing.cubic);\nconst easeInOutCubic = Easing.inOut(Easing.cubic);\nconst popEase = Easing.out(Easing.back(1.7));\nconst pullEase = Easing.out(Easing.back(1.6));\n\nfunction finite(value: number | undefined, fallback: number) {\n return typeof value === \"number\" && Number.isFinite(value) ? value : fallback;\n}\n\n/** Maps a composition frame onto the 30 fps timeline, scaled by `speed`. */\nfunction getGlyphAnatomyTime(\n frame: number,\n options: { fps?: number; speed?: number } = {},\n) {\n const fps = Math.max(1, finite(options.fps, 30));\n const speed = Math.max(0, finite(options.speed, 1));\n return (Math.max(0, finite(frame, 0)) * 30 * speed) / fps;\n}\n\ninterface Point {\n x: number;\n y: number;\n}\n\ninterface AnatomySegment {\n from: Point;\n to: Point;\n /** Cubic handles; absent on straight segments. */\n c1?: Point;\n c2?: Point;\n}\n\ninterface PathCommand {\n type: string;\n x?: number;\n y?: number;\n x1?: number;\n y1?: number;\n x2?: number;\n y2?: number;\n}\n\nconst lerp = (a: Point, b: Point, k: number): Point => ({\n x: a.x + (b.x - a.x) * k,\n y: a.y + (b.y - a.y) * k,\n});\n\n/**\n * Turns glyph path commands into contours of explicit segments. Quadratic\n * curves become cubics (handles at ⅔ toward the control point), so every\n * curve shows one handle on each end, as in Figma or Glyphs.\n */\nfunction getAnatomyContours(\n commands: readonly PathCommand[],\n): AnatomySegment[][] {\n const contours: AnatomySegment[][] = [];\n let segments: AnatomySegment[] = [];\n let start: Point | null = null;\n let at: Point | null = null;\n const close = () => {\n if (start && at && (at.x !== start.x || at.y !== start.y)) {\n segments.push({ from: at, to: start });\n }\n if (segments.length > 0) contours.push(segments);\n segments = [];\n start = null;\n at = null;\n };\n for (const c of commands) {\n const to = { x: c.x ?? 0, y: c.y ?? 0 };\n if (c.type === \"M\") {\n close();\n start = to;\n at = to;\n } else if (!at) {\n } else if (c.type === \"L\") {\n segments.push({ from: at, to });\n at = to;\n } else if (c.type === \"Q\") {\n const q = { x: c.x1 ?? 0, y: c.y1 ?? 0 };\n segments.push({\n from: at,\n to,\n c1: lerp(at, q, 2 / 3),\n c2: lerp(to, q, 2 / 3),\n });\n at = to;\n } else if (c.type === \"C\") {\n segments.push({\n from: at,\n to,\n c1: { x: c.x1 ?? 0, y: c.y1 ?? 0 },\n c2: { x: c.x2 ?? 0, y: c.y2 ?? 0 },\n });\n at = to;\n } else if (c.type === \"Z\") {\n close();\n }\n }\n close();\n return contours;\n}\n\n/**\n * How far each handle has travelled from its anchor to its place, 0 → 1 with\n * overshoot. At 0 the curve is its chord.\n */\nfunction getGlyphAnatomyPull(t: number, order: number, total: number) {\n const { pull, pullDuration } = glyphAnatomyTiming;\n const span = pull[1] - pull[0] - pullDuration;\n const start = pull[0] + (total > 1 ? (span * order) / (total - 1) : 0);\n return interpolate(t, [start, start + pullDuration], [0, 1], {\n ...CLAMP,\n easing: pullEase,\n });\n}\n\n/** Scale of anchor `order` of `total` popping in along the letter's path. */\nfunction getGlyphAnatomyAnchor(t: number, order: number, total: number) {\n const { anchors, anchorPop } = glyphAnatomyTiming;\n const span = anchors[1] - anchors[0] - anchorPop;\n const start = anchors[0] + (total > 1 ? (span * order) / (total - 1) : 0);\n return Math.max(\n 0,\n interpolate(t, [start, start + anchorPop], [0, 1], {\n ...CLAMP,\n easing: popEase,\n }),\n );\n}\n\n/** Letter-level fades: outline in, fill in, scaffolding out. */\nfunction getGlyphAnatomyLetter(t: number) {\n const { anchors, fill, fade } = glyphAnatomyTiming;\n return {\n outline: interpolate(t, [anchors[0], anchors[0] + 4], [0, 1], CLAMP),\n fill: interpolate(t, [...fill], [0, 1], {\n ...CLAMP,\n easing: easeInOutCubic,\n }),\n scaffold: interpolate(t, [...fade], [1, 0], {\n ...CLAMP,\n easing: easeInOutCubic,\n }),\n };\n}\n\n/** Draw progress of guide `index`, 0..1. */\nfunction getGlyphAnatomyGuide(t: number, index: number) {\n const { guideStart, guideStagger, guideDraw } = glyphAnatomyTiming;\n const start = guideStart + guideStagger * index;\n return interpolate(t, [start, start + guideDraw], [0, 1], {\n ...CLAMP,\n easing: easeOutCubic,\n });\n}\n\n/** Frame where the scaffolding of the last of `count` letters has faded. */\nfunction getGlyphAnatomyLength(count: number) {\n const { fade, letterStagger } = glyphAnatomyTiming;\n return fade[1] + letterStagger * Math.max(0, count - 1);\n}\n\n/** Path data for a contour with each handle pulled `k(segment)` of the way. */\nfunction getAnatomyPath(\n segments: readonly AnatomySegment[],\n pullOf: (index: number) => number,\n) {\n if (segments.length === 0) return \"\";\n const f = (p: Point) => `${p.x.toFixed(2)} ${p.y.toFixed(2)}`;\n let d = `M${f(segments[0].from)}`;\n segments.forEach((s, i) => {\n if (s.c1 && s.c2) {\n const k = pullOf(i);\n d += `C${f(lerp(s.from, s.c1, k))} ${f(lerp(s.to, s.c2, k))} ${f(s.to)}`;\n } else {\n d += `L${f(s.to)}`;\n }\n });\n return `${d}Z`;\n}\n\ninterface AnatomyLetter {\n contours: AnatomySegment[][];\n}\n\nfunction layout(font: Font, text: string, fontSize: number) {\n const scale = fontSize / font.unitsPerEm;\n // Per-character lookup: full shaping runs GSUB lookups that opentype.js\n // does not support in every font.\n const glyphs = Array.from(text).map((char) => font.charToGlyph(char));\n let x = 0;\n const letters: AnatomyLetter[] = glyphs.map((glyph, i) => {\n if (i > 0) x += font.getKerningValue(glyphs[i - 1], glyph) * scale;\n const contours = getAnatomyContours(glyph.getPath(x, 0, fontSize).commands);\n x += (glyph.advanceWidth ?? 0) * scale;\n return { contours };\n });\n const os2 = font.tables.os2 as\n | { sCapHeight?: number; sxHeight?: number }\n | undefined;\n const em = (v: number | undefined, fallback: number) =>\n ((v ?? fallback * font.unitsPerEm) * fontSize) / font.unitsPerEm;\n return {\n letters,\n width: x,\n capHeight: em(os2?.sCapHeight, 0.7),\n xHeight: em(os2?.sxHeight, 0.5),\n descender: (-font.descender * fontSize) / font.unitsPerEm,\n };\n}\n\nconst fontCache = new Map<string, Promise<Font>>();\n\nfunction loadAnatomyFont(url: string) {\n let pending = fontCache.get(url);\n if (!pending) {\n pending = fetch(url)\n .then((res) => res.arrayBuffer())\n .then((buffer) => parse(buffer));\n fontCache.set(url, pending);\n pending.catch(() => fontCache.delete(url));\n }\n return pending;\n}\n\nfunction useAnatomyFont(url: string) {\n const [font, setFont] = useState<Font | null>(null);\n\n useEffect(() => {\n const handle = delayRender(`glyph-anatomy: loading ${url}`);\n let released = false;\n const release = () => {\n if (released) return;\n released = true;\n continueRender(handle);\n };\n loadAnatomyFont(url).then((parsed) => {\n if (!released) setFont(parsed);\n release();\n }, release);\n return release;\n }, [url]);\n\n return font;\n}\n\nfunction GlyphAnatomyBase({\n text = glyphAnatomyDefaults.text,\n fontUrl = glyphAnatomyDefaults.fontUrl,\n fontSize = glyphAnatomyDefaults.fontSize,\n color = glyphAnatomyDefaults.color,\n guideColor = glyphAnatomyDefaults.guideColor,\n guides = glyphAnatomyDefaults.guides,\n keepPoints = glyphAnatomyDefaults.keepPoints,\n speed = glyphAnatomyDefaults.speed,\n className,\n}: GlyphAnatomyProps) {\n const frame = useCurrentFrame();\n const { fps, width, height } = useVideoConfig();\n const font = useAnatomyFont(fontUrl);\n if (!font) return null;\n\n const unit = height / 720;\n const t = getGlyphAnatomyTime(frame, { fps, speed });\n const word = layout(font, text, fontSize);\n const originX = (width - word.width * unit) / 2;\n const baseline = (height + word.capHeight * unit) / 2;\n const hair = 1.25;\n const anchorSize = 6;\n const handleRadius = 2.6;\n const margin = 0.3 * fontSize;\n // Guides fade with the last letter's scaffolding.\n const lastStart =\n glyphAnatomyTiming.letterStagger * Math.max(0, word.letters.length - 1);\n const scaffoldAll = keepPoints\n ? 1\n : getGlyphAnatomyLetter(t - lastStart).scaffold;\n\n const guideLines = [\n { label: \"Cap height\", y: -word.capHeight },\n { label: \"x-height\", y: -word.xHeight },\n { label: \"Baseline\", y: 0 },\n { label: \"Descender\", y: word.descender },\n ];\n\n return (\n <div\n className={className}\n style={{ position: \"absolute\", inset: 0, overflow: \"hidden\" }}\n >\n <svg\n width=\"100%\"\n height=\"100%\"\n viewBox={`0 0 ${width} ${height}`}\n style={{ display: \"block\" }}\n >\n <g transform={`translate(${originX} ${baseline}) scale(${unit})`}>\n {guides\n ? guideLines.map((guide, i) => {\n const draw = getGlyphAnatomyGuide(t, i);\n if (draw <= 0) return null;\n const length = word.width + 2 * margin;\n return (\n <g key={guide.label} opacity={0.7 * scaffoldAll}>\n <line\n x1={-margin}\n x2={-margin + length * draw}\n y1={guide.y}\n y2={guide.y}\n stroke={guideColor}\n strokeWidth={hair * 0.8}\n />\n <text\n x={-margin}\n y={guide.y - 5}\n fill={guideColor}\n fontFamily={INTER}\n fontSize={11}\n fontWeight={500}\n opacity={draw}\n >\n {guide.label}\n </text>\n </g>\n );\n })\n : null}\n {word.letters.map((letter, i) => {\n const lt = t - glyphAnatomyTiming.letterStagger * i;\n const state = getGlyphAnatomyLetter(lt);\n const scaffold = keepPoints ? 1 : state.scaffold;\n const curves = letter.contours.flatMap((segments, c) =>\n segments.flatMap((s, k) => (s.c1 ? [`${c}:${k}`] : [])),\n );\n const curveOrder = new Map(curves.map((key, n) => [key, n]));\n const anchors = letter.contours.flatMap((segments) =>\n segments.map((s) => s.from),\n );\n const pullOf = (c: number) => (k: number) =>\n getGlyphAnatomyPull(\n lt,\n curveOrder.get(`${c}:${k}`) ?? 0,\n curves.length,\n );\n const paths = letter.contours.map((segments, c) =>\n getAnatomyPath(segments, pullOf(c)),\n );\n let anchorIndex = 0;\n return (\n <g key={i}>\n {state.fill > 0 ? (\n <path d={paths.join(\"\")} fill={color} opacity={state.fill} />\n ) : null}\n {state.outline > 0 && scaffold > 0 ? (\n <g opacity={scaffold}>\n {paths.map((d, c) => (\n <path\n key={c}\n d={d}\n fill=\"none\"\n stroke={color}\n strokeWidth={hair}\n opacity={state.outline}\n />\n ))}\n {letter.contours.map((segments, c) =>\n segments.map((s, k) => {\n if (!s.c1 || !s.c2) return null;\n const pull = pullOf(c)(k);\n if (pull <= 0) return null;\n const h1 = lerp(s.from, s.c1, pull);\n const h2 = lerp(s.to, s.c2, pull);\n return (\n <g key={`${c}-${k}`}>\n <line\n x1={s.from.x}\n y1={s.from.y}\n x2={h1.x}\n y2={h1.y}\n stroke={guideColor}\n strokeWidth={hair * 0.8}\n />\n <line\n x1={s.to.x}\n y1={s.to.y}\n x2={h2.x}\n y2={h2.y}\n stroke={guideColor}\n strokeWidth={hair * 0.8}\n />\n <circle\n cx={h1.x}\n cy={h1.y}\n r={handleRadius}\n fill={guideColor}\n />\n <circle\n cx={h2.x}\n cy={h2.y}\n r={handleRadius}\n fill={guideColor}\n />\n </g>\n );\n }),\n )}\n {letter.contours.map((segments, c) =>\n segments.map((s, k) => {\n const scale = getGlyphAnatomyAnchor(\n lt,\n anchorIndex++,\n anchors.length,\n );\n if (scale <= 0) return null;\n const size = anchorSize * scale;\n return (\n <rect\n key={`${c}-${k}`}\n x={s.from.x - size / 2}\n y={s.from.y - size / 2}\n width={size}\n height={size}\n fill=\"#ffffff\"\n stroke={guideColor}\n strokeWidth={hair}\n />\n );\n }),\n )}\n </g>\n ) : null}\n </g>\n );\n })}\n </g>\n </svg>\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n text: {\n type: \"text-content\",\n default: \"Glyph\",\n description: \"Text\",\n },\n color: {\n type: \"color\",\n default: \"#fafafa\",\n description: \"Glyph color\",\n },\n guideColor: {\n type: \"color\",\n default: \"#0d99ff\",\n description: \"Points\",\n },\n fontSize: {\n type: \"number\",\n default: 200,\n min: 80,\n max: 320,\n step: 2,\n description: \"Font size\",\n hiddenFromList: false,\n },\n guides: {\n type: \"boolean\",\n default: true,\n description: \"Guides\",\n },\n keepPoints: {\n type: \"boolean\",\n default: false,\n description: \"Keep points\",\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"text\",\"color\",\"guideColor\",\"fontSize\",\"guides\",\"keepPoints\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n text: \"Glyph\",\n color: \"#fafafa\",\n guideColor: \"#0d99ff\",\n fontSize: 200,\n guides: true,\n keepPoints: false,\n speed: 1,\n};\n\ntype GlyphAnatomyElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof GlyphAnatomyBase>;\n\nconst GlyphAnatomyInner = forwardRef<\n HTMLDivElement,\n GlyphAnatomyElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<GlyphAnatomy>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <GlyphAnatomyBase\n {...(componentProps as unknown as ComponentProps<typeof GlyphAnatomyBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const GlyphAnatomy = Interactive.withSchema({\n Component: GlyphAnatomyInner,\n componentName: \"<GlyphAnatomy>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/gooey-morph.json b/registry-artifacts/elements/gooey-morph.jsonindex 66980be3..337480c6 100644--- a/registry-artifacts/elements/gooey-morph.json+++ b/registry-artifacts/elements/gooey-morph.json@@ -2,10 +2,12 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [],"dimensions": null,"displayName": "Gooey Morph","durationInFrames": 76,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "gooey-morph","sourceCode": "import { forwardRef, useId, useImperativeHandle, useRef, type ComponentProps } from \"react\";\nimport { Easing, Interactive, Sequence, interpolate, useCurrentFrame, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\n\ninterface GooeyMorphProps {\n className?: string;\n width?: number;\n height?: number;\n barWidth?: number;\n barHeight?: number;\n barStartPositions?: [number, number][];\n barRestPositions?: [number, number][];\n barEntryFrames?: number[];\n barTravelFrames?: number;\n word?: string;\n fontFamily?: string;\n fontSize?: number;\n tracking?: number;\n wordCenterX?: number;\n wordBaselineY?: number;\n blurRadius?: number;\n blurIterations?: number;\n alphaInputBlack?: number;\n alphaInputWhite?: number;\n morphStartFrame?: number;\n morphPeakFrame?: number;\n morphEndFrame?: number;\n displaceAmount?: number;\n displaceSize?: number;\n displaceComplexity?: number;\n displaceEvolutionPerSecond?: number;\n fill?: string;\n}\n\nfunction boxBlurSigma(radius: number, iterations: number): number {\n const w = 2 * radius + 1;\n return Math.sqrt((iterations * (w * w - 1)) / 12);\n}\n\nfunction GooeyMorphBase({\n className,\n width = 1920,\n height = 1080,\n barWidth = 213,\n barHeight = 181,\n barStartPositions = [\n [956.9, 764.9],\n [297.5, 799.9],\n [738.2, 257.9],\n [1617.9, 302.9],\n ],\n barRestPositions = [\n [634.9, 538.9],\n [852.5, 538.9],\n [1070.2, 538.9],\n [1287.9, 538.9],\n ],\n barEntryFrames = [8, 0, 4, 13],\n barTravelFrames = 30,\n word = \"HELLO\",\n fontFamily = \"sans-serif\",\n fontSize = 237,\n tracking = 0,\n wordCenterX = 961.4,\n wordBaselineY = 601.3,\n blurRadius = 6,\n blurIterations = 6,\n alphaInputBlack = 0.4588,\n alphaInputWhite = 0.5098,\n morphStartFrame = 50,\n morphPeakFrame = 63,\n morphEndFrame = 76,\n displaceAmount = 20,\n displaceSize = 19,\n displaceComplexity = 1,\n displaceEvolutionPerSecond = 50,\n fill = \"#ffffff\",\n}: GooeyMorphProps) {\n const frame = useCurrentFrame();\n const filterId = useId();\n\n const travelEase = Easing.bezier(0.88, 0.14, 0.12, 0.86);\n\n const morphWindow: [number, number, number] = [\n morphStartFrame,\n morphPeakFrame,\n morphEndFrame,\n ];\n\n const blur = interpolate(frame, morphWindow, [0, blurRadius, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.bezier(0.33, 0, 0.67, 1),\n });\n const sigma = boxBlurSigma(blur, blurIterations);\n\n const displaceScale = interpolate(\n frame,\n morphWindow,\n [0, displaceAmount, 0],\n {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.bezier(0.33, 0, 0.67, 1),\n },\n );\n\n const barsOpacity = interpolate(\n frame,\n [morphStartFrame, morphEndFrame],\n [1, 0],\n {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n },\n );\n const wordOpacity = interpolate(\n frame,\n [morphStartFrame, morphEndFrame],\n [0, 1],\n {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n },\n );\n\n const slope = 1 / Math.max(alphaInputWhite - alphaInputBlack, 1e-6);\n const offset = -alphaInputBlack * slope;\n\n const evolution = (frame / 30) * displaceEvolutionPerSecond;\n\n return (\n <div\n className={className}\n style={{ position: \"absolute\", inset: 0, overflow: \"hidden\" }}\n >\n <svg\n width=\"100%\"\n height=\"100%\"\n viewBox={`0 0 ${width} ${height}`}\n preserveAspectRatio=\"xMidYMid meet\"\n style={{ display: \"block\" }}\n >\n <defs>\n <filter\n id={filterId}\n x=\"-15%\"\n y=\"-15%\"\n width=\"130%\"\n height=\"130%\"\n colorInterpolationFilters=\"sRGB\"\n >\n <feGaussianBlur\n in=\"SourceGraphic\"\n stdDeviation={sigma}\n result=\"blurred\"\n />\n <feColorMatrix\n in=\"blurred\"\n type=\"matrix\"\n values={[\n \"1 0 0 0 0\",\n \"0 1 0 0 0\",\n \"0 0 1 0 0\",\n `0 0 0 ${slope} ${offset}`,\n ].join(\" \")}\n result=\"threshold\"\n />\n <feTurbulence\n type=\"fractalNoise\"\n baseFrequency={1 / Math.max(displaceSize, 1)}\n numOctaves={Math.max(1, Math.round(displaceComplexity))}\n seed={7}\n result=\"noise\"\n />\n <feOffset\n in=\"noise\"\n dx={evolution}\n dy={evolution * 0.6}\n result=\"noiseMoved\"\n />\n <feDisplacementMap\n in=\"threshold\"\n in2=\"noiseMoved\"\n scale={displaceScale}\n xChannelSelector=\"R\"\n yChannelSelector=\"G\"\n />\n </filter>\n </defs>\n\n <g filter={`url(#${filterId})`}>\n <g opacity={barsOpacity}>\n {barRestPositions.map((rest, i) => {\n const start = barStartPositions[i] ?? rest;\n const entry = barEntryFrames[i] ?? 0;\n const local = frame - entry;\n const stops = [0, barTravelFrames / 2, barTravelFrames];\n\n const x = interpolate(\n local,\n stops,\n [start[0], rest[0], rest[0]],\n {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: travelEase,\n },\n );\n const y = interpolate(\n local,\n stops,\n [start[1], start[1], rest[1]],\n {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: travelEase,\n },\n );\n\n return (\n <rect\n key={rest.join(\",\")}\n x={x - barWidth / 2}\n y={y - barHeight / 2}\n width={barWidth}\n height={barHeight}\n fill={fill}\n />\n );\n })}\n </g>\n\n <text\n x={wordCenterX}\n y={wordBaselineY}\n textAnchor=\"middle\"\n fontFamily={fontFamily}\n fontSize={fontSize}\n fontWeight={900}\n letterSpacing={tracking}\n fill={fill}\n opacity={wordOpacity}\n >\n {word}\n </text>\n </g>\n </svg>\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n word: {\n type: \"text-content\",\n default: \"HELLO\",\n description: \"Word\",\n },\n fill: {\n type: \"color\",\n default: \"#f2f2f2\",\n description: \"Fill\",\n },\n fontFamily: {\n type: \"text-content\",\n default: \"'Bodoni Moda', Georgia, serif\",\n description: \"Font family\",\n },\n blurRadius: {\n type: \"number\",\n min: 0,\n max: 20,\n step: 1,\n default: 6,\n description: \"Goo blur radius\",\n hiddenFromList: false,\n },\n displaceAmount: {\n type: \"number\",\n min: 0,\n max: 80,\n step: 1,\n default: 20,\n description: \"Displace amount\",\n hiddenFromList: false,\n },\n barTravelFrames: {\n type: \"number\",\n min: 10,\n max: 60,\n step: 1,\n default: 30,\n description: \"Bar travel (frames)\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"word\",\"fill\",\"fontFamily\",\"blurRadius\",\"displaceAmount\",\"barTravelFrames\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n word: \"HELLO\",\n fill: \"#f2f2f2\",\n fontFamily: \"'Bodoni Moda', Georgia, serif\",\n blurRadius: 6,\n displaceAmount: 20,\n barTravelFrames: 30,\n speed: 1,\n};\n\ntype GooeyMorphElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof GooeyMorphBase>;\n\nconst GooeyMorphInner = forwardRef<\n HTMLDivElement,\n GooeyMorphElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<GooeyMorph>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <GooeyMorphBase\n {...(componentProps as unknown as ComponentProps<typeof GooeyMorphBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const GooeyMorph = Interactive.withSchema({\n Component: GooeyMorphInner,\n componentName: \"<GooeyMorph>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/gradient-scale-cut-text.json b/registry-artifacts/elements/gradient-scale-cut-text.jsonindex d6d5e44e..51dba405 100644--- a/registry-artifacts/elements/gradient-scale-cut-text.json+++ b/registry-artifacts/elements/gradient-scale-cut-text.json@@ -2,10 +2,12 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [],"dimensions": null,"displayName": "Gradient Scale Cut Text","durationInFrames": 36,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "gradient-scale-cut-text","sourceCode": "import { Easing, Interactive, Sequence, interpolate, useCurrentFrame, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface GradientScaleCutTextProps {\n text?: string;\n giantFontSize?: number;\n compactFontSize?: number;\n fontWeight?: number;\n gradientStart?: string;\n gradientEnd?: string;\n ghostColor?: string;\n backgroundColor?: string;\n anchorOffsetX?: number;\n giantTravel?: number;\n settleTravel?: number;\n cutFrame?: number;\n revealSoftness?: number;\n compactBlur?: number;\n speed?: number;\n className?: string;\n}\n\nconst gradientScaleCutTextLength = 36;\n\nconst REVEAL_END = 33;\nconst SETTLE_FRAMES = 8;\nconst GIANT_Y = -28;\nconst GIANT_X_CORRECTION = -48;\nconst COMPACT_Y = 5;\nconst COMPACT_X_SCALE = 0.87;\nconst COMPACT_START_X_CORRECTION = 28;\nconst FONT_FAMILY = \"Arial, Helvetica, sans-serif\";\nconst clamp = {\n extrapolateLeft: \"clamp\" as const,\n extrapolateRight: \"clamp\" as const,\n};\n\ninterface TextLayerProps {\n text: string;\n fontSize: number;\n fontWeight: number;\n gradientStart: string;\n gradientEnd: string;\n ghostColor: string;\n maskImage: string;\n}\n\nfunction TextLayer({\n text,\n fontSize,\n fontWeight,\n gradientStart,\n gradientEnd,\n ghostColor,\n maskImage,\n}: TextLayerProps) {\n const textStyle = {\n display: \"block\",\n fontFamily: FONT_FAMILY,\n fontSize,\n fontWeight,\n letterSpacing: 0,\n lineHeight: 1.12,\n whiteSpace: \"nowrap\" as const,\n };\n\n return (\n <div style={{ position: \"relative\" }}>\n <span style={{ ...textStyle, color: ghostColor }}>{text}</span>\n <span\n style={{\n ...textStyle,\n position: \"absolute\",\n inset: 0,\n color: \"transparent\",\n backgroundImage: `linear-gradient(90deg, ${gradientStart} 0%, ${gradientStart} 4%, ${gradientEnd} 26%, ${gradientEnd} 100%)`,\n backgroundClip: \"text\",\n maskImage,\n maskRepeat: \"no-repeat\",\n opacity: 1,\n WebkitBackgroundClip: \"text\",\n WebkitMaskImage: maskImage,\n WebkitMaskRepeat: \"no-repeat\",\n }}\n >\n {text}\n </span>\n </div>\n );\n}\n\nfunction GradientScaleCutTextBase({\n text = \"Introducing\",\n giantFontSize = 520,\n compactFontSize = 132,\n fontWeight = 700,\n gradientStart = \"#f04a14\",\n gradientEnd = \"#f3f1f1\",\n ghostColor = \"#170b0a\",\n backgroundColor = \"#000000\",\n anchorOffsetX = -16,\n giantTravel = 400,\n settleTravel = 160,\n cutFrame = 13,\n revealSoftness = 14,\n compactBlur = 12,\n speed = 1,\n className,\n}: GradientScaleCutTextProps) {\n const frame = useCurrentFrame() * Math.max(speed, 0);\n const safeCutFrame = Math.max(cutFrame, 1);\n const safeGiantFontSize = Math.max(giantFontSize, 1);\n const safeCompactFontSize = Math.max(compactFontSize, 1);\n const safeSoftness = Math.max(revealSoftness, 0);\n const safeBlur = Math.max(compactBlur, 0);\n const revealProgress = interpolate(frame, [0, REVEAL_END], [0.02, 1], {\n ...clamp,\n easing: Easing.bezier(0.22, 0.74, 0.24, 1),\n });\n const revealEdge = revealProgress * (100 + safeSoftness / 2);\n const revealSolid = Math.max(0, revealEdge - safeSoftness / 2);\n const revealFade = revealEdge + safeSoftness / 2;\n const maskImage = `linear-gradient(90deg, #000 0%, #000 ${revealSolid}%, transparent ${revealFade}%, transparent ${revealFade}%)`;\n const giantProgress = interpolate(\n frame,\n [0, Math.max(safeCutFrame - 1, 1)],\n [0, 1],\n {\n ...clamp,\n easing: Easing.out(Easing.cubic),\n },\n );\n const settleProgress = interpolate(\n frame,\n [safeCutFrame, safeCutFrame + SETTLE_FRAMES],\n [0, 1],\n {\n ...clamp,\n easing: Easing.out(Easing.cubic),\n },\n );\n const moveProgress = interpolate(\n frame,\n [\n safeCutFrame + 1,\n safeCutFrame + 2,\n safeCutFrame + 4,\n safeCutFrame + SETTLE_FRAMES,\n ],\n [0, 0.58, 0.875, 1],\n clamp,\n );\n const showGiant = frame < safeCutFrame;\n const compactX =\n interpolate(moveProgress, [0, 1], [settleTravel, 0], clamp) +\n COMPACT_START_X_CORRECTION * (1 - moveProgress);\n const compactBlurValue = safeBlur * (1 - settleProgress);\n\n return (\n <div\n className={className}\n style={{\n position: \"absolute\",\n inset: 0,\n overflow: \"hidden\",\n backgroundColor,\n }}\n >\n {showGiant ? (\n <div\n style={{\n position: \"absolute\",\n top: `calc(50% + ${GIANT_Y}px)`,\n left: `calc(50% + ${anchorOffsetX + GIANT_X_CORRECTION - giantTravel * giantProgress}px)`,\n opacity: 1,\n transform: \"translate3d(0, -50%, 0)\",\n }}\n >\n <TextLayer\n text={text}\n fontSize={safeGiantFontSize}\n fontWeight={fontWeight}\n gradientStart={gradientStart}\n gradientEnd={gradientEnd}\n ghostColor={ghostColor}\n maskImage={maskImage}\n />\n </div>\n ) : (\n <div\n style={{\n position: \"absolute\",\n top: `calc(50% + ${COMPACT_Y}px)`,\n left: `calc(50% + ${anchorOffsetX + compactX}px)`,\n filter: `blur(${compactBlurValue}px)`,\n opacity: 1,\n transform: `translate3d(-50%, -50%, 0) scaleX(${COMPACT_X_SCALE})`,\n transformOrigin: \"center\",\n }}\n >\n <TextLayer\n text={text}\n fontSize={safeCompactFontSize}\n fontWeight={fontWeight}\n gradientStart={gradientStart}\n gradientEnd={gradientEnd}\n ghostColor={ghostColor}\n maskImage={maskImage}\n />\n </div>\n )}\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n text: {\n type: \"text-content\",\n default: \"Introducing\",\n description: \"Text\",\n },\n giantFontSize: {\n type: \"number\",\n min: 160,\n max: 720,\n step: 4,\n default: 520,\n description: \"Giant font size\",\n hiddenFromList: false,\n },\n compactFontSize: {\n type: \"number\",\n min: 40,\n max: 240,\n step: 2,\n default: 132,\n description: \"Compact font size\",\n hiddenFromList: false,\n },\n anchorOffsetX: {\n type: \"number\",\n min: -400,\n max: 400,\n step: 4,\n default: -16,\n description: \"Final horizontal anchor offset\",\n hiddenFromList: false,\n },\n giantTravel: {\n type: \"number\",\n min: 0,\n max: 800,\n step: 4,\n default: 400,\n description: \"Giant phase left travel\",\n hiddenFromList: false,\n },\n settleTravel: {\n type: \"number\",\n min: 0,\n max: 400,\n step: 4,\n default: 160,\n description: \"Compact entrance travel\",\n hiddenFromList: false,\n },\n cutFrame: {\n type: \"number\",\n min: 4,\n max: 24,\n step: 1,\n default: 13,\n description: \"Hard cut frame\",\n hiddenFromList: false,\n },\n revealSoftness: {\n type: \"number\",\n min: 0,\n max: 40,\n step: 1,\n default: 14,\n description: \"Reveal edge softness\",\n hiddenFromList: false,\n },\n compactBlur: {\n type: \"number\",\n min: 0,\n max: 40,\n step: 1,\n default: 12,\n description: \"Blur after the cut\",\n hiddenFromList: false,\n },\n gradientStart: {\n type: \"color\",\n default: \"#f04a14\",\n description: \"Gradient start\",\n },\n gradientEnd: {\n type: \"color\",\n default: \"#f3f1f1\",\n description: \"Gradient end\",\n },\n ghostColor: {\n type: \"color\",\n default: \"#170b0a\",\n description: \"Unrevealed text color\",\n },\n backgroundColor: {\n type: \"color\",\n default: \"#000000\",\n description: \"Background color\",\n },\n fontWeight: {\n type: \"enum\",\n default: \"700\",\n variants: {\n \"400\": {},\n \"500\": {},\n \"600\": {},\n \"700\": {},\n },\n description: \"Font weight\",\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"text\",\"giantFontSize\",\"compactFontSize\",\"anchorOffsetX\",\"giantTravel\",\"settleTravel\",\"cutFrame\",\"revealSoftness\",\"compactBlur\",\"gradientStart\",\"gradientEnd\",\"ghostColor\",\"backgroundColor\",\"fontWeight\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n text: \"Introducing\",\n giantFontSize: 520,\n compactFontSize: 132,\n anchorOffsetX: -16,\n giantTravel: 400,\n settleTravel: 160,\n cutFrame: 13,\n revealSoftness: 14,\n compactBlur: 12,\n gradientStart: \"#f04a14\",\n gradientEnd: \"#f3f1f1\",\n ghostColor: \"#170b0a\",\n backgroundColor: \"#000000\",\n fontWeight: \"700\",\n speed: 1,\n};\n\ntype GradientScaleCutTextElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof GradientScaleCutTextBase>;\n\nconst GradientScaleCutTextInner = forwardRef<\n HTMLDivElement,\n GradientScaleCutTextElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<GradientScaleCutText>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <GradientScaleCutTextBase\n {...(componentProps as unknown as ComponentProps<typeof GradientScaleCutTextBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const GradientScaleCutText = Interactive.withSchema({\n Component: GradientScaleCutTextInner,\n componentName: \"<GradientScaleCutText>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/halftone-print.json b/registry-artifacts/elements/halftone-print.jsonindex 1017128b..b7c5ccd2 100644--- a/registry-artifacts/elements/halftone-print.json+++ b/registry-artifacts/elements/halftone-print.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/transitions",@@ -11,6 +12,7 @@"dimensions": null,"displayName": "Halftone Print","durationInFrames": 90,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "halftone-print","sourceCode": "import { AbsoluteFill, Interactive, Sequence, isHtmlInCanvasSupported, useCurrentFrame, useDelayRender, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport React, { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\nimport { type TransitionPresentation, type TransitionPresentationComponentProps } from \"@remotion/transitions\";\n\nconst QUAD = new Float32Array([-1, -1, 1, -1, -1, 1, 1, 1]);\n\nconst VERTEX_SHADER = `#version 300 es\nin vec2 a_pos;\nout vec2 v_uv;\nvoid main() {\n v_uv = vec2(a_pos.x * 0.5 + 0.5, 0.5 - a_pos.y * 0.5);\n gl_Position = vec4(a_pos, 0.0, 1.0);\n}`;\n\nconst LAYER: React.CSSProperties = {\n position: \"absolute\",\n inset: 0,\n width: \"100%\",\n height: \"100%\",\n};\n\nconst OUTPUT_LAYER: React.CSSProperties = { ...LAYER, pointerEvents: \"none\" };\n\nconst isCanvasTransitionSupported = (): boolean =>\n isHtmlInCanvasSupported();\n\nconst isCanvasFilterSupported = (): boolean => isHtmlInCanvasSupported();\n\ntype SceneShaderFrame<Props> = {\n gl: WebGL2RenderingContext;\n uniform: (name: string) => WebGLUniformLocation | null;\n width: number;\n height: number;\n progress: number;\n passedProps: Props;\n};\n\ntype SceneShaderDrawParams<Props> = {\n from: OffscreenCanvas | null;\n to: OffscreenCanvas | null;\n width: number;\n height: number;\n progress: number;\n passedProps: Props;\n};\n\ntype SceneShaderInstance<Props> = {\n draw: (params: SceneShaderDrawParams<Props>) => void;\n clear: () => void;\n cleanup: () => void;\n};\n\ntype SceneShader<Props> = (\n canvas: OffscreenCanvas,\n) => SceneShaderInstance<Props>;\n\ntype SceneFilterFrame<Props> = {\n gl: WebGL2RenderingContext;\n uniform: (name: string) => WebGLUniformLocation | null;\n width: number;\n height: number;\n frame: number;\n time: number;\n passedProps: Props;\n};\n\ntype SceneFilterDrawParams<Props> = {\n scene: OffscreenCanvas | null;\n width: number;\n height: number;\n frame: number;\n time: number;\n passedProps: Props;\n};\n\ntype SceneFilterInstance<Props> = {\n draw: (params: SceneFilterDrawParams<Props>) => void;\n clear: () => void;\n cleanup: () => void;\n};\n\ntype SceneFilter<Props> = (\n canvas: OffscreenCanvas,\n) => SceneFilterInstance<Props>;\n\nfunction compileShader(\n gl: WebGL2RenderingContext,\n source: string,\n type: GLenum,\n): WebGLShader {\n const shader = gl.createShader(type);\n if (!shader) {\n throw new Error(\"canvas-presentation: failed to create shader\");\n }\n gl.shaderSource(shader, source);\n gl.compileShader(shader);\n if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {\n const log = gl.getShaderInfoLog(shader);\n gl.deleteShader(shader);\n throw new Error(`canvas-presentation: failed to compile shader: ${log}`);\n }\n return shader;\n}\n\nfunction createProgram(\n gl: WebGL2RenderingContext,\n fragment: string,\n): WebGLProgram {\n const program = gl.createProgram();\n if (!program) {\n throw new Error(\"canvas-presentation: failed to create program\");\n }\n const vs = compileShader(gl, VERTEX_SHADER, gl.VERTEX_SHADER);\n const fs = compileShader(gl, fragment, gl.FRAGMENT_SHADER);\n gl.attachShader(program, vs);\n gl.attachShader(program, fs);\n gl.linkProgram(program);\n gl.deleteShader(vs);\n gl.deleteShader(fs);\n if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {\n const log = gl.getProgramInfoLog(program);\n gl.deleteProgram(program);\n throw new Error(`canvas-presentation: failed to link program: ${log}`);\n }\n return program;\n}\n\nfunction createSceneTexture(gl: WebGL2RenderingContext): WebGLTexture {\n const texture = gl.createTexture();\n if (!texture) {\n throw new Error(\"canvas-presentation: failed to create texture\");\n }\n gl.bindTexture(gl.TEXTURE_2D, texture);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);\n gl.texImage2D(\n gl.TEXTURE_2D,\n 0,\n gl.RGBA,\n 1,\n 1,\n 0,\n gl.RGBA,\n gl.UNSIGNED_BYTE,\n new Uint8Array([0, 0, 0, 0]),\n );\n return texture;\n}\n\nfunction createQuadSurface(canvas: OffscreenCanvas, fragment: string) {\n const gl = canvas.getContext(\"webgl2\", { premultipliedAlpha: true });\n if (!gl) {\n throw new Error(\"canvas-presentation: WebGL2 is unavailable\");\n }\n\n const program = createProgram(gl, fragment);\n const vao = gl.createVertexArray();\n gl.bindVertexArray(vao);\n const buffer = gl.createBuffer();\n gl.bindBuffer(gl.ARRAY_BUFFER, buffer);\n gl.bufferData(gl.ARRAY_BUFFER, QUAD, gl.STATIC_DRAW);\n const aPos = gl.getAttribLocation(program, \"a_pos\");\n gl.enableVertexAttribArray(aPos);\n gl.vertexAttribPointer(aPos, 2, gl.FLOAT, false, 0, 0);\n\n const locations = new Map<string, WebGLUniformLocation | null>();\n const uniform = (name: string) => {\n const cached = locations.get(name);\n if (cached !== undefined) {\n return cached;\n }\n const location = gl.getUniformLocation(program, name);\n locations.set(name, location);\n return location;\n };\n\n const clear = () => {\n gl.clearColor(0, 0, 0, 0);\n gl.clear(gl.COLOR_BUFFER_BIT);\n };\n\n const textures: WebGLTexture[] = [];\n const createTexture = () => {\n const texture = createSceneTexture(gl);\n textures.push(texture);\n return texture;\n };\n\n const begin = (width: number, height: number) => {\n gl.viewport(0, 0, width, height);\n clear();\n gl.useProgram(program);\n gl.bindVertexArray(vao);\n };\n\n const bindScene = (\n image: OffscreenCanvas | null,\n texture: WebGLTexture,\n unit: number,\n name: string,\n ) => {\n gl.activeTexture(gl.TEXTURE0 + unit);\n gl.bindTexture(gl.TEXTURE_2D, texture);\n if (image) {\n gl.texImage2D(\n gl.TEXTURE_2D,\n 0,\n gl.RGBA,\n gl.RGBA,\n gl.UNSIGNED_BYTE,\n image,\n );\n }\n gl.uniform1i(uniform(name), unit);\n };\n\n const draw = () => gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);\n\n const cleanup = () => {\n gl.deleteProgram(program);\n for (const texture of textures) {\n gl.deleteTexture(texture);\n }\n gl.deleteBuffer(buffer);\n gl.deleteVertexArray(vao);\n };\n\n return {\n gl,\n uniform,\n clear,\n createTexture,\n begin,\n bindScene,\n draw,\n cleanup,\n };\n}\n\nfunction makeSceneShader<Props extends Record<string, unknown>>(\n fragment: string,\n setUniforms?: (frame: SceneShaderFrame<Props>) => void,\n): SceneShader<Props> {\n return (canvas) => {\n const surface = createQuadSurface(canvas, fragment);\n const fromTexture = surface.createTexture();\n const toTexture = surface.createTexture();\n\n return {\n clear: surface.clear,\n cleanup: surface.cleanup,\n draw: ({ from, to, width, height, progress, passedProps }) => {\n surface.begin(width, height);\n surface.bindScene(from, fromTexture, 0, \"u_from\");\n surface.bindScene(to, toTexture, 1, \"u_to\");\n\n surface.gl.uniform1f(surface.uniform(\"u_progress\"), progress);\n surface.gl.uniform1f(surface.uniform(\"u_aspect\"), width / height);\n setUniforms?.({\n gl: surface.gl,\n uniform: surface.uniform,\n width,\n height,\n progress,\n passedProps,\n });\n\n surface.draw();\n },\n };\n };\n}\n\nfunction makeFilterShader<Props extends Record<string, unknown>>(\n fragment: string,\n setUniforms?: (frame: SceneFilterFrame<Props>) => void,\n): SceneFilter<Props> {\n return (canvas) => {\n const surface = createQuadSurface(canvas, fragment);\n const sceneTexture = surface.createTexture();\n\n return {\n clear: surface.clear,\n cleanup: surface.cleanup,\n draw: ({ scene, width, height, frame, time, passedProps }) => {\n surface.begin(width, height);\n surface.bindScene(scene, sceneTexture, 0, \"u_scene\");\n\n surface.gl.uniform1f(surface.uniform(\"u_frame\"), frame);\n surface.gl.uniform1f(surface.uniform(\"u_time\"), time);\n surface.gl.uniform1f(surface.uniform(\"u_aspect\"), width / height);\n setUniforms?.({\n gl: surface.gl,\n uniform: surface.uniform,\n width,\n height,\n frame,\n time,\n passedProps,\n });\n\n surface.draw();\n },\n };\n };\n}\n\nconst transferred = new WeakMap<HTMLCanvasElement, OffscreenCanvas>();\n\nfunction takeOffscreen(canvas: HTMLCanvasElement): OffscreenCanvas {\n const existing = transferred.get(canvas);\n if (existing) {\n return existing;\n }\n const created = canvas.transferControlToOffscreen();\n transferred.set(canvas, created);\n return created;\n}\n\nfunction makeCanvasComponent<Props extends Record<string, unknown>>(\n shader: SceneShader<Props>,\n): React.FC<TransitionPresentationComponentProps<Props>> {\n return function CanvasScenePresentation({\n children,\n presentationProgress,\n presentationDirection,\n passedProps,\n onElementImage,\n onUnmount,\n bothEnteringAndExiting,\n }) {\n const layoutRef = React.useRef<HTMLCanvasElement | null>(null);\n const outputRef = React.useRef<HTMLCanvasElement | null>(null);\n const captureRef = React.useRef<OffscreenCanvas | null>(null);\n const captureContextRef =\n React.useRef<OffscreenCanvasRenderingContext2D | null>(null);\n const outputSurfaceRef = React.useRef<OffscreenCanvas | null>(null);\n const instanceRef = React.useRef<SceneShaderInstance<Props> | null>(null);\n const passedPropsRef = React.useRef(passedProps);\n passedPropsRef.current = passedProps;\n const onElementImageRef = React.useRef(onElementImage);\n onElementImageRef.current = onElementImage;\n const onUnmountRef = React.useRef(onUnmount);\n onUnmountRef.current = onUnmount;\n\n const { delayRender, continueRender } = useDelayRender();\n const passThrough =\n bothEnteringAndExiting && presentationDirection === \"exiting\";\n\n const drawRef = React.useRef<\n (\n prevImage: OffscreenCanvas | null,\n nextImage: OffscreenCanvas | null,\n progress: number,\n ) => void\n >(() => undefined);\n drawRef.current = (prevImage, nextImage, progress) => {\n const instance = instanceRef.current;\n if (!instance) {\n return;\n }\n const handle = delayRender(\"canvas-presentation: paint\");\n const to = prevImage;\n const from = nextImage;\n const width = from?.width ?? to?.width ?? 0;\n const height = from?.height ?? to?.height ?? 0;\n if (width === 0 || height === 0) {\n instance.clear();\n continueRender(handle);\n return;\n }\n instance.draw({\n from,\n to,\n width,\n height,\n progress: !to ? 0 : !from ? 1 : progress,\n passedProps: passedPropsRef.current,\n });\n continueRender(handle);\n };\n\n const draw = React.useCallback(\n (\n prevImage: OffscreenCanvas | null,\n nextImage: OffscreenCanvas | null,\n progress: number,\n ) => drawRef.current(prevImage, nextImage, progress),\n [],\n );\n\n React.useLayoutEffect(() => {\n if (passThrough) {\n return;\n }\n const layout = layoutRef.current;\n const output = outputRef.current;\n if (!layout || !output) {\n return;\n }\n const capture = takeOffscreen(layout);\n const context = capture.getContext(\"2d\");\n if (!context) {\n throw new Error(\"canvas-presentation: failed to acquire a 2D context\");\n }\n const surface = takeOffscreen(output);\n captureRef.current = capture;\n captureContextRef.current = context;\n outputSurfaceRef.current = surface;\n instanceRef.current = shader(surface);\n\n return () => {\n instanceRef.current?.cleanup();\n instanceRef.current = null;\n captureRef.current = null;\n captureContextRef.current = null;\n outputSurfaceRef.current = null;\n };\n }, [passThrough, shader]);\n\n React.useLayoutEffect(() => {\n if (passThrough) {\n return;\n }\n const layout = layoutRef.current;\n if (!layout) {\n return;\n }\n layout.layoutSubtree = true;\n const handlePaint = () => {\n const scene = layout.firstElementChild;\n const capture = captureRef.current;\n const context = captureContextRef.current;\n if (!scene || !capture || !context) {\n return;\n }\n const elementImage = layout.captureElementImage(scene);\n try {\n context.reset();\n context.drawElementImage(elementImage, 0, 0);\n } finally {\n elementImage.close();\n }\n onElementImageRef.current(capture, draw);\n };\n layout.addEventListener(\"paint\", handlePaint);\n return () => layout.removeEventListener(\"paint\", handlePaint);\n }, [passThrough, draw]);\n\n React.useLayoutEffect(() => {\n if (passThrough) {\n return;\n }\n const layout = layoutRef.current;\n if (!layout) {\n return;\n }\n const observer = new ResizeObserver(([entry]) => {\n const capture = captureRef.current;\n const surface = outputSurfaceRef.current;\n if (!capture || !surface) {\n return;\n }\n const width = entry.devicePixelContentBoxSize[0].inlineSize;\n const height = entry.devicePixelContentBoxSize[0].blockSize;\n capture.width = width;\n capture.height = height;\n surface.width = width;\n surface.height = height;\n layout.requestPaint?.();\n });\n observer.observe(layout, { box: \"device-pixel-content-box\" });\n return () => observer.disconnect();\n }, [passThrough]);\n\n // biome-ignore lint/correctness/useExhaustiveDependencies: presentationProgress is the intentional trigger — a new progress value is what schedules the next paint\n React.useLayoutEffect(() => {\n if (passThrough) {\n return;\n }\n layoutRef.current?.requestPaint?.();\n }, [passThrough, presentationProgress]);\n\n React.useLayoutEffect(() => {\n if (passThrough) {\n return;\n }\n return () => onUnmountRef.current();\n }, [passThrough]);\n\n if (passThrough) {\n return <>{children}</>;\n }\n\n return (\n <AbsoluteFill>\n <canvas ref={layoutRef} style={LAYER}>\n {children}\n </canvas>\n <canvas ref={outputRef} style={OUTPUT_LAYER} />\n </AbsoluteFill>\n );\n };\n}\n\ntype CanvasFilterProps = {\n children: React.ReactNode;\n};\n\nfunction makeFilterComponent<Props extends Record<string, unknown>>(\n shader: SceneFilter<Props>,\n): React.FC<Props & CanvasFilterProps> {\n return function CanvasSceneFilter(props) {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const { delayRender, continueRender } = useDelayRender();\n\n const layoutRef = React.useRef<HTMLCanvasElement | null>(null);\n const outputRef = React.useRef<HTMLCanvasElement | null>(null);\n const captureRef = React.useRef<OffscreenCanvas | null>(null);\n const captureContextRef =\n React.useRef<OffscreenCanvasRenderingContext2D | null>(null);\n const outputSurfaceRef = React.useRef<OffscreenCanvas | null>(null);\n const instanceRef = React.useRef<SceneFilterInstance<Props> | null>(null);\n\n const passedPropsRef = React.useRef(props);\n passedPropsRef.current = props;\n const frameRef = React.useRef(frame);\n frameRef.current = frame;\n const timeRef = React.useRef(frame / fps);\n timeRef.current = frame / fps;\n\n React.useLayoutEffect(() => {\n const layout = layoutRef.current;\n const output = outputRef.current;\n if (!layout || !output) {\n return;\n }\n const capture = takeOffscreen(layout);\n const context = capture.getContext(\"2d\");\n if (!context) {\n throw new Error(\"canvas-presentation: failed to acquire a 2D context\");\n }\n const surface = takeOffscreen(output);\n captureRef.current = capture;\n captureContextRef.current = context;\n outputSurfaceRef.current = surface;\n instanceRef.current = shader(surface);\n\n return () => {\n instanceRef.current?.cleanup();\n instanceRef.current = null;\n captureRef.current = null;\n captureContextRef.current = null;\n outputSurfaceRef.current = null;\n };\n }, [shader]);\n\n React.useLayoutEffect(() => {\n const layout = layoutRef.current;\n if (!layout) {\n return;\n }\n layout.layoutSubtree = true;\n const handlePaint = () => {\n const scene = layout.firstElementChild;\n const capture = captureRef.current;\n const context = captureContextRef.current;\n const instance = instanceRef.current;\n if (!scene || !capture || !context || !instance) {\n return;\n }\n const elementImage = layout.captureElementImage(scene);\n try {\n context.reset();\n context.drawElementImage(elementImage, 0, 0);\n } finally {\n elementImage.close();\n }\n if (capture.width === 0 || capture.height === 0) {\n instance.clear();\n return;\n }\n instance.draw({\n scene: capture,\n width: capture.width,\n height: capture.height,\n frame: frameRef.current,\n time: timeRef.current,\n passedProps: passedPropsRef.current,\n });\n };\n layout.addEventListener(\"paint\", handlePaint);\n return () => layout.removeEventListener(\"paint\", handlePaint);\n }, []);\n\n React.useLayoutEffect(() => {\n const layout = layoutRef.current;\n if (!layout) {\n return;\n }\n const observer = new ResizeObserver(([entry]) => {\n const capture = captureRef.current;\n const surface = outputSurfaceRef.current;\n if (!capture || !surface) {\n return;\n }\n const width = entry.devicePixelContentBoxSize[0].inlineSize;\n const height = entry.devicePixelContentBoxSize[0].blockSize;\n capture.width = width;\n capture.height = height;\n surface.width = width;\n surface.height = height;\n layout.requestPaint?.();\n });\n observer.observe(layout, { box: \"device-pixel-content-box\" });\n return () => observer.disconnect();\n }, []);\n\n React.useLayoutEffect(() => {\n const layout = layoutRef.current;\n if (!layout) {\n return;\n }\n const handle = delayRender(\"canvas-presentation: filter paint\");\n const settle = () => continueRender(handle);\n layout.addEventListener(\"paint\", settle, { once: true });\n layout.requestPaint?.();\n return () => {\n layout.removeEventListener(\"paint\", settle);\n continueRender(handle);\n };\n });\n\n return (\n <AbsoluteFill>\n <canvas ref={layoutRef} style={LAYER}>\n {props.children}\n </canvas>\n <canvas ref={outputRef} style={OUTPUT_LAYER} />\n </AbsoluteFill>\n );\n };\n}\n\ntype CanvasPresentationOptions<Props extends Record<string, unknown>> = {\n shader: SceneShader<Props>;\n fallback: React.FC<TransitionPresentationComponentProps<Props>>;\n};\n\nfunction makeCanvasPresentation<Props extends Record<string, unknown>>({\n shader,\n fallback: Fallback,\n}: CanvasPresentationOptions<Props>): (\n props: Props,\n) => TransitionPresentation<Props> {\n const Canvas = makeCanvasComponent(shader);\n\n const Presentation: React.FC<TransitionPresentationComponentProps<Props>> = (\n props,\n ) =>\n isCanvasTransitionSupported() ? (\n <Canvas {...props} />\n ) : (\n <Fallback {...props} />\n );\n\n return (props) => ({ component: Presentation, props });\n}\n\ntype CanvasFilterOptions<Props extends Record<string, unknown>> = {\n shader: SceneFilter<Props>;\n fallback: React.FC<Props & CanvasFilterProps>;\n};\n\nfunction makeCanvasFilter<Props extends Record<string, unknown>>({\n shader,\n fallback: Fallback,\n}: CanvasFilterOptions<Props>): React.FC<Props & CanvasFilterProps> {\n const Canvas = makeFilterComponent(shader);\n\n return function CanvasFilter(props) {\n return isCanvasFilterSupported() ? (\n <Canvas {...props} />\n ) : (\n <Fallback {...props} />\n );\n };\n}\n\ntype HalftonePrintProps = {\n dotSize?: number;\n angle?: number;\n misregistration?: number;\n paperTint?: string;\n};\n\nconst DEFAULTS = {\n dotSize: 10,\n angle: 0,\n misregistration: 1.2,\n paperTint: \"#f4efe4\",\n};\n\ntype NormalizedProps = {\n cell: number;\n angle: number;\n shift: number;\n paper: string;\n};\n\nconst FRAGMENT_SHADER = `#version 300 es\nprecision highp float;\n\nuniform sampler2D u_scene;\nuniform float u_aspect;\nuniform float u_cell;\nuniform float u_angle;\nuniform float u_shift;\nuniform vec3 u_paper;\n\nin vec2 v_uv;\nout vec4 outColor;\n\nconst vec3 CYAN_ABSORB = vec3(0.92, 0.12, 0.02);\nconst vec3 MAGENTA_ABSORB = vec3(0.10, 0.88, 0.06);\nconst vec3 YELLOW_ABSORB = vec3(0.03, 0.10, 0.90);\n\nvec2 toSquare(vec2 uv) {\n return vec2(uv.x * u_aspect, uv.y);\n}\n\nvec2 fromSquare(vec2 p) {\n return vec2(p.x / u_aspect, p.y);\n}\n\nfloat screenInk(float angle, vec2 drift, vec3 pick) {\n vec2 p = toSquare(v_uv);\n float s = sin(angle);\n float c = cos(angle);\n vec2 r = vec2(p.x * c - p.y * s, p.x * s + p.y * c);\n\n vec2 center = (floor(r / u_cell) + 0.5) * u_cell;\n vec2 unrotated =\n vec2(center.x * c + center.y * s, -center.x * s + center.y * c);\n\n vec4 texel = texture(u_scene, fromSquare(unrotated + drift));\n vec3 straight = texel.rgb / max(texel.a, 0.004);\n float ink = clamp(1.0 - dot(straight, pick), 0.0, 1.0) * texel.a;\n\n float radius = sqrt(ink) * u_cell * 0.72;\n float aa = u_cell * 0.045;\n float coverage = 1.0 - smoothstep(radius - aa, radius + aa, length(r - center));\n return coverage * step(0.002, ink);\n}\n\nvoid main() {\n vec4 source = texture(u_scene, v_uv);\n\n float cyan =\n screenInk(u_angle + 0.2618, u_shift * vec2(1.0, 0.0), vec3(1.0, 0.0, 0.0));\n float magenta =\n screenInk(u_angle + 1.3090, u_shift * vec2(-0.5, 0.866), vec3(0.0, 1.0, 0.0));\n float yellow =\n screenInk(u_angle, u_shift * vec2(-0.5, -0.866), vec3(0.0, 0.0, 1.0));\n\n vec3 color = u_paper;\n color *= 1.0 - cyan * CYAN_ABSORB;\n color *= 1.0 - magenta * MAGENTA_ABSORB;\n color *= 1.0 - yellow * YELLOW_ABSORB;\n\n outColor = vec4(color * source.a, source.a);\n}`;\n\nfunction toRgb(hex: string): [number, number, number] {\n const value = hex.replace(\"#\", \"\");\n const full =\n value.length === 3\n ? value\n .split(\"\")\n .map((c) => c + c)\n .join(\"\")\n : value;\n const int = Number.parseInt(full, 16);\n if (Number.isNaN(int)) return [1, 1, 1];\n return [\n ((int >> 16) & 255) / 255,\n ((int >> 8) & 255) / 255,\n (int & 255) / 255,\n ];\n}\n\nconst shader = makeFilterShader<NormalizedProps>(\n FRAGMENT_SHADER,\n ({ gl, uniform, passedProps }) => {\n const { cell, angle, shift, paper } = passedProps;\n gl.uniform1f(uniform(\"u_cell\"), cell);\n gl.uniform1f(uniform(\"u_angle\"), angle);\n gl.uniform1f(uniform(\"u_shift\"), shift);\n gl.uniform3fv(uniform(\"u_paper\"), toRgb(paper));\n },\n);\n\nconst HalftonePrintFallback: React.FC<NormalizedProps & CanvasFilterProps> = ({\n children,\n}) => <AbsoluteFill>{children}</AbsoluteFill>;\n\nconst HalftonePrintCanvas = makeCanvasFilter<NormalizedProps>({\n shader,\n fallback: HalftonePrintFallback,\n});\n\nconst HalftonePrintBase: React.FC<\n HalftonePrintProps & CanvasFilterProps\n> = ({\n dotSize = DEFAULTS.dotSize,\n angle = DEFAULTS.angle,\n misregistration = DEFAULTS.misregistration,\n paperTint = DEFAULTS.paperTint,\n children,\n}) => {\n const { height } = useVideoConfig();\n\n return (\n <HalftonePrintCanvas\n cell={Math.max(dotSize, 1) / height}\n angle={(angle * Math.PI) / 180}\n shift={misregistration / height}\n paper={paperTint}\n >\n {children}\n </HalftonePrintCanvas>\n );\n};\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n dotSize: {\n type: \"number\",\n min: 4,\n max: 32,\n step: 1,\n default: 10,\n description: \"Dot size\",\n hiddenFromList: false,\n },\n angle: {\n type: \"number\",\n min: 0,\n max: 90,\n step: 1,\n default: 0,\n description: \"Screen angle\",\n hiddenFromList: false,\n },\n misregistration: {\n type: \"number\",\n min: 0,\n max: 6,\n step: 0.2,\n default: 1.2,\n description: \"Misregistration\",\n hiddenFromList: false,\n },\n paperTint: {\n type: \"color\",\n default: \"#f4efe4\",\n description: \"Paper\",\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"dotSize\",\"angle\",\"misregistration\",\"paperTint\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n dotSize: 10,\n angle: 0,\n misregistration: 1.2,\n paperTint: \"#f4efe4\",\n speed: 1,\n};\n\ntype HalftonePrintElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof HalftonePrintBase>;\n\nconst HalftonePrintInner = forwardRef<\n HTMLDivElement,\n HalftonePrintElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<HalftonePrint>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <HalftonePrintBase\n {...(componentProps as unknown as ComponentProps<typeof HalftonePrintBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const HalftonePrint = Interactive.withSchema({\n Component: HalftonePrintInner,\n componentName: \"<HalftonePrint>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/hologram.json b/registry-artifacts/elements/hologram.jsonindex dd26c0e7..cf02c04a 100644--- a/registry-artifacts/elements/hologram.json+++ b/registry-artifacts/elements/hologram.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/transitions",@@ -11,6 +12,7 @@"dimensions": null,"displayName": "Hologram","durationInFrames": 90,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "hologram","sourceCode": "import { AbsoluteFill, Interactive, Sequence, isHtmlInCanvasSupported, useCurrentFrame, useDelayRender, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport React, { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\nimport { type TransitionPresentation, type TransitionPresentationComponentProps } from \"@remotion/transitions\";\n\nconst QUAD = new Float32Array([-1, -1, 1, -1, -1, 1, 1, 1]);\n\nconst VERTEX_SHADER = `#version 300 es\nin vec2 a_pos;\nout vec2 v_uv;\nvoid main() {\n v_uv = vec2(a_pos.x * 0.5 + 0.5, 0.5 - a_pos.y * 0.5);\n gl_Position = vec4(a_pos, 0.0, 1.0);\n}`;\n\nconst LAYER: React.CSSProperties = {\n position: \"absolute\",\n inset: 0,\n width: \"100%\",\n height: \"100%\",\n};\n\nconst OUTPUT_LAYER: React.CSSProperties = { ...LAYER, pointerEvents: \"none\" };\n\nconst isCanvasTransitionSupported = (): boolean =>\n isHtmlInCanvasSupported();\n\nconst isCanvasFilterSupported = (): boolean => isHtmlInCanvasSupported();\n\ntype SceneShaderFrame<Props> = {\n gl: WebGL2RenderingContext;\n uniform: (name: string) => WebGLUniformLocation | null;\n width: number;\n height: number;\n progress: number;\n passedProps: Props;\n};\n\ntype SceneShaderDrawParams<Props> = {\n from: OffscreenCanvas | null;\n to: OffscreenCanvas | null;\n width: number;\n height: number;\n progress: number;\n passedProps: Props;\n};\n\ntype SceneShaderInstance<Props> = {\n draw: (params: SceneShaderDrawParams<Props>) => void;\n clear: () => void;\n cleanup: () => void;\n};\n\ntype SceneShader<Props> = (\n canvas: OffscreenCanvas,\n) => SceneShaderInstance<Props>;\n\ntype SceneFilterFrame<Props> = {\n gl: WebGL2RenderingContext;\n uniform: (name: string) => WebGLUniformLocation | null;\n width: number;\n height: number;\n frame: number;\n time: number;\n passedProps: Props;\n};\n\ntype SceneFilterDrawParams<Props> = {\n scene: OffscreenCanvas | null;\n width: number;\n height: number;\n frame: number;\n time: number;\n passedProps: Props;\n};\n\ntype SceneFilterInstance<Props> = {\n draw: (params: SceneFilterDrawParams<Props>) => void;\n clear: () => void;\n cleanup: () => void;\n};\n\ntype SceneFilter<Props> = (\n canvas: OffscreenCanvas,\n) => SceneFilterInstance<Props>;\n\nfunction compileShader(\n gl: WebGL2RenderingContext,\n source: string,\n type: GLenum,\n): WebGLShader {\n const shader = gl.createShader(type);\n if (!shader) {\n throw new Error(\"canvas-presentation: failed to create shader\");\n }\n gl.shaderSource(shader, source);\n gl.compileShader(shader);\n if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {\n const log = gl.getShaderInfoLog(shader);\n gl.deleteShader(shader);\n throw new Error(`canvas-presentation: failed to compile shader: ${log}`);\n }\n return shader;\n}\n\nfunction createProgram(\n gl: WebGL2RenderingContext,\n fragment: string,\n): WebGLProgram {\n const program = gl.createProgram();\n if (!program) {\n throw new Error(\"canvas-presentation: failed to create program\");\n }\n const vs = compileShader(gl, VERTEX_SHADER, gl.VERTEX_SHADER);\n const fs = compileShader(gl, fragment, gl.FRAGMENT_SHADER);\n gl.attachShader(program, vs);\n gl.attachShader(program, fs);\n gl.linkProgram(program);\n gl.deleteShader(vs);\n gl.deleteShader(fs);\n if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {\n const log = gl.getProgramInfoLog(program);\n gl.deleteProgram(program);\n throw new Error(`canvas-presentation: failed to link program: ${log}`);\n }\n return program;\n}\n\nfunction createSceneTexture(gl: WebGL2RenderingContext): WebGLTexture {\n const texture = gl.createTexture();\n if (!texture) {\n throw new Error(\"canvas-presentation: failed to create texture\");\n }\n gl.bindTexture(gl.TEXTURE_2D, texture);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);\n gl.texImage2D(\n gl.TEXTURE_2D,\n 0,\n gl.RGBA,\n 1,\n 1,\n 0,\n gl.RGBA,\n gl.UNSIGNED_BYTE,\n new Uint8Array([0, 0, 0, 0]),\n );\n return texture;\n}\n\nfunction createQuadSurface(canvas: OffscreenCanvas, fragment: string) {\n const gl = canvas.getContext(\"webgl2\", { premultipliedAlpha: true });\n if (!gl) {\n throw new Error(\"canvas-presentation: WebGL2 is unavailable\");\n }\n\n const program = createProgram(gl, fragment);\n const vao = gl.createVertexArray();\n gl.bindVertexArray(vao);\n const buffer = gl.createBuffer();\n gl.bindBuffer(gl.ARRAY_BUFFER, buffer);\n gl.bufferData(gl.ARRAY_BUFFER, QUAD, gl.STATIC_DRAW);\n const aPos = gl.getAttribLocation(program, \"a_pos\");\n gl.enableVertexAttribArray(aPos);\n gl.vertexAttribPointer(aPos, 2, gl.FLOAT, false, 0, 0);\n\n const locations = new Map<string, WebGLUniformLocation | null>();\n const uniform = (name: string) => {\n const cached = locations.get(name);\n if (cached !== undefined) {\n return cached;\n }\n const location = gl.getUniformLocation(program, name);\n locations.set(name, location);\n return location;\n };\n\n const clear = () => {\n gl.clearColor(0, 0, 0, 0);\n gl.clear(gl.COLOR_BUFFER_BIT);\n };\n\n const textures: WebGLTexture[] = [];\n const createTexture = () => {\n const texture = createSceneTexture(gl);\n textures.push(texture);\n return texture;\n };\n\n const begin = (width: number, height: number) => {\n gl.viewport(0, 0, width, height);\n clear();\n gl.useProgram(program);\n gl.bindVertexArray(vao);\n };\n\n const bindScene = (\n image: OffscreenCanvas | null,\n texture: WebGLTexture,\n unit: number,\n name: string,\n ) => {\n gl.activeTexture(gl.TEXTURE0 + unit);\n gl.bindTexture(gl.TEXTURE_2D, texture);\n if (image) {\n gl.texImage2D(\n gl.TEXTURE_2D,\n 0,\n gl.RGBA,\n gl.RGBA,\n gl.UNSIGNED_BYTE,\n image,\n );\n }\n gl.uniform1i(uniform(name), unit);\n };\n\n const draw = () => gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);\n\n const cleanup = () => {\n gl.deleteProgram(program);\n for (const texture of textures) {\n gl.deleteTexture(texture);\n }\n gl.deleteBuffer(buffer);\n gl.deleteVertexArray(vao);\n };\n\n return {\n gl,\n uniform,\n clear,\n createTexture,\n begin,\n bindScene,\n draw,\n cleanup,\n };\n}\n\nfunction makeSceneShader<Props extends Record<string, unknown>>(\n fragment: string,\n setUniforms?: (frame: SceneShaderFrame<Props>) => void,\n): SceneShader<Props> {\n return (canvas) => {\n const surface = createQuadSurface(canvas, fragment);\n const fromTexture = surface.createTexture();\n const toTexture = surface.createTexture();\n\n return {\n clear: surface.clear,\n cleanup: surface.cleanup,\n draw: ({ from, to, width, height, progress, passedProps }) => {\n surface.begin(width, height);\n surface.bindScene(from, fromTexture, 0, \"u_from\");\n surface.bindScene(to, toTexture, 1, \"u_to\");\n\n surface.gl.uniform1f(surface.uniform(\"u_progress\"), progress);\n surface.gl.uniform1f(surface.uniform(\"u_aspect\"), width / height);\n setUniforms?.({\n gl: surface.gl,\n uniform: surface.uniform,\n width,\n height,\n progress,\n passedProps,\n });\n\n surface.draw();\n },\n };\n };\n}\n\nfunction makeFilterShader<Props extends Record<string, unknown>>(\n fragment: string,\n setUniforms?: (frame: SceneFilterFrame<Props>) => void,\n): SceneFilter<Props> {\n return (canvas) => {\n const surface = createQuadSurface(canvas, fragment);\n const sceneTexture = surface.createTexture();\n\n return {\n clear: surface.clear,\n cleanup: surface.cleanup,\n draw: ({ scene, width, height, frame, time, passedProps }) => {\n surface.begin(width, height);\n surface.bindScene(scene, sceneTexture, 0, \"u_scene\");\n\n surface.gl.uniform1f(surface.uniform(\"u_frame\"), frame);\n surface.gl.uniform1f(surface.uniform(\"u_time\"), time);\n surface.gl.uniform1f(surface.uniform(\"u_aspect\"), width / height);\n setUniforms?.({\n gl: surface.gl,\n uniform: surface.uniform,\n width,\n height,\n frame,\n time,\n passedProps,\n });\n\n surface.draw();\n },\n };\n };\n}\n\nconst transferred = new WeakMap<HTMLCanvasElement, OffscreenCanvas>();\n\nfunction takeOffscreen(canvas: HTMLCanvasElement): OffscreenCanvas {\n const existing = transferred.get(canvas);\n if (existing) {\n return existing;\n }\n const created = canvas.transferControlToOffscreen();\n transferred.set(canvas, created);\n return created;\n}\n\nfunction makeCanvasComponent<Props extends Record<string, unknown>>(\n shader: SceneShader<Props>,\n): React.FC<TransitionPresentationComponentProps<Props>> {\n return function CanvasScenePresentation({\n children,\n presentationProgress,\n presentationDirection,\n passedProps,\n onElementImage,\n onUnmount,\n bothEnteringAndExiting,\n }) {\n const layoutRef = React.useRef<HTMLCanvasElement | null>(null);\n const outputRef = React.useRef<HTMLCanvasElement | null>(null);\n const captureRef = React.useRef<OffscreenCanvas | null>(null);\n const captureContextRef =\n React.useRef<OffscreenCanvasRenderingContext2D | null>(null);\n const outputSurfaceRef = React.useRef<OffscreenCanvas | null>(null);\n const instanceRef = React.useRef<SceneShaderInstance<Props> | null>(null);\n const passedPropsRef = React.useRef(passedProps);\n passedPropsRef.current = passedProps;\n const onElementImageRef = React.useRef(onElementImage);\n onElementImageRef.current = onElementImage;\n const onUnmountRef = React.useRef(onUnmount);\n onUnmountRef.current = onUnmount;\n\n const { delayRender, continueRender } = useDelayRender();\n const passThrough =\n bothEnteringAndExiting && presentationDirection === \"exiting\";\n\n const drawRef = React.useRef<\n (\n prevImage: OffscreenCanvas | null,\n nextImage: OffscreenCanvas | null,\n progress: number,\n ) => void\n >(() => undefined);\n drawRef.current = (prevImage, nextImage, progress) => {\n const instance = instanceRef.current;\n if (!instance) {\n return;\n }\n const handle = delayRender(\"canvas-presentation: paint\");\n const to = prevImage;\n const from = nextImage;\n const width = from?.width ?? to?.width ?? 0;\n const height = from?.height ?? to?.height ?? 0;\n if (width === 0 || height === 0) {\n instance.clear();\n continueRender(handle);\n return;\n }\n instance.draw({\n from,\n to,\n width,\n height,\n progress: !to ? 0 : !from ? 1 : progress,\n passedProps: passedPropsRef.current,\n });\n continueRender(handle);\n };\n\n const draw = React.useCallback(\n (\n prevImage: OffscreenCanvas | null,\n nextImage: OffscreenCanvas | null,\n progress: number,\n ) => drawRef.current(prevImage, nextImage, progress),\n [],\n );\n\n React.useLayoutEffect(() => {\n if (passThrough) {\n return;\n }\n const layout = layoutRef.current;\n const output = outputRef.current;\n if (!layout || !output) {\n return;\n }\n const capture = takeOffscreen(layout);\n const context = capture.getContext(\"2d\");\n if (!context) {\n throw new Error(\"canvas-presentation: failed to acquire a 2D context\");\n }\n const surface = takeOffscreen(output);\n captureRef.current = capture;\n captureContextRef.current = context;\n outputSurfaceRef.current = surface;\n instanceRef.current = shader(surface);\n\n return () => {\n instanceRef.current?.cleanup();\n instanceRef.current = null;\n captureRef.current = null;\n captureContextRef.current = null;\n outputSurfaceRef.current = null;\n };\n }, [passThrough, shader]);\n\n React.useLayoutEffect(() => {\n if (passThrough) {\n return;\n }\n const layout = layoutRef.current;\n if (!layout) {\n return;\n }\n layout.layoutSubtree = true;\n const handlePaint = () => {\n const scene = layout.firstElementChild;\n const capture = captureRef.current;\n const context = captureContextRef.current;\n if (!scene || !capture || !context) {\n return;\n }\n const elementImage = layout.captureElementImage(scene);\n try {\n context.reset();\n context.drawElementImage(elementImage, 0, 0);\n } finally {\n elementImage.close();\n }\n onElementImageRef.current(capture, draw);\n };\n layout.addEventListener(\"paint\", handlePaint);\n return () => layout.removeEventListener(\"paint\", handlePaint);\n }, [passThrough, draw]);\n\n React.useLayoutEffect(() => {\n if (passThrough) {\n return;\n }\n const layout = layoutRef.current;\n if (!layout) {\n return;\n }\n const observer = new ResizeObserver(([entry]) => {\n const capture = captureRef.current;\n const surface = outputSurfaceRef.current;\n if (!capture || !surface) {\n return;\n }\n const width = entry.devicePixelContentBoxSize[0].inlineSize;\n const height = entry.devicePixelContentBoxSize[0].blockSize;\n capture.width = width;\n capture.height = height;\n surface.width = width;\n surface.height = height;\n layout.requestPaint?.();\n });\n observer.observe(layout, { box: \"device-pixel-content-box\" });\n return () => observer.disconnect();\n }, [passThrough]);\n\n // biome-ignore lint/correctness/useExhaustiveDependencies: presentationProgress is the intentional trigger — a new progress value is what schedules the next paint\n React.useLayoutEffect(() => {\n if (passThrough) {\n return;\n }\n layoutRef.current?.requestPaint?.();\n }, [passThrough, presentationProgress]);\n\n React.useLayoutEffect(() => {\n if (passThrough) {\n return;\n }\n return () => onUnmountRef.current();\n }, [passThrough]);\n\n if (passThrough) {\n return <>{children}</>;\n }\n\n return (\n <AbsoluteFill>\n <canvas ref={layoutRef} style={LAYER}>\n {children}\n </canvas>\n <canvas ref={outputRef} style={OUTPUT_LAYER} />\n </AbsoluteFill>\n );\n };\n}\n\ntype CanvasFilterProps = {\n children: React.ReactNode;\n};\n\nfunction makeFilterComponent<Props extends Record<string, unknown>>(\n shader: SceneFilter<Props>,\n): React.FC<Props & CanvasFilterProps> {\n return function CanvasSceneFilter(props) {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const { delayRender, continueRender } = useDelayRender();\n\n const layoutRef = React.useRef<HTMLCanvasElement | null>(null);\n const outputRef = React.useRef<HTMLCanvasElement | null>(null);\n const captureRef = React.useRef<OffscreenCanvas | null>(null);\n const captureContextRef =\n React.useRef<OffscreenCanvasRenderingContext2D | null>(null);\n const outputSurfaceRef = React.useRef<OffscreenCanvas | null>(null);\n const instanceRef = React.useRef<SceneFilterInstance<Props> | null>(null);\n\n const passedPropsRef = React.useRef(props);\n passedPropsRef.current = props;\n const frameRef = React.useRef(frame);\n frameRef.current = frame;\n const timeRef = React.useRef(frame / fps);\n timeRef.current = frame / fps;\n\n React.useLayoutEffect(() => {\n const layout = layoutRef.current;\n const output = outputRef.current;\n if (!layout || !output) {\n return;\n }\n const capture = takeOffscreen(layout);\n const context = capture.getContext(\"2d\");\n if (!context) {\n throw new Error(\"canvas-presentation: failed to acquire a 2D context\");\n }\n const surface = takeOffscreen(output);\n captureRef.current = capture;\n captureContextRef.current = context;\n outputSurfaceRef.current = surface;\n instanceRef.current = shader(surface);\n\n return () => {\n instanceRef.current?.cleanup();\n instanceRef.current = null;\n captureRef.current = null;\n captureContextRef.current = null;\n outputSurfaceRef.current = null;\n };\n }, [shader]);\n\n React.useLayoutEffect(() => {\n const layout = layoutRef.current;\n if (!layout) {\n return;\n }\n layout.layoutSubtree = true;\n const handlePaint = () => {\n const scene = layout.firstElementChild;\n const capture = captureRef.current;\n const context = captureContextRef.current;\n const instance = instanceRef.current;\n if (!scene || !capture || !context || !instance) {\n return;\n }\n const elementImage = layout.captureElementImage(scene);\n try {\n context.reset();\n context.drawElementImage(elementImage, 0, 0);\n } finally {\n elementImage.close();\n }\n if (capture.width === 0 || capture.height === 0) {\n instance.clear();\n return;\n }\n instance.draw({\n scene: capture,\n width: capture.width,\n height: capture.height,\n frame: frameRef.current,\n time: timeRef.current,\n passedProps: passedPropsRef.current,\n });\n };\n layout.addEventListener(\"paint\", handlePaint);\n return () => layout.removeEventListener(\"paint\", handlePaint);\n }, []);\n\n React.useLayoutEffect(() => {\n const layout = layoutRef.current;\n if (!layout) {\n return;\n }\n const observer = new ResizeObserver(([entry]) => {\n const capture = captureRef.current;\n const surface = outputSurfaceRef.current;\n if (!capture || !surface) {\n return;\n }\n const width = entry.devicePixelContentBoxSize[0].inlineSize;\n const height = entry.devicePixelContentBoxSize[0].blockSize;\n capture.width = width;\n capture.height = height;\n surface.width = width;\n surface.height = height;\n layout.requestPaint?.();\n });\n observer.observe(layout, { box: \"device-pixel-content-box\" });\n return () => observer.disconnect();\n }, []);\n\n React.useLayoutEffect(() => {\n const layout = layoutRef.current;\n if (!layout) {\n return;\n }\n const handle = delayRender(\"canvas-presentation: filter paint\");\n const settle = () => continueRender(handle);\n layout.addEventListener(\"paint\", settle, { once: true });\n layout.requestPaint?.();\n return () => {\n layout.removeEventListener(\"paint\", settle);\n continueRender(handle);\n };\n });\n\n return (\n <AbsoluteFill>\n <canvas ref={layoutRef} style={LAYER}>\n {props.children}\n </canvas>\n <canvas ref={outputRef} style={OUTPUT_LAYER} />\n </AbsoluteFill>\n );\n };\n}\n\ntype CanvasPresentationOptions<Props extends Record<string, unknown>> = {\n shader: SceneShader<Props>;\n fallback: React.FC<TransitionPresentationComponentProps<Props>>;\n};\n\nfunction makeCanvasPresentation<Props extends Record<string, unknown>>({\n shader,\n fallback: Fallback,\n}: CanvasPresentationOptions<Props>): (\n props: Props,\n) => TransitionPresentation<Props> {\n const Canvas = makeCanvasComponent(shader);\n\n const Presentation: React.FC<TransitionPresentationComponentProps<Props>> = (\n props,\n ) =>\n isCanvasTransitionSupported() ? (\n <Canvas {...props} />\n ) : (\n <Fallback {...props} />\n );\n\n return (props) => ({ component: Presentation, props });\n}\n\ntype CanvasFilterOptions<Props extends Record<string, unknown>> = {\n shader: SceneFilter<Props>;\n fallback: React.FC<Props & CanvasFilterProps>;\n};\n\nfunction makeCanvasFilter<Props extends Record<string, unknown>>({\n shader,\n fallback: Fallback,\n}: CanvasFilterOptions<Props>): React.FC<Props & CanvasFilterProps> {\n const Canvas = makeFilterComponent(shader);\n\n return function CanvasFilter(props) {\n return isCanvasFilterSupported() ? (\n <Canvas {...props} />\n ) : (\n <Fallback {...props} />\n );\n };\n}\n\ntype HologramProps = {\n tint?: string;\n glow?: number;\n ghost?: number;\n flicker?: number;\n intensity?: number;\n};\n\nconst DEFAULTS = {\n tint: \"#63e8ff\",\n glow: 1,\n ghost: 1,\n flicker: 1,\n intensity: 1,\n};\n\nconst FRAGMENT_SHADER = `#version 300 es\nprecision highp float;\n\nuniform sampler2D u_scene;\nuniform float u_aspect;\nuniform float u_frame;\nuniform vec3 u_tint;\nuniform float u_glow;\nuniform float u_ghost;\nuniform float u_flicker;\nuniform float u_intensity;\n\nin vec2 v_uv;\nout vec4 outColor;\n\nconst float PI = 3.141592653589793;\nconst float TAU = 6.28318530718;\nconst float GOLDEN = 2.39996323;\nconst int HALO_TAPS = 8;\nconst vec3 LUMA = vec3(0.299, 0.587, 0.114);\n\nfloat hash(vec2 p) {\n return fract(sin(dot(p, vec2(12.9898, 78.233))) * 43758.5453123);\n}\n\nfloat lumaAt(vec2 uv) {\n return dot(texture(u_scene, uv).rgb, LUMA);\n}\n\nvoid main() {\n vec4 src = texture(u_scene, v_uv);\n float amount = clamp(u_intensity, 0.0, 1.0);\n\n if (!(amount > 0.001)) {\n outColor = src;\n return;\n }\n\n float row = floor(v_uv.y * 300.0);\n float clock = floor(u_frame);\n float slip =\n (hash(vec2(row, clock)) - 0.5) * u_ghost * 0.006 * step(0.55, hash(vec2(row, clock + 3.0)));\n vec2 base = vec2(v_uv.x + slip / u_aspect, v_uv.y);\n\n vec4 held = texture(u_scene, base);\n float lit = dot(held.rgb, LUMA);\n\n vec2 apart = vec2(u_ghost * 0.0045 / u_aspect, u_ghost * 0.0035);\n vec3 twin = texture(u_scene, base + apart).rgb;\n\n float step2 = 0.0022;\n float gx =\n lumaAt(base + vec2(step2 / u_aspect, 0.0)) -\n lumaAt(base - vec2(step2 / u_aspect, 0.0));\n float gy = lumaAt(base + vec2(0.0, step2)) - lumaAt(base - vec2(0.0, step2));\n float rim = clamp(length(vec2(gx, gy)) * 7.0, 0.0, 1.0);\n\n vec3 halo = vec3(0.0);\n for (int i = 0; i < HALO_TAPS; i++) {\n float angle = float(i) * GOLDEN;\n float reach = sqrt((float(i) + 0.5) / float(HALO_TAPS)) * u_glow * 0.022;\n vec2 at = base + vec2(cos(angle) * reach / u_aspect, sin(angle) * reach);\n halo += max(texture(u_scene, at).rgb - 0.34, vec3(0.0));\n }\n halo /= float(HALO_TAPS);\n\n vec3 core = u_tint * (0.12 + lit * 1.55);\n core = mix(core, held.rgb * u_tint * 1.9, 0.12);\n core += u_tint * rim * 1.9 * u_glow;\n core += halo * u_tint * 2.4 * u_glow;\n core += twin * u_tint * 0.5 * u_ghost;\n\n float interlace = mod(row, 2.0) < 1.0 ? 1.0 : 0.58;\n core *= interlace;\n\n float blink =\n 1.0 -\n u_flicker *\n (0.04 + 0.05 * hash(vec2(clock, 7.0))) *\n (0.5 + 0.5 * sin(u_frame * TAU / 15.0));\n core *= blink;\n\n float presence = clamp(lit * 1.5 + rim * 0.8 + 0.03, 0.0, 1.0);\n vec3 painted = clamp(u_tint * 0.035 + core * presence, 0.0, 1.0);\n\n outColor = vec4(mix(src.rgb, painted, amount), src.a);\n}`;\n\nfunction toRgb(hex: string): [number, number, number] {\n const value = hex.replace(\"#\", \"\");\n const full =\n value.length === 3\n ? value\n .split(\"\")\n .map((c) => c + c)\n .join(\"\")\n : value;\n const int = Number.parseInt(full, 16);\n if (Number.isNaN(int)) return [1, 1, 1];\n return [\n ((int >> 16) & 255) / 255,\n ((int >> 8) & 255) / 255,\n (int & 255) / 255,\n ];\n}\n\nconst shader = makeFilterShader<HologramProps>(\n FRAGMENT_SHADER,\n ({ gl, uniform, passedProps }) => {\n const {\n tint = DEFAULTS.tint,\n glow = DEFAULTS.glow,\n ghost = DEFAULTS.ghost,\n flicker = DEFAULTS.flicker,\n intensity = DEFAULTS.intensity,\n } = passedProps;\n gl.uniform3fv(uniform(\"u_tint\"), toRgb(tint));\n gl.uniform1f(uniform(\"u_glow\"), glow);\n gl.uniform1f(uniform(\"u_ghost\"), ghost);\n gl.uniform1f(uniform(\"u_flicker\"), flicker);\n gl.uniform1f(uniform(\"u_intensity\"), intensity);\n },\n);\n\nconst HologramFallback: React.FC<HologramProps & CanvasFilterProps> = ({\n children,\n tint = DEFAULTS.tint,\n intensity = DEFAULTS.intensity,\n}) => (\n <AbsoluteFill>\n <AbsoluteFill style={{ filter: `saturate(${1 - 0.5 * intensity})` }}>\n {children}\n </AbsoluteFill>\n <AbsoluteFill\n style={{\n background: tint,\n mixBlendMode: \"color\",\n opacity: 0.75 * intensity,\n }}\n />\n <AbsoluteFill\n style={{\n background:\n \"repeating-linear-gradient(to bottom, rgba(0, 0, 0, 0.32) 0px, rgba(0, 0, 0, 0.32) 2px, transparent 2px, transparent 4px)\",\n opacity: intensity,\n }}\n />\n </AbsoluteFill>\n);\n\nconst HologramBase = makeCanvasFilter<HologramProps>({\n shader,\n fallback: HologramFallback,\n});\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n tint: {\n type: \"color\",\n default: \"#63e8ff\",\n description: \"Tint\",\n },\n glow: {\n type: \"number\",\n min: 0,\n max: 3,\n step: 0.1,\n default: 1,\n description: \"Glow\",\n hiddenFromList: false,\n },\n ghost: {\n type: \"number\",\n min: 0,\n max: 3,\n step: 0.1,\n default: 1,\n description: \"Ghost\",\n hiddenFromList: false,\n },\n flicker: {\n type: \"number\",\n min: 0,\n max: 3,\n step: 0.1,\n default: 1,\n description: \"Flicker\",\n hiddenFromList: false,\n },\n intensity: {\n type: \"number\",\n min: 0,\n max: 1,\n step: 0.05,\n default: 1,\n description: \"Intensity\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"tint\",\"glow\",\"ghost\",\"flicker\",\"intensity\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n tint: \"#63e8ff\",\n glow: 1,\n ghost: 1,\n flicker: 1,\n intensity: 1,\n speed: 1,\n};\n\ntype HologramElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof HologramBase>;\n\nconst HologramInner = forwardRef<\n HTMLDivElement,\n HologramElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<Hologram>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <HologramBase\n {...(componentProps as unknown as ComponentProps<typeof HologramBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const Hologram = Interactive.withSchema({\n Component: HologramInner,\n componentName: \"<Hologram>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-activity.json b/registry-artifacts/elements/icon-activity.jsonindex 2fac8ca4..9345b269 100644--- a/registry-artifacts/elements/icon-activity.json+++ b/registry-artifacts/elements/icon-activity.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Activity","durationInFrames": 90,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-activity","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst PULSE_PATH =\n \"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2\";\n\nconst TIMINGS = {\n drawDurationInFrames: 14,\n actionDelayInFrames: 2,\n actionDurationInFrames: 45,\n loop: true,\n} as const;\n\nfunction ActivityIconBase({\n animation = \"both\",\n loop = true,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress, actionFrame } =\n useIconAnimation({ animation, loop, speed }, TIMINGS);\n\n const acting = animation !== \"draw\" && actionFrame >= 0;\n\n const beat = acting\n ? interpolate(\n actionProgress,\n [0, 0.1, 0.18, 0.28, 0.38, 1],\n [1, 1.07, 1, 1.05, 1, 1],\n {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n },\n )\n : 1;\n\n const pulse = drawnPathProps(PULSE_PATH, acting ? 1 : drawProgress);\n\n const scale = (0.85 + 0.15 * scaleIn) * beat;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `scale(${scale})`,\n }}\n >\n <path\n d={PULSE_PATH}\n strokeDasharray={pulse.strokeDasharray}\n strokeDashoffset={pulse.strokeDashoffset}\n />\n </svg>\n );\n}\n\nfunction ActivityIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d=\"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2\" />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: true,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: true,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype ActivityIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof ActivityIconBase>;\n\nconst ActivityIconInner = forwardRef<\n HTMLDivElement,\n ActivityIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<ActivityIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <ActivityIconBase\n {...(componentProps as unknown as ComponentProps<typeof ActivityIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const ActivityIcon = Interactive.withSchema({\n Component: ActivityIconInner,\n componentName: \"<ActivityIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-alert-triangle.json b/registry-artifacts/elements/icon-alert-triangle.jsonindex e05576c1..2026ff5b 100644--- a/registry-artifacts/elements/icon-alert-triangle.json+++ b/registry-artifacts/elements/icon-alert-triangle.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Alert Triangle","durationInFrames": 75,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-alert-triangle","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst TRIANGLE_PATH =\n \"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3\";\nconst STEM_PATH = \"M12 9v4\";\nconst DOT_PATH = \"M12 17h.01\";\n\nconst TIMINGS = {\n drawDurationInFrames: 16,\n actionDelayInFrames: 2,\n actionDurationInFrames: 24,\n loop: false,\n} as const;\n\nfunction AlertTriangleIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress } = useIconAnimation(\n { animation, loop, speed },\n TIMINGS,\n );\n\n const linearDraw = 1 - (1 - drawProgress) ** (1 / 3);\n\n const triangleProgress = interpolate(linearDraw, [0, 0.875], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n });\n const stemProgress = interpolate(linearDraw, [0.625, 1], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n const dotPop = interpolate(linearDraw, [0.85, 1], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.back(1.8)),\n });\n\n const triangle = drawnPathProps(TRIANGLE_PATH, triangleProgress);\n const stem = drawnPathProps(STEM_PATH, stemProgress);\n\n const blinkOpacity = interpolate(\n actionProgress,\n [0, 0.2, 0.4, 0.6, 0.8],\n [1, 0.25, 1, 0.25, 1],\n { extrapolateLeft: \"clamp\", extrapolateRight: \"clamp\" },\n );\n const stemSquash = interpolate(\n actionProgress,\n [0, 0.2, 0.4, 0.6, 0.8],\n [1, 0.85, 1, 0.85, 1],\n { extrapolateLeft: \"clamp\", extrapolateRight: \"clamp\" },\n );\n\n const scale = 0.85 + 0.15 * scaleIn;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `scale(${scale})`,\n }}\n >\n <path\n d={TRIANGLE_PATH}\n strokeDasharray={triangle.strokeDasharray}\n strokeDashoffset={triangle.strokeDashoffset}\n />\n <g opacity={blinkOpacity}>\n <g\n transform={`translate(12 13) scale(1 ${stemSquash}) translate(-12 -13)`}\n >\n <path\n d={STEM_PATH}\n strokeDasharray={stem.strokeDasharray}\n strokeDashoffset={stem.strokeDashoffset}\n />\n </g>\n <g transform={`translate(12 17) scale(${dotPop}) translate(-12 -17)`}>\n <path d={DOT_PATH} />\n </g>\n </g>\n </svg>\n );\n}\n\nfunction AlertTriangleIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d={TRIANGLE_PATH} />\n <path d={STEM_PATH} />\n <path d={DOT_PATH} />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype AlertTriangleIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof AlertTriangleIconBase>;\n\nconst AlertTriangleIconInner = forwardRef<\n HTMLDivElement,\n AlertTriangleIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<AlertTriangleIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <AlertTriangleIconBase\n {...(componentProps as unknown as ComponentProps<typeof AlertTriangleIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const AlertTriangleIcon = Interactive.withSchema({\n Component: AlertTriangleIconInner,\n componentName: \"<AlertTriangleIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-arrow-down.json b/registry-artifacts/elements/icon-arrow-down.jsonindex 7ab7448b..c6c67578 100644--- a/registry-artifacts/elements/icon-arrow-down.json+++ b/registry-artifacts/elements/icon-arrow-down.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Arrow Down","durationInFrames": 60,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-arrow-down","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst SHAFT_PATH = \"M12 5v14\";\nconst HEAD_PATH = \"m19 12-7 7-7-7\";\n\nconst TIMINGS = {\n drawDurationInFrames: 12,\n actionDelayInFrames: 2,\n actionDurationInFrames: 16,\n loop: false,\n} as const;\n\nfunction ArrowDownIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress } = useIconAnimation(\n { animation, loop, speed },\n TIMINGS,\n );\n\n const linearDraw = 1 - (1 - drawProgress) ** (1 / 3);\n\n const shaftProgress = interpolate(linearDraw, [0, 0.66], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n const headProgress = interpolate(linearDraw, [0.5, 1], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n });\n\n const shaft = drawnPathProps(SHAFT_PATH, shaftProgress);\n const head = drawnPathProps(HEAD_PATH, headProgress);\n\n const outward = interpolate(actionProgress, [0, 0.5], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.back(2.2)),\n });\n const settle = interpolate(actionProgress, [0.5, 1], [1, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n });\n const nudgeY = 6 * (actionProgress < 0.5 ? outward : settle);\n const scale = 0.85 + 0.15 * scaleIn;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `scale(${scale})`,\n }}\n >\n <g transform={`translate(0 ${nudgeY})`}>\n <path\n d={SHAFT_PATH}\n strokeDasharray={shaft.strokeDasharray}\n strokeDashoffset={shaft.strokeDashoffset}\n />\n <path\n d={HEAD_PATH}\n strokeDasharray={head.strokeDasharray}\n strokeDashoffset={head.strokeDashoffset}\n />\n </g>\n </svg>\n );\n}\n\nfunction ArrowDownIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d={SHAFT_PATH} />\n <path d={HEAD_PATH} />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype ArrowDownIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof ArrowDownIconBase>;\n\nconst ArrowDownIconInner = forwardRef<\n HTMLDivElement,\n ArrowDownIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<ArrowDownIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <ArrowDownIconBase\n {...(componentProps as unknown as ComponentProps<typeof ArrowDownIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const ArrowDownIcon = Interactive.withSchema({\n Component: ArrowDownIconInner,\n componentName: \"<ArrowDownIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-arrow-left.json b/registry-artifacts/elements/icon-arrow-left.jsonindex 322afe87..e3cf8a3c 100644--- a/registry-artifacts/elements/icon-arrow-left.json+++ b/registry-artifacts/elements/icon-arrow-left.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Arrow Left","durationInFrames": 60,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-arrow-left","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst SHAFT_PATH = \"M19 12H5\";\nconst HEAD_PATH = \"m12 19-7-7 7-7\";\n\nconst TIMINGS = {\n drawDurationInFrames: 12,\n actionDelayInFrames: 2,\n actionDurationInFrames: 16,\n loop: false,\n} as const;\n\nfunction ArrowLeftIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress } = useIconAnimation(\n { animation, loop, speed },\n TIMINGS,\n );\n\n const linearDraw = 1 - (1 - drawProgress) ** (1 / 3);\n\n const shaftProgress = interpolate(linearDraw, [0, 0.66], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n const headProgress = interpolate(linearDraw, [0.5, 1], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n });\n\n const shaft = drawnPathProps(SHAFT_PATH, shaftProgress);\n const head = drawnPathProps(HEAD_PATH, headProgress);\n\n const outward = interpolate(actionProgress, [0, 0.5], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.back(2.2)),\n });\n const settle = interpolate(actionProgress, [0.5, 1], [1, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n });\n const nudgeX = -6 * (actionProgress < 0.5 ? outward : settle);\n const scale = 0.85 + 0.15 * scaleIn;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `scale(${scale})`,\n }}\n >\n <g transform={`translate(${nudgeX} 0)`}>\n <path\n d={SHAFT_PATH}\n strokeDasharray={shaft.strokeDasharray}\n strokeDashoffset={shaft.strokeDashoffset}\n />\n <path\n d={HEAD_PATH}\n strokeDasharray={head.strokeDasharray}\n strokeDashoffset={head.strokeDashoffset}\n />\n </g>\n </svg>\n );\n}\n\nfunction ArrowLeftIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d={SHAFT_PATH} />\n <path d={HEAD_PATH} />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype ArrowLeftIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof ArrowLeftIconBase>;\n\nconst ArrowLeftIconInner = forwardRef<\n HTMLDivElement,\n ArrowLeftIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<ArrowLeftIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <ArrowLeftIconBase\n {...(componentProps as unknown as ComponentProps<typeof ArrowLeftIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const ArrowLeftIcon = Interactive.withSchema({\n Component: ArrowLeftIconInner,\n componentName: \"<ArrowLeftIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-arrow-right.json b/registry-artifacts/elements/icon-arrow-right.jsonindex b4ca1e45..15830fb4 100644--- a/registry-artifacts/elements/icon-arrow-right.json+++ b/registry-artifacts/elements/icon-arrow-right.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Arrow Right","durationInFrames": 60,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-arrow-right","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst SHAFT_PATH = \"M5 12h14\";\nconst HEAD_PATH = \"m12 5 7 7-7 7\";\n\nconst TIMINGS = {\n drawDurationInFrames: 12,\n actionDelayInFrames: 2,\n actionDurationInFrames: 16,\n loop: false,\n} as const;\n\nfunction ArrowRightIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress } = useIconAnimation(\n { animation, loop, speed },\n TIMINGS,\n );\n\n const linearDraw = 1 - (1 - drawProgress) ** (1 / 3);\n\n const shaftProgress = interpolate(linearDraw, [0, 0.66], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n const headProgress = interpolate(linearDraw, [0.5, 1], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n });\n\n const shaft = drawnPathProps(SHAFT_PATH, shaftProgress);\n const head = drawnPathProps(HEAD_PATH, headProgress);\n\n const outward = interpolate(actionProgress, [0, 0.5], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.back(2.2)),\n });\n const settle = interpolate(actionProgress, [0.5, 1], [1, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n });\n const nudgeX = 6 * (actionProgress < 0.5 ? outward : settle);\n const scale = 0.85 + 0.15 * scaleIn;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `scale(${scale})`,\n }}\n >\n <g transform={`translate(${nudgeX} 0)`}>\n <path\n d={SHAFT_PATH}\n strokeDasharray={shaft.strokeDasharray}\n strokeDashoffset={shaft.strokeDashoffset}\n />\n <path\n d={HEAD_PATH}\n strokeDasharray={head.strokeDasharray}\n strokeDashoffset={head.strokeDashoffset}\n />\n </g>\n </svg>\n );\n}\n\nfunction ArrowRightIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d={SHAFT_PATH} />\n <path d={HEAD_PATH} />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype ArrowRightIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof ArrowRightIconBase>;\n\nconst ArrowRightIconInner = forwardRef<\n HTMLDivElement,\n ArrowRightIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<ArrowRightIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <ArrowRightIconBase\n {...(componentProps as unknown as ComponentProps<typeof ArrowRightIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const ArrowRightIcon = Interactive.withSchema({\n Component: ArrowRightIconInner,\n componentName: \"<ArrowRightIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-arrow-up.json b/registry-artifacts/elements/icon-arrow-up.jsonindex 97092853..7402a97a 100644--- a/registry-artifacts/elements/icon-arrow-up.json+++ b/registry-artifacts/elements/icon-arrow-up.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Arrow Up","durationInFrames": 60,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-arrow-up","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst SHAFT_PATH = \"M12 19V5\";\nconst HEAD_PATH = \"m5 12 7-7 7 7\";\n\nconst TIMINGS = {\n drawDurationInFrames: 12,\n actionDelayInFrames: 2,\n actionDurationInFrames: 16,\n loop: false,\n} as const;\n\nfunction ArrowUpIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress } = useIconAnimation(\n { animation, loop, speed },\n TIMINGS,\n );\n\n const linearDraw = 1 - (1 - drawProgress) ** (1 / 3);\n\n const shaftProgress = interpolate(linearDraw, [0, 0.66], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n const headProgress = interpolate(linearDraw, [0.5, 1], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n });\n\n const shaft = drawnPathProps(SHAFT_PATH, shaftProgress);\n const head = drawnPathProps(HEAD_PATH, headProgress);\n\n const outward = interpolate(actionProgress, [0, 0.5], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.back(2.2)),\n });\n const settle = interpolate(actionProgress, [0.5, 1], [1, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n });\n const nudgeY = -6 * (actionProgress < 0.5 ? outward : settle);\n const scale = 0.85 + 0.15 * scaleIn;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `scale(${scale})`,\n }}\n >\n <g transform={`translate(0 ${nudgeY})`}>\n <path\n d={SHAFT_PATH}\n strokeDasharray={shaft.strokeDasharray}\n strokeDashoffset={shaft.strokeDashoffset}\n />\n <path\n d={HEAD_PATH}\n strokeDasharray={head.strokeDasharray}\n strokeDashoffset={head.strokeDashoffset}\n />\n </g>\n </svg>\n );\n}\n\nfunction ArrowUpIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d={SHAFT_PATH} />\n <path d={HEAD_PATH} />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype ArrowUpIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof ArrowUpIconBase>;\n\nconst ArrowUpIconInner = forwardRef<\n HTMLDivElement,\n ArrowUpIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<ArrowUpIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <ArrowUpIconBase\n {...(componentProps as unknown as ComponentProps<typeof ArrowUpIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const ArrowUpIcon = Interactive.withSchema({\n Component: ArrowUpIconInner,\n componentName: \"<ArrowUpIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-at-sign.json b/registry-artifacts/elements/icon-at-sign.jsonindex fdf47b79..dab72e3a 100644--- a/registry-artifacts/elements/icon-at-sign.json+++ b/registry-artifacts/elements/icon-at-sign.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "At Sign","durationInFrames": 75,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-at-sign","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst CIRCLE_PATH = \"M12 8a4 4 0 1 0 0 8 4 4 0 1 0 0-8Z\";\nconst SWOOSH_PATH = \"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8\";\n\nconst CENTER = 12;\n\nconst TIMINGS = {\n drawDurationInFrames: 18,\n actionDelayInFrames: 2,\n actionDurationInFrames: 22,\n loop: false,\n} as const;\n\nfunction AtSignIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress, actionFrame } =\n useIconAnimation({ animation, loop, speed }, TIMINGS);\n\n const linearDraw = 1 - (1 - drawProgress) ** (1 / 3);\n const acting = animation !== \"draw\" && actionFrame >= 0;\n\n const circleDraw = interpolate(linearDraw, [0, 0.55], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n const swooshDraw = interpolate(linearDraw, [0.35, 1], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n\n const circlePop = acting\n ? interpolate(actionProgress, [0, 0.22, 0.45], [1, 1.15, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n })\n : 1;\n const swooshProgress = acting ? 1 : swooshDraw;\n const circleProgress = acting ? 1 : circleDraw;\n\n const circle = drawnPathProps(CIRCLE_PATH, circleProgress);\n const swoosh = drawnPathProps(SWOOSH_PATH, swooshProgress);\n\n const scale = 0.85 + 0.15 * scaleIn;\n const popTransform = `translate(${CENTER * (1 - circlePop)} ${CENTER * (1 - circlePop)}) scale(${circlePop})`;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `scale(${scale})`,\n }}\n >\n <g transform={popTransform}>\n <path\n d={CIRCLE_PATH}\n strokeDasharray={circle.strokeDasharray}\n strokeDashoffset={circle.strokeDashoffset}\n />\n </g>\n <path\n d={SWOOSH_PATH}\n strokeDasharray={swoosh.strokeDasharray}\n strokeDashoffset={swoosh.strokeDashoffset}\n />\n </svg>\n );\n}\n\nfunction AtSignIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <circle cx=\"12\" cy=\"12\" r=\"4\" />\n <path d={SWOOSH_PATH} />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype AtSignIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof AtSignIconBase>;\n\nconst AtSignIconInner = forwardRef<\n HTMLDivElement,\n AtSignIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<AtSignIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <AtSignIconBase\n {...(componentProps as unknown as ComponentProps<typeof AtSignIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const AtSignIcon = Interactive.withSchema({\n Component: AtSignIconInner,\n componentName: \"<AtSignIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-award.json b/registry-artifacts/elements/icon-award.jsonindex 5abc672b..97bc14e0 100644--- a/registry-artifacts/elements/icon-award.json+++ b/registry-artifacts/elements/icon-award.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Award","durationInFrames": 75,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-award","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst MEDAL_PATH = \"M12 2a6 6 0 1 0 0 12 6 6 0 1 0 0-12Z\";\nconst RIBBON_PATH =\n \"m15.477 12.89 1.515 8.526a.5.5 0 0 1-.81.47l-3.58-2.687a1 1 0 0 0-1.197 0l-3.586 2.686a.5.5 0 0 1-.81-.469l1.514-8.526\";\n\nconst MEDAL_CX = 12;\nconst MEDAL_CY = 8;\nconst PIVOT_X = 12;\nconst PIVOT_Y = 2;\n\nconst TIMINGS = {\n drawDurationInFrames: 14,\n actionDelayInFrames: 2,\n actionDurationInFrames: 30,\n loop: false,\n} as const;\n\nfunction AwardIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress, actionFrame } =\n useIconAnimation({ animation, loop, speed }, TIMINGS);\n\n const acting = animation !== \"draw\" && actionFrame >= 0;\n\n const ribbonDraw = acting\n ? interpolate(actionProgress, [0.05, 0.4], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n })\n : 0;\n const pop = acting\n ? interpolate(actionProgress, [0.35, 0.55, 1], [1, 1.15, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n })\n : 1;\n const swing = acting\n ? interpolate(\n actionProgress,\n [0.35, 0.5, 0.65, 0.8, 1],\n [0, 4, -3, 1.5, 0],\n {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.sin),\n },\n )\n : 0;\n\n const medal = drawnPathProps(MEDAL_PATH, acting ? 1 : drawProgress);\n const ribbon = drawnPathProps(RIBBON_PATH, ribbonDraw);\n\n const scale = 0.85 + 0.15 * scaleIn;\n const popTransform = `translate(${MEDAL_CX * (1 - pop)} ${MEDAL_CY * (1 - pop)}) scale(${pop})`;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `scale(${scale})`,\n }}\n >\n <g transform={`rotate(${swing} ${PIVOT_X} ${PIVOT_Y})`}>\n <path\n d={RIBBON_PATH}\n strokeDasharray={ribbon.strokeDasharray}\n strokeDashoffset={ribbon.strokeDashoffset}\n />\n <g transform={popTransform}>\n <path\n d={MEDAL_PATH}\n strokeDasharray={medal.strokeDasharray}\n strokeDashoffset={medal.strokeDashoffset}\n />\n </g>\n </g>\n </svg>\n );\n}\n\nfunction AwardIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d=\"m15.477 12.89 1.515 8.526a.5.5 0 0 1-.81.47l-3.58-2.687a1 1 0 0 0-1.197 0l-3.586 2.686a.5.5 0 0 1-.81-.469l1.514-8.526\" />\n <circle cx=\"12\" cy=\"8\" r=\"6\" />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype AwardIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof AwardIconBase>;\n\nconst AwardIconInner = forwardRef<\n HTMLDivElement,\n AwardIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<AwardIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <AwardIconBase\n {...(componentProps as unknown as ComponentProps<typeof AwardIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const AwardIcon = Interactive.withSchema({\n Component: AwardIconInner,\n componentName: \"<AwardIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-bar-chart-3.json b/registry-artifacts/elements/icon-bar-chart-3.jsonindex d197d61b..c02bd870 100644--- a/registry-artifacts/elements/icon-bar-chart-3.json+++ b/registry-artifacts/elements/icon-bar-chart-3.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Bar Chart 3","durationInFrames": 80,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-bar-chart-3","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst AXIS_PATH = \"M3 3v16a2 2 0 0 0 2 2h16\";\nconst BARS = [\"M8 17V14\", \"M13 17V5\", \"M18 17V9\"];\nconst BASE_Y = 17;\n\nconst TIMINGS = {\n drawDurationInFrames: 12,\n actionDelayInFrames: 2,\n actionDurationInFrames: 30,\n loop: false,\n} as const;\n\nfunction BarChart3IconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress, actionFrame } =\n useIconAnimation({ animation, loop, speed }, TIMINGS);\n\n const acting = animation !== \"draw\" && actionFrame >= 0;\n\n const axis = drawnPathProps(AXIS_PATH, drawProgress);\n\n const bars = BARS.map((d, i) => {\n const start = i * 0.22;\n const grow = interpolate(\n actionProgress,\n [start, start + 0.3, start + 0.42],\n [0, 1.08, 1],\n {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n },\n );\n const scaleY = animation === \"draw\" ? 1 : acting ? grow : 0;\n return { d, scaleY };\n });\n\n const scale = 0.85 + 0.15 * scaleIn;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `scale(${scale})`,\n }}\n >\n <path\n d={AXIS_PATH}\n strokeDasharray={axis.strokeDasharray}\n strokeDashoffset={axis.strokeDashoffset}\n />\n {bars.map((bar) => (\n <g\n key={bar.d}\n transform={`translate(0 ${BASE_Y * (1 - bar.scaleY)}) scale(1 ${bar.scaleY})`}\n >\n <path d={bar.d} />\n </g>\n ))}\n </svg>\n );\n}\n\nfunction BarChart3IconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d={AXIS_PATH} />\n <path d=\"M18 17V9\" />\n <path d=\"M13 17V5\" />\n <path d=\"M8 17v-3\" />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype BarChart3IconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof BarChart3IconBase>;\n\nconst BarChart3IconInner = forwardRef<\n HTMLDivElement,\n BarChart3IconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<BarChart3Icon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <BarChart3IconBase\n {...(componentProps as unknown as ComponentProps<typeof BarChart3IconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const BarChart3Icon = Interactive.withSchema({\n Component: BarChart3IconInner,\n componentName: \"<BarChart3Icon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-bell.json b/registry-artifacts/elements/icon-bell.jsonindex b56d2c47..18e15f5a 100644--- a/registry-artifacts/elements/icon-bell.json+++ b/registry-artifacts/elements/icon-bell.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Bell","durationInFrames": 75,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-bell","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst BODY_PATH =\n \"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326\";\nconst CLAPPER_PATH = \"M10.268 21a2 2 0 0 0 3.464 0\";\n\nconst TIMINGS = {\n drawDurationInFrames: 14,\n actionDelayInFrames: 2,\n actionDurationInFrames: 30,\n loop: false,\n} as const;\n\nfunction BellIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress } = useIconAnimation(\n { animation, loop, speed },\n TIMINGS,\n );\n\n const linearDraw = 1 - (1 - drawProgress) ** (1 / 3);\n\n const bodyProgress = interpolate(linearDraw, [0, 0.857], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n });\n const clapperProgress = interpolate(linearDraw, [0.714, 1], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n\n const body = drawnPathProps(BODY_PATH, bodyProgress);\n const clapper = drawnPathProps(CLAPPER_PATH, clapperProgress);\n\n const ring = interpolate(\n actionProgress,\n [0, 0.2, 0.4, 0.6, 0.8, 1],\n [0, 14, -11, 7, -3, 0],\n { extrapolateLeft: \"clamp\", extrapolateRight: \"clamp\" },\n );\n\n const scale = 0.85 + 0.15 * scaleIn;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `scale(${scale})`,\n }}\n >\n <g transform={`rotate(${ring} 12 2)`}>\n <path\n d={BODY_PATH}\n strokeDasharray={body.strokeDasharray}\n strokeDashoffset={body.strokeDashoffset}\n />\n <path\n d={CLAPPER_PATH}\n strokeDasharray={clapper.strokeDasharray}\n strokeDashoffset={clapper.strokeDashoffset}\n />\n </g>\n </svg>\n );\n}\n\nfunction BellIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d={BODY_PATH} />\n <path d={CLAPPER_PATH} />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype BellIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof BellIconBase>;\n\nconst BellIconInner = forwardRef<\n HTMLDivElement,\n BellIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<BellIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <BellIconBase\n {...(componentProps as unknown as ComponentProps<typeof BellIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const BellIcon = Interactive.withSchema({\n Component: BellIconInner,\n componentName: \"<BellIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-bookmark.json b/registry-artifacts/elements/icon-bookmark.jsonindex d4ed27d3..82120c57 100644--- a/registry-artifacts/elements/icon-bookmark.json+++ b/registry-artifacts/elements/icon-bookmark.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Bookmark","durationInFrames": 70,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-bookmark","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst BOOKMARK_PATH =\n \"M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z\";\n\nconst TIMINGS = {\n drawDurationInFrames: 14,\n actionDelayInFrames: 2,\n actionDurationInFrames: 20,\n loop: false,\n} as const;\n\nfunction BookmarkIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress, actionFrame } =\n useIconAnimation({ animation, loop, speed }, TIMINGS);\n\n const acting = animation !== \"draw\" && actionFrame >= 0;\n\n const drop = acting\n ? interpolate(actionProgress, [0, 0.4, 0.6, 1], [-3, 0.5, -0.2, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n })\n : 0;\n const tilt = acting\n ? interpolate(actionProgress, [0, 0.35, 0.7], [0, -6, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n })\n : 0;\n\n const dash = drawnPathProps(BOOKMARK_PATH, drawProgress);\n const scale = 0.85 + 0.15 * scaleIn;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `scale(${scale})`,\n }}\n >\n <g transform={`rotate(${tilt} 12 3) translate(0 ${drop})`}>\n <path\n d={BOOKMARK_PATH}\n strokeDasharray={dash.strokeDasharray}\n strokeDashoffset={dash.strokeDashoffset}\n />\n </g>\n </svg>\n );\n}\n\nfunction BookmarkIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d={BOOKMARK_PATH} />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype BookmarkIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof BookmarkIconBase>;\n\nconst BookmarkIconInner = forwardRef<\n HTMLDivElement,\n BookmarkIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<BookmarkIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <BookmarkIconBase\n {...(componentProps as unknown as ComponentProps<typeof BookmarkIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const BookmarkIcon = Interactive.withSchema({\n Component: BookmarkIconInner,\n componentName: \"<BookmarkIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-calendar.json b/registry-artifacts/elements/icon-calendar.jsonindex 9f42abbc..8471fca1 100644--- a/registry-artifacts/elements/icon-calendar.json+++ b/registry-artifacts/elements/icon-calendar.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Calendar","durationInFrames": 75,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-calendar","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst FRAME_PATH =\n \"M5 4H19A2 2 0 0 1 21 6V20A2 2 0 0 1 19 22H5A2 2 0 0 1 3 20V6A2 2 0 0 1 5 4Z\";\nconst RING1_PATH = \"M8 2v4\";\nconst RING2_PATH = \"M16 2v4\";\nconst RULE_PATH = \"M3 10H21\";\n\nconst TIMINGS = {\n drawDurationInFrames: 18,\n actionDelayInFrames: 2,\n actionDurationInFrames: 20,\n loop: false,\n} as const;\n\nfunction CalendarIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress, actionFrame } =\n useIconAnimation({ animation, loop, speed }, TIMINGS);\n\n const linearDraw = 1 - (1 - drawProgress) ** (1 / 3);\n const acting = animation !== \"draw\" && actionFrame >= 0;\n\n const frameDraw = interpolate(linearDraw, [0, 0.6], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n const ringsDraw = interpolate(linearDraw, [0.4, 0.75], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n const ruleDraw = interpolate(linearDraw, [0.65, 1], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n\n const ring1Dip = acting\n ? interpolate(actionProgress, [0, 0.25, 0.5], [0, 1.5, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n })\n : 0;\n const ring2Dip = acting\n ? interpolate(actionProgress, [0.1, 0.35, 0.6], [0, 1.5, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n })\n : 0;\n const pop = acting\n ? interpolate(actionProgress, [0.5, 0.7, 1], [1, 1.04, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n })\n : 1;\n\n const frame = drawnPathProps(FRAME_PATH, acting ? 1 : frameDraw);\n const ring1 = drawnPathProps(RING1_PATH, acting ? 1 : ringsDraw);\n const ring2 = drawnPathProps(RING2_PATH, acting ? 1 : ringsDraw);\n const rule = drawnPathProps(RULE_PATH, acting ? 1 : ruleDraw);\n\n const scale = (0.85 + 0.15 * scaleIn) * pop;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `scale(${scale})`,\n }}\n >\n <path\n d={FRAME_PATH}\n strokeDasharray={frame.strokeDasharray}\n strokeDashoffset={frame.strokeDashoffset}\n />\n <g transform={`translate(0 ${ring1Dip})`}>\n <path\n d={RING1_PATH}\n strokeDasharray={ring1.strokeDasharray}\n strokeDashoffset={ring1.strokeDashoffset}\n />\n </g>\n <g transform={`translate(0 ${ring2Dip})`}>\n <path\n d={RING2_PATH}\n strokeDasharray={ring2.strokeDasharray}\n strokeDashoffset={ring2.strokeDashoffset}\n />\n </g>\n <path\n d={RULE_PATH}\n strokeDasharray={rule.strokeDasharray}\n strokeDashoffset={rule.strokeDashoffset}\n />\n </svg>\n );\n}\n\nfunction CalendarIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d=\"M8 2v4\" />\n <path d=\"M16 2v4\" />\n <rect width=\"18\" height=\"18\" x=\"3\" y=\"4\" rx=\"2\" />\n <path d=\"M3 10h18\" />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype CalendarIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof CalendarIconBase>;\n\nconst CalendarIconInner = forwardRef<\n HTMLDivElement,\n CalendarIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<CalendarIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <CalendarIconBase\n {...(componentProps as unknown as ComponentProps<typeof CalendarIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const CalendarIcon = Interactive.withSchema({\n Component: CalendarIconInner,\n componentName: \"<CalendarIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-camera.json b/registry-artifacts/elements/icon-camera.jsonindex c20e2f71..a5607f2f 100644--- a/registry-artifacts/elements/icon-camera.json+++ b/registry-artifacts/elements/icon-camera.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Camera","durationInFrames": 70,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-camera","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst BODY_PATH =\n \"M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z\";\nconst LENS_PATH =\n \"M12 10 A3 3 0 0 1 15 13 A3 3 0 0 1 12 16 A3 3 0 0 1 9 13 A3 3 0 0 1 12 10\";\n\nconst TIMINGS = {\n drawDurationInFrames: 18,\n actionDelayInFrames: 2,\n actionDurationInFrames: 18,\n loop: false,\n} as const;\n\nfunction CameraIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress, actionFrame } =\n useIconAnimation({ animation, loop, speed }, TIMINGS);\n\n const linearDraw = 1 - (1 - drawProgress) ** (1 / 3);\n\n const bodyDraw = interpolate(linearDraw, [0, 0.667], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n const lensDraw = interpolate(linearDraw, [0.444, 1], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n\n const acting = animation !== \"draw\" && actionFrame >= 0;\n\n const shutter = acting\n ? interpolate(\n actionProgress,\n [0, 0.28, 0.56, 0.78, 1],\n [1, 0.55, 1.08, 1, 1],\n {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n },\n )\n : 1;\n\n const body = drawnPathProps(BODY_PATH, bodyDraw);\n const lens = drawnPathProps(LENS_PATH, lensDraw);\n\n const scale = 0.85 + 0.15 * scaleIn;\n const lensTransform = `translate(${12 * (1 - shutter)} ${13 * (1 - shutter)}) scale(${shutter})`;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `scale(${scale})`,\n }}\n >\n <path\n d={BODY_PATH}\n strokeDasharray={body.strokeDasharray}\n strokeDashoffset={body.strokeDashoffset}\n />\n <g transform={lensTransform}>\n <path\n d={LENS_PATH}\n strokeDasharray={lens.strokeDasharray}\n strokeDashoffset={lens.strokeDashoffset}\n />\n </g>\n </svg>\n );\n}\n\nfunction CameraIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d={BODY_PATH} />\n <circle cx=\"12\" cy=\"13\" r=\"3\" />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype CameraIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof CameraIconBase>;\n\nconst CameraIconInner = forwardRef<\n HTMLDivElement,\n CameraIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<CameraIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <CameraIconBase\n {...(componentProps as unknown as ComponentProps<typeof CameraIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const CameraIcon = Interactive.withSchema({\n Component: CameraIconInner,\n componentName: \"<CameraIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-check-circle.json b/registry-artifacts/elements/icon-check-circle.jsonindex b066d8bb..89fc9e6d 100644--- a/registry-artifacts/elements/icon-check-circle.json+++ b/registry-artifacts/elements/icon-check-circle.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Check Circle","durationInFrames": 75,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-check-circle","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst CIRCLE_PATH =\n \"M12 2 A10 10 0 0 1 22 12 A10 10 0 0 1 12 22 A10 10 0 0 1 2 12 A10 10 0 0 1 12 2\";\nconst CHECK_PATH = \"M9 12 11 14 15 10\";\n\nconst TIMINGS = {\n drawDurationInFrames: 20,\n actionDelayInFrames: 2,\n actionDurationInFrames: 18,\n loop: false,\n} as const;\n\nfunction CheckCircleIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress } = useIconAnimation(\n { animation, loop, speed },\n TIMINGS,\n );\n\n const linearDraw = 1 - (1 - drawProgress) ** (1 / 3);\n\n const circleProgress = interpolate(linearDraw, [0, 0.85], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n });\n const checkProgress = interpolate(linearDraw, [0.6, 1], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n\n const circle = drawnPathProps(CIRCLE_PATH, circleProgress);\n const check = drawnPathProps(CHECK_PATH, checkProgress);\n\n const pop = interpolate(actionProgress, [0, 0.4, 1], [0, 1, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n });\n const scale = (0.85 + 0.15 * scaleIn) * (1 + 0.12 * pop);\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `scale(${scale})`,\n }}\n >\n <path\n d={CIRCLE_PATH}\n strokeDasharray={circle.strokeDasharray}\n strokeDashoffset={circle.strokeDashoffset}\n />\n <path\n d={CHECK_PATH}\n strokeDasharray={check.strokeDasharray}\n strokeDashoffset={check.strokeDashoffset}\n />\n </svg>\n );\n}\n\nfunction CheckCircleIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <circle cx=\"12\" cy=\"12\" r=\"10\" />\n <path d={CHECK_PATH} />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype CheckCircleIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof CheckCircleIconBase>;\n\nconst CheckCircleIconInner = forwardRef<\n HTMLDivElement,\n CheckCircleIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<CheckCircleIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <CheckCircleIconBase\n {...(componentProps as unknown as ComponentProps<typeof CheckCircleIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const CheckCircleIcon = Interactive.withSchema({\n Component: CheckCircleIconInner,\n componentName: \"<CheckCircleIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-check.json b/registry-artifacts/elements/icon-check.jsonindex eadabccb..ebc96a6c 100644--- a/registry-artifacts/elements/icon-check.json+++ b/registry-artifacts/elements/icon-check.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Check","durationInFrames": 60,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-check","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst CHECK_PATH = \"M4 12 9 17 20 6\";\n\nconst TIMINGS = {\n drawDurationInFrames: 14,\n actionDelayInFrames: 2,\n actionDurationInFrames: 18,\n loop: false,\n} as const;\n\nfunction CheckIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress } = useIconAnimation(\n { animation, loop, speed },\n TIMINGS,\n );\n\n const dash = drawnPathProps(CHECK_PATH, drawProgress);\n const pop = interpolate(actionProgress, [0, 0.4, 1], [0, 1, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n });\n const rotate = interpolate(actionProgress, [0, 0.5], [-4, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n });\n const scale = (0.85 + 0.15 * scaleIn) * (1 + 0.18 * pop);\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `rotate(${rotate}deg) scale(${scale})`,\n }}\n >\n <path\n d={CHECK_PATH}\n strokeDasharray={dash.strokeDasharray}\n strokeDashoffset={dash.strokeDashoffset}\n />\n </svg>\n );\n}\n\nfunction CheckIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d={CHECK_PATH} />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype CheckIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof CheckIconBase>;\n\nconst CheckIconInner = forwardRef<\n HTMLDivElement,\n CheckIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<CheckIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <CheckIconBase\n {...(componentProps as unknown as ComponentProps<typeof CheckIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const CheckIcon = Interactive.withSchema({\n Component: CheckIconInner,\n componentName: \"<CheckIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-chevron-down.json b/registry-artifacts/elements/icon-chevron-down.jsonindex a3fcb8a4..eec049d7 100644--- a/registry-artifacts/elements/icon-chevron-down.json+++ b/registry-artifacts/elements/icon-chevron-down.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Chevron Down","durationInFrames": 60,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-chevron-down","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst CHEVRON_PATH = \"M6 9 12 15 18 9\";\n\nconst TIMINGS = {\n drawDurationInFrames: 14,\n actionDelayInFrames: 2,\n actionDurationInFrames: 22,\n loop: false,\n} as const;\n\nfunction ChevronDownIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress } = useIconAnimation(\n { animation, loop, speed },\n TIMINGS,\n );\n\n const dash = drawnPathProps(CHEVRON_PATH, drawProgress);\n const nudge = interpolate(\n actionProgress,\n [0, 0.22, 0.45, 0.68, 1],\n [0, 4, 0, 2, 0],\n {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n },\n );\n const scale = 0.85 + 0.15 * scaleIn;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `translateY(${nudge}px) scale(${scale})`,\n }}\n >\n <path\n d={CHEVRON_PATH}\n strokeDasharray={dash.strokeDasharray}\n strokeDashoffset={dash.strokeDashoffset}\n />\n </svg>\n );\n}\n\nfunction ChevronDownIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d={CHEVRON_PATH} />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype ChevronDownIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof ChevronDownIconBase>;\n\nconst ChevronDownIconInner = forwardRef<\n HTMLDivElement,\n ChevronDownIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<ChevronDownIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <ChevronDownIconBase\n {...(componentProps as unknown as ComponentProps<typeof ChevronDownIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const ChevronDownIcon = Interactive.withSchema({\n Component: ChevronDownIconInner,\n componentName: \"<ChevronDownIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-chevron-left.json b/registry-artifacts/elements/icon-chevron-left.jsonindex 4ecbb13b..05b188aa 100644--- a/registry-artifacts/elements/icon-chevron-left.json+++ b/registry-artifacts/elements/icon-chevron-left.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Chevron Left","durationInFrames": 60,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-chevron-left","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst CHEVRON_PATH = \"M15 18 9 12 15 6\";\n\nconst TIMINGS = {\n drawDurationInFrames: 14,\n actionDelayInFrames: 2,\n actionDurationInFrames: 22,\n loop: false,\n} as const;\n\nfunction ChevronLeftIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress } = useIconAnimation(\n { animation, loop, speed },\n TIMINGS,\n );\n\n const dash = drawnPathProps(CHEVRON_PATH, drawProgress);\n const nudge = interpolate(\n actionProgress,\n [0, 0.22, 0.45, 0.68, 1],\n [0, -4, 0, -2, 0],\n {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n },\n );\n const scale = 0.85 + 0.15 * scaleIn;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `translateX(${nudge}px) scale(${scale})`,\n }}\n >\n <path\n d={CHEVRON_PATH}\n strokeDasharray={dash.strokeDasharray}\n strokeDashoffset={dash.strokeDashoffset}\n />\n </svg>\n );\n}\n\nfunction ChevronLeftIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d={CHEVRON_PATH} />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype ChevronLeftIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof ChevronLeftIconBase>;\n\nconst ChevronLeftIconInner = forwardRef<\n HTMLDivElement,\n ChevronLeftIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<ChevronLeftIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <ChevronLeftIconBase\n {...(componentProps as unknown as ComponentProps<typeof ChevronLeftIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const ChevronLeftIcon = Interactive.withSchema({\n Component: ChevronLeftIconInner,\n componentName: \"<ChevronLeftIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-chevron-right.json b/registry-artifacts/elements/icon-chevron-right.jsonindex 730b179d..37464908 100644--- a/registry-artifacts/elements/icon-chevron-right.json+++ b/registry-artifacts/elements/icon-chevron-right.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Chevron Right","durationInFrames": 60,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-chevron-right","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst CHEVRON_PATH = \"M9 18 15 12 9 6\";\n\nconst TIMINGS = {\n drawDurationInFrames: 14,\n actionDelayInFrames: 2,\n actionDurationInFrames: 22,\n loop: false,\n} as const;\n\nfunction ChevronRightIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress } = useIconAnimation(\n { animation, loop, speed },\n TIMINGS,\n );\n\n const dash = drawnPathProps(CHEVRON_PATH, drawProgress);\n const nudge = interpolate(\n actionProgress,\n [0, 0.22, 0.45, 0.68, 1],\n [0, 4, 0, 2, 0],\n {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n },\n );\n const scale = 0.85 + 0.15 * scaleIn;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `translateX(${nudge}px) scale(${scale})`,\n }}\n >\n <path\n d={CHEVRON_PATH}\n strokeDasharray={dash.strokeDasharray}\n strokeDashoffset={dash.strokeDashoffset}\n />\n </svg>\n );\n}\n\nfunction ChevronRightIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d={CHEVRON_PATH} />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype ChevronRightIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof ChevronRightIconBase>;\n\nconst ChevronRightIconInner = forwardRef<\n HTMLDivElement,\n ChevronRightIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<ChevronRightIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <ChevronRightIconBase\n {...(componentProps as unknown as ComponentProps<typeof ChevronRightIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const ChevronRightIcon = Interactive.withSchema({\n Component: ChevronRightIconInner,\n componentName: \"<ChevronRightIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-chevron-up.json b/registry-artifacts/elements/icon-chevron-up.jsonindex bc7e2a55..44f55bc8 100644--- a/registry-artifacts/elements/icon-chevron-up.json+++ b/registry-artifacts/elements/icon-chevron-up.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Chevron Up","durationInFrames": 60,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-chevron-up","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst CHEVRON_PATH = \"M18 15 12 9 6 15\";\n\nconst TIMINGS = {\n drawDurationInFrames: 14,\n actionDelayInFrames: 2,\n actionDurationInFrames: 22,\n loop: false,\n} as const;\n\nfunction ChevronUpIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress } = useIconAnimation(\n { animation, loop, speed },\n TIMINGS,\n );\n\n const dash = drawnPathProps(CHEVRON_PATH, drawProgress);\n const nudge = interpolate(\n actionProgress,\n [0, 0.22, 0.45, 0.68, 1],\n [0, -4, 0, -2, 0],\n {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n },\n );\n const scale = 0.85 + 0.15 * scaleIn;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `translateY(${nudge}px) scale(${scale})`,\n }}\n >\n <path\n d={CHEVRON_PATH}\n strokeDasharray={dash.strokeDasharray}\n strokeDashoffset={dash.strokeDashoffset}\n />\n </svg>\n );\n}\n\nfunction ChevronUpIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d={CHEVRON_PATH} />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype ChevronUpIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof ChevronUpIconBase>;\n\nconst ChevronUpIconInner = forwardRef<\n HTMLDivElement,\n ChevronUpIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<ChevronUpIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <ChevronUpIconBase\n {...(componentProps as unknown as ComponentProps<typeof ChevronUpIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const ChevronUpIcon = Interactive.withSchema({\n Component: ChevronUpIconInner,\n componentName: \"<ChevronUpIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-clock.json b/registry-artifacts/elements/icon-clock.jsonindex 086c25ee..9c8716b7 100644--- a/registry-artifacts/elements/icon-clock.json+++ b/registry-artifacts/elements/icon-clock.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Clock","durationInFrames": 90,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-clock","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst FACE_PATH = \"M12 2a10 10 0 1 0 0 20 10 10 0 1 0 0-20Z\";\nconst HANDS_PATH = \"M12 6v6l4 2\";\nconst MINUTE_PATH = \"M12 6V12\";\nconst HOUR_PATH = \"M12 12 16 14\";\n\nconst CENTER = 12;\nconst STEPS = 4;\n\nconst TIMINGS = {\n drawDurationInFrames: 16,\n actionDelayInFrames: 2,\n actionDurationInFrames: 40,\n loop: true,\n} as const;\n\nfunction ClockIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress, actionFrame } =\n useIconAnimation({ animation, loop, speed }, TIMINGS);\n\n const linearDraw = 1 - (1 - drawProgress) ** (1 / 3);\n const acting = animation !== \"draw\" && actionFrame >= 0;\n\n const faceDraw = interpolate(linearDraw, [0, 0.7], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n const handsDraw = interpolate(linearDraw, [0.5, 1], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n\n const scaled = actionProgress * STEPS;\n const stepIndex = Math.floor(scaled);\n const frac = scaled - stepIndex;\n const eased = interpolate(frac, [0, 0.55, 1], [0, 1, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n });\n const tick = acting ? ((stepIndex + eased) / STEPS) * 360 : 0;\n\n const face = drawnPathProps(FACE_PATH, acting ? 1 : faceDraw);\n const minute = drawnPathProps(MINUTE_PATH, acting ? 1 : handsDraw);\n const hour = drawnPathProps(HOUR_PATH, acting ? 1 : handsDraw);\n\n const scale = 0.85 + 0.15 * scaleIn;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `scale(${scale})`,\n }}\n >\n <path\n d={FACE_PATH}\n strokeDasharray={face.strokeDasharray}\n strokeDashoffset={face.strokeDashoffset}\n />\n <path\n d={HOUR_PATH}\n strokeDasharray={hour.strokeDasharray}\n strokeDashoffset={hour.strokeDashoffset}\n />\n <g transform={`rotate(${tick} ${CENTER} ${CENTER})`}>\n <path\n d={MINUTE_PATH}\n strokeDasharray={minute.strokeDasharray}\n strokeDashoffset={minute.strokeDashoffset}\n />\n </g>\n </svg>\n );\n}\n\nfunction ClockIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <circle cx=\"12\" cy=\"12\" r=\"10\" />\n <path d={HANDS_PATH} />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: true,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: true,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype ClockIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof ClockIconBase>;\n\nconst ClockIconInner = forwardRef<\n HTMLDivElement,\n ClockIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<ClockIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <ClockIconBase\n {...(componentProps as unknown as ComponentProps<typeof ClockIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const ClockIcon = Interactive.withSchema({\n Component: ClockIconInner,\n componentName: \"<ClockIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-cloud.json b/registry-artifacts/elements/icon-cloud.jsonindex 932e1004..32ec3146 100644--- a/registry-artifacts/elements/icon-cloud.json+++ b/registry-artifacts/elements/icon-cloud.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Cloud","durationInFrames": 70,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-cloud","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst CLOUD_PATH = \"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z\";\n\nconst TIMINGS = {\n drawDurationInFrames: 14,\n actionDelayInFrames: 2,\n actionDurationInFrames: 30,\n loop: false,\n} as const;\n\nfunction CloudIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress, actionFrame } =\n useIconAnimation({ animation, loop, speed }, TIMINGS);\n\n const acting = animation !== \"draw\" && actionFrame >= 0;\n\n const float = acting\n ? interpolate(actionProgress, [0, 0.35, 0.6, 0.8, 1], [0, -2, 0, -1, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.sin),\n })\n : 0;\n\n const cloud = drawnPathProps(CLOUD_PATH, drawProgress);\n\n const scale = 0.85 + 0.15 * scaleIn;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `translateY(${float}px) scale(${scale})`,\n }}\n >\n <path\n d={CLOUD_PATH}\n strokeDasharray={cloud.strokeDasharray}\n strokeDashoffset={cloud.strokeDashoffset}\n />\n </svg>\n );\n}\n\nfunction CloudIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d={CLOUD_PATH} />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype CloudIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof CloudIconBase>;\n\nconst CloudIconInner = forwardRef<\n HTMLDivElement,\n CloudIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<CloudIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <CloudIconBase\n {...(componentProps as unknown as ComponentProps<typeof CloudIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const CloudIcon = Interactive.withSchema({\n Component: CloudIconInner,\n componentName: \"<CloudIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-code.json b/registry-artifacts/elements/icon-code.jsonindex 24e4f3e5..d9833c19 100644--- a/registry-artifacts/elements/icon-code.json+++ b/registry-artifacts/elements/icon-code.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Code","durationInFrames": 70,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-code","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst RIGHT_PATH = \"M16 18 22 12 16 6\";\nconst LEFT_PATH = \"M8 6 2 12 8 18\";\n\nconst TIMINGS = {\n drawDurationInFrames: 12,\n actionDelayInFrames: 2,\n actionDurationInFrames: 22,\n loop: false,\n} as const;\n\nfunction CodeIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress, actionFrame } =\n useIconAnimation({ animation, loop, speed }, TIMINGS);\n\n const acting = animation !== \"draw\" && actionFrame >= 0;\n\n const open = acting\n ? interpolate(actionProgress, [0, 0.4, 1], [0, 2.5, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n })\n : 0;\n const pop = acting\n ? interpolate(actionProgress, [0.4, 0.7, 1], [1, 1.04, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n })\n : 1;\n\n const right = drawnPathProps(RIGHT_PATH, drawProgress);\n const left = drawnPathProps(LEFT_PATH, drawProgress);\n\n const scale = (0.85 + 0.15 * scaleIn) * pop;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `scale(${scale})`,\n }}\n >\n <g transform={`translate(${open} 0)`}>\n <path\n d={RIGHT_PATH}\n strokeDasharray={right.strokeDasharray}\n strokeDashoffset={right.strokeDashoffset}\n />\n </g>\n <g transform={`translate(${-open} 0)`}>\n <path\n d={LEFT_PATH}\n strokeDasharray={left.strokeDasharray}\n strokeDashoffset={left.strokeDashoffset}\n />\n </g>\n </svg>\n );\n}\n\nfunction CodeIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d=\"m16 18 6-6-6-6\" />\n <path d=\"m8 6-6 6 6 6\" />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype CodeIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof CodeIconBase>;\n\nconst CodeIconInner = forwardRef<\n HTMLDivElement,\n CodeIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<CodeIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <CodeIconBase\n {...(componentProps as unknown as ComponentProps<typeof CodeIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const CodeIcon = Interactive.withSchema({\n Component: CodeIconInner,\n componentName: \"<CodeIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-copy.json b/registry-artifacts/elements/icon-copy.jsonindex c170be85..3ef6d817 100644--- a/registry-artifacts/elements/icon-copy.json+++ b/registry-artifacts/elements/icon-copy.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Copy","durationInFrames": 70,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-copy","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst BACK_PATH = \"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2\";\nconst FRONT_PATH =\n \"M10 8H20A2 2 0 0 1 22 10V20A2 2 0 0 1 20 22H10A2 2 0 0 1 8 20V10A2 2 0 0 1 10 8Z\";\n\nconst TIMINGS = {\n drawDurationInFrames: 14,\n actionDelayInFrames: 2,\n actionDurationInFrames: 20,\n loop: false,\n} as const;\n\nfunction CopyIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress } = useIconAnimation(\n { animation, loop, speed },\n TIMINGS,\n );\n\n const linearDraw = 1 - (1 - drawProgress) ** (1 / 3);\n\n const backProgress = interpolate(linearDraw, [0, 0.714], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n });\n const frontProgress = interpolate(linearDraw, [0.286, 1], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n\n const back = drawnPathProps(BACK_PATH, backProgress);\n const front = drawnPathProps(FRONT_PATH, frontProgress);\n\n const offset = interpolate(\n actionProgress,\n [0, 0.35, 0.65, 1],\n [0, -2, -2, 0],\n {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n },\n );\n\n const scale = 0.85 + 0.15 * scaleIn;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `scale(${scale})`,\n }}\n >\n <path\n d={BACK_PATH}\n strokeDasharray={back.strokeDasharray}\n strokeDashoffset={back.strokeDashoffset}\n />\n <g transform={`translate(${offset} ${offset})`}>\n <path\n d={FRONT_PATH}\n strokeDasharray={front.strokeDasharray}\n strokeDashoffset={front.strokeDashoffset}\n />\n </g>\n </svg>\n );\n}\n\nfunction CopyIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <rect width=\"14\" height=\"14\" x=\"8\" y=\"8\" rx=\"2\" ry=\"2\" />\n <path d={BACK_PATH} />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype CopyIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof CopyIconBase>;\n\nconst CopyIconInner = forwardRef<\n HTMLDivElement,\n CopyIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<CopyIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <CopyIconBase\n {...(componentProps as unknown as ComponentProps<typeof CopyIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const CopyIcon = Interactive.withSchema({\n Component: CopyIconInner,\n componentName: \"<CopyIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-credit-card.json b/registry-artifacts/elements/icon-credit-card.jsonindex 2cd87f68..336f752d 100644--- a/registry-artifacts/elements/icon-credit-card.json+++ b/registry-artifacts/elements/icon-credit-card.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Credit Card","durationInFrames": 70,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-credit-card","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst CARD_PATH =\n \"M4 5H20A2 2 0 0 1 22 7V17A2 2 0 0 1 20 19H4A2 2 0 0 1 2 17V7A2 2 0 0 1 4 5Z\";\nconst STRIPE_PATH = \"M2 10H22\";\n\nconst PIVOT_X = 12;\nconst PIVOT_Y = 19;\n\nconst TIMINGS = {\n drawDurationInFrames: 14,\n actionDelayInFrames: 2,\n actionDurationInFrames: 24,\n loop: false,\n} as const;\n\nfunction CreditCardIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress, actionFrame } =\n useIconAnimation({ animation, loop, speed }, TIMINGS);\n\n const acting = animation !== \"draw\" && actionFrame >= 0;\n\n const swipe = interpolate(actionProgress, [0.1, 0.45], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.cubic),\n });\n const tilt = acting\n ? interpolate(actionProgress, [0.4, 0.6, 1], [0, 4, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n })\n : 0;\n\n const stripeProgress = animation === \"draw\" ? 1 : acting ? swipe : 0;\n\n const card = drawnPathProps(CARD_PATH, drawProgress);\n const stripe = drawnPathProps(STRIPE_PATH, stripeProgress);\n\n const scale = 0.85 + 0.15 * scaleIn;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `scale(${scale})`,\n }}\n >\n <g transform={`rotate(${tilt} ${PIVOT_X} ${PIVOT_Y})`}>\n <path\n d={CARD_PATH}\n strokeDasharray={card.strokeDasharray}\n strokeDashoffset={card.strokeDashoffset}\n />\n <path\n d={STRIPE_PATH}\n strokeDasharray={stripe.strokeDasharray}\n strokeDashoffset={stripe.strokeDashoffset}\n />\n </g>\n </svg>\n );\n}\n\nfunction CreditCardIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <rect width=\"20\" height=\"14\" x=\"2\" y=\"5\" rx=\"2\" />\n <line x1=\"2\" x2=\"22\" y1=\"10\" y2=\"10\" />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype CreditCardIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof CreditCardIconBase>;\n\nconst CreditCardIconInner = forwardRef<\n HTMLDivElement,\n CreditCardIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<CreditCardIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <CreditCardIconBase\n {...(componentProps as unknown as ComponentProps<typeof CreditCardIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const CreditCardIcon = Interactive.withSchema({\n Component: CreditCardIconInner,\n componentName: \"<CreditCardIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-crown.json b/registry-artifacts/elements/icon-crown.jsonindex 0896f89a..2099f7a1 100644--- a/registry-artifacts/elements/icon-crown.json+++ b/registry-artifacts/elements/icon-crown.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Crown","durationInFrames": 75,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-crown","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst CROWN_PATH =\n \"M11.562 3.266a.5.5 0 0 1 .876 0L15.39 8.87a1 1 0 0 0 1.516.294L21.183 5.5a.5.5 0 0 1 .798.519l-2.834 10.246a1 1 0 0 1-.956.734H5.81a1 1 0 0 1-.957-.734L2.02 6.02a.5.5 0 0 1 .798-.519l4.276 3.664a1 1 0 0 0 1.516-.294z\";\nconst BAND_PATH = \"M5 21h14\";\n\nconst BASE_X = 12;\nconst BASE_Y = 21;\n\nconst TIMINGS = {\n drawDurationInFrames: 16,\n actionDelayInFrames: 2,\n actionDurationInFrames: 28,\n loop: false,\n} as const;\n\nfunction CrownIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress, actionFrame } =\n useIconAnimation({ animation, loop, speed }, TIMINGS);\n\n const linearDraw = 1 - (1 - drawProgress) ** (1 / 3);\n const acting = animation !== \"draw\" && actionFrame >= 0;\n\n const crownDraw = interpolate(linearDraw, [0, 0.75], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n const bandDraw = interpolate(linearDraw, [0.5, 1], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n\n const descend = acting\n ? interpolate(actionProgress, [0, 0.22, 0.55], [0, -3, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.sin),\n })\n : 0;\n const pop = acting\n ? interpolate(actionProgress, [0.4, 0.55, 0.7], [1, 1.06, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n })\n : 1;\n const rock = acting\n ? interpolate(\n actionProgress,\n [0.55, 0.68, 0.82, 0.94, 1],\n [0, 2, -1.5, 0.8, 0],\n {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.sin),\n },\n )\n : 0;\n\n const crown = drawnPathProps(CROWN_PATH, acting ? 1 : crownDraw);\n const band = drawnPathProps(BAND_PATH, acting ? 1 : bandDraw);\n\n const scale = 0.85 + 0.15 * scaleIn;\n const actionTransform = `translate(0 ${descend}) rotate(${rock} ${BASE_X} ${BASE_Y}) translate(${BASE_X * (1 - pop)} ${BASE_Y * (1 - pop)}) scale(${pop})`;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `scale(${scale})`,\n }}\n >\n <g transform={actionTransform}>\n <path\n d={CROWN_PATH}\n strokeDasharray={crown.strokeDasharray}\n strokeDashoffset={crown.strokeDashoffset}\n />\n <path\n d={BAND_PATH}\n strokeDasharray={band.strokeDasharray}\n strokeDashoffset={band.strokeDashoffset}\n />\n </g>\n </svg>\n );\n}\n\nfunction CrownIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d=\"M11.562 3.266a.5.5 0 0 1 .876 0L15.39 8.87a1 1 0 0 0 1.516.294L21.183 5.5a.5.5 0 0 1 .798.519l-2.834 10.246a1 1 0 0 1-.956.734H5.81a1 1 0 0 1-.957-.734L2.02 6.02a.5.5 0 0 1 .798-.519l4.276 3.664a1 1 0 0 0 1.516-.294z\" />\n <path d=\"M5 21h14\" />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype CrownIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof CrownIconBase>;\n\nconst CrownIconInner = forwardRef<\n HTMLDivElement,\n CrownIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<CrownIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <CrownIconBase\n {...(componentProps as unknown as ComponentProps<typeof CrownIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const CrownIcon = Interactive.withSchema({\n Component: CrownIconInner,\n componentName: \"<CrownIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-database.json b/registry-artifacts/elements/icon-database.jsonindex 2e4f3900..3da0d322 100644--- a/registry-artifacts/elements/icon-database.json+++ b/registry-artifacts/elements/icon-database.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Database","durationInFrames": 80,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-database","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst DISC_PATH = \"M3 5A9 3 0 0 0 21 5A9 3 0 0 0 3 5Z\";\nconst BODY_PATH = \"M3 5V19A9 3 0 0 0 21 19V5\";\nconst MID_PATH = \"M3 12A9 3 0 0 0 21 12\";\n\nconst DISC_CX = 12;\nconst DISC_CY = 5;\n\nconst TIMINGS = {\n drawDurationInFrames: 18,\n actionDelayInFrames: 2,\n actionDurationInFrames: 24,\n loop: false,\n} as const;\n\nfunction DatabaseIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress, actionFrame } =\n useIconAnimation({ animation, loop, speed }, TIMINGS);\n\n const linearDraw = 1 - (1 - drawProgress) ** (1 / 3);\n const acting = animation !== \"draw\" && actionFrame >= 0;\n\n const discDraw = interpolate(linearDraw, [0, 0.55], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n const bodyDraw = interpolate(linearDraw, [0.35, 0.75], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n const midDraw = interpolate(linearDraw, [0.6, 1], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n\n const discPop = acting\n ? interpolate(actionProgress, [0, 0.25, 0.5], [1, 1.06, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n })\n : 1;\n const midDip = acting\n ? interpolate(actionProgress, [0.25, 0.5, 0.8], [0, 1.5, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n })\n : 0;\n\n const disc = drawnPathProps(DISC_PATH, acting ? 1 : discDraw);\n const body = drawnPathProps(BODY_PATH, acting ? 1 : bodyDraw);\n const mid = drawnPathProps(MID_PATH, acting ? 1 : midDraw);\n\n const scale = 0.85 + 0.15 * scaleIn;\n const discTransform = `translate(${DISC_CX * (1 - discPop)} ${DISC_CY * (1 - discPop)}) scale(${discPop})`;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `scale(${scale})`,\n }}\n >\n <path\n d={BODY_PATH}\n strokeDasharray={body.strokeDasharray}\n strokeDashoffset={body.strokeDashoffset}\n />\n <g transform={`translate(0 ${midDip})`}>\n <path\n d={MID_PATH}\n strokeDasharray={mid.strokeDasharray}\n strokeDashoffset={mid.strokeDashoffset}\n />\n </g>\n <g transform={discTransform}>\n <path\n d={DISC_PATH}\n strokeDasharray={disc.strokeDasharray}\n strokeDashoffset={disc.strokeDashoffset}\n />\n </g>\n </svg>\n );\n}\n\nfunction DatabaseIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <ellipse cx=\"12\" cy=\"5\" rx=\"9\" ry=\"3\" />\n <path d=\"M3 5V19A9 3 0 0 0 21 19V5\" />\n <path d=\"M3 12A9 3 0 0 0 21 12\" />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype DatabaseIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof DatabaseIconBase>;\n\nconst DatabaseIconInner = forwardRef<\n HTMLDivElement,\n DatabaseIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<DatabaseIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <DatabaseIconBase\n {...(componentProps as unknown as ComponentProps<typeof DatabaseIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const DatabaseIcon = Interactive.withSchema({\n Component: DatabaseIconInner,\n componentName: \"<DatabaseIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-dollar-sign.json b/registry-artifacts/elements/icon-dollar-sign.jsonindex 0cfada6c..82c80793 100644--- a/registry-artifacts/elements/icon-dollar-sign.json+++ b/registry-artifacts/elements/icon-dollar-sign.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Dollar Sign","durationInFrames": 70,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-dollar-sign","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst BAR_PATH = \"M12 2V22\";\nconst S_PATH = \"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6\";\n\nconst BASE_Y = 22;\n\nconst TIMINGS = {\n drawDurationInFrames: 14,\n actionDelayInFrames: 2,\n actionDurationInFrames: 20,\n loop: false,\n} as const;\n\nfunction DollarSignIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress, actionFrame } =\n useIconAnimation({ animation, loop, speed }, TIMINGS);\n\n const linearDraw = 1 - (1 - drawProgress) ** (1 / 3);\n const acting = animation !== \"draw\" && actionFrame >= 0;\n\n const barDraw = interpolate(linearDraw, [0, 0.55], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n const sDraw = interpolate(linearDraw, [0.3, 1], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n\n const stretch = acting\n ? interpolate(actionProgress, [0.1, 0.5, 1], [1, 1.1, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n })\n : 1;\n\n const bar = drawnPathProps(BAR_PATH, acting ? 1 : barDraw);\n const s = drawnPathProps(S_PATH, acting ? 1 : sDraw);\n\n const scale = 0.85 + 0.15 * scaleIn;\n const stretchTransform = `translate(0 ${BASE_Y * (1 - stretch)}) scale(1 ${stretch})`;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `scale(${scale})`,\n }}\n >\n <g transform={stretchTransform}>\n <path\n d={BAR_PATH}\n strokeDasharray={bar.strokeDasharray}\n strokeDashoffset={bar.strokeDashoffset}\n />\n <path\n d={S_PATH}\n strokeDasharray={s.strokeDasharray}\n strokeDashoffset={s.strokeDashoffset}\n />\n </g>\n </svg>\n );\n}\n\nfunction DollarSignIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <line x1=\"12\" x2=\"12\" y1=\"2\" y2=\"22\" />\n <path d={S_PATH} />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype DollarSignIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof DollarSignIconBase>;\n\nconst DollarSignIconInner = forwardRef<\n HTMLDivElement,\n DollarSignIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<DollarSignIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <DollarSignIconBase\n {...(componentProps as unknown as ComponentProps<typeof DollarSignIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const DollarSignIcon = Interactive.withSchema({\n Component: DollarSignIconInner,\n componentName: \"<DollarSignIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-download.json b/registry-artifacts/elements/icon-download.jsonindex e85fe86c..7934cd1b 100644--- a/registry-artifacts/elements/icon-download.json+++ b/registry-artifacts/elements/icon-download.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Download","durationInFrames": 70,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-download","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst TRAY_DRAW = \"M3 15v4a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-4\";\nconst TRAY_STATIC = \"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4\";\nconst SHAFT_DRAW = \"M12 3V15\";\nconst SHAFT_STATIC = \"M12 15V3\";\nconst HEAD_PATH = \"M7 10 12 15 17 10\";\n\nconst TIMINGS = {\n drawDurationInFrames: 14,\n actionDelayInFrames: 2,\n actionDurationInFrames: 18,\n loop: false,\n} as const;\n\nfunction DownloadIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress } = useIconAnimation(\n { animation, loop, speed },\n TIMINGS,\n );\n\n const linearDraw = 1 - (1 - drawProgress) ** (1 / 3);\n\n const trayProgress = interpolate(linearDraw, [0, 0.714], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n });\n const arrowProgress = interpolate(linearDraw, [0.429, 1], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n const arrowOpacity = interpolate(linearDraw, [0.429, 0.6], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n });\n\n const tray = drawnPathProps(TRAY_DRAW, trayProgress);\n const shaft = drawnPathProps(SHAFT_DRAW, arrowProgress);\n const head = drawnPathProps(HEAD_PATH, arrowProgress);\n\n const dropY = interpolate(actionProgress, [0, 0.25, 0.65, 1], [0, -4, 3, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n });\n const traySquash = interpolate(\n actionProgress,\n [0, 0.5, 0.65, 0.8, 1],\n [1, 1, 0.94, 1, 1],\n { extrapolateLeft: \"clamp\", extrapolateRight: \"clamp\" },\n );\n\n const scale = 0.85 + 0.15 * scaleIn;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `scale(${scale})`,\n }}\n >\n <g\n transform={`translate(12 21) scale(1 ${traySquash}) translate(-12 -21)`}\n >\n <path\n d={TRAY_DRAW}\n strokeDasharray={tray.strokeDasharray}\n strokeDashoffset={tray.strokeDashoffset}\n />\n </g>\n <g opacity={arrowOpacity} transform={`translate(0 ${dropY})`}>\n <path\n d={SHAFT_DRAW}\n strokeDasharray={shaft.strokeDasharray}\n strokeDashoffset={shaft.strokeDashoffset}\n />\n <path\n d={HEAD_PATH}\n strokeDasharray={head.strokeDasharray}\n strokeDashoffset={head.strokeDashoffset}\n />\n </g>\n </svg>\n );\n}\n\nfunction DownloadIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d={SHAFT_STATIC} />\n <path d={TRAY_STATIC} />\n <path d={HEAD_PATH} />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype DownloadIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof DownloadIconBase>;\n\nconst DownloadIconInner = forwardRef<\n HTMLDivElement,\n DownloadIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<DownloadIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <DownloadIconBase\n {...(componentProps as unknown as ComponentProps<typeof DownloadIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const DownloadIcon = Interactive.withSchema({\n Component: DownloadIconInner,\n componentName: \"<DownloadIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-external-link.json b/registry-artifacts/elements/icon-external-link.jsonindex 2a5df021..d5859178 100644--- a/registry-artifacts/elements/icon-external-link.json+++ b/registry-artifacts/elements/icon-external-link.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "External Link","durationInFrames": 70,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-external-link","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst BOX_PATH = \"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6\";\nconst SHAFT_PATH = \"M10 14 21 3\";\nconst HEAD_PATH = \"M15 3h6v6\";\n\nconst ARROW_CX = 15.5;\nconst ARROW_CY = 8.5;\n\nconst TIMINGS = {\n drawDurationInFrames: 16,\n actionDelayInFrames: 2,\n actionDurationInFrames: 20,\n loop: false,\n} as const;\n\nfunction ExternalLinkIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress } = useIconAnimation(\n { animation, loop, speed },\n TIMINGS,\n );\n\n const linearDraw = 1 - (1 - drawProgress) ** (1 / 3);\n\n const boxProgress = interpolate(linearDraw, [0, 0.75], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n const shaftProgress = interpolate(linearDraw, [0.5, 0.875], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n });\n const headProgress = interpolate(linearDraw, [0.75, 1], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n });\n\n const box = drawnPathProps(BOX_PATH, boxProgress);\n const shaft = drawnPathProps(SHAFT_PATH, shaftProgress);\n const head = drawnPathProps(HEAD_PATH, headProgress);\n\n const dart = interpolate(actionProgress, [0, 0.4, 0.6, 1], [0, 1, 1, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n });\n const tx = 3 * dart;\n const ty = -3 * dart;\n const arrowScale = 1 + 0.05 * dart;\n const scale = 0.85 + 0.15 * scaleIn;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `scale(${scale})`,\n }}\n >\n <path\n d={BOX_PATH}\n strokeDasharray={box.strokeDasharray}\n strokeDashoffset={box.strokeDashoffset}\n />\n <g\n transform={`translate(${tx} ${ty}) translate(${ARROW_CX} ${ARROW_CY}) scale(${arrowScale}) translate(${-ARROW_CX} ${-ARROW_CY})`}\n >\n <path\n d={SHAFT_PATH}\n strokeDasharray={shaft.strokeDasharray}\n strokeDashoffset={shaft.strokeDashoffset}\n />\n <path\n d={HEAD_PATH}\n strokeDasharray={head.strokeDasharray}\n strokeDashoffset={head.strokeDashoffset}\n />\n </g>\n </svg>\n );\n}\n\nfunction ExternalLinkIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d={BOX_PATH} />\n <path d={SHAFT_PATH} />\n <path d={HEAD_PATH} />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype ExternalLinkIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof ExternalLinkIconBase>;\n\nconst ExternalLinkIconInner = forwardRef<\n HTMLDivElement,\n ExternalLinkIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<ExternalLinkIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <ExternalLinkIconBase\n {...(componentProps as unknown as ComponentProps<typeof ExternalLinkIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const ExternalLinkIcon = Interactive.withSchema({\n Component: ExternalLinkIconInner,\n componentName: \"<ExternalLinkIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-eye-off.json b/registry-artifacts/elements/icon-eye-off.jsonindex bb212999..2308f2f8 100644--- a/registry-artifacts/elements/icon-eye-off.json+++ b/registry-artifacts/elements/icon-eye-off.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Eye Off","durationInFrames": 70,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-eye-off","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst FRAG1_PATH =\n \"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49\";\nconst FRAG2_PATH = \"M14.084 14.158a3 3 0 0 1-4.242-4.242\";\nconst FRAG3_PATH =\n \"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143\";\nconst SLASH_PATH = \"M2 2 22 22\";\n\nconst TIMINGS = {\n drawDurationInFrames: 16,\n actionDelayInFrames: 2,\n actionDurationInFrames: 22,\n loop: false,\n} as const;\n\nconst FRAGMENTS = [\n { path: FRAG1_PATH, drawWindow: [0, 0.69] },\n { path: FRAG2_PATH, drawWindow: [0.19, 0.88] },\n { path: FRAG3_PATH, drawWindow: [0.375, 1] },\n] as const;\n\nfunction EyeOffIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress, actionFrame } =\n useIconAnimation({ animation, loop, speed }, TIMINGS);\n\n const linearDraw = 1 - (1 - drawProgress) ** (1 / 3);\n const acting = animation !== \"draw\" && actionFrame >= 0;\n\n const slashProgress = acting\n ? interpolate(actionProgress, [0, 0.45], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n })\n : 0;\n const fragOpacity = acting\n ? interpolate(actionProgress, [0.09, 0.5, 1], [1, 0.35, 0.6], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n })\n : 1;\n\n const slash = drawnPathProps(SLASH_PATH, slashProgress);\n const scale = 0.85 + 0.15 * scaleIn;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `scale(${scale})`,\n }}\n >\n <g opacity={fragOpacity}>\n {FRAGMENTS.map((frag) => {\n const drawn = acting\n ? 1\n : interpolate(linearDraw, [...frag.drawWindow], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n const dash = drawnPathProps(frag.path, drawn);\n return (\n <path\n key={frag.path}\n d={frag.path}\n strokeDasharray={dash.strokeDasharray}\n strokeDashoffset={dash.strokeDashoffset}\n />\n );\n })}\n </g>\n <path\n d={SLASH_PATH}\n strokeDasharray={slash.strokeDasharray}\n strokeDashoffset={slash.strokeDashoffset}\n />\n </svg>\n );\n}\n\nfunction EyeOffIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d={FRAG1_PATH} />\n <path d={FRAG2_PATH} />\n <path d={FRAG3_PATH} />\n <path d={SLASH_PATH} />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype EyeOffIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof EyeOffIconBase>;\n\nconst EyeOffIconInner = forwardRef<\n HTMLDivElement,\n EyeOffIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<EyeOffIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <EyeOffIconBase\n {...(componentProps as unknown as ComponentProps<typeof EyeOffIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const EyeOffIcon = Interactive.withSchema({\n Component: EyeOffIconInner,\n componentName: \"<EyeOffIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-eye.json b/registry-artifacts/elements/icon-eye.jsonindex 4ed42de3..d36d4383 100644--- a/registry-artifacts/elements/icon-eye.json+++ b/registry-artifacts/elements/icon-eye.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Eye","durationInFrames": 70,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-eye","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst OUTLINE_PATH =\n \"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0\";\nconst PUPIL_PATH =\n \"M12 9 A3 3 0 0 1 15 12 A3 3 0 0 1 12 15 A3 3 0 0 1 9 12 A3 3 0 0 1 12 9\";\n\nconst TIMINGS = {\n drawDurationInFrames: 16,\n actionDelayInFrames: 2,\n actionDurationInFrames: 22,\n loop: false,\n} as const;\n\nfunction EyeIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress, actionFrame } =\n useIconAnimation({ animation, loop, speed }, TIMINGS);\n\n const linearDraw = 1 - (1 - drawProgress) ** (1 / 3);\n const acting = animation !== \"draw\" && actionFrame >= 0;\n\n const outlineDraw = interpolate(linearDraw, [0, 0.75], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n const pupilDraw = interpolate(linearDraw, [0.5, 1], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n\n const blink = acting\n ? interpolate(actionProgress, [0, 0.27, 0.55], [1, 0.4, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n })\n : 1;\n const pupilPop =\n acting && actionProgress >= 0.55\n ? interpolate(actionProgress, [0.55, 0.77, 1], [0.8, 1.1, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n })\n : 1;\n\n const outline = drawnPathProps(OUTLINE_PATH, outlineDraw);\n const pupil = drawnPathProps(PUPIL_PATH, pupilDraw);\n\n const scale = 0.85 + 0.15 * scaleIn;\n const pupilTransform = `translate(${12 * (1 - pupilPop)} ${12 * (1 - pupilPop)}) scale(${pupilPop})`;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `scale(${scale}) scaleY(${blink})`,\n }}\n >\n <path\n d={OUTLINE_PATH}\n strokeDasharray={outline.strokeDasharray}\n strokeDashoffset={outline.strokeDashoffset}\n />\n <g transform={pupilTransform}>\n <path\n d={PUPIL_PATH}\n strokeDasharray={pupil.strokeDasharray}\n strokeDashoffset={pupil.strokeDashoffset}\n />\n </g>\n </svg>\n );\n}\n\nfunction EyeIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d={OUTLINE_PATH} />\n <circle cx=\"12\" cy=\"12\" r=\"3\" />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype EyeIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof EyeIconBase>;\n\nconst EyeIconInner = forwardRef<\n HTMLDivElement,\n EyeIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<EyeIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <EyeIconBase\n {...(componentProps as unknown as ComponentProps<typeof EyeIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const EyeIcon = Interactive.withSchema({\n Component: EyeIconInner,\n componentName: \"<EyeIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-file-text.json b/registry-artifacts/elements/icon-file-text.jsonindex 6c4c9faf..88bc5c53 100644--- a/registry-artifacts/elements/icon-file-text.json+++ b/registry-artifacts/elements/icon-file-text.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "File Text","durationInFrames": 80,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-file-text","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst PAGE_PATH =\n \"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z\";\nconst FOLD_PATH = \"M14 2v5a1 1 0 0 0 1 1h5\";\nconst LINE1_PATH = \"M8 9H10\";\nconst LINE2_PATH = \"M8 13H16\";\nconst LINE3_PATH = \"M8 17H16\";\n\nconst TIMINGS = {\n drawDurationInFrames: 14,\n actionDelayInFrames: 2,\n actionDurationInFrames: 26,\n loop: false,\n} as const;\n\nfunction FileTextIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress, actionFrame } =\n useIconAnimation({ animation, loop, speed }, TIMINGS);\n\n const linearDraw = 1 - (1 - drawProgress) ** (1 / 3);\n const acting = animation !== \"draw\" && actionFrame >= 0;\n\n const pageDraw = interpolate(linearDraw, [0, 0.7], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n const foldDraw = interpolate(linearDraw, [0.55, 1], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n\n const line1Type = interpolate(actionProgress, [0.05, 0.4], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.linear,\n });\n const line2Type = interpolate(actionProgress, [0.3, 0.65], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.linear,\n });\n const line3Type = interpolate(actionProgress, [0.55, 0.9], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.linear,\n });\n\n const line1Progress = animation === \"draw\" ? 1 : acting ? line1Type : 0;\n const line2Progress = animation === \"draw\" ? 1 : acting ? line2Type : 0;\n const line3Progress = animation === \"draw\" ? 1 : acting ? line3Type : 0;\n\n const page = drawnPathProps(PAGE_PATH, acting ? 1 : pageDraw);\n const fold = drawnPathProps(FOLD_PATH, acting ? 1 : foldDraw);\n const line1 = drawnPathProps(LINE1_PATH, line1Progress);\n const line2 = drawnPathProps(LINE2_PATH, line2Progress);\n const line3 = drawnPathProps(LINE3_PATH, line3Progress);\n\n const scale = 0.85 + 0.15 * scaleIn;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `scale(${scale})`,\n }}\n >\n <path\n d={PAGE_PATH}\n strokeDasharray={page.strokeDasharray}\n strokeDashoffset={page.strokeDashoffset}\n />\n <path\n d={FOLD_PATH}\n strokeDasharray={fold.strokeDasharray}\n strokeDashoffset={fold.strokeDashoffset}\n />\n <path\n d={LINE1_PATH}\n strokeDasharray={line1.strokeDasharray}\n strokeDashoffset={line1.strokeDashoffset}\n />\n <path\n d={LINE2_PATH}\n strokeDasharray={line2.strokeDasharray}\n strokeDashoffset={line2.strokeDashoffset}\n />\n <path\n d={LINE3_PATH}\n strokeDasharray={line3.strokeDasharray}\n strokeDashoffset={line3.strokeDashoffset}\n />\n </svg>\n );\n}\n\nfunction FileTextIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d={PAGE_PATH} />\n <path d={FOLD_PATH} />\n <path d=\"M10 9H8\" />\n <path d=\"M16 13H8\" />\n <path d=\"M16 17H8\" />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype FileTextIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof FileTextIconBase>;\n\nconst FileTextIconInner = forwardRef<\n HTMLDivElement,\n FileTextIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<FileTextIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <FileTextIconBase\n {...(componentProps as unknown as ComponentProps<typeof FileTextIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const FileTextIcon = Interactive.withSchema({\n Component: FileTextIconInner,\n componentName: \"<FileTextIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-filter.json b/registry-artifacts/elements/icon-filter.jsonindex 947caf08..783b9126 100644--- a/registry-artifacts/elements/icon-filter.json+++ b/registry-artifacts/elements/icon-filter.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Filter","durationInFrames": 70,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-filter","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst FUNNEL_PATH =\n \"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z\";\n\nconst TIMINGS = {\n drawDurationInFrames: 14,\n actionDelayInFrames: 2,\n actionDurationInFrames: 20,\n loop: false,\n} as const;\n\nfunction FilterIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress, actionFrame } =\n useIconAnimation({ animation, loop, speed }, TIMINGS);\n\n const acting = animation !== \"draw\" && actionFrame >= 0;\n\n const rotate = acting\n ? interpolate(actionProgress, [0, 0.3, 0.6, 1], [0, -5, 5, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n })\n : 0;\n const dip = acting\n ? interpolate(actionProgress, [0, 0.3, 0.6, 1], [0, 1, 1, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n })\n : 0;\n\n const dash = drawnPathProps(FUNNEL_PATH, drawProgress);\n const scale = 0.85 + 0.15 * scaleIn;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `scale(${scale})`,\n }}\n >\n <g transform={`rotate(${rotate} 12 3) translate(0 ${dip})`}>\n <path\n d={FUNNEL_PATH}\n strokeDasharray={dash.strokeDasharray}\n strokeDashoffset={dash.strokeDashoffset}\n />\n </g>\n </svg>\n );\n}\n\nfunction FilterIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d={FUNNEL_PATH} />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype FilterIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof FilterIconBase>;\n\nconst FilterIconInner = forwardRef<\n HTMLDivElement,\n FilterIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<FilterIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <FilterIconBase\n {...(componentProps as unknown as ComponentProps<typeof FilterIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const FilterIcon = Interactive.withSchema({\n Component: FilterIconInner,\n componentName: \"<FilterIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-flame.json b/registry-artifacts/elements/icon-flame.jsonindex ecf6aabb..16c2b250 100644--- a/registry-artifacts/elements/icon-flame.json+++ b/registry-artifacts/elements/icon-flame.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Flame","durationInFrames": 90,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-flame","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst FLAME_PATH =\n \"M12 3q1 4 4 6.5t3 5.5a1 1 0 0 1-14 0 5 5 0 0 1 1-3 1 1 0 0 0 5 0c0-2-1.5-3-1.5-5q0-2 2.5-4\";\n\nconst TIMINGS = {\n drawDurationInFrames: 14,\n actionDelayInFrames: 2,\n actionDurationInFrames: 40,\n loop: true,\n} as const;\n\nfunction FlameIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, actionProgress } = useIconAnimation(\n { animation, loop, speed },\n TIMINGS,\n );\n\n const linearDraw = 1 - (1 - drawProgress) ** (1 / 3);\n\n const flameProgress = interpolate(linearDraw, [0, 1], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n });\n const entrance = interpolate(linearDraw, [0, 1], [0.85, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n\n const flame = drawnPathProps(FLAME_PATH, flameProgress);\n\n const flickerEase = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n } as const;\n const scaleY = interpolate(\n actionProgress,\n [0, 0.25, 0.5, 0.75, 1],\n [1, 1.06, 0.97, 1.04, 1],\n flickerEase,\n );\n const skew = interpolate(\n actionProgress,\n [0, 0.25, 0.5, 0.75, 1],\n [0, -2, 2, -1, 0],\n flickerEase,\n );\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `scale(${entrance})`,\n }}\n >\n <g\n transform={`translate(12 22) scale(1 ${scaleY}) skewX(${skew}) translate(-12 -22)`}\n >\n <path\n d={FLAME_PATH}\n strokeDasharray={flame.strokeDasharray}\n strokeDashoffset={flame.strokeDashoffset}\n />\n </g>\n </svg>\n );\n}\n\nfunction FlameIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d={FLAME_PATH} />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: true,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: true,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype FlameIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof FlameIconBase>;\n\nconst FlameIconInner = forwardRef<\n HTMLDivElement,\n FlameIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<FlameIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <FlameIconBase\n {...(componentProps as unknown as ComponentProps<typeof FlameIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const FlameIcon = Interactive.withSchema({\n Component: FlameIconInner,\n componentName: \"<FlameIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-folder.json b/registry-artifacts/elements/icon-folder.jsonindex 653578db..b9d07296 100644--- a/registry-artifacts/elements/icon-folder.json+++ b/registry-artifacts/elements/icon-folder.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Folder","durationInFrames": 70,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-folder","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst FOLDER_PATH =\n \"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z\";\n\nconst PIVOT_X = 4;\nconst PIVOT_Y = 20;\n\nconst TIMINGS = {\n drawDurationInFrames: 14,\n actionDelayInFrames: 2,\n actionDurationInFrames: 20,\n loop: false,\n} as const;\n\nfunction FolderIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress, actionFrame } =\n useIconAnimation({ animation, loop, speed }, TIMINGS);\n\n const acting = animation !== \"draw\" && actionFrame >= 0;\n\n const peek = acting\n ? interpolate(actionProgress, [0, 0.45, 1], [0, -4, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n })\n : 0;\n\n const folder = drawnPathProps(FOLDER_PATH, drawProgress);\n\n const scale = 0.85 + 0.15 * scaleIn;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `scale(${scale})`,\n }}\n >\n <g transform={`rotate(${peek} ${PIVOT_X} ${PIVOT_Y})`}>\n <path\n d={FOLDER_PATH}\n strokeDasharray={folder.strokeDasharray}\n strokeDashoffset={folder.strokeDashoffset}\n />\n </g>\n </svg>\n );\n}\n\nfunction FolderIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d={FOLDER_PATH} />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype FolderIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof FolderIconBase>;\n\nconst FolderIconInner = forwardRef<\n HTMLDivElement,\n FolderIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<FolderIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <FolderIconBase\n {...(componentProps as unknown as ComponentProps<typeof FolderIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const FolderIcon = Interactive.withSchema({\n Component: FolderIconInner,\n componentName: \"<FolderIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-gem.json b/registry-artifacts/elements/icon-gem.jsonindex f63140d2..3ca24ca4 100644--- a/registry-artifacts/elements/icon-gem.json+++ b/registry-artifacts/elements/icon-gem.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Gem","durationInFrames": 80,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-gem","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst STONE_PATH =\n \"M17 3a2 2 0 0 1 1.6.8l3 4a2 2 0 0 1 .013 2.382l-7.99 10.986a2 2 0 0 1-3.247 0l-7.99-10.986A2 2 0 0 1 2.4 7.8l2.998-3.997A2 2 0 0 1 7 3z\";\nconst VCUT_PATH = \"M10.5 3 8 9l4 13 4-13-2.5-6\";\nconst BAND_PATH = \"M2 9h20\";\n\nconst CENTER = 12;\n\nconst TIMINGS = {\n drawDurationInFrames: 18,\n actionDelayInFrames: 2,\n actionDurationInFrames: 24,\n loop: false,\n} as const;\n\nfunction GemIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress, actionFrame } =\n useIconAnimation({ animation, loop, speed }, TIMINGS);\n\n const linearDraw = 1 - (1 - drawProgress) ** (1 / 3);\n const acting = animation !== \"draw\" && actionFrame >= 0;\n\n const stoneDraw = interpolate(linearDraw, [0, 0.67], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n const vcutDraw = interpolate(linearDraw, [0.44, 0.89], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n const bandDraw = interpolate(linearDraw, [0.67, 1], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n\n const pop = acting\n ? interpolate(actionProgress, [0, 0.35, 0.6, 1], [1, 1.06, 1, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n })\n : 1;\n const shimmer = acting\n ? interpolate(\n actionProgress,\n [0, 0.25, 0.45, 0.65, 0.85, 1],\n [1, 0.7, 1, 0.78, 1, 1],\n {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.sin),\n },\n )\n : 1;\n\n const stone = drawnPathProps(STONE_PATH, acting ? 1 : stoneDraw);\n const vcut = drawnPathProps(VCUT_PATH, acting ? 1 : vcutDraw);\n const band = drawnPathProps(BAND_PATH, acting ? 1 : bandDraw);\n\n const scale = 0.85 + 0.15 * scaleIn;\n const popTransform = `translate(${CENTER * (1 - pop)} ${CENTER * (1 - pop)}) scale(${pop})`;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `scale(${scale})`,\n }}\n >\n <g transform={popTransform}>\n <path\n d={STONE_PATH}\n strokeDasharray={stone.strokeDasharray}\n strokeDashoffset={stone.strokeDashoffset}\n />\n <g opacity={shimmer}>\n <path\n d={VCUT_PATH}\n strokeDasharray={vcut.strokeDasharray}\n strokeDashoffset={vcut.strokeDashoffset}\n />\n <path\n d={BAND_PATH}\n strokeDasharray={band.strokeDasharray}\n strokeDashoffset={band.strokeDashoffset}\n />\n </g>\n </g>\n </svg>\n );\n}\n\nfunction GemIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d=\"M10.5 3 8 9l4 13 4-13-2.5-6\" />\n <path d=\"M17 3a2 2 0 0 1 1.6.8l3 4a2 2 0 0 1 .013 2.382l-7.99 10.986a2 2 0 0 1-3.247 0l-7.99-10.986A2 2 0 0 1 2.4 7.8l2.998-3.997A2 2 0 0 1 7 3z\" />\n <path d=\"M2 9h20\" />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype GemIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof GemIconBase>;\n\nconst GemIconInner = forwardRef<\n HTMLDivElement,\n GemIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<GemIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <GemIconBase\n {...(componentProps as unknown as ComponentProps<typeof GemIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const GemIcon = Interactive.withSchema({\n Component: GemIconInner,\n componentName: \"<GemIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-gift.json b/registry-artifacts/elements/icon-gift.jsonindex c43b9748..a0ab5465 100644--- a/registry-artifacts/elements/icon-gift.json+++ b/registry-artifacts/elements/icon-gift.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Gift","durationInFrames": 80,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-gift","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst BOX_PATH = \"M20 11v8a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-8\";\nconst LID_PATH =\n \"M4 7H20A1 1 0 0 1 21 8V10A1 1 0 0 1 20 11H4A1 1 0 0 1 3 10V8A1 1 0 0 1 4 7Z\";\nconst CENTER_TOP_PATH = \"M12 7V11\";\nconst CENTER_BOTTOM_PATH = \"M12 11V21\";\nconst BOW_PATH =\n \"M7.5 7a1 1 0 0 1 0-5A4.8 8 0 0 1 12 7a4.8 8 0 0 1 4.5-5 1 1 0 0 1 0 5\";\n\nconst LID_CX = 12;\nconst LID_CY = 9;\n\nconst TIMINGS = {\n drawDurationInFrames: 18,\n actionDelayInFrames: 2,\n actionDurationInFrames: 28,\n loop: false,\n} as const;\n\nfunction GiftIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress, actionFrame } =\n useIconAnimation({ animation, loop, speed }, TIMINGS);\n\n const linearDraw = 1 - (1 - drawProgress) ** (1 / 3);\n const acting = animation !== \"draw\" && actionFrame >= 0;\n\n const boxDraw = interpolate(linearDraw, [0, 0.55], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n const lidDraw = interpolate(linearDraw, [0.35, 0.7], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n const ribbonDraw = interpolate(linearDraw, [0.6, 1], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n\n const lidLift = acting\n ? interpolate(actionProgress, [0, 0.4, 0.65], [0, -2.5, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n })\n : 0;\n const lidTilt = acting\n ? interpolate(actionProgress, [0, 0.4, 0.65], [0, 3, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n })\n : 0;\n const lidPop = acting\n ? interpolate(actionProgress, [0.6, 0.78, 1], [1, 1.06, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n })\n : 1;\n\n const box = drawnPathProps(BOX_PATH, acting ? 1 : boxDraw);\n const lid = drawnPathProps(LID_PATH, acting ? 1 : lidDraw);\n const centerTop = drawnPathProps(CENTER_TOP_PATH, acting ? 1 : ribbonDraw);\n const centerBottom = drawnPathProps(\n CENTER_BOTTOM_PATH,\n acting ? 1 : ribbonDraw,\n );\n const bow = drawnPathProps(BOW_PATH, acting ? 1 : ribbonDraw);\n\n const scale = 0.85 + 0.15 * scaleIn;\n const lidTransform = `translate(0 ${lidLift}) rotate(${lidTilt} ${LID_CX} ${LID_CY}) translate(${LID_CX * (1 - lidPop)} ${LID_CY * (1 - lidPop)}) scale(${lidPop})`;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `scale(${scale})`,\n }}\n >\n <path\n d={BOX_PATH}\n strokeDasharray={box.strokeDasharray}\n strokeDashoffset={box.strokeDashoffset}\n />\n <path\n d={CENTER_BOTTOM_PATH}\n strokeDasharray={centerBottom.strokeDasharray}\n strokeDashoffset={centerBottom.strokeDashoffset}\n />\n <g transform={lidTransform}>\n <path\n d={LID_PATH}\n strokeDasharray={lid.strokeDasharray}\n strokeDashoffset={lid.strokeDashoffset}\n />\n <path\n d={CENTER_TOP_PATH}\n strokeDasharray={centerTop.strokeDasharray}\n strokeDashoffset={centerTop.strokeDashoffset}\n />\n <path\n d={BOW_PATH}\n strokeDasharray={bow.strokeDasharray}\n strokeDashoffset={bow.strokeDashoffset}\n />\n </g>\n </svg>\n );\n}\n\nfunction GiftIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d=\"M12 7v14\" />\n <path d={BOX_PATH} />\n <path d={BOW_PATH} />\n <rect x=\"3\" y=\"7\" width=\"18\" height=\"4\" rx=\"1\" />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype GiftIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof GiftIconBase>;\n\nconst GiftIconInner = forwardRef<\n HTMLDivElement,\n GiftIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<GiftIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <GiftIconBase\n {...(componentProps as unknown as ComponentProps<typeof GiftIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const GiftIcon = Interactive.withSchema({\n Component: GiftIconInner,\n componentName: \"<GiftIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-globe.json b/registry-artifacts/elements/icon-globe.jsonindex e27c07aa..6c6428f7 100644--- a/registry-artifacts/elements/icon-globe.json+++ b/registry-artifacts/elements/icon-globe.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Globe","durationInFrames": 90,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-globe","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst SPHERE_PATH = \"M12 2a10 10 0 1 0 0 20 10 10 0 1 0 0-20Z\";\nconst MERIDIAN_PATH = \"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20\";\nconst EQUATOR_PATH = \"M2 12H22\";\n\nconst AXIS_X = 12;\n\nconst TIMINGS = {\n drawDurationInFrames: 16,\n actionDelayInFrames: 2,\n actionDurationInFrames: 40,\n loop: true,\n} as const;\n\nfunction GlobeIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress, actionFrame } =\n useIconAnimation({ animation, loop, speed }, TIMINGS);\n\n const linearDraw = 1 - (1 - drawProgress) ** (1 / 3);\n const acting = animation !== \"draw\" && actionFrame >= 0;\n\n const sphereDraw = interpolate(linearDraw, [0, 0.7], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n const linesDraw = interpolate(linearDraw, [0.5, 1], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n\n const spinX = acting ? Math.cos(actionProgress * Math.PI * 2) : 1;\n\n const sphere = drawnPathProps(SPHERE_PATH, acting ? 1 : sphereDraw);\n const meridian = drawnPathProps(MERIDIAN_PATH, acting ? 1 : linesDraw);\n const equator = drawnPathProps(EQUATOR_PATH, acting ? 1 : linesDraw);\n\n const scale = 0.85 + 0.15 * scaleIn;\n const spinTransform = `translate(${AXIS_X * (1 - spinX)} 0) scale(${spinX} 1)`;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `scale(${scale})`,\n }}\n >\n <g transform={spinTransform}>\n <path\n d={SPHERE_PATH}\n strokeDasharray={sphere.strokeDasharray}\n strokeDashoffset={sphere.strokeDashoffset}\n />\n <path\n d={EQUATOR_PATH}\n strokeDasharray={equator.strokeDasharray}\n strokeDashoffset={equator.strokeDashoffset}\n />\n <path\n d={MERIDIAN_PATH}\n strokeDasharray={meridian.strokeDasharray}\n strokeDashoffset={meridian.strokeDashoffset}\n />\n </g>\n </svg>\n );\n}\n\nfunction GlobeIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <circle cx=\"12\" cy=\"12\" r=\"10\" />\n <path d={MERIDIAN_PATH} />\n <path d=\"M2 12h20\" />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: true,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: true,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype GlobeIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof GlobeIconBase>;\n\nconst GlobeIconInner = forwardRef<\n HTMLDivElement,\n GlobeIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<GlobeIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <GlobeIconBase\n {...(componentProps as unknown as ComponentProps<typeof GlobeIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const GlobeIcon = Interactive.withSchema({\n Component: GlobeIconInner,\n componentName: \"<GlobeIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-heart.json b/registry-artifacts/elements/icon-heart.jsonindex a906fb85..252a46f3 100644--- a/registry-artifacts/elements/icon-heart.json+++ b/registry-artifacts/elements/icon-heart.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Heart","durationInFrames": 75,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-heart","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst HEART_PATH =\n \"M2 9.5a5.5 5.5 0 0 1 9.591-3.676.56.56 0 0 0 .818 0A5.49 5.49 0 0 1 22 9.5c0 2.29-1.5 4-3 5.5l-5.492 5.313a2 2 0 0 1-3 .019L5 15c-1.5-1.5-3-3.2-3-5.5\";\n\nconst TIMINGS = {\n drawDurationInFrames: 14,\n actionDelayInFrames: 2,\n actionDurationInFrames: 26,\n loop: false,\n} as const;\n\nfunction HeartIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress } = useIconAnimation(\n { animation, loop, speed },\n TIMINGS,\n );\n\n const linearDraw = 1 - (1 - drawProgress) ** (1 / 3);\n\n const heartProgress = interpolate(linearDraw, [0, 1], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n });\n\n const heart = drawnPathProps(HEART_PATH, heartProgress);\n\n const beat = interpolate(\n actionProgress,\n [0, 0.2, 0.4, 0.6, 0.8, 1],\n [1, 1.16, 1, 1.1, 1, 1],\n {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n },\n );\n\n const scale = (0.85 + 0.15 * scaleIn) * beat;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `scale(${scale})`,\n }}\n >\n <path\n d={HEART_PATH}\n strokeDasharray={heart.strokeDasharray}\n strokeDashoffset={heart.strokeDashoffset}\n />\n </svg>\n );\n}\n\nfunction HeartIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d={HEART_PATH} />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype HeartIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof HeartIconBase>;\n\nconst HeartIconInner = forwardRef<\n HTMLDivElement,\n HeartIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<HeartIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <HeartIconBase\n {...(componentProps as unknown as ComponentProps<typeof HeartIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const HeartIcon = Interactive.withSchema({\n Component: HeartIconInner,\n componentName: \"<HeartIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-help-circle.json b/registry-artifacts/elements/icon-help-circle.jsonindex 8c56da34..77130c3d 100644--- a/registry-artifacts/elements/icon-help-circle.json+++ b/registry-artifacts/elements/icon-help-circle.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Help Circle","durationInFrames": 70,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-help-circle","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst RING_PATH = \"M12 2a10 10 0 1 0 0 20 10 10 0 1 0 0-20Z\";\nconst CURVE_PATH = \"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3\";\nconst DOT_PATH = \"M12 17h.01\";\n\nconst PIVOT_X = 12;\nconst PIVOT_Y = 8;\n\nconst TIMINGS = {\n drawDurationInFrames: 18,\n actionDelayInFrames: 2,\n actionDurationInFrames: 20,\n loop: false,\n} as const;\n\nfunction HelpCircleIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress, actionFrame } =\n useIconAnimation({ animation, loop, speed }, TIMINGS);\n\n const linearDraw = 1 - (1 - drawProgress) ** (1 / 3);\n const acting = animation !== \"draw\" && actionFrame >= 0;\n\n const ringDraw = interpolate(linearDraw, [0, 0.6], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n const curveDraw = interpolate(linearDraw, [0.4, 0.85], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n const dotDraw = interpolate(linearDraw, [0.75, 1], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n\n const tilt = acting\n ? interpolate(actionProgress, [0, 0.4, 0.7, 1], [0, 6, -4, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n })\n : 0;\n\n const ring = drawnPathProps(RING_PATH, acting ? 1 : ringDraw);\n const curve = drawnPathProps(CURVE_PATH, acting ? 1 : curveDraw);\n const dot = drawnPathProps(DOT_PATH, acting ? 1 : dotDraw);\n\n const scale = 0.85 + 0.15 * scaleIn;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `scale(${scale})`,\n }}\n >\n <path\n d={RING_PATH}\n strokeDasharray={ring.strokeDasharray}\n strokeDashoffset={ring.strokeDashoffset}\n />\n <g transform={`rotate(${tilt} ${PIVOT_X} ${PIVOT_Y})`}>\n <path\n d={CURVE_PATH}\n strokeDasharray={curve.strokeDasharray}\n strokeDashoffset={curve.strokeDashoffset}\n />\n <path\n d={DOT_PATH}\n strokeDasharray={dot.strokeDasharray}\n strokeDashoffset={dot.strokeDashoffset}\n />\n </g>\n </svg>\n );\n}\n\nfunction HelpCircleIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <circle cx=\"12\" cy=\"12\" r=\"10\" />\n <path d={CURVE_PATH} />\n <path d={DOT_PATH} />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype HelpCircleIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof HelpCircleIconBase>;\n\nconst HelpCircleIconInner = forwardRef<\n HTMLDivElement,\n HelpCircleIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<HelpCircleIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <HelpCircleIconBase\n {...(componentProps as unknown as ComponentProps<typeof HelpCircleIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const HelpCircleIcon = Interactive.withSchema({\n Component: HelpCircleIconInner,\n componentName: \"<HelpCircleIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-home.json b/registry-artifacts/elements/icon-home.jsonindex b5142aeb..f0cbb60a 100644--- a/registry-artifacts/elements/icon-home.json+++ b/registry-artifacts/elements/icon-home.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Home","durationInFrames": 70,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-home","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst DOOR_PATH = \"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8\";\nconst HOUSE_PATH =\n \"M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z\";\n\nconst TIMINGS = {\n drawDurationInFrames: 14,\n actionDelayInFrames: 2,\n actionDurationInFrames: 22,\n loop: false,\n} as const;\n\nfunction HomeIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress, actionFrame } =\n useIconAnimation({ animation, loop, speed }, TIMINGS);\n\n const acting = animation !== \"draw\" && actionFrame >= 0;\n\n const doorDraw = interpolate(actionProgress, [0.1, 0.5], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n const pop = acting\n ? interpolate(actionProgress, [0.5, 0.7, 1], [1, 1.05, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n })\n : 1;\n\n const doorProgress = animation === \"draw\" ? 1 : acting ? doorDraw : 0;\n\n const house = drawnPathProps(HOUSE_PATH, drawProgress);\n const door = drawnPathProps(DOOR_PATH, doorProgress);\n\n const scale = (0.85 + 0.15 * scaleIn) * pop;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `scale(${scale})`,\n }}\n >\n <path\n d={HOUSE_PATH}\n strokeDasharray={house.strokeDasharray}\n strokeDashoffset={house.strokeDashoffset}\n />\n <path\n d={DOOR_PATH}\n strokeDasharray={door.strokeDasharray}\n strokeDashoffset={door.strokeDashoffset}\n />\n </svg>\n );\n}\n\nfunction HomeIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d={DOOR_PATH} />\n <path d={HOUSE_PATH} />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype HomeIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof HomeIconBase>;\n\nconst HomeIconInner = forwardRef<\n HTMLDivElement,\n HomeIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<HomeIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <HomeIconBase\n {...(componentProps as unknown as ComponentProps<typeof HomeIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const HomeIcon = Interactive.withSchema({\n Component: HomeIconInner,\n componentName: \"<HomeIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-image.json b/registry-artifacts/elements/icon-image.jsonindex ff0c6d38..152d1afd 100644--- a/registry-artifacts/elements/icon-image.json+++ b/registry-artifacts/elements/icon-image.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Image","durationInFrames": 75,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-image","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst FRAME_PATH =\n \"M5 3H19A2 2 0 0 1 21 5V19A2 2 0 0 1 19 21H5A2 2 0 0 1 3 19V5A2 2 0 0 1 5 3Z\";\nconst SUN_PATH =\n \"M9 7 A2 2 0 0 1 11 9 A2 2 0 0 1 9 11 A2 2 0 0 1 7 9 A2 2 0 0 1 9 7\";\nconst MOUNTAIN_PATH = \"M6 21 15.086 11.914A2 2 0 0 1 17.914 11.914L21 15\";\n\nconst TIMINGS = {\n drawDurationInFrames: 18,\n actionDelayInFrames: 2,\n actionDurationInFrames: 20,\n loop: false,\n} as const;\n\nfunction ImageIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress, actionFrame } =\n useIconAnimation({ animation, loop, speed }, TIMINGS);\n\n const linearDraw = 1 - (1 - drawProgress) ** (1 / 3);\n\n const frameDraw = interpolate(linearDraw, [0, 0.667], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n const sunDraw = interpolate(linearDraw, [0.444, 0.778], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n const mountainDraw = interpolate(linearDraw, [0.556, 1], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n\n const acting = animation !== \"draw\" && actionFrame >= 0;\n\n const mountainProgress = acting\n ? interpolate(actionProgress, [0, 0.6], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n })\n : mountainDraw;\n const sunShiftY = acting\n ? interpolate(actionProgress, [0, 0.6, 0.9], [1, -0.5, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n })\n : 0;\n const sunOpacity = acting\n ? interpolate(actionProgress, [0, 0.5], [0.6, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n })\n : 1;\n\n const frame = drawnPathProps(FRAME_PATH, frameDraw);\n const sun = drawnPathProps(SUN_PATH, acting ? 1 : sunDraw);\n const mountain = drawnPathProps(MOUNTAIN_PATH, mountainProgress);\n\n const scale = 0.85 + 0.15 * scaleIn;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `scale(${scale})`,\n }}\n >\n <path\n d={FRAME_PATH}\n strokeDasharray={frame.strokeDasharray}\n strokeDashoffset={frame.strokeDashoffset}\n />\n <g transform={`translate(0 ${sunShiftY})`} opacity={sunOpacity}>\n <path\n d={SUN_PATH}\n strokeDasharray={sun.strokeDasharray}\n strokeDashoffset={sun.strokeDashoffset}\n />\n </g>\n <path\n d={MOUNTAIN_PATH}\n strokeDasharray={mountain.strokeDasharray}\n strokeDashoffset={mountain.strokeDashoffset}\n />\n </svg>\n );\n}\n\nfunction ImageIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <rect width=\"18\" height=\"18\" x=\"3\" y=\"3\" rx=\"2\" ry=\"2\" />\n <circle cx=\"9\" cy=\"9\" r=\"2\" />\n <path d=\"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21\" />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype ImageIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof ImageIconBase>;\n\nconst ImageIconInner = forwardRef<\n HTMLDivElement,\n ImageIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<ImageIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <ImageIconBase\n {...(componentProps as unknown as ComponentProps<typeof ImageIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const ImageIcon = Interactive.withSchema({\n Component: ImageIconInner,\n componentName: \"<ImageIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-inbox.json b/registry-artifacts/elements/icon-inbox.jsonindex 061043f9..198c3b0e 100644--- a/registry-artifacts/elements/icon-inbox.json+++ b/registry-artifacts/elements/icon-inbox.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Inbox","durationInFrames": 70,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-inbox","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst TRAY_PATH =\n \"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z\";\nconst LIP_PATH = \"M22 12H16L14 15H10L8 12H2\";\n\nconst TIMINGS = {\n drawDurationInFrames: 16,\n actionDelayInFrames: 2,\n actionDurationInFrames: 22,\n loop: false,\n} as const;\n\nfunction InboxIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress, actionFrame } =\n useIconAnimation({ animation, loop, speed }, TIMINGS);\n\n const linearDraw = 1 - (1 - drawProgress) ** (1 / 3);\n const acting = animation !== \"draw\" && actionFrame >= 0;\n\n const trayDraw = interpolate(linearDraw, [0, 0.7], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n const lipDraw = interpolate(linearDraw, [0.45, 1], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n\n const dip = acting\n ? interpolate(actionProgress, [0, 0.25, 0.55, 1], [0, 0, 2, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n })\n : 0;\n const pop = acting\n ? interpolate(actionProgress, [0.55, 0.75, 1], [1, 1.03, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n })\n : 1;\n\n const tray = drawnPathProps(TRAY_PATH, acting ? 1 : trayDraw);\n const lip = drawnPathProps(LIP_PATH, acting ? 1 : lipDraw);\n\n const scale = (0.85 + 0.15 * scaleIn) * pop;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `translateY(${dip}px) scale(${scale})`,\n }}\n >\n <path\n d={TRAY_PATH}\n strokeDasharray={tray.strokeDasharray}\n strokeDashoffset={tray.strokeDashoffset}\n />\n <path\n d={LIP_PATH}\n strokeDasharray={lip.strokeDasharray}\n strokeDashoffset={lip.strokeDashoffset}\n />\n </svg>\n );\n}\n\nfunction InboxIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <polyline points=\"22 12 16 12 14 15 10 15 8 12 2 12\" />\n <path d={TRAY_PATH} />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype InboxIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof InboxIconBase>;\n\nconst InboxIconInner = forwardRef<\n HTMLDivElement,\n InboxIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<InboxIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <InboxIconBase\n {...(componentProps as unknown as ComponentProps<typeof InboxIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const InboxIcon = Interactive.withSchema({\n Component: InboxIconInner,\n componentName: \"<InboxIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-info.json b/registry-artifacts/elements/icon-info.jsonindex 1e639322..4e508be1 100644--- a/registry-artifacts/elements/icon-info.json+++ b/registry-artifacts/elements/icon-info.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Info","durationInFrames": 75,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-info","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst CIRCLE_PATH =\n \"M12 2 A10 10 0 0 1 22 12 A10 10 0 0 1 12 22 A10 10 0 0 1 2 12 A10 10 0 0 1 12 2\";\nconst STEM_PATH = \"M12 12v4\";\nconst DOT_PATH = \"M12 8h.01\";\n\nconst TIMINGS = {\n drawDurationInFrames: 20,\n actionDelayInFrames: 2,\n actionDurationInFrames: 16,\n loop: false,\n} as const;\n\nfunction InfoIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress } = useIconAnimation(\n { animation, loop, speed },\n TIMINGS,\n );\n\n const linearDraw = 1 - (1 - drawProgress) ** (1 / 3);\n\n const circleProgress = interpolate(linearDraw, [0, 0.7], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n });\n const stemProgress = interpolate(linearDraw, [0.7, 1], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n const dotPop = interpolate(linearDraw, [0.5, 0.65], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.back(1.8)),\n });\n\n const circle = drawnPathProps(CIRCLE_PATH, circleProgress);\n const stem = drawnPathProps(STEM_PATH, stemProgress);\n\n const bob = interpolate(actionProgress, [0, 0.5, 1], [0, -2, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.sin),\n });\n\n const scale = 0.85 + 0.15 * scaleIn;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `scale(${scale})`,\n }}\n >\n <path\n d={CIRCLE_PATH}\n strokeDasharray={circle.strokeDasharray}\n strokeDashoffset={circle.strokeDashoffset}\n />\n <path\n d={STEM_PATH}\n strokeDasharray={stem.strokeDasharray}\n strokeDashoffset={stem.strokeDashoffset}\n />\n <g\n transform={`translate(0 ${bob}) translate(12 8) scale(${dotPop}) translate(-12 -8)`}\n >\n <path d={DOT_PATH} />\n </g>\n </svg>\n );\n}\n\nfunction InfoIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <circle cx=\"12\" cy=\"12\" r=\"10\" />\n <path d=\"M12 16v-4\" />\n <path d={DOT_PATH} />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype InfoIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof InfoIconBase>;\n\nconst InfoIconInner = forwardRef<\n HTMLDivElement,\n InfoIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<InfoIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <InfoIconBase\n {...(componentProps as unknown as ComponentProps<typeof InfoIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const InfoIcon = Interactive.withSchema({\n Component: InfoIconInner,\n componentName: \"<InfoIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-key.json b/registry-artifacts/elements/icon-key.jsonindex 3d8eb2c0..225aa3fa 100644--- a/registry-artifacts/elements/icon-key.json+++ b/registry-artifacts/elements/icon-key.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Key","durationInFrames": 75,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-key","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst HEAD_PATH =\n \"M7.5 10 A5.5 5.5 0 0 1 13 15.5 A5.5 5.5 0 0 1 7.5 21 A5.5 5.5 0 0 1 2 15.5 A5.5 5.5 0 0 1 7.5 10\";\nconst SHAFT_PATH = \"M21 2 11.4 11.6\";\nconst TEETH_PATH =\n \"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4\";\n\nconst TIMINGS = {\n drawDurationInFrames: 16,\n actionDelayInFrames: 2,\n actionDurationInFrames: 28,\n loop: false,\n} as const;\n\nfunction KeyIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress, actionFrame } =\n useIconAnimation({ animation, loop, speed }, TIMINGS);\n\n const linearDraw = 1 - (1 - drawProgress) ** (1 / 3);\n const acting = animation !== \"draw\" && actionFrame >= 0;\n\n const headDraw = interpolate(linearDraw, [0, 0.625], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n const shaftDraw = interpolate(linearDraw, [0.375, 0.8], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n const teethDraw = interpolate(linearDraw, [0.56, 1], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n\n const turn = acting\n ? interpolate(actionProgress, [0, 0.5, 0.64, 0.9, 1], [0, -25, -25, 2, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n })\n : 0;\n\n const head = drawnPathProps(HEAD_PATH, headDraw);\n const shaft = drawnPathProps(SHAFT_PATH, shaftDraw);\n const teeth = drawnPathProps(TEETH_PATH, teethDraw);\n\n const scale = 0.85 + 0.15 * scaleIn;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `scale(${scale})`,\n }}\n >\n <g transform={`rotate(${turn} 7.5 15.5)`}>\n <path\n d={HEAD_PATH}\n strokeDasharray={head.strokeDasharray}\n strokeDashoffset={head.strokeDashoffset}\n />\n <path\n d={SHAFT_PATH}\n strokeDasharray={shaft.strokeDasharray}\n strokeDashoffset={shaft.strokeDashoffset}\n />\n <path\n d={TEETH_PATH}\n strokeDasharray={teeth.strokeDasharray}\n strokeDashoffset={teeth.strokeDashoffset}\n />\n </g>\n </svg>\n );\n}\n\nfunction KeyIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d={TEETH_PATH} />\n <path d={SHAFT_PATH} />\n <circle cx=\"7.5\" cy=\"15.5\" r=\"5.5\" />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype KeyIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof KeyIconBase>;\n\nconst KeyIconInner = forwardRef<\n HTMLDivElement,\n KeyIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<KeyIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <KeyIconBase\n {...(componentProps as unknown as ComponentProps<typeof KeyIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const KeyIcon = Interactive.withSchema({\n Component: KeyIconInner,\n componentName: \"<KeyIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-layout-grid.json b/registry-artifacts/elements/icon-layout-grid.jsonindex fb81a6ca..bdecc236 100644--- a/registry-artifacts/elements/icon-layout-grid.json+++ b/registry-artifacts/elements/icon-layout-grid.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Layout Grid","durationInFrames": 75,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-layout-grid","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst TL_PATH =\n \"M4 3H9A1 1 0 0 1 10 4V9A1 1 0 0 1 9 10H4A1 1 0 0 1 3 9V4A1 1 0 0 1 4 3Z\";\nconst TR_PATH =\n \"M15 3H20A1 1 0 0 1 21 4V9A1 1 0 0 1 20 10H15A1 1 0 0 1 14 9V4A1 1 0 0 1 15 3Z\";\nconst BR_PATH =\n \"M15 14H20A1 1 0 0 1 21 15V20A1 1 0 0 1 20 21H15A1 1 0 0 1 14 20V15A1 1 0 0 1 15 14Z\";\nconst BL_PATH =\n \"M4 14H9A1 1 0 0 1 10 15V20A1 1 0 0 1 9 21H4A1 1 0 0 1 3 20V15A1 1 0 0 1 4 14Z\";\n\nconst TIMINGS = {\n drawDurationInFrames: 20,\n actionDelayInFrames: 2,\n actionDurationInFrames: 26,\n loop: false,\n} as const;\n\nconst TILES = [\n { path: TL_PATH, cx: 6.5, cy: 6.5, drawWindow: [0, 0.4], stagger: 0 },\n { path: TR_PATH, cx: 17.5, cy: 6.5, drawWindow: [0.2, 0.6], stagger: 0.23 },\n { path: BR_PATH, cx: 17.5, cy: 17.5, drawWindow: [0.4, 0.8], stagger: 0.46 },\n { path: BL_PATH, cx: 6.5, cy: 17.5, drawWindow: [0.6, 1], stagger: 0.69 },\n] as const;\n\nfunction LayoutGridIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress, actionFrame } =\n useIconAnimation({ animation, loop, speed }, TIMINGS);\n\n const linearDraw = 1 - (1 - drawProgress) ** (1 / 3);\n const acting = animation !== \"draw\" && actionFrame >= 0;\n\n const scale = 0.85 + 0.15 * scaleIn;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `scale(${scale})`,\n }}\n >\n {TILES.map((tile) => {\n const drawn = interpolate(linearDraw, [...tile.drawWindow], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n const dash = drawnPathProps(tile.path, drawn);\n const pop =\n acting && actionProgress >= tile.stagger\n ? interpolate(\n actionProgress,\n [tile.stagger, tile.stagger + 0.25, tile.stagger + 0.5],\n [0.85, 1.06, 1],\n {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n },\n )\n : 1;\n const tx = tile.cx * (1 - pop);\n const ty = tile.cy * (1 - pop);\n return (\n <g key={tile.path} transform={`translate(${tx} ${ty}) scale(${pop})`}>\n <path\n d={tile.path}\n strokeDasharray={dash.strokeDasharray}\n strokeDashoffset={dash.strokeDashoffset}\n />\n </g>\n );\n })}\n </svg>\n );\n}\n\nfunction LayoutGridIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <rect width=\"7\" height=\"7\" x=\"3\" y=\"3\" rx=\"1\" />\n <rect width=\"7\" height=\"7\" x=\"14\" y=\"3\" rx=\"1\" />\n <rect width=\"7\" height=\"7\" x=\"14\" y=\"14\" rx=\"1\" />\n <rect width=\"7\" height=\"7\" x=\"3\" y=\"14\" rx=\"1\" />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype LayoutGridIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof LayoutGridIconBase>;\n\nconst LayoutGridIconInner = forwardRef<\n HTMLDivElement,\n LayoutGridIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<LayoutGridIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <LayoutGridIconBase\n {...(componentProps as unknown as ComponentProps<typeof LayoutGridIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const LayoutGridIcon = Interactive.withSchema({\n Component: LayoutGridIconInner,\n componentName: \"<LayoutGridIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-link.json b/registry-artifacts/elements/icon-link.jsonindex 327b62fe..88b04151 100644--- a/registry-artifacts/elements/icon-link.json+++ b/registry-artifacts/elements/icon-link.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Link","durationInFrames": 70,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-link","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst TOP_PATH = \"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71\";\nconst BOTTOM_PATH =\n \"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71\";\n\nconst TIMINGS = {\n drawDurationInFrames: 14,\n actionDelayInFrames: 2,\n actionDurationInFrames: 20,\n loop: false,\n} as const;\n\nfunction LinkIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress, actionFrame } =\n useIconAnimation({ animation, loop, speed }, TIMINGS);\n\n const acting = animation !== \"draw\" && actionFrame >= 0;\n\n const pull = acting\n ? interpolate(actionProgress, [0, 0.4, 0.75], [0, 1.06, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n })\n : 0;\n const pop = acting\n ? interpolate(actionProgress, [0.6, 0.78, 1], [1, 1.06, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n })\n : 1;\n\n const top = drawnPathProps(TOP_PATH, drawProgress);\n const bottom = drawnPathProps(BOTTOM_PATH, drawProgress);\n\n const scale = (0.85 + 0.15 * scaleIn) * pop;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `scale(${scale})`,\n }}\n >\n <g transform={`translate(${pull} ${-pull})`}>\n <path\n d={TOP_PATH}\n strokeDasharray={top.strokeDasharray}\n strokeDashoffset={top.strokeDashoffset}\n />\n </g>\n <g transform={`translate(${-pull} ${pull})`}>\n <path\n d={BOTTOM_PATH}\n strokeDasharray={bottom.strokeDasharray}\n strokeDashoffset={bottom.strokeDashoffset}\n />\n </g>\n </svg>\n );\n}\n\nfunction LinkIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d={TOP_PATH} />\n <path d={BOTTOM_PATH} />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype LinkIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof LinkIconBase>;\n\nconst LinkIconInner = forwardRef<\n HTMLDivElement,\n LinkIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<LinkIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <LinkIconBase\n {...(componentProps as unknown as ComponentProps<typeof LinkIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const LinkIcon = Interactive.withSchema({\n Component: LinkIconInner,\n componentName: \"<LinkIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-loader.json b/registry-artifacts/elements/icon-loader.jsonindex b72de460..adee20c3 100644--- a/registry-artifacts/elements/icon-loader.json+++ b/registry-artifacts/elements/icon-loader.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Loader","durationInFrames": 90,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-loader","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst ARC_PATH = \"M21 12a9 9 0 1 1-6.219-8.56\";\n\nconst TIMINGS = {\n drawDurationInFrames: 10,\n actionDelayInFrames: 2,\n actionDurationInFrames: 40,\n loop: true,\n} as const;\n\nfunction LoaderIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, actionProgress, cycleIndex } = useIconAnimation(\n { animation, loop, speed },\n TIMINGS,\n );\n\n const linearDraw = 1 - (1 - drawProgress) ** (1 / 3);\n\n const arcProgress = interpolate(linearDraw, [0, 1], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n });\n const entrance = interpolate(linearDraw, [0, 1], [0.9, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n\n const arc = drawnPathProps(ARC_PATH, arcProgress);\n const rotate = (cycleIndex + actionProgress) * 360;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `rotate(${rotate}deg) scale(${entrance})`,\n }}\n >\n <path\n d={ARC_PATH}\n strokeDasharray={arc.strokeDasharray}\n strokeDashoffset={arc.strokeDashoffset}\n />\n </svg>\n );\n}\n\nfunction LoaderIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d={ARC_PATH} />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: true,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: true,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype LoaderIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof LoaderIconBase>;\n\nconst LoaderIconInner = forwardRef<\n HTMLDivElement,\n LoaderIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<LoaderIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <LoaderIconBase\n {...(componentProps as unknown as ComponentProps<typeof LoaderIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const LoaderIcon = Interactive.withSchema({\n Component: LoaderIconInner,\n componentName: \"<LoaderIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-lock.json b/registry-artifacts/elements/icon-lock.jsonindex cd70ed5e..72cfb78a 100644--- a/registry-artifacts/elements/icon-lock.json+++ b/registry-artifacts/elements/icon-lock.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Lock","durationInFrames": 70,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-lock","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst BODY_PATH =\n \"M5 11H19A2 2 0 0 1 21 13V20A2 2 0 0 1 19 22H5A2 2 0 0 1 3 20V13A2 2 0 0 1 5 11Z\";\nconst SHACKLE_PATH = \"M7 11V7a5 5 0 0 1 10 0v4\";\n\nconst TIMINGS = {\n drawDurationInFrames: 16,\n actionDelayInFrames: 2,\n actionDurationInFrames: 22,\n loop: false,\n} as const;\n\nfunction LockIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress, actionFrame } =\n useIconAnimation({ animation, loop, speed }, TIMINGS);\n\n const linearDraw = 1 - (1 - drawProgress) ** (1 / 3);\n const acting = animation !== \"draw\" && actionFrame >= 0;\n\n const bodyDraw = interpolate(linearDraw, [0, 0.75], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n const shackleDraw = interpolate(linearDraw, [0.5, 1], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n\n const lift = acting\n ? interpolate(actionProgress, [0, 0.35, 0.7], [0, -2.5, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.in(Easing.quad),\n })\n : 0;\n const pop = acting\n ? interpolate(actionProgress, [0.7, 0.85, 1], [1, 1.05, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n })\n : 1;\n\n const body = drawnPathProps(BODY_PATH, bodyDraw);\n const shackle = drawnPathProps(SHACKLE_PATH, shackleDraw);\n\n const scale = (0.85 + 0.15 * scaleIn) * pop;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `scale(${scale})`,\n }}\n >\n <path\n d={BODY_PATH}\n strokeDasharray={body.strokeDasharray}\n strokeDashoffset={body.strokeDashoffset}\n />\n <g transform={`translate(0 ${lift})`}>\n <path\n d={SHACKLE_PATH}\n strokeDasharray={shackle.strokeDasharray}\n strokeDashoffset={shackle.strokeDashoffset}\n />\n </g>\n </svg>\n );\n}\n\nfunction LockIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <rect width=\"18\" height=\"11\" x=\"3\" y=\"11\" rx=\"2\" ry=\"2\" />\n <path d={SHACKLE_PATH} />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype LockIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof LockIconBase>;\n\nconst LockIconInner = forwardRef<\n HTMLDivElement,\n LockIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<LockIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <LockIconBase\n {...(componentProps as unknown as ComponentProps<typeof LockIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const LockIcon = Interactive.withSchema({\n Component: LockIconInner,\n componentName: \"<LockIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-log-out.json b/registry-artifacts/elements/icon-log-out.jsonindex 3f2878af..4b772596 100644--- a/registry-artifacts/elements/icon-log-out.json+++ b/registry-artifacts/elements/icon-log-out.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Log Out","durationInFrames": 70,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-log-out","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst DOOR_PATH = \"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4\";\nconst SHAFT_PATH = \"M21 12H9\";\nconst HEAD_PATH = \"M16 17 21 12 16 7\";\n\nconst TIMINGS = {\n drawDurationInFrames: 16,\n actionDelayInFrames: 2,\n actionDurationInFrames: 22,\n loop: false,\n} as const;\n\nfunction LogOutIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress, actionFrame } =\n useIconAnimation({ animation, loop, speed }, TIMINGS);\n\n const linearDraw = 1 - (1 - drawProgress) ** (1 / 3);\n const acting = animation !== \"draw\" && actionFrame >= 0;\n\n const doorDraw = interpolate(linearDraw, [0, 0.625], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n const shaftDraw = interpolate(linearDraw, [0.375, 0.8], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n const headDraw = interpolate(linearDraw, [0.56, 1], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n\n const exit = acting\n ? interpolate(actionProgress, [0, 0.22, 0.45, 0.68, 1], [0, 4, 0, 2, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n })\n : 0;\n\n const door = drawnPathProps(DOOR_PATH, doorDraw);\n const shaft = drawnPathProps(SHAFT_PATH, shaftDraw);\n const head = drawnPathProps(HEAD_PATH, headDraw);\n\n const scale = 0.85 + 0.15 * scaleIn;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `scale(${scale})`,\n }}\n >\n <path\n d={DOOR_PATH}\n strokeDasharray={door.strokeDasharray}\n strokeDashoffset={door.strokeDashoffset}\n />\n <g transform={`translate(${exit} 0)`}>\n <path\n d={SHAFT_PATH}\n strokeDasharray={shaft.strokeDasharray}\n strokeDashoffset={shaft.strokeDashoffset}\n />\n <path\n d={HEAD_PATH}\n strokeDasharray={head.strokeDasharray}\n strokeDashoffset={head.strokeDashoffset}\n />\n </g>\n </svg>\n );\n}\n\nfunction LogOutIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d={HEAD_PATH} />\n <path d={SHAFT_PATH} />\n <path d={DOOR_PATH} />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype LogOutIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof LogOutIconBase>;\n\nconst LogOutIconInner = forwardRef<\n HTMLDivElement,\n LogOutIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<LogOutIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <LogOutIconBase\n {...(componentProps as unknown as ComponentProps<typeof LogOutIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const LogOutIcon = Interactive.withSchema({\n Component: LogOutIconInner,\n componentName: \"<LogOutIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-mail.json b/registry-artifacts/elements/icon-mail.jsonindex d4b03c68..f46f66bd 100644--- a/registry-artifacts/elements/icon-mail.json+++ b/registry-artifacts/elements/icon-mail.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Mail","durationInFrames": 75,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-mail","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst BODY_PATH =\n \"M4 4H20A2 2 0 0 1 22 6V18A2 2 0 0 1 20 20H4A2 2 0 0 1 2 18V6A2 2 0 0 1 4 4Z\";\nconst FLAP_PATH = \"M22 7 13.009 12.727a2 2 0 0 1-2.009 0L2 7\";\nconst FLAP_RIGHT_PATH = \"M22 7 13.009 12.727\";\nconst FLAP_LEFT_PATH = \"M2 7 11 12.727\";\n\nconst TIMINGS = {\n drawDurationInFrames: 16,\n actionDelayInFrames: 2,\n actionDurationInFrames: 24,\n loop: false,\n} as const;\n\nfunction MailIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress, actionFrame } =\n useIconAnimation({ animation, loop, speed }, TIMINGS);\n\n const linearDraw = 1 - (1 - drawProgress) ** (1 / 3);\n const acting = animation !== \"draw\" && actionFrame >= 0;\n\n const bodyDraw = interpolate(linearDraw, [0, 0.75], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n const flapDraw = interpolate(linearDraw, [0.5, 1], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n\n const flapProgress = acting ? 1 : flapDraw;\n const pop = acting\n ? interpolate(actionProgress, [0, 0.45, 1], [1, 1.05, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n })\n : 1;\n const bob = acting\n ? interpolate(actionProgress, [0, 0.45, 1], [0, -1.6, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n })\n : 0;\n\n const body = drawnPathProps(BODY_PATH, bodyDraw);\n const flapRight = drawnPathProps(FLAP_RIGHT_PATH, flapProgress);\n const flapLeft = drawnPathProps(FLAP_LEFT_PATH, flapProgress);\n\n const scale = (0.85 + 0.15 * scaleIn) * pop;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `translateY(${bob}px) scale(${scale})`,\n }}\n >\n <path\n d={BODY_PATH}\n strokeDasharray={body.strokeDasharray}\n strokeDashoffset={body.strokeDashoffset}\n />\n <path\n d={FLAP_RIGHT_PATH}\n strokeDasharray={flapRight.strokeDasharray}\n strokeDashoffset={flapRight.strokeDashoffset}\n />\n <path\n d={FLAP_LEFT_PATH}\n strokeDasharray={flapLeft.strokeDasharray}\n strokeDashoffset={flapLeft.strokeDashoffset}\n />\n </svg>\n );\n}\n\nfunction MailIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d={FLAP_PATH} />\n <rect x=\"2\" y=\"4\" width=\"20\" height=\"16\" rx=\"2\" />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype MailIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof MailIconBase>;\n\nconst MailIconInner = forwardRef<\n HTMLDivElement,\n MailIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<MailIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <MailIconBase\n {...(componentProps as unknown as ComponentProps<typeof MailIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const MailIcon = Interactive.withSchema({\n Component: MailIconInner,\n componentName: \"<MailIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-maximize.json b/registry-artifacts/elements/icon-maximize.jsonindex 716c1972..f2bb7cee 100644--- a/registry-artifacts/elements/icon-maximize.json+++ b/registry-artifacts/elements/icon-maximize.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Maximize","durationInFrames": 70,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-maximize","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst TL_PATH = \"M8 3H5a2 2 0 0 0-2 2v3\";\nconst TR_PATH = \"M21 8V5a2 2 0 0 0-2-2h-3\";\nconst BL_PATH = \"M3 16v3a2 2 0 0 0 2 2h3\";\nconst BR_PATH = \"M16 21h3a2 2 0 0 0 2-2v-3\";\n\nconst TIMINGS = {\n drawDurationInFrames: 14,\n actionDelayInFrames: 2,\n actionDurationInFrames: 24,\n loop: false,\n} as const;\n\nconst BRACKETS = [\n { path: TL_PATH, dx: -1, dy: -1 },\n { path: TR_PATH, dx: 1, dy: -1 },\n { path: BL_PATH, dx: -1, dy: 1 },\n { path: BR_PATH, dx: 1, dy: 1 },\n] as const;\n\nfunction MaximizeIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress, actionFrame } =\n useIconAnimation({ animation, loop, speed }, TIMINGS);\n\n const acting = animation !== \"draw\" && actionFrame >= 0;\n const expand = acting\n ? interpolate(actionProgress, [0, 0.42, 1], [0, 1.77, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n })\n : 0;\n\n const scale = 0.85 + 0.15 * scaleIn;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `scale(${scale})`,\n }}\n >\n {BRACKETS.map((bracket) => {\n const dash = drawnPathProps(bracket.path, drawProgress);\n return (\n <g\n key={bracket.path}\n transform={`translate(${bracket.dx * expand} ${bracket.dy * expand})`}\n >\n <path\n d={bracket.path}\n strokeDasharray={dash.strokeDasharray}\n strokeDashoffset={dash.strokeDashoffset}\n />\n </g>\n );\n })}\n </svg>\n );\n}\n\nfunction MaximizeIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d={TL_PATH} />\n <path d={TR_PATH} />\n <path d={BL_PATH} />\n <path d={BR_PATH} />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype MaximizeIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof MaximizeIconBase>;\n\nconst MaximizeIconInner = forwardRef<\n HTMLDivElement,\n MaximizeIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<MaximizeIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <MaximizeIconBase\n {...(componentProps as unknown as ComponentProps<typeof MaximizeIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const MaximizeIcon = Interactive.withSchema({\n Component: MaximizeIconInner,\n componentName: \"<MaximizeIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-menu.json b/registry-artifacts/elements/icon-menu.jsonindex 92601274..e7db6be8 100644--- a/registry-artifacts/elements/icon-menu.json+++ b/registry-artifacts/elements/icon-menu.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Menu","durationInFrames": 70,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-menu","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst TOP_PATH = \"M4 5 20 5\";\nconst MID_PATH = \"M4 12 20 12\";\nconst BOT_PATH = \"M4 19 20 19\";\n\nconst TIMINGS = {\n drawDurationInFrames: 16,\n actionDelayInFrames: 2,\n actionDurationInFrames: 20,\n loop: false,\n} as const;\n\nconst BARS = [\n { path: TOP_PATH, drawWindow: [0, 0.5], stagger: 0 },\n { path: MID_PATH, drawWindow: [0.25, 0.75], stagger: 0.18 },\n { path: BOT_PATH, drawWindow: [0.5, 1], stagger: 0.36 },\n] as const;\n\nfunction MenuIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress, actionFrame } =\n useIconAnimation({ animation, loop, speed }, TIMINGS);\n\n const linearDraw = 1 - (1 - drawProgress) ** (1 / 3);\n const acting = animation !== \"draw\" && actionFrame >= 0;\n\n const scale = 0.85 + 0.15 * scaleIn;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `scale(${scale})`,\n }}\n >\n {BARS.map((bar) => {\n const drawn = interpolate(linearDraw, [...bar.drawWindow], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n const dash = drawnPathProps(bar.path, drawn);\n const slide = acting\n ? interpolate(\n actionProgress,\n [bar.stagger, bar.stagger + 0.3, bar.stagger + 0.55],\n [-3, 2, 0],\n {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n },\n )\n : 0;\n return (\n <g key={bar.path} transform={`translate(${slide} 0)`}>\n <path\n d={bar.path}\n strokeDasharray={dash.strokeDasharray}\n strokeDashoffset={dash.strokeDashoffset}\n />\n </g>\n );\n })}\n </svg>\n );\n}\n\nfunction MenuIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d={TOP_PATH} />\n <path d={MID_PATH} />\n <path d={BOT_PATH} />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype MenuIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof MenuIconBase>;\n\nconst MenuIconInner = forwardRef<\n HTMLDivElement,\n MenuIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<MenuIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <MenuIconBase\n {...(componentProps as unknown as ComponentProps<typeof MenuIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const MenuIcon = Interactive.withSchema({\n Component: MenuIconInner,\n componentName: \"<MenuIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-message-circle.json b/registry-artifacts/elements/icon-message-circle.jsonindex 6b243e7f..473c549b 100644--- a/registry-artifacts/elements/icon-message-circle.json+++ b/registry-artifacts/elements/icon-message-circle.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Message Circle","durationInFrames": 70,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-message-circle","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst BUBBLE_PATH =\n \"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719\";\n\nconst TAIL_X = 4;\nconst TAIL_Y = 20;\n\nconst TIMINGS = {\n drawDurationInFrames: 14,\n actionDelayInFrames: 2,\n actionDurationInFrames: 20,\n loop: false,\n} as const;\n\nfunction MessageCircleIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress, actionFrame } =\n useIconAnimation({ animation, loop, speed }, TIMINGS);\n\n const acting = animation !== \"draw\" && actionFrame >= 0;\n\n const inflate = acting\n ? interpolate(actionProgress, [0, 0.45, 1], [0.9, 1.08, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n })\n : 1;\n\n const bubble = drawnPathProps(BUBBLE_PATH, drawProgress);\n\n const scale = 0.85 + 0.15 * scaleIn;\n const inflateTransform = `translate(${TAIL_X * (1 - inflate)} ${TAIL_Y * (1 - inflate)}) scale(${inflate})`;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `scale(${scale})`,\n }}\n >\n <g transform={inflateTransform}>\n <path\n d={BUBBLE_PATH}\n strokeDasharray={bubble.strokeDasharray}\n strokeDashoffset={bubble.strokeDashoffset}\n />\n </g>\n </svg>\n );\n}\n\nfunction MessageCircleIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d={BUBBLE_PATH} />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype MessageCircleIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof MessageCircleIconBase>;\n\nconst MessageCircleIconInner = forwardRef<\n HTMLDivElement,\n MessageCircleIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<MessageCircleIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <MessageCircleIconBase\n {...(componentProps as unknown as ComponentProps<typeof MessageCircleIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const MessageCircleIcon = Interactive.withSchema({\n Component: MessageCircleIconInner,\n componentName: \"<MessageCircleIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-mic.json b/registry-artifacts/elements/icon-mic.jsonindex 3d8b90fb..b52c146a 100644--- a/registry-artifacts/elements/icon-mic.json+++ b/registry-artifacts/elements/icon-mic.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Mic","durationInFrames": 75,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-mic","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst CAPSULE_PATH =\n \"M12 2A3 3 0 0 1 15 5V12A3 3 0 0 1 12 15A3 3 0 0 1 9 12V5A3 3 0 0 1 12 2Z\";\nconst ARC_PATH = \"M19 10v2a7 7 0 0 1-14 0v-2\";\nconst STAND_PATH = \"M12 19v3\";\n\nconst TIMINGS = {\n drawDurationInFrames: 16,\n actionDelayInFrames: 2,\n actionDurationInFrames: 24,\n loop: false,\n} as const;\n\nfunction MicIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress, actionFrame } =\n useIconAnimation({ animation, loop, speed }, TIMINGS);\n\n const linearDraw = 1 - (1 - drawProgress) ** (1 / 3);\n\n const capsuleDraw = interpolate(linearDraw, [0, 0.625], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n const arcDraw = interpolate(linearDraw, [0.375, 0.875], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n const standDraw = interpolate(linearDraw, [0.625, 1], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n\n const acting = animation !== \"draw\" && actionFrame >= 0;\n\n const capsuleScaleY = acting\n ? interpolate(\n actionProgress,\n [0, 0.15, 0.3, 0.5, 0.65, 0.8, 1],\n [1, 0.94, 1.04, 1, 0.97, 1.02, 1],\n {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n },\n )\n : 1;\n\n const capsule = drawnPathProps(CAPSULE_PATH, capsuleDraw);\n const arc = drawnPathProps(ARC_PATH, arcDraw);\n const stand = drawnPathProps(STAND_PATH, standDraw);\n\n const scale = 0.85 + 0.15 * scaleIn;\n const capsuleTransform = `translate(0 ${8.5 * (1 - capsuleScaleY)}) scale(1 ${capsuleScaleY})`;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `scale(${scale})`,\n }}\n >\n <g transform={capsuleTransform}>\n <path\n d={CAPSULE_PATH}\n strokeDasharray={capsule.strokeDasharray}\n strokeDashoffset={capsule.strokeDashoffset}\n />\n </g>\n <path\n d={ARC_PATH}\n strokeDasharray={arc.strokeDasharray}\n strokeDashoffset={arc.strokeDashoffset}\n />\n <path\n d={STAND_PATH}\n strokeDasharray={stand.strokeDasharray}\n strokeDashoffset={stand.strokeDashoffset}\n />\n </svg>\n );\n}\n\nfunction MicIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d={STAND_PATH} />\n <path d={ARC_PATH} />\n <rect x=\"9\" y=\"2\" width=\"6\" height=\"13\" rx=\"3\" />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype MicIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof MicIconBase>;\n\nconst MicIconInner = forwardRef<\n HTMLDivElement,\n MicIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<MicIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <MicIconBase\n {...(componentProps as unknown as ComponentProps<typeof MicIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const MicIcon = Interactive.withSchema({\n Component: MicIconInner,\n componentName: \"<MicIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-monitor.json b/registry-artifacts/elements/icon-monitor.jsonindex 2c615b92..6d172044 100644--- a/registry-artifacts/elements/icon-monitor.json+++ b/registry-artifacts/elements/icon-monitor.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Monitor","durationInFrames": 75,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-monitor","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst SCREEN_PATH =\n \"M4 3H20A2 2 0 0 1 22 5V15A2 2 0 0 1 20 17H4A2 2 0 0 1 2 15V5A2 2 0 0 1 4 3Z\";\nconst BASE_PATH = \"M8 21H16\";\nconst NECK_PATH = \"M12 17V21\";\n\nconst SCREEN_CY = 10;\n\nconst TIMINGS = {\n drawDurationInFrames: 16,\n actionDelayInFrames: 2,\n actionDurationInFrames: 18,\n loop: false,\n} as const;\n\nfunction MonitorIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress, actionFrame } =\n useIconAnimation({ animation, loop, speed }, TIMINGS);\n\n const linearDraw = 1 - (1 - drawProgress) ** (1 / 3);\n const acting = animation !== \"draw\" && actionFrame >= 0;\n\n const standDraw = interpolate(linearDraw, [0, 0.5], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n const screenDraw = interpolate(linearDraw, [0.35, 1], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n\n const screenYScale = acting\n ? interpolate(actionProgress, [0, 0.45, 1], [0.92, 1.04, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n })\n : 1;\n const pop = acting\n ? interpolate(actionProgress, [0.5, 0.7, 1], [1, 1.02, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n })\n : 1;\n\n const screen = drawnPathProps(SCREEN_PATH, acting ? 1 : screenDraw);\n const base = drawnPathProps(BASE_PATH, acting ? 1 : standDraw);\n const neck = drawnPathProps(NECK_PATH, acting ? 1 : standDraw);\n\n const scale = (0.85 + 0.15 * scaleIn) * pop;\n const screenTransform = `translate(0 ${SCREEN_CY * (1 - screenYScale)}) scale(1 ${screenYScale})`;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `scale(${scale})`,\n }}\n >\n <g transform={screenTransform}>\n <path\n d={SCREEN_PATH}\n strokeDasharray={screen.strokeDasharray}\n strokeDashoffset={screen.strokeDashoffset}\n />\n </g>\n <path\n d={BASE_PATH}\n strokeDasharray={base.strokeDasharray}\n strokeDashoffset={base.strokeDashoffset}\n />\n <path\n d={NECK_PATH}\n strokeDasharray={neck.strokeDasharray}\n strokeDashoffset={neck.strokeDashoffset}\n />\n </svg>\n );\n}\n\nfunction MonitorIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <rect width=\"20\" height=\"14\" x=\"2\" y=\"3\" rx=\"2\" />\n <line x1=\"8\" x2=\"16\" y1=\"21\" y2=\"21\" />\n <line x1=\"12\" x2=\"12\" y1=\"17\" y2=\"21\" />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype MonitorIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof MonitorIconBase>;\n\nconst MonitorIconInner = forwardRef<\n HTMLDivElement,\n MonitorIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<MonitorIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <MonitorIconBase\n {...(componentProps as unknown as ComponentProps<typeof MonitorIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const MonitorIcon = Interactive.withSchema({\n Component: MonitorIconInner,\n componentName: \"<MonitorIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-moon.json b/registry-artifacts/elements/icon-moon.jsonindex 4bcc74cd..45c02ad0 100644--- a/registry-artifacts/elements/icon-moon.json+++ b/registry-artifacts/elements/icon-moon.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Moon","durationInFrames": 70,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-moon","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst MOON_PATH =\n \"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401\";\n\nconst CENTER = 12;\n\nconst TIMINGS = {\n drawDurationInFrames: 14,\n actionDelayInFrames: 2,\n actionDurationInFrames: 24,\n loop: false,\n} as const;\n\nfunction MoonIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress, actionFrame } =\n useIconAnimation({ animation, loop, speed }, TIMINGS);\n\n const acting = animation !== \"draw\" && actionFrame >= 0;\n\n const settle = acting\n ? interpolate(actionProgress, [0, 0.2, 0.5, 0.78, 1], [0, -16, 9, -3, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.sin),\n })\n : 0;\n\n const moon = drawnPathProps(MOON_PATH, drawProgress);\n\n const scale = 0.85 + 0.15 * scaleIn;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `scale(${scale})`,\n }}\n >\n <g transform={`rotate(${settle} ${CENTER} ${CENTER})`}>\n <path\n d={MOON_PATH}\n strokeDasharray={moon.strokeDasharray}\n strokeDashoffset={moon.strokeDashoffset}\n />\n </g>\n </svg>\n );\n}\n\nfunction MoonIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d={MOON_PATH} />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype MoonIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof MoonIconBase>;\n\nconst MoonIconInner = forwardRef<\n HTMLDivElement,\n MoonIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<MoonIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <MoonIconBase\n {...(componentProps as unknown as ComponentProps<typeof MoonIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const MoonIcon = Interactive.withSchema({\n Component: MoonIconInner,\n componentName: \"<MoonIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-more-horizontal.json b/registry-artifacts/elements/icon-more-horizontal.jsonindex 20538802..fae38e23 100644--- a/registry-artifacts/elements/icon-more-horizontal.json+++ b/registry-artifacts/elements/icon-more-horizontal.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "More Horizontal","durationInFrames": 70,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-more-horizontal","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst LEFT_PATH =\n \"M5 11 A1 1 0 0 1 6 12 A1 1 0 0 1 5 13 A1 1 0 0 1 4 12 A1 1 0 0 1 5 11\";\nconst CENTER_PATH =\n \"M12 11 A1 1 0 0 1 13 12 A1 1 0 0 1 12 13 A1 1 0 0 1 11 12 A1 1 0 0 1 12 11\";\nconst RIGHT_PATH =\n \"M19 11 A1 1 0 0 1 20 12 A1 1 0 0 1 19 13 A1 1 0 0 1 18 12 A1 1 0 0 1 19 11\";\n\nconst TIMINGS = {\n drawDurationInFrames: 16,\n actionDelayInFrames: 2,\n actionDurationInFrames: 22,\n loop: false,\n} as const;\n\nconst DOTS = [\n { cx: 5, path: LEFT_PATH, drawWindow: [0, 0.5], stagger: 0 },\n { cx: 12, path: CENTER_PATH, drawWindow: [0.25, 0.75], stagger: 0.27 },\n { cx: 19, path: RIGHT_PATH, drawWindow: [0.5, 1], stagger: 0.54 },\n] as const;\n\nfunction MoreHorizontalIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress, actionFrame } =\n useIconAnimation({ animation, loop, speed }, TIMINGS);\n\n const linearDraw = 1 - (1 - drawProgress) ** (1 / 3);\n const acting = animation !== \"draw\" && actionFrame >= 0;\n\n const scale = 0.85 + 0.15 * scaleIn;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `scale(${scale})`,\n }}\n >\n {DOTS.map((dot) => {\n const drawn = interpolate(linearDraw, [...dot.drawWindow], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n const dash = drawnPathProps(dot.path, drawn);\n const dotScale = 0.6 + 0.4 * drawn;\n const lift = acting\n ? interpolate(\n actionProgress,\n [dot.stagger, dot.stagger + 0.2, dot.stagger + 0.4],\n [0, -3, 0],\n {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n },\n )\n : 0;\n const tx = dot.cx * (1 - dotScale);\n const ty = 12 * (1 - dotScale) + lift;\n return (\n <g\n key={dot.cx}\n transform={`translate(${tx} ${ty}) scale(${dotScale})`}\n >\n <path\n d={dot.path}\n strokeDasharray={dash.strokeDasharray}\n strokeDashoffset={dash.strokeDashoffset}\n />\n </g>\n );\n })}\n </svg>\n );\n}\n\nfunction MoreHorizontalIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <circle cx=\"5\" cy=\"12\" r=\"1\" />\n <circle cx=\"12\" cy=\"12\" r=\"1\" />\n <circle cx=\"19\" cy=\"12\" r=\"1\" />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype MoreHorizontalIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof MoreHorizontalIconBase>;\n\nconst MoreHorizontalIconInner = forwardRef<\n HTMLDivElement,\n MoreHorizontalIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<MoreHorizontalIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <MoreHorizontalIconBase\n {...(componentProps as unknown as ComponentProps<typeof MoreHorizontalIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const MoreHorizontalIcon = Interactive.withSchema({\n Component: MoreHorizontalIconInner,\n componentName: \"<MoreHorizontalIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-package.json b/registry-artifacts/elements/icon-package.jsonindex a48490ed..efc130b6 100644--- a/registry-artifacts/elements/icon-package.json+++ b/registry-artifacts/elements/icon-package.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Package","durationInFrames": 80,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-package","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst BOX_PATH =\n \"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z\";\nconst CENTER_PATH = \"M12 22V12\";\nconst EDGE_PATH = \"M7.5 4.27 16.5 9.42\";\nconst SEAM_PATH = \"M3.29 7 12 12 20.71 7\";\n\nconst BASE_Y = 22;\n\nconst TIMINGS = {\n drawDurationInFrames: 16,\n actionDelayInFrames: 2,\n actionDurationInFrames: 26,\n loop: false,\n} as const;\n\nfunction PackageIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress, actionFrame } =\n useIconAnimation({ animation, loop, speed }, TIMINGS);\n\n const linearDraw = 1 - (1 - drawProgress) ** (1 / 3);\n const acting = animation !== \"draw\" && actionFrame >= 0;\n\n const boxDraw = interpolate(linearDraw, [0, 0.7], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n const edgesDraw = interpolate(linearDraw, [0.45, 0.8], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n const seamDraw = interpolate(linearDraw, [0.7, 1], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n\n const drop = acting\n ? interpolate(actionProgress, [0, 0.25, 0.5], [0, 2, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n })\n : 0;\n const squashY = acting\n ? interpolate(\n actionProgress,\n [0, 0.25, 0.5, 0.7, 1],\n [1, 0.95, 1.04, 1, 1],\n {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n },\n )\n : 1;\n const box = drawnPathProps(BOX_PATH, acting ? 1 : boxDraw);\n const center = drawnPathProps(CENTER_PATH, acting ? 1 : edgesDraw);\n const edge = drawnPathProps(EDGE_PATH, acting ? 1 : edgesDraw);\n const seam = drawnPathProps(SEAM_PATH, acting ? 1 : seamDraw);\n\n const scale = 0.85 + 0.15 * scaleIn;\n const bodyTransform = `translate(0 ${drop + BASE_Y * (1 - squashY)}) scale(1 ${squashY})`;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `scale(${scale})`,\n }}\n >\n <g transform={bodyTransform}>\n <path\n d={BOX_PATH}\n strokeDasharray={box.strokeDasharray}\n strokeDashoffset={box.strokeDashoffset}\n />\n <path\n d={CENTER_PATH}\n strokeDasharray={center.strokeDasharray}\n strokeDashoffset={center.strokeDashoffset}\n />\n <path\n d={EDGE_PATH}\n strokeDasharray={edge.strokeDasharray}\n strokeDashoffset={edge.strokeDashoffset}\n />\n <path\n d={SEAM_PATH}\n strokeDasharray={seam.strokeDasharray}\n strokeDashoffset={seam.strokeDashoffset}\n />\n </g>\n </svg>\n );\n}\n\nfunction PackageIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d={BOX_PATH} />\n <path d={CENTER_PATH} />\n <polyline points=\"3.29 7 12 12 20.71 7\" />\n <path d=\"m7.5 4.27 9 5.15\" />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype PackageIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof PackageIconBase>;\n\nconst PackageIconInner = forwardRef<\n HTMLDivElement,\n PackageIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<PackageIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <PackageIconBase\n {...(componentProps as unknown as ComponentProps<typeof PackageIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const PackageIcon = Interactive.withSchema({\n Component: PackageIconInner,\n componentName: \"<PackageIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-party-popper.json b/registry-artifacts/elements/icon-party-popper.jsonindex 82835b71..d73456f7 100644--- a/registry-artifacts/elements/icon-party-popper.json+++ b/registry-artifacts/elements/icon-party-popper.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Party Popper","durationInFrames": 75,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-party-popper","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst CONE_MAIN = \"M5.8 11.3 2 22l10.7-3.79\";\nconst CONE_CURL =\n \"M11 13c1.93 1.93 2.83 4.17 2 5-.83.83-3.07-.07-5-2-1.93-1.93-2.83-4.17-2-5 .83-.83 3.07.07 5 2Z\";\n\nconst CONFETTI = [\n {\n d: \"M11 2 .33.82c.34.86-.2 1.82-1.11 1.98C9.52 4.9 9 5.52 9 6.23V7\",\n cx: 10,\n cy: 4.5,\n dx: 0.22,\n dy: -0.98,\n },\n { d: \"M4 3h.01\", cx: 4, cy: 3, dx: -0.64, dy: -0.77 },\n { d: \"M15 2h.01\", cx: 15, cy: 2, dx: 0.65, dy: -0.76 },\n {\n d: \"m22 2-2.24.75a2.9 2.9 0 0 0-1.96 3.12c.1.86-.57 1.63-1.45 1.63h-.38c-.86 0-1.6.6-1.76 1.44L14 10\",\n cx: 18,\n cy: 6,\n dx: 0.95,\n dy: -0.32,\n },\n {\n d: \"m22 13-.82-.33c-.86-.34-1.82.2-1.98 1.11c-.11.7-.72 1.22-1.43 1.22H17\",\n cx: 19,\n cy: 14,\n dx: 0.89,\n dy: 0.45,\n },\n { d: \"M22 8h.01\", cx: 22, cy: 8, dx: 1, dy: -0.08 },\n { d: \"M22 20h.01\", cx: 22, cy: 20, dx: 0.76, dy: 0.65 },\n] as const;\n\nconst TIMINGS = {\n drawDurationInFrames: 12,\n actionDelayInFrames: 2,\n actionDurationInFrames: 26,\n loop: false,\n} as const;\n\nfunction PartyPopperIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionFrame, actionProgress } =\n useIconAnimation({ animation, loop, speed }, TIMINGS);\n const { fps } = useVideoConfig();\n\n const linearDraw = 1 - (1 - drawProgress) ** (1 / 3);\n\n const mainProgress = interpolate(linearDraw, [0, 0.6], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n const curlProgress = interpolate(linearDraw, [0.4, 1], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n });\n\n const main = drawnPathProps(CONE_MAIN, mainProgress);\n const curl = drawnPathProps(CONE_CURL, curlProgress);\n\n const recoil = interpolate(actionProgress, [0, 0.35, 1], [0, -6, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n });\n const scale = 0.85 + 0.15 * scaleIn;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `scale(${scale})`,\n }}\n >\n <g transform={`rotate(${recoil} 2 22)`}>\n <path\n d={CONE_MAIN}\n strokeDasharray={main.strokeDasharray}\n strokeDashoffset={main.strokeDashoffset}\n />\n <path\n d={CONE_CURL}\n strokeDasharray={curl.strokeDasharray}\n strokeDashoffset={curl.strokeDashoffset}\n />\n </g>\n {CONFETTI.map((piece, index) => {\n const pieceFrame = actionFrame - index * 2;\n const burst =\n pieceFrame <= 0\n ? 0\n : spring({\n frame: pieceFrame,\n fps,\n config: { damping: 12, stiffness: 170, mass: 0.7 },\n durationInFrames: 20,\n });\n const dist = 3 * burst;\n const opacity = interpolate(burst, [0, 0.15], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n });\n return (\n <path\n key={index}\n d={piece.d}\n opacity={opacity}\n transform={`translate(${piece.dx * dist} ${piece.dy * dist}) translate(${piece.cx} ${piece.cy}) scale(${burst}) translate(${-piece.cx} ${-piece.cy})`}\n />\n );\n })}\n </svg>\n );\n}\n\nfunction PartyPopperIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d={CONE_MAIN} />\n <path d={CONE_CURL} />\n {CONFETTI.map((piece, index) => (\n <path key={index} d={piece.d} />\n ))}\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype PartyPopperIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof PartyPopperIconBase>;\n\nconst PartyPopperIconInner = forwardRef<\n HTMLDivElement,\n PartyPopperIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<PartyPopperIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <PartyPopperIconBase\n {...(componentProps as unknown as ComponentProps<typeof PartyPopperIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const PartyPopperIcon = Interactive.withSchema({\n Component: PartyPopperIconInner,\n componentName: \"<PartyPopperIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-pause.json b/registry-artifacts/elements/icon-pause.jsonindex c63fbffe..b17bd709 100644--- a/registry-artifacts/elements/icon-pause.json+++ b/registry-artifacts/elements/icon-pause.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Pause","durationInFrames": 60,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-pause","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst LEFT_PATH =\n \"M6 21A1 1 0 0 1 5 20V4A1 1 0 0 1 6 3H9A1 1 0 0 1 10 4V20A1 1 0 0 1 9 21H6Z\";\nconst RIGHT_PATH =\n \"M18 21A1 1 0 0 0 19 20V4A1 1 0 0 0 18 3H15A1 1 0 0 0 14 4V20A1 1 0 0 0 15 21H18Z\";\n\nconst TIMINGS = {\n drawDurationInFrames: 14,\n actionDelayInFrames: 2,\n actionDurationInFrames: 20,\n loop: false,\n} as const;\n\nfunction PauseIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress } = useIconAnimation(\n { animation, loop, speed },\n TIMINGS,\n );\n\n const linearDraw = 1 - (1 - drawProgress) ** (1 / 3);\n\n const leftProgress = interpolate(linearDraw, [0, 0.88], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n const rightProgress = interpolate(linearDraw, [0.12, 1], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n\n const left = drawnPathProps(LEFT_PATH, leftProgress);\n const right = drawnPathProps(RIGHT_PATH, rightProgress);\n\n const pinch = interpolate(actionProgress, [0, 0.45, 1], [0, 1.5, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n });\n const squash = interpolate(actionProgress, [0, 0.45, 1], [1, 0.94, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n });\n\n const scale = 0.85 + 0.15 * scaleIn;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `scaleX(${scale}) scaleY(${scale * squash})`,\n }}\n >\n <g transform={`translate(${pinch} 0)`}>\n <path\n d={LEFT_PATH}\n strokeDasharray={left.strokeDasharray}\n strokeDashoffset={left.strokeDashoffset}\n />\n </g>\n <g transform={`translate(${-pinch} 0)`}>\n <path\n d={RIGHT_PATH}\n strokeDasharray={right.strokeDasharray}\n strokeDashoffset={right.strokeDashoffset}\n />\n </g>\n </svg>\n );\n}\n\nfunction PauseIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <rect x=\"14\" y=\"3\" width=\"5\" height=\"18\" rx=\"1\" />\n <rect x=\"5\" y=\"3\" width=\"5\" height=\"18\" rx=\"1\" />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype PauseIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof PauseIconBase>;\n\nconst PauseIconInner = forwardRef<\n HTMLDivElement,\n PauseIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<PauseIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <PauseIconBase\n {...(componentProps as unknown as ComponentProps<typeof PauseIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const PauseIcon = Interactive.withSchema({\n Component: PauseIconInner,\n componentName: \"<PauseIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-pencil.json b/registry-artifacts/elements/icon-pencil.jsonindex 12d3d787..16c95be7 100644--- a/registry-artifacts/elements/icon-pencil.json+++ b/registry-artifacts/elements/icon-pencil.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Pencil","durationInFrames": 75,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-pencil","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst BODY_PATH =\n \"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z\";\nconst TIP_PATH = \"M15 5 19 9\";\n\nconst TIMINGS = {\n drawDurationInFrames: 14,\n actionDelayInFrames: 2,\n actionDurationInFrames: 24,\n loop: false,\n} as const;\n\nfunction PencilIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress, actionFrame } =\n useIconAnimation({ animation, loop, speed }, TIMINGS);\n\n const linearDraw = 1 - (1 - drawProgress) ** (1 / 3);\n\n const bodyDraw = interpolate(linearDraw, [0, 0.857], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n const tipDraw = interpolate(linearDraw, [0.571, 1], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n\n const acting = animation !== \"draw\" && actionFrame >= 0;\n\n const rotate = acting\n ? interpolate(actionProgress, [0, 0.25, 0.5, 0.75, 1], [0, -6, 4, -2, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n })\n : 0;\n const nudge = acting\n ? interpolate(\n actionProgress,\n [0, 0.25, 0.5, 0.75, 1],\n [0, 1, -0.5, 0.5, 0],\n {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n },\n )\n : 0;\n\n const body = drawnPathProps(BODY_PATH, bodyDraw);\n const tip = drawnPathProps(TIP_PATH, tipDraw);\n\n const scale = 0.85 + 0.15 * scaleIn;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `scale(${scale})`,\n }}\n >\n <g transform={`rotate(${rotate} 3 21) translate(${nudge} 0)`}>\n <path\n d={BODY_PATH}\n strokeDasharray={body.strokeDasharray}\n strokeDashoffset={body.strokeDashoffset}\n />\n <path\n d={TIP_PATH}\n strokeDasharray={tip.strokeDasharray}\n strokeDashoffset={tip.strokeDashoffset}\n />\n </g>\n </svg>\n );\n}\n\nfunction PencilIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d={BODY_PATH} />\n <path d={TIP_PATH} />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype PencilIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof PencilIconBase>;\n\nconst PencilIconInner = forwardRef<\n HTMLDivElement,\n PencilIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<PencilIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <PencilIconBase\n {...(componentProps as unknown as ComponentProps<typeof PencilIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const PencilIcon = Interactive.withSchema({\n Component: PencilIconInner,\n componentName: \"<PencilIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-phone.json b/registry-artifacts/elements/icon-phone.jsonindex 922044e2..6c224d60 100644--- a/registry-artifacts/elements/icon-phone.json+++ b/registry-artifacts/elements/icon-phone.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Phone","durationInFrames": 70,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-phone","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst PHONE_PATH =\n \"M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384\";\n\nconst CENTER = 12;\n\nconst TIMINGS = {\n drawDurationInFrames: 14,\n actionDelayInFrames: 2,\n actionDurationInFrames: 28,\n loop: false,\n} as const;\n\nfunction PhoneIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress, actionFrame } =\n useIconAnimation({ animation, loop, speed }, TIMINGS);\n\n const acting = animation !== \"draw\" && actionFrame >= 0;\n\n const ring = acting\n ? interpolate(\n actionProgress,\n [0, 0.18, 0.4, 0.62, 0.82, 1],\n [0, 10, -8, 5, -2, 0],\n {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n },\n )\n : 0;\n\n const phone = drawnPathProps(PHONE_PATH, drawProgress);\n\n const scale = 0.85 + 0.15 * scaleIn;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `scale(${scale})`,\n }}\n >\n <g transform={`rotate(${ring} ${CENTER} ${CENTER})`}>\n <path\n d={PHONE_PATH}\n strokeDasharray={phone.strokeDasharray}\n strokeDashoffset={phone.strokeDashoffset}\n />\n </g>\n </svg>\n );\n}\n\nfunction PhoneIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d={PHONE_PATH} />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype PhoneIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof PhoneIconBase>;\n\nconst PhoneIconInner = forwardRef<\n HTMLDivElement,\n PhoneIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<PhoneIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <PhoneIconBase\n {...(componentProps as unknown as ComponentProps<typeof PhoneIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const PhoneIcon = Interactive.withSchema({\n Component: PhoneIconInner,\n componentName: \"<PhoneIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-play.json b/registry-artifacts/elements/icon-play.jsonindex 562167cf..b5f73185 100644--- a/registry-artifacts/elements/icon-play.json+++ b/registry-artifacts/elements/icon-play.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Play","durationInFrames": 60,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-play","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst PLAY_PATH =\n \"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z\";\n\nconst TIMINGS = {\n drawDurationInFrames: 14,\n actionDelayInFrames: 2,\n actionDurationInFrames: 18,\n loop: false,\n} as const;\n\nfunction PlayIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress } = useIconAnimation(\n { animation, loop, speed },\n TIMINGS,\n );\n\n const dash = drawnPathProps(PLAY_PATH, drawProgress);\n const press = interpolate(\n actionProgress,\n [0, 0.33, 0.66, 1],\n [1, 0.92, 1.1, 1],\n {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n },\n );\n const nudge = interpolate(actionProgress, [0.33, 0.66, 1], [0, 1.5, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n const scale = (0.85 + 0.15 * scaleIn) * press;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `translateX(${nudge}px) scale(${scale})`,\n }}\n >\n <path\n d={PLAY_PATH}\n strokeDasharray={dash.strokeDasharray}\n strokeDashoffset={dash.strokeDashoffset}\n />\n </svg>\n );\n}\n\nfunction PlayIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d={PLAY_PATH} />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype PlayIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof PlayIconBase>;\n\nconst PlayIconInner = forwardRef<\n HTMLDivElement,\n PlayIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<PlayIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <PlayIconBase\n {...(componentProps as unknown as ComponentProps<typeof PlayIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const PlayIcon = Interactive.withSchema({\n Component: PlayIconInner,\n componentName: \"<PlayIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-plus-circle.json b/registry-artifacts/elements/icon-plus-circle.jsonindex 82925bae..4ee2f9d6 100644--- a/registry-artifacts/elements/icon-plus-circle.json+++ b/registry-artifacts/elements/icon-plus-circle.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Plus Circle","durationInFrames": 70,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-plus-circle","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst RING_PATH = \"M12 2a10 10 0 1 0 0 20 10 10 0 1 0 0-20Z\";\nconst H_PATH = \"M8 12h8\";\nconst V_PATH = \"M12 8v8\";\n\nconst TIMINGS = {\n drawDurationInFrames: 14,\n actionDelayInFrames: 2,\n actionDurationInFrames: 20,\n loop: false,\n} as const;\n\nfunction PlusCircleIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress, actionFrame } =\n useIconAnimation({ animation, loop, speed }, TIMINGS);\n\n const acting = animation !== \"draw\" && actionFrame >= 0;\n\n const hDraw = interpolate(actionProgress, [0.1, 0.4], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n const vDraw = interpolate(actionProgress, [0.25, 0.55], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n const pop = acting\n ? interpolate(actionProgress, [0.55, 0.75, 1], [1, 1.06, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n })\n : 1;\n\n const hProgress = animation === \"draw\" ? 1 : acting ? hDraw : 0;\n const vProgress = animation === \"draw\" ? 1 : acting ? vDraw : 0;\n\n const ring = drawnPathProps(RING_PATH, drawProgress);\n const h = drawnPathProps(H_PATH, hProgress);\n const v = drawnPathProps(V_PATH, vProgress);\n\n const scale = (0.85 + 0.15 * scaleIn) * pop;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `scale(${scale})`,\n }}\n >\n <path\n d={RING_PATH}\n strokeDasharray={ring.strokeDasharray}\n strokeDashoffset={ring.strokeDashoffset}\n />\n <path\n d={H_PATH}\n strokeDasharray={h.strokeDasharray}\n strokeDashoffset={h.strokeDashoffset}\n />\n <path\n d={V_PATH}\n strokeDasharray={v.strokeDasharray}\n strokeDashoffset={v.strokeDashoffset}\n />\n </svg>\n );\n}\n\nfunction PlusCircleIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <circle cx=\"12\" cy=\"12\" r=\"10\" />\n <path d={H_PATH} />\n <path d={V_PATH} />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype PlusCircleIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof PlusCircleIconBase>;\n\nconst PlusCircleIconInner = forwardRef<\n HTMLDivElement,\n PlusCircleIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<PlusCircleIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <PlusCircleIconBase\n {...(componentProps as unknown as ComponentProps<typeof PlusCircleIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const PlusCircleIcon = Interactive.withSchema({\n Component: PlusCircleIconInner,\n componentName: \"<PlusCircleIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-plus.json b/registry-artifacts/elements/icon-plus.jsonindex 3dfe9f03..90b53085 100644--- a/registry-artifacts/elements/icon-plus.json+++ b/registry-artifacts/elements/icon-plus.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Plus","durationInFrames": 60,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-plus","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst HORIZONTAL_PATH = \"M5 12h14\";\nconst VERTICAL_PATH = \"M12 5v14\";\n\nconst TIMINGS = {\n drawDurationInFrames: 14,\n actionDelayInFrames: 2,\n actionDurationInFrames: 16,\n loop: false,\n} as const;\n\nfunction PlusIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionFrame, actionProgress } =\n useIconAnimation({ animation, loop, speed }, TIMINGS);\n const { fps } = useVideoConfig();\n\n const linearDraw = 1 - (1 - drawProgress) ** (1 / 3);\n\n const horizontalProgress = interpolate(linearDraw, [0, 0.571], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n });\n const verticalProgress = interpolate(linearDraw, [0.286, 0.857], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n });\n\n const horizontal = drawnPathProps(HORIZONTAL_PATH, horizontalProgress);\n const vertical = drawnPathProps(VERTICAL_PATH, verticalProgress);\n\n const rotate =\n 90 *\n spring({\n frame: actionFrame,\n fps,\n config: { damping: 14, stiffness: 130, mass: 0.8 },\n durationInFrames: 16,\n });\n const pop = interpolate(actionProgress, [0, 0.5, 1], [0, 1, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n });\n const scale = (0.85 + 0.15 * scaleIn) * (1 + 0.15 * pop);\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `rotate(${rotate}deg) scale(${scale})`,\n }}\n >\n <path\n d={HORIZONTAL_PATH}\n strokeDasharray={horizontal.strokeDasharray}\n strokeDashoffset={horizontal.strokeDashoffset}\n />\n <path\n d={VERTICAL_PATH}\n strokeDasharray={vertical.strokeDasharray}\n strokeDashoffset={vertical.strokeDashoffset}\n />\n </svg>\n );\n}\n\nfunction PlusIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d={HORIZONTAL_PATH} />\n <path d={VERTICAL_PATH} />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype PlusIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof PlusIconBase>;\n\nconst PlusIconInner = forwardRef<\n HTMLDivElement,\n PlusIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<PlusIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <PlusIconBase\n {...(componentProps as unknown as ComponentProps<typeof PlusIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const PlusIcon = Interactive.withSchema({\n Component: PlusIconInner,\n componentName: \"<PlusIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-refresh-cw.json b/registry-artifacts/elements/icon-refresh-cw.jsonindex 5b4685cd..52fa3ea9 100644--- a/registry-artifacts/elements/icon-refresh-cw.json+++ b/registry-artifacts/elements/icon-refresh-cw.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Refresh Cw","durationInFrames": 90,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-refresh-cw","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst ARC_TOP = \"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8\";\nconst ARROW_TOP = \"M21 3v5h-5\";\nconst ARC_BOTTOM = \"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16\";\nconst ARROW_BOTTOM = \"M8 16H3v5\";\n\nconst SPIN_EASE = Easing.bezier(0.45, 0, 0.25, 1);\n\nconst TIMINGS = {\n drawDurationInFrames: 14,\n actionDelayInFrames: 2,\n actionDurationInFrames: 55,\n loop: true,\n} as const;\n\nfunction RefreshCwIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionFrame, cycleIndex } = useIconAnimation(\n { animation, loop, speed },\n TIMINGS,\n );\n const { fps } = useVideoConfig();\n\n const linearDraw = 1 - (1 - drawProgress) ** (1 / 3);\n\n const arcProgress = interpolate(linearDraw, [0, 0.857], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n });\n const arrowTopPop = interpolate(linearDraw, [0.6, 0.714], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.back(1.8)),\n });\n const arrowBottomPop = interpolate(linearDraw, [0.76, 0.857], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.back(1.8)),\n });\n\n const arcTop = drawnPathProps(ARC_TOP, arcProgress);\n const arcBottom = drawnPathProps(ARC_BOTTOM, arcProgress);\n\n const resolvedLoop = loop ?? TIMINGS.loop;\n const rotate = resolvedLoop\n ? cycleIndex * 360 +\n interpolate(actionFrame, [0, 44], [0, 360], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: SPIN_EASE,\n })\n : 360 *\n spring({\n frame: actionFrame,\n fps,\n config: { damping: 14, stiffness: 120, mass: 0.9 },\n durationInFrames: 44,\n });\n\n const scale = 0.85 + 0.15 * scaleIn;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `rotate(${rotate}deg) scale(${scale})`,\n }}\n >\n <path\n d={ARC_TOP}\n strokeDasharray={arcTop.strokeDasharray}\n strokeDashoffset={arcTop.strokeDashoffset}\n />\n <path\n d={ARC_BOTTOM}\n strokeDasharray={arcBottom.strokeDasharray}\n strokeDashoffset={arcBottom.strokeDashoffset}\n />\n <g transform={`translate(21 8) scale(${arrowTopPop}) translate(-21 -8)`}>\n <path d={ARROW_TOP} />\n </g>\n <g\n transform={`translate(3 16) scale(${arrowBottomPop}) translate(-3 -16)`}\n >\n <path d={ARROW_BOTTOM} />\n </g>\n </svg>\n );\n}\n\nfunction RefreshCwIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d={ARC_TOP} />\n <path d={ARROW_TOP} />\n <path d={ARC_BOTTOM} />\n <path d={ARROW_BOTTOM} />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: true,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: true,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype RefreshCwIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof RefreshCwIconBase>;\n\nconst RefreshCwIconInner = forwardRef<\n HTMLDivElement,\n RefreshCwIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<RefreshCwIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <RefreshCwIconBase\n {...(componentProps as unknown as ComponentProps<typeof RefreshCwIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const RefreshCwIcon = Interactive.withSchema({\n Component: RefreshCwIconInner,\n componentName: \"<RefreshCwIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-rocket.json b/registry-artifacts/elements/icon-rocket.jsonindex 6f436afe..47dbf9d9 100644--- a/registry-artifacts/elements/icon-rocket.json+++ b/registry-artifacts/elements/icon-rocket.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Rocket","durationInFrames": 80,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-rocket","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst BODY_PATH =\n \"M9 12a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.4 22.4 0 0 1-4 2z\";\nconst FIN_RIGHT_PATH = \"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5\";\nconst FIN_LEFT_PATH = \"M9 12H4s.55-3.03 2-4c1.62-1.08 5 .05 5 .05\";\nconst FLAME_PATH =\n \"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09\";\n\nconst TIMINGS = {\n drawDurationInFrames: 18,\n actionDelayInFrames: 2,\n actionDurationInFrames: 30,\n loop: false,\n} as const;\n\nfunction RocketIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress, actionFrame } =\n useIconAnimation({ animation, loop, speed }, TIMINGS);\n\n const linearDraw = 1 - (1 - drawProgress) ** (1 / 3);\n const acting = animation !== \"draw\" && actionFrame >= 0;\n\n const bodyDraw = interpolate(linearDraw, [0, 0.67], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n const finsDraw = interpolate(linearDraw, [0.44, 0.89], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n const flameDraw = interpolate(linearDraw, [0.67, 1], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n\n const rise = acting\n ? interpolate(actionProgress, [0, 0.45, 1], [0, -4, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n })\n : 0;\n const tilt = acting\n ? interpolate(actionProgress, [0, 0.45, 1], [0, -3, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n })\n : 0;\n const flicker = acting\n ? interpolate(\n actionProgress,\n [0, 0.2, 0.4, 0.6, 0.8],\n [1, 1.2, 1, 1.18, 1],\n {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n },\n )\n : 1;\n\n const body = drawnPathProps(BODY_PATH, acting ? 1 : bodyDraw);\n const finRight = drawnPathProps(FIN_RIGHT_PATH, acting ? 1 : finsDraw);\n const finLeft = drawnPathProps(FIN_LEFT_PATH, acting ? 1 : finsDraw);\n const flame = drawnPathProps(FLAME_PATH, acting ? 1 : flameDraw);\n\n const scale = 0.85 + 0.15 * scaleIn;\n const flameTransform = `translate(${4.5 * (1 - flicker)} ${18 * (1 - flicker)}) scale(${flicker})`;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `scale(${scale})`,\n }}\n >\n <g transform={`translate(0 ${rise}) rotate(${tilt} 8 20)`}>\n <path\n d={BODY_PATH}\n strokeDasharray={body.strokeDasharray}\n strokeDashoffset={body.strokeDashoffset}\n />\n <path\n d={FIN_RIGHT_PATH}\n strokeDasharray={finRight.strokeDasharray}\n strokeDashoffset={finRight.strokeDashoffset}\n />\n <path\n d={FIN_LEFT_PATH}\n strokeDasharray={finLeft.strokeDasharray}\n strokeDashoffset={finLeft.strokeDashoffset}\n />\n <g transform={flameTransform}>\n <path\n d={FLAME_PATH}\n strokeDasharray={flame.strokeDasharray}\n strokeDashoffset={flame.strokeDashoffset}\n />\n </g>\n </g>\n </svg>\n );\n}\n\nfunction RocketIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d=\"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5\" />\n <path d=\"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09\" />\n <path d=\"M9 12a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.4 22.4 0 0 1-4 2z\" />\n <path d=\"M9 12H4s.55-3.03 2-4c1.62-1.08 5 .05 5 .05\" />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype RocketIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof RocketIconBase>;\n\nconst RocketIconInner = forwardRef<\n HTMLDivElement,\n RocketIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<RocketIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <RocketIconBase\n {...(componentProps as unknown as ComponentProps<typeof RocketIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const RocketIcon = Interactive.withSchema({\n Component: RocketIconInner,\n componentName: \"<RocketIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-save.json b/registry-artifacts/elements/icon-save.jsonindex d9eaf21d..a59721e0 100644--- a/registry-artifacts/elements/icon-save.json+++ b/registry-artifacts/elements/icon-save.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Save","durationInFrames": 70,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-save","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst DISK_PATH =\n \"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z\";\nconst LABEL_PATH = \"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7\";\nconst SLOT_PATH = \"M7 3v4a1 1 0 0 0 1 1h7\";\n\nconst TIMINGS = {\n drawDurationInFrames: 18,\n actionDelayInFrames: 2,\n actionDurationInFrames: 18,\n loop: false,\n} as const;\n\nfunction SaveIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress, actionFrame } =\n useIconAnimation({ animation, loop, speed }, TIMINGS);\n\n const linearDraw = 1 - (1 - drawProgress) ** (1 / 3);\n const acting = animation !== \"draw\" && actionFrame >= 0;\n\n const diskDraw = interpolate(linearDraw, [0, 0.667], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n const labelDraw = interpolate(linearDraw, [0.444, 0.889], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n const slotDraw = interpolate(linearDraw, [0.667, 1], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n\n const slotProgress = acting\n ? interpolate(actionProgress, [0.25, 0.75], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n })\n : slotDraw;\n\n const squash = acting\n ? interpolate(actionProgress, [0, 0.3, 0.6], [1, 0.92, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n })\n : 1;\n const dip = acting\n ? interpolate(actionProgress, [0, 0.3, 0.6], [0, -1.5, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n })\n : 0;\n\n const disk = drawnPathProps(DISK_PATH, diskDraw);\n const label = drawnPathProps(LABEL_PATH, labelDraw);\n const slot = drawnPathProps(SLOT_PATH, slotProgress);\n\n const scale = 0.85 + 0.15 * scaleIn;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `translateY(${dip}px) scale(${scale}) scaleY(${squash})`,\n }}\n >\n <path\n d={DISK_PATH}\n strokeDasharray={disk.strokeDasharray}\n strokeDashoffset={disk.strokeDashoffset}\n />\n <path\n d={LABEL_PATH}\n strokeDasharray={label.strokeDasharray}\n strokeDashoffset={label.strokeDashoffset}\n />\n <path\n d={SLOT_PATH}\n strokeDasharray={slot.strokeDasharray}\n strokeDashoffset={slot.strokeDashoffset}\n />\n </svg>\n );\n}\n\nfunction SaveIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d={DISK_PATH} />\n <path d={LABEL_PATH} />\n <path d={SLOT_PATH} />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype SaveIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof SaveIconBase>;\n\nconst SaveIconInner = forwardRef<\n HTMLDivElement,\n SaveIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<SaveIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <SaveIconBase\n {...(componentProps as unknown as ComponentProps<typeof SaveIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const SaveIcon = Interactive.withSchema({\n Component: SaveIconInner,\n componentName: \"<SaveIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-search.json b/registry-artifacts/elements/icon-search.jsonindex 7b056fa7..f706bb7b 100644--- a/registry-artifacts/elements/icon-search.json+++ b/registry-artifacts/elements/icon-search.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Search","durationInFrames": 75,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-search","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst CIRCLE_PATH =\n \"M11 3 A8 8 0 0 1 19 11 A8 8 0 0 1 11 19 A8 8 0 0 1 3 11 A8 8 0 0 1 11 3\";\nconst HANDLE_DRAW = \"M16.66 16.66 21 21\";\nconst HANDLE_STATIC = \"m21 21-4.34-4.34\";\n\nconst TIMINGS = {\n drawDurationInFrames: 14,\n actionDelayInFrames: 2,\n actionDurationInFrames: 40,\n loop: false,\n} as const;\n\nfunction SearchIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress } = useIconAnimation(\n { animation, loop, speed },\n TIMINGS,\n );\n\n const linearDraw = 1 - (1 - drawProgress) ** (1 / 3);\n\n const circleProgress = interpolate(linearDraw, [0, 0.857], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n });\n const handleProgress = interpolate(linearDraw, [0.571, 1], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n\n const circle = drawnPathProps(CIRCLE_PATH, circleProgress);\n const handle = drawnPathProps(HANDLE_DRAW, handleProgress);\n\n const scanEase = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n } as const;\n const scanX = interpolate(\n actionProgress,\n [0, 0.25, 0.5, 0.75, 1],\n [0, -3, 3, -1, 0],\n scanEase,\n );\n const scanY = interpolate(\n actionProgress,\n [0, 0.25, 0.5, 0.75, 1],\n [0, -2, -1, 2, 0],\n scanEase,\n );\n\n const scale = 0.85 + 0.15 * scaleIn;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `scale(${scale})`,\n }}\n >\n <g transform={`translate(${scanX} ${scanY})`}>\n <path\n d={CIRCLE_PATH}\n strokeDasharray={circle.strokeDasharray}\n strokeDashoffset={circle.strokeDashoffset}\n />\n <path\n d={HANDLE_DRAW}\n strokeDasharray={handle.strokeDasharray}\n strokeDashoffset={handle.strokeDashoffset}\n />\n </g>\n </svg>\n );\n}\n\nfunction SearchIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <circle cx=\"11\" cy=\"11\" r=\"8\" />\n <path d={HANDLE_STATIC} />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype SearchIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof SearchIconBase>;\n\nconst SearchIconInner = forwardRef<\n HTMLDivElement,\n SearchIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<SearchIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <SearchIconBase\n {...(componentProps as unknown as ComponentProps<typeof SearchIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const SearchIcon = Interactive.withSchema({\n Component: SearchIconInner,\n componentName: \"<SearchIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-send.json b/registry-artifacts/elements/icon-send.jsonindex 52b457b3..3de4962e 100644--- a/registry-artifacts/elements/icon-send.json+++ b/registry-artifacts/elements/icon-send.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Send","durationInFrames": 75,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-send","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst PLANE_PATH =\n \"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z\";\nconst FOLD_PATH = \"m21.854 2.147-10.94 10.939\";\n\nconst TIMINGS = {\n drawDurationInFrames: 14,\n actionDelayInFrames: 2,\n actionDurationInFrames: 22,\n loop: false,\n} as const;\n\nfunction SendIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress } = useIconAnimation(\n { animation, loop, speed },\n TIMINGS,\n );\n\n const linearDraw = 1 - (1 - drawProgress) ** (1 / 3);\n\n const planeProgress = interpolate(linearDraw, [0, 1], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n });\n const foldProgress = interpolate(linearDraw, [0.714, 1], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n\n const plane = drawnPathProps(PLANE_PATH, planeProgress);\n const fold = drawnPathProps(FOLD_PATH, foldProgress);\n\n const dartEase = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n } as const;\n const tx = interpolate(\n actionProgress,\n [0, 0.18, 0.5, 1],\n [0, -1.5, 5, 0],\n dartEase,\n );\n const ty = interpolate(\n actionProgress,\n [0, 0.18, 0.5, 1],\n [0, 1, -4, 0],\n dartEase,\n );\n const rot = interpolate(\n actionProgress,\n [0, 0.18, 0.5, 1],\n [0, 2, -12, 0],\n dartEase,\n );\n\n const scale = 0.85 + 0.15 * scaleIn;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `scale(${scale})`,\n }}\n >\n <g transform={`translate(${tx} ${ty}) rotate(${rot} 12 12)`}>\n <path\n d={PLANE_PATH}\n strokeDasharray={plane.strokeDasharray}\n strokeDashoffset={plane.strokeDashoffset}\n />\n <path\n d={FOLD_PATH}\n strokeDasharray={fold.strokeDasharray}\n strokeDashoffset={fold.strokeDashoffset}\n />\n </g>\n </svg>\n );\n}\n\nfunction SendIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d={PLANE_PATH} />\n <path d={FOLD_PATH} />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype SendIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof SendIconBase>;\n\nconst SendIconInner = forwardRef<\n HTMLDivElement,\n SendIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<SendIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <SendIconBase\n {...(componentProps as unknown as ComponentProps<typeof SendIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const SendIcon = Interactive.withSchema({\n Component: SendIconInner,\n componentName: \"<SendIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-settings.json b/registry-artifacts/elements/icon-settings.jsonindex 1d2d1819..642c6115 100644--- a/registry-artifacts/elements/icon-settings.json+++ b/registry-artifacts/elements/icon-settings.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Settings","durationInFrames": 75,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-settings","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst GEAR_PATH =\n \"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915\";\nconst CIRCLE_PATH =\n \"M12 9 A3 3 0 0 1 15 12 A3 3 0 0 1 12 15 A3 3 0 0 1 9 12 A3 3 0 0 1 12 9\";\n\nconst TIMINGS = {\n drawDurationInFrames: 16,\n actionDelayInFrames: 2,\n actionDurationInFrames: 26,\n loop: false,\n} as const;\n\nfunction SettingsIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionFrame } = useIconAnimation(\n { animation, loop, speed },\n TIMINGS,\n );\n const { fps } = useVideoConfig();\n\n const linearDraw = 1 - (1 - drawProgress) ** (1 / 3);\n\n const gearProgress = interpolate(linearDraw, [0, 1], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n });\n const circleProgress = interpolate(linearDraw, [0.625, 1], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n\n const gear = drawnPathProps(GEAR_PATH, gearProgress);\n const circle = drawnPathProps(CIRCLE_PATH, circleProgress);\n\n const gearRotate =\n 60 *\n spring({\n frame: actionFrame,\n fps,\n config: { damping: 14, stiffness: 120, mass: 0.9 },\n durationInFrames: 26,\n });\n\n const scale = 0.85 + 0.15 * scaleIn;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `scale(${scale})`,\n }}\n >\n <g transform={`rotate(${gearRotate} 12 12)`}>\n <path\n d={GEAR_PATH}\n strokeDasharray={gear.strokeDasharray}\n strokeDashoffset={gear.strokeDashoffset}\n />\n </g>\n <path\n d={CIRCLE_PATH}\n strokeDasharray={circle.strokeDasharray}\n strokeDashoffset={circle.strokeDashoffset}\n />\n </svg>\n );\n}\n\nfunction SettingsIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d={GEAR_PATH} />\n <circle cx=\"12\" cy=\"12\" r=\"3\" />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype SettingsIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof SettingsIconBase>;\n\nconst SettingsIconInner = forwardRef<\n HTMLDivElement,\n SettingsIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<SettingsIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <SettingsIconBase\n {...(componentProps as unknown as ComponentProps<typeof SettingsIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const SettingsIcon = Interactive.withSchema({\n Component: SettingsIconInner,\n componentName: \"<SettingsIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-share-2.json b/registry-artifacts/elements/icon-share-2.jsonindex e316a9a6..a597a58b 100644--- a/registry-artifacts/elements/icon-share-2.json+++ b/registry-artifacts/elements/icon-share-2.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Share 2","durationInFrames": 80,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-share-2","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst LEFT_NODE_PATH =\n \"M6 9 A3 3 0 0 1 9 12 A3 3 0 0 1 6 15 A3 3 0 0 1 3 12 A3 3 0 0 1 6 9\";\nconst TOP_NODE_PATH =\n \"M18 2 A3 3 0 0 1 21 5 A3 3 0 0 1 18 8 A3 3 0 0 1 15 5 A3 3 0 0 1 18 2\";\nconst BOTTOM_NODE_PATH =\n \"M18 16 A3 3 0 0 1 21 19 A3 3 0 0 1 18 22 A3 3 0 0 1 15 19 A3 3 0 0 1 18 16\";\nconst TOP_LINE_PATH = \"M8.59 10.49 15.41 6.51\";\nconst BOTTOM_LINE_PATH = \"M8.59 13.51 15.42 17.49\";\n\nconst TIMINGS = {\n drawDurationInFrames: 18,\n actionDelayInFrames: 2,\n actionDurationInFrames: 26,\n loop: false,\n} as const;\n\nfunction Share2IconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress, actionFrame } =\n useIconAnimation({ animation, loop, speed }, TIMINGS);\n\n const linearDraw = 1 - (1 - drawProgress) ** (1 / 3);\n const acting = animation !== \"draw\" && actionFrame >= 0;\n\n const leftNodeDraw = interpolate(linearDraw, [0, 0.44], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n const connectorDraw = interpolate(linearDraw, [0.33, 0.78], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n const rightNodeDraw = interpolate(linearDraw, [0.56, 1], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n\n const topLineProgress = acting\n ? interpolate(actionProgress, [0, 0.4], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n })\n : connectorDraw;\n const bottomLineProgress = acting\n ? interpolate(actionProgress, [0.15, 0.55], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n })\n : connectorDraw;\n\n const topPop = acting\n ? interpolate(actionProgress, [0.3, 0.45, 0.65], [1, 1.25, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n })\n : 1;\n const bottomPop = acting\n ? interpolate(actionProgress, [0.45, 0.6, 0.8], [1, 1.25, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n })\n : 1;\n\n const leftNode = drawnPathProps(LEFT_NODE_PATH, leftNodeDraw);\n const topLine = drawnPathProps(TOP_LINE_PATH, topLineProgress);\n const bottomLine = drawnPathProps(BOTTOM_LINE_PATH, bottomLineProgress);\n const topNode = drawnPathProps(TOP_NODE_PATH, rightNodeDraw);\n const bottomNode = drawnPathProps(BOTTOM_NODE_PATH, rightNodeDraw);\n\n const scale = 0.85 + 0.15 * scaleIn;\n const topTransform = `translate(${18 * (1 - topPop)} ${5 * (1 - topPop)}) scale(${topPop})`;\n const bottomTransform = `translate(${18 * (1 - bottomPop)} ${19 * (1 - bottomPop)}) scale(${bottomPop})`;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `scale(${scale})`,\n }}\n >\n <path\n d={LEFT_NODE_PATH}\n strokeDasharray={leftNode.strokeDasharray}\n strokeDashoffset={leftNode.strokeDashoffset}\n />\n <path\n d={TOP_LINE_PATH}\n strokeDasharray={topLine.strokeDasharray}\n strokeDashoffset={topLine.strokeDashoffset}\n />\n <path\n d={BOTTOM_LINE_PATH}\n strokeDasharray={bottomLine.strokeDasharray}\n strokeDashoffset={bottomLine.strokeDashoffset}\n />\n <g transform={topTransform}>\n <path\n d={TOP_NODE_PATH}\n strokeDasharray={topNode.strokeDasharray}\n strokeDashoffset={topNode.strokeDashoffset}\n />\n </g>\n <g transform={bottomTransform}>\n <path\n d={BOTTOM_NODE_PATH}\n strokeDasharray={bottomNode.strokeDasharray}\n strokeDashoffset={bottomNode.strokeDashoffset}\n />\n </g>\n </svg>\n );\n}\n\nfunction Share2IconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <circle cx=\"18\" cy=\"5\" r=\"3\" />\n <circle cx=\"6\" cy=\"12\" r=\"3\" />\n <circle cx=\"18\" cy=\"19\" r=\"3\" />\n <line x1=\"8.59\" x2=\"15.42\" y1=\"13.51\" y2=\"17.49\" />\n <line x1=\"15.41\" x2=\"8.59\" y1=\"6.51\" y2=\"10.49\" />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype Share2IconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof Share2IconBase>;\n\nconst Share2IconInner = forwardRef<\n HTMLDivElement,\n Share2IconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<Share2Icon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <Share2IconBase\n {...(componentProps as unknown as ComponentProps<typeof Share2IconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const Share2Icon = Interactive.withSchema({\n Component: Share2IconInner,\n componentName: \"<Share2Icon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-shield.json b/registry-artifacts/elements/icon-shield.jsonindex 97548b26..f9afca61 100644--- a/registry-artifacts/elements/icon-shield.json+++ b/registry-artifacts/elements/icon-shield.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Shield","durationInFrames": 70,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-shield","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst SHIELD_PATH =\n \"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z\";\n\nconst CENTER = 12;\n\nconst TIMINGS = {\n drawDurationInFrames: 14,\n actionDelayInFrames: 2,\n actionDurationInFrames: 18,\n loop: false,\n} as const;\n\nfunction ShieldIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress, actionFrame } =\n useIconAnimation({ animation, loop, speed }, TIMINGS);\n\n const acting = animation !== \"draw\" && actionFrame >= 0;\n\n const brace = acting\n ? interpolate(actionProgress, [0, 0.45, 1], [1, 1.1, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n })\n : 1;\n const lean = acting\n ? interpolate(actionProgress, [0, 0.45, 1], [0, -2, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n })\n : 0;\n\n const shield = drawnPathProps(SHIELD_PATH, drawProgress);\n\n const scale = 0.85 + 0.15 * scaleIn;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `scale(${scale})`,\n }}\n >\n <g\n transform={`rotate(${lean} ${CENTER} ${CENTER}) translate(${CENTER * (1 - brace)} ${CENTER * (1 - brace)}) scale(${brace})`}\n >\n <path\n d={SHIELD_PATH}\n strokeDasharray={shield.strokeDasharray}\n strokeDashoffset={shield.strokeDashoffset}\n />\n </g>\n </svg>\n );\n}\n\nfunction ShieldIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d={SHIELD_PATH} />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype ShieldIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof ShieldIconBase>;\n\nconst ShieldIconInner = forwardRef<\n HTMLDivElement,\n ShieldIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<ShieldIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <ShieldIconBase\n {...(componentProps as unknown as ComponentProps<typeof ShieldIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const ShieldIcon = Interactive.withSchema({\n Component: ShieldIconInner,\n componentName: \"<ShieldIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-shopping-cart.json b/registry-artifacts/elements/icon-shopping-cart.jsonindex b2251abf..4e76b253 100644--- a/registry-artifacts/elements/icon-shopping-cart.json+++ b/registry-artifacts/elements/icon-shopping-cart.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Shopping Cart","durationInFrames": 75,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-shopping-cart","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst BODY_PATH =\n \"M2.05 2.05h2l2.66 12.42a2 2 0 0 0 2 1.58h9.78a2 2 0 0 0 1.95-1.57l1.65-7.43H5.12\";\nconst BACK_WHEEL_PATH = \"M8 20a1 1 0 1 0 0 2 1 1 0 1 0 0-2Z\";\nconst FRONT_WHEEL_PATH = \"M19 20a1 1 0 1 0 0 2 1 1 0 1 0 0-2Z\";\n\nconst BACK_CX = 8;\nconst FRONT_CX = 19;\nconst WHEEL_CY = 21;\n\nconst TIMINGS = {\n drawDurationInFrames: 16,\n actionDelayInFrames: 2,\n actionDurationInFrames: 26,\n loop: false,\n} as const;\n\nfunction ShoppingCartIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress, actionFrame } =\n useIconAnimation({ animation, loop, speed }, TIMINGS);\n\n const linearDraw = 1 - (1 - drawProgress) ** (1 / 3);\n const acting = animation !== \"draw\" && actionFrame >= 0;\n\n const bodyDraw = interpolate(linearDraw, [0, 0.7], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n const wheelsDraw = interpolate(linearDraw, [0.5, 1], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n\n const rollX = acting\n ? interpolate(actionProgress, [0, 0.4, 0.7], [0, 4, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n })\n : 0;\n const tilt = acting\n ? interpolate(actionProgress, [0, 0.4, 0.7], [0, -1, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n })\n : 0;\n const backPop = acting\n ? interpolate(actionProgress, [0.5, 0.65, 0.85], [1, 1.2, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n })\n : 1;\n const frontPop = acting\n ? interpolate(actionProgress, [0.6, 0.75, 0.95], [1, 1.2, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n })\n : 1;\n\n const body = drawnPathProps(BODY_PATH, acting ? 1 : bodyDraw);\n const backWheel = drawnPathProps(BACK_WHEEL_PATH, acting ? 1 : wheelsDraw);\n const frontWheel = drawnPathProps(FRONT_WHEEL_PATH, acting ? 1 : wheelsDraw);\n\n const scale = 0.85 + 0.15 * scaleIn;\n const backTransform = `translate(${BACK_CX * (1 - backPop)} ${WHEEL_CY * (1 - backPop)}) scale(${backPop})`;\n const frontTransform = `translate(${FRONT_CX * (1 - frontPop)} ${WHEEL_CY * (1 - frontPop)}) scale(${frontPop})`;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `scale(${scale})`,\n }}\n >\n <g transform={`translate(${rollX} 0) rotate(${tilt} 12 12)`}>\n <path\n d={BODY_PATH}\n strokeDasharray={body.strokeDasharray}\n strokeDashoffset={body.strokeDashoffset}\n />\n <g transform={backTransform}>\n <path\n d={BACK_WHEEL_PATH}\n strokeDasharray={backWheel.strokeDasharray}\n strokeDashoffset={backWheel.strokeDashoffset}\n />\n </g>\n <g transform={frontTransform}>\n <path\n d={FRONT_WHEEL_PATH}\n strokeDasharray={frontWheel.strokeDasharray}\n strokeDashoffset={frontWheel.strokeDashoffset}\n />\n </g>\n </g>\n </svg>\n );\n}\n\nfunction ShoppingCartIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <circle cx=\"8\" cy=\"21\" r=\"1\" />\n <circle cx=\"19\" cy=\"21\" r=\"1\" />\n <path d={BODY_PATH} />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype ShoppingCartIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof ShoppingCartIconBase>;\n\nconst ShoppingCartIconInner = forwardRef<\n HTMLDivElement,\n ShoppingCartIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<ShoppingCartIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <ShoppingCartIconBase\n {...(componentProps as unknown as ComponentProps<typeof ShoppingCartIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const ShoppingCartIcon = Interactive.withSchema({\n Component: ShoppingCartIconInner,\n componentName: \"<ShoppingCartIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-skip-forward.json b/registry-artifacts/elements/icon-skip-forward.jsonindex 4a695ef5..0e1ceec4 100644--- a/registry-artifacts/elements/icon-skip-forward.json+++ b/registry-artifacts/elements/icon-skip-forward.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Skip Forward","durationInFrames": 60,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-skip-forward","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst TRIANGLE_PATH =\n \"M6.029 4.285A2 2 0 0 0 3 6v12a2 2 0 0 0 3.029 1.715l9.997-5.998a2 2 0 0 0 .003-3.432z\";\nconst BAR_PATH = \"M21 4v16\";\n\nconst TIMINGS = {\n drawDurationInFrames: 14,\n actionDelayInFrames: 2,\n actionDurationInFrames: 20,\n loop: false,\n} as const;\n\nfunction SkipForwardIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress } = useIconAnimation(\n { animation, loop, speed },\n TIMINGS,\n );\n\n const linearDraw = 1 - (1 - drawProgress) ** (1 / 3);\n\n const triangleProgress = interpolate(linearDraw, [0, 0.71], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n const barProgress = interpolate(linearDraw, [0.43, 1], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n\n const triangle = drawnPathProps(TRIANGLE_PATH, triangleProgress);\n const bar = drawnPathProps(BAR_PATH, barProgress);\n\n const dash = interpolate(\n actionProgress,\n [0, 0.2, 0.6, 0.82, 1],\n [0, -1.2, 2, -0.3, 0],\n {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n },\n );\n const squeeze = interpolate(actionProgress, [0.45, 0.6, 0.78], [1, 0.96, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n });\n const shove = interpolate(actionProgress, [0.55, 0.62, 1], [0, 0.5, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n\n const scale = 0.85 + 0.15 * scaleIn;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `scale(${scale})`,\n }}\n >\n <g\n transform={`translate(${dash} 0) scale(${squeeze} 1)`}\n style={{ transformOrigin: \"16px 12px\" }}\n >\n <path\n d={TRIANGLE_PATH}\n strokeDasharray={triangle.strokeDasharray}\n strokeDashoffset={triangle.strokeDashoffset}\n />\n </g>\n <g transform={`translate(${shove} 0)`}>\n <path\n d={BAR_PATH}\n strokeDasharray={bar.strokeDasharray}\n strokeDashoffset={bar.strokeDashoffset}\n />\n </g>\n </svg>\n );\n}\n\nfunction SkipForwardIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d={BAR_PATH} />\n <path d={TRIANGLE_PATH} />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype SkipForwardIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof SkipForwardIconBase>;\n\nconst SkipForwardIconInner = forwardRef<\n HTMLDivElement,\n SkipForwardIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<SkipForwardIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <SkipForwardIconBase\n {...(componentProps as unknown as ComponentProps<typeof SkipForwardIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const SkipForwardIcon = Interactive.withSchema({\n Component: SkipForwardIconInner,\n componentName: \"<SkipForwardIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-smartphone.json b/registry-artifacts/elements/icon-smartphone.jsonindex ab1b1909..69032984 100644--- a/registry-artifacts/elements/icon-smartphone.json+++ b/registry-artifacts/elements/icon-smartphone.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Smartphone","durationInFrames": 70,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-smartphone","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst BODY_PATH =\n \"M7 2H17A2 2 0 0 1 19 4V20A2 2 0 0 1 17 22H7A2 2 0 0 1 5 20V4A2 2 0 0 1 7 2Z\";\nconst BUTTON_PATH = \"M12 18h.01\";\n\nconst CENTER = 12;\n\nconst TIMINGS = {\n drawDurationInFrames: 14,\n actionDelayInFrames: 2,\n actionDurationInFrames: 18,\n loop: false,\n} as const;\n\nfunction SmartphoneIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress, actionFrame } =\n useIconAnimation({ animation, loop, speed }, TIMINGS);\n\n const linearDraw = 1 - (1 - drawProgress) ** (1 / 3);\n const acting = animation !== \"draw\" && actionFrame >= 0;\n\n const bodyDraw = interpolate(linearDraw, [0, 0.75], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n const buttonDraw = interpolate(linearDraw, [0.7, 1], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n\n const buzz = acting\n ? interpolate(\n actionProgress,\n [0, 0.2, 0.45, 0.7, 0.9, 1],\n [0, 3, -3, 2, -1, 0],\n {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n },\n )\n : 0;\n\n const body = drawnPathProps(BODY_PATH, acting ? 1 : bodyDraw);\n const button = drawnPathProps(BUTTON_PATH, acting ? 1 : buttonDraw);\n\n const scale = 0.85 + 0.15 * scaleIn;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `scale(${scale})`,\n }}\n >\n <g transform={`rotate(${buzz} ${CENTER} ${CENTER})`}>\n <path\n d={BODY_PATH}\n strokeDasharray={body.strokeDasharray}\n strokeDashoffset={body.strokeDashoffset}\n />\n <path\n d={BUTTON_PATH}\n strokeDasharray={button.strokeDasharray}\n strokeDashoffset={button.strokeDashoffset}\n />\n </g>\n </svg>\n );\n}\n\nfunction SmartphoneIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <rect width=\"14\" height=\"20\" x=\"5\" y=\"2\" rx=\"2\" ry=\"2\" />\n <path d=\"M12 18h.01\" />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype SmartphoneIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof SmartphoneIconBase>;\n\nconst SmartphoneIconInner = forwardRef<\n HTMLDivElement,\n SmartphoneIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<SmartphoneIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <SmartphoneIconBase\n {...(componentProps as unknown as ComponentProps<typeof SmartphoneIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const SmartphoneIcon = Interactive.withSchema({\n Component: SmartphoneIconInner,\n componentName: \"<SmartphoneIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-sparkles.json b/registry-artifacts/elements/icon-sparkles.jsonindex d5f3acf8..c84e7921 100644--- a/registry-artifacts/elements/icon-sparkles.json+++ b/registry-artifacts/elements/icon-sparkles.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Sparkles","durationInFrames": 90,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-sparkles","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst MAIN_PATH =\n \"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z\";\nconst ACCENT_TR_V = \"M20 2v4\";\nconst ACCENT_TR_H = \"M22 4h-4\";\n\nconst TIMINGS = {\n drawDurationInFrames: 14,\n actionDelayInFrames: 2,\n actionDurationInFrames: 45,\n loop: true,\n} as const;\n\nfunction SparklesIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress } = useIconAnimation(\n { animation, loop, speed },\n TIMINGS,\n );\n\n const linearDraw = 1 - (1 - drawProgress) ** (1 / 3);\n\n const mainProgress = interpolate(linearDraw, [0, 0.857], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n });\n const popTR = interpolate(linearDraw, [0.55, 0.714], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.back(1.8)),\n });\n const popBL = interpolate(linearDraw, [0.857, 1], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.back(1.8)),\n });\n\n const main = drawnPathProps(MAIN_PATH, mainProgress);\n\n const mainPulse = interpolate(actionProgress, [0, 0.5, 1], [1, 1.08, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n });\n const smallPulse = interpolate(actionProgress, [0, 0.5, 1], [1, 0.7, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n });\n const smallOpacity = interpolate(actionProgress, [0, 0.5, 1], [1, 0.5, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n });\n\n const scale = 0.85 + 0.15 * scaleIn;\n const trScale = popTR * smallPulse;\n const blScale = popBL * smallPulse;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `scale(${scale})`,\n }}\n >\n <g transform={`translate(12 12) scale(${mainPulse}) translate(-12 -12)`}>\n <path\n d={MAIN_PATH}\n strokeDasharray={main.strokeDasharray}\n strokeDashoffset={main.strokeDashoffset}\n />\n </g>\n <g\n opacity={smallOpacity}\n transform={`translate(20 4) scale(${trScale}) translate(-20 -4)`}\n >\n <path d={ACCENT_TR_V} />\n <path d={ACCENT_TR_H} />\n </g>\n <g\n opacity={smallOpacity}\n transform={`translate(4 20) scale(${blScale}) translate(-4 -20)`}\n >\n <circle cx=\"4\" cy=\"20\" r=\"2\" />\n </g>\n </svg>\n );\n}\n\nfunction SparklesIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d={MAIN_PATH} />\n <path d={ACCENT_TR_V} />\n <path d={ACCENT_TR_H} />\n <circle cx=\"4\" cy=\"20\" r=\"2\" />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: true,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: true,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype SparklesIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof SparklesIconBase>;\n\nconst SparklesIconInner = forwardRef<\n HTMLDivElement,\n SparklesIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<SparklesIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <SparklesIconBase\n {...(componentProps as unknown as ComponentProps<typeof SparklesIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const SparklesIcon = Interactive.withSchema({\n Component: SparklesIconInner,\n componentName: \"<SparklesIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-star.json b/registry-artifacts/elements/icon-star.jsonindex 5c05034e..28cc9798 100644--- a/registry-artifacts/elements/icon-star.json+++ b/registry-artifacts/elements/icon-star.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Star","durationInFrames": 70,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-star","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst STAR_PATH =\n \"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z\";\n\nconst TIMINGS = {\n drawDurationInFrames: 14,\n actionDelayInFrames: 2,\n actionDurationInFrames: 18,\n loop: false,\n} as const;\n\nfunction StarIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionFrame, actionProgress } =\n useIconAnimation({ animation, loop, speed }, TIMINGS);\n const { fps } = useVideoConfig();\n\n const linearDraw = 1 - (1 - drawProgress) ** (1 / 3);\n\n const starProgress = interpolate(linearDraw, [0, 1], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n });\n\n const star = drawnPathProps(STAR_PATH, starProgress);\n\n const settle = spring({\n frame: actionFrame,\n fps,\n config: { damping: 12, stiffness: 140, mass: 0.8 },\n durationInFrames: 18,\n });\n const rotate = -8 * (1 - settle);\n const pop = interpolate(actionProgress, [0, 0.5, 1], [0, 1, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n });\n const scale = (0.85 + 0.15 * scaleIn) * (1 + 0.12 * pop);\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `rotate(${rotate}deg) scale(${scale})`,\n }}\n >\n <path\n d={STAR_PATH}\n strokeDasharray={star.strokeDasharray}\n strokeDashoffset={star.strokeDashoffset}\n />\n </svg>\n );\n}\n\nfunction StarIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d={STAR_PATH} />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype StarIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof StarIconBase>;\n\nconst StarIconInner = forwardRef<\n HTMLDivElement,\n StarIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<StarIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <StarIconBase\n {...(componentProps as unknown as ComponentProps<typeof StarIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const StarIcon = Interactive.withSchema({\n Component: StarIconInner,\n componentName: \"<StarIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-sun.json b/registry-artifacts/elements/icon-sun.jsonindex 486d05b0..a47588a2 100644--- a/registry-artifacts/elements/icon-sun.json+++ b/registry-artifacts/elements/icon-sun.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Sun","durationInFrames": 85,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-sun","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst CORE_PATH = \"M12 8a4 4 0 1 0 0 8 4 4 0 1 0 0-8Z\";\n\nconst RAYS = [\n \"M12 4 12 2\",\n \"M17.66 6.34 19.07 4.93\",\n \"M20 12 22 12\",\n \"M17.66 17.66 19.07 19.07\",\n \"M12 20 12 22\",\n \"M6.34 17.66 4.93 19.07\",\n \"M4 12 2 12\",\n \"M6.34 6.34 4.93 4.93\",\n];\n\nconst CENTER = 12;\n\nconst TIMINGS = {\n drawDurationInFrames: 14,\n actionDelayInFrames: 2,\n actionDurationInFrames: 30,\n loop: false,\n} as const;\n\nfunction SunIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress, actionFrame } =\n useIconAnimation({ animation, loop, speed }, TIMINGS);\n\n const acting = animation !== \"draw\" && actionFrame >= 0;\n\n const corePop = acting\n ? interpolate(actionProgress, [0.55, 0.75, 1], [1, 1.08, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n })\n : 1;\n\n const core = drawnPathProps(CORE_PATH, drawProgress);\n\n const rays = RAYS.map((d, i) => {\n const start = i * 0.07;\n const rayFan = interpolate(actionProgress, [start, start + 0.28], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n const progress = animation === \"draw\" ? 1 : acting ? rayFan : 0;\n return { d, ...drawnPathProps(d, progress) };\n });\n\n const scale = 0.85 + 0.15 * scaleIn;\n const coreTransform = `translate(${CENTER * (1 - corePop)} ${CENTER * (1 - corePop)}) scale(${corePop})`;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `scale(${scale})`,\n }}\n >\n {rays.map((ray) => (\n <path\n key={ray.d}\n d={ray.d}\n strokeDasharray={ray.strokeDasharray}\n strokeDashoffset={ray.strokeDashoffset}\n />\n ))}\n <g transform={coreTransform}>\n <path\n d={CORE_PATH}\n strokeDasharray={core.strokeDasharray}\n strokeDashoffset={core.strokeDashoffset}\n />\n </g>\n </svg>\n );\n}\n\nfunction SunIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <circle cx=\"12\" cy=\"12\" r=\"4\" />\n <path d=\"M12 2v2\" />\n <path d=\"M12 20v2\" />\n <path d=\"m4.93 4.93 1.41 1.41\" />\n <path d=\"m17.66 17.66 1.41 1.41\" />\n <path d=\"M2 12h2\" />\n <path d=\"M20 12h2\" />\n <path d=\"m6.34 17.66-1.41 1.41\" />\n <path d=\"m19.07 4.93-1.41 1.41\" />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype SunIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof SunIconBase>;\n\nconst SunIconInner = forwardRef<\n HTMLDivElement,\n SunIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<SunIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <SunIconBase\n {...(componentProps as unknown as ComponentProps<typeof SunIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const SunIcon = Interactive.withSchema({\n Component: SunIconInner,\n componentName: \"<SunIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-tag.json b/registry-artifacts/elements/icon-tag.jsonindex 2fd8452d..31c97993 100644--- a/registry-artifacts/elements/icon-tag.json+++ b/registry-artifacts/elements/icon-tag.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Tag","durationInFrames": 70,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-tag","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst TAG_PATH =\n \"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z\";\n\nconst HOLE_X = 7.5;\nconst HOLE_Y = 7.5;\n\nconst TIMINGS = {\n drawDurationInFrames: 16,\n actionDelayInFrames: 2,\n actionDurationInFrames: 26,\n loop: false,\n} as const;\n\nfunction TagIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress, actionFrame } =\n useIconAnimation({ animation, loop, speed }, TIMINGS);\n\n const linearDraw = 1 - (1 - drawProgress) ** (1 / 3);\n const acting = animation !== \"draw\" && actionFrame >= 0;\n\n const holeScale = acting\n ? 1\n : interpolate(linearDraw, [0.7, 1], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n\n const swing = acting\n ? interpolate(actionProgress, [0, 0.2, 0.45, 0.7, 1], [0, 8, -6, 3, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.sin),\n })\n : 0;\n\n const tag = drawnPathProps(TAG_PATH, drawProgress);\n\n const scale = 0.85 + 0.15 * scaleIn;\n const holeTransform = `translate(${HOLE_X * (1 - holeScale)} ${HOLE_Y * (1 - holeScale)}) scale(${holeScale})`;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `scale(${scale})`,\n }}\n >\n <g transform={`rotate(${swing} ${HOLE_X} ${HOLE_Y})`}>\n <path\n d={TAG_PATH}\n strokeDasharray={tag.strokeDasharray}\n strokeDashoffset={tag.strokeDashoffset}\n />\n <g transform={holeTransform}>\n <circle cx=\"7.5\" cy=\"7.5\" r=\"0.5\" fill={color} stroke=\"none\" />\n </g>\n </g>\n </svg>\n );\n}\n\nfunction TagIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d={TAG_PATH} />\n <circle cx=\"7.5\" cy=\"7.5\" r=\"0.5\" fill={color} stroke=\"none\" />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype TagIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof TagIconBase>;\n\nconst TagIconInner = forwardRef<\n HTMLDivElement,\n TagIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<TagIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <TagIconBase\n {...(componentProps as unknown as ComponentProps<typeof TagIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const TagIcon = Interactive.withSchema({\n Component: TagIconInner,\n componentName: \"<TagIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-target.json b/registry-artifacts/elements/icon-target.jsonindex 32fd20d5..ebf2e9cc 100644--- a/registry-artifacts/elements/icon-target.json+++ b/registry-artifacts/elements/icon-target.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Target","durationInFrames": 80,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-target","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst RING_OUTER = \"M12 2a10 10 0 1 0 0 20 10 10 0 1 0 0-20Z\";\nconst RING_MID = \"M12 6a6 6 0 1 0 0 12 6 6 0 1 0 0-12Z\";\nconst RING_INNER = \"M12 10a2 2 0 1 0 0 4 2 2 0 1 0 0-4Z\";\n\nconst CENTER = 12;\n\nconst TIMINGS = {\n drawDurationInFrames: 18,\n actionDelayInFrames: 2,\n actionDurationInFrames: 24,\n loop: false,\n} as const;\n\nfunction TargetIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress, actionFrame } =\n useIconAnimation({ animation, loop, speed }, TIMINGS);\n\n const linearDraw = 1 - (1 - drawProgress) ** (1 / 3);\n const acting = animation !== \"draw\" && actionFrame >= 0;\n\n const outerDraw = interpolate(linearDraw, [0, 0.55], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n const midDraw = interpolate(linearDraw, [0.28, 0.83], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n const innerDraw = interpolate(linearDraw, [0.55, 1], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n\n const pop = acting\n ? interpolate(actionProgress, [0, 0.25, 0.6], [1, 1.5, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n })\n : 1;\n const shake = acting\n ? interpolate(\n actionProgress,\n [0.6, 0.68, 0.78, 0.88, 1],\n [0, 0.6, -0.6, 0.3, 0],\n {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n },\n )\n : 0;\n\n const outer = drawnPathProps(RING_OUTER, acting ? 1 : outerDraw);\n const mid = drawnPathProps(RING_MID, acting ? 1 : midDraw);\n const inner = drawnPathProps(RING_INNER, acting ? 1 : innerDraw);\n\n const scale = 0.85 + 0.15 * scaleIn;\n const popTransform = `translate(${CENTER * (1 - pop)} ${CENTER * (1 - pop)}) scale(${pop})`;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `scale(${scale})`,\n }}\n >\n <g transform={`translate(${shake} 0)`}>\n <path\n d={RING_OUTER}\n strokeDasharray={outer.strokeDasharray}\n strokeDashoffset={outer.strokeDashoffset}\n />\n <path\n d={RING_MID}\n strokeDasharray={mid.strokeDasharray}\n strokeDashoffset={mid.strokeDashoffset}\n />\n <g transform={popTransform}>\n <path\n d={RING_INNER}\n strokeDasharray={inner.strokeDasharray}\n strokeDashoffset={inner.strokeDashoffset}\n />\n </g>\n </g>\n </svg>\n );\n}\n\nfunction TargetIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <circle cx=\"12\" cy=\"12\" r=\"10\" />\n <circle cx=\"12\" cy=\"12\" r=\"6\" />\n <circle cx=\"12\" cy=\"12\" r=\"2\" />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype TargetIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof TargetIconBase>;\n\nconst TargetIconInner = forwardRef<\n HTMLDivElement,\n TargetIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<TargetIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <TargetIconBase\n {...(componentProps as unknown as ComponentProps<typeof TargetIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const TargetIcon = Interactive.withSchema({\n Component: TargetIconInner,\n componentName: \"<TargetIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-terminal.json b/registry-artifacts/elements/icon-terminal.jsonindex 56ac6e41..ca765e3e 100644--- a/registry-artifacts/elements/icon-terminal.json+++ b/registry-artifacts/elements/icon-terminal.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Terminal","durationInFrames": 75,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-terminal","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst CHEVRON_PATH = \"M4 17 10 11 4 5\";\nconst CURSOR_PATH = \"M12 19H20\";\n\nconst TIMINGS = {\n drawDurationInFrames: 14,\n actionDelayInFrames: 2,\n actionDurationInFrames: 32,\n loop: false,\n} as const;\n\nfunction TerminalIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress, actionFrame } =\n useIconAnimation({ animation, loop, speed }, TIMINGS);\n\n const linearDraw = 1 - (1 - drawProgress) ** (1 / 3);\n const acting = animation !== \"draw\" && actionFrame >= 0;\n\n const chevronDraw = interpolate(linearDraw, [0, 0.7], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n const cursorDraw = interpolate(linearDraw, [0.55, 1], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n\n const nudge = acting\n ? interpolate(actionProgress, [0, 0.15, 0.35], [0, 2, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n })\n : 0;\n const cursorOpacity = acting\n ? interpolate(\n actionProgress,\n [0.3, 0.42, 0.54, 0.66, 0.78],\n [1, 0, 1, 0, 1],\n { extrapolateLeft: \"clamp\", extrapolateRight: \"clamp\" },\n )\n : 1;\n\n const chevron = drawnPathProps(CHEVRON_PATH, acting ? 1 : chevronDraw);\n const cursor = drawnPathProps(CURSOR_PATH, acting ? 1 : cursorDraw);\n\n const scale = 0.85 + 0.15 * scaleIn;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `scale(${scale})`,\n }}\n >\n <g transform={`translate(${nudge} 0)`}>\n <path\n d={CHEVRON_PATH}\n strokeDasharray={chevron.strokeDasharray}\n strokeDashoffset={chevron.strokeDashoffset}\n />\n </g>\n <path\n d={CURSOR_PATH}\n strokeDasharray={cursor.strokeDasharray}\n strokeDashoffset={cursor.strokeDashoffset}\n opacity={cursorOpacity}\n />\n </svg>\n );\n}\n\nfunction TerminalIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d=\"M12 19h8\" />\n <path d=\"m4 17 6-6-6-6\" />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype TerminalIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof TerminalIconBase>;\n\nconst TerminalIconInner = forwardRef<\n HTMLDivElement,\n TerminalIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<TerminalIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <TerminalIconBase\n {...(componentProps as unknown as ComponentProps<typeof TerminalIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const TerminalIcon = Interactive.withSchema({\n Component: TerminalIconInner,\n componentName: \"<TerminalIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-thumbs-up.json b/registry-artifacts/elements/icon-thumbs-up.jsonindex a5864344..b2ebcfdb 100644--- a/registry-artifacts/elements/icon-thumbs-up.json+++ b/registry-artifacts/elements/icon-thumbs-up.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Thumbs Up","durationInFrames": 70,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-thumbs-up","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst HAND_PATH =\n \"M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z\";\nconst CUFF_PATH = \"M7 10v12\";\n\nconst TIMINGS = {\n drawDurationInFrames: 16,\n actionDelayInFrames: 2,\n actionDurationInFrames: 18,\n loop: false,\n} as const;\n\nfunction ThumbsUpIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionFrame, actionProgress } =\n useIconAnimation({ animation, loop, speed }, TIMINGS);\n const { fps } = useVideoConfig();\n\n const linearDraw = 1 - (1 - drawProgress) ** (1 / 3);\n\n const handProgress = interpolate(linearDraw, [0.25, 1], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n const cuffProgress = interpolate(linearDraw, [0, 0.5], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n });\n\n const hand = drawnPathProps(HAND_PATH, handProgress);\n const cuff = drawnPathProps(CUFF_PATH, cuffProgress);\n\n const settle = spring({\n frame: actionFrame,\n fps,\n config: { damping: 11, stiffness: 150, mass: 0.8 },\n durationInFrames: 18,\n });\n const rotate = -18 * (1 - settle);\n const pop = interpolate(actionProgress, [0, 0.5, 1], [1, 1.1, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n });\n const scale = (0.85 + 0.15 * scaleIn) * pop;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `scale(${scale})`,\n }}\n >\n <g transform={`rotate(${rotate} 4 22)`}>\n <path\n d={HAND_PATH}\n strokeDasharray={hand.strokeDasharray}\n strokeDashoffset={hand.strokeDashoffset}\n />\n <path\n d={CUFF_PATH}\n strokeDasharray={cuff.strokeDasharray}\n strokeDashoffset={cuff.strokeDashoffset}\n />\n </g>\n </svg>\n );\n}\n\nfunction ThumbsUpIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d={HAND_PATH} />\n <path d={CUFF_PATH} />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype ThumbsUpIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof ThumbsUpIconBase>;\n\nconst ThumbsUpIconInner = forwardRef<\n HTMLDivElement,\n ThumbsUpIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<ThumbsUpIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <ThumbsUpIconBase\n {...(componentProps as unknown as ComponentProps<typeof ThumbsUpIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const ThumbsUpIcon = Interactive.withSchema({\n Component: ThumbsUpIconInner,\n componentName: \"<ThumbsUpIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-timer.json b/registry-artifacts/elements/icon-timer.jsonindex 4a4fd427..d1e6b854 100644--- a/registry-artifacts/elements/icon-timer.json+++ b/registry-artifacts/elements/icon-timer.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Timer","durationInFrames": 90,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-timer","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst DIAL_PATH = \"M12 6a8 8 0 1 0 0 16 8 8 0 1 0 0-16Z\";\nconst BUTTON_PATH = \"M10 2H14\";\nconst HAND_PATH = \"M12 14 15 11\";\n\nconst DIAL_CX = 12;\nconst DIAL_CY = 14;\n\nconst TIMINGS = {\n drawDurationInFrames: 18,\n actionDelayInFrames: 2,\n actionDurationInFrames: 48,\n loop: false,\n} as const;\n\nfunction TimerIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress, actionFrame } =\n useIconAnimation({ animation, loop, speed }, TIMINGS);\n\n const linearDraw = 1 - (1 - drawProgress) ** (1 / 3);\n const acting = animation !== \"draw\" && actionFrame >= 0;\n\n const dialDraw = interpolate(linearDraw, [0, 0.6], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n const buttonDraw = interpolate(linearDraw, [0.45, 0.75], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n const handDraw = interpolate(linearDraw, [0.7, 1], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n\n const buttonDip = acting\n ? interpolate(actionProgress, [0, 0.15, 0.3], [0, 1.5, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n })\n : 0;\n const handSweep = acting\n ? interpolate(actionProgress, [0.3, 1], [0, 360], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.cubic),\n })\n : 0;\n\n const dial = drawnPathProps(DIAL_PATH, acting ? 1 : dialDraw);\n const button = drawnPathProps(BUTTON_PATH, acting ? 1 : buttonDraw);\n const hand = drawnPathProps(HAND_PATH, acting ? 1 : handDraw);\n\n const scale = 0.85 + 0.15 * scaleIn;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `scale(${scale})`,\n }}\n >\n <path\n d={DIAL_PATH}\n strokeDasharray={dial.strokeDasharray}\n strokeDashoffset={dial.strokeDashoffset}\n />\n <g transform={`translate(0 ${buttonDip})`}>\n <path\n d={BUTTON_PATH}\n strokeDasharray={button.strokeDasharray}\n strokeDashoffset={button.strokeDashoffset}\n />\n </g>\n <g transform={`rotate(${handSweep} ${DIAL_CX} ${DIAL_CY})`}>\n <path\n d={HAND_PATH}\n strokeDasharray={hand.strokeDasharray}\n strokeDashoffset={hand.strokeDashoffset}\n />\n </g>\n </svg>\n );\n}\n\nfunction TimerIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <line x1=\"10\" x2=\"14\" y1=\"2\" y2=\"2\" />\n <line x1=\"12\" x2=\"15\" y1=\"14\" y2=\"11\" />\n <circle cx=\"12\" cy=\"14\" r=\"8\" />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype TimerIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof TimerIconBase>;\n\nconst TimerIconInner = forwardRef<\n HTMLDivElement,\n TimerIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<TimerIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <TimerIconBase\n {...(componentProps as unknown as ComponentProps<typeof TimerIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const TimerIcon = Interactive.withSchema({\n Component: TimerIconInner,\n componentName: \"<TimerIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-trash.json b/registry-artifacts/elements/icon-trash.jsonindex c64df927..6e24b110 100644--- a/registry-artifacts/elements/icon-trash.json+++ b/registry-artifacts/elements/icon-trash.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Trash","durationInFrames": 75,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-trash","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst BODY_PATH = \"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6\";\nconst INNER1_PATH = \"M10 11v6\";\nconst INNER2_PATH = \"M14 11v6\";\nconst LID_PATH = \"M3 6h18\";\nconst HANDLE_PATH = \"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2\";\n\nconst TIMINGS = {\n drawDurationInFrames: 14,\n actionDelayInFrames: 2,\n actionDurationInFrames: 24,\n loop: false,\n} as const;\n\nfunction TrashIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress } = useIconAnimation(\n { animation, loop, speed },\n TIMINGS,\n );\n\n const linearDraw = 1 - (1 - drawProgress) ** (1 / 3);\n\n const bodyProgress = interpolate(linearDraw, [0, 0.714], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n });\n const innerProgress = interpolate(linearDraw, [0.571, 1], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n const lidProgress = interpolate(linearDraw, [0.714, 1], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n\n const body = drawnPathProps(BODY_PATH, bodyProgress);\n const inner1 = drawnPathProps(INNER1_PATH, innerProgress);\n const inner2 = drawnPathProps(INNER2_PATH, innerProgress);\n const lid = drawnPathProps(LID_PATH, lidProgress);\n const handle = drawnPathProps(HANDLE_PATH, lidProgress);\n\n const lidRotate = interpolate(actionProgress, [0, 0.4, 1], [0, -14, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n });\n const lidLift = interpolate(actionProgress, [0, 0.4, 1], [0, -1, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n });\n\n const scale = 0.85 + 0.15 * scaleIn;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `scale(${scale})`,\n }}\n >\n <path\n d={BODY_PATH}\n strokeDasharray={body.strokeDasharray}\n strokeDashoffset={body.strokeDashoffset}\n />\n <path\n d={INNER1_PATH}\n strokeDasharray={inner1.strokeDasharray}\n strokeDashoffset={inner1.strokeDashoffset}\n />\n <path\n d={INNER2_PATH}\n strokeDasharray={inner2.strokeDasharray}\n strokeDashoffset={inner2.strokeDashoffset}\n />\n <g transform={`translate(0 ${lidLift}) rotate(${lidRotate} 3 6)`}>\n <path\n d={LID_PATH}\n strokeDasharray={lid.strokeDasharray}\n strokeDashoffset={lid.strokeDashoffset}\n />\n <path\n d={HANDLE_PATH}\n strokeDasharray={handle.strokeDasharray}\n strokeDashoffset={handle.strokeDashoffset}\n />\n </g>\n </svg>\n );\n}\n\nfunction TrashIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d={INNER1_PATH} />\n <path d={INNER2_PATH} />\n <path d={BODY_PATH} />\n <path d={LID_PATH} />\n <path d={HANDLE_PATH} />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype TrashIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof TrashIconBase>;\n\nconst TrashIconInner = forwardRef<\n HTMLDivElement,\n TrashIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<TrashIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <TrashIconBase\n {...(componentProps as unknown as ComponentProps<typeof TrashIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const TrashIcon = Interactive.withSchema({\n Component: TrashIconInner,\n componentName: \"<TrashIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-trending-down.json b/registry-artifacts/elements/icon-trending-down.jsonindex f2cf4044..50e4fdc9 100644--- a/registry-artifacts/elements/icon-trending-down.json+++ b/registry-artifacts/elements/icon-trending-down.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Trending Down","durationInFrames": 75,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-trending-down","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst TREND_PATH = \"M2 7 8.5 13.5 13.5 8.5 22 17\";\nconst ARROW_PATH = \"M16 17H22V11\";\n\nconst LOW_X = 22;\nconst LOW_Y = 17;\n\nconst TIMINGS = {\n drawDurationInFrames: 18,\n actionDelayInFrames: 2,\n actionDurationInFrames: 20,\n loop: false,\n} as const;\n\nfunction TrendingDownIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress, actionFrame } =\n useIconAnimation({ animation, loop, speed }, TIMINGS);\n\n const linearDraw = 1 - (1 - drawProgress) ** (1 / 3);\n const acting = animation !== \"draw\" && actionFrame >= 0;\n\n const trendDraw = interpolate(linearDraw, [0, 0.8], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.in(Easing.quad),\n });\n const arrowDraw = interpolate(linearDraw, [0.65, 1], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n\n const pop = acting\n ? interpolate(actionProgress, [0.1, 0.45, 1], [1, 1.15, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n })\n : 1;\n const drop = acting\n ? interpolate(actionProgress, [0.1, 0.45, 1], [0, 1, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n })\n : 0;\n\n const trend = drawnPathProps(TREND_PATH, acting ? 1 : trendDraw);\n const arrow = drawnPathProps(ARROW_PATH, acting ? 1 : arrowDraw);\n\n const scale = 0.85 + 0.15 * scaleIn;\n const popTransform = `translate(${LOW_X * (1 - pop)} ${LOW_Y * (1 - pop) + drop}) scale(${pop})`;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `scale(${scale})`,\n }}\n >\n <path\n d={TREND_PATH}\n strokeDasharray={trend.strokeDasharray}\n strokeDashoffset={trend.strokeDashoffset}\n />\n <g transform={popTransform}>\n <path\n d={ARROW_PATH}\n strokeDasharray={arrow.strokeDasharray}\n strokeDashoffset={arrow.strokeDashoffset}\n />\n </g>\n </svg>\n );\n}\n\nfunction TrendingDownIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d=\"M16 17h6v-6\" />\n <path d=\"m22 17-8.5-8.5-5 5L2 7\" />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype TrendingDownIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof TrendingDownIconBase>;\n\nconst TrendingDownIconInner = forwardRef<\n HTMLDivElement,\n TrendingDownIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<TrendingDownIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <TrendingDownIconBase\n {...(componentProps as unknown as ComponentProps<typeof TrendingDownIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const TrendingDownIcon = Interactive.withSchema({\n Component: TrendingDownIconInner,\n componentName: \"<TrendingDownIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-trending-up.json b/registry-artifacts/elements/icon-trending-up.jsonindex 01d8bd58..022a7082 100644--- a/registry-artifacts/elements/icon-trending-up.json+++ b/registry-artifacts/elements/icon-trending-up.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Trending Up","durationInFrames": 75,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-trending-up","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst TREND_PATH = \"M2 17 8.5 10.5 13.5 15.5 22 7\";\nconst ARROW_PATH = \"M16 7H22V13\";\n\nconst PEAK_X = 22;\nconst PEAK_Y = 7;\n\nconst TIMINGS = {\n drawDurationInFrames: 18,\n actionDelayInFrames: 2,\n actionDurationInFrames: 20,\n loop: false,\n} as const;\n\nfunction TrendingUpIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress, actionFrame } =\n useIconAnimation({ animation, loop, speed }, TIMINGS);\n\n const linearDraw = 1 - (1 - drawProgress) ** (1 / 3);\n const acting = animation !== \"draw\" && actionFrame >= 0;\n\n const trendDraw = interpolate(linearDraw, [0, 0.8], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.in(Easing.quad),\n });\n const arrowDraw = interpolate(linearDraw, [0.65, 1], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n\n const pop = acting\n ? interpolate(actionProgress, [0.1, 0.45, 1], [1, 1.25, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n })\n : 1;\n\n const trend = drawnPathProps(TREND_PATH, acting ? 1 : trendDraw);\n const arrow = drawnPathProps(ARROW_PATH, acting ? 1 : arrowDraw);\n\n const scale = 0.85 + 0.15 * scaleIn;\n const popTransform = `translate(${PEAK_X * (1 - pop)} ${PEAK_Y * (1 - pop)}) scale(${pop})`;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `scale(${scale})`,\n }}\n >\n <path\n d={TREND_PATH}\n strokeDasharray={trend.strokeDasharray}\n strokeDashoffset={trend.strokeDashoffset}\n />\n <g transform={popTransform}>\n <path\n d={ARROW_PATH}\n strokeDasharray={arrow.strokeDasharray}\n strokeDashoffset={arrow.strokeDashoffset}\n />\n </g>\n </svg>\n );\n}\n\nfunction TrendingUpIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d=\"M16 7h6v6\" />\n <path d=\"m22 7-8.5 8.5-5-5L2 17\" />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype TrendingUpIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof TrendingUpIconBase>;\n\nconst TrendingUpIconInner = forwardRef<\n HTMLDivElement,\n TrendingUpIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<TrendingUpIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <TrendingUpIconBase\n {...(componentProps as unknown as ComponentProps<typeof TrendingUpIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const TrendingUpIcon = Interactive.withSchema({\n Component: TrendingUpIconInner,\n componentName: \"<TrendingUpIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-trophy.json b/registry-artifacts/elements/icon-trophy.jsonindex 74537564..ca1c93e3 100644--- a/registry-artifacts/elements/icon-trophy.json+++ b/registry-artifacts/elements/icon-trophy.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Trophy","durationInFrames": 85,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-trophy","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst CUP_PATH = \"M6 9a6 6 0 0 0 12 0V3a1 1 0 0 0-1-1H7a1 1 0 0 0-1 1z\";\nconst LEG_LEFT_PATH = \"M10 14.66v1.626a2 2 0 0 1-.976 1.696A5 5 0 0 0 7 21.978\";\nconst LEG_RIGHT_PATH =\n \"M14 14.66v1.626a2 2 0 0 0 .976 1.696A5 5 0 0 1 17 21.978\";\nconst BASE_PATH = \"M4 22h16\";\nconst HANDLE_LEFT_PATH = \"M6 9H4.5a1 1 0 0 1 0-5H6\";\nconst HANDLE_RIGHT_PATH = \"M18 9h1.5a1 1 0 0 0 0-5H18\";\n\nconst CENTER = 12;\n\nconst TIMINGS = {\n drawDurationInFrames: 18,\n actionDelayInFrames: 2,\n actionDurationInFrames: 24,\n loop: false,\n} as const;\n\nfunction TrophyIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress, actionFrame } =\n useIconAnimation({ animation, loop, speed }, TIMINGS);\n\n const linearDraw = 1 - (1 - drawProgress) ** (1 / 3);\n const acting = animation !== \"draw\" && actionFrame >= 0;\n\n const cupDraw = interpolate(linearDraw, [0, 0.78], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n const legDraw = interpolate(linearDraw, [0.56, 1], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n\n const hop = acting\n ? interpolate(actionProgress, [0, 0.4, 1], [0, -3, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n })\n : 0;\n const pop = acting\n ? interpolate(actionProgress, [0, 0.4, 0.75, 1], [1, 1.08, 1, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n })\n : 1;\n const handleDraw = acting\n ? interpolate(actionProgress, [0.1, 0.6], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n })\n : 0;\n\n const cup = drawnPathProps(CUP_PATH, acting ? 1 : cupDraw);\n const legLeft = drawnPathProps(LEG_LEFT_PATH, acting ? 1 : legDraw);\n const legRight = drawnPathProps(LEG_RIGHT_PATH, acting ? 1 : legDraw);\n const base = drawnPathProps(BASE_PATH, acting ? 1 : legDraw);\n const handleLeft = drawnPathProps(HANDLE_LEFT_PATH, handleDraw);\n const handleRight = drawnPathProps(HANDLE_RIGHT_PATH, handleDraw);\n\n const scale = 0.85 + 0.15 * scaleIn;\n const hoistTransform = `translate(${CENTER * (1 - pop)} ${CENTER * (1 - pop) + hop}) scale(${pop})`;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `scale(${scale})`,\n }}\n >\n <g transform={hoistTransform}>\n <path\n d={HANDLE_LEFT_PATH}\n strokeDasharray={handleLeft.strokeDasharray}\n strokeDashoffset={handleLeft.strokeDashoffset}\n />\n <path\n d={HANDLE_RIGHT_PATH}\n strokeDasharray={handleRight.strokeDasharray}\n strokeDashoffset={handleRight.strokeDashoffset}\n />\n <path\n d={CUP_PATH}\n strokeDasharray={cup.strokeDasharray}\n strokeDashoffset={cup.strokeDashoffset}\n />\n <path\n d={LEG_LEFT_PATH}\n strokeDasharray={legLeft.strokeDasharray}\n strokeDashoffset={legLeft.strokeDashoffset}\n />\n <path\n d={LEG_RIGHT_PATH}\n strokeDasharray={legRight.strokeDasharray}\n strokeDashoffset={legRight.strokeDashoffset}\n />\n <path\n d={BASE_PATH}\n strokeDasharray={base.strokeDasharray}\n strokeDashoffset={base.strokeDashoffset}\n />\n </g>\n </svg>\n );\n}\n\nfunction TrophyIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d=\"M10 14.66v1.626a2 2 0 0 1-.976 1.696A5 5 0 0 0 7 21.978\" />\n <path d=\"M14 14.66v1.626a2 2 0 0 0 .976 1.696A5 5 0 0 1 17 21.978\" />\n <path d=\"M18 9h1.5a1 1 0 0 0 0-5H18\" />\n <path d=\"M4 22h16\" />\n <path d=\"M6 9a6 6 0 0 0 12 0V3a1 1 0 0 0-1-1H7a1 1 0 0 0-1 1z\" />\n <path d=\"M6 9H4.5a1 1 0 0 1 0-5H6\" />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype TrophyIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof TrophyIconBase>;\n\nconst TrophyIconInner = forwardRef<\n HTMLDivElement,\n TrophyIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<TrophyIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <TrophyIconBase\n {...(componentProps as unknown as ComponentProps<typeof TrophyIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const TrophyIcon = Interactive.withSchema({\n Component: TrophyIconInner,\n componentName: \"<TrophyIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-upload.json b/registry-artifacts/elements/icon-upload.jsonindex aa7ddab9..6bf746a1 100644--- a/registry-artifacts/elements/icon-upload.json+++ b/registry-artifacts/elements/icon-upload.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Upload","durationInFrames": 70,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-upload","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst TRAY_DRAW = \"M3 15v4a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-4\";\nconst TRAY_STATIC = \"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4\";\nconst SHAFT_DRAW = \"M12 15V3\";\nconst SHAFT_STATIC = \"M12 3v12\";\nconst HEAD_PATH = \"M17 8 12 3 7 8\";\n\nconst TIMINGS = {\n drawDurationInFrames: 14,\n actionDelayInFrames: 2,\n actionDurationInFrames: 18,\n loop: false,\n} as const;\n\nfunction UploadIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress } = useIconAnimation(\n { animation, loop, speed },\n TIMINGS,\n );\n\n const linearDraw = 1 - (1 - drawProgress) ** (1 / 3);\n\n const trayProgress = interpolate(linearDraw, [0, 0.714], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n });\n const arrowProgress = interpolate(linearDraw, [0.429, 1], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n const arrowOpacity = interpolate(linearDraw, [0.429, 0.6], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n });\n\n const tray = drawnPathProps(TRAY_DRAW, trayProgress);\n const shaft = drawnPathProps(SHAFT_DRAW, arrowProgress);\n const head = drawnPathProps(HEAD_PATH, arrowProgress);\n\n const launchY = interpolate(actionProgress, [0, 0.4, 0.7, 1], [0, -5, 1, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n });\n const traySquash = interpolate(\n actionProgress,\n [0, 0.2, 0.4, 1],\n [1, 0.96, 1, 1],\n { extrapolateLeft: \"clamp\", extrapolateRight: \"clamp\" },\n );\n\n const scale = 0.85 + 0.15 * scaleIn;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `scale(${scale})`,\n }}\n >\n <g\n transform={`translate(12 21) scale(1 ${traySquash}) translate(-12 -21)`}\n >\n <path\n d={TRAY_DRAW}\n strokeDasharray={tray.strokeDasharray}\n strokeDashoffset={tray.strokeDashoffset}\n />\n </g>\n <g opacity={arrowOpacity} transform={`translate(0 ${launchY})`}>\n <path\n d={SHAFT_DRAW}\n strokeDasharray={shaft.strokeDasharray}\n strokeDashoffset={shaft.strokeDashoffset}\n />\n <path\n d={HEAD_PATH}\n strokeDasharray={head.strokeDasharray}\n strokeDashoffset={head.strokeDashoffset}\n />\n </g>\n </svg>\n );\n}\n\nfunction UploadIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d={SHAFT_STATIC} />\n <path d={HEAD_PATH} />\n <path d={TRAY_STATIC} />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype UploadIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof UploadIconBase>;\n\nconst UploadIconInner = forwardRef<\n HTMLDivElement,\n UploadIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<UploadIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <UploadIconBase\n {...(componentProps as unknown as ComponentProps<typeof UploadIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const UploadIcon = Interactive.withSchema({\n Component: UploadIconInner,\n componentName: \"<UploadIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-user-plus.json b/registry-artifacts/elements/icon-user-plus.jsonindex 9d911eed..9350e979 100644--- a/registry-artifacts/elements/icon-user-plus.json+++ b/registry-artifacts/elements/icon-user-plus.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "User Plus","durationInFrames": 75,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-user-plus","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst HEAD_PATH =\n \"M9 3 A4 4 0 0 1 13 7 A4 4 0 0 1 9 11 A4 4 0 0 1 5 7 A4 4 0 0 1 9 3\";\nconst SHOULDERS_PATH = \"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2\";\nconst PLUS_H_PATH = \"M22 11 16 11\";\nconst PLUS_V_PATH = \"M19 8 19 14\";\n\nconst TIMINGS = {\n drawDurationInFrames: 14,\n actionDelayInFrames: 2,\n actionDurationInFrames: 26,\n loop: false,\n} as const;\n\nfunction UserPlusIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress, actionFrame } =\n useIconAnimation({ animation, loop, speed }, TIMINGS);\n\n const linearDraw = 1 - (1 - drawProgress) ** (1 / 3);\n const acting = animation !== \"draw\" && actionFrame >= 0;\n\n const headDraw = interpolate(linearDraw, [0, 0.71], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n const shouldersDraw = interpolate(linearDraw, [0.43, 1], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n\n const hProgress = acting\n ? interpolate(actionProgress, [0.08, 0.31], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n })\n : 0;\n const vProgress = acting\n ? interpolate(actionProgress, [0.19, 0.42], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n })\n : 0;\n const plusPop = acting\n ? interpolate(actionProgress, [0.42, 0.65, 1], [1, 1.3, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n })\n : 1;\n\n const head = drawnPathProps(HEAD_PATH, headDraw);\n const shoulders = drawnPathProps(SHOULDERS_PATH, shouldersDraw);\n const plusH = drawnPathProps(PLUS_H_PATH, hProgress);\n const plusV = drawnPathProps(PLUS_V_PATH, vProgress);\n\n const scale = 0.85 + 0.15 * scaleIn;\n const plusTransform = `translate(${19 * (1 - plusPop)} ${11 * (1 - plusPop)}) scale(${plusPop})`;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `scale(${scale})`,\n }}\n >\n <path\n d={HEAD_PATH}\n strokeDasharray={head.strokeDasharray}\n strokeDashoffset={head.strokeDashoffset}\n />\n <path\n d={SHOULDERS_PATH}\n strokeDasharray={shoulders.strokeDasharray}\n strokeDashoffset={shoulders.strokeDashoffset}\n />\n <g transform={plusTransform}>\n <path\n d={PLUS_H_PATH}\n strokeDasharray={plusH.strokeDasharray}\n strokeDashoffset={plusH.strokeDashoffset}\n />\n <path\n d={PLUS_V_PATH}\n strokeDasharray={plusV.strokeDasharray}\n strokeDashoffset={plusV.strokeDashoffset}\n />\n </g>\n </svg>\n );\n}\n\nfunction UserPlusIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d={SHOULDERS_PATH} />\n <circle cx=\"9\" cy=\"7\" r=\"4\" />\n <line x1=\"19\" x2=\"19\" y1=\"8\" y2=\"14\" />\n <line x1=\"22\" x2=\"16\" y1=\"11\" y2=\"11\" />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype UserPlusIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof UserPlusIconBase>;\n\nconst UserPlusIconInner = forwardRef<\n HTMLDivElement,\n UserPlusIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<UserPlusIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <UserPlusIconBase\n {...(componentProps as unknown as ComponentProps<typeof UserPlusIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const UserPlusIcon = Interactive.withSchema({\n Component: UserPlusIconInner,\n componentName: \"<UserPlusIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-user.json b/registry-artifacts/elements/icon-user.jsonindex 514dc1ea..7df97172 100644--- a/registry-artifacts/elements/icon-user.json+++ b/registry-artifacts/elements/icon-user.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "User","durationInFrames": 70,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-user","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst HEAD_PATH =\n \"M12 3 A4 4 0 0 1 16 7 A4 4 0 0 1 12 11 A4 4 0 0 1 8 7 A4 4 0 0 1 12 3\";\nconst SHOULDERS_PATH = \"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2\";\n\nconst TIMINGS = {\n drawDurationInFrames: 14,\n actionDelayInFrames: 2,\n actionDurationInFrames: 22,\n loop: false,\n} as const;\n\nfunction UserIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress, actionFrame } =\n useIconAnimation({ animation, loop, speed }, TIMINGS);\n\n const linearDraw = 1 - (1 - drawProgress) ** (1 / 3);\n const acting = animation !== \"draw\" && actionFrame >= 0;\n\n const headDraw = interpolate(linearDraw, [0, 0.71], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n const shouldersDraw = interpolate(linearDraw, [0.43, 1], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n\n const headDip = acting\n ? interpolate(actionProgress, [0, 0.45, 1], [0, 1, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n })\n : 0;\n const shoulderRise = acting\n ? interpolate(actionProgress, [0, 0.45, 1], [0, -1, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n })\n : 0;\n\n const head = drawnPathProps(HEAD_PATH, headDraw);\n const shoulders = drawnPathProps(SHOULDERS_PATH, shouldersDraw);\n\n const scale = 0.85 + 0.15 * scaleIn;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `scale(${scale})`,\n }}\n >\n <g transform={`translate(0 ${headDip})`}>\n <path\n d={HEAD_PATH}\n strokeDasharray={head.strokeDasharray}\n strokeDashoffset={head.strokeDashoffset}\n />\n </g>\n <g transform={`translate(0 ${shoulderRise})`}>\n <path\n d={SHOULDERS_PATH}\n strokeDasharray={shoulders.strokeDasharray}\n strokeDashoffset={shoulders.strokeDashoffset}\n />\n </g>\n </svg>\n );\n}\n\nfunction UserIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d={SHOULDERS_PATH} />\n <circle cx=\"12\" cy=\"7\" r=\"4\" />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype UserIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof UserIconBase>;\n\nconst UserIconInner = forwardRef<\n HTMLDivElement,\n UserIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<UserIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <UserIconBase\n {...(componentProps as unknown as ComponentProps<typeof UserIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const UserIcon = Interactive.withSchema({\n Component: UserIconInner,\n componentName: \"<UserIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-users.json b/registry-artifacts/elements/icon-users.jsonindex 81392835..915099e1 100644--- a/registry-artifacts/elements/icon-users.json+++ b/registry-artifacts/elements/icon-users.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Users","durationInFrames": 80,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-users","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst HEAD_PATH =\n \"M9 3 A4 4 0 0 1 13 7 A4 4 0 0 1 9 11 A4 4 0 0 1 5 7 A4 4 0 0 1 9 3\";\nconst SHOULDERS_PATH = \"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2\";\nconst BACK_HEAD_PATH = \"M16 3.128a4 4 0 0 1 0 7.744\";\nconst BACK_SHOULDERS_PATH = \"M22 21v-2a4 4 0 0 0-3-3.87\";\n\nconst TIMINGS = {\n drawDurationInFrames: 14,\n actionDelayInFrames: 2,\n actionDurationInFrames: 24,\n loop: false,\n} as const;\n\nfunction UsersIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress, actionFrame } =\n useIconAnimation({ animation, loop, speed }, TIMINGS);\n\n const linearDraw = 1 - (1 - drawProgress) ** (1 / 3);\n const acting = animation !== \"draw\" && actionFrame >= 0;\n\n const headDraw = interpolate(linearDraw, [0, 0.71], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n const shouldersDraw = interpolate(linearDraw, [0.43, 1], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n\n const pop = acting\n ? interpolate(actionProgress, [0, 0.25, 0.42], [1, 1.08, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n })\n : 1;\n const backOpacity = acting\n ? interpolate(actionProgress, [0.33, 0.9], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n })\n : 0;\n const backSlide = acting\n ? interpolate(actionProgress, [0.33, 1], [-2, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n })\n : -2;\n\n const head = drawnPathProps(HEAD_PATH, headDraw);\n const shoulders = drawnPathProps(SHOULDERS_PATH, shouldersDraw);\n\n const scale = 0.85 + 0.15 * scaleIn;\n const frontTransform = `translate(${9 * (1 - pop)} ${12 * (1 - pop)}) scale(${pop})`;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `scale(${scale})`,\n }}\n >\n <g transform={`translate(${backSlide} 0)`} opacity={backOpacity}>\n <path d={BACK_HEAD_PATH} />\n <path d={BACK_SHOULDERS_PATH} />\n </g>\n <g transform={frontTransform}>\n <path\n d={HEAD_PATH}\n strokeDasharray={head.strokeDasharray}\n strokeDashoffset={head.strokeDashoffset}\n />\n <path\n d={SHOULDERS_PATH}\n strokeDasharray={shoulders.strokeDasharray}\n strokeDashoffset={shoulders.strokeDashoffset}\n />\n </g>\n </svg>\n );\n}\n\nfunction UsersIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d={SHOULDERS_PATH} />\n <path d={BACK_HEAD_PATH} />\n <path d={BACK_SHOULDERS_PATH} />\n <circle cx=\"9\" cy=\"7\" r=\"4\" />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype UsersIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof UsersIconBase>;\n\nconst UsersIconInner = forwardRef<\n HTMLDivElement,\n UsersIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<UsersIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <UsersIconBase\n {...(componentProps as unknown as ComponentProps<typeof UsersIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const UsersIcon = Interactive.withSchema({\n Component: UsersIconInner,\n componentName: \"<UsersIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-video.json b/registry-artifacts/elements/icon-video.jsonindex 8837bb19..d7a9d836 100644--- a/registry-artifacts/elements/icon-video.json+++ b/registry-artifacts/elements/icon-video.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Video","durationInFrames": 70,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-video","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst BODY_PATH =\n \"M4 6H14A2 2 0 0 1 16 8V16A2 2 0 0 1 14 18H4A2 2 0 0 1 2 16V8A2 2 0 0 1 4 6Z\";\nconst LENS_PATH =\n \"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5\";\n\nconst TIMINGS = {\n drawDurationInFrames: 16,\n actionDelayInFrames: 2,\n actionDurationInFrames: 20,\n loop: false,\n} as const;\n\nfunction VideoIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress, actionFrame } =\n useIconAnimation({ animation, loop, speed }, TIMINGS);\n\n const linearDraw = 1 - (1 - drawProgress) ** (1 / 3);\n\n const bodyDraw = interpolate(linearDraw, [0, 0.75], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n const lensDraw = interpolate(linearDraw, [0.5, 1], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n\n const acting = animation !== \"draw\" && actionFrame >= 0;\n\n const pan = acting\n ? interpolate(actionProgress, [0, 0.5, 0.75, 1], [0, 8, -1, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n })\n : 0;\n\n const body = drawnPathProps(BODY_PATH, bodyDraw);\n const lens = drawnPathProps(LENS_PATH, lensDraw);\n\n const scale = 0.85 + 0.15 * scaleIn;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `scale(${scale})`,\n }}\n >\n <path\n d={BODY_PATH}\n strokeDasharray={body.strokeDasharray}\n strokeDashoffset={body.strokeDashoffset}\n />\n <g transform={`rotate(${pan} 16 11.75)`}>\n <path\n d={LENS_PATH}\n strokeDasharray={lens.strokeDasharray}\n strokeDashoffset={lens.strokeDashoffset}\n />\n </g>\n </svg>\n );\n}\n\nfunction VideoIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d={LENS_PATH} />\n <rect x=\"2\" y=\"6\" width=\"14\" height=\"12\" rx=\"2\" />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype VideoIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof VideoIconBase>;\n\nconst VideoIconInner = forwardRef<\n HTMLDivElement,\n VideoIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<VideoIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <VideoIconBase\n {...(componentProps as unknown as ComponentProps<typeof VideoIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const VideoIcon = Interactive.withSchema({\n Component: VideoIconInner,\n componentName: \"<VideoIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-volume-2.json b/registry-artifacts/elements/icon-volume-2.jsonindex 0b237b25..0c90b75e 100644--- a/registry-artifacts/elements/icon-volume-2.json+++ b/registry-artifacts/elements/icon-volume-2.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Volume 2","durationInFrames": 70,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-volume-2","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst SPEAKER_PATH =\n \"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z\";\nconst INNER_PATH = \"M16 9a5 5 0 0 1 0 6\";\nconst OUTER_PATH = \"M19.364 18.364a9 9 0 0 0 0-12.728\";\n\nconst TIMINGS = {\n drawDurationInFrames: 20,\n actionDelayInFrames: 2,\n actionDurationInFrames: 18,\n loop: false,\n} as const;\n\nfunction Volume2IconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress, actionFrame } =\n useIconAnimation({ animation, loop, speed }, TIMINGS);\n\n const linearDraw = 1 - (1 - drawProgress) ** (1 / 3);\n\n const bodyDraw = interpolate(linearDraw, [0, 0.6], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n const innerDraw = interpolate(linearDraw, [0.4, 0.8], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n const outerDraw = interpolate(linearDraw, [0.6, 1], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n\n const acting = animation !== \"draw\" && actionFrame >= 0;\n\n const innerProgress = acting ? 1 : innerDraw;\n const outerProgress = acting ? 1 : outerDraw;\n\n const innerShift = acting\n ? interpolate(actionProgress, [0, 0.35, 0.7], [0, 2, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n })\n : 0;\n const innerGrow = acting\n ? interpolate(actionProgress, [0, 0.35, 0.7], [1, 1.08, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n })\n : 1;\n const outerShift = acting\n ? interpolate(actionProgress, [0.12, 0.47, 0.82], [0, 2, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n })\n : 0;\n const outerGrow = acting\n ? interpolate(actionProgress, [0.12, 0.47, 0.82], [1, 1.08, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n })\n : 1;\n\n const body = drawnPathProps(SPEAKER_PATH, bodyDraw);\n const inner = drawnPathProps(INNER_PATH, innerProgress);\n const outer = drawnPathProps(OUTER_PATH, outerProgress);\n\n const innerTransform = `translate(${11 * (1 - innerGrow) + innerShift} ${12 * (1 - innerGrow)}) scale(${innerGrow})`;\n const outerTransform = `translate(${11 * (1 - outerGrow) + outerShift} ${12 * (1 - outerGrow)}) scale(${outerGrow})`;\n\n const scale = 0.85 + 0.15 * scaleIn;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `scale(${scale})`,\n }}\n >\n <path\n d={SPEAKER_PATH}\n strokeDasharray={body.strokeDasharray}\n strokeDashoffset={body.strokeDashoffset}\n />\n <g transform={innerTransform}>\n <path\n d={INNER_PATH}\n strokeDasharray={inner.strokeDasharray}\n strokeDashoffset={inner.strokeDashoffset}\n />\n </g>\n <g transform={outerTransform}>\n <path\n d={OUTER_PATH}\n strokeDasharray={outer.strokeDasharray}\n strokeDashoffset={outer.strokeDashoffset}\n />\n </g>\n </svg>\n );\n}\n\nfunction Volume2IconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d={SPEAKER_PATH} />\n <path d={INNER_PATH} />\n <path d={OUTER_PATH} />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype Volume2IconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof Volume2IconBase>;\n\nconst Volume2IconInner = forwardRef<\n HTMLDivElement,\n Volume2IconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<Volume2Icon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <Volume2IconBase\n {...(componentProps as unknown as ComponentProps<typeof Volume2IconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const Volume2Icon = Interactive.withSchema({\n Component: Volume2IconInner,\n componentName: \"<Volume2Icon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-volume-x.json b/registry-artifacts/elements/icon-volume-x.jsonindex 2f28aa80..d796e899 100644--- a/registry-artifacts/elements/icon-volume-x.json+++ b/registry-artifacts/elements/icon-volume-x.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Volume X","durationInFrames": 70,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-volume-x","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst SPEAKER_PATH =\n \"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z\";\nconst X1_PATH = \"M22 9 16 15\";\nconst X2_PATH = \"M16 9 22 15\";\n\nconst TIMINGS = {\n drawDurationInFrames: 14,\n actionDelayInFrames: 2,\n actionDurationInFrames: 22,\n loop: false,\n} as const;\n\nfunction VolumeXIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress, actionFrame } =\n useIconAnimation({ animation, loop, speed }, TIMINGS);\n\n const acting = animation !== \"draw\" && actionFrame >= 0;\n\n const x1Progress = acting\n ? interpolate(actionProgress, [0.09, 0.32], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n })\n : 0;\n const x2Progress = acting\n ? interpolate(actionProgress, [0.23, 0.45], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n })\n : 0;\n\n const shake = acting\n ? interpolate(\n actionProgress,\n [0.45, 0.55, 0.65, 0.75, 0.85, 1],\n [0, 2, -1.5, 1, -0.5, 0],\n {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n },\n )\n : 0;\n\n const body = drawnPathProps(SPEAKER_PATH, drawProgress);\n const x1 = drawnPathProps(X1_PATH, x1Progress);\n const x2 = drawnPathProps(X2_PATH, x2Progress);\n\n const scale = 0.85 + 0.15 * scaleIn;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `translateX(${shake}px) scale(${scale})`,\n }}\n >\n <path\n d={SPEAKER_PATH}\n strokeDasharray={body.strokeDasharray}\n strokeDashoffset={body.strokeDashoffset}\n />\n <path\n d={X1_PATH}\n strokeDasharray={x1.strokeDasharray}\n strokeDashoffset={x1.strokeDashoffset}\n />\n <path\n d={X2_PATH}\n strokeDasharray={x2.strokeDasharray}\n strokeDashoffset={x2.strokeDashoffset}\n />\n </svg>\n );\n}\n\nfunction VolumeXIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d={SPEAKER_PATH} />\n <line x1=\"22\" x2=\"16\" y1=\"9\" y2=\"15\" />\n <line x1=\"16\" x2=\"22\" y1=\"9\" y2=\"15\" />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype VolumeXIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof VolumeXIconBase>;\n\nconst VolumeXIconInner = forwardRef<\n HTMLDivElement,\n VolumeXIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<VolumeXIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <VolumeXIconBase\n {...(componentProps as unknown as ComponentProps<typeof VolumeXIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const VolumeXIcon = Interactive.withSchema({\n Component: VolumeXIconInner,\n componentName: \"<VolumeXIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-wallet.json b/registry-artifacts/elements/icon-wallet.jsonindex f2f8a7c7..8b4dddfc 100644--- a/registry-artifacts/elements/icon-wallet.json+++ b/registry-artifacts/elements/icon-wallet.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Wallet","durationInFrames": 70,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-wallet","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst FLAP_PATH =\n \"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1\";\nconst BODY_PATH = \"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4\";\n\nconst CENTER = 12;\n\nconst TIMINGS = {\n drawDurationInFrames: 16,\n actionDelayInFrames: 2,\n actionDurationInFrames: 20,\n loop: false,\n} as const;\n\nfunction WalletIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress, actionFrame } =\n useIconAnimation({ animation, loop, speed }, TIMINGS);\n\n const linearDraw = 1 - (1 - drawProgress) ** (1 / 3);\n const acting = animation !== \"draw\" && actionFrame >= 0;\n\n const bodyDraw = interpolate(linearDraw, [0, 0.7], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n const flapDraw = interpolate(linearDraw, [0.5, 1], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n\n const fatten = acting\n ? interpolate(actionProgress, [0.1, 0.5, 1], [1, 1.05, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n })\n : 1;\n\n const flap = drawnPathProps(FLAP_PATH, acting ? 1 : flapDraw);\n const body = drawnPathProps(BODY_PATH, acting ? 1 : bodyDraw);\n\n const scale = 0.85 + 0.15 * scaleIn;\n const fattenTransform = `translate(${CENTER * (1 - fatten)} 0) scale(${fatten} 1)`;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `scale(${scale})`,\n }}\n >\n <g transform={fattenTransform}>\n <path\n d={BODY_PATH}\n strokeDasharray={body.strokeDasharray}\n strokeDashoffset={body.strokeDashoffset}\n />\n <path\n d={FLAP_PATH}\n strokeDasharray={flap.strokeDasharray}\n strokeDashoffset={flap.strokeDashoffset}\n />\n </g>\n </svg>\n );\n}\n\nfunction WalletIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d={FLAP_PATH} />\n <path d={BODY_PATH} />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype WalletIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof WalletIconBase>;\n\nconst WalletIconInner = forwardRef<\n HTMLDivElement,\n WalletIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<WalletIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <WalletIconBase\n {...(componentProps as unknown as ComponentProps<typeof WalletIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const WalletIcon = Interactive.withSchema({\n Component: WalletIconInner,\n componentName: \"<WalletIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-x-circle.json b/registry-artifacts/elements/icon-x-circle.jsonindex 924c6ddd..f1a17b70 100644--- a/registry-artifacts/elements/icon-x-circle.json+++ b/registry-artifacts/elements/icon-x-circle.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "X Circle","durationInFrames": 70,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-x-circle","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst RING_PATH = \"M12 2a10 10 0 1 0 0 20 10 10 0 1 0 0-20Z\";\nconst SLASH1_PATH = \"M15 9 9 15\";\nconst SLASH2_PATH = \"M9 9 15 15\";\n\nconst TIMINGS = {\n drawDurationInFrames: 14,\n actionDelayInFrames: 2,\n actionDurationInFrames: 20,\n loop: false,\n} as const;\n\nfunction XCircleIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress, actionFrame } =\n useIconAnimation({ animation, loop, speed }, TIMINGS);\n\n const acting = animation !== \"draw\" && actionFrame >= 0;\n\n const slash1Draw = interpolate(actionProgress, [0.1, 0.35], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n const slash2Draw = interpolate(actionProgress, [0.25, 0.5], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n const shake = acting\n ? interpolate(\n actionProgress,\n [0.5, 0.62, 0.74, 0.86, 1],\n [0, 2, -2, 1, 0],\n {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n },\n )\n : 0;\n\n const slash1Progress = animation === \"draw\" ? 1 : acting ? slash1Draw : 0;\n const slash2Progress = animation === \"draw\" ? 1 : acting ? slash2Draw : 0;\n\n const ring = drawnPathProps(RING_PATH, drawProgress);\n const slash1 = drawnPathProps(SLASH1_PATH, slash1Progress);\n const slash2 = drawnPathProps(SLASH2_PATH, slash2Progress);\n\n const scale = 0.85 + 0.15 * scaleIn;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `translateX(${shake}px) scale(${scale})`,\n }}\n >\n <path\n d={RING_PATH}\n strokeDasharray={ring.strokeDasharray}\n strokeDashoffset={ring.strokeDashoffset}\n />\n <path\n d={SLASH1_PATH}\n strokeDasharray={slash1.strokeDasharray}\n strokeDashoffset={slash1.strokeDashoffset}\n />\n <path\n d={SLASH2_PATH}\n strokeDasharray={slash2.strokeDasharray}\n strokeDashoffset={slash2.strokeDashoffset}\n />\n </svg>\n );\n}\n\nfunction XCircleIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <circle cx=\"12\" cy=\"12\" r=\"10\" />\n <path d={SLASH1_PATH} />\n <path d={SLASH2_PATH} />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype XCircleIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof XCircleIconBase>;\n\nconst XCircleIconInner = forwardRef<\n HTMLDivElement,\n XCircleIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<XCircleIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <XCircleIconBase\n {...(componentProps as unknown as ComponentProps<typeof XCircleIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const XCircleIcon = Interactive.withSchema({\n Component: XCircleIconInner,\n componentName: \"<XCircleIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-x.json b/registry-artifacts/elements/icon-x.jsonindex 1cbb21be..080aa606 100644--- a/registry-artifacts/elements/icon-x.json+++ b/registry-artifacts/elements/icon-x.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "X","durationInFrames": 60,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-x","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst FIRST_PATH = \"M18 6 6 18\";\nconst SECOND_PATH = \"M6 6 18 18\";\n\nconst TIMINGS = {\n drawDurationInFrames: 14,\n actionDelayInFrames: 2,\n actionDurationInFrames: 18,\n loop: false,\n} as const;\n\nfunction XIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress } = useIconAnimation(\n { animation, loop, speed },\n TIMINGS,\n );\n\n const linearDraw = 1 - (1 - drawProgress) ** (1 / 3);\n\n const firstProgress = interpolate(linearDraw, [0, 0.57], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n });\n const secondProgress = interpolate(linearDraw, [0.29, 0.86], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n });\n\n const first = drawnPathProps(FIRST_PATH, firstProgress);\n const second = drawnPathProps(SECOND_PATH, secondProgress);\n\n const rotate = interpolate(\n actionProgress,\n [0, 0.25, 0.5, 0.75, 1],\n [0, -8, 6, -3, 0],\n { extrapolateLeft: \"clamp\", extrapolateRight: \"clamp\" },\n );\n const scale = 0.85 + 0.15 * scaleIn;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `rotate(${rotate}deg) scale(${scale})`,\n }}\n >\n <path\n d={FIRST_PATH}\n strokeDasharray={first.strokeDasharray}\n strokeDashoffset={first.strokeDashoffset}\n />\n <path\n d={SECOND_PATH}\n strokeDasharray={second.strokeDasharray}\n strokeDashoffset={second.strokeDashoffset}\n />\n </svg>\n );\n}\n\nfunction XIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d={FIRST_PATH} />\n <path d={SECOND_PATH} />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype XIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof XIconBase>;\n\nconst XIconInner = forwardRef<\n HTMLDivElement,\n XIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<XIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <XIconBase\n {...(componentProps as unknown as ComponentProps<typeof XIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const XIcon = Interactive.withSchema({\n Component: XIconInner,\n componentName: \"<XIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/icon-zap.json b/registry-artifacts/elements/icon-zap.jsonindex d5683539..3ac576c4 100644--- a/registry-artifacts/elements/icon-zap.json+++ b/registry-artifacts/elements/icon-zap.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/paths",@@ -14,6 +15,7 @@},"displayName": "Zap","durationInFrames": 60,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "icon-zap","sourceCode": "import { Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { evolvePath } from \"@remotion/paths\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\ninterface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\ninterface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nfunction iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart = animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nfunction useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nfunction staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nfunction drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n\nconst ZAP_PATH =\n \"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z\";\n\nconst TIMINGS = {\n drawDurationInFrames: 10,\n actionDelayInFrames: 2,\n actionDurationInFrames: 14,\n loop: false,\n} as const;\n\nfunction ZapIconBase({\n animation = \"both\",\n loop,\n speed,\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: IconAnimationProps) {\n const { drawProgress, scaleIn, actionProgress } = useIconAnimation(\n { animation, loop, speed },\n TIMINGS,\n );\n\n const linearDraw = 1 - (1 - drawProgress) ** (1 / 3);\n\n const boltProgress = interpolate(linearDraw, [0, 0.8], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n });\n\n const bolt = drawnPathProps(ZAP_PATH, boltProgress);\n\n const flash = interpolate(\n actionProgress,\n [0, 0.15, 0.3, 0.45, 0.6, 1],\n [1, 0.3, 1, 0.3, 1, 1],\n { extrapolateLeft: \"clamp\", extrapolateRight: \"clamp\" },\n );\n const pop = interpolate(actionProgress, [0, 0.3, 0.6, 1], [1, 1.1, 1, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.inOut(Easing.quad),\n });\n const strikeEase = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.out(Easing.quad),\n } as const;\n const strikeX = interpolate(\n actionProgress,\n [0, 0.15, 0.4, 1],\n [0, 1.5, -3, 0],\n strikeEase,\n );\n const strikeY = interpolate(\n actionProgress,\n [0, 0.15, 0.4, 1],\n [0, -2, 4, 0],\n strikeEase,\n );\n const skew = interpolate(\n actionProgress,\n [0, 0.15, 0.4, 0.7, 1],\n [0, -4, 9, -2, 0],\n strikeEase,\n );\n const scale = (0.85 + 0.15 * scaleIn) * pop;\n\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{\n overflow: \"visible\",\n transformOrigin: \"center\",\n transform: `scale(${scale})`,\n }}\n >\n <g\n opacity={flash}\n transform={`translate(${strikeX} ${strikeY}) translate(12 12) skewX(${skew}) translate(-12 -12)`}\n >\n <path\n d={ZAP_PATH}\n strokeDasharray={bolt.strokeDasharray}\n strokeDashoffset={bolt.strokeDashoffset}\n />\n </g>\n </svg>\n );\n}\n\nfunction ZapIconStatic({\n size = 48,\n color = \"currentColor\",\n strokeWidth = 2,\n className,\n}: {\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}) {\n return (\n <svg\n className={className}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d={ZAP_PATH} />\n </svg>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n animation: {\n type: \"enum\",\n default: \"both\",\n variants: {\n draw: {},\n action: {},\n both: {},\n },\n description: \"Animation\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n size: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 4,\n default: 48,\n description: \"Size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n strokeWidth: {\n type: \"number\",\n min: 1,\n max: 3,\n step: 0.25,\n default: 2,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 48,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"animation\",\"loop\",\"size\",\"color\",\"strokeWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n animation: \"both\",\n loop: false,\n size: 48,\n color: \"#171717\",\n strokeWidth: 2,\n speed: 1,\n};\n\ntype ZapIconElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof ZapIconBase>;\n\nconst ZapIconInner = forwardRef<\n HTMLDivElement,\n ZapIconElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 48, height = 48, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<ZapIcon>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <ZapIconBase\n {...(componentProps as unknown as ComponentProps<typeof ZapIconBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const ZapIcon = Interactive.withSchema({\n Component: ZapIconInner,\n componentName: \"<ZapIcon>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/infinite-bento-pan.json b/registry-artifacts/elements/infinite-bento-pan.jsonindex 867e2879..196225a8 100644--- a/registry-artifacts/elements/infinite-bento-pan.json+++ b/registry-artifacts/elements/infinite-bento-pan.json@@ -2,10 +2,12 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [],"dimensions": null,"displayName": "Infinite Bento Pan","durationInFrames": 300,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "infinite-bento-pan","sourceCode": "import { Interactive, Sequence, interpolate, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface InfiniteBentoPanProps {\n panSpeed?: number;\n accentColor?: string;\n speed?: number;\n className?: string;\n}\n\nconst FONT_FAMILY =\n \"var(--font-geist-sans), -apple-system, BlinkMacSystemFont, sans-serif\";\n\nconst SUPER_W = 3500;\nconst SUPER_H = 2500;\n\ntype CardKind =\n | \"chart\"\n | \"counter\"\n | \"gradient\"\n | \"code\"\n | \"logo\"\n | \"stat\"\n | \"bars\";\n\ninterface CardDef {\n x: number;\n y: number;\n w: number;\n h: number;\n kind: CardKind;\n hue: number;\n label?: string;\n}\n\nconst CARDS: CardDef[] = [\n { x: 80, y: 80, w: 480, h: 280, kind: \"chart\", hue: 220, label: \"Revenue\" },\n { x: 600, y: 80, w: 280, h: 280, kind: \"counter\", hue: 280, label: \"MRR\" },\n { x: 920, y: 80, w: 360, h: 180, kind: \"gradient\", hue: 200 },\n { x: 1320, y: 80, w: 480, h: 280, kind: \"code\", hue: 0, label: \"deploy.ts\" },\n { x: 1840, y: 80, w: 280, h: 280, kind: \"logo\", hue: 320 },\n { x: 2160, y: 80, w: 380, h: 180, kind: \"stat\", hue: 160, label: \"Uptime\" },\n { x: 2580, y: 80, w: 360, h: 280, kind: \"bars\", hue: 40, label: \"Visits\" },\n { x: 920, y: 300, w: 360, h: 200, kind: \"counter\", hue: 180, label: \"Users\" },\n {\n x: 2160,\n y: 300,\n w: 380,\n h: 200,\n kind: \"chart\",\n hue: 100,\n label: \"Latency\",\n },\n { x: 80, y: 400, w: 280, h: 280, kind: \"gradient\", hue: 340 },\n { x: 400, y: 400, w: 480, h: 280, kind: \"code\", hue: 0, label: \"api.ts\" },\n { x: 1320, y: 420, w: 280, h: 280, kind: \"stat\", hue: 60, label: \"P95\" },\n { x: 1640, y: 420, w: 380, h: 280, kind: \"bars\", hue: 260, label: \"Builds\" },\n { x: 2580, y: 420, w: 360, h: 280, kind: \"logo\", hue: 200 },\n { x: 80, y: 720, w: 480, h: 240, kind: \"chart\", hue: 290, label: \"Errors\" },\n { x: 600, y: 720, w: 280, h: 240, kind: \"stat\", hue: 20, label: \"RPS\" },\n { x: 920, y: 740, w: 380, h: 220, kind: \"gradient\", hue: 240 },\n {\n x: 1320,\n y: 740,\n w: 360,\n h: 220,\n kind: \"counter\",\n hue: 140,\n label: \"Active\",\n },\n { x: 1720, y: 740, w: 480, h: 240, kind: \"code\", hue: 0, label: \"worker.ts\" },\n { x: 2240, y: 740, w: 360, h: 240, kind: \"bars\", hue: 320, label: \"Queue\" },\n { x: 80, y: 1000, w: 360, h: 220, kind: \"logo\", hue: 180 },\n { x: 460, y: 1000, w: 380, h: 220, kind: \"stat\", hue: 80, label: \"Cache\" },\n { x: 880, y: 1000, w: 480, h: 220, kind: \"chart\", hue: 200, label: \"CPU\" },\n {\n x: 1400,\n y: 1000,\n w: 280,\n h: 220,\n kind: \"counter\",\n hue: 360,\n label: \"Jobs\",\n },\n { x: 1720, y: 1020, w: 360, h: 220, kind: \"gradient\", hue: 120 },\n { x: 2120, y: 1020, w: 380, h: 220, kind: \"code\", hue: 0, label: \"db.sql\" },\n { x: 2540, y: 1020, w: 400, h: 220, kind: \"bars\", hue: 280, label: \"Tasks\" },\n { x: 80, y: 1280, w: 480, h: 260, kind: \"code\", hue: 0, label: \"edge.ts\" },\n { x: 600, y: 1280, w: 360, h: 260, kind: \"chart\", hue: 240, label: \"TTFB\" },\n { x: 1000, y: 1280, w: 280, h: 260, kind: \"logo\", hue: 60 },\n { x: 1320, y: 1280, w: 380, h: 260, kind: \"stat\", hue: 200, label: \"Hits\" },\n {\n x: 1740,\n y: 1280,\n w: 360,\n h: 260,\n kind: \"counter\",\n hue: 300,\n label: \"Bytes\",\n },\n { x: 2140, y: 1280, w: 380, h: 260, kind: \"gradient\", hue: 160 },\n { x: 2560, y: 1280, w: 380, h: 260, kind: \"bars\", hue: 0, label: \"Errors\" },\n { x: 80, y: 1600, w: 380, h: 220, kind: \"stat\", hue: 280, label: \"Saved\" },\n { x: 500, y: 1600, w: 480, h: 220, kind: \"chart\", hue: 40, label: \"Net Out\" },\n { x: 1020, y: 1600, w: 360, h: 220, kind: \"code\", hue: 0, label: \"auth.ts\" },\n { x: 1420, y: 1600, w: 280, h: 220, kind: \"logo\", hue: 220 },\n {\n x: 1740,\n y: 1620,\n w: 380,\n h: 220,\n kind: \"counter\",\n hue: 100,\n label: \"Hooks\",\n },\n { x: 2160, y: 1620, w: 360, h: 220, kind: \"bars\", hue: 340, label: \"Runs\" },\n { x: 2560, y: 1620, w: 380, h: 220, kind: \"gradient\", hue: 200 },\n { x: 80, y: 1880, w: 480, h: 240, kind: \"bars\", hue: 180, label: \"Edges\" },\n { x: 600, y: 1880, w: 380, h: 240, kind: \"gradient\", hue: 320 },\n { x: 1020, y: 1880, w: 360, h: 240, kind: \"logo\", hue: 80 },\n {\n x: 1420,\n y: 1880,\n w: 480,\n h: 240,\n kind: \"chart\",\n hue: 260,\n label: \"Tokens\",\n },\n {\n x: 1940,\n y: 1880,\n w: 280,\n h: 240,\n kind: \"counter\",\n hue: 20,\n label: \"Calls\",\n },\n { x: 2260, y: 1880, w: 380, h: 240, kind: \"stat\", hue: 140, label: \"Score\" },\n { x: 2680, y: 1880, w: 260, h: 240, kind: \"code\", hue: 0, label: \"ws.ts\" },\n];\n\nfunction noise(i: number, frame: number) {\n return Math.sin(frame / 30 + i) * 0.5 + 0.5;\n}\n\nfunction ChartCard({ accent, t }: { accent: string; t: number }) {\n const points: string[] = [];\n for (let i = 0; i < 12; i++) {\n const x = (i / 11) * 100;\n const y =\n 50 - (Math.sin(i * 0.7 + t) * 18 + Math.cos(i * 0.4 + t * 0.6) * 8);\n points.push(`${x},${y}`);\n }\n return (\n <svg\n viewBox=\"0 0 100 60\"\n preserveAspectRatio=\"none\"\n style={{ width: \"100%\", height: \"100%\" }}\n >\n <polyline\n points={points.join(\" \")}\n fill=\"none\"\n stroke={accent}\n strokeWidth={1.4}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n <polyline\n points={`${points.join(\" \")} 100,60 0,60`}\n fill={`${accent}22`}\n stroke=\"none\"\n />\n </svg>\n );\n}\n\nfunction BarsCard({ accent, t }: { accent: string; t: number }) {\n return (\n <div\n style={{\n display: \"flex\",\n alignItems: \"flex-end\",\n gap: 6,\n height: \"100%\",\n width: \"100%\",\n }}\n >\n {Array.from({ length: 10 }).map((_, i) => {\n const h = 25 + (Math.sin(i * 0.8 + t) * 0.5 + 0.5) * 70;\n return (\n <div\n key={i}\n style={{\n flex: 1,\n height: `${h}%`,\n background: `linear-gradient(180deg, ${accent} 0%, ${accent}55 100%)`,\n borderRadius: 4,\n }}\n />\n );\n })}\n </div>\n );\n}\n\nfunction CodeCard() {\n const lines = [\n { indent: 0, w: 60, c: \"#7dd3fc\" },\n { indent: 1, w: 80, c: \"rgba(255,255,255,0.8)\" },\n { indent: 1, w: 50, c: \"#f9a8d4\" },\n { indent: 2, w: 70, c: \"rgba(255,255,255,0.8)\" },\n { indent: 2, w: 40, c: \"#fde047\" },\n { indent: 1, w: 30, c: \"rgba(255,255,255,0.6)\" },\n { indent: 0, w: 20, c: \"rgba(255,255,255,0.6)\" },\n ];\n return (\n <div\n style={{\n display: \"flex\",\n flexDirection: \"column\",\n gap: 8,\n fontFamily: \"ui-monospace, SFMono-Regular, Menlo, monospace\",\n }}\n >\n {lines.map((l, i) => (\n <div\n key={i}\n style={{\n marginLeft: l.indent * 14,\n width: `${l.w}%`,\n height: 8,\n borderRadius: 3,\n background: l.c,\n opacity: 0.7,\n }}\n />\n ))}\n </div>\n );\n}\n\nfunction LogoCard({ accent, hue }: { accent: string; hue: number }) {\n return (\n <div\n style={{\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n style={{\n width: 80,\n height: 80,\n borderRadius: 20,\n background: `linear-gradient(135deg, ${accent} 0%, hsl(${hue},70%,55%) 100%)`,\n boxShadow: `0 10px 30px ${accent}44`,\n }}\n />\n </div>\n );\n}\n\nfunction GradientCard({ hue }: { hue: number }) {\n return (\n <div\n style={{\n width: \"100%\",\n height: \"100%\",\n background: `radial-gradient(circle at 30% 30%, hsl(${hue},80%,60%) 0%, hsl(${(hue + 60) % 360},70%,40%) 50%, #0a0a0a 100%)`,\n }}\n />\n );\n}\n\nfunction Card({\n card,\n accent,\n index,\n frame,\n}: {\n card: CardDef;\n accent: string;\n index: number;\n frame: number;\n}) {\n const t = noise(index, frame) * 6.28;\n const baseStyle: React.CSSProperties = {\n position: \"absolute\",\n left: card.x,\n top: card.y,\n width: card.w,\n height: card.h,\n borderRadius: 18,\n background: \"linear-gradient(180deg, #131313 0%, #0a0a0a 100%)\",\n border: \"1px solid rgba(255,255,255,0.07)\",\n overflow: \"hidden\",\n padding: 18,\n color: \"white\",\n display: \"flex\",\n flexDirection: \"column\",\n };\n\n const labelEl = card.label ? (\n <div\n style={{\n fontSize: 12,\n fontWeight: 600,\n color: \"rgba(255,255,255,0.55)\",\n letterSpacing: \"0.04em\",\n textTransform: \"uppercase\",\n marginBottom: 8,\n }}\n >\n {card.label}\n </div>\n ) : null;\n\n if (card.kind === \"chart\") {\n return (\n <div style={baseStyle}>\n {labelEl}\n <div style={{ flex: 1 }}>\n <ChartCard accent={accent} t={t} />\n </div>\n </div>\n );\n }\n if (card.kind === \"bars\") {\n return (\n <div style={baseStyle}>\n {labelEl}\n <div style={{ flex: 1 }}>\n <BarsCard accent={accent} t={t} />\n </div>\n </div>\n );\n }\n if (card.kind === \"counter\") {\n const v = Math.floor(1200 + noise(index, frame) * 800);\n return (\n <div style={baseStyle}>\n {labelEl}\n <div\n style={{\n flex: 1,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"flex-start\",\n fontSize: 56,\n fontWeight: 700,\n letterSpacing: \"-0.04em\",\n color: \"white\",\n }}\n >\n {v.toLocaleString()}\n </div>\n <div style={{ fontSize: 12, color: accent, fontWeight: 600 }}>\n +{(noise(index + 1, frame) * 12).toFixed(1)}%\n </div>\n </div>\n );\n }\n if (card.kind === \"stat\") {\n const v = (95 + noise(index, frame) * 5).toFixed(2);\n return (\n <div style={baseStyle}>\n {labelEl}\n <div\n style={{\n flex: 1,\n display: \"flex\",\n alignItems: \"center\",\n fontSize: 48,\n fontWeight: 700,\n letterSpacing: \"-0.03em\",\n }}\n >\n {v}\n <span\n style={{\n fontSize: 20,\n color: \"rgba(255,255,255,0.5)\",\n marginLeft: 4,\n }}\n >\n %\n </span>\n </div>\n </div>\n );\n }\n if (card.kind === \"code\") {\n return (\n <div style={baseStyle}>\n {labelEl}\n <div style={{ flex: 1, display: \"flex\", alignItems: \"center\" }}>\n <div style={{ width: \"100%\" }}>\n <CodeCard />\n </div>\n </div>\n </div>\n );\n }\n if (card.kind === \"logo\") {\n return (\n <div style={{ ...baseStyle, padding: 0 }}>\n <LogoCard accent={accent} hue={card.hue} />\n </div>\n );\n }\n // gradient\n return (\n <div style={{ ...baseStyle, padding: 0 }}>\n <GradientCard hue={card.hue} />\n </div>\n );\n}\n\nfunction InfiniteBentoPanBase({\n panSpeed = 1,\n accentColor = \"#7c3aed\",\n speed = 1,\n className,\n}: InfiniteBentoPanProps) {\n const frame = useCurrentFrame() * speed;\n const { durationInFrames, width, height } = useVideoConfig();\n\n const maxX = SUPER_W - width;\n const maxY = SUPER_H - height;\n\n // diagonal pan: from top-left toward bottom-right\n const t = interpolate(frame, [0, durationInFrames], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n });\n\n const px = t * maxX * Math.min(1, panSpeed);\n const py = t * maxY * Math.min(1, panSpeed);\n\n return (\n <div\n className={className}\n style={{\n position: \"absolute\",\n inset: 0,\n background: \"transparent\",\n overflow: \"hidden\",\n fontFamily: FONT_FAMILY,\n }}\n >\n <div\n style={{\n position: \"absolute\",\n left: 0,\n top: 0,\n width: SUPER_W,\n height: SUPER_H,\n translate: `${-px}px ${-py}px`,\n willChange: \"transform\",\n }}\n >\n {CARDS.map((c, i) => (\n <Card key={i} card={c} accent={accentColor} index={i} frame={frame} />\n ))}\n </div>\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n background:\n \"radial-gradient(circle at center, transparent 30%, rgba(0,0,0,0.85) 80%, #000 100%)\",\n pointerEvents: \"none\",\n }}\n />\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n panSpeed: {\n type: \"number\",\n min: 0.25,\n max: 3,\n step: 0.25,\n default: 1,\n description: \"Pan speed\",\n hiddenFromList: false,\n },\n accentColor: {\n type: \"color\",\n default: \"#7c3aed\",\n description: \"Accent color\",\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"panSpeed\",\"accentColor\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n panSpeed: 1,\n accentColor: \"#7c3aed\",\n speed: 1,\n};\n\ntype InfiniteBentoPanElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof InfiniteBentoPanBase>;\n\nconst InfiniteBentoPanInner = forwardRef<\n HTMLDivElement,\n InfiniteBentoPanElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<InfiniteBentoPan>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <InfiniteBentoPanBase\n {...(componentProps as unknown as ComponentProps<typeof InfiniteBentoPanBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const InfiniteBentoPan = Interactive.withSchema({\n Component: InfiniteBentoPanInner,\n componentName: \"<InfiniteBentoPan>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/infinite-marquee.json b/registry-artifacts/elements/infinite-marquee.jsonindex 62ab99c4..10758865 100644--- a/registry-artifacts/elements/infinite-marquee.json+++ b/registry-artifacts/elements/infinite-marquee.json@@ -2,10 +2,12 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [],"dimensions": null,"displayName": "Infinite Marquee","durationInFrames": 180,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "infinite-marquee","sourceCode": "import { Interactive, Sequence, useCurrentFrame, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface InfiniteMarqueeProps {\n text?: string;\n fontSize?: number;\n color?: string;\n fontWeight?: number;\n pixelsPerFrame?: number;\n stroke?: boolean;\n strokeColor?: string;\n speed?: number;\n className?: string;\n}\n\nfunction InfiniteMarqueeBase({\n text = \"ship · build · animate · \",\n fontSize = 120,\n color = \"#171717\",\n fontWeight = 900,\n pixelsPerFrame = 4,\n stroke = false,\n strokeColor = \"#171717\",\n speed = 1,\n className,\n}: InfiniteMarqueeProps) {\n const frame = useCurrentFrame() * speed;\n\n const approxWidth = text.length * fontSize * 0.55;\n const offset = -((frame * pixelsPerFrame) % approxWidth);\n\n const spanStyle: React.CSSProperties = {\n fontSize,\n fontWeight,\n fontFamily:\n \"var(--font-geist-sans), -apple-system, BlinkMacSystemFont, sans-serif\",\n color: stroke ? \"transparent\" : color,\n WebkitTextStroke: stroke ? `2px ${strokeColor}` : undefined,\n paddingRight: \"0.4em\",\n letterSpacing: \"-0.03em\",\n };\n\n return (\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n className={className}\n style={{\n display: \"flex\",\n whiteSpace: \"nowrap\",\n translate: `${offset}px`,\n }}\n >\n <span style={spanStyle}>{text}</span>\n <span style={spanStyle}>{text}</span>\n <span style={spanStyle}>{text}</span>\n </div>\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n text: {\n type: \"text-content\",\n default: \"ship · build · animate · \",\n description: \"Text\",\n },\n fontSize: {\n type: \"number\",\n min: 12,\n max: 240,\n step: 1,\n default: 120,\n description: \"Font size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n fontWeight: {\n type: \"enum\",\n default: \"700\",\n variants: {\n \"400\": {},\n \"500\": {},\n \"600\": {},\n \"700\": {},\n },\n description: \"Font weight\",\n },\n pixelsPerFrame: {\n type: \"number\",\n min: 1,\n max: 30,\n step: 1,\n default: 4,\n description: \"Pixels / frame\",\n hiddenFromList: false,\n },\n stroke: {\n type: \"boolean\",\n default: false,\n description: \"Stroke\",\n },\n strokeColor: {\n type: \"color\",\n default: \"#171717\",\n description: \"Stroke color\",\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"text\",\"fontSize\",\"color\",\"fontWeight\",\"pixelsPerFrame\",\"stroke\",\"strokeColor\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n text: \"ship · build · animate · \",\n fontSize: 120,\n color: \"#171717\",\n fontWeight: \"700\",\n pixelsPerFrame: 4,\n stroke: false,\n strokeColor: \"#171717\",\n speed: 1,\n};\n\ntype InfiniteMarqueeElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof InfiniteMarqueeBase>;\n\nconst InfiniteMarqueeInner = forwardRef<\n HTMLDivElement,\n InfiniteMarqueeElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<InfiniteMarquee>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <InfiniteMarqueeBase\n {...(componentProps as unknown as ComponentProps<typeof InfiniteMarqueeBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const InfiniteMarquee = Interactive.withSchema({\n Component: InfiniteMarqueeInner,\n componentName: \"<InfiniteMarquee>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/inline-highlight.json b/registry-artifacts/elements/inline-highlight.jsonindex 1afd3b7d..ab2b2672 100644--- a/registry-artifacts/elements/inline-highlight.json+++ b/registry-artifacts/elements/inline-highlight.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [],"dimensions": {"width": 640,@@ -9,6 +10,7 @@},"displayName": "Inline Highlight","durationInFrames": 90,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "inline-highlight","sourceCode": "import { Interactive, Sequence, interpolate, interpolateColors, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface InlineHighlightProps {\n before: string;\n highlight: string;\n after?: string;\n baseColor?: string;\n highlightColor?: string;\n fontSize?: number;\n fontWeight?: number;\n speed?: number;\n className?: string;\n}\n\nfunction InlineHighlightBase({\n before,\n highlight,\n after = \"\",\n baseColor = \"#171717\",\n highlightColor = \"#ff5e3a\",\n fontSize = 48,\n fontWeight = 600,\n speed = 1,\n className,\n}: InlineHighlightProps) {\n const frame = useCurrentFrame() * speed;\n const { durationInFrames } = useVideoConfig();\n\n const progress = interpolate(\n frame,\n [durationInFrames * 0.2, durationInFrames * 0.7],\n [0, 1],\n { extrapolateLeft: \"clamp\", extrapolateRight: \"clamp\" },\n );\n\n const color = interpolateColors(\n progress,\n [0, 1],\n [baseColor, highlightColor],\n );\n\n return (\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n background: \"white\",\n }}\n >\n <span\n className={className}\n style={{\n fontSize,\n fontWeight,\n color: baseColor,\n letterSpacing: \"-0.03em\",\n fontFamily:\n \"var(--font-geist-sans), -apple-system, BlinkMacSystemFont, sans-serif\",\n }}\n >\n {before}\n <span style={{ color }}>{highlight}</span>\n {after}\n </span>\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n before: {\n type: \"text-content\",\n default: \"Ship faster with \",\n description: \"Before\",\n },\n highlight: {\n type: \"text-content\",\n default: \"remocn\",\n description: \"Highlight\",\n },\n after: {\n type: \"text-content\",\n default: \".\",\n description: \"After\",\n },\n baseColor: {\n type: \"color\",\n default: \"#171717\",\n description: \"Base color\",\n },\n highlightColor: {\n type: \"color\",\n default: \"#ff5e3a\",\n description: \"Highlight color\",\n },\n fontSize: {\n type: \"number\",\n min: 12,\n max: 160,\n step: 1,\n default: 72,\n description: \"Font size\",\n hiddenFromList: false,\n },\n fontWeight: {\n type: \"enum\",\n default: \"600\",\n variants: {\n \"400\": {},\n \"500\": {},\n \"600\": {},\n \"700\": {},\n },\n description: \"Font weight\",\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 640,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 100,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"before\",\"highlight\",\"after\",\"baseColor\",\"highlightColor\",\"fontSize\",\"fontWeight\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n before: \"Ship faster with \",\n highlight: \"remocn\",\n after: \".\",\n baseColor: \"#171717\",\n highlightColor: \"#ff5e3a\",\n fontSize: 72,\n fontWeight: \"600\",\n speed: 1,\n};\n\ntype InlineHighlightElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof InlineHighlightBase>;\n\nconst InlineHighlightInner = forwardRef<\n HTMLDivElement,\n InlineHighlightElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 640, height = 100, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<InlineHighlight>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <InlineHighlightBase\n {...(componentProps as unknown as ComponentProps<typeof InlineHighlightBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const InlineHighlight = Interactive.withSchema({\n Component: InlineHighlightInner,\n componentName: \"<InlineHighlight>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/inline-pill-takeover.json b/registry-artifacts/elements/inline-pill-takeover.jsonindex b3edf3e9..a97b4a4c 100644--- a/registry-artifacts/elements/inline-pill-takeover.json+++ b/registry-artifacts/elements/inline-pill-takeover.json@@ -2,10 +2,12 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [],"dimensions": null,"displayName": "Inline Pill Takeover","durationInFrames": 30,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "inline-pill-takeover","sourceCode": "import { Easing, Interactive, Sequence, interpolate, useCurrentFrame, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface InlinePillTakeoverProps {\n before: string;\n insert: string;\n after: string;\n fontSize?: number;\n color?: string;\n fontWeight?: number;\n pillWidth?: number;\n pillColor?: string;\n pillTextColor?: string;\n expandFrames?: number;\n pillRevealHeightScale?: number;\n pillGrowAt?: number;\n pillGrowFrames?: number;\n pillGrowWidthScale?: number;\n pillGrowHeightScale?: number;\n outerExitFrames?: number;\n takeoverAt?: number;\n takeoverScale?: number;\n blur?: number;\n speed?: number;\n className?: string;\n}\n\nconst PRE_CUT_FRAMES = 12;\nconst TAKEOVER_SETTLE_FRAMES = 6;\nconst PRE_CUT_CAMERA_SCALE = 1.25;\nconst CAMERA_CUT_ENTRY_PROGRESS = 0.86;\nconst expandEasing = Easing.out(Easing.quad);\nconst pillGrowEasing = Easing.inOut(Easing.quad);\nconst fadeEasing = Easing.in(Easing.cubic);\nconst preCutEasing = Easing.out(Easing.quad);\nconst takeoverSettleEasing = Easing.out(Easing.cubic);\n\nfunction InlinePillTakeoverBase({\n before,\n insert,\n after,\n fontSize = 52,\n color = \"#fff3df\",\n fontWeight = 400,\n pillWidth = 260,\n pillColor = \"#fffaf0\",\n pillTextColor = \"#1c1210\",\n expandFrames = 12,\n pillRevealHeightScale = 0.35,\n pillGrowAt = 12,\n pillGrowFrames = 24,\n pillGrowWidthScale = 1.08,\n pillGrowHeightScale = 1.16,\n outerExitFrames = 18,\n takeoverAt = 12,\n takeoverScale = 2.15,\n blur = 12,\n speed = 1,\n className,\n}: InlinePillTakeoverProps) {\n const frame = useCurrentFrame() * speed;\n const safeExpandFrames = Math.max(expandFrames, 0.001);\n const pillGrowEnd = pillGrowAt + Math.max(pillGrowFrames, 0.001);\n const outerExitEnd = Math.max(outerExitFrames, 2.001);\n const dashWidth = fontSize * 0.72;\n const pillHeight = fontSize * 1.22;\n const cutAt = takeoverAt + PRE_CUT_FRAMES;\n const cutEntryScale = takeoverScale * CAMERA_CUT_ENTRY_PROGRESS;\n\n const expand = interpolate(frame, [0, safeExpandFrames], [0, 1], {\n easing: expandEasing,\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n });\n const pillGrowProgress = interpolate(\n frame,\n [pillGrowAt, pillGrowEnd],\n [0, 1],\n {\n easing: pillGrowEasing,\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n },\n );\n const outerExit = interpolate(frame, [2, outerExitEnd], [0, 1], {\n easing: fadeEasing,\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n });\n const pillTextOpacity = frame >= 3 ? 1 : 0;\n const preCutCameraScale = interpolate(\n frame,\n [takeoverAt, cutAt - 1],\n [1, PRE_CUT_CAMERA_SCALE],\n {\n easing: preCutEasing,\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n },\n );\n const postCutCameraScale = interpolate(\n frame,\n [cutAt, cutAt + TAKEOVER_SETTLE_FRAMES],\n [cutEntryScale, takeoverScale],\n {\n easing: takeoverSettleEasing,\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n },\n );\n const cameraScale = frame < cutAt ? preCutCameraScale : postCutCameraScale;\n const revealedPillWidth = dashWidth + (pillWidth - dashWidth) * expand;\n const revealedPillHeight =\n pillHeight * (pillRevealHeightScale + (1 - pillRevealHeightScale) * expand);\n const pillWidthGrow = 1 + (pillGrowWidthScale - 1) * pillGrowProgress;\n const pillHeightGrow = 1 + (pillGrowHeightScale - 1) * pillGrowProgress;\n const animatedPillWidth = revealedPillWidth * pillWidthGrow;\n const animatedPillHeight = revealedPillHeight * pillHeightGrow;\n\n return (\n <div\n className={className}\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n overflow: \"hidden\",\n background: \"transparent\",\n }}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n transform: `scale(${cameraScale})`,\n transformOrigin: \"center\",\n }}\n >\n <div\n style={{\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n width: \"100%\",\n gap: `${fontSize * 0.16}px`,\n whiteSpace: \"nowrap\",\n fontFamily:\n \"var(--font-geist-sans, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif)\",\n fontSize,\n fontWeight,\n letterSpacing: \"-0.02em\",\n lineHeight: 1,\n }}\n >\n <span\n style={{\n flex: 1,\n textAlign: \"right\",\n color,\n opacity: 1 - outerExit,\n filter: outerExit > 0 ? `blur(${blur * outerExit}px)` : undefined,\n }}\n >\n {before}\n </span>\n\n <span\n style={{\n position: \"relative\",\n display: \"inline-block\",\n flexShrink: 0,\n width: animatedPillWidth,\n height: animatedPillHeight,\n overflow: \"hidden\",\n borderRadius: animatedPillHeight / 2,\n background: pillColor,\n color: pillTextColor,\n }}\n >\n <span\n style={{\n position: \"absolute\",\n top: \"50%\",\n left: \"50%\",\n translate: \"-50% -50%\",\n fontSize: fontSize * 0.84,\n opacity: pillTextOpacity,\n whiteSpace: \"nowrap\",\n }}\n >\n {insert}\n </span>\n </span>\n\n <span\n style={{\n flex: 1,\n textAlign: \"left\",\n color,\n opacity: 1 - outerExit,\n filter: outerExit > 0 ? `blur(${blur * outerExit}px)` : undefined,\n }}\n >\n {after}\n </span>\n </div>\n </div>\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n before: {\n type: \"text-content\",\n default: \"powering 20%\",\n description: \"Text before pill\",\n },\n insert: {\n type: \"text-content\",\n default: \"Start building\",\n description: \"Pill text\",\n },\n after: {\n type: \"text-content\",\n default: \"of the Internet.\",\n description: \"Text after pill\",\n },\n fontSize: {\n type: \"number\",\n min: 24,\n max: 120,\n step: 1,\n default: 52,\n description: \"Font size\",\n hiddenFromList: false,\n },\n pillWidth: {\n type: \"number\",\n min: 100,\n max: 600,\n step: 5,\n default: 260,\n description: \"Expanded pill width\",\n hiddenFromList: false,\n },\n expandFrames: {\n type: \"number\",\n min: 6,\n max: 45,\n step: 1,\n default: 12,\n description: \"Width reveal frames\",\n hiddenFromList: false,\n },\n pillRevealHeightScale: {\n type: \"number\",\n min: 0.05,\n max: 1,\n step: 0.05,\n default: 0.35,\n description: \"Initial reveal height scale\",\n hiddenFromList: false,\n },\n pillGrowAt: {\n type: \"number\",\n min: 6,\n max: 30,\n step: 1,\n default: 12,\n description: \"Pill growth start frame\",\n hiddenFromList: false,\n },\n pillGrowFrames: {\n type: \"number\",\n min: 6,\n max: 36,\n step: 1,\n default: 24,\n description: \"Pill growth frames\",\n hiddenFromList: false,\n },\n pillGrowWidthScale: {\n type: \"number\",\n min: 1,\n max: 1.3,\n step: 0.01,\n default: 1.08,\n description: \"Final pill width scale\",\n hiddenFromList: false,\n },\n pillGrowHeightScale: {\n type: \"number\",\n min: 1,\n max: 1.5,\n step: 0.01,\n default: 1.16,\n description: \"Final pill height scale\",\n hiddenFromList: false,\n },\n outerExitFrames: {\n type: \"number\",\n min: 6,\n max: 30,\n step: 1,\n default: 18,\n description: \"Outer text exit frames\",\n hiddenFromList: false,\n },\n takeoverAt: {\n type: \"number\",\n min: 12,\n max: 40,\n step: 1,\n default: 12,\n description: \"Camera move start frame\",\n hiddenFromList: false,\n },\n takeoverScale: {\n type: \"number\",\n min: 1,\n max: 4,\n step: 0.05,\n default: 2.15,\n description: \"Final takeover scale\",\n hiddenFromList: false,\n },\n blur: {\n type: \"number\",\n min: 0,\n max: 30,\n step: 1,\n default: 12,\n description: \"Outer text blur\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#fff3df\",\n description: \"Outer text color\",\n },\n pillColor: {\n type: \"color\",\n default: \"#fffaf0\",\n description: \"Pill color\",\n },\n pillTextColor: {\n type: \"color\",\n default: \"#1c1210\",\n description: \"Pill text color\",\n },\n fontWeight: {\n type: \"enum\",\n default: \"400\",\n variants: {\n \"400\": {},\n \"500\": {},\n \"600\": {},\n \"700\": {},\n },\n description: \"Font weight\",\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"before\",\"insert\",\"after\",\"fontSize\",\"pillWidth\",\"expandFrames\",\"pillRevealHeightScale\",\"pillGrowAt\",\"pillGrowFrames\",\"pillGrowWidthScale\",\"pillGrowHeightScale\",\"outerExitFrames\",\"takeoverAt\",\"takeoverScale\",\"blur\",\"color\",\"pillColor\",\"pillTextColor\",\"fontWeight\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n before: \"powering 20%\",\n insert: \"Start building\",\n after: \"of the Internet.\",\n fontSize: 52,\n pillWidth: 260,\n expandFrames: 12,\n pillRevealHeightScale: 0.35,\n pillGrowAt: 12,\n pillGrowFrames: 24,\n pillGrowWidthScale: 1.08,\n pillGrowHeightScale: 1.16,\n outerExitFrames: 18,\n takeoverAt: 12,\n takeoverScale: 2.15,\n blur: 12,\n color: \"#fff3df\",\n pillColor: \"#fffaf0\",\n pillTextColor: \"#1c1210\",\n fontWeight: \"400\",\n speed: 1,\n};\n\ntype InlinePillTakeoverElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof InlinePillTakeoverBase>;\n\nconst InlinePillTakeoverInner = forwardRef<\n HTMLDivElement,\n InlinePillTakeoverElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<InlinePillTakeover>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <InlinePillTakeoverBase\n {...(componentProps as unknown as ComponentProps<typeof InlinePillTakeoverBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const InlinePillTakeover = Interactive.withSchema({\n Component: InlinePillTakeoverInner,\n componentName: \"<InlinePillTakeover>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/inline-word-roll.json b/registry-artifacts/elements/inline-word-roll.jsonindex 99a3cae2..d12ea06f 100644--- a/registry-artifacts/elements/inline-word-roll.json+++ b/registry-artifacts/elements/inline-word-roll.json@@ -2,10 +2,12 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [],"dimensions": null,"displayName": "Inline Word Roll","durationInFrames": 75,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "inline-word-roll","sourceCode": "import { forwardRef, useImperativeHandle, useLayoutEffect, useRef, useState, type ComponentProps } from \"react\";\nimport { Easing, Interactive, Sequence, useCurrentFrame, useDelayRender, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\n\ninterface InlineWordRollProps {\n prefix?: string;\n /** Separate words or phrases with | or newlines. */\n text?: string;\n suffix?: string;\n fontSize?: number;\n fontFamily?: string;\n fontWeight?: number;\n color?: string;\n /** Initial interval between switches, in frames. */\n interval?: number;\n /** Each following interval is multiplied by this number; 1 keeps a steady pace. */\n acceleration?: number;\n transitionFrames?: number;\n}\n\nconst inlineWordRollDefaultText =\n \"leads | customers | subscribers | appointments | demos | quotes | registrants | trials | conversions\";\n\nconst parseInlineWords = (text: string) =>\n text\n .split(/[|\\n\\r]+/)\n .map((word) => word.trim())\n .filter(Boolean);\n\nconst finite = (value: number, fallback: number) =>\n Number.isFinite(value) ? value : fallback;\nconst clamp = (n: number) => Math.max(0, Math.min(1, n));\nconst ease = Easing.bezier(0.22, 0.75, 0.25, 1);\n\nfunction getInlineWordRollState(\n frame: number,\n count: number,\n interval = 12,\n acceleration = 0.9,\n transitionFrames = 6,\n) {\n const transition = Math.max(1, finite(transitionFrames, 6));\n const gap = Math.max(transition, finite(interval, 12));\n const rate = Math.min(1, Math.max(0.5, finite(acceleration, 0.9)));\n const f = Math.max(0, finite(frame, 0));\n let start = 0;\n for (let index = 1; index < count; index++) {\n start += Math.max(transition, gap * rate ** (index - 1));\n if (f < start) return { from: index - 1, to: index - 1, progress: 1 };\n if (f < start + transition)\n return {\n from: index - 1,\n to: index,\n progress: clamp((f - start) / transition),\n };\n }\n const last = Math.max(0, count - 1);\n return { from: last, to: last, progress: 1 };\n}\n\nfunction getInlineWordRollDuration({\n text = inlineWordRollDefaultText,\n interval = 12,\n acceleration = 0.9,\n transitionFrames = 6,\n}: Pick<\n InlineWordRollProps,\n \"text\" | \"interval\" | \"acceleration\" | \"transitionFrames\"\n> = {}) {\n const count = parseInlineWords(text).length;\n const transition = Math.max(1, finite(transitionFrames, 6));\n const gap = Math.max(transition, finite(interval, 12));\n const rate = Math.min(1, Math.max(0.5, finite(acceleration, 0.9)));\n let total = 0;\n for (let index = 0; index < count - 1; index++)\n total += Math.max(transition, gap * rate ** index);\n return count < 2 ? 0 : Math.ceil(total + transition);\n}\n\nfunction InlineWordRollBase({\n prefix = \"Looking for\",\n text = inlineWordRollDefaultText,\n suffix = \"?\",\n fontSize = 60,\n fontFamily = \"Arial, Helvetica, sans-serif\",\n fontWeight = 400,\n color = \"#f5f5f5\",\n interval = 12,\n acceleration = 0.9,\n transitionFrames = 6,\n}: InlineWordRollProps) {\n const frame = useCurrentFrame();\n const { width, height } = useVideoConfig();\n const { delayRender, continueRender, cancelRender } = useDelayRender();\n const words = parseInlineWords(text);\n const measurement = useRef<HTMLDivElement>(null);\n const pending = useRef<number | null>(null);\n const [metrics, setMetrics] = useState<{\n prefix: number;\n words: number[];\n } | null>(null);\n const size = Math.max(1, finite(fontSize, 60));\n const typography = {\n fontFamily,\n fontSize: size,\n fontWeight,\n letterSpacing: \"-0.035em\",\n lineHeight: 1.2,\n whiteSpace: \"pre\" as const,\n };\n\n useLayoutEffect(() => {\n let cancelled = false;\n const handle = delayRender(\"Measure Inline Word Roll font\");\n pending.current = handle;\n void document.fonts\n .load(\n `${fontWeight} ${size}px ${fontFamily}`,\n `${prefix} ${text}${suffix}`,\n )\n .then(() => {\n if (cancelled || !measurement.current) return;\n const children = Array.from(measurement.current.children);\n // Computed widths are in composition pixels. Bounding rectangles include\n // the Player's preview scale and would shrink our layout a second time.\n const measure = (node: Element) =>\n Number.parseFloat(getComputedStyle(node).width);\n setMetrics({\n prefix: measure(children[0]),\n words: children.slice(1).map(measure),\n });\n })\n .catch((error: unknown) => {\n if (!cancelled)\n cancelRender(\n error instanceof Error ? error : new Error(String(error)),\n );\n });\n return () => {\n cancelled = true;\n continueRender(handle);\n if (pending.current === handle) pending.current = null;\n };\n }, [\n prefix,\n text,\n suffix,\n size,\n fontFamily,\n fontWeight,\n delayRender,\n continueRender,\n cancelRender,\n ]);\n\n useLayoutEffect(() => {\n if (metrics && pending.current !== null) {\n continueRender(pending.current);\n pending.current = null;\n }\n }, [metrics, continueRender]);\n\n const state = getInlineWordRollState(\n frame,\n words.length,\n interval,\n acceleration,\n transitionFrames,\n );\n const moving = state.from !== state.to;\n const p = ease(state.progress);\n const gap = prefix ? size * 0.23 : 0;\n const prefixWidth = metrics?.prefix ?? 0;\n const fromWidth = metrics?.words[state.from] ?? 0;\n const toWidth = metrics?.words[state.to] ?? 0;\n const slotWidth = fromWidth + (toWidth - fromWidth) * p;\n const totalWidth = prefixWidth + gap + slotWidth;\n const widest = prefixWidth + gap + Math.max(0, ...(metrics?.words ?? []));\n const fit = Math.min(\n 1,\n (width * 0.84) / Math.max(1, widest),\n (height * 0.5) / (size * 1.2),\n );\n const rowHeight = size * 1.2;\n\n return (\n <div\n role=\"img\"\n aria-label={[prefix, words[state.to] ? `${words[state.to]}${suffix}` : \"\"]\n .filter(Boolean)\n .join(\" \")}\n style={{ position: \"absolute\", inset: 0, overflow: \"hidden\", color }}\n >\n <div\n ref={measurement}\n aria-hidden=\"true\"\n style={{\n ...typography,\n position: \"absolute\",\n visibility: \"hidden\",\n pointerEvents: \"none\",\n }}\n >\n <span style={{ display: \"inline-block\" }}>{prefix}</span>\n {words.map((word, index) => (\n <span key={`${index}:${word}`} style={{ display: \"inline-block\" }}>\n {word}\n {suffix}\n </span>\n ))}\n </div>\n <div\n aria-hidden=\"true\"\n style={{\n position: \"absolute\",\n left: \"50%\",\n top: \"50%\",\n scale: fit,\n visibility: metrics && words.length ? \"visible\" : \"hidden\",\n }}\n >\n <div\n style={{\n ...typography,\n position: \"absolute\",\n left: -totalWidth / 2,\n top: -rowHeight / 2,\n height: rowHeight,\n }}\n >\n <span style={{ position: \"absolute\", left: 0 }}>{prefix}</span>\n <div\n style={{\n position: \"absolute\",\n left: prefixWidth + gap,\n top: 0,\n width: Math.max(fromWidth, toWidth) + size * 0.12,\n height: rowHeight,\n overflow: \"hidden\",\n maskImage:\n \"linear-gradient(to bottom, transparent, black 12%, black 88%, transparent)\",\n }}\n >\n <span\n style={{\n position: \"absolute\",\n left: 0,\n top: 0,\n translate: `0 ${moving ? -p * rowHeight : 0}px`,\n opacity: moving ? 1 - clamp(p * 1.2) : 1,\n }}\n >\n {words[state.from]}\n {words.length ? suffix : \"\"}\n </span>\n {moving ? (\n <span\n style={{\n position: \"absolute\",\n left: 0,\n top: 0,\n translate: `0 ${(1 - p) * rowHeight}px`,\n opacity: clamp(p * 1.6),\n }}\n >\n {words[state.to]}\n {suffix}\n </span>\n ) : null}\n </div>\n </div>\n </div>\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n prefix: {\n type: \"text-content\",\n default: \"Looking for\",\n description: \"Fixed text\",\n },\n text: {\n type: \"text-content\",\n default: \"leads | customers | subscribers | appointments | demos | quotes | registrants | trials | conversions\",\n description: \"Words separated by |\",\n },\n suffix: {\n type: \"text-content\",\n default: \"?\",\n description: \"Word suffix\",\n },\n fontSize: {\n type: \"number\",\n default: 60,\n min: 16,\n max: 160,\n step: 1,\n description: \"Font size\",\n hiddenFromList: false,\n },\n interval: {\n type: \"number\",\n default: 12,\n min: 6,\n max: 60,\n step: 1,\n description: \"Initial frames per word\",\n hiddenFromList: false,\n },\n acceleration: {\n type: \"number\",\n default: 0.9,\n min: 0.5,\n max: 1,\n step: 0.01,\n description: \"Interval multiplier\",\n hiddenFromList: false,\n },\n transitionFrames: {\n type: \"number\",\n default: 6,\n min: 1,\n max: 20,\n step: 1,\n description: \"Roll duration\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#f5f5f5\",\n description: \"Color\",\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"prefix\",\"text\",\"suffix\",\"fontSize\",\"interval\",\"acceleration\",\"transitionFrames\",\"color\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n prefix: \"Looking for\",\n text: \"leads | customers | subscribers | appointments | demos | quotes | registrants | trials | conversions\",\n suffix: \"?\",\n fontSize: 60,\n interval: 12,\n acceleration: 0.9,\n transitionFrames: 6,\n color: \"#f5f5f5\",\n speed: 1,\n};\n\ntype InlineWordRollElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof InlineWordRollBase>;\n\nconst InlineWordRollInner = forwardRef<\n HTMLDivElement,\n InlineWordRollElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<InlineWordRoll>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <InlineWordRollBase\n {...(componentProps as unknown as ComponentProps<typeof InlineWordRollBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const InlineWordRoll = Interactive.withSchema({\n Component: InlineWordRollInner,\n componentName: \"<InlineWordRoll>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/keystroke.json b/registry-artifacts/elements/keystroke.jsonindex 10f7f321..9f39aacf 100644--- a/registry-artifacts/elements/keystroke.json+++ b/registry-artifacts/elements/keystroke.json@@ -2,10 +2,12 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [],"dimensions": null,"displayName": "Keystroke","durationInFrames": 166,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "keystroke","sourceCode": "import { forwardRef, useImperativeHandle, useMemo, useRef, type ComponentProps } from \"react\";\nimport { Easing, Interactive, Sequence, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\n\ntype KeystrokePlatform = \"mac\" | \"windows\";\ntype KeystrokeTheme = \"light\" | \"dark\";\ntype KeystrokeIcon =\n | \"command\"\n | \"option\"\n | \"shift\"\n | \"control\"\n | \"return\"\n | \"delete\"\n | \"escape\"\n | \"tab\"\n | \"space\"\n | \"capsLock\"\n | \"up\"\n | \"down\"\n | \"left\"\n | \"right\";\n\ninterface KeystrokeStep {\n at: number;\n keys: string;\n hold?: number;\n}\n\ninterface KeystrokeProps {\n steps?: readonly KeystrokeStep[];\n platform?: KeystrokePlatform;\n theme?: KeystrokeTheme;\n accent?: string;\n x?: number;\n y?: number;\n size?: number;\n linger?: number;\n speed?: number;\n className?: string;\n}\n\ninterface KeystrokeOptions extends Omit<KeystrokeProps, \"className\"> {\n width?: number;\n height?: number;\n fps?: number;\n}\n\ntype KeystrokeLegend =\n | { kind: \"icon\"; icon: KeystrokeIcon }\n | { kind: \"char\"; text: string }\n | { kind: \"word\"; text: string };\n\ninterface KeystrokeKey {\n name: string;\n label: string;\n legend: KeystrokeLegend;\n units: number;\n modifier: boolean;\n}\n\ntype KeystrokeChord = KeystrokeKey[];\n\ninterface KeystrokeKeyTiming {\n press: number;\n release: number;\n}\n\ninterface KeystrokeChordTiming {\n enter: number;\n fire: number;\n keys: KeystrokeKeyTiming[];\n}\n\ninterface KeystrokeLayout {\n caps: { chord: number; index: number; x: number; width: number }[];\n separators: { chord: number; x: number; width: number }[];\n widths: number[];\n}\n\ninterface KeystrokeGroup {\n index: number;\n step: number;\n keys: string;\n label: string;\n chords: KeystrokeChord[];\n timing: KeystrokeChordTiming[];\n layout: KeystrokeLayout;\n at: number;\n hold: number;\n enter: number;\n lastRelease: number;\n pushes: number[];\n exit: number;\n end: number;\n}\n\ninterface KeystrokePalette {\n cap: string;\n edge: string;\n wall: string;\n ink: string;\n separator: string;\n shadow: string;\n}\n\ntype Unset = \"steps\" | \"className\";\ntype Modifier = \"fn\" | \"ctrl\" | \"alt\" | \"shift\" | \"meta\";\ntype Named =\n | \"enter\"\n | \"escape\"\n | \"tab\"\n | \"space\"\n | \"backspace\"\n | \"delete\"\n | \"capsLock\"\n | \"up\"\n | \"down\"\n | \"left\"\n | \"right\"\n | \"home\"\n | \"end\"\n | \"pageUp\"\n | \"pageDown\";\ntype IconShape = { box: string; paths: readonly string[] };\ntype IconSpec = { label: string; icon: KeystrokeIcon; units: number };\ntype NamedSpec = IconSpec | { label: string; word: string; units: number };\ntype Draft = Omit<\n KeystrokeGroup,\n \"index\" | \"label\" | \"layout\" | \"pushes\" | \"exit\" | \"end\"\n>;\n\nconst keystrokeDefaults: Required<Omit<KeystrokeProps, Unset>> = {\n platform: \"mac\",\n theme: \"light\",\n accent: \"#0a84ff\",\n x: 0.5,\n y: 0.86,\n size: 64,\n linger: 30,\n speed: 1,\n};\n\nconst keystrokeDefaultSteps: readonly KeystrokeStep[] = [\n { at: 20, keys: \"mod+k\" },\n { at: 78, keys: \"g i\" },\n { at: 114, keys: \"shift+mod+p\" },\n];\n\nconst keystrokePalettes: Record<KeystrokeTheme, KeystrokePalette> = {\n light: {\n cap: \"#fcfcfb\",\n edge: \"#dfdfda\",\n wall: \"#cfcfca\",\n ink: \"#1d1d1f\",\n separator: \"#8e8e89\",\n shadow: \"rgba(20, 20, 16, 0.18)\",\n },\n dark: {\n cap: \"#38393e\",\n edge: \"#48494f\",\n wall: \"#1f2023\",\n ink: \"#f5f5f7\",\n separator: \"#9d9da4\",\n shadow: \"rgba(0, 0, 0, 0.5)\",\n },\n};\n\nconst PRESS = 3;\nconst PRESS_GAP = 3;\nconst RELEASE_GAP = 3;\nconst LEAD = 7;\nconst STAGGER = 1;\nconst BEAT = 2;\nconst HOLD = 8;\nconst RELEASE = 10;\nconst RELEASE_RISE = 3;\nconst RELEASE_TAPER = 6;\nconst RELEASE_DAMPING = 0.46;\nconst ENTER = 10;\nconst ENTER_RISE = 4;\nconst ENTER_TAPER = 7;\nconst ENTER_DAMPING = 0.65;\nconst FADE_IN = 4;\nconst SLIDE = 10;\nconst DIM = 6;\nconst DIM_OPACITY = 0.45;\nconst PUSH = 10;\nconst BRIEF = 18;\nconst EXIT = 8;\nconst TAIL = 14;\nconst MAX_FRAMES = 600;\nconst MIN_SIZE = 8;\nconst MAX_SIZE = 400;\nconst WALL = 0.16;\nconst TRAVEL = 0.12;\nconst RADIUS = 0.16;\nconst RISE = 0.42;\nconst KEY_GAP = 0.14;\nconst SEPARATOR = 0.95;\nconst CHAR_FONT = 0.4;\nconst WORD_FONT = 0.26;\nconst ICON_SIZE = 0.36;\nconst SEPARATOR_FONT = 0.25;\nconst WORD_CHAR = 0.6 * WORD_FONT;\nconst WORD_PAD = 0.24;\nconst WINDOWS_WORD = 1.25;\nconst SLOT_RISE = 1.09;\nconst SLOT_SCALE = 0.86;\nconst SLOT_OPACITY = 0.55;\nconst EXIT_DRIFT = 0.22;\nconst EXIT_SCALE = 0.04;\nconst SHADOW_Y = 0.07;\nconst SHADOW_Y_PRESSED = 0.02;\nconst SHADOW_BLUR = 0.11;\nconst SHADOW_BLUR_PRESSED = 0.03;\nconst GLIDE = Easing.bezier(0.33, 1, 0.68, 1);\nconst FONT_FAMILY =\n 'var(--font-geist-sans, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Inter, Roboto, Helvetica, Arial, sans-serif)';\n\nconst ICONS: Record<KeystrokeIcon, IconShape> = {\n command: {\n box: \"0 0 24 24\",\n paths: [\n \"M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3\",\n ],\n },\n option: { box: \"0 0 24 24\", paths: [\"M3 3h6l6 18h6\", \"M14 3h7\"] },\n shift: {\n box: \"0 0 24 24\",\n paths: [\n \"M9 19a1 1 0 0 0 1 1h4a1 1 0 0 0 1-1v-6a1 1 0 0 1 1-1h3.293a.707.707 0 0 0 .5-1.207l-7.086-7.086a1 1 0 0 0-1.414 0l-7.086 7.086a.707.707 0 0 0 .5 1.207H8a1 1 0 0 1 1 1z\",\n ],\n },\n control: { box: \"0 0 24 24\", paths: [\"m18 15-6-6-6 6\"] },\n return: {\n box: \"0 0 24 24\",\n paths: [\"M20 4v7a4 4 0 0 1-4 4H4\", \"m9 10-5 5 5 5\"],\n },\n delete: {\n box: \"0 0 24 24\",\n paths: [\n \"M10 5a2 2 0 0 0-1.344.519l-6.328 5.74a1 1 0 0 0 0 1.481l6.328 5.741A2 2 0 0 0 10 19h10a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2z\",\n \"m12 9 6 6\",\n \"m18 9-6 6\",\n ],\n },\n escape: {\n box: \"0 0 24 24\",\n paths: [\"M2 8V2h6\", \"m2 2 10 10\", \"M12 2A10 10 0 1 1 2 12\"],\n },\n tab: {\n box: \"0 0 24 24\",\n paths: [\"M17 12H3\", \"m11 18 6-6-6-6\", \"M21 5v14\"],\n },\n space: {\n box: \"0 6 24 24\",\n paths: [\"M22 17v1c0 .5-.5 1-1 1H3c-.5 0-1-.5-1-1v-1\"],\n },\n capsLock: {\n box: \"0 0 24 24\",\n paths: [\n \"M14 16a1 1 0 0 0 1-1v-2a1 1 0 0 1 1-1h3.293a.707.707 0 0 0 .5-1.207l-6.939-6.939a1.207 1.207 0 0 0-1.708 0l-6.94 6.94a.707.707 0 0 0 .5 1.206H8a1 1 0 0 1 1 1v2a1 1 0 0 0 1 1z\",\n \"M9 20h6\",\n ],\n },\n up: { box: \"0 0 24 24\", paths: [\"m5 12 7-7 7 7\", \"M12 19V5\"] },\n down: { box: \"0 0 24 24\", paths: [\"M12 5v14\", \"m19 12-7 7-7-7\"] },\n left: { box: \"0 0 24 24\", paths: [\"m12 19-7-7 7-7\", \"M19 12H5\"] },\n right: { box: \"0 0 24 24\", paths: [\"M5 12h14\", \"m12 5 7 7-7 7\"] },\n};\n\nconst MODIFIERS = new Map<string, Modifier>([\n [\"fn\", \"fn\"],\n [\"ctrl\", \"ctrl\"],\n [\"control\", \"ctrl\"],\n [\"alt\", \"alt\"],\n [\"option\", \"alt\"],\n [\"opt\", \"alt\"],\n [\"shift\", \"shift\"],\n [\"cmd\", \"meta\"],\n [\"command\", \"meta\"],\n [\"meta\", \"meta\"],\n [\"win\", \"meta\"],\n [\"super\", \"meta\"],\n]);\n\nconst MODIFIER_ORDER: Record<KeystrokePlatform, readonly Modifier[]> = {\n mac: [\"fn\", \"ctrl\", \"alt\", \"shift\", \"meta\"],\n windows: [\"fn\", \"meta\", \"ctrl\", \"alt\", \"shift\"],\n};\n\nconst MAC_MODIFIERS: Record<Exclude<Modifier, \"fn\">, IconSpec> = {\n ctrl: { label: \"Control\", icon: \"control\", units: 1 },\n alt: { label: \"Option\", icon: \"option\", units: 1 },\n shift: { label: \"Shift\", icon: \"shift\", units: 1.5 },\n meta: { label: \"Command\", icon: \"command\", units: 1 },\n};\n\nconst WINDOWS_MODIFIERS: Record<Modifier, string> = {\n fn: \"Fn\",\n ctrl: \"Ctrl\",\n alt: \"Alt\",\n shift: \"Shift\",\n meta: \"Win\",\n};\n\nconst NAMED = new Map<string, Named>([\n [\"enter\", \"enter\"],\n [\"return\", \"enter\"],\n [\"esc\", \"escape\"],\n [\"escape\", \"escape\"],\n [\"tab\", \"tab\"],\n [\"space\", \"space\"],\n [\"backspace\", \"backspace\"],\n [\"delete\", \"delete\"],\n [\"del\", \"delete\"],\n [\"capslock\", \"capsLock\"],\n [\"up\", \"up\"],\n [\"arrowup\", \"up\"],\n [\"down\", \"down\"],\n [\"arrowdown\", \"down\"],\n [\"left\", \"left\"],\n [\"arrowleft\", \"left\"],\n [\"right\", \"right\"],\n [\"arrowright\", \"right\"],\n [\"home\", \"home\"],\n [\"end\", \"end\"],\n [\"pageup\", \"pageUp\"],\n [\"pgup\", \"pageUp\"],\n [\"pagedown\", \"pageDown\"],\n [\"pgdn\", \"pageDown\"],\n]);\n\nconst CHARACTERS = new Map<string, string>([\n [\"plus\", \"+\"],\n [\"minus\", \"-\"],\n [\"comma\", \",\"],\n [\"period\", \".\"],\n [\"slash\", \"/\"],\n [\"backslash\", \"\\\\\"],\n [\"semicolon\", \";\"],\n [\"quote\", \"'\"],\n [\"backquote\", \"`\"],\n [\"bracketleft\", \"[\"],\n [\"bracketright\", \"]\"],\n [\"equal\", \"=\"],\n]);\n\nconst ARROWS: Record<\"up\" | \"down\" | \"left\" | \"right\", IconSpec> = {\n up: { label: \"Up Arrow\", icon: \"up\", units: 1 },\n down: { label: \"Down Arrow\", icon: \"down\", units: 1 },\n left: { label: \"Left Arrow\", icon: \"left\", units: 1 },\n right: { label: \"Right Arrow\", icon: \"right\", units: 1 },\n};\n\nconst NAMED_KEYS: Record<KeystrokePlatform, Record<Named, NamedSpec>> = {\n mac: {\n enter: { label: \"Return\", icon: \"return\", units: 1.5 },\n escape: { label: \"Escape\", icon: \"escape\", units: 1 },\n tab: { label: \"Tab\", icon: \"tab\", units: 1.25 },\n space: { label: \"Space\", icon: \"space\", units: 2.5 },\n backspace: { label: \"Delete\", icon: \"delete\", units: 1.25 },\n delete: { label: \"Delete\", icon: \"delete\", units: 1.25 },\n capsLock: { label: \"Caps Lock\", icon: \"capsLock\", units: 1.5 },\n ...ARROWS,\n home: { label: \"Home\", word: \"home\", units: 1 },\n end: { label: \"End\", word: \"end\", units: 1 },\n pageUp: { label: \"Page Up\", word: \"page up\", units: 1 },\n pageDown: { label: \"Page Down\", word: \"page down\", units: 1 },\n },\n windows: {\n enter: { label: \"Enter\", word: \"Enter\", units: WINDOWS_WORD },\n escape: { label: \"Esc\", word: \"Esc\", units: WINDOWS_WORD },\n tab: { label: \"Tab\", word: \"Tab\", units: WINDOWS_WORD },\n space: { label: \"Space\", word: \"Space\", units: 2.5 },\n backspace: { label: \"Backspace\", word: \"Backspace\", units: WINDOWS_WORD },\n delete: { label: \"Delete\", word: \"Delete\", units: WINDOWS_WORD },\n capsLock: { label: \"Caps Lock\", word: \"Caps Lock\", units: WINDOWS_WORD },\n ...ARROWS,\n home: { label: \"Home\", word: \"Home\", units: WINDOWS_WORD },\n end: { label: \"End\", word: \"End\", units: WINDOWS_WORD },\n pageUp: { label: \"Page Up\", word: \"PgUp\", units: WINDOWS_WORD },\n pageDown: { label: \"Page Down\", word: \"PgDn\", units: WINDOWS_WORD },\n },\n};\n\nconst finite = (value: number | undefined, fallback: number) =>\n typeof value === \"number\" && Number.isFinite(value) ? value : fallback;\nconst clamp = (value: number, min: number, max: number) =>\n Math.min(max, Math.max(min, value));\nconst within = (\n value: number | undefined,\n fallback: number,\n min: number,\n max: number,\n) => clamp(finite(value, fallback), min, max);\nconst round = (value: number) => Math.round(value * 1000) / 1000 + 0;\nconst smoothstep = (value: number) => {\n const t = clamp(value, 0, 1);\n return t * t * (3 - 2 * t);\n};\nconst fpsOf = (fps: number | undefined) => Math.max(1, finite(fps, 30));\nconst rateOf = (speed: number | undefined) =>\n Math.max(0, finite(speed, keystrokeDefaults.speed));\nconst platformOf = (value: string | undefined): KeystrokePlatform =>\n value === \"windows\" ? value : \"mac\";\nconst themeOf = (value: string | undefined): KeystrokeTheme =>\n value === \"dark\" ? value : \"light\";\nconst accentOf = (value: string | undefined) =>\n typeof value === \"string\" && value.trim() !== \"\"\n ? value.trim()\n : keystrokeDefaults.accent;\nconst modOf = (platform: KeystrokePlatform): Modifier =>\n platform === \"mac\" ? \"meta\" : \"ctrl\";\n\nfunction eased(frames: number, duration: number, curve: (t: number) => number) {\n if (Number.isNaN(frames) || frames <= 0) return 0;\n if (frames >= duration) return 1;\n return curve(frames / duration);\n}\n\nfunction settle(rise: number, damping: number, taper: number, end: number) {\n const frequency = (Math.PI - Math.acos(damping)) / rise;\n const ratio = damping / Math.sqrt(1 - damping ** 2);\n return (frames: number) => {\n if (Number.isNaN(frames) || frames <= 0) return 0;\n if (frames >= end) return 1;\n const phase = frequency * frames;\n const decay = Math.exp(-ratio * phase);\n const ring = decay * (Math.cos(phase) + ratio * Math.sin(phase));\n return 1 - ring * (1 - smoothstep((frames - taper) / (end - taper)));\n };\n}\n\nconst riseCurve = settle(ENTER_RISE, ENTER_DAMPING, ENTER_TAPER, ENTER);\nconst releaseCurve = settle(\n RELEASE_RISE,\n RELEASE_DAMPING,\n RELEASE_TAPER,\n RELEASE,\n);\n\nfunction getKeystrokePress(frames: number) {\n return eased(frames, PRESS, smoothstep);\n}\n\nfunction getKeystrokeRelease(frames: number) {\n return releaseCurve(frames);\n}\n\nfunction getKeystrokeRise(frames: number) {\n return riseCurve(frames);\n}\n\nfunction getKeystrokeDepth(time: number, timing: KeystrokeKeyTiming) {\n if (Number.isNaN(time) || time <= timing.press) return 0;\n if (time < timing.release) return getKeystrokePress(time - timing.press);\n const bottom = getKeystrokePress(timing.release - timing.press);\n return bottom * (1 - getKeystrokeRelease(time - timing.release));\n}\n\nfunction getKeystrokeWordUnits(text: string, min = 1) {\n const raw = Array.from(text).length * WORD_CHAR + 2 * WORD_PAD;\n return Math.max(min, Math.ceil(raw * 4 - 1e-9) / 4);\n}\n\nfunction wordKey(\n name: string,\n label: string,\n text: string,\n platform: KeystrokePlatform,\n modifier: boolean,\n min = 1,\n): KeystrokeKey {\n const floor = platform === \"windows\" ? Math.max(min, WINDOWS_WORD) : min;\n const units = getKeystrokeWordUnits(text, floor);\n return { name, label, legend: { kind: \"word\", text }, units, modifier };\n}\n\nfunction modifierKey(\n modifier: Modifier,\n platform: KeystrokePlatform,\n): KeystrokeKey {\n if (platform === \"windows\") {\n const word = WINDOWS_MODIFIERS[modifier];\n return wordKey(modifier, word, word, platform, true);\n }\n if (modifier === \"fn\") return wordKey(\"fn\", \"Fn\", \"fn\", platform, true);\n const { label, icon, units } = MAC_MODIFIERS[modifier];\n return {\n name: modifier,\n label,\n legend: { kind: \"icon\", icon },\n units,\n modifier: true,\n };\n}\n\nfunction namedKey(named: Named, platform: KeystrokePlatform): KeystrokeKey {\n const spec = NAMED_KEYS[platform][named];\n if (\"word\" in spec) {\n return wordKey(named, spec.label, spec.word, platform, false, spec.units);\n }\n return {\n name: named,\n label: spec.label,\n legend: { kind: \"icon\", icon: spec.icon },\n units: spec.units,\n modifier: false,\n };\n}\n\nfunction keyOf(part: string, platform: KeystrokePlatform): KeystrokeKey {\n const name = part.toLowerCase();\n const named = NAMED.get(name);\n if (named) return namedKey(named, platform);\n const character =\n CHARACTERS.get(name) ?? (Array.from(part).length === 1 ? part : undefined);\n if (character !== undefined) {\n const text = character.toUpperCase();\n return {\n name: character.toLowerCase(),\n label: text,\n legend: { kind: \"char\", text },\n units: 1,\n modifier: false,\n };\n }\n const fkey = /^f([1-9]|1\\d|2[0-4])$/.exec(name);\n if (fkey) {\n const text = `F${fkey[1]}`;\n return wordKey(name, text, text, platform, false);\n }\n const text = `${part.charAt(0).toUpperCase()}${part.slice(1)}`;\n return wordKey(name, text, text, platform, false);\n}\n\nfunction splitChord(token: string) {\n const parts = token.split(\"+\");\n const names: string[] = [];\n for (const [index, part] of parts.entries()) {\n if (part !== \"\") names.push(part);\n else if (index === parts.length - 1 && parts[index - 1] === \"\") {\n names.push(\"+\");\n }\n }\n return names;\n}\n\nfunction parseChord(token: string, platform: KeystrokePlatform) {\n const held = new Set<Modifier>();\n const keys: KeystrokeKey[] = [];\n for (const part of splitChord(token)) {\n const name = part.toLowerCase();\n const modifier = name === \"mod\" ? modOf(platform) : MODIFIERS.get(name);\n if (modifier) held.add(modifier);\n else keys.push(keyOf(part, platform));\n }\n const modifiers = MODIFIER_ORDER[platform]\n .filter((modifier) => held.has(modifier))\n .map((modifier) => modifierKey(modifier, platform));\n return [...modifiers, ...keys];\n}\n\nfunction parseKeystrokeKeys(\n keys: string,\n platform?: KeystrokePlatform,\n): KeystrokeChord[] {\n if (typeof keys !== \"string\") return [];\n const target = platformOf(platform);\n return keys\n .trim()\n .split(/\\s+/)\n .filter((token) => token !== \"\")\n .map((token) => parseChord(token, target))\n .filter((chord) => chord.length > 0);\n}\n\nfunction getKeystrokeLayout(\n chords: readonly KeystrokeChord[],\n): KeystrokeLayout {\n const layout: KeystrokeLayout = { caps: [], separators: [], widths: [] };\n let cursor = 0;\n for (const [chord, keys] of chords.entries()) {\n if (chord > 0) {\n layout.separators.push({ chord, x: round(cursor), width: SEPARATOR });\n cursor += SEPARATOR;\n }\n for (const [index, key] of keys.entries()) {\n if (index > 0) cursor += KEY_GAP;\n layout.caps.push({ chord, index, x: round(cursor), width: key.units });\n cursor += key.units;\n }\n layout.widths.push(round(cursor));\n }\n return layout;\n}\n\nfunction schedule(chords: readonly KeystrokeChord[], hold: number) {\n const timing: KeystrokeChordTiming[] = [];\n let enter = 0;\n for (const chord of chords) {\n const last = chord.length - 1;\n const fire = enter + LEAD + PRESS_GAP * last + PRESS;\n const keys = chord.map((_, index) => ({\n press: fire - PRESS - PRESS_GAP * (last - index),\n release: fire + hold + RELEASE_GAP * (last - index),\n }));\n timing.push({ enter, fire, keys });\n enter = fire + hold + RELEASE_GAP * last + BEAT;\n }\n return timing;\n}\n\nfunction getKeystrokeLeadIn(keys: string, hold = HOLD) {\n const chords = parseKeystrokeKeys(keys);\n if (chords.length === 0) return 0;\n const timing = schedule(chords, within(hold, HOLD, 0, MAX_FRAMES));\n return timing[timing.length - 1].fire - timing[0].enter;\n}\n\nfunction getKeystrokeTimeline(\n options: Pick<KeystrokeOptions, \"steps\" | \"platform\" | \"linger\" | \"fps\"> = {},\n) {\n const platform = platformOf(options.platform);\n const scale = 30 / fpsOf(options.fps);\n const lingerFrames = within(\n options.linger,\n keystrokeDefaults.linger,\n 0,\n MAX_FRAMES,\n );\n const linger = lingerFrames * scale;\n const steps = options.steps ?? keystrokeDefaultSteps;\n const drafts: Draft[] = [];\n for (const [step, entry] of steps.entries()) {\n if (typeof entry.at !== \"number\" || !Number.isFinite(entry.at)) continue;\n const chords = parseKeystrokeKeys(entry.keys, platform);\n if (chords.length === 0) continue;\n const at = entry.at * scale;\n const hold = within(entry.hold, HOLD, 0, MAX_FRAMES) * scale;\n const planned = schedule(chords, hold);\n const offset = at - planned[planned.length - 1].fire;\n const timing = planned.map((chord) => ({\n enter: round(chord.enter + offset),\n fire: round(chord.fire + offset),\n keys: chord.keys.map((key) => ({\n press: round(key.press + offset),\n release: round(key.release + offset),\n })),\n }));\n const releases = timing.flatMap((chord) =>\n chord.keys.map((key) => key.release),\n );\n drafts.push({\n step,\n keys: entry.keys,\n chords,\n timing,\n at: round(at),\n hold: round(hold),\n enter: timing[0].enter,\n lastRelease: Math.max(...releases),\n });\n }\n drafts.sort((a, b) => a.enter - b.enter || a.at - b.at || a.step - b.step);\n const groups = drafts.map((draft, index): KeystrokeGroup => {\n const pushes: number[] = [];\n let exit = Math.max(draft.enter, draft.lastRelease + linger);\n for (const newer of drafts.slice(index + 1)) {\n if (newer.enter >= exit + EXIT) break;\n const at = Math.max(newer.enter, draft.enter);\n const brief = Math.max(at, draft.lastRelease) + BRIEF;\n pushes.push(at);\n exit = Math.min(exit, pushes.length === 1 ? brief : at);\n if (pushes.length === 2) break;\n }\n exit = round(Math.max(exit, draft.enter));\n const label = draft.chords\n .map((chord) => chord.map((key) => key.label).join(\" \"))\n .join(\" then \");\n return {\n ...draft,\n index,\n label,\n layout: getKeystrokeLayout(draft.chords),\n pushes,\n exit,\n end: round(exit + EXIT),\n };\n });\n const end = groups.reduce((latest, group) => Math.max(latest, group.end), 0);\n return { platform, linger: round(linger), groups, end };\n}\n\ntype KeystrokeTimeline = ReturnType<typeof getKeystrokeTimeline>;\n\nconst keystrokeLength = getKeystrokeTimeline().end;\n\nfunction getKeystrokeDuration(\n options: Pick<KeystrokeOptions, \"steps\" | \"linger\" | \"speed\" | \"fps\"> = {},\n) {\n const fps = fpsOf(options.fps);\n const rate = rateOf(options.speed);\n const { end } = getKeystrokeTimeline(options);\n const motion = rate === 0 ? 0 : (end * fps) / 30 / rate;\n return Math.ceil(round(motion)) + Math.round((TAIL * fps) / 30);\n}\n\nfunction getKeystrokeTime(\n frame: number,\n options: Pick<KeystrokeOptions, \"fps\" | \"speed\"> = {},\n) {\n const elapsed = Math.max(0, finite(frame, 0));\n return (elapsed * rateOf(options.speed) * 30) / fpsOf(options.fps);\n}\n\nfunction getKeystrokeMetrics(size: number, unit = 1) {\n return {\n size: round(size),\n height: round(size),\n wall: round(size * WALL),\n travel: round(size * TRAVEL),\n keytop: round(size * (1 - WALL)),\n radius: round(size * RADIUS),\n rise: round(size * RISE),\n border: round(Math.max(1, unit)),\n charFont: round(size * CHAR_FONT),\n wordFont: round(size * WORD_FONT),\n icon: round(size * ICON_SIZE),\n separatorFont: round(size * SEPARATOR_FONT),\n };\n}\n\ntype KeystrokeMetrics = ReturnType<typeof getKeystrokeMetrics>;\n\nfunction legendColor(ink: string, accent: string, amount: number) {\n const share = Math.floor(clamp(amount, 0, 1) * 100);\n if (share <= 0) return ink;\n if (share >= 100) return accent;\n return `color-mix(in srgb, ${accent} ${share}%, ${ink})`;\n}\n\nfunction fadeIn(frames: number) {\n return eased(frames, FADE_IN, (t) => 1 - (1 - t) ** 2);\n}\n\nfunction groupState(\n group: KeystrokeGroup,\n time: number,\n metrics: KeystrokeMetrics,\n palette: KeystrokePalette,\n accent: string,\n) {\n const { size } = metrics;\n const slot = group.pushes.reduce(\n (sum, at) => sum + eased(time - at, PUSH, GLIDE),\n 0,\n );\n const leaving = clamp((time - group.exit) / EXIT, 0, 1);\n const pushedAway = group.pushes.some((at) => at <= group.exit);\n const drift = (pushedAway ? -1 : 1) * EXIT_DRIFT * size * leaving ** 3;\n const dimmed = 1 - (1 - SLOT_OPACITY) * Math.min(1, slot);\n const last = group.chords.length - 1;\n let visible = group.layout.widths[0];\n for (let chord = 1; chord <= last; chord++) {\n const added = group.layout.widths[chord] - group.layout.widths[chord - 1];\n visible += added * eased(time - group.timing[chord].enter, SLIDE, GLIDE);\n }\n const left = -visible / 2;\n const caps = group.layout.caps.flatMap((cap) => {\n const timing = group.timing[cap.chord];\n const enter = timing.enter + cap.index * STAGGER;\n if (time <= enter) return [];\n const key = group.chords[cap.chord][cap.index];\n const depth = getKeystrokeDepth(time, timing.keys[cap.index]);\n const landing =\n group.timing.at(cap.chord + 1)?.fire ?? Number.POSITIVE_INFINITY;\n const dim = smoothstep((time - (landing - DIM)) / DIM);\n const lean = clamp(depth, -1, 1);\n const shadowY = SHADOW_Y - (SHADOW_Y - SHADOW_Y_PRESSED) * lean;\n const shadowBlur = SHADOW_BLUR - (SHADOW_BLUR - SHADOW_BLUR_PRESSED) * lean;\n return [\n {\n id: `${cap.chord}-${cap.index}`,\n chord: cap.chord,\n index: cap.index,\n key,\n x: round((left + cap.x) * size),\n y: round((1 - getKeystrokeRise(time - enter)) * metrics.rise),\n width: round(cap.width * size),\n opacity: round(fadeIn(time - enter) * (1 - (1 - DIM_OPACITY) * dim)),\n depth: round(depth),\n lift: round(depth * metrics.travel),\n wall: round(metrics.wall - depth * metrics.travel),\n shadowY: round(shadowY * size),\n shadowBlur: round(shadowBlur * size),\n color: legendColor(palette.ink, accent, clamp(depth, 0, 1)),\n },\n ];\n });\n const separators = group.layout.separators.flatMap((separator) => {\n const enter = group.timing[separator.chord].enter;\n if (time <= enter) return [];\n return [\n {\n id: `then-${separator.chord}`,\n chord: separator.chord,\n x: round((left + separator.x) * size),\n y: round((1 - getKeystrokeRise(time - enter)) * metrics.rise),\n width: round(separator.width * size),\n opacity: round(fadeIn(time - enter)),\n },\n ];\n });\n return {\n id: `${group.step}`,\n index: group.index,\n step: group.step,\n keys: group.keys,\n label: group.label,\n slot: round(slot),\n width: round(visible * size),\n y: round(-slot * SLOT_RISE * size + drift),\n scale: round((1 - (1 - SLOT_SCALE) * slot) * (1 - EXIT_SCALE * leaving)),\n opacity: round(dimmed * (1 - leaving ** 2)),\n caps,\n separators,\n };\n}\n\nfunction getKeystrokeState(\n frame: number,\n options: KeystrokeOptions = {},\n timeline: KeystrokeTimeline = getKeystrokeTimeline(options),\n) {\n const width = Math.max(1, finite(options.width, 1280));\n const height = Math.max(1, finite(options.height, 720));\n const unit = height / 720;\n const reference = within(\n options.size,\n keystrokeDefaults.size,\n MIN_SIZE,\n MAX_SIZE,\n );\n const metrics = getKeystrokeMetrics(reference * unit, unit);\n const time = getKeystrokeTime(frame, options);\n const x = finite(options.x, keystrokeDefaults.x);\n const y = finite(options.y, keystrokeDefaults.y);\n const theme = themeOf(options.theme);\n const palette = keystrokePalettes[theme];\n const accent = accentOf(options.accent);\n const groups = timeline.groups\n .filter((group) => time > group.enter && time < group.end)\n .map((group) => groupState(group, time, metrics, palette, accent));\n return {\n width,\n height,\n unit,\n time: round(time),\n x,\n y,\n originX: round(x * width),\n originY: round(y * height),\n theme,\n palette,\n accent,\n metrics,\n groups,\n };\n}\n\ntype KeystrokeState = ReturnType<typeof getKeystrokeState>;\n\nfunction Legend({\n legend,\n metrics,\n}: {\n legend: KeystrokeLegend;\n metrics: KeystrokeMetrics;\n}) {\n if (legend.kind === \"icon\") {\n const icon = ICONS[legend.icon];\n return (\n <svg\n width={metrics.icon}\n height={metrics.icon}\n viewBox={icon.box}\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth={2}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n style={{ display: \"block\" }}\n >\n {icon.paths.map((d) => (\n <path key={d} d={d} />\n ))}\n </svg>\n );\n }\n const fontSize = legend.kind === \"word\" ? metrics.wordFont : metrics.charFont;\n return (\n <span\n style={{ fontSize, fontWeight: 500, lineHeight: 1, whiteSpace: \"nowrap\" }}\n >\n {legend.text}\n </span>\n );\n}\n\nfunction KeystrokeBase({\n steps = keystrokeDefaultSteps,\n platform = keystrokeDefaults.platform,\n theme = keystrokeDefaults.theme,\n accent = keystrokeDefaults.accent,\n x = keystrokeDefaults.x,\n y = keystrokeDefaults.y,\n size = keystrokeDefaults.size,\n linger = keystrokeDefaults.linger,\n speed = keystrokeDefaults.speed,\n className,\n}: KeystrokeProps) {\n const frame = useCurrentFrame();\n const { width, height, fps } = useVideoConfig();\n const timeline = useMemo(\n () => getKeystrokeTimeline({ steps, platform, linger, fps }),\n [steps, platform, linger, fps],\n );\n const state = getKeystrokeState(\n frame,\n { width, height, fps, theme, accent, x, y, size, speed },\n timeline,\n );\n const { metrics, palette } = state;\n\n return (\n <div\n className={className}\n style={{\n position: \"absolute\",\n inset: 0,\n overflow: \"hidden\",\n pointerEvents: \"none\",\n fontFamily: FONT_FAMILY,\n }}\n >\n {state.groups.map((group) => (\n <div\n key={group.id}\n style={{\n position: \"absolute\",\n left: `${state.x * 100}%`,\n top: `${state.y * 100}%`,\n width: 0,\n height: 0,\n opacity: group.opacity,\n transform: `translateY(${group.y}px) scale(${group.scale})`,\n transformOrigin: \"0 0\",\n }}\n >\n {group.separators.map((separator) => (\n <div\n key={separator.id}\n style={{\n position: \"absolute\",\n left: separator.x,\n top: separator.y - metrics.height / 2,\n width: separator.width,\n height: metrics.keytop,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n opacity: separator.opacity,\n color: palette.separator,\n fontSize: metrics.separatorFont,\n fontWeight: 500,\n lineHeight: 1,\n whiteSpace: \"nowrap\",\n }}\n >\n then\n </div>\n ))}\n {group.caps.map((cap) => (\n <div\n key={cap.id}\n style={{\n position: \"absolute\",\n left: cap.x,\n top: cap.y - metrics.height / 2,\n width: cap.width,\n height: metrics.height,\n opacity: cap.opacity,\n }}\n >\n <div\n style={{\n position: \"absolute\",\n left: 0,\n right: 0,\n top: metrics.travel,\n bottom: 0,\n borderRadius: metrics.radius,\n background: palette.wall,\n boxShadow: `0 ${cap.shadowY}px ${cap.shadowBlur}px ${palette.shadow}`,\n }}\n />\n <div\n style={{\n position: \"absolute\",\n left: 0,\n right: 0,\n top: 0,\n height: metrics.keytop,\n boxSizing: \"border-box\",\n borderRadius: metrics.radius,\n border: `${metrics.border}px solid ${palette.edge}`,\n background: palette.cap,\n color: cap.color,\n transform: `translateY(${cap.lift}px)`,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <Legend legend={cap.key.legend} metrics={metrics} />\n </div>\n </div>\n ))}\n </div>\n ))}\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n platform: {\n type: \"enum\",\n default: \"mac\",\n variants: {\n mac: {},\n windows: {},\n },\n description: \"Platform\",\n },\n theme: {\n type: \"enum\",\n default: \"light\",\n variants: {\n light: {},\n dark: {},\n },\n description: \"Theme\",\n },\n accent: {\n type: \"color\",\n default: \"#0a84ff\",\n description: \"Accent\",\n },\n size: {\n type: \"number\",\n default: 64,\n min: 32,\n max: 128,\n step: 1,\n description: \"Key size\",\n hiddenFromList: false,\n },\n linger: {\n type: \"number\",\n default: 30,\n min: 0,\n max: 90,\n step: 1,\n description: \"Linger\",\n hiddenFromList: false,\n },\n x: {\n type: \"number\",\n default: 0.5,\n min: 0,\n max: 1,\n step: 0.01,\n description: \"Center x\",\n hiddenFromList: false,\n },\n y: {\n type: \"number\",\n default: 0.86,\n min: 0,\n max: 1,\n step: 0.01,\n description: \"Center y\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"platform\",\"theme\",\"accent\",\"size\",\"linger\",\"x\",\"y\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n platform: \"mac\",\n theme: \"light\",\n accent: \"#0a84ff\",\n size: 64,\n linger: 30,\n x: 0.5,\n y: 0.86,\n speed: 1,\n};\n\ntype KeystrokeElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof KeystrokeBase>;\n\nconst KeystrokeInner = forwardRef<\n HTMLDivElement,\n KeystrokeElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<Keystroke>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <KeystrokeBase\n {...(componentProps as unknown as ComponentProps<typeof KeystrokeBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const Keystroke = Interactive.withSchema({\n Component: KeystrokeInner,\n componentName: \"<Keystroke>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/kinetic-center-build.json b/registry-artifacts/elements/kinetic-center-build.jsonindex c1a70955..f438196d 100644--- a/registry-artifacts/elements/kinetic-center-build.json+++ b/registry-artifacts/elements/kinetic-center-build.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [],"dimensions": {"width": 600,@@ -9,6 +10,7 @@},"displayName": "Kinetic Center Build","durationInFrames": 60,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "kinetic-center-build","sourceCode": "import { forwardRef, useImperativeHandle, useMemo, useRef, type ComponentProps } from \"react\";\nimport { Easing, Interactive, Sequence, interpolate, useCurrentFrame, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\n\ninterface KineticCenterBuildProps {\n text: string;\n entryOffset?: number;\n fontSize?: number;\n color?: string;\n fontWeight?: number;\n speed?: number;\n className?: string;\n}\n\nconst FONT_FAMILY =\n \"var(--font-geist-sans), -apple-system, BlinkMacSystemFont, sans-serif\";\n\nconst MEASURE_FONT =\n '-apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif';\n\nfunction measureWidths(\n words: string[],\n fontSize: number,\n fontWeight: number,\n): number[] {\n if (typeof document === \"undefined\") {\n return words.map((w) => w.length * fontSize * 0.55);\n }\n const ctx = document.createElement(\"canvas\").getContext(\"2d\");\n if (!ctx) return words.map((w) => w.length * fontSize * 0.55);\n ctx.font = `${fontWeight} ${fontSize}px ${MEASURE_FONT}`;\n return words.map((w) => ctx.measureText(w).width);\n}\n\nfunction KineticCenterBuildBase({\n text,\n entryOffset = 88,\n fontSize = 72,\n color = \"#171717\",\n fontWeight = 600,\n speed = 1,\n className,\n}: KineticCenterBuildProps) {\n const frame = useCurrentFrame() * speed;\n\n const words = useMemo(() => text.split(\" \"), [text]);\n const widths = useMemo(\n () => measureWidths(words, fontSize, fontWeight),\n [words, fontSize, fontWeight],\n );\n\n const gap = 10;\n const firstDur = 10;\n const pushDur = 13;\n const travelDur = 7;\n const entryScale = 0.992;\n const entryBlur = 3.5;\n const reflowBlur = 0.8;\n const firstWordY = 6;\n const easing = Easing.bezier(0.2, 0.8, 0.2, 1);\n\n const positionsAt = useMemo(() => {\n const out: number[][] = [];\n for (let k = 1; k <= words.length; k++) {\n let total = gap * (k - 1);\n for (let j = 0; j < k; j++) total += widths[j];\n let cursor = -total / 2;\n const xs: number[] = [];\n for (let j = 0; j < k; j++) {\n xs.push(cursor + widths[j] / 2);\n cursor += widths[j] + gap;\n }\n out.push(xs);\n }\n return out;\n }, [words, widths]);\n\n const n = words.length;\n\n return (\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n background: \"transparent\",\n }}\n >\n <div\n className={className}\n style={{\n position: \"relative\",\n fontSize,\n fontWeight,\n color,\n letterSpacing: \"-0.03em\",\n fontFamily: FONT_FAMILY,\n whiteSpace: \"nowrap\",\n }}\n >\n {words.map((word, j) => {\n const entryStart = j === 0 ? 0 : firstDur + (j - 1) * pushDur;\n const entryEnd = entryStart + (j === 0 ? firstDur : pushDur);\n const targetX = positionsAt[j][j];\n const xFrom = j === 0 ? 0 : targetX + entryOffset;\n\n let x = targetX;\n let opacity = 1;\n let scale = 1;\n let blur = 0;\n let y = 0;\n\n if (frame < entryStart) {\n opacity = 0;\n x = xFrom;\n scale = entryScale;\n blur = entryBlur;\n y = j === 0 ? firstWordY : 0;\n } else if (frame <= entryEnd) {\n const range: [number, number] = [entryStart, entryEnd];\n const travelRange: [number, number] = [\n entryStart,\n Math.min(entryStart + travelDur, entryEnd),\n ];\n const opts = {\n extrapolateLeft: \"clamp\" as const,\n extrapolateRight: \"clamp\" as const,\n easing,\n };\n x = interpolate(frame, travelRange, [xFrom, targetX], opts);\n opacity = interpolate(frame, range, [0, 1], opts);\n scale = interpolate(frame, range, [entryScale, 1], opts);\n blur = interpolate(frame, range, [entryBlur, 0], opts);\n y =\n j === 0\n ? interpolate(frame, travelRange, [firstWordY, 0], opts)\n : 0;\n } else {\n for (let w = j + 1; w < n; w++) {\n const pushStart = firstDur + (w - 1) * pushDur;\n const pushEnd = pushStart + pushDur;\n const fromX = positionsAt[w - 1][j];\n const toX = positionsAt[w][j];\n if (frame >= pushEnd) {\n x = toX;\n } else if (frame >= pushStart) {\n x = interpolate(\n frame,\n [pushStart, Math.min(pushStart + travelDur, pushEnd)],\n [fromX, toX],\n {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing,\n },\n );\n blur = interpolate(\n frame,\n [pushStart, (pushStart + pushEnd) / 2, pushEnd],\n [0, reflowBlur, 0],\n { extrapolateLeft: \"clamp\", extrapolateRight: \"clamp\" },\n );\n break;\n } else {\n x = fromX;\n break;\n }\n }\n }\n\n return (\n <span\n key={j}\n style={{\n position: \"absolute\",\n left: \"50%\",\n top: \"50%\",\n whiteSpace: \"nowrap\",\n backfaceVisibility: \"hidden\",\n transform: `translate(-50%, -50%) translate3d(${x}px, ${y}px, 0) scale(${scale})`,\n filter: `blur(${blur}px)`,\n opacity,\n }}\n >\n {word}\n </span>\n );\n })}\n </div>\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n text: {\n type: \"text-content\",\n default: \"Words push left.\",\n description: \"Text\",\n },\n entryOffset: {\n type: \"number\",\n min: 20,\n max: 160,\n step: 1,\n default: 88,\n description: \"Entry offset\",\n hiddenFromList: false,\n },\n fontSize: {\n type: \"number\",\n min: 12,\n max: 160,\n step: 1,\n default: 72,\n description: \"Font size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n fontWeight: {\n type: \"enum\",\n default: \"600\",\n variants: {\n \"400\": {},\n \"500\": {},\n \"600\": {},\n \"700\": {},\n },\n description: \"Font weight\",\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 600,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 100,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"text\",\"entryOffset\",\"fontSize\",\"color\",\"fontWeight\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n text: \"Words push left.\",\n entryOffset: 88,\n fontSize: 72,\n color: \"#171717\",\n fontWeight: \"600\",\n speed: 1,\n};\n\ntype KineticCenterBuildElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof KineticCenterBuildBase>;\n\nconst KineticCenterBuildInner = forwardRef<\n HTMLDivElement,\n KineticCenterBuildElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 600, height = 100, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<KineticCenterBuild>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <KineticCenterBuildBase\n {...(componentProps as unknown as ComponentProps<typeof KineticCenterBuildBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const KineticCenterBuild = Interactive.withSchema({\n Component: KineticCenterBuildInner,\n componentName: \"<KineticCenterBuild>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/kinetic-morph-text.json b/registry-artifacts/elements/kinetic-morph-text.jsonindex 6841a6c7..681ed841 100644--- a/registry-artifacts/elements/kinetic-morph-text.json+++ b/registry-artifacts/elements/kinetic-morph-text.json@@ -2,10 +2,12 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [],"dimensions": null,"displayName": "Kinetic Morph Text","durationInFrames": 246,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "kinetic-morph-text","sourceCode": "import { forwardRef, useId, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState, type ComponentProps } from \"react\";\nimport { Easing, Interactive, Sequence, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\n\ninterface KineticMorphTextProps {\n /** One phrase per line, or separate phrases with |. */\n text?: string;\n fontSize?: number;\n fontWeight?: number;\n color?: string;\n backgroundColor?: string;\n /** Flight radius in composition pixels. */\n spread?: number;\n /** Maximum letter rotation in degrees. */\n rotation?: number;\n /** Strength of the soft silhouette blend, from 0 to 1. */\n morph?: number;\n /** Opacity of the sampled outline echoes, from 0 to 1. */\n trails?: number;\n transitionFrames?: number;\n holdFrames?: number;\n loop?: boolean;\n speed?: number;\n className?: string;\n}\n\nconst kineticMorphTextDefaultText =\n \"Hello | Make it move | Shape what's next\";\n\nconst FONT_FAMILY = \"Arial, Helvetica, sans-serif\";\nconst TRANSITION = 54;\nconst HOLD = 42;\nconst clamp = (value: number) => Math.min(1, Math.max(0, value));\nconst finite = (value: number, fallback: number) =>\n Number.isFinite(value) ? value : fallback;\nconst ease = Easing.bezier(0.65, 0, 0.25, 1);\nconst smooth = (value: number) => {\n const p = clamp(value);\n return p * p * (3 - 2 * p);\n};\nconst mix = (a: number, b: number, p: number) => a + (b - a) * p;\nconst noise = (index: number) => {\n const value = Math.sin(index * 127.1 + 311.7) * 43758.5453;\n return value - Math.floor(value);\n};\n\nfunction parseKineticMorphText(text: string): string[] {\n return text\n .split(/[|\\n\\r]+/)\n .map((phrase) => phrase.trim().replace(/\\s+/g, \" \"))\n .filter(Boolean);\n}\n\n/** Includes the last readable hold. Timing values are authored at 30 fps. */\nfunction getKineticMorphTextDuration({\n text = kineticMorphTextDefaultText,\n transitionFrames = TRANSITION,\n holdFrames = HOLD,\n speed = 1,\n}: Pick<\n KineticMorphTextProps,\n \"text\" | \"transitionFrames\" | \"holdFrames\" | \"speed\" | \"loop\"\n> = {}): number {\n const count = parseKineticMorphText(text).length;\n const transition = Math.max(1, finite(transitionFrames, TRANSITION));\n const hold = Math.max(0, finite(holdFrames, HOLD));\n const rate = Math.max(0.01, finite(speed, 1));\n // Both modes use one transition + hold per phrase. Loop mode starts with\n // a readable first phrase and spends its last transition returning to it.\n const frames = count * (transition + hold);\n return Math.max(1, Math.ceil(frames / rate));\n}\n\n/** Last moving frame at defaults; the demo adds a final 42-frame hold. */\nconst kineticMorphTextLength = 246;\n\ninterface KineticMorphGlyph {\n character: string;\n x: number;\n}\n\ninterface KineticMorphPair {\n from?: KineticMorphGlyph;\n to?: KineticMorphGlyph;\n}\n\n/** Reserve identical graphemes before pairing remaining replacements. */\nfunction matchKineticMorphGlyphs(\n from: KineticMorphGlyph[],\n to: KineticMorphGlyph[],\n): KineticMorphPair[] {\n const unused = new Set(from.map((_, index) => index));\n const matches = to.map((target) => {\n let closest = -1;\n let distance = Number.POSITIVE_INFINITY;\n for (const index of unused) {\n const source = from[index];\n if (source.character !== target.character) continue;\n const travel = Math.abs(source.x - target.x);\n if (travel < distance) {\n closest = index;\n distance = travel;\n }\n }\n if (closest !== -1) unused.delete(closest);\n return closest;\n });\n const remaining = [...unused];\n const pairs: KineticMorphPair[] = to.map((target, index) => {\n const source = matches[index] === -1 ? remaining.shift() : matches[index];\n return {\n from: source === undefined ? undefined : from[source],\n to: target,\n };\n });\n for (const index of remaining) pairs.push({ from: from[index] });\n return pairs;\n}\n\nfunction getKineticMorphTimeline(\n frame: number,\n count: number,\n transitionFrames = TRANSITION,\n holdFrames = HOLD,\n loop = false,\n) {\n const transition = Math.max(1, finite(transitionFrames, TRANSITION));\n const hold = Math.max(0, finite(holdFrames, HOLD));\n const time = Math.max(0, finite(frame, 0));\n if (count === 0) return { from: -1, to: -1, progress: 1 };\n if (!loop && time < transition) {\n return { from: -1, to: 0, progress: time / transition };\n }\n const cursor = loop ? time : time - transition;\n const cycle = transition + hold;\n const index = Math.floor(cursor / cycle);\n if ((!loop && index >= count - 1) || (loop && count === 1)) {\n return { from: count - 1, to: count - 1, progress: 1 };\n }\n return {\n from: index % count,\n to: (index + 1) % count,\n progress: clamp(((cursor % cycle) - hold) / transition),\n };\n}\n\ninterface PoseOptions {\n spread: number;\n rotation: number;\n morph: number;\n}\n\nfunction getKineticMorphPose(\n pair: KineticMorphPair,\n index: number,\n count: number,\n progress: number,\n { spread, rotation, morph }: PoseOptions,\n) {\n // A bounded stagger keeps long phrases within the same transition window.\n const delay = noise(index + 3) * 0.12;\n const p = clamp((progress - delay) / (1 - delay));\n const travel = ease(p);\n const motion = Math.sin(Math.PI * travel);\n const angle = (index / Math.max(count, 1)) * Math.PI * 2 - Math.PI / 2;\n const orbitX = Math.cos(angle) * spread * (0.7 + noise(index) * 0.4);\n const orbitY = Math.sin(angle) * spread * 0.72 - spread * 0.25;\n const fromX = pair.from?.x ?? orbitX * 1.2;\n const toX = pair.to?.x ?? orbitX * 1.2;\n const fromY = pair.from ? 0 : orbitY + spread * 0.65;\n const toY = pair.to ? 0 : orbitY - spread * 0.6;\n const x = mix(fromX, toX, travel) + orbitX * motion;\n const y = mix(fromY, toY, travel) + orbitY * motion;\n const turn = (noise(index + 9) * 2 - 1) * rotation;\n const rotate = pair.from\n ? pair.to\n ? turn * motion\n : turn * travel\n : turn * (1 - travel);\n const replacement = Boolean(\n pair.from && pair.to && pair.from.character !== pair.to.character,\n );\n const blend = replacement ? smooth((p - 0.36) / 0.28) : 0;\n const melt = replacement ? Math.sin(Math.PI * blend) * morph : 0;\n const opacity = pair.from\n ? pair.to\n ? 1\n : 1 - smooth((p - 0.35) / 0.5)\n : smooth(p / 0.36);\n return {\n x,\n y,\n rotate,\n scaleX: 1 - melt * 0.52 + motion * 0.08,\n scaleY: 1 + melt * 0.42 - motion * 0.06,\n blend,\n melt,\n opacity,\n motion,\n };\n}\n\ninterface Layout {\n key: string;\n phrases: KineticMorphGlyph[][];\n size: number;\n baseline: number;\n}\n\nfunction useGlyphLayout(\n text: string,\n size: number,\n weight: number,\n width: number,\n) {\n const [layout, setLayout] = useState<Layout | null>(null);\n const key = JSON.stringify([text, size, weight, width]);\n\n useLayoutEffect(() => {\n const context = document.createElement(\"canvas\").getContext(\"2d\");\n if (!context) return;\n const segmenter = new Intl.Segmenter(\"en\", { granularity: \"grapheme\" });\n const phrases = parseKineticMorphText(text).map((phrase) =>\n Array.from(segmenter.segment(phrase), ({ segment }) => segment),\n );\n context.font = `${weight} ${size}px ${FONT_FAMILY}`;\n context.fontKerning = \"none\";\n const advances = phrases.map((phrase) =>\n phrase.map((character) => context.measureText(character).width),\n );\n const widths = advances.map((row) =>\n row.reduce((sum, value) => sum + value, 0),\n );\n const fit = Math.min(1, (width * 0.82) / Math.max(1, ...widths));\n const metrics = context.measureText(\"Hg\");\n setLayout({\n key,\n size: size * fit,\n baseline:\n ((metrics.actualBoundingBoxAscent - metrics.actualBoundingBoxDescent) /\n 2) *\n fit,\n phrases: phrases.map((phrase, row) => {\n let cursor = (-widths[row] * fit) / 2;\n return phrase.flatMap((character, column) => {\n const advance = advances[row][column] * fit;\n const x = cursor + advance / 2;\n cursor += advance;\n return character.trim() ? [{ character, x }] : [];\n });\n }),\n });\n }, [key, text, size, weight, width]);\n\n return layout?.key === key ? layout : null;\n}\n\nfunction MorphGlyph({\n pair,\n index,\n count,\n progress,\n options,\n size,\n baseline,\n color,\n trails,\n transitionFrames,\n}: {\n pair: KineticMorphPair;\n index: number;\n count: number;\n progress: number;\n options: PoseOptions;\n size: number;\n baseline: number;\n color: string;\n trails: number;\n transitionFrames: number;\n}) {\n const filterId = useId().replace(/:/g, \"\");\n const pose = getKineticMorphPose(pair, index, count, progress, options);\n const transform = (value: typeof pose) =>\n `translate(${value.x} ${value.y}) rotate(${value.rotate}) scale(${value.scaleX} ${value.scaleY})`;\n const replacement =\n pair.from && pair.to && pair.from.character !== pair.to.character;\n const character = pair.from?.character ?? pair.to?.character;\n\n return (\n <g>\n {trails > 0 && pose.motion > 0.001\n ? [3, 2, 1].map((sample) => {\n const echo = getKineticMorphPose(\n pair,\n index,\n count,\n Math.max(0, progress - (sample * 1.5) / transitionFrames),\n options,\n );\n return (\n <text\n key={sample}\n transform={transform(echo)}\n y={baseline}\n fill=\"none\"\n stroke={color}\n strokeWidth={Math.max(0.7, size * 0.009)}\n opacity={echo.opacity * pose.motion * trails * (1 - sample / 4)}\n >\n {replacement && echo.blend > 0.5\n ? pair.to?.character\n : character}\n </text>\n );\n })\n : null}\n {replacement && pose.melt > 0.001 ? (\n <defs>\n <filter\n id={filterId}\n x=\"-70%\"\n y=\"-70%\"\n width=\"240%\"\n height=\"240%\"\n colorInterpolationFilters=\"sRGB\"\n >\n <feGaussianBlur stdDeviation={pose.melt * size * 0.045} />\n <feColorMatrix\n type=\"matrix\"\n values=\"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 12 -4\"\n />\n </filter>\n </defs>\n ) : null}\n <g transform={transform(pose)} opacity={pose.opacity}>\n <g\n filter={\n replacement && pose.melt > 0.001 ? `url(#${filterId})` : undefined\n }\n fill={color}\n >\n <text y={baseline} opacity={replacement ? 1 - pose.blend : 1}>\n {character}\n </text>\n {replacement ? (\n <text y={baseline} opacity={pose.blend}>\n {pair.to?.character}\n </text>\n ) : null}\n </g>\n </g>\n </g>\n );\n}\n\nfunction KineticMorphTextBase({\n text = kineticMorphTextDefaultText,\n fontSize = 100,\n fontWeight = 600,\n color = \"#b4f4d9\",\n backgroundColor = \"#a800b7\",\n spread = 180,\n rotation = 110,\n morph = 0.75,\n trails = 0.45,\n transitionFrames = TRANSITION,\n holdFrames = HOLD,\n loop = false,\n speed = 1,\n className,\n}: KineticMorphTextProps) {\n const currentFrame = useCurrentFrame();\n const { width, height, fps } = useVideoConfig();\n const frame = currentFrame * (30 / fps) * Math.max(0, finite(speed, 1));\n const size = Math.min(height * 0.28, Math.max(1, finite(fontSize, 100)));\n const weight = Math.min(900, Math.max(100, finite(Number(fontWeight), 600)));\n const layout = useGlyphLayout(text, size, weight, width);\n const transition = Math.max(1, finite(transitionFrames, TRANSITION));\n const timeline = getKineticMorphTimeline(\n frame,\n layout?.phrases.length ?? 0,\n transition,\n holdFrames,\n loop,\n );\n const pairs = useMemo(\n () =>\n matchKineticMorphGlyphs(\n layout?.phrases[timeline.from] ?? [],\n layout?.phrases[timeline.to] ?? [],\n ),\n [layout, timeline.from, timeline.to],\n );\n const options = {\n spread: Math.min(\n width * 0.24,\n height * 0.32,\n Math.max(0, finite(spread, 180)),\n ),\n rotation: Math.max(0, finite(rotation, 110)),\n morph: clamp(finite(morph, 0.75)),\n };\n\n return (\n <div\n className={className}\n style={{\n position: \"absolute\",\n inset: 0,\n backgroundColor,\n overflow: \"hidden\",\n }}\n >\n <svg\n width=\"100%\"\n height=\"100%\"\n viewBox={`0 0 ${width} ${height}`}\n role=\"img\"\n aria-label={parseKineticMorphText(text).join(\". \")}\n style={{\n display: \"block\",\n fontFamily: FONT_FAMILY,\n fontSize: layout?.size ?? size,\n fontWeight: weight,\n fontKerning: \"none\",\n }}\n >\n <g\n transform={`translate(${width / 2} ${height / 2})`}\n textAnchor=\"middle\"\n >\n {layout\n ? pairs.map((pair, index) => (\n <MorphGlyph\n key={`${timeline.from}:${timeline.to}:${index}`}\n pair={pair}\n index={index}\n count={pairs.length}\n progress={timeline.progress}\n options={options}\n size={layout.size}\n baseline={layout.baseline}\n color={color}\n trails={clamp(finite(trails, 0.45))}\n transitionFrames={transition}\n />\n ))\n : null}\n </g>\n </svg>\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n text: {\n type: \"text-content\",\n default: \"Hello | Make it move | Shape what's next\",\n description: \"Phrases (separate with |)\",\n },\n fontSize: {\n type: \"number\",\n default: 100,\n min: 24,\n max: 180,\n step: 1,\n description: \"Font size\",\n hiddenFromList: false,\n },\n fontWeight: {\n type: \"enum\",\n default: \"600\",\n variants: {\n \"400\": {},\n \"500\": {},\n \"600\": {},\n \"700\": {},\n },\n description: \"Font weight\",\n },\n spread: {\n type: \"number\",\n default: 180,\n min: 0,\n max: 230,\n step: 5,\n description: \"Flight spread\",\n hiddenFromList: false,\n },\n rotation: {\n type: \"number\",\n default: 110,\n min: 0,\n max: 240,\n step: 5,\n description: \"Rotation\",\n hiddenFromList: false,\n },\n morph: {\n type: \"number\",\n default: 0.75,\n min: 0,\n max: 1,\n step: 0.05,\n description: \"Morph strength\",\n hiddenFromList: false,\n },\n trails: {\n type: \"number\",\n default: 0.45,\n min: 0,\n max: 1,\n step: 0.05,\n description: \"Outline trails\",\n hiddenFromList: false,\n },\n transitionFrames: {\n type: \"number\",\n default: 54,\n min: 18,\n max: 90,\n step: 1,\n description: \"Transition frames\",\n hiddenFromList: false,\n },\n holdFrames: {\n type: \"number\",\n default: 42,\n min: 0,\n max: 90,\n step: 1,\n description: \"Hold frames\",\n hiddenFromList: false,\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop phrases\",\n },\n color: {\n type: \"color\",\n default: \"#b4f4d9\",\n description: \"Text color\",\n },\n backgroundColor: {\n type: \"color\",\n default: \"#a800b7\",\n description: \"Background\",\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"text\",\"fontSize\",\"fontWeight\",\"spread\",\"rotation\",\"morph\",\"trails\",\"transitionFrames\",\"holdFrames\",\"loop\",\"color\",\"backgroundColor\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n text: \"Hello | Make it move | Shape what's next\",\n fontSize: 100,\n fontWeight: \"600\",\n spread: 180,\n rotation: 110,\n morph: 0.75,\n trails: 0.45,\n transitionFrames: 54,\n holdFrames: 42,\n loop: false,\n color: \"#b4f4d9\",\n backgroundColor: \"#a800b7\",\n speed: 1,\n};\n\ntype KineticMorphTextElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof KineticMorphTextBase>;\n\nconst KineticMorphTextInner = forwardRef<\n HTMLDivElement,\n KineticMorphTextElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<KineticMorphText>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <KineticMorphTextBase\n {...(componentProps as unknown as ComponentProps<typeof KineticMorphTextBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const KineticMorphText = Interactive.withSchema({\n Component: KineticMorphTextInner,\n componentName: \"<KineticMorphText>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/kinetic-warp.json b/registry-artifacts/elements/kinetic-warp.jsonindex 76e927ff..bf9e2fc7 100644--- a/registry-artifacts/elements/kinetic-warp.json+++ b/registry-artifacts/elements/kinetic-warp.json@@ -2,10 +2,12 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [],"dimensions": null,"displayName": "Kinetic Warp","durationInFrames": 100,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "kinetic-warp","sourceCode": "import { forwardRef, useEffect, useImperativeHandle, useMemo, useRef, useState, type ComponentProps } from \"react\";\nimport { Easing, Interactive, Sequence, continueRender, delayRender, interpolate, useCurrentFrame, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\n\ninterface KineticWarpProps {\n className?: string;\n compWidth?: number;\n compHeight?: number;\n textColor?: string;\n text?: string;\n fontFamily?: string;\n fontUrl?: string;\n fontWeight?: number;\n fontSize?: number;\n leading?: number;\n tracking?: number;\n layerScale?: number;\n positionX?: number;\n positionY?: number;\n meshRows?: number;\n meshColumns?: number;\n colRestX?: number;\n colRightX?: number;\n colLeftX?: number;\n rowRestY?: number;\n rowDownY?: number;\n rowUpY?: number;\n keyframeStride?: number;\n easingBezier?: [number, number, number, number];\n resampleStep?: number;\n}\n\nfunction monotoneSpline(xs: number[], ys: number[]): (x: number) => number {\n const n = xs.length;\n const dx: number[] = [];\n const secant: number[] = [];\n for (let i = 0; i < n - 1; i++) {\n dx.push(xs[i + 1] - xs[i]);\n secant.push((ys[i + 1] - ys[i]) / (xs[i + 1] - xs[i]));\n }\n\n const m: number[] = new Array(n);\n m[0] = secant[0];\n m[n - 1] = secant[n - 2];\n for (let i = 1; i < n - 1; i++) {\n m[i] = secant[i - 1] * secant[i] <= 0 ? 0 : (secant[i - 1] + secant[i]) / 2;\n }\n\n for (let i = 0; i < n - 1; i++) {\n if (secant[i] === 0) {\n m[i] = 0;\n m[i + 1] = 0;\n continue;\n }\n const a = m[i] / secant[i];\n const b = m[i + 1] / secant[i];\n const s = a * a + b * b;\n if (s > 9) {\n const t = 3 / Math.sqrt(s);\n m[i] = t * a * secant[i];\n m[i + 1] = t * b * secant[i];\n }\n }\n\n return (x: number) => {\n if (x <= xs[0]) return ys[0] + m[0] * (x - xs[0]);\n if (x >= xs[n - 1]) return ys[n - 1] + m[n - 1] * (x - xs[n - 1]);\n let i = n - 2;\n while (i > 0 && x < xs[i]) i--;\n const h = dx[i];\n const t = (x - xs[i]) / h;\n const t2 = t * t;\n const t3 = t2 * t;\n return (\n (2 * t3 - 3 * t2 + 1) * ys[i] +\n (t3 - 2 * t2 + t) * h * m[i] +\n (-2 * t3 + 3 * t2) * ys[i + 1] +\n (t3 - t2) * h * m[i + 1]\n );\n };\n}\n\nfunction KineticWarpBase({\n className,\n compWidth = 1920,\n compHeight = 1080,\n textColor = \"#FFFFFF\",\n text = \"REM\\nOCN\",\n fontFamily = \"sans-serif\",\n fontUrl = \"\",\n fontWeight = 700,\n fontSize = 107.1,\n leading = 70,\n tracking = -21,\n layerScale = 480,\n positionX = 960,\n positionY = 540,\n meshRows = 2,\n meshColumns = 4,\n colRestX = 960,\n colRightX = 1255,\n colLeftX = 678,\n rowRestY = 540,\n rowDownY = 850,\n rowUpY = 387,\n keyframeStride = 20,\n easingBezier = [0.3, 0.74, 0.09, 1],\n resampleStep = 4,\n}: KineticWarpProps) {\n const frame = useCurrentFrame();\n const canvasRef = useRef<HTMLCanvasElement | null>(null);\n const [fontReady, setFontReady] = useState(false);\n\n const scale = layerScale / 100;\n const pxSize = fontSize * scale;\n const pxLeading = leading * scale;\n const pxTracking = (tracking / 1000) * pxSize;\n\n useEffect(() => {\n const handle = delayRender(\"kinetic-warp: loading font\");\n let cancelled = false;\n const done = () => {\n if (!cancelled) setFontReady(true);\n continueRender(handle);\n };\n if (typeof document === \"undefined\" || !document.fonts) {\n done();\n return;\n }\n document.fonts\n .load(`${fontWeight} ${pxSize}px \"${fontFamily}\"`)\n .then(done, done);\n return () => {\n cancelled = true;\n };\n }, [fontFamily, fontWeight, pxSize]);\n\n const source = useMemo(() => {\n if (!fontReady || typeof document === \"undefined\") return null;\n const canvas = document.createElement(\"canvas\");\n canvas.width = compWidth;\n canvas.height = compHeight;\n const ctx = canvas.getContext(\"2d\");\n if (!ctx) return null;\n\n ctx.font = `${fontWeight} ${pxSize}px \"${fontFamily}\", sans-serif`;\n ctx.letterSpacing = `${pxTracking}px`;\n ctx.fillStyle = textColor;\n ctx.textAlign = \"left\";\n ctx.textBaseline = \"alphabetic\";\n\n const lines = text.split(\"\\n\");\n const metrics = lines.map((line) => ctx.measureText(line));\n\n const ascent = metrics[0].actualBoundingBoxAscent;\n const descent = metrics[metrics.length - 1].actualBoundingBoxDescent;\n const span = (lines.length - 1) * pxLeading;\n const firstBaseline = positionY - (span - ascent + descent) / 2;\n\n lines.forEach((line, i) => {\n const m = metrics[i];\n const x =\n positionX - (m.actualBoundingBoxRight - m.actualBoundingBoxLeft) / 2;\n ctx.fillText(line, x, firstBaseline + i * pxLeading);\n });\n\n return canvas;\n }, [\n compWidth,\n compHeight,\n text,\n fontFamily,\n fontWeight,\n pxSize,\n pxLeading,\n pxTracking,\n textColor,\n positionX,\n positionY,\n fontReady,\n ]);\n\n const scratch = useMemo(() => {\n if (typeof document === \"undefined\") return null;\n const canvas = document.createElement(\"canvas\");\n canvas.width = compWidth;\n canvas.height = compHeight;\n return canvas;\n }, [compWidth, compHeight]);\n\n const easing = Easing.bezier(...easingBezier);\n const stops = [0, 1, 2, 3, 4, 5].map((i) => i * keyframeStride);\n const clamp = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing,\n } as const;\n\n const colX = interpolate(\n frame,\n stops,\n [colRestX, colRightX, colRightX, colLeftX, colLeftX, colRestX],\n clamp,\n );\n const rowY = interpolate(\n frame,\n stops,\n [rowRestY, rowRestY, rowDownY, rowDownY, rowUpY, rowRestY],\n clamp,\n );\n\n useEffect(() => {\n const canvas = canvasRef.current;\n if (!canvas || !source || !scratch) return;\n const out = canvas.getContext(\"2d\");\n const mid = scratch.getContext(\"2d\");\n if (!out || !mid) return;\n\n const xs = Array.from(\n { length: meshColumns + 1 },\n (_, i) => (i * compWidth) / meshColumns,\n );\n const ys = Array.from(\n { length: meshRows + 1 },\n (_, i) => (i * compHeight) / meshRows,\n );\n const xd = xs.slice();\n const yd = ys.slice();\n xd[Math.round(meshColumns / 2)] = colX;\n yd[Math.round(meshRows / 2)] = rowY;\n\n const gx = monotoneSpline(xd, xs);\n const gy = monotoneSpline(yd, ys);\n\n mid.clearRect(0, 0, compWidth, compHeight);\n out.clearRect(0, 0, compWidth, compHeight);\n\n for (let d0 = 0; d0 < compWidth; d0 += resampleStep) {\n const d1 = Math.min(d0 + resampleStep, compWidth);\n const s0 = gx(d0);\n const sw = gx(d1) - s0;\n if (sw <= 0) continue;\n mid.drawImage(source, s0, 0, sw, compHeight, d0, 0, d1 - d0, compHeight);\n }\n\n for (let d0 = 0; d0 < compHeight; d0 += resampleStep) {\n const d1 = Math.min(d0 + resampleStep, compHeight);\n const s0 = gy(d0);\n const sh = gy(d1) - s0;\n if (sh <= 0) continue;\n out.drawImage(scratch, 0, s0, compWidth, sh, 0, d0, compWidth, d1 - d0);\n }\n }, [\n source,\n scratch,\n colX,\n rowY,\n compWidth,\n compHeight,\n meshRows,\n meshColumns,\n resampleStep,\n ]);\n\n return (\n <div\n className={className}\n style={{ position: \"absolute\", inset: 0, overflow: \"hidden\" }}\n >\n {fontUrl ? <link rel=\"stylesheet\" href={fontUrl} /> : null}\n <canvas\n ref={canvasRef}\n width={compWidth}\n height={compHeight}\n style={{ width: \"100%\", height: \"100%\", display: \"block\" }}\n />\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n text: {\n type: \"text-content\",\n default: \"REM\\nOCN\",\n description: \"Text\",\n },\n textColor: {\n type: \"color\",\n default: \"#FFFFFF\",\n description: \"Color\",\n },\n fontFamily: {\n type: \"text-content\",\n default: \"Passion One\",\n description: \"Font family\",\n },\n fontUrl: {\n type: \"text-content\",\n default: \"https://fonts.googleapis.com/css2?family=Passion+One:wght@400;700;900&display=block\",\n description: \"Font URL\",\n },\n fontWeight: {\n type: \"enum\",\n default: \"700\",\n variants: {\n \"400\": {},\n \"500\": {},\n \"600\": {},\n \"700\": {},\n },\n description: \"Font weight\",\n },\n fontSize: {\n type: \"number\",\n min: 40,\n max: 200,\n step: 0.1,\n default: 107.1,\n description: \"Font size\",\n hiddenFromList: false,\n },\n layerScale: {\n type: \"number\",\n min: 100,\n max: 800,\n step: 10,\n default: 480,\n description: \"Layer scale (%)\",\n hiddenFromList: false,\n },\n keyframeStride: {\n type: \"number\",\n min: 5,\n max: 40,\n step: 1,\n default: 20,\n description: \"Keyframe stride\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"text\",\"textColor\",\"fontFamily\",\"fontUrl\",\"fontWeight\",\"fontSize\",\"layerScale\",\"keyframeStride\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n text: \"REM\\nOCN\",\n textColor: \"#FFFFFF\",\n fontFamily: \"Passion One\",\n fontUrl: \"https://fonts.googleapis.com/css2?family=Passion+One:wght@400;700;900&display=block\",\n fontWeight: \"700\",\n fontSize: 107.1,\n layerScale: 480,\n keyframeStride: 20,\n speed: 1,\n};\n\ntype KineticWarpElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof KineticWarpBase>;\n\nconst KineticWarpInner = forwardRef<\n HTMLDivElement,\n KineticWarpElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<KineticWarp>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <KineticWarpBase\n {...(componentProps as unknown as ComponentProps<typeof KineticWarpBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const KineticWarp = Interactive.withSchema({\n Component: KineticWarpInner,\n componentName: \"<KineticWarp>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/line-by-line-slide.json b/registry-artifacts/elements/line-by-line-slide.jsonindex 133acd64..39fa1d8f 100644--- a/registry-artifacts/elements/line-by-line-slide.json+++ b/registry-artifacts/elements/line-by-line-slide.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [],"dimensions": {"width": 600,@@ -9,6 +10,7 @@},"displayName": "Line-by-Line Slide","durationInFrames": 90,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "line-by-line-slide","sourceCode": "import { Easing, Interactive, Sequence, interpolate, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface LineByLineSlideProps {\n text: string;\n distance?: number;\n fontSize?: number;\n color?: string;\n fontWeight?: number;\n speed?: number;\n className?: string;\n}\n\nfunction LineByLineSlideBase({\n text,\n distance = 48,\n fontSize = 72,\n color = \"#171717\",\n fontWeight = 600,\n speed = 1,\n className,\n}: LineByLineSlideProps) {\n const frame = useCurrentFrame() * speed;\n const { durationInFrames } = useVideoConfig();\n\n const lines = text.split(\"\\n\");\n\n const enterDur = 27;\n const enterTravel = 14;\n const exitDur = 18;\n const exitTravelFrom = 8;\n const enterStagger = 4;\n const exitStagger = 2;\n\n const enterEasing = Easing.bezier(0.22, 1, 0.36, 1);\n const exitEasing = Easing.bezier(0.64, 0, 0.78, 0);\n\n const enterEnd = enterDur + (lines.length - 1) * enterStagger;\n const exitStart = Math.max(\n enterEnd,\n durationInFrames - exitDur - (lines.length - 1) * exitStagger,\n );\n\n return (\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n background: \"transparent\",\n }}\n >\n <span\n className={className}\n style={{\n fontSize,\n fontWeight,\n color,\n letterSpacing: \"-0.03em\",\n lineHeight: 1.1,\n textAlign: \"left\",\n fontFamily:\n \"var(--font-geist-sans), -apple-system, BlinkMacSystemFont, sans-serif\",\n }}\n >\n {lines.map((line, i) => {\n const enterLocal = frame - i * enterStagger;\n const exitLocal = frame - exitStart - i * exitStagger;\n\n const enterP = interpolate(enterLocal, [0, enterDur], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: enterEasing,\n });\n\n const exitP = interpolate(exitLocal, [0, exitDur], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: exitEasing,\n });\n\n const opacity = enterP * (1 - exitP);\n\n const xEnter = interpolate(\n enterLocal,\n [0, enterTravel],\n [-distance, 0],\n {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: enterEasing,\n },\n );\n\n const xExit = interpolate(\n exitLocal,\n [exitTravelFrom, exitDur],\n [0, distance],\n {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: exitEasing,\n },\n );\n\n const x = xEnter + xExit;\n\n return (\n <span\n key={i}\n style={{\n display: \"block\",\n transformOrigin: \"0% 50%\",\n opacity,\n translate: `${x}px`,\n }}\n >\n {line}\n </span>\n );\n })}\n </span>\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n text: {\n type: \"text-content\",\n default: \"Think different.\\nDo more.\",\n description: \"Text\",\n },\n distance: {\n type: \"number\",\n min: 0,\n max: 160,\n step: 1,\n default: 48,\n description: \"Distance\",\n hiddenFromList: false,\n },\n fontSize: {\n type: \"number\",\n min: 12,\n max: 160,\n step: 1,\n default: 72,\n description: \"Font size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n fontWeight: {\n type: \"enum\",\n default: \"600\",\n variants: {\n \"400\": {},\n \"500\": {},\n \"600\": {},\n \"700\": {},\n },\n description: \"Font weight\",\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 600,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 200,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"text\",\"distance\",\"fontSize\",\"color\",\"fontWeight\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n text: \"Think different.\\nDo more.\",\n distance: 48,\n fontSize: 72,\n color: \"#171717\",\n fontWeight: \"600\",\n speed: 1,\n};\n\ntype LineByLineSlideElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof LineByLineSlideBase>;\n\nconst LineByLineSlideInner = forwardRef<\n HTMLDivElement,\n LineByLineSlideElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 600, height = 200, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<LineByLineSlide>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <LineByLineSlideBase\n {...(componentProps as unknown as ComponentProps<typeof LineByLineSlideBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const LineByLineSlide = Interactive.withSchema({\n Component: LineByLineSlideInner,\n componentName: \"<LineByLineSlide>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/marker-highlight.json b/registry-artifacts/elements/marker-highlight.jsonindex 85a5e811..a0158561 100644--- a/registry-artifacts/elements/marker-highlight.json+++ b/registry-artifacts/elements/marker-highlight.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [],"dimensions": {"width": 340,@@ -9,6 +10,7 @@},"displayName": "Marker Highlight","durationInFrames": 90,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "marker-highlight","sourceCode": "import { Interactive, Sequence, interpolate, interpolateColors, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface MarkerHighlightProps {\n before?: string;\n highlight: string;\n after?: string;\n markerColor?: string;\n baseColor?: string;\n highlightedTextColor?: string;\n fontSize?: number;\n fontWeight?: number;\n speed?: number;\n className?: string;\n}\n\nfunction MarkerHighlightBase({\n before = \"\",\n highlight,\n after = \"\",\n markerColor = \"#facc15\",\n baseColor = \"#171717\",\n highlightedTextColor = \"#171717\",\n fontSize = 72,\n fontWeight = 600,\n speed = 1,\n className,\n}: MarkerHighlightProps) {\n const frame = useCurrentFrame() * speed;\n const { fps } = useVideoConfig();\n\n const markerScale = spring({\n frame: frame - 15,\n fps,\n config: { damping: 14 },\n });\n\n const textColor = interpolateColors(\n interpolate(markerScale, [0.5, 0.8], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n }),\n [0, 1],\n [baseColor, highlightedTextColor],\n );\n\n return (\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n background: \"white\",\n }}\n >\n <span\n className={className}\n style={{\n fontSize,\n fontWeight,\n color: baseColor,\n letterSpacing: \"-0.03em\",\n fontFamily:\n \"var(--font-geist-sans), -apple-system, BlinkMacSystemFont, sans-serif\",\n }}\n >\n {before}\n <span style={{ position: \"relative\", display: \"inline-block\" }}>\n <span\n aria-hidden\n style={{\n position: \"absolute\",\n inset: \"0 -0.1em\",\n background: markerColor,\n transformOrigin: \"left center\",\n scale: `${markerScale} 1`,\n zIndex: 0,\n }}\n />\n <span style={{ position: \"relative\", zIndex: 1, color: textColor }}>\n {highlight}\n </span>\n </span>\n {after}\n </span>\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n before: {\n type: \"text-content\",\n default: \"Made for \",\n description: \"Before\",\n },\n highlight: {\n type: \"text-content\",\n default: \"builders\",\n description: \"Highlight\",\n },\n after: {\n type: \"text-content\",\n default: \".\",\n description: \"After\",\n },\n markerColor: {\n type: \"color\",\n default: \"#facc15\",\n description: \"Marker color\",\n },\n baseColor: {\n type: \"color\",\n default: \"#171717\",\n description: \"Base color\",\n },\n highlightedTextColor: {\n type: \"color\",\n default: \"#171717\",\n description: \"Highlighted text color\",\n },\n fontSize: {\n type: \"number\",\n min: 12,\n max: 160,\n step: 1,\n default: 72,\n description: \"Font size\",\n hiddenFromList: false,\n },\n fontWeight: {\n type: \"enum\",\n default: \"600\",\n variants: {\n \"400\": {},\n \"500\": {},\n \"600\": {},\n \"700\": {},\n },\n description: \"Font weight\",\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 340,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 100,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"before\",\"highlight\",\"after\",\"markerColor\",\"baseColor\",\"highlightedTextColor\",\"fontSize\",\"fontWeight\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n before: \"Made for \",\n highlight: \"builders\",\n after: \".\",\n markerColor: \"#facc15\",\n baseColor: \"#171717\",\n highlightedTextColor: \"#171717\",\n fontSize: 72,\n fontWeight: \"600\",\n speed: 1,\n};\n\ntype MarkerHighlightElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof MarkerHighlightBase>;\n\nconst MarkerHighlightInner = forwardRef<\n HTMLDivElement,\n MarkerHighlightElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 340, height = 100, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<MarkerHighlight>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <MarkerHighlightBase\n {...(componentProps as unknown as ComponentProps<typeof MarkerHighlightBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const MarkerHighlight = Interactive.withSchema({\n Component: MarkerHighlightInner,\n componentName: \"<MarkerHighlight>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/mask-reveal-up.json b/registry-artifacts/elements/mask-reveal-up.jsonindex 886ec035..b8bec7c2 100644--- a/registry-artifacts/elements/mask-reveal-up.json+++ b/registry-artifacts/elements/mask-reveal-up.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [],"dimensions": {"width": 640,@@ -9,6 +10,7 @@},"displayName": "Mask Reveal Up","durationInFrames": 90,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "mask-reveal-up","sourceCode": "import { Easing, Interactive, Sequence, interpolate, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface MaskRevealUpProps {\n text: string;\n distance?: number;\n fontSize?: number;\n color?: string;\n fontWeight?: number;\n speed?: number;\n className?: string;\n}\n\nfunction MaskRevealUpBase({\n text,\n distance = 30,\n fontSize = 72,\n color = \"#171717\",\n fontWeight = 600,\n speed = 1,\n className,\n}: MaskRevealUpProps) {\n const frame = useCurrentFrame() * speed;\n const { durationInFrames } = useVideoConfig();\n\n const lines = text.split(\"\\n\");\n\n const enterDur = 23;\n const enterTravel = 11;\n const exitDur = 16;\n const exitTravelFrom = 8;\n const enterStagger = 3;\n const exitStagger = 2;\n\n const enterEasing = Easing.bezier(0.22, 1, 0.36, 1);\n const exitEasing = Easing.bezier(0.64, 0, 0.78, 0);\n\n const enterEnd = enterDur + (lines.length - 1) * enterStagger;\n const exitStart = Math.max(\n enterEnd,\n durationInFrames - exitDur - (lines.length - 1) * exitStagger,\n );\n\n return (\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n background: \"transparent\",\n }}\n >\n <span\n className={className}\n style={{\n fontSize,\n fontWeight,\n color,\n letterSpacing: \"-0.03em\",\n lineHeight: 1.1,\n textAlign: \"center\",\n fontFamily:\n \"var(--font-geist-sans), -apple-system, BlinkMacSystemFont, sans-serif\",\n }}\n >\n {lines.map((line, i) => {\n const enterLocal = frame - i * enterStagger;\n const exitLocal = frame - exitStart - i * exitStagger;\n\n const enterP = interpolate(enterLocal, [0, enterDur], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: enterEasing,\n });\n\n const exitP = interpolate(exitLocal, [0, exitDur], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: exitEasing,\n });\n\n const opacity = enterP * (1 - exitP);\n\n const yEnter = interpolate(\n enterLocal,\n [0, enterTravel],\n [distance, 0],\n {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: enterEasing,\n },\n );\n\n const yExit = interpolate(\n exitLocal,\n [exitTravelFrom, exitDur],\n [0, -22],\n {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: exitEasing,\n },\n );\n\n const y = yEnter + yExit;\n\n const blurEnter = interpolate(enterLocal, [0, enterDur], [6, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: enterEasing,\n });\n\n const blurExit = interpolate(exitLocal, [0, exitDur], [0, 6], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: exitEasing,\n });\n\n const blur = blurEnter + blurExit;\n\n return (\n <span\n key={i}\n style={{\n display: \"block\",\n transformOrigin: \"50% 50%\",\n opacity,\n translate: `0 ${y}px`,\n filter: `blur(${blur}px)`,\n }}\n >\n {line}\n </span>\n );\n })}\n </span>\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n text: {\n type: \"text-content\",\n default: \"Designed to move.\\nBuilt to focus.\",\n description: \"Text\",\n },\n distance: {\n type: \"number\",\n min: 0,\n max: 120,\n step: 1,\n default: 30,\n description: \"Distance\",\n hiddenFromList: false,\n },\n fontSize: {\n type: \"number\",\n min: 12,\n max: 160,\n step: 1,\n default: 72,\n description: \"Font size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n fontWeight: {\n type: \"enum\",\n default: \"600\",\n variants: {\n \"400\": {},\n \"500\": {},\n \"600\": {},\n \"700\": {},\n },\n description: \"Font weight\",\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 640,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 200,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"text\",\"distance\",\"fontSize\",\"color\",\"fontWeight\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n text: \"Designed to move.\\nBuilt to focus.\",\n distance: 30,\n fontSize: 72,\n color: \"#171717\",\n fontWeight: \"600\",\n speed: 1,\n};\n\ntype MaskRevealUpElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof MaskRevealUpBase>;\n\nconst MaskRevealUpInner = forwardRef<\n HTMLDivElement,\n MaskRevealUpElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 640, height = 200, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<MaskRevealUp>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <MaskRevealUpBase\n {...(componentProps as unknown as ComponentProps<typeof MaskRevealUpBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const MaskRevealUp = Interactive.withSchema({\n Component: MaskRevealUpInner,\n componentName: \"<MaskRevealUp>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/matrix-decode.json b/registry-artifacts/elements/matrix-decode.jsonindex 005e77a1..082e0e90 100644--- a/registry-artifacts/elements/matrix-decode.json+++ b/registry-artifacts/elements/matrix-decode.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [],"dimensions": {"width": 340,@@ -9,6 +10,7 @@},"displayName": "Matrix Decode","durationInFrames": 90,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "matrix-decode","sourceCode": "import { Interactive, Sequence, random, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface MatrixDecodeProps {\n text: string;\n charset?: string;\n fontSize?: number;\n color?: string;\n fontWeight?: number;\n revealDuration?: number;\n speed?: number;\n className?: string;\n}\n\nfunction MatrixDecodeBase({\n text,\n charset = \"!@#$%^&*()_+-=<>?/\\\\|\",\n fontSize = 72,\n color = \"#22c55e\",\n fontWeight = 600,\n revealDuration = 60,\n speed = 1,\n className,\n}: MatrixDecodeProps) {\n const frame = useCurrentFrame() * speed;\n // useVideoConfig kept for consistency with sibling primitives\n useVideoConfig();\n\n let output = \"\";\n for (let i = 0; i < text.length; i++) {\n const revealFrame = (i / Math.max(text.length, 1)) * revealDuration;\n if (text[i] === \" \") {\n output += \" \";\n } else if (frame >= revealFrame) {\n output += text[i];\n } else {\n const r = random(`${i}-${Math.floor(frame / 2)}`);\n const ch = charset[Math.floor(r * charset.length)];\n output += ch;\n }\n }\n\n return (\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n background: \"white\",\n }}\n >\n <span\n className={className}\n style={{\n fontSize,\n fontWeight,\n color,\n letterSpacing: \"0.05em\",\n whiteSpace: \"pre\",\n fontFamily:\n \"var(--font-geist-mono), ui-monospace, SFMono-Regular, Menlo, monospace\",\n }}\n >\n {output}\n </span>\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n text: {\n type: \"text-content\",\n default: \"DECRYPTED\",\n description: \"Text\",\n },\n charset: {\n type: \"text-content\",\n default: \"!@#$%^&*()_+-=<>?/\\\\|\",\n description: \"Charset\",\n },\n fontSize: {\n type: \"number\",\n min: 12,\n max: 160,\n step: 1,\n default: 72,\n description: \"Font size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#22c55e\",\n description: \"Color\",\n },\n fontWeight: {\n type: \"enum\",\n default: \"600\",\n variants: {\n \"400\": {},\n \"500\": {},\n \"600\": {},\n \"700\": {},\n },\n description: \"Font weight\",\n },\n revealDuration: {\n type: \"number\",\n min: 10,\n max: 240,\n step: 1,\n default: 60,\n description: \"Reveal duration\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 340,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 100,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"text\",\"charset\",\"fontSize\",\"color\",\"fontWeight\",\"revealDuration\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n text: \"DECRYPTED\",\n charset: \"!@#$%^&*()_+-=<>?/\\\\|\",\n fontSize: 72,\n color: \"#22c55e\",\n fontWeight: \"600\",\n revealDuration: 60,\n speed: 1,\n};\n\ntype MatrixDecodeElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof MatrixDecodeBase>;\n\nconst MatrixDecodeInner = forwardRef<\n HTMLDivElement,\n MatrixDecodeElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 340, height = 100, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<MatrixDecode>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <MatrixDecodeBase\n {...(componentProps as unknown as ComponentProps<typeof MatrixDecodeBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const MatrixDecode = Interactive.withSchema({\n Component: MatrixDecodeInner,\n componentName: \"<MatrixDecode>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/micro-scale-fade.json b/registry-artifacts/elements/micro-scale-fade.jsonindex 910fe75c..63d86b47 100644--- a/registry-artifacts/elements/micro-scale-fade.json+++ b/registry-artifacts/elements/micro-scale-fade.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [],"dimensions": {"width": 680,@@ -9,6 +10,7 @@},"displayName": "Micro Scale Fade","durationInFrames": 60,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "micro-scale-fade","sourceCode": "import { Easing, Interactive, Sequence, interpolate, useCurrentFrame, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface MicroScaleFadeProps {\n text: string;\n scaleFrom?: number;\n fontSize?: number;\n color?: string;\n fontWeight?: number;\n speed?: number;\n className?: string;\n}\n\nfunction MicroScaleFadeBase({\n text,\n scaleFrom = 0.96,\n fontSize = 72,\n color = \"#171717\",\n fontWeight = 600,\n speed = 1,\n className,\n}: MicroScaleFadeProps) {\n const frame = useCurrentFrame() * speed;\n const easing = Easing.bezier(0.32, 0.72, 0, 1);\n\n const opacity = interpolate(frame, [0, 18], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing,\n });\n\n const scale = interpolate(frame, [0, 18], [scaleFrom, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing,\n });\n\n return (\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n background: \"transparent\",\n }}\n >\n <span\n className={className}\n style={{\n fontSize,\n fontWeight,\n color,\n letterSpacing: \"-0.03em\",\n fontFamily:\n \"var(--font-geist-sans), -apple-system, BlinkMacSystemFont, sans-serif\",\n display: \"inline-block\",\n transformOrigin: \"50% 50%\",\n opacity,\n scale: `${scale}`,\n }}\n >\n {text}\n </span>\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n text: {\n type: \"text-content\",\n default: \"Welcome to motion.\",\n description: \"Text\",\n },\n scaleFrom: {\n type: \"number\",\n min: 0.8,\n max: 1,\n step: 0.01,\n default: 0.96,\n description: \"Scale from\",\n hiddenFromList: false,\n },\n fontSize: {\n type: \"number\",\n min: 12,\n max: 160,\n step: 1,\n default: 72,\n description: \"Font size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n fontWeight: {\n type: \"enum\",\n default: \"600\",\n variants: {\n \"400\": {},\n \"500\": {},\n \"600\": {},\n \"700\": {},\n },\n description: \"Font weight\",\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 680,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 100,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"text\",\"scaleFrom\",\"fontSize\",\"color\",\"fontWeight\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n text: \"Welcome to motion.\",\n scaleFrom: 0.96,\n fontSize: 72,\n color: \"#171717\",\n fontWeight: \"600\",\n speed: 1,\n};\n\ntype MicroScaleFadeElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof MicroScaleFadeBase>;\n\nconst MicroScaleFadeInner = forwardRef<\n HTMLDivElement,\n MicroScaleFadeElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 680, height = 100, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<MicroScaleFade>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <MicroScaleFadeBase\n {...(componentProps as unknown as ComponentProps<typeof MicroScaleFadeBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const MicroScaleFade = Interactive.withSchema({\n Component: MicroScaleFadeInner,\n componentName: \"<MicroScaleFade>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/mondrian-split.json b/registry-artifacts/elements/mondrian-split.jsonindex 02b75bce..4479226c 100644--- a/registry-artifacts/elements/mondrian-split.json+++ b/registry-artifacts/elements/mondrian-split.json@@ -2,10 +2,12 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [],"dimensions": null,"displayName": "Mondrian Split","durationInFrames": 133,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "mondrian-split","sourceCode": "import { forwardRef, useImperativeHandle, useMemo, useRef, type CSSProperties, type ComponentProps, type ReactNode } from \"react\";\nimport { Easing, Interactive, Sequence, random, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\n\ntype MondrianSplitAxis = \"x\" | \"y\";\ntype MondrianSplitSlot = \"red\" | \"yellow\" | \"blue\";\ntype MondrianSplitSide = \"left\" | \"top\" | \"right\" | \"bottom\";\n\ninterface MondrianSplitProps {\n children?: ReactNode;\n seed?: number;\n splits?: number;\n lineWeight?: number;\n expandCell?: number;\n lineColor?: string;\n redColor?: string;\n yellowColor?: string;\n blueColor?: string;\n fieldColor?: string;\n speed?: number;\n className?: string;\n}\n\ntype MondrianSplitOptions = Pick<\n MondrianSplitProps,\n \"seed\" | \"splits\" | \"lineWeight\" | \"expandCell\"\n> & {\n width?: number;\n height?: number;\n};\n\ninterface MondrianSplitBox {\n x0: number;\n y0: number;\n x1: number;\n y1: number;\n}\n\ninterface MondrianSplitRect {\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\ninterface GridNode {\n box: MondrianSplitBox;\n bounds: Record<MondrianSplitSide, number>;\n line: number;\n}\n\ninterface GridCut {\n axis: MondrianSplitAxis;\n position: number;\n node: number;\n}\n\ninterface GridMove {\n track: number;\n from: number;\n to: number;\n start: number;\n}\n\ninterface GridWipe {\n axis: MondrianSplitAxis;\n fromEnd: boolean;\n}\n\nconst mondrianSplitDefaults = {\n seed: 7,\n splits: 7,\n lineWeight: 14,\n expandCell: 0,\n lineColor: \"#121212\",\n redColor: \"#d62d20\",\n yellowColor: \"#f4c20d\",\n blueColor: \"#1f4e9e\",\n fieldColor: \"#d62d20\",\n};\n\nconst LINE_START = 3;\nconst LINE_GAP = 5;\nconst LINE_DRAW = 10;\nconst FILL_LAG = 7;\nconst FILL_GAP = 4;\nconst FILL_WIPE = 9;\nconst FIELD_LAG = 6;\nconst FIELD_WIPE = 12;\nconst HOLD = 14;\nconst TRACK_COUNT = 3;\nconst TRACK_GAP = 5;\nconst TRACK_SLIDE = 20;\nconst EXPAND_LEAD = 4;\nconst SIDE_GAP = 3;\nconst SIDE_PUSH = 22;\nconst TAIL = 12;\nconst SLIDE_PEAK = 0.72;\nconst SLIDE_OVER = 0.035;\nconst RESERVE = 0.045;\nconst WIND = 0.22;\nconst DIP = 0.035;\nconst DIP_SHARE = 0.2;\nconst SIDES: MondrianSplitSide[] = [\"left\", \"top\", \"right\", \"bottom\"];\nconst SLOTS: MondrianSplitSlot[] = [\"blue\", \"yellow\", \"red\", \"blue\", \"yellow\"];\nconst FALLBACK_CUTS = [0.38, 0.62, 0.3, 0.7, 0.5];\n\nconst drawEase = Easing.bezier(0.16, 1, 0.3, 1);\nconst wipeEase = Easing.bezier(0.7, 0, 0.2, 1);\nconst riseEase = Easing.bezier(0.65, 0, 0.3, 1);\nconst settleEase = Easing.bezier(0.4, 0, 0.6, 1);\nconst windEase = Easing.bezier(0.45, 0, 0.55, 1);\nconst pushEase = Easing.poly(2.5);\nconst layer: CSSProperties = { position: \"absolute\", inset: 0 };\n\nconst finite = (value: number, fallback: number) =>\n Number.isFinite(value) ? value : fallback;\nconst clamp = (value: number, min: number, max: number) =>\n Math.min(max, Math.max(min, value));\nconst mix = (from: number, to: number, amount: number) =>\n from + (to - from) * amount;\nconst progress = (time: number, start: number, duration: number) =>\n clamp((time - start) / duration, 0, 1);\nconst other = (axis: MondrianSplitAxis): MondrianSplitAxis =>\n axis === \"x\" ? \"y\" : \"x\";\nconst lowEdge = (box: MondrianSplitBox, axis: MondrianSplitAxis) =>\n axis === \"x\" ? box.x0 : box.y0;\nconst extent = (box: MondrianSplitBox, axis: MondrianSplitAxis) =>\n axis === \"x\" ? box.x1 - box.x0 : box.y1 - box.y0;\nconst area = (box: MondrianSplitBox) => extent(box, \"x\") * extent(box, \"y\");\nconst splitCount = (splits: number) =>\n Math.round(clamp(finite(splits, mondrianSplitDefaults.splits), 3, 12));\nconst coloredCount = (count: number) => clamp(Math.round(count * 0.3), 1, 5);\n\nconst touches = (a: MondrianSplitBox, b: MondrianSplitBox) => {\n const overlapX = Math.min(a.x1, b.x1) - Math.max(a.x0, b.x0);\n const overlapY = Math.min(a.y1, b.y1) - Math.max(a.y0, b.y0);\n const beside = Math.abs(a.x1 - b.x0) < 0.5 || Math.abs(b.x1 - a.x0) < 0.5;\n const stacked = Math.abs(a.y1 - b.y0) < 0.5 || Math.abs(b.y1 - a.y0) < 0.5;\n return (beside && overlapY > 0.5) || (stacked && overlapX > 0.5);\n};\n\nconst choose = (weights: readonly number[], roll: number) => {\n let remaining = roll * weights.reduce((sum, value) => sum + value, 0);\n for (let index = 0; index < weights.length; index++) {\n remaining -= weights[index];\n if (remaining <= 0) return index;\n }\n return weights.length - 1;\n};\n\nconst slide = (amount: number) => {\n if (amount >= 1) return 1;\n if (amount <= SLIDE_PEAK) {\n return (1 + SLIDE_OVER) * riseEase(amount / SLIDE_PEAK);\n }\n const settle = settleEase((amount - SLIDE_PEAK) / (1 - SLIDE_PEAK));\n return mix(1 + SLIDE_OVER, 1, settle);\n};\n\nconst push = (amount: number, dip: number) => {\n if (amount >= 1) return 1;\n if (amount <= 0) return 0;\n if (amount < WIND) return -dip * windEase(amount / WIND);\n return mix(-dip, 1, pushEase((amount - WIND) / (1 - WIND)));\n};\n\nconst stretch = (\n from0: number,\n from1: number,\n to0: number,\n to1: number,\n min: number,\n max: number,\n) => {\n if (from0 === to0 && from1 === to1) return (value: number) => value;\n return (value: number) => {\n if (value <= from0) {\n return min + (value - min) * ((to0 - min) / (from0 - min));\n }\n if (value >= from1) {\n return max - (max - value) * ((max - to1) / (max - from1));\n }\n return to0 + (value - from0) * ((to1 - to0) / (from1 - from0));\n };\n};\n\nconst wipe = (\n box: MondrianSplitBox,\n { axis, fromEnd }: GridWipe,\n amount: number,\n): MondrianSplitRect => {\n const width = box.x1 - box.x0;\n const height = box.y1 - box.y0;\n if (axis === \"x\") {\n const span = width * amount;\n return {\n x: fromEnd ? box.x1 - span : box.x0,\n y: box.y0,\n width: span,\n height,\n };\n }\n const span = height * amount;\n return {\n x: box.x0,\n y: fromEnd ? box.y1 - span : box.y0,\n width,\n height: span,\n };\n};\n\nconst inFrame = (rect: MondrianSplitRect, width: number, height: number) =>\n rect.width > 0.01 &&\n rect.height > 0.01 &&\n rect.x < width &&\n rect.y < height &&\n rect.x + rect.width > 0 &&\n rect.y + rect.height > 0;\n\nconst placeBoxes = (\n cuts: readonly Pick<GridCut, \"axis\" | \"node\">[],\n positions: readonly number[],\n width: number,\n height: number,\n) => {\n const boxes: MondrianSplitBox[] = [{ x0: 0, y0: 0, x1: width, y1: height }];\n for (let id = 0; id < cuts.length; id++) {\n const { axis, node } = cuts[id];\n const box = boxes[node];\n const at = positions[id];\n boxes.push(\n axis === \"x\" ? { ...box, x1: at } : { ...box, y1: at },\n axis === \"x\" ? { ...box, x0: at } : { ...box, y0: at },\n );\n }\n return boxes;\n};\n\nconst percent = (value: number, size: number) =>\n `${(clamp(value / size, 0, 1) * 100).toFixed(4)}%`;\n\nfunction getMondrianSplitTimeline({\n splits = mondrianSplitDefaults.splits,\n}: Pick<MondrianSplitProps, \"splits\"> = {}) {\n const count = splitCount(splits);\n const fill = LINE_START + (count - 1) * LINE_GAP + FILL_LAG;\n const field = fill + (coloredCount(count) - 1) * FILL_GAP + FIELD_LAG;\n const reflow = field + FIELD_WIPE + HOLD;\n const settled = reflow + (TRACK_COUNT - 1) * TRACK_GAP + TRACK_SLIDE;\n const expand = settled - EXPAND_LEAD;\n const end = expand + (SIDES.length - 1) * SIDE_GAP + SIDE_PUSH;\n return { lines: LINE_START, fill, field, reflow, expand, end };\n}\n\nconst mondrianSplitLength = getMondrianSplitTimeline().end;\n\nfunction getMondrianSplitDuration({\n speed = 1,\n splits = mondrianSplitDefaults.splits,\n}: Pick<MondrianSplitProps, \"speed\" | \"splits\"> = {}) {\n const rate = Math.max(0, finite(speed, 1));\n const frames = getMondrianSplitTimeline({ splits }).end + TAIL;\n return rate === 0 ? 1 : Math.max(1, Math.ceil(frames / rate));\n}\n\nfunction getMondrianSplitLayout({\n seed = mondrianSplitDefaults.seed,\n splits = mondrianSplitDefaults.splits,\n lineWeight = mondrianSplitDefaults.lineWeight,\n expandCell = mondrianSplitDefaults.expandCell,\n width = 1280,\n height = 720,\n}: MondrianSplitOptions = {}) {\n const w = Math.max(1, finite(width, 1280));\n const h = Math.max(1, finite(height, 720));\n const short = Math.min(w, h);\n const weight = clamp(finite(lineWeight, 14), 2, 48) * (short / 720);\n const count = splitCount(splits);\n const timeline = getMondrianSplitTimeline({ splits: count });\n const salt = Math.round(finite(seed, mondrianSplitDefaults.seed));\n const roll = (name: string) => random(`mondrian-split-${salt}-${name}`);\n const minSide = Math.max(short * 0.1, weight * 3);\n const snap = short * 0.045;\n const align = short * 0.075;\n const gap = Math.max(short * 0.07, weight * 2.5);\n const minMove = short * 0.06;\n const overscan = weight + short * 0.04;\n const nodes: GridNode[] = [\n {\n box: { x0: 0, y0: 0, x1: w, y1: h },\n bounds: { left: -1, top: -1, right: -1, bottom: -1 },\n line: -1,\n },\n ];\n const cuts: GridCut[] = [];\n\n const lean = (\n box: MondrianSplitBox,\n ratio: number,\n name: string,\n ): MondrianSplitAxis => {\n const wide = extent(box, \"x\");\n const tall = extent(box, \"y\");\n if (wide > tall * ratio) return \"x\";\n if (tall > wide * ratio) return \"y\";\n return roll(name) < 0.5 ? \"x\" : \"y\";\n };\n\n const cut = (node: number, axis: MondrianSplitAxis, position: number) => {\n const id = cuts.length;\n const { box, bounds: edges } = nodes[node];\n const vertical = axis === \"x\";\n nodes[node].line = id;\n cuts.push({ axis, position, node });\n nodes.push(\n {\n box: vertical ? { ...box, x1: position } : { ...box, y1: position },\n bounds: vertical ? { ...edges, right: id } : { ...edges, bottom: id },\n line: -1,\n },\n {\n box: vertical ? { ...box, x0: position } : { ...box, y0: position },\n bounds: vertical ? { ...edges, left: id } : { ...edges, top: id },\n line: -1,\n },\n );\n };\n\n const snapTo = (axis: MondrianSplitAxis, position: number) => {\n let best = position;\n let distance = snap;\n for (const line of cuts) {\n const offset = Math.abs(line.position - position);\n if (line.axis === axis && offset < distance) {\n best = line.position;\n distance = offset;\n }\n }\n return best;\n };\n\n const nearMiss = (axis: MondrianSplitAxis, position: number) =>\n cuts.some(\n (line) =>\n line.axis === axis &&\n line.position !== position &&\n Math.abs(line.position - position) < snap,\n );\n\n const tryCut = (\n node: number,\n axis: MondrianSplitAxis,\n fraction: number,\n strict: boolean,\n ) => {\n const { box } = nodes[node];\n const low = lowEdge(box, axis);\n const length = extent(box, axis);\n if (length < minSide * 2) return false;\n const position = clamp(\n snapTo(axis, low + length * fraction),\n low + minSide,\n low + length - minSide,\n );\n if (strict && nearMiss(axis, position)) return false;\n cut(node, axis, position);\n return true;\n };\n\n let anchor = -1;\n const longAxis = lean(nodes[0].box, 1.05, \"square\");\n const rootAxis = roll(\"root-axis\") < 0.75 ? longAxis : other(longAxis);\n const rootFraction =\n roll(\"root-side\") < 0.5\n ? mix(0.3, 0.4, roll(\"root-at\"))\n : mix(0.6, 0.7, roll(\"root-at\"));\n if (tryCut(0, rootAxis, rootFraction, false)) {\n const share = mix(0.6, 0.76, roll(\"anchor-at\"));\n const anchorLow = roll(\"anchor-side\") < 0.5;\n const big = rootFraction < 0.5 ? 2 : 1;\n if (tryCut(big, other(rootAxis), anchorLow ? share : 1 - share, false)) {\n anchor = anchorLow ? nodes.length - 2 : nodes.length - 1;\n }\n }\n\n const splittable = (index: number) => {\n const { box, line } = nodes[index];\n return (\n line === -1 &&\n index !== anchor &&\n Math.max(extent(box, \"x\"), extent(box, \"y\")) >= minSide * 2\n );\n };\n\n const budget = count * 24;\n for (let attempt = 0; cuts.length < count && attempt < budget; attempt++) {\n const tag = `${cuts.length}-${attempt}`;\n const pool = nodes.flatMap((_, index) =>\n splittable(index) ? [index] : [],\n );\n if (pool.length === 0) break;\n const weights = pool.map((index) => area(nodes[index].box) ** 1.2);\n const node = pool[choose(weights, roll(`${tag}-cell`))];\n const { box } = nodes[node];\n const preferred = lean(box, 1.25, `${tag}-axis`);\n const fits = extent(box, preferred) >= minSide * 2;\n const at = roll(`${tag}-at`);\n const fraction = at < 0.5 ? 0.28 + at * 0.34 : 0.55 + (at - 0.5) * 0.34;\n tryCut(node, fits ? preferred : other(preferred), fraction, true);\n }\n\n const byPriority = (a: number, b: number) =>\n Number(a === anchor) - Number(b === anchor) ||\n area(nodes[b].box) - area(nodes[a].box);\n const fallback = () => {\n const pool = nodes.flatMap((node, index) =>\n node.line === -1 ? [index] : [],\n );\n pool.sort(byPriority);\n for (const strict of [true, false]) {\n for (const node of pool) {\n const { box } = nodes[node];\n const first: MondrianSplitAxis =\n extent(box, \"x\") >= extent(box, \"y\") ? \"x\" : \"y\";\n for (const axis of [first, other(first)]) {\n for (const fraction of FALLBACK_CUTS) {\n if (tryCut(node, axis, fraction, strict)) return true;\n }\n }\n }\n }\n return false;\n };\n while (cuts.length < count) {\n if (!fallback()) break;\n }\n\n const trackKeys: string[] = [];\n const lines = cuts.map((draft, id) => {\n const key = `${draft.axis}:${draft.position}`;\n if (!trackKeys.includes(key)) trackKeys.push(key);\n const { bounds } = nodes[draft.node];\n const vertical = draft.axis === \"x\";\n const near = vertical ? bounds.top : bounds.left;\n const far = vertical ? bounds.bottom : bounds.right;\n return {\n id,\n axis: draft.axis,\n position: draft.position,\n node: draft.node,\n track: trackKeys.indexOf(key),\n lowBound: vertical ? bounds.left : bounds.top,\n highBound: vertical ? bounds.right : bounds.bottom,\n fromEnd: near === far ? roll(`draw-${id}`) < 0.5 : far < near,\n start: LINE_START + id * LINE_GAP,\n };\n });\n\n const leaves = nodes.flatMap((node, index) =>\n node.line === -1 ? [index] : [],\n );\n const ranked = [...leaves].sort(\n (a, b) => area(nodes[b].box) - area(nodes[a].box) || a - b,\n );\n const pick = clamp(Math.round(finite(expandCell, 0)), 0, ranked.length - 1);\n const target = ranked[pick];\n const targetBox = nodes[target].box;\n\n const others = leaves.filter((index) => index !== target);\n const largest = Math.max(1, ...others.map((index) => area(nodes[index].box)));\n const candidates = others\n .map((index) => ({\n index,\n score:\n roll(`fill-${index}`) +\n (touches(nodes[index].box, targetBox) ? 0.45 : 0) +\n (0.3 * area(nodes[index].box)) / largest,\n }))\n .sort((a, b) => a.score - b.score);\n const painted: { index: number; slot: MondrianSplitSlot }[] = [];\n const quota = Math.min(coloredCount(count), candidates.length);\n for (let order = 0; order < quota; order++) {\n const slot = SLOTS[order];\n const free = candidates.filter(\n ({ index }) => !painted.some((cell) => cell.index === index),\n );\n const clean = free.find(\n ({ index }) =>\n !painted.some(\n (cell) =>\n cell.slot === slot &&\n touches(nodes[cell.index].box, nodes[index].box),\n ) && !(slot === \"red\" && touches(nodes[index].box, targetBox)),\n );\n const choice = clean ?? free[0];\n if (choice) painted.push({ index: choice.index, slot });\n }\n\n const wipeOf = (index: number): GridWipe => {\n const { box } = nodes[index];\n const axis = extent(box, \"x\") >= extent(box, \"y\") ? \"x\" : \"y\";\n const middle = axis === \"x\" ? box.x0 + box.x1 : box.y0 + box.y1;\n return { axis, fromEnd: middle < (axis === \"x\" ? w : h) };\n };\n const diagonal = (index: number) => {\n const { box } = nodes[index];\n return (box.x0 + box.x1) / w + (box.y0 + box.y1) / h;\n };\n const fills = [...painted]\n .sort((a, b) => diagonal(a.index) - diagonal(b.index))\n .map((cell, order) => ({\n node: cell.index,\n slot: cell.slot,\n ...wipeOf(cell.index),\n start: timeline.fill + order * FILL_GAP,\n }));\n const field = { node: target, ...wipeOf(target), start: timeline.field };\n\n const tracks = trackKeys.map((_, track) => {\n const members = lines.filter((line) => line.track === track);\n return {\n track,\n axis: members[0].axis,\n position: members[0].position,\n length: members.reduce(\n (sum, line) => sum + extent(nodes[line.node].box, other(line.axis)),\n 0,\n ),\n };\n });\n const reserveLow = lines.map((line) => line.position);\n const reserveHigh = lines.map((line) => line.position);\n const limits = (track: number) => {\n let low = Number.NEGATIVE_INFINITY;\n let high = Number.POSITIVE_INFINITY;\n for (const line of lines) {\n if (line.track === track) {\n const size = line.axis === \"x\" ? w : h;\n const floor = line.lowBound === -1 ? 0 : reserveHigh[line.lowBound];\n const ceiling =\n line.highBound === -1 ? size : reserveLow[line.highBound];\n low = Math.max(low, floor + gap);\n high = Math.min(high, ceiling - gap);\n } else {\n if (line.lowBound !== -1 && lines[line.lowBound].track === track) {\n high = Math.min(high, reserveLow[line.id] - gap);\n }\n if (line.highBound !== -1 && lines[line.highBound].track === track) {\n low = Math.max(low, reserveHigh[line.id] + gap);\n }\n }\n }\n return { low, high };\n };\n const moves: GridMove[] = [];\n const settledAt = (track: number, position: number) =>\n moves.find((move) => move.track === track)?.to ?? position;\n const borders = (side: MondrianSplitSide, track: number) => {\n const id = nodes[target].bounds[side];\n return id !== -1 && lines[id].track === track;\n };\n const inward = (track: number) => {\n if (borders(\"left\", track) || borders(\"top\", track)) return 1;\n if (borders(\"right\", track) || borders(\"bottom\", track)) return -1;\n return 0;\n };\n const heading = (track: number, down: number, up: number) => {\n const squeeze = inward(track);\n if (squeeze !== 0) {\n return (squeeze > 0 ? up : down) >= minMove ? squeeze : 0;\n }\n if (down < minMove) return up >= minMove ? 1 : 0;\n if (up < minMove) return -1;\n return roll(`track-way-${track}`) < up / (up + down) ? 1 : -1;\n };\n const order = tracks\n .map((track) => ({\n ...track,\n weight: track.length * (0.6 + 0.8 * roll(`track-${track.track}`)),\n }))\n .sort((a, b) => b.weight - a.weight);\n for (const track of order) {\n if (moves.length >= TRACK_COUNT) break;\n const { low, high } = limits(track.track);\n const down = (track.position - low) / (1 + RESERVE);\n const up = (high - track.position) / (1 + RESERVE);\n const direction = heading(track.track, down, up);\n if (direction === 0) continue;\n const span = track.axis === \"x\" ? w : h;\n const room = Math.min(direction > 0 ? up : down, span * 0.2);\n const stride = mix(0.6, 0.95, roll(`track-far-${track.track}`));\n const reach = track.position + direction * Math.max(minMove, room * stride);\n const nearest = tracks\n .filter((rival) => rival.axis === track.axis)\n .filter((rival) => rival.track !== track.track)\n .map((rival) => settledAt(rival.track, rival.position))\n .reduce(\n (best, position) =>\n Math.abs(position - reach) < Math.abs(best - reach) ? position : best,\n Number.POSITIVE_INFINITY,\n );\n const to = Math.abs(nearest - reach) < align ? nearest : reach;\n const margin = Math.abs(to - track.position) * RESERVE;\n if (\n Math.abs(to - track.position) < minMove ||\n to - margin < low ||\n to + margin > high\n ) {\n continue;\n }\n for (const line of lines) {\n if (line.track === track.track) {\n reserveLow[line.id] = Math.min(track.position, to) - margin;\n reserveHigh[line.id] = Math.max(track.position, to) + margin;\n }\n }\n moves.push({\n track: track.track,\n from: track.position,\n to,\n start: timeline.reflow + moves.length * TRACK_GAP,\n });\n }\n\n const settled = lines.map((line) => settledAt(line.track, line.position));\n const home = placeBoxes(lines, settled, w, h)[target];\n const travel: Record<MondrianSplitSide, number> = {\n left: home.x0 + overscan,\n top: home.y0 + overscan,\n right: w + overscan - home.x1,\n bottom: h + overscan - home.y1,\n };\n const ranking = [...SIDES].sort((a, b) => travel[a] - travel[b]);\n const side = (name: MondrianSplitSide) => {\n const across = name === \"left\" || name === \"right\" ? \"x\" : \"y\";\n const share = (extent(home, across) * DIP_SHARE) / travel[name];\n return {\n start: timeline.expand + ranking.indexOf(name) * SIDE_GAP,\n dip: nodes[target].bounds[name] === -1 ? 0 : Math.min(DIP, share),\n };\n };\n\n return {\n width: w,\n height: h,\n weight,\n minSide,\n gap,\n minMove,\n align,\n overscan,\n timeline,\n nodes,\n lines,\n leaves,\n target,\n fills,\n field,\n moves,\n sides: {\n left: side(\"left\"),\n top: side(\"top\"),\n right: side(\"right\"),\n bottom: side(\"bottom\"),\n },\n };\n}\n\ntype MondrianSplitLayout = ReturnType<typeof getMondrianSplitLayout>;\n\nfunction getMondrianSplitState(\n frame: number,\n layout: MondrianSplitLayout = getMondrianSplitLayout(),\n) {\n const time = Math.max(0, finite(frame, 0));\n const { width, height, weight, overscan } = layout;\n const positions = layout.lines.map((line) => {\n const move = layout.moves.find((item) => item.track === line.track);\n if (!move) return line.position;\n const amount = slide(progress(time, move.start, TRACK_SLIDE));\n return line.position + (move.to - move.from) * amount;\n });\n const boxes = placeBoxes(layout.lines, positions, width, height);\n const home = boxes[layout.target];\n const reach = (name: MondrianSplitSide) => {\n const { start, dip } = layout.sides[name];\n return push(progress(time, start, SIDE_PUSH), dip);\n };\n const mapX = stretch(\n home.x0,\n home.x1,\n mix(home.x0, -overscan, reach(\"left\")),\n mix(home.x1, width + overscan, reach(\"right\")),\n -overscan,\n width + overscan,\n );\n const mapY = stretch(\n home.y0,\n home.y1,\n mix(home.y0, -overscan, reach(\"top\")),\n mix(home.y1, height + overscan, reach(\"bottom\")),\n -overscan,\n height + overscan,\n );\n const project = (box: MondrianSplitBox): MondrianSplitBox => ({\n x0: mapX(box.x0),\n y0: mapY(box.y0),\n x1: mapX(box.x1),\n y1: mapY(box.y1),\n });\n\n const lines = layout.lines.flatMap((line) => {\n const drawn = drawEase(progress(time, line.start, LINE_DRAW));\n if (drawn <= 0) return [];\n const box = boxes[line.node];\n const vertical = line.axis === \"x\";\n const low = vertical ? box.y0 : box.x0;\n const high = vertical ? box.y1 : box.x1;\n const along = vertical ? mapY : mapX;\n const start = along(line.fromEnd ? high - (high - low) * drawn : low);\n const end = along(line.fromEnd ? high : low + (high - low) * drawn);\n const position = (vertical ? mapX : mapY)(positions[line.id]);\n const half = weight / 2;\n const length = end - start;\n const rect: MondrianSplitRect = vertical\n ? { x: position - half, y: start, width: weight, height: length }\n : { x: start, y: position - half, width: length, height: weight };\n return inFrame(rect, width, height)\n ? [{ id: line.id, axis: line.axis, position, drawn, ...rect }]\n : [];\n });\n\n const fills = layout.fills.flatMap((fill) => {\n const amount = wipeEase(progress(time, fill.start, FILL_WIPE));\n if (amount <= 0) return [];\n const rect = wipe(project(boxes[fill.node]), fill, amount);\n return inFrame(rect, width, height)\n ? [{ id: fill.node, slot: fill.slot, ...rect }]\n : [];\n });\n\n const reveal = wipeEase(progress(time, layout.field.start, FIELD_WIPE));\n const field = reveal > 0 ? wipe(project(home), layout.field, reveal) : null;\n\n return {\n time,\n lines,\n fills,\n field: field && inFrame(field, width, height) ? field : null,\n cells: layout.leaves.map((id) => ({ id, ...project(boxes[id]) })),\n };\n}\n\ntype MondrianSplitState = ReturnType<typeof getMondrianSplitState>;\n\nfunction getMondrianSplitClip(\n field: MondrianSplitRect | null,\n width: number,\n height: number,\n) {\n if (!field) return \"inset(50%)\";\n const top = percent(field.y, height);\n const right = percent(width - field.x - field.width, width);\n const bottom = percent(height - field.y - field.height, height);\n const left = percent(field.x, width);\n return `inset(${top} ${right} ${bottom} ${left})`;\n}\n\nfunction MondrianSplitBase({\n children,\n seed = mondrianSplitDefaults.seed,\n splits = mondrianSplitDefaults.splits,\n lineWeight = mondrianSplitDefaults.lineWeight,\n expandCell = mondrianSplitDefaults.expandCell,\n lineColor = mondrianSplitDefaults.lineColor,\n redColor = mondrianSplitDefaults.redColor,\n yellowColor = mondrianSplitDefaults.yellowColor,\n blueColor = mondrianSplitDefaults.blueColor,\n fieldColor = mondrianSplitDefaults.fieldColor,\n speed = 1,\n className,\n}: MondrianSplitProps) {\n const frame = useCurrentFrame();\n const { width, height, fps } = useVideoConfig();\n const layout = useMemo(\n () =>\n getMondrianSplitLayout({\n seed,\n splits,\n lineWeight,\n expandCell,\n width,\n height,\n }),\n [seed, splits, lineWeight, expandCell, width, height],\n );\n const time = frame * (30 / fps) * Math.max(0, finite(speed, 1));\n const state = getMondrianSplitState(time, layout);\n const palette: Record<MondrianSplitSlot, string> = {\n red: redColor,\n yellow: yellowColor,\n blue: blueColor,\n };\n const viewBox = `0 0 ${width} ${height}`;\n\n return (\n <div\n className={className}\n style={{ position: \"absolute\", inset: 0, overflow: \"hidden\" }}\n >\n <svg\n width=\"100%\"\n height=\"100%\"\n viewBox={viewBox}\n preserveAspectRatio=\"none\"\n aria-hidden=\"true\"\n style={layer}\n >\n {state.fills.map((fill) => (\n <rect\n key={fill.id}\n x={fill.x}\n y={fill.y}\n width={fill.width}\n height={fill.height}\n fill={palette[fill.slot]}\n />\n ))}\n {state.field ? (\n <rect\n x={state.field.x}\n y={state.field.y}\n width={state.field.width}\n height={state.field.height}\n fill={fieldColor}\n />\n ) : null}\n </svg>\n {children == null ? null : (\n <div\n style={{\n ...layer,\n clipPath: getMondrianSplitClip(state.field, width, height),\n }}\n >\n {children}\n </div>\n )}\n <svg\n width=\"100%\"\n height=\"100%\"\n viewBox={viewBox}\n preserveAspectRatio=\"none\"\n role=\"img\"\n aria-label=\"De Stijl grid\"\n style={layer}\n >\n {state.lines.map((line) => (\n <rect\n key={line.id}\n x={line.x}\n y={line.y}\n width={line.width}\n height={line.height}\n fill={lineColor}\n />\n ))}\n </svg>\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n seed: {\n type: \"number\",\n default: 7,\n min: 1,\n max: 99,\n step: 1,\n description: \"Seed\",\n hiddenFromList: false,\n },\n splits: {\n type: \"number\",\n default: 7,\n min: 3,\n max: 12,\n step: 1,\n description: \"Splits\",\n hiddenFromList: false,\n },\n lineWeight: {\n type: \"number\",\n default: 14,\n min: 4,\n max: 32,\n step: 1,\n description: \"Line weight\",\n hiddenFromList: false,\n },\n expandCell: {\n type: \"number\",\n default: 0,\n min: 0,\n max: 12,\n step: 1,\n description: \"Expanding cell (0 is the largest)\",\n hiddenFromList: false,\n },\n lineColor: {\n type: \"color\",\n default: \"#121212\",\n description: \"Lines\",\n },\n redColor: {\n type: \"color\",\n default: \"#d62d20\",\n description: \"Red\",\n },\n yellowColor: {\n type: \"color\",\n default: \"#f4c20d\",\n description: \"Yellow\",\n },\n blueColor: {\n type: \"color\",\n default: \"#1f4e9e\",\n description: \"Blue\",\n },\n fieldColor: {\n type: \"color\",\n default: \"#d62d20\",\n description: \"Expanding cell color\",\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"seed\",\"splits\",\"lineWeight\",\"expandCell\",\"lineColor\",\"redColor\",\"yellowColor\",\"blueColor\",\"fieldColor\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n seed: 7,\n splits: 7,\n lineWeight: 14,\n expandCell: 0,\n lineColor: \"#121212\",\n redColor: \"#d62d20\",\n yellowColor: \"#f4c20d\",\n blueColor: \"#1f4e9e\",\n fieldColor: \"#d62d20\",\n speed: 1,\n};\n\ntype MondrianSplitElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof MondrianSplitBase>;\n\nconst MondrianSplitInner = forwardRef<\n HTMLDivElement,\n MondrianSplitElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<MondrianSplit>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <MondrianSplitBase\n {...(componentProps as unknown as ComponentProps<typeof MondrianSplitBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const MondrianSplit = Interactive.withSchema({\n Component: MondrianSplitInner,\n componentName: \"<MondrianSplit>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/outline-fill-track-text.json b/registry-artifacts/elements/outline-fill-track-text.jsonindex c0ddec2b..7e04090d 100644--- a/registry-artifacts/elements/outline-fill-track-text.json+++ b/registry-artifacts/elements/outline-fill-track-text.json@@ -2,10 +2,12 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [],"dimensions": null,"displayName": "Outline Fill Track Text","durationInFrames": 80,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "outline-fill-track-text","sourceCode": "import { forwardRef, useImperativeHandle, useMemo, useRef, type ComponentProps } from \"react\";\nimport { Easing, Interactive, Sequence, interpolate, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\n\ninterface OutlineFillTrackTextProps {\n leadText?: string;\n valueText?: string;\n fontSize?: number;\n fontWeight?: number;\n color?: string;\n outlineColor?: string;\n outlineWidth?: number;\n backgroundColor?: string;\n glowColor?: string;\n enterOffset?: number;\n anchorOffsetX?: number;\n trackDistance?: number;\n wordGap?: number;\n endPadding?: number;\n fillDuration?: number;\n speed?: number;\n className?: string;\n}\n\nconst outlineFillTrackTextLength = 80;\n\nconst ENTER_END = 16;\nconst TRACK_START = 16;\nconst TRACK_END = 72;\nconst FILL_START = 34;\nconst FILL_PREFILL = 10;\nconst FONT_FAMILY = \"Arial, Helvetica, sans-serif\";\nconst clamp = {\n extrapolateLeft: \"clamp\" as const,\n extrapolateRight: \"clamp\" as const,\n};\n\nfunction estimateTextWidth(\n text: string,\n fontSize: number,\n fontWeight: number,\n): number {\n if (typeof document === \"undefined\") {\n return text.length * fontSize * 0.56;\n }\n\n const context = document.createElement(\"canvas\").getContext(\"2d\");\n if (!context) return text.length * fontSize * 0.56;\n context.font = `${fontWeight} ${fontSize}px Arial`;\n return context.measureText(text).width;\n}\n\nfunction OutlineFillTrackTextBase({\n leadText = \"Keep\",\n valueText = \"1000000000%\",\n fontSize = 368,\n fontWeight = 700,\n color = \"#f4f3f6\",\n outlineColor = \"#e6e2ed\",\n outlineWidth = 3,\n backgroundColor = \"#030012\",\n glowColor = \"#64109a\",\n enterOffset = 240,\n anchorOffsetX = -84,\n trackDistance = 0,\n wordGap = 220,\n endPadding = 96,\n fillDuration = 38,\n speed = 1,\n className,\n}: OutlineFillTrackTextProps) {\n const frame = useCurrentFrame() * Math.max(speed, 0);\n const { width: compositionWidth } = useVideoConfig();\n const safeFontSize = Math.max(fontSize, 1);\n const safeFontWeight = Math.max(fontWeight, 1);\n const safeOutlineWidth = Math.max(outlineWidth, 0);\n const safeGap = Math.max(wordGap, 0);\n const safeEndPadding = Math.max(endPadding, 0);\n const safeFillDuration = Math.max(fillDuration, 1);\n\n const measurements = useMemo(() => {\n const leadWidth = estimateTextWidth(leadText, safeFontSize, safeFontWeight);\n const valueWidth = estimateTextWidth(\n valueText,\n safeFontSize,\n safeFontWeight,\n );\n return {\n valueWidth,\n distance: leadWidth / 2 + safeGap + valueWidth / 2,\n };\n }, [leadText, safeFontSize, safeFontWeight, safeGap, valueText]);\n\n const valueOffset = trackDistance > 0 ? trackDistance : measurements.distance;\n const anchorX = compositionWidth / 2 + anchorOffsetX;\n const trailingOverflow = Math.max(\n 0,\n anchorX + measurements.valueWidth / 2 - (compositionWidth - safeEndPadding),\n );\n const travelDistance = valueOffset + trailingOverflow;\n const enterProgress = interpolate(frame, [0, ENTER_END], [0, 1], {\n ...clamp,\n easing: Easing.bezier(0.16, 0.84, 0.24, 1),\n });\n const trackProgress = interpolate(frame, [TRACK_START, TRACK_END], [0, 1], {\n ...clamp,\n easing: Easing.bezier(0.42, 0, 0.58, 1),\n });\n const fillProgress = interpolate(\n frame,\n [FILL_START - FILL_PREFILL, FILL_START + safeFillDuration],\n [0, 1],\n clamp,\n );\n const leadY = enterOffset * (1 - enterProgress);\n const revealEdge = enterProgress * 112 - 8;\n const revealSolid = Math.max(0, Math.min(100, revealEdge - 10));\n const revealFade = Math.max(0, Math.min(100, revealEdge + 10));\n const leadMask = `linear-gradient(180deg, #000 0%, #000 ${revealSolid}%, transparent ${revealFade}%, transparent 100%)`;\n const glowOpacity = interpolate(\n enterProgress,\n [0, 0.18, 0.72, 1],\n [0.92, 1, 0.52, 0],\n clamp,\n );\n const fieldY = interpolate(enterProgress, [0, 1], [-42, -210], clamp);\n const textStyle = {\n display: \"block\",\n fontFamily: FONT_FAMILY,\n fontSize: safeFontSize,\n fontWeight: safeFontWeight,\n letterSpacing: 0,\n lineHeight: 0.86,\n whiteSpace: \"nowrap\" as const,\n };\n\n return (\n <div\n className={className}\n style={{\n position: \"absolute\",\n inset: 0,\n overflow: \"hidden\",\n backgroundColor,\n }}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n background: `radial-gradient(ellipse 118% 66% at 50% -12%, ${glowColor} 0%, ${glowColor} 14%, transparent 76%)`,\n filter: `blur(${safeFontSize * 0.15}px)`,\n opacity: glowOpacity,\n pointerEvents: \"none\",\n transform: \"translateZ(0)\",\n }}\n />\n\n <div\n style={{\n position: \"absolute\",\n top: \"50%\",\n left: `calc(50% + ${anchorOffsetX}px)`,\n transform: `translate3d(${-travelDistance * trackProgress}px, -50%, 0)`,\n }}\n >\n <div\n style={{\n position: \"absolute\",\n top: 0,\n left: 0,\n color,\n maskImage: leadMask,\n maskRepeat: \"no-repeat\",\n opacity: 1,\n transform: `translate3d(-50%, calc(-50% + ${leadY}px), 0)`,\n WebkitMaskImage: leadMask,\n WebkitMaskRepeat: \"no-repeat\",\n ...textStyle,\n }}\n >\n {leadText}\n </div>\n\n <div\n style={{\n position: \"absolute\",\n top: 0,\n left: valueOffset,\n transform: \"translate3d(-50%, -50%, 0)\",\n visibility: frame < FILL_START ? \"hidden\" : \"visible\",\n }}\n >\n <span\n style={{\n ...textStyle,\n color: \"transparent\",\n paintOrder: \"stroke fill\",\n WebkitTextStroke: `${safeOutlineWidth}px ${outlineColor}`,\n }}\n >\n {valueText}\n </span>\n <span\n style={{\n ...textStyle,\n position: \"absolute\",\n inset: 0,\n clipPath: `inset(0 ${100 - fillProgress * 100}% 0 0)`,\n color,\n opacity: 1,\n }}\n >\n {valueText}\n </span>\n </div>\n\n <div\n style={{\n position: \"absolute\",\n top: fieldY,\n left: 0,\n width: safeFontSize * 2.8,\n height: safeFontSize * 0.72,\n background: `radial-gradient(ellipse at center, ${backgroundColor} 0%, ${backgroundColor} 18%, transparent 74%)`,\n filter: `blur(${safeFontSize * 0.07}px)`,\n opacity: glowOpacity,\n pointerEvents: \"none\",\n transform: \"translate3d(-50%, -50%, 0)\",\n }}\n />\n </div>\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n leadText: {\n type: \"text-content\",\n default: \"Keep\",\n description: \"Lead text\",\n },\n valueText: {\n type: \"text-content\",\n default: \"1000000000%\",\n description: \"Outlined value\",\n },\n fontSize: {\n type: \"number\",\n min: 120,\n max: 520,\n step: 4,\n default: 368,\n description: \"Font size\",\n hiddenFromList: false,\n },\n enterOffset: {\n type: \"number\",\n min: 0,\n max: 420,\n step: 4,\n default: 240,\n description: \"Vertical entrance offset\",\n hiddenFromList: false,\n },\n anchorOffsetX: {\n type: \"number\",\n min: -400,\n max: 400,\n step: 4,\n default: -84,\n description: \"Shared horizontal anchor offset\",\n hiddenFromList: false,\n },\n trackDistance: {\n type: \"number\",\n min: 0,\n max: 1800,\n step: 10,\n default: 0,\n description: \"Lead-to-value distance override; zero measures the text\",\n hiddenFromList: false,\n },\n wordGap: {\n type: \"number\",\n min: 0,\n max: 500,\n step: 4,\n default: 220,\n description: \"Gap between the lead and value\",\n hiddenFromList: false,\n },\n endPadding: {\n type: \"number\",\n min: 0,\n max: 320,\n step: 4,\n default: 96,\n description: \"Trailing edge padding for long values\",\n hiddenFromList: false,\n },\n fillDuration: {\n type: \"number\",\n min: 8,\n max: 45,\n step: 1,\n default: 38,\n description: \"Fill duration in frames\",\n hiddenFromList: false,\n },\n outlineWidth: {\n type: \"number\",\n min: 0,\n max: 12,\n step: 0.5,\n default: 3,\n description: \"Outline width\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#f4f3f6\",\n description: \"Fill color\",\n },\n outlineColor: {\n type: \"color\",\n default: \"#e6e2ed\",\n description: \"Outline color\",\n },\n backgroundColor: {\n type: \"color\",\n default: \"#030012\",\n description: \"Background color\",\n },\n glowColor: {\n type: \"color\",\n default: \"#64109a\",\n description: \"Entrance glow color\",\n },\n fontWeight: {\n type: \"enum\",\n default: \"700\",\n variants: {\n \"400\": {},\n \"500\": {},\n \"600\": {},\n \"700\": {},\n },\n description: \"Font weight\",\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"leadText\",\"valueText\",\"fontSize\",\"enterOffset\",\"anchorOffsetX\",\"trackDistance\",\"wordGap\",\"endPadding\",\"fillDuration\",\"outlineWidth\",\"color\",\"outlineColor\",\"backgroundColor\",\"glowColor\",\"fontWeight\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n leadText: \"Keep\",\n valueText: \"1000000000%\",\n fontSize: 368,\n enterOffset: 240,\n anchorOffsetX: -84,\n trackDistance: 0,\n wordGap: 220,\n endPadding: 96,\n fillDuration: 38,\n outlineWidth: 3,\n color: \"#f4f3f6\",\n outlineColor: \"#e6e2ed\",\n backgroundColor: \"#030012\",\n glowColor: \"#64109a\",\n fontWeight: \"700\",\n speed: 1,\n};\n\ntype OutlineFillTrackTextElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof OutlineFillTrackTextBase>;\n\nconst OutlineFillTrackTextInner = forwardRef<\n HTMLDivElement,\n OutlineFillTrackTextElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<OutlineFillTrackText>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <OutlineFillTrackTextBase\n {...(componentProps as unknown as ComponentProps<typeof OutlineFillTrackTextBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const OutlineFillTrackText = Interactive.withSchema({\n Component: OutlineFillTrackTextInner,\n componentName: \"<OutlineFillTrackText>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/outline-trace.json b/registry-artifacts/elements/outline-trace.jsonindex 71a79ea3..3fde557e 100644--- a/registry-artifacts/elements/outline-trace.json+++ b/registry-artifacts/elements/outline-trace.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "opentype.js",@@ -11,6 +12,7 @@"dimensions": null,"displayName": "Outline Trace","durationInFrames": 44,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "outline-trace","sourceCode": "import { parse, type Font } from \"opentype.js\";\nimport { forwardRef, useEffect, useId, useImperativeHandle, useRef, useState, type ComponentProps } from \"react\";\nimport { Easing, Interactive, Sequence, continueRender, delayRender, interpolate, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\n\ninterface OutlineTraceProps {\n text?: string;\n fontUrl?: string;\n fontSize?: number;\n color?: string;\n strokeColor?: string;\n strokeWidth?: number;\n stagger?: number;\n fill?: boolean;\n keepStroke?: boolean;\n speed?: number;\n className?: string;\n}\n\n/** Static Inter ExtraBold (800) from Google Fonts. */\nconst interExtraBoldTtf =\n \"https://fonts.gstatic.com/s/inter/v20/UcCO3FwrK3iLTeHuS_nVMrMxCp50SjIw2boKoduKmMEVuDyYMZg.ttf\";\n\nconst outlineTraceDefaults = {\n text: \"Outline\",\n fontUrl: interExtraBoldTtf,\n fontSize: 150,\n color: \"#fafafa\",\n strokeColor: \"\",\n strokeWidth: 2.5,\n stagger: 3,\n fill: true,\n keepStroke: false,\n speed: 1,\n} satisfies Required<Omit<OutlineTraceProps, \"className\">>;\n\n/** Per-letter beats on the 30 fps clock, relative to the letter's start. */\nconst outlineTraceTiming = {\n outer: [0, 18],\n counter: [4, 18],\n fill: [14, 26],\n} as const;\n\nconst CLAMP = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n} as const;\n\nconst easeInOutCubic = Easing.inOut(Easing.cubic);\nconst easeOutCubic = Easing.out(Easing.cubic);\n\nfunction finite(value: number | undefined, fallback: number) {\n return typeof value === \"number\" && Number.isFinite(value) ? value : fallback;\n}\n\n/** Maps a composition frame onto the 30 fps timeline, scaled by `speed`. */\nfunction getOutlineTraceTime(\n frame: number,\n options: { fps?: number; speed?: number } = {},\n) {\n const fps = Math.max(1, finite(options.fps, 30));\n const speed = Math.max(0, finite(options.speed, 1));\n return (Math.max(0, finite(frame, 0)) * 30 * speed) / fps;\n}\n\ninterface OutlineTraceLetterState {\n /** Trim progress of the outer contours, 0..1. */\n outer: number;\n /** Trim progress of the counters, 0..1. */\n counter: number;\n /** Share of the glyph box the fill has risen through, 0..1. */\n fill: number;\n}\n\nfunction getOutlineTraceLetter(\n t: number,\n index: number,\n stagger = outlineTraceDefaults.stagger,\n): OutlineTraceLetterState {\n const u = t - index * Math.max(0, finite(stagger, 3));\n const { outer, counter, fill } = outlineTraceTiming;\n return {\n outer: interpolate(u, [...outer], [0, 1], {\n ...CLAMP,\n easing: easeInOutCubic,\n }),\n counter: interpolate(u, [...counter], [0, 1], {\n ...CLAMP,\n easing: easeInOutCubic,\n }),\n fill: interpolate(u, [...fill], [0, 1], { ...CLAMP, easing: easeOutCubic }),\n };\n}\n\n/** Frame where the last of `count` letters has filled. */\nfunction getOutlineTraceLength(\n count: number,\n stagger = outlineTraceDefaults.stagger,\n) {\n const last = Math.max(0, count - 1) * Math.max(0, finite(stagger, 3));\n return Math.ceil(last + outlineTraceTiming.fill[1]);\n}\n\ninterface PathCommand {\n type: string;\n x?: number;\n y?: number;\n x1?: number;\n y1?: number;\n x2?: number;\n y2?: number;\n}\n\ninterface Box {\n x0: number;\n y0: number;\n x1: number;\n y1: number;\n}\n\ninterface OutlineContour {\n d: string;\n box: Box;\n /** True for a hole inside another contour of the same glyph. */\n counter: boolean;\n}\n\nconst fmt = (n: number) => Number(n.toFixed(2));\n\n/**\n * Splits glyph path commands into closed contours and marks the counters:\n * contours whose box lies inside another contour's box.\n */\nfunction getOutlineContours(commands: readonly PathCommand[]) {\n const raw: { d: string; box: Box }[] = [];\n let d = \"\";\n let box: Box | null = null;\n const grow = (x = 0, y = 0) => {\n if (!box) box = { x0: x, y0: y, x1: x, y1: y };\n else {\n box.x0 = Math.min(box.x0, x);\n box.y0 = Math.min(box.y0, y);\n box.x1 = Math.max(box.x1, x);\n box.y1 = Math.max(box.y1, y);\n }\n };\n const close = () => {\n if (d && box) raw.push({ d: `${d}Z`, box });\n d = \"\";\n box = null;\n };\n for (const c of commands) {\n if (c.type === \"M\") {\n close();\n d = `M${fmt(c.x ?? 0)} ${fmt(c.y ?? 0)}`;\n grow(c.x, c.y);\n } else if (c.type === \"L\") {\n d += `L${fmt(c.x ?? 0)} ${fmt(c.y ?? 0)}`;\n grow(c.x, c.y);\n } else if (c.type === \"Q\") {\n d += `Q${fmt(c.x1 ?? 0)} ${fmt(c.y1 ?? 0)} ${fmt(c.x ?? 0)} ${fmt(c.y ?? 0)}`;\n grow(c.x1, c.y1);\n grow(c.x, c.y);\n } else if (c.type === \"C\") {\n d += `C${fmt(c.x1 ?? 0)} ${fmt(c.y1 ?? 0)} ${fmt(c.x2 ?? 0)} ${fmt(c.y2 ?? 0)} ${fmt(c.x ?? 0)} ${fmt(c.y ?? 0)}`;\n grow(c.x1, c.y1);\n grow(c.x2, c.y2);\n grow(c.x, c.y);\n } else if (c.type === \"Z\") {\n close();\n }\n }\n close();\n const inside = (a: Box, b: Box) =>\n a !== b && a.x0 >= b.x0 && a.y0 >= b.y0 && a.x1 <= b.x1 && a.y1 <= b.y1;\n return raw.map(\n (c): OutlineContour => ({\n ...c,\n counter: raw.some((other) => inside(c.box, other.box)),\n }),\n );\n}\n\ninterface OutlineGlyph {\n contours: OutlineContour[];\n box: Box | null;\n}\n\n/**\n * Lays out `text` in reference px with the baseline at y = 0. Glyphs are\n * looked up per character: full shaping runs GSUB lookups that opentype.js\n * does not support in every font.\n */\nfunction layoutOutlineGlyphs(\n font: Font,\n text: string,\n fontSize: number,\n) {\n const scale = fontSize / font.unitsPerEm;\n const glyphs = Array.from(text).map((char) => font.charToGlyph(char));\n let x = 0;\n const letters: OutlineGlyph[] = glyphs.map((glyph, i) => {\n if (i > 0) x += font.getKerningValue(glyphs[i - 1], glyph) * scale;\n const contours = getOutlineContours(glyph.getPath(x, 0, fontSize).commands);\n x += (glyph.advanceWidth ?? 0) * scale;\n const box = contours.reduce<Box | null>(\n (acc, c) =>\n acc\n ? {\n x0: Math.min(acc.x0, c.box.x0),\n y0: Math.min(acc.y0, c.box.y0),\n x1: Math.max(acc.x1, c.box.x1),\n y1: Math.max(acc.y1, c.box.y1),\n }\n : { ...c.box },\n null,\n );\n return { contours, box };\n });\n const os2 = font.tables.os2 as { sCapHeight?: number } | undefined;\n const capHeight =\n ((os2?.sCapHeight ?? font.unitsPerEm * 0.7) * fontSize) / font.unitsPerEm;\n return { letters, width: x, capHeight };\n}\n\nconst fontCache = new Map<string, Promise<Font>>();\n\nfunction loadOutlineFont(url: string) {\n let pending = fontCache.get(url);\n if (!pending) {\n pending = fetch(url)\n .then((res) => res.arrayBuffer())\n .then((buffer) => parse(buffer));\n fontCache.set(url, pending);\n pending.catch(() => fontCache.delete(url));\n }\n return pending;\n}\n\nfunction useOutlineFont(url: string) {\n const [font, setFont] = useState<Font | null>(null);\n\n useEffect(() => {\n const handle = delayRender(`outline-trace: loading ${url}`);\n let released = false;\n const release = () => {\n if (released) return;\n released = true;\n continueRender(handle);\n };\n loadOutlineFont(url).then((parsed) => {\n if (!released) setFont(parsed);\n release();\n }, release);\n return release;\n }, [url]);\n\n return font;\n}\n\nfunction OutlineTraceBase({\n text = outlineTraceDefaults.text,\n fontUrl = outlineTraceDefaults.fontUrl,\n fontSize = outlineTraceDefaults.fontSize,\n color = outlineTraceDefaults.color,\n strokeColor = outlineTraceDefaults.strokeColor,\n strokeWidth = outlineTraceDefaults.strokeWidth,\n stagger = outlineTraceDefaults.stagger,\n fill = outlineTraceDefaults.fill,\n keepStroke = outlineTraceDefaults.keepStroke,\n speed = outlineTraceDefaults.speed,\n className,\n}: OutlineTraceProps) {\n const frame = useCurrentFrame();\n const { fps, width, height } = useVideoConfig();\n const id = `outline-trace-${useId().replace(/[^a-zA-Z0-9_-]/g, \"\")}`;\n const font = useOutlineFont(fontUrl);\n if (!font) return null;\n\n const unit = height / 720;\n const t = getOutlineTraceTime(frame, { fps, speed });\n const layout = layoutOutlineGlyphs(font, text, fontSize);\n const originX = (width - layout.width * unit) / 2;\n const baseline = (height + layout.capHeight * unit) / 2;\n const stroke = strokeColor || color;\n\n return (\n <div\n className={className}\n style={{ position: \"absolute\", inset: 0, overflow: \"hidden\" }}\n >\n <svg\n width=\"100%\"\n height=\"100%\"\n viewBox={`0 0 ${width} ${height}`}\n style={{ display: \"block\" }}\n >\n <g transform={`translate(${originX} ${baseline}) scale(${unit})`}>\n <filter id={`${id}-erode`}>\n <feMorphology operator=\"erode\" radius={strokeWidth / 2} />\n </filter>\n {layout.letters.map((letter, i) => {\n if (!letter.box) return null;\n const state = getOutlineTraceLetter(t, i, stagger);\n const box = letter.box;\n const tall = box.y1 - box.y0 + 2 * strokeWidth;\n const rise = tall * (fill ? state.fill : 0);\n const strokeOpacity = fill && !keepStroke ? 1 - state.fill : 1;\n const whole = letter.contours.map((c) => c.d).join(\"\");\n const margin = 4 * strokeWidth;\n return (\n <g key={i}>\n {/* Static instances of variable fonts keep overlapping\n contours (the bar of a t crosses its stem). The mask hides\n stroke that runs inside the glyph's filled silhouette. */}\n <mask\n id={`${id}-mask-${i}`}\n maskUnits=\"userSpaceOnUse\"\n x={box.x0 - margin}\n y={box.y0 - margin}\n width={box.x1 - box.x0 + 2 * margin}\n height={box.y1 - box.y0 + 2 * margin}\n >\n <rect\n x={box.x0 - margin}\n y={box.y0 - margin}\n width={box.x1 - box.x0 + 2 * margin}\n height={box.y1 - box.y0 + 2 * margin}\n fill=\"#ffffff\"\n />\n <path d={whole} fill=\"#000000\" filter={`url(#${id}-erode)`} />\n </mask>\n {fill && state.fill > 0 ? (\n <>\n <clipPath id={`${id}-${i}`}>\n <rect\n x={box.x0 - strokeWidth}\n y={box.y1 + strokeWidth - rise}\n width={box.x1 - box.x0 + 2 * strokeWidth}\n height={rise}\n />\n </clipPath>\n <path\n d={whole}\n fill={color}\n clipPath={`url(#${id}-${i})`}\n />\n </>\n ) : null}\n {strokeOpacity > 0 ? (\n <g mask={`url(#${id}-mask-${i})`}>\n {letter.contours.map((contour, k) => {\n const progress = contour.counter\n ? state.counter\n : state.outer;\n if (progress <= 0) return null;\n return (\n <path\n key={k}\n d={contour.d}\n pathLength={1}\n fill=\"none\"\n stroke={stroke}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeDasharray=\"1 1\"\n strokeDashoffset={1 - progress}\n opacity={strokeOpacity}\n />\n );\n })}\n </g>\n ) : null}\n </g>\n );\n })}\n </g>\n </svg>\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n text: {\n type: \"text-content\",\n default: \"Outline\",\n description: \"Text\",\n },\n color: {\n type: \"color\",\n default: \"#111111\",\n description: \"Fill\",\n },\n strokeColor: {\n type: \"color\",\n default: \"#111111\",\n description: \"Stroke\",\n },\n fontSize: {\n type: \"number\",\n default: 150,\n min: 60,\n max: 300,\n step: 2,\n description: \"Font size\",\n hiddenFromList: false,\n },\n strokeWidth: {\n type: \"number\",\n default: 2.5,\n min: 0.5,\n max: 8,\n step: 0.5,\n description: \"Stroke width\",\n hiddenFromList: false,\n },\n stagger: {\n type: \"number\",\n default: 3,\n min: 0,\n max: 12,\n step: 1,\n description: \"Letter stagger\",\n hiddenFromList: false,\n },\n fill: {\n type: \"boolean\",\n default: true,\n description: \"Fill\",\n },\n keepStroke: {\n type: \"boolean\",\n default: false,\n description: \"Keep stroke\",\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"text\",\"color\",\"strokeColor\",\"fontSize\",\"strokeWidth\",\"stagger\",\"fill\",\"keepStroke\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n text: \"Outline\",\n color: \"#111111\",\n strokeColor: \"#111111\",\n fontSize: 150,\n strokeWidth: 2.5,\n stagger: 3,\n fill: true,\n keepStroke: false,\n speed: 1,\n};\n\ntype OutlineTraceElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof OutlineTraceBase>;\n\nconst OutlineTraceInner = forwardRef<\n HTMLDivElement,\n OutlineTraceElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<OutlineTrace>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <OutlineTraceBase\n {...(componentProps as unknown as ComponentProps<typeof OutlineTraceBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const OutlineTrace = Interactive.withSchema({\n Component: OutlineTraceInner,\n componentName: \"<OutlineTrace>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/path-ride.json b/registry-artifacts/elements/path-ride.jsonindex 973b20e3..5c229858 100644--- a/registry-artifacts/elements/path-ride.json+++ b/registry-artifacts/elements/path-ride.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/google-fonts",@@ -15,6 +16,7 @@"dimensions": null,"displayName": "Path Ride","durationInFrames": 70,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "path-ride","sourceCode": "import { loadFont } from \"@remotion/google-fonts/Inter\";\nimport { getLength, getPointAtLength, getTangentAtLength } from \"@remotion/paths\";\nimport { forwardRef, useEffect, useImperativeHandle, useMemo, useRef, useState, type ComponentProps } from \"react\";\nimport { Easing, Interactive, Sequence, continueRender, delayRender, interpolate, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\n\nconst { fontFamily: INTER } = loadFont(\"normal\", {\n weights: [\"100\", \"900\"],\n subsets: [\"latin\"],\n});\n\ninterface PathRideProps {\n text?: string;\n path?: string;\n fontSize?: number;\n fontWeight?: number;\n fontFamily?: string;\n color?: string;\n lineColor?: string;\n lineWidth?: number;\n speed?: number;\n className?: string;\n}\n\n/** An S-curve across a 1280×720 frame. */\nconst pathRideDefaultPath =\n \"M 120 560 C 360 120 560 120 640 360 S 920 600 1160 160\";\n\nconst pathRideDefaults = {\n text: \"Follow the line\",\n path: pathRideDefaultPath,\n fontSize: 44,\n fontWeight: 700,\n fontFamily: INTER,\n color: \"#fafafa\",\n lineColor: \"#D97757\",\n lineWidth: 3,\n speed: 1,\n} satisfies Required<Omit<PathRideProps, \"className\">>;\n\n/** Beats on the 30 fps clock. */\nconst pathRideTiming = {\n draw: [0, 40],\n straighten: [50, 68],\n erase: [52, 70],\n} as const;\n\n/** Gap between the head and the last letter, in em. */\nconst LEAD = 0.3;\n/** Letters fade in over this much arc length, in em. */\nconst FADE_IN = 0.5;\n/** Extra lift of the baseline above the line, in em. */\nconst LIFT = 0.08;\n/** Samples along the path; the line and the letters read positions from them. */\nconst SAMPLES = 400;\nconst MEASURE_SIZE = 100;\n/** Inter's baseline and cap height in a `line-height: 1` box, until measured. */\nconst INTER_METRICS = { baseline: 0.8637, capHeight: 0.7275 };\n\nconst CLAMP = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n} as const;\n\nconst easeInOutCubic = Easing.inOut(Easing.cubic);\n\nfunction finite(value: number | undefined, fallback: number) {\n return typeof value === \"number\" && Number.isFinite(value) ? value : fallback;\n}\n\n/** Maps a composition frame onto the 30 fps timeline, scaled by `speed`. */\nfunction getPathRideTime(\n frame: number,\n options: { fps?: number; speed?: number } = {},\n) {\n const fps = Math.max(1, finite(options.fps, 30));\n const speed = Math.max(0, finite(options.speed, 1));\n return (Math.max(0, finite(frame, 0)) * 30 * speed) / fps;\n}\n\n/** Arc length drawn so far. */\nfunction getPathRideHead(t: number, length: number) {\n return interpolate(t, [...pathRideTiming.draw], [0, length], {\n ...CLAMP,\n easing: easeInOutCubic,\n });\n}\n\n/** Arc length erased from the start. */\nfunction getPathRideTail(t: number, length: number) {\n return interpolate(t, [...pathRideTiming.erase], [0, length], {\n ...CLAMP,\n easing: easeInOutCubic,\n });\n}\n\n/** How far the curve has pulled straight, 0..1. */\nfunction getPathRideStraighten(t: number) {\n return interpolate(t, [...pathRideTiming.straighten], [0, 1], {\n ...CLAMP,\n easing: easeInOutCubic,\n });\n}\n\n/** Frame where the line has erased and the text rests on its baseline. */\nconst pathRideLength = Math.max(\n pathRideTiming.straighten[1],\n pathRideTiming.erase[1],\n);\n\n/** Letter centers from the text start, and the total width. */\nfunction getPathRideCenters(advances: readonly number[]) {\n let x = 0;\n const centers = advances.map((a) => {\n const c = x + a / 2;\n x += a;\n return c;\n });\n return { centers, width: x };\n}\n\n/**\n * Arc length of a letter's center: it trails the head by the lead plus the\n * text after it, so the last letter follows the head most closely.\n */\nfunction getPathRideArc(\n head: number,\n center: number,\n width: number,\n fontSize: number,\n) {\n return head - LEAD * fontSize - (width - center);\n}\n\n/** Opacity of a letter from how far onto the curve it has come. */\nfunction getPathRideFade(arc: number, fontSize: number) {\n return Math.min(1, Math.max(0, arc / (FADE_IN * fontSize)));\n}\n\ninterface Point {\n x: number;\n y: number;\n}\n\ninterface PathSamples {\n length: number;\n points: Point[];\n tangents: Point[];\n}\n\n/** Points and unit tangents at evenly spaced arc lengths along `path`. */\nfunction samplePath(path: string, count = SAMPLES): PathSamples {\n const length = getLength(path);\n const n = Math.max(2, Math.round(count));\n const points: Point[] = [];\n const tangents: Point[] = [];\n for (let i = 0; i < n; i++) {\n const at = (length * i) / (n - 1);\n // Both can come back null on a degenerate path; reuse the last sample.\n const p = getPointAtLength(path, at) ?? points[i - 1] ?? { x: 0, y: 0 };\n const tangent = getTangentAtLength(path, at) ??\n tangents[i - 1] ?? { x: 1, y: 0 };\n points.push({ x: p.x, y: p.y });\n tangents.push({ x: tangent.x, y: tangent.y });\n }\n return { length, points, tangents };\n}\n\n/** Position and unit tangent at arc length `s`, clamped to the path. */\nfunction getPathSample(samples: PathSamples, s: number) {\n const n = samples.points.length;\n const u = samples.length > 0 ? (s / samples.length) * (n - 1) : 0;\n const i = Math.min(n - 2, Math.max(0, Math.floor(u)));\n const f = Math.min(1, Math.max(0, u - i));\n const a = samples.points[i];\n const b = samples.points[i + 1];\n const ta = samples.tangents[i];\n const tb = samples.tangents[i + 1];\n const tx = ta.x + (tb.x - ta.x) * f;\n const ty = ta.y + (tb.y - ta.y) * f;\n const norm = Math.hypot(tx, ty) || 1;\n return {\n x: a.x + (b.x - a.x) * f,\n y: a.y + (b.y - a.y) * f,\n tx: tx / norm,\n ty: ty / norm,\n };\n}\n\ninterface PathRideStraight {\n /** Arc length that lands on the text's left edge. */\n start: number;\n /** Reference x of the text's left edge on the straight baseline. */\n left: number;\n /** Reference y of the straight baseline. */\n baseline: number;\n}\n\ninterface PathRidePose {\n x: number;\n y: number;\n angle: number;\n}\n\n/**\n * A point of the path pulled `k` of the way from the curve to the straight\n * baseline, lifted `lift` along its normal. Arc length maps to x one to one,\n * so the text keeps its spacing while the curve pulls taut.\n */\nfunction getPathRidePoint(\n samples: PathSamples,\n s: number,\n k: number,\n straight: PathRideStraight,\n lift = 0,\n): PathRidePose {\n const p = getPathSample(samples, s);\n const x = p.x + (straight.left + (s - straight.start) - p.x) * k;\n const y = p.y + (straight.baseline - p.y) * k;\n const tx = p.tx + (1 - p.tx) * k;\n const ty = p.ty * (1 - k);\n const norm = Math.hypot(tx, ty) || 1;\n return {\n x: x + (ty / norm) * lift,\n y: y - (tx / norm) * lift,\n angle: Math.atan2(ty, tx),\n };\n}\n\n/** Polyline of the pulled path between two arc lengths. */\nfunction getPathRideLine(\n samples: PathSamples,\n from: number,\n to: number,\n k: number,\n straight: PathRideStraight,\n) {\n if (to <= from) return \"\";\n const step = samples.length / (samples.points.length - 1);\n const stops = [from];\n for (let s = Math.ceil(from / step) * step; s < to; s += step) {\n if (s > from) stops.push(s);\n }\n stops.push(to);\n return stops\n .map((s, i) => {\n const p = getPathRidePoint(samples, s, k, straight);\n return `${i === 0 ? \"M\" : \"L\"}${p.x.toFixed(2)} ${p.y.toFixed(2)}`;\n })\n .join(\"\");\n}\n\nfunction useMetrics(text: string, font: string, fallback: number) {\n const chars = Array.from(text);\n const key = chars.join(\"\");\n const [metrics, setMetrics] = useState<{\n advances: number[];\n baseline: number;\n capHeight: number;\n } | null>(null);\n\n useEffect(() => {\n const handle = delayRender(\"path-ride: measuring the text\");\n let released = false;\n const release = () => {\n if (released) return;\n released = true;\n continueRender(handle);\n };\n const measure = () => {\n if (released) return;\n const ctx = document.createElement(\"canvas\").getContext(\"2d\");\n if (ctx) {\n ctx.font = font;\n const m = ctx.measureText(\"H\");\n const ascent = m.fontBoundingBoxAscent / MEASURE_SIZE;\n const descent = m.fontBoundingBoxDescent / MEASURE_SIZE;\n setMetrics({\n advances: Array.from(key).map(\n (c) => ctx.measureText(c).width / MEASURE_SIZE,\n ),\n baseline:\n ascent > 0\n ? (1 - (ascent + descent)) / 2 + ascent\n : INTER_METRICS.baseline,\n capHeight:\n m.actualBoundingBoxAscent > 0\n ? m.actualBoundingBoxAscent / MEASURE_SIZE\n : INTER_METRICS.capHeight,\n });\n }\n release();\n };\n document.fonts.load(font, key).then(measure, measure);\n return release;\n }, [key, font]);\n\n return (\n metrics ?? {\n advances: chars.map(() => fallback),\n baseline: INTER_METRICS.baseline,\n capHeight: INTER_METRICS.capHeight,\n }\n );\n}\n\nfunction PathRideBase({\n text = pathRideDefaults.text,\n path = pathRideDefaults.path,\n fontSize = pathRideDefaults.fontSize,\n fontWeight = pathRideDefaults.fontWeight,\n fontFamily = pathRideDefaults.fontFamily,\n color = pathRideDefaults.color,\n lineColor = pathRideDefaults.lineColor,\n lineWidth = pathRideDefaults.lineWidth,\n speed = pathRideDefaults.speed,\n className,\n}: PathRideProps) {\n const frame = useCurrentFrame();\n const { fps, width, height } = useVideoConfig();\n const unit = height / 720;\n const t = getPathRideTime(frame, { fps, speed });\n const metrics = useMetrics(\n text,\n `${fontWeight} ${MEASURE_SIZE}px ${fontFamily}`,\n 0.55,\n );\n const samples = useMemo(() => samplePath(path), [path]);\n const chars = Array.from(text);\n const advances = metrics.advances.map((a) => a * fontSize);\n const { centers, width: textWidth } = getPathRideCenters(advances);\n const length = samples.length;\n const head = getPathRideHead(t, length);\n const tail = getPathRideTail(t, length);\n const k = getPathRideStraighten(t);\n const lift = lineWidth / 2 + LIFT * fontSize;\n // The line settles `lift` below the text so the capitals center on the frame.\n const straight: PathRideStraight = {\n start: getPathRideArc(length, 0, textWidth, fontSize),\n left: 640 - textWidth / 2,\n baseline: 360 + (metrics.capHeight * fontSize) / 2 + lift,\n };\n const tip = getPathRidePoint(samples, head, k, straight);\n const tipOpacity = interpolate(\n head,\n [0, length * 0.02, length * 0.98, length],\n [0, 1, 1, 0],\n CLAMP,\n );\n // Reference space (1280×720, y down) mapped onto the composition.\n const toX = (x: number) => width / 2 + (x - 640) * unit;\n const toY = (y: number) => height / 2 + (y - 360) * unit;\n const size = fontSize * unit;\n const line = getPathRideLine(samples, tail, head, k, straight);\n\n return (\n <div\n className={className}\n style={{ position: \"absolute\", inset: 0, overflow: \"hidden\" }}\n >\n <svg\n width=\"100%\"\n height=\"100%\"\n viewBox={`0 0 ${width} ${height}`}\n style={{ position: \"absolute\", inset: 0 }}\n >\n <g\n transform={`translate(${toX(0)} ${toY(0)}) scale(${unit})`}\n fill=\"none\"\n >\n {line ? (\n <path\n d={line}\n stroke={lineColor}\n strokeWidth={lineWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n ) : null}\n {tipOpacity > 0 ? (\n <circle\n cx={tip.x}\n cy={tip.y}\n r={lineWidth * 1.6}\n fill={lineColor}\n opacity={tipOpacity}\n />\n ) : null}\n </g>\n </svg>\n {chars.map((char, j) => {\n const arc = getPathRideArc(head, centers[j], textWidth, fontSize);\n const fade = getPathRideFade(arc, fontSize);\n if (fade <= 0) return null;\n const pose = getPathRidePoint(samples, arc, k, straight, lift);\n return (\n <span\n key={j}\n style={{\n position: \"absolute\",\n left: 0,\n top: 0,\n fontFamily,\n fontSize: size,\n lineHeight: 1,\n fontWeight,\n fontVariationSettings: `\"wght\" ${fontWeight}`,\n color,\n whiteSpace: \"pre\",\n opacity: fade,\n transformOrigin: \"0 0\",\n transform: `translate(${toX(pose.x)}px, ${toY(pose.y)}px) rotate(${pose.angle}rad) translate(-50%, ${-metrics.baseline * size}px)`,\n }}\n >\n {char}\n </span>\n );\n })}\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n text: {\n type: \"text-content\",\n default: \"Follow the line\",\n description: \"Text\",\n },\n path: {\n type: \"text-content\",\n default: \"M 120 560 C 360 120 560 120 640 360 S 920 600 1160 160\",\n description: \"Path (1280×720)\",\n },\n color: {\n type: \"color\",\n default: \"#111111\",\n description: \"Text color\",\n },\n lineColor: {\n type: \"color\",\n default: \"#fafafa\",\n description: \"Line color\",\n },\n fontSize: {\n type: \"number\",\n default: 44,\n min: 16,\n max: 120,\n step: 1,\n description: \"Font size\",\n hiddenFromList: false,\n },\n fontWeight: {\n type: \"number\",\n default: 700,\n min: 100,\n max: 900,\n step: 50,\n description: \"Weight\",\n hiddenFromList: false,\n },\n lineWidth: {\n type: \"number\",\n default: 3,\n min: 1,\n max: 12,\n step: 0.5,\n description: \"Line width\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"text\",\"path\",\"color\",\"lineColor\",\"fontSize\",\"fontWeight\",\"lineWidth\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n text: \"Follow the line\",\n path: \"M 120 560 C 360 120 560 120 640 360 S 920 600 1160 160\",\n color: \"#111111\",\n lineColor: \"#fafafa\",\n fontSize: 44,\n fontWeight: 700,\n lineWidth: 3,\n speed: 1,\n};\n\ntype PathRideElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof PathRideBase>;\n\nconst PathRideInner = forwardRef<\n HTMLDivElement,\n PathRideElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<PathRide>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <PathRideBase\n {...(componentProps as unknown as ComponentProps<typeof PathRideBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const PathRide = Interactive.withSchema({\n Component: PathRideInner,\n componentName: \"<PathRide>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/per-character-rise.json b/registry-artifacts/elements/per-character-rise.jsonindex 998bae18..93f60e67 100644--- a/registry-artifacts/elements/per-character-rise.json+++ b/registry-artifacts/elements/per-character-rise.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [],"dimensions": {"width": 570,@@ -9,6 +10,7 @@},"displayName": "Per Character Rise","durationInFrames": 60,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "per-character-rise","sourceCode": "import { Easing, Interactive, Sequence, interpolate, useCurrentFrame, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface PerCharacterRiseProps {\n text: string;\n distance?: number;\n fontSize?: number;\n color?: string;\n fontWeight?: number;\n speed?: number;\n className?: string;\n}\n\nfunction PerCharacterRiseBase({\n text,\n distance = 32,\n fontSize = 72,\n color = \"#171717\",\n fontWeight = 600,\n speed = 1,\n className,\n}: PerCharacterRiseProps) {\n const frame = useCurrentFrame() * speed;\n\n const chars = Array.from(text);\n const charDurationFrames = 21;\n const charTravelFrames = 10;\n const staggerFrames = 1;\n\n return (\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n background: \"transparent\",\n }}\n >\n <span\n className={className}\n style={{\n fontSize,\n fontWeight,\n color,\n letterSpacing: \"-0.05em\",\n fontFamily:\n \"var(--font-geist-sans), -apple-system, BlinkMacSystemFont, sans-serif\",\n }}\n >\n {chars.map((char, i) => {\n const local = frame - i * staggerFrames;\n const easing = Easing.bezier(0.2, 0.8, 0.2, 1);\n const travelEasing = Easing.bezier(0.2, 0.8, 0.6, 0.85);\n const opacity = interpolate(local, [0, charDurationFrames], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing,\n });\n const y = interpolate(local, [0, charTravelFrames], [distance, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: travelEasing,\n });\n return (\n <span\n key={i}\n style={{\n display: \"inline-block\",\n whiteSpace: \"pre\",\n backfaceVisibility: \"hidden\",\n transformOrigin: \"50% 55%\",\n opacity,\n translate: `0 ${y}px`,\n }}\n >\n {char}\n </span>\n );\n })}\n </span>\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n text: {\n type: \"text-content\",\n default: \"One more thing.\",\n description: \"Text\",\n },\n distance: {\n type: \"number\",\n min: 0,\n max: 120,\n step: 1,\n default: 32,\n description: \"Distance\",\n hiddenFromList: false,\n },\n fontSize: {\n type: \"number\",\n min: 12,\n max: 160,\n step: 1,\n default: 72,\n description: \"Font size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n fontWeight: {\n type: \"enum\",\n default: \"600\",\n variants: {\n \"400\": {},\n \"500\": {},\n \"600\": {},\n \"700\": {},\n },\n description: \"Font weight\",\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 570,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 100,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"text\",\"distance\",\"fontSize\",\"color\",\"fontWeight\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n text: \"One more thing.\",\n distance: 32,\n fontSize: 72,\n color: \"#171717\",\n fontWeight: \"600\",\n speed: 1,\n};\n\ntype PerCharacterRiseElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof PerCharacterRiseBase>;\n\nconst PerCharacterRiseInner = forwardRef<\n HTMLDivElement,\n PerCharacterRiseElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 570, height = 100, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<PerCharacterRise>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <PerCharacterRiseBase\n {...(componentProps as unknown as ComponentProps<typeof PerCharacterRiseBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const PerCharacterRise = Interactive.withSchema({\n Component: PerCharacterRiseInner,\n componentName: \"<PerCharacterRise>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/per-word-crossfade.json b/registry-artifacts/elements/per-word-crossfade.jsonindex 24cf8df7..9ab841a6 100644--- a/registry-artifacts/elements/per-word-crossfade.json+++ b/registry-artifacts/elements/per-word-crossfade.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [],"dimensions": {"width": 720,@@ -9,6 +10,7 @@},"displayName": "Per-Word Crossfade","durationInFrames": 90,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "per-word-crossfade","sourceCode": "import { Easing, Interactive, Sequence, interpolate, useCurrentFrame, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface PerWordCrossfadeProps {\n fromText: string;\n toText: string;\n fontSize?: number;\n color?: string;\n fontWeight?: number;\n speed?: number;\n className?: string;\n}\n\nfunction PerWordCrossfadeBase({\n fromText,\n toText,\n fontSize = 72,\n color = \"#171717\",\n fontWeight = 600,\n speed = 1,\n className,\n}: PerWordCrossfadeProps) {\n const frame = useCurrentFrame() * speed;\n\n const fromWords = fromText.split(\" \");\n const toWords = toText.split(\" \");\n\n const enterDur = 21;\n const enterTravel = 5;\n const exitDur = 15;\n const exitTravelFrom = 6;\n const enterStagger = 2;\n const exitStagger = 1;\n const overlapF = 5;\n const microDelayF = 2;\n\n const enterEasing = Easing.bezier(0.16, 1, 0.3, 1);\n const exitEasing = Easing.bezier(0.7, 0, 0.84, 0);\n\n const exitTotal = exitDur + (fromWords.length - 1) * exitStagger;\n const newStart = Math.max(0, exitTotal - overlapF + microDelayF);\n\n const fontStack =\n \"var(--font-geist-sans), -apple-system, BlinkMacSystemFont, sans-serif\";\n\n return (\n <div\n className={className}\n style={{\n position: \"absolute\",\n inset: 0,\n background: \"transparent\",\n }}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <span\n style={{\n fontSize,\n fontWeight,\n color,\n letterSpacing: \"-0.03em\",\n fontFamily: fontStack,\n }}\n >\n {fromWords.map((word, i) => {\n const local = frame - i * exitStagger;\n const opacity = interpolate(local, [0, exitDur], [1, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: exitEasing,\n });\n const y = interpolate(local, [exitTravelFrom, exitDur], [0, -6], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: exitEasing,\n });\n return (\n <span\n key={i}\n style={{\n display: \"inline-block\",\n marginRight: \"0.25em\",\n transformOrigin: \"50% 55%\",\n opacity,\n translate: `0 ${y}px`,\n }}\n >\n {word}\n </span>\n );\n })}\n </span>\n </div>\n\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <span\n style={{\n fontSize,\n fontWeight,\n color,\n letterSpacing: \"-0.03em\",\n fontFamily: fontStack,\n }}\n >\n {toWords.map((word, j) => {\n const local = frame - newStart - j * enterStagger;\n const opacity = interpolate(local, [0, enterDur], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: enterEasing,\n });\n const y = interpolate(local, [0, enterTravel], [8, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: enterEasing,\n });\n return (\n <span\n key={j}\n style={{\n display: \"inline-block\",\n marginRight: \"0.25em\",\n transformOrigin: \"50% 55%\",\n opacity,\n translate: `0 ${y}px`,\n }}\n >\n {word}\n </span>\n );\n })}\n </span>\n </div>\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n fromText: {\n type: \"text-content\",\n default: \"Beautifully simple.\",\n description: \"From text\",\n },\n toText: {\n type: \"text-content\",\n default: \"Designed for focus.\",\n description: \"To text\",\n },\n fontSize: {\n type: \"number\",\n min: 12,\n max: 160,\n step: 1,\n default: 72,\n description: \"Font size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n fontWeight: {\n type: \"enum\",\n default: \"600\",\n variants: {\n \"400\": {},\n \"500\": {},\n \"600\": {},\n \"700\": {},\n },\n description: \"Font weight\",\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 720,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 100,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"fromText\",\"toText\",\"fontSize\",\"color\",\"fontWeight\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n fromText: \"Beautifully simple.\",\n toText: \"Designed for focus.\",\n fontSize: 72,\n color: \"#171717\",\n fontWeight: \"600\",\n speed: 1,\n};\n\ntype PerWordCrossfadeElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof PerWordCrossfadeBase>;\n\nconst PerWordCrossfadeInner = forwardRef<\n HTMLDivElement,\n PerWordCrossfadeElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 720, height = 100, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<PerWordCrossfade>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <PerWordCrossfadeBase\n {...(componentProps as unknown as ComponentProps<typeof PerWordCrossfadeBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const PerWordCrossfade = Interactive.withSchema({\n Component: PerWordCrossfadeInner,\n componentName: \"<PerWordCrossfade>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/period-drop.json b/registry-artifacts/elements/period-drop.jsonindex a7c63d07..a031b92e 100644--- a/registry-artifacts/elements/period-drop.json+++ b/registry-artifacts/elements/period-drop.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/google-fonts",@@ -11,6 +12,7 @@"dimensions": null,"displayName": "Period Drop","durationInFrames": 47,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "period-drop","sourceCode": "import { loadFont } from \"@remotion/google-fonts/Inter\";\nimport { Easing, Interactive, Sequence, interpolate, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\nconst { fontFamily: INTER } = loadFont(\"normal\", {\n weights: [\"100\", \"900\"],\n subsets: [\"latin\"],\n});\n\ninterface PeriodDropProps {\n text?: string;\n fontSize?: number;\n fontWeight?: number;\n fontFamily?: string;\n color?: string;\n dotColor?: string;\n dotSize?: number;\n speed?: number;\n className?: string;\n}\n\nconst periodDropDefaults = {\n text: \"remocn\",\n fontSize: 160,\n fontWeight: 800,\n fontFamily: INTER,\n color: \"#fafafa\",\n dotColor: \"#D97757\",\n dotSize: 0.2,\n speed: 1,\n} satisfies Required<Omit<PeriodDropProps, \"className\">>;\n\n/** Frame where the dot has come to rest, squash included. */\nconst periodDropLength = 47;\n\n/** Timeline constants on the 30 fps clock. */\nconst periodDropTiming = {\n riseFrames: 12,\n riseStagger: 2,\n dropStart: 20,\n fallFrames: 12,\n restitution: 0.35,\n bounces: 2,\n /** Drop height as a share of the composition height. */\n dropHeight: 0.62,\n /** `scaleY` at full speed. */\n stretch: 0.3,\n /** `scaleY` lost at a full-speed impact. */\n squash: 0.22,\n /** Frames for an impact squash to decay by 1/e. */\n recover: 1.1,\n} as const;\n\nconst CLAMP = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n} as const;\n\nconst easeOutQuart = Easing.out(Easing.poly(4));\n\nfunction finite(value: number | undefined, fallback: number) {\n return typeof value === \"number\" && Number.isFinite(value) ? value : fallback;\n}\n\n/** Maps a composition frame onto the 30 fps timeline, scaled by `speed`. */\nfunction getPeriodDropTime(\n frame: number,\n options: { fps?: number; speed?: number } = {},\n) {\n const fps = Math.max(1, finite(options.fps, 30));\n const speed = Math.max(0, finite(options.speed, 1));\n return (Math.max(0, finite(frame, 0)) * 30 * speed) / fps;\n}\n\n/** How far letter `index` still sits below its line, 1 → 0. */\nfunction getPeriodDropRise(t: number, index: number) {\n const start = periodDropTiming.riseStagger * index;\n return interpolate(t, [start, start + periodDropTiming.riseFrames], [1, 0], {\n ...CLAMP,\n easing: easeOutQuart,\n });\n}\n\n/** Frames at which the dot touches the line: the landing, then each bounce. */\nfunction getPeriodDropImpacts() {\n const { dropStart, fallFrames, restitution, bounces } = periodDropTiming;\n const impacts = [dropStart + fallFrames];\n for (let n = 1; n <= bounces; n++) {\n impacts.push(impacts[n - 1] + 2 * restitution ** n * fallFrames);\n }\n return impacts;\n}\n\ninterface PeriodDropDot {\n visible: boolean;\n /** Height above the rest point as a share of the drop, 0 at rest, −1 at the start. */\n y: number;\n scaleX: number;\n scaleY: number;\n}\n\n/**\n * The dot's fall and bounces. Heights are shares of the drop height, time is\n * in 30 fps frames. Gravity is set by the fall: `g = 2 / fall²`, so the\n * landing speed is `2 / fall`. Each bounce leaves at `restitution` times the\n * previous speed, and the squash of each impact scales with it.\n */\nfunction getPeriodDropDot(t: number): PeriodDropDot {\n const { dropStart, fallFrames, restitution, stretch, squash, recover } =\n periodDropTiming;\n if (t < dropStart) return { visible: false, y: -1, scaleX: 1, scaleY: 1 };\n const g = 2 / (fallFrames * fallFrames);\n const landing = g * fallFrames;\n const impacts = getPeriodDropImpacts();\n\n let y = 0;\n let speed = 0;\n let deform = 0;\n if (t < impacts[0]) {\n const u = t - dropStart;\n y = -1 + 0.5 * g * u * u;\n speed = g * u;\n deform = speed / landing;\n } else {\n let n = impacts.length - 1;\n while (n > 0 && t < impacts[n]) n--;\n const tau = t - impacts[n];\n const bounce = n + 1;\n const launch =\n bounce < impacts.length ? restitution ** bounce * landing : 0;\n const flight = launch > 0 ? (2 * launch) / g : 0;\n if (tau < flight) {\n y = -(launch * tau - 0.5 * g * tau * tau);\n speed = Math.abs(launch - g * tau);\n }\n const impact = restitution ** n;\n const decay = Math.exp(-tau / recover);\n deform = -impact * decay + (1 - decay) * (speed / landing);\n }\n // Snap the last imperceptible wobble so the dot rests exactly.\n if (Math.abs(deform) < 0.005) deform = 0;\n\n const scaleY =\n deform >= 0 ? 1 + stretch * deform : 1 + squash * Math.max(-1, deform);\n return { visible: true, y: Math.min(0, y), scaleX: 1 / scaleY, scaleY };\n}\n\nfunction PeriodDropBase({\n text = periodDropDefaults.text,\n fontSize = periodDropDefaults.fontSize,\n fontWeight = periodDropDefaults.fontWeight,\n fontFamily = periodDropDefaults.fontFamily,\n color = periodDropDefaults.color,\n dotColor = periodDropDefaults.dotColor,\n dotSize = periodDropDefaults.dotSize,\n speed = periodDropDefaults.speed,\n className,\n}: PeriodDropProps) {\n const frame = useCurrentFrame();\n const { fps, height } = useVideoConfig();\n const unit = height / 720;\n const t = getPeriodDropTime(frame, { fps, speed });\n const dot = getPeriodDropDot(t);\n const drop = periodDropTiming.dropHeight * height;\n\n return (\n <div\n className={className}\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n overflow: \"hidden\",\n }}\n >\n <div\n style={{\n fontFamily,\n fontSize: fontSize * unit,\n lineHeight: 1,\n fontWeight,\n fontVariationSettings: `\"wght\" ${fontWeight}`,\n color,\n whiteSpace: \"pre\",\n }}\n >\n {Array.from(text).map((char, i) => (\n <span\n key={i}\n style={{\n display: \"inline-block\",\n overflow: \"hidden\",\n // Extend the clip below the line box so descenders survive.\n paddingBottom: \"0.15em\",\n marginBottom: \"-0.15em\",\n verticalAlign: \"top\",\n }}\n >\n <span\n style={{\n display: \"inline-block\",\n transform: `translateY(${getPeriodDropRise(t, i) * 115}%)`,\n }}\n >\n {char}\n </span>\n </span>\n ))}\n <span\n style={{\n display: \"inline-block\",\n width: `${dotSize}em`,\n height: `${dotSize}em`,\n marginLeft: \"0.04em\",\n borderRadius: \"50%\",\n background: dotColor,\n visibility: dot.visible ? \"visible\" : \"hidden\",\n transformOrigin: \"50% 100%\",\n transform: `translateY(${dot.y * drop}px) scale(${dot.scaleX}, ${dot.scaleY})`,\n }}\n />\n </div>\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n text: {\n type: \"text-content\",\n default: \"remocn\",\n description: \"Text\",\n },\n color: {\n type: \"color\",\n default: \"#fafafa\",\n description: \"Text color\",\n },\n dotColor: {\n type: \"color\",\n default: \"#ff4d1a\",\n description: \"Dot color\",\n },\n fontSize: {\n type: \"number\",\n default: 160,\n min: 60,\n max: 280,\n step: 2,\n description: \"Font size\",\n hiddenFromList: false,\n },\n fontWeight: {\n type: \"number\",\n default: 800,\n min: 100,\n max: 900,\n step: 50,\n description: \"Weight\",\n hiddenFromList: false,\n },\n dotSize: {\n type: \"number\",\n default: 0.2,\n min: 0.08,\n max: 0.5,\n step: 0.01,\n description: \"Dot size (em)\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"text\",\"color\",\"dotColor\",\"fontSize\",\"fontWeight\",\"dotSize\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n text: \"remocn\",\n color: \"#fafafa\",\n dotColor: \"#ff4d1a\",\n fontSize: 160,\n fontWeight: 800,\n dotSize: 0.2,\n speed: 1,\n};\n\ntype PeriodDropElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof PeriodDropBase>;\n\nconst PeriodDropInner = forwardRef<\n HTMLDivElement,\n PeriodDropElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<PeriodDrop>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <PeriodDropBase\n {...(componentProps as unknown as ComponentProps<typeof PeriodDropBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const PeriodDrop = Interactive.withSchema({\n Component: PeriodDropInner,\n componentName: \"<PeriodDrop>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/perspective-marquee.json b/registry-artifacts/elements/perspective-marquee.jsonindex a5a8dd48..8f162e12 100644--- a/registry-artifacts/elements/perspective-marquee.json+++ b/registry-artifacts/elements/perspective-marquee.json@@ -2,10 +2,12 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [],"dimensions": null,"displayName": "Perspective Marquee","durationInFrames": 240,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "perspective-marquee","sourceCode": "import { Interactive, Sequence, useCurrentFrame, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface PerspectiveMarqueeProps {\n items?: string[];\n fontSize?: number;\n color?: string;\n fontWeight?: number;\n pixelsPerFrame?: number;\n rotateY?: number;\n rotateX?: number;\n perspective?: number;\n fadeColor?: string;\n speed?: number;\n className?: string;\n}\n\nconst FONT_FAMILY =\n \"var(--font-geist-sans), -apple-system, BlinkMacSystemFont, sans-serif\";\n\nconst DEFAULT_ITEMS = [\n \"Vercel\",\n \"Linear\",\n \"Stripe\",\n \"Figma\",\n \"Notion\",\n \"Raycast\",\n \"Arc\",\n \"Cursor\",\n];\n\nfunction PerspectiveMarqueeBase({\n items = DEFAULT_ITEMS,\n fontSize = 84,\n color = \"#fafafa\",\n fontWeight = 700,\n pixelsPerFrame = 2,\n rotateY = -28,\n rotateX = 8,\n perspective = 1200,\n fadeColor = \"#050505\",\n speed = 1,\n className,\n}: PerspectiveMarqueeProps) {\n const frame = useCurrentFrame() * speed;\n\n // Approximate width of one full item set so the modulo wraps cleanly.\n const itemPadding = fontSize * 0.9;\n const approxItemWidth = items.reduce(\n (acc, item) => acc + item.length * fontSize * 0.6 + itemPadding,\n 0,\n );\n\n const offset = -((frame * pixelsPerFrame) % approxItemWidth);\n\n // Render the row 3x so the loop is seamless even when rotated in 3D.\n const rendered = [...items, ...items, ...items];\n\n return (\n <div\n className={className}\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n overflow: \"hidden\",\n perspective: `${perspective}px`,\n }}\n >\n <div\n style={{\n width: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"flex-start\",\n transform: `rotateX(${rotateX}deg) rotateY(${rotateY}deg)`,\n transformStyle: \"preserve-3d\",\n }}\n >\n <div\n style={{\n display: \"flex\",\n whiteSpace: \"nowrap\",\n translate: `${offset}px`,\n }}\n >\n {rendered.map((item, i) => {\n // Approximate this item's center X (relative to the marquee row,\n // including the rolling offset). Used to dial in depth-of-field blur\n // and opacity by horizontal position on screen.\n const itemCenter =\n i * (approxItemWidth / items.length) +\n approxItemWidth / items.length / 2 +\n offset;\n // Normalize roughly to [-1, 1] across a 1280px viewport.\n const norm = (itemCenter - 640) / 640;\n const distance = Math.min(1, Math.abs(norm));\n const blurPx = distance * 6;\n const opacity = 1 - distance * 0.4;\n\n return (\n <span\n key={i}\n style={{\n display: \"inline-block\",\n fontFamily: FONT_FAMILY,\n fontSize,\n fontWeight,\n color,\n letterSpacing: \"-0.03em\",\n paddingRight: itemPadding,\n filter: `blur(${blurPx}px)`,\n opacity,\n }}\n >\n {item}\n </span>\n );\n })}\n </div>\n </div>\n\n {/* Vignette to fade marquee edges into background */}\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n pointerEvents: \"none\",\n background: `linear-gradient(90deg, ${fadeColor} 0%, transparent 18%, transparent 82%, ${fadeColor} 100%)`,\n }}\n />\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n pointerEvents: \"none\",\n background: `linear-gradient(180deg, ${fadeColor} 0%, transparent 25%, transparent 75%, ${fadeColor} 100%)`,\n }}\n />\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n fontSize: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 2,\n default: 84,\n description: \"Font size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#fafafa\",\n description: \"Color\",\n },\n fontWeight: {\n type: \"enum\",\n default: \"700\",\n variants: {\n \"400\": {},\n \"500\": {},\n \"600\": {},\n \"700\": {},\n },\n description: \"Font weight\",\n },\n pixelsPerFrame: {\n type: \"number\",\n min: 0.25,\n max: 10,\n step: 0.25,\n default: 2,\n description: \"Pixels / frame\",\n hiddenFromList: false,\n },\n rotateY: {\n type: \"number\",\n min: -60,\n max: 60,\n step: 1,\n default: -28,\n description: \"Rotate Y (deg)\",\n hiddenFromList: false,\n },\n rotateX: {\n type: \"number\",\n min: -30,\n max: 30,\n step: 1,\n default: 8,\n description: \"Rotate X (deg)\",\n hiddenFromList: false,\n },\n perspective: {\n type: \"number\",\n min: 400,\n max: 3000,\n step: 50,\n default: 1200,\n description: \"Perspective\",\n hiddenFromList: false,\n },\n fadeColor: {\n type: \"color\",\n default: \"#050505\",\n description: \"Fade color\",\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"fontSize\",\"color\",\"fontWeight\",\"pixelsPerFrame\",\"rotateY\",\"rotateX\",\"perspective\",\"fadeColor\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n fontSize: 84,\n color: \"#fafafa\",\n fontWeight: \"700\",\n pixelsPerFrame: 2,\n rotateY: -28,\n rotateX: 8,\n perspective: 1200,\n fadeColor: \"#050505\",\n speed: 1,\n};\n\ntype PerspectiveMarqueeElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof PerspectiveMarqueeBase>;\n\nconst PerspectiveMarqueeInner = forwardRef<\n HTMLDivElement,\n PerspectiveMarqueeElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<PerspectiveMarquee>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <PerspectiveMarqueeBase\n {...(componentProps as unknown as ComponentProps<typeof PerspectiveMarqueeBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const PerspectiveMarquee = Interactive.withSchema({\n Component: PerspectiveMarqueeInner,\n componentName: \"<PerspectiveMarquee>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/perspective-squeeze.json b/registry-artifacts/elements/perspective-squeeze.jsonindex 802594a3..18de2f86 100644--- a/registry-artifacts/elements/perspective-squeeze.json+++ b/registry-artifacts/elements/perspective-squeeze.json@@ -2,10 +2,12 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [],"dimensions": null,"displayName": "Perspective Squeeze","durationInFrames": 225,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "perspective-squeeze","sourceCode": "import { Easing, Interactive, Sequence, interpolate, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ntype Corners = [\n [number, number],\n [number, number],\n [number, number],\n [number, number],\n];\n\ninterface PerspectiveSqueezeProps {\n className?: string;\n width?: number;\n height?: number;\n blockWidth?: number;\n blockHeight?: number;\n lowerBlockPosition?: [number, number];\n upperBlockPosition?: [number, number];\n cornersRest?: Corners;\n cornerKeyframes?: number[];\n upperCornersMid?: Corners;\n upperCornersEnd?: Corners;\n lowerCornersMid?: Corners;\n lowerCornersEnd?: Corners;\n upperText?: string;\n lowerText?: string;\n upperFontFamily?: string;\n lowerFontFamily?: string;\n upperFontSize?: number;\n lowerFontSize?: number;\n capRatio?: number;\n lineGap?: number;\n scaleKeyframes?: number[];\n lowerScaleY?: number[];\n upperScaleY?: number[];\n fill?: string;\n}\n\nfunction cornerPinMatrix(src: Corners, dst: Corners): string {\n const a: number[][] = [];\n const rhs: number[] = [];\n\n for (let i = 0; i < 4; i++) {\n const [x, y] = src[i];\n const [u, v] = dst[i];\n a.push([x, y, 1, 0, 0, 0, -u * x, -u * y]);\n rhs.push(u);\n a.push([0, 0, 0, x, y, 1, -v * x, -v * y]);\n rhs.push(v);\n }\n\n const n = 8;\n for (let col = 0; col < n; col++) {\n let pivot = col;\n for (let r = col + 1; r < n; r++) {\n if (Math.abs(a[r][col]) > Math.abs(a[pivot][col])) pivot = r;\n }\n [a[col], a[pivot]] = [a[pivot], a[col]];\n [rhs[col], rhs[pivot]] = [rhs[pivot], rhs[col]];\n\n const d = a[col][col];\n if (Math.abs(d) < 1e-12) continue;\n for (let c = col; c < n; c++) a[col][c] /= d;\n rhs[col] /= d;\n\n for (let r = 0; r < n; r++) {\n if (r === col) continue;\n const f = a[r][col];\n if (f === 0) continue;\n for (let c = col; c < n; c++) a[r][c] -= f * a[col][c];\n rhs[r] -= f * rhs[col];\n }\n }\n\n const [m0, m1, m2, m3, m4, m5, m6, m7] = rhs;\n return `matrix3d(${m0}, ${m3}, 0, ${m6}, ${m1}, ${m4}, 0, ${m7}, 0, 0, 1, 0, ${m2}, ${m5}, 0, 1)`;\n}\n\nfunction lerpCorners(from: Corners, to: Corners, t: number): Corners {\n return from.map((p, i) => [\n p[0] + (to[i][0] - p[0]) * t,\n p[1] + (to[i][1] - p[1]) * t,\n ]) as Corners;\n}\n\nfunction PerspectiveSqueezeBase({\n className,\n width = 1920,\n height = 1080,\n blockWidth = 990,\n blockHeight = 546,\n lowerBlockPosition = [960, 860],\n upperBlockPosition = [960, 314],\n cornersRest = [\n [0, 0],\n [990, 0],\n [0, 546],\n [990, 546],\n ],\n cornerKeyframes = [0, 45, 70],\n upperCornersMid = [\n [0, -326],\n [990, 0],\n [0, 546],\n [990, 546],\n ],\n upperCornersEnd = [\n [0, 352],\n [990, -428],\n [460, 546],\n [990, 546],\n ],\n lowerCornersMid = [\n [0, 0],\n [990, 0],\n [0, 225],\n [990, 546],\n ],\n lowerCornersEnd = [\n [0, 0],\n [990, 0],\n [0, 897],\n [990, 116],\n ],\n upperText = \"REMOCN\",\n lowerText = \"BEST\",\n upperFontFamily = \"sans-serif\",\n lowerFontFamily = \"sans-serif\",\n upperFontSize = 603,\n lowerFontSize = 124,\n capRatio = 0.65,\n lineGap = 50,\n scaleKeyframes = [0, 60, 118, 161, 196, 225],\n lowerScaleY = [100, 384.8, 270, 330, 150, 100],\n upperScaleY = [100, 35.8, 64, 45, 110, 100],\n fill = \"#ffffff\",\n}: PerspectiveSqueezeProps) {\n const frame = useCurrentFrame();\n const { width: compWidth, height: compHeight } = useVideoConfig();\n const stageScale = Math.min(compWidth / width, compHeight / height);\n\n const squishEase = Easing.bezier(0.6, 0, 0.4, 1);\n\n const scaleAt = (track: number[]) =>\n interpolate(frame, scaleKeyframes, track, {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: squishEase,\n }) / 100;\n\n const cornersAt = (mid: Corners, end: Corners): Corners => {\n const [k0, k1, k2] = cornerKeyframes;\n if (frame <= k0) return cornersRest;\n if (frame >= k2) return end;\n if (frame <= k1) {\n return lerpCorners(\n cornersRest,\n mid,\n squishEase((frame - k0) / Math.max(k1 - k0, 1)),\n );\n }\n return lerpCorners(\n mid,\n end,\n squishEase((frame - k1) / Math.max(k2 - k1, 1)),\n );\n };\n\n const upperScale = scaleAt(upperScaleY);\n const lowerScale = scaleAt(lowerScaleY);\n\n const upperBoxHeight = upperFontSize * capRatio * upperScale;\n const lowerBoxHeight = lowerFontSize * capRatio * lowerScale;\n const stackTop =\n (blockHeight - (upperBoxHeight + lineGap + lowerBoxHeight)) / 2;\n const upperBaseline = stackTop + upperBoxHeight;\n const lowerBaseline = upperBaseline + lineGap + lowerBoxHeight;\n\n const line = (\n text: string,\n family: string,\n size: number,\n baseline: number,\n scale: number,\n ) => (\n <text\n x={0}\n y={baseline}\n textLength={blockWidth}\n lengthAdjust=\"spacingAndGlyphs\"\n fontFamily={family}\n fontSize={size}\n fontWeight={800}\n fill={fill}\n transform={`matrix(1, 0, 0, ${scale}, 0, ${baseline * (1 - scale)})`}\n >\n {text}\n </text>\n );\n\n const block = (corners: Corners, position: [number, number]) => (\n <div\n style={{\n position: \"absolute\",\n left: position[0] - blockWidth / 2,\n top: position[1] - blockHeight / 2,\n width: blockWidth,\n height: blockHeight,\n transformOrigin: \"0 0\",\n transform: cornerPinMatrix(cornersRest, corners),\n }}\n >\n <svg\n width={blockWidth}\n height={blockHeight}\n viewBox={`0 0 ${blockWidth} ${blockHeight}`}\n style={{ display: \"block\", overflow: \"hidden\" }}\n >\n {line(\n upperText,\n upperFontFamily,\n upperFontSize,\n upperBaseline,\n upperScale,\n )}\n {line(\n lowerText,\n lowerFontFamily,\n lowerFontSize,\n lowerBaseline,\n lowerScale,\n )}\n </svg>\n </div>\n );\n\n return (\n <div\n className={className}\n style={{ position: \"absolute\", inset: 0, overflow: \"hidden\" }}\n >\n <div\n style={{\n position: \"absolute\",\n left: (compWidth - width * stageScale) / 2,\n top: (compHeight - height * stageScale) / 2,\n width,\n height,\n scale: `${stageScale}`,\n transformOrigin: \"0 0\",\n }}\n >\n {block(cornersAt(upperCornersMid, upperCornersEnd), upperBlockPosition)}\n {block(cornersAt(lowerCornersMid, lowerCornersEnd), lowerBlockPosition)}\n </div>\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n upperText: {\n type: \"text-content\",\n default: \"REMOCN\",\n description: \"Upper line\",\n },\n lowerText: {\n type: \"text-content\",\n default: \"BEST\",\n description: \"Lower line\",\n },\n fill: {\n type: \"color\",\n default: \"#f2f2f2\",\n description: \"Fill\",\n },\n upperFontFamily: {\n type: \"text-content\",\n default: \"Impact, 'Arial Narrow', sans-serif\",\n description: \"Upper font\",\n },\n lowerFontFamily: {\n type: \"text-content\",\n default: \"Impact, 'Arial Narrow', sans-serif\",\n description: \"Lower font\",\n },\n lineGap: {\n type: \"number\",\n min: 0,\n max: 120,\n step: 2,\n default: 50,\n description: \"Line gap\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"upperText\",\"lowerText\",\"fill\",\"upperFontFamily\",\"lowerFontFamily\",\"lineGap\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n upperText: \"REMOCN\",\n lowerText: \"BEST\",\n fill: \"#f2f2f2\",\n upperFontFamily: \"Impact, 'Arial Narrow', sans-serif\",\n lowerFontFamily: \"Impact, 'Arial Narrow', sans-serif\",\n lineGap: 50,\n speed: 1,\n};\n\ntype PerspectiveSqueezeElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof PerspectiveSqueezeBase>;\n\nconst PerspectiveSqueezeInner = forwardRef<\n HTMLDivElement,\n PerspectiveSqueezeElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<PerspectiveSqueeze>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <PerspectiveSqueezeBase\n {...(componentProps as unknown as ComponentProps<typeof PerspectiveSqueezeBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const PerspectiveSqueeze = Interactive.withSchema({\n Component: PerspectiveSqueezeInner,\n componentName: \"<PerspectiveSqueeze>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/pixelate-region.json b/registry-artifacts/elements/pixelate-region.jsonindex 41c2292d..e5ccf15f 100644--- a/registry-artifacts/elements/pixelate-region.json+++ b/registry-artifacts/elements/pixelate-region.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/transitions",@@ -11,6 +12,7 @@"dimensions": null,"displayName": "Pixelate Region","durationInFrames": 90,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "pixelate-region","sourceCode": "import { AbsoluteFill, Interactive, Sequence, isHtmlInCanvasSupported, useCurrentFrame, useDelayRender, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport React, { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\nimport { type TransitionPresentation, type TransitionPresentationComponentProps } from \"@remotion/transitions\";\n\nconst QUAD = new Float32Array([-1, -1, 1, -1, -1, 1, 1, 1]);\n\nconst VERTEX_SHADER = `#version 300 es\nin vec2 a_pos;\nout vec2 v_uv;\nvoid main() {\n v_uv = vec2(a_pos.x * 0.5 + 0.5, 0.5 - a_pos.y * 0.5);\n gl_Position = vec4(a_pos, 0.0, 1.0);\n}`;\n\nconst LAYER: React.CSSProperties = {\n position: \"absolute\",\n inset: 0,\n width: \"100%\",\n height: \"100%\",\n};\n\nconst OUTPUT_LAYER: React.CSSProperties = { ...LAYER, pointerEvents: \"none\" };\n\nconst isCanvasTransitionSupported = (): boolean =>\n isHtmlInCanvasSupported();\n\nconst isCanvasFilterSupported = (): boolean => isHtmlInCanvasSupported();\n\ntype SceneShaderFrame<Props> = {\n gl: WebGL2RenderingContext;\n uniform: (name: string) => WebGLUniformLocation | null;\n width: number;\n height: number;\n progress: number;\n passedProps: Props;\n};\n\ntype SceneShaderDrawParams<Props> = {\n from: OffscreenCanvas | null;\n to: OffscreenCanvas | null;\n width: number;\n height: number;\n progress: number;\n passedProps: Props;\n};\n\ntype SceneShaderInstance<Props> = {\n draw: (params: SceneShaderDrawParams<Props>) => void;\n clear: () => void;\n cleanup: () => void;\n};\n\ntype SceneShader<Props> = (\n canvas: OffscreenCanvas,\n) => SceneShaderInstance<Props>;\n\ntype SceneFilterFrame<Props> = {\n gl: WebGL2RenderingContext;\n uniform: (name: string) => WebGLUniformLocation | null;\n width: number;\n height: number;\n frame: number;\n time: number;\n passedProps: Props;\n};\n\ntype SceneFilterDrawParams<Props> = {\n scene: OffscreenCanvas | null;\n width: number;\n height: number;\n frame: number;\n time: number;\n passedProps: Props;\n};\n\ntype SceneFilterInstance<Props> = {\n draw: (params: SceneFilterDrawParams<Props>) => void;\n clear: () => void;\n cleanup: () => void;\n};\n\ntype SceneFilter<Props> = (\n canvas: OffscreenCanvas,\n) => SceneFilterInstance<Props>;\n\nfunction compileShader(\n gl: WebGL2RenderingContext,\n source: string,\n type: GLenum,\n): WebGLShader {\n const shader = gl.createShader(type);\n if (!shader) {\n throw new Error(\"canvas-presentation: failed to create shader\");\n }\n gl.shaderSource(shader, source);\n gl.compileShader(shader);\n if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {\n const log = gl.getShaderInfoLog(shader);\n gl.deleteShader(shader);\n throw new Error(`canvas-presentation: failed to compile shader: ${log}`);\n }\n return shader;\n}\n\nfunction createProgram(\n gl: WebGL2RenderingContext,\n fragment: string,\n): WebGLProgram {\n const program = gl.createProgram();\n if (!program) {\n throw new Error(\"canvas-presentation: failed to create program\");\n }\n const vs = compileShader(gl, VERTEX_SHADER, gl.VERTEX_SHADER);\n const fs = compileShader(gl, fragment, gl.FRAGMENT_SHADER);\n gl.attachShader(program, vs);\n gl.attachShader(program, fs);\n gl.linkProgram(program);\n gl.deleteShader(vs);\n gl.deleteShader(fs);\n if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {\n const log = gl.getProgramInfoLog(program);\n gl.deleteProgram(program);\n throw new Error(`canvas-presentation: failed to link program: ${log}`);\n }\n return program;\n}\n\nfunction createSceneTexture(gl: WebGL2RenderingContext): WebGLTexture {\n const texture = gl.createTexture();\n if (!texture) {\n throw new Error(\"canvas-presentation: failed to create texture\");\n }\n gl.bindTexture(gl.TEXTURE_2D, texture);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);\n gl.texImage2D(\n gl.TEXTURE_2D,\n 0,\n gl.RGBA,\n 1,\n 1,\n 0,\n gl.RGBA,\n gl.UNSIGNED_BYTE,\n new Uint8Array([0, 0, 0, 0]),\n );\n return texture;\n}\n\nfunction createQuadSurface(canvas: OffscreenCanvas, fragment: string) {\n const gl = canvas.getContext(\"webgl2\", { premultipliedAlpha: true });\n if (!gl) {\n throw new Error(\"canvas-presentation: WebGL2 is unavailable\");\n }\n\n const program = createProgram(gl, fragment);\n const vao = gl.createVertexArray();\n gl.bindVertexArray(vao);\n const buffer = gl.createBuffer();\n gl.bindBuffer(gl.ARRAY_BUFFER, buffer);\n gl.bufferData(gl.ARRAY_BUFFER, QUAD, gl.STATIC_DRAW);\n const aPos = gl.getAttribLocation(program, \"a_pos\");\n gl.enableVertexAttribArray(aPos);\n gl.vertexAttribPointer(aPos, 2, gl.FLOAT, false, 0, 0);\n\n const locations = new Map<string, WebGLUniformLocation | null>();\n const uniform = (name: string) => {\n const cached = locations.get(name);\n if (cached !== undefined) {\n return cached;\n }\n const location = gl.getUniformLocation(program, name);\n locations.set(name, location);\n return location;\n };\n\n const clear = () => {\n gl.clearColor(0, 0, 0, 0);\n gl.clear(gl.COLOR_BUFFER_BIT);\n };\n\n const textures: WebGLTexture[] = [];\n const createTexture = () => {\n const texture = createSceneTexture(gl);\n textures.push(texture);\n return texture;\n };\n\n const begin = (width: number, height: number) => {\n gl.viewport(0, 0, width, height);\n clear();\n gl.useProgram(program);\n gl.bindVertexArray(vao);\n };\n\n const bindScene = (\n image: OffscreenCanvas | null,\n texture: WebGLTexture,\n unit: number,\n name: string,\n ) => {\n gl.activeTexture(gl.TEXTURE0 + unit);\n gl.bindTexture(gl.TEXTURE_2D, texture);\n if (image) {\n gl.texImage2D(\n gl.TEXTURE_2D,\n 0,\n gl.RGBA,\n gl.RGBA,\n gl.UNSIGNED_BYTE,\n image,\n );\n }\n gl.uniform1i(uniform(name), unit);\n };\n\n const draw = () => gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);\n\n const cleanup = () => {\n gl.deleteProgram(program);\n for (const texture of textures) {\n gl.deleteTexture(texture);\n }\n gl.deleteBuffer(buffer);\n gl.deleteVertexArray(vao);\n };\n\n return {\n gl,\n uniform,\n clear,\n createTexture,\n begin,\n bindScene,\n draw,\n cleanup,\n };\n}\n\nfunction makeSceneShader<Props extends Record<string, unknown>>(\n fragment: string,\n setUniforms?: (frame: SceneShaderFrame<Props>) => void,\n): SceneShader<Props> {\n return (canvas) => {\n const surface = createQuadSurface(canvas, fragment);\n const fromTexture = surface.createTexture();\n const toTexture = surface.createTexture();\n\n return {\n clear: surface.clear,\n cleanup: surface.cleanup,\n draw: ({ from, to, width, height, progress, passedProps }) => {\n surface.begin(width, height);\n surface.bindScene(from, fromTexture, 0, \"u_from\");\n surface.bindScene(to, toTexture, 1, \"u_to\");\n\n surface.gl.uniform1f(surface.uniform(\"u_progress\"), progress);\n surface.gl.uniform1f(surface.uniform(\"u_aspect\"), width / height);\n setUniforms?.({\n gl: surface.gl,\n uniform: surface.uniform,\n width,\n height,\n progress,\n passedProps,\n });\n\n surface.draw();\n },\n };\n };\n}\n\nfunction makeFilterShader<Props extends Record<string, unknown>>(\n fragment: string,\n setUniforms?: (frame: SceneFilterFrame<Props>) => void,\n): SceneFilter<Props> {\n return (canvas) => {\n const surface = createQuadSurface(canvas, fragment);\n const sceneTexture = surface.createTexture();\n\n return {\n clear: surface.clear,\n cleanup: surface.cleanup,\n draw: ({ scene, width, height, frame, time, passedProps }) => {\n surface.begin(width, height);\n surface.bindScene(scene, sceneTexture, 0, \"u_scene\");\n\n surface.gl.uniform1f(surface.uniform(\"u_frame\"), frame);\n surface.gl.uniform1f(surface.uniform(\"u_time\"), time);\n surface.gl.uniform1f(surface.uniform(\"u_aspect\"), width / height);\n setUniforms?.({\n gl: surface.gl,\n uniform: surface.uniform,\n width,\n height,\n frame,\n time,\n passedProps,\n });\n\n surface.draw();\n },\n };\n };\n}\n\nconst transferred = new WeakMap<HTMLCanvasElement, OffscreenCanvas>();\n\nfunction takeOffscreen(canvas: HTMLCanvasElement): OffscreenCanvas {\n const existing = transferred.get(canvas);\n if (existing) {\n return existing;\n }\n const created = canvas.transferControlToOffscreen();\n transferred.set(canvas, created);\n return created;\n}\n\nfunction makeCanvasComponent<Props extends Record<string, unknown>>(\n shader: SceneShader<Props>,\n): React.FC<TransitionPresentationComponentProps<Props>> {\n return function CanvasScenePresentation({\n children,\n presentationProgress,\n presentationDirection,\n passedProps,\n onElementImage,\n onUnmount,\n bothEnteringAndExiting,\n }) {\n const layoutRef = React.useRef<HTMLCanvasElement | null>(null);\n const outputRef = React.useRef<HTMLCanvasElement | null>(null);\n const captureRef = React.useRef<OffscreenCanvas | null>(null);\n const captureContextRef =\n React.useRef<OffscreenCanvasRenderingContext2D | null>(null);\n const outputSurfaceRef = React.useRef<OffscreenCanvas | null>(null);\n const instanceRef = React.useRef<SceneShaderInstance<Props> | null>(null);\n const passedPropsRef = React.useRef(passedProps);\n passedPropsRef.current = passedProps;\n const onElementImageRef = React.useRef(onElementImage);\n onElementImageRef.current = onElementImage;\n const onUnmountRef = React.useRef(onUnmount);\n onUnmountRef.current = onUnmount;\n\n const { delayRender, continueRender } = useDelayRender();\n const passThrough =\n bothEnteringAndExiting && presentationDirection === \"exiting\";\n\n const drawRef = React.useRef<\n (\n prevImage: OffscreenCanvas | null,\n nextImage: OffscreenCanvas | null,\n progress: number,\n ) => void\n >(() => undefined);\n drawRef.current = (prevImage, nextImage, progress) => {\n const instance = instanceRef.current;\n if (!instance) {\n return;\n }\n const handle = delayRender(\"canvas-presentation: paint\");\n const to = prevImage;\n const from = nextImage;\n const width = from?.width ?? to?.width ?? 0;\n const height = from?.height ?? to?.height ?? 0;\n if (width === 0 || height === 0) {\n instance.clear();\n continueRender(handle);\n return;\n }\n instance.draw({\n from,\n to,\n width,\n height,\n progress: !to ? 0 : !from ? 1 : progress,\n passedProps: passedPropsRef.current,\n });\n continueRender(handle);\n };\n\n const draw = React.useCallback(\n (\n prevImage: OffscreenCanvas | null,\n nextImage: OffscreenCanvas | null,\n progress: number,\n ) => drawRef.current(prevImage, nextImage, progress),\n [],\n );\n\n React.useLayoutEffect(() => {\n if (passThrough) {\n return;\n }\n const layout = layoutRef.current;\n const output = outputRef.current;\n if (!layout || !output) {\n return;\n }\n const capture = takeOffscreen(layout);\n const context = capture.getContext(\"2d\");\n if (!context) {\n throw new Error(\"canvas-presentation: failed to acquire a 2D context\");\n }\n const surface = takeOffscreen(output);\n captureRef.current = capture;\n captureContextRef.current = context;\n outputSurfaceRef.current = surface;\n instanceRef.current = shader(surface);\n\n return () => {\n instanceRef.current?.cleanup();\n instanceRef.current = null;\n captureRef.current = null;\n captureContextRef.current = null;\n outputSurfaceRef.current = null;\n };\n }, [passThrough, shader]);\n\n React.useLayoutEffect(() => {\n if (passThrough) {\n return;\n }\n const layout = layoutRef.current;\n if (!layout) {\n return;\n }\n layout.layoutSubtree = true;\n const handlePaint = () => {\n const scene = layout.firstElementChild;\n const capture = captureRef.current;\n const context = captureContextRef.current;\n if (!scene || !capture || !context) {\n return;\n }\n const elementImage = layout.captureElementImage(scene);\n try {\n context.reset();\n context.drawElementImage(elementImage, 0, 0);\n } finally {\n elementImage.close();\n }\n onElementImageRef.current(capture, draw);\n };\n layout.addEventListener(\"paint\", handlePaint);\n return () => layout.removeEventListener(\"paint\", handlePaint);\n }, [passThrough, draw]);\n\n React.useLayoutEffect(() => {\n if (passThrough) {\n return;\n }\n const layout = layoutRef.current;\n if (!layout) {\n return;\n }\n const observer = new ResizeObserver(([entry]) => {\n const capture = captureRef.current;\n const surface = outputSurfaceRef.current;\n if (!capture || !surface) {\n return;\n }\n const width = entry.devicePixelContentBoxSize[0].inlineSize;\n const height = entry.devicePixelContentBoxSize[0].blockSize;\n capture.width = width;\n capture.height = height;\n surface.width = width;\n surface.height = height;\n layout.requestPaint?.();\n });\n observer.observe(layout, { box: \"device-pixel-content-box\" });\n return () => observer.disconnect();\n }, [passThrough]);\n\n // biome-ignore lint/correctness/useExhaustiveDependencies: presentationProgress is the intentional trigger — a new progress value is what schedules the next paint\n React.useLayoutEffect(() => {\n if (passThrough) {\n return;\n }\n layoutRef.current?.requestPaint?.();\n }, [passThrough, presentationProgress]);\n\n React.useLayoutEffect(() => {\n if (passThrough) {\n return;\n }\n return () => onUnmountRef.current();\n }, [passThrough]);\n\n if (passThrough) {\n return <>{children}</>;\n }\n\n return (\n <AbsoluteFill>\n <canvas ref={layoutRef} style={LAYER}>\n {children}\n </canvas>\n <canvas ref={outputRef} style={OUTPUT_LAYER} />\n </AbsoluteFill>\n );\n };\n}\n\ntype CanvasFilterProps = {\n children: React.ReactNode;\n};\n\nfunction makeFilterComponent<Props extends Record<string, unknown>>(\n shader: SceneFilter<Props>,\n): React.FC<Props & CanvasFilterProps> {\n return function CanvasSceneFilter(props) {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const { delayRender, continueRender } = useDelayRender();\n\n const layoutRef = React.useRef<HTMLCanvasElement | null>(null);\n const outputRef = React.useRef<HTMLCanvasElement | null>(null);\n const captureRef = React.useRef<OffscreenCanvas | null>(null);\n const captureContextRef =\n React.useRef<OffscreenCanvasRenderingContext2D | null>(null);\n const outputSurfaceRef = React.useRef<OffscreenCanvas | null>(null);\n const instanceRef = React.useRef<SceneFilterInstance<Props> | null>(null);\n\n const passedPropsRef = React.useRef(props);\n passedPropsRef.current = props;\n const frameRef = React.useRef(frame);\n frameRef.current = frame;\n const timeRef = React.useRef(frame / fps);\n timeRef.current = frame / fps;\n\n React.useLayoutEffect(() => {\n const layout = layoutRef.current;\n const output = outputRef.current;\n if (!layout || !output) {\n return;\n }\n const capture = takeOffscreen(layout);\n const context = capture.getContext(\"2d\");\n if (!context) {\n throw new Error(\"canvas-presentation: failed to acquire a 2D context\");\n }\n const surface = takeOffscreen(output);\n captureRef.current = capture;\n captureContextRef.current = context;\n outputSurfaceRef.current = surface;\n instanceRef.current = shader(surface);\n\n return () => {\n instanceRef.current?.cleanup();\n instanceRef.current = null;\n captureRef.current = null;\n captureContextRef.current = null;\n outputSurfaceRef.current = null;\n };\n }, [shader]);\n\n React.useLayoutEffect(() => {\n const layout = layoutRef.current;\n if (!layout) {\n return;\n }\n layout.layoutSubtree = true;\n const handlePaint = () => {\n const scene = layout.firstElementChild;\n const capture = captureRef.current;\n const context = captureContextRef.current;\n const instance = instanceRef.current;\n if (!scene || !capture || !context || !instance) {\n return;\n }\n const elementImage = layout.captureElementImage(scene);\n try {\n context.reset();\n context.drawElementImage(elementImage, 0, 0);\n } finally {\n elementImage.close();\n }\n if (capture.width === 0 || capture.height === 0) {\n instance.clear();\n return;\n }\n instance.draw({\n scene: capture,\n width: capture.width,\n height: capture.height,\n frame: frameRef.current,\n time: timeRef.current,\n passedProps: passedPropsRef.current,\n });\n };\n layout.addEventListener(\"paint\", handlePaint);\n return () => layout.removeEventListener(\"paint\", handlePaint);\n }, []);\n\n React.useLayoutEffect(() => {\n const layout = layoutRef.current;\n if (!layout) {\n return;\n }\n const observer = new ResizeObserver(([entry]) => {\n const capture = captureRef.current;\n const surface = outputSurfaceRef.current;\n if (!capture || !surface) {\n return;\n }\n const width = entry.devicePixelContentBoxSize[0].inlineSize;\n const height = entry.devicePixelContentBoxSize[0].blockSize;\n capture.width = width;\n capture.height = height;\n surface.width = width;\n surface.height = height;\n layout.requestPaint?.();\n });\n observer.observe(layout, { box: \"device-pixel-content-box\" });\n return () => observer.disconnect();\n }, []);\n\n React.useLayoutEffect(() => {\n const layout = layoutRef.current;\n if (!layout) {\n return;\n }\n const handle = delayRender(\"canvas-presentation: filter paint\");\n const settle = () => continueRender(handle);\n layout.addEventListener(\"paint\", settle, { once: true });\n layout.requestPaint?.();\n return () => {\n layout.removeEventListener(\"paint\", settle);\n continueRender(handle);\n };\n });\n\n return (\n <AbsoluteFill>\n <canvas ref={layoutRef} style={LAYER}>\n {props.children}\n </canvas>\n <canvas ref={outputRef} style={OUTPUT_LAYER} />\n </AbsoluteFill>\n );\n };\n}\n\ntype CanvasPresentationOptions<Props extends Record<string, unknown>> = {\n shader: SceneShader<Props>;\n fallback: React.FC<TransitionPresentationComponentProps<Props>>;\n};\n\nfunction makeCanvasPresentation<Props extends Record<string, unknown>>({\n shader,\n fallback: Fallback,\n}: CanvasPresentationOptions<Props>): (\n props: Props,\n) => TransitionPresentation<Props> {\n const Canvas = makeCanvasComponent(shader);\n\n const Presentation: React.FC<TransitionPresentationComponentProps<Props>> = (\n props,\n ) =>\n isCanvasTransitionSupported() ? (\n <Canvas {...props} />\n ) : (\n <Fallback {...props} />\n );\n\n return (props) => ({ component: Presentation, props });\n}\n\ntype CanvasFilterOptions<Props extends Record<string, unknown>> = {\n shader: SceneFilter<Props>;\n fallback: React.FC<Props & CanvasFilterProps>;\n};\n\nfunction makeCanvasFilter<Props extends Record<string, unknown>>({\n shader,\n fallback: Fallback,\n}: CanvasFilterOptions<Props>): React.FC<Props & CanvasFilterProps> {\n const Canvas = makeFilterComponent(shader);\n\n return function CanvasFilter(props) {\n return isCanvasFilterSupported() ? (\n <Canvas {...props} />\n ) : (\n <Fallback {...props} />\n );\n };\n}\n\ntype PixelateRect = {\n x: number;\n y: number;\n width: number;\n height: number;\n};\n\ntype PixelateRegionProps = {\n regions: PixelateRect[];\n cellSize?: number;\n};\n\nconst MAX_REGIONS = 8;\n\nconst DEFAULTS = {\n cellSize: 24,\n};\n\ntype NormalizedProps = {\n rects: PixelateRect[];\n cellX: number;\n cellY: number;\n};\n\nconst FRAGMENT_SHADER = `#version 300 es\nprecision highp float;\n\nuniform sampler2D u_scene;\nuniform vec4 u_regions[${MAX_REGIONS}];\nuniform int u_region_count;\nuniform vec2 u_cell;\n\nin vec2 v_uv;\nout vec4 outColor;\n\nconst int TAPS = 3;\n\nvec4 cellAverage(vec2 center, vec2 cell) {\n vec4 sum = vec4(0.0);\n for (int y = 0; y < TAPS; y++) {\n for (int x = 0; x < TAPS; x++) {\n vec2 offset =\n (vec2(float(x), float(y)) + 0.5) / float(TAPS) - 0.5;\n sum += texture(u_scene, center + offset * cell);\n }\n }\n return sum / float(TAPS * TAPS);\n}\n\nvoid main() {\n vec4 result = texture(u_scene, v_uv);\n vec2 cell = max(u_cell, vec2(0.0005));\n\n for (int i = 0; i < ${MAX_REGIONS}; i++) {\n if (i >= u_region_count) {\n continue;\n }\n vec4 region = u_regions[i];\n vec2 lo = region.xy;\n vec2 hi = region.xy + region.zw;\n vec2 hit = step(lo, v_uv) * step(v_uv, hi);\n if (hit.x * hit.y < 0.5) {\n continue;\n }\n vec2 center = lo + (floor((v_uv - lo) / cell) + 0.5) * cell;\n result = vec4(cellAverage(center, cell).rgb, 1.0);\n }\n\n outColor = result;\n}`;\n\nconst shader = makeFilterShader<NormalizedProps>(\n FRAGMENT_SHADER,\n ({ gl, uniform, passedProps }) => {\n const { rects, cellX, cellY } = passedProps;\n const packed = new Float32Array(MAX_REGIONS * 4);\n const count = Math.min(rects.length, MAX_REGIONS);\n for (let i = 0; i < count; i++) {\n const rect = rects[i];\n packed[i * 4] = rect.x;\n packed[i * 4 + 1] = rect.y;\n packed[i * 4 + 2] = rect.width;\n packed[i * 4 + 3] = rect.height;\n }\n gl.uniform4fv(uniform(\"u_regions[0]\"), packed);\n gl.uniform1i(uniform(\"u_region_count\"), count);\n gl.uniform2f(uniform(\"u_cell\"), cellX, cellY);\n },\n);\n\nconst PixelateRegionFallback: React.FC<NormalizedProps & CanvasFilterProps> = ({\n children,\n rects,\n}) => (\n <AbsoluteFill>\n {children}\n {rects.map((rect) => (\n <div\n key={`${rect.x}-${rect.y}-${rect.width}-${rect.height}`}\n style={{\n position: \"absolute\",\n left: `${rect.x * 100}%`,\n top: `${rect.y * 100}%`,\n width: `${rect.width * 100}%`,\n height: `${rect.height * 100}%`,\n background: \"#14161c\",\n }}\n />\n ))}\n </AbsoluteFill>\n);\n\nconst PixelateRegionCanvas = makeCanvasFilter<NormalizedProps>({\n shader,\n fallback: PixelateRegionFallback,\n});\n\nconst PixelateRegionBase: React.FC<\n PixelateRegionProps & CanvasFilterProps\n> = ({ regions, cellSize = DEFAULTS.cellSize, children }) => {\n const { width, height } = useVideoConfig();\n\n if (regions.length > MAX_REGIONS) {\n throw new Error(\n `pixelate-region: at most ${MAX_REGIONS} regions can be covered at once, received ${regions.length}. Dropping any of them would leave what it covered visible, so nest a second PixelateRegionBase instead.`,\n );\n }\n\n const rects = regions.map((region) => ({\n x: region.x / width,\n y: region.y / height,\n width: region.width / width,\n height: region.height / height,\n }));\n\n return (\n <PixelateRegionCanvas\n rects={rects}\n cellX={cellSize / width}\n cellY={cellSize / height}\n >\n {children}\n </PixelateRegionCanvas>\n );\n};\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n cellSize: {\n type: \"number\",\n min: 6,\n max: 72,\n step: 2,\n default: 24,\n description: \"Cell size\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"cellSize\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n cellSize: 24,\n speed: 1,\n};\n\ntype PixelateRegionElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof PixelateRegionBase>;\n\nconst PixelateRegionInner = forwardRef<\n HTMLDivElement,\n PixelateRegionElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<PixelateRegion>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <PixelateRegionBase\n {...(componentProps as unknown as ComponentProps<typeof PixelateRegionBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const PixelateRegion = Interactive.withSchema({\n Component: PixelateRegionInner,\n componentName: \"<PixelateRegion>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/radial-burst.json b/registry-artifacts/elements/radial-burst.jsonindex 2da5543b..498cf42f 100644--- a/registry-artifacts/elements/radial-burst.json+++ b/registry-artifacts/elements/radial-burst.json@@ -2,10 +2,12 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [],"dimensions": null,"displayName": "Radial Burst","durationInFrames": 114,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "radial-burst","sourceCode": "import { Easing, Interactive, Sequence, interpolateColors, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface RadialBurstProps {\n /** Number of rounded segments, from 4 to 16. */\n segments?: number;\n /** Burst radius at a 720px reference size. */\n radius?: number;\n /** Segment thickness at a 720px reference size. */\n thickness?: number;\n /** Rotation during assembly, in degrees; negative reverses it. */\n rotation?: number;\n /** Sculptural stretch and tilt, from 0 (classic) to 1.5. */\n intensity?: number;\n /** Curvature of the flying ribbons in degrees. */\n twist?: number;\n /** Number of contour echoes, from 0 to 5. */\n echoes?: number;\n color?: string;\n accentColor?: string;\n backgroundColor?: string;\n speed?: number;\n loop?: boolean;\n className?: string;\n}\n\n/** The ring has completely left the composition by this frame at 30 fps. */\nconst radialBurstLength = 114;\nconst CYCLE = 120;\nconst finite = (value: number, fallback: number) =>\n Number.isFinite(value) ? value : fallback;\nconst clamp = (value: number) => Math.min(1, Math.max(0, value));\nconst mix = (from: number, to: number, progress: number) =>\n from + (to - from) * progress;\nconst easeInOut = Easing.bezier(0.65, 0, 0.25, 1);\nconst easeOut = Easing.bezier(0.16, 1, 0.3, 1);\nconst progress = (frame: number, start: number, end: number) =>\n clamp((frame - start) / (end - start));\n\n/** Includes the clean tail, in frames at 30 fps. */\nfunction getRadialBurstDuration({\n speed = 1,\n}: Pick<RadialBurstProps, \"speed\"> = {}) {\n const rate = finite(speed, 1);\n return rate <= 0 ? 1 : Math.max(1, Math.ceil(CYCLE / rate));\n}\n\nfunction getRadialBurstState(\n frame: number,\n {\n segments = 8,\n radius = 210,\n thickness = 30,\n rotation = 135,\n intensity = 1,\n loop = false,\n width = 1280,\n height = 720,\n }: Omit<\n RadialBurstProps,\n \"color\" | \"accentColor\" | \"backgroundColor\" | \"speed\" | \"className\"\n > & {\n width?: number;\n height?: number;\n } = {},\n) {\n const w = Math.max(1, finite(width, 1280));\n const h = Math.max(1, finite(height, 720));\n const unit = Math.min(w, h) / 720;\n const time = Math.max(0, finite(frame, 0));\n const local = loop ? time % CYCLE : time;\n const count = Math.round(Math.min(16, Math.max(4, finite(segments, 8))));\n const burstRadius = Math.min(280, Math.max(100, finite(radius, 210))) * unit;\n const stroke = Math.min(60, Math.max(8, finite(thickness, 30))) * unit;\n const ringRadius = burstRadius * 0.68;\n const assemble = easeInOut(progress(local, 44, 76));\n const curl = easeInOut(progress(local, 48, 78));\n const close = easeInOut(progress(local, 72, 84));\n const anticipate = easeInOut(progress(local, 86, 96));\n const exit = progress(local, 96, radialBurstLength) ** 2.6;\n const launch = spring({\n frame: Math.max(0, local - 18),\n fps: 30,\n durationInFrames: 26,\n config: { damping: 13, stiffness: 170, mass: 0.8 },\n });\n const pop = spring({\n frame: Math.max(0, local - 2),\n fps: 30,\n durationInFrames: 16,\n config: { damping: 11, stiffness: 180, mass: 0.65 },\n });\n const ringStroke = mix(stroke * 0.8, stroke * 1.1, anticipate);\n const exitStroke = mix(ringStroke, stroke * 2.2, exit);\n // The inner edge, not just the centerline, must pass every corner.\n const clearRadius = Math.hypot(w, h) / 2 + stroke * 2.2 + 2;\n const orbitRadius = mix(\n mix(28 * unit, burstRadius, launch),\n ringRadius,\n assemble,\n );\n const finalRadius = mix(ringRadius, ringRadius * 0.84, anticipate);\n const strength = Math.min(1.5, Math.max(0, finite(intensity, 1)));\n const energy = Math.sin(Math.PI * progress(local, 18, 84));\n const tilt =\n easeOut(progress(local, 18, 48)) *\n (1 - easeInOut(progress(local, 96, 114)));\n\n return {\n frame: local,\n count,\n unit,\n strength,\n energy: Math.max(0, energy) * strength,\n planeScale: 1 - tilt * 0.46 * Math.min(1.5, strength),\n planeAngle:\n Math.sin(progress(local, 18, 114) * Math.PI * 1.6) * 32 * strength,\n offsetX:\n Math.sin(Math.PI * progress(local, 18, 114)) * 65 * unit * strength,\n offsetY:\n -Math.sin(Math.PI * progress(local, 18, 114)) * 32 * unit * strength,\n dotRadius: 37 * unit * pop * (1 - easeOut(progress(local, 18, 26))),\n dotSquash: 1 - Math.sin(Math.PI * progress(local, 2, 18)) * 0.16,\n showSegments: local >= 18 && local < 84,\n showRing: local >= 84 && local < radialBurstLength,\n segmentOpacity: easeOut(progress(local, 18, 23)),\n radius: local < 84 ? orbitRadius : mix(finalRadius, clearRadius, exit),\n strokeWidth: local < 84 ? mix(stroke, stroke * 0.8, assemble) : exitStroke,\n segmentLength: mix(\n 12 * unit,\n Math.min(82 * unit, burstRadius * 0.42),\n easeOut(progress(local, 18, 36)),\n ),\n curl,\n // Gaps close with a tiny overlap to prevent raster seams at the weld.\n arcAngle: ((Math.PI * 2) / count) * mix(0.62, 1.002, close),\n rotation: finite(rotation, 135) * easeInOut(progress(local, 34, 84)),\n };\n}\n\n/** A straight rounded spoke curls continuously into a circular arc. */\nfunction getSegmentPoints({\n radius,\n segmentLength,\n arcAngle,\n curl,\n}: Pick<\n ReturnType<typeof getRadialBurstState>,\n \"radius\" | \"segmentLength\" | \"arcAngle\" | \"curl\"\n>) {\n const half = arcAngle / 2;\n const x = radius * Math.cos(half);\n const y = radius * Math.sin(half);\n const tangent = (4 / 3) * Math.tan(arcAngle / 4) * radius;\n const arc = [\n [x, -y],\n [x + tangent * Math.sin(half), -y + tangent * Math.cos(half)],\n [x + tangent * Math.sin(half), y - tangent * Math.cos(half)],\n [x, y],\n ];\n const angle = (curl * Math.PI) / 2;\n return [-0.5, -1 / 6, 1 / 6, 0.5].map((offset, index) => {\n const px = radius + segmentLength * offset * Math.cos(angle);\n const py = segmentLength * offset * Math.sin(angle);\n return [mix(px, arc[index][0], curl), mix(py, arc[index][1], curl)];\n });\n}\n\nfunction getRadialBurstSegmentPath(\n state: Parameters<typeof getSegmentPoints>[0],\n) {\n const points = getSegmentPoints(state).map((point) =>\n point.map((value) => value.toFixed(3)).join(\" \"),\n );\n return `M ${points[0]} C ${points[1]} ${points[2]} ${points[3]}`;\n}\n\n/** Sample a bent centerline and its normals to make a tapered, filled ribbon. */\nfunction getRadialBurstRibbonPath(\n state: ReturnType<typeof getRadialBurstState>,\n index: number,\n twist = 110,\n) {\n const energy = state.energy;\n const points = getSegmentPoints({\n ...state,\n radius: state.radius * (1 + Math.sin(index * 2.4) * energy * 0.15),\n segmentLength: state.segmentLength * (1 + energy * 2.8),\n });\n const bend =\n (Math.min(180, Math.max(-180, finite(twist, 110))) / 110) *\n energy *\n 145 *\n state.unit;\n points[1][1] += bend * 0.55;\n points[2][1] += bend;\n // Carry the tip with the bend so the centerline does not double back into\n // a hairpin while the ribbon transitions from a spoke to an arc.\n points[3][1] += bend * 1.25;\n points[2][0] += energy * 38 * state.unit;\n const upper: string[] = [];\n const lower: string[] = [];\n const format = (x: number, y: number) => `${x.toFixed(3)} ${y.toFixed(3)}`;\n let firstWidth = 0;\n let lastWidth = 0;\n for (let sample = 0; sample <= 36; sample++) {\n const t = sample / 36;\n const q = 1 - t;\n const x =\n q ** 3 * points[0][0] +\n 3 * q * q * t * points[1][0] +\n 3 * q * t * t * points[2][0] +\n t ** 3 * points[3][0];\n const y =\n q ** 3 * points[0][1] +\n 3 * q * q * t * points[1][1] +\n 3 * q * t * t * points[2][1] +\n t ** 3 * points[3][1];\n const dx =\n 3 * q * q * (points[1][0] - points[0][0]) +\n 6 * q * t * (points[2][0] - points[1][0]) +\n 3 * t * t * (points[3][0] - points[2][0]);\n const dy =\n 3 * q * q * (points[1][1] - points[0][1]) +\n 6 * q * t * (points[2][1] - points[1][1]) +\n 3 * t * t * (points[3][1] - points[2][1]);\n const length = Math.max(0.001, Math.hypot(dx, dy));\n const ddx =\n 6 * q * (points[2][0] - 2 * points[1][0] + points[0][0]) +\n 6 * t * (points[3][0] - 2 * points[2][0] + points[1][0]);\n const ddy =\n 6 * q * (points[2][1] - 2 * points[1][1] + points[0][1]) +\n 6 * t * (points[3][1] - 2 * points[2][1] + points[1][1]);\n const curvature = Math.abs(dx * ddy - dy * ddx) / length ** 3;\n const swell = Math.sin(Math.PI * t) ** 1.4;\n // Offset curves fold back on themselves when their width exceeds the\n // bend radius. Limit the width locally to keep tight curls smooth.\n const halfWidth = Math.min(\n (state.strokeWidth / 2) * (1 + energy * (2.4 * swell - 0.65 * t)),\n 0.72 / Math.max(curvature, 0.00001),\n );\n if (sample === 0) firstWidth = halfWidth;\n if (sample === 36) lastWidth = halfWidth;\n upper.push(\n format(x - (dy / length) * halfWidth, y + (dx / length) * halfWidth),\n );\n lower.push(\n format(x + (dy / length) * halfWidth, y - (dx / length) * halfWidth),\n );\n }\n return `M ${upper.join(\" L \")} A ${lastWidth} ${lastWidth} 0 0 0 ${lower[36]} L ${lower.slice(0, -1).reverse().join(\" L \")} A ${firstWidth} ${firstWidth} 0 0 0 ${upper[0]} Z`;\n}\n\nfunction RadialBurstBase({\n segments = 8,\n radius = 210,\n thickness = 30,\n rotation = 135,\n intensity = 1,\n twist = 110,\n echoes = 3,\n color = \"#ffffff\",\n accentColor = \"#f4e4a7\",\n backgroundColor = \"#a800b7\",\n speed = 1,\n loop = false,\n className,\n}: RadialBurstProps) {\n const frame = useCurrentFrame();\n const { width, height, fps } = useVideoConfig();\n const time = frame * (30 / fps) * Math.max(0, finite(speed, 1));\n const options = {\n segments,\n radius,\n thickness,\n rotation,\n intensity,\n loop,\n width,\n height,\n };\n const state = getRadialBurstState(time, options);\n const path = getRadialBurstSegmentPath(state);\n const echoCount = Math.round(Math.min(5, Math.max(0, finite(echoes, 3))));\n const plane = (pose: typeof state) =>\n `translate(${pose.offsetX} ${pose.offsetY}) rotate(${pose.planeAngle}) scale(1 ${pose.planeScale})`;\n const ribbons = (pose: typeof state, outline: boolean) =>\n Array.from({ length: pose.count }, (_, index) => (\n <path\n key={index}\n d={getRadialBurstRibbonPath(pose, index, twist)}\n transform={`rotate(${(index * 360) / pose.count + pose.rotation - 90 + Math.sin(index * 1.7) * pose.energy * 16})`}\n fill={\n outline\n ? \"none\"\n : index % 3 === 0\n ? interpolateColors(\n clamp(pose.energy),\n [0, 1],\n [color, accentColor],\n )\n : color\n }\n stroke={outline ? color : \"none\"}\n strokeWidth={1.5 * pose.unit}\n />\n ));\n\n return (\n <div\n className={className}\n style={{\n position: \"absolute\",\n inset: 0,\n overflow: \"hidden\",\n backgroundColor,\n }}\n >\n <svg\n width=\"100%\"\n height=\"100%\"\n viewBox={`0 0 ${width} ${height}`}\n role=\"img\"\n aria-label=\"Geometric radial burst\"\n style={{ display: \"block\" }}\n >\n <g transform={`translate(${width / 2} ${height / 2})`}>\n {state.strength > 0 &&\n state.frame >= 18 &&\n state.frame < radialBurstLength\n ? Array.from({ length: echoCount }, (_, index) => {\n const lag = (echoCount - index) * 2.2;\n const echo = getRadialBurstState(\n Math.max(18, state.frame - lag),\n { ...options, loop: false },\n );\n const opacity =\n 0.36 *\n (1 - index / (echoCount + 1)) *\n Math.min(1, state.strength) *\n (1 - easeOut(progress(state.frame, 107, 114)));\n return (\n <g key={index} transform={plane(echo)} opacity={opacity}>\n {echo.showSegments ? (\n ribbons(echo, true)\n ) : echo.showRing ? (\n <circle\n r={echo.radius}\n fill=\"none\"\n stroke={index % 2 ? color : accentColor}\n strokeWidth={echo.strokeWidth * (0.22 + index * 0.07)}\n />\n ) : null}\n </g>\n );\n })\n : null}\n <g transform={plane(state)}>\n {state.dotRadius > 0.001 ? (\n <circle\n r={state.dotRadius}\n fill={color}\n transform={`scale(${1 / state.dotSquash} ${state.dotSquash})`}\n />\n ) : null}\n {state.showSegments && state.strength > 0 ? (\n <g opacity={state.segmentOpacity}>{ribbons(state, false)}</g>\n ) : state.showSegments ? (\n <g\n fill=\"none\"\n stroke={color}\n strokeWidth={state.strokeWidth}\n strokeLinecap=\"round\"\n opacity={state.segmentOpacity}\n transform={`rotate(${state.rotation - 90})`}\n >\n {Array.from({ length: state.count }, (_, index) => (\n <path\n key={index}\n d={path}\n transform={`rotate(${(index * 360) / state.count})`}\n />\n ))}\n </g>\n ) : null}\n {state.showRing ? (\n <circle\n r={state.radius}\n fill=\"none\"\n stroke={color}\n strokeWidth={state.strokeWidth}\n />\n ) : null}\n </g>\n </g>\n </svg>\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n segments: {\n type: \"number\",\n default: 8,\n min: 4,\n max: 16,\n step: 1,\n description: \"Segments\",\n hiddenFromList: false,\n },\n radius: {\n type: \"number\",\n default: 210,\n min: 100,\n max: 280,\n step: 5,\n description: \"Burst radius\",\n hiddenFromList: false,\n },\n thickness: {\n type: \"number\",\n default: 30,\n min: 8,\n max: 60,\n step: 1,\n description: \"Thickness\",\n hiddenFromList: false,\n },\n rotation: {\n type: \"number\",\n default: 135,\n min: -360,\n max: 360,\n step: 15,\n description: \"Rotation\",\n hiddenFromList: false,\n },\n intensity: {\n type: \"number\",\n default: 1,\n min: 0,\n max: 1.5,\n step: 0.1,\n description: \"Intensity\",\n hiddenFromList: false,\n },\n twist: {\n type: \"number\",\n default: 110,\n min: -180,\n max: 180,\n step: 10,\n description: \"Ribbon twist\",\n hiddenFromList: false,\n },\n echoes: {\n type: \"number\",\n default: 3,\n min: 0,\n max: 5,\n step: 1,\n description: \"Contour echoes\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#ffffff\",\n description: \"Shape color\",\n },\n accentColor: {\n type: \"color\",\n default: \"#f4e4a7\",\n description: \"Accent color\",\n },\n backgroundColor: {\n type: \"color\",\n default: \"#a800b7\",\n description: \"Background\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop animation\",\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"segments\",\"radius\",\"thickness\",\"rotation\",\"intensity\",\"twist\",\"echoes\",\"color\",\"accentColor\",\"backgroundColor\",\"loop\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n segments: 8,\n radius: 210,\n thickness: 30,\n rotation: 135,\n intensity: 1,\n twist: 110,\n echoes: 3,\n color: \"#ffffff\",\n accentColor: \"#f4e4a7\",\n backgroundColor: \"#a800b7\",\n loop: false,\n speed: 1,\n};\n\ntype RadialBurstElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof RadialBurstBase>;\n\nconst RadialBurstInner = forwardRef<\n HTMLDivElement,\n RadialBurstElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<RadialBurst>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <RadialBurstBase\n {...(componentProps as unknown as ComponentProps<typeof RadialBurstBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const RadialBurst = Interactive.withSchema({\n Component: RadialBurstInner,\n componentName: \"<RadialBurst>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/reel.json b/registry-artifacts/elements/reel.jsonindex a530023d..e49197f4 100644--- a/registry-artifacts/elements/reel.json+++ b/registry-artifacts/elements/reel.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [],"dimensions": {"width": 1180,@@ -9,6 +10,7 @@},"displayName": "Reel","durationInFrames": 160,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "reel","sourceCode": "import { AbsoluteFill, Easing, Img, Interactive, Sequence, interpolate, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\nconst clamp = {\n extrapolateLeft: \"clamp\" as const,\n extrapolateRight: \"clamp\" as const,\n};\nconst EASE_OUT = Easing.out(Easing.cubic);\n\ntype ReelProps = {\n images: string[];\n width?: number;\n height?: number;\n radius?: number;\n step?: number;\n reveal?: number;\n objectPosition?: string;\n background?: string;\n};\n\nfunction ReelBase({\n images,\n width = 1180,\n height = 676,\n radius = 16,\n step = 20,\n reveal = 13,\n objectPosition = \"top\",\n background = \"#050506\",\n}: ReelProps) {\n const frame = useCurrentFrame();\n const { width: compWidth, height: compHeight } = useVideoConfig();\n const left = (compWidth - width) / 2;\n const top = (compHeight - height) / 2;\n\n return (\n <AbsoluteFill>\n {images.map((src, i) => {\n const p = interpolate(frame, [i * step, i * step + reveal], [0, 1], {\n ...clamp,\n easing: EASE_OUT,\n });\n if (p <= 0) return null;\n const inset = (1 - p) * 50;\n const imgScale = interpolate(p, [0, 1], [1.08, 1], clamp);\n return (\n <div\n key={i}\n style={{\n position: \"absolute\",\n left,\n top,\n width,\n height,\n zIndex: i,\n clipPath: `inset(${inset}% ${inset}% round ${radius}px)`,\n WebkitClipPath: `inset(${inset}% ${inset}% round ${radius}px)`,\n background,\n boxShadow: \"0 30px 80px rgba(0,0,0,0.6)\",\n willChange: \"clip-path\",\n }}\n >\n <Img\n src={src}\n style={{\n width: \"100%\",\n height: \"100%\",\n objectFit: \"cover\",\n objectPosition,\n scale: `${imgScale}`,\n willChange: \"transform\",\n }}\n />\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n borderRadius: radius,\n border: \"1px solid rgba(255,255,255,0.08)\",\n }}\n />\n </div>\n );\n })}\n </AbsoluteFill>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n width: {\n type: \"number\",\n min: 600,\n max: 1280,\n step: 20,\n default: 1180,\n description: \"Card width\",\n hiddenFromList: false,\n },\n height: {\n type: \"number\",\n min: 360,\n max: 720,\n step: 4,\n default: 676,\n description: \"Card height\",\n hiddenFromList: false,\n },\n radius: {\n type: \"number\",\n min: 0,\n max: 40,\n step: 1,\n default: 16,\n description: \"Corner radius\",\n hiddenFromList: false,\n },\n step: {\n type: \"number\",\n min: 6,\n max: 40,\n step: 1,\n default: 20,\n description: \"Frames / image\",\n hiddenFromList: false,\n },\n reveal: {\n type: \"number\",\n min: 4,\n max: 30,\n step: 1,\n default: 13,\n description: \"Reveal frames\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"width\",\"height\",\"radius\",\"step\",\"reveal\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n width: 1180,\n height: 676,\n radius: 16,\n step: 20,\n reveal: 13,\n speed: 1,\n};\n\ntype ReelElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof ReelBase>;\n\nconst ReelInner = forwardRef<\n HTMLDivElement,\n ReelElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<Reel>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: 1180,\n height: 676,\n ...style,\n }}\n >\n <ReelBase\n {...(componentProps as unknown as ComponentProps<typeof ReelBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const Reel = Interactive.withSchema({\n Component: ReelInner,\n componentName: \"<Reel>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/rgb-glitch-text.json b/registry-artifacts/elements/rgb-glitch-text.jsonindex a2bc8f12..b48c4d82 100644--- a/registry-artifacts/elements/rgb-glitch-text.json+++ b/registry-artifacts/elements/rgb-glitch-text.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [],"dimensions": {"width": 300,@@ -9,6 +10,7 @@},"displayName": "RGB Glitch Text","durationInFrames": 90,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "rgb-glitch-text","sourceCode": "import { Interactive, Sequence, random, useCurrentFrame, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface RGBGlitchTextProps {\n text: string;\n fontSize?: number;\n color?: string;\n fontWeight?: number;\n glitchAt?: number;\n glitchDuration?: number;\n intensity?: number;\n seed?: string;\n speed?: number;\n className?: string;\n}\n\nfunction RGBGlitchTextBase({\n text,\n fontSize = 96,\n color = \"#171717\",\n fontWeight = 700,\n glitchAt = 20,\n glitchDuration = 8,\n intensity = 6,\n seed = \"glitch\",\n speed = 1,\n className,\n}: RGBGlitchTextProps) {\n const frame = useCurrentFrame() * speed;\n\n const isGlitching = frame >= glitchAt && frame < glitchAt + glitchDuration;\n\n const offset = (axisSeed: string, scale: number) =>\n (random(`${seed}-${axisSeed}-${frame}`) * 2 - 1) * scale;\n\n const rX = isGlitching ? offset(\"r-x\", intensity) : 0;\n const rY = isGlitching ? offset(\"r-y\", intensity * 0.4) : 0;\n const gX = isGlitching ? offset(\"g-x\", intensity) : 0;\n const gY = isGlitching ? offset(\"g-y\", intensity * 0.4) : 0;\n const bX = isGlitching ? offset(\"b-x\", intensity) : 0;\n const bY = isGlitching ? offset(\"b-y\", intensity * 0.4) : 0;\n\n const copyOpacity = isGlitching ? 1 : 0;\n\n const baseStyle: React.CSSProperties = {\n position: \"absolute\",\n top: 0,\n left: 0,\n fontSize,\n fontWeight,\n letterSpacing: \"-0.03em\",\n fontFamily:\n \"var(--font-geist-sans), -apple-system, BlinkMacSystemFont, sans-serif\",\n whiteSpace: \"pre\",\n mixBlendMode: \"multiply\",\n };\n\n return (\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n background: \"#fafafa\",\n }}\n >\n <div\n className={className}\n style={{ position: \"relative\", display: \"inline-block\" }}\n >\n <span\n style={{\n position: \"relative\",\n fontSize,\n fontWeight,\n color,\n letterSpacing: \"-0.03em\",\n fontFamily:\n \"var(--font-geist-sans), -apple-system, BlinkMacSystemFont, sans-serif\",\n whiteSpace: \"pre\",\n }}\n >\n {text}\n </span>\n <span\n style={{\n ...baseStyle,\n color: \"#ff0040\",\n opacity: copyOpacity,\n translate: `${rX}px ${rY}px`,\n }}\n >\n {text}\n </span>\n <span\n style={{\n ...baseStyle,\n color: \"#00ff80\",\n opacity: copyOpacity,\n translate: `${gX}px ${gY}px`,\n }}\n >\n {text}\n </span>\n <span\n style={{\n ...baseStyle,\n color: \"#0080ff\",\n opacity: copyOpacity,\n translate: `${bX}px ${bY}px`,\n }}\n >\n {text}\n </span>\n </div>\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n text: {\n type: \"text-content\",\n default: \"GLITCH\",\n description: \"Text\",\n },\n fontSize: {\n type: \"number\",\n min: 12,\n max: 200,\n step: 1,\n default: 96,\n description: \"Font size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n fontWeight: {\n type: \"enum\",\n default: \"700\",\n variants: {\n \"400\": {},\n \"500\": {},\n \"600\": {},\n \"700\": {},\n },\n description: \"Font weight\",\n },\n glitchAt: {\n type: \"number\",\n min: 0,\n max: 120,\n step: 1,\n default: 20,\n description: \"Glitch at (frame)\",\n hiddenFromList: false,\n },\n glitchDuration: {\n type: \"number\",\n min: 1,\n max: 60,\n step: 1,\n default: 8,\n description: \"Glitch duration\",\n hiddenFromList: false,\n },\n intensity: {\n type: \"number\",\n min: 0,\n max: 30,\n step: 1,\n default: 6,\n description: \"Intensity (px)\",\n hiddenFromList: false,\n },\n seed: {\n type: \"text-content\",\n default: \"glitch\",\n description: \"Seed\",\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 300,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 130,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"text\",\"fontSize\",\"color\",\"fontWeight\",\"glitchAt\",\"glitchDuration\",\"intensity\",\"seed\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n text: \"GLITCH\",\n fontSize: 96,\n color: \"#171717\",\n fontWeight: \"700\",\n glitchAt: 20,\n glitchDuration: 8,\n intensity: 6,\n seed: \"glitch\",\n speed: 1,\n};\n\ntype RGBGlitchTextElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof RGBGlitchTextBase>;\n\nconst RGBGlitchTextInner = forwardRef<\n HTMLDivElement,\n RGBGlitchTextElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 300, height = 130, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<RGBGlitchText>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <RGBGlitchTextBase\n {...(componentProps as unknown as ComponentProps<typeof RGBGlitchTextBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const RGBGlitchText = Interactive.withSchema({\n Component: RGBGlitchTextInner,\n componentName: \"<RGBGlitchText>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/ring-text.json b/registry-artifacts/elements/ring-text.jsonindex c84cfd8f..15f110bd 100644--- a/registry-artifacts/elements/ring-text.json+++ b/registry-artifacts/elements/ring-text.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/google-fonts",@@ -11,6 +12,7 @@"dimensions": null,"displayName": "Ring Text","durationInFrames": 180,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "ring-text","sourceCode": "import { loadFont } from \"@remotion/google-fonts/Inter\";\nimport { forwardRef, useEffect, useImperativeHandle, useRef, useState, type ComponentProps } from \"react\";\nimport { Easing, Interactive, Sequence, continueRender, delayRender, interpolate, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\n\nconst { fontFamily: INTER } = loadFont(\"normal\", {\n weights: [\"100\", \"900\"],\n subsets: [\"latin\"],\n});\n\ninterface RingTextProps {\n text?: string;\n separator?: string;\n radius?: number;\n fontSize?: number;\n fontWeight?: number;\n fontFamily?: string;\n color?: string;\n band?: string;\n tilt?: number;\n roll?: number;\n period?: number;\n speed?: number;\n className?: string;\n}\n\nconst ringTextDefaults = {\n text: \"Type in motion\",\n separator: \"•\",\n radius: 210,\n fontSize: 40,\n fontWeight: 800,\n fontFamily: INTER,\n color: \"#fafafa\",\n band: \"#0a0a0a\",\n tilt: 38,\n roll: -16,\n period: 240,\n speed: 1,\n} satisfies Required<Omit<RingTextProps, \"className\">>;\n\n/** Frame where the entrance has settled into the cruise spin. */\nconst ringTextLength = 30;\n\n/** Band height, in em. */\nconst ringBandHeight = 1.5;\n\nconst ENTRANCE = 30;\nconst FADE = 12;\nconst START_SCALE = 0.85;\n/** Extra turn, in degrees, that decays over the entrance. */\nconst ENTRANCE_SPIN = 90;\nconst WOBBLE = 6;\nconst WOBBLE_PERIOD = 150;\n/** Letters on the far side of the ring dim to this opacity. */\nconst BACK_OPACITY = 0.55;\n/** Advance per character, in em, until the face is measured. */\nconst FALLBACK_ADVANCE = 0.6;\n\nconst CLAMP = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n} as const;\n\nconst easeOutCubic = Easing.out(Easing.cubic);\n\nfunction finite(value: number | undefined, fallback: number) {\n return typeof value === \"number\" && Number.isFinite(value) ? value : fallback;\n}\n\n/** Maps a composition frame onto the 30 fps timeline, scaled by `speed`. */\nfunction getRingTextTime(\n frame: number,\n options: { fps?: number; speed?: number } = {},\n) {\n const fps = Math.max(1, finite(options.fps, 30));\n const speed = Math.max(0, finite(options.speed, 1));\n return (Math.max(0, finite(frame, 0)) * 30 * speed) / fps;\n}\n\n/** The characters of one lap: the text, a space, the separator, a space. */\nfunction getRingTextToken(text: string, separator: string) {\n return Array.from(separator ? `${text} ${separator} ` : `${text} `);\n}\n\ninterface RingTextPanel {\n /** Index into the token. */\n char: number;\n /** Panel center around the ring, radians. */\n angle: number;\n /** Panel width, reference px. */\n width: number;\n}\n\ninterface RingTextLayout {\n radius: number;\n repeats: number;\n /** Extra space added to every character so the band closes, reference px. */\n spacing: number;\n panels: RingTextPanel[];\n}\n\n/**\n * Repeats the token as many times as fits the circumference and spreads the\n * remainder as letter spacing. A token longer than the ring grows the radius.\n */\nfunction getRingTextLayout(\n advances: readonly number[],\n radius: number,\n): RingTextLayout {\n const tokenWidth = advances.reduce((sum, a) => sum + Math.max(0, a), 0);\n const count = advances.length;\n if (count === 0 || tokenWidth <= 0) {\n return { radius, repeats: 0, spacing: 0, panels: [] };\n }\n const circumference = Math.max(2 * Math.PI * Math.max(0, radius), tokenWidth);\n const repeats = Math.max(1, Math.floor(circumference / tokenWidth));\n const spacing = (circumference - repeats * tokenWidth) / (repeats * count);\n const panels: RingTextPanel[] = [];\n let travelled = 0;\n for (let r = 0; r < repeats; r++) {\n for (let char = 0; char < count; char++) {\n const width = Math.max(0, advances[char]) + spacing;\n panels.push({\n char,\n angle: (2 * Math.PI * (travelled + width / 2)) / circumference,\n width,\n });\n travelled += width;\n }\n }\n return {\n radius: circumference / (2 * Math.PI),\n repeats,\n spacing,\n panels,\n };\n}\n\n/** Ring pose at `t`: spin in degrees, tilt with its wobble, entrance scale and opacity. */\nfunction getRingTextPose(\n t: number,\n options: { period?: number; tilt?: number } = {},\n) {\n const period = Math.max(1, finite(options.period, ringTextDefaults.period));\n const tilt = finite(options.tilt, ringTextDefaults.tilt);\n const settle = easeOutCubic(Math.min(1, Math.max(0, t / ENTRANCE)));\n return {\n spin: (360 * t) / period + ENTRANCE_SPIN * settle,\n tilt: tilt + WOBBLE * Math.sin((2 * Math.PI * t) / WOBBLE_PERIOD),\n scale: START_SCALE + (1 - START_SCALE) * settle,\n opacity: interpolate(t, [0, FADE], [0, 1], CLAMP),\n };\n}\n\n/** Letter opacity from how squarely its panel faces the camera. */\nfunction getRingTextShade(angle: number, spinDegrees: number) {\n const facing = Math.cos(angle - (spinDegrees * Math.PI) / 180);\n return BACK_OPACITY + ((1 - BACK_OPACITY) * (facing + 1)) / 2;\n}\n\nfunction useAdvances(chars: readonly string[], font: string, fallback: number) {\n const key = chars.join(\"\");\n const [advances, setAdvances] = useState<number[] | null>(null);\n\n useEffect(() => {\n const handle = delayRender(\"ring-text: measuring the characters\");\n let released = false;\n const release = () => {\n if (released) return;\n released = true;\n continueRender(handle);\n };\n const measure = () => {\n if (released) return;\n const ctx = document.createElement(\"canvas\").getContext(\"2d\");\n if (ctx) {\n ctx.font = font;\n setAdvances(Array.from(key).map((c) => ctx.measureText(c).width));\n }\n release();\n };\n document.fonts.load(font, key).then(measure, measure);\n return release;\n }, [key, font]);\n\n return advances ?? chars.map(() => fallback);\n}\n\nfunction RingTextBase({\n text = ringTextDefaults.text,\n separator = ringTextDefaults.separator,\n radius = ringTextDefaults.radius,\n fontSize = ringTextDefaults.fontSize,\n fontWeight = ringTextDefaults.fontWeight,\n fontFamily = ringTextDefaults.fontFamily,\n color = ringTextDefaults.color,\n band = ringTextDefaults.band,\n tilt = ringTextDefaults.tilt,\n roll = ringTextDefaults.roll,\n period = ringTextDefaults.period,\n speed = ringTextDefaults.speed,\n className,\n}: RingTextProps) {\n const frame = useCurrentFrame();\n const { fps, height } = useVideoConfig();\n const unit = height / 720;\n const t = getRingTextTime(frame, { fps, speed });\n const chars = getRingTextToken(text, separator);\n const advances = useAdvances(\n chars,\n `${fontWeight} ${fontSize}px ${fontFamily}`,\n FALLBACK_ADVANCE * fontSize,\n );\n const layout = getRingTextLayout(advances, radius);\n const pose = getRingTextPose(t, { period, tilt });\n const bandHeight = ringBandHeight * fontSize * unit;\n // Adjacent flat panels meet at an angle and their antialiased edges let the\n // background through; bleeding each panel into its neighbors hides the seam.\n const bleed = 1.5 * Math.max(1, unit);\n\n return (\n <div\n className={className}\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n overflow: \"hidden\",\n perspective: 1600 * unit,\n // Opacity lives here: on the preserve-3d ring it would flatten it.\n opacity: pose.opacity,\n }}\n >\n <div\n style={{\n position: \"relative\",\n width: 0,\n height: 0,\n transformStyle: \"preserve-3d\",\n // Negative tilt views the ring from above: the near side is at the\n // bottom and reads left to right, the far side shows it mirrored.\n transform: `scale(${pose.scale}) rotateZ(${roll}deg) rotateX(${-pose.tilt}deg) rotateY(${-pose.spin}deg)`,\n }}\n >\n {layout.panels.map((panel, i) => {\n const width = panel.width * unit;\n return (\n <div\n key={i}\n style={{\n position: \"absolute\",\n left: -width / 2 - bleed,\n top: -bandHeight / 2,\n width: width + 2 * bleed,\n height: bandHeight,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n background: band,\n color,\n fontFamily,\n fontSize: fontSize * unit,\n lineHeight: 1,\n fontWeight,\n fontVariationSettings: `\"wght\" ${fontWeight}`,\n whiteSpace: \"pre\",\n backfaceVisibility: \"visible\",\n transform: `rotateY(${panel.angle}rad) translateZ(${layout.radius * unit}px)`,\n }}\n >\n {/* Only the letter dims: shading the band per panel would show\n every seam between panels. */}\n <span\n style={{\n opacity: getRingTextShade(panel.angle, pose.spin),\n }}\n >\n {chars[panel.char]}\n </span>\n </div>\n );\n })}\n </div>\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n text: {\n type: \"text-content\",\n default: \"Type in motion\",\n description: \"Text\",\n },\n separator: {\n type: \"text-content\",\n default: \"•\",\n description: \"Separator\",\n },\n color: {\n type: \"color\",\n default: \"#d4ff1f\",\n description: \"Text color\",\n },\n band: {\n type: \"color\",\n default: \"#0a0a0a\",\n description: \"Band color\",\n },\n radius: {\n type: \"number\",\n default: 210,\n min: 80,\n max: 340,\n step: 5,\n description: \"Radius\",\n hiddenFromList: false,\n },\n fontSize: {\n type: \"number\",\n default: 40,\n min: 16,\n max: 90,\n step: 1,\n description: \"Font size\",\n hiddenFromList: false,\n },\n tilt: {\n type: \"number\",\n default: 38,\n min: 0,\n max: 80,\n step: 1,\n description: \"Tilt\",\n hiddenFromList: false,\n },\n roll: {\n type: \"number\",\n default: -16,\n min: -60,\n max: 60,\n step: 1,\n description: \"Roll\",\n hiddenFromList: false,\n },\n period: {\n type: \"number\",\n default: 240,\n min: 60,\n max: 900,\n step: 10,\n description: \"Frames per turn\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"text\",\"separator\",\"color\",\"band\",\"radius\",\"fontSize\",\"tilt\",\"roll\",\"period\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n text: \"Type in motion\",\n separator: \"•\",\n color: \"#d4ff1f\",\n band: \"#0a0a0a\",\n radius: 210,\n fontSize: 40,\n tilt: 38,\n roll: -16,\n period: 240,\n speed: 1,\n};\n\ntype RingTextElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof RingTextBase>;\n\nconst RingTextInner = forwardRef<\n HTMLDivElement,\n RingTextElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<RingText>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <RingTextBase\n {...(componentProps as unknown as ComponentProps<typeof RingTextBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const RingText = Interactive.withSchema({\n Component: RingTextInner,\n componentName: \"<RingText>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/rolling-number.json b/registry-artifacts/elements/rolling-number.jsonindex 03c18bb9..efad9f91 100644--- a/registry-artifacts/elements/rolling-number.json+++ b/registry-artifacts/elements/rolling-number.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/google-fonts",@@ -14,6 +15,7 @@},"displayName": "Rolling Number","durationInFrames": 150,+ "initialProps": null,"installationMode": "wrapped","slug": "rolling-number","sourceCode": "import { loadFont as loadMono } from \"@remotion/google-fonts/JetBrainsMono\";\nimport { AbsoluteFill, Easing, interpolate, useCurrentFrame, useVideoConfig } from \"remotion\";\nimport React from \"react\";\n\nconst { fontFamily: MONO_FAMILY } = loadMono();\n\nexport interface RollingNumberProps {\n from?: number;\n to?: number;\n fontSize?: number;\n color?: string;\n speed?: number;\n}\n\nconst COUNT_PORTION = 0.8;\nconst COUNT_EASING = Easing.out(Easing.poly(4));\nconst REVEAL_BAND = 0.4;\nconst REVEAL_EASING = Easing.inOut(Easing.sin);\nconst REVEAL_RISE_EM = 0.32;\n\nfunction easedProgress(\n frame: number,\n speed: number,\n durationInFrames: number,\n): number {\n return interpolate(\n frame * speed,\n [0, durationInFrames * COUNT_PORTION],\n [0, 1],\n {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: COUNT_EASING,\n },\n );\n}\n\nfunction placeTravel(start: number, end: number, place: number): number {\n const pow = 10 ** place;\n const up = end >= start;\n const diff = Math.abs(end - start);\n const startDigit = Math.floor(start / pow) % 10;\n const finalDigit = Math.floor(end / pow) % 10;\n const fullTurns = Math.floor(diff / (pow * 10));\n const stepDelta = up\n ? (finalDigit - startDigit + 10) % 10\n : (startDigit - finalDigit + 10) % 10;\n const magnitude = fullTurns * 10 + stepDelta;\n return up ? magnitude : -magnitude;\n}\n\nfunction placeReveal(current: number, place: number): number {\n if (place === 0) return 1;\n const threshold = 10 ** place;\n return interpolate(current, [threshold * REVEAL_BAND, threshold], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: REVEAL_EASING,\n });\n}\n\nfunction wrap10(value: number): number {\n return ((value % 10) + 10) % 10;\n}\n\nfunction DigitColumn({\n value,\n fontSize,\n reveal,\n}: {\n value: number;\n fontSize: number;\n reveal: number;\n}) {\n const cellHeight = fontSize * 1.1;\n return (\n <span\n style={{\n display: \"inline-block\",\n overflow: \"hidden\",\n height: cellHeight,\n width: \"0.62em\",\n verticalAlign: \"top\",\n textAlign: \"center\",\n opacity: reveal,\n translate: `0 ${(1 - reveal) * fontSize * REVEAL_RISE_EM}px`,\n }}\n >\n <span\n style={{\n display: \"flex\",\n flexDirection: \"column\",\n translate: `0 ${-value * cellHeight}px`,\n }}\n >\n {[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0].map((d, i) => (\n <span\n key={i}\n style={{ height: cellHeight, lineHeight: `${cellHeight}px` }}\n >\n {d}\n </span>\n ))}\n </span>\n </span>\n );\n}\n\nexport function RollingNumber({\n from = 0,\n to = 24813,\n fontSize = 120,\n color = \"#171717\",\n speed = 1,\n}: RollingNumberProps) {\n const frame = useCurrentFrame();\n const { durationInFrames } = useVideoConfig();\n\n const start = Math.max(0, Math.round(from));\n const end = Math.max(0, Math.round(to));\n\n const e = easedProgress(frame, speed, durationInFrames);\n const current = start + e * (end - start);\n\n const maxVal = Math.max(start, end);\n const digits = String(maxVal);\n const cellHeight = fontSize * 1.1;\n\n const cells: React.ReactNode[] = [];\n for (let place = 0; place < digits.length; place++) {\n if (place > 0 && place % 3 === 0) {\n cells.unshift(\n <span\n key={`s${place}`}\n style={{\n display: \"inline-block\",\n width: \"0.34em\",\n height: cellHeight,\n }}\n />,\n );\n }\n const pow = 10 ** place;\n const startDigit = Math.floor(start / pow) % 10;\n const travel = placeTravel(start, end, place);\n const pos = startDigit + e * travel;\n cells.unshift(\n <DigitColumn\n key={`d${place}`}\n value={wrap10(pos)}\n fontSize={fontSize}\n reveal={placeReveal(current, place)}\n />,\n );\n }\n\n return (\n <AbsoluteFill\n style={{\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n style={{\n display: \"flex\",\n alignItems: \"flex-start\",\n fontSize,\n fontWeight: 800,\n color,\n fontFamily: MONO_FAMILY,\n fontVariantNumeric: \"tabular-nums\",\n letterSpacing: \"-0.03em\",\n lineHeight: 1,\n }}\n >\n {cells}\n </div>\n </AbsoluteFill>\n );\n}"diff --git a/registry-artifacts/elements/rolodex-flip.json b/registry-artifacts/elements/rolodex-flip.jsonindex 90660886..4911ba0f 100644--- a/registry-artifacts/elements/rolodex-flip.json+++ b/registry-artifacts/elements/rolodex-flip.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [],"dimensions": {"width": 220,@@ -9,6 +10,7 @@},"displayName": "Rolodex Flip","durationInFrames": 110,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "rolodex-flip","sourceCode": "import { Easing, Interactive, Sequence, interpolate, useCurrentFrame, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport React, { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\nconst clampOpts = {\n extrapolateLeft: \"clamp\" as const,\n extrapolateRight: \"clamp\" as const,\n};\n\ninterface RolodexFlipProps {\n items: string[];\n from?: number;\n interval?: number;\n flipDuration?: number;\n className?: string;\n style?: React.CSSProperties;\n}\n\nfunction RolodexFlipBase({\n items,\n from = 0,\n interval = 20,\n flipDuration = 10,\n className,\n style,\n}: RolodexFlipProps) {\n const frame = useCurrentFrame();\n const sizer = items.reduce((a, b) => (b.length > a.length ? b : a), \"\");\n return (\n <span\n className={className}\n style={{\n position: \"relative\",\n display: \"inline-block\",\n perspective: 420,\n verticalAlign: \"bottom\",\n ...style,\n }}\n >\n <span style={{ visibility: \"hidden\" }}>{sizer}</span>\n {items.map((item, i) => {\n const inStart = from + (i - 1) * interval + flipDuration / 2;\n const outStart = from + i * interval;\n\n let rotate = 0;\n let y = 0;\n let opacity = 1;\n\n if (i > 0) {\n const pIn = interpolate(\n frame,\n [inStart, inStart + flipDuration],\n [0, 1],\n { ...clampOpts, easing: Easing.out(Easing.cubic) },\n );\n rotate = (1 - pIn) * -85;\n y = (1 - pIn) * 20;\n opacity = pIn;\n }\n if (i < items.length - 1) {\n const pOut = interpolate(\n frame,\n [outStart, outStart + flipDuration],\n [0, 1],\n { ...clampOpts, easing: Easing.in(Easing.cubic) },\n );\n rotate += pOut * 85;\n y -= pOut * 20;\n opacity *= 1 - pOut;\n }\n if (opacity <= 0.001) return null;\n\n return (\n <span\n key={`${i}-${item}`}\n style={{\n position: \"absolute\",\n left: 0,\n top: 0,\n whiteSpace: \"nowrap\",\n opacity,\n transform: `translateY(${y}px) rotateX(${rotate}deg)`,\n transformOrigin: \"50% 50%\",\n backfaceVisibility: \"hidden\",\n }}\n >\n {item}\n </span>\n );\n })}\n </span>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n interval: {\n type: \"number\",\n min: 10,\n max: 40,\n step: 2,\n default: 20,\n description: \"Interval\",\n hiddenFromList: false,\n },\n flipDuration: {\n type: \"number\",\n min: 4,\n max: 20,\n step: 1,\n default: 10,\n description: \"Flip duration\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 220,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 60,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"interval\",\"flipDuration\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n interval: 20,\n flipDuration: 10,\n speed: 1,\n};\n\ntype RolodexFlipElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof RolodexFlipBase>;\n\nconst RolodexFlipInner = forwardRef<\n HTMLDivElement,\n RolodexFlipElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 220, height = 60, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<RolodexFlip>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <RolodexFlipBase\n {...(componentProps as unknown as ComponentProps<typeof RolodexFlipBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const RolodexFlip = Interactive.withSchema({\n Component: RolodexFlipInner,\n componentName: \"<RolodexFlip>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/rush-type.json b/registry-artifacts/elements/rush-type.jsonindex b8fa0d06..459140d8 100644--- a/registry-artifacts/elements/rush-type.json+++ b/registry-artifacts/elements/rush-type.json@@ -2,10 +2,12 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [],"dimensions": null,"displayName": "Rush Type","durationInFrames": 104,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "rush-type","sourceCode": "import { forwardRef, useEffect, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState, type ComponentProps } from \"react\";\nimport { Interactive, Sequence, continueRender, delayRender, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\n\ninterface RushTypeProps {\n /** A short phrase. One whitespace-delimited word is shown per cycle. */\n phrase?: string;\n /** Cap height of the resting word in composition pixels. */\n fontSize?: number;\n fontFamily?: string;\n fontWeight?: number;\n color?: string;\n backgroundColor?: string;\n /** Authored vertical scale at the blast before perspective is applied. */\n verticalStretch?: number;\n /** 0 removes channel separation, 1 is the reference look, 2 exaggerates it. */\n chromaticSpread?: number;\n /** Readable resting phase, in frames. */\n restDuration?: number;\n /** Total near-point hang around the word swap, in frames. */\n peakHoldDuration?: number;\n /** Global playback multiplier. */\n speed?: number;\n className?: string;\n}\n\ntype RushTypePhase = \"hang\" | \"arrive\" | \"rest\" | \"depart\";\n\ninterface RushTypeFrameState {\n phase: RushTypePhase;\n wordIndex: number;\n beforeWordIndex: number;\n afterWordIndex: number;\n cycle: number;\n motion: number;\n isResting: boolean;\n swapAmount: number;\n shutterRatios: [number, number, number];\n thinAmount: number;\n bloomAmount: number;\n crtAmount: number;\n groundAmount: number;\n}\n\nconst rushTypeDefaultPhrase = \"gone before you look\";\n\nconst ARRIVE_FRAMES = 7;\nconst LEAVE_FRAMES = 4;\nconst DEFAULT_REST_FRAMES = 12;\nconst DEFAULT_HOLD_FRAMES = 3;\nconst SHUTTER_SECONDS = 0.04;\nconst SMEAR_GAIN = 1.6;\nconst SAMPLES = 28;\nconst SHUTTER_SHAPE = 0.85;\nconst ROLL_U = 0.38;\nconst LAG_U = 0.55;\nconst THIN = 0.55;\nconst BLOOM_GAIN = 0.5;\nconst BLOOM_SPREAD = 3.2;\nconst BLOOM_BIAS = 3.5;\nconst SPEED_GAIN = 0.95;\nconst EXPOSURE = 1.75;\nconst HORIZONTAL_STRETCH = 1.57;\nconst FOCAL = 1;\nconst ORBIT_DEPTH = 0.42;\nconst ORBIT_RISE = 0.16;\nconst ORBIT_YAW = 0.55;\nconst ORBIT_YAW_LAG = 0.6;\nconst ORBIT_PITCH = 0.26;\nconst ORBIT_PITCH_LAG = -0.9;\nconst ORBIT_HANG_ARC = 0.9;\nconst PIVOT_FRAC = 0.07;\nconst CRT_GAIN = 1;\nconst CRT_PITCH = 5;\nconst CRT_MASK = 0.16;\nconst CRT_SCAN_PITCH = 3;\nconst CRT_SCAN = 0.12;\nconst CRT_BEAM = 0.7;\nconst CRT_HUM = 0.035;\nconst CRT_HUM_SPEED = 0.14;\nconst GROUND_SPEED = 0.028;\nconst GLOW_SPREAD = 2.6;\nconst GLOW_MIN = 0.34;\nconst GLOW_MAX_Y = 1.2;\nconst SWAP_SPREAD = 0.35;\nconst SWAP_FLASH = 0.5;\n\nconst FALL = [1, 0.557, 0.121, 0.049, 0.014, 0];\nconst RISE = [0, 0.08, 0.8, 1];\nconst ORBIT_IN = [0, 0.5, 0.82, 0.95, 1, 1];\nconst ORBIT_OUT = [0, 0.05, 0.14, 0.38, 1];\nconst DRIFT_DIRECTION = [-1, 0.7, -0.45, 1];\nconst SWING_ARC = Math.PI - ORBIT_HANG_ARC;\n\nfunction parseHexColor(\n value: string,\n fallback: readonly [number, number, number],\n): [number, number, number] {\n const hex = value.trim().replace(/^#/, \"\");\n const expanded =\n hex.length === 3 ? hex.replace(/./g, (char) => char + char) : hex;\n if (!/^[0-9a-f]{6}$/i.test(expanded)) {\n return [fallback[0], fallback[1], fallback[2]];\n }\n return [\n Number.parseInt(expanded.slice(0, 2), 16) / 255,\n Number.parseInt(expanded.slice(2, 4), 16) / 255,\n Number.parseInt(expanded.slice(4, 6), 16) / 255,\n ];\n}\n\nfunction positiveModulo(value: number, modulus: number): number {\n return ((value % modulus) + modulus) % modulus;\n}\n\nfunction sampleTable(table: readonly number[], progress: number): number {\n const last = table.length - 1;\n const x = Math.min(Math.max(progress, 0), 1) * last;\n const index = Math.min(Math.floor(x), last - 1);\n return table[index] + (table[index + 1] - table[index]) * (x - index);\n}\n\nfunction normalizeRushTypePhrase(phrase: string): string[] {\n const words = phrase.trim().split(/\\s+/).filter(Boolean);\n return words.length > 0 ? words : rushTypeDefaultPhrase.split(\" \");\n}\n\nfunction getRushTypeCycleLength(\n restDuration = DEFAULT_REST_FRAMES,\n peakHoldDuration = DEFAULT_HOLD_FRAMES,\n): number {\n return (\n ARRIVE_FRAMES +\n LEAVE_FRAMES +\n Math.max(restDuration, 1) +\n Math.max(peakHoldDuration, 0)\n );\n}\n\nfunction getRushTypeDuration({\n phrase = rushTypeDefaultPhrase,\n restDuration = DEFAULT_REST_FRAMES,\n peakHoldDuration = DEFAULT_HOLD_FRAMES,\n}: Pick<\n RushTypeProps,\n \"phrase\" | \"restDuration\" | \"peakHoldDuration\"\n> = {}): number {\n return Math.round(\n normalizeRushTypePhrase(phrase).length *\n getRushTypeCycleLength(restDuration, peakHoldDuration),\n );\n}\n\nconst rushTypeLength = getRushTypeDuration();\n\nfunction getRushTypeShutterRatios(\n chromaticSpread = 1,\n): [number, number, number] {\n const spread = Math.max(chromaticSpread, 0);\n return [0.62 ** spread, 1, 0.34 ** spread];\n}\n\ninterface TimelinePose {\n phase: RushTypePhase;\n p: number;\n psi: number;\n cycle: number;\n wordIndex: number;\n}\n\ninterface TimelineOptions {\n wordCount: number;\n restDuration: number;\n peakHoldDuration: number;\n}\n\nfunction getTimelinePose(\n frame: number,\n { wordCount, restDuration, peakHoldDuration }: TimelineOptions,\n): TimelinePose {\n const safeWordCount = Math.max(Math.floor(wordCount), 1);\n const safeRest = Math.max(restDuration, 1);\n const safeHold = Math.max(peakHoldDuration, 0);\n const halfHold = safeHold / 2;\n const cycleLength = getRushTypeCycleLength(safeRest, safeHold);\n const arriveEnd = halfHold + ARRIVE_FRAMES;\n const restEnd = arriveEnd + safeRest;\n const leaveEnd = restEnd + LEAVE_FRAMES;\n const startOffset = arriveEnd + safeRest / 2;\n const shifted = frame + startOffset;\n const cycle = Math.floor(shifted / cycleLength);\n const tau = positiveModulo(shifted, cycleLength);\n const wordIndex = positiveModulo(cycle, safeWordCount);\n\n if (tau < halfHold) {\n return {\n phase: \"hang\",\n p: 1,\n psi: ORBIT_HANG_ARC * (tau / Math.max(halfHold, 1e-6)),\n cycle,\n wordIndex,\n };\n }\n\n if (tau < arriveEnd) {\n const progress = (tau - halfHold) / ARRIVE_FRAMES;\n return {\n phase: \"arrive\",\n p: sampleTable(FALL, progress),\n psi: ORBIT_HANG_ARC + SWING_ARC * sampleTable(ORBIT_IN, progress),\n cycle,\n wordIndex,\n };\n }\n\n if (tau < restEnd) {\n return { phase: \"rest\", p: 0, psi: Math.PI, cycle, wordIndex };\n }\n\n if (tau < leaveEnd) {\n const progress = (tau - restEnd) / LEAVE_FRAMES;\n return {\n phase: \"depart\",\n p: sampleTable(RISE, progress),\n psi: Math.PI + SWING_ARC * sampleTable(ORBIT_OUT, progress),\n cycle,\n wordIndex,\n };\n }\n\n const progress = (tau - leaveEnd) / Math.max(halfHold, 1e-6);\n return {\n phase: \"hang\",\n p: 1,\n psi: 2 * Math.PI - ORBIT_HANG_ARC * (1 - progress),\n cycle,\n wordIndex,\n };\n}\n\ninterface ComputedFrame {\n before: TimelinePose;\n here: TimelinePose;\n after: TimelinePose;\n swapU: number;\n swapAmount: number;\n shutterRatios: [number, number, number];\n}\n\nfunction computeFrame({\n frame,\n fps,\n wordCount,\n restDuration,\n peakHoldDuration,\n chromaticSpread,\n}: {\n frame: number;\n fps: number;\n wordCount: number;\n restDuration: number;\n peakHoldDuration: number;\n chromaticSpread: number;\n}): ComputedFrame {\n const shutterFrames = SHUTTER_SECONDS * Math.max(fps, 1);\n const halfShutter = shutterFrames / 2;\n const options = { wordCount, restDuration, peakHoldDuration };\n const before = getTimelinePose(frame - halfShutter, options);\n const here = getTimelinePose(frame, options);\n const after = getTimelinePose(frame + halfShutter, options);\n const cycleLength = getRushTypeCycleLength(restDuration, peakHoldDuration);\n const halfHold = Math.max(peakHoldDuration, 0) / 2;\n const arriveEnd = halfHold + ARRIVE_FRAMES;\n const startOffset = arriveEnd + Math.max(restDuration, 1) / 2;\n const shifted = frame + startOffset;\n const nearestBoundary = Math.round(shifted / cycleLength) * cycleLength;\n const boundaryDistance = shifted - nearestBoundary;\n const crossesSwap = wordCount > 1 && after.cycle > before.cycle;\n const swapU = crossesSwap\n ? (after.cycle * cycleLength - shifted) / shutterFrames\n : 2;\n const swapAmount =\n wordCount > 1\n ? Math.max(0, 1 - (2 * boundaryDistance) ** 2 / shutterFrames ** 2)\n : 0;\n\n return {\n before,\n here,\n after,\n swapU,\n swapAmount,\n shutterRatios: getRushTypeShutterRatios(chromaticSpread),\n };\n}\n\nfunction getRushTypeFrameState({\n frame,\n fps = 30,\n phrase = rushTypeDefaultPhrase,\n restDuration = DEFAULT_REST_FRAMES,\n peakHoldDuration = DEFAULT_HOLD_FRAMES,\n chromaticSpread = 1,\n speed = 1,\n}: {\n frame: number;\n fps?: number;\n} & Pick<\n RushTypeProps,\n \"phrase\" | \"restDuration\" | \"peakHoldDuration\" | \"chromaticSpread\" | \"speed\"\n>): RushTypeFrameState {\n const words = normalizeRushTypePhrase(phrase);\n const computed = computeFrame({\n frame: frame * Math.max(speed, 0),\n fps,\n wordCount: words.length,\n restDuration,\n peakHoldDuration,\n chromaticSpread,\n });\n const motion = computed.here.p;\n\n return {\n phase: computed.here.phase,\n wordIndex: computed.here.wordIndex,\n beforeWordIndex: computed.before.wordIndex,\n afterWordIndex: computed.after.wordIndex,\n cycle: computed.here.cycle,\n motion,\n isResting:\n computed.here.phase === \"rest\" &&\n computed.before.p === 0 &&\n computed.after.p === 0,\n swapAmount: computed.swapAmount,\n shutterRatios: computed.shutterRatios,\n thinAmount: THIN * motion,\n bloomAmount: BLOOM_GAIN * motion,\n crtAmount: CRT_GAIN * motion,\n groundAmount: GROUND_SPEED * motion,\n };\n}\n\nfunction orbitTurn(psi: number, amplitude: number, lag: number): number {\n const pin = Math.sin(lag);\n return (amplitude * (Math.sin(psi - lag) - pin)) / (1 + Math.abs(pin));\n}\n\nconst VERTEX_SHADER = `\nattribute vec2 aPos;\nvarying vec2 vUv;\nvoid main() {\n vUv = aPos * 0.5 + 0.5;\n gl_Position = vec4(aPos, 0.0, 1.0);\n}\n`;\n\nconst FRAGMENT_SHADER = `\nprecision highp float;\nvarying vec2 vUv;\n\nuniform sampler2D uText;\nuniform vec2 uRes;\nuniform vec2 uHalfPx;\nuniform float uAtlasRows;\nuniform float uSx;\nuniform vec3 uSyQ;\nuniform float uCenterY;\nuniform float uSwapU;\nuniform float uHalfA;\nuniform float uHalfB;\nuniform vec3 uK;\nuniform vec2 uSwapScl;\nuniform float uShape;\nuniform float uRoll;\nuniform float uLag;\nuniform float uThin;\nuniform float uBloom;\nuniform float uGain;\nuniform float uExp;\nuniform float uFocal;\nuniform vec3 uPos;\nuniform vec4 uRot;\nuniform float uCrt;\nuniform float uTime;\nuniform vec4 uGlow;\nuniform float uGlowAmp;\nuniform vec3 uColor;\nuniform vec3 uBg;\n\n#define SAMPLES ${SAMPLES}\n#define BLOOM_TAPS 4\n#define BLOOM_SPREAD ${BLOOM_SPREAD.toFixed(3)}\n#define BLOOM_BIAS ${BLOOM_BIAS.toFixed(3)}\n#define TAU 6.2831853\n#define CRT_PITCH ${CRT_PITCH.toFixed(3)}\n#define CRT_MASK ${CRT_MASK.toFixed(4)}\n#define CRT_SCAN_PITCH ${CRT_SCAN_PITCH.toFixed(3)}\n#define CRT_SCAN ${CRT_SCAN.toFixed(4)}\n#define CRT_BEAM ${CRT_BEAM.toFixed(4)}\n#define CRT_HUM ${CRT_HUM.toFixed(4)}\n#define CRT_HUM_SPEED ${CRT_HUM_SPEED.toFixed(4)}\n\nvec2 atlasUv(float sy, float halfIdx, vec2 wordPoint, out float inside) {\n float sx = max(uSx, 1e-4);\n float sv = max(abs(sy), 1e-4);\n vec2 q = vec2(\n (wordPoint.x / sx + uHalfPx.x * 0.5) / uHalfPx.x,\n (wordPoint.y / sv + uHalfPx.y * 0.5) / uHalfPx.y\n );\n inside = step(0.0, q.x) * step(q.x, 1.0) * step(0.0, q.y) * step(q.y, 1.0);\n return vec2(\n clamp(q.x, 0.0, 1.0),\n (clamp(q.y, 0.0, 1.0) + halfIdx) / uAtlasRows\n );\n}\n\nfloat tap(float sy, float halfIdx, vec2 wordPoint, float front) {\n float inside;\n vec2 texturePoint = atlasUv(sy, halfIdx, wordPoint, inside);\n float value = texture2D(uText, texturePoint).r * inside * front;\n return value * mix(1.0, value, uThin);\n}\n\nfloat tapBlur(float sy, float halfIdx, vec2 wordPoint, float front) {\n float inside;\n vec2 texturePoint = atlasUv(sy, halfIdx, wordPoint, inside);\n return texture2D(uText, texturePoint, BLOOM_BIAS).r * inside * front;\n}\n\nvoid main() {\n vec2 pixel = vUv * uRes;\n vec2 center = vec2(uRes.x * 0.5, uRes.y * uCenterY);\n vec2 screenPoint = pixel - center;\n\n float sinYaw = uRot.x;\n float cosYaw = uRot.y;\n float sinPitch = uRot.z;\n float cosPitch = uRot.w;\n float a1 = -(screenPoint.x * sinYaw + uFocal * cosYaw);\n float b1 = sinPitch * (screenPoint.x * cosYaw - uFocal * sinYaw);\n float c1 = uFocal * uPos.x - screenPoint.x * uPos.z;\n float a2 = -screenPoint.y * sinYaw;\n float b2 = screenPoint.y * sinPitch * cosYaw - uFocal * cosPitch;\n float c2 = uFocal * uPos.y - screenPoint.y * uPos.z;\n float determinant = a1 * b2 - a2 * b1;\n float inverse = 1.0 / (abs(determinant) < 1e-4 ? 1e-4 : determinant);\n float a = (c1 * b2 - c2 * b1) * inverse;\n float b = (a1 * c2 - a2 * c1) * inverse;\n float cameraZ = uPos.z - a * sinYaw + b * sinPitch * cosYaw;\n vec2 wordPoint = vec2(a, b);\n float front = step(uFocal * 0.05, cameraZ);\n vec3 accumulated = vec3(0.0);\n\n if (abs(uSyQ.y) + abs(uSyQ.z) < 1e-5) {\n accumulated = vec3(tap(uSyQ.x, uHalfA, wordPoint, front));\n } else {\n float offset =\n uLag * (wordPoint.x / uRes.x) - uRoll * (screenPoint.y / uRes.y);\n float weightSum = 0.0;\n\n for (int i = 0; i < SAMPLES; i++) {\n float u = float(i) / float(SAMPLES - 1) - 0.5;\n float weight = 1.0 - uShape * abs(u) * 2.0;\n weightSum += weight;\n float shiftedU = u + offset;\n vec3 shutterU = shiftedU * uK;\n vec3 sy = uSyQ.x + uSyQ.y * shutterU + uSyQ.z * shutterU * shutterU;\n accumulated.r += weight * tap(\n sy.r * (shutterU.r < uSwapU ? uSwapScl.x : uSwapScl.y),\n shutterU.r < uSwapU ? uHalfA : uHalfB,\n wordPoint,\n front\n );\n accumulated.g += weight * tap(\n sy.g * (shutterU.g < uSwapU ? uSwapScl.x : uSwapScl.y),\n shutterU.g < uSwapU ? uHalfA : uHalfB,\n wordPoint,\n front\n );\n accumulated.b += weight * tap(\n sy.b * (shutterU.b < uSwapU ? uSwapScl.x : uSwapScl.y),\n shutterU.b < uSwapU ? uHalfA : uHalfB,\n wordPoint,\n front\n );\n }\n\n accumulated /= max(weightSum, 1e-4);\n\n vec3 halo = vec3(0.0);\n for (int j = 0; j < BLOOM_TAPS; j++) {\n float u =\n (float(j) / float(BLOOM_TAPS - 1) - 0.5) * BLOOM_SPREAD + offset;\n vec3 shutterU = u * uK;\n vec3 sy = uSyQ.x + uSyQ.y * shutterU + uSyQ.z * shutterU * shutterU;\n halo.r += tapBlur(\n sy.r * (shutterU.r < uSwapU ? uSwapScl.x : uSwapScl.y),\n shutterU.r < uSwapU ? uHalfA : uHalfB,\n wordPoint,\n front\n );\n halo.g += tapBlur(\n sy.g * (shutterU.g < uSwapU ? uSwapScl.x : uSwapScl.y),\n shutterU.g < uSwapU ? uHalfA : uHalfB,\n wordPoint,\n front\n );\n halo.b += tapBlur(\n sy.b * (shutterU.b < uSwapU ? uSwapScl.x : uSwapScl.y),\n shutterU.b < uSwapU ? uHalfA : uHalfB,\n wordPoint,\n front\n );\n }\n accumulated += halo * (uBloom / float(BLOOM_TAPS));\n accumulated *= uGain;\n }\n\n accumulated =\n (1.0 - exp(-accumulated * uExp)) / (1.0 - exp(-uExp));\n\n vec2 glowDistance =\n (pixel - uGlow.xy) / max(uGlow.zw, vec2(1.0));\n float ground =\n uGlowAmp * (1.0 - smoothstep(0.0, 1.0, length(glowDistance)));\n accumulated += ground * (1.0 - accumulated);\n\n if (uCrt > 0.0) {\n float luminance = max(max(accumulated.r, accumulated.g), accumulated.b);\n vec3 maskWave = 0.5 + 0.5 * cos(\n TAU * (pixel.x / CRT_PITCH - vec3(0.0, 0.33333, 0.66667))\n );\n vec3 mask = mix(vec3(1.0), maskWave * 2.0, CRT_MASK * uCrt);\n float scanWave = 0.5 + 0.5 * cos(TAU * pixel.y / CRT_SCAN_PITCH);\n float scan =\n 1.0 - CRT_SCAN * uCrt * (1.0 - CRT_BEAM * luminance) * (1.0 - scanWave);\n float bar = 0.5 + 0.5 * cos(\n TAU * (pixel.y / uRes.y - uTime * CRT_HUM_SPEED)\n );\n float hum = 1.0 + CRT_HUM * uCrt * (bar * 2.0 - 1.0);\n accumulated *= mask * scan * hum;\n }\n\n gl_FragColor = vec4(uBg + (uColor - uBg) * accumulated, 1.0);\n}\n`;\n\nconst UNIFORM_NAMES = [\n \"uText\",\n \"uRes\",\n \"uHalfPx\",\n \"uAtlasRows\",\n \"uSx\",\n \"uSyQ\",\n \"uCenterY\",\n \"uSwapU\",\n \"uHalfA\",\n \"uHalfB\",\n \"uK\",\n \"uSwapScl\",\n \"uShape\",\n \"uRoll\",\n \"uLag\",\n \"uThin\",\n \"uBloom\",\n \"uGain\",\n \"uExp\",\n \"uFocal\",\n \"uPos\",\n \"uRot\",\n \"uCrt\",\n \"uTime\",\n \"uGlow\",\n \"uGlowAmp\",\n \"uColor\",\n \"uBg\",\n] as const;\n\ninterface GlState {\n gl: WebGLRenderingContext;\n program: WebGLProgram;\n buffer: WebGLBuffer;\n texture: WebGLTexture;\n uniforms: Record<(typeof UNIFORM_NAMES)[number], WebGLUniformLocation | null>;\n atlasWidth: number;\n halfHeight: number;\n textureCapHeight: number;\n maxTextureSize: number;\n scratch: HTMLCanvasElement;\n atlasKey: string;\n atlasRows: number;\n wordHalfWidths: number[];\n wordHalfWidth: number;\n}\n\nfunction compileShader(\n gl: WebGLRenderingContext,\n type: number,\n source: string,\n): WebGLShader {\n const shader = gl.createShader(type);\n if (!shader) throw new Error(\"RushTypeBase could not create a WebGL shader\");\n gl.shaderSource(shader, source);\n gl.compileShader(shader);\n if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {\n const message = gl.getShaderInfoLog(shader) ?? \"Unknown shader error\";\n gl.deleteShader(shader);\n throw new Error(`RushTypeBase shader compilation failed: ${message}`);\n }\n return shader;\n}\n\nfunction createGlState(canvas: HTMLCanvasElement): GlState | null {\n const gl = canvas.getContext(\"webgl\", {\n alpha: false,\n antialias: false,\n depth: false,\n stencil: false,\n preserveDrawingBuffer: false,\n powerPreference: \"high-performance\",\n });\n if (!gl) return null;\n\n const vertex = compileShader(gl, gl.VERTEX_SHADER, VERTEX_SHADER);\n const fragment = compileShader(gl, gl.FRAGMENT_SHADER, FRAGMENT_SHADER);\n const program = gl.createProgram();\n if (!program) throw new Error(\"RushTypeBase could not create a WebGL program\");\n gl.attachShader(program, vertex);\n gl.attachShader(program, fragment);\n gl.bindAttribLocation(program, 0, \"aPos\");\n gl.linkProgram(program);\n gl.deleteShader(vertex);\n gl.deleteShader(fragment);\n if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {\n const message = gl.getProgramInfoLog(program) ?? \"Unknown link error\";\n gl.deleteProgram(program);\n throw new Error(`RushTypeBase shader linking failed: ${message}`);\n }\n\n const buffer = gl.createBuffer();\n const texture = gl.createTexture();\n if (!buffer || !texture) {\n throw new Error(\"RushTypeBase could not allocate WebGL resources\");\n }\n gl.bindBuffer(gl.ARRAY_BUFFER, buffer);\n gl.bufferData(\n gl.ARRAY_BUFFER,\n new Float32Array([-1, -1, 3, -1, -1, 3]),\n gl.STATIC_DRAW,\n );\n\n const atlasWidth = canvas.width >= 1800 ? 4096 : 2048;\n const halfHeight = atlasWidth / 4;\n const textureCapHeight = Math.round(halfHeight * 0.64);\n gl.bindTexture(gl.TEXTURE_2D, texture);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);\n gl.texParameteri(\n gl.TEXTURE_2D,\n gl.TEXTURE_MIN_FILTER,\n gl.LINEAR_MIPMAP_LINEAR,\n );\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);\n\n const scratch = document.createElement(\"canvas\");\n scratch.width = atlasWidth;\n scratch.height = halfHeight;\n const uniforms = Object.fromEntries(\n UNIFORM_NAMES.map((name) => [name, gl.getUniformLocation(program, name)]),\n ) as GlState[\"uniforms\"];\n gl.clearColor(0, 0, 0, 1);\n\n return {\n gl,\n program,\n buffer,\n texture,\n uniforms,\n atlasWidth,\n halfHeight,\n textureCapHeight,\n maxTextureSize: gl.getParameter(gl.MAX_TEXTURE_SIZE) as number,\n scratch,\n atlasKey: \"\",\n atlasRows: 2,\n wordHalfWidths: [],\n wordHalfWidth: 1,\n };\n}\n\nfunction resolveFontFamily(fontFamily: string): string {\n if (typeof document === \"undefined\") return fontFamily;\n const probe = document.createElement(\"span\");\n probe.style.cssText =\n \"position:absolute;visibility:hidden;pointer-events:none\";\n probe.style.fontFamily = fontFamily;\n probe.textContent = \"Ag\";\n document.body.appendChild(probe);\n const resolved = getComputedStyle(probe).fontFamily;\n probe.remove();\n return resolved || fontFamily;\n}\n\nfunction rasterWord(\n state: GlState,\n word: string,\n row: number,\n fontFamily: string,\n fontWeight: number,\n): number {\n const context = state.scratch.getContext(\"2d\");\n if (!context) return 1;\n context.fillStyle = \"#000\";\n context.fillRect(0, 0, state.atlasWidth, state.halfHeight);\n\n let rasterSize = state.textureCapHeight * 1.4;\n context.font = `${fontWeight} ${rasterSize}px ${fontFamily}`;\n const capHeight =\n context.measureText(\"H\").actualBoundingBoxAscent || rasterSize * 0.72;\n rasterSize *= state.textureCapHeight / capHeight;\n context.font = `${fontWeight} ${rasterSize}px ${fontFamily}`;\n\n const maxWidth = state.atlasWidth * 0.92;\n const measured = context.measureText(word).width;\n if (measured > maxWidth) {\n rasterSize *= maxWidth / measured;\n context.font = `${fontWeight} ${rasterSize}px ${fontFamily}`;\n }\n\n context.fillStyle = \"#fff\";\n context.textAlign = \"center\";\n context.textBaseline = \"alphabetic\";\n context.fillText(\n word,\n state.atlasWidth / 2,\n state.halfHeight / 2 + state.textureCapHeight / 2,\n );\n const halfWidth = context.measureText(word).width / 2;\n\n const { gl } = state;\n gl.bindTexture(gl.TEXTURE_2D, state.texture);\n gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true);\n gl.texSubImage2D(\n gl.TEXTURE_2D,\n 0,\n 0,\n row * state.halfHeight,\n gl.RGBA,\n gl.UNSIGNED_BYTE,\n state.scratch,\n );\n gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);\n return halfWidth;\n}\n\nfunction nextPowerOfTwo(value: number): number {\n return 2 ** Math.ceil(Math.log2(Math.max(value, 2)));\n}\n\nfunction getRushTypePhraseAtlasRows({\n wordCount,\n rowHeight,\n maxTextureSize,\n}: {\n wordCount: number;\n rowHeight: number;\n maxTextureSize: number;\n}): number | null {\n const rows = nextPowerOfTwo(wordCount);\n return rowHeight * rows <= maxTextureSize ? rows : null;\n}\n\nfunction allocateAtlas(state: GlState, rows: number): void {\n const { gl } = state;\n gl.bindTexture(gl.TEXTURE_2D, state.texture);\n gl.texImage2D(\n gl.TEXTURE_2D,\n 0,\n gl.RGBA,\n state.atlasWidth,\n state.halfHeight * rows,\n 0,\n gl.RGBA,\n gl.UNSIGNED_BYTE,\n null,\n );\n state.atlasRows = rows;\n}\n\nfunction updateAtlas(\n state: GlState,\n words: string[],\n firstWordIndex: number,\n secondWordIndex: number,\n fontFamily: string,\n fontWeight: number,\n): { firstRow: number; secondRow: number } {\n const phraseRows = getRushTypePhraseAtlasRows({\n wordCount: words.length,\n rowHeight: state.halfHeight,\n maxTextureSize: state.maxTextureSize,\n });\n\n if (phraseRows !== null) {\n const atlasKey = `phrase\\u0000${fontFamily}\\u0000${fontWeight}\\u0000${words.join(\"\\u0000\")}`;\n if (state.atlasKey !== atlasKey) {\n allocateAtlas(state, phraseRows);\n state.wordHalfWidths = words.map((word, row) =>\n rasterWord(state, word, row, fontFamily, fontWeight),\n );\n state.gl.generateMipmap(state.gl.TEXTURE_2D);\n state.atlasKey = atlasKey;\n }\n state.wordHalfWidth = Math.max(\n state.wordHalfWidths[firstWordIndex] ?? 1,\n state.wordHalfWidths[secondWordIndex] ?? 1,\n );\n return { firstRow: firstWordIndex, secondRow: secondWordIndex };\n }\n\n const firstWord = words[firstWordIndex] ?? words[0];\n const secondWord = words[secondWordIndex] ?? words[0];\n const atlasKey = `pair\\u0000${fontFamily}\\u0000${fontWeight}\\u0000${firstWord}\\u0000${secondWord}`;\n if (state.atlasKey !== atlasKey) {\n allocateAtlas(state, 2);\n const firstWidth = rasterWord(state, firstWord, 0, fontFamily, fontWeight);\n const secondWidth = rasterWord(\n state,\n secondWord,\n 1,\n fontFamily,\n fontWeight,\n );\n state.gl.generateMipmap(state.gl.TEXTURE_2D);\n state.wordHalfWidths = [firstWidth, secondWidth];\n state.atlasKey = atlasKey;\n }\n state.wordHalfWidth = Math.max(...state.wordHalfWidths, 1);\n return { firstRow: 0, secondRow: 1 };\n}\n\nfunction destroyGlState(state: GlState): void {\n const { gl } = state;\n gl.deleteProgram(state.program);\n gl.deleteBuffer(state.buffer);\n gl.deleteTexture(state.texture);\n}\n\nfunction drawRushType({\n state,\n computed,\n words,\n fontSize,\n fontFamily,\n fontWeight,\n verticalStretch,\n textColor,\n backgroundColor,\n frame,\n fps,\n}: {\n state: GlState;\n computed: ComputedFrame;\n words: string[];\n fontSize: number;\n fontFamily: string;\n fontWeight: number;\n verticalStretch: number;\n textColor: [number, number, number];\n backgroundColor: [number, number, number];\n frame: number;\n fps: number;\n}): void {\n const { gl, uniforms } = state;\n const { firstRow, secondRow } = updateAtlas(\n state,\n words,\n computed.before.wordIndex,\n computed.after.wordIndex,\n fontFamily,\n fontWeight,\n );\n\n const unit = Math.max(fontSize, 1) / state.textureCapHeight;\n const scaleY = (pose: TimelinePose) =>\n unit * (1 + pose.p * (Math.max(verticalStretch, 1) - 1));\n const scaleBefore = scaleY(computed.before);\n const scaleCurrent = scaleY(computed.here);\n const scaleAfter = scaleY(computed.after);\n const quadraticA = scaleCurrent;\n const quadraticC = 2 * (scaleAfter + scaleBefore - 2 * scaleCurrent);\n const tangent = scaleAfter - scaleBefore;\n const peakSmear = SMEAR_GAIN * computed.here.p * scaleCurrent;\n const magnitude = Math.sqrt(tangent * tangent + peakSmear * peakSmear);\n const quadraticB = tangent < 0 ? -magnitude : magnitude;\n const scaleX = unit * (1 + computed.here.p * (HORIZONTAL_STRETCH - 1));\n\n const direction =\n DRIFT_DIRECTION[\n positiveModulo(computed.here.cycle, DRIFT_DIRECTION.length)\n ] ?? 1;\n const psi = computed.here.psi * Math.sign(direction || 1);\n const orbitAmplitude = Math.abs(direction);\n const focal =\n state.scratch.height > 0 ? state.gl.drawingBufferHeight * FOCAL : 1;\n const z = focal * (1 - ORBIT_DEPTH * (1 + Math.cos(psi)) * 0.5);\n const x = 0;\n const y = focal * ORBIT_RISE * orbitAmplitude * Math.sin(psi);\n const yaw = orbitTurn(psi, ORBIT_YAW, ORBIT_YAW_LAG);\n const pitch = orbitTurn(psi, ORBIT_PITCH, ORBIT_PITCH_LAG);\n const pivot = PIVOT_FRAC * computed.here.p;\n const perspective = focal / z;\n const glowX = gl.drawingBufferWidth / 2 + (focal * x) / z;\n const glowY = gl.drawingBufferHeight * (0.5 + pivot) + (focal * y) / z;\n const wordWidth = state.wordHalfWidth * scaleX * perspective;\n const wordHeight = state.textureCapHeight * scaleCurrent * perspective;\n\n gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);\n // biome-ignore lint/correctness/useHookAtTopLevel: gl.useProgram is a WebGL method, not a React hook\n gl.useProgram(state.program);\n gl.bindBuffer(gl.ARRAY_BUFFER, state.buffer);\n gl.enableVertexAttribArray(0);\n gl.vertexAttribPointer(0, 2, gl.FLOAT, false, 0, 0);\n gl.activeTexture(gl.TEXTURE0);\n gl.bindTexture(gl.TEXTURE_2D, state.texture);\n gl.uniform1i(uniforms.uText, 0);\n gl.uniform2f(uniforms.uRes, gl.drawingBufferWidth, gl.drawingBufferHeight);\n gl.uniform2f(uniforms.uHalfPx, state.atlasWidth, state.halfHeight);\n gl.uniform1f(uniforms.uAtlasRows, state.atlasRows);\n gl.uniform1f(uniforms.uSx, scaleX);\n gl.uniform3f(uniforms.uSyQ, quadraticA, quadraticB, quadraticC);\n gl.uniform1f(uniforms.uCenterY, 0.5 + pivot);\n gl.uniform1f(uniforms.uSwapU, computed.swapU);\n gl.uniform1f(uniforms.uHalfA, firstRow);\n gl.uniform1f(uniforms.uHalfB, secondRow);\n gl.uniform3f(\n uniforms.uK,\n computed.shutterRatios[0],\n computed.shutterRatios[1],\n computed.shutterRatios[2],\n );\n gl.uniform2f(\n uniforms.uSwapScl,\n 1 + SWAP_SPREAD * computed.swapAmount,\n 1 - SWAP_SPREAD * computed.swapAmount,\n );\n gl.uniform1f(uniforms.uShape, SHUTTER_SHAPE);\n gl.uniform1f(uniforms.uRoll, ROLL_U);\n gl.uniform1f(uniforms.uLag, LAG_U);\n gl.uniform1f(uniforms.uThin, THIN * computed.here.p);\n gl.uniform1f(uniforms.uBloom, BLOOM_GAIN * computed.here.p);\n gl.uniform1f(\n uniforms.uGain,\n (1 + SPEED_GAIN * computed.here.p) * (1 + SWAP_FLASH * computed.swapAmount),\n );\n gl.uniform1f(uniforms.uExp, EXPOSURE);\n gl.uniform1f(uniforms.uFocal, focal);\n gl.uniform3f(uniforms.uPos, x, y, z);\n gl.uniform4f(\n uniforms.uRot,\n Math.sin(yaw),\n Math.cos(yaw),\n Math.sin(pitch),\n Math.cos(pitch),\n );\n gl.uniform1f(uniforms.uCrt, CRT_GAIN * computed.here.p);\n gl.uniform1f(uniforms.uTime, frame / Math.max(fps, 1));\n gl.uniform4f(\n uniforms.uGlow,\n glowX,\n glowY,\n Math.max(wordWidth * GLOW_SPREAD, gl.drawingBufferWidth * GLOW_MIN),\n Math.min(\n Math.max(wordHeight * GLOW_SPREAD, gl.drawingBufferHeight * GLOW_MIN),\n gl.drawingBufferHeight * GLOW_MAX_Y,\n ),\n );\n gl.uniform1f(uniforms.uGlowAmp, GROUND_SPEED * computed.here.p);\n gl.uniform3f(uniforms.uColor, textColor[0], textColor[1], textColor[2]);\n gl.uniform3f(\n uniforms.uBg,\n backgroundColor[0],\n backgroundColor[1],\n backgroundColor[2],\n );\n gl.clearColor(backgroundColor[0], backgroundColor[1], backgroundColor[2], 1);\n gl.clear(gl.COLOR_BUFFER_BIT);\n gl.drawArrays(gl.TRIANGLES, 0, 3);\n}\n\nfunction RushTypeBase({\n phrase = rushTypeDefaultPhrase,\n fontSize = 68,\n fontFamily = \"Arial, Helvetica, sans-serif\",\n fontWeight = 400,\n color = \"#ffffff\",\n backgroundColor = \"#000000\",\n verticalStretch = 7,\n chromaticSpread = 1,\n restDuration = DEFAULT_REST_FRAMES,\n peakHoldDuration = DEFAULT_HOLD_FRAMES,\n speed = 1,\n className,\n}: RushTypeProps) {\n const frame = useCurrentFrame();\n const { fps, width, height } = useVideoConfig();\n const canvasRef = useRef<HTMLCanvasElement>(null);\n const stateRef = useRef<GlState | null>(null);\n const [fontReady, setFontReady] = useState(false);\n const [webGlFailed, setWebGlFailed] = useState(false);\n const [renderHandle] = useState(() => delayRender(\"rush-type: first frame\"));\n const continuedRef = useRef(false);\n const words = useMemo(() => normalizeRushTypePhrase(phrase), [phrase]);\n const resolvedFontFamily = useMemo(\n () => resolveFontFamily(fontFamily),\n [fontFamily],\n );\n const textColor = useMemo(() => parseHexColor(color, [1, 1, 1]), [color]);\n const frameColor = useMemo(\n () => parseHexColor(backgroundColor, [0, 0, 0]),\n [backgroundColor],\n );\n const effectiveFrame = frame * Math.max(speed, 0);\n const computed = computeFrame({\n frame: effectiveFrame,\n fps,\n wordCount: words.length,\n restDuration,\n peakHoldDuration,\n chromaticSpread,\n });\n\n useEffect(() => {\n let cancelled = false;\n setFontReady(false);\n const ready = () => {\n if (!cancelled) setFontReady(true);\n };\n if (typeof document === \"undefined\" || !document.fonts) {\n ready();\n return () => {\n cancelled = true;\n };\n }\n document.fonts\n .load(\n `${Number(fontWeight) || 400} ${Math.max(fontSize, 1)}px ${fontFamily}`,\n )\n .then(ready, ready);\n return () => {\n cancelled = true;\n };\n }, [fontFamily, fontSize, fontWeight]);\n\n useLayoutEffect(() => {\n const canvas = canvasRef.current;\n if (!canvas || stateRef.current || webGlFailed) return;\n try {\n const state = createGlState(canvas);\n if (!state) {\n setWebGlFailed(true);\n return;\n }\n stateRef.current = state;\n } catch {\n setWebGlFailed(true);\n }\n return () => {\n if (stateRef.current) destroyGlState(stateRef.current);\n stateRef.current = null;\n };\n }, [webGlFailed]);\n\n useLayoutEffect(() => {\n const state = stateRef.current;\n if (!state || !fontReady) return;\n drawRushType({\n state,\n computed,\n words,\n fontSize,\n fontFamily: resolvedFontFamily,\n fontWeight: Number(fontWeight) || 400,\n verticalStretch,\n textColor,\n backgroundColor: frameColor,\n frame: effectiveFrame,\n fps,\n });\n if (!continuedRef.current) {\n continuedRef.current = true;\n continueRender(renderHandle);\n }\n }, [\n computed,\n effectiveFrame,\n fontReady,\n fontSize,\n fontWeight,\n fps,\n frameColor,\n renderHandle,\n resolvedFontFamily,\n textColor,\n verticalStretch,\n words,\n ]);\n\n useEffect(() => {\n if (!webGlFailed || continuedRef.current) return;\n continuedRef.current = true;\n continueRender(renderHandle);\n }, [renderHandle, webGlFailed]);\n\n const currentWord = words[computed.here.wordIndex] ?? words[0];\n\n return (\n <div\n className={className}\n role=\"img\"\n aria-label={`${phrase}: words stretching into vertical motion blur`}\n style={{\n position: \"absolute\",\n inset: 0,\n overflow: \"hidden\",\n backgroundColor,\n }}\n >\n <canvas\n ref={canvasRef}\n width={width}\n height={height}\n style={{\n display: webGlFailed ? \"none\" : \"block\",\n width: \"100%\",\n height: \"100%\",\n }}\n />\n {webGlFailed ? (\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n color,\n fontFamily,\n fontSize,\n fontWeight,\n }}\n >\n {currentWord}\n </div>\n ) : null}\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n phrase: {\n type: \"text-content\",\n default: \"gone before you look\",\n description: \"Phrase\",\n },\n fontSize: {\n type: \"number\",\n default: 68,\n min: 32,\n max: 140,\n step: 2,\n description: \"Resting size\",\n hiddenFromList: false,\n },\n fontWeight: {\n type: \"enum\",\n default: \"400\",\n variants: {\n \"400\": {},\n \"500\": {},\n \"600\": {},\n \"700\": {},\n },\n description: \"Font weight\",\n },\n color: {\n type: \"color\",\n default: \"#ffffff\",\n description: \"Text color\",\n },\n backgroundColor: {\n type: \"color\",\n default: \"#000000\",\n description: \"Background\",\n },\n verticalStretch: {\n type: \"number\",\n default: 7,\n min: 3,\n max: 12,\n step: 0.25,\n description: \"Vertical stretch\",\n hiddenFromList: false,\n },\n chromaticSpread: {\n type: \"number\",\n default: 1,\n min: 0,\n max: 2,\n step: 0.05,\n description: \"Chromatic spread\",\n hiddenFromList: false,\n },\n restDuration: {\n type: \"number\",\n default: 12,\n min: 6,\n max: 30,\n step: 1,\n description: \"Rest duration\",\n hiddenFromList: false,\n },\n peakHoldDuration: {\n type: \"number\",\n default: 3,\n min: 0,\n max: 15,\n step: 1,\n description: \"Peak hold\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"phrase\",\"fontSize\",\"fontWeight\",\"color\",\"backgroundColor\",\"verticalStretch\",\"chromaticSpread\",\"restDuration\",\"peakHoldDuration\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n phrase: \"gone before you look\",\n fontSize: 68,\n fontWeight: \"400\",\n color: \"#ffffff\",\n backgroundColor: \"#000000\",\n verticalStretch: 7,\n chromaticSpread: 1,\n restDuration: 12,\n peakHoldDuration: 3,\n speed: 1,\n};\n\ntype RushTypeElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof RushTypeBase>;\n\nconst RushTypeInner = forwardRef<\n HTMLDivElement,\n RushTypeElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<RushType>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <RushTypeBase\n {...(componentProps as unknown as ComponentProps<typeof RushTypeBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const RushType = Interactive.withSchema({\n Component: RushTypeInner,\n componentName: \"<RushType>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/scale-down-fade.json b/registry-artifacts/elements/scale-down-fade.jsonindex fcb55da0..3e2d1a44 100644--- a/registry-artifacts/elements/scale-down-fade.json+++ b/registry-artifacts/elements/scale-down-fade.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [],"dimensions": {"width": 600,@@ -9,6 +10,7 @@},"displayName": "Scale Down Fade","durationInFrames": 90,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "scale-down-fade","sourceCode": "import { Easing, Interactive, Sequence, interpolate, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface ScaleDownFadeProps {\n text: string;\n fontSize?: number;\n color?: string;\n fontWeight?: number;\n speed?: number;\n className?: string;\n}\n\nfunction ScaleDownFadeBase({\n text,\n fontSize = 72,\n color = \"#171717\",\n fontWeight = 600,\n speed = 1,\n className,\n}: ScaleDownFadeProps) {\n const frame = useCurrentFrame() * speed;\n const { durationInFrames } = useVideoConfig();\n\n const enterDurFrames = 16;\n const exitDurFrames = 11;\n const exitStart = Math.max(enterDurFrames, durationInFrames - exitDurFrames);\n\n const enterEasing = Easing.bezier(0.22, 1, 0.36, 1);\n const exitEasing = Easing.bezier(0.64, 0, 0.78, 0);\n\n const enterP = interpolate(frame, [0, enterDurFrames], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: enterEasing,\n });\n\n const exitP = interpolate(frame, [exitStart, durationInFrames], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: exitEasing,\n });\n\n const opacity = enterP * (1 - exitP);\n\n const yEnter = interpolate(frame, [0, enterDurFrames], [8, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: enterEasing,\n });\n\n const yExit = interpolate(frame, [exitStart, durationInFrames], [0, -8], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: exitEasing,\n });\n\n const y = yEnter + yExit;\n\n const scaleEnter = interpolate(frame, [0, enterDurFrames], [1.04, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: enterEasing,\n });\n\n const scaleExitDelta = interpolate(\n frame,\n [exitStart, durationInFrames],\n [0, -0.06],\n {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: exitEasing,\n },\n );\n\n const scale = scaleEnter + scaleExitDelta;\n\n return (\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n background: \"transparent\",\n }}\n >\n <span\n className={className}\n style={{\n fontSize,\n fontWeight,\n color,\n letterSpacing: \"-0.03em\",\n fontFamily:\n \"var(--font-geist-sans), -apple-system, BlinkMacSystemFont, sans-serif\",\n display: \"inline-block\",\n transformOrigin: \"50% 50%\",\n opacity,\n translate: `0 ${y}px`,\n scale: `${scale}`,\n }}\n >\n {text}\n </span>\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n text: {\n type: \"text-content\",\n default: \"Quietly refined.\",\n description: \"Text\",\n },\n fontSize: {\n type: \"number\",\n min: 12,\n max: 160,\n step: 1,\n default: 72,\n description: \"Font size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n fontWeight: {\n type: \"enum\",\n default: \"600\",\n variants: {\n \"400\": {},\n \"500\": {},\n \"600\": {},\n \"700\": {},\n },\n description: \"Font weight\",\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 600,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 100,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"text\",\"fontSize\",\"color\",\"fontWeight\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n text: \"Quietly refined.\",\n fontSize: 72,\n color: \"#171717\",\n fontWeight: \"600\",\n speed: 1,\n};\n\ntype ScaleDownFadeElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof ScaleDownFadeBase>;\n\nconst ScaleDownFadeInner = forwardRef<\n HTMLDivElement,\n ScaleDownFadeElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 600, height = 100, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<ScaleDownFade>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <ScaleDownFadeBase\n {...(componentProps as unknown as ComponentProps<typeof ScaleDownFadeBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const ScaleDownFade = Interactive.withSchema({\n Component: ScaleDownFadeInner,\n componentName: \"<ScaleDownFade>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/search-reveal.json b/registry-artifacts/elements/search-reveal.jsonindex 4e40363a..bb329247 100644--- a/registry-artifacts/elements/search-reveal.json+++ b/registry-artifacts/elements/search-reveal.json@@ -2,10 +2,12 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [],"dimensions": null,"displayName": "Search Reveal","durationInFrames": 90,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "search-reveal","sourceCode": "import { AbsoluteFill, Easing, Interactive, Sequence, interpolate, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ntype SearchRevealProps = {\n text?: string;\n fieldWidth?: number;\n fontSize?: number;\n framesPerCharacter?: number;\n showPanel?: boolean;\n showGuides?: boolean;\n color?: string;\n fieldColor?: string;\n ringColor?: string;\n panelColor?: string;\n accentColor?: string;\n backgroundColor?: string;\n speed?: number;\n reducedMotion?: boolean;\n className?: string;\n};\n\nconst searchRevealLength = 90;\nconst finite = (value: number | undefined, fallback: number) =>\n typeof value === \"number\" && Number.isFinite(value) ? value : fallback;\nconst clamp = (value: number, min: number, max: number) =>\n Math.min(max, Math.max(min, value));\nconst letters = (text: string) =>\n Array.from(\n new Intl.Segmenter(\"en\", { granularity: \"grapheme\" }).segment(text),\n (part) => part.segment,\n );\nconst curve = Easing.bezier(0.22, 1, 0.36, 1);\nconst tween = (frame: number, start: number, end: number, from = 0, to = 1) =>\n interpolate(frame, [start, end], [from, to], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: curve,\n });\n\nfunction timing(props: SearchRevealProps) {\n const characters = letters(props.text ?? \"remocn\");\n const step = clamp(finite(props.framesPerCharacter, 4), 1, 12);\n const end = Math.max(searchRevealLength, 54 + characters.length * step + 10);\n return { characters, step, end, speed: Math.max(0, finite(props.speed, 1)) };\n}\n\n/** Demo duration at 30 fps, including an 18-frame final hold. */\nfunction getSearchRevealDuration(props: SearchRevealProps = {}) {\n const { end, speed } = timing(props);\n return speed === 0 ? 1 : Math.ceil((end + 18) / speed);\n}\n\n/** Frame is expressed at 30 fps; playback speed is applied here. */\nfunction getSearchRevealState(\n frame: number,\n props: SearchRevealProps = {},\n) {\n const { characters, step, end, speed } = timing(props);\n const t = props.reducedMotion ? end : Math.max(0, finite(frame, 0)) * speed;\n const typedCount = clamp(Math.floor((t - 54) / step), 0, characters.length);\n const width = clamp(finite(props.fieldWidth, 464), 320, 640);\n const reveal = props.showPanel === false ? 0 : tween(t, 56, 90);\n const fieldWidth = tween(t, 26, 48, 130, width);\n const fieldHeight = tween(t, 26, 46, 24, 80);\n const panelWidth =\n fieldWidth + (Math.max(774, width + 170) - fieldWidth) * reveal;\n const panelHeight = fieldHeight + (374 - fieldHeight) * reveal;\n return {\n t,\n end,\n typedCount,\n text: characters.slice(0, typedCount).join(\"\"),\n circleRadius: tween(t, 0, 26, 250, 410),\n circleOffset: tween(t, 0, 26, 62, 185),\n circlesVisible: t < 26,\n fieldVisible: t >= 26,\n fieldWidth,\n fieldHeight,\n tilt: tween(t, 26, 47, -4, 0),\n iconOpacity: tween(t, 34, 46),\n panelWidth,\n panelHeight,\n panelRadius: 40 * (1 - reveal),\n panelOpacity: tween(t, 56, 60),\n reveal,\n caretVisible:\n t >= 52 &&\n t < end &&\n (typedCount < characters.length || Math.floor((t - 52) / 12) % 2 === 0),\n };\n}\n\nfunction Cross({ x, y, size = 9 }: { x: number; y: number; size?: number }) {\n return (\n <path\n d={`M ${x - size} ${y} H ${x + size} M ${x} ${y - size} V ${y + size}`}\n />\n );\n}\n\n/** A video scene: expanding construction circles, a search pill, and typed copy. */\nfunction SearchRevealBase({\n text = \"remocn\",\n fieldWidth = 464,\n fontSize = 34,\n framesPerCharacter = 4,\n showPanel = true,\n showGuides = true,\n color = \"#26232b\",\n fieldColor = \"#ffffff\",\n ringColor = \"#cbc5cf\",\n panelColor = \"#a800b7\",\n accentColor = \"#e8f99a\",\n backgroundColor = \"#f5f1f5\",\n speed = 1,\n reducedMotion = false,\n className,\n}: SearchRevealProps) {\n const frame = useCurrentFrame();\n const { width, height, fps } = useVideoConfig();\n const state = getSearchRevealState((frame * 30) / fps, {\n text,\n fieldWidth,\n framesPerCharacter,\n showPanel,\n speed,\n reducedMotion,\n });\n const scale = Math.min(width / 1280, height / 720);\n const fittedFont = Math.min(\n clamp(finite(fontSize, 34), 18, 54),\n (state.fieldWidth - 120) / Math.max(1, letters(text).length * 0.65),\n );\n const markerWidth = showPanel ? state.panelWidth : state.fieldWidth;\n const markerHeight = showPanel ? state.panelHeight : state.fieldHeight;\n\n return (\n <AbsoluteFill\n className={className}\n style={{\n backgroundColor,\n overflow: \"hidden\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n style={{\n width: 1280,\n height: 720,\n flexShrink: 0,\n position: \"relative\",\n transform: `scale(${scale})`,\n }}\n >\n {state.circlesVisible && (\n <svg\n aria-hidden=\"true\"\n width=\"1280\"\n height=\"720\"\n viewBox=\"-640 -360 1280 720\"\n style={{ position: \"absolute\", inset: 0, overflow: \"visible\" }}\n >\n <g fill=\"none\" stroke={ringColor} strokeWidth=\"1\">\n {[-1, 1].map((side) => (\n <g key={side}>\n <circle\n cx={side * state.circleOffset}\n r={state.circleRadius}\n />\n {showGuides &&\n [-1, 1].map((edge) => (\n <Cross\n key={edge}\n x={\n side * state.circleOffset + edge * state.circleRadius\n }\n y={0}\n size={6}\n />\n ))}\n </g>\n ))}\n </g>\n </svg>\n )}\n {state.fieldVisible && (\n <div\n style={{\n position: \"absolute\",\n left: \"50%\",\n top: \"50%\",\n width: 0,\n height: 0,\n transform: `rotate(${state.tilt}deg)`,\n }}\n >\n {showPanel && (\n <div\n style={{\n position: \"absolute\",\n left: -state.panelWidth / 2,\n top: -state.panelHeight / 2,\n width: state.panelWidth,\n height: state.panelHeight,\n borderRadius: state.panelRadius,\n overflow: \"hidden\",\n opacity: state.panelOpacity,\n backgroundColor: panelColor,\n }}\n >\n <svg\n aria-hidden=\"true\"\n width=\"844\"\n height=\"374\"\n viewBox=\"0 0 844 374\"\n style={{\n position: \"absolute\",\n left: \"50%\",\n top: \"50%\",\n transform: `translate(-50%, -50%) scale(${1.07 - state.reveal * 0.07})`,\n }}\n >\n <g\n transform={`translate(310 -45) rotate(${-24 + 10 * state.reveal})`}\n fill=\"none\"\n stroke={fieldColor}\n >\n {Array.from({ length: 30 }, (_, i) => (\n <ellipse\n key={i}\n rx={82 + i * 3}\n ry={118}\n transform={`rotate(${i * 6})`}\n strokeWidth=\"1.4\"\n opacity={0.35 + i / 70}\n />\n ))}\n </g>\n <g\n transform={`translate(65 233) rotate(${state.reveal * 25})`}\n fill={accentColor}\n >\n {Array.from({ length: 10 }, (_, i) => (\n <ellipse\n key={i}\n cy=\"-41\"\n rx=\"19\"\n ry=\"48\"\n transform={`rotate(${i * 36})`}\n />\n ))}\n </g>\n <g\n transform={`translate(720 357) rotate(${-18 * state.reveal})`}\n fill=\"none\"\n stroke={accentColor}\n strokeWidth=\"22\"\n >\n <path d=\"M -68 -115 V 80 M -122 -60 L -14 26 M -125 18 L -12 -61\" />\n <circle cx=\"103\" cy=\"-35\" r=\"54\" />\n </g>\n </svg>\n </div>\n )}\n {showGuides && (\n <svg\n aria-hidden=\"true\"\n width=\"1280\"\n height=\"720\"\n viewBox=\"-640 -360 1280 720\"\n style={{\n position: \"absolute\",\n left: -640,\n top: -360,\n overflow: \"visible\",\n }}\n >\n <g\n fill=\"none\"\n stroke={ringColor}\n strokeWidth=\"1\"\n opacity={0.5 * state.iconOpacity}\n >\n <path\n d={`M ${markerWidth / 2} ${-markerHeight / 2 - 14} V -360 M ${-markerWidth / 2} ${markerHeight / 2 + 14} V 360`}\n />\n </g>\n <g fill=\"none\" stroke={color} strokeWidth=\"1.5\">\n <Cross x={-markerWidth / 2} y={markerHeight / 2} />\n <Cross x={markerWidth / 2} y={-markerHeight / 2} />\n </g>\n </svg>\n )}\n <div\n style={{\n position: \"absolute\",\n left: -state.fieldWidth / 2,\n top: -state.fieldHeight / 2,\n width: state.fieldWidth,\n height: state.fieldHeight,\n borderRadius: 999,\n backgroundColor: fieldColor,\n boxShadow: \"0 3px 12px #26232b08, inset 0 0 0 1px #26232b0a\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n overflow: \"hidden\",\n color,\n fontFamily: \"Arial, Helvetica, sans-serif\",\n fontSize: fittedFont,\n fontWeight: 400,\n }}\n >\n <div\n style={{\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n maxWidth: state.fieldWidth - 116,\n overflow: \"hidden\",\n whiteSpace: \"pre\",\n }}\n >\n <span>{state.text}</span>\n <span\n aria-hidden=\"true\"\n style={{\n width: 1.5,\n height: fittedFont * 1.12,\n marginLeft: 2,\n flexShrink: 0,\n backgroundColor: color,\n opacity: state.caretVisible ? 1 : 0,\n }}\n />\n </div>\n <svg\n aria-hidden=\"true\"\n width=\"28\"\n height=\"28\"\n viewBox=\"0 0 28 28\"\n fill=\"none\"\n stroke={ringColor}\n strokeWidth=\"1.5\"\n strokeLinecap=\"round\"\n style={{\n position: \"absolute\",\n right: 24,\n opacity: state.iconOpacity,\n }}\n >\n <circle cx=\"11.5\" cy=\"11.5\" r=\"7.5\" />\n <path d=\"m17 17 7 7\" />\n </svg>\n </div>\n </div>\n )}\n </div>\n </AbsoluteFill>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n text: {\n type: \"text-content\",\n default: \"remocn\",\n description: \"Search text\",\n },\n fieldWidth: {\n type: \"number\",\n default: 464,\n min: 320,\n max: 640,\n step: 8,\n description: \"Field width\",\n hiddenFromList: false,\n },\n fontSize: {\n type: \"number\",\n default: 34,\n min: 18,\n max: 54,\n step: 1,\n description: \"Font size\",\n hiddenFromList: false,\n },\n framesPerCharacter: {\n type: \"number\",\n default: 4,\n min: 1,\n max: 12,\n step: 1,\n description: \"Frames per character\",\n hiddenFromList: false,\n },\n showPanel: {\n type: \"boolean\",\n default: true,\n description: \"Graphic panel\",\n },\n showGuides: {\n type: \"boolean\",\n default: true,\n description: \"Construction guides\",\n },\n color: {\n type: \"color\",\n default: \"#26232b\",\n description: \"Text and markers\",\n },\n fieldColor: {\n type: \"color\",\n default: \"#ffffff\",\n description: \"Search field\",\n },\n ringColor: {\n type: \"color\",\n default: \"#cbc5cf\",\n description: \"Circles and search icon\",\n },\n panelColor: {\n type: \"color\",\n default: \"#a800b7\",\n description: \"Panel color\",\n },\n accentColor: {\n type: \"color\",\n default: \"#e8f99a\",\n description: \"Graphic accents\",\n },\n backgroundColor: {\n type: \"color\",\n default: \"#f5f1f5\",\n description: \"Background\",\n },\n reducedMotion: {\n type: \"boolean\",\n default: false,\n description: \"Static final pose\",\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"text\",\"fieldWidth\",\"fontSize\",\"framesPerCharacter\",\"showPanel\",\"showGuides\",\"color\",\"fieldColor\",\"ringColor\",\"panelColor\",\"accentColor\",\"backgroundColor\",\"reducedMotion\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n text: \"remocn\",\n fieldWidth: 464,\n fontSize: 34,\n framesPerCharacter: 4,\n showPanel: true,\n showGuides: true,\n color: \"#26232b\",\n fieldColor: \"#ffffff\",\n ringColor: \"#cbc5cf\",\n panelColor: \"#a800b7\",\n accentColor: \"#e8f99a\",\n backgroundColor: \"#f5f1f5\",\n reducedMotion: false,\n speed: 1,\n};\n\ntype SearchRevealElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof SearchRevealBase>;\n\nconst SearchRevealInner = forwardRef<\n HTMLDivElement,\n SearchRevealElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<SearchReveal>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <SearchRevealBase\n {...(componentProps as unknown as ComponentProps<typeof SearchRevealBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const SearchReveal = Interactive.withSchema({\n Component: SearchRevealInner,\n componentName: \"<SearchReveal>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/security-cam.json b/registry-artifacts/elements/security-cam.jsonindex e9a30f8f..2ff6e2e9 100644--- a/registry-artifacts/elements/security-cam.json+++ b/registry-artifacts/elements/security-cam.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/transitions",@@ -11,6 +12,7 @@"dimensions": null,"displayName": "Security Cam","durationInFrames": 90,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "security-cam","sourceCode": "import { AbsoluteFill, Interactive, Sequence, isHtmlInCanvasSupported, useCurrentFrame, useDelayRender, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport React, { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\nimport { type TransitionPresentation, type TransitionPresentationComponentProps } from \"@remotion/transitions\";\n\nconst QUAD = new Float32Array([-1, -1, 1, -1, -1, 1, 1, 1]);\n\nconst VERTEX_SHADER = `#version 300 es\nin vec2 a_pos;\nout vec2 v_uv;\nvoid main() {\n v_uv = vec2(a_pos.x * 0.5 + 0.5, 0.5 - a_pos.y * 0.5);\n gl_Position = vec4(a_pos, 0.0, 1.0);\n}`;\n\nconst LAYER: React.CSSProperties = {\n position: \"absolute\",\n inset: 0,\n width: \"100%\",\n height: \"100%\",\n};\n\nconst OUTPUT_LAYER: React.CSSProperties = { ...LAYER, pointerEvents: \"none\" };\n\nconst isCanvasTransitionSupported = (): boolean =>\n isHtmlInCanvasSupported();\n\nconst isCanvasFilterSupported = (): boolean => isHtmlInCanvasSupported();\n\ntype SceneShaderFrame<Props> = {\n gl: WebGL2RenderingContext;\n uniform: (name: string) => WebGLUniformLocation | null;\n width: number;\n height: number;\n progress: number;\n passedProps: Props;\n};\n\ntype SceneShaderDrawParams<Props> = {\n from: OffscreenCanvas | null;\n to: OffscreenCanvas | null;\n width: number;\n height: number;\n progress: number;\n passedProps: Props;\n};\n\ntype SceneShaderInstance<Props> = {\n draw: (params: SceneShaderDrawParams<Props>) => void;\n clear: () => void;\n cleanup: () => void;\n};\n\ntype SceneShader<Props> = (\n canvas: OffscreenCanvas,\n) => SceneShaderInstance<Props>;\n\ntype SceneFilterFrame<Props> = {\n gl: WebGL2RenderingContext;\n uniform: (name: string) => WebGLUniformLocation | null;\n width: number;\n height: number;\n frame: number;\n time: number;\n passedProps: Props;\n};\n\ntype SceneFilterDrawParams<Props> = {\n scene: OffscreenCanvas | null;\n width: number;\n height: number;\n frame: number;\n time: number;\n passedProps: Props;\n};\n\ntype SceneFilterInstance<Props> = {\n draw: (params: SceneFilterDrawParams<Props>) => void;\n clear: () => void;\n cleanup: () => void;\n};\n\ntype SceneFilter<Props> = (\n canvas: OffscreenCanvas,\n) => SceneFilterInstance<Props>;\n\nfunction compileShader(\n gl: WebGL2RenderingContext,\n source: string,\n type: GLenum,\n): WebGLShader {\n const shader = gl.createShader(type);\n if (!shader) {\n throw new Error(\"canvas-presentation: failed to create shader\");\n }\n gl.shaderSource(shader, source);\n gl.compileShader(shader);\n if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {\n const log = gl.getShaderInfoLog(shader);\n gl.deleteShader(shader);\n throw new Error(`canvas-presentation: failed to compile shader: ${log}`);\n }\n return shader;\n}\n\nfunction createProgram(\n gl: WebGL2RenderingContext,\n fragment: string,\n): WebGLProgram {\n const program = gl.createProgram();\n if (!program) {\n throw new Error(\"canvas-presentation: failed to create program\");\n }\n const vs = compileShader(gl, VERTEX_SHADER, gl.VERTEX_SHADER);\n const fs = compileShader(gl, fragment, gl.FRAGMENT_SHADER);\n gl.attachShader(program, vs);\n gl.attachShader(program, fs);\n gl.linkProgram(program);\n gl.deleteShader(vs);\n gl.deleteShader(fs);\n if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {\n const log = gl.getProgramInfoLog(program);\n gl.deleteProgram(program);\n throw new Error(`canvas-presentation: failed to link program: ${log}`);\n }\n return program;\n}\n\nfunction createSceneTexture(gl: WebGL2RenderingContext): WebGLTexture {\n const texture = gl.createTexture();\n if (!texture) {\n throw new Error(\"canvas-presentation: failed to create texture\");\n }\n gl.bindTexture(gl.TEXTURE_2D, texture);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);\n gl.texImage2D(\n gl.TEXTURE_2D,\n 0,\n gl.RGBA,\n 1,\n 1,\n 0,\n gl.RGBA,\n gl.UNSIGNED_BYTE,\n new Uint8Array([0, 0, 0, 0]),\n );\n return texture;\n}\n\nfunction createQuadSurface(canvas: OffscreenCanvas, fragment: string) {\n const gl = canvas.getContext(\"webgl2\", { premultipliedAlpha: true });\n if (!gl) {\n throw new Error(\"canvas-presentation: WebGL2 is unavailable\");\n }\n\n const program = createProgram(gl, fragment);\n const vao = gl.createVertexArray();\n gl.bindVertexArray(vao);\n const buffer = gl.createBuffer();\n gl.bindBuffer(gl.ARRAY_BUFFER, buffer);\n gl.bufferData(gl.ARRAY_BUFFER, QUAD, gl.STATIC_DRAW);\n const aPos = gl.getAttribLocation(program, \"a_pos\");\n gl.enableVertexAttribArray(aPos);\n gl.vertexAttribPointer(aPos, 2, gl.FLOAT, false, 0, 0);\n\n const locations = new Map<string, WebGLUniformLocation | null>();\n const uniform = (name: string) => {\n const cached = locations.get(name);\n if (cached !== undefined) {\n return cached;\n }\n const location = gl.getUniformLocation(program, name);\n locations.set(name, location);\n return location;\n };\n\n const clear = () => {\n gl.clearColor(0, 0, 0, 0);\n gl.clear(gl.COLOR_BUFFER_BIT);\n };\n\n const textures: WebGLTexture[] = [];\n const createTexture = () => {\n const texture = createSceneTexture(gl);\n textures.push(texture);\n return texture;\n };\n\n const begin = (width: number, height: number) => {\n gl.viewport(0, 0, width, height);\n clear();\n gl.useProgram(program);\n gl.bindVertexArray(vao);\n };\n\n const bindScene = (\n image: OffscreenCanvas | null,\n texture: WebGLTexture,\n unit: number,\n name: string,\n ) => {\n gl.activeTexture(gl.TEXTURE0 + unit);\n gl.bindTexture(gl.TEXTURE_2D, texture);\n if (image) {\n gl.texImage2D(\n gl.TEXTURE_2D,\n 0,\n gl.RGBA,\n gl.RGBA,\n gl.UNSIGNED_BYTE,\n image,\n );\n }\n gl.uniform1i(uniform(name), unit);\n };\n\n const draw = () => gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);\n\n const cleanup = () => {\n gl.deleteProgram(program);\n for (const texture of textures) {\n gl.deleteTexture(texture);\n }\n gl.deleteBuffer(buffer);\n gl.deleteVertexArray(vao);\n };\n\n return {\n gl,\n uniform,\n clear,\n createTexture,\n begin,\n bindScene,\n draw,\n cleanup,\n };\n}\n\nfunction makeSceneShader<Props extends Record<string, unknown>>(\n fragment: string,\n setUniforms?: (frame: SceneShaderFrame<Props>) => void,\n): SceneShader<Props> {\n return (canvas) => {\n const surface = createQuadSurface(canvas, fragment);\n const fromTexture = surface.createTexture();\n const toTexture = surface.createTexture();\n\n return {\n clear: surface.clear,\n cleanup: surface.cleanup,\n draw: ({ from, to, width, height, progress, passedProps }) => {\n surface.begin(width, height);\n surface.bindScene(from, fromTexture, 0, \"u_from\");\n surface.bindScene(to, toTexture, 1, \"u_to\");\n\n surface.gl.uniform1f(surface.uniform(\"u_progress\"), progress);\n surface.gl.uniform1f(surface.uniform(\"u_aspect\"), width / height);\n setUniforms?.({\n gl: surface.gl,\n uniform: surface.uniform,\n width,\n height,\n progress,\n passedProps,\n });\n\n surface.draw();\n },\n };\n };\n}\n\nfunction makeFilterShader<Props extends Record<string, unknown>>(\n fragment: string,\n setUniforms?: (frame: SceneFilterFrame<Props>) => void,\n): SceneFilter<Props> {\n return (canvas) => {\n const surface = createQuadSurface(canvas, fragment);\n const sceneTexture = surface.createTexture();\n\n return {\n clear: surface.clear,\n cleanup: surface.cleanup,\n draw: ({ scene, width, height, frame, time, passedProps }) => {\n surface.begin(width, height);\n surface.bindScene(scene, sceneTexture, 0, \"u_scene\");\n\n surface.gl.uniform1f(surface.uniform(\"u_frame\"), frame);\n surface.gl.uniform1f(surface.uniform(\"u_time\"), time);\n surface.gl.uniform1f(surface.uniform(\"u_aspect\"), width / height);\n setUniforms?.({\n gl: surface.gl,\n uniform: surface.uniform,\n width,\n height,\n frame,\n time,\n passedProps,\n });\n\n surface.draw();\n },\n };\n };\n}\n\nconst transferred = new WeakMap<HTMLCanvasElement, OffscreenCanvas>();\n\nfunction takeOffscreen(canvas: HTMLCanvasElement): OffscreenCanvas {\n const existing = transferred.get(canvas);\n if (existing) {\n return existing;\n }\n const created = canvas.transferControlToOffscreen();\n transferred.set(canvas, created);\n return created;\n}\n\nfunction makeCanvasComponent<Props extends Record<string, unknown>>(\n shader: SceneShader<Props>,\n): React.FC<TransitionPresentationComponentProps<Props>> {\n return function CanvasScenePresentation({\n children,\n presentationProgress,\n presentationDirection,\n passedProps,\n onElementImage,\n onUnmount,\n bothEnteringAndExiting,\n }) {\n const layoutRef = React.useRef<HTMLCanvasElement | null>(null);\n const outputRef = React.useRef<HTMLCanvasElement | null>(null);\n const captureRef = React.useRef<OffscreenCanvas | null>(null);\n const captureContextRef =\n React.useRef<OffscreenCanvasRenderingContext2D | null>(null);\n const outputSurfaceRef = React.useRef<OffscreenCanvas | null>(null);\n const instanceRef = React.useRef<SceneShaderInstance<Props> | null>(null);\n const passedPropsRef = React.useRef(passedProps);\n passedPropsRef.current = passedProps;\n const onElementImageRef = React.useRef(onElementImage);\n onElementImageRef.current = onElementImage;\n const onUnmountRef = React.useRef(onUnmount);\n onUnmountRef.current = onUnmount;\n\n const { delayRender, continueRender } = useDelayRender();\n const passThrough =\n bothEnteringAndExiting && presentationDirection === \"exiting\";\n\n const drawRef = React.useRef<\n (\n prevImage: OffscreenCanvas | null,\n nextImage: OffscreenCanvas | null,\n progress: number,\n ) => void\n >(() => undefined);\n drawRef.current = (prevImage, nextImage, progress) => {\n const instance = instanceRef.current;\n if (!instance) {\n return;\n }\n const handle = delayRender(\"canvas-presentation: paint\");\n const to = prevImage;\n const from = nextImage;\n const width = from?.width ?? to?.width ?? 0;\n const height = from?.height ?? to?.height ?? 0;\n if (width === 0 || height === 0) {\n instance.clear();\n continueRender(handle);\n return;\n }\n instance.draw({\n from,\n to,\n width,\n height,\n progress: !to ? 0 : !from ? 1 : progress,\n passedProps: passedPropsRef.current,\n });\n continueRender(handle);\n };\n\n const draw = React.useCallback(\n (\n prevImage: OffscreenCanvas | null,\n nextImage: OffscreenCanvas | null,\n progress: number,\n ) => drawRef.current(prevImage, nextImage, progress),\n [],\n );\n\n React.useLayoutEffect(() => {\n if (passThrough) {\n return;\n }\n const layout = layoutRef.current;\n const output = outputRef.current;\n if (!layout || !output) {\n return;\n }\n const capture = takeOffscreen(layout);\n const context = capture.getContext(\"2d\");\n if (!context) {\n throw new Error(\"canvas-presentation: failed to acquire a 2D context\");\n }\n const surface = takeOffscreen(output);\n captureRef.current = capture;\n captureContextRef.current = context;\n outputSurfaceRef.current = surface;\n instanceRef.current = shader(surface);\n\n return () => {\n instanceRef.current?.cleanup();\n instanceRef.current = null;\n captureRef.current = null;\n captureContextRef.current = null;\n outputSurfaceRef.current = null;\n };\n }, [passThrough, shader]);\n\n React.useLayoutEffect(() => {\n if (passThrough) {\n return;\n }\n const layout = layoutRef.current;\n if (!layout) {\n return;\n }\n layout.layoutSubtree = true;\n const handlePaint = () => {\n const scene = layout.firstElementChild;\n const capture = captureRef.current;\n const context = captureContextRef.current;\n if (!scene || !capture || !context) {\n return;\n }\n const elementImage = layout.captureElementImage(scene);\n try {\n context.reset();\n context.drawElementImage(elementImage, 0, 0);\n } finally {\n elementImage.close();\n }\n onElementImageRef.current(capture, draw);\n };\n layout.addEventListener(\"paint\", handlePaint);\n return () => layout.removeEventListener(\"paint\", handlePaint);\n }, [passThrough, draw]);\n\n React.useLayoutEffect(() => {\n if (passThrough) {\n return;\n }\n const layout = layoutRef.current;\n if (!layout) {\n return;\n }\n const observer = new ResizeObserver(([entry]) => {\n const capture = captureRef.current;\n const surface = outputSurfaceRef.current;\n if (!capture || !surface) {\n return;\n }\n const width = entry.devicePixelContentBoxSize[0].inlineSize;\n const height = entry.devicePixelContentBoxSize[0].blockSize;\n capture.width = width;\n capture.height = height;\n surface.width = width;\n surface.height = height;\n layout.requestPaint?.();\n });\n observer.observe(layout, { box: \"device-pixel-content-box\" });\n return () => observer.disconnect();\n }, [passThrough]);\n\n // biome-ignore lint/correctness/useExhaustiveDependencies: presentationProgress is the intentional trigger — a new progress value is what schedules the next paint\n React.useLayoutEffect(() => {\n if (passThrough) {\n return;\n }\n layoutRef.current?.requestPaint?.();\n }, [passThrough, presentationProgress]);\n\n React.useLayoutEffect(() => {\n if (passThrough) {\n return;\n }\n return () => onUnmountRef.current();\n }, [passThrough]);\n\n if (passThrough) {\n return <>{children}</>;\n }\n\n return (\n <AbsoluteFill>\n <canvas ref={layoutRef} style={LAYER}>\n {children}\n </canvas>\n <canvas ref={outputRef} style={OUTPUT_LAYER} />\n </AbsoluteFill>\n );\n };\n}\n\ntype CanvasFilterProps = {\n children: React.ReactNode;\n};\n\nfunction makeFilterComponent<Props extends Record<string, unknown>>(\n shader: SceneFilter<Props>,\n): React.FC<Props & CanvasFilterProps> {\n return function CanvasSceneFilter(props) {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const { delayRender, continueRender } = useDelayRender();\n\n const layoutRef = React.useRef<HTMLCanvasElement | null>(null);\n const outputRef = React.useRef<HTMLCanvasElement | null>(null);\n const captureRef = React.useRef<OffscreenCanvas | null>(null);\n const captureContextRef =\n React.useRef<OffscreenCanvasRenderingContext2D | null>(null);\n const outputSurfaceRef = React.useRef<OffscreenCanvas | null>(null);\n const instanceRef = React.useRef<SceneFilterInstance<Props> | null>(null);\n\n const passedPropsRef = React.useRef(props);\n passedPropsRef.current = props;\n const frameRef = React.useRef(frame);\n frameRef.current = frame;\n const timeRef = React.useRef(frame / fps);\n timeRef.current = frame / fps;\n\n React.useLayoutEffect(() => {\n const layout = layoutRef.current;\n const output = outputRef.current;\n if (!layout || !output) {\n return;\n }\n const capture = takeOffscreen(layout);\n const context = capture.getContext(\"2d\");\n if (!context) {\n throw new Error(\"canvas-presentation: failed to acquire a 2D context\");\n }\n const surface = takeOffscreen(output);\n captureRef.current = capture;\n captureContextRef.current = context;\n outputSurfaceRef.current = surface;\n instanceRef.current = shader(surface);\n\n return () => {\n instanceRef.current?.cleanup();\n instanceRef.current = null;\n captureRef.current = null;\n captureContextRef.current = null;\n outputSurfaceRef.current = null;\n };\n }, [shader]);\n\n React.useLayoutEffect(() => {\n const layout = layoutRef.current;\n if (!layout) {\n return;\n }\n layout.layoutSubtree = true;\n const handlePaint = () => {\n const scene = layout.firstElementChild;\n const capture = captureRef.current;\n const context = captureContextRef.current;\n const instance = instanceRef.current;\n if (!scene || !capture || !context || !instance) {\n return;\n }\n const elementImage = layout.captureElementImage(scene);\n try {\n context.reset();\n context.drawElementImage(elementImage, 0, 0);\n } finally {\n elementImage.close();\n }\n if (capture.width === 0 || capture.height === 0) {\n instance.clear();\n return;\n }\n instance.draw({\n scene: capture,\n width: capture.width,\n height: capture.height,\n frame: frameRef.current,\n time: timeRef.current,\n passedProps: passedPropsRef.current,\n });\n };\n layout.addEventListener(\"paint\", handlePaint);\n return () => layout.removeEventListener(\"paint\", handlePaint);\n }, []);\n\n React.useLayoutEffect(() => {\n const layout = layoutRef.current;\n if (!layout) {\n return;\n }\n const observer = new ResizeObserver(([entry]) => {\n const capture = captureRef.current;\n const surface = outputSurfaceRef.current;\n if (!capture || !surface) {\n return;\n }\n const width = entry.devicePixelContentBoxSize[0].inlineSize;\n const height = entry.devicePixelContentBoxSize[0].blockSize;\n capture.width = width;\n capture.height = height;\n surface.width = width;\n surface.height = height;\n layout.requestPaint?.();\n });\n observer.observe(layout, { box: \"device-pixel-content-box\" });\n return () => observer.disconnect();\n }, []);\n\n React.useLayoutEffect(() => {\n const layout = layoutRef.current;\n if (!layout) {\n return;\n }\n const handle = delayRender(\"canvas-presentation: filter paint\");\n const settle = () => continueRender(handle);\n layout.addEventListener(\"paint\", settle, { once: true });\n layout.requestPaint?.();\n return () => {\n layout.removeEventListener(\"paint\", settle);\n continueRender(handle);\n };\n });\n\n return (\n <AbsoluteFill>\n <canvas ref={layoutRef} style={LAYER}>\n {props.children}\n </canvas>\n <canvas ref={outputRef} style={OUTPUT_LAYER} />\n </AbsoluteFill>\n );\n };\n}\n\ntype CanvasPresentationOptions<Props extends Record<string, unknown>> = {\n shader: SceneShader<Props>;\n fallback: React.FC<TransitionPresentationComponentProps<Props>>;\n};\n\nfunction makeCanvasPresentation<Props extends Record<string, unknown>>({\n shader,\n fallback: Fallback,\n}: CanvasPresentationOptions<Props>): (\n props: Props,\n) => TransitionPresentation<Props> {\n const Canvas = makeCanvasComponent(shader);\n\n const Presentation: React.FC<TransitionPresentationComponentProps<Props>> = (\n props,\n ) =>\n isCanvasTransitionSupported() ? (\n <Canvas {...props} />\n ) : (\n <Fallback {...props} />\n );\n\n return (props) => ({ component: Presentation, props });\n}\n\ntype CanvasFilterOptions<Props extends Record<string, unknown>> = {\n shader: SceneFilter<Props>;\n fallback: React.FC<Props & CanvasFilterProps>;\n};\n\nfunction makeCanvasFilter<Props extends Record<string, unknown>>({\n shader,\n fallback: Fallback,\n}: CanvasFilterOptions<Props>): React.FC<Props & CanvasFilterProps> {\n const Canvas = makeFilterComponent(shader);\n\n return function CanvasFilter(props) {\n return isCanvasFilterSupported() ? (\n <Canvas {...props} />\n ) : (\n <Fallback {...props} />\n );\n };\n}\n\ntype SecurityCamProps = {\n compression?: number;\n blockSize?: number;\n noise?: number;\n intensity?: number;\n};\n\nconst DEFAULTS = {\n compression: 0.7,\n blockSize: 10,\n noise: 0.6,\n intensity: 1,\n};\n\ntype NormalizedProps = {\n compression: number;\n cellX: number;\n cellY: number;\n noise: number;\n intensity: number;\n};\n\nconst FRAGMENT_SHADER = `#version 300 es\nprecision highp float;\n\nuniform sampler2D u_scene;\nuniform float u_frame;\nuniform vec2 u_cell;\nuniform float u_compression;\nuniform float u_noise;\nuniform float u_intensity;\n\nin vec2 v_uv;\nout vec4 outColor;\n\nconst float PI = 3.141592653589793;\n\nfloat hash(vec2 p) {\n return fract(sin(dot(p, vec2(12.9898, 78.233))) * 43758.5453123);\n}\n\nfloat lumaOf(vec3 c) {\n return dot(c, vec3(0.299, 0.587, 0.114));\n}\n\nvec2 chromaOf(vec3 c) {\n return vec2(c.b - lumaOf(c), c.r - lumaOf(c));\n}\n\nvec3 fromLumaChroma(float y, vec2 cbcr) {\n return vec3(y + cbcr.y, y - 0.194 * cbcr.x - 0.509 * cbcr.y, y + cbcr.x);\n}\n\nvec3 blockMean(vec2 origin, vec2 cell) {\n vec3 total = vec3(0.0);\n for (int y = 0; y < 2; y++) {\n for (int x = 0; x < 2; x++) {\n vec2 at = origin + (vec2(float(x), float(y)) + 0.5) * cell * 0.5;\n total += texture(u_scene, at).rgb;\n }\n }\n return total * 0.25;\n}\n\nvoid main() {\n vec4 src = texture(u_scene, v_uv);\n float amount = clamp(u_intensity, 0.0, 1.0);\n\n if (!(amount > 0.001)) {\n outColor = src;\n return;\n }\n\n vec2 cell = max(u_cell, vec2(0.0008));\n vec2 wide = cell * 2.0;\n\n vec3 lumaBlock = blockMean(floor(v_uv / cell) * cell, cell);\n vec3 chromaBlock = blockMean(floor(v_uv / wide) * wide, wide);\n\n float squeeze = clamp(u_compression, 0.0, 1.0) * amount;\n\n float y = mix(lumaOf(src.rgb), lumaOf(lumaBlock), squeeze * 0.8);\n float levels = mix(255.0, 20.0, squeeze);\n y = floor(y * levels + 0.5) / levels;\n\n vec2 cbcr = mix(chromaOf(src.rgb), chromaOf(chromaBlock), squeeze);\n cbcr *= mix(1.0, 0.62, amount);\n\n vec3 color = fromLumaChroma(y, cbcr);\n\n float pump = 1.0 + 0.03 * sin(u_frame * PI / 45.0) * amount;\n color = clamp((color * pump - 0.05 * amount) / (1.0 - 0.14 * amount), 0.0, 1.0);\n\n float clock = mod(u_frame, 64.0);\n float shadow = 1.0 - smoothstep(0.0, 0.55, y);\n float grain =\n hash(v_uv + vec2(clock * 0.017, clock * 0.029)) - 0.5;\n color += grain * 0.16 * u_noise * amount * (0.25 + shadow);\n\n outColor = vec4(clamp(color, 0.0, 1.0), src.a);\n}`;\n\nconst shader = makeFilterShader<NormalizedProps>(\n FRAGMENT_SHADER,\n ({ gl, uniform, passedProps }) => {\n const { compression, cellX, cellY, noise, intensity } = passedProps;\n gl.uniform1f(uniform(\"u_compression\"), compression);\n gl.uniform2f(uniform(\"u_cell\"), cellX, cellY);\n gl.uniform1f(uniform(\"u_noise\"), noise);\n gl.uniform1f(uniform(\"u_intensity\"), intensity);\n },\n);\n\nconst SecurityCamFallback: React.FC<NormalizedProps & CanvasFilterProps> = ({\n children,\n intensity,\n}) => (\n <AbsoluteFill>\n <AbsoluteFill\n style={{\n filter: `saturate(${1 - 0.38 * intensity}) contrast(${1 + 0.22 * intensity}) brightness(${1 - 0.05 * intensity})`,\n }}\n >\n {children}\n </AbsoluteFill>\n <AbsoluteFill\n style={{\n background:\n \"radial-gradient(ellipse 82% 80% at 50% 50%, transparent 50%, rgba(0, 0, 0, 0.55) 100%)\",\n opacity: intensity,\n }}\n />\n </AbsoluteFill>\n);\n\nconst SecurityCamCanvas = makeCanvasFilter<NormalizedProps>({\n shader,\n fallback: SecurityCamFallback,\n});\n\nconst SecurityCamBase: React.FC<SecurityCamProps & CanvasFilterProps> = ({\n compression = DEFAULTS.compression,\n blockSize = DEFAULTS.blockSize,\n noise = DEFAULTS.noise,\n intensity = DEFAULTS.intensity,\n children,\n}) => {\n const { width, height } = useVideoConfig();\n\n return (\n <SecurityCamCanvas\n compression={compression}\n cellX={Math.max(blockSize, 1) / width}\n cellY={Math.max(blockSize, 1) / height}\n noise={noise}\n intensity={intensity}\n >\n {children}\n </SecurityCamCanvas>\n );\n};\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n compression: {\n type: \"number\",\n min: 0,\n max: 1,\n step: 0.05,\n default: 0.7,\n description: \"Compression\",\n hiddenFromList: false,\n },\n blockSize: {\n type: \"number\",\n min: 4,\n max: 32,\n step: 1,\n default: 10,\n description: \"Macroblock\",\n hiddenFromList: false,\n },\n noise: {\n type: \"number\",\n min: 0,\n max: 2,\n step: 0.05,\n default: 0.6,\n description: \"Sensor noise\",\n hiddenFromList: false,\n },\n intensity: {\n type: \"number\",\n min: 0,\n max: 1,\n step: 0.05,\n default: 1,\n description: \"Intensity\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"compression\",\"blockSize\",\"noise\",\"intensity\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n compression: 0.7,\n blockSize: 10,\n noise: 0.6,\n intensity: 1,\n speed: 1,\n};\n\ntype SecurityCamElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof SecurityCamBase>;\n\nconst SecurityCamInner = forwardRef<\n HTMLDivElement,\n SecurityCamElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<SecurityCam>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <SecurityCamBase\n {...(componentProps as unknown as ComponentProps<typeof SecurityCamBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const SecurityCam = Interactive.withSchema({\n Component: SecurityCamInner,\n componentName: \"<SecurityCam>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/selection-snap.json b/registry-artifacts/elements/selection-snap.jsonindex fa3d2724..62d0960a 100644--- a/registry-artifacts/elements/selection-snap.json+++ b/registry-artifacts/elements/selection-snap.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/google-fonts",@@ -11,6 +12,7 @@"dimensions": null,"displayName": "Selection Snap","durationInFrames": 38,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "selection-snap","sourceCode": "import { loadFont } from \"@remotion/google-fonts/Inter\";\nimport { forwardRef, useEffect, useImperativeHandle, useRef, useState, type CSSProperties, type ComponentProps } from \"react\";\nimport { Easing, Interactive, Sequence, continueRender, delayRender, interpolate, interpolateColors, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\n\nconst { fontFamily: INTER } = loadFont(\"normal\", {\n weights: [\"100\", \"900\"],\n subsets: [\"latin\"],\n});\n\ninterface SelectionSnapProps {\n text?: string;\n fontSize?: number;\n fontFamily?: string;\n fromWeight?: number;\n toWeight?: number;\n color?: string;\n accent?: string;\n selectionColor?: string;\n badge?: boolean;\n speed?: number;\n className?: string;\n}\n\nconst selectionSnapDefaults = {\n text: \"Frame\",\n fontSize: 150,\n fontFamily: INTER,\n fromWeight: 100,\n toWeight: 900,\n color: \"#fafafa\",\n accent: \"#D97757\",\n selectionColor: \"#0d99ff\",\n badge: true,\n speed: 1,\n} satisfies Required<Omit<SelectionSnapProps, \"className\">>;\n\n/** Frame on the 30 fps timeline where every channel has come to rest. */\nconst selectionSnapLength = 38;\n\n/** Padding around the word, in em: the loose viewfinder and the snapped box. */\nconst selectionSnapPadding = {\n loose: { x: 1.1, y: 0.9 },\n tight: { x: 0.12, y: 0 },\n} as const;\n\n/** Corners first, then edge midpoints, as fractions of the box. */\nconst selectionSnapHandles = [\n [0, 0],\n [1, 0],\n [1, 1],\n [0, 1],\n [0.5, 0],\n [1, 0.5],\n [0.5, 1],\n [0, 0.5],\n] as const;\n\nconst CLAMP = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n} as const;\n\nconst easeOutCubic = Easing.out(Easing.cubic);\nconst easeInOutCubic = Easing.inOut(Easing.cubic);\nconst snapEase = Easing.bezier(0.34, 1.3, 0.64, 1);\nconst popEase = Easing.out(Easing.back(1.7));\n\nfunction finite(value: number | undefined, fallback: number) {\n return typeof value === \"number\" && Number.isFinite(value) ? value : fallback;\n}\n\n/** Back-eased 0 → 1 over `duration` frames from `start`, never below 0. */\nfunction pop(t: number, start: number, duration: number) {\n return Math.max(\n 0,\n interpolate(t, [start, start + duration], [0, 1], {\n ...CLAMP,\n easing: popEase,\n }),\n );\n}\n\n/** Maps a composition frame onto the 30 fps timeline, scaled by `speed`. */\nfunction getSelectionSnapTime(\n frame: number,\n options: { fps?: number; speed?: number } = {},\n) {\n const fps = Math.max(1, finite(options.fps, 30));\n const speed = Math.max(0, finite(options.speed, 1));\n return (Math.max(0, finite(frame, 0)) * 30 * speed) / fps;\n}\n\ninterface SelectionSnapState {\n /** Word and brackets fading in, 0..1. */\n intro: number;\n /** Viewfinder settle scale. */\n bracketScale: number;\n /** Loose (0) to tight (1) padding. Overshoots past 1 on the snap. */\n snap: number;\n /** Weight progress, 0..1. */\n weight: number;\n /** Color progress toward the accent, 0..1. */\n tint: number;\n /** Bracket arms growing along the edges; 1 closes them into a box. */\n edges: number;\n /** Scale of each handle, in `selectionSnapHandles` order. */\n handles: number[];\n /** Badge entrance, 0..1 with overshoot. */\n badge: number;\n /** Badge readout progress, 0..1. */\n count: number;\n}\n\nfunction getSelectionSnapState(t: number): SelectionSnapState {\n return {\n intro: interpolate(t, [0, 8], [0, 1], { ...CLAMP, easing: easeOutCubic }),\n bracketScale: interpolate(t, [0, 8], [1.06, 1], {\n ...CLAMP,\n easing: easeOutCubic,\n }),\n snap: interpolate(t, [14, 28], [0, 1], { ...CLAMP, easing: snapEase }),\n weight: interpolate(t, [14, 30], [0, 1], {\n ...CLAMP,\n easing: easeInOutCubic,\n }),\n tint: interpolate(t, [18, 30], [0, 1], {\n ...CLAMP,\n easing: easeInOutCubic,\n }),\n edges: interpolate(t, [16, 26], [0, 1], {\n ...CLAMP,\n easing: easeInOutCubic,\n }),\n handles: selectionSnapHandles.map((_, i) => pop(t, 24 + i, 5)),\n badge: pop(t, 24, 8),\n count: interpolate(t, [24, 38], [0, 1], { ...CLAMP, easing: easeOutCubic }),\n };\n}\n\n/** Padding in em for a snap progress. */\nfunction getSelectionSnapPadding(snap: number) {\n const { loose, tight } = selectionSnapPadding;\n return {\n x: loose.x + (tight.x - loose.x) * snap,\n y: loose.y + (tight.y - loose.y) * snap,\n };\n}\n\n/** Size of the snapped box in reference px, from the word's final width. */\nfunction getSelectionSnapSize(textWidth: number, fontSize: number) {\n const { tight } = selectionSnapPadding;\n return {\n width: Math.round(textWidth + 2 * tight.x * fontSize),\n height: Math.round(fontSize * (1 + 2 * tight.y)),\n };\n}\n\nfunction useTextWidth(text: string, font: string) {\n const [width, setWidth] = useState<number | null>(null);\n\n useEffect(() => {\n const handle = delayRender(\"selection-snap: measuring the word\");\n let released = false;\n const release = () => {\n if (released) return;\n released = true;\n continueRender(handle);\n };\n const measure = () => {\n if (released) return;\n const ctx = document.createElement(\"canvas\").getContext(\"2d\");\n if (ctx) {\n ctx.font = font;\n setWidth(ctx.measureText(text).width);\n }\n release();\n };\n document.fonts.load(font, text).then(measure, measure);\n return release;\n }, [text, font]);\n\n return width;\n}\n\nfunction SelectionSnapBase({\n text = selectionSnapDefaults.text,\n fontSize = selectionSnapDefaults.fontSize,\n fontFamily = selectionSnapDefaults.fontFamily,\n fromWeight = selectionSnapDefaults.fromWeight,\n toWeight = selectionSnapDefaults.toWeight,\n color = selectionSnapDefaults.color,\n accent = selectionSnapDefaults.accent,\n selectionColor = selectionSnapDefaults.selectionColor,\n badge = selectionSnapDefaults.badge,\n speed = selectionSnapDefaults.speed,\n className,\n}: SelectionSnapProps) {\n const frame = useCurrentFrame();\n const { fps, height } = useVideoConfig();\n const unit = height / 720;\n const t = getSelectionSnapTime(frame, { fps, speed });\n const state = getSelectionSnapState(t);\n\n const size = fontSize * unit;\n const pad = getSelectionSnapPadding(state.snap);\n const weight = fromWeight + (toWeight - fromWeight) * state.weight;\n const stroke = Math.max(1, 1.5 * unit);\n const arm = 0.16 * size;\n const handleSize = 9 * unit;\n const finalWidth = useTextWidth(\n text,\n `${toWeight} ${fontSize}px ${fontFamily}`,\n );\n const readout =\n finalWidth === null ? null : getSelectionSnapSize(finalWidth, fontSize);\n\n // Percentages resolve against the box width for `width` and its height for\n // `height`, so one expression grows every arm to its edge's midpoint.\n const along = `calc(${arm}px + (50% - ${arm}px) * ${state.edges})`;\n const arms: CSSProperties[] = [\n { top: 0, left: 0, width: along, height: stroke },\n { top: 0, right: 0, width: along, height: stroke },\n { bottom: 0, left: 0, width: along, height: stroke },\n { bottom: 0, right: 0, width: along, height: stroke },\n { top: 0, left: 0, width: stroke, height: along },\n { bottom: 0, left: 0, width: stroke, height: along },\n { top: 0, right: 0, width: stroke, height: along },\n { bottom: 0, right: 0, width: stroke, height: along },\n ];\n\n return (\n <div\n className={className}\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n overflow: \"hidden\",\n }}\n >\n <div\n style={{\n position: \"relative\",\n display: \"inline-block\",\n padding: `${pad.y * size}px ${pad.x * size}px`,\n }}\n >\n <span\n style={{\n display: \"block\",\n whiteSpace: \"pre\",\n fontFamily,\n fontSize: size,\n lineHeight: 1,\n fontWeight: Math.round(weight / 100) * 100,\n fontVariationSettings: `\"wght\" ${weight.toFixed(2)}`,\n color: interpolateColors(state.tint, [0, 1], [color, accent]),\n opacity: state.intro,\n }}\n >\n {text}\n </span>\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n opacity: state.intro,\n transform: `scale(${state.bracketScale})`,\n }}\n >\n {arms.map((style, i) => (\n <div\n key={i}\n style={{\n position: \"absolute\",\n background: selectionColor,\n ...style,\n }}\n />\n ))}\n {selectionSnapHandles.map(([x, y], i) => (\n <div\n key={`${x}-${y}`}\n style={{\n position: \"absolute\",\n left: `${x * 100}%`,\n top: `${y * 100}%`,\n width: handleSize,\n height: handleSize,\n boxSizing: \"border-box\",\n background: \"#ffffff\",\n border: `${stroke}px solid ${selectionColor}`,\n transform: `translate(-50%, -50%) scale(${state.handles[i]})`,\n }}\n />\n ))}\n </div>\n {badge && readout ? (\n <div\n style={{\n position: \"absolute\",\n left: \"50%\",\n top: `calc(100% + ${12 * unit}px)`,\n padding: `${3 * unit}px ${7 * unit}px`,\n borderRadius: 4 * unit,\n background: selectionColor,\n color: \"#ffffff\",\n fontFamily: INTER,\n fontSize: 14 * unit,\n lineHeight: 1.2,\n fontWeight: 600,\n fontVariationSettings: '\"wght\" 600',\n fontVariantNumeric: \"tabular-nums\",\n whiteSpace: \"nowrap\",\n opacity: Math.min(1, state.badge),\n transform: `translate(-50%, ${(1 - state.badge) * 8 * unit}px) scale(${0.6 + 0.4 * state.badge})`,\n transformOrigin: \"50% 0\",\n }}\n >\n {Math.round(readout.width * state.count)} ×{\" \"}\n {Math.round(readout.height * state.count)}\n </div>\n ) : null}\n </div>\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n text: {\n type: \"text-content\",\n default: \"Frame\",\n description: \"Text\",\n },\n color: {\n type: \"color\",\n default: \"#fafafa\",\n description: \"Start color\",\n },\n accent: {\n type: \"color\",\n default: \"#ff4d1a\",\n description: \"Accent\",\n },\n selectionColor: {\n type: \"color\",\n default: \"#3d5afe\",\n description: \"Selection\",\n },\n fontSize: {\n type: \"number\",\n default: 150,\n min: 60,\n max: 260,\n step: 2,\n description: \"Font size\",\n hiddenFromList: false,\n },\n fromWeight: {\n type: \"number\",\n default: 100,\n min: 100,\n max: 900,\n step: 50,\n description: \"From weight\",\n hiddenFromList: false,\n },\n toWeight: {\n type: \"number\",\n default: 900,\n min: 100,\n max: 900,\n step: 50,\n description: \"To weight\",\n hiddenFromList: false,\n },\n badge: {\n type: \"boolean\",\n default: true,\n description: \"Size badge\",\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"text\",\"color\",\"accent\",\"selectionColor\",\"fontSize\",\"fromWeight\",\"toWeight\",\"badge\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n text: \"Frame\",\n color: \"#fafafa\",\n accent: \"#ff4d1a\",\n selectionColor: \"#3d5afe\",\n fontSize: 150,\n fromWeight: 100,\n toWeight: 900,\n badge: true,\n speed: 1,\n};\n\ntype SelectionSnapElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof SelectionSnapBase>;\n\nconst SelectionSnapInner = forwardRef<\n HTMLDivElement,\n SelectionSnapElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<SelectionSnap>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <SelectionSnapBase\n {...(componentProps as unknown as ComponentProps<typeof SelectionSnapBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const SelectionSnap = Interactive.withSchema({\n Component: SelectionSnapInner,\n componentName: \"<SelectionSnap>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/shader-caustics.json b/registry-artifacts/elements/shader-caustics.jsonindex c146846f..a07da5ea 100644--- a/registry-artifacts/elements/shader-caustics.json+++ b/registry-artifacts/elements/shader-caustics.json@@ -2,10 +2,12 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [],"dimensions": null,"displayName": "Shader Caustics","durationInFrames": 150,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "shader-caustics","sourceCode": "import { forwardRef, useEffect, useImperativeHandle, useRef, useState, type ComponentProps } from \"react\";\nimport { Interactive, Sequence, continueRender, delayRender, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\n\n// A field of refracted light — caustics. The web of bright filaments light\n// makes when it passes through a surface and lands on the floor beneath.\n// Written for the remocn registry as a custom WebGL shader (not a\n// paper-design wrapper): frame-driven, deterministic, no wall-clock time.\n//\n// The filaments are slightly denser and brighter toward the bottom of the\n// frame — the light lands on the base — which makes it a natural carrier for\n// foundation stories. `accent` / `accentAmount` tint the filaments themselves\n// (not the floor), so an undertone can arrive mid-video by animating\n// `accentAmount` from the master timeline and stay in the light afterwards.\n\ninterface ShaderCausticsProps {\n /** [floor color, filament light color]. */\n colors?: [string, string];\n /** Tint mixed into the bright filaments. */\n accent?: string;\n /** 0..1 — how much of the accent the filaments take. */\n accentAmount?: number;\n /** Spatial frequency of the light web. */\n scale?: number;\n /** Overall brightness of the filaments. */\n intensity?: number;\n /** Global time multiplier. */\n speed?: number;\n className?: string;\n}\n\nconst VERT = `\nattribute vec2 a_pos;\nvoid main() {\n gl_Position = vec4(a_pos, 0.0, 1.0);\n}\n`;\n\nconst FRAG = `\nprecision highp float;\n\nuniform vec2 u_res;\nuniform float u_time;\nuniform float u_scale;\nuniform float u_intensity;\nuniform vec3 u_floor;\nuniform vec3 u_light;\nuniform vec3 u_accent;\nuniform float u_accentAmt;\n\nfloat hash(vec2 p) {\n return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453123);\n}\n\nvoid main() {\n vec2 uv = gl_FragCoord.xy / u_res;\n float aspect = u_res.x / u_res.y;\n vec2 p = vec2(uv.x * aspect, uv.y) * u_scale;\n\n // Iterative trigonometric warp: each pass bends the sample point by the\n // previous pass, and the reciprocal distance to the warped axes\n // accumulates into the caustic web.\n float t = u_time * 0.35;\n vec2 i = p;\n float c = 0.0;\n for (int n = 0; n < 4; n++) {\n float phase = t * (1.0 - 3.2 / float(n + 2));\n i = p + vec2(\n cos(phase - i.x) + sin(phase + i.y),\n sin(phase - i.y) + cos(phase + i.x)\n );\n c += 1.0 / length(vec2(\n p.x / (sin(i.x + phase) * 90.0),\n p.y / (cos(i.y + phase) * 90.0)\n ));\n }\n c /= 4.0;\n c = 1.24 - pow(abs(c), 1.35);\n // |c| collapses to zero along thin branching veins — that zero-crossing\n // set IS the caustic web. Light the veins with an exponential falloff\n // (sharp core + a soft halo) and leave everything else near-black.\n float web = exp(-abs(c) * 0.5) + 0.22 * exp(-abs(c) * 0.12);\n web = web / (1.0 + 0.6 * web);\n\n // The light lands on the base: filaments read stronger low in the frame.\n float ground = mix(1.25, 0.55, uv.y);\n web *= ground * u_intensity;\n\n // Vignette keeps the corners quiet so type always wins.\n vec2 v = uv - 0.5;\n float vig = 1.0 - dot(v, v) * 1.1;\n web *= clamp(vig, 0.0, 1.0);\n\n vec3 filament = mix(u_light, u_accent, clamp(u_accentAmt, 0.0, 1.0));\n vec3 col = u_floor + filament * web;\n\n // A whisper of living grain, time-derived so it stays deterministic.\n col += (hash(gl_FragCoord.xy + floor(u_time * 9.0)) - 0.5) * 0.012;\n\n gl_FragColor = vec4(col, 1.0);\n}\n`;\n\nconst hexToRgb = (hex: string): [number, number, number] => {\n const h = hex.replace(\"#\", \"\");\n const v =\n h.length === 3\n ? h\n .split(\"\")\n .map((c) => c + c)\n .join(\"\")\n : h;\n const n = parseInt(v, 16);\n return [((n >> 16) & 255) / 255, ((n >> 8) & 255) / 255, (n & 255) / 255];\n};\n\ntype GlState = {\n gl: WebGLRenderingContext;\n uniforms: Record<string, WebGLUniformLocation | null>;\n};\n\nfunction ShaderCausticsBase({\n colors = [\"#0a0a0a\", \"#2e2e33\"],\n accent = \"#7F57FF\",\n accentAmount = 0,\n scale = 5.2,\n intensity = 1,\n speed = 1,\n className,\n}: ShaderCausticsProps) {\n const frame = useCurrentFrame();\n const { fps, width, height } = useVideoConfig();\n const canvasRef = useRef<HTMLCanvasElement>(null);\n const stateRef = useRef<GlState | null>(null);\n const [handle] = useState(() => delayRender(\"shader-caustics\"));\n const continuedRef = useRef(false);\n\n useEffect(() => {\n const canvas = canvasRef.current;\n if (!canvas || stateRef.current) return;\n const gl = canvas.getContext(\"webgl\", {\n antialias: false,\n preserveDrawingBuffer: true,\n });\n if (!gl) return;\n\n const compile = (type: number, src: string) => {\n const shader = gl.createShader(type);\n if (!shader) throw new Error(\"Failed to create WebGL shader\");\n gl.shaderSource(shader, src);\n gl.compileShader(shader);\n return shader;\n };\n const program = gl.createProgram();\n if (!program) return;\n gl.attachShader(program, compile(gl.VERTEX_SHADER, VERT));\n gl.attachShader(program, compile(gl.FRAGMENT_SHADER, FRAG));\n gl.linkProgram(program);\n // biome-ignore lint/correctness/useHookAtTopLevel: gl.useProgram is a WebGL method, not a React hook\n gl.useProgram(program);\n\n const buf = gl.createBuffer();\n gl.bindBuffer(gl.ARRAY_BUFFER, buf);\n gl.bufferData(\n gl.ARRAY_BUFFER,\n new Float32Array([-1, -1, 3, -1, -1, 3]),\n gl.STATIC_DRAW,\n );\n const loc = gl.getAttribLocation(program, \"a_pos\");\n gl.enableVertexAttribArray(loc);\n gl.vertexAttribPointer(loc, 2, gl.FLOAT, false, 0, 0);\n\n const uniforms: GlState[\"uniforms\"] = {};\n for (const name of [\n \"u_res\",\n \"u_time\",\n \"u_scale\",\n \"u_intensity\",\n \"u_floor\",\n \"u_light\",\n \"u_accent\",\n \"u_accentAmt\",\n ]) {\n uniforms[name] = gl.getUniformLocation(program, name);\n }\n stateRef.current = { gl, uniforms };\n }, []);\n\n useEffect(() => {\n const state = stateRef.current;\n const canvas = canvasRef.current;\n if (!state || !canvas) return;\n const { gl, uniforms } = state;\n\n gl.viewport(0, 0, canvas.width, canvas.height);\n gl.uniform2f(uniforms.u_res, canvas.width, canvas.height);\n gl.uniform1f(uniforms.u_time, (frame / fps) * speed);\n gl.uniform1f(uniforms.u_scale, scale);\n gl.uniform1f(uniforms.u_intensity, intensity);\n gl.uniform3fv(uniforms.u_floor, hexToRgb(colors[0]));\n gl.uniform3fv(uniforms.u_light, hexToRgb(colors[1]));\n gl.uniform3fv(uniforms.u_accent, hexToRgb(accent));\n gl.uniform1f(uniforms.u_accentAmt, accentAmount);\n gl.drawArrays(gl.TRIANGLES, 0, 3);\n\n if (!continuedRef.current) {\n continuedRef.current = true;\n requestAnimationFrame(() =>\n requestAnimationFrame(() => continueRender(handle)),\n );\n }\n }, [\n frame,\n fps,\n speed,\n scale,\n intensity,\n colors,\n accent,\n accentAmount,\n handle,\n ]);\n\n return (\n <div className={className} style={{ position: \"absolute\", inset: 0 }}>\n <canvas\n ref={canvasRef}\n width={width}\n height={height}\n style={{ width: \"100%\", height: \"100%\", display: \"block\" }}\n />\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n scale: {\n type: \"number\",\n min: 1,\n max: 12,\n step: 0.1,\n default: 5.2,\n description: \"Scale\",\n hiddenFromList: false,\n },\n intensity: {\n type: \"number\",\n min: 0,\n max: 2,\n step: 0.1,\n default: 1,\n description: \"Intensity\",\n hiddenFromList: false,\n },\n accent: {\n type: \"color\",\n default: \"#7F57FF\",\n description: \"Accent\",\n },\n accentAmount: {\n type: \"number\",\n min: 0,\n max: 1,\n step: 0.05,\n default: 0,\n description: \"Accent amount\",\n hiddenFromList: false,\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"speed\",\"scale\",\"intensity\",\"accent\",\"accentAmount\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n speed: 1,\n scale: 5.2,\n intensity: 1,\n accent: \"#7F57FF\",\n accentAmount: 0,\n};\n\ntype ShaderCausticsElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof ShaderCausticsBase>;\n\nconst ShaderCausticsInner = forwardRef<\n HTMLDivElement,\n ShaderCausticsElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<ShaderCaustics>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <ShaderCausticsBase\n {...(componentProps as unknown as ComponentProps<typeof ShaderCausticsBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const ShaderCaustics = Interactive.withSchema({\n Component: ShaderCausticsInner,\n componentName: \"<ShaderCaustics>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/shader-color-panels.json b/registry-artifacts/elements/shader-color-panels.jsonindex 5d1b3d43..8a59886d 100644--- a/registry-artifacts/elements/shader-color-panels.json+++ b/registry-artifacts/elements/shader-color-panels.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@paper-design/shaders-react",@@ -11,6 +12,7 @@"dimensions": null,"displayName": "Shader Color Panels","durationInFrames": 150,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "shader-color-panels","sourceCode": "import { ColorPanels, type ColorPanelsProps } from \"@paper-design/shaders-react\";\nimport { forwardRef, useCallback, useImperativeHandle, useRef, useState, type ComponentProps } from \"react\";\nimport { Interactive, Sequence, continueRender, delayRender, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\n\nconst NEUTRAL_COLORS = [\"#3a3a52\", \"#4a4a68\", \"#52527a\", \"#5a5a8a\"];\n\ninterface ShaderColorPanelsProps\n extends Omit<ColorPanelsProps, \"frame\" | \"ref\"> {}\n\nfunction ShaderColorPanelsBase({\n speed = 1,\n colors = NEUTRAL_COLORS,\n colorBack = \"#12121a\",\n density = 3,\n length = 1.1,\n className,\n ...rest\n}: ShaderColorPanelsProps) {\n const frame = useCurrentFrame();\n const { fps, width, height } = useVideoConfig();\n\n const [handle] = useState(() => delayRender(\"shader-color-panels\"));\n const gate = useCallback(\n (element: HTMLDivElement | null) => {\n if (!element) return;\n requestAnimationFrame(() =>\n requestAnimationFrame(() => continueRender(handle)),\n );\n },\n [handle],\n );\n\n return (\n <div\n ref={gate}\n className={className}\n style={{ position: \"absolute\", inset: 0 }}\n >\n <ColorPanels\n speed={0}\n frame={(frame / fps) * speed * 1000}\n colors={colors}\n colorBack={colorBack}\n density={density}\n length={length}\n fit=\"cover\"\n width={width}\n height={height}\n {...rest}\n />\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n density: {\n type: \"number\",\n min: 1,\n max: 8,\n step: 1,\n default: 3,\n description: \"Density\",\n hiddenFromList: false,\n },\n length: {\n type: \"number\",\n min: 0.5,\n max: 3,\n step: 0.1,\n default: 1.1,\n description: \"Length\",\n hiddenFromList: false,\n },\n colorBack: {\n type: \"color\",\n default: \"#12121a\",\n description: \"Background\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"speed\",\"density\",\"length\",\"colorBack\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n speed: 1,\n density: 3,\n length: 1.1,\n colorBack: \"#12121a\",\n};\n\ntype ShaderColorPanelsElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof ShaderColorPanelsBase>;\n\nconst ShaderColorPanelsInner = forwardRef<\n HTMLDivElement,\n ShaderColorPanelsElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<ShaderColorPanels>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <ShaderColorPanelsBase\n {...(componentProps as unknown as ComponentProps<typeof ShaderColorPanelsBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const ShaderColorPanels = Interactive.withSchema({\n Component: ShaderColorPanelsInner,\n componentName: \"<ShaderColorPanels>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/shader-dithering.json b/registry-artifacts/elements/shader-dithering.jsonindex 0de97f17..23d53b0a 100644--- a/registry-artifacts/elements/shader-dithering.json+++ b/registry-artifacts/elements/shader-dithering.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@paper-design/shaders-react",@@ -11,6 +12,7 @@"dimensions": null,"displayName": "Shader Dithering","durationInFrames": 150,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "shader-dithering","sourceCode": "import { Dithering, type DitheringProps } from \"@paper-design/shaders-react\";\nimport { forwardRef, useCallback, useImperativeHandle, useRef, useState, type ComponentProps } from \"react\";\nimport { Interactive, Sequence, continueRender, delayRender, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\n\ninterface ShaderDitheringProps\n extends Omit<DitheringProps, \"frame\" | \"ref\"> {}\n\nfunction ShaderDitheringBase({\n speed = 1,\n colorBack = \"#12121a\",\n colorFront = \"#6a6a85\",\n shape = \"wave\",\n type = \"4x4\",\n size = 2,\n className,\n ...rest\n}: ShaderDitheringProps) {\n const frame = useCurrentFrame();\n const { fps, width, height } = useVideoConfig();\n\n const [handle] = useState(() => delayRender(\"shader-dithering\"));\n const gate = useCallback(\n (element: HTMLDivElement | null) => {\n if (!element) return;\n requestAnimationFrame(() =>\n requestAnimationFrame(() => continueRender(handle)),\n );\n },\n [handle],\n );\n\n return (\n <div\n ref={gate}\n className={className}\n style={{ position: \"absolute\", inset: 0 }}\n >\n <Dithering\n speed={0}\n frame={(frame / fps) * speed * 1000}\n colorBack={colorBack}\n colorFront={colorFront}\n shape={shape}\n type={type}\n size={size}\n fit=\"cover\"\n width={width}\n height={height}\n {...rest}\n />\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n size: {\n type: \"number\",\n min: 1,\n max: 8,\n step: 1,\n default: 2,\n description: \"Dot Size\",\n hiddenFromList: false,\n },\n colorBack: {\n type: \"color\",\n default: \"#12121a\",\n description: \"Background\",\n },\n colorFront: {\n type: \"color\",\n default: \"#6a6a85\",\n description: \"Front\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"speed\",\"size\",\"colorBack\",\"colorFront\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n speed: 1,\n size: 2,\n colorBack: \"#12121a\",\n colorFront: \"#6a6a85\",\n};\n\ntype ShaderDitheringElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof ShaderDitheringBase>;\n\nconst ShaderDitheringInner = forwardRef<\n HTMLDivElement,\n ShaderDitheringElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<ShaderDithering>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <ShaderDitheringBase\n {...(componentProps as unknown as ComponentProps<typeof ShaderDitheringBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const ShaderDithering = Interactive.withSchema({\n Component: ShaderDitheringInner,\n componentName: \"<ShaderDithering>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/shader-dot-orbit.json b/registry-artifacts/elements/shader-dot-orbit.jsonindex eea044b5..e26090e1 100644--- a/registry-artifacts/elements/shader-dot-orbit.json+++ b/registry-artifacts/elements/shader-dot-orbit.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@paper-design/shaders-react",@@ -11,6 +12,7 @@"dimensions": null,"displayName": "Shader Dot Orbit","durationInFrames": 150,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "shader-dot-orbit","sourceCode": "import { DotOrbit, type DotOrbitProps } from \"@paper-design/shaders-react\";\nimport { forwardRef, useCallback, useImperativeHandle, useRef, useState, type ComponentProps } from \"react\";\nimport { Interactive, Sequence, continueRender, delayRender, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\n\nconst NEUTRAL_COLORS = [\"#4a4a68\", \"#52527a\", \"#3a3a5c\"];\n\ninterface ShaderDotOrbitProps\n extends Omit<DotOrbitProps, \"frame\" | \"ref\"> {}\n\nfunction ShaderDotOrbitBase({\n speed = 1,\n colorBack = \"#12121a\",\n colors = NEUTRAL_COLORS,\n size = 1,\n spreading = 1,\n className,\n ...rest\n}: ShaderDotOrbitProps) {\n const frame = useCurrentFrame();\n const { fps, width, height } = useVideoConfig();\n\n const [handle] = useState(() => delayRender(\"shader-dot-orbit\"));\n const gate = useCallback(\n (element: HTMLDivElement | null) => {\n if (!element) return;\n requestAnimationFrame(() =>\n requestAnimationFrame(() => continueRender(handle)),\n );\n },\n [handle],\n );\n\n return (\n <div\n ref={gate}\n className={className}\n style={{ position: \"absolute\", inset: 0 }}\n >\n <DotOrbit\n speed={0}\n frame={(frame / fps) * speed * 1000}\n colorBack={colorBack}\n colors={colors}\n size={size}\n spreading={spreading}\n fit=\"cover\"\n width={width}\n height={height}\n {...rest}\n />\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n size: {\n type: \"number\",\n min: 0.1,\n max: 3,\n step: 0.1,\n default: 1,\n description: \"Size\",\n hiddenFromList: false,\n },\n spreading: {\n type: \"number\",\n min: 0,\n max: 2,\n step: 0.1,\n default: 1,\n description: \"Spreading\",\n hiddenFromList: false,\n },\n colorBack: {\n type: \"color\",\n default: \"#12121a\",\n description: \"Background\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"speed\",\"size\",\"spreading\",\"colorBack\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n speed: 1,\n size: 1,\n spreading: 1,\n colorBack: \"#12121a\",\n};\n\ntype ShaderDotOrbitElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof ShaderDotOrbitBase>;\n\nconst ShaderDotOrbitInner = forwardRef<\n HTMLDivElement,\n ShaderDotOrbitElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<ShaderDotOrbit>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <ShaderDotOrbitBase\n {...(componentProps as unknown as ComponentProps<typeof ShaderDotOrbitBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const ShaderDotOrbit = Interactive.withSchema({\n Component: ShaderDotOrbitInner,\n componentName: \"<ShaderDotOrbit>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/shader-gem-smoke.json b/registry-artifacts/elements/shader-gem-smoke.jsonindex de5341f5..b6de6f70 100644--- a/registry-artifacts/elements/shader-gem-smoke.json+++ b/registry-artifacts/elements/shader-gem-smoke.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@paper-design/shaders-react",@@ -11,6 +12,7 @@"dimensions": null,"displayName": "Shader Gem Smoke","durationInFrames": 150,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "shader-gem-smoke","sourceCode": "import { GemSmoke, type GemSmokeProps } from \"@paper-design/shaders-react\";\nimport React, { forwardRef, useCallback, useImperativeHandle, useRef, useState, type ComponentProps } from \"react\";\nimport { Interactive, Sequence, continueRender, delayRender, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\n\nconst NEUTRAL_COLORS = [\"#3a3a5c\", \"#52527a\"];\n\ninterface ShaderGemSmokeProps\n extends Omit<GemSmokeProps, \"frame\" | \"ref\"> {}\n\n/**\n * Paper's Gem Smoke shader, driven deterministically by the current frame.\n *\n * Animated color fields placed over a logo shape — smoke lives behind (and\n * inside) the glassy silhouette. Feed it a brand mark via `image` (a URL,\n * e.g. staticFile('prisma/symbol-light.svg')); the shape is processed once\n * and cached, so every frame renders the same smoke at the same time.\n */\nfunction ShaderGemSmokeBase({\n speed = 1,\n colors = NEUTRAL_COLORS,\n colorBack = \"#0a0a10\",\n innerDistortion = 0.8,\n outerDistortion = 0.6,\n outerGlow = 0.55,\n innerGlow = 1,\n size = 0.8,\n className,\n ...rest\n}: ShaderGemSmokeProps) {\n const frame = useCurrentFrame();\n const { fps, width, height } = useVideoConfig();\n\n const [handle] = useState(() => delayRender(\"shader-gem-smoke\"));\n const gate = useCallback(\n (element: HTMLDivElement | null) => {\n if (!element) return;\n requestAnimationFrame(() =>\n requestAnimationFrame(() => continueRender(handle)),\n );\n },\n [handle],\n );\n\n return (\n <div\n ref={gate}\n className={className}\n style={{ position: \"absolute\", inset: 0 }}\n >\n <React.Suspense fallback={null}>\n <GemSmoke\n speed={0}\n frame={(frame / fps) * speed * 1000}\n colors={colors}\n colorBack={colorBack}\n innerDistortion={innerDistortion}\n outerDistortion={outerDistortion}\n outerGlow={outerGlow}\n innerGlow={innerGlow}\n size={size}\n fit=\"cover\"\n width={width}\n height={height}\n suspendWhenProcessingImage\n {...rest}\n />\n </React.Suspense>\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n colorBack: {\n type: \"color\",\n default: \"#0a0a10\",\n description: \"Background\",\n },\n innerDistortion: {\n type: \"number\",\n min: 0,\n max: 2,\n step: 0.05,\n default: 0.8,\n description: \"Inner distortion\",\n hiddenFromList: false,\n },\n outerDistortion: {\n type: \"number\",\n min: 0,\n max: 2,\n step: 0.05,\n default: 0.6,\n description: \"Outer distortion\",\n hiddenFromList: false,\n },\n size: {\n type: \"number\",\n min: 0.2,\n max: 1.5,\n step: 0.05,\n default: 0.8,\n description: \"Size\",\n hiddenFromList: false,\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"speed\",\"colorBack\",\"innerDistortion\",\"outerDistortion\",\"size\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n speed: 1,\n colorBack: \"#0a0a10\",\n innerDistortion: 0.8,\n outerDistortion: 0.6,\n size: 0.8,\n};\n\ntype ShaderGemSmokeElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof ShaderGemSmokeBase>;\n\nconst ShaderGemSmokeInner = forwardRef<\n HTMLDivElement,\n ShaderGemSmokeElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<ShaderGemSmoke>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <ShaderGemSmokeBase\n {...(componentProps as unknown as ComponentProps<typeof ShaderGemSmokeBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const ShaderGemSmoke = Interactive.withSchema({\n Component: ShaderGemSmokeInner,\n componentName: \"<ShaderGemSmoke>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/shader-god-rays.json b/registry-artifacts/elements/shader-god-rays.jsonindex 3d147cd7..ea443b82 100644--- a/registry-artifacts/elements/shader-god-rays.json+++ b/registry-artifacts/elements/shader-god-rays.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@paper-design/shaders-react",@@ -11,6 +12,7 @@"dimensions": null,"displayName": "Shader God Rays","durationInFrames": 150,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "shader-god-rays","sourceCode": "import { GodRays, type GodRaysProps } from \"@paper-design/shaders-react\";\nimport { forwardRef, useCallback, useImperativeHandle, useRef, useState, type ComponentProps } from \"react\";\nimport { Interactive, Sequence, continueRender, delayRender, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\n\nconst NEUTRAL_COLORS = [\"#5a5a7e\", \"#8a8a95\", \"#ffffff\", \"#3a3a5c\"];\n\ninterface ShaderGodRaysProps\n extends Omit<GodRaysProps, \"frame\" | \"ref\"> {}\n\nfunction ShaderGodRaysBase({\n speed = 1,\n colorBack = \"#12121a\",\n colorBloom = \"#3a3a5c\",\n colors = NEUTRAL_COLORS,\n intensity = 0.8,\n density = 0.3,\n bloom = 0.4,\n className,\n ...rest\n}: ShaderGodRaysProps) {\n const frame = useCurrentFrame();\n const { fps, width, height } = useVideoConfig();\n\n const [handle] = useState(() => delayRender(\"shader-god-rays\"));\n const gate = useCallback(\n (element: HTMLDivElement | null) => {\n if (!element) return;\n requestAnimationFrame(() =>\n requestAnimationFrame(() => continueRender(handle)),\n );\n },\n [handle],\n );\n\n return (\n <div\n ref={gate}\n className={className}\n style={{ position: \"absolute\", inset: 0 }}\n >\n <GodRays\n speed={0}\n frame={(frame / fps) * speed * 1000}\n colorBack={colorBack}\n colorBloom={colorBloom}\n colors={colors}\n intensity={intensity}\n density={density}\n bloom={bloom}\n fit=\"cover\"\n width={width}\n height={height}\n {...rest}\n />\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n intensity: {\n type: \"number\",\n min: 0,\n max: 2,\n step: 0.05,\n default: 0.8,\n description: \"Intensity\",\n hiddenFromList: false,\n },\n density: {\n type: \"number\",\n min: 0,\n max: 1,\n step: 0.05,\n default: 0.3,\n description: \"Density\",\n hiddenFromList: false,\n },\n bloom: {\n type: \"number\",\n min: 0,\n max: 1,\n step: 0.05,\n default: 0.4,\n description: \"Bloom\",\n hiddenFromList: false,\n },\n colorBack: {\n type: \"color\",\n default: \"#12121a\",\n description: \"Background\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"speed\",\"intensity\",\"density\",\"bloom\",\"colorBack\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n speed: 1,\n intensity: 0.8,\n density: 0.3,\n bloom: 0.4,\n colorBack: \"#12121a\",\n};\n\ntype ShaderGodRaysElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof ShaderGodRaysBase>;\n\nconst ShaderGodRaysInner = forwardRef<\n HTMLDivElement,\n ShaderGodRaysElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<ShaderGodRays>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <ShaderGodRaysBase\n {...(componentProps as unknown as ComponentProps<typeof ShaderGodRaysBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const ShaderGodRays = Interactive.withSchema({\n Component: ShaderGodRaysInner,\n componentName: \"<ShaderGodRays>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/shader-grain-gradient.json b/registry-artifacts/elements/shader-grain-gradient.jsonindex df8a7f8b..efed191d 100644--- a/registry-artifacts/elements/shader-grain-gradient.json+++ b/registry-artifacts/elements/shader-grain-gradient.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@paper-design/shaders-react",@@ -11,6 +12,7 @@"dimensions": null,"displayName": "Shader Grain Gradient","durationInFrames": 150,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "shader-grain-gradient","sourceCode": "import { GrainGradient, type GrainGradientProps } from \"@paper-design/shaders-react\";\nimport { forwardRef, useCallback, useImperativeHandle, useRef, useState, type ComponentProps } from \"react\";\nimport { Interactive, Sequence, continueRender, delayRender, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\n\nconst NEUTRAL_COLORS = [\"#3a3a52\", \"#4a4a68\", \"#5a5a7e\"];\n\ninterface ShaderGrainGradientProps\n extends Omit<GrainGradientProps, \"frame\" | \"ref\"> {}\n\nfunction ShaderGrainGradientBase({\n speed = 1,\n colors = NEUTRAL_COLORS,\n colorBack = \"#12121a\",\n softness = 0.6,\n intensity = 0.2,\n noise = 0.15,\n className,\n ...rest\n}: ShaderGrainGradientProps) {\n const frame = useCurrentFrame();\n const { fps, width, height } = useVideoConfig();\n\n const [handle] = useState(() => delayRender(\"shader-grain-gradient\"));\n const gate = useCallback(\n (element: HTMLDivElement | null) => {\n if (!element) return;\n requestAnimationFrame(() =>\n requestAnimationFrame(() => continueRender(handle)),\n );\n },\n [handle],\n );\n\n return (\n <div\n ref={gate}\n className={className}\n style={{ position: \"absolute\", inset: 0 }}\n >\n <GrainGradient\n speed={0}\n frame={(frame / fps) * speed * 1000}\n colors={colors}\n colorBack={colorBack}\n softness={softness}\n intensity={intensity}\n noise={noise}\n fit=\"cover\"\n width={width}\n height={height}\n {...rest}\n />\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n softness: {\n type: \"number\",\n min: 0,\n max: 1,\n step: 0.05,\n default: 0.6,\n description: \"Softness\",\n hiddenFromList: false,\n },\n intensity: {\n type: \"number\",\n min: 0,\n max: 1,\n step: 0.05,\n default: 0.2,\n description: \"Intensity\",\n hiddenFromList: false,\n },\n noise: {\n type: \"number\",\n min: 0,\n max: 1,\n step: 0.05,\n default: 0.15,\n description: \"Noise\",\n hiddenFromList: false,\n },\n colorBack: {\n type: \"color\",\n default: \"#12121a\",\n description: \"Background\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"speed\",\"softness\",\"intensity\",\"noise\",\"colorBack\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n speed: 1,\n softness: 0.6,\n intensity: 0.2,\n noise: 0.15,\n colorBack: \"#12121a\",\n};\n\ntype ShaderGrainGradientElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof ShaderGrainGradientBase>;\n\nconst ShaderGrainGradientInner = forwardRef<\n HTMLDivElement,\n ShaderGrainGradientElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<ShaderGrainGradient>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <ShaderGrainGradientBase\n {...(componentProps as unknown as ComponentProps<typeof ShaderGrainGradientBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const ShaderGrainGradient = Interactive.withSchema({\n Component: ShaderGrainGradientInner,\n componentName: \"<ShaderGrainGradient>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/shader-light-tunnel.json b/registry-artifacts/elements/shader-light-tunnel.jsonindex bbc31204..d23065ee 100644--- a/registry-artifacts/elements/shader-light-tunnel.json+++ b/registry-artifacts/elements/shader-light-tunnel.json@@ -2,10 +2,12 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [],"dimensions": null,"displayName": "Light Tunnel","durationInFrames": 90,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "shader-light-tunnel","sourceCode": "import { forwardRef, useImperativeHandle, useLayoutEffect, useRef, type ComponentProps } from \"react\";\nimport { Interactive, Sequence, useCurrentFrame, useDelayRender, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\n\ninterface ShaderLightTunnelProps {\n speed?: number;\n /** Spiral winding and circular motion of the material, from 0 to 2. */\n twist?: number;\n /** Repetitions of the hero ribbons around the tunnel, integer from 1 to 6. */\n spirals?: number;\n /** Exposure of the original hero material, from 0 to 3. */\n glow?: number;\n /** Camera perspective, from 0.5 to 2. */\n depth?: number;\n /** Starting shader time, in seconds. */\n timeOffset?: number;\n}\n\nconst VERTEX = `#version 300 es\nvoid main() {\n vec2 p = vec2(float((gl_VertexID << 1) & 2), float(gl_VertexID & 2));\n gl_Position = vec4(p * 2.0 - 1.0, 0.0, 1.0);\n}`;\n\n/* @remocn · OpenShaders — https://openshaders.com/@remocn\n * Original hero field and halftone source. The tunnel adapter only remaps\n * sampling coordinates, holds the material phase, and applies exposure.\n */\nconst HERO_FIELD = `#version 300 es\nprecision highp float;\n\nuniform vec2 iResolution;\nuniform float iTime;\nuniform float uLightMode;\nuniform vec3 uDarkBackground;\nuniform vec3 uLightBackground;\nout vec4 fragColor;\n\nconst float HUE = 0.663466752;\nconst float HUE_SPREAD = 0.314346701;\nconst float HUE_TRAVEL = 1.65112376;\nconst float CHROMA = 0.160295546;\nconst float LIGHTNESS = 0.537409723;\nconst float COLOUR_CYCLE = 0.124862425;\nconst float THETA = 2.12986207;\nconst float SHEAR = 0.968176901;\nconst float SHRINK = 0.955401778;\nconst float LAYERS = 72.0;\nconst float WARP_FREQ_X = 0.439311415;\nconst float WARP_FREQ_Y = 2.87923527;\nconst float WARP_AMP_X = 0.156202048;\nconst float WARP_AMP_Y = 0.0256033838;\nconst float ASPECT_X = 2.23183894;\nconst float ASPECT_Y = 0.15731883;\nconst float OFFSET_X = 0.375628948;\nconst float OFFSET_Y = -0.017801486;\nconst float TILT = 1.63293767;\nconst float ZOOM = 0.93135649;\nconst float CENTRE_X = -0.0956316143;\nconst float CENTRE_Y = -0.520057321;\nconst float GLOW_SIZE = 0.00201825937;\nconst float FALLOFF = 0.352821857;\nconst float VIGNETTE = 0.136085436;\nconst float FLOW_SPEED = 0.391012281;\nconst float FLOW_DIRECTION = 1.0;\nconst float BREATH_RATE = 0.382053256;\nconst float BREATH_AMOUNT = 0.0873704553;\nconst float PHASE = 56.3862724;\nconst float ECHO = 0.0;\nconst float ECHO_SHIFT = 0.178754866;\nconst float SOFTNESS = 0.00164903817;\nconst float LIGHT_SWING = 0.149726808;\n\nconst float TAU = 6.28318530718;\n\nvec3 oklchToLinear(float L, float C, float h) {\n float a = C * cos(h), b = C * sin(h);\n float l_ = L + 0.3963377774 * a + 0.2158037573 * b;\n float m_ = L - 0.1055613458 * a - 0.0638541728 * b;\n float s_ = L - 0.0894841775 * a - 1.2914855480 * b;\n vec3 lms = vec3(l_, m_, s_);\n lms = lms * lms * lms;\n return mat3(4.0767416621, -1.2684380046, -0.0041960863,\n -3.3077115913, 2.6097574011, -0.7034186147,\n 0.2309699292, -0.3413193965, 1.7076147010) * lms;\n}\n\nfloat blueNoise(vec2 p, float frame) {\n p += 5.588238 * mod(frame, 64.0);\n return fract(52.9829189 * fract(0.06711056 * p.x + 0.00583715 * p.y));\n}\n\nvoid main() {\n vec2 R = iResolution.xy;\n vec2 pos = (gl_FragCoord.xy - 0.5 * R) / R.y;\n float t = iTime * FLOW_SPEED * FLOW_DIRECTION + PHASE;\n float breath = (-sin(iTime * BREATH_RATE * 1.5) + sin(iTime * BREATH_RATE + 1.0)) * 0.25 + 0.5;\n\n vec2 u = (pos - vec2(CENTRE_X, CENTRE_Y)) * (ZOOM - breath * BREATH_AMOUNT);\n float ct = cos(TILT), st = sin(TILT);\n u = mat2(ct, st, -st, ct) * u;\n\n mat2 fold = mat2(cos(THETA), sin(THETA), -SHEAR, cos(THETA));\n\n float hue0 = HUE * TAU;\n float hue1 = hue0 + HUE_SPREAD * TAU;\n vec3 color = vec3(0.0);\n\n for (float i = 1.0; i <= 96.0; i += 1.0) {\n if (i > LAYERS) break;\n u.x += -sin(u.y * WARP_FREQ_X + t + i * 0.007) * WARP_AMP_X;\n u.y += -sin(u.x * WARP_FREQ_Y - t + i * 0.02) * WARP_AMP_Y;\n u = fold * u * SHRINK;\n\n vec2 q = u - vec2(OFFSET_X + breath * 0.1, OFFSET_Y);\n vec2 s = vec2(q.x * ASPECT_X, q.y * ASPECT_Y);\n float glow = GLOW_SIZE / (dot(s, s) + SOFTNESS);\n#ifndef SKIP_ECHO\n vec2 e = vec2((q.x - ECHO_SHIFT) * ASPECT_X, s.y);\n glow += ECHO * GLOW_SIZE / (dot(e, e) + SOFTNESS);\n#endif\n glow *= 0.25 + breath * 0.4;\n\n float r = length(u);\n float k = sin(i * COLOUR_CYCLE + t * 1.2 + r * HUE_TRAVEL) * 0.5 + 0.5;\n vec3 tint = clamp(oklchToLinear(LIGHTNESS + LIGHT_SWING * k, CHROMA * (0.75 + 0.35 * k), mix(hue0, hue1, k)), 0.0, 1.0);\n color += glow * tint * exp2(-r * FALLOFF);\n }\n\n vec3 x = max(color, 0.0);\n color = (x * (2.51 * x + 0.03)) / (x * (2.43 * x + 0.59) + 0.14);\n color = pow(clamp(color, 0.0, 1.0), vec3(0.85, 0.92, 0.98));\n\n float edge = smoothstep(0.5, 1.6, length(pos));\n color *= 1.0 - edge * VIGNETTE;\n\n vec3 dark = uDarkBackground + color * (1.0 - uDarkBackground);\n float strength = max(color.r, max(color.g, color.b));\n vec3 light = uLightBackground * (1.0 - strength) + color * 0.96;\n color = mix(dark, light, uLightMode);\n\n color += (blueNoise(gl_FragCoord.xy, floor(iTime * 24.0)) - 0.5) / 255.0;\n fragColor = vec4(clamp(color, 0.0, 1.0), 1.0);\n}\n`;\n\nconst HERO_HALFTONE = `#version 300 es\nprecision highp float;\n\nuniform sampler2D tScene;\nuniform vec2 iResolution;\nuniform float iTime;\nuniform float uLightMode;\nuniform vec3 uDarkBackground;\nuniform vec3 uLightBackground;\nuniform float uPixelRatio;\nout vec4 fragColor;\n\nconst float uStrength = 0.797335207;\nconst float uScale = 0.985214949;\nconst float uSeed = 0.435611069;\n\nconst float TAU = 6.28318530718;\nconst vec3 LUMA = vec3(0.2126, 0.7152, 0.0722);\n\nvec3 toInk(vec3 c) { return mix(c - uDarkBackground, uLightBackground - c, uLightMode); }\nvec3 fromInk(vec3 ink) { return mix(uDarkBackground + ink, uLightBackground - ink, uLightMode); }\nvec3 sceneInk(vec2 uv) { return toInk(texture(tScene, clamp(uv, 0.0, 1.0)).rgb); }\n\nfloat blueNoise(vec2 p, float frame) {\n p += 5.588238 * mod(frame, 64.0);\n return fract(52.9829189 * fract(0.06711056 * p.x + 0.00583715 * p.y));\n}\n\nvec3 halftone(vec2 frag) {\n float cell = max(3.0, uScale * 3.6 * uPixelRatio);\n float angle = 0.26 + uSeed * 0.3;\n mat2 turn = mat2(cos(angle), -sin(angle), sin(angle), cos(angle));\n vec2 rotated = turn * frag;\n vec2 grid = floor(rotated / cell);\n vec2 centre = (grid + 0.5) * cell;\n vec2 source = transpose(turn) * centre;\n vec3 soft = sceneInk(frag / iResolution);\n vec3 ink = sceneInk(source / iResolution);\n float level = clamp(dot(ink, LUMA), 0.0, 1.0);\n float radius = cell * sqrt(pow(level, 0.9) / 3.14159265);\n float dist = length(rotated - centre);\n float aa = 0.7 * uPixelRatio;\n float dot_ = 1.0 - smoothstep(radius - aa, radius + aa, dist);\n vec3 dots = ink * min(0.8 / max(level, 1e-3), 2.2) * dot_;\n float presence = smoothstep(0.03, 0.16, level) * (0.3 + 0.14 * uStrength);\n return mix(soft, dots, presence);\n}\n\nvoid main() {\n vec2 frag = gl_FragCoord.xy;\n vec3 ink = halftone(frag);\n vec3 color = fromInk(clamp(ink, 0.0, 1.0));\n color += (blueNoise(frag, floor(iTime * 24.0)) - 0.5) / 255.0;\n fragColor = vec4(clamp(color, 0.0, 1.0), 1.0);\n}\n`;\n\n// Project the unchanged hero field onto a seamless cylindrical surface.\n// Material flows inward along the tunnel; the camera never moves sideways.\n// Hold the hero's color/breath cycle at its initial phase. Only the tunnel\n// coordinates advance, so the ribbons do not enter the hero's darker phases.\nconst TUNNEL_FIELD = HERO_FIELD.replaceAll(\"iTime\", \"uMaterialTime\")\n .replace(\n \"uniform float uMaterialTime;\",\n `uniform float iTime;\n const float uMaterialTime = 0.0;\n uniform float uDepth;\n uniform float uTwist;\n uniform float uSpirals;\n uniform float uCameraZoom;\n vec2 tunnelPosition(vec2 frag) {\n vec2 view = (frag - iResolution * 0.5) / iResolution.y / uCameraZoom;\n float radius = max(length(view), 0.005);\n float z = 0.55 * uDepth / radius + iTime * 1.2;\n // Rotate the material explicitly so circular motion reads at every depth.\n // The camera and its centered projection remain fixed.\n // Integer angular repeats add ribbons without a seam or extra field passes.\n float angle = (atan(view.y, view.x)\n + (z * 0.3 + iTime * 1.5) * uTwist) * uSpirals;\n // Constant phase travels to smaller radii: r(t) = r(0) * exp(-2.4 * t).\n // Log spacing keeps the inward folds readable across the whole tunnel.\n float inward = log(radius / (0.55 * uDepth)) * 5.0 + iTime * 12.0;\n float ring = 0.68 + 0.1 * sin(inward);\n return vec2(cos(angle), sin(angle)) * ring\n + vec2(sin(inward) * 0.08, cos(inward) * 0.06 - 0.25);\n }`,\n )\n .replace(\n \"vec2 pos = (gl_FragCoord.xy - 0.5 * R) / R.y;\",\n \"vec2 pos = tunnelPosition(gl_FragCoord.xy);\",\n );\n\nconst TUNNEL_HALFTONE = HERO_HALFTONE.replace(\n \"uniform vec2 iResolution;\",\n \"uniform vec2 iResolution;\\nuniform float uGlow;\",\n).replace(\n \"fragColor = vec4(clamp(color, 0.0, 1.0), 1.0);\",\n `vec2 center = (gl_FragCoord.xy - iResolution * 0.5) / iResolution.y;\n // Defocus the actual field at the vanishing point instead of cutting a dark\n // circle into it. A Gaussian blend has no visible boundary around the center.\n float centerWeight = exp(-dot(center, center) / (2.0 * 0.065 * 0.065));\n if (centerWeight > 0.001) {\n vec3 blurred = vec3(0.0);\n float totalWeight = 0.0;\n vec2 spread = vec2(iResolution.y * 0.025) / iResolution;\n // Prefilter each tap so tight spiral turns do not reappear as ghost images.\n float blurLod = max(0.0, log2(iResolution.y * 0.025));\n vec2 uv = gl_FragCoord.xy / iResolution;\n for (int y = -2; y <= 2; y++) {\n for (int x = -2; x <= 2; x++) {\n vec2 offset = vec2(float(x), float(y));\n float weight = exp(-dot(offset, offset) * 0.5);\n blurred += textureLod(tScene, clamp(uv + offset * spread, 0.0, 1.0), blurLod).rgb * weight;\n totalWeight += weight;\n }\n }\n color = mix(color, blurred / totalWeight, centerWeight);\n }\n fragColor = vec4(clamp(color * uGlow, 0.0, 1.0), 1.0);`,\n);\n\nconst bounded = (value: number, fallback: number, min: number, max: number) =>\n Math.min(max, Math.max(min, Number.isFinite(value) ? value : fallback));\n\n/** Shared GPU renderer for the background and the spiral-pass transition. */\nfunction createTunnelRenderer(canvas: HTMLCanvasElement) {\n const gl = canvas.getContext(\"webgl2\", {\n alpha: false,\n antialias: false,\n depth: false,\n stencil: false,\n });\n if (!gl) throw new Error(\"Shader Light Tunnel requires WebGL2.\");\n const shaders: WebGLShader[] = [];\n const programs: WebGLProgram[] = [];\n let texture: WebGLTexture | null = null;\n let framebuffer: WebGLFramebuffer | null = null;\n const dispose = () => {\n for (const shader of shaders) gl.deleteShader(shader);\n for (const program of programs) gl.deleteProgram(program);\n gl.deleteTexture(texture);\n gl.deleteFramebuffer(framebuffer);\n };\n const compile = (fragment: string) => {\n const program = gl.createProgram();\n if (!program)\n throw new Error(\"Shader Light Tunnel: GPU allocation failed.\");\n programs.push(program);\n for (const [type, source] of [\n [gl.VERTEX_SHADER, VERTEX],\n [gl.FRAGMENT_SHADER, fragment],\n ] as const) {\n const shader = gl.createShader(type);\n if (!shader)\n throw new Error(\"Shader Light Tunnel: shader allocation failed.\");\n shaders.push(shader);\n gl.shaderSource(shader, source);\n gl.compileShader(shader);\n if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS))\n throw new Error(\n gl.getShaderInfoLog(shader) ?? \"Tunnel shader compilation failed.\",\n );\n gl.attachShader(program, shader);\n }\n gl.linkProgram(program);\n if (!gl.getProgramParameter(program, gl.LINK_STATUS))\n throw new Error(\n gl.getProgramInfoLog(program) ?? \"Tunnel shader link failed.\",\n );\n const locations = new Map<string, WebGLUniformLocation | null>();\n const uniform = (name: string) => {\n if (!locations.has(name))\n locations.set(name, gl.getUniformLocation(program, name));\n return locations.get(name) ?? null;\n };\n return {\n begin: (\n time: number,\n twist: number,\n glow: number,\n depth: number,\n spirals: number,\n cameraZoom = 1,\n ) => {\n gl.useProgram(program);\n gl.viewport(0, 0, canvas.width, canvas.height);\n gl.uniform2f(uniform(\"iResolution\"), canvas.width, canvas.height);\n gl.uniform1f(uniform(\"iTime\"), time);\n gl.uniform1f(uniform(\"uLightMode\"), 0);\n gl.uniform3f(uniform(\"uDarkBackground\"), 9 / 255, 9 / 255, 9 / 255);\n gl.uniform3f(uniform(\"uLightBackground\"), 1, 1, 1);\n gl.uniform1f(uniform(\"uPixelRatio\"), 1);\n gl.uniform1f(uniform(\"uTwist\"), bounded(twist, 0.7, 0, 2));\n gl.uniform1f(\n uniform(\"uSpirals\"),\n Math.round(bounded(spirals, 3, 1, 6)),\n );\n gl.uniform1f(uniform(\"uGlow\"), bounded(glow, 1, 0, 3));\n gl.uniform1f(uniform(\"uDepth\"), bounded(depth, 1, 0.5, 2));\n gl.uniform1f(uniform(\"uCameraZoom\"), bounded(cameraZoom, 1, 1, 32));\n gl.uniform1i(uniform(\"tScene\"), 0);\n },\n };\n };\n try {\n const field = compile(TUNNEL_FIELD);\n const halftone = compile(TUNNEL_HALFTONE);\n texture = gl.createTexture();\n framebuffer = gl.createFramebuffer();\n if (!texture || !framebuffer)\n throw new Error(\"Shader Light Tunnel: render target allocation failed.\");\n gl.activeTexture(gl.TEXTURE0);\n gl.bindTexture(gl.TEXTURE_2D, texture);\n gl.texParameteri(\n gl.TEXTURE_2D,\n gl.TEXTURE_MIN_FILTER,\n gl.LINEAR_MIPMAP_LINEAR,\n );\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);\n let targetWidth = 0,\n targetHeight = 0;\n return {\n dispose,\n draw: (\n time: number,\n twist: number,\n glow: number,\n depth: number,\n spirals: number,\n cameraZoom = 1,\n ) => {\n if (gl.isContextLost())\n throw new Error(\"Shader Light Tunnel: WebGL context lost.\");\n gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer);\n gl.bindTexture(gl.TEXTURE_2D, texture);\n if (targetWidth !== canvas.width || targetHeight !== canvas.height) {\n gl.texImage2D(\n gl.TEXTURE_2D,\n 0,\n gl.RGBA,\n canvas.width,\n canvas.height,\n 0,\n gl.RGBA,\n gl.UNSIGNED_BYTE,\n null,\n );\n gl.framebufferTexture2D(\n gl.FRAMEBUFFER,\n gl.COLOR_ATTACHMENT0,\n gl.TEXTURE_2D,\n texture,\n 0,\n );\n if (\n gl.checkFramebufferStatus(gl.FRAMEBUFFER) !==\n gl.FRAMEBUFFER_COMPLETE\n )\n throw new Error(\"Shader Light Tunnel: incomplete framebuffer.\");\n targetWidth = canvas.width;\n targetHeight = canvas.height;\n }\n field.begin(time, twist, glow, depth, spirals, cameraZoom);\n gl.drawArrays(gl.TRIANGLES, 0, 3);\n gl.bindFramebuffer(gl.FRAMEBUFFER, null);\n gl.generateMipmap(gl.TEXTURE_2D);\n halftone.begin(time, twist, glow, depth, spirals);\n gl.drawArrays(gl.TRIANGLES, 0, 3);\n },\n };\n } catch (error) {\n dispose();\n throw error;\n }\n}\n\nfunction ShaderLightTunnelBase({\n speed = 1,\n twist = 0.7,\n spirals = 3,\n glow = 1,\n depth = 1,\n timeOffset = 0,\n}: ShaderLightTunnelProps) {\n const frame = useCurrentFrame();\n const { width, height, fps } = useVideoConfig();\n const { delayRender, continueRender, cancelRender } = useDelayRender();\n const canvas = useRef<HTMLCanvasElement>(null);\n const renderer = useRef<ReturnType<typeof createTunnelRenderer> | null>(null);\n\n useLayoutEffect(() => {\n if (!canvas.current) return;\n const handle = delayRender(\"Initialize Shader Light Tunnel\");\n try {\n renderer.current = createTunnelRenderer(canvas.current);\n continueRender(handle);\n } catch (error) {\n cancelRender(error instanceof Error ? error : new Error(String(error)));\n }\n return () => {\n renderer.current?.dispose();\n renderer.current = null;\n };\n }, [delayRender, continueRender, cancelRender]);\n\n // biome-ignore lint/correctness/useExhaustiveDependencies: canvas resizing clears its buffer, including on paused frames.\n useLayoutEffect(() => {\n try {\n const time =\n bounded(timeOffset, 0, -10000, 10000) +\n (frame / fps) * bounded(speed, 1, 0, 5);\n renderer.current?.draw(time, twist, glow, depth, spirals);\n } catch (error) {\n cancelRender(error instanceof Error ? error : new Error(String(error)));\n }\n }, [\n frame,\n fps,\n width,\n height,\n speed,\n twist,\n spirals,\n glow,\n depth,\n timeOffset,\n cancelRender,\n ]);\n\n return (\n <canvas\n ref={canvas}\n width={width}\n height={height}\n aria-hidden=\"true\"\n tabIndex={-1}\n style={{\n position: \"absolute\",\n inset: 0,\n width: \"100%\",\n height: \"100%\",\n pointerEvents: \"none\",\n }}\n />\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n twist: {\n type: \"number\",\n default: 0.7,\n min: 0,\n max: 2,\n step: 0.05,\n description: \"Spiral motion\",\n hiddenFromList: false,\n },\n spirals: {\n type: \"number\",\n default: 3,\n min: 1,\n max: 6,\n step: 1,\n description: \"Spiral count\",\n hiddenFromList: false,\n },\n glow: {\n type: \"number\",\n default: 1,\n min: 0,\n max: 3,\n step: 0.05,\n description: \"Light exposure\",\n hiddenFromList: false,\n },\n depth: {\n type: \"number\",\n default: 1,\n min: 0.5,\n max: 2,\n step: 0.05,\n description: \"Perspective\",\n hiddenFromList: false,\n },\n timeOffset: {\n type: \"number\",\n default: 0,\n min: 0,\n max: 60,\n step: 0.1,\n description: \"Start time\",\n hiddenFromList: false,\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"speed\",\"twist\",\"spirals\",\"glow\",\"depth\",\"timeOffset\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n speed: 1,\n twist: 0.7,\n spirals: 3,\n glow: 1,\n depth: 1,\n timeOffset: 0,\n};\n\ntype ShaderLightTunnelElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof ShaderLightTunnelBase>;\n\nconst ShaderLightTunnelInner = forwardRef<\n HTMLDivElement,\n ShaderLightTunnelElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<ShaderLightTunnel>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <ShaderLightTunnelBase\n {...(componentProps as unknown as ComponentProps<typeof ShaderLightTunnelBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const ShaderLightTunnel = Interactive.withSchema({\n Component: ShaderLightTunnelInner,\n componentName: \"<ShaderLightTunnel>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/shader-liquid-metal.json b/registry-artifacts/elements/shader-liquid-metal.jsonindex 1e71de47..6ee3c649 100644--- a/registry-artifacts/elements/shader-liquid-metal.json+++ b/registry-artifacts/elements/shader-liquid-metal.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@paper-design/shaders-react",@@ -11,6 +12,7 @@"dimensions": null,"displayName": "Shader Liquid Metal","durationInFrames": 150,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "shader-liquid-metal","sourceCode": "import { LiquidMetal, type LiquidMetalProps } from \"@paper-design/shaders-react\";\nimport { forwardRef, useCallback, useImperativeHandle, useRef, useState, type ComponentProps } from \"react\";\nimport { Interactive, Sequence, continueRender, delayRender, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\n\ninterface ShaderLiquidMetalProps\n extends Omit<LiquidMetalProps, \"frame\" | \"ref\"> {}\n\nfunction ShaderLiquidMetalBase({\n speed = 1,\n colorBack = \"#2a2a30\",\n colorTint = \"#8a8a95\",\n distortion = 0.1,\n repetition = 1.5,\n contour = 0.4,\n softness = 0.05,\n shape = \"none\",\n className,\n ...rest\n}: ShaderLiquidMetalProps) {\n const frame = useCurrentFrame();\n const { fps, width, height } = useVideoConfig();\n\n const [handle] = useState(() => delayRender(\"shader-liquid-metal\"));\n const gate = useCallback(\n (element: HTMLDivElement | null) => {\n if (!element) return;\n requestAnimationFrame(() =>\n requestAnimationFrame(() => continueRender(handle)),\n );\n },\n [handle],\n );\n\n return (\n <div\n ref={gate}\n className={className}\n style={{ position: \"absolute\", inset: 0 }}\n >\n <LiquidMetal\n speed={0}\n frame={(frame / fps) * speed * 1000}\n colorBack={colorBack}\n colorTint={colorTint}\n distortion={distortion}\n repetition={repetition}\n contour={contour}\n softness={softness}\n shape={shape}\n fit=\"cover\"\n width={width}\n height={height}\n {...rest}\n />\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n distortion: {\n type: \"number\",\n min: 0,\n max: 0.5,\n step: 0.01,\n default: 0.1,\n description: \"Distortion\",\n hiddenFromList: false,\n },\n repetition: {\n type: \"number\",\n min: 1,\n max: 6,\n step: 0.5,\n default: 1.5,\n description: \"Repetition\",\n hiddenFromList: false,\n },\n contour: {\n type: \"number\",\n min: 0,\n max: 1,\n step: 0.05,\n default: 0.4,\n description: \"Contour\",\n hiddenFromList: false,\n },\n colorBack: {\n type: \"color\",\n default: \"#2a2a30\",\n description: \"Background\",\n },\n colorTint: {\n type: \"color\",\n default: \"#8a8a95\",\n description: \"Tint\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"speed\",\"distortion\",\"repetition\",\"contour\",\"colorBack\",\"colorTint\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n speed: 1,\n distortion: 0.1,\n repetition: 1.5,\n contour: 0.4,\n colorBack: \"#2a2a30\",\n colorTint: \"#8a8a95\",\n};\n\ntype ShaderLiquidMetalElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof ShaderLiquidMetalBase>;\n\nconst ShaderLiquidMetalInner = forwardRef<\n HTMLDivElement,\n ShaderLiquidMetalElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<ShaderLiquidMetal>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <ShaderLiquidMetalBase\n {...(componentProps as unknown as ComponentProps<typeof ShaderLiquidMetalBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const ShaderLiquidMetal = Interactive.withSchema({\n Component: ShaderLiquidMetalInner,\n componentName: \"<ShaderLiquidMetal>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/shader-mesh-gradient.json b/registry-artifacts/elements/shader-mesh-gradient.jsonindex 15d16d3d..be9a9704 100644--- a/registry-artifacts/elements/shader-mesh-gradient.json+++ b/registry-artifacts/elements/shader-mesh-gradient.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@paper-design/shaders-react",@@ -11,6 +12,7 @@"dimensions": null,"displayName": "Shader Mesh Gradient","durationInFrames": 150,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "shader-mesh-gradient","sourceCode": "import { MeshGradient, type MeshGradientProps } from \"@paper-design/shaders-react\";\nimport { forwardRef, useCallback, useImperativeHandle, useRef, useState, type ComponentProps } from \"react\";\nimport { Interactive, Sequence, continueRender, delayRender, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\n\nconst NEUTRAL_COLORS = [\"#12121a\", \"#232338\", \"#3a3a5c\", \"#52527a\"];\n\ninterface ShaderMeshGradientProps\n extends Omit<MeshGradientProps, \"frame\" | \"ref\"> {}\n\nfunction ShaderMeshGradientBase({\n speed = 1,\n colors = NEUTRAL_COLORS,\n distortion = 0.6,\n swirl = 0.1,\n className,\n ...rest\n}: ShaderMeshGradientProps) {\n const frame = useCurrentFrame();\n const { fps, width, height } = useVideoConfig();\n\n const [handle] = useState(() => delayRender(\"shader-mesh-gradient\"));\n const gate = useCallback(\n (element: HTMLDivElement | null) => {\n if (!element) return;\n requestAnimationFrame(() =>\n requestAnimationFrame(() => continueRender(handle)),\n );\n },\n [handle],\n );\n\n return (\n <div\n ref={gate}\n className={className}\n style={{ position: \"absolute\", inset: 0 }}\n >\n <MeshGradient\n speed={0}\n frame={(frame / fps) * speed * 1000}\n colors={colors}\n distortion={distortion}\n swirl={swirl}\n fit=\"cover\"\n width={width}\n height={height}\n {...rest}\n />\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n distortion: {\n type: \"number\",\n min: 0,\n max: 1.5,\n step: 0.05,\n default: 0.6,\n description: \"Distortion\",\n hiddenFromList: false,\n },\n swirl: {\n type: \"number\",\n min: 0,\n max: 1,\n step: 0.05,\n default: 0.1,\n description: \"Swirl\",\n hiddenFromList: false,\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"speed\",\"distortion\",\"swirl\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n speed: 1,\n distortion: 0.6,\n swirl: 0.1,\n};\n\ntype ShaderMeshGradientElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof ShaderMeshGradientBase>;\n\nconst ShaderMeshGradientInner = forwardRef<\n HTMLDivElement,\n ShaderMeshGradientElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<ShaderMeshGradient>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <ShaderMeshGradientBase\n {...(componentProps as unknown as ComponentProps<typeof ShaderMeshGradientBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const ShaderMeshGradient = Interactive.withSchema({\n Component: ShaderMeshGradientInner,\n componentName: \"<ShaderMeshGradient>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/shader-metaballs.json b/registry-artifacts/elements/shader-metaballs.jsonindex 31578618..0a8ff5f9 100644--- a/registry-artifacts/elements/shader-metaballs.json+++ b/registry-artifacts/elements/shader-metaballs.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@paper-design/shaders-react",@@ -11,6 +12,7 @@"dimensions": null,"displayName": "Shader Metaballs","durationInFrames": 150,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "shader-metaballs","sourceCode": "import { Metaballs, type MetaballsProps } from \"@paper-design/shaders-react\";\nimport { forwardRef, useCallback, useImperativeHandle, useRef, useState, type ComponentProps } from \"react\";\nimport { Interactive, Sequence, continueRender, delayRender, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\n\nconst NEUTRAL_COLORS = [\"#3a3a5c\", \"#52527a\", \"#8a8a95\"];\n\ninterface ShaderMetaballsProps\n extends Omit<MetaballsProps, \"frame\" | \"ref\"> {}\n\nfunction ShaderMetaballsBase({\n speed = 1,\n colorBack = \"#12121a\",\n colors = NEUTRAL_COLORS,\n count = 10,\n size = 0.83,\n className,\n ...rest\n}: ShaderMetaballsProps) {\n const frame = useCurrentFrame();\n const { fps, width, height } = useVideoConfig();\n\n const [handle] = useState(() => delayRender(\"shader-metaballs\"));\n const gate = useCallback(\n (element: HTMLDivElement | null) => {\n if (!element) return;\n requestAnimationFrame(() =>\n requestAnimationFrame(() => continueRender(handle)),\n );\n },\n [handle],\n );\n\n return (\n <div\n ref={gate}\n className={className}\n style={{ position: \"absolute\", inset: 0 }}\n >\n <Metaballs\n speed={0}\n frame={(frame / fps) * speed * 1000}\n colorBack={colorBack}\n colors={colors}\n count={count}\n size={size}\n fit=\"cover\"\n width={width}\n height={height}\n {...rest}\n />\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n count: {\n type: \"number\",\n min: 1,\n max: 20,\n step: 1,\n default: 10,\n description: \"Count\",\n hiddenFromList: false,\n },\n size: {\n type: \"number\",\n min: 0.2,\n max: 1.5,\n step: 0.05,\n default: 0.83,\n description: \"Size\",\n hiddenFromList: false,\n },\n colorBack: {\n type: \"color\",\n default: \"#12121a\",\n description: \"Background\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"speed\",\"count\",\"size\",\"colorBack\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n speed: 1,\n count: 10,\n size: 0.83,\n colorBack: \"#12121a\",\n};\n\ntype ShaderMetaballsElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof ShaderMetaballsBase>;\n\nconst ShaderMetaballsInner = forwardRef<\n HTMLDivElement,\n ShaderMetaballsElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<ShaderMetaballs>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <ShaderMetaballsBase\n {...(componentProps as unknown as ComponentProps<typeof ShaderMetaballsBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const ShaderMetaballs = Interactive.withSchema({\n Component: ShaderMetaballsInner,\n componentName: \"<ShaderMetaballs>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/shader-neuro-noise.json b/registry-artifacts/elements/shader-neuro-noise.jsonindex 1c1832d8..da4f77c9 100644--- a/registry-artifacts/elements/shader-neuro-noise.json+++ b/registry-artifacts/elements/shader-neuro-noise.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@paper-design/shaders-react",@@ -11,6 +12,7 @@"dimensions": null,"displayName": "Shader Neuro Noise","durationInFrames": 150,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "shader-neuro-noise","sourceCode": "import { NeuroNoise, type NeuroNoiseProps } from \"@paper-design/shaders-react\";\nimport { forwardRef, useCallback, useImperativeHandle, useRef, useState, type ComponentProps } from \"react\";\nimport { Interactive, Sequence, continueRender, delayRender, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\n\ninterface ShaderNeuroNoiseProps\n extends Omit<NeuroNoiseProps, \"frame\" | \"ref\"> {}\n\nfunction ShaderNeuroNoiseBase({\n speed = 1,\n colorFront = \"#8a8a95\",\n colorMid = \"#4a4a68\",\n colorBack = \"#12121a\",\n brightness = 0.05,\n contrast = 0.3,\n className,\n ...rest\n}: ShaderNeuroNoiseProps) {\n const frame = useCurrentFrame();\n const { fps, width, height } = useVideoConfig();\n\n const [handle] = useState(() => delayRender(\"shader-neuro-noise\"));\n const gate = useCallback(\n (element: HTMLDivElement | null) => {\n if (!element) return;\n requestAnimationFrame(() =>\n requestAnimationFrame(() => continueRender(handle)),\n );\n },\n [handle],\n );\n\n return (\n <div\n ref={gate}\n className={className}\n style={{ position: \"absolute\", inset: 0 }}\n >\n <NeuroNoise\n speed={0}\n frame={(frame / fps) * speed * 1000}\n colorFront={colorFront}\n colorMid={colorMid}\n colorBack={colorBack}\n brightness={brightness}\n contrast={contrast}\n fit=\"cover\"\n width={width}\n height={height}\n {...rest}\n />\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n brightness: {\n type: \"number\",\n min: 0,\n max: 1,\n step: 0.05,\n default: 0.05,\n description: \"Brightness\",\n hiddenFromList: false,\n },\n contrast: {\n type: \"number\",\n min: 0,\n max: 1,\n step: 0.05,\n default: 0.3,\n description: \"Contrast\",\n hiddenFromList: false,\n },\n colorBack: {\n type: \"color\",\n default: \"#12121a\",\n description: \"Background\",\n },\n colorMid: {\n type: \"color\",\n default: \"#4a4a68\",\n description: \"Mid\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"speed\",\"brightness\",\"contrast\",\"colorBack\",\"colorMid\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n speed: 1,\n brightness: 0.05,\n contrast: 0.3,\n colorBack: \"#12121a\",\n colorMid: \"#4a4a68\",\n};\n\ntype ShaderNeuroNoiseElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof ShaderNeuroNoiseBase>;\n\nconst ShaderNeuroNoiseInner = forwardRef<\n HTMLDivElement,\n ShaderNeuroNoiseElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<ShaderNeuroNoise>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <ShaderNeuroNoiseBase\n {...(componentProps as unknown as ComponentProps<typeof ShaderNeuroNoiseBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const ShaderNeuroNoise = Interactive.withSchema({\n Component: ShaderNeuroNoiseInner,\n componentName: \"<ShaderNeuroNoise>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/shader-perlin-noise.json b/registry-artifacts/elements/shader-perlin-noise.jsonindex 6ebd18d4..7a60ae3d 100644--- a/registry-artifacts/elements/shader-perlin-noise.json+++ b/registry-artifacts/elements/shader-perlin-noise.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@paper-design/shaders-react",@@ -11,6 +12,7 @@"dimensions": null,"displayName": "Shader Perlin Noise","durationInFrames": 150,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "shader-perlin-noise","sourceCode": "import { PerlinNoise, type PerlinNoiseProps } from \"@paper-design/shaders-react\";\nimport { forwardRef, useCallback, useImperativeHandle, useRef, useState, type ComponentProps } from \"react\";\nimport { Interactive, Sequence, continueRender, delayRender, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\n\ninterface ShaderPerlinNoiseProps\n extends Omit<PerlinNoiseProps, \"frame\" | \"ref\"> {}\n\nfunction ShaderPerlinNoiseBase({\n speed = 1,\n colorBack = \"#12121a\",\n colorFront = \"#6a6a85\",\n proportion = 0.35,\n softness = 0.1,\n className,\n ...rest\n}: ShaderPerlinNoiseProps) {\n const frame = useCurrentFrame();\n const { fps, width, height } = useVideoConfig();\n\n const [handle] = useState(() => delayRender(\"shader-perlin-noise\"));\n const gate = useCallback(\n (element: HTMLDivElement | null) => {\n if (!element) return;\n requestAnimationFrame(() =>\n requestAnimationFrame(() => continueRender(handle)),\n );\n },\n [handle],\n );\n\n return (\n <div\n ref={gate}\n className={className}\n style={{ position: \"absolute\", inset: 0 }}\n >\n <PerlinNoise\n speed={0}\n frame={(frame / fps) * speed * 1000}\n colorBack={colorBack}\n colorFront={colorFront}\n proportion={proportion}\n softness={softness}\n fit=\"cover\"\n width={width}\n height={height}\n {...rest}\n />\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n proportion: {\n type: \"number\",\n min: 0,\n max: 1,\n step: 0.05,\n default: 0.35,\n description: \"Proportion\",\n hiddenFromList: false,\n },\n softness: {\n type: \"number\",\n min: 0,\n max: 1,\n step: 0.05,\n default: 0.1,\n description: \"Softness\",\n hiddenFromList: false,\n },\n colorBack: {\n type: \"color\",\n default: \"#12121a\",\n description: \"Background\",\n },\n colorFront: {\n type: \"color\",\n default: \"#6a6a85\",\n description: \"Front\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"speed\",\"proportion\",\"softness\",\"colorBack\",\"colorFront\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n speed: 1,\n proportion: 0.35,\n softness: 0.1,\n colorBack: \"#12121a\",\n colorFront: \"#6a6a85\",\n};\n\ntype ShaderPerlinNoiseElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof ShaderPerlinNoiseBase>;\n\nconst ShaderPerlinNoiseInner = forwardRef<\n HTMLDivElement,\n ShaderPerlinNoiseElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<ShaderPerlinNoise>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <ShaderPerlinNoiseBase\n {...(componentProps as unknown as ComponentProps<typeof ShaderPerlinNoiseBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const ShaderPerlinNoise = Interactive.withSchema({\n Component: ShaderPerlinNoiseInner,\n componentName: \"<ShaderPerlinNoise>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/shader-pulsing-border.json b/registry-artifacts/elements/shader-pulsing-border.jsonindex e865409d..c206ec40 100644--- a/registry-artifacts/elements/shader-pulsing-border.json+++ b/registry-artifacts/elements/shader-pulsing-border.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@paper-design/shaders-react",@@ -11,6 +12,7 @@"dimensions": null,"displayName": "Shader Pulsing Border","durationInFrames": 150,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "shader-pulsing-border","sourceCode": "import { PulsingBorder, type PulsingBorderProps } from \"@paper-design/shaders-react\";\nimport { forwardRef, useCallback, useImperativeHandle, useRef, useState, type ComponentProps } from \"react\";\nimport { Interactive, Sequence, continueRender, delayRender, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\n\nconst NEUTRAL_COLORS = [\"#52527a\", \"#8a8a95\", \"#3a3a5c\"];\n\ninterface ShaderPulsingBorderProps\n extends Omit<PulsingBorderProps, \"frame\" | \"ref\"> {}\n\nfunction ShaderPulsingBorderBase({\n speed = 1,\n colorBack = \"#12121a\",\n colors = NEUTRAL_COLORS,\n roundness = 0.25,\n thickness = 0.1,\n intensity = 0.2,\n bloom = 0.25,\n className,\n ...rest\n}: ShaderPulsingBorderProps) {\n const frame = useCurrentFrame();\n const { fps, width, height } = useVideoConfig();\n\n const [handle] = useState(() => delayRender(\"shader-pulsing-border\"));\n const gate = useCallback(\n (element: HTMLDivElement | null) => {\n if (!element) return;\n requestAnimationFrame(() =>\n requestAnimationFrame(() => continueRender(handle)),\n );\n },\n [handle],\n );\n\n return (\n <div\n ref={gate}\n className={className}\n style={{ position: \"absolute\", inset: 0 }}\n >\n <PulsingBorder\n speed={0}\n frame={(frame / fps) * speed * 1000}\n colorBack={colorBack}\n colors={colors}\n roundness={roundness}\n thickness={thickness}\n intensity={intensity}\n bloom={bloom}\n fit=\"cover\"\n width={width}\n height={height}\n {...rest}\n />\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n thickness: {\n type: \"number\",\n min: 0.02,\n max: 0.5,\n step: 0.02,\n default: 0.1,\n description: \"Thickness\",\n hiddenFromList: false,\n },\n roundness: {\n type: \"number\",\n min: 0,\n max: 1,\n step: 0.05,\n default: 0.25,\n description: \"Roundness\",\n hiddenFromList: false,\n },\n intensity: {\n type: \"number\",\n min: 0,\n max: 1,\n step: 0.05,\n default: 0.2,\n description: \"Intensity\",\n hiddenFromList: false,\n },\n colorBack: {\n type: \"color\",\n default: \"#12121a\",\n description: \"Background\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"speed\",\"thickness\",\"roundness\",\"intensity\",\"colorBack\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n speed: 1,\n thickness: 0.1,\n roundness: 0.25,\n intensity: 0.2,\n colorBack: \"#12121a\",\n};\n\ntype ShaderPulsingBorderElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof ShaderPulsingBorderBase>;\n\nconst ShaderPulsingBorderInner = forwardRef<\n HTMLDivElement,\n ShaderPulsingBorderElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<ShaderPulsingBorder>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <ShaderPulsingBorderBase\n {...(componentProps as unknown as ComponentProps<typeof ShaderPulsingBorderBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const ShaderPulsingBorder = Interactive.withSchema({\n Component: ShaderPulsingBorderInner,\n componentName: \"<ShaderPulsingBorder>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/shader-simplex-noise.json b/registry-artifacts/elements/shader-simplex-noise.jsonindex 350ae367..d194ff0a 100644--- a/registry-artifacts/elements/shader-simplex-noise.json+++ b/registry-artifacts/elements/shader-simplex-noise.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@paper-design/shaders-react",@@ -11,6 +12,7 @@"dimensions": null,"displayName": "Shader Simplex Noise","durationInFrames": 150,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "shader-simplex-noise","sourceCode": "import { SimplexNoise, type SimplexNoiseProps } from \"@paper-design/shaders-react\";\nimport { forwardRef, useCallback, useImperativeHandle, useRef, useState, type ComponentProps } from \"react\";\nimport { Interactive, Sequence, continueRender, delayRender, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\n\nconst NEUTRAL_COLORS = [\"#12121a\", \"#3a3a5c\", \"#52527a\", \"#8a8a95\"];\n\ninterface ShaderSimplexNoiseProps\n extends Omit<SimplexNoiseProps, \"frame\" | \"ref\"> {}\n\nfunction ShaderSimplexNoiseBase({\n speed = 1,\n colors = NEUTRAL_COLORS,\n stepsPerColor = 2,\n softness = 0.1,\n className,\n ...rest\n}: ShaderSimplexNoiseProps) {\n const frame = useCurrentFrame();\n const { fps, width, height } = useVideoConfig();\n\n const [handle] = useState(() => delayRender(\"shader-simplex-noise\"));\n const gate = useCallback(\n (element: HTMLDivElement | null) => {\n if (!element) return;\n requestAnimationFrame(() =>\n requestAnimationFrame(() => continueRender(handle)),\n );\n },\n [handle],\n );\n\n return (\n <div\n ref={gate}\n className={className}\n style={{ position: \"absolute\", inset: 0 }}\n >\n <SimplexNoise\n speed={0}\n frame={(frame / fps) * speed * 1000}\n colors={colors}\n stepsPerColor={stepsPerColor}\n softness={softness}\n fit=\"cover\"\n width={width}\n height={height}\n {...rest}\n />\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n stepsPerColor: {\n type: \"number\",\n min: 1,\n max: 6,\n step: 1,\n default: 2,\n description: \"Steps\",\n hiddenFromList: false,\n },\n softness: {\n type: \"number\",\n min: 0,\n max: 1,\n step: 0.05,\n default: 0.1,\n description: \"Softness\",\n hiddenFromList: false,\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"speed\",\"stepsPerColor\",\"softness\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n speed: 1,\n stepsPerColor: 2,\n softness: 0.1,\n};\n\ntype ShaderSimplexNoiseElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof ShaderSimplexNoiseBase>;\n\nconst ShaderSimplexNoiseInner = forwardRef<\n HTMLDivElement,\n ShaderSimplexNoiseElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<ShaderSimplexNoise>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <ShaderSimplexNoiseBase\n {...(componentProps as unknown as ComponentProps<typeof ShaderSimplexNoiseBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const ShaderSimplexNoise = Interactive.withSchema({\n Component: ShaderSimplexNoiseInner,\n componentName: \"<ShaderSimplexNoise>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/shader-smoke-ring.json b/registry-artifacts/elements/shader-smoke-ring.jsonindex 3b08eccc..0288ca1d 100644--- a/registry-artifacts/elements/shader-smoke-ring.json+++ b/registry-artifacts/elements/shader-smoke-ring.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@paper-design/shaders-react",@@ -11,6 +12,7 @@"dimensions": null,"displayName": "Shader Smoke Ring","durationInFrames": 150,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "shader-smoke-ring","sourceCode": "import { SmokeRing, type SmokeRingProps } from \"@paper-design/shaders-react\";\nimport { forwardRef, useCallback, useImperativeHandle, useRef, useState, type ComponentProps } from \"react\";\nimport { Interactive, Sequence, continueRender, delayRender, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\n\nconst NEUTRAL_COLORS = [\"#c8c8d0\"];\n\ninterface ShaderSmokeRingProps\n extends Omit<SmokeRingProps, \"frame\" | \"ref\"> {}\n\nfunction ShaderSmokeRingBase({\n speed = 1,\n colorBack = \"#12121a\",\n colors = NEUTRAL_COLORS,\n radius = 0.25,\n thickness = 0.65,\n scale = 0.8,\n className,\n ...rest\n}: ShaderSmokeRingProps) {\n const frame = useCurrentFrame();\n const { fps, width, height } = useVideoConfig();\n\n const [handle] = useState(() => delayRender(\"shader-smoke-ring\"));\n const gate = useCallback(\n (element: HTMLDivElement | null) => {\n if (!element) return;\n requestAnimationFrame(() =>\n requestAnimationFrame(() => continueRender(handle)),\n );\n },\n [handle],\n );\n\n return (\n <div\n ref={gate}\n className={className}\n style={{ position: \"absolute\", inset: 0 }}\n >\n <SmokeRing\n speed={0}\n frame={(frame / fps) * speed * 1000}\n colorBack={colorBack}\n colors={colors}\n radius={radius}\n thickness={thickness}\n scale={scale}\n fit=\"cover\"\n width={width}\n height={height}\n {...rest}\n />\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n radius: {\n type: \"number\",\n min: 0,\n max: 1,\n step: 0.05,\n default: 0.25,\n description: \"Radius\",\n hiddenFromList: false,\n },\n thickness: {\n type: \"number\",\n min: 0.1,\n max: 1.5,\n step: 0.05,\n default: 0.65,\n description: \"Thickness\",\n hiddenFromList: false,\n },\n scale: {\n type: \"number\",\n min: 0.3,\n max: 2,\n step: 0.05,\n default: 0.8,\n description: \"Scale\",\n hiddenFromList: false,\n },\n colorBack: {\n type: \"color\",\n default: \"#12121a\",\n description: \"Background\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"speed\",\"radius\",\"thickness\",\"scale\",\"colorBack\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n speed: 1,\n radius: 0.25,\n thickness: 0.65,\n scale: 0.8,\n colorBack: \"#12121a\",\n};\n\ntype ShaderSmokeRingElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof ShaderSmokeRingBase>;\n\nconst ShaderSmokeRingInner = forwardRef<\n HTMLDivElement,\n ShaderSmokeRingElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<ShaderSmokeRing>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <ShaderSmokeRingBase\n {...(componentProps as unknown as ComponentProps<typeof ShaderSmokeRingBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const ShaderSmokeRing = Interactive.withSchema({\n Component: ShaderSmokeRingInner,\n componentName: \"<ShaderSmokeRing>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/shader-spiral.json b/registry-artifacts/elements/shader-spiral.jsonindex 631845b3..a7451833 100644--- a/registry-artifacts/elements/shader-spiral.json+++ b/registry-artifacts/elements/shader-spiral.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@paper-design/shaders-react",@@ -11,6 +12,7 @@"dimensions": null,"displayName": "Shader Spiral","durationInFrames": 150,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "shader-spiral","sourceCode": "import { Spiral, type SpiralProps } from \"@paper-design/shaders-react\";\nimport { forwardRef, useCallback, useImperativeHandle, useRef, useState, type ComponentProps } from \"react\";\nimport { Interactive, Sequence, continueRender, delayRender, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\n\ninterface ShaderSpiralProps extends Omit<SpiralProps, \"frame\" | \"ref\"> {}\n\nfunction ShaderSpiralBase({\n speed = 1,\n colorBack = \"#12121a\",\n colorFront = \"#52527a\",\n density = 1,\n strokeWidth = 0.5,\n softness = 0.2,\n className,\n ...rest\n}: ShaderSpiralProps) {\n const frame = useCurrentFrame();\n const { fps, width, height } = useVideoConfig();\n\n const [handle] = useState(() => delayRender(\"shader-spiral\"));\n const gate = useCallback(\n (element: HTMLDivElement | null) => {\n if (!element) return;\n requestAnimationFrame(() =>\n requestAnimationFrame(() => continueRender(handle)),\n );\n },\n [handle],\n );\n\n return (\n <div\n ref={gate}\n className={className}\n style={{ position: \"absolute\", inset: 0 }}\n >\n <Spiral\n speed={0}\n frame={(frame / fps) * speed * 1000}\n colorBack={colorBack}\n colorFront={colorFront}\n density={density}\n strokeWidth={strokeWidth}\n softness={softness}\n fit=\"cover\"\n width={width}\n height={height}\n {...rest}\n />\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n density: {\n type: \"number\",\n min: 0.2,\n max: 4,\n step: 0.1,\n default: 1,\n description: \"Density\",\n hiddenFromList: false,\n },\n strokeWidth: {\n type: \"number\",\n min: 0.05,\n max: 1,\n step: 0.05,\n default: 0.5,\n description: \"Stroke\",\n hiddenFromList: false,\n },\n softness: {\n type: \"number\",\n min: 0,\n max: 1,\n step: 0.05,\n default: 0.2,\n description: \"Softness\",\n hiddenFromList: false,\n },\n colorBack: {\n type: \"color\",\n default: \"#12121a\",\n description: \"Background\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"speed\",\"density\",\"strokeWidth\",\"softness\",\"colorBack\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n speed: 1,\n density: 1,\n strokeWidth: 0.5,\n softness: 0.2,\n colorBack: \"#12121a\",\n};\n\ntype ShaderSpiralElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof ShaderSpiralBase>;\n\nconst ShaderSpiralInner = forwardRef<\n HTMLDivElement,\n ShaderSpiralElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<ShaderSpiral>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <ShaderSpiralBase\n {...(componentProps as unknown as ComponentProps<typeof ShaderSpiralBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const ShaderSpiral = Interactive.withSchema({\n Component: ShaderSpiralInner,\n componentName: \"<ShaderSpiral>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/shader-strata.json b/registry-artifacts/elements/shader-strata.jsonindex e55e2b03..300d8d8a 100644--- a/registry-artifacts/elements/shader-strata.json+++ b/registry-artifacts/elements/shader-strata.json@@ -2,10 +2,12 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [],"dimensions": null,"displayName": "Shader Strata","durationInFrames": 150,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "shader-strata","sourceCode": "import { forwardRef, useEffect, useImperativeHandle, useRef, useState, type ComponentProps } from \"react\";\nimport { Interactive, Sequence, continueRender, delayRender, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\n\n// A field of fine horizontal sediment layers — strata. Each layer's edge is\n// displaced by fbm noise and drifts at its own depth speed, so the stack reads\n// as a living foundation rather than a gradient. Written for the remocn\n// registry as a custom WebGL shader (not a paper-design wrapper): frame-driven,\n// deterministic, no wall-clock time anywhere.\n//\n// `accent` / `accentAmount` tint the DEEP strata (the bottom of the frame) —\n// the layers everything else stands on — which is what makes it a natural\n// carrier for \"base\" stories: the undertone can arrive mid-video by animating\n// `accentAmount` with the master timeline.\n\ninterface ShaderStrataProps {\n /** Palette from the deepest layer to the surface layer. Exactly 4 stops. */\n colors?: [string, string, string, string];\n /** Tint mixed into the deep strata. */\n accent?: string;\n /** 0..1 — how much of the accent the deep strata take. */\n accentAmount?: number;\n /** Number of strata bands across the frame height. */\n layers?: number;\n /** Edge waviness of each layer, in fractions of the frame height. */\n amplitude?: number;\n /** Global time multiplier. */\n speed?: number;\n className?: string;\n}\n\nconst VERT = `\nattribute vec2 a_pos;\nvoid main() {\n gl_Position = vec4(a_pos, 0.0, 1.0);\n}\n`;\n\nconst FRAG = `\nprecision highp float;\n\nuniform vec2 u_res;\nuniform float u_time;\nuniform float u_layers;\nuniform float u_amp;\nuniform vec3 u_c0;\nuniform vec3 u_c1;\nuniform vec3 u_c2;\nuniform vec3 u_c3;\nuniform vec3 u_accent;\nuniform float u_accentAmt;\n\nfloat hash(vec2 p) {\n return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453123);\n}\n\nfloat noise(vec2 p) {\n vec2 i = floor(p);\n vec2 f = fract(p);\n vec2 u = f * f * (3.0 - 2.0 * f);\n return mix(\n mix(hash(i), hash(i + vec2(1.0, 0.0)), u.x),\n mix(hash(i + vec2(0.0, 1.0)), hash(i + vec2(1.0, 1.0)), u.x),\n u.y\n );\n}\n\nfloat fbm(vec2 p) {\n float v = 0.0;\n float a = 0.5;\n for (int i = 0; i < 4; i++) {\n v += a * noise(p);\n p *= 2.03;\n a *= 0.5;\n }\n return v;\n}\n\nvoid main() {\n vec2 uv = gl_FragCoord.xy / u_res;\n float aspect = u_res.x / u_res.y;\n\n // Deeper layers drift faster — parallax without per-band recursion.\n float drift = u_time * (0.012 + 0.05 * (1.0 - uv.y));\n float w = fbm(vec2(uv.x * 2.6 * aspect + drift, uv.y * 2.2 - u_time * 0.01));\n\n float yd = uv.y + (w - 0.5) * u_amp;\n float band = yd * u_layers;\n float idx = floor(band);\n float f = fract(band);\n\n // Per-band value jitter + a soft sediment shadow at each band's lower edge.\n float j = hash(vec2(idx, 7.0));\n float edge = smoothstep(0.0, 0.4, f) * (1.0 - 0.3 * smoothstep(0.8, 1.0, f));\n\n float depth = clamp(idx / u_layers, 0.0, 1.0);\n vec3 col = mix(u_c0, u_c1, smoothstep(0.0, 0.4, depth));\n col = mix(col, u_c2, smoothstep(0.35, 0.75, depth));\n col = mix(col, u_c3, smoothstep(0.7, 1.0, depth));\n col *= 0.84 + 0.16 * j;\n col *= 0.92 + 0.08 * edge;\n\n // The accent rises from the deep strata and thins toward the surface.\n float mask = (1.0 - uv.y);\n mask *= mask;\n col = mix(col, u_accent, clamp(u_accentAmt, 0.0, 1.0) * mask * 0.38);\n\n // A whisper of living grain, time-derived so it stays deterministic.\n col += (hash(gl_FragCoord.xy + floor(u_time * 9.0)) - 0.5) * 0.012;\n\n gl_FragColor = vec4(col, 1.0);\n}\n`;\n\nconst hexToRgb = (hex: string): [number, number, number] => {\n const h = hex.replace(\"#\", \"\");\n const v =\n h.length === 3\n ? h\n .split(\"\")\n .map((c) => c + c)\n .join(\"\")\n : h;\n const n = parseInt(v, 16);\n return [((n >> 16) & 255) / 255, ((n >> 8) & 255) / 255, (n & 255) / 255];\n};\n\ntype GlState = {\n gl: WebGLRenderingContext;\n uniforms: Record<string, WebGLUniformLocation | null>;\n};\n\nfunction ShaderStrataBase({\n colors = [\"#050507\", \"#0a0a0d\", \"#111014\", \"#17161b\"],\n accent = \"#6733FF\",\n accentAmount = 0,\n layers = 14,\n amplitude = 0.16,\n speed = 1,\n className,\n}: ShaderStrataProps) {\n const frame = useCurrentFrame();\n const { fps, width, height } = useVideoConfig();\n const canvasRef = useRef<HTMLCanvasElement>(null);\n const stateRef = useRef<GlState | null>(null);\n const [handle] = useState(() => delayRender(\"shader-strata\"));\n const continuedRef = useRef(false);\n\n useEffect(() => {\n const canvas = canvasRef.current;\n if (!canvas || stateRef.current) return;\n const gl = canvas.getContext(\"webgl\", {\n antialias: false,\n preserveDrawingBuffer: true,\n });\n if (!gl) return;\n\n const compile = (type: number, src: string) => {\n const shader = gl.createShader(type);\n if (!shader) throw new Error(\"Failed to create WebGL shader\");\n gl.shaderSource(shader, src);\n gl.compileShader(shader);\n return shader;\n };\n const program = gl.createProgram();\n if (!program) return;\n gl.attachShader(program, compile(gl.VERTEX_SHADER, VERT));\n gl.attachShader(program, compile(gl.FRAGMENT_SHADER, FRAG));\n gl.linkProgram(program);\n // biome-ignore lint/correctness/useHookAtTopLevel: gl.useProgram is a WebGL method, not a React hook\n gl.useProgram(program);\n\n const buf = gl.createBuffer();\n gl.bindBuffer(gl.ARRAY_BUFFER, buf);\n gl.bufferData(\n gl.ARRAY_BUFFER,\n new Float32Array([-1, -1, 3, -1, -1, 3]),\n gl.STATIC_DRAW,\n );\n const loc = gl.getAttribLocation(program, \"a_pos\");\n gl.enableVertexAttribArray(loc);\n gl.vertexAttribPointer(loc, 2, gl.FLOAT, false, 0, 0);\n\n const uniforms: GlState[\"uniforms\"] = {};\n for (const name of [\n \"u_res\",\n \"u_time\",\n \"u_layers\",\n \"u_amp\",\n \"u_c0\",\n \"u_c1\",\n \"u_c2\",\n \"u_c3\",\n \"u_accent\",\n \"u_accentAmt\",\n ]) {\n uniforms[name] = gl.getUniformLocation(program, name);\n }\n stateRef.current = { gl, uniforms };\n }, []);\n\n useEffect(() => {\n const state = stateRef.current;\n const canvas = canvasRef.current;\n if (!state || !canvas) return;\n const { gl, uniforms } = state;\n\n gl.viewport(0, 0, canvas.width, canvas.height);\n gl.uniform2f(uniforms.u_res, canvas.width, canvas.height);\n gl.uniform1f(uniforms.u_time, (frame / fps) * speed);\n gl.uniform1f(uniforms.u_layers, layers);\n gl.uniform1f(uniforms.u_amp, amplitude);\n gl.uniform3fv(uniforms.u_c0, hexToRgb(colors[0]));\n gl.uniform3fv(uniforms.u_c1, hexToRgb(colors[1]));\n gl.uniform3fv(uniforms.u_c2, hexToRgb(colors[2]));\n gl.uniform3fv(uniforms.u_c3, hexToRgb(colors[3]));\n gl.uniform3fv(uniforms.u_accent, hexToRgb(accent));\n gl.uniform1f(uniforms.u_accentAmt, accentAmount);\n gl.drawArrays(gl.TRIANGLES, 0, 3);\n\n if (!continuedRef.current) {\n continuedRef.current = true;\n requestAnimationFrame(() =>\n requestAnimationFrame(() => continueRender(handle)),\n );\n }\n }, [\n frame,\n fps,\n speed,\n layers,\n amplitude,\n colors,\n accent,\n accentAmount,\n handle,\n ]);\n\n return (\n <div className={className} style={{ position: \"absolute\", inset: 0 }}>\n <canvas\n ref={canvasRef}\n width={width}\n height={height}\n style={{ width: \"100%\", height: \"100%\", display: \"block\" }}\n />\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n layers: {\n type: \"number\",\n min: 4,\n max: 30,\n step: 1,\n default: 14,\n description: \"Layers\",\n hiddenFromList: false,\n },\n amplitude: {\n type: \"number\",\n min: 0,\n max: 0.5,\n step: 0.01,\n default: 0.16,\n description: \"Amplitude\",\n hiddenFromList: false,\n },\n accent: {\n type: \"color\",\n default: \"#6733FF\",\n description: \"Accent\",\n },\n accentAmount: {\n type: \"number\",\n min: 0,\n max: 1,\n step: 0.05,\n default: 0,\n description: \"Accent amount\",\n hiddenFromList: false,\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"speed\",\"layers\",\"amplitude\",\"accent\",\"accentAmount\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n speed: 1,\n layers: 14,\n amplitude: 0.16,\n accent: \"#6733FF\",\n accentAmount: 0,\n};\n\ntype ShaderStrataElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof ShaderStrataBase>;\n\nconst ShaderStrataInner = forwardRef<\n HTMLDivElement,\n ShaderStrataElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<ShaderStrata>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <ShaderStrataBase\n {...(componentProps as unknown as ComponentProps<typeof ShaderStrataBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const ShaderStrata = Interactive.withSchema({\n Component: ShaderStrataInner,\n componentName: \"<ShaderStrata>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/shader-swirl.json b/registry-artifacts/elements/shader-swirl.jsonindex c0d6e3af..ad94764a 100644--- a/registry-artifacts/elements/shader-swirl.json+++ b/registry-artifacts/elements/shader-swirl.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@paper-design/shaders-react",@@ -11,6 +12,7 @@"dimensions": null,"displayName": "Shader Swirl","durationInFrames": 150,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "shader-swirl","sourceCode": "import { Swirl, type SwirlProps } from \"@paper-design/shaders-react\";\nimport { forwardRef, useCallback, useImperativeHandle, useRef, useState, type ComponentProps } from \"react\";\nimport { Interactive, Sequence, continueRender, delayRender, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\n\nconst NEUTRAL_COLORS = [\"#52527a\", \"#3a3a5c\", \"#232338\"];\n\ninterface ShaderSwirlProps extends Omit<SwirlProps, \"frame\" | \"ref\"> {}\n\nfunction ShaderSwirlBase({\n speed = 1,\n colors = NEUTRAL_COLORS,\n colorBack = \"#12121a\",\n bandCount = 4,\n twist = 0.1,\n softness = 0.2,\n className,\n ...rest\n}: ShaderSwirlProps) {\n const frame = useCurrentFrame();\n const { fps, width, height } = useVideoConfig();\n\n const [handle] = useState(() => delayRender(\"shader-swirl\"));\n const gate = useCallback(\n (element: HTMLDivElement | null) => {\n if (!element) return;\n requestAnimationFrame(() =>\n requestAnimationFrame(() => continueRender(handle)),\n );\n },\n [handle],\n );\n\n return (\n <div\n ref={gate}\n className={className}\n style={{ position: \"absolute\", inset: 0 }}\n >\n <Swirl\n speed={0}\n frame={(frame / fps) * speed * 1000}\n colors={colors}\n colorBack={colorBack}\n bandCount={bandCount}\n twist={twist}\n softness={softness}\n fit=\"cover\"\n width={width}\n height={height}\n {...rest}\n />\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n bandCount: {\n type: \"number\",\n min: 1,\n max: 12,\n step: 1,\n default: 4,\n description: \"Bands\",\n hiddenFromList: false,\n },\n twist: {\n type: \"number\",\n min: 0,\n max: 1,\n step: 0.05,\n default: 0.1,\n description: \"Twist\",\n hiddenFromList: false,\n },\n softness: {\n type: \"number\",\n min: 0,\n max: 1,\n step: 0.05,\n default: 0.2,\n description: \"Softness\",\n hiddenFromList: false,\n },\n colorBack: {\n type: \"color\",\n default: \"#12121a\",\n description: \"Background\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"speed\",\"bandCount\",\"twist\",\"softness\",\"colorBack\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n speed: 1,\n bandCount: 4,\n twist: 0.1,\n softness: 0.2,\n colorBack: \"#12121a\",\n};\n\ntype ShaderSwirlElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof ShaderSwirlBase>;\n\nconst ShaderSwirlInner = forwardRef<\n HTMLDivElement,\n ShaderSwirlElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<ShaderSwirl>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <ShaderSwirlBase\n {...(componentProps as unknown as ComponentProps<typeof ShaderSwirlBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const ShaderSwirl = Interactive.withSchema({\n Component: ShaderSwirlInner,\n componentName: \"<ShaderSwirl>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/shader-text-reveal.json b/registry-artifacts/elements/shader-text-reveal.jsonindex 17e8eb65..c16df767 100644--- a/registry-artifacts/elements/shader-text-reveal.json+++ b/registry-artifacts/elements/shader-text-reveal.json@@ -2,10 +2,12 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [],"dimensions": null,"displayName": "Shader Text Reveal","durationInFrames": 48,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "shader-text-reveal","sourceCode": "import { forwardRef, useImperativeHandle, useLayoutEffect, useRef, type ComponentProps } from \"react\";\nimport { Interactive, Sequence, useCurrentFrame, useDelayRender, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\n\ntype ShaderTextRevealProps = {\n /** Words appear one at a time. Separate phrases with newlines to keep them together. */\n text?: string;\n fontSize?: number;\n fontFamily?: string;\n fontWeight?: number;\n /** Frames per word, including its entrance and exit. The final word stays visible. */\n wordDuration?: number;\n /** Strength of the original hero shader inside the letters, from 0 to 1. */\n intensity?: number;\n};\n\nconst clamp = (n: number, min = 0, max = 1) => Math.min(max, Math.max(min, n));\n\nfunction getShaderTextState(\n frame: number,\n wordCount: number,\n wordDuration: number,\n) {\n const duration = Math.max(12, Math.round(wordDuration));\n const count = Math.max(1, wordCount);\n const f = Math.max(0, frame);\n const index = Math.min(count - 1, Math.floor(f / duration));\n const local = f - index * duration;\n const enter = clamp((local / duration + 0.16) / 0.76);\n const exit =\n index === count - 1 ? 0 : clamp((local / duration - 0.65) / 0.35);\n return {\n index,\n enter,\n exit: exit * exit * (3 - 2 * exit),\n scale: 1 + 0.12 * (1 - enter) ** 3,\n };\n}\n\nconst VERTEX = `#version 300 es\nvoid main() {\n vec2 p = vec2(float((gl_VertexID << 1) & 2), float(gl_VertexID & 2));\n gl_Position = vec4(p * 2.0 - 1.0, 0.0, 1.0);\n}`;\n\n/* @remocn · OpenShaders — https://openshaders.com/@remocn\n * Original hero field and halftone GLSL. Only its clock is driven by Remotion.\n */\nconst HERO_FIELD = `#version 300 es\nprecision highp float;\n\nuniform vec2 iResolution;\nuniform float iTime;\nuniform float uLightMode;\nuniform vec3 uDarkBackground;\nuniform vec3 uLightBackground;\nout vec4 fragColor;\n\nconst float HUE = 0.663466752;\nconst float HUE_SPREAD = 0.314346701;\nconst float HUE_TRAVEL = 1.65112376;\nconst float CHROMA = 0.160295546;\nconst float LIGHTNESS = 0.537409723;\nconst float COLOUR_CYCLE = 0.124862425;\nconst float THETA = 2.12986207;\nconst float SHEAR = 0.968176901;\nconst float SHRINK = 0.955401778;\nconst float LAYERS = 72.0;\nconst float WARP_FREQ_X = 0.439311415;\nconst float WARP_FREQ_Y = 2.87923527;\nconst float WARP_AMP_X = 0.156202048;\nconst float WARP_AMP_Y = 0.0256033838;\nconst float ASPECT_X = 2.23183894;\nconst float ASPECT_Y = 0.15731883;\nconst float OFFSET_X = 0.375628948;\nconst float OFFSET_Y = -0.017801486;\nconst float TILT = 1.63293767;\nconst float ZOOM = 0.93135649;\nconst float CENTRE_X = -0.0956316143;\nconst float CENTRE_Y = -0.520057321;\nconst float GLOW_SIZE = 0.00201825937;\nconst float FALLOFF = 0.352821857;\nconst float VIGNETTE = 0.136085436;\nconst float FLOW_SPEED = 0.391012281;\nconst float FLOW_DIRECTION = 1.0;\nconst float BREATH_RATE = 0.382053256;\nconst float BREATH_AMOUNT = 0.0873704553;\nconst float PHASE = 56.3862724;\nconst float ECHO = 0.0;\nconst float ECHO_SHIFT = 0.178754866;\nconst float SOFTNESS = 0.00164903817;\nconst float LIGHT_SWING = 0.149726808;\n\nconst float TAU = 6.28318530718;\n\nvec3 oklchToLinear(float L, float C, float h) {\n float a = C * cos(h), b = C * sin(h);\n float l_ = L + 0.3963377774 * a + 0.2158037573 * b;\n float m_ = L - 0.1055613458 * a - 0.0638541728 * b;\n float s_ = L - 0.0894841775 * a - 1.2914855480 * b;\n vec3 lms = vec3(l_, m_, s_);\n lms = lms * lms * lms;\n return mat3(4.0767416621, -1.2684380046, -0.0041960863,\n -3.3077115913, 2.6097574011, -0.7034186147,\n 0.2309699292, -0.3413193965, 1.7076147010) * lms;\n}\n\nfloat blueNoise(vec2 p, float frame) {\n p += 5.588238 * mod(frame, 64.0);\n return fract(52.9829189 * fract(0.06711056 * p.x + 0.00583715 * p.y));\n}\n\nvoid main() {\n vec2 R = iResolution.xy;\n vec2 pos = (gl_FragCoord.xy - 0.5 * R) / R.y;\n float t = iTime * FLOW_SPEED * FLOW_DIRECTION + PHASE;\n float breath = (-sin(iTime * BREATH_RATE * 1.5) + sin(iTime * BREATH_RATE + 1.0)) * 0.25 + 0.5;\n\n vec2 u = (pos - vec2(CENTRE_X, CENTRE_Y)) * (ZOOM - breath * BREATH_AMOUNT);\n float ct = cos(TILT), st = sin(TILT);\n u = mat2(ct, st, -st, ct) * u;\n\n mat2 fold = mat2(cos(THETA), sin(THETA), -SHEAR, cos(THETA));\n\n float hue0 = HUE * TAU;\n float hue1 = hue0 + HUE_SPREAD * TAU;\n vec3 color = vec3(0.0);\n\n for (float i = 1.0; i <= 96.0; i += 1.0) {\n if (i > LAYERS) break;\n u.x += -sin(u.y * WARP_FREQ_X + t + i * 0.007) * WARP_AMP_X;\n u.y += -sin(u.x * WARP_FREQ_Y - t + i * 0.02) * WARP_AMP_Y;\n u = fold * u * SHRINK;\n\n vec2 q = u - vec2(OFFSET_X + breath * 0.1, OFFSET_Y);\n vec2 s = vec2(q.x * ASPECT_X, q.y * ASPECT_Y);\n float glow = GLOW_SIZE / (dot(s, s) + SOFTNESS);\n#ifndef SKIP_ECHO\n vec2 e = vec2((q.x - ECHO_SHIFT) * ASPECT_X, s.y);\n glow += ECHO * GLOW_SIZE / (dot(e, e) + SOFTNESS);\n#endif\n glow *= 0.25 + breath * 0.4;\n\n float r = length(u);\n float k = sin(i * COLOUR_CYCLE + t * 1.2 + r * HUE_TRAVEL) * 0.5 + 0.5;\n vec3 tint = clamp(oklchToLinear(LIGHTNESS + LIGHT_SWING * k, CHROMA * (0.75 + 0.35 * k), mix(hue0, hue1, k)), 0.0, 1.0);\n color += glow * tint * exp2(-r * FALLOFF);\n }\n\n vec3 x = max(color, 0.0);\n color = (x * (2.51 * x + 0.03)) / (x * (2.43 * x + 0.59) + 0.14);\n color = pow(clamp(color, 0.0, 1.0), vec3(0.85, 0.92, 0.98));\n\n float edge = smoothstep(0.5, 1.6, length(pos));\n color *= 1.0 - edge * VIGNETTE;\n\n vec3 dark = uDarkBackground + color * (1.0 - uDarkBackground);\n float strength = max(color.r, max(color.g, color.b));\n vec3 light = uLightBackground * (1.0 - strength) + color * 0.96;\n color = mix(dark, light, uLightMode);\n\n color += (blueNoise(gl_FragCoord.xy, floor(iTime * 24.0)) - 0.5) / 255.0;\n fragColor = vec4(clamp(color, 0.0, 1.0), 1.0);\n}\n`;\n\nconst HERO_HALFTONE = `#version 300 es\nprecision highp float;\n\nuniform sampler2D tScene;\nuniform vec2 iResolution;\nuniform float iTime;\nuniform float uLightMode;\nuniform vec3 uDarkBackground;\nuniform vec3 uLightBackground;\nuniform float uPixelRatio;\nout vec4 fragColor;\n\nconst float uStrength = 0.797335207;\nconst float uScale = 0.985214949;\nconst float uSeed = 0.435611069;\n\nconst float TAU = 6.28318530718;\nconst vec3 LUMA = vec3(0.2126, 0.7152, 0.0722);\n\nvec3 toInk(vec3 c) { return mix(c - uDarkBackground, uLightBackground - c, uLightMode); }\nvec3 fromInk(vec3 ink) { return mix(uDarkBackground + ink, uLightBackground - ink, uLightMode); }\nvec3 sceneInk(vec2 uv) { return toInk(texture(tScene, clamp(uv, 0.0, 1.0)).rgb); }\n\nfloat blueNoise(vec2 p, float frame) {\n p += 5.588238 * mod(frame, 64.0);\n return fract(52.9829189 * fract(0.06711056 * p.x + 0.00583715 * p.y));\n}\n\nvec3 halftone(vec2 frag) {\n float cell = max(3.0, uScale * 3.6 * uPixelRatio);\n float angle = 0.26 + uSeed * 0.3;\n mat2 turn = mat2(cos(angle), -sin(angle), sin(angle), cos(angle));\n vec2 rotated = turn * frag;\n vec2 grid = floor(rotated / cell);\n vec2 centre = (grid + 0.5) * cell;\n vec2 source = transpose(turn) * centre;\n vec3 soft = sceneInk(frag / iResolution);\n vec3 ink = sceneInk(source / iResolution);\n float level = clamp(dot(ink, LUMA), 0.0, 1.0);\n float radius = cell * sqrt(pow(level, 0.9) / 3.14159265);\n float dist = length(rotated - centre);\n float aa = 0.7 * uPixelRatio;\n float dot_ = 1.0 - smoothstep(radius - aa, radius + aa, dist);\n vec3 dots = ink * min(0.8 / max(level, 1e-3), 2.2) * dot_;\n float presence = smoothstep(0.03, 0.16, level) * (0.3 + 0.14 * uStrength);\n return mix(soft, dots, presence);\n}\n\nvoid main() {\n vec2 frag = gl_FragCoord.xy;\n vec3 ink = halftone(frag);\n vec3 color = fromInk(clamp(ink, 0.0, 1.0));\n color += (blueNoise(frag, floor(iTime * 24.0)) - 0.5) / 255.0;\n fragColor = vec4(clamp(color, 0.0, 1.0), 1.0);\n}\n`;\n\nconst FRAGMENT = `#version 300 es\nprecision highp float;\nuniform sampler2D uText;\nuniform sampler2D uHero;\nuniform vec2 uResolution;\nuniform vec4 uBounds;\nuniform float uEnter;\nuniform float uExit;\nuniform float uScale;\nuniform float uTime;\nuniform float uIntensity;\nout vec4 fragColor;\n\nvoid main() {\n vec2 uv = (gl_FragCoord.xy / uResolution - 0.5) / uScale + 0.5;\n vec2 q = (uv - uBounds.xy) / uBounds.zw;\n float flow = sin(q.x * 7.0 + q.y * 5.0 - uTime * 3.2) * 0.065\n + sin(q.x * 13.0 - q.y * 8.0 + uTime * 2.1) * 0.025;\n float rank = q.x * 0.64 + (1.0 - q.y) * 0.36 + flow;\n float d = rank - mix(-0.15, 1.65, uEnter);\n float edge = exp(-pow((d + 0.1) * 6.0, 2.0));\n // Refraction affects the glyph itself, concentrated inside the wet leading edge.\n vec3 field = texture(uHero, uv).rgb;\n vec2 warp = vec2(field.r - field.b, field.g - field.r);\n vec2 sampleUV = uv + warp * edge * uIntensity * 2.5 / uResolution;\n float glyph = texture(uText, sampleUV).a;\n float appear = 1.0 - smoothstep(-0.025, 0.09, d);\n float exitRank = q.x * 0.65 + (1.0 - q.y) * 0.5 + flow;\n float leave = smoothstep(-0.12, 0.06, exitRank - mix(-0.25, 1.45, uExit));\n\n vec3 liquid = texture(uHero, sampleUV).rgb;\n vec3 silver = vec3(0.96, 0.925, 1.0);\n float settled = 1.0 - smoothstep(-0.58, -0.16, d);\n vec3 color = mix(liquid, silver, settled);\n color = mix(silver, color, uIntensity);\n float alpha = glyph * appear * leave;\n fragColor = vec4(color * alpha, alpha);\n}`;\n\nfunction createRenderer(canvas: HTMLCanvasElement) {\n const gl = canvas.getContext(\"webgl2\", {\n alpha: true,\n premultipliedAlpha: true,\n antialias: false,\n depth: false,\n });\n if (!gl) throw new Error(\"Shader Text Reveal requires WebGL2.\");\n const shaders: WebGLShader[] = [];\n const programs: WebGLProgram[] = [];\n const textures: WebGLTexture[] = [];\n const buffers: WebGLFramebuffer[] = [];\n const dispose = () => {\n for (const shader of shaders) gl.deleteShader(shader);\n for (const program of programs) gl.deleteProgram(program);\n for (const texture of textures) gl.deleteTexture(texture);\n for (const buffer of buffers) gl.deleteFramebuffer(buffer);\n };\n const compile = (fragment: string) => {\n const program = gl.createProgram();\n if (!program) throw new Error(\"Shader Text Reveal: GPU allocation failed.\");\n programs.push(program);\n for (const [type, source] of [\n [gl.VERTEX_SHADER, VERTEX],\n [gl.FRAGMENT_SHADER, fragment],\n ] as const) {\n const shader = gl.createShader(type);\n if (!shader)\n throw new Error(\"Shader Text Reveal: shader allocation failed.\");\n shaders.push(shader);\n gl.shaderSource(shader, source);\n gl.compileShader(shader);\n if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS))\n throw new Error(\n gl.getShaderInfoLog(shader) ?? \"Shader compilation failed.\",\n );\n gl.attachShader(program, shader);\n }\n gl.linkProgram(program);\n if (!gl.getProgramParameter(program, gl.LINK_STATUS))\n throw new Error(gl.getProgramInfoLog(program) ?? \"Shader link failed.\");\n const locations = new Map<string, WebGLUniformLocation | null>();\n const uniform = (name: string) => {\n if (!locations.has(name))\n locations.set(name, gl.getUniformLocation(program, name));\n return locations.get(name) ?? null;\n };\n return {\n uniform,\n begin: (time: number) => {\n gl.useProgram(program);\n gl.viewport(0, 0, canvas.width, canvas.height);\n gl.uniform2f(uniform(\"iResolution\"), canvas.width, canvas.height);\n gl.uniform1f(uniform(\"iTime\"), time);\n gl.uniform1f(uniform(\"uLightMode\"), 0);\n gl.uniform3f(uniform(\"uDarkBackground\"), 9 / 255, 9 / 255, 9 / 255);\n gl.uniform3f(uniform(\"uLightBackground\"), 1, 1, 1);\n gl.uniform1f(uniform(\"uPixelRatio\"), 1);\n },\n };\n };\n const texture = () => {\n const value = gl.createTexture();\n if (!value)\n throw new Error(\"Shader Text Reveal: texture allocation failed.\");\n textures.push(value);\n gl.activeTexture(gl.TEXTURE0);\n gl.bindTexture(gl.TEXTURE_2D, value);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);\n return value;\n };\n const target = () => {\n const value = texture();\n const buffer = gl.createFramebuffer();\n if (!buffer)\n throw new Error(\"Shader Text Reveal: framebuffer allocation failed.\");\n buffers.push(buffer);\n gl.bindFramebuffer(gl.FRAMEBUFFER, buffer);\n gl.texImage2D(\n gl.TEXTURE_2D,\n 0,\n gl.RGBA,\n canvas.width,\n canvas.height,\n 0,\n gl.RGBA,\n gl.UNSIGNED_BYTE,\n null,\n );\n gl.framebufferTexture2D(\n gl.FRAMEBUFFER,\n gl.COLOR_ATTACHMENT0,\n gl.TEXTURE_2D,\n value,\n 0,\n );\n if (gl.checkFramebufferStatus(gl.FRAMEBUFFER) !== gl.FRAMEBUFFER_COMPLETE)\n throw new Error(\"Shader Text Reveal: incomplete framebuffer.\");\n return { value, buffer };\n };\n const bind = (value: WebGLTexture, unit: number) => {\n gl.activeTexture(gl.TEXTURE0 + unit);\n gl.bindTexture(gl.TEXTURE_2D, value);\n };\n try {\n const field = compile(HERO_FIELD);\n const halftone = compile(HERO_HALFTONE);\n const composite = compile(FRAGMENT);\n const text = texture();\n const raw = target();\n const hero = target();\n gl.bindFramebuffer(gl.FRAMEBUFFER, null);\n gl.clearColor(0, 0, 0, 0);\n gl.clear(gl.COLOR_BUFFER_BIT);\n let previous: HTMLCanvasElement | null = null;\n return {\n dispose,\n draw: (\n word: TextTexture,\n state: ReturnType<typeof getShaderTextState>,\n time: number,\n intensity: number,\n ) => {\n if (gl.isContextLost())\n throw new Error(\"Shader Text Reveal: WebGL context lost.\");\n // Render the hero's original field, then its original halftone pass.\n gl.bindFramebuffer(gl.FRAMEBUFFER, raw.buffer);\n field.begin(time);\n gl.drawArrays(gl.TRIANGLES, 0, 3);\n gl.bindFramebuffer(gl.FRAMEBUFFER, hero.buffer);\n halftone.begin(time);\n bind(raw.value, 0);\n gl.uniform1i(halftone.uniform(\"tScene\"), 0);\n gl.drawArrays(gl.TRIANGLES, 0, 3);\n\n gl.bindFramebuffer(gl.FRAMEBUFFER, null);\n composite.begin(time);\n bind(text, 0);\n if (previous !== word.canvas) {\n gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true);\n gl.texImage2D(\n gl.TEXTURE_2D,\n 0,\n gl.RGBA,\n gl.RGBA,\n gl.UNSIGNED_BYTE,\n word.canvas,\n );\n gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);\n previous = word.canvas;\n }\n bind(hero.value, 1);\n gl.uniform1i(composite.uniform(\"uText\"), 0);\n gl.uniform1i(composite.uniform(\"uHero\"), 1);\n gl.uniform2f(\n composite.uniform(\"uResolution\"),\n canvas.width,\n canvas.height,\n );\n gl.uniform4f(composite.uniform(\"uBounds\"), ...word.bounds);\n gl.uniform1f(composite.uniform(\"uEnter\"), state.enter);\n gl.uniform1f(composite.uniform(\"uExit\"), state.exit);\n gl.uniform1f(composite.uniform(\"uScale\"), state.scale);\n gl.uniform1f(composite.uniform(\"uTime\"), time);\n gl.uniform1f(composite.uniform(\"uIntensity\"), clamp(intensity));\n gl.drawArrays(gl.TRIANGLES, 0, 3);\n },\n };\n } catch (error) {\n dispose();\n throw error;\n }\n}\n\ntype TextTexture = {\n canvas: HTMLCanvasElement;\n bounds: [number, number, number, number];\n};\n\nfunction textTexture(\n text: string,\n width: number,\n height: number,\n fontSize: number,\n fontWeight: number,\n fontFamily: string,\n): TextTexture {\n const canvas = document.createElement(\"canvas\");\n canvas.width = width;\n canvas.height = height;\n const ctx = canvas.getContext(\"2d\");\n if (!ctx) throw new Error(\"Shader Text Reveal: cannot rasterize text.\");\n let size = Math.min(Math.max(1, fontSize), height * 0.58);\n ctx.font = `${fontWeight} ${size}px ${fontFamily}`;\n size *= Math.min(\n 1,\n (width * 0.72) / Math.max(1, ctx.measureText(text).width),\n );\n ctx.font = `${fontWeight} ${size}px ${fontFamily}`;\n const metrics = ctx.measureText(text);\n const left = (width - metrics.width) / 2;\n const ascent = metrics.actualBoundingBoxAscent;\n const descent = metrics.actualBoundingBoxDescent;\n const baseline = (height + ascent - descent) / 2;\n ctx.fillStyle = \"white\";\n ctx.fillText(text, left, baseline);\n return {\n canvas,\n bounds: [\n left / width,\n (height - baseline - descent) / height,\n Math.max(1, metrics.width) / width,\n Math.max(1, ascent + descent) / height,\n ],\n };\n}\n\nfunction ShaderTextRevealBase({\n text = \"Your product\",\n fontSize = 400,\n fontFamily = \"Arial, sans-serif\",\n fontWeight = 500,\n wordDuration = 30,\n intensity = 1,\n}: ShaderTextRevealProps) {\n const frame = useCurrentFrame();\n const { width, height, fps } = useVideoConfig();\n const { delayRender, continueRender, cancelRender } = useDelayRender();\n const canvas = useRef<HTMLCanvasElement>(null);\n const resources = useRef<{\n renderer: ReturnType<typeof createRenderer>;\n words: TextTexture[];\n } | null>(null);\n const current = useRef({ frame, fps, wordDuration, intensity });\n current.current = { frame, fps, wordDuration, intensity };\n\n useLayoutEffect(() => {\n const element = canvas.current;\n if (!element) return;\n let cancelled = false;\n const handle = delayRender(\"Load Shader Text Reveal font\");\n const phrases = text.includes(\"\\n\") ? text.split(\"\\n\") : text.split(/\\s+/);\n const words = phrases.map((word) => word.trim()).filter(Boolean);\n const draw = () => {\n const resource = resources.current;\n if (!resource || resource.words.length === 0) return;\n const clock = current.current;\n const state = getShaderTextState(\n clock.frame,\n resource.words.length,\n clock.wordDuration,\n );\n resource.renderer.draw(\n resource.words[state.index],\n state,\n clock.frame / clock.fps,\n clock.intensity,\n );\n };\n void document.fonts\n .load(`${fontWeight} ${fontSize}px ${fontFamily}`, text || \" \")\n .then(() => {\n if (cancelled) return;\n const textures = words.map((word) =>\n textTexture(word, width, height, fontSize, fontWeight, fontFamily),\n );\n const renderer = createRenderer(element);\n resources.current = { renderer, words: textures };\n draw();\n continueRender(handle);\n })\n .catch((error: unknown) => {\n if (!cancelled)\n cancelRender(\n error instanceof Error ? error : new Error(String(error)),\n );\n });\n return () => {\n cancelled = true;\n continueRender(handle);\n resources.current?.renderer.dispose();\n resources.current = null;\n };\n }, [\n text,\n width,\n height,\n fontSize,\n fontWeight,\n fontFamily,\n delayRender,\n continueRender,\n cancelRender,\n ]);\n\n useLayoutEffect(() => {\n const resource = resources.current;\n if (!resource || resource.words.length === 0) return;\n try {\n const state = getShaderTextState(\n frame,\n resource.words.length,\n wordDuration,\n );\n resource.renderer.draw(\n resource.words[state.index],\n state,\n frame / fps,\n intensity,\n );\n } catch (error) {\n cancelRender(error instanceof Error ? error : new Error(String(error)));\n }\n }, [frame, fps, wordDuration, intensity, cancelRender]);\n\n return (\n <canvas\n ref={canvas}\n width={width}\n height={height}\n role=\"img\"\n aria-label={text}\n style={{\n position: \"absolute\",\n inset: 0,\n width: \"100%\",\n height: \"100%\",\n pointerEvents: \"none\",\n }}\n />\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n text: {\n type: \"text-content\",\n default: \"Your product\",\n description: \"Text\",\n },\n fontSize: {\n type: \"number\",\n default: 400,\n min: 24,\n max: 500,\n step: 1,\n description: \"Font size\",\n hiddenFromList: false,\n },\n wordDuration: {\n type: \"number\",\n default: 30,\n min: 12,\n max: 90,\n step: 1,\n description: \"Frames per word\",\n hiddenFromList: false,\n },\n intensity: {\n type: \"number\",\n default: 1,\n min: 0,\n max: 1,\n step: 0.01,\n description: \"Hero shader strength\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"text\",\"fontSize\",\"wordDuration\",\"intensity\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n text: \"Your product\",\n fontSize: 400,\n wordDuration: 30,\n intensity: 1,\n speed: 1,\n};\n\ntype ShaderTextRevealElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof ShaderTextRevealBase>;\n\nconst ShaderTextRevealInner = forwardRef<\n HTMLDivElement,\n ShaderTextRevealElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<ShaderTextReveal>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <ShaderTextRevealBase\n {...(componentProps as unknown as ComponentProps<typeof ShaderTextRevealBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const ShaderTextReveal = Interactive.withSchema({\n Component: ShaderTextRevealInner,\n componentName: \"<ShaderTextReveal>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/shader-voronoi.json b/registry-artifacts/elements/shader-voronoi.jsonindex 26cc0fbb..c05c02c2 100644--- a/registry-artifacts/elements/shader-voronoi.json+++ b/registry-artifacts/elements/shader-voronoi.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@paper-design/shaders-react",@@ -11,6 +12,7 @@"dimensions": null,"displayName": "Shader Voronoi","durationInFrames": 150,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "shader-voronoi","sourceCode": "import { Voronoi, type VoronoiProps } from \"@paper-design/shaders-react\";\nimport { forwardRef, useCallback, useImperativeHandle, useRef, useState, type ComponentProps } from \"react\";\nimport { Interactive, Sequence, continueRender, delayRender, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\n\nconst NEUTRAL_COLORS = [\"#3a3a5c\", \"#52527a\"];\n\ninterface ShaderVoronoiProps\n extends Omit<VoronoiProps, \"frame\" | \"ref\"> {}\n\nfunction ShaderVoronoiBase({\n speed = 1,\n colors = NEUTRAL_COLORS,\n colorGap = \"#12121a\",\n distortion = 0.4,\n gap = 0.04,\n glow = 0,\n className,\n ...rest\n}: ShaderVoronoiProps) {\n const frame = useCurrentFrame();\n const { fps, width, height } = useVideoConfig();\n\n const [handle] = useState(() => delayRender(\"shader-voronoi\"));\n const gate = useCallback(\n (element: HTMLDivElement | null) => {\n if (!element) return;\n requestAnimationFrame(() =>\n requestAnimationFrame(() => continueRender(handle)),\n );\n },\n [handle],\n );\n\n return (\n <div\n ref={gate}\n className={className}\n style={{ position: \"absolute\", inset: 0 }}\n >\n <Voronoi\n speed={0}\n frame={(frame / fps) * speed * 1000}\n colors={colors}\n colorGap={colorGap}\n distortion={distortion}\n gap={gap}\n glow={glow}\n fit=\"cover\"\n width={width}\n height={height}\n {...rest}\n />\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n distortion: {\n type: \"number\",\n min: 0,\n max: 1,\n step: 0.05,\n default: 0.4,\n description: \"Distortion\",\n hiddenFromList: false,\n },\n gap: {\n type: \"number\",\n min: 0,\n max: 0.2,\n step: 0.01,\n default: 0.04,\n description: \"Gap\",\n hiddenFromList: false,\n },\n glow: {\n type: \"number\",\n min: 0,\n max: 1,\n step: 0.05,\n default: 0,\n description: \"Glow\",\n hiddenFromList: false,\n },\n colorGap: {\n type: \"color\",\n default: \"#12121a\",\n description: \"Gap Color\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"speed\",\"distortion\",\"gap\",\"glow\",\"colorGap\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n speed: 1,\n distortion: 0.4,\n gap: 0.04,\n glow: 0,\n colorGap: \"#12121a\",\n};\n\ntype ShaderVoronoiElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof ShaderVoronoiBase>;\n\nconst ShaderVoronoiInner = forwardRef<\n HTMLDivElement,\n ShaderVoronoiElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<ShaderVoronoi>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <ShaderVoronoiBase\n {...(componentProps as unknown as ComponentProps<typeof ShaderVoronoiBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const ShaderVoronoi = Interactive.withSchema({\n Component: ShaderVoronoiInner,\n componentName: \"<ShaderVoronoi>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/shader-warp.json b/registry-artifacts/elements/shader-warp.jsonindex 1b88038c..4baf6c1f 100644--- a/registry-artifacts/elements/shader-warp.json+++ b/registry-artifacts/elements/shader-warp.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@paper-design/shaders-react",@@ -11,6 +12,7 @@"dimensions": null,"displayName": "Shader Warp","durationInFrames": 150,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "shader-warp","sourceCode": "import { Warp, type WarpProps } from \"@paper-design/shaders-react\";\nimport { forwardRef, useCallback, useImperativeHandle, useRef, useState, type ComponentProps } from \"react\";\nimport { Interactive, Sequence, continueRender, delayRender, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\n\nconst NEUTRAL_COLORS = [\"#12121a\", \"#3a3a5c\", \"#12121a\", \"#52527a\"];\n\ninterface ShaderWarpProps extends Omit<WarpProps, \"frame\" | \"ref\"> {}\n\nfunction ShaderWarpBase({\n speed = 1,\n colors = NEUTRAL_COLORS,\n proportion = 0.5,\n softness = 1,\n distortion = 0.2,\n swirl = 0.4,\n className,\n ...rest\n}: ShaderWarpProps) {\n const frame = useCurrentFrame();\n const { fps, width, height } = useVideoConfig();\n\n const [handle] = useState(() => delayRender(\"shader-warp\"));\n const gate = useCallback(\n (element: HTMLDivElement | null) => {\n if (!element) return;\n requestAnimationFrame(() =>\n requestAnimationFrame(() => continueRender(handle)),\n );\n },\n [handle],\n );\n\n return (\n <div\n ref={gate}\n className={className}\n style={{ position: \"absolute\", inset: 0 }}\n >\n <Warp\n speed={0}\n frame={(frame / fps) * speed * 1000}\n colors={colors}\n proportion={proportion}\n softness={softness}\n distortion={distortion}\n swirl={swirl}\n fit=\"cover\"\n width={width}\n height={height}\n {...rest}\n />\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n distortion: {\n type: \"number\",\n min: 0,\n max: 1,\n step: 0.05,\n default: 0.2,\n description: \"Distortion\",\n hiddenFromList: false,\n },\n swirl: {\n type: \"number\",\n min: 0,\n max: 1,\n step: 0.05,\n default: 0.4,\n description: \"Swirl\",\n hiddenFromList: false,\n },\n softness: {\n type: \"number\",\n min: 0,\n max: 1,\n step: 0.05,\n default: 1,\n description: \"Softness\",\n hiddenFromList: false,\n },\n proportion: {\n type: \"number\",\n min: 0,\n max: 1,\n step: 0.05,\n default: 0.5,\n description: \"Proportion\",\n hiddenFromList: false,\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"speed\",\"distortion\",\"swirl\",\"softness\",\"proportion\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n speed: 1,\n distortion: 0.2,\n swirl: 0.4,\n softness: 1,\n proportion: 0.5,\n};\n\ntype ShaderWarpElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof ShaderWarpBase>;\n\nconst ShaderWarpInner = forwardRef<\n HTMLDivElement,\n ShaderWarpElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<ShaderWarp>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <ShaderWarpBase\n {...(componentProps as unknown as ComponentProps<typeof ShaderWarpBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const ShaderWarp = Interactive.withSchema({\n Component: ShaderWarpInner,\n componentName: \"<ShaderWarp>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/shader-water.json b/registry-artifacts/elements/shader-water.jsonindex 6c55f247..ac542661 100644--- a/registry-artifacts/elements/shader-water.json+++ b/registry-artifacts/elements/shader-water.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@paper-design/shaders-react",@@ -11,6 +12,7 @@"dimensions": null,"displayName": "Shader Water","durationInFrames": 150,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "shader-water","sourceCode": "import { Water, type WaterProps } from \"@paper-design/shaders-react\";\nimport { forwardRef, useCallback, useImperativeHandle, useRef, useState, type ComponentProps } from \"react\";\nimport { Interactive, Sequence, continueRender, delayRender, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\n\ninterface ShaderWaterProps extends Omit<WaterProps, \"frame\" | \"ref\"> {}\n\nfunction ShaderWaterBase({\n speed = 1,\n colorBack = \"#16202b\",\n colorHighlight = \"#5a6a7a\",\n highlights = 0.06,\n waves = 0.3,\n caustic = 0.08,\n className,\n ...rest\n}: ShaderWaterProps) {\n const frame = useCurrentFrame();\n const { fps, width, height } = useVideoConfig();\n\n const [handle] = useState(() => delayRender(\"shader-water\"));\n const gate = useCallback(\n (element: HTMLDivElement | null) => {\n if (!element) return;\n requestAnimationFrame(() =>\n requestAnimationFrame(() => continueRender(handle)),\n );\n },\n [handle],\n );\n\n return (\n <div\n ref={gate}\n className={className}\n style={{ position: \"absolute\", inset: 0 }}\n >\n <Water\n speed={0}\n frame={(frame / fps) * speed * 1000}\n colorBack={colorBack}\n colorHighlight={colorHighlight}\n highlights={highlights}\n waves={waves}\n caustic={caustic}\n fit=\"cover\"\n width={width}\n height={height}\n {...rest}\n />\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n waves: {\n type: \"number\",\n min: 0,\n max: 1,\n step: 0.05,\n default: 0.3,\n description: \"Waves\",\n hiddenFromList: false,\n },\n caustic: {\n type: \"number\",\n min: 0,\n max: 1,\n step: 0.02,\n default: 0.08,\n description: \"Caustic\",\n hiddenFromList: false,\n },\n highlights: {\n type: \"number\",\n min: 0,\n max: 1,\n step: 0.02,\n default: 0.06,\n description: \"Highlights\",\n hiddenFromList: false,\n },\n colorBack: {\n type: \"color\",\n default: \"#16202b\",\n description: \"Background\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"speed\",\"waves\",\"caustic\",\"highlights\",\"colorBack\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n speed: 1,\n waves: 0.3,\n caustic: 0.08,\n highlights: 0.06,\n colorBack: \"#16202b\",\n};\n\ntype ShaderWaterElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof ShaderWaterBase>;\n\nconst ShaderWaterInner = forwardRef<\n HTMLDivElement,\n ShaderWaterElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<ShaderWater>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <ShaderWaterBase\n {...(componentProps as unknown as ComponentProps<typeof ShaderWaterBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const ShaderWater = Interactive.withSchema({\n Component: ShaderWaterInner,\n componentName: \"<ShaderWater>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/shader-weave.json b/registry-artifacts/elements/shader-weave.jsonindex b7a3091d..3a6d9414 100644--- a/registry-artifacts/elements/shader-weave.json+++ b/registry-artifacts/elements/shader-weave.json@@ -2,10 +2,12 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [],"dimensions": null,"displayName": "Shader Weave","durationInFrames": 150,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "shader-weave","sourceCode": "import { forwardRef, useEffect, useImperativeHandle, useRef, useState, type ComponentProps } from \"react\";\nimport { Interactive, Sequence, continueRender, delayRender, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\n\n// A woven substrate — warp and weft threads crossing on a domain-warped grid,\n// interlacing over/under like real cloth, with a slow sheen of light travelling\n// across the fabric rather than the grid scrolling. The metaphor: the base a\n// component is woven from. Written for the remocn registry as a custom WebGL\n// shader (not a paper-design wrapper): frame-driven, deterministic, no\n// wall-clock time anywhere.\n//\n// `accent` / `accentAmount` run a coloured thread through the weave — the tint\n// lives mostly IN the threads, so raising `accentAmount` mid-video reads as a\n// violet thread lighting up across the whole cloth (a natural carrier for a\n// \"new base\" story). The grid itself never moves; only the light does.\n\ninterface ShaderWeaveProps {\n /** Palette: fabric-shadow, fabric-mid, fabric-warm, thread-highlight. 4 stops. */\n colors?: [string, string, string, string];\n /** Tint carried by the threads. */\n accent?: string;\n /** 0..1 — how much accent the threads take. */\n accentAmount?: number;\n /** Thread density across the frame height. */\n scale?: number;\n /** Domain-warp amount — how hand-woven the threads bend (fractions of frame). */\n warp?: number;\n /** Global time multiplier (drives only the sheen, never the grid position). */\n speed?: number;\n className?: string;\n}\n\nconst VERT = `\nattribute vec2 a_pos;\nvoid main() {\n gl_Position = vec4(a_pos, 0.0, 1.0);\n}\n`;\n\nconst FRAG = `\nprecision highp float;\n\nuniform vec2 u_res;\nuniform float u_time;\nuniform float u_scale;\nuniform float u_warp;\nuniform vec3 u_c0;\nuniform vec3 u_c1;\nuniform vec3 u_c2;\nuniform vec3 u_c3;\nuniform vec3 u_accent;\nuniform float u_accentAmt;\n\nfloat hash(vec2 p) {\n return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453123);\n}\n\nfloat noise(vec2 p) {\n vec2 i = floor(p);\n vec2 f = fract(p);\n vec2 u = f * f * (3.0 - 2.0 * f);\n return mix(\n mix(hash(i), hash(i + vec2(1.0, 0.0)), u.x),\n mix(hash(i + vec2(0.0, 1.0)), hash(i + vec2(1.0, 1.0)), u.x),\n u.y\n );\n}\n\nfloat fbm(vec2 p) {\n float v = 0.0;\n float a = 0.5;\n for (int i = 0; i < 4; i++) {\n v += a * noise(p);\n p *= 2.03;\n a *= 0.5;\n }\n return v;\n}\n\n// A thin ridge line at every integer of x — the profile of one thread.\nfloat thread(float x, float sharp) {\n float f = fract(x);\n float d = min(f, 1.0 - f);\n return smoothstep(sharp, 0.0, d);\n}\n\nvoid main() {\n vec2 uv = gl_FragCoord.xy / u_res;\n float aspect = u_res.x / u_res.y;\n\n // Domain warp — bend the weave so it reads hand-made, not a CSS grid. The\n // warp field drifts very slowly; the grid lattice itself stays put.\n vec2 q = uv + u_warp * vec2(\n fbm(uv * 3.0 + vec2(u_time * 0.03, 0.0)) - 0.5,\n fbm(uv * 3.0 + vec2(7.3, -u_time * 0.02)) - 0.5\n );\n\n float qx = q.x * u_scale * aspect;\n float qy = q.y * u_scale;\n\n float tw = thread(qx, 0.09); // warp (vertical threads)\n float tf = thread(qy, 0.09); // weft (horizontal threads)\n\n // Interlace: per cell, one direction sits over the other.\n float over = mod(floor(qx) + floor(qy), 2.0);\n float warpB = tw * (over < 0.5 ? 1.0 : 0.5);\n float weftB = tf * (over < 0.5 ? 0.5 : 1.0);\n float weave = max(warpB, weftB);\n\n // Sheen — light travelling across a still cloth (this is the only motion).\n float sheen = fbm(q * 1.7 + vec2(u_time * 0.05, u_time * 0.028));\n weave *= 0.3 + 0.95 * sheen;\n\n // Fabric ground: near-black, faintly breathing between the shadow stops.\n vec3 base = mix(u_c0, u_c1, smoothstep(0.15, 0.8, sheen));\n base = mix(base, u_c2, smoothstep(0.62, 1.0, sheen) * 0.5);\n\n // Threads sit a touch above the ground.\n vec3 col = mix(base, u_c3, clamp(weave, 0.0, 1.0) * 0.55);\n\n // The accent runs through the threads — a violet thread across the cloth.\n float amt = clamp(u_accentAmt, 0.0, 1.0);\n col = mix(col, u_accent, amt * (0.08 + 0.34 * weave));\n col += u_accent * amt * 0.015;\n\n // A whisper of living grain, time-derived so it stays deterministic.\n col += (hash(gl_FragCoord.xy + floor(u_time * 9.0)) - 0.5) * 0.012;\n\n gl_FragColor = vec4(col, 1.0);\n}\n`;\n\nconst hexToRgb = (hex: string): [number, number, number] => {\n const h = hex.replace(\"#\", \"\");\n const v =\n h.length === 3\n ? h\n .split(\"\")\n .map((c) => c + c)\n .join(\"\")\n : h;\n const n = parseInt(v, 16);\n return [((n >> 16) & 255) / 255, ((n >> 8) & 255) / 255, (n & 255) / 255];\n};\n\ntype GlState = {\n gl: WebGLRenderingContext;\n uniforms: Record<string, WebGLUniformLocation | null>;\n};\n\nfunction ShaderWeaveBase({\n colors = [\"#050506\", \"#0a0a0c\", \"#111015\", \"#1b1a22\"],\n accent = \"#6733FF\",\n accentAmount = 0,\n scale = 22,\n warp = 0.03,\n speed = 1,\n className,\n}: ShaderWeaveProps) {\n const frame = useCurrentFrame();\n const { fps, width, height } = useVideoConfig();\n const canvasRef = useRef<HTMLCanvasElement>(null);\n const stateRef = useRef<GlState | null>(null);\n const [handle] = useState(() => delayRender(\"shader-weave\"));\n const continuedRef = useRef(false);\n\n useEffect(() => {\n const canvas = canvasRef.current;\n if (!canvas || stateRef.current) return;\n const gl = canvas.getContext(\"webgl\", {\n antialias: false,\n preserveDrawingBuffer: true,\n });\n if (!gl) return;\n\n const compile = (type: number, src: string) => {\n const shader = gl.createShader(type);\n if (!shader) throw new Error(\"Failed to create WebGL shader\");\n gl.shaderSource(shader, src);\n gl.compileShader(shader);\n return shader;\n };\n const program = gl.createProgram();\n if (!program) return;\n gl.attachShader(program, compile(gl.VERTEX_SHADER, VERT));\n gl.attachShader(program, compile(gl.FRAGMENT_SHADER, FRAG));\n gl.linkProgram(program);\n // biome-ignore lint/correctness/useHookAtTopLevel: gl.useProgram is a WebGL method, not a React hook\n gl.useProgram(program);\n\n const buf = gl.createBuffer();\n gl.bindBuffer(gl.ARRAY_BUFFER, buf);\n gl.bufferData(\n gl.ARRAY_BUFFER,\n new Float32Array([-1, -1, 3, -1, -1, 3]),\n gl.STATIC_DRAW,\n );\n const loc = gl.getAttribLocation(program, \"a_pos\");\n gl.enableVertexAttribArray(loc);\n gl.vertexAttribPointer(loc, 2, gl.FLOAT, false, 0, 0);\n\n const uniforms: GlState[\"uniforms\"] = {};\n for (const name of [\n \"u_res\",\n \"u_time\",\n \"u_scale\",\n \"u_warp\",\n \"u_c0\",\n \"u_c1\",\n \"u_c2\",\n \"u_c3\",\n \"u_accent\",\n \"u_accentAmt\",\n ]) {\n uniforms[name] = gl.getUniformLocation(program, name);\n }\n stateRef.current = { gl, uniforms };\n }, []);\n\n useEffect(() => {\n const state = stateRef.current;\n const canvas = canvasRef.current;\n if (!state || !canvas) return;\n const { gl, uniforms } = state;\n\n gl.viewport(0, 0, canvas.width, canvas.height);\n gl.uniform2f(uniforms.u_res, canvas.width, canvas.height);\n gl.uniform1f(uniforms.u_time, (frame / fps) * speed);\n gl.uniform1f(uniforms.u_scale, scale);\n gl.uniform1f(uniforms.u_warp, warp);\n gl.uniform3fv(uniforms.u_c0, hexToRgb(colors[0]));\n gl.uniform3fv(uniforms.u_c1, hexToRgb(colors[1]));\n gl.uniform3fv(uniforms.u_c2, hexToRgb(colors[2]));\n gl.uniform3fv(uniforms.u_c3, hexToRgb(colors[3]));\n gl.uniform3fv(uniforms.u_accent, hexToRgb(accent));\n gl.uniform1f(uniforms.u_accentAmt, accentAmount);\n gl.drawArrays(gl.TRIANGLES, 0, 3);\n\n if (!continuedRef.current) {\n continuedRef.current = true;\n requestAnimationFrame(() =>\n requestAnimationFrame(() => continueRender(handle)),\n );\n }\n }, [frame, fps, speed, scale, warp, colors, accent, accentAmount, handle]);\n\n return (\n <div className={className} style={{ position: \"absolute\", inset: 0 }}>\n <canvas\n ref={canvasRef}\n width={width}\n height={height}\n style={{ width: \"100%\", height: \"100%\", display: \"block\" }}\n />\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n scale: {\n type: \"number\",\n min: 6,\n max: 48,\n step: 1,\n default: 22,\n description: \"Scale\",\n hiddenFromList: false,\n },\n warp: {\n type: \"number\",\n min: 0,\n max: 0.2,\n step: 0.01,\n default: 0.03,\n description: \"Warp\",\n hiddenFromList: false,\n },\n accent: {\n type: \"color\",\n default: \"#6733FF\",\n description: \"Accent\",\n },\n accentAmount: {\n type: \"number\",\n min: 0,\n max: 1,\n step: 0.05,\n default: 0,\n description: \"Accent amount\",\n hiddenFromList: false,\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"speed\",\"scale\",\"warp\",\"accent\",\"accentAmount\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n speed: 1,\n scale: 22,\n warp: 0.03,\n accent: \"#6733FF\",\n accentAmount: 0,\n};\n\ntype ShaderWeaveElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof ShaderWeaveBase>;\n\nconst ShaderWeaveInner = forwardRef<\n HTMLDivElement,\n ShaderWeaveElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<ShaderWeave>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <ShaderWeaveBase\n {...(componentProps as unknown as ComponentProps<typeof ShaderWeaveBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const ShaderWeave = Interactive.withSchema({\n Component: ShaderWeaveInner,\n componentName: \"<ShaderWeave>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/shadow-sweep-text.json b/registry-artifacts/elements/shadow-sweep-text.jsonindex fd257752..ba790150 100644--- a/registry-artifacts/elements/shadow-sweep-text.json+++ b/registry-artifacts/elements/shadow-sweep-text.json@@ -2,10 +2,12 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [],"dimensions": null,"displayName": "Shadow Sweep Text","durationInFrames": 37,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "shadow-sweep-text","sourceCode": "import { Easing, Interactive, Sequence, interpolate, useCurrentFrame, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface ShadowSweepTextProps {\n text: string;\n fontSize?: number;\n color?: string;\n fontWeight?: number;\n backgroundColor?: string;\n shadowColor?: string;\n shadowSoftness?: number;\n rise?: number;\n driftLeft?: number;\n speed?: number;\n className?: string;\n}\n\nconst shadowSweepTextLength = 37;\n\nconst ENTER_END = 23;\nconst EXIT_START = 26;\nconst EXIT_END = shadowSweepTextLength - 1;\nconst REST_X = -20;\nconst REST_Y = 9;\nconst clamp = {\n extrapolateLeft: \"clamp\" as const,\n extrapolateRight: \"clamp\" as const,\n};\n\nfunction ShadowSweepTextBase({\n text,\n fontSize = 96,\n color = \"#aaa6b5\",\n fontWeight = 700,\n backgroundColor = \"#030012\",\n shadowColor = backgroundColor,\n shadowSoftness = 130,\n rise = 96,\n driftLeft = 16,\n speed = 1,\n className,\n}: ShadowSweepTextProps) {\n const frame = useCurrentFrame() * speed;\n const safeSoftness = Math.max(shadowSoftness, 0);\n const travelProgress = interpolate(\n frame,\n [0, shadowSweepTextLength - 1],\n [0, 1],\n {\n ...clamp,\n easing: Easing.out(Easing.cubic),\n },\n );\n const enterProgress = interpolate(frame, [-3, ENTER_END], [0, 1], clamp);\n const exitProgress = interpolate(\n frame,\n [EXIT_START, EXIT_END],\n [0, 1],\n clamp,\n );\n const x = REST_X + driftLeft * (1 - travelProgress);\n const y = REST_Y + rise * (1 - travelProgress);\n const isEntering = frame < ENTER_END;\n const isExiting = frame >= EXIT_START;\n const sweepProgress = isEntering\n ? enterProgress\n : isExiting\n ? exitProgress\n : null;\n const edgeOffset =\n sweepProgress === null ? 0 : (sweepProgress * 2 - 1) * (safeSoftness / 2);\n const edgePosition =\n sweepProgress === null\n ? \"50%\"\n : `calc(${sweepProgress * 100}% + ${edgeOffset}px)`;\n const maskStart =\n sweepProgress === null\n ? \"50%\"\n : `calc(${sweepProgress * 100}% + ${edgeOffset - safeSoftness / 2}px)`;\n const maskEnd =\n sweepProgress === null\n ? \"50%\"\n : `calc(${sweepProgress * 100}% + ${edgeOffset + safeSoftness / 2}px)`;\n const textMask = isEntering\n ? `linear-gradient(90deg, #000 0, #000 ${maskStart}, transparent ${maskEnd}, transparent 100%)`\n : isExiting\n ? `linear-gradient(90deg, transparent 0, transparent ${maskStart}, #000 ${maskEnd}, #000 100%)`\n : undefined;\n const fieldOpacity =\n sweepProgress === null\n ? 0\n : interpolate(sweepProgress, [0, 0.08, 0.82, 1], [0, 1, 1, 0], clamp);\n const fieldWidth = Math.max(safeSoftness * 3, 1);\n const fieldHeight = Math.max(fontSize * 2.6, safeSoftness * 1.8, 1);\n\n if (text.length === 0) {\n return (\n <div\n className={className}\n style={{ position: \"absolute\", inset: 0, backgroundColor }}\n />\n );\n }\n\n return (\n <div\n className={className}\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n overflow: \"hidden\",\n backgroundColor,\n }}\n >\n <div\n style={{\n position: \"relative\",\n display: \"inline-block\",\n transform: `translate3d(${x}px, ${y}px, 0)`,\n }}\n >\n <span\n style={{\n color,\n display: \"inline-block\",\n fontFamily: \"Arial, Helvetica, sans-serif\",\n fontSize,\n fontWeight,\n letterSpacing: 0,\n lineHeight: 1,\n maskImage: textMask,\n maskRepeat: \"no-repeat\",\n opacity: 1,\n WebkitMaskImage: textMask,\n WebkitMaskRepeat: \"no-repeat\",\n whiteSpace: \"nowrap\",\n }}\n >\n {text}\n </span>\n\n <div\n style={{\n position: \"absolute\",\n top: \"50%\",\n left: edgePosition,\n width: fieldWidth,\n height: fieldHeight,\n background: `radial-gradient(ellipse at center, ${shadowColor} 0%, ${shadowColor} 14%, transparent 72%)`,\n filter: `blur(${safeSoftness * 0.08}px)`,\n opacity: fieldOpacity,\n pointerEvents: \"none\",\n transform: \"translate3d(-50%, -50%, 0)\",\n }}\n />\n </div>\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n text: {\n type: \"text-content\",\n default: \"are abandoned\",\n description: \"Text\",\n },\n fontSize: {\n type: \"number\",\n min: 24,\n max: 180,\n step: 1,\n default: 96,\n description: \"Font size\",\n hiddenFromList: false,\n },\n rise: {\n type: \"number\",\n min: 0,\n max: 300,\n step: 1,\n default: 96,\n description: \"Vertical travel\",\n hiddenFromList: false,\n },\n driftLeft: {\n type: \"number\",\n min: 0,\n max: 120,\n step: 1,\n default: 16,\n description: \"Leftward travel\",\n hiddenFromList: false,\n },\n shadowSoftness: {\n type: \"number\",\n min: 0,\n max: 280,\n step: 2,\n default: 130,\n description: \"Shadow softness\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#aaa6b5\",\n description: \"Text color\",\n },\n backgroundColor: {\n type: \"color\",\n default: \"#030012\",\n description: \"Background color\",\n },\n shadowColor: {\n type: \"color\",\n default: \"#030012\",\n description: \"Shadow color\",\n },\n fontWeight: {\n type: \"enum\",\n default: \"700\",\n variants: {\n \"400\": {},\n \"500\": {},\n \"600\": {},\n \"700\": {},\n },\n description: \"Font weight\",\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"text\",\"fontSize\",\"rise\",\"driftLeft\",\"shadowSoftness\",\"color\",\"backgroundColor\",\"shadowColor\",\"fontWeight\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n text: \"are abandoned\",\n fontSize: 96,\n rise: 96,\n driftLeft: 16,\n shadowSoftness: 130,\n color: \"#aaa6b5\",\n backgroundColor: \"#030012\",\n shadowColor: \"#030012\",\n fontWeight: \"700\",\n speed: 1,\n};\n\ntype ShadowSweepTextElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof ShadowSweepTextBase>;\n\nconst ShadowSweepTextInner = forwardRef<\n HTMLDivElement,\n ShadowSweepTextElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<ShadowSweepText>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <ShadowSweepTextBase\n {...(componentProps as unknown as ComponentProps<typeof ShadowSweepTextBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const ShadowSweepText = Interactive.withSchema({\n Component: ShadowSweepTextInner,\n componentName: \"<ShadowSweepText>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/shared-axis-y.json b/registry-artifacts/elements/shared-axis-y.jsonindex 64fe18ba..7ecd6378 100644--- a/registry-artifacts/elements/shared-axis-y.json+++ b/registry-artifacts/elements/shared-axis-y.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [],"dimensions": {"width": 720,@@ -9,6 +10,7 @@},"displayName": "Shared Axis Y","durationInFrames": 90,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "shared-axis-y","sourceCode": "import { Easing, Interactive, Sequence, interpolate, useCurrentFrame, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface SharedAxisYProps {\n fromText: string;\n toText: string;\n fontSize?: number;\n color?: string;\n fontWeight?: number;\n speed?: number;\n className?: string;\n}\n\nfunction SharedAxisYBase({\n fromText,\n toText,\n fontSize = 72,\n color = \"#171717\",\n fontWeight = 600,\n speed = 1,\n className,\n}: SharedAxisYProps) {\n const frame = useCurrentFrame() * speed;\n\n const fromWords = fromText.split(\" \");\n const toWords = toText.split(\" \");\n\n const enterDur = 5;\n const exitDur = 4;\n const enterStagger = 2;\n const exitStagger = 2;\n const overlapF = 0;\n const microDelayF = 1;\n\n const exitTotal = exitDur + (fromWords.length - 1) * exitStagger;\n const newStart = Math.max(0, exitTotal - overlapF + microDelayF);\n\n const fontStack =\n \"var(--font-geist-sans), -apple-system, BlinkMacSystemFont, sans-serif\";\n\n return (\n <div\n className={className}\n style={{\n position: \"absolute\",\n inset: 0,\n background: \"transparent\",\n }}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <span\n style={{\n fontSize,\n fontWeight,\n color,\n letterSpacing: \"-0.03em\",\n fontFamily: fontStack,\n }}\n >\n {fromWords.map((word, i) => {\n const local = frame - i * exitStagger;\n const opacity = interpolate(local, [0, exitDur], [1, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.step1,\n });\n return (\n <span\n key={i}\n style={{\n display: \"inline-block\",\n marginRight: \"0.25em\",\n opacity,\n }}\n >\n {word}\n </span>\n );\n })}\n </span>\n </div>\n\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <span\n style={{\n fontSize,\n fontWeight,\n color,\n letterSpacing: \"-0.03em\",\n fontFamily: fontStack,\n }}\n >\n {toWords.map((word, j) => {\n const local = frame - newStart - j * enterStagger;\n const opacity = interpolate(local, [0, enterDur], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.step1,\n });\n return (\n <span\n key={j}\n style={{\n display: \"inline-block\",\n marginRight: \"0.25em\",\n opacity,\n }}\n >\n {word}\n </span>\n );\n })}\n </span>\n </div>\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n fromText: {\n type: \"text-content\",\n default: \"Layered navigation.\",\n description: \"From text\",\n },\n toText: {\n type: \"text-content\",\n default: \"Hierarchy made clear.\",\n description: \"To text\",\n },\n fontSize: {\n type: \"number\",\n min: 12,\n max: 160,\n step: 1,\n default: 72,\n description: \"Font size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n fontWeight: {\n type: \"enum\",\n default: \"600\",\n variants: {\n \"400\": {},\n \"500\": {},\n \"600\": {},\n \"700\": {},\n },\n description: \"Font weight\",\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 720,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 100,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"fromText\",\"toText\",\"fontSize\",\"color\",\"fontWeight\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n fromText: \"Layered navigation.\",\n toText: \"Hierarchy made clear.\",\n fontSize: 72,\n color: \"#171717\",\n fontWeight: \"600\",\n speed: 1,\n};\n\ntype SharedAxisYElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof SharedAxisYBase>;\n\nconst SharedAxisYInner = forwardRef<\n HTMLDivElement,\n SharedAxisYElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 720, height = 100, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<SharedAxisY>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <SharedAxisYBase\n {...(componentProps as unknown as ComponentProps<typeof SharedAxisYBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const SharedAxisY = Interactive.withSchema({\n Component: SharedAxisYInner,\n componentName: \"<SharedAxisY>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/shared-axis-z.json b/registry-artifacts/elements/shared-axis-z.jsonindex 6c666e1a..7327d6a8 100644--- a/registry-artifacts/elements/shared-axis-z.json+++ b/registry-artifacts/elements/shared-axis-z.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [],"dimensions": {"width": 870,@@ -9,6 +10,7 @@},"displayName": "Shared Axis Z","durationInFrames": 90,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "shared-axis-z","sourceCode": "import { Easing, Interactive, Sequence, interpolate, useCurrentFrame, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface SharedAxisZProps {\n fromText: string;\n toText: string;\n fontSize?: number;\n color?: string;\n fontWeight?: number;\n speed?: number;\n className?: string;\n}\n\nfunction SharedAxisZBase({\n fromText,\n toText,\n fontSize = 72,\n color = \"#171717\",\n fontWeight = 600,\n speed = 1,\n className,\n}: SharedAxisZProps) {\n const frame = useCurrentFrame() * speed;\n\n const enterDur = 16;\n const exitDur = 11;\n const overlapF = 3;\n const microDelayF = 1;\n\n const exitTotal = exitDur;\n const newStart = Math.max(0, exitTotal - overlapF + microDelayF);\n\n const exitEasing = Easing.bezier(0.4, 0, 1, 1);\n const enterEasing = Easing.bezier(0.2, 0, 0, 1);\n\n const fromOpacity = interpolate(frame, [0, exitDur], [1, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: exitEasing,\n });\n const fromScale = interpolate(frame, [0, exitDur], [1, 1.06], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: exitEasing,\n });\n const fromBlur = interpolate(frame, [0, exitDur], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: exitEasing,\n });\n\n const local = frame - newStart;\n const toOpacity = interpolate(local, [0, enterDur], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: enterEasing,\n });\n const toScale = interpolate(local, [0, enterDur], [0.9, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: enterEasing,\n });\n const toBlur = interpolate(local, [0, enterDur], [2, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: enterEasing,\n });\n\n const fontStack =\n \"var(--font-geist-sans), -apple-system, BlinkMacSystemFont, sans-serif\";\n\n return (\n <div\n className={className}\n style={{\n position: \"absolute\",\n inset: 0,\n background: \"transparent\",\n }}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <span\n style={{\n fontSize,\n fontWeight,\n color,\n letterSpacing: \"-0.03em\",\n fontFamily: fontStack,\n display: \"inline-block\",\n transformOrigin: \"50% 50%\",\n opacity: fromOpacity,\n scale: `${fromScale}`,\n filter: `blur(${fromBlur}px)`,\n }}\n >\n {fromText}\n </span>\n </div>\n\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <span\n style={{\n fontSize,\n fontWeight,\n color,\n letterSpacing: \"-0.03em\",\n fontFamily: fontStack,\n display: \"inline-block\",\n transformOrigin: \"50% 50%\",\n opacity: toOpacity,\n scale: `${toScale}`,\n filter: `blur(${toBlur}px)`,\n }}\n >\n {toText}\n </span>\n </div>\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n fromText: {\n type: \"text-content\",\n default: \"Zooming between states.\",\n description: \"From text\",\n },\n toText: {\n type: \"text-content\",\n default: \"Elevate and settle.\",\n description: \"To text\",\n },\n fontSize: {\n type: \"number\",\n min: 12,\n max: 160,\n step: 1,\n default: 72,\n description: \"Font size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n fontWeight: {\n type: \"enum\",\n default: \"600\",\n variants: {\n \"400\": {},\n \"500\": {},\n \"600\": {},\n \"700\": {},\n },\n description: \"Font weight\",\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 870,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 100,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"fromText\",\"toText\",\"fontSize\",\"color\",\"fontWeight\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n fromText: \"Zooming between states.\",\n toText: \"Elevate and settle.\",\n fontSize: 72,\n color: \"#171717\",\n fontWeight: \"600\",\n speed: 1,\n};\n\ntype SharedAxisZElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof SharedAxisZBase>;\n\nconst SharedAxisZInner = forwardRef<\n HTMLDivElement,\n SharedAxisZElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 870, height = 100, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<SharedAxisZ>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <SharedAxisZBase\n {...(componentProps as unknown as ComponentProps<typeof SharedAxisZBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const SharedAxisZ = Interactive.withSchema({\n Component: SharedAxisZInner,\n componentName: \"<SharedAxisZ>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/sheen-slide-in.json b/registry-artifacts/elements/sheen-slide-in.jsonindex 21611055..c8476462 100644--- a/registry-artifacts/elements/sheen-slide-in.json+++ b/registry-artifacts/elements/sheen-slide-in.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [],"dimensions": {"width": 620,@@ -9,6 +10,7 @@},"displayName": "Sheen Slide In","durationInFrames": 64,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "sheen-slide-in","sourceCode": "import { Easing, Interactive, Sequence, interpolate, useCurrentFrame, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface SheenSlideInProps {\n text: string;\n exitAt?: number;\n fontSize?: number;\n baseColor?: string;\n sheenColor?: string;\n fontWeight?: number;\n speed?: number;\n className?: string;\n}\n\nconst SETTLE_AMP_EM = 1.8;\nconst SETTLE_TAU = 2.5;\nconst CREEP_AMP_EM = 0.28;\nconst CREEP_TAU = 12;\nconst FADE_FRAMES = 4;\nconst SHEEN_IN_START = 0;\nconst SHEEN_IN_END = 4;\nconst SHEEN_SWEEP_END = 48;\nconst SHEEN_OUT_START = 48;\nconst SHEEN_OUT_END = 58;\nconst EXIT_FRAMES = 4;\nconst EXIT_SCALE = 0.9;\n\nfunction sheenSlideInLength(exitAt = 60): number {\n return exitAt + EXIT_FRAMES;\n}\n\nfunction travelEm(frame: number): number {\n return (\n SETTLE_AMP_EM * Math.exp(-frame / SETTLE_TAU) +\n CREEP_AMP_EM * Math.exp(-frame / CREEP_TAU)\n );\n}\n\nconst exitEasing = Easing.out(Easing.quad);\n\nfunction SheenSlideInBase({\n text,\n exitAt = 60,\n fontSize = 72,\n baseColor = \"#18181b\",\n sheenColor = \"#4f8ef7\",\n fontWeight = 400,\n speed = 1,\n className,\n}: SheenSlideInProps) {\n const frame = useCurrentFrame() * speed;\n\n const x = fontSize * travelEm(frame);\n\n const exit = interpolate(frame, [exitAt, exitAt + EXIT_FRAMES], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: exitEasing,\n });\n\n const opacity = interpolate(frame, [0, FADE_FRAMES], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n });\n\n const sheenOpacity =\n interpolate(frame, [SHEEN_IN_START, SHEEN_IN_END], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n }) *\n interpolate(frame, [SHEEN_OUT_START, SHEEN_OUT_END], [1, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n });\n\n const sheenPosition = interpolate(frame, [0, SHEEN_SWEEP_END], [160, -60], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.bezier(0.42, 0, 0.58, 1),\n });\n\n const textStyle: React.CSSProperties = {\n fontSize,\n fontWeight,\n letterSpacing: \"-0.02em\",\n lineHeight: 1.1,\n margin: 0,\n fontFamily:\n \"var(--font-geist-sans, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif)\",\n };\n\n if (exit >= 1) {\n return (\n <div\n style={{ position: \"absolute\", inset: 0, background: \"transparent\" }}\n />\n );\n }\n\n return (\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n whiteSpace: \"nowrap\",\n background: \"transparent\",\n }}\n >\n <div\n style={{\n position: \"relative\",\n display: \"inline-block\",\n opacity,\n translate: `${x}px 0`,\n scale: `${1 - (1 - EXIT_SCALE) * exit}`,\n }}\n >\n <span className={className} style={{ ...textStyle, color: baseColor }}>\n {text}\n </span>\n <span\n aria-hidden\n style={{\n ...textStyle,\n position: \"absolute\",\n inset: 0,\n color: \"transparent\",\n backgroundClip: \"text\",\n WebkitBackgroundClip: \"text\",\n backgroundImage: `linear-gradient(100deg, transparent 25%, ${sheenColor} 50%, transparent 75%)`,\n backgroundSize: \"250% 100%\",\n backgroundPosition: `${sheenPosition}% 50%`,\n opacity: sheenOpacity,\n }}\n >\n {text}\n </span>\n </div>\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n text: {\n type: \"text-content\",\n default: \"Introducing\",\n description: \"Text\",\n },\n exitAt: {\n type: \"number\",\n min: 30,\n max: 150,\n step: 5,\n default: 60,\n description: \"Exit frame\",\n hiddenFromList: false,\n },\n fontSize: {\n type: \"number\",\n min: 12,\n max: 160,\n step: 1,\n default: 72,\n description: \"Font size\",\n hiddenFromList: false,\n },\n baseColor: {\n type: \"color\",\n default: \"#18181b\",\n description: \"Base color\",\n },\n sheenColor: {\n type: \"color\",\n default: \"#4f8ef7\",\n description: \"Sheen color\",\n },\n fontWeight: {\n type: \"enum\",\n default: \"400\",\n variants: {\n \"400\": {},\n \"500\": {},\n \"600\": {},\n \"700\": {},\n },\n description: \"Font weight\",\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 620,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 120,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"text\",\"exitAt\",\"fontSize\",\"baseColor\",\"sheenColor\",\"fontWeight\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n text: \"Introducing\",\n exitAt: 60,\n fontSize: 72,\n baseColor: \"#18181b\",\n sheenColor: \"#4f8ef7\",\n fontWeight: \"400\",\n speed: 1,\n};\n\ntype SheenSlideInElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof SheenSlideInBase>;\n\nconst SheenSlideInInner = forwardRef<\n HTMLDivElement,\n SheenSlideInElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 620, height = 120, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<SheenSlideIn>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <SheenSlideInBase\n {...(componentProps as unknown as ComponentProps<typeof SheenSlideInBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const SheenSlideIn = Interactive.withSchema({\n Component: SheenSlideInInner,\n componentName: \"<SheenSlideIn>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/shimmer-sweep.json b/registry-artifacts/elements/shimmer-sweep.jsonindex b62ccf19..fcc831d6 100644--- a/registry-artifacts/elements/shimmer-sweep.json+++ b/registry-artifacts/elements/shimmer-sweep.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [],"dimensions": {"width": 500,@@ -9,6 +10,7 @@},"displayName": "Shimmer Sweep","durationInFrames": 120,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "shimmer-sweep","sourceCode": "import { Interactive, Sequence, interpolate, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface ShimmerSweepProps {\n text: string;\n baseColor?: string;\n shineColor?: string;\n fontSize?: number;\n fontWeight?: number;\n speed?: number;\n className?: string;\n}\n\nfunction ShimmerSweepBase({\n text,\n baseColor = \"#3f3f46\",\n shineColor = \"#fafafa\",\n fontSize = 96,\n fontWeight = 700,\n speed = 1,\n className,\n}: ShimmerSweepProps) {\n const frame = useCurrentFrame() * speed;\n const { durationInFrames } = useVideoConfig();\n\n const position = interpolate(\n frame,\n [0, durationInFrames * 0.8],\n [200, -100],\n { extrapolateLeft: \"clamp\", extrapolateRight: \"clamp\" },\n );\n\n const textStyle: React.CSSProperties = {\n fontSize,\n fontWeight,\n letterSpacing: \"-0.03em\",\n fontFamily:\n \"var(--font-geist-sans), -apple-system, BlinkMacSystemFont, sans-serif\",\n margin: 0,\n lineHeight: 1,\n };\n\n return (\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n background: \"white\",\n }}\n >\n <div style={{ position: \"relative\", display: \"inline-block\" }}>\n <span style={{ ...textStyle, color: baseColor }}>{text}</span>\n <span\n className={className}\n style={{\n ...textStyle,\n position: \"absolute\",\n inset: 0,\n color: \"transparent\",\n backgroundClip: \"text\",\n WebkitBackgroundClip: \"text\",\n backgroundImage: `linear-gradient(110deg, transparent 30%, ${shineColor} 50%, transparent 70%)`,\n backgroundSize: \"200% 100%\",\n backgroundPosition: `${position}% 50%`,\n }}\n >\n {text}\n </span>\n </div>\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n text: {\n type: \"text-content\",\n default: \"Generating\",\n description: \"Text\",\n },\n baseColor: {\n type: \"color\",\n default: \"#3f3f46\",\n description: \"Base color\",\n },\n shineColor: {\n type: \"color\",\n default: \"#fafafa\",\n description: \"Shine color\",\n },\n fontSize: {\n type: \"number\",\n min: 12,\n max: 200,\n step: 1,\n default: 96,\n description: \"Font size\",\n hiddenFromList: false,\n },\n fontWeight: {\n type: \"enum\",\n default: \"700\",\n variants: {\n \"400\": {},\n \"500\": {},\n \"600\": {},\n \"700\": {},\n },\n description: \"Font weight\",\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 500,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 130,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"text\",\"baseColor\",\"shineColor\",\"fontSize\",\"fontWeight\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n text: \"Generating\",\n baseColor: \"#3f3f46\",\n shineColor: \"#fafafa\",\n fontSize: 96,\n fontWeight: \"700\",\n speed: 1,\n};\n\ntype ShimmerSweepElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof ShimmerSweepBase>;\n\nconst ShimmerSweepInner = forwardRef<\n HTMLDivElement,\n ShimmerSweepElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 500, height = 130, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<ShimmerSweep>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <ShimmerSweepBase\n {...(componentProps as unknown as ComponentProps<typeof ShimmerSweepBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const ShimmerSweep = Interactive.withSchema({\n Component: ShimmerSweepInner,\n componentName: \"<ShimmerSweep>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/short-slide-down.json b/registry-artifacts/elements/short-slide-down.jsonindex 62e8576f..3f27b3ec 100644--- a/registry-artifacts/elements/short-slide-down.json+++ b/registry-artifacts/elements/short-slide-down.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [],"dimensions": {"width": 640,@@ -9,6 +10,7 @@},"displayName": "Short Slide Down","durationInFrames": 60,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "short-slide-down","sourceCode": "import { forwardRef, useImperativeHandle, useMemo, useRef, type ComponentProps } from \"react\";\nimport { Easing, Interactive, Sequence, interpolate, useCurrentFrame, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\n\ninterface ShortSlideDownProps {\n text: string;\n entryOffset?: number;\n fontSize?: number;\n color?: string;\n fontWeight?: number;\n speed?: number;\n className?: string;\n}\n\nconst FONT_FAMILY =\n \"var(--font-geist-sans), -apple-system, BlinkMacSystemFont, sans-serif\";\n\nfunction ShortSlideDownBase({\n text,\n entryOffset = 28,\n fontSize = 72,\n color = \"#171717\",\n fontWeight = 600,\n speed = 1,\n className,\n}: ShortSlideDownProps) {\n const frame = useCurrentFrame() * speed;\n\n const words = useMemo(() => text.split(\" \"), [text]);\n const n = words.length;\n\n const lineGap = 12;\n const rowHeight = fontSize;\n const firstDur = 11;\n const pushDur = 15;\n const travelDur = 8;\n const entryScale = 0.992;\n const entryBlur = 2.4;\n const reflowBlur = 0.7;\n const firstWordY = -14;\n const easing = Easing.bezier(0.2, 0.8, 0.2, 1);\n\n const positionsAt = useMemo(() => {\n const out: number[][] = [];\n for (let k = 1; k <= n; k++) {\n const total = rowHeight * k + lineGap * (k - 1);\n const start = -total / 2 + rowHeight / 2;\n const ys: number[] = [];\n for (let j = 0; j < k; j++) ys.push(start + j * (rowHeight + lineGap));\n out.push(ys);\n }\n return out;\n }, [n, rowHeight]);\n\n return (\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n background: \"transparent\",\n }}\n >\n <div\n className={className}\n style={{\n position: \"relative\",\n fontSize,\n fontWeight,\n color,\n letterSpacing: \"-0.03em\",\n fontFamily: FONT_FAMILY,\n whiteSpace: \"nowrap\",\n }}\n >\n {words.map((word, j) => {\n const entryStart = j === 0 ? 0 : firstDur + (j - 1) * pushDur;\n const entryEnd = entryStart + (j === 0 ? firstDur : pushDur);\n const targetY = positionsAt[j][j];\n const yFrom = j === 0 ? firstWordY : targetY - entryOffset;\n\n let y = targetY;\n let opacity = 1;\n let scale = 1;\n let blur = 0;\n\n if (frame < entryStart) {\n opacity = 0;\n y = yFrom;\n scale = entryScale;\n blur = entryBlur;\n } else if (frame <= entryEnd) {\n const range: [number, number] = [entryStart, entryEnd];\n const travelRange: [number, number] = [\n entryStart,\n Math.min(entryStart + travelDur, entryEnd),\n ];\n const opts = {\n extrapolateLeft: \"clamp\" as const,\n extrapolateRight: \"clamp\" as const,\n easing,\n };\n y = interpolate(frame, travelRange, [yFrom, targetY], opts);\n opacity = interpolate(frame, range, [0, 1], opts);\n scale = interpolate(frame, range, [entryScale, 1], opts);\n blur = interpolate(frame, range, [entryBlur, 0], opts);\n } else {\n for (let w = j + 1; w < n; w++) {\n const pushStart = firstDur + (w - 1) * pushDur;\n const pushEnd = pushStart + pushDur;\n const fromY = positionsAt[w - 1][j];\n const toY = positionsAt[w][j];\n if (frame >= pushEnd) {\n y = toY;\n } else if (frame >= pushStart) {\n y = interpolate(\n frame,\n [pushStart, Math.min(pushStart + travelDur, pushEnd)],\n [fromY, toY],\n {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing,\n },\n );\n blur = interpolate(\n frame,\n [pushStart, (pushStart + pushEnd) / 2, pushEnd],\n [0, reflowBlur, 0],\n { extrapolateLeft: \"clamp\", extrapolateRight: \"clamp\" },\n );\n break;\n } else {\n y = fromY;\n break;\n }\n }\n }\n\n return (\n <span\n key={j}\n style={{\n position: \"absolute\",\n left: \"50%\",\n top: \"50%\",\n whiteSpace: \"nowrap\",\n backfaceVisibility: \"hidden\",\n transform: `translate(-50%, -50%) translate3d(0px, ${y}px, 0) scale(${scale})`,\n filter: `blur(${blur}px)`,\n opacity,\n }}\n >\n {word}\n </span>\n );\n })}\n </div>\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n text: {\n type: \"text-content\",\n default: \"Build from above.\",\n description: \"Text\",\n },\n entryOffset: {\n type: \"number\",\n min: 8,\n max: 80,\n step: 1,\n default: 28,\n description: \"Entry offset\",\n hiddenFromList: false,\n },\n fontSize: {\n type: \"number\",\n min: 12,\n max: 160,\n step: 1,\n default: 72,\n description: \"Font size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n fontWeight: {\n type: \"enum\",\n default: \"600\",\n variants: {\n \"400\": {},\n \"500\": {},\n \"600\": {},\n \"700\": {},\n },\n description: \"Font weight\",\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 640,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 100,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"text\",\"entryOffset\",\"fontSize\",\"color\",\"fontWeight\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n text: \"Build from above.\",\n entryOffset: 28,\n fontSize: 72,\n color: \"#171717\",\n fontWeight: \"600\",\n speed: 1,\n};\n\ntype ShortSlideDownElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof ShortSlideDownBase>;\n\nconst ShortSlideDownInner = forwardRef<\n HTMLDivElement,\n ShortSlideDownElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 640, height = 100, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<ShortSlideDown>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <ShortSlideDownBase\n {...(componentProps as unknown as ComponentProps<typeof ShortSlideDownBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const ShortSlideDown = Interactive.withSchema({\n Component: ShortSlideDownInner,\n componentName: \"<ShortSlideDown>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/short-slide-right.json b/registry-artifacts/elements/short-slide-right.jsonindex 8d74b097..f37ff959 100644--- a/registry-artifacts/elements/short-slide-right.json+++ b/registry-artifacts/elements/short-slide-right.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [],"dimensions": {"width": 640,@@ -9,6 +10,7 @@},"displayName": "Short Slide Right","durationInFrames": 60,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "short-slide-right","sourceCode": "import { Easing, Interactive, Sequence, interpolate, useCurrentFrame, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface ShortSlideRightProps {\n text: string;\n distance?: number;\n staggerDelay?: number;\n fontSize?: number;\n color?: string;\n fontWeight?: number;\n speed?: number;\n className?: string;\n}\n\nfunction ShortSlideRightBase({\n text,\n distance = 24,\n staggerDelay = 3,\n fontSize = 72,\n color = \"#171717\",\n fontWeight = 600,\n speed = 1,\n className,\n}: ShortSlideRightProps) {\n const frame = useCurrentFrame() * speed;\n\n const words = text.split(\" \");\n\n const enterDur = 16;\n const travelDur = 8;\n const wordOpacityDur = 6;\n const easing = Easing.bezier(0.2, 0.8, 0.2, 1);\n\n const x = interpolate(frame, [0, travelDur], [-distance, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing,\n });\n\n const blurVal = interpolate(frame, [0, enterDur], [1.2, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing,\n });\n\n return (\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n background: \"transparent\",\n }}\n >\n <span\n className={className}\n style={{\n fontSize,\n fontWeight,\n color,\n letterSpacing: \"-0.03em\",\n fontFamily:\n \"var(--font-geist-sans), -apple-system, BlinkMacSystemFont, sans-serif\",\n display: \"inline-block\",\n translate: `${x}px`,\n filter: `blur(${blurVal}px)`,\n }}\n >\n {words.map((word, i) => {\n const opacity = interpolate(\n frame - i * staggerDelay,\n [0, wordOpacityDur],\n [0, 1],\n {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing,\n },\n );\n return (\n <span\n key={i}\n style={{\n display: \"inline-block\",\n marginRight: \"0.25em\",\n opacity,\n }}\n >\n {word}\n </span>\n );\n })}\n </span>\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n text: {\n type: \"text-content\",\n default: \"Move with intent.\",\n description: \"Text\",\n },\n distance: {\n type: \"number\",\n min: 0,\n max: 120,\n step: 1,\n default: 24,\n description: \"Distance\",\n hiddenFromList: false,\n },\n staggerDelay: {\n type: \"number\",\n min: 0,\n max: 12,\n step: 1,\n default: 3,\n description: \"Stagger\",\n hiddenFromList: false,\n },\n fontSize: {\n type: \"number\",\n min: 12,\n max: 160,\n step: 1,\n default: 72,\n description: \"Font size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n fontWeight: {\n type: \"enum\",\n default: \"600\",\n variants: {\n \"400\": {},\n \"500\": {},\n \"600\": {},\n \"700\": {},\n },\n description: \"Font weight\",\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 640,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 100,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"text\",\"distance\",\"staggerDelay\",\"fontSize\",\"color\",\"fontWeight\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n text: \"Move with intent.\",\n distance: 24,\n staggerDelay: 3,\n fontSize: 72,\n color: \"#171717\",\n fontWeight: \"600\",\n speed: 1,\n};\n\ntype ShortSlideRightElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof ShortSlideRightBase>;\n\nconst ShortSlideRightInner = forwardRef<\n HTMLDivElement,\n ShortSlideRightElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 640, height = 100, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<ShortSlideRight>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <ShortSlideRightBase\n {...(componentProps as unknown as ComponentProps<typeof ShortSlideRightBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const ShortSlideRight = Interactive.withSchema({\n Component: ShortSlideRightInner,\n componentName: \"<ShortSlideRight>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/simulated-cursor.json b/registry-artifacts/elements/simulated-cursor.jsonindex e6f6ec73..da6acda1 100644--- a/registry-artifacts/elements/simulated-cursor.json+++ b/registry-artifacts/elements/simulated-cursor.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [],"dimensions": {"width": 890,@@ -9,6 +10,7 @@},"displayName": "Simulated Cursor","durationInFrames": 150,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "simulated-cursor","sourceCode": "import { Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface CursorPoint {\n x: number;\n y: number;\n hold?: number;\n click?: boolean;\n}\n\ninterface SimulatedCursorProps {\n points?: CursorPoint[];\n color?: string;\n size?: number;\n speed?: number;\n className?: string;\n}\n\nconst DEFAULT_POINTS: CursorPoint[] = [\n { x: 200, y: 150, hold: 20 },\n { x: 800, y: 360, hold: 25, click: true },\n { x: 1050, y: 560, hold: 20 },\n];\n\nfunction SimulatedCursorBase({\n points = DEFAULT_POINTS,\n color = \"#ffffff\",\n size = 32,\n speed = 1,\n className,\n}: SimulatedCursorProps) {\n const frame = useCurrentFrame() * speed;\n const { fps, durationInFrames } = useVideoConfig();\n\n const travelPerLeg = 24;\n const segments: Array<{\n start: number;\n end: number;\n holdEnd: number;\n from: CursorPoint;\n to: CursorPoint;\n }> = [];\n\n let cursor = 0;\n for (let i = 0; i < points.length - 1; i++) {\n const from = points[i];\n const to = points[i + 1];\n const start = cursor;\n const end = start + travelPerLeg;\n const holdEnd = end + (to.hold ?? 15);\n segments.push({ start, end, holdEnd, from, to });\n cursor = holdEnd;\n }\n\n // Find current segment\n let x = points[0].x;\n let y = points[0].y;\n let activeClickFrame: number | null = null;\n let clickTarget: CursorPoint | null = null;\n\n if (segments.length === 0) {\n x = points[0].x;\n y = points[0].y;\n } else if (frame < segments[0].start + (points[0].hold ?? 0)) {\n x = points[0].x;\n y = points[0].y;\n } else {\n for (const seg of segments) {\n if (frame >= seg.start && frame < seg.holdEnd) {\n if (frame < seg.end) {\n // travelling\n x = interpolate(frame, [seg.start, seg.end], [seg.from.x, seg.to.x], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n });\n y = interpolate(frame, [seg.start, seg.end], [seg.from.y, seg.to.y], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n });\n } else {\n x = seg.to.x;\n y = seg.to.y;\n if (seg.to.click) {\n activeClickFrame = frame - seg.end;\n clickTarget = seg.to;\n }\n }\n break;\n }\n if (frame >= seg.holdEnd) {\n x = seg.to.x;\n y = seg.to.y;\n }\n }\n }\n\n // Click feedback\n let clickScale = 1;\n let rippleRadius = 0;\n let rippleOpacity = 0;\n if (activeClickFrame !== null && clickTarget) {\n const dip = spring({\n fps,\n frame: activeClickFrame,\n config: { damping: 10, stiffness: 200, mass: 0.6 },\n durationInFrames: 14,\n });\n clickScale = 1 - dip * 0.18;\n rippleRadius = interpolate(activeClickFrame, [0, 24], [4, 60], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n });\n rippleOpacity = interpolate(activeClickFrame, [0, 24], [0.6, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n });\n }\n\n // Suppress unused warning when durationInFrames not used directly\n void durationInFrames;\n\n return (\n <div\n className={className}\n style={{\n position: \"absolute\",\n inset: 0,\n overflow: \"hidden\",\n }}\n >\n {/* Click ripple */}\n {rippleOpacity > 0 && (\n <svg\n style={{\n position: \"absolute\",\n left: x - 80,\n top: y - 80,\n width: 160,\n height: 160,\n pointerEvents: \"none\",\n }}\n >\n <circle\n cx={80}\n cy={80}\n r={rippleRadius}\n fill=\"none\"\n stroke={color}\n strokeWidth={2}\n opacity={rippleOpacity}\n />\n </svg>\n )}\n\n {/* Cursor */}\n <div\n style={{\n position: \"absolute\",\n left: x,\n top: y,\n width: size,\n height: size,\n scale: `${clickScale}`,\n transformOrigin: \"top left\",\n zIndex: 2147483647,\n pointerEvents: \"none\",\n willChange: \"transform, left, top\",\n }}\n >\n <svg\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n d=\"M5 3L5 19L9.5 14.5L12.5 21L15 20L12 13.5L18.5 13.5L5 3Z\"\n fill={color}\n stroke=\"#000000\"\n strokeWidth={1.2}\n strokeLinejoin=\"round\"\n />\n </svg>\n </div>\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n color: {\n type: \"color\",\n default: \"#ffffff\",\n description: \"Color\",\n },\n size: {\n type: \"number\",\n min: 12,\n max: 96,\n step: 1,\n default: 32,\n description: \"Size\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 890,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 450,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"color\",\"size\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n color: \"#ffffff\",\n size: 32,\n speed: 1,\n};\n\ntype SimulatedCursorElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof SimulatedCursorBase>;\n\nconst SimulatedCursorInner = forwardRef<\n HTMLDivElement,\n SimulatedCursorElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 890, height = 450, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<SimulatedCursor>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <SimulatedCursorBase\n {...(componentProps as unknown as ComponentProps<typeof SimulatedCursorBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const SimulatedCursor = Interactive.withSchema({\n Component: SimulatedCursorInner,\n componentName: \"<SimulatedCursor>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/slot-machine-roll.json b/registry-artifacts/elements/slot-machine-roll.jsonindex e9ea0a45..e407aebd 100644--- a/registry-artifacts/elements/slot-machine-roll.json+++ b/registry-artifacts/elements/slot-machine-roll.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [],"dimensions": {"width": 190,@@ -9,6 +10,7 @@},"displayName": "Slot Machine Roll","durationInFrames": 90,+ "initialProps": null,"installationMode": "wrapped","slug": "slot-machine-roll","sourceCode": "import { spring, useCurrentFrame, useVideoConfig } from \"remotion\";\n\nexport interface SlotMachineRollProps {\n from?: string;\n to?: string;\n fontSize?: number;\n color?: string;\n fontWeight?: number;\n speed?: number;\n className?: string;\n}\n\nexport function SlotMachineRoll({\n from = \"$99\",\n to = \"$199\",\n fontSize = 120,\n color = \"#171717\",\n fontWeight = 700,\n speed = 1,\n className,\n}: SlotMachineRollProps) {\n const frame = useCurrentFrame() * speed;\n const { fps } = useVideoConfig();\n\n const len = Math.max(from.length, to.length);\n const paddedFrom = from.padStart(len, \" \");\n const paddedTo = to.padStart(len, \" \");\n\n const columns = [];\n for (let i = 0; i < len; i++) {\n const raw = spring({\n frame: frame - i * 4,\n fps,\n config: { damping: 14 },\n });\n const t = Math.max(0, Math.min(1, raw));\n columns.push(\n <span\n key={i}\n style={{\n display: \"inline-block\",\n overflow: \"hidden\",\n height: \"1.1em\",\n lineHeight: \"1.1em\",\n verticalAlign: \"top\",\n width: \"0.7em\",\n textAlign: \"center\",\n }}\n >\n <span\n style={{\n display: \"flex\",\n flexDirection: \"column\",\n translate: `0 ${-t * fontSize * 1.1}px`,\n }}\n >\n <span>{paddedFrom[i]}</span>\n <span>{paddedTo[i]}</span>\n </span>\n </span>,\n );\n }\n\n return (\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n background: \"white\",\n }}\n >\n <span\n className={className}\n style={{\n fontSize,\n fontWeight,\n color,\n letterSpacing: \"-0.03em\",\n fontFamily:\n \"var(--font-geist-sans), -apple-system, BlinkMacSystemFont, sans-serif\",\n lineHeight: 1.1,\n }}\n >\n {columns}\n </span>\n </div>\n );\n}"diff --git a/registry-artifacts/elements/soft-blur-in.json b/registry-artifacts/elements/soft-blur-in.jsonindex 248a08b4..f5a4ef68 100644--- a/registry-artifacts/elements/soft-blur-in.json+++ b/registry-artifacts/elements/soft-blur-in.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [],"dimensions": {"width": 600,@@ -9,6 +10,7 @@},"displayName": "Soft Blur In","durationInFrames": 60,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "soft-blur-in","sourceCode": "import { Easing, Interactive, Sequence, interpolate, useCurrentFrame, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface SoftBlurInProps {\n text: string;\n blur?: number;\n fontSize?: number;\n color?: string;\n fontWeight?: number;\n speed?: number;\n className?: string;\n}\n\nfunction SoftBlurInBase({\n text,\n blur = 12,\n fontSize = 72,\n color = \"#171717\",\n fontWeight = 600,\n speed = 1,\n className,\n}: SoftBlurInProps) {\n const frame = useCurrentFrame() * speed;\n\n const chars = Array.from(text);\n const charDurationFrames = 27;\n const charTravelFrames = 9;\n const staggerFrames = 1;\n\n return (\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n background: \"transparent\",\n }}\n >\n <span\n className={className}\n style={{\n fontSize,\n fontWeight,\n color,\n letterSpacing: \"-0.05em\",\n fontFamily:\n \"var(--font-geist-sans), -apple-system, BlinkMacSystemFont, sans-serif\",\n }}\n >\n {chars.map((char, i) => {\n const local = frame - i * staggerFrames;\n const easing = Easing.bezier(0.22, 1, 0.36, 1);\n const opacity = interpolate(local, [0, charDurationFrames], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing,\n });\n const y = interpolate(local, [0, charTravelFrames], [16, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing,\n });\n const blurAmount = interpolate(\n local,\n [0, charDurationFrames],\n [blur, 0],\n { extrapolateLeft: \"clamp\", extrapolateRight: \"clamp\", easing },\n );\n return (\n <span\n key={i}\n style={{\n display: \"inline-block\",\n whiteSpace: \"pre\",\n backfaceVisibility: \"hidden\",\n transformOrigin: \"50% 55%\",\n opacity,\n translate: `0 ${y}px`,\n filter: `blur(${blurAmount}px)`,\n }}\n >\n {char}\n </span>\n );\n })}\n </span>\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n text: {\n type: \"text-content\",\n default: \"Think different.\",\n description: \"Text\",\n },\n blur: {\n type: \"number\",\n min: 1,\n max: 30,\n step: 1,\n default: 12,\n description: \"Blur\",\n hiddenFromList: false,\n },\n fontSize: {\n type: \"number\",\n min: 12,\n max: 160,\n step: 1,\n default: 72,\n description: \"Font size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n fontWeight: {\n type: \"enum\",\n default: \"600\",\n variants: {\n \"400\": {},\n \"500\": {},\n \"600\": {},\n \"700\": {},\n },\n description: \"Font weight\",\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 600,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 100,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"text\",\"blur\",\"fontSize\",\"color\",\"fontWeight\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n text: \"Think different.\",\n blur: 12,\n fontSize: 72,\n color: \"#171717\",\n fontWeight: \"600\",\n speed: 1,\n};\n\ntype SoftBlurInElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof SoftBlurInBase>;\n\nconst SoftBlurInInner = forwardRef<\n HTMLDivElement,\n SoftBlurInElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 600, height = 100, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<SoftBlurIn>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <SoftBlurInBase\n {...(componentProps as unknown as ComponentProps<typeof SoftBlurInBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const SoftBlurIn = Interactive.withSchema({\n Component: SoftBlurInInner,\n componentName: \"<SoftBlurIn>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/speed-lines.json b/registry-artifacts/elements/speed-lines.jsonindex e246b2b4..75cdec96 100644--- a/registry-artifacts/elements/speed-lines.json+++ b/registry-artifacts/elements/speed-lines.json@@ -2,10 +2,12 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [],"dimensions": null,"displayName": "Speed Lines","durationInFrames": 31,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "speed-lines","sourceCode": "import { forwardRef, useImperativeHandle, useRef, type ComponentProps, type ReactNode } from \"react\";\nimport { Interactive, Sequence, random, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\n\ntype SpeedLinesMode = \"trail\" | \"focus\";\n\ninterface SpeedLinesPoint {\n x: number;\n y: number;\n}\n\ninterface SpeedLinesProps {\n mode?: SpeedLinesMode;\n from?: SpeedLinesPoint;\n to?: SpeedLinesPoint;\n x?: number;\n y?: number;\n count?: number;\n weight?: number;\n spread?: number;\n duration?: number;\n bounce?: number;\n squash?: number;\n color?: string;\n seed?: number;\n delay?: number;\n speed?: number;\n children?: ReactNode;\n className?: string;\n}\n\ntype Paint = \"color\" | \"children\" | \"className\";\ntype Unset = \"to\" | \"children\" | \"className\";\n\ninterface SpeedLinesOptions extends Omit<SpeedLinesProps, Paint> {\n width?: number;\n height?: number;\n fps?: number;\n}\n\ninterface SpeedLinesSegment {\n index: number;\n x1: number;\n y1: number;\n x2: number;\n y2: number;\n length: number;\n}\n\ninterface SpeedLinesStreak extends SpeedLinesSegment {\n offset: number;\n reach: number;\n}\n\ninterface SpeedLinesRay extends SpeedLinesSegment {\n angle: number;\n rest: number;\n inner: number;\n outer: number;\n}\n\ninterface SpeedLinesRayTiming {\n rest: number;\n outer: number;\n start?: number;\n release?: number;\n}\n\nconst speedLinesDefaults: Required<Omit<SpeedLinesProps, Unset>> = {\n mode: \"trail\",\n from: { x: -0.25, y: 0.5 },\n x: 0.5,\n y: 0.5,\n count: 12,\n weight: 2,\n spread: 96,\n duration: 14,\n bounce: 0.5,\n squash: 0.5,\n color: \"#ffffff\",\n seed: 1,\n delay: 0,\n speed: 1,\n};\n\nconst REFERENCE = 720;\nconst LANDING = 0.3;\nconst CARRY = 0.3;\nconst ECHO = 0.2;\nconst SOFTEN = 1.2;\nconst SETTLE = 6;\nconst STRETCH = Math.log(1.3);\nconst SQUASH = Math.log(1.25);\nconst STRETCH_GAIN = 0.007;\nconst SQUASH_GAIN = 0.018;\nconst PROBE = 1e-3;\nconst CENTER = \"translate(-50%, -50%)\";\nconst HOLD = 24;\nconst SPAWN_START = 0.04;\nconst SPAWN_END = 0.8;\nconst LIFE = 0.3;\nconst MIN_LIFE = 3;\nconst DRAW = 0.4;\nconst ERASE = 0.35;\nconst SHUTTER = 1.6;\nconst DRIFT = 0.15;\nconst SETBACK = 0.35;\nconst SLOW = 5;\nconst FAST = 14;\nconst GOLDEN = (Math.sqrt(5) - 1) / 2;\nconst IMPACT = 3;\nconst RUSH_JITTER = 1;\nconst RELAX = 0.12;\nconst RELAX_RATE = 1.5;\nconst RELEASE = 8;\nconst RELEASE_JITTER = 1.5;\nconst RETRACT = 3.5;\nconst FOCUS_END = RELEASE + RELEASE_JITTER + RETRACT;\nconst ANGLE_JITTER = 0.6;\nconst RADIUS_JITTER = 0.6;\nconst MAX_COUNT = 64;\nconst MIN_WEIGHT = 0.5;\nconst MAX_WEIGHT = 12;\nconst MIN_SPREAD = 8;\nconst MAX_SPREAD = 480;\nconst MIN_DURATION = 4;\nconst MAX_DURATION = 120;\n\nconst finite = (value: number | undefined, fallback: number) =>\n typeof value === \"number\" && Number.isFinite(value) ? value : fallback;\nconst clamp = (value: number, min: number, max: number) =>\n Math.min(max, Math.max(min, value));\nconst round = (value: number) => Math.round(value * 100) / 100;\nconst fine = (value: number) => Math.round(value * 10000) / 10000;\nconst fraction = (value: number) => value - Math.floor(value);\nconst modeOf = (value: string | undefined): SpeedLinesMode =>\n value === \"focus\" ? \"focus\" : \"trail\";\nconst travelOf = (value: number | undefined) =>\n clamp(finite(value, speedLinesDefaults.duration), MIN_DURATION, MAX_DURATION);\n\nfunction smoothstep(value: number) {\n const t = clamp(value, 0, 1);\n return t * t * (3 - 2 * t);\n}\n\nfunction easeOut(value: number) {\n const t = clamp(value, 0, 1);\n return 1 - (1 - t) * (1 - t);\n}\n\nfunction pointOf(\n value: SpeedLinesPoint | undefined,\n fallback: SpeedLinesPoint,\n) {\n return { x: finite(value?.x, fallback.x), y: finite(value?.y, fallback.y) };\n}\n\nfunction key(seed: number, index: number, name: string) {\n return random(`speed-lines-${seed}-${index}-${name}`);\n}\n\nfunction settingsOf(options: SpeedLinesOptions) {\n const height = Math.max(1, finite(options.height, 720));\n const x = finite(options.x, speedLinesDefaults.x);\n const y = finite(options.y, speedLinesDefaults.y);\n const count = finite(options.count, speedLinesDefaults.count);\n const weight = finite(options.weight, speedLinesDefaults.weight);\n const spread = finite(options.spread, speedLinesDefaults.spread);\n return {\n mode: modeOf(options.mode),\n width: Math.max(1, finite(options.width, 1280)),\n height,\n fps: Math.max(1, finite(options.fps, 30)),\n unit: height / REFERENCE,\n from: pointOf(options.from, speedLinesDefaults.from),\n to: pointOf(options.to, { x, y }),\n x,\n y,\n count: Math.round(clamp(count, 1, MAX_COUNT)),\n weight: clamp(weight, MIN_WEIGHT, MAX_WEIGHT),\n spread: clamp(spread, MIN_SPREAD, MAX_SPREAD),\n duration: travelOf(options.duration),\n bounce: clamp(finite(options.bounce, speedLinesDefaults.bounce), 0, 1),\n squash: clamp(finite(options.squash, speedLinesDefaults.squash), 0, 1),\n seed: finite(options.seed, speedLinesDefaults.seed),\n delay: Math.max(0, finite(options.delay, speedLinesDefaults.delay)),\n speed: Math.max(0, finite(options.speed, speedLinesDefaults.speed)),\n };\n}\n\ntype Settings = ReturnType<typeof settingsOf>;\n\nfunction directionOf(settings: Settings) {\n const { from, to, width, height } = settings;\n const dx = (to.x - from.x) * width;\n const dy = (to.y - from.y) * height;\n const distance = Math.hypot(dx, dy);\n if (distance < 1e-6) return { dx: 1, dy: 0, distance: 0 };\n return { dx: dx / distance, dy: dy / distance, distance };\n}\n\nfunction along(position: number, size: number, step: number) {\n if (step > 1e-9) return (size - position) / step;\n if (step < -1e-9) return -position / step;\n return Number.POSITIVE_INFINITY;\n}\n\nfunction exitDistance(\n cx: number,\n cy: number,\n cos: number,\n sin: number,\n width: number,\n height: number,\n) {\n const inside = cx >= 0 && cx <= width && cy >= 0 && cy <= height;\n if (!inside) {\n const reachX = Math.max(Math.abs(cx), Math.abs(width - cx));\n const reachY = Math.max(Math.abs(cy), Math.abs(height - cy));\n return Math.hypot(reachX, reachY);\n }\n return Math.min(along(cx, width, cos), along(cy, height, sin));\n}\n\nfunction springOf(bounce: number) {\n const landing = LANDING + CARRY * bounce;\n const kappa = (1 + Math.sqrt(1 - landing)) / 2;\n const gain = 1 / (0.5 - kappa / 3);\n const echo = ECHO * bounce;\n const decrement = -Math.log(echo);\n const damping = echo > 0 ? decrement / Math.hypot(Math.PI, decrement) : 1;\n const natural = 1 / (1 + SOFTEN * bounce);\n const decay = damping * natural;\n return {\n kappa,\n gain,\n contact: gain * (1 - kappa),\n decay,\n ring: natural * Math.sqrt(1 - damping * damping),\n settle: Math.ceil(SETTLE / decay),\n };\n}\n\nfunction easeOf(time: number, travel: number, bounce: number) {\n if (time <= 0) return 0;\n const { kappa, gain, contact, decay, ring, settle } = springOf(bounce);\n if (time < travel) {\n const w = time / travel;\n return gain * ((w * w) / 2 - (kappa * w * w * w) / 3);\n }\n const since = time - travel;\n if (since >= settle) return 1;\n const taper = smoothstep((2 * since) / settle - 1);\n const wave = ring > 1e-9 ? Math.sin(ring * since) / ring : since;\n const envelope = Math.exp(-decay * since) * (1 - taper);\n return 1 + (contact / travel) * wave * envelope;\n}\n\nfunction getSpeedLinesTimeline(options: SpeedLinesOptions = {}) {\n const { mode, duration, bounce } = settingsOf(options);\n if (mode === \"focus\") return { mode, impact: IMPACT, end: FOCUS_END };\n return { mode, impact: duration, end: duration + springOf(bounce).settle };\n}\n\ntype SpeedLinesTimeline = ReturnType<typeof getSpeedLinesTimeline>;\n\nconst speedLinesLength = getSpeedLinesTimeline().end;\n\nfunction getSpeedLinesDuration(options: SpeedLinesOptions = {}) {\n const { delay, speed } = settingsOf(options);\n if (speed === 0) return 1;\n const { end } = getSpeedLinesTimeline(options);\n return Math.max(1, Math.ceil(delay + (end + HOLD) / speed));\n}\n\nfunction getSpeedLinesTime(\n frame: number,\n options: SpeedLinesOptions = {},\n) {\n const { fps, delay, speed } = settingsOf(options);\n const elapsed = Math.max(0, finite(frame, 0) - delay);\n return elapsed * (30 / fps) * speed;\n}\n\nfunction getSpeedLinesEase(\n time: number,\n options: SpeedLinesOptions = {},\n) {\n const { duration, bounce } = settingsOf(options);\n return easeOf(finite(time, 0), duration, bounce);\n}\n\nfunction positionAt(time: number, settings: Settings) {\n const { mode, from, to, width, height, duration, bounce } = settings;\n if (mode === \"focus\") {\n return { x: settings.x * width, y: settings.y * height, progress: 1 };\n }\n const progress = easeOf(time, duration, bounce);\n const startX = from.x * width;\n const startY = from.y * height;\n return {\n x: startX + (to.x * width - startX) * progress,\n y: startY + (to.y * height - startY) * progress,\n progress,\n };\n}\n\nfunction getSpeedLinesPosition(\n time: number,\n options: SpeedLinesOptions = {},\n) {\n const { x, y } = positionAt(finite(time, 0), settingsOf(options));\n return { x, y };\n}\n\nfunction shapeAt(time: number, settings: Settings) {\n const { mode, duration, bounce, squash, unit, speed } = settings;\n if (mode === \"focus\") return { rotation: 0, along: 1, across: 1 };\n const { dx, dy, distance } = directionOf(settings);\n const rotation = (Math.atan2(dy, dx) * 180) / Math.PI;\n if (squash === 0 || distance === 0 || time <= 0) {\n return { rotation, along: 1, across: 1 };\n }\n const span = distance / unit;\n const ahead = easeOf(time + PROBE, duration, bounce);\n const behind = easeOf(time - PROBE, duration, bounce);\n const rate = (Math.abs(ahead - behind) / (2 * PROBE)) * span * speed;\n const landed = time > duration ? easeOf(time, duration, bounce) - 1 : 0;\n const past = Math.max(0, landed) * span;\n const stretch = STRETCH * Math.tanh((squash * STRETCH_GAIN * rate) / STRETCH);\n const compression =\n SQUASH * Math.tanh((squash * SQUASH_GAIN * past) / SQUASH);\n const strain = clamp(stretch - compression, -SQUASH, STRETCH);\n return { rotation, along: Math.exp(strain), across: Math.exp(-strain) };\n}\n\nfunction getSpeedLinesShape(\n time: number,\n options: SpeedLinesOptions = {},\n) {\n return shapeAt(finite(time, 0), settingsOf(options));\n}\n\ntype SpeedLinesShape = ReturnType<typeof getSpeedLinesShape>;\n\nfunction getSpeedLinesVelocity(\n frame: number,\n options: SpeedLinesOptions = {},\n) {\n const settings = settingsOf(options);\n const current = finite(frame, 0);\n const now = positionAt(getSpeedLinesTime(current, options), settings);\n const before = positionAt(getSpeedLinesTime(current - 1, options), settings);\n const scale = settings.fps / 30;\n const x = (now.x - before.x) * scale;\n const y = (now.y - before.y) * scale;\n const { dx, dy } = directionOf(settings);\n return { x, y, forward: x * dx + y * dy };\n}\n\nfunction streakSeeds(settings: Settings) {\n const { seed, count, spread, unit } = settings;\n const band = spread * unit;\n const phase = random(`speed-lines-${seed}-lanes`);\n return Array.from({ length: count }, (_, index) => {\n const jitter = (key(seed, index, \"lane\") - 0.5) / (2 * count);\n const lane = fraction(phase + GOLDEN * index + jitter);\n const slot = (index + key(seed, index, \"spawn\")) / count;\n return {\n index,\n spawn: SPAWN_START + (SPAWN_END - SPAWN_START) * slot,\n offset: band * (lane - 0.5),\n factor: 0.5 + 0.5 * key(seed, index, \"length\"),\n setback: SETBACK * band * key(seed, index, \"setback\"),\n };\n });\n}\n\nfunction getSpeedLinesStreaks(\n frame: number,\n options: SpeedLinesOptions = {},\n): SpeedLinesStreak[] {\n const settings = settingsOf(options);\n if (settings.mode !== \"trail\") return [];\n const time = getSpeedLinesTime(frame, options);\n const { dx, dy, distance } = directionOf(settings);\n if (distance === 0 || time <= 0) return [];\n const { forward } = getSpeedLinesVelocity(frame, options);\n const { unit, duration, bounce, weight } = settings;\n const fast = smoothstep((forward - SLOW * unit) / ((FAST - SLOW) * unit));\n const gate = fast * (1 - smoothstep(time - duration));\n if (gate <= 0) return [];\n const center = positionAt(time, settings);\n const progress = time / duration;\n const life = Math.max(MIN_LIFE, LIFE * duration) / duration;\n const minimum = 0.5 * weight * unit;\n const streaks: SpeedLinesStreak[] = [];\n for (const streak of streakSeeds(settings)) {\n const age = (progress - streak.spawn) / life;\n if (age <= 0 || age >= 1) continue;\n const reach = SHUTTER * streak.factor * forward * gate;\n const drawn = easeOut(age / DRAW);\n const erased = smoothstep((age - ERASE) / (1 - ERASE));\n const length = reach * (drawn - erased);\n if (length < minimum) continue;\n const spawned = easeOf(streak.spawn * duration, duration, bounce);\n const since = Math.max(0, (center.progress - spawned) * distance);\n const base = streak.setback + DRIFT * since;\n const front = base + reach * erased;\n const back = base + reach * drawn;\n const laneX = center.x - dy * streak.offset;\n const laneY = center.y + dx * streak.offset;\n streaks.push({\n index: streak.index,\n offset: streak.offset,\n reach,\n x1: round(laneX - dx * front),\n y1: round(laneY - dy * front),\n x2: round(laneX - dx * back),\n y2: round(laneY - dy * back),\n length,\n });\n }\n return streaks;\n}\n\nfunction getSpeedLinesRadius(time: number, ray: SpeedLinesRayTiming) {\n const { rest, outer, start = 0, release = RELEASE } = ray;\n const t = finite(time, 0);\n if (t <= start) return outer;\n if (t < IMPACT) {\n const q = (t - start) / (IMPACT - start);\n return outer + (rest - outer) * q * q;\n }\n const settle = (at: number) =>\n rest * (1 + RELAX * (1 - Math.exp(-(at - IMPACT) / RELAX_RATE)));\n if (t < release) return settle(t);\n const held = settle(release);\n const q = clamp((t - release) / RETRACT, 0, 1);\n return outer - (outer - held) * (1 - q * q);\n}\n\nfunction getSpeedLinesRays(\n frame: number,\n options: SpeedLinesOptions = {},\n): SpeedLinesRay[] {\n const settings = settingsOf(options);\n if (settings.mode !== \"focus\") return [];\n const time = getSpeedLinesTime(frame, options);\n if (time <= 0 || time >= FOCUS_END) return [];\n const { seed, count, spread, weight, unit, width, height } = settings;\n const cx = settings.x * width;\n const cy = settings.y * height;\n const minimum = 0.5 * weight * unit;\n const rotation = random(`speed-lines-${seed}-rotation`);\n const rays: SpeedLinesRay[] = [];\n for (let index = 0; index < count; index++) {\n const jitter = ANGLE_JITTER * (key(seed, index, \"angle\") - 0.5);\n const angle = 2 * Math.PI * (rotation + (index + jitter) / count);\n const cos = Math.cos(angle);\n const sin = Math.sin(angle);\n const reach = RADIUS_JITTER * key(seed, index, \"radius\");\n const rest = spread * unit * (1 + reach);\n const outer = exitDistance(cx, cy, cos, sin, width, height) + weight * unit;\n const inner = getSpeedLinesRadius(time, {\n rest,\n outer,\n start: RUSH_JITTER * key(seed, index, \"rush\"),\n release: RELEASE + RELEASE_JITTER * key(seed, index, \"release\"),\n });\n const length = outer - inner;\n if (length < minimum) continue;\n rays.push({\n index,\n angle,\n rest,\n inner,\n outer,\n x1: round(cx + cos * inner),\n y1: round(cy + sin * inner),\n x2: round(cx + cos * outer),\n y2: round(cy + sin * outer),\n length,\n });\n }\n return rays;\n}\n\nfunction getSpeedLinesState(\n frame: number,\n options: SpeedLinesOptions = {},\n) {\n const settings = settingsOf(options);\n const time = getSpeedLinesTime(frame, options);\n const point = positionAt(time, settings);\n const shape = shapeAt(time, settings);\n const rotation = round(shape.rotation);\n const scale = `scale(${fine(shape.along)}, ${fine(shape.across)})`;\n const streaks = getSpeedLinesStreaks(frame, options);\n const rays = getSpeedLinesRays(frame, options);\n const path = [...streaks, ...rays]\n .map(({ x1, y1, x2, y2 }) => `M ${x1} ${y1} L ${x2} ${y2}`)\n .join(\" \");\n return {\n mode: settings.mode,\n width: settings.width,\n height: settings.height,\n unit: settings.unit,\n time,\n x: point.x,\n y: point.y,\n left: (point.x / settings.width) * 100,\n top: (point.y / settings.height) * 100,\n radius: (settings.spread * settings.unit) / 2,\n strokeWidth: settings.weight * settings.unit,\n rotation,\n along: shape.along,\n across: shape.across,\n transform:\n shape.along === 1\n ? CENTER\n : `${CENTER} rotate(${rotation}deg) ${scale} rotate(${-rotation}deg)`,\n streaks,\n rays,\n path,\n };\n}\n\ntype SpeedLinesState = ReturnType<typeof getSpeedLinesState>;\n\nfunction SpeedLinesBase({\n mode = speedLinesDefaults.mode,\n from = speedLinesDefaults.from,\n to,\n x = speedLinesDefaults.x,\n y = speedLinesDefaults.y,\n count = speedLinesDefaults.count,\n weight = speedLinesDefaults.weight,\n spread = speedLinesDefaults.spread,\n duration = speedLinesDefaults.duration,\n bounce = speedLinesDefaults.bounce,\n squash = speedLinesDefaults.squash,\n color = speedLinesDefaults.color,\n seed = speedLinesDefaults.seed,\n delay = speedLinesDefaults.delay,\n speed = speedLinesDefaults.speed,\n children,\n className,\n}: SpeedLinesProps) {\n const frame = useCurrentFrame();\n const { width, height, fps } = useVideoConfig();\n const state = getSpeedLinesState(frame, {\n mode,\n from,\n to,\n x,\n y,\n count,\n weight,\n spread,\n duration,\n bounce,\n squash,\n seed,\n delay,\n speed,\n width,\n height,\n fps,\n });\n const fallback = state.mode === \"trail\" && children === undefined;\n const placed = children !== undefined && children !== null;\n\n return (\n <div\n className={className}\n style={{ position: \"absolute\", inset: 0, pointerEvents: \"none\" }}\n >\n <svg\n width=\"100%\"\n height=\"100%\"\n viewBox={`0 0 ${width} ${height}`}\n aria-hidden=\"true\"\n style={{ position: \"absolute\", inset: 0, display: \"block\" }}\n >\n {state.path ? (\n <path\n d={state.path}\n fill=\"none\"\n stroke={color}\n strokeWidth={state.strokeWidth}\n strokeLinecap=\"round\"\n />\n ) : null}\n {fallback ? (\n <ellipse\n cx={state.x}\n cy={state.y}\n rx={state.radius * state.along}\n ry={state.radius * state.across}\n transform={`rotate(${state.rotation} ${state.x} ${state.y})`}\n fill={color}\n />\n ) : null}\n </svg>\n {placed ? (\n <div\n style={{\n position: \"absolute\",\n left: `${state.left}%`,\n top: `${state.top}%`,\n width: \"max-content\",\n transform: state.transform,\n transformOrigin: \"50% 50%\",\n }}\n >\n {children}\n </div>\n ) : null}\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n mode: {\n type: \"enum\",\n default: \"trail\",\n variants: {\n trail: {},\n focus: {},\n },\n description: \"Mode\",\n },\n count: {\n type: \"number\",\n default: 12,\n min: 3,\n max: 32,\n step: 1,\n description: \"Lines\",\n hiddenFromList: false,\n },\n weight: {\n type: \"number\",\n default: 2,\n min: 1,\n max: 8,\n step: 0.5,\n description: \"Stroke weight\",\n hiddenFromList: false,\n },\n spread: {\n type: \"number\",\n default: 96,\n min: 16,\n max: 320,\n step: 4,\n description: \"Spread\",\n hiddenFromList: false,\n },\n duration: {\n type: \"number\",\n default: 14,\n min: 6,\n max: 40,\n step: 1,\n description: \"Travel frames\",\n hiddenFromList: false,\n },\n bounce: {\n type: \"number\",\n default: 0.5,\n min: 0,\n max: 1,\n step: 0.05,\n description: \"Bounce\",\n hiddenFromList: false,\n },\n squash: {\n type: \"number\",\n default: 0.5,\n min: 0,\n max: 1,\n step: 0.05,\n description: \"Squash\",\n hiddenFromList: false,\n },\n x: {\n type: \"number\",\n default: 0.5,\n min: 0,\n max: 1,\n step: 0.01,\n description: \"Point x\",\n hiddenFromList: false,\n },\n y: {\n type: \"number\",\n default: 0.5,\n min: 0,\n max: 1,\n step: 0.01,\n description: \"Point y\",\n hiddenFromList: false,\n },\n delay: {\n type: \"number\",\n default: 0,\n min: 0,\n max: 60,\n step: 1,\n description: \"Delay\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#ffffff\",\n description: \"Line color\",\n },\n seed: {\n type: \"number\",\n default: 1,\n min: 1,\n step: 1,\n description: \"Seed\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"mode\",\"count\",\"weight\",\"spread\",\"duration\",\"bounce\",\"squash\",\"x\",\"y\",\"delay\",\"color\",\"seed\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n mode: \"trail\",\n count: 12,\n weight: 2,\n spread: 96,\n duration: 14,\n bounce: 0.5,\n squash: 0.5,\n x: 0.5,\n y: 0.5,\n delay: 0,\n color: \"#ffffff\",\n seed: 1,\n speed: 1,\n};\n\ntype SpeedLinesElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof SpeedLinesBase>;\n\nconst SpeedLinesInner = forwardRef<\n HTMLDivElement,\n SpeedLinesElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<SpeedLines>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <SpeedLinesBase\n {...(componentProps as unknown as ComponentProps<typeof SpeedLinesBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const SpeedLines = Interactive.withSchema({\n Component: SpeedLinesInner,\n componentName: \"<SpeedLines>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/spring-scale-in.json b/registry-artifacts/elements/spring-scale-in.jsonindex f6c835c8..68642019 100644--- a/registry-artifacts/elements/spring-scale-in.json+++ b/registry-artifacts/elements/spring-scale-in.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [],"dimensions": {"width": 720,@@ -9,6 +10,7 @@},"displayName": "Spring Scale In","durationInFrames": 60,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "spring-scale-in","sourceCode": "import { Easing, Interactive, Sequence, interpolate, useCurrentFrame, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface SpringScaleInProps {\n text: string;\n staggerDelay?: number;\n scaleFrom?: number;\n fontSize?: number;\n color?: string;\n fontWeight?: number;\n speed?: number;\n className?: string;\n}\n\nfunction SpringScaleInBase({\n text,\n staggerDelay = 3,\n scaleFrom = 0.7,\n fontSize = 72,\n color = \"#171717\",\n fontWeight = 600,\n speed = 1,\n className,\n}: SpringScaleInProps) {\n const frame = useCurrentFrame() * speed;\n\n const words = text.split(\" \");\n const wordDurationFrames = 11;\n const easing = Easing.bezier(0.34, 1.56, 0.64, 1);\n\n return (\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n background: \"transparent\",\n }}\n >\n <span\n className={className}\n style={{\n fontSize,\n fontWeight,\n color,\n letterSpacing: \"-0.03em\",\n fontFamily:\n \"var(--font-geist-sans), -apple-system, BlinkMacSystemFont, sans-serif\",\n }}\n >\n {words.map((word, i) => {\n const local = frame - i * staggerDelay;\n const opacity = interpolate(local, [0, wordDurationFrames], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing,\n });\n const scale = interpolate(\n local,\n [0, wordDurationFrames],\n [scaleFrom, 1],\n {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing,\n },\n );\n return (\n <span\n key={i}\n style={{\n display: \"inline-block\",\n marginRight: \"0.25em\",\n transformOrigin: \"50% 50%\",\n opacity,\n scale: `${scale}`,\n }}\n >\n {word}\n </span>\n );\n })}\n </span>\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n text: {\n type: \"text-content\",\n default: \"Fast. Crisp. Fluid.\",\n description: \"Text\",\n },\n staggerDelay: {\n type: \"number\",\n min: 1,\n max: 12,\n step: 1,\n default: 3,\n description: \"Stagger\",\n hiddenFromList: false,\n },\n scaleFrom: {\n type: \"number\",\n min: 0.1,\n max: 1,\n step: 0.05,\n default: 0.7,\n description: \"Scale from\",\n hiddenFromList: false,\n },\n fontSize: {\n type: \"number\",\n min: 12,\n max: 160,\n step: 1,\n default: 72,\n description: \"Font size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n fontWeight: {\n type: \"enum\",\n default: \"600\",\n variants: {\n \"400\": {},\n \"500\": {},\n \"600\": {},\n \"700\": {},\n },\n description: \"Font weight\",\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 720,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 100,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"text\",\"staggerDelay\",\"scaleFrom\",\"fontSize\",\"color\",\"fontWeight\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n text: \"Fast. Crisp. Fluid.\",\n staggerDelay: 3,\n scaleFrom: 0.7,\n fontSize: 72,\n color: \"#171717\",\n fontWeight: \"600\",\n speed: 1,\n};\n\ntype SpringScaleInElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof SpringScaleInBase>;\n\nconst SpringScaleInInner = forwardRef<\n HTMLDivElement,\n SpringScaleInElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 720, height = 100, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<SpringScaleIn>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <SpringScaleInBase\n {...(componentProps as unknown as ComponentProps<typeof SpringScaleInBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const SpringScaleIn = Interactive.withSchema({\n Component: SpringScaleInInner,\n componentName: \"<SpringScaleIn>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/squeeze-in.json b/registry-artifacts/elements/squeeze-in.jsonindex d9b0d792..d5e7c320 100644--- a/registry-artifacts/elements/squeeze-in.json+++ b/registry-artifacts/elements/squeeze-in.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [],"dimensions": {"width": 620,@@ -9,6 +10,7 @@},"displayName": "Squeeze In","durationInFrames": 34,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "squeeze-in","sourceCode": "import { Easing, Interactive, Sequence, interpolate, useCurrentFrame, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface SqueezeInProps {\n text: string;\n fontSize?: number;\n color?: string;\n fontWeight?: number;\n stagger?: number;\n squeeze?: number;\n speed?: number;\n className?: string;\n}\n\nconst SQUEEZE_FRAMES = 16;\n\nfunction squeezeInLength(text: string, stagger = 3): number {\n const chars = Array.from(text);\n if (chars.length === 0) return 0;\n return chars.length * stagger + SQUEEZE_FRAMES;\n}\n\nconst squeezeEasing = Easing.out(Easing.cubic);\n\nfunction SqueezeInBase({\n text,\n fontSize = 72,\n color = \"#171717\",\n fontWeight = 400,\n stagger = 3,\n squeeze = 0.03,\n speed = 1,\n className,\n}: SqueezeInProps) {\n const frame = useCurrentFrame() * speed;\n\n const chars = Array.from(text);\n const lastRevealAt = chars.length * stagger;\n\n const squeezeProgress = interpolate(\n frame,\n [lastRevealAt, lastRevealAt + SQUEEZE_FRAMES],\n [0, 1],\n {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: squeezeEasing,\n },\n );\n\n const gap = squeeze * fontSize * (1 - squeezeProgress);\n const wipe = interpolate(frame, [0, lastRevealAt], [100, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n });\n const anchorX =\n (-squeeze * fontSize * squeezeProgress * (chars.length - 1)) / 2;\n\n return (\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n whiteSpace: \"nowrap\",\n background: \"transparent\",\n }}\n >\n <span\n className={className}\n style={{\n translate: `${anchorX}px 0`,\n clipPath: `inset(-0.2em ${wipe}% -0.25em -0.1em)`,\n fontSize,\n fontWeight,\n color,\n letterSpacing: \"-0.02em\",\n lineHeight: 1.1,\n fontFamily:\n \"var(--font-geist-sans, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif)\",\n }}\n >\n {chars.map((char, j) => (\n <span\n key={j}\n style={{\n display: \"inline-block\",\n whiteSpace: \"pre\",\n marginRight: j < chars.length - 1 ? gap : undefined,\n }}\n >\n {char}\n </span>\n ))}\n </span>\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n text: {\n type: \"text-content\",\n default: \"Remocn\",\n description: \"Text\",\n },\n fontSize: {\n type: \"number\",\n min: 12,\n max: 160,\n step: 1,\n default: 72,\n description: \"Font size\",\n hiddenFromList: false,\n },\n stagger: {\n type: \"number\",\n min: 1,\n max: 8,\n step: 1,\n default: 3,\n description: \"Frames / char\",\n hiddenFromList: false,\n },\n squeeze: {\n type: \"number\",\n min: 0,\n max: 0.2,\n step: 0.01,\n default: 0.03,\n description: \"Extra gap (em)\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n fontWeight: {\n type: \"enum\",\n default: \"400\",\n variants: {\n \"400\": {},\n \"500\": {},\n \"600\": {},\n \"700\": {},\n },\n description: \"Font weight\",\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 620,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 110,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"text\",\"fontSize\",\"stagger\",\"squeeze\",\"color\",\"fontWeight\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n text: \"Remocn\",\n fontSize: 72,\n stagger: 3,\n squeeze: 0.03,\n color: \"#171717\",\n fontWeight: \"400\",\n speed: 1,\n};\n\ntype SqueezeInElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof SqueezeInBase>;\n\nconst SqueezeInInner = forwardRef<\n HTMLDivElement,\n SqueezeInElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 620, height = 110, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<SqueezeIn>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <SqueezeInBase\n {...(componentProps as unknown as ComponentProps<typeof SqueezeInBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const SqueezeIn = Interactive.withSchema({\n Component: SqueezeInInner,\n componentName: \"<SqueezeIn>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/squiggle.json b/registry-artifacts/elements/squiggle.jsonindex 1695424d..3158a67f 100644--- a/registry-artifacts/elements/squiggle.json+++ b/registry-artifacts/elements/squiggle.json@@ -2,10 +2,12 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [],"dimensions": null,"displayName": "Squiggle","durationInFrames": 66,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "squiggle","sourceCode": "import { Interactive, Sequence, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ntype SquiggleShape = \"wave\" | \"zigzag\" | \"loops\" | \"coil\";\ntype SquiggleJoin = \"miter\" | \"round\";\n\ninterface SquiggleProps {\n shape?: SquiggleShape;\n x?: number;\n y?: number;\n length?: number;\n angle?: number;\n amplitude?: number;\n wavelength?: number;\n weight?: number;\n color?: string;\n settle?: number;\n hold?: number;\n erase?: boolean;\n delay?: number;\n speed?: number;\n className?: string;\n}\n\ntype Paint = \"color\" | \"className\";\n\ninterface SquiggleOptions extends Omit<SquiggleProps, Paint> {\n width?: number;\n height?: number;\n fps?: number;\n}\n\ninterface SquigglePoint {\n x: number;\n y: number;\n}\n\ninterface SquiggleCurveInput {\n shape: SquiggleShape;\n length: number;\n wavelength: number;\n amplitude: number;\n phase: number;\n unit?: number;\n}\n\nconst squiggleDefaults: Required<Omit<SquiggleProps, \"className\">> = {\n shape: \"wave\",\n x: 0.375,\n y: 0.5,\n length: 320,\n angle: 0,\n amplitude: 14,\n wavelength: 48,\n weight: 3,\n color: \"#ffffff\",\n settle: 0.5,\n hold: 12,\n erase: true,\n delay: 0,\n speed: 1,\n};\n\ntype SmoothShape = Exclude<SquiggleShape, \"zigzag\">;\n\nconst DRAW = 24;\nconst SETTLE = 36;\nconst ERASE = 18;\nconst SWIM = 1.5;\nconst EXIT_SWIM = 0.5;\nconst TAIL = 14;\nconst REST = 24;\nconst MIN_WAVELENGTH = 8;\nconst LOOP_FLOOR = 3;\nconst MIN_POINTS = 24;\nconst MAX_POINTS = 4000;\nconst EPSILON = 0.01;\nconst SAMPLES: Record<SmoothShape, number> = { wave: 32, loops: 64, coil: 80 };\nconst REACH: Record<SmoothShape, number> = { wave: 0, loops: 2.4, coil: 4.2 };\n\nconst finite = (value: number | undefined, fallback: number) =>\n typeof value === \"number\" && Number.isFinite(value) ? value : fallback;\nconst clamp = (value: number, min: number, max: number) =>\n Math.min(max, Math.max(min, value));\nconst round = (value: number) => Math.round(value * 100) / 100;\nconst rateOf = (speed: number | undefined) =>\n Math.max(0, finite(speed, squiggleDefaults.speed));\nconst shapeOf = (value: string | undefined): SquiggleShape =>\n value === \"zigzag\" || value === \"loops\" || value === \"coil\" ? value : \"wave\";\nconst joinOf = (shape: SquiggleShape): SquiggleJoin =>\n shape === \"zigzag\" ? \"miter\" : \"round\";\nconst easeOutQuart = (t: number) => 1 - (1 - t) ** 4;\nconst easeOutCubic = (t: number) => 1 - (1 - t) ** 3;\nconst easeInOutCubic = (t: number) =>\n t < 0.5 ? 4 * t ** 3 : 1 - (-2 * t + 2) ** 3 / 2;\nconst easeInOutSine = (t: number) => (1 - Math.cos(Math.PI * t)) / 2;\n\nfunction smoothstep(value: number) {\n const t = clamp(value, 0, 1);\n return t * t * (3 - 2 * t);\n}\n\nfunction getSquiggleTimeline(\n options: Pick<SquiggleOptions, \"hold\" | \"erase\"> = {},\n) {\n const hold = Math.max(0, finite(options.hold, squiggleDefaults.hold));\n const erase = options.erase !== false;\n const eraseStart = SETTLE + hold;\n const eraseEnd = eraseStart + ERASE;\n const end = erase ? eraseEnd : SETTLE;\n return {\n draw: DRAW,\n settle: SETTLE,\n hold,\n erase,\n eraseStart,\n eraseEnd,\n end,\n duration: end + (erase ? TAIL : REST),\n };\n}\n\ntype SquiggleTimeline = ReturnType<typeof getSquiggleTimeline>;\n\nconst squiggleLength = getSquiggleTimeline().end;\n\nfunction getSquiggleDuration(\n options: Pick<SquiggleOptions, \"hold\" | \"erase\" | \"speed\" | \"delay\"> = {},\n) {\n const rate = rateOf(options.speed);\n if (rate === 0) return 1;\n const delay = Math.max(0, finite(options.delay, squiggleDefaults.delay));\n const { duration } = getSquiggleTimeline(options);\n return Math.max(1, Math.ceil(delay + duration / rate));\n}\n\nfunction getSquiggleTime(\n frame: number,\n options: Pick<SquiggleOptions, \"fps\" | \"speed\" | \"delay\"> = {},\n) {\n const fps = Math.max(1, finite(options.fps, 30));\n const delay = Math.max(0, finite(options.delay, squiggleDefaults.delay));\n const elapsed = Math.max(0, finite(frame, 0) - delay);\n return (elapsed * 30 * rateOf(options.speed)) / fps;\n}\n\nfunction getSquiggleHead(time: number) {\n if (!(time > 0)) return 0;\n return easeOutQuart(Math.min(1, time / DRAW));\n}\n\nfunction getSquiggleTail(\n time: number,\n timeline: SquiggleTimeline = getSquiggleTimeline(),\n) {\n if (!timeline.erase) return 0;\n const progress = (time - timeline.eraseStart) / ERASE;\n if (!(progress > 0)) return 0;\n return easeInOutCubic(Math.min(1, progress));\n}\n\nfunction getSquiggleCalm(time: number) {\n if (!(time > 0)) return 0;\n return easeInOutSine(Math.min(1, time / SETTLE));\n}\n\nfunction getSquigglePhase(\n time: number,\n timeline: SquiggleTimeline = getSquiggleTimeline(),\n) {\n const swim = time > 0 ? easeOutCubic(Math.min(1, time / SETTLE)) : 0;\n return SWIM * swim + EXIT_SWIM * getSquiggleTail(time, timeline);\n}\n\nfunction getSquiggleEnvelope(\n s: number,\n length: number,\n wavelength: number,\n) {\n const taper = Math.min(wavelength, length / 3);\n if (!(taper > 0)) return 0;\n return smoothstep(s / taper) * smoothstep((length - s) / taper);\n}\n\nfunction getZigzagCurve(\n length: number,\n wavelength: number,\n amplitude: number,\n shift: number,\n) {\n const k = (2 * Math.PI) / wavelength;\n const points: SquigglePoint[] = [{ x: 0, y: 0 }];\n const first = Math.floor(-(Math.PI / 2 + shift) / Math.PI) + 1;\n for (let m = first; points.length < MAX_POINTS - 1; m++) {\n const s = (Math.PI / 2 + m * Math.PI + shift) / k;\n if (s >= length) break;\n if (s <= 0) continue;\n const side = m % 2 === 0 ? 1 : -1;\n const w = getSquiggleEnvelope(s, length, wavelength);\n points.push({ x: s, y: side * amplitude * w });\n }\n points.push({ x: length, y: 0 });\n return points;\n}\n\nfunction getSquiggleCurve(input: SquiggleCurveInput) {\n const shape = shapeOf(input.shape);\n const length = Math.max(0, finite(input.length, 0));\n const wavelength = Math.max(1e-3, finite(input.wavelength, 1));\n const amplitude = Math.max(0, finite(input.amplitude, 0));\n const unit = Math.max(1e-3, finite(input.unit, 1));\n const shift = 2 * Math.PI * finite(input.phase, 0);\n if (shape === \"zigzag\") {\n return getZigzagCurve(length, wavelength, amplitude, shift);\n }\n const k = (2 * Math.PI) / wavelength;\n const gate = smoothstep(amplitude / (LOOP_FLOOR * unit));\n const reach = (REACH[shape] / k) * gate;\n const fine = wavelength / (SAMPLES[shape] * Math.max(1, unit));\n const coarsest = Math.max(length / MIN_POINTS, 1e-6);\n const step = clamp(fine, length / (MAX_POINTS - 2), coarsest);\n const sample = (s: number): SquigglePoint => {\n const w = getSquiggleEnvelope(s, length, wavelength);\n const theta = k * s - shift;\n if (shape === \"wave\") return { x: s, y: amplitude * w * Math.sin(theta) };\n const along = s - reach * w * Math.sin(theta);\n return { x: along, y: -amplitude * w * Math.cos(theta) };\n };\n const offset = (((shift / k) % step) + step) % step;\n const points = [sample(0)];\n for (let j = 0; points.length < MAX_POINTS - 1; j++) {\n const s = offset + j * step;\n if (s >= length) break;\n if (s > 0) points.push(sample(s));\n }\n points.push(sample(length));\n return points;\n}\n\nfunction getSquiggleTrim(\n points: readonly SquigglePoint[],\n tail: number,\n head: number,\n) {\n const lengths = [0];\n for (let i = 1; i < points.length; i++) {\n const a = points[i - 1];\n const b = points[i];\n lengths.push(lengths[i - 1] + Math.hypot(b.x - a.x, b.y - a.y));\n }\n const last = points.length - 1;\n const total = last > 0 ? lengths[last] : 0;\n const from = clamp(finite(tail, 0), 0, 1) * total;\n const to = clamp(finite(head, 0), 0, 1) * total;\n const trimmed: SquigglePoint[] = [];\n if (last < 1 || !(to - from > EPSILON)) return { total, points: trimmed };\n const pointAt = (distance: number, index: number): SquigglePoint => {\n const a = points[index - 1];\n const b = points[index];\n const span = lengths[index] - lengths[index - 1];\n const t = span > 0 ? (distance - lengths[index - 1]) / span : 0;\n return { x: a.x + (b.x - a.x) * t, y: a.y + (b.y - a.y) * t };\n };\n let index = 1;\n while (index < last && lengths[index] < from) index++;\n trimmed.push(pointAt(from, index));\n while (index < last && lengths[index] < to) {\n trimmed.push(points[index]);\n index++;\n }\n trimmed.push(pointAt(to, index));\n return { total, points: trimmed };\n}\n\nfunction getSquigglePath(points: readonly SquigglePoint[]) {\n let path = \"\";\n let previous = \"\";\n for (const point of points) {\n const pair = `${round(point.x)} ${round(point.y)}`;\n if (pair === previous) continue;\n path += `${path === \"\" ? \"M\" : \"L\"}${pair}`;\n previous = pair;\n }\n return path;\n}\n\nfunction getSquiggleState(frame: number, options: SquiggleOptions = {}) {\n const width = Math.max(1, finite(options.width, 1280));\n const height = Math.max(1, finite(options.height, 720));\n const unit = height / 720;\n const shape = shapeOf(options.shape);\n const timeline = getSquiggleTimeline(options);\n const time = getSquiggleTime(frame, options);\n const head = getSquiggleHead(time);\n const tail = getSquiggleTail(time, timeline);\n const phase = getSquigglePhase(time, timeline);\n const settle = clamp(finite(options.settle, squiggleDefaults.settle), 0, 1);\n const lively = finite(options.amplitude, squiggleDefaults.amplitude);\n const calm = 1 - settle * getSquiggleCalm(time);\n const amplitude = Math.max(0, lively) * unit * calm;\n const length = Math.max(0, finite(options.length, squiggleDefaults.length));\n const course = length * unit;\n const cycle = finite(options.wavelength, squiggleDefaults.wavelength);\n const wavelength = Math.max(MIN_WAVELENGTH, cycle) * unit;\n const weight = Math.max(0, finite(options.weight, squiggleDefaults.weight));\n const angle = finite(options.angle, squiggleDefaults.angle);\n const radians = (angle * Math.PI) / 180;\n const cos = Math.cos(radians);\n const sin = Math.sin(radians);\n const start = {\n x: finite(options.x, squiggleDefaults.x) * width,\n y: finite(options.y, squiggleDefaults.y) * height,\n };\n const end = { x: start.x + course * cos, y: start.y + course * sin };\n const drawn = head - tail > 0;\n const curve: SquigglePoint[] = drawn\n ? getSquiggleCurve({\n shape,\n length: course,\n wavelength,\n amplitude,\n phase,\n unit,\n })\n : [];\n const placed = curve.map((point) => ({\n x: start.x + point.x * cos - point.y * sin,\n y: start.y + point.x * sin + point.y * cos,\n }));\n const trim = getSquiggleTrim(placed, tail, head);\n const path = getSquigglePath(trim.points);\n return {\n width,\n height,\n unit,\n shape,\n time,\n timeline,\n head,\n tail,\n phase,\n amplitude,\n wavelength,\n length: course,\n strokeWidth: round(weight * unit),\n join: joinOf(shape),\n start,\n end,\n total: trim.total,\n points: trim.points,\n path,\n visible: path.includes(\"L\"),\n };\n}\n\ntype SquiggleState = ReturnType<typeof getSquiggleState>;\n\nfunction SquiggleBase({\n shape = squiggleDefaults.shape,\n x = squiggleDefaults.x,\n y = squiggleDefaults.y,\n length = squiggleDefaults.length,\n angle = squiggleDefaults.angle,\n amplitude = squiggleDefaults.amplitude,\n wavelength = squiggleDefaults.wavelength,\n weight = squiggleDefaults.weight,\n color = squiggleDefaults.color,\n settle = squiggleDefaults.settle,\n hold = squiggleDefaults.hold,\n erase = squiggleDefaults.erase,\n delay = squiggleDefaults.delay,\n speed = squiggleDefaults.speed,\n className,\n}: SquiggleProps) {\n const frame = useCurrentFrame();\n const { width, height, fps } = useVideoConfig();\n const state = getSquiggleState(frame, {\n shape,\n x,\n y,\n length,\n angle,\n amplitude,\n wavelength,\n weight,\n settle,\n hold,\n erase,\n delay,\n speed,\n width,\n height,\n fps,\n });\n\n return (\n <div\n className={className}\n style={{ position: \"absolute\", inset: 0, pointerEvents: \"none\" }}\n >\n <svg\n width=\"100%\"\n height=\"100%\"\n viewBox={`0 0 ${width} ${height}`}\n role=\"img\"\n aria-label=\"SquiggleBase line\"\n style={{ display: \"block\" }}\n >\n {state.visible ? (\n <path\n d={state.path}\n fill=\"none\"\n stroke={color}\n strokeWidth={state.strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin={state.join}\n />\n ) : null}\n </svg>\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n shape: {\n type: \"enum\",\n default: \"wave\",\n variants: {\n wave: {},\n zigzag: {},\n loops: {},\n coil: {},\n },\n description: \"Shape\",\n },\n color: {\n type: \"color\",\n default: \"#ffffff\",\n description: \"Line color\",\n },\n weight: {\n type: \"number\",\n default: 3,\n min: 1,\n max: 12,\n step: 0.5,\n description: \"Stroke weight\",\n hiddenFromList: false,\n },\n amplitude: {\n type: \"number\",\n default: 14,\n min: 0,\n max: 60,\n step: 1,\n description: \"Amplitude\",\n hiddenFromList: false,\n },\n wavelength: {\n type: \"number\",\n default: 48,\n min: 12,\n max: 160,\n step: 2,\n description: \"Wavelength\",\n hiddenFromList: false,\n },\n length: {\n type: \"number\",\n default: 320,\n min: 40,\n max: 1200,\n step: 10,\n description: \"Length\",\n hiddenFromList: false,\n },\n angle: {\n type: \"number\",\n default: 0,\n min: -180,\n max: 180,\n step: 5,\n description: \"Angle\",\n hiddenFromList: false,\n },\n x: {\n type: \"number\",\n default: 0.375,\n min: 0,\n max: 1,\n step: 0.005,\n description: \"Start x\",\n hiddenFromList: false,\n },\n y: {\n type: \"number\",\n default: 0.5,\n min: 0,\n max: 1,\n step: 0.005,\n description: \"Start y\",\n hiddenFromList: false,\n },\n settle: {\n type: \"number\",\n default: 0.5,\n min: 0,\n max: 1,\n step: 0.05,\n description: \"Settle\",\n hiddenFromList: false,\n },\n hold: {\n type: \"number\",\n default: 12,\n min: 0,\n max: 90,\n step: 1,\n description: \"Hold\",\n hiddenFromList: false,\n },\n erase: {\n type: \"boolean\",\n default: true,\n description: \"Erase\",\n },\n delay: {\n type: \"number\",\n default: 0,\n min: 0,\n max: 60,\n step: 1,\n description: \"Delay\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"shape\",\"color\",\"weight\",\"amplitude\",\"wavelength\",\"length\",\"angle\",\"x\",\"y\",\"settle\",\"hold\",\"erase\",\"delay\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n shape: \"wave\",\n color: \"#ffffff\",\n weight: 3,\n amplitude: 14,\n wavelength: 48,\n length: 320,\n angle: 0,\n x: 0.375,\n y: 0.5,\n settle: 0.5,\n hold: 12,\n erase: true,\n delay: 0,\n speed: 1,\n};\n\ntype SquiggleElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof SquiggleBase>;\n\nconst SquiggleInner = forwardRef<\n HTMLDivElement,\n SquiggleElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<Squiggle>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <SquiggleBase\n {...(componentProps as unknown as ComponentProps<typeof SquiggleBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const Squiggle = Interactive.withSchema({\n Component: SquiggleInner,\n componentName: \"<Squiggle>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/staggered-fade-up.json b/registry-artifacts/elements/staggered-fade-up.jsonindex a57e39ef..410da5cd 100644--- a/registry-artifacts/elements/staggered-fade-up.json+++ b/registry-artifacts/elements/staggered-fade-up.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [],"dimensions": {"width": 870,@@ -9,6 +10,7 @@},"displayName": "Staggered Fade Up","durationInFrames": 90,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "staggered-fade-up","sourceCode": "import { Interactive, Sequence, interpolate, useCurrentFrame, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface StaggeredFadeUpProps {\n text: string;\n staggerDelay?: number;\n distance?: number;\n fontSize?: number;\n color?: string;\n fontWeight?: number;\n speed?: number;\n className?: string;\n}\n\nfunction StaggeredFadeUpBase({\n text,\n staggerDelay = 4,\n distance = 20,\n fontSize = 72,\n color = \"#171717\",\n fontWeight = 600,\n speed = 1,\n className,\n}: StaggeredFadeUpProps) {\n const frame = useCurrentFrame() * speed;\n\n const words = text.split(\" \");\n\n return (\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n background: \"white\",\n }}\n >\n <span\n className={className}\n style={{\n fontSize,\n fontWeight,\n color,\n letterSpacing: \"-0.03em\",\n fontFamily:\n \"var(--font-geist-sans), -apple-system, BlinkMacSystemFont, sans-serif\",\n }}\n >\n {words.map((word, i) => {\n const local = frame - i * staggerDelay;\n const opacity = interpolate(local, [0, 12], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n });\n const y = interpolate(local, [0, 12], [distance, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n });\n return (\n <span\n key={i}\n style={{\n display: \"inline-block\",\n marginRight: \"0.25em\",\n opacity,\n translate: `0 ${y}px`,\n }}\n >\n {word}\n </span>\n );\n })}\n </span>\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n text: {\n type: \"text-content\",\n default: \"Ship faster with remocn\",\n description: \"Text\",\n },\n staggerDelay: {\n type: \"number\",\n min: 0,\n max: 30,\n step: 1,\n default: 4,\n description: \"Stagger delay\",\n hiddenFromList: false,\n },\n distance: {\n type: \"number\",\n min: 0,\n max: 120,\n step: 1,\n default: 20,\n description: \"Distance\",\n hiddenFromList: false,\n },\n fontSize: {\n type: \"number\",\n min: 12,\n max: 160,\n step: 1,\n default: 72,\n description: \"Font size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n fontWeight: {\n type: \"enum\",\n default: \"600\",\n variants: {\n \"400\": {},\n \"500\": {},\n \"600\": {},\n \"700\": {},\n },\n description: \"Font weight\",\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 870,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 100,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"text\",\"staggerDelay\",\"distance\",\"fontSize\",\"color\",\"fontWeight\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n text: \"Ship faster with remocn\",\n staggerDelay: 4,\n distance: 20,\n fontSize: 72,\n color: \"#171717\",\n fontWeight: \"600\",\n speed: 1,\n};\n\ntype StaggeredFadeUpElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof StaggeredFadeUpBase>;\n\nconst StaggeredFadeUpInner = forwardRef<\n HTMLDivElement,\n StaggeredFadeUpElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 870, height = 100, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<StaggeredFadeUp>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <StaggeredFadeUpBase\n {...(componentProps as unknown as ComponentProps<typeof StaggeredFadeUpBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const StaggeredFadeUp = Interactive.withSchema({\n Component: StaggeredFadeUpInner,\n componentName: \"<StaggeredFadeUp>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/stretch-in.json b/registry-artifacts/elements/stretch-in.jsonindex 44f51e3e..f3ead59a 100644--- a/registry-artifacts/elements/stretch-in.json+++ b/registry-artifacts/elements/stretch-in.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "opentype.js",@@ -11,6 +12,7 @@"dimensions": null,"displayName": "Stretch In","durationInFrames": 48,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "stretch-in","sourceCode": "import { parse, type Font } from \"opentype.js\";\nimport { forwardRef, useEffect, useImperativeHandle, useMemo, useRef, useState, type ComponentProps } from \"react\";\nimport { Easing, Interactive, Sequence, continueRender, delayRender, interpolate, useCurrentFrame, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\n\ninterface StretchInProps {\n className?: string;\n width?: number;\n height?: number;\n text?: string;\n fontUrl?: string;\n fontSize?: number;\n letterSpacing?: number;\n baselineY?: number;\n entryStart?: number;\n entryStagger?: number;\n travelFrames?: number;\n travelDistance?: number;\n vertexLagFrames?: number;\n curveSteps?: number;\n fill?: string;\n strokeWidth?: number;\n stroke?: string;\n}\n\ntype Contour = [number, number][];\n\nfunction flattenPath(\n commands: ReturnType<Font[\"getPath\"]>[\"commands\"],\n steps: number,\n): Contour[] {\n const contours: Contour[] = [];\n let current: Contour = [];\n let cx = 0;\n let cy = 0;\n\n for (const cmd of commands) {\n if (cmd.type === \"M\") {\n if (current.length > 0) contours.push(current);\n current = [[cmd.x, cmd.y]];\n cx = cmd.x;\n cy = cmd.y;\n } else if (cmd.type === \"L\") {\n current.push([cmd.x, cmd.y]);\n cx = cmd.x;\n cy = cmd.y;\n } else if (cmd.type === \"Q\") {\n for (let i = 1; i <= steps; i++) {\n const t = i / steps;\n const mt = 1 - t;\n current.push([\n mt * mt * cx + 2 * mt * t * cmd.x1 + t * t * cmd.x,\n mt * mt * cy + 2 * mt * t * cmd.y1 + t * t * cmd.y,\n ]);\n }\n cx = cmd.x;\n cy = cmd.y;\n } else if (cmd.type === \"C\") {\n for (let i = 1; i <= steps; i++) {\n const t = i / steps;\n const mt = 1 - t;\n current.push([\n mt * mt * mt * cx +\n 3 * mt * mt * t * cmd.x1 +\n 3 * mt * t * t * cmd.x2 +\n t * t * t * cmd.x,\n mt * mt * mt * cy +\n 3 * mt * mt * t * cmd.y1 +\n 3 * mt * t * t * cmd.y2 +\n t * t * t * cmd.y,\n ]);\n }\n cx = cmd.x;\n cy = cmd.y;\n } else if (cmd.type === \"Z\") {\n if (current.length > 0) contours.push(current);\n current = [];\n }\n }\n if (current.length > 0) contours.push(current);\n return contours;\n}\n\nfunction StretchInBase({\n className,\n width = 1920,\n height = 1080,\n text = \"REMOCN\",\n fontUrl = \"https://fonts.gstatic.com/s/anton/v27/1Ptgg87LROyAm0K0.ttf\",\n fontSize = 510,\n letterSpacing = 0,\n baselineY,\n entryStart = 0,\n entryStagger = 3,\n travelFrames = 33,\n travelDistance = 1500,\n vertexLagFrames = 3.5,\n curveSteps = 8,\n fill = \"#ffffff\",\n strokeWidth = 0,\n stroke = \"#ffffff\",\n}: StretchInProps) {\n const frame = useCurrentFrame();\n const [font, setFont] = useState<Font | null>(null);\n\n useEffect(() => {\n const handle = delayRender(\"stretch-in: loading font\");\n let cancelled = false;\n fetch(fontUrl)\n .then((res) => res.arrayBuffer())\n .then((buffer) => {\n if (!cancelled) setFont(parse(buffer));\n continueRender(handle);\n })\n .catch(() => {\n continueRender(handle);\n });\n return () => {\n cancelled = true;\n };\n }, [fontUrl]);\n\n const letters = useMemo(() => {\n if (!font) return null;\n const scale = fontSize / font.unitsPerEm;\n const glyphs = font.stringToGlyphs(text);\n let x = 0;\n const items = glyphs.map((glyph, i) => {\n if (i > 0) x += font.getKerningValue(glyphs[i - 1], glyph) * scale;\n const left = x;\n const advance = (glyph.advanceWidth ?? 0) * scale;\n const contours = flattenPath(\n glyph.getPath(x, 0, fontSize).commands,\n curveSteps,\n );\n x += advance + letterSpacing;\n return { left, width: advance, contours };\n });\n return { items, totalWidth: Math.max(0, x - letterSpacing) };\n }, [font, text, fontSize, letterSpacing, curveSteps]);\n\n if (!letters) return null;\n\n const startX = (width - letters.totalWidth) / 2;\n const resolvedBaseline = baselineY ?? (height + fontSize * 0.72) / 2;\n\n return (\n <div\n className={className}\n style={{ position: \"absolute\", inset: 0, overflow: \"hidden\" }}\n >\n <svg\n width=\"100%\"\n height=\"100%\"\n viewBox={`0 0 ${width} ${height}`}\n preserveAspectRatio=\"xMidYMid meet\"\n style={{ display: \"block\" }}\n >\n {letters.items.map((glyph, i) => {\n const entry = entryStart + entryStagger * i;\n const run = Math.max(1, travelFrames - vertexLagFrames);\n\n const d = glyph.contours\n .map((contour) => {\n const pts = contour.map(([px, py]) => {\n const u =\n glyph.width === 0\n ? 0\n : Math.min(1, Math.max(0, (px - glyph.left) / glyph.width));\n const start = entry + u * vertexLagFrames;\n const remaining = interpolate(\n frame,\n [start, start + run],\n [1, 0],\n {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: Easing.bezier(0.2, 0.9, 0.25, 1),\n },\n );\n return [\n startX + px + travelDistance * remaining,\n resolvedBaseline + py,\n ];\n });\n return (\n `M${pts[0][0].toFixed(2)},${pts[0][1].toFixed(2)}` +\n pts\n .slice(1)\n .map((p) => `L${p[0].toFixed(2)},${p[1].toFixed(2)}`)\n .join(\"\") +\n \"Z\"\n );\n })\n .join(\" \");\n\n return (\n <path\n key={`${i}-${glyph.left}`}\n d={d}\n fill={fill}\n fillRule=\"evenodd\"\n stroke={strokeWidth > 0 ? stroke : \"none\"}\n strokeWidth={strokeWidth}\n />\n );\n })}\n </svg>\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n text: {\n type: \"text-content\",\n default: \"REMOCN\",\n description: \"Text\",\n },\n fill: {\n type: \"color\",\n default: \"#ffffff\",\n description: \"Fill\",\n },\n fontSize: {\n type: \"number\",\n min: 100,\n max: 700,\n step: 10,\n default: 510,\n description: \"Font size\",\n hiddenFromList: false,\n },\n entryStagger: {\n type: \"number\",\n min: 0,\n max: 12,\n step: 1,\n default: 3,\n description: \"Letter stagger\",\n hiddenFromList: false,\n },\n travelFrames: {\n type: \"number\",\n min: 4,\n max: 40,\n step: 1,\n default: 33,\n description: \"Travel (frames)\",\n hiddenFromList: false,\n },\n vertexLagFrames: {\n type: \"number\",\n min: 0,\n max: 8,\n step: 0.5,\n default: 3.5,\n description: \"Smear lag (frames)\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"text\",\"fill\",\"fontSize\",\"entryStagger\",\"travelFrames\",\"vertexLagFrames\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n text: \"REMOCN\",\n fill: \"#ffffff\",\n fontSize: 510,\n entryStagger: 3,\n travelFrames: 33,\n vertexLagFrames: 3.5,\n speed: 1,\n};\n\ntype StretchInElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof StretchInBase>;\n\nconst StretchInInner = forwardRef<\n HTMLDivElement,\n StretchInElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<StretchIn>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <StretchInBase\n {...(componentProps as unknown as ComponentProps<typeof StretchInBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const StretchIn = Interactive.withSchema({\n Component: StretchInInner,\n componentName: \"<StretchIn>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/strikethrough-replace.json b/registry-artifacts/elements/strikethrough-replace.jsonindex 89a3737e..c688dfaf 100644--- a/registry-artifacts/elements/strikethrough-replace.json+++ b/registry-artifacts/elements/strikethrough-replace.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [],"dimensions": {"width": 300,@@ -9,6 +10,7 @@},"displayName": "Strikethrough Replace","durationInFrames": 120,+ "initialProps": null,"installationMode": "wrapped","slug": "strikethrough-replace","sourceCode": "import { interpolate, useCurrentFrame, useVideoConfig } from \"remotion\";\n\nexport interface StrikethroughReplaceProps {\n from: string;\n to: string;\n lineColor?: string;\n fontSize?: number;\n color?: string;\n fontWeight?: number;\n speed?: number;\n className?: string;\n}\n\nexport function StrikethroughReplace({\n from,\n to,\n lineColor = \"#ff5e3a\",\n fontSize = 48,\n color = \"#171717\",\n fontWeight = 600,\n speed = 1,\n className,\n}: StrikethroughReplaceProps) {\n const frame = useCurrentFrame() * speed;\n const { durationInFrames } = useVideoConfig();\n\n // Phases:\n // 0 .. 40% -> draw strikethrough across `from`\n // 40% .. 60% -> fade out `from`, fade in `to`\n // 60% .. 100% -> hold\n const strikeEnd = durationInFrames * 0.4;\n const fadeStart = durationInFrames * 0.4;\n const fadeEnd = durationInFrames * 0.6;\n\n const linePct = interpolate(frame, [0, strikeEnd], [0, 100], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n });\n\n const fromOpacity = interpolate(frame, [fadeStart, fadeEnd], [1, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n });\n\n const toOpacity = interpolate(frame, [fadeStart, fadeEnd], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n });\n const toY = interpolate(frame, [fadeStart, fadeEnd], [8, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n });\n\n const textStyle: React.CSSProperties = {\n fontSize,\n fontWeight,\n color,\n letterSpacing: \"-0.03em\",\n fontFamily:\n \"var(--font-geist-sans), -apple-system, BlinkMacSystemFont, sans-serif\",\n whiteSpace: \"nowrap\",\n };\n\n return (\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n background: \"white\",\n }}\n >\n <div\n style={{\n position: \"relative\",\n display: \"inline-flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n {/* from text with strikethrough line */}\n <span\n className={className}\n style={{\n ...textStyle,\n position: \"absolute\",\n opacity: fromOpacity,\n }}\n >\n {from}\n <span\n aria-hidden\n style={{\n position: \"absolute\",\n left: 0,\n top: \"50%\",\n height: Math.max(2, Math.round(fontSize * 0.08)),\n width: `${linePct}%`,\n background: lineColor,\n translate: \"0 -50%\",\n borderRadius: 2,\n }}\n />\n </span>\n\n {/* to text */}\n <span\n className={className}\n style={{\n ...textStyle,\n opacity: toOpacity,\n translate: `0 ${toY}px`,\n }}\n >\n {to}\n </span>\n </div>\n </div>\n );\n}"diff --git a/registry-artifacts/elements/stripe-type.json b/registry-artifacts/elements/stripe-type.jsonindex eb8820ad..04f466a0 100644--- a/registry-artifacts/elements/stripe-type.json+++ b/registry-artifacts/elements/stripe-type.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/google-fonts",@@ -11,6 +12,7 @@"dimensions": null,"displayName": "Stripe Type","durationInFrames": 30,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "stripe-type","sourceCode": "import { loadFont } from \"@remotion/google-fonts/Inter\";\nimport { forwardRef, useEffect, useImperativeHandle, useRef, useState, type ComponentProps } from \"react\";\nimport { Easing, Interactive, Sequence, continueRender, delayRender, interpolate, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\n\nconst { fontFamily: INTER } = loadFont(\"normal\", {\n weights: [\"100\", \"900\"],\n subsets: [\"latin\"],\n});\n\ntype StripeTypeSettle = \"striped\" | \"solid\";\n\ninterface StripeTypeProps {\n text?: string;\n fontSize?: number;\n fontWeight?: number;\n fontFamily?: string;\n color?: string;\n stripes?: number;\n gap?: number;\n settle?: StripeTypeSettle;\n exit?: boolean;\n hold?: number;\n speed?: number;\n className?: string;\n}\n\nconst stripeTypeDefaults = {\n text: \"Launch\",\n fontSize: 180,\n fontWeight: 800,\n fontFamily: INTER,\n color: \"#fafafa\",\n stripes: 8,\n gap: 0.35,\n settle: \"striped\",\n exit: true,\n hold: 30,\n speed: 1,\n} satisfies Required<Omit<StripeTypeProps, \"className\">>;\n\n/** Beats on the 30 fps clock. */\nconst stripeTypeTiming = {\n stagger: 2,\n travel: 16,\n close: 10,\n /** Frames of empty screen after the exit in the preview. */\n tail: 10,\n} as const;\n\n/** Ink box of Inter in a `line-height: 1` box, in em from the top, until measured. */\nconst INTER_INK = { top: 0.136, bottom: 0.864 + 0.24 };\nconst MEASURE_SIZE = 100;\n\nconst CLAMP = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n} as const;\n\n// Expo-shaped curves that land exactly on 0 and 1 (Easing.exp stops 2⁻¹⁰ short).\nconst easeOutExpo = Easing.bezier(0.16, 1, 0.3, 1);\nconst easeInExpo = Easing.bezier(0.7, 0, 0.84, 0);\nconst easeInOutCubic = Easing.inOut(Easing.cubic);\n\nfunction finite(value: number | undefined, fallback: number) {\n return typeof value === \"number\" && Number.isFinite(value) ? value : fallback;\n}\n\n/** Maps a composition frame onto the 30 fps timeline, scaled by `speed`. */\nfunction getStripeTypeTime(\n frame: number,\n options: { fps?: number; speed?: number } = {},\n) {\n const fps = Math.max(1, finite(options.fps, 30));\n const speed = Math.max(0, finite(options.speed, 1));\n return (Math.max(0, finite(frame, 0)) * 30 * speed) / fps;\n}\n\nfunction stripeCount(stripes: number | undefined) {\n return Math.max(1, Math.round(finite(stripes, stripeTypeDefaults.stripes)));\n}\n\ninterface StripeBand {\n /** Top of the band as a share of the ink box height. */\n top: number;\n /** Bottom of the band as a share of the ink box height. */\n bottom: number;\n}\n\n/**\n * Bands over the ink box. With `n` bands and gap share `g` the pitch is\n * `1 / (n − g)`: the first band starts at the top, the last ends at the\n * bottom.\n */\nfunction getStripeBands(stripes: number, gap: number): StripeBand[] {\n const n = stripeCount(stripes);\n const g = Math.min(0.95, Math.max(0, finite(gap, 0)));\n const pitch = 1 / (n - g);\n return Array.from({ length: n }, (_, k) => ({\n top: k * pitch,\n bottom: k * pitch + pitch * (1 - g),\n }));\n}\n\ninterface StripeTypeTimeline {\n /** Frame where the last band has locked. */\n entered: number;\n /** Frame where the gaps have closed (equals `entered` when striped). */\n settled: number;\n exitStart: number;\n exitEnd: number;\n /** Frames the preview needs. */\n duration: number;\n}\n\nfunction getStripeTypeTimeline(\n options: Pick<StripeTypeProps, \"stripes\" | \"settle\" | \"exit\" | \"hold\"> = {},\n): StripeTypeTimeline {\n const n = stripeCount(options.stripes);\n const { stagger, travel, close, tail } = stripeTypeTiming;\n const entered = stagger * (n - 1) + travel;\n const settled = options.settle === \"solid\" ? entered + close : entered;\n const hold = Math.max(0, finite(options.hold, stripeTypeDefaults.hold));\n const exitStart = settled + hold;\n const exitEnd = exitStart + stagger * (n - 1) + travel;\n const exit = options.exit !== false;\n return {\n entered,\n settled,\n exitStart,\n exitEnd,\n duration: exit ? exitEnd + tail : settled + hold,\n };\n}\n\n/** Preview length for the given options and speed. */\nfunction getStripeTypeDuration(\n options: Pick<\n StripeTypeProps,\n \"stripes\" | \"settle\" | \"exit\" | \"hold\" | \"speed\"\n > = {},\n) {\n const speed = finite(options.speed, 1);\n if (speed <= 0) return 1;\n return Math.ceil(getStripeTypeTimeline(options).duration / speed);\n}\n\n/**\n * Horizontal offset of band `k` as a share of its travel distance: −1 or 1\n * off the frame, 0 locked. Even bands enter from the left, odd from the right,\n * and on the exit each band passes on through the other side.\n */\nfunction getStripeBandOffset(\n t: number,\n k: number,\n options: Pick<StripeTypeProps, \"stripes\" | \"settle\" | \"exit\" | \"hold\"> = {},\n) {\n const { stagger, travel } = stripeTypeTiming;\n const timeline = getStripeTypeTimeline(options);\n const side = k % 2 === 0 ? -1 : 1;\n const inStart = stagger * k;\n const enter = interpolate(t, [inStart, inStart + travel], [1, 0], {\n ...CLAMP,\n easing: easeOutExpo,\n });\n // `|| 0` folds −0 into 0 for a locked band.\n if (options.exit === false) return side * enter || 0;\n const outStart = timeline.exitStart + stagger * k;\n const leave = interpolate(t, [outStart, outStart + travel], [0, 1], {\n ...CLAMP,\n easing: easeInExpo,\n });\n return side * enter - side * leave || 0;\n}\n\n/** Gap share over time: the set gap, closing to 0 when `settle` is solid. */\nfunction getStripeGap(\n t: number,\n gap: number,\n options: Pick<StripeTypeProps, \"stripes\" | \"settle\"> = {},\n) {\n if (options.settle !== \"solid\") return gap;\n const { entered, settled } = getStripeTypeTimeline(options);\n return interpolate(t, [entered, settled], [gap, 0], {\n ...CLAMP,\n easing: easeInOutCubic,\n });\n}\n\n/** Ink box of the word in its `line-height: 1` box, and its width, in em. */\nfunction useInkBox(text: string, font: string) {\n const [ink, setInk] = useState<{\n top: number;\n bottom: number;\n width: number;\n } | null>(null);\n\n useEffect(() => {\n const handle = delayRender(\"stripe-type: measuring the word\");\n let released = false;\n const release = () => {\n if (released) return;\n released = true;\n continueRender(handle);\n };\n const measure = () => {\n if (released) return;\n const ctx = document.createElement(\"canvas\").getContext(\"2d\");\n if (ctx) {\n ctx.font = font;\n const m = ctx.measureText(text);\n const ascent = m.fontBoundingBoxAscent / MEASURE_SIZE;\n const descent = m.fontBoundingBoxDescent / MEASURE_SIZE;\n const baseline = (1 - (ascent + descent)) / 2 + ascent;\n if (ascent > 0) {\n setInk({\n top: baseline - m.actualBoundingBoxAscent / MEASURE_SIZE,\n bottom: baseline + m.actualBoundingBoxDescent / MEASURE_SIZE,\n width: m.width / MEASURE_SIZE,\n });\n }\n }\n release();\n };\n document.fonts.load(font, text).then(measure, measure);\n return release;\n }, [text, font]);\n\n return ink;\n}\n\nfunction StripeTypeBase({\n text = stripeTypeDefaults.text,\n fontSize = stripeTypeDefaults.fontSize,\n fontWeight = stripeTypeDefaults.fontWeight,\n fontFamily = stripeTypeDefaults.fontFamily,\n color = stripeTypeDefaults.color,\n stripes = stripeTypeDefaults.stripes,\n gap = stripeTypeDefaults.gap,\n settle = stripeTypeDefaults.settle,\n exit = stripeTypeDefaults.exit,\n hold = stripeTypeDefaults.hold,\n speed = stripeTypeDefaults.speed,\n className,\n}: StripeTypeProps) {\n const frame = useCurrentFrame();\n const { fps, width, height } = useVideoConfig();\n const unit = height / 720;\n const size = fontSize * unit;\n const t = getStripeTypeTime(frame, { fps, speed });\n const measured = useInkBox(\n text,\n `${fontWeight} ${MEASURE_SIZE}px ${fontFamily}`,\n );\n const ink = measured ?? {\n ...INTER_INK,\n width: 0.6 * Array.from(text).length,\n };\n const options = { stripes, settle, exit, hold };\n const bands = getStripeBands(stripes, getStripeGap(t, gap, options));\n const inkHeight = ink.bottom - ink.top;\n // Far enough that a band starting on either side is fully off the frame.\n const travel = (width + ink.width * size) / 2 + 0.2 * size;\n\n const type = {\n fontFamily,\n fontSize: size,\n lineHeight: 1,\n fontWeight,\n fontVariationSettings: `\"wght\" ${fontWeight}`,\n color,\n whiteSpace: \"pre\",\n } as const;\n\n return (\n <div\n className={className}\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n overflow: \"hidden\",\n }}\n >\n <div style={{ position: \"relative\" }}>\n <div aria-hidden style={{ ...type, visibility: \"hidden\" }}>\n {text}\n </div>\n {bands.map((band, k) => {\n const top = (ink.top + band.top * inkHeight) * 100;\n // Each band reaches a pixel into the next gap, so closed gaps leave\n // no antialiased seam between bands.\n const bleed = k < bands.length - 1 ? Math.max(1, unit) / size : 0;\n const bottom =\n (1 - (ink.top + band.bottom * inkHeight) - bleed) * 100;\n const offset = getStripeBandOffset(t, k, options);\n return (\n <div\n key={k}\n aria-hidden={k > 0}\n style={{\n ...type,\n position: \"absolute\",\n inset: 0,\n clipPath: `inset(${top}% -1% ${bottom}% -1%)`,\n transform: `translateX(${offset * travel}px)`,\n }}\n >\n {text}\n </div>\n );\n })}\n </div>\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n text: {\n type: \"text-content\",\n default: \"Launch\",\n description: \"Text\",\n },\n color: {\n type: \"color\",\n default: \"#fafafa\",\n description: \"Text color\",\n },\n settle: {\n type: \"enum\",\n default: \"striped\",\n variants: {\n striped: {},\n solid: {},\n },\n description: \"Settle\",\n },\n fontSize: {\n type: \"number\",\n default: 180,\n min: 60,\n max: 320,\n step: 2,\n description: \"Font size\",\n hiddenFromList: false,\n },\n fontWeight: {\n type: \"number\",\n default: 800,\n min: 100,\n max: 900,\n step: 50,\n description: \"Weight\",\n hiddenFromList: false,\n },\n stripes: {\n type: \"number\",\n default: 8,\n min: 2,\n max: 16,\n step: 1,\n description: \"Stripes\",\n hiddenFromList: false,\n },\n gap: {\n type: \"number\",\n default: 0.35,\n min: 0,\n max: 0.8,\n step: 0.05,\n description: \"Gap\",\n hiddenFromList: false,\n },\n hold: {\n type: \"number\",\n default: 30,\n min: 0,\n max: 120,\n step: 5,\n description: \"Hold\",\n hiddenFromList: false,\n },\n exit: {\n type: \"boolean\",\n default: true,\n description: \"Exit\",\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"text\",\"color\",\"settle\",\"fontSize\",\"fontWeight\",\"stripes\",\"gap\",\"hold\",\"exit\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n text: \"Launch\",\n color: \"#fafafa\",\n settle: \"striped\",\n fontSize: 180,\n fontWeight: 800,\n stripes: 8,\n gap: 0.35,\n hold: 30,\n exit: true,\n speed: 1,\n};\n\ntype StripeTypeElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof StripeTypeBase>;\n\nconst StripeTypeInner = forwardRef<\n HTMLDivElement,\n StripeTypeElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<StripeType>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <StripeTypeBase\n {...(componentProps as unknown as ComponentProps<typeof StripeTypeBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const StripeType = Interactive.withSchema({\n Component: StripeTypeInner,\n componentName: \"<StripeType>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/sustained-glitch.json b/registry-artifacts/elements/sustained-glitch.jsonindex 35fe3d48..52352c89 100644--- a/registry-artifacts/elements/sustained-glitch.json+++ b/registry-artifacts/elements/sustained-glitch.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/transitions",@@ -11,6 +12,7 @@"dimensions": null,"displayName": "Sustained Glitch","durationInFrames": 120,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "sustained-glitch","sourceCode": "import { AbsoluteFill, Interactive, Sequence, isHtmlInCanvasSupported, random, useCurrentFrame, useDelayRender, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport React, { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\nimport { type TransitionPresentation, type TransitionPresentationComponentProps } from \"@remotion/transitions\";\n\nconst QUAD = new Float32Array([-1, -1, 1, -1, -1, 1, 1, 1]);\n\nconst VERTEX_SHADER = `#version 300 es\nin vec2 a_pos;\nout vec2 v_uv;\nvoid main() {\n v_uv = vec2(a_pos.x * 0.5 + 0.5, 0.5 - a_pos.y * 0.5);\n gl_Position = vec4(a_pos, 0.0, 1.0);\n}`;\n\nconst LAYER: React.CSSProperties = {\n position: \"absolute\",\n inset: 0,\n width: \"100%\",\n height: \"100%\",\n};\n\nconst OUTPUT_LAYER: React.CSSProperties = { ...LAYER, pointerEvents: \"none\" };\n\nconst isCanvasTransitionSupported = (): boolean =>\n isHtmlInCanvasSupported();\n\nconst isCanvasFilterSupported = (): boolean => isHtmlInCanvasSupported();\n\ntype SceneShaderFrame<Props> = {\n gl: WebGL2RenderingContext;\n uniform: (name: string) => WebGLUniformLocation | null;\n width: number;\n height: number;\n progress: number;\n passedProps: Props;\n};\n\ntype SceneShaderDrawParams<Props> = {\n from: OffscreenCanvas | null;\n to: OffscreenCanvas | null;\n width: number;\n height: number;\n progress: number;\n passedProps: Props;\n};\n\ntype SceneShaderInstance<Props> = {\n draw: (params: SceneShaderDrawParams<Props>) => void;\n clear: () => void;\n cleanup: () => void;\n};\n\ntype SceneShader<Props> = (\n canvas: OffscreenCanvas,\n) => SceneShaderInstance<Props>;\n\ntype SceneFilterFrame<Props> = {\n gl: WebGL2RenderingContext;\n uniform: (name: string) => WebGLUniformLocation | null;\n width: number;\n height: number;\n frame: number;\n time: number;\n passedProps: Props;\n};\n\ntype SceneFilterDrawParams<Props> = {\n scene: OffscreenCanvas | null;\n width: number;\n height: number;\n frame: number;\n time: number;\n passedProps: Props;\n};\n\ntype SceneFilterInstance<Props> = {\n draw: (params: SceneFilterDrawParams<Props>) => void;\n clear: () => void;\n cleanup: () => void;\n};\n\ntype SceneFilter<Props> = (\n canvas: OffscreenCanvas,\n) => SceneFilterInstance<Props>;\n\nfunction compileShader(\n gl: WebGL2RenderingContext,\n source: string,\n type: GLenum,\n): WebGLShader {\n const shader = gl.createShader(type);\n if (!shader) {\n throw new Error(\"canvas-presentation: failed to create shader\");\n }\n gl.shaderSource(shader, source);\n gl.compileShader(shader);\n if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {\n const log = gl.getShaderInfoLog(shader);\n gl.deleteShader(shader);\n throw new Error(`canvas-presentation: failed to compile shader: ${log}`);\n }\n return shader;\n}\n\nfunction createProgram(\n gl: WebGL2RenderingContext,\n fragment: string,\n): WebGLProgram {\n const program = gl.createProgram();\n if (!program) {\n throw new Error(\"canvas-presentation: failed to create program\");\n }\n const vs = compileShader(gl, VERTEX_SHADER, gl.VERTEX_SHADER);\n const fs = compileShader(gl, fragment, gl.FRAGMENT_SHADER);\n gl.attachShader(program, vs);\n gl.attachShader(program, fs);\n gl.linkProgram(program);\n gl.deleteShader(vs);\n gl.deleteShader(fs);\n if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {\n const log = gl.getProgramInfoLog(program);\n gl.deleteProgram(program);\n throw new Error(`canvas-presentation: failed to link program: ${log}`);\n }\n return program;\n}\n\nfunction createSceneTexture(gl: WebGL2RenderingContext): WebGLTexture {\n const texture = gl.createTexture();\n if (!texture) {\n throw new Error(\"canvas-presentation: failed to create texture\");\n }\n gl.bindTexture(gl.TEXTURE_2D, texture);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);\n gl.texImage2D(\n gl.TEXTURE_2D,\n 0,\n gl.RGBA,\n 1,\n 1,\n 0,\n gl.RGBA,\n gl.UNSIGNED_BYTE,\n new Uint8Array([0, 0, 0, 0]),\n );\n return texture;\n}\n\nfunction createQuadSurface(canvas: OffscreenCanvas, fragment: string) {\n const gl = canvas.getContext(\"webgl2\", { premultipliedAlpha: true });\n if (!gl) {\n throw new Error(\"canvas-presentation: WebGL2 is unavailable\");\n }\n\n const program = createProgram(gl, fragment);\n const vao = gl.createVertexArray();\n gl.bindVertexArray(vao);\n const buffer = gl.createBuffer();\n gl.bindBuffer(gl.ARRAY_BUFFER, buffer);\n gl.bufferData(gl.ARRAY_BUFFER, QUAD, gl.STATIC_DRAW);\n const aPos = gl.getAttribLocation(program, \"a_pos\");\n gl.enableVertexAttribArray(aPos);\n gl.vertexAttribPointer(aPos, 2, gl.FLOAT, false, 0, 0);\n\n const locations = new Map<string, WebGLUniformLocation | null>();\n const uniform = (name: string) => {\n const cached = locations.get(name);\n if (cached !== undefined) {\n return cached;\n }\n const location = gl.getUniformLocation(program, name);\n locations.set(name, location);\n return location;\n };\n\n const clear = () => {\n gl.clearColor(0, 0, 0, 0);\n gl.clear(gl.COLOR_BUFFER_BIT);\n };\n\n const textures: WebGLTexture[] = [];\n const createTexture = () => {\n const texture = createSceneTexture(gl);\n textures.push(texture);\n return texture;\n };\n\n const begin = (width: number, height: number) => {\n gl.viewport(0, 0, width, height);\n clear();\n gl.useProgram(program);\n gl.bindVertexArray(vao);\n };\n\n const bindScene = (\n image: OffscreenCanvas | null,\n texture: WebGLTexture,\n unit: number,\n name: string,\n ) => {\n gl.activeTexture(gl.TEXTURE0 + unit);\n gl.bindTexture(gl.TEXTURE_2D, texture);\n if (image) {\n gl.texImage2D(\n gl.TEXTURE_2D,\n 0,\n gl.RGBA,\n gl.RGBA,\n gl.UNSIGNED_BYTE,\n image,\n );\n }\n gl.uniform1i(uniform(name), unit);\n };\n\n const draw = () => gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);\n\n const cleanup = () => {\n gl.deleteProgram(program);\n for (const texture of textures) {\n gl.deleteTexture(texture);\n }\n gl.deleteBuffer(buffer);\n gl.deleteVertexArray(vao);\n };\n\n return {\n gl,\n uniform,\n clear,\n createTexture,\n begin,\n bindScene,\n draw,\n cleanup,\n };\n}\n\nfunction makeSceneShader<Props extends Record<string, unknown>>(\n fragment: string,\n setUniforms?: (frame: SceneShaderFrame<Props>) => void,\n): SceneShader<Props> {\n return (canvas) => {\n const surface = createQuadSurface(canvas, fragment);\n const fromTexture = surface.createTexture();\n const toTexture = surface.createTexture();\n\n return {\n clear: surface.clear,\n cleanup: surface.cleanup,\n draw: ({ from, to, width, height, progress, passedProps }) => {\n surface.begin(width, height);\n surface.bindScene(from, fromTexture, 0, \"u_from\");\n surface.bindScene(to, toTexture, 1, \"u_to\");\n\n surface.gl.uniform1f(surface.uniform(\"u_progress\"), progress);\n surface.gl.uniform1f(surface.uniform(\"u_aspect\"), width / height);\n setUniforms?.({\n gl: surface.gl,\n uniform: surface.uniform,\n width,\n height,\n progress,\n passedProps,\n });\n\n surface.draw();\n },\n };\n };\n}\n\nfunction makeFilterShader<Props extends Record<string, unknown>>(\n fragment: string,\n setUniforms?: (frame: SceneFilterFrame<Props>) => void,\n): SceneFilter<Props> {\n return (canvas) => {\n const surface = createQuadSurface(canvas, fragment);\n const sceneTexture = surface.createTexture();\n\n return {\n clear: surface.clear,\n cleanup: surface.cleanup,\n draw: ({ scene, width, height, frame, time, passedProps }) => {\n surface.begin(width, height);\n surface.bindScene(scene, sceneTexture, 0, \"u_scene\");\n\n surface.gl.uniform1f(surface.uniform(\"u_frame\"), frame);\n surface.gl.uniform1f(surface.uniform(\"u_time\"), time);\n surface.gl.uniform1f(surface.uniform(\"u_aspect\"), width / height);\n setUniforms?.({\n gl: surface.gl,\n uniform: surface.uniform,\n width,\n height,\n frame,\n time,\n passedProps,\n });\n\n surface.draw();\n },\n };\n };\n}\n\nconst transferred = new WeakMap<HTMLCanvasElement, OffscreenCanvas>();\n\nfunction takeOffscreen(canvas: HTMLCanvasElement): OffscreenCanvas {\n const existing = transferred.get(canvas);\n if (existing) {\n return existing;\n }\n const created = canvas.transferControlToOffscreen();\n transferred.set(canvas, created);\n return created;\n}\n\nfunction makeCanvasComponent<Props extends Record<string, unknown>>(\n shader: SceneShader<Props>,\n): React.FC<TransitionPresentationComponentProps<Props>> {\n return function CanvasScenePresentation({\n children,\n presentationProgress,\n presentationDirection,\n passedProps,\n onElementImage,\n onUnmount,\n bothEnteringAndExiting,\n }) {\n const layoutRef = React.useRef<HTMLCanvasElement | null>(null);\n const outputRef = React.useRef<HTMLCanvasElement | null>(null);\n const captureRef = React.useRef<OffscreenCanvas | null>(null);\n const captureContextRef =\n React.useRef<OffscreenCanvasRenderingContext2D | null>(null);\n const outputSurfaceRef = React.useRef<OffscreenCanvas | null>(null);\n const instanceRef = React.useRef<SceneShaderInstance<Props> | null>(null);\n const passedPropsRef = React.useRef(passedProps);\n passedPropsRef.current = passedProps;\n const onElementImageRef = React.useRef(onElementImage);\n onElementImageRef.current = onElementImage;\n const onUnmountRef = React.useRef(onUnmount);\n onUnmountRef.current = onUnmount;\n\n const { delayRender, continueRender } = useDelayRender();\n const passThrough =\n bothEnteringAndExiting && presentationDirection === \"exiting\";\n\n const drawRef = React.useRef<\n (\n prevImage: OffscreenCanvas | null,\n nextImage: OffscreenCanvas | null,\n progress: number,\n ) => void\n >(() => undefined);\n drawRef.current = (prevImage, nextImage, progress) => {\n const instance = instanceRef.current;\n if (!instance) {\n return;\n }\n const handle = delayRender(\"canvas-presentation: paint\");\n const to = prevImage;\n const from = nextImage;\n const width = from?.width ?? to?.width ?? 0;\n const height = from?.height ?? to?.height ?? 0;\n if (width === 0 || height === 0) {\n instance.clear();\n continueRender(handle);\n return;\n }\n instance.draw({\n from,\n to,\n width,\n height,\n progress: !to ? 0 : !from ? 1 : progress,\n passedProps: passedPropsRef.current,\n });\n continueRender(handle);\n };\n\n const draw = React.useCallback(\n (\n prevImage: OffscreenCanvas | null,\n nextImage: OffscreenCanvas | null,\n progress: number,\n ) => drawRef.current(prevImage, nextImage, progress),\n [],\n );\n\n React.useLayoutEffect(() => {\n if (passThrough) {\n return;\n }\n const layout = layoutRef.current;\n const output = outputRef.current;\n if (!layout || !output) {\n return;\n }\n const capture = takeOffscreen(layout);\n const context = capture.getContext(\"2d\");\n if (!context) {\n throw new Error(\"canvas-presentation: failed to acquire a 2D context\");\n }\n const surface = takeOffscreen(output);\n captureRef.current = capture;\n captureContextRef.current = context;\n outputSurfaceRef.current = surface;\n instanceRef.current = shader(surface);\n\n return () => {\n instanceRef.current?.cleanup();\n instanceRef.current = null;\n captureRef.current = null;\n captureContextRef.current = null;\n outputSurfaceRef.current = null;\n };\n }, [passThrough, shader]);\n\n React.useLayoutEffect(() => {\n if (passThrough) {\n return;\n }\n const layout = layoutRef.current;\n if (!layout) {\n return;\n }\n layout.layoutSubtree = true;\n const handlePaint = () => {\n const scene = layout.firstElementChild;\n const capture = captureRef.current;\n const context = captureContextRef.current;\n if (!scene || !capture || !context) {\n return;\n }\n const elementImage = layout.captureElementImage(scene);\n try {\n context.reset();\n context.drawElementImage(elementImage, 0, 0);\n } finally {\n elementImage.close();\n }\n onElementImageRef.current(capture, draw);\n };\n layout.addEventListener(\"paint\", handlePaint);\n return () => layout.removeEventListener(\"paint\", handlePaint);\n }, [passThrough, draw]);\n\n React.useLayoutEffect(() => {\n if (passThrough) {\n return;\n }\n const layout = layoutRef.current;\n if (!layout) {\n return;\n }\n const observer = new ResizeObserver(([entry]) => {\n const capture = captureRef.current;\n const surface = outputSurfaceRef.current;\n if (!capture || !surface) {\n return;\n }\n const width = entry.devicePixelContentBoxSize[0].inlineSize;\n const height = entry.devicePixelContentBoxSize[0].blockSize;\n capture.width = width;\n capture.height = height;\n surface.width = width;\n surface.height = height;\n layout.requestPaint?.();\n });\n observer.observe(layout, { box: \"device-pixel-content-box\" });\n return () => observer.disconnect();\n }, [passThrough]);\n\n // biome-ignore lint/correctness/useExhaustiveDependencies: presentationProgress is the intentional trigger — a new progress value is what schedules the next paint\n React.useLayoutEffect(() => {\n if (passThrough) {\n return;\n }\n layoutRef.current?.requestPaint?.();\n }, [passThrough, presentationProgress]);\n\n React.useLayoutEffect(() => {\n if (passThrough) {\n return;\n }\n return () => onUnmountRef.current();\n }, [passThrough]);\n\n if (passThrough) {\n return <>{children}</>;\n }\n\n return (\n <AbsoluteFill>\n <canvas ref={layoutRef} style={LAYER}>\n {children}\n </canvas>\n <canvas ref={outputRef} style={OUTPUT_LAYER} />\n </AbsoluteFill>\n );\n };\n}\n\ntype CanvasFilterProps = {\n children: React.ReactNode;\n};\n\nfunction makeFilterComponent<Props extends Record<string, unknown>>(\n shader: SceneFilter<Props>,\n): React.FC<Props & CanvasFilterProps> {\n return function CanvasSceneFilter(props) {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const { delayRender, continueRender } = useDelayRender();\n\n const layoutRef = React.useRef<HTMLCanvasElement | null>(null);\n const outputRef = React.useRef<HTMLCanvasElement | null>(null);\n const captureRef = React.useRef<OffscreenCanvas | null>(null);\n const captureContextRef =\n React.useRef<OffscreenCanvasRenderingContext2D | null>(null);\n const outputSurfaceRef = React.useRef<OffscreenCanvas | null>(null);\n const instanceRef = React.useRef<SceneFilterInstance<Props> | null>(null);\n\n const passedPropsRef = React.useRef(props);\n passedPropsRef.current = props;\n const frameRef = React.useRef(frame);\n frameRef.current = frame;\n const timeRef = React.useRef(frame / fps);\n timeRef.current = frame / fps;\n\n React.useLayoutEffect(() => {\n const layout = layoutRef.current;\n const output = outputRef.current;\n if (!layout || !output) {\n return;\n }\n const capture = takeOffscreen(layout);\n const context = capture.getContext(\"2d\");\n if (!context) {\n throw new Error(\"canvas-presentation: failed to acquire a 2D context\");\n }\n const surface = takeOffscreen(output);\n captureRef.current = capture;\n captureContextRef.current = context;\n outputSurfaceRef.current = surface;\n instanceRef.current = shader(surface);\n\n return () => {\n instanceRef.current?.cleanup();\n instanceRef.current = null;\n captureRef.current = null;\n captureContextRef.current = null;\n outputSurfaceRef.current = null;\n };\n }, [shader]);\n\n React.useLayoutEffect(() => {\n const layout = layoutRef.current;\n if (!layout) {\n return;\n }\n layout.layoutSubtree = true;\n const handlePaint = () => {\n const scene = layout.firstElementChild;\n const capture = captureRef.current;\n const context = captureContextRef.current;\n const instance = instanceRef.current;\n if (!scene || !capture || !context || !instance) {\n return;\n }\n const elementImage = layout.captureElementImage(scene);\n try {\n context.reset();\n context.drawElementImage(elementImage, 0, 0);\n } finally {\n elementImage.close();\n }\n if (capture.width === 0 || capture.height === 0) {\n instance.clear();\n return;\n }\n instance.draw({\n scene: capture,\n width: capture.width,\n height: capture.height,\n frame: frameRef.current,\n time: timeRef.current,\n passedProps: passedPropsRef.current,\n });\n };\n layout.addEventListener(\"paint\", handlePaint);\n return () => layout.removeEventListener(\"paint\", handlePaint);\n }, []);\n\n React.useLayoutEffect(() => {\n const layout = layoutRef.current;\n if (!layout) {\n return;\n }\n const observer = new ResizeObserver(([entry]) => {\n const capture = captureRef.current;\n const surface = outputSurfaceRef.current;\n if (!capture || !surface) {\n return;\n }\n const width = entry.devicePixelContentBoxSize[0].inlineSize;\n const height = entry.devicePixelContentBoxSize[0].blockSize;\n capture.width = width;\n capture.height = height;\n surface.width = width;\n surface.height = height;\n layout.requestPaint?.();\n });\n observer.observe(layout, { box: \"device-pixel-content-box\" });\n return () => observer.disconnect();\n }, []);\n\n React.useLayoutEffect(() => {\n const layout = layoutRef.current;\n if (!layout) {\n return;\n }\n const handle = delayRender(\"canvas-presentation: filter paint\");\n const settle = () => continueRender(handle);\n layout.addEventListener(\"paint\", settle, { once: true });\n layout.requestPaint?.();\n return () => {\n layout.removeEventListener(\"paint\", settle);\n continueRender(handle);\n };\n });\n\n return (\n <AbsoluteFill>\n <canvas ref={layoutRef} style={LAYER}>\n {props.children}\n </canvas>\n <canvas ref={outputRef} style={OUTPUT_LAYER} />\n </AbsoluteFill>\n );\n };\n}\n\ntype CanvasPresentationOptions<Props extends Record<string, unknown>> = {\n shader: SceneShader<Props>;\n fallback: React.FC<TransitionPresentationComponentProps<Props>>;\n};\n\nfunction makeCanvasPresentation<Props extends Record<string, unknown>>({\n shader,\n fallback: Fallback,\n}: CanvasPresentationOptions<Props>): (\n props: Props,\n) => TransitionPresentation<Props> {\n const Canvas = makeCanvasComponent(shader);\n\n const Presentation: React.FC<TransitionPresentationComponentProps<Props>> = (\n props,\n ) =>\n isCanvasTransitionSupported() ? (\n <Canvas {...props} />\n ) : (\n <Fallback {...props} />\n );\n\n return (props) => ({ component: Presentation, props });\n}\n\ntype CanvasFilterOptions<Props extends Record<string, unknown>> = {\n shader: SceneFilter<Props>;\n fallback: React.FC<Props & CanvasFilterProps>;\n};\n\nfunction makeCanvasFilter<Props extends Record<string, unknown>>({\n shader,\n fallback: Fallback,\n}: CanvasFilterOptions<Props>): React.FC<Props & CanvasFilterProps> {\n const Canvas = makeFilterComponent(shader);\n\n return function CanvasFilter(props) {\n return isCanvasFilterSupported() ? (\n <Canvas {...props} />\n ) : (\n <Fallback {...props} />\n );\n };\n}\n\ntype SustainedGlitchProps = {\n intensity?: number;\n frequency?: number;\n slices?: number;\n seed?: number;\n};\n\nconst DEFAULTS = {\n intensity: 1,\n frequency: 1,\n slices: 24,\n seed: 1,\n};\n\nconst FRAGMENT_SHADER = `#version 300 es\nprecision highp float;\n\nuniform sampler2D u_scene;\nuniform float u_frame;\nuniform float u_intensity;\nuniform float u_frequency;\nuniform float u_slices;\nuniform float u_seed;\n\nin vec2 v_uv;\nout vec4 outColor;\n\nconst float BLOCK_COLUMNS = 16.0;\n\nfloat hash(vec2 p) {\n return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453123);\n}\n\nvec4 sampleSplit(vec2 uv, float split) {\n vec4 center = texture(u_scene, uv);\n float r = texture(u_scene, fract(vec2(uv.x + split, uv.y))).r;\n float b = texture(u_scene, fract(vec2(uv.x - split, uv.y))).b;\n return vec4(r, center.g, b, center.a);\n}\n\nvoid main() {\n float slotLength = max(30.0 / max(u_frequency, 0.1), 4.0);\n float slot = floor(u_frame / slotLength);\n float local = u_frame - slot * slotLength;\n\n float burstLength = 2.0 + floor(hash(vec2(slot, u_seed + 2.0)) * 4.0);\n float start =\n floor(hash(vec2(slot, u_seed + 1.0)) * max(slotLength - burstLength, 1.0));\n float fires = step(0.25, hash(vec2(slot, u_seed + 3.0)));\n\n float age = local - start;\n float live = fires * step(0.0, age) * step(age, burstLength - 1.0);\n float energy =\n max(u_intensity, 0.0) * live * (1.0 - age / burstLength);\n\n if (energy <= 0.0) {\n outColor = texture(u_scene, v_uv);\n return;\n }\n\n float clock = mod(u_frame, 512.0) + u_seed;\n float row = floor(v_uv.y * max(u_slices, 2.0));\n float torn = step(0.45, hash(vec2(row, clock)));\n float amount = hash(vec2(row + 17.0, clock * 1.7 + 3.0)) - 0.5;\n float sliceShift = amount * 0.28 * energy * torn;\n\n vec2 block = vec2(floor(v_uv.x * BLOCK_COLUMNS), row);\n float corrupt = step(1.0 - 0.45 * min(energy, 1.0), hash(block + clock * 7.3));\n vec2 jump =\n vec2(\n hash(block + clock * 3.1 + 5.0) - 0.5,\n hash(block + clock * 9.7 + 11.0) - 0.5\n ) *\n vec2(0.62, 0.34) *\n corrupt;\n\n vec2 uv = fract(v_uv + vec2(sliceShift, 0.0) + jump);\n float split = 0.02 * energy * (0.35 + abs(amount));\n\n vec4 color = sampleSplit(uv, split);\n color.rgb +=\n vec3(0.05, 0.015, 0.09) *\n energy *\n torn *\n hash(vec2(row, clock + 41.0)) *\n color.a;\n\n outColor = vec4(clamp(color.rgb, 0.0, 1.0), color.a);\n}`;\n\nconst shader = makeFilterShader<SustainedGlitchProps>(\n FRAGMENT_SHADER,\n ({ gl, uniform, passedProps }) => {\n const {\n intensity = DEFAULTS.intensity,\n frequency = DEFAULTS.frequency,\n slices = DEFAULTS.slices,\n seed = DEFAULTS.seed,\n } = passedProps;\n gl.uniform1f(uniform(\"u_intensity\"), intensity);\n gl.uniform1f(uniform(\"u_frequency\"), frequency);\n gl.uniform1f(uniform(\"u_slices\"), slices);\n gl.uniform1f(uniform(\"u_seed\"), seed);\n },\n);\n\nfunction burstEnergy(\n frame: number,\n intensity: number,\n frequency: number,\n seed: number,\n): number {\n const slotLength = Math.max(30 / Math.max(frequency, 0.1), 4);\n const slot = Math.floor(frame / slotLength);\n const local = frame - slot * slotLength;\n\n const burstLength = 2 + Math.floor(random(`glitch-len-${seed}-${slot}`) * 4);\n const start = Math.floor(\n random(`glitch-start-${seed}-${slot}`) *\n Math.max(slotLength - burstLength, 1),\n );\n if (random(`glitch-fire-${seed}-${slot}`) < 0.25) return 0;\n\n const age = local - start;\n if (age < 0 || age > burstLength - 1) return 0;\n return Math.max(intensity, 0) * (1 - age / burstLength);\n}\n\nconst SustainedGlitchFallback: React.FC<\n SustainedGlitchProps & CanvasFilterProps\n> = ({\n children,\n intensity = DEFAULTS.intensity,\n frequency = DEFAULTS.frequency,\n slices = DEFAULTS.slices,\n seed = DEFAULTS.seed,\n}) => {\n const frame = useCurrentFrame();\n const energy = burstEnergy(frame, intensity, frequency, seed);\n\n if (energy <= 0) {\n return <AbsoluteFill>{children}</AbsoluteFill>;\n }\n\n const bands = Math.max(2, Math.min(6, Math.round(slices / 5)));\n const height = 100 / bands;\n\n return (\n <AbsoluteFill>\n {Array.from({ length: bands }, (_, band) => {\n const shift =\n (random(`glitch-shift-${seed}-${frame}-${band}`) - 0.5) * 46 * energy;\n const tint = band % 2 === 0 ? \"rgb(255, 42, 90)\" : \"rgb(0, 224, 255)\";\n return (\n <AbsoluteFill\n key={band}\n style={{\n clipPath: `inset(${band * height}% 0 ${100 - (band + 1) * height}% 0)`,\n translate: `${shift}px`,\n }}\n >\n {children}\n <AbsoluteFill\n style={{\n background: tint,\n mixBlendMode: \"screen\",\n opacity:\n 0.18 *\n energy *\n random(`glitch-tint-${seed}-${frame}-${band}`),\n }}\n />\n </AbsoluteFill>\n );\n })}\n </AbsoluteFill>\n );\n};\n\nconst SustainedGlitchBase = makeCanvasFilter<SustainedGlitchProps>({\n shader,\n fallback: SustainedGlitchFallback,\n});\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n intensity: {\n type: \"number\",\n min: 0,\n max: 2,\n step: 0.05,\n default: 1,\n description: \"Intensity\",\n hiddenFromList: false,\n },\n frequency: {\n type: \"number\",\n min: 0.1,\n max: 6,\n step: 0.1,\n default: 1,\n description: \"Frequency\",\n hiddenFromList: false,\n },\n slices: {\n type: \"number\",\n min: 6,\n max: 48,\n step: 1,\n default: 24,\n description: \"Slices\",\n hiddenFromList: false,\n },\n seed: {\n type: \"number\",\n min: 1,\n max: 20,\n step: 1,\n default: 1,\n description: \"Seed\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"intensity\",\"frequency\",\"slices\",\"seed\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n intensity: 1,\n frequency: 1,\n slices: 24,\n seed: 1,\n speed: 1,\n};\n\ntype SustainedGlitchElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof SustainedGlitchBase>;\n\nconst SustainedGlitchInner = forwardRef<\n HTMLDivElement,\n SustainedGlitchElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<SustainedGlitch>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <SustainedGlitchBase\n {...(componentProps as unknown as ComponentProps<typeof SustainedGlitchBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const SustainedGlitch = Interactive.withSchema({\n Component: SustainedGlitchInner,\n componentName: \"<SustainedGlitch>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/terminal-simulator.json b/registry-artifacts/elements/terminal-simulator.jsonindex eb0ec6ab..0dcb0f74 100644--- a/registry-artifacts/elements/terminal-simulator.json+++ b/registry-artifacts/elements/terminal-simulator.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [],"dimensions": {"width": 900,@@ -9,6 +10,7 @@},"displayName": "Terminal Simulator","durationInFrames": 240,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "terminal-simulator","sourceCode": "import { Interactive, Sequence, interpolate, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ntype TerminalLineType = \"command\" | \"log\" | \"success\" | \"error\";\n\ninterface TerminalLine {\n text: string;\n type: TerminalLineType;\n delay?: number;\n /**\n * Extra freeze-frame pause AFTER this line finishes typing, in frames.\n * Use this to build dramatic tension before the next batch of logs.\n * If omitted, lines whose text ends in \"...\" auto-freeze for 18 frames.\n */\n pause?: number;\n}\n\ninterface TerminalSimulatorProps {\n lines?: TerminalLine[];\n prompt?: string;\n title?: string;\n background?: string;\n chromeColor?: string;\n fontSize?: number;\n /**\n * Reveal speed. Despite the name, the reveal is now CHUNKED — each\n * `1 / charsPerFrame` frames bumps the cursor by `chunkSize` characters,\n * so output appears in bursts instead of dripping char-by-char.\n */\n charsPerFrame?: number;\n /** Characters revealed per step. */\n chunkSize?: number;\n speed?: number;\n className?: string;\n}\n\nconst DEFAULT_LINES: TerminalLine[] = [\n { text: \"npm run build\", type: \"command\", delay: 0 },\n { text: \"Resolving dependencies...\", type: \"log\", delay: 6 },\n { text: \"> [email protected] build\", type: \"log\", delay: 4 },\n { text: \"> next build\", type: \"log\", delay: 4 },\n { text: \"Compiling...\", type: \"log\", delay: 12 },\n { text: \"Compiled successfully in 4.2s\", type: \"success\", delay: 14 },\n { text: \"Generating static pages (24/24)\", type: \"log\", delay: 10 },\n { text: \"Build completed without errors\", type: \"success\", delay: 12 },\n];\n\nconst TYPE_COLORS: Record<TerminalLineType, string> = {\n command: \"#fafafa\",\n log: \"#a1a1aa\",\n success: \"#22c55e\",\n error: \"#ef4444\",\n};\n\n/** Auto freeze-frame heuristic: any line ending in \"...\" holds the camera. */\nfunction autoPause(line: TerminalLine): number {\n if (line.pause !== undefined) return line.pause;\n if (line.text.trimEnd().endsWith(\"...\")) return 18;\n return 0;\n}\n\nfunction TerminalSimulatorBase({\n lines = DEFAULT_LINES,\n prompt = \"$\",\n title = \"~/projects/remocn\",\n background = \"#0a0a0a\",\n chromeColor = \"#1a1a1a\",\n fontSize = 18,\n charsPerFrame = 1,\n chunkSize = 1,\n speed = 1,\n className,\n}: TerminalSimulatorProps) {\n const frame = useCurrentFrame() * speed;\n const { fps } = useVideoConfig();\n\n const lineHeight = Math.round(fontSize * 1.6);\n const visibleLines = 8;\n const windowWidth = 900;\n const windowHeight = 480;\n\n // Compute cumulative start frames for each line, including auto/explicit\n // pauses AFTER a line finishes typing.\n const starts: number[] = [];\n let acc = 10;\n for (let i = 0; i < lines.length; i++) {\n const delay = lines[i].delay ?? 8;\n acc += delay;\n starts.push(acc);\n // Approximate typing duration (in frames) for chunked output.\n const typingFrames = Math.ceil(\n lines[i].text.length / (chunkSize * charsPerFrame),\n );\n acc += typingFrames + autoPause(lines[i]);\n }\n\n // STEP-FUNCTION scroll. Each overflowing line snaps the buffer up by\n // exactly one lineHeight on the frame it begins. No interpolation, no\n // easing — terminals do not glide.\n let translateY = 0;\n for (let i = visibleLines; i < lines.length; i++) {\n if (frame >= starts[i]) {\n translateY -= lineHeight;\n }\n }\n\n return (\n <div\n className={className}\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n style={{\n width: windowWidth,\n height: windowHeight,\n background,\n borderRadius: 12,\n overflow: \"hidden\",\n boxShadow:\n \"0 30px 80px rgba(0,0,0,0.6), 0 0 0 1px rgba(255,255,255,0.06)\",\n display: \"flex\",\n flexDirection: \"column\",\n fontFamily:\n \"var(--font-geist-mono), ui-monospace, SFMono-Regular, monospace\",\n }}\n >\n {/* Chrome */}\n <div\n style={{\n height: 40,\n background: chromeColor,\n display: \"flex\",\n alignItems: \"center\",\n padding: \"0 16px\",\n gap: 8,\n borderBottom: \"1px solid rgba(255,255,255,0.06)\",\n }}\n >\n <Light color=\"#ff5f57\" />\n <Light color=\"#febc2e\" />\n <Light color=\"#28c840\" />\n <div\n style={{\n flex: 1,\n textAlign: \"center\",\n color: \"#71717a\",\n fontSize: 13,\n }}\n >\n {title}\n </div>\n </div>\n\n {/* Content */}\n <div\n style={{\n flex: 1,\n padding: 20,\n overflow: \"hidden\",\n position: \"relative\",\n }}\n >\n <div\n style={{\n position: \"absolute\",\n left: 20,\n right: 20,\n top: 20,\n translate: `0 ${translateY}px`,\n }}\n >\n {lines.map((line, index) => (\n <Sequence\n key={index}\n from={Math.round(starts[index] / speed)}\n layout=\"none\"\n >\n <TerminalLineRow\n line={line}\n prompt={prompt}\n fontSize={fontSize}\n lineHeight={lineHeight}\n charsPerFrame={charsPerFrame}\n chunkSize={chunkSize}\n fps={fps}\n speed={speed}\n />\n </Sequence>\n ))}\n </div>\n </div>\n </div>\n </div>\n );\n}\n\nfunction Light({ color }: { color: string }) {\n return (\n <div\n style={{\n width: 12,\n height: 12,\n borderRadius: \"50%\",\n background: color,\n opacity: 0.85,\n }}\n />\n );\n}\n\nfunction TerminalLineRow({\n line,\n prompt,\n fontSize,\n lineHeight,\n charsPerFrame,\n chunkSize,\n fps,\n speed,\n}: {\n line: TerminalLine;\n prompt: string;\n fontSize: number;\n lineHeight: number;\n charsPerFrame: number;\n chunkSize: number;\n fps: number;\n speed: number;\n}) {\n const localFrame = useCurrentFrame() * speed;\n const totalChars = line.text.length;\n\n // Chunked reveal: Math.floor of an interpolated count, then snapped to the\n // nearest multiple of `chunkSize`. This is what gives the bursty terminal\n // feel — text doesn't drip, it lurches.\n const linearRevealed = Math.floor(\n interpolate(localFrame, [0, totalChars / charsPerFrame], [0, totalChars], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n }),\n );\n const revealed = Math.min(\n totalChars,\n Math.ceil(linearRevealed / chunkSize) * chunkSize,\n );\n const visible = line.text.substring(0, revealed);\n const typingDone = revealed >= totalChars;\n // 2 Hz blink at any framerate.\n const cursorVisible = Math.floor((localFrame / fps) * 2) % 2 === 0;\n\n return (\n <div\n style={{\n height: lineHeight,\n fontSize,\n color: TYPE_COLORS[line.type],\n display: \"flex\",\n alignItems: \"center\",\n whiteSpace: \"pre\",\n }}\n >\n {line.type === \"command\" && (\n <span style={{ color: \"#22c55e\", marginRight: 8 }}>{prompt}</span>\n )}\n <span>{visible}</span>\n {!typingDone && cursorVisible && (\n <span\n style={{\n display: \"inline-block\",\n width: fontSize * 0.55,\n height: fontSize,\n background: TYPE_COLORS[line.type],\n marginLeft: 2,\n }}\n />\n )}\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n prompt: {\n type: \"text-content\",\n default: \"$\",\n description: \"Prompt\",\n },\n title: {\n type: \"text-content\",\n default: \"~/projects/remocn\",\n description: \"Title\",\n },\n background: {\n type: \"color\",\n default: \"#0a0a0a\",\n description: \"Background\",\n },\n chromeColor: {\n type: \"color\",\n default: \"#1a1a1a\",\n description: \"Chrome color\",\n },\n fontSize: {\n type: \"number\",\n min: 10,\n max: 32,\n step: 1,\n default: 18,\n description: \"Font size\",\n hiddenFromList: false,\n },\n charsPerFrame: {\n type: \"number\",\n min: 0.25,\n max: 6,\n step: 0.25,\n default: 1,\n description: \"Chars / frame\",\n hiddenFromList: false,\n },\n chunkSize: {\n type: \"number\",\n min: 1,\n max: 20,\n step: 1,\n default: 1,\n description: \"Chunk size\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 900,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 480,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"prompt\",\"title\",\"background\",\"chromeColor\",\"fontSize\",\"charsPerFrame\",\"chunkSize\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n prompt: \"$\",\n title: \"~/projects/remocn\",\n background: \"#0a0a0a\",\n chromeColor: \"#1a1a1a\",\n fontSize: 18,\n charsPerFrame: 1,\n chunkSize: 1,\n speed: 1,\n};\n\ntype TerminalSimulatorElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof TerminalSimulatorBase>;\n\nconst TerminalSimulatorInner = forwardRef<\n HTMLDivElement,\n TerminalSimulatorElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 900, height = 480, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<TerminalSimulator>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <TerminalSimulatorBase\n {...(componentProps as unknown as ComponentProps<typeof TerminalSimulatorBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const TerminalSimulator = Interactive.withSchema({\n Component: TerminalSimulatorInner,\n componentName: \"<TerminalSimulator>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/top-down-letters.json b/registry-artifacts/elements/top-down-letters.jsonindex a8c3060e..f0a302b9 100644--- a/registry-artifacts/elements/top-down-letters.json+++ b/registry-artifacts/elements/top-down-letters.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [],"dimensions": {"width": 230,@@ -9,6 +10,7 @@},"displayName": "Top-Down Letters","durationInFrames": 60,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "top-down-letters","sourceCode": "import { Easing, Interactive, Sequence, interpolate, useCurrentFrame, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface TopDownLettersProps {\n text: string;\n staggerDelay?: number;\n distance?: number;\n fontSize?: number;\n color?: string;\n fontWeight?: number;\n speed?: number;\n className?: string;\n}\n\nfunction TopDownLettersBase({\n text,\n staggerDelay = 3,\n distance = 46,\n fontSize = 72,\n color = \"#171717\",\n fontWeight = 600,\n speed = 1,\n className,\n}: TopDownLettersProps) {\n const frame = useCurrentFrame() * speed;\n\n const chars = Array.from(text);\n const charDurationFrames = 12;\n const charTravelFrames = 7;\n\n return (\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n background: \"transparent\",\n }}\n >\n <span\n className={className}\n style={{\n fontSize,\n fontWeight,\n color,\n letterSpacing: \"-0.05em\",\n fontFamily:\n \"var(--font-geist-sans), -apple-system, BlinkMacSystemFont, sans-serif\",\n }}\n >\n {chars.map((char, i) => {\n const local = frame - i * staggerDelay;\n const easing = Easing.bezier(0.18, 1, 0.32, 1);\n const opacity = interpolate(local, [0, charDurationFrames], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing,\n });\n const y = interpolate(local, [0, charTravelFrames], [-distance, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing,\n });\n return (\n <span\n key={i}\n style={{\n display: \"inline-block\",\n whiteSpace: \"pre\",\n backfaceVisibility: \"hidden\",\n transformOrigin: \"50% 55%\",\n opacity,\n translate: `0 ${y}px`,\n }}\n >\n {char}\n </span>\n );\n })}\n </span>\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n text: {\n type: \"text-content\",\n default: \"Signal\",\n description: \"Text\",\n },\n staggerDelay: {\n type: \"number\",\n min: 1,\n max: 12,\n step: 1,\n default: 3,\n description: \"Stagger\",\n hiddenFromList: false,\n },\n distance: {\n type: \"number\",\n min: 0,\n max: 120,\n step: 1,\n default: 46,\n description: \"Distance\",\n hiddenFromList: false,\n },\n fontSize: {\n type: \"number\",\n min: 12,\n max: 160,\n step: 1,\n default: 72,\n description: \"Font size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n fontWeight: {\n type: \"enum\",\n default: \"600\",\n variants: {\n \"400\": {},\n \"500\": {},\n \"600\": {},\n \"700\": {},\n },\n description: \"Font weight\",\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 230,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 100,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"text\",\"staggerDelay\",\"distance\",\"fontSize\",\"color\",\"fontWeight\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n text: \"Signal\",\n staggerDelay: 3,\n distance: 46,\n fontSize: 72,\n color: \"#171717\",\n fontWeight: \"600\",\n speed: 1,\n};\n\ntype TopDownLettersElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof TopDownLettersBase>;\n\nconst TopDownLettersInner = forwardRef<\n HTMLDivElement,\n TopDownLettersElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 230, height = 100, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<TopDownLetters>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <TopDownLettersBase\n {...(componentProps as unknown as ComponentProps<typeof TopDownLettersBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const TopDownLetters = Interactive.withSchema({\n Component: TopDownLettersInner,\n componentName: \"<TopDownLetters>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/tracking-in.json b/registry-artifacts/elements/tracking-in.jsonindex bac9fe14..2da813a1 100644--- a/registry-artifacts/elements/tracking-in.json+++ b/registry-artifacts/elements/tracking-in.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [],"dimensions": {"width": 550,@@ -9,6 +10,7 @@},"displayName": "Tracking In","durationInFrames": 90,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "tracking-in","sourceCode": "import { Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface TrackingInProps {\n text: string;\n startTracking?: number;\n startBlur?: number;\n fontSize?: number;\n color?: string;\n fontWeight?: number;\n speed?: number;\n className?: string;\n}\n\nfunction TrackingInBase({\n text,\n startTracking = 0.5,\n startBlur = 12,\n fontSize = 96,\n color = \"#171717\",\n fontWeight = 700,\n speed = 1,\n className,\n}: TrackingInProps) {\n const frame = useCurrentFrame() * speed;\n const { fps } = useVideoConfig();\n\n const t = spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 90 },\n });\n\n const letterSpacing = `${interpolate(t, [0, 1], [startTracking, -0.03])}em`;\n const blurAmount = interpolate(t, [0, 1], [startBlur, 0]);\n const opacity = interpolate(frame, [0, 15], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n });\n\n return (\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n background: \"white\",\n }}\n >\n <span\n className={className}\n style={{\n fontSize,\n fontWeight,\n color,\n letterSpacing,\n opacity,\n filter: `blur(${blurAmount}px)`,\n fontFamily:\n \"var(--font-geist-sans), -apple-system, BlinkMacSystemFont, sans-serif\",\n whiteSpace: \"nowrap\",\n }}\n >\n {text}\n </span>\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n text: {\n type: \"text-content\",\n default: \"tracking in\",\n description: \"Text\",\n },\n startTracking: {\n type: \"number\",\n min: 0,\n max: 2,\n step: 0.05,\n default: 0.5,\n description: \"Start tracking (em)\",\n hiddenFromList: false,\n },\n startBlur: {\n type: \"number\",\n min: 0,\n max: 40,\n step: 1,\n default: 12,\n description: \"Start blur\",\n hiddenFromList: false,\n },\n fontSize: {\n type: \"number\",\n min: 12,\n max: 200,\n step: 1,\n default: 96,\n description: \"Font size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n fontWeight: {\n type: \"enum\",\n default: \"700\",\n variants: {\n \"400\": {},\n \"500\": {},\n \"600\": {},\n \"700\": {},\n },\n description: \"Font weight\",\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 550,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 130,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"text\",\"startTracking\",\"startBlur\",\"fontSize\",\"color\",\"fontWeight\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n text: \"tracking in\",\n startTracking: 0.5,\n startBlur: 12,\n fontSize: 96,\n color: \"#171717\",\n fontWeight: \"700\",\n speed: 1,\n};\n\ntype TrackingInElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof TrackingInBase>;\n\nconst TrackingInInner = forwardRef<\n HTMLDivElement,\n TrackingInElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 550, height = 130, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<TrackingIn>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <TrackingInBase\n {...(componentProps as unknown as ComponentProps<typeof TrackingInBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const TrackingIn = Interactive.withSchema({\n Component: TrackingInInner,\n componentName: \"<TrackingIn>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/trim-burst.json b/registry-artifacts/elements/trim-burst.jsonindex 4ab8457c..a56d96c9 100644--- a/registry-artifacts/elements/trim-burst.json+++ b/registry-artifacts/elements/trim-burst.json@@ -2,10 +2,12 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [],"dimensions": null,"displayName": "Trim Burst","durationInFrames": 18,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "trim-burst","sourceCode": "import { forwardRef, useImperativeHandle, useMemo, useRef, type ComponentProps } from \"react\";\nimport { Easing, Interactive, Sequence, random, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\n\ntype TrimBurstCap = \"round\" | \"butt\";\n\ninterface TrimBurstProps {\n x?: number;\n y?: number;\n count?: number;\n innerRadius?: number;\n reach?: number;\n strokeLength?: number;\n weight?: number;\n rotation?: number;\n spread?: number;\n jitter?: number;\n dots?: boolean;\n cap?: TrimBurstCap;\n color?: string;\n seed?: number;\n delay?: number;\n speed?: number;\n className?: string;\n}\n\ntype Paint = \"color\" | \"className\";\n\ninterface TrimBurstOptions extends Omit<TrimBurstProps, Paint> {\n width?: number;\n height?: number;\n fps?: number;\n}\n\ninterface TrimBurstStroke {\n index: number;\n angle: number;\n scale: number;\n launch: number;\n}\n\ninterface TrimBurstTrim {\n start: number;\n end: number;\n length: number;\n}\n\ninterface TrimBurstLine {\n index: number;\n x1: number;\n y1: number;\n x2: number;\n y2: number;\n width: number;\n}\n\ninterface TrimBurstDot {\n index: number;\n cx: number;\n cy: number;\n r: number;\n}\n\nconst trimBurstDefaults: Required<Omit<TrimBurstProps, \"className\">> = {\n x: 0.5,\n y: 0.5,\n count: 8,\n innerRadius: 16,\n reach: 64,\n strokeLength: 56,\n weight: 2,\n rotation: 0,\n spread: 360,\n jitter: 0.5,\n dots: false,\n cap: \"round\",\n color: \"#ffffff\",\n seed: 1,\n delay: 0,\n speed: 1,\n};\n\nconst LIFE = 15;\nconst LAG = 3;\nconst STAGGER = 6;\nconst HOLD = 24;\nconst LEASH = 6;\nconst WOBBLE = 0.25;\nconst MAX_STEP = 45;\nconst SHRINK = 0.45;\nconst DOT_START = 4;\nconst DOT_POP = 4;\nconst DOT_BACK = 1.4;\nconst DOT_RADIUS = 1.25;\nconst DOT_GAP = 2;\nconst MAX_COUNT = 32;\nconst MAX_SIZE = 2000;\nconst MIN_STROKE = 1;\nconst MIN_WEIGHT = 0.25;\nconst MAX_WEIGHT = 24;\nconst VISIBLE = 0.001;\nconst END_EASE = Easing.bezier(0.16, 1, 0.3, 1);\nconst START_EASE = Easing.bezier(0.45, 0, 0.55, 1);\n\nconst finite = (value: number | undefined, fallback: number) =>\n typeof value === \"number\" && Number.isFinite(value) ? value : fallback;\nconst clamp = (value: number, min: number, max: number) =>\n Math.min(max, Math.max(min, value));\nconst within = (\n value: number | undefined,\n fallback: number,\n min: number,\n max: number,\n) => clamp(finite(value, fallback), min, max);\nconst round = (value: number) => Math.round(value * 1000) / 1000;\nconst rateOf = (speed: number | undefined) =>\n Math.max(0, finite(speed, trimBurstDefaults.speed));\nconst delayOf = (delay: number | undefined) =>\n Math.max(0, finite(delay, trimBurstDefaults.delay));\nconst countOf = (count: number | undefined) =>\n Math.round(within(count, trimBurstDefaults.count, 1, MAX_COUNT));\nconst jitterOf = (jitter: number | undefined) =>\n within(jitter, trimBurstDefaults.jitter, 0, 1);\nconst capOf = (cap: string | undefined): TrimBurstCap =>\n cap === \"butt\" ? cap : \"round\";\n\nfunction getTrimBurstTimeline(\n options: Pick<TrimBurstOptions, \"count\" | \"jitter\"> = {},\n) {\n const count = countOf(options.count);\n const stagger = count > 1 ? STAGGER * jitterOf(options.jitter) : 0;\n return { life: LIFE, lag: LAG, stagger, length: LIFE + stagger };\n}\n\ntype TrimBurstTimeline = ReturnType<typeof getTrimBurstTimeline>;\n\nconst trimBurstLength = getTrimBurstTimeline().length;\n\nfunction getTrimBurstDuration(\n options: Pick<TrimBurstOptions, \"count\" | \"jitter\" | \"delay\" | \"speed\"> = {},\n) {\n const rate = rateOf(options.speed);\n const { length } = getTrimBurstTimeline(options);\n const motion = rate === 0 ? 0 : length / rate;\n return Math.ceil(round(delayOf(options.delay) + motion)) + HOLD;\n}\n\nfunction getTrimBurstTime(\n frame: number,\n options: Pick<TrimBurstOptions, \"fps\" | \"delay\" | \"speed\"> = {},\n) {\n const fps = Math.max(1, finite(options.fps, 30));\n const elapsed = Math.max(0, finite(frame, 0) - delayOf(options.delay));\n return elapsed * (30 / fps) * rateOf(options.speed);\n}\n\nfunction getTrimBurstEndProgress(time: number) {\n if (Number.isNaN(time) || time <= 0) return 0;\n if (time >= LIFE) return 1;\n return END_EASE(time / LIFE);\n}\n\nfunction getTrimBurstStartProgress(time: number) {\n if (Number.isNaN(time) || time <= LAG) return 0;\n if (time >= LIFE) return 1;\n return START_EASE((time - LAG) / (LIFE - LAG));\n}\n\nfunction getTrimBurstLeash(gap: number, strokeLength: number) {\n if (!(gap > 0 && strokeLength > 0)) return 0;\n return gap / (1 + (gap / strokeLength) ** LEASH) ** (1 / LEASH);\n}\n\nfunction getTrimBurstTrim(\n time: number,\n reach: number,\n strokeLength: number,\n): TrimBurstTrim {\n const distance = Math.max(0, finite(reach, 0));\n const end = distance * getTrimBurstEndProgress(time);\n const own = distance * getTrimBurstStartProgress(time);\n const length = getTrimBurstLeash(end - own, strokeLength);\n return { start: end - length, end, length };\n}\n\nfunction getTrimBurstDotScale(time: number) {\n if (Number.isNaN(time) || time <= DOT_START || time >= LIFE) return 0;\n const pop = Math.min(1, (time - DOT_START) / DOT_POP) - 1;\n const grow = 1 + (DOT_BACK + 1) * pop ** 3 + DOT_BACK * pop ** 2;\n const settle = DOT_START + DOT_POP;\n const shrink = clamp((time - settle) / (LIFE - settle), 0, 1);\n return grow * (1 - shrink ** 3);\n}\n\nfunction getTrimBurstStrokes(\n options: Pick<\n TrimBurstOptions,\n \"count\" | \"rotation\" | \"spread\" | \"jitter\" | \"seed\"\n > = {},\n): TrimBurstStroke[] {\n const count = countOf(options.count);\n const rotation = finite(options.rotation, trimBurstDefaults.rotation);\n const spread = within(options.spread, trimBurstDefaults.spread, 0, 360);\n const jitter = jitterOf(options.jitter);\n const seed = finite(options.seed, trimBurstDefaults.seed);\n const fan = spread < 360 && count > 1;\n const step = fan ? spread / (count - 1) : 360 / count;\n const first = fan ? rotation - spread / 2 : rotation;\n const wobble = WOBBLE * jitter * Math.min(step, MAX_STEP);\n const { stagger } = getTrimBurstTimeline({ count, jitter });\n const keys = Array.from({ length: count }, (_, index) =>\n random(`trim-burst-${seed}-order-${index}`),\n );\n const order = keys.map((_, index) => index);\n order.sort((a, b) => keys[a] - keys[b]);\n const ranks: number[] = [];\n for (const [position, index] of order.entries()) ranks[index] = position;\n return keys.map((_, index) => {\n const turn = random(`trim-burst-${seed}-angle-${index}`) * 2 - 1;\n const shrink = random(`trim-burst-${seed}-scale-${index}`);\n return {\n index,\n angle: first + index * step + turn * wobble,\n scale: 1 - SHRINK * jitter * shrink,\n launch: count > 1 ? (stagger * ranks[index]) / (count - 1) : 0,\n };\n });\n}\n\nfunction getTrimBurstState(\n frame: number,\n options: TrimBurstOptions = {},\n strokes: TrimBurstStroke[] = getTrimBurstStrokes(options),\n) {\n const fallback = trimBurstDefaults;\n const width = Math.max(1, finite(options.width, 1280));\n const height = Math.max(1, finite(options.height, 720));\n const unit = height / 720;\n const time = getTrimBurstTime(frame, options);\n const originX = finite(options.x, fallback.x) * width;\n const originY = finite(options.y, fallback.y) * height;\n const inner = within(options.innerRadius, fallback.innerRadius, 0, MAX_SIZE);\n const reach = within(options.reach, fallback.reach, 0, MAX_SIZE);\n const strokeLength = within(\n options.strokeLength,\n fallback.strokeLength,\n MIN_STROKE,\n MAX_SIZE,\n );\n const size = within(options.weight, fallback.weight, MIN_WEIGHT, MAX_WEIGHT);\n const offset = inner * unit;\n const weight = size * unit;\n const gap = DOT_GAP * weight;\n const radius = DOT_RADIUS * weight;\n const lines: TrimBurstLine[] = [];\n const dots: TrimBurstDot[] = [];\n for (const stroke of strokes) {\n const local = time - stroke.launch;\n const trim = getTrimBurstTrim(\n local,\n reach * unit * stroke.scale,\n strokeLength * unit * stroke.scale,\n );\n const angle = (stroke.angle * Math.PI) / 180;\n const dx = Math.sin(angle);\n const dy = -Math.cos(angle);\n const along = (distance: number) => ({\n x: round(originX + dx * (offset + distance)),\n y: round(originY + dy * (offset + distance)),\n });\n if (trim.length > VISIBLE) {\n const from = along(trim.start);\n const to = along(trim.end);\n lines.push({\n index: stroke.index,\n x1: from.x,\n y1: from.y,\n x2: to.x,\n y2: to.y,\n width: round(Math.min(weight, trim.length)),\n });\n }\n const pop = options.dots === true ? getTrimBurstDotScale(local) : 0;\n if (pop > 0) {\n const center = along(trim.end + gap + radius);\n dots.push({\n index: stroke.index,\n cx: center.x,\n cy: center.y,\n r: round(radius * pop),\n });\n }\n }\n return {\n width,\n height,\n unit,\n time,\n originX,\n originY,\n weight,\n cap: capOf(options.cap),\n lines,\n dots,\n };\n}\n\ntype TrimBurstState = ReturnType<typeof getTrimBurstState>;\n\nfunction TrimBurstBase({\n x = trimBurstDefaults.x,\n y = trimBurstDefaults.y,\n count = trimBurstDefaults.count,\n innerRadius = trimBurstDefaults.innerRadius,\n reach = trimBurstDefaults.reach,\n strokeLength = trimBurstDefaults.strokeLength,\n weight = trimBurstDefaults.weight,\n rotation = trimBurstDefaults.rotation,\n spread = trimBurstDefaults.spread,\n jitter = trimBurstDefaults.jitter,\n dots = trimBurstDefaults.dots,\n cap = trimBurstDefaults.cap,\n color = trimBurstDefaults.color,\n seed = trimBurstDefaults.seed,\n delay = trimBurstDefaults.delay,\n speed = trimBurstDefaults.speed,\n className,\n}: TrimBurstProps) {\n const frame = useCurrentFrame();\n const { width, height, fps } = useVideoConfig();\n const strokes = useMemo(\n () => getTrimBurstStrokes({ count, rotation, spread, jitter, seed }),\n [count, rotation, spread, jitter, seed],\n );\n const state = getTrimBurstState(\n frame,\n {\n width,\n height,\n fps,\n x,\n y,\n innerRadius,\n reach,\n strokeLength,\n weight,\n dots,\n cap,\n delay,\n speed,\n },\n strokes,\n );\n\n return (\n <div\n className={className}\n style={{ position: \"absolute\", inset: 0, pointerEvents: \"none\" }}\n >\n <svg\n width=\"100%\"\n height=\"100%\"\n viewBox={`0 0 ${width} ${height}`}\n role=\"img\"\n aria-label=\"Trim burst\"\n style={{ display: \"block\", overflow: \"visible\" }}\n >\n <g fill=\"none\" stroke={color} strokeLinecap={state.cap}>\n {state.lines.map((line) => (\n <line\n key={line.index}\n x1={line.x1}\n y1={line.y1}\n x2={line.x2}\n y2={line.y2}\n strokeWidth={line.width}\n />\n ))}\n </g>\n <g fill={color}>\n {state.dots.map((dot) => (\n <circle key={dot.index} cx={dot.cx} cy={dot.cy} r={dot.r} />\n ))}\n </g>\n </svg>\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n count: {\n type: \"number\",\n default: 8,\n min: 1,\n max: 24,\n step: 1,\n description: \"Strokes\",\n hiddenFromList: false,\n },\n innerRadius: {\n type: \"number\",\n default: 16,\n min: 0,\n max: 160,\n step: 1,\n description: \"Inner radius\",\n hiddenFromList: false,\n },\n reach: {\n type: \"number\",\n default: 64,\n min: 8,\n max: 240,\n step: 1,\n description: \"Reach\",\n hiddenFromList: false,\n },\n strokeLength: {\n type: \"number\",\n default: 56,\n min: 4,\n max: 200,\n step: 1,\n description: \"Stroke length\",\n hiddenFromList: false,\n },\n weight: {\n type: \"number\",\n default: 2,\n min: 0.5,\n max: 8,\n step: 0.5,\n description: \"Stroke weight\",\n hiddenFromList: false,\n },\n rotation: {\n type: \"number\",\n default: 0,\n min: -180,\n max: 180,\n step: 1,\n description: \"Rotation\",\n hiddenFromList: false,\n },\n spread: {\n type: \"number\",\n default: 360,\n min: 15,\n max: 360,\n step: 5,\n description: \"Spread\",\n hiddenFromList: false,\n },\n jitter: {\n type: \"number\",\n default: 0.5,\n min: 0,\n max: 1,\n step: 0.05,\n description: \"Jitter\",\n hiddenFromList: false,\n },\n dots: {\n type: \"boolean\",\n default: false,\n description: \"Tip dots\",\n },\n cap: {\n type: \"enum\",\n default: \"round\",\n variants: {\n round: {},\n butt: {},\n },\n description: \"Caps\",\n },\n color: {\n type: \"color\",\n default: \"#ffffff\",\n description: \"Line color\",\n },\n seed: {\n type: \"number\",\n default: 1,\n min: 1,\n max: 99,\n step: 1,\n description: \"Seed\",\n hiddenFromList: false,\n },\n delay: {\n type: \"number\",\n default: 0,\n min: 0,\n max: 30,\n step: 1,\n description: \"Delay\",\n hiddenFromList: false,\n },\n x: {\n type: \"number\",\n default: 0.5,\n min: 0,\n max: 1,\n step: 0.01,\n description: \"Center x\",\n hiddenFromList: false,\n },\n y: {\n type: \"number\",\n default: 0.5,\n min: 0,\n max: 1,\n step: 0.01,\n description: \"Center y\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"count\",\"innerRadius\",\"reach\",\"strokeLength\",\"weight\",\"rotation\",\"spread\",\"jitter\",\"dots\",\"cap\",\"color\",\"seed\",\"delay\",\"x\",\"y\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n count: 8,\n innerRadius: 16,\n reach: 64,\n strokeLength: 56,\n weight: 2,\n rotation: 0,\n spread: 360,\n jitter: 0.5,\n dots: false,\n cap: \"round\",\n color: \"#ffffff\",\n seed: 1,\n delay: 0,\n x: 0.5,\n y: 0.5,\n speed: 1,\n};\n\ntype TrimBurstElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof TrimBurstBase>;\n\nconst TrimBurstInner = forwardRef<\n HTMLDivElement,\n TrimBurstElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<TrimBurst>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <TrimBurstBase\n {...(componentProps as unknown as ComponentProps<typeof TrimBurstBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const TrimBurst = Interactive.withSchema({\n Component: TrimBurstInner,\n componentName: \"<TrimBurst>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/truchet-flip.json b/registry-artifacts/elements/truchet-flip.jsonindex cd5e3079..418b8afc 100644--- a/registry-artifacts/elements/truchet-flip.json+++ b/registry-artifacts/elements/truchet-flip.json@@ -2,10 +2,12 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [],"dimensions": null,"displayName": "Truchet Flip","durationInFrames": 102,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "truchet-flip","sourceCode": "import { forwardRef, useImperativeHandle, useMemo, useRef, type ComponentProps } from \"react\";\nimport { Interactive, Sequence, random, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\n\ntype TruchetFlipWaveMode = \"radial\" | \"diagonal\" | \"random\";\ntype TruchetFlipResolve = \"rings\" | \"field\" | \"silhouette\";\ntype TruchetFlipVariant = \"stroke\" | \"filled\";\ntype TruchetFlipOrientation = 0 | 1;\n\ninterface TruchetFlipProps {\n tiles?: number;\n weight?: number;\n passes?: number;\n waveMode?: TruchetFlipWaveMode;\n resolve?: TruchetFlipResolve;\n variant?: TruchetFlipVariant;\n color?: string;\n secondaryColor?: string;\n seed?: number;\n speed?: number;\n loop?: boolean;\n className?: string;\n}\n\ntype Paint = \"color\" | \"secondaryColor\" | \"className\";\ntype Unset = \"secondaryColor\" | \"className\";\n\ninterface TruchetFlipOptions extends Omit<TruchetFlipProps, Paint> {\n width?: number;\n height?: number;\n fps?: number;\n}\n\ninterface TruchetFlipTile {\n col: number;\n row: number;\n x: number;\n y: number;\n alternate: boolean;\n initial: TruchetFlipOrientation;\n target: TruchetFlipOrientation;\n delay: number;\n}\n\nconst truchetFlipDefaults: Required<Omit<TruchetFlipProps, Unset>> = {\n tiles: 10,\n weight: 0.2,\n passes: 2,\n waveMode: \"radial\",\n resolve: \"rings\",\n variant: \"stroke\",\n color: \"#ffffff\",\n seed: 1,\n speed: 1,\n loop: false,\n};\n\nconst LEAD = 6;\nconst SPREAD = 30;\nconst SNAP = 12;\nconst SNAP_SETTLE = 8;\nconst SNAP_RISE = 4;\nconst SNAP_DAMPING = 0.65;\nconst GAP = 24;\nconst RESOLVE_GAP = 30;\nconst HOLD = 18;\nconst LOOP_HOLD = 24;\nconst MAX_PASSES = 4;\nconst MIN_TILES = 4;\nconst MAX_TILES = 24;\nconst MIN_WEIGHT = 0.04;\nconst MAX_WEIGHT = 0.34;\nconst SILHOUETTE = 0.38;\nconst OVERLAP = 0.75;\nconst SNAP_FREQUENCY = (Math.PI - Math.acos(SNAP_DAMPING)) / SNAP_RISE;\nconst SNAP_RATIO = SNAP_DAMPING / Math.sqrt(1 - SNAP_DAMPING ** 2);\n\nconst finite = (value: number | undefined, fallback: number) =>\n typeof value === \"number\" && Number.isFinite(value) ? value : fallback;\nconst clamp = (value: number, min: number, max: number) =>\n Math.min(max, Math.max(min, value));\nconst round = (value: number) => Math.round(value * 1000) / 1000;\nconst isOdd = (value: number) => Math.abs(value % 2) === 1;\nconst turn = (wave: number) => (wave % 2 === 0 ? 1 : -1);\nconst rateOf = (speed: number | undefined) =>\n Math.max(0, finite(speed, truchetFlipDefaults.speed));\nconst waveOf = (value: string | undefined): TruchetFlipWaveMode =>\n value === \"diagonal\" || value === \"random\" ? value : \"radial\";\nconst resolveOf = (value: string | undefined): TruchetFlipResolve =>\n value === \"field\" || value === \"silhouette\" ? value : \"rings\";\nconst variantOf = (value: string | undefined): TruchetFlipVariant =>\n value === \"filled\" ? value : \"stroke\";\n\nfunction smoothstep(value: number) {\n const t = clamp(value, 0, 1);\n return t * t * (3 - 2 * t);\n}\n\nfunction mazeKey(seed: number, col: number, row: number) {\n return random(`truchet-flip-${seed}-${col}-${row}`);\n}\n\nfunction waveKey(seed: number, col: number, row: number) {\n return random(`truchet-flip-${seed}-wave-${col}-${row}`);\n}\n\nfunction getTruchetFlipSnap(frames: number) {\n if (Number.isNaN(frames) || frames <= 0) return 0;\n if (frames >= SNAP) return 1;\n const phase = SNAP_FREQUENCY * frames;\n const decay = Math.exp(-SNAP_RATIO * phase);\n const ring = decay * (Math.cos(phase) + SNAP_RATIO * Math.sin(phase));\n const settle = smoothstep((frames - SNAP_SETTLE) / (SNAP - SNAP_SETTLE));\n return 1 - ring * (1 - settle);\n}\n\nfunction getTruchetFlipTimeline(options: TruchetFlipOptions = {}) {\n const requested = finite(options.passes, truchetFlipDefaults.passes);\n const passes = Math.round(clamp(requested, 0, MAX_PASSES));\n const starts = Array.from({ length: passes }, (_, i) => LEAD + i * GAP);\n const lastPass = LEAD + Math.max(0, passes - 1) * GAP;\n const resolveStart = passes === 0 ? LEAD : lastPass + RESOLVE_GAP;\n const settled = resolveStart + SPREAD + SNAP;\n const returnStart = settled + LOOP_HOLD;\n const loop = options.loop === true;\n const duration = loop ? returnStart + SPREAD + SNAP : settled + HOLD;\n return {\n passes,\n starts,\n resolveStart,\n settled,\n returnStart,\n loop,\n duration,\n };\n}\n\ntype TruchetFlipTimeline = ReturnType<typeof getTruchetFlipTimeline>;\n\nconst truchetFlipLength = getTruchetFlipTimeline().settled;\n\nfunction getTruchetFlipDuration(options: TruchetFlipOptions = {}) {\n const rate = rateOf(options.speed);\n const { duration } = getTruchetFlipTimeline(options);\n return rate === 0 ? 1 : Math.max(1, Math.ceil(duration / rate));\n}\n\nfunction getTruchetFlipTime(\n frame: number,\n options: TruchetFlipOptions = {},\n) {\n const scale = 30 / Math.max(1, finite(options.fps, 30));\n const time = Math.max(0, finite(frame, 0)) * scale * rateOf(options.speed);\n const { duration, loop } = getTruchetFlipTimeline(options);\n return loop ? time % duration : time;\n}\n\nfunction getTruchetFlipTarget(\n resolve: TruchetFlipResolve,\n col: number,\n row: number,\n tiles = truchetFlipDefaults.tiles,\n): TruchetFlipOrientation {\n if (resolve === \"field\") return 0;\n if (resolve === \"silhouette\") {\n const inside = Math.hypot(col + 0.5, row + 0.5) < tiles * SILHOUETTE;\n return inside && isOdd(col + row) ? 1 : 0;\n }\n const left = col < 0;\n const above = row < 0;\n return left === above ? 0 : 1;\n}\n\nfunction getTruchetFlipGrid(options: TruchetFlipOptions = {}) {\n const width = Math.max(1, finite(options.width, 1280));\n const height = Math.max(1, finite(options.height, 720));\n const requested = finite(options.tiles, truchetFlipDefaults.tiles);\n const count = Math.round(clamp(requested, MIN_TILES, MAX_TILES));\n const size = Math.min(width, height) / count;\n const halfCols = Math.ceil(width / 2 / size - 1e-6);\n const halfRows = Math.ceil(height / 2 / size - 1e-6);\n const seed = finite(options.seed, truchetFlipDefaults.seed);\n const mode = waveOf(options.waveMode);\n const resolve = resolveOf(options.resolve);\n const cells: { col: number; row: number }[] = [];\n for (let row = -halfRows; row < halfRows; row++) {\n for (let col = -halfCols; col < halfCols; col++) cells.push({ col, row });\n }\n const ranks: number[] = [];\n if (mode === \"random\") {\n const keys = cells.map(({ col, row }) => waveKey(seed, col, row));\n const order = keys.map((_, index) => index);\n order.sort((a, b) => keys[a] - keys[b]);\n for (const [position, index] of order.entries()) ranks[index] = position;\n }\n const shift = halfCols + halfRows;\n const diagonals = 2 * (shift - 1);\n const nearest = Math.hypot(0.5, 0.5);\n const farthest = Math.hypot(halfCols - 0.5, halfRows - 0.5);\n const delayOf = (col: number, row: number, index: number) => {\n if (mode === \"random\") {\n return (SPREAD * ranks[index]) / (cells.length - 1);\n }\n if (mode === \"diagonal\") {\n return (SPREAD * (col + row + shift)) / diagonals;\n }\n const distance = Math.hypot(col + 0.5, row + 0.5) - nearest;\n return (SPREAD * distance) / Math.max(1e-6, farthest - nearest);\n };\n const tiles: TruchetFlipTile[] = cells.map(({ col, row }, index) => ({\n col,\n row,\n x: round(width / 2 + (col + 0.5) * size),\n y: round(height / 2 + (row + 0.5) * size),\n alternate: isOdd(col + row),\n initial: mazeKey(seed, col, row) < 0.5 ? 0 : 1,\n target: getTruchetFlipTarget(resolve, col, row, count),\n delay: round(clamp(delayOf(col, row, index), 0, SPREAD)),\n }));\n return {\n width,\n height,\n count,\n size,\n unit: Math.min(width, height) / 720,\n tiles,\n };\n}\n\ntype TruchetFlipGrid = ReturnType<typeof getTruchetFlipGrid>;\n\nfunction getTruchetFlipAngle(\n tile: TruchetFlipTile,\n time: number,\n timeline: TruchetFlipTimeline,\n) {\n let turns = 0;\n for (const [wave, start] of timeline.starts.entries()) {\n turns += turn(wave) * getTruchetFlipSnap(time - start - tile.delay);\n }\n const reached = (tile.initial + timeline.passes) % 2;\n if (reached !== tile.target) {\n const since = time - timeline.resolveStart - tile.delay;\n turns += turn(timeline.passes) * getTruchetFlipSnap(since);\n }\n if (timeline.loop && tile.target !== tile.initial) {\n const since = time - timeline.returnStart - tile.delay;\n turns += turn(timeline.passes + 1) * getTruchetFlipSnap(since);\n }\n return (tile.initial + turns) * 90;\n}\n\nfunction getTruchetFlipTilePath(\n size: number,\n variant: TruchetFlipVariant = \"stroke\",\n overlap = OVERLAP,\n) {\n const half = Math.max(0, finite(size, 0)) / 2;\n const pad = clamp(finite(overlap, OVERLAP), 0, half / 4);\n const radius = `${round(half)} ${round(half)}`;\n const point = (x: number, y: number) => `${round(x)} ${round(y)}`;\n if (variant === \"filled\") {\n const reach = Math.sqrt(half * half - pad * pad);\n const sector = (cx: number, cy: number, side: number) => {\n const corner = point(cx - side * pad, cy - side * pad);\n const start = point(cx + side * reach, cy - side * pad);\n const end = point(cx - side * pad, cy + side * reach);\n return `M ${corner} L ${start} A ${radius} 0 0 1 ${end} Z`;\n };\n return `${sector(-half, -half, 1)} ${sector(half, half, -1)}`;\n }\n const bend = half > 0 ? pad / half : 0;\n const cos = half * Math.cos(bend);\n const sin = half * Math.sin(bend);\n const arc = (cx: number, cy: number, side: number) => {\n const start = point(cx + side * cos, cy - side * sin);\n const end = point(cx - side * sin, cy + side * cos);\n return `M ${start} A ${radius} 0 0 1 ${end}`;\n };\n return `${arc(-half, -half, 1)} ${arc(half, half, -1)}`;\n}\n\nfunction getTruchetFlipState(\n frame: number,\n options: TruchetFlipOptions = {},\n grid: TruchetFlipGrid = getTruchetFlipGrid(options),\n) {\n const timeline = getTruchetFlipTimeline(options);\n const time = getTruchetFlipTime(frame, options);\n const variant = variantOf(options.variant);\n const requested = finite(options.weight, truchetFlipDefaults.weight);\n const weight = clamp(requested, MIN_WEIGHT, MAX_WEIGHT);\n return {\n ...grid,\n time,\n timeline,\n variant,\n strokeWidth: round(grid.size * weight),\n path: getTruchetFlipTilePath(grid.size, variant, OVERLAP * grid.unit),\n tiles: grid.tiles.map((tile) => {\n const angle = getTruchetFlipAngle(tile, time, timeline);\n const rotation = round(angle);\n const transform = `translate(${tile.x} ${tile.y}) rotate(${rotation})`;\n return { ...tile, angle, transform };\n }),\n };\n}\n\nfunction TruchetFlipBase({\n tiles = truchetFlipDefaults.tiles,\n weight = truchetFlipDefaults.weight,\n passes = truchetFlipDefaults.passes,\n waveMode = truchetFlipDefaults.waveMode,\n resolve = truchetFlipDefaults.resolve,\n variant = truchetFlipDefaults.variant,\n color = truchetFlipDefaults.color,\n secondaryColor,\n seed = truchetFlipDefaults.seed,\n speed = truchetFlipDefaults.speed,\n loop = truchetFlipDefaults.loop,\n className,\n}: TruchetFlipProps) {\n const frame = useCurrentFrame();\n const { width, height, fps } = useVideoConfig();\n const grid = useMemo(() => {\n const layout = { width, height, tiles, seed, waveMode, resolve };\n return getTruchetFlipGrid(layout);\n }, [width, height, tiles, seed, waveMode, resolve]);\n const motion = { fps, weight, passes, variant, speed, loop };\n const state = getTruchetFlipState(frame, motion, grid);\n const filled = state.variant === \"filled\";\n const primary = state.tiles.filter((tile) => !tile.alternate);\n const alternate = state.tiles.filter((tile) => tile.alternate);\n const layers = [\n { key: \"primary\", paint: color, tiles: primary },\n { key: \"alternate\", paint: secondaryColor ?? color, tiles: alternate },\n ];\n\n return (\n <div\n className={className}\n style={{ position: \"absolute\", inset: 0, overflow: \"hidden\" }}\n >\n <svg\n width=\"100%\"\n height=\"100%\"\n viewBox={`0 0 ${width} ${height}`}\n role=\"img\"\n aria-label=\"Truchet tile pattern\"\n style={{ display: \"block\" }}\n >\n {layers.map((layer) => (\n <g\n key={layer.key}\n fill={filled ? layer.paint : \"none\"}\n stroke={filled ? \"none\" : layer.paint}\n strokeWidth={filled ? undefined : state.strokeWidth}\n >\n {layer.tiles.map((tile) => (\n <path\n key={`${tile.col}:${tile.row}`}\n d={state.path}\n transform={tile.transform}\n />\n ))}\n </g>\n ))}\n </svg>\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n tiles: {\n type: \"number\",\n default: 10,\n min: 4,\n max: 24,\n step: 1,\n description: \"Tiles across\",\n hiddenFromList: false,\n },\n weight: {\n type: \"number\",\n default: 0.2,\n min: 0.04,\n max: 0.34,\n step: 0.01,\n description: \"Stroke weight\",\n hiddenFromList: false,\n },\n passes: {\n type: \"number\",\n default: 2,\n min: 0,\n max: 4,\n step: 1,\n description: \"Passes\",\n hiddenFromList: false,\n },\n waveMode: {\n type: \"enum\",\n default: \"radial\",\n variants: {\n radial: {},\n diagonal: {},\n random: {},\n },\n description: \"Wave\",\n },\n resolve: {\n type: \"enum\",\n default: \"rings\",\n variants: {\n rings: {},\n field: {},\n silhouette: {},\n },\n description: \"Resolve to\",\n },\n variant: {\n type: \"enum\",\n default: \"stroke\",\n variants: {\n stroke: {},\n filled: {},\n },\n description: \"Variant\",\n },\n color: {\n type: \"color\",\n default: \"#ffffff\",\n description: \"Line color\",\n },\n secondaryColor: {\n type: \"color\",\n default: \"#ffffff\",\n description: \"Alternate tiles\",\n },\n seed: {\n type: \"number\",\n default: 1,\n min: 1,\n step: 1,\n description: \"Seed\",\n hiddenFromList: false,\n },\n loop: {\n type: \"boolean\",\n default: false,\n description: \"Loop\",\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"tiles\",\"weight\",\"passes\",\"waveMode\",\"resolve\",\"variant\",\"color\",\"secondaryColor\",\"seed\",\"loop\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n tiles: 10,\n weight: 0.2,\n passes: 2,\n waveMode: \"radial\",\n resolve: \"rings\",\n variant: \"stroke\",\n color: \"#ffffff\",\n secondaryColor: \"#ffffff\",\n seed: 1,\n loop: false,\n speed: 1,\n};\n\ntype TruchetFlipElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof TruchetFlipBase>;\n\nconst TruchetFlipInner = forwardRef<\n HTMLDivElement,\n TruchetFlipElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<TruchetFlip>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <TruchetFlipBase\n {...(componentProps as unknown as ComponentProps<typeof TruchetFlipBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const TruchetFlip = Interactive.withSchema({\n Component: TruchetFlipInner,\n componentName: \"<TruchetFlip>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/tv-power-off.json b/registry-artifacts/elements/tv-power-off.jsonindex 4fb7a2ef..8724a8de 100644--- a/registry-artifacts/elements/tv-power-off.json+++ b/registry-artifacts/elements/tv-power-off.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/transitions",@@ -11,6 +12,7 @@"dimensions": null,"displayName": "TV Power Off","durationInFrames": 18,+ "initialProps": null,"installationMode": "wrapped","slug": "tv-power-off","sourceCode": "import { AbsoluteFill, isHtmlInCanvasSupported, useCurrentFrame, useDelayRender, useVideoConfig } from \"remotion\";\nimport React from \"react\";\nimport { type TransitionPresentation, type TransitionPresentationComponentProps } from \"@remotion/transitions\";\n\nconst QUAD = new Float32Array([-1, -1, 1, -1, -1, 1, 1, 1]);\n\nconst VERTEX_SHADER = `#version 300 es\nin vec2 a_pos;\nout vec2 v_uv;\nvoid main() {\n v_uv = vec2(a_pos.x * 0.5 + 0.5, 0.5 - a_pos.y * 0.5);\n gl_Position = vec4(a_pos, 0.0, 1.0);\n}`;\n\nconst LAYER: React.CSSProperties = {\n position: \"absolute\",\n inset: 0,\n width: \"100%\",\n height: \"100%\",\n};\n\nconst OUTPUT_LAYER: React.CSSProperties = { ...LAYER, pointerEvents: \"none\" };\n\nconst isCanvasTransitionSupported = (): boolean =>\n isHtmlInCanvasSupported();\n\nconst isCanvasFilterSupported = (): boolean => isHtmlInCanvasSupported();\n\ntype SceneShaderFrame<Props> = {\n gl: WebGL2RenderingContext;\n uniform: (name: string) => WebGLUniformLocation | null;\n width: number;\n height: number;\n progress: number;\n passedProps: Props;\n};\n\ntype SceneShaderDrawParams<Props> = {\n from: OffscreenCanvas | null;\n to: OffscreenCanvas | null;\n width: number;\n height: number;\n progress: number;\n passedProps: Props;\n};\n\ntype SceneShaderInstance<Props> = {\n draw: (params: SceneShaderDrawParams<Props>) => void;\n clear: () => void;\n cleanup: () => void;\n};\n\ntype SceneShader<Props> = (\n canvas: OffscreenCanvas,\n) => SceneShaderInstance<Props>;\n\ntype SceneFilterFrame<Props> = {\n gl: WebGL2RenderingContext;\n uniform: (name: string) => WebGLUniformLocation | null;\n width: number;\n height: number;\n frame: number;\n time: number;\n passedProps: Props;\n};\n\ntype SceneFilterDrawParams<Props> = {\n scene: OffscreenCanvas | null;\n width: number;\n height: number;\n frame: number;\n time: number;\n passedProps: Props;\n};\n\ntype SceneFilterInstance<Props> = {\n draw: (params: SceneFilterDrawParams<Props>) => void;\n clear: () => void;\n cleanup: () => void;\n};\n\ntype SceneFilter<Props> = (\n canvas: OffscreenCanvas,\n) => SceneFilterInstance<Props>;\n\nfunction compileShader(\n gl: WebGL2RenderingContext,\n source: string,\n type: GLenum,\n): WebGLShader {\n const shader = gl.createShader(type);\n if (!shader) {\n throw new Error(\"canvas-presentation: failed to create shader\");\n }\n gl.shaderSource(shader, source);\n gl.compileShader(shader);\n if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {\n const log = gl.getShaderInfoLog(shader);\n gl.deleteShader(shader);\n throw new Error(`canvas-presentation: failed to compile shader: ${log}`);\n }\n return shader;\n}\n\nfunction createProgram(\n gl: WebGL2RenderingContext,\n fragment: string,\n): WebGLProgram {\n const program = gl.createProgram();\n if (!program) {\n throw new Error(\"canvas-presentation: failed to create program\");\n }\n const vs = compileShader(gl, VERTEX_SHADER, gl.VERTEX_SHADER);\n const fs = compileShader(gl, fragment, gl.FRAGMENT_SHADER);\n gl.attachShader(program, vs);\n gl.attachShader(program, fs);\n gl.linkProgram(program);\n gl.deleteShader(vs);\n gl.deleteShader(fs);\n if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {\n const log = gl.getProgramInfoLog(program);\n gl.deleteProgram(program);\n throw new Error(`canvas-presentation: failed to link program: ${log}`);\n }\n return program;\n}\n\nfunction createSceneTexture(gl: WebGL2RenderingContext): WebGLTexture {\n const texture = gl.createTexture();\n if (!texture) {\n throw new Error(\"canvas-presentation: failed to create texture\");\n }\n gl.bindTexture(gl.TEXTURE_2D, texture);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);\n gl.texImage2D(\n gl.TEXTURE_2D,\n 0,\n gl.RGBA,\n 1,\n 1,\n 0,\n gl.RGBA,\n gl.UNSIGNED_BYTE,\n new Uint8Array([0, 0, 0, 0]),\n );\n return texture;\n}\n\nfunction createQuadSurface(canvas: OffscreenCanvas, fragment: string) {\n const gl = canvas.getContext(\"webgl2\", { premultipliedAlpha: true });\n if (!gl) {\n throw new Error(\"canvas-presentation: WebGL2 is unavailable\");\n }\n\n const program = createProgram(gl, fragment);\n const vao = gl.createVertexArray();\n gl.bindVertexArray(vao);\n const buffer = gl.createBuffer();\n gl.bindBuffer(gl.ARRAY_BUFFER, buffer);\n gl.bufferData(gl.ARRAY_BUFFER, QUAD, gl.STATIC_DRAW);\n const aPos = gl.getAttribLocation(program, \"a_pos\");\n gl.enableVertexAttribArray(aPos);\n gl.vertexAttribPointer(aPos, 2, gl.FLOAT, false, 0, 0);\n\n const locations = new Map<string, WebGLUniformLocation | null>();\n const uniform = (name: string) => {\n const cached = locations.get(name);\n if (cached !== undefined) {\n return cached;\n }\n const location = gl.getUniformLocation(program, name);\n locations.set(name, location);\n return location;\n };\n\n const clear = () => {\n gl.clearColor(0, 0, 0, 0);\n gl.clear(gl.COLOR_BUFFER_BIT);\n };\n\n const textures: WebGLTexture[] = [];\n const createTexture = () => {\n const texture = createSceneTexture(gl);\n textures.push(texture);\n return texture;\n };\n\n const begin = (width: number, height: number) => {\n gl.viewport(0, 0, width, height);\n clear();\n gl.useProgram(program);\n gl.bindVertexArray(vao);\n };\n\n const bindScene = (\n image: OffscreenCanvas | null,\n texture: WebGLTexture,\n unit: number,\n name: string,\n ) => {\n gl.activeTexture(gl.TEXTURE0 + unit);\n gl.bindTexture(gl.TEXTURE_2D, texture);\n if (image) {\n gl.texImage2D(\n gl.TEXTURE_2D,\n 0,\n gl.RGBA,\n gl.RGBA,\n gl.UNSIGNED_BYTE,\n image,\n );\n }\n gl.uniform1i(uniform(name), unit);\n };\n\n const draw = () => gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);\n\n const cleanup = () => {\n gl.deleteProgram(program);\n for (const texture of textures) {\n gl.deleteTexture(texture);\n }\n gl.deleteBuffer(buffer);\n gl.deleteVertexArray(vao);\n };\n\n return {\n gl,\n uniform,\n clear,\n createTexture,\n begin,\n bindScene,\n draw,\n cleanup,\n };\n}\n\nfunction makeSceneShader<Props extends Record<string, unknown>>(\n fragment: string,\n setUniforms?: (frame: SceneShaderFrame<Props>) => void,\n): SceneShader<Props> {\n return (canvas) => {\n const surface = createQuadSurface(canvas, fragment);\n const fromTexture = surface.createTexture();\n const toTexture = surface.createTexture();\n\n return {\n clear: surface.clear,\n cleanup: surface.cleanup,\n draw: ({ from, to, width, height, progress, passedProps }) => {\n surface.begin(width, height);\n surface.bindScene(from, fromTexture, 0, \"u_from\");\n surface.bindScene(to, toTexture, 1, \"u_to\");\n\n surface.gl.uniform1f(surface.uniform(\"u_progress\"), progress);\n surface.gl.uniform1f(surface.uniform(\"u_aspect\"), width / height);\n setUniforms?.({\n gl: surface.gl,\n uniform: surface.uniform,\n width,\n height,\n progress,\n passedProps,\n });\n\n surface.draw();\n },\n };\n };\n}\n\nfunction makeFilterShader<Props extends Record<string, unknown>>(\n fragment: string,\n setUniforms?: (frame: SceneFilterFrame<Props>) => void,\n): SceneFilter<Props> {\n return (canvas) => {\n const surface = createQuadSurface(canvas, fragment);\n const sceneTexture = surface.createTexture();\n\n return {\n clear: surface.clear,\n cleanup: surface.cleanup,\n draw: ({ scene, width, height, frame, time, passedProps }) => {\n surface.begin(width, height);\n surface.bindScene(scene, sceneTexture, 0, \"u_scene\");\n\n surface.gl.uniform1f(surface.uniform(\"u_frame\"), frame);\n surface.gl.uniform1f(surface.uniform(\"u_time\"), time);\n surface.gl.uniform1f(surface.uniform(\"u_aspect\"), width / height);\n setUniforms?.({\n gl: surface.gl,\n uniform: surface.uniform,\n width,\n height,\n frame,\n time,\n passedProps,\n });\n\n surface.draw();\n },\n };\n };\n}\n\nconst transferred = new WeakMap<HTMLCanvasElement, OffscreenCanvas>();\n\nfunction takeOffscreen(canvas: HTMLCanvasElement): OffscreenCanvas {\n const existing = transferred.get(canvas);\n if (existing) {\n return existing;\n }\n const created = canvas.transferControlToOffscreen();\n transferred.set(canvas, created);\n return created;\n}\n\nfunction makeCanvasComponent<Props extends Record<string, unknown>>(\n shader: SceneShader<Props>,\n): React.FC<TransitionPresentationComponentProps<Props>> {\n return function CanvasScenePresentation({\n children,\n presentationProgress,\n presentationDirection,\n passedProps,\n onElementImage,\n onUnmount,\n bothEnteringAndExiting,\n }) {\n const layoutRef = React.useRef<HTMLCanvasElement | null>(null);\n const outputRef = React.useRef<HTMLCanvasElement | null>(null);\n const captureRef = React.useRef<OffscreenCanvas | null>(null);\n const captureContextRef =\n React.useRef<OffscreenCanvasRenderingContext2D | null>(null);\n const outputSurfaceRef = React.useRef<OffscreenCanvas | null>(null);\n const instanceRef = React.useRef<SceneShaderInstance<Props> | null>(null);\n const passedPropsRef = React.useRef(passedProps);\n passedPropsRef.current = passedProps;\n const onElementImageRef = React.useRef(onElementImage);\n onElementImageRef.current = onElementImage;\n const onUnmountRef = React.useRef(onUnmount);\n onUnmountRef.current = onUnmount;\n\n const { delayRender, continueRender } = useDelayRender();\n const passThrough =\n bothEnteringAndExiting && presentationDirection === \"exiting\";\n\n const drawRef = React.useRef<\n (\n prevImage: OffscreenCanvas | null,\n nextImage: OffscreenCanvas | null,\n progress: number,\n ) => void\n >(() => undefined);\n drawRef.current = (prevImage, nextImage, progress) => {\n const instance = instanceRef.current;\n if (!instance) {\n return;\n }\n const handle = delayRender(\"canvas-presentation: paint\");\n const to = prevImage;\n const from = nextImage;\n const width = from?.width ?? to?.width ?? 0;\n const height = from?.height ?? to?.height ?? 0;\n if (width === 0 || height === 0) {\n instance.clear();\n continueRender(handle);\n return;\n }\n instance.draw({\n from,\n to,\n width,\n height,\n progress: !to ? 0 : !from ? 1 : progress,\n passedProps: passedPropsRef.current,\n });\n continueRender(handle);\n };\n\n const draw = React.useCallback(\n (\n prevImage: OffscreenCanvas | null,\n nextImage: OffscreenCanvas | null,\n progress: number,\n ) => drawRef.current(prevImage, nextImage, progress),\n [],\n );\n\n React.useLayoutEffect(() => {\n if (passThrough) {\n return;\n }\n const layout = layoutRef.current;\n const output = outputRef.current;\n if (!layout || !output) {\n return;\n }\n const capture = takeOffscreen(layout);\n const context = capture.getContext(\"2d\");\n if (!context) {\n throw new Error(\"canvas-presentation: failed to acquire a 2D context\");\n }\n const surface = takeOffscreen(output);\n captureRef.current = capture;\n captureContextRef.current = context;\n outputSurfaceRef.current = surface;\n instanceRef.current = shader(surface);\n\n return () => {\n instanceRef.current?.cleanup();\n instanceRef.current = null;\n captureRef.current = null;\n captureContextRef.current = null;\n outputSurfaceRef.current = null;\n };\n }, [passThrough, shader]);\n\n React.useLayoutEffect(() => {\n if (passThrough) {\n return;\n }\n const layout = layoutRef.current;\n if (!layout) {\n return;\n }\n layout.layoutSubtree = true;\n const handlePaint = () => {\n const scene = layout.firstElementChild;\n const capture = captureRef.current;\n const context = captureContextRef.current;\n if (!scene || !capture || !context) {\n return;\n }\n const elementImage = layout.captureElementImage(scene);\n try {\n context.reset();\n context.drawElementImage(elementImage, 0, 0);\n } finally {\n elementImage.close();\n }\n onElementImageRef.current(capture, draw);\n };\n layout.addEventListener(\"paint\", handlePaint);\n return () => layout.removeEventListener(\"paint\", handlePaint);\n }, [passThrough, draw]);\n\n React.useLayoutEffect(() => {\n if (passThrough) {\n return;\n }\n const layout = layoutRef.current;\n if (!layout) {\n return;\n }\n const observer = new ResizeObserver(([entry]) => {\n const capture = captureRef.current;\n const surface = outputSurfaceRef.current;\n if (!capture || !surface) {\n return;\n }\n const width = entry.devicePixelContentBoxSize[0].inlineSize;\n const height = entry.devicePixelContentBoxSize[0].blockSize;\n capture.width = width;\n capture.height = height;\n surface.width = width;\n surface.height = height;\n layout.requestPaint?.();\n });\n observer.observe(layout, { box: \"device-pixel-content-box\" });\n return () => observer.disconnect();\n }, [passThrough]);\n\n // biome-ignore lint/correctness/useExhaustiveDependencies: presentationProgress is the intentional trigger — a new progress value is what schedules the next paint\n React.useLayoutEffect(() => {\n if (passThrough) {\n return;\n }\n layoutRef.current?.requestPaint?.();\n }, [passThrough, presentationProgress]);\n\n React.useLayoutEffect(() => {\n if (passThrough) {\n return;\n }\n return () => onUnmountRef.current();\n }, [passThrough]);\n\n if (passThrough) {\n return <>{children}</>;\n }\n\n return (\n <AbsoluteFill>\n <canvas ref={layoutRef} style={LAYER}>\n {children}\n </canvas>\n <canvas ref={outputRef} style={OUTPUT_LAYER} />\n </AbsoluteFill>\n );\n };\n}\n\ntype CanvasFilterProps = {\n children: React.ReactNode;\n};\n\nfunction makeFilterComponent<Props extends Record<string, unknown>>(\n shader: SceneFilter<Props>,\n): React.FC<Props & CanvasFilterProps> {\n return function CanvasSceneFilter(props) {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const { delayRender, continueRender } = useDelayRender();\n\n const layoutRef = React.useRef<HTMLCanvasElement | null>(null);\n const outputRef = React.useRef<HTMLCanvasElement | null>(null);\n const captureRef = React.useRef<OffscreenCanvas | null>(null);\n const captureContextRef =\n React.useRef<OffscreenCanvasRenderingContext2D | null>(null);\n const outputSurfaceRef = React.useRef<OffscreenCanvas | null>(null);\n const instanceRef = React.useRef<SceneFilterInstance<Props> | null>(null);\n\n const passedPropsRef = React.useRef(props);\n passedPropsRef.current = props;\n const frameRef = React.useRef(frame);\n frameRef.current = frame;\n const timeRef = React.useRef(frame / fps);\n timeRef.current = frame / fps;\n\n React.useLayoutEffect(() => {\n const layout = layoutRef.current;\n const output = outputRef.current;\n if (!layout || !output) {\n return;\n }\n const capture = takeOffscreen(layout);\n const context = capture.getContext(\"2d\");\n if (!context) {\n throw new Error(\"canvas-presentation: failed to acquire a 2D context\");\n }\n const surface = takeOffscreen(output);\n captureRef.current = capture;\n captureContextRef.current = context;\n outputSurfaceRef.current = surface;\n instanceRef.current = shader(surface);\n\n return () => {\n instanceRef.current?.cleanup();\n instanceRef.current = null;\n captureRef.current = null;\n captureContextRef.current = null;\n outputSurfaceRef.current = null;\n };\n }, [shader]);\n\n React.useLayoutEffect(() => {\n const layout = layoutRef.current;\n if (!layout) {\n return;\n }\n layout.layoutSubtree = true;\n const handlePaint = () => {\n const scene = layout.firstElementChild;\n const capture = captureRef.current;\n const context = captureContextRef.current;\n const instance = instanceRef.current;\n if (!scene || !capture || !context || !instance) {\n return;\n }\n const elementImage = layout.captureElementImage(scene);\n try {\n context.reset();\n context.drawElementImage(elementImage, 0, 0);\n } finally {\n elementImage.close();\n }\n if (capture.width === 0 || capture.height === 0) {\n instance.clear();\n return;\n }\n instance.draw({\n scene: capture,\n width: capture.width,\n height: capture.height,\n frame: frameRef.current,\n time: timeRef.current,\n passedProps: passedPropsRef.current,\n });\n };\n layout.addEventListener(\"paint\", handlePaint);\n return () => layout.removeEventListener(\"paint\", handlePaint);\n }, []);\n\n React.useLayoutEffect(() => {\n const layout = layoutRef.current;\n if (!layout) {\n return;\n }\n const observer = new ResizeObserver(([entry]) => {\n const capture = captureRef.current;\n const surface = outputSurfaceRef.current;\n if (!capture || !surface) {\n return;\n }\n const width = entry.devicePixelContentBoxSize[0].inlineSize;\n const height = entry.devicePixelContentBoxSize[0].blockSize;\n capture.width = width;\n capture.height = height;\n surface.width = width;\n surface.height = height;\n layout.requestPaint?.();\n });\n observer.observe(layout, { box: \"device-pixel-content-box\" });\n return () => observer.disconnect();\n }, []);\n\n React.useLayoutEffect(() => {\n const layout = layoutRef.current;\n if (!layout) {\n return;\n }\n const handle = delayRender(\"canvas-presentation: filter paint\");\n const settle = () => continueRender(handle);\n layout.addEventListener(\"paint\", settle, { once: true });\n layout.requestPaint?.();\n return () => {\n layout.removeEventListener(\"paint\", settle);\n continueRender(handle);\n };\n });\n\n return (\n <AbsoluteFill>\n <canvas ref={layoutRef} style={LAYER}>\n {props.children}\n </canvas>\n <canvas ref={outputRef} style={OUTPUT_LAYER} />\n </AbsoluteFill>\n );\n };\n}\n\ntype CanvasPresentationOptions<Props extends Record<string, unknown>> = {\n shader: SceneShader<Props>;\n fallback: React.FC<TransitionPresentationComponentProps<Props>>;\n};\n\nfunction makeCanvasPresentation<Props extends Record<string, unknown>>({\n shader,\n fallback: Fallback,\n}: CanvasPresentationOptions<Props>): (\n props: Props,\n) => TransitionPresentation<Props> {\n const Canvas = makeCanvasComponent(shader);\n\n const Presentation: React.FC<TransitionPresentationComponentProps<Props>> = (\n props,\n ) =>\n isCanvasTransitionSupported() ? (\n <Canvas {...props} />\n ) : (\n <Fallback {...props} />\n );\n\n return (props) => ({ component: Presentation, props });\n}\n\ntype CanvasFilterOptions<Props extends Record<string, unknown>> = {\n shader: SceneFilter<Props>;\n fallback: React.FC<Props & CanvasFilterProps>;\n};\n\nfunction makeCanvasFilter<Props extends Record<string, unknown>>({\n shader,\n fallback: Fallback,\n}: CanvasFilterOptions<Props>): React.FC<Props & CanvasFilterProps> {\n const Canvas = makeFilterComponent(shader);\n\n return function CanvasFilter(props) {\n return isCanvasFilterSupported() ? (\n <Canvas {...props} />\n ) : (\n <Fallback {...props} />\n );\n };\n}\n\nexport type TvPowerOffProps = {\n durationInFrames?: number;\n delay?: number;\n gain?: number;\n afterglow?: number;\n phosphor?: string;\n};\n\nconst DEFAULTS = {\n durationInFrames: 18,\n delay: 0,\n gain: 1,\n afterglow: 1,\n phosphor: \"#d8ecff\",\n};\n\nconst COLLAPSE_END = 0.6;\nconst PINCH_END = 0.82;\nconst MIN_SQUASH = 0.0055;\nconst MIN_PINCH = 0.004;\nconst CONCENTRATION = 0.3;\nconst DECAY_CURVE = 2.6;\nconst BLACKOUT_IN = 0.06;\n\nconst FRAGMENT_SHADER = `#version 300 es\nprecision highp float;\n\nuniform sampler2D u_scene;\nuniform vec2 u_resolution;\nuniform float u_aspect;\nuniform float u_progress;\nuniform float u_gain;\nuniform float u_afterglow;\nuniform vec3 u_phosphor;\n\nin vec2 v_uv;\nout vec4 outColor;\n\nconst int TAPS = 32;\nconst int COLUMN_TAPS = 8;\nconst float GOLDEN = 0.6180339887;\nconst float COLLAPSE_END = ${COLLAPSE_END.toFixed(4)};\nconst float PINCH_END = ${PINCH_END.toFixed(4)};\nconst float MIN_SQUASH = ${MIN_SQUASH.toFixed(5)};\nconst float MIN_PINCH = ${MIN_PINCH.toFixed(5)};\nconst float CONCENTRATION = ${CONCENTRATION.toFixed(4)};\nconst float DECAY_CURVE = ${DECAY_CURVE.toFixed(4)};\nconst float BLACKOUT_IN = ${BLACKOUT_IN.toFixed(4)};\n\nvoid main() {\n float p = u_progress;\n\n if (p <= 0.0) {\n outColor = texture(u_scene, v_uv);\n return;\n }\n if (p >= 1.0) {\n outColor = vec4(0.0, 0.0, 0.0, 1.0);\n return;\n }\n\n float collapse = clamp(p / COLLAPSE_END, 0.0, 1.0);\n float pinch = clamp((p - COLLAPSE_END) / (PINCH_END - COLLAPSE_END), 0.0, 1.0);\n float decayed = clamp((p - PINCH_END) / (1.0 - PINCH_END), 0.0, 1.0);\n\n vec2 scale = vec2(pow(MIN_PINCH, pinch), pow(MIN_SQUASH, collapse));\n vec2 centered = (v_uv - 0.5) / scale + 0.5;\n vec2 span = 1.0 / (scale * u_resolution);\n\n vec3 sum = vec3(0.0);\n for (int i = 0; i < TAPS; i++) {\n float fi = float(i);\n vec2 at = centered + vec2(\n (fract(fi * GOLDEN + 0.5) - 0.5) * span.x,\n ((fi + 0.5) / float(TAPS) - 0.5) * span.y\n );\n vec2 inside = step(vec2(0.0), at) * step(at, vec2(1.0));\n sum += texture(u_scene, at).rgb * inside.x * inside.y;\n }\n\n float concentrate = pow(1.0 / (scale.x * scale.y), CONCENTRATION);\n vec3 light =\n (sum / float(TAPS)) * (1.0 + (concentrate - 1.0) * max(u_gain, 0.0));\n\n float glow = max(u_afterglow, 0.0);\n float bleed = smoothstep(0.2, 0.8, collapse) * (1.0 - pinch) * glow;\n\n if (bleed > 0.0) {\n vec3 column = vec3(0.0);\n float cx = clamp(centered.x, 0.0, 1.0);\n for (int i = 0; i < COLUMN_TAPS; i++) {\n column +=\n texture(u_scene, vec2(cx, (float(i) + 0.5) / float(COLUMN_TAPS))).rgb;\n }\n column /= float(COLUMN_TAPS);\n\n float dy = v_uv.y - 0.5;\n float reach = 0.02 + 0.03 * collapse;\n light +=\n column *\n mix(vec3(1.0), u_phosphor, 0.65) *\n exp(-(dy * dy) / (reach * reach)) *\n bleed *\n 0.9;\n }\n\n if (pinch > 0.0) {\n vec2 d = (v_uv - 0.5) * vec2(u_aspect, 1.0);\n float radius = max(0.045 * glow, 0.0005);\n light +=\n u_phosphor *\n exp(-dot(d, d) / (radius * radius)) *\n smoothstep(0.0, 0.5, pinch) *\n 1.15;\n }\n\n light *= pow(max(1.0 - decayed, 0.0001), DECAY_CURVE);\n\n float blackout = smoothstep(0.0, BLACKOUT_IN, p);\n outColor = vec4(\n clamp(light, 0.0, 1.0),\n mix(texture(u_scene, v_uv).a, 1.0, blackout)\n );\n}`;\n\nconst clamp = (value: number, min: number, max: number) =>\n Math.min(max, Math.max(min, value));\n\nfunction toRgb(hex: string): [number, number, number] {\n const value = hex.replace(\"#\", \"\");\n const full =\n value.length === 3\n ? value\n .split(\"\")\n .map((c) => c + c)\n .join(\"\")\n : value;\n const int = Number.parseInt(full, 16);\n if (Number.isNaN(int)) return [1, 1, 1];\n return [\n ((int >> 16) & 255) / 255,\n ((int >> 8) & 255) / 255,\n (int & 255) / 255,\n ];\n}\n\nfunction powerProgress(props: TvPowerOffProps, frame: number): number {\n const {\n durationInFrames = DEFAULTS.durationInFrames,\n delay = DEFAULTS.delay,\n } = props;\n return clamp((frame - delay) / Math.max(1, durationInFrames), 0, 1);\n}\n\nconst shader = makeFilterShader<TvPowerOffProps>(\n FRAGMENT_SHADER,\n ({ gl, uniform, width, height, frame, passedProps }) => {\n const {\n gain = DEFAULTS.gain,\n afterglow = DEFAULTS.afterglow,\n phosphor = DEFAULTS.phosphor,\n } = passedProps;\n gl.uniform1f(uniform(\"u_progress\"), powerProgress(passedProps, frame));\n gl.uniform2f(uniform(\"u_resolution\"), width, height);\n gl.uniform1f(uniform(\"u_gain\"), gain);\n gl.uniform1f(uniform(\"u_afterglow\"), afterglow);\n gl.uniform3fv(uniform(\"u_phosphor\"), toRgb(phosphor));\n },\n);\n\nconst TvPowerOffFallback: React.FC<TvPowerOffProps & CanvasFilterProps> = (\n props,\n) => {\n const frame = useCurrentFrame();\n const {\n children,\n gain = DEFAULTS.gain,\n afterglow = DEFAULTS.afterglow,\n phosphor = DEFAULTS.phosphor,\n } = props;\n\n const p = powerProgress(props, frame);\n const collapse = clamp(p / COLLAPSE_END, 0, 1);\n const pinch = clamp((p - COLLAPSE_END) / (PINCH_END - COLLAPSE_END), 0, 1);\n const decayed = clamp((p - PINCH_END) / (1 - PINCH_END), 0, 1);\n\n const squash = MIN_SQUASH ** collapse;\n const pinchX = MIN_PINCH ** pinch;\n const concentrate = (1 / (squash * pinchX)) ** CONCENTRATION;\n const fade = (1 - decayed) ** DECAY_CURVE;\n\n return (\n <AbsoluteFill>\n <AbsoluteFill\n style={{\n background: \"#000000\",\n opacity: clamp(p / BLACKOUT_IN, 0, 1),\n }}\n />\n <AbsoluteFill\n style={{\n scale: `${pinchX} ${squash}`,\n filter: `brightness(${1 + (concentrate - 1) * Math.max(gain, 0)})`,\n opacity: fade,\n }}\n >\n {children}\n </AbsoluteFill>\n <AbsoluteFill\n style={{\n background: `radial-gradient(circle at 50% 50%, ${phosphor} 0%, transparent 55%)`,\n opacity: clamp(pinch * afterglow, 0, 1) * fade,\n }}\n />\n </AbsoluteFill>\n );\n};\n\nexport const TvPowerOff = makeCanvasFilter<TvPowerOffProps>({\n shader,\n fallback: TvPowerOffFallback,\n});"diff --git a/registry-artifacts/elements/type-fossil.json b/registry-artifacts/elements/type-fossil.jsonindex 0dcc062d..726a56de 100644--- a/registry-artifacts/elements/type-fossil.json+++ b/registry-artifacts/elements/type-fossil.json@@ -2,10 +2,12 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [],"dimensions": null,"displayName": "Type Fossil","durationInFrames": 174,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "type-fossil","sourceCode": "import { forwardRef, useId, useImperativeHandle, useRef, type ComponentProps } from \"react\";\nimport { Easing, Interactive, Sequence, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\n\ninterface TypeFossilProps {\n text?: string;\n /** Earlier versions, separated by | or newlines. Up to twelve drafts. */\n drafts?: string;\n layers?: number;\n /** Thickness of the typographic slice, in reference pixels. */\n depth?: number;\n fontSize?: number;\n fontWeight?: number | string;\n color?: string;\n accentColor?: string;\n backgroundColor?: string;\n speed?: number;\n className?: string;\n}\n\nconst typeFossilLength = 174;\nconst typeFossilDefaultDrafts =\n \"Idea | Maybe | Try | Almost | Again | Closer\";\nconst finite = (n: number, fallback: number) =>\n Number.isFinite(n) ? n : fallback;\nconst clamp = (n: number) => Math.min(1, Math.max(0, n));\nconst mix = (a: number, b: number, p: number) => a + (b - a) * p;\nconst progress = (t: number, a: number, b: number) => clamp((t - a) / (b - a));\nconst ease = Easing.bezier(0.65, 0, 0.3, 1);\nconst out = Easing.bezier(0.16, 1, 0.3, 1);\n\nfunction parseFossilDrafts(drafts: string) {\n return drafts\n .split(/[|\\n\\r]+/)\n .map((value) => value.trim().replace(/\\s+/g, \" \"))\n .filter(Boolean)\n .slice(0, 12);\n}\n\nfunction timing(draftCount: number) {\n const count = Math.round(Math.max(0, Math.min(12, finite(draftCount, 6))));\n const collapseStart = count === 0 ? 16 : 20 + (count - 1) * 18 + 16;\n return { draftCount: count, collapseStart, settle: collapseStart + 48 };\n}\n\nfunction getTypeFossilDuration({\n drafts = typeFossilDefaultDrafts,\n speed = 1,\n}: Pick<TypeFossilProps, \"drafts\" | \"speed\"> = {}) {\n const rate = Math.max(0, finite(speed, 1));\n const { settle } = timing(parseFossilDrafts(drafts).length);\n return rate === 0 ? 1 : Math.max(1, Math.ceil((settle + 34) / rate));\n}\n\n/** One readable revision at a time, followed by a single compression into print. */\nfunction getTypeFossilState(\n frame: number,\n {\n layers = 16,\n depth = 100,\n draftCount = 6,\n }: Pick<TypeFossilProps, \"layers\" | \"depth\"> & { draftCount?: number } = {},\n) {\n const t = Math.max(0, finite(frame, 0));\n const count = Math.round(Math.max(4, Math.min(24, finite(layers, 16))));\n const thickness = Math.max(50, Math.min(150, finite(depth, 100)));\n const schedule = timing(draftCount);\n const collapse = ease(progress(t, schedule.collapseStart, schedule.settle));\n const open = mix(0.55, 1, out(progress(t, 0, 16)));\n const spread = open * (1 - collapse);\n let from = 0;\n let to = 0;\n let change = 0;\n for (let revision = 0; revision < schedule.draftCount; revision++) {\n const start = 20 + revision * 18;\n if (t < start) break;\n if (t >= start + 8) {\n from = revision + 1;\n to = from;\n change = 0;\n } else {\n from = revision;\n to = revision + 1;\n change = ease(progress(t, start, start + 8));\n break;\n }\n }\n return {\n frame: t,\n count,\n thickness,\n from,\n to,\n change,\n draftCount: schedule.draftCount,\n settle: schedule.settle,\n collapse,\n spread,\n spanX: thickness * 1.35 * spread,\n spanY: -thickness * 0.68 * spread,\n skew: -10 * (1 - collapse),\n ghostOpacity: 1 - ease(progress(t, schedule.settle - 18, schedule.settle)),\n };\n}\n\n/** Bounded parallel contours, no perspective division or near-plane disappearance. */\nfunction getFossilLayerPose(\n state: ReturnType<typeof getTypeFossilState>,\n index: number,\n) {\n const i = Math.round(\n Math.max(0, Math.min(state.count - 1, finite(index, 0))),\n );\n const fraction = i / (state.count - 1);\n return {\n x: 640 + state.spanX / 2 - state.spanX * fraction,\n y: 360 + state.spanY / 2 - state.spanY * fraction,\n opacity: i === 0 ? 1 : state.ghostOpacity,\n skew: state.skew,\n fraction,\n };\n}\n\nfunction fitSize(text: string, fontSize: number) {\n const widthUnits = Array.from(text).reduce(\n (sum, char) =>\n sum +\n (/\\s/.test(char)\n ? 0.35\n : /[ilI.,'!:;]/.test(char)\n ? 0.4\n : /[MW@ЖШЩЮ]/.test(char)\n ? 1\n : 0.8),\n 0,\n );\n return Math.min(fontSize, 720 / Math.max(1, widthUnits));\n}\n\nfunction TypeFossilBase({\n text = \"Form\",\n drafts = typeFossilDefaultDrafts,\n layers = 16,\n depth = 100,\n fontSize = 220,\n fontWeight = 600,\n color = \"#302b26\",\n accentColor = \"#a800b7\",\n backgroundColor = \"#eeeae2\",\n speed = 1,\n className,\n}: TypeFossilProps) {\n const id = useId().replace(/:/g, \"\");\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const finalText = text.trim().replace(/\\s+/g, \" \");\n const revisions = [...parseFossilDrafts(drafts), finalText];\n const state = getTypeFossilState(\n ((frame * 30) / fps) * Math.max(0, finite(speed, 1)),\n { layers, depth, draftCount: revisions.length - 1 },\n );\n const size = Math.max(24, Math.min(300, finite(fontSize, 220)));\n const weight = Math.max(100, Math.min(900, finite(Number(fontWeight), 600)));\n const wipeX = mix(-100, 1380, state.change);\n const renderSlice = (copy: string) => {\n const font = fitSize(copy, size);\n return Array.from({ length: state.count }, (_, order) => {\n const index = state.count - 1 - order;\n const pose = getFossilLayerPose(state, index);\n return (\n <text\n key={index}\n x=\"0\"\n y={font * 0.35}\n textAnchor=\"middle\"\n fontSize={font}\n fontWeight={weight}\n transform={`translate(${pose.x} ${pose.y}) skewX(${pose.skew})`}\n fill={index === 0 ? color : \"none\"}\n stroke={index === 0 ? \"none\" : accentColor}\n strokeWidth={index === 0 ? 0 : 0.75}\n strokeOpacity={0.18 + (1 - pose.fraction) * 0.38}\n opacity={pose.opacity}\n paintOrder=\"stroke fill\"\n >\n {copy}\n </text>\n );\n });\n };\n return (\n <div\n className={className}\n style={{\n position: \"absolute\",\n inset: 0,\n overflow: \"hidden\",\n backgroundColor,\n fontFamily: \"Arial, Helvetica, sans-serif\",\n }}\n >\n <svg\n width=\"100%\"\n height=\"100%\"\n viewBox=\"0 0 1280 720\"\n preserveAspectRatio=\"xMidYMid meet\"\n role=\"img\"\n aria-label={finalText || \"Empty type fossil\"}\n >\n <defs>\n <clipPath id={`${id}-old`}>\n <rect\n x={wipeX}\n y=\"-100\"\n width={1480 - (wipeX + 100)}\n height=\"920\"\n />\n </clipPath>\n <clipPath id={`${id}-new`}>\n <rect x=\"-100\" y=\"-100\" width={wipeX + 100} height=\"920\" />\n </clipPath>\n </defs>\n {finalText ? (\n state.from === state.to ? (\n renderSlice(revisions[state.from])\n ) : (\n <>\n <g clipPath={`url(#${id}-old)`}>\n {renderSlice(revisions[state.from])}\n </g>\n <g clipPath={`url(#${id}-new)`}>\n {renderSlice(revisions[state.to])}\n </g>\n </>\n )\n ) : null}\n </svg>\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n text: {\n type: \"text-content\",\n default: \"Form\",\n description: \"Final word\",\n },\n drafts: {\n type: \"text-content\",\n default: \"Idea | Maybe | Try | Almost | Again | Closer\",\n description: \"Drafts (separate with |)\",\n },\n layers: {\n type: \"number\",\n default: 16,\n min: 4,\n max: 24,\n step: 1,\n description: \"Contour layers\",\n hiddenFromList: false,\n },\n depth: {\n type: \"number\",\n default: 100,\n min: 50,\n max: 150,\n step: 5,\n description: \"Slice depth\",\n hiddenFromList: false,\n },\n fontSize: {\n type: \"number\",\n default: 220,\n min: 24,\n max: 300,\n step: 1,\n description: \"Font size\",\n hiddenFromList: false,\n },\n fontWeight: {\n type: \"enum\",\n default: \"600\",\n variants: {\n \"400\": {},\n \"500\": {},\n \"600\": {},\n \"700\": {},\n },\n description: \"Font weight\",\n },\n color: {\n type: \"color\",\n default: \"#302b26\",\n description: \"Ink\",\n },\n accentColor: {\n type: \"color\",\n default: \"#a800b7\",\n description: \"Contours\",\n },\n backgroundColor: {\n type: \"color\",\n default: \"#eeeae2\",\n description: \"Background\",\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"text\",\"drafts\",\"layers\",\"depth\",\"fontSize\",\"fontWeight\",\"color\",\"accentColor\",\"backgroundColor\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n text: \"Form\",\n drafts: \"Idea | Maybe | Try | Almost | Again | Closer\",\n layers: 16,\n depth: 100,\n fontSize: 220,\n fontWeight: \"600\",\n color: \"#302b26\",\n accentColor: \"#a800b7\",\n backgroundColor: \"#eeeae2\",\n speed: 1,\n};\n\ntype TypeFossilElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof TypeFossilBase>;\n\nconst TypeFossilInner = forwardRef<\n HTMLDivElement,\n TypeFossilElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<TypeFossil>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <TypeFossilBase\n {...(componentProps as unknown as ComponentProps<typeof TypeFossilBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const TypeFossil = Interactive.withSchema({\n Component: TypeFossilInner,\n componentName: \"<TypeFossil>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/type-repeater.json b/registry-artifacts/elements/type-repeater.jsonindex 9cc7bed7..8e9e0e37 100644--- a/registry-artifacts/elements/type-repeater.json+++ b/registry-artifacts/elements/type-repeater.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/google-fonts",@@ -11,6 +12,7 @@"dimensions": null,"displayName": "Type Repeater","durationInFrames": 90,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "type-repeater","sourceCode": "import { loadFont } from \"@remotion/google-fonts/Inter\";\nimport { forwardRef, useId, useImperativeHandle, useRef, type ComponentProps } from \"react\";\nimport { Easing, Interactive, Sequence, interpolate, interpolateColors, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\n\nconst { fontFamily: INTER } = loadFont(\"normal\", {\n weights: [\"100\", \"900\"],\n subsets: [\"latin\"],\n});\n\ntype TypeRepeaterMode = \"fan\" | \"spiral\" | \"tunnel\";\n\ninterface TypeRepeaterProps {\n text?: string;\n copies?: number;\n mode?: TypeRepeaterMode;\n fontSize?: number;\n fontWeight?: number;\n fontFamily?: string;\n color?: string;\n accent?: string;\n outline?: boolean;\n speed?: number;\n className?: string;\n}\n\nconst typeRepeaterDefaults = {\n text: \"Repeat\",\n copies: 12,\n mode: \"tunnel\",\n fontSize: 110,\n fontWeight: 800,\n fontFamily: INTER,\n color: \"#fafafa\",\n accent: \"#D97757\",\n outline: true,\n speed: 1,\n} satisfies Required<Omit<TypeRepeaterProps, \"className\">>;\n\n/** Beats on the 30 fps clock. */\nconst typeRepeaterTiming = {\n intro: [0, 10],\n unfold: [10, 34],\n breathe: [34, 70],\n collapse: [70, 90],\n} as const;\n\n/** Frame where the copies have folded back into the word. */\nconst typeRepeaterLength = typeRepeaterTiming.collapse[1];\n\n/**\n * Per-copy steps for each mode. `fan` alternates sides around a pivot below\n * the word; `spiral` and `tunnel` grow each copy outward behind it.\n */\nconst typeRepeaterModes = {\n fan: { rotate: 11, scale: 1, pivot: 2.6, symmetric: true },\n spiral: { rotate: 12, scale: 1.1, pivot: 0, symmetric: false },\n tunnel: { rotate: 0, scale: 1.2, pivot: 0, symmetric: false },\n} as const satisfies Record<\n TypeRepeaterMode,\n { rotate: number; scale: number; pivot: number; symmetric: boolean }\n>;\n\nconst BREATHE = 0.06;\nconst FADE = 0.85;\n\nconst CLAMP = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n} as const;\n\nconst easeOutCubic = Easing.out(Easing.cubic);\nconst easeInOutCubic = Easing.inOut(Easing.cubic);\nconst unfoldEase = Easing.out(Easing.back(1.4));\n\nfunction finite(value: number | undefined, fallback: number) {\n return typeof value === \"number\" && Number.isFinite(value) ? value : fallback;\n}\n\n/** Maps a composition frame onto the 30 fps timeline, scaled by `speed`. */\nfunction getTypeRepeaterTime(\n frame: number,\n options: { fps?: number; speed?: number } = {},\n) {\n const fps = Math.max(1, finite(options.fps, 30));\n const speed = Math.max(0, finite(options.speed, 1));\n return (Math.max(0, finite(frame, 0)) * 30 * speed) / fps;\n}\n\n/** How far the copies have spread, 0 (one word) to about 1. */\nfunction getTypeRepeaterSpread(t: number) {\n const { unfold, breathe, collapse } = typeRepeaterTiming;\n if (t < breathe[0]) {\n return interpolate(t, [...unfold], [0, 1], {\n ...CLAMP,\n easing: unfoldEase,\n });\n }\n if (t < breathe[1]) {\n const phase = (t - breathe[0]) / (breathe[1] - breathe[0]);\n return 1 + BREATHE * Math.sin(2 * Math.PI * phase);\n }\n return interpolate(t, [...collapse], [1, 0], {\n ...CLAMP,\n easing: easeInOutCubic,\n });\n}\n\n/** Entrance of the front word, 0..1. */\nfunction getTypeRepeaterIntro(t: number) {\n return interpolate(t, [...typeRepeaterTiming.intro], [0, 1], {\n ...CLAMP,\n easing: easeOutCubic,\n });\n}\n\ninterface TypeRepeaterCopy {\n rotate: number;\n scale: number;\n opacity: number;\n /** 0 for the word's color, 1 for the accent. */\n tint: number;\n}\n\n/** Transform and fade of copy `index` (0 is the word itself). */\nfunction getTypeRepeaterCopy(\n index: number,\n copies: number,\n spread: number,\n mode: TypeRepeaterMode,\n): TypeRepeaterCopy {\n const step = typeRepeaterModes[mode] ?? typeRepeaterModes.spiral;\n const n = Math.max(1, Math.round(copies));\n const steps = step.symmetric ? Math.ceil(index / 2) : index;\n const side = step.symmetric && index % 2 === 0 ? -1 : 1;\n const reach = steps * spread;\n return {\n rotate: side * step.rotate * reach || 0,\n scale: step.scale ** reach,\n opacity:\n index === 0\n ? 1\n : (1 - (FADE * index) / n) * Math.min(1, Math.max(0, spread * 4)),\n tint: n > 1 ? index / (n - 1) : 0,\n };\n}\n\nfunction TypeRepeaterBase({\n text = typeRepeaterDefaults.text,\n copies = typeRepeaterDefaults.copies,\n mode = typeRepeaterDefaults.mode,\n fontSize = typeRepeaterDefaults.fontSize,\n fontWeight = typeRepeaterDefaults.fontWeight,\n fontFamily = typeRepeaterDefaults.fontFamily,\n color = typeRepeaterDefaults.color,\n accent = typeRepeaterDefaults.accent,\n outline = typeRepeaterDefaults.outline,\n speed = typeRepeaterDefaults.speed,\n className,\n}: TypeRepeaterProps) {\n const frame = useCurrentFrame();\n const { fps, height } = useVideoConfig();\n const outlineId = `type-repeater-${useId().replace(/[^a-zA-Z0-9_-]/g, \"\")}`;\n const unit = height / 720;\n const size = fontSize * unit;\n const t = getTypeRepeaterTime(frame, { fps, speed });\n const spread = getTypeRepeaterSpread(t);\n const intro = getTypeRepeaterIntro(t);\n const count = Math.max(1, Math.round(finite(copies, 12)));\n const pivot = (typeRepeaterModes[mode] ?? typeRepeaterModes.spiral).pivot;\n\n return (\n <div\n className={className}\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n overflow: \"hidden\",\n }}\n >\n {outline ? (\n // Outline from the filled silhouette: the variable font's overlapping\n // contours would show through a text stroke.\n <svg width={0} height={0} style={{ position: \"absolute\" }} aria-hidden>\n <defs>\n <filter id={outlineId}>\n <feMorphology\n in=\"SourceAlpha\"\n operator=\"erode\"\n radius={1.5 * unit}\n result=\"inner\"\n />\n <feComposite in=\"SourceGraphic\" in2=\"inner\" operator=\"out\" />\n </filter>\n </defs>\n </svg>\n ) : null}\n <div\n style={{\n position: \"relative\",\n opacity: intro,\n transform: `scale(${0.9 + 0.1 * intro})`,\n }}\n >\n {Array.from({ length: count }, (_, i) => count - 1 - i).map((i) => {\n const copy = getTypeRepeaterCopy(i, count, spread, mode);\n if (copy.opacity <= 0) return null;\n return (\n <div\n key={i}\n aria-hidden={i > 0}\n style={{\n position: i === 0 ? \"relative\" : \"absolute\",\n inset: i === 0 ? undefined : 0,\n fontFamily,\n fontSize: size,\n lineHeight: 1,\n fontWeight,\n fontVariationSettings: `\"wght\" ${fontWeight}`,\n whiteSpace: \"pre\",\n color: interpolateColors(copy.tint, [0, 1], [color, accent]),\n opacity: copy.opacity,\n filter: outline && i > 0 ? `url(#${outlineId})` : undefined,\n transformOrigin: `50% calc(50% + ${pivot}em)`,\n transform: `rotate(${copy.rotate}deg) scale(${copy.scale})`,\n }}\n >\n {text}\n </div>\n );\n })}\n </div>\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n text: {\n type: \"text-content\",\n default: \"Repeat\",\n description: \"Text\",\n },\n mode: {\n type: \"enum\",\n default: \"tunnel\",\n variants: {\n tunnel: {},\n spiral: {},\n fan: {},\n },\n description: \"Mode\",\n },\n color: {\n type: \"color\",\n default: \"#111111\",\n description: \"Word color\",\n },\n accent: {\n type: \"color\",\n default: \"#fafafa\",\n description: \"Last copy\",\n },\n copies: {\n type: \"number\",\n default: 12,\n min: 2,\n max: 24,\n step: 1,\n description: \"Copies\",\n hiddenFromList: false,\n },\n fontSize: {\n type: \"number\",\n default: 110,\n min: 40,\n max: 240,\n step: 2,\n description: \"Font size\",\n hiddenFromList: false,\n },\n fontWeight: {\n type: \"number\",\n default: 800,\n min: 100,\n max: 900,\n step: 50,\n description: \"Weight\",\n hiddenFromList: false,\n },\n outline: {\n type: \"boolean\",\n default: true,\n description: \"Outline copies\",\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"text\",\"mode\",\"color\",\"accent\",\"copies\",\"fontSize\",\"fontWeight\",\"outline\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n text: \"Repeat\",\n mode: \"tunnel\",\n color: \"#111111\",\n accent: \"#fafafa\",\n copies: 12,\n fontSize: 110,\n fontWeight: 800,\n outline: true,\n speed: 1,\n};\n\ntype TypeRepeaterElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof TypeRepeaterBase>;\n\nconst TypeRepeaterInner = forwardRef<\n HTMLDivElement,\n TypeRepeaterElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<TypeRepeater>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <TypeRepeaterBase\n {...(componentProps as unknown as ComponentProps<typeof TypeRepeaterBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const TypeRepeater = Interactive.withSchema({\n Component: TypeRepeaterInner,\n componentName: \"<TypeRepeater>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/type-wall.json b/registry-artifacts/elements/type-wall.jsonindex 48ccc493..29720ddf 100644--- a/registry-artifacts/elements/type-wall.json+++ b/registry-artifacts/elements/type-wall.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/google-fonts",@@ -11,6 +12,7 @@"dimensions": null,"displayName": "Type Wall","durationInFrames": 150,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "type-wall","sourceCode": "import { loadFont as loadAnton } from \"@remotion/google-fonts/Anton\";\nimport { loadFont as loadInter } from \"@remotion/google-fonts/Inter\";\nimport { forwardRef, useId, useImperativeHandle, useRef, type ComponentProps } from \"react\";\nimport { Easing, Interactive, Sequence, interpolate, random, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\n\nconst { fontFamily: INTER } = loadInter(\"normal\", {\n weights: [\"900\"],\n subsets: [\"latin\"],\n});\nconst { fontFamily: ANTON } = loadAnton(\"normal\", {\n weights: [\"400\"],\n subsets: [\"latin\"],\n});\n\ntype TypeWallStyle = \"solid\" | \"narrow\" | \"outline\";\n\ninterface TypeWallProps {\n text?: string;\n separator?: string;\n fontSize?: number;\n color?: string;\n accent?: string;\n accentText?: string;\n seed?: number;\n speed?: number;\n className?: string;\n}\n\nconst typeWallDefaults = {\n text: \"MOTION\",\n separator: \"·\",\n fontSize: 64,\n color: \"#fafafa\",\n accent: \"#D97757\",\n accentText: \"#0a0a0a\",\n seed: 7,\n speed: 1,\n} satisfies Required<Omit<TypeWallProps, \"className\">>;\n\n/** Row faces away from the center, the accent row always solid. */\nconst typeWallStyles: readonly TypeWallStyle[] = [\n \"solid\",\n \"narrow\",\n \"outline\",\n];\n\n/** Anton sized so its capitals match Inter's cap height (0.7275 / 0.8594 em). */\nconst NARROW_SCALE = 0.7275 / 0.8594;\n/** Tokens per second at speed 1, before each row's seeded factor. */\nconst TOKENS_PER_SECOND = 0.22;\nconst ENTRANCE = 20;\nconst STAGGER = 2;\n/** Tokens a row streams past on its way in, on top of its cruise. */\nconst ENTRANCE_BURST = 2.5;\nconst BAND = [6, 20] as const;\n/** Lower bound on a token's width per character, in em, for the repeat count. */\nconst MIN_CHAR_WIDTH = 0.4;\nconst MAX_TOKENS = 48;\n\nconst CLAMP = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n} as const;\n\nconst easeOutCubic = Easing.out(Easing.cubic);\n\nfunction finite(value: number | undefined, fallback: number) {\n return typeof value === \"number\" && Number.isFinite(value) ? value : fallback;\n}\n\nfunction fract(x: number) {\n return x - Math.floor(x);\n}\n\n/** Maps a composition frame onto the 30 fps timeline, scaled by `speed`. */\nfunction getTypeWallTime(\n frame: number,\n options: { fps?: number; speed?: number } = {},\n) {\n const fps = Math.max(1, finite(options.fps, 30));\n const speed = Math.max(0, finite(options.speed, 1));\n return (Math.max(0, finite(frame, 0)) * 30 * speed) / fps;\n}\n\n/** Row indices from the top of the frame to the bottom; row 0 is centered. */\nfunction getTypeWallRows(height: number, rowHeight: number) {\n const reach = Math.ceil((height / 2 - rowHeight / 2) / rowHeight) + 1;\n const rows: number[] = [];\n for (let k = -reach; k <= reach; k++) rows.push(k);\n return rows;\n}\n\nfunction getTypeWallStyle(row: number): TypeWallStyle {\n if (row === 0) return \"solid\";\n const n = typeWallStyles.length;\n return typeWallStyles[((row % n) + n) % n];\n}\n\n/** −1 runs left, 1 runs right. The accent row runs left. */\nfunction getTypeWallDirection(row: number) {\n return Math.abs(row) % 2 === 0 ? -1 : 1;\n}\n\n/** Cruise speed in tokens per frame and the row's starting phase. */\nfunction getTypeWallMotion(row: number, seed: number) {\n const factor = 0.7 + 0.6 * random(`type-wall-${seed}-speed-${row}`);\n return {\n velocity: (TOKENS_PER_SECOND * factor) / 30,\n phase: random(`type-wall-${seed}-phase-${row}`),\n };\n}\n\ninterface TypeWallRowState {\n direction: number;\n /** Translation of the token strip in tokens, always in [−1, 0). */\n shift: number;\n /** Share of the row revealed from its entering side, 0..1. */\n reveal: number;\n}\n\nfunction getTypeWallRow(\n t: number,\n row: number,\n seed = typeWallDefaults.seed,\n): TypeWallRowState {\n const direction = getTypeWallDirection(row);\n const { velocity, phase } = getTypeWallMotion(row, seed);\n const e = easeOutCubic(\n Math.min(1, Math.max(0, (t - STAGGER * Math.abs(row)) / ENTRANCE)),\n );\n const travel = phase + velocity * t + ENTRANCE_BURST * e;\n // Leftward rows slide the strip left; rightward rows run it from −1 up to 0.\n const shift = direction < 0 ? -fract(travel) : fract(travel) - 1;\n return { direction, shift: shift || 0, reveal: e };\n}\n\n/** The accent band growing from the center, 0..1. */\nfunction getTypeWallBand(t: number) {\n return interpolate(t, [...BAND], [0, 1], { ...CLAMP, easing: easeOutCubic });\n}\n\n/** Frame where the slowest (outermost) row has finished entering. */\nfunction getTypeWallEntranceEnd(height: number, rowHeight: number) {\n const rows = getTypeWallRows(height, rowHeight);\n return ENTRANCE + STAGGER * Math.max(...rows.map(Math.abs));\n}\n\n/** How many tokens a strip needs to cover the width twice over. */\nfunction getTypeWallTokenCount(\n width: number,\n fontSize: number,\n token: string,\n) {\n const tokenWidth =\n Math.max(1, Array.from(token).length) * MIN_CHAR_WIDTH * fontSize;\n return Math.min(MAX_TOKENS, Math.ceil(width / tokenWidth) + 2);\n}\n\nfunction TypeWallBase({\n text = typeWallDefaults.text,\n separator = typeWallDefaults.separator,\n fontSize = typeWallDefaults.fontSize,\n color = typeWallDefaults.color,\n accent = typeWallDefaults.accent,\n accentText = typeWallDefaults.accentText,\n seed = typeWallDefaults.seed,\n speed = typeWallDefaults.speed,\n className,\n}: TypeWallProps) {\n const frame = useCurrentFrame();\n const { fps, width, height } = useVideoConfig();\n const unit = height / 720;\n const rowHeight = Math.max(8, fontSize * unit);\n const t = getTypeWallTime(frame, { fps, speed });\n const rows = getTypeWallRows(height, rowHeight);\n const token = `${text} ${separator} `;\n const band = getTypeWallBand(t);\n const outlineId = `type-wall-${useId().replace(/[^a-zA-Z0-9_-]/g, \"\")}`;\n\n return (\n <div\n className={className}\n style={{ position: \"absolute\", inset: 0, overflow: \"hidden\" }}\n >\n {/* Outline from the filled silhouette: the variable font's overlapping\n contours would show through a text stroke. */}\n <svg width={0} height={0} style={{ position: \"absolute\" }} aria-hidden>\n <defs>\n <filter id={outlineId}>\n <feMorphology\n in=\"SourceAlpha\"\n operator=\"erode\"\n radius={1.5 * unit}\n result=\"inner\"\n />\n <feComposite\n in=\"SourceAlpha\"\n in2=\"inner\"\n operator=\"out\"\n result=\"ring\"\n />\n <feFlood floodColor={color} />\n <feComposite in2=\"ring\" operator=\"in\" />\n </filter>\n </defs>\n </svg>\n {rows.map((row) => {\n const style = getTypeWallStyle(row);\n const state = getTypeWallRow(t, row, seed);\n const narrow = style === \"narrow\";\n const size = narrow ? rowHeight * NARROW_SCALE : rowHeight;\n const count = getTypeWallTokenCount(width, size, token);\n const onBand = row === 0;\n const hidden = `${(1 - state.reveal) * 100}%`;\n return (\n <div\n key={row}\n style={{\n position: \"absolute\",\n left: 0,\n right: 0,\n top: height / 2 + (row - 0.5) * rowHeight,\n height: rowHeight,\n clipPath:\n state.direction < 0\n ? `inset(0 0 0 ${hidden})`\n : `inset(0 ${hidden} 0 0)`,\n }}\n >\n {onBand ? (\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n background: accent,\n transform: `scaleX(${band})`,\n }}\n />\n ) : null}\n <div\n style={{\n position: \"absolute\",\n left: 0,\n top: 0,\n width: \"max-content\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n whiteSpace: \"pre\",\n fontFamily: narrow ? ANTON : INTER,\n fontSize: size,\n lineHeight: 1,\n fontWeight: narrow ? 400 : 900,\n color: onBand ? accentText : color,\n filter: style === \"outline\" ? `url(#${outlineId})` : undefined,\n transform: `translateX(${(state.shift * 100) / count}%)`,\n }}\n >\n {Array.from({ length: count }, (_, i) => (\n <span key={i}>{token}</span>\n ))}\n </div>\n </div>\n );\n })}\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n text: {\n type: \"text-content\",\n default: \"MOTION\",\n description: \"Text\",\n },\n separator: {\n type: \"text-content\",\n default: \"·\",\n description: \"Separator\",\n },\n color: {\n type: \"color\",\n default: \"#fafafa\",\n description: \"Text color\",\n },\n accent: {\n type: \"color\",\n default: \"#ff4d1a\",\n description: \"Band color\",\n },\n accentText: {\n type: \"color\",\n default: \"#111111\",\n description: \"Band text\",\n },\n fontSize: {\n type: \"number\",\n default: 64,\n min: 24,\n max: 180,\n step: 2,\n description: \"Row height\",\n hiddenFromList: false,\n },\n seed: {\n type: \"number\",\n default: 7,\n min: 0,\n max: 99,\n step: 1,\n description: \"Seed\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"text\",\"separator\",\"color\",\"accent\",\"accentText\",\"fontSize\",\"seed\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n text: \"MOTION\",\n separator: \"·\",\n color: \"#fafafa\",\n accent: \"#ff4d1a\",\n accentText: \"#111111\",\n fontSize: 64,\n seed: 7,\n speed: 1,\n};\n\ntype TypeWallElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof TypeWallBase>;\n\nconst TypeWallInner = forwardRef<\n HTMLDivElement,\n TypeWallElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<TypeWall>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <TypeWallBase\n {...(componentProps as unknown as ComponentProps<typeof TypeWallBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const TypeWall = Interactive.withSchema({\n Component: TypeWallInner,\n componentName: \"<TypeWall>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/typed-split-wipe.json b/registry-artifacts/elements/typed-split-wipe.jsonindex 5dbfb7b3..3cd16a7c 100644--- a/registry-artifacts/elements/typed-split-wipe.json+++ b/registry-artifacts/elements/typed-split-wipe.json@@ -2,10 +2,12 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [],"dimensions": null,"displayName": "Typed Split Wipe","durationInFrames": 75,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "typed-split-wipe","sourceCode": "import { forwardRef, useImperativeHandle, useRef, type CSSProperties, type ComponentProps } from \"react\";\nimport { Easing, Interactive, Sequence, interpolate, useCurrentFrame, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\n\ninterface TypedSplitWipeProps {\n prefix: string;\n anchor: string;\n suffix: string;\n typeFrames?: number;\n exitAt?: number;\n exitFrames?: number;\n wordStagger?: number;\n anchorShift?: number;\n fontSize?: number;\n color?: string;\n fontWeight?: number;\n speed?: number;\n className?: string;\n}\n\nconst clamp = {\n extrapolateLeft: \"clamp\" as const,\n extrapolateRight: \"clamp\" as const,\n};\nconst wipeEasing = Easing.inOut(Easing.quad);\n\nfunction getTypedSplitWipeText(\n text: string,\n frame: number,\n typeFrames: number,\n) {\n const characters = Array.from(text);\n const typedLength = interpolate(\n frame,\n [0, Math.max(typeFrames, 0.001)],\n [0, characters.length],\n clamp,\n );\n const visibleLength = Math.min(\n characters.length,\n Math.max(frame >= 0 ? 1 : 0, Math.floor(typedLength) + 1),\n );\n return characters.slice(0, visibleLength).join(\"\");\n}\n\nfunction TypedSplitWipeBase({\n prefix,\n anchor,\n suffix,\n typeFrames = 30,\n exitAt = 50,\n exitFrames = 20,\n wordStagger = 4,\n anchorShift = -72,\n fontSize = 42,\n color = \"#e8e8e8\",\n fontWeight = 400,\n speed = 1,\n className,\n}: TypedSplitWipeProps) {\n const frame = useCurrentFrame() * speed;\n const fullText = [prefix, anchor, suffix].filter(Boolean).join(\" \");\n const safeExitFrames = Math.max(exitFrames, 0.001);\n const typedText = getTypedSplitWipeText(fullText, frame, typeFrames);\n const suffixWords = suffix.trim().split(/\\s+/).filter(Boolean);\n\n const textStyle: CSSProperties = {\n color,\n fontFamily:\n \"var(--font-geist-sans, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif)\",\n fontSize,\n fontWeight,\n letterSpacing: \"-0.03em\",\n lineHeight: 1,\n whiteSpace: \"pre\",\n };\n\n const prefixExit = interpolate(\n frame,\n [exitAt, exitAt + safeExitFrames],\n [0, 1],\n { ...clamp, easing: wipeEasing },\n );\n const anchorExitStart = exitAt + Math.max(exitFrames - 6, 0);\n const anchorExit = interpolate(\n frame,\n [anchorExitStart, anchorExitStart + 6],\n [0, 1],\n { ...clamp, easing: wipeEasing },\n );\n\n return (\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n overflow: \"hidden\",\n background: \"transparent\",\n }}\n >\n {frame < exitAt ? (\n <span className={className} style={textStyle}>\n {typedText}\n </span>\n ) : (\n <span\n className={className}\n style={{\n ...textStyle,\n display: \"inline-flex\",\n alignItems: \"baseline\",\n gap: \"0.25em\",\n }}\n >\n {prefix && (\n <span\n style={{\n display: \"inline-block\",\n clipPath: `inset(0 ${prefixExit * 100}% 0 0)`,\n }}\n >\n {prefix}\n </span>\n )}\n\n {anchor && (\n <span\n style={{\n display: \"inline-block\",\n clipPath: `inset(0 ${anchorExit * 50}% 0 ${anchorExit * 50}%)`,\n transform: `translateX(${anchorShift * prefixExit}px)`,\n }}\n >\n {anchor}\n </span>\n )}\n\n {suffixWords.map((word, index) => {\n const wordExitStart = exitAt + 2 + index * wordStagger;\n const wordExit = interpolate(\n frame,\n [wordExitStart, wordExitStart + safeExitFrames * 0.65],\n [0, 1],\n { ...clamp, easing: wipeEasing },\n );\n\n return (\n <span\n key={`${word}-${index}`}\n style={{\n display: \"inline-block\",\n clipPath: `inset(0 0 0 ${wordExit * 100}%)`,\n }}\n >\n {word}\n </span>\n );\n })}\n </span>\n )}\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n prefix: {\n type: \"text-content\",\n default: \"Introducing\",\n description: \"Leading text\",\n },\n anchor: {\n type: \"text-content\",\n default: \"X\",\n description: \"Persistent anchor\",\n },\n suffix: {\n type: \"text-content\",\n default: \"Ads MCP\",\n description: \"Staggered trailing words\",\n },\n typeFrames: {\n type: \"number\",\n min: 6,\n max: 60,\n step: 1,\n default: 30,\n description: \"Typing frames\",\n hiddenFromList: false,\n },\n exitAt: {\n type: \"number\",\n min: 20,\n max: 90,\n step: 1,\n default: 50,\n description: \"Exit start frame\",\n hiddenFromList: false,\n },\n exitFrames: {\n type: \"number\",\n min: 6,\n max: 40,\n step: 1,\n default: 20,\n description: \"Exit duration\",\n hiddenFromList: false,\n },\n wordStagger: {\n type: \"number\",\n min: 0,\n max: 12,\n step: 1,\n default: 4,\n description: \"Suffix word stagger\",\n hiddenFromList: false,\n },\n anchorShift: {\n type: \"number\",\n min: -200,\n max: 0,\n step: 2,\n default: -72,\n description: \"Anchor exit shift\",\n hiddenFromList: false,\n },\n fontSize: {\n type: \"number\",\n min: 18,\n max: 120,\n step: 1,\n default: 42,\n description: \"Font size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#e8e8e8\",\n description: \"Text color\",\n },\n fontWeight: {\n type: \"enum\",\n default: \"400\",\n variants: {\n \"400\": {},\n \"500\": {},\n \"600\": {},\n \"700\": {},\n },\n description: \"Font weight\",\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"prefix\",\"anchor\",\"suffix\",\"typeFrames\",\"exitAt\",\"exitFrames\",\"wordStagger\",\"anchorShift\",\"fontSize\",\"color\",\"fontWeight\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n prefix: \"Introducing\",\n anchor: \"X\",\n suffix: \"Ads MCP\",\n typeFrames: 30,\n exitAt: 50,\n exitFrames: 20,\n wordStagger: 4,\n anchorShift: -72,\n fontSize: 42,\n color: \"#e8e8e8\",\n fontWeight: \"400\",\n speed: 1,\n};\n\ntype TypedSplitWipeElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof TypedSplitWipeBase>;\n\nconst TypedSplitWipeInner = forwardRef<\n HTMLDivElement,\n TypedSplitWipeElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<TypedSplitWipe>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <TypedSplitWipeBase\n {...(componentProps as unknown as ComponentProps<typeof TypedSplitWipeBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const TypedSplitWipe = Interactive.withSchema({\n Component: TypedSplitWipeInner,\n componentName: \"<TypedSplitWipe>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/underwater-ripple.json b/registry-artifacts/elements/underwater-ripple.jsonindex 6a93cca1..5a847144 100644--- a/registry-artifacts/elements/underwater-ripple.json+++ b/registry-artifacts/elements/underwater-ripple.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/transitions",@@ -11,6 +12,7 @@"dimensions": null,"displayName": "Underwater Ripple","durationInFrames": 120,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "underwater-ripple","sourceCode": "import { AbsoluteFill, Interactive, Sequence, isHtmlInCanvasSupported, useCurrentFrame, useDelayRender, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport React, { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\nimport { type TransitionPresentation, type TransitionPresentationComponentProps } from \"@remotion/transitions\";\n\nconst QUAD = new Float32Array([-1, -1, 1, -1, -1, 1, 1, 1]);\n\nconst VERTEX_SHADER = `#version 300 es\nin vec2 a_pos;\nout vec2 v_uv;\nvoid main() {\n v_uv = vec2(a_pos.x * 0.5 + 0.5, 0.5 - a_pos.y * 0.5);\n gl_Position = vec4(a_pos, 0.0, 1.0);\n}`;\n\nconst LAYER: React.CSSProperties = {\n position: \"absolute\",\n inset: 0,\n width: \"100%\",\n height: \"100%\",\n};\n\nconst OUTPUT_LAYER: React.CSSProperties = { ...LAYER, pointerEvents: \"none\" };\n\nconst isCanvasTransitionSupported = (): boolean =>\n isHtmlInCanvasSupported();\n\nconst isCanvasFilterSupported = (): boolean => isHtmlInCanvasSupported();\n\ntype SceneShaderFrame<Props> = {\n gl: WebGL2RenderingContext;\n uniform: (name: string) => WebGLUniformLocation | null;\n width: number;\n height: number;\n progress: number;\n passedProps: Props;\n};\n\ntype SceneShaderDrawParams<Props> = {\n from: OffscreenCanvas | null;\n to: OffscreenCanvas | null;\n width: number;\n height: number;\n progress: number;\n passedProps: Props;\n};\n\ntype SceneShaderInstance<Props> = {\n draw: (params: SceneShaderDrawParams<Props>) => void;\n clear: () => void;\n cleanup: () => void;\n};\n\ntype SceneShader<Props> = (\n canvas: OffscreenCanvas,\n) => SceneShaderInstance<Props>;\n\ntype SceneFilterFrame<Props> = {\n gl: WebGL2RenderingContext;\n uniform: (name: string) => WebGLUniformLocation | null;\n width: number;\n height: number;\n frame: number;\n time: number;\n passedProps: Props;\n};\n\ntype SceneFilterDrawParams<Props> = {\n scene: OffscreenCanvas | null;\n width: number;\n height: number;\n frame: number;\n time: number;\n passedProps: Props;\n};\n\ntype SceneFilterInstance<Props> = {\n draw: (params: SceneFilterDrawParams<Props>) => void;\n clear: () => void;\n cleanup: () => void;\n};\n\ntype SceneFilter<Props> = (\n canvas: OffscreenCanvas,\n) => SceneFilterInstance<Props>;\n\nfunction compileShader(\n gl: WebGL2RenderingContext,\n source: string,\n type: GLenum,\n): WebGLShader {\n const shader = gl.createShader(type);\n if (!shader) {\n throw new Error(\"canvas-presentation: failed to create shader\");\n }\n gl.shaderSource(shader, source);\n gl.compileShader(shader);\n if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {\n const log = gl.getShaderInfoLog(shader);\n gl.deleteShader(shader);\n throw new Error(`canvas-presentation: failed to compile shader: ${log}`);\n }\n return shader;\n}\n\nfunction createProgram(\n gl: WebGL2RenderingContext,\n fragment: string,\n): WebGLProgram {\n const program = gl.createProgram();\n if (!program) {\n throw new Error(\"canvas-presentation: failed to create program\");\n }\n const vs = compileShader(gl, VERTEX_SHADER, gl.VERTEX_SHADER);\n const fs = compileShader(gl, fragment, gl.FRAGMENT_SHADER);\n gl.attachShader(program, vs);\n gl.attachShader(program, fs);\n gl.linkProgram(program);\n gl.deleteShader(vs);\n gl.deleteShader(fs);\n if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {\n const log = gl.getProgramInfoLog(program);\n gl.deleteProgram(program);\n throw new Error(`canvas-presentation: failed to link program: ${log}`);\n }\n return program;\n}\n\nfunction createSceneTexture(gl: WebGL2RenderingContext): WebGLTexture {\n const texture = gl.createTexture();\n if (!texture) {\n throw new Error(\"canvas-presentation: failed to create texture\");\n }\n gl.bindTexture(gl.TEXTURE_2D, texture);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);\n gl.texImage2D(\n gl.TEXTURE_2D,\n 0,\n gl.RGBA,\n 1,\n 1,\n 0,\n gl.RGBA,\n gl.UNSIGNED_BYTE,\n new Uint8Array([0, 0, 0, 0]),\n );\n return texture;\n}\n\nfunction createQuadSurface(canvas: OffscreenCanvas, fragment: string) {\n const gl = canvas.getContext(\"webgl2\", { premultipliedAlpha: true });\n if (!gl) {\n throw new Error(\"canvas-presentation: WebGL2 is unavailable\");\n }\n\n const program = createProgram(gl, fragment);\n const vao = gl.createVertexArray();\n gl.bindVertexArray(vao);\n const buffer = gl.createBuffer();\n gl.bindBuffer(gl.ARRAY_BUFFER, buffer);\n gl.bufferData(gl.ARRAY_BUFFER, QUAD, gl.STATIC_DRAW);\n const aPos = gl.getAttribLocation(program, \"a_pos\");\n gl.enableVertexAttribArray(aPos);\n gl.vertexAttribPointer(aPos, 2, gl.FLOAT, false, 0, 0);\n\n const locations = new Map<string, WebGLUniformLocation | null>();\n const uniform = (name: string) => {\n const cached = locations.get(name);\n if (cached !== undefined) {\n return cached;\n }\n const location = gl.getUniformLocation(program, name);\n locations.set(name, location);\n return location;\n };\n\n const clear = () => {\n gl.clearColor(0, 0, 0, 0);\n gl.clear(gl.COLOR_BUFFER_BIT);\n };\n\n const textures: WebGLTexture[] = [];\n const createTexture = () => {\n const texture = createSceneTexture(gl);\n textures.push(texture);\n return texture;\n };\n\n const begin = (width: number, height: number) => {\n gl.viewport(0, 0, width, height);\n clear();\n gl.useProgram(program);\n gl.bindVertexArray(vao);\n };\n\n const bindScene = (\n image: OffscreenCanvas | null,\n texture: WebGLTexture,\n unit: number,\n name: string,\n ) => {\n gl.activeTexture(gl.TEXTURE0 + unit);\n gl.bindTexture(gl.TEXTURE_2D, texture);\n if (image) {\n gl.texImage2D(\n gl.TEXTURE_2D,\n 0,\n gl.RGBA,\n gl.RGBA,\n gl.UNSIGNED_BYTE,\n image,\n );\n }\n gl.uniform1i(uniform(name), unit);\n };\n\n const draw = () => gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);\n\n const cleanup = () => {\n gl.deleteProgram(program);\n for (const texture of textures) {\n gl.deleteTexture(texture);\n }\n gl.deleteBuffer(buffer);\n gl.deleteVertexArray(vao);\n };\n\n return {\n gl,\n uniform,\n clear,\n createTexture,\n begin,\n bindScene,\n draw,\n cleanup,\n };\n}\n\nfunction makeSceneShader<Props extends Record<string, unknown>>(\n fragment: string,\n setUniforms?: (frame: SceneShaderFrame<Props>) => void,\n): SceneShader<Props> {\n return (canvas) => {\n const surface = createQuadSurface(canvas, fragment);\n const fromTexture = surface.createTexture();\n const toTexture = surface.createTexture();\n\n return {\n clear: surface.clear,\n cleanup: surface.cleanup,\n draw: ({ from, to, width, height, progress, passedProps }) => {\n surface.begin(width, height);\n surface.bindScene(from, fromTexture, 0, \"u_from\");\n surface.bindScene(to, toTexture, 1, \"u_to\");\n\n surface.gl.uniform1f(surface.uniform(\"u_progress\"), progress);\n surface.gl.uniform1f(surface.uniform(\"u_aspect\"), width / height);\n setUniforms?.({\n gl: surface.gl,\n uniform: surface.uniform,\n width,\n height,\n progress,\n passedProps,\n });\n\n surface.draw();\n },\n };\n };\n}\n\nfunction makeFilterShader<Props extends Record<string, unknown>>(\n fragment: string,\n setUniforms?: (frame: SceneFilterFrame<Props>) => void,\n): SceneFilter<Props> {\n return (canvas) => {\n const surface = createQuadSurface(canvas, fragment);\n const sceneTexture = surface.createTexture();\n\n return {\n clear: surface.clear,\n cleanup: surface.cleanup,\n draw: ({ scene, width, height, frame, time, passedProps }) => {\n surface.begin(width, height);\n surface.bindScene(scene, sceneTexture, 0, \"u_scene\");\n\n surface.gl.uniform1f(surface.uniform(\"u_frame\"), frame);\n surface.gl.uniform1f(surface.uniform(\"u_time\"), time);\n surface.gl.uniform1f(surface.uniform(\"u_aspect\"), width / height);\n setUniforms?.({\n gl: surface.gl,\n uniform: surface.uniform,\n width,\n height,\n frame,\n time,\n passedProps,\n });\n\n surface.draw();\n },\n };\n };\n}\n\nconst transferred = new WeakMap<HTMLCanvasElement, OffscreenCanvas>();\n\nfunction takeOffscreen(canvas: HTMLCanvasElement): OffscreenCanvas {\n const existing = transferred.get(canvas);\n if (existing) {\n return existing;\n }\n const created = canvas.transferControlToOffscreen();\n transferred.set(canvas, created);\n return created;\n}\n\nfunction makeCanvasComponent<Props extends Record<string, unknown>>(\n shader: SceneShader<Props>,\n): React.FC<TransitionPresentationComponentProps<Props>> {\n return function CanvasScenePresentation({\n children,\n presentationProgress,\n presentationDirection,\n passedProps,\n onElementImage,\n onUnmount,\n bothEnteringAndExiting,\n }) {\n const layoutRef = React.useRef<HTMLCanvasElement | null>(null);\n const outputRef = React.useRef<HTMLCanvasElement | null>(null);\n const captureRef = React.useRef<OffscreenCanvas | null>(null);\n const captureContextRef =\n React.useRef<OffscreenCanvasRenderingContext2D | null>(null);\n const outputSurfaceRef = React.useRef<OffscreenCanvas | null>(null);\n const instanceRef = React.useRef<SceneShaderInstance<Props> | null>(null);\n const passedPropsRef = React.useRef(passedProps);\n passedPropsRef.current = passedProps;\n const onElementImageRef = React.useRef(onElementImage);\n onElementImageRef.current = onElementImage;\n const onUnmountRef = React.useRef(onUnmount);\n onUnmountRef.current = onUnmount;\n\n const { delayRender, continueRender } = useDelayRender();\n const passThrough =\n bothEnteringAndExiting && presentationDirection === \"exiting\";\n\n const drawRef = React.useRef<\n (\n prevImage: OffscreenCanvas | null,\n nextImage: OffscreenCanvas | null,\n progress: number,\n ) => void\n >(() => undefined);\n drawRef.current = (prevImage, nextImage, progress) => {\n const instance = instanceRef.current;\n if (!instance) {\n return;\n }\n const handle = delayRender(\"canvas-presentation: paint\");\n const to = prevImage;\n const from = nextImage;\n const width = from?.width ?? to?.width ?? 0;\n const height = from?.height ?? to?.height ?? 0;\n if (width === 0 || height === 0) {\n instance.clear();\n continueRender(handle);\n return;\n }\n instance.draw({\n from,\n to,\n width,\n height,\n progress: !to ? 0 : !from ? 1 : progress,\n passedProps: passedPropsRef.current,\n });\n continueRender(handle);\n };\n\n const draw = React.useCallback(\n (\n prevImage: OffscreenCanvas | null,\n nextImage: OffscreenCanvas | null,\n progress: number,\n ) => drawRef.current(prevImage, nextImage, progress),\n [],\n );\n\n React.useLayoutEffect(() => {\n if (passThrough) {\n return;\n }\n const layout = layoutRef.current;\n const output = outputRef.current;\n if (!layout || !output) {\n return;\n }\n const capture = takeOffscreen(layout);\n const context = capture.getContext(\"2d\");\n if (!context) {\n throw new Error(\"canvas-presentation: failed to acquire a 2D context\");\n }\n const surface = takeOffscreen(output);\n captureRef.current = capture;\n captureContextRef.current = context;\n outputSurfaceRef.current = surface;\n instanceRef.current = shader(surface);\n\n return () => {\n instanceRef.current?.cleanup();\n instanceRef.current = null;\n captureRef.current = null;\n captureContextRef.current = null;\n outputSurfaceRef.current = null;\n };\n }, [passThrough, shader]);\n\n React.useLayoutEffect(() => {\n if (passThrough) {\n return;\n }\n const layout = layoutRef.current;\n if (!layout) {\n return;\n }\n layout.layoutSubtree = true;\n const handlePaint = () => {\n const scene = layout.firstElementChild;\n const capture = captureRef.current;\n const context = captureContextRef.current;\n if (!scene || !capture || !context) {\n return;\n }\n const elementImage = layout.captureElementImage(scene);\n try {\n context.reset();\n context.drawElementImage(elementImage, 0, 0);\n } finally {\n elementImage.close();\n }\n onElementImageRef.current(capture, draw);\n };\n layout.addEventListener(\"paint\", handlePaint);\n return () => layout.removeEventListener(\"paint\", handlePaint);\n }, [passThrough, draw]);\n\n React.useLayoutEffect(() => {\n if (passThrough) {\n return;\n }\n const layout = layoutRef.current;\n if (!layout) {\n return;\n }\n const observer = new ResizeObserver(([entry]) => {\n const capture = captureRef.current;\n const surface = outputSurfaceRef.current;\n if (!capture || !surface) {\n return;\n }\n const width = entry.devicePixelContentBoxSize[0].inlineSize;\n const height = entry.devicePixelContentBoxSize[0].blockSize;\n capture.width = width;\n capture.height = height;\n surface.width = width;\n surface.height = height;\n layout.requestPaint?.();\n });\n observer.observe(layout, { box: \"device-pixel-content-box\" });\n return () => observer.disconnect();\n }, [passThrough]);\n\n // biome-ignore lint/correctness/useExhaustiveDependencies: presentationProgress is the intentional trigger — a new progress value is what schedules the next paint\n React.useLayoutEffect(() => {\n if (passThrough) {\n return;\n }\n layoutRef.current?.requestPaint?.();\n }, [passThrough, presentationProgress]);\n\n React.useLayoutEffect(() => {\n if (passThrough) {\n return;\n }\n return () => onUnmountRef.current();\n }, [passThrough]);\n\n if (passThrough) {\n return <>{children}</>;\n }\n\n return (\n <AbsoluteFill>\n <canvas ref={layoutRef} style={LAYER}>\n {children}\n </canvas>\n <canvas ref={outputRef} style={OUTPUT_LAYER} />\n </AbsoluteFill>\n );\n };\n}\n\ntype CanvasFilterProps = {\n children: React.ReactNode;\n};\n\nfunction makeFilterComponent<Props extends Record<string, unknown>>(\n shader: SceneFilter<Props>,\n): React.FC<Props & CanvasFilterProps> {\n return function CanvasSceneFilter(props) {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const { delayRender, continueRender } = useDelayRender();\n\n const layoutRef = React.useRef<HTMLCanvasElement | null>(null);\n const outputRef = React.useRef<HTMLCanvasElement | null>(null);\n const captureRef = React.useRef<OffscreenCanvas | null>(null);\n const captureContextRef =\n React.useRef<OffscreenCanvasRenderingContext2D | null>(null);\n const outputSurfaceRef = React.useRef<OffscreenCanvas | null>(null);\n const instanceRef = React.useRef<SceneFilterInstance<Props> | null>(null);\n\n const passedPropsRef = React.useRef(props);\n passedPropsRef.current = props;\n const frameRef = React.useRef(frame);\n frameRef.current = frame;\n const timeRef = React.useRef(frame / fps);\n timeRef.current = frame / fps;\n\n React.useLayoutEffect(() => {\n const layout = layoutRef.current;\n const output = outputRef.current;\n if (!layout || !output) {\n return;\n }\n const capture = takeOffscreen(layout);\n const context = capture.getContext(\"2d\");\n if (!context) {\n throw new Error(\"canvas-presentation: failed to acquire a 2D context\");\n }\n const surface = takeOffscreen(output);\n captureRef.current = capture;\n captureContextRef.current = context;\n outputSurfaceRef.current = surface;\n instanceRef.current = shader(surface);\n\n return () => {\n instanceRef.current?.cleanup();\n instanceRef.current = null;\n captureRef.current = null;\n captureContextRef.current = null;\n outputSurfaceRef.current = null;\n };\n }, [shader]);\n\n React.useLayoutEffect(() => {\n const layout = layoutRef.current;\n if (!layout) {\n return;\n }\n layout.layoutSubtree = true;\n const handlePaint = () => {\n const scene = layout.firstElementChild;\n const capture = captureRef.current;\n const context = captureContextRef.current;\n const instance = instanceRef.current;\n if (!scene || !capture || !context || !instance) {\n return;\n }\n const elementImage = layout.captureElementImage(scene);\n try {\n context.reset();\n context.drawElementImage(elementImage, 0, 0);\n } finally {\n elementImage.close();\n }\n if (capture.width === 0 || capture.height === 0) {\n instance.clear();\n return;\n }\n instance.draw({\n scene: capture,\n width: capture.width,\n height: capture.height,\n frame: frameRef.current,\n time: timeRef.current,\n passedProps: passedPropsRef.current,\n });\n };\n layout.addEventListener(\"paint\", handlePaint);\n return () => layout.removeEventListener(\"paint\", handlePaint);\n }, []);\n\n React.useLayoutEffect(() => {\n const layout = layoutRef.current;\n if (!layout) {\n return;\n }\n const observer = new ResizeObserver(([entry]) => {\n const capture = captureRef.current;\n const surface = outputSurfaceRef.current;\n if (!capture || !surface) {\n return;\n }\n const width = entry.devicePixelContentBoxSize[0].inlineSize;\n const height = entry.devicePixelContentBoxSize[0].blockSize;\n capture.width = width;\n capture.height = height;\n surface.width = width;\n surface.height = height;\n layout.requestPaint?.();\n });\n observer.observe(layout, { box: \"device-pixel-content-box\" });\n return () => observer.disconnect();\n }, []);\n\n React.useLayoutEffect(() => {\n const layout = layoutRef.current;\n if (!layout) {\n return;\n }\n const handle = delayRender(\"canvas-presentation: filter paint\");\n const settle = () => continueRender(handle);\n layout.addEventListener(\"paint\", settle, { once: true });\n layout.requestPaint?.();\n return () => {\n layout.removeEventListener(\"paint\", settle);\n continueRender(handle);\n };\n });\n\n return (\n <AbsoluteFill>\n <canvas ref={layoutRef} style={LAYER}>\n {props.children}\n </canvas>\n <canvas ref={outputRef} style={OUTPUT_LAYER} />\n </AbsoluteFill>\n );\n };\n}\n\ntype CanvasPresentationOptions<Props extends Record<string, unknown>> = {\n shader: SceneShader<Props>;\n fallback: React.FC<TransitionPresentationComponentProps<Props>>;\n};\n\nfunction makeCanvasPresentation<Props extends Record<string, unknown>>({\n shader,\n fallback: Fallback,\n}: CanvasPresentationOptions<Props>): (\n props: Props,\n) => TransitionPresentation<Props> {\n const Canvas = makeCanvasComponent(shader);\n\n const Presentation: React.FC<TransitionPresentationComponentProps<Props>> = (\n props,\n ) =>\n isCanvasTransitionSupported() ? (\n <Canvas {...props} />\n ) : (\n <Fallback {...props} />\n );\n\n return (props) => ({ component: Presentation, props });\n}\n\ntype CanvasFilterOptions<Props extends Record<string, unknown>> = {\n shader: SceneFilter<Props>;\n fallback: React.FC<Props & CanvasFilterProps>;\n};\n\nfunction makeCanvasFilter<Props extends Record<string, unknown>>({\n shader,\n fallback: Fallback,\n}: CanvasFilterOptions<Props>): React.FC<Props & CanvasFilterProps> {\n const Canvas = makeFilterComponent(shader);\n\n return function CanvasFilter(props) {\n return isCanvasFilterSupported() ? (\n <Canvas {...props} />\n ) : (\n <Fallback {...props} />\n );\n };\n}\n\ntype UnderwaterRippleProps = {\n amplitude?: number;\n scale?: number;\n speed?: number;\n dispersion?: number;\n};\n\nconst DEFAULTS = {\n amplitude: 7,\n scale: 1,\n speed: 2,\n dispersion: 1,\n};\n\ntype NormalizedProps = {\n amplitude: number;\n scale: number;\n phase: number;\n dispersion: number;\n};\n\nconst FRAGMENT_SHADER = `#version 300 es\nprecision highp float;\n\nuniform sampler2D u_scene;\nuniform float u_aspect;\nuniform float u_phase;\nuniform float u_amplitude;\nuniform float u_scale;\nuniform float u_dispersion;\n\nin vec2 v_uv;\nout vec4 outColor;\n\nvec2 fieldGradient(vec2 p, float phase) {\n float scale = max(u_scale, 0.05);\n vec2 k1 = vec2(1.0, 0.35);\n vec2 k2 = vec2(-0.42, 1.0);\n vec2 k3 = vec2(0.78, -0.63);\n float f1 = 6.1 * scale;\n float f2 = 8.7 * scale;\n float f3 = 12.3 * scale;\n\n vec2 g = vec2(0.0);\n g += cos(dot(p, k1) * f1 + phase) * f1 * k1;\n g += cos(dot(p, k2) * f2 - phase * 2.0) * f2 * k2;\n g += cos(dot(p, k3) * f3 + phase * 3.0) * f3 * k3;\n\n return g / (3.0 * f2);\n}\n\nvoid main() {\n vec2 p = vec2(v_uv.x * u_aspect, v_uv.y);\n vec2 grad = fieldGradient(p, u_phase);\n\n vec2 offset = grad * u_amplitude;\n float strength = length(grad);\n vec2 direction = strength > 0.0001 ? grad / strength : vec2(0.0);\n float spread = u_dispersion * u_amplitude * 0.3 * min(strength, 2.0);\n\n vec2 base = v_uv + vec2(offset.x / u_aspect, offset.y);\n vec2 lead = vec2(direction.x / u_aspect, direction.y) * spread;\n\n vec4 center = texture(u_scene, base);\n float r = texture(u_scene, base + lead).r;\n float b = texture(u_scene, base - lead).b;\n\n outColor = vec4(r, center.g, b, center.a);\n}`;\n\nconst shader = makeFilterShader<NormalizedProps>(\n FRAGMENT_SHADER,\n ({ gl, uniform, passedProps }) => {\n const { amplitude, scale, phase, dispersion } = passedProps;\n gl.uniform1f(uniform(\"u_amplitude\"), amplitude);\n gl.uniform1f(uniform(\"u_scale\"), scale);\n gl.uniform1f(uniform(\"u_phase\"), phase);\n gl.uniform1f(uniform(\"u_dispersion\"), dispersion);\n },\n);\n\nconst UnderwaterRippleFallback: React.FC<\n NormalizedProps & CanvasFilterProps\n> = ({ children }) => <AbsoluteFill>{children}</AbsoluteFill>;\n\nconst UnderwaterRippleCanvas = makeCanvasFilter<NormalizedProps>({\n shader,\n fallback: UnderwaterRippleFallback,\n});\n\nconst UnderwaterRippleBase: React.FC<\n UnderwaterRippleProps & CanvasFilterProps\n> = ({\n amplitude = DEFAULTS.amplitude,\n scale = DEFAULTS.scale,\n speed = DEFAULTS.speed,\n dispersion = DEFAULTS.dispersion,\n children,\n}) => {\n const frame = useCurrentFrame();\n const { height, durationInFrames } = useVideoConfig();\n const cycle = Math.max(durationInFrames, 1);\n\n return (\n <UnderwaterRippleCanvas\n amplitude={amplitude / height}\n scale={scale}\n phase={(frame / cycle) * speed * Math.PI * 2}\n dispersion={dispersion}\n >\n {children}\n </UnderwaterRippleCanvas>\n );\n};\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n amplitude: {\n type: \"number\",\n min: 0,\n max: 40,\n step: 1,\n default: 7,\n description: \"Amplitude\",\n hiddenFromList: false,\n },\n scale: {\n type: \"number\",\n min: 0.2,\n max: 4,\n step: 0.1,\n default: 1,\n description: \"Scale\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n dispersion: {\n type: \"number\",\n min: 0,\n max: 4,\n step: 0.1,\n default: 1,\n description: \"Dispersion\",\n hiddenFromList: false,\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"amplitude\",\"scale\",\"speed\",\"dispersion\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n amplitude: 7,\n scale: 1,\n speed: 1,\n dispersion: 1,\n};\n\ntype UnderwaterRippleElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof UnderwaterRippleBase>;\n\nconst UnderwaterRippleInner = forwardRef<\n HTMLDivElement,\n UnderwaterRippleElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<UnderwaterRipple>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <UnderwaterRippleBase\n {...(componentProps as unknown as ComponentProps<typeof UnderwaterRippleBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const UnderwaterRipple = Interactive.withSchema({\n Component: UnderwaterRippleInner,\n componentName: \"<UnderwaterRipple>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/value-swap.json b/registry-artifacts/elements/value-swap.jsonindex 04c7a1dd..df31b33e 100644--- a/registry-artifacts/elements/value-swap.json+++ b/registry-artifacts/elements/value-swap.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [],"dimensions": {"width": 220,@@ -9,6 +10,7 @@},"displayName": "Value Swap","durationInFrames": 100,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "value-swap","sourceCode": "import { Easing, Interactive, Sequence, interpolate, useCurrentFrame, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport React, { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\nconst clampOpts = {\n extrapolateLeft: \"clamp\" as const,\n extrapolateRight: \"clamp\" as const,\n};\n\ninterface ValueSwapProps {\n values: string[];\n at: number | number[];\n duration?: number;\n distance?: number;\n direction?: \"up\" | \"down\";\n className?: string;\n style?: React.CSSProperties;\n}\n\nfunction ValueSwapBase({\n values,\n at,\n duration = 10,\n distance = 12,\n direction = \"up\",\n className,\n style,\n}: ValueSwapProps) {\n const frame = useCurrentFrame();\n const ats = Array.isArray(at) ? at : [at];\n const d = direction === \"down\" ? -distance : distance;\n const count = Math.min(values.length, ats.length + 1);\n const rendered = values.slice(0, count);\n const sizer = rendered.reduce((a, b) => (b.length > a.length ? b : a), \"\");\n const swapP = (start: number) =>\n interpolate(frame, [start, start + duration], [0, 1], {\n ...clampOpts,\n easing: Easing.inOut(Easing.cubic),\n });\n return (\n <span\n className={className}\n style={{\n position: \"relative\",\n display: \"inline-block\",\n ...style,\n }}\n >\n <span style={{ visibility: \"hidden\" }}>{sizer}</span>\n {rendered.map((value, i) => {\n const pIn = i > 0 ? swapP(ats[i - 1]) : 1;\n const pOut = i < count - 1 ? swapP(ats[i]) : 0;\n const opacity = pIn * (1 - pOut);\n if (opacity <= 0.001) return null;\n const y = (1 - pIn) * d + pOut * -d;\n return (\n <span\n key={`${i}-${value}`}\n style={{\n position: \"absolute\",\n left: 0,\n top: 0,\n whiteSpace: \"nowrap\",\n opacity,\n translate: `0 ${y}px`,\n }}\n >\n {value}\n </span>\n );\n })}\n </span>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n duration: {\n type: \"number\",\n min: 4,\n max: 24,\n step: 1,\n default: 10,\n description: \"Duration\",\n hiddenFromList: false,\n },\n distance: {\n type: \"number\",\n min: 4,\n max: 32,\n step: 2,\n default: 12,\n description: \"Distance\",\n hiddenFromList: false,\n },\n direction: {\n type: \"enum\",\n default: \"up\",\n variants: {\n up: {},\n down: {},\n },\n description: \"Direction\",\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 220,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 70,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"duration\",\"distance\",\"direction\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n duration: 10,\n distance: 12,\n direction: \"up\",\n speed: 1,\n};\n\ntype ValueSwapElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof ValueSwapBase>;\n\nconst ValueSwapInner = forwardRef<\n HTMLDivElement,\n ValueSwapElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 220, height = 70, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<ValueSwap>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <ValueSwapBase\n {...(componentProps as unknown as ComponentProps<typeof ValueSwapBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const ValueSwap = Interactive.withSchema({\n Component: ValueSwapInner,\n componentName: \"<ValueSwap>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/vhs-filter.json b/registry-artifacts/elements/vhs-filter.jsonindex fe7e53b9..a4521a76 100644--- a/registry-artifacts/elements/vhs-filter.json+++ b/registry-artifacts/elements/vhs-filter.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [{"name": "@remotion/transitions",@@ -11,6 +12,7 @@"dimensions": null,"displayName": "VHS Filter","durationInFrames": 90,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "vhs-filter","sourceCode": "import { AbsoluteFill, Interactive, Sequence, isHtmlInCanvasSupported, random, useCurrentFrame, useDelayRender, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport React, { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\nimport { type TransitionPresentation, type TransitionPresentationComponentProps } from \"@remotion/transitions\";\n\nconst QUAD = new Float32Array([-1, -1, 1, -1, -1, 1, 1, 1]);\n\nconst VERTEX_SHADER = `#version 300 es\nin vec2 a_pos;\nout vec2 v_uv;\nvoid main() {\n v_uv = vec2(a_pos.x * 0.5 + 0.5, 0.5 - a_pos.y * 0.5);\n gl_Position = vec4(a_pos, 0.0, 1.0);\n}`;\n\nconst LAYER: React.CSSProperties = {\n position: \"absolute\",\n inset: 0,\n width: \"100%\",\n height: \"100%\",\n};\n\nconst OUTPUT_LAYER: React.CSSProperties = { ...LAYER, pointerEvents: \"none\" };\n\nconst isCanvasTransitionSupported = (): boolean =>\n isHtmlInCanvasSupported();\n\nconst isCanvasFilterSupported = (): boolean => isHtmlInCanvasSupported();\n\ntype SceneShaderFrame<Props> = {\n gl: WebGL2RenderingContext;\n uniform: (name: string) => WebGLUniformLocation | null;\n width: number;\n height: number;\n progress: number;\n passedProps: Props;\n};\n\ntype SceneShaderDrawParams<Props> = {\n from: OffscreenCanvas | null;\n to: OffscreenCanvas | null;\n width: number;\n height: number;\n progress: number;\n passedProps: Props;\n};\n\ntype SceneShaderInstance<Props> = {\n draw: (params: SceneShaderDrawParams<Props>) => void;\n clear: () => void;\n cleanup: () => void;\n};\n\ntype SceneShader<Props> = (\n canvas: OffscreenCanvas,\n) => SceneShaderInstance<Props>;\n\ntype SceneFilterFrame<Props> = {\n gl: WebGL2RenderingContext;\n uniform: (name: string) => WebGLUniformLocation | null;\n width: number;\n height: number;\n frame: number;\n time: number;\n passedProps: Props;\n};\n\ntype SceneFilterDrawParams<Props> = {\n scene: OffscreenCanvas | null;\n width: number;\n height: number;\n frame: number;\n time: number;\n passedProps: Props;\n};\n\ntype SceneFilterInstance<Props> = {\n draw: (params: SceneFilterDrawParams<Props>) => void;\n clear: () => void;\n cleanup: () => void;\n};\n\ntype SceneFilter<Props> = (\n canvas: OffscreenCanvas,\n) => SceneFilterInstance<Props>;\n\nfunction compileShader(\n gl: WebGL2RenderingContext,\n source: string,\n type: GLenum,\n): WebGLShader {\n const shader = gl.createShader(type);\n if (!shader) {\n throw new Error(\"canvas-presentation: failed to create shader\");\n }\n gl.shaderSource(shader, source);\n gl.compileShader(shader);\n if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {\n const log = gl.getShaderInfoLog(shader);\n gl.deleteShader(shader);\n throw new Error(`canvas-presentation: failed to compile shader: ${log}`);\n }\n return shader;\n}\n\nfunction createProgram(\n gl: WebGL2RenderingContext,\n fragment: string,\n): WebGLProgram {\n const program = gl.createProgram();\n if (!program) {\n throw new Error(\"canvas-presentation: failed to create program\");\n }\n const vs = compileShader(gl, VERTEX_SHADER, gl.VERTEX_SHADER);\n const fs = compileShader(gl, fragment, gl.FRAGMENT_SHADER);\n gl.attachShader(program, vs);\n gl.attachShader(program, fs);\n gl.linkProgram(program);\n gl.deleteShader(vs);\n gl.deleteShader(fs);\n if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {\n const log = gl.getProgramInfoLog(program);\n gl.deleteProgram(program);\n throw new Error(`canvas-presentation: failed to link program: ${log}`);\n }\n return program;\n}\n\nfunction createSceneTexture(gl: WebGL2RenderingContext): WebGLTexture {\n const texture = gl.createTexture();\n if (!texture) {\n throw new Error(\"canvas-presentation: failed to create texture\");\n }\n gl.bindTexture(gl.TEXTURE_2D, texture);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);\n gl.texImage2D(\n gl.TEXTURE_2D,\n 0,\n gl.RGBA,\n 1,\n 1,\n 0,\n gl.RGBA,\n gl.UNSIGNED_BYTE,\n new Uint8Array([0, 0, 0, 0]),\n );\n return texture;\n}\n\nfunction createQuadSurface(canvas: OffscreenCanvas, fragment: string) {\n const gl = canvas.getContext(\"webgl2\", { premultipliedAlpha: true });\n if (!gl) {\n throw new Error(\"canvas-presentation: WebGL2 is unavailable\");\n }\n\n const program = createProgram(gl, fragment);\n const vao = gl.createVertexArray();\n gl.bindVertexArray(vao);\n const buffer = gl.createBuffer();\n gl.bindBuffer(gl.ARRAY_BUFFER, buffer);\n gl.bufferData(gl.ARRAY_BUFFER, QUAD, gl.STATIC_DRAW);\n const aPos = gl.getAttribLocation(program, \"a_pos\");\n gl.enableVertexAttribArray(aPos);\n gl.vertexAttribPointer(aPos, 2, gl.FLOAT, false, 0, 0);\n\n const locations = new Map<string, WebGLUniformLocation | null>();\n const uniform = (name: string) => {\n const cached = locations.get(name);\n if (cached !== undefined) {\n return cached;\n }\n const location = gl.getUniformLocation(program, name);\n locations.set(name, location);\n return location;\n };\n\n const clear = () => {\n gl.clearColor(0, 0, 0, 0);\n gl.clear(gl.COLOR_BUFFER_BIT);\n };\n\n const textures: WebGLTexture[] = [];\n const createTexture = () => {\n const texture = createSceneTexture(gl);\n textures.push(texture);\n return texture;\n };\n\n const begin = (width: number, height: number) => {\n gl.viewport(0, 0, width, height);\n clear();\n gl.useProgram(program);\n gl.bindVertexArray(vao);\n };\n\n const bindScene = (\n image: OffscreenCanvas | null,\n texture: WebGLTexture,\n unit: number,\n name: string,\n ) => {\n gl.activeTexture(gl.TEXTURE0 + unit);\n gl.bindTexture(gl.TEXTURE_2D, texture);\n if (image) {\n gl.texImage2D(\n gl.TEXTURE_2D,\n 0,\n gl.RGBA,\n gl.RGBA,\n gl.UNSIGNED_BYTE,\n image,\n );\n }\n gl.uniform1i(uniform(name), unit);\n };\n\n const draw = () => gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);\n\n const cleanup = () => {\n gl.deleteProgram(program);\n for (const texture of textures) {\n gl.deleteTexture(texture);\n }\n gl.deleteBuffer(buffer);\n gl.deleteVertexArray(vao);\n };\n\n return {\n gl,\n uniform,\n clear,\n createTexture,\n begin,\n bindScene,\n draw,\n cleanup,\n };\n}\n\nfunction makeSceneShader<Props extends Record<string, unknown>>(\n fragment: string,\n setUniforms?: (frame: SceneShaderFrame<Props>) => void,\n): SceneShader<Props> {\n return (canvas) => {\n const surface = createQuadSurface(canvas, fragment);\n const fromTexture = surface.createTexture();\n const toTexture = surface.createTexture();\n\n return {\n clear: surface.clear,\n cleanup: surface.cleanup,\n draw: ({ from, to, width, height, progress, passedProps }) => {\n surface.begin(width, height);\n surface.bindScene(from, fromTexture, 0, \"u_from\");\n surface.bindScene(to, toTexture, 1, \"u_to\");\n\n surface.gl.uniform1f(surface.uniform(\"u_progress\"), progress);\n surface.gl.uniform1f(surface.uniform(\"u_aspect\"), width / height);\n setUniforms?.({\n gl: surface.gl,\n uniform: surface.uniform,\n width,\n height,\n progress,\n passedProps,\n });\n\n surface.draw();\n },\n };\n };\n}\n\nfunction makeFilterShader<Props extends Record<string, unknown>>(\n fragment: string,\n setUniforms?: (frame: SceneFilterFrame<Props>) => void,\n): SceneFilter<Props> {\n return (canvas) => {\n const surface = createQuadSurface(canvas, fragment);\n const sceneTexture = surface.createTexture();\n\n return {\n clear: surface.clear,\n cleanup: surface.cleanup,\n draw: ({ scene, width, height, frame, time, passedProps }) => {\n surface.begin(width, height);\n surface.bindScene(scene, sceneTexture, 0, \"u_scene\");\n\n surface.gl.uniform1f(surface.uniform(\"u_frame\"), frame);\n surface.gl.uniform1f(surface.uniform(\"u_time\"), time);\n surface.gl.uniform1f(surface.uniform(\"u_aspect\"), width / height);\n setUniforms?.({\n gl: surface.gl,\n uniform: surface.uniform,\n width,\n height,\n frame,\n time,\n passedProps,\n });\n\n surface.draw();\n },\n };\n };\n}\n\nconst transferred = new WeakMap<HTMLCanvasElement, OffscreenCanvas>();\n\nfunction takeOffscreen(canvas: HTMLCanvasElement): OffscreenCanvas {\n const existing = transferred.get(canvas);\n if (existing) {\n return existing;\n }\n const created = canvas.transferControlToOffscreen();\n transferred.set(canvas, created);\n return created;\n}\n\nfunction makeCanvasComponent<Props extends Record<string, unknown>>(\n shader: SceneShader<Props>,\n): React.FC<TransitionPresentationComponentProps<Props>> {\n return function CanvasScenePresentation({\n children,\n presentationProgress,\n presentationDirection,\n passedProps,\n onElementImage,\n onUnmount,\n bothEnteringAndExiting,\n }) {\n const layoutRef = React.useRef<HTMLCanvasElement | null>(null);\n const outputRef = React.useRef<HTMLCanvasElement | null>(null);\n const captureRef = React.useRef<OffscreenCanvas | null>(null);\n const captureContextRef =\n React.useRef<OffscreenCanvasRenderingContext2D | null>(null);\n const outputSurfaceRef = React.useRef<OffscreenCanvas | null>(null);\n const instanceRef = React.useRef<SceneShaderInstance<Props> | null>(null);\n const passedPropsRef = React.useRef(passedProps);\n passedPropsRef.current = passedProps;\n const onElementImageRef = React.useRef(onElementImage);\n onElementImageRef.current = onElementImage;\n const onUnmountRef = React.useRef(onUnmount);\n onUnmountRef.current = onUnmount;\n\n const { delayRender, continueRender } = useDelayRender();\n const passThrough =\n bothEnteringAndExiting && presentationDirection === \"exiting\";\n\n const drawRef = React.useRef<\n (\n prevImage: OffscreenCanvas | null,\n nextImage: OffscreenCanvas | null,\n progress: number,\n ) => void\n >(() => undefined);\n drawRef.current = (prevImage, nextImage, progress) => {\n const instance = instanceRef.current;\n if (!instance) {\n return;\n }\n const handle = delayRender(\"canvas-presentation: paint\");\n const to = prevImage;\n const from = nextImage;\n const width = from?.width ?? to?.width ?? 0;\n const height = from?.height ?? to?.height ?? 0;\n if (width === 0 || height === 0) {\n instance.clear();\n continueRender(handle);\n return;\n }\n instance.draw({\n from,\n to,\n width,\n height,\n progress: !to ? 0 : !from ? 1 : progress,\n passedProps: passedPropsRef.current,\n });\n continueRender(handle);\n };\n\n const draw = React.useCallback(\n (\n prevImage: OffscreenCanvas | null,\n nextImage: OffscreenCanvas | null,\n progress: number,\n ) => drawRef.current(prevImage, nextImage, progress),\n [],\n );\n\n React.useLayoutEffect(() => {\n if (passThrough) {\n return;\n }\n const layout = layoutRef.current;\n const output = outputRef.current;\n if (!layout || !output) {\n return;\n }\n const capture = takeOffscreen(layout);\n const context = capture.getContext(\"2d\");\n if (!context) {\n throw new Error(\"canvas-presentation: failed to acquire a 2D context\");\n }\n const surface = takeOffscreen(output);\n captureRef.current = capture;\n captureContextRef.current = context;\n outputSurfaceRef.current = surface;\n instanceRef.current = shader(surface);\n\n return () => {\n instanceRef.current?.cleanup();\n instanceRef.current = null;\n captureRef.current = null;\n captureContextRef.current = null;\n outputSurfaceRef.current = null;\n };\n }, [passThrough, shader]);\n\n React.useLayoutEffect(() => {\n if (passThrough) {\n return;\n }\n const layout = layoutRef.current;\n if (!layout) {\n return;\n }\n layout.layoutSubtree = true;\n const handlePaint = () => {\n const scene = layout.firstElementChild;\n const capture = captureRef.current;\n const context = captureContextRef.current;\n if (!scene || !capture || !context) {\n return;\n }\n const elementImage = layout.captureElementImage(scene);\n try {\n context.reset();\n context.drawElementImage(elementImage, 0, 0);\n } finally {\n elementImage.close();\n }\n onElementImageRef.current(capture, draw);\n };\n layout.addEventListener(\"paint\", handlePaint);\n return () => layout.removeEventListener(\"paint\", handlePaint);\n }, [passThrough, draw]);\n\n React.useLayoutEffect(() => {\n if (passThrough) {\n return;\n }\n const layout = layoutRef.current;\n if (!layout) {\n return;\n }\n const observer = new ResizeObserver(([entry]) => {\n const capture = captureRef.current;\n const surface = outputSurfaceRef.current;\n if (!capture || !surface) {\n return;\n }\n const width = entry.devicePixelContentBoxSize[0].inlineSize;\n const height = entry.devicePixelContentBoxSize[0].blockSize;\n capture.width = width;\n capture.height = height;\n surface.width = width;\n surface.height = height;\n layout.requestPaint?.();\n });\n observer.observe(layout, { box: \"device-pixel-content-box\" });\n return () => observer.disconnect();\n }, [passThrough]);\n\n // biome-ignore lint/correctness/useExhaustiveDependencies: presentationProgress is the intentional trigger — a new progress value is what schedules the next paint\n React.useLayoutEffect(() => {\n if (passThrough) {\n return;\n }\n layoutRef.current?.requestPaint?.();\n }, [passThrough, presentationProgress]);\n\n React.useLayoutEffect(() => {\n if (passThrough) {\n return;\n }\n return () => onUnmountRef.current();\n }, [passThrough]);\n\n if (passThrough) {\n return <>{children}</>;\n }\n\n return (\n <AbsoluteFill>\n <canvas ref={layoutRef} style={LAYER}>\n {children}\n </canvas>\n <canvas ref={outputRef} style={OUTPUT_LAYER} />\n </AbsoluteFill>\n );\n };\n}\n\ntype CanvasFilterProps = {\n children: React.ReactNode;\n};\n\nfunction makeFilterComponent<Props extends Record<string, unknown>>(\n shader: SceneFilter<Props>,\n): React.FC<Props & CanvasFilterProps> {\n return function CanvasSceneFilter(props) {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const { delayRender, continueRender } = useDelayRender();\n\n const layoutRef = React.useRef<HTMLCanvasElement | null>(null);\n const outputRef = React.useRef<HTMLCanvasElement | null>(null);\n const captureRef = React.useRef<OffscreenCanvas | null>(null);\n const captureContextRef =\n React.useRef<OffscreenCanvasRenderingContext2D | null>(null);\n const outputSurfaceRef = React.useRef<OffscreenCanvas | null>(null);\n const instanceRef = React.useRef<SceneFilterInstance<Props> | null>(null);\n\n const passedPropsRef = React.useRef(props);\n passedPropsRef.current = props;\n const frameRef = React.useRef(frame);\n frameRef.current = frame;\n const timeRef = React.useRef(frame / fps);\n timeRef.current = frame / fps;\n\n React.useLayoutEffect(() => {\n const layout = layoutRef.current;\n const output = outputRef.current;\n if (!layout || !output) {\n return;\n }\n const capture = takeOffscreen(layout);\n const context = capture.getContext(\"2d\");\n if (!context) {\n throw new Error(\"canvas-presentation: failed to acquire a 2D context\");\n }\n const surface = takeOffscreen(output);\n captureRef.current = capture;\n captureContextRef.current = context;\n outputSurfaceRef.current = surface;\n instanceRef.current = shader(surface);\n\n return () => {\n instanceRef.current?.cleanup();\n instanceRef.current = null;\n captureRef.current = null;\n captureContextRef.current = null;\n outputSurfaceRef.current = null;\n };\n }, [shader]);\n\n React.useLayoutEffect(() => {\n const layout = layoutRef.current;\n if (!layout) {\n return;\n }\n layout.layoutSubtree = true;\n const handlePaint = () => {\n const scene = layout.firstElementChild;\n const capture = captureRef.current;\n const context = captureContextRef.current;\n const instance = instanceRef.current;\n if (!scene || !capture || !context || !instance) {\n return;\n }\n const elementImage = layout.captureElementImage(scene);\n try {\n context.reset();\n context.drawElementImage(elementImage, 0, 0);\n } finally {\n elementImage.close();\n }\n if (capture.width === 0 || capture.height === 0) {\n instance.clear();\n return;\n }\n instance.draw({\n scene: capture,\n width: capture.width,\n height: capture.height,\n frame: frameRef.current,\n time: timeRef.current,\n passedProps: passedPropsRef.current,\n });\n };\n layout.addEventListener(\"paint\", handlePaint);\n return () => layout.removeEventListener(\"paint\", handlePaint);\n }, []);\n\n React.useLayoutEffect(() => {\n const layout = layoutRef.current;\n if (!layout) {\n return;\n }\n const observer = new ResizeObserver(([entry]) => {\n const capture = captureRef.current;\n const surface = outputSurfaceRef.current;\n if (!capture || !surface) {\n return;\n }\n const width = entry.devicePixelContentBoxSize[0].inlineSize;\n const height = entry.devicePixelContentBoxSize[0].blockSize;\n capture.width = width;\n capture.height = height;\n surface.width = width;\n surface.height = height;\n layout.requestPaint?.();\n });\n observer.observe(layout, { box: \"device-pixel-content-box\" });\n return () => observer.disconnect();\n }, []);\n\n React.useLayoutEffect(() => {\n const layout = layoutRef.current;\n if (!layout) {\n return;\n }\n const handle = delayRender(\"canvas-presentation: filter paint\");\n const settle = () => continueRender(handle);\n layout.addEventListener(\"paint\", settle, { once: true });\n layout.requestPaint?.();\n return () => {\n layout.removeEventListener(\"paint\", settle);\n continueRender(handle);\n };\n });\n\n return (\n <AbsoluteFill>\n <canvas ref={layoutRef} style={LAYER}>\n {props.children}\n </canvas>\n <canvas ref={outputRef} style={OUTPUT_LAYER} />\n </AbsoluteFill>\n );\n };\n}\n\ntype CanvasPresentationOptions<Props extends Record<string, unknown>> = {\n shader: SceneShader<Props>;\n fallback: React.FC<TransitionPresentationComponentProps<Props>>;\n};\n\nfunction makeCanvasPresentation<Props extends Record<string, unknown>>({\n shader,\n fallback: Fallback,\n}: CanvasPresentationOptions<Props>): (\n props: Props,\n) => TransitionPresentation<Props> {\n const Canvas = makeCanvasComponent(shader);\n\n const Presentation: React.FC<TransitionPresentationComponentProps<Props>> = (\n props,\n ) =>\n isCanvasTransitionSupported() ? (\n <Canvas {...props} />\n ) : (\n <Fallback {...props} />\n );\n\n return (props) => ({ component: Presentation, props });\n}\n\ntype CanvasFilterOptions<Props extends Record<string, unknown>> = {\n shader: SceneFilter<Props>;\n fallback: React.FC<Props & CanvasFilterProps>;\n};\n\nfunction makeCanvasFilter<Props extends Record<string, unknown>>({\n shader,\n fallback: Fallback,\n}: CanvasFilterOptions<Props>): React.FC<Props & CanvasFilterProps> {\n const Canvas = makeFilterComponent(shader);\n\n return function CanvasFilter(props) {\n return isCanvasFilterSupported() ? (\n <Canvas {...props} />\n ) : (\n <Fallback {...props} />\n );\n };\n}\n\ntype VhsFilterProps = {\n bleed?: number;\n wobble?: number;\n noise?: number;\n intensity?: number;\n};\n\nconst DEFAULTS = {\n bleed: 1,\n wobble: 1,\n noise: 1,\n intensity: 1,\n};\n\nconst FRAGMENT_SHADER = `#version 300 es\nprecision highp float;\n\nuniform sampler2D u_scene;\nuniform float u_frame;\nuniform float u_time;\nuniform float u_bleed;\nuniform float u_wobble;\nuniform float u_noise;\nuniform float u_intensity;\n\nin vec2 v_uv;\nout vec4 outColor;\n\nconst float PI = 3.141592653589793;\nconst float LINES = 486.0;\nconst int TAPS = 6;\n\nfloat hash(vec2 p) {\n return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453123);\n}\n\nfloat valueNoise(float x) {\n float i = floor(x);\n float f = fract(x);\n float a = hash(vec2(i, 7.0));\n float b = hash(vec2(i + 1.0, 7.0));\n return mix(a, b, f * f * (3.0 - 2.0 * f));\n}\n\nvec3 rgb2yiq(vec3 c) {\n return vec3(\n dot(c, vec3(0.299, 0.587, 0.114)),\n dot(c, vec3(0.5959, -0.2746, -0.3213)),\n dot(c, vec3(0.2115, -0.5227, 0.3112))\n );\n}\n\nvec3 yiq2rgb(vec3 c) {\n return vec3(\n c.x + 0.956 * c.y + 0.619 * c.z,\n c.x - 0.272 * c.y - 0.647 * c.z,\n c.x - 1.106 * c.y + 1.703 * c.z\n );\n}\n\nvoid main() {\n float line = floor(v_uv.y * LINES);\n float clock = mod(u_frame, 64.0);\n\n float drift =\n sin(v_uv.y * 37.0 + u_time * 2.3) * 0.55 +\n sin(v_uv.y * 96.0 - u_time * 1.1) * 0.25;\n float jitter = valueNoise(line * 0.61 + u_time * 24.0) - 0.5;\n float wobble = (drift * 0.35 + jitter * 0.9) * 0.007 * u_wobble * u_intensity;\n\n float band = smoothstep(0.955, 0.994, v_uv.y);\n float tear = valueNoise(line * 2.7 + u_time * 43.0) - 0.5;\n float headSwitch = band * tear * 0.085 * u_intensity;\n\n vec2 uv = vec2(v_uv.x + wobble + headSwitch, v_uv.y);\n vec4 base = texture(u_scene, uv);\n float luma = rgb2yiq(base.rgb).x;\n\n float smear = u_bleed * 0.02 * u_intensity;\n vec2 chroma = vec2(0.0);\n float total = 0.0;\n for (int i = 0; i < TAPS; i++) {\n float t = float(i) / float(TAPS - 1);\n float weight = 1.0 - t * 0.72;\n vec3 tap = texture(u_scene, vec2(uv.x - smear * t, uv.y)).rgb;\n chroma += rgb2yiq(tap).yz * weight;\n total += weight;\n }\n\n vec3 color = yiq2rgb(vec3(luma, chroma / total));\n\n float scan = 0.94 + 0.06 * cos(v_uv.y * LINES * PI);\n color *= mix(1.0, scan, u_intensity);\n\n float grain =\n hash(vec2(v_uv.x * 640.0 + clock * 13.0, line + clock * 5.0)) - 0.5;\n color += grain * 0.07 * u_noise * u_intensity;\n\n color = mix(color, vec3(luma), band * 0.55 * u_intensity);\n color += band * (hash(vec2(line, clock * 3.0)) - 0.5) * 0.26 * u_intensity;\n\n outColor = vec4(clamp(color, 0.0, 1.0), base.a);\n}`;\n\nconst shader = makeFilterShader<VhsFilterProps>(\n FRAGMENT_SHADER,\n ({ gl, uniform, passedProps }) => {\n const {\n bleed = DEFAULTS.bleed,\n wobble = DEFAULTS.wobble,\n noise = DEFAULTS.noise,\n intensity = DEFAULTS.intensity,\n } = passedProps;\n gl.uniform1f(uniform(\"u_bleed\"), bleed);\n gl.uniform1f(uniform(\"u_wobble\"), wobble);\n gl.uniform1f(uniform(\"u_noise\"), noise);\n gl.uniform1f(uniform(\"u_intensity\"), intensity);\n },\n);\n\nconst VhsFilterFallback: React.FC<VhsFilterProps & CanvasFilterProps> = ({\n children,\n bleed = DEFAULTS.bleed,\n wobble = DEFAULTS.wobble,\n noise = DEFAULTS.noise,\n intensity = DEFAULTS.intensity,\n}) => {\n const frame = useCurrentFrame();\n const shift =\n (random(`vhs-wobble-${frame}`) - 0.5) * 3.4 * wobble * intensity;\n const flicker =\n 1 + (random(`vhs-flicker-${frame}`) - 0.5) * 0.07 * noise * intensity;\n const smear = 3 + bleed * 5;\n\n return (\n <AbsoluteFill>\n <AbsoluteFill\n style={{\n translate: `${shift}px`,\n filter: `saturate(${1 + bleed * 0.3}) contrast(1.04) brightness(${flicker}) blur(${0.3 * intensity}px)`,\n }}\n >\n {children}\n </AbsoluteFill>\n <AbsoluteFill\n style={{\n translate: `${shift - smear}px`,\n filter: \"saturate(2.2) blur(1.4px)\",\n mixBlendMode: \"screen\",\n opacity: 0.24 * bleed * intensity,\n }}\n >\n {children}\n </AbsoluteFill>\n <AbsoluteFill\n style={{\n background:\n \"repeating-linear-gradient(to bottom, rgba(0, 0, 0, 0.22) 0px, rgba(0, 0, 0, 0.22) 1px, transparent 1px, transparent 3px)\",\n opacity: intensity,\n }}\n />\n <div\n style={{\n position: \"absolute\",\n insetInline: 0,\n bottom: 0,\n height: \"3.6%\",\n translate: `${shift * 3}px`,\n background: `rgba(228, 228, 228, ${0.13 * intensity})`,\n mixBlendMode: \"screen\",\n }}\n />\n </AbsoluteFill>\n );\n};\n\nconst VhsFilterBase = makeCanvasFilter<VhsFilterProps>({\n shader,\n fallback: VhsFilterFallback,\n});\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n bleed: {\n type: \"number\",\n min: 0,\n max: 3,\n step: 0.1,\n default: 1,\n description: \"Chroma bleed\",\n hiddenFromList: false,\n },\n wobble: {\n type: \"number\",\n min: 0,\n max: 3,\n step: 0.1,\n default: 1,\n description: \"Tape wobble\",\n hiddenFromList: false,\n },\n noise: {\n type: \"number\",\n min: 0,\n max: 3,\n step: 0.1,\n default: 1,\n description: \"Noise\",\n hiddenFromList: false,\n },\n intensity: {\n type: \"number\",\n min: 0,\n max: 1,\n step: 0.05,\n default: 1,\n description: \"Intensity\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"bleed\",\"wobble\",\"noise\",\"intensity\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n bleed: 1,\n wobble: 1,\n noise: 1,\n intensity: 1,\n speed: 1,\n};\n\ntype VhsFilterElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof VhsFilterBase>;\n\nconst VhsFilterInner = forwardRef<\n HTMLDivElement,\n VhsFilterElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<VhsFilter>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <VhsFilterBase\n {...(componentProps as unknown as ComponentProps<typeof VhsFilterBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const VhsFilter = Interactive.withSchema({\n Component: VhsFilterInner,\n componentName: \"<VhsFilter>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/word-push.json b/registry-artifacts/elements/word-push.jsonindex caa41b32..633758d9 100644--- a/registry-artifacts/elements/word-push.json+++ b/registry-artifacts/elements/word-push.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [],"dimensions": {"width": 760,@@ -9,6 +10,7 @@},"displayName": "Word Push","durationInFrames": 42,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "word-push","sourceCode": "import { Easing, Interactive, Sequence, interpolate, useCurrentFrame, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface WordPushProps {\n text: string;\n fontSize?: number;\n color?: string;\n fontWeight?: number;\n wordGap?: number;\n accel?: number;\n speed?: number;\n className?: string;\n}\n\nconst REVEAL_FRAMES = 2;\nconst SLIDE_FRAMES = 12;\nconst OVERSHOOT_EM = 0.5;\nconst CHAR_WIDTH_EM = 0.5;\nconst SPACE_WIDTH_EM = 0.22;\n\nfunction revealFrame(index: number, wordGap: number, accel: number): number {\n if (accel === 1) return index * wordGap;\n return (wordGap * (1 - accel ** index)) / (1 - accel);\n}\n\nfunction wordPushLength(\n text: string,\n wordGap = 10,\n accel = 0.8,\n): number {\n const words = text.trim().split(/\\s+/).filter(Boolean);\n if (words.length === 0) return 0;\n return (\n Math.ceil(revealFrame(words.length - 1, wordGap, accel)) + SLIDE_FRAMES\n );\n}\n\nconst pushEasing = Easing.out(Easing.cubic);\nconst driveEasing = Easing.bezier(0.15, 0.7, 0.25, 1);\n\nfunction WordPushBase({\n text,\n fontSize = 72,\n color = \"#171717\",\n fontWeight = 400,\n wordGap = 10,\n accel = 0.8,\n speed = 1,\n className,\n}: WordPushProps) {\n const frame = useCurrentFrame() * speed;\n\n const words = text.trim().split(/\\s+/).filter(Boolean);\n\n let lineX = interpolate(\n frame,\n [0, SLIDE_FRAMES],\n [-OVERSHOOT_EM * fontSize, 0],\n {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: driveEasing,\n },\n );\n for (let j = 1; j < words.length; j++) {\n const wordWidth =\n (words[j].length * CHAR_WIDTH_EM + SPACE_WIDTH_EM) * fontSize;\n const revealAt = revealFrame(j, wordGap, accel);\n const pushed = interpolate(\n frame,\n [revealAt + 1, revealAt + 1 + SLIDE_FRAMES],\n [0, 1],\n {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: pushEasing,\n },\n );\n lineX += (wordWidth / 2) * (1 - pushed);\n }\n\n return (\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n whiteSpace: \"nowrap\",\n translate: `${lineX}px 0`,\n background: \"transparent\",\n }}\n >\n <span\n className={className}\n style={{\n fontSize,\n fontWeight,\n color,\n letterSpacing: \"-0.02em\",\n fontFamily:\n \"var(--font-geist-sans, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif)\",\n }}\n >\n {words.map((word, j) => {\n const revealAt = revealFrame(j, wordGap, accel);\n\n const opacity = interpolate(\n frame,\n [revealAt, revealAt + REVEAL_FRAMES],\n [0, 1],\n {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n },\n );\n\n const driven =\n j === 0\n ? 1\n : interpolate(\n frame,\n [revealAt, revealAt + SLIDE_FRAMES],\n [0, 1],\n {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: driveEasing,\n },\n );\n\n return (\n <span\n key={j}\n style={{\n display: \"inline-block\",\n whiteSpace: \"pre\",\n marginRight: j < words.length - 1 ? \"0.22em\" : undefined,\n opacity,\n translate: `${OVERSHOOT_EM * fontSize * (1 - driven)}px 0`,\n }}\n >\n {word}\n </span>\n );\n })}\n </span>\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n text: {\n type: \"text-content\",\n default: \"move at your own pace\",\n description: \"Text\",\n },\n fontSize: {\n type: \"number\",\n min: 12,\n max: 160,\n step: 1,\n default: 72,\n description: \"Font size\",\n hiddenFromList: false,\n },\n wordGap: {\n type: \"number\",\n min: 3,\n max: 30,\n step: 1,\n default: 10,\n description: \"Frames / word\",\n hiddenFromList: false,\n },\n accel: {\n type: \"number\",\n min: 0.5,\n max: 1,\n step: 0.05,\n default: 0.8,\n description: \"Gap shrink / word\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n fontWeight: {\n type: \"enum\",\n default: \"400\",\n variants: {\n \"400\": {},\n \"500\": {},\n \"600\": {},\n \"700\": {},\n },\n description: \"Font weight\",\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 760,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 110,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"text\",\"fontSize\",\"wordGap\",\"accel\",\"color\",\"fontWeight\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n text: \"move at your own pace\",\n fontSize: 72,\n wordGap: 10,\n accel: 0.8,\n color: \"#171717\",\n fontWeight: \"400\",\n speed: 1,\n};\n\ntype WordPushElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof WordPushBase>;\n\nconst WordPushInner = forwardRef<\n HTMLDivElement,\n WordPushElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 760, height = 110, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<WordPush>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <WordPushBase\n {...(componentProps as unknown as ComponentProps<typeof WordPushBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const WordPush = Interactive.withSchema({\n Component: WordPushInner,\n componentName: \"<WordPush>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/word-stream.json b/registry-artifacts/elements/word-stream.jsonindex b940305d..574ede6c 100644--- a/registry-artifacts/elements/word-stream.json+++ b/registry-artifacts/elements/word-stream.json@@ -2,6 +2,7 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [],"dimensions": {"width": 700,@@ -9,6 +10,7 @@},"displayName": "Word Stream","durationInFrames": 63,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "word-stream","sourceCode": "import { Easing, Interactive, Sequence, interpolate, useCurrentFrame, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface WordStreamProps {\n text: string;\n fontSize?: number;\n color?: string;\n fontWeight?: number;\n wordGap?: number;\n hold?: number;\n drift?: number;\n speed?: number;\n className?: string;\n}\n\ninterface PhraseSchedule {\n words: string[];\n start: number;\n exitStart: number;\n last: boolean;\n}\n\nconst REVEAL_FRAMES = 3;\nconst ENTRY_FRAMES = 8;\nconst RUN_OUT_FRAMES = 5;\nconst SWAP_OVERLAP = 0;\n\nfunction wordStreamLength(text: string, wordGap = 6, hold = 18): number {\n const schedule = schedulePhrases(text, wordGap, hold);\n const finalPhrase = schedule[schedule.length - 1];\n if (!finalPhrase) return 0;\n return (\n finalPhrase.start + (finalPhrase.words.length - 1) * wordGap + REVEAL_FRAMES\n );\n}\n\nfunction schedulePhrases(\n text: string,\n wordGap: number,\n hold: number,\n): PhraseSchedule[] {\n const phrases = text\n .split(\"|\")\n .map((phrase) => phrase.trim())\n .filter(Boolean);\n let cursor = 0;\n return phrases.map((phrase, i) => {\n const words = phrase.split(/\\s+/);\n const start = cursor;\n const complete = start + (words.length - 1) * wordGap + REVEAL_FRAMES;\n const exitStart = complete + hold;\n cursor = exitStart + SWAP_OVERLAP;\n return { words, start, exitStart, last: i === phrases.length - 1 };\n });\n}\n\nconst revealEasing = Easing.bezier(0.2, 0.8, 0.2, 1);\nconst entryEasing = Easing.bezier(0.2, 0.8, 0.3, 1);\nconst runOutEasing = Easing.bezier(0.7, 0, 0.9, 0.4);\n\nfunction WordStreamBase({\n text,\n fontSize = 72,\n color = \"#171717\",\n fontWeight = 400,\n wordGap = 6,\n hold = 18,\n drift = 2,\n speed = 1,\n className,\n}: WordStreamProps) {\n const frame = useCurrentFrame() * speed;\n\n const schedule = schedulePhrases(text, wordGap, hold);\n\n return (\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n background: \"transparent\",\n }}\n >\n {schedule.map((phrase, i) => {\n if (frame < phrase.start) return null;\n if (!phrase.last && frame >= phrase.exitStart) return null;\n\n const scale = fontSize / 72;\n const crawl = scale * drift;\n const life = phrase.exitStart - phrase.start;\n\n const entryX = interpolate(\n frame,\n [phrase.start, phrase.start + ENTRY_FRAMES],\n [scale * 30, 0],\n {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: entryEasing,\n },\n );\n const crawlX =\n crawl *\n (life / 2 - (Math.min(frame, phrase.exitStart) - phrase.start));\n const runOutX = phrase.last\n ? 0\n : interpolate(\n frame,\n [phrase.exitStart - RUN_OUT_FRAMES, phrase.exitStart],\n [0, -scale * 80],\n {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: runOutEasing,\n },\n );\n const x = entryX + crawlX + runOutX;\n\n return (\n <div\n key={i}\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n whiteSpace: \"nowrap\",\n translate: `${x}px 0`,\n }}\n >\n <span\n className={className}\n style={{\n fontSize,\n fontWeight,\n color,\n letterSpacing: \"-0.02em\",\n fontFamily:\n \"var(--font-geist-sans, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif)\",\n }}\n >\n {phrase.words.map((word, j) => {\n const revealAt = phrase.start + j * wordGap;\n\n const opacity = interpolate(\n frame,\n [revealAt, revealAt + REVEAL_FRAMES],\n [0, 1],\n {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: revealEasing,\n },\n );\n\n return (\n <span\n key={j}\n style={{\n display: \"inline-block\",\n whiteSpace: \"pre\",\n marginRight:\n j < phrase.words.length - 1 ? \"0.28em\" : undefined,\n opacity,\n }}\n >\n {word}\n </span>\n );\n })}\n </span>\n </div>\n );\n })}\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n text: {\n type: \"text-content\",\n default: \"introducing | one-tap checkout | for your store\",\n description: \"Phrases (| separated)\",\n },\n fontSize: {\n type: \"number\",\n min: 12,\n max: 160,\n step: 1,\n default: 72,\n description: \"Font size\",\n hiddenFromList: false,\n },\n wordGap: {\n type: \"number\",\n min: 2,\n max: 30,\n step: 1,\n default: 6,\n description: \"Frames / word\",\n hiddenFromList: false,\n },\n hold: {\n type: \"number\",\n min: 6,\n max: 90,\n step: 3,\n default: 18,\n description: \"Phrase hold\",\n hiddenFromList: false,\n },\n drift: {\n type: \"number\",\n min: 0,\n max: 6,\n step: 0.5,\n default: 2,\n description: \"Drift px / frame\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#171717\",\n description: \"Color\",\n },\n fontWeight: {\n type: \"enum\",\n default: \"400\",\n variants: {\n \"400\": {},\n \"500\": {},\n \"600\": {},\n \"700\": {},\n },\n description: \"Font weight\",\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n width: {\n type: \"number\",\n default: 700,\n min: 10,\n step: 10,\n description: \"Width\",\n },\n height: {\n type: \"number\",\n default: 110,\n min: 10,\n step: 10,\n description: \"Height\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"text\",\"fontSize\",\"wordGap\",\"hold\",\"drift\",\"color\",\"fontWeight\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n text: \"introducing | one-tap checkout | for your store\",\n fontSize: 72,\n wordGap: 6,\n hold: 18,\n drift: 2,\n color: \"#171717\",\n fontWeight: \"400\",\n speed: 1,\n};\n\ntype WordStreamElementProps = InteractiveBaseProps &\n InteractiveTransformProps & { readonly width?: number; readonly height?: number } &\n ComponentProps<typeof WordStreamBase>;\n\nconst WordStreamInner = forwardRef<\n HTMLDivElement,\n WordStreamElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, width = 700, height = 110, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<WordStream>\"}\n outlineRef={outlineRef}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width,\n height,\n ...style,\n }}\n >\n <WordStreamBase\n {...(componentProps as unknown as ComponentProps<typeof WordStreamBase>)}\n />\n </div>\n </div>\n </Sequence>\n );\n});\n\nexport const WordStream = Interactive.withSchema({\n Component: WordStreamInner,\n componentName: \"<WordStream>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/elements/zoom-words.json b/registry-artifacts/elements/zoom-words.jsonindex 1de3addf..c9fe10e4 100644--- a/registry-artifacts/elements/zoom-words.json+++ b/registry-artifacts/elements/zoom-words.json@@ -2,10 +2,12 @@"type": "remotion-element","version": 1,"element": {+ "assets": [],"dependencies": [],"dimensions": null,"displayName": "Zoom Words","durationInFrames": 63,+ "initialProps": null,"installationMode": "component-owned-sequence","slug": "zoom-words","sourceCode": "import { Easing, Interactive, Sequence, interpolate, useCurrentFrame, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface ZoomWordsProps {\n text: string;\n fontSize?: number;\n zoom?: number;\n color?: string;\n fontWeight?: number;\n wordGap?: number;\n anchor?: number;\n blur?: number;\n blurFrames?: number;\n speed?: number;\n className?: string;\n}\n\nconst CHAR_WIDTH_EM = 0.52;\nconst SPACE_WIDTH_EM = 0.3;\nconst WORD_BLUR_EM = 0.05;\nconst phraseEasing = Easing.bezier(0.5, 0, 0.7, 0.7);\nconst FADE_EARLY = 0.5;\nconst FADE_SLOTS = 2;\n\nfunction smoothstep(t: number): number {\n const x = Math.min(Math.max(t, 0), 1);\n return x * x * (3 - 2 * x);\n}\nconst WORD_SHIFT_X_EM = 0.16;\nconst WORD_SHIFT_Y_EM = 0.12;\n\nfunction wordWidthEm(word: string): number {\n return Array.from(word).length * CHAR_WIDTH_EM + SPACE_WIDTH_EM;\n}\n\nfunction zoomWordsLength(text: string, wordGap = 12): number {\n const words = text.trim().split(/\\s+/).filter(Boolean);\n return words.length * wordGap;\n}\n\nfunction ZoomWordsBase({\n text,\n fontSize = 64,\n zoom = 2.2,\n color = \"#cfc2ff\",\n fontWeight = 400,\n wordGap = 12,\n anchor = 0.5,\n blur = 0.04,\n blurFrames = 60,\n speed = 1,\n className,\n}: ZoomWordsProps) {\n const frame = useCurrentFrame() * speed;\n\n const words = text.trim().split(/\\s+/).filter(Boolean);\n\n const phraseFrames = words.length * wordGap;\n const wordProgress =\n words.length *\n interpolate(frame, [0, phraseFrames], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: phraseEasing,\n });\n\n const totalEm = words.reduce((sum, w) => sum + wordWidthEm(w), 0);\n const firstHalfEm = words.length > 0 ? wordWidthEm(words[0]) / 2 : 0;\n const lastHalfEm =\n words.length > 0 ? wordWidthEm(words[words.length - 1]) / 2 : 0;\n let revealedEm = 0;\n for (let i = 0; i < words.length; i++) {\n revealedEm +=\n wordWidthEm(words[i]) *\n smoothstep((wordProgress - i + FADE_EARLY) / FADE_SLOTS);\n }\n const travelMax = Math.max(totalEm - lastHalfEm - firstHalfEm, 0.001);\n const raw = Math.min(Math.max(revealedEm, 0), travelMax);\n const cameraEm = firstHalfEm + travelMax * smoothstep(raw / travelMax);\n const cameraPct = totalEm > 0 ? (cameraEm / totalEm) * 100 : 0;\n\n const blurNow =\n blur *\n fontSize *\n zoom *\n interpolate(frame, [0, blurFrames], [1, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n });\n\n return (\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n overflow: \"hidden\",\n background: \"transparent\",\n }}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n scale: `${zoom}`,\n filter: blurNow > 0.05 ? `blur(${blurNow}px)` : undefined,\n }}\n >\n <div\n style={{\n position: \"absolute\",\n top: \"50%\",\n left: `${anchor * 100}%`,\n transform: \"translateY(-50%)\",\n whiteSpace: \"pre\",\n }}\n >\n <span\n className={className}\n style={{\n display: \"inline-flex\",\n alignItems: \"baseline\",\n transform: `translateX(-${cameraPct.toFixed(3)}%)`,\n fontSize,\n fontWeight,\n color,\n letterSpacing: \"-0.02em\",\n lineHeight: 1.15,\n whiteSpace: \"pre\",\n fontFamily:\n \"var(--font-geist-sans, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif)\",\n }}\n >\n {words.map((word, i) => {\n const p = smoothstep(\n (wordProgress - i + FADE_EARLY) / FADE_SLOTS,\n );\n const opacity = smoothstep(p * 1.2);\n const wordBlur = WORD_BLUR_EM * fontSize * (1 - p);\n const arrive = 1 - smoothstep(p * 1.6);\n return (\n <span\n key={i}\n style={{\n display: \"inline-block\",\n whiteSpace: \"pre\",\n opacity,\n filter: wordBlur > 0.05 ? `blur(${wordBlur}px)` : undefined,\n translate: `${(WORD_SHIFT_X_EM * fontSize * arrive).toFixed(1)}px ${(WORD_SHIFT_Y_EM * fontSize * arrive).toFixed(1)}px`,\n }}\n >\n {word}\n {i < words.length - 1 && \" \"}\n </span>\n );\n })}\n </span>\n </div>\n </div>\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n text: {\n type: \"text-content\",\n default: \"Still piecing together tools\",\n description: \"Text\",\n },\n fontSize: {\n type: \"number\",\n min: 24,\n max: 160,\n step: 1,\n default: 64,\n description: \"Font size\",\n hiddenFromList: false,\n },\n wordGap: {\n type: \"number\",\n min: 4,\n max: 24,\n step: 1,\n default: 12,\n description: \"Frames / word\",\n hiddenFromList: false,\n },\n zoom: {\n type: \"number\",\n min: 1,\n max: 4,\n step: 0.1,\n default: 2.2,\n description: \"Camera zoom\",\n hiddenFromList: false,\n },\n anchor: {\n type: \"number\",\n min: 0.2,\n max: 0.9,\n step: 0.05,\n default: 0.5,\n description: \"Camera anchor\",\n hiddenFromList: false,\n },\n blur: {\n type: \"number\",\n min: 0,\n max: 0.3,\n step: 0.01,\n default: 0.04,\n description: \"Start blur (em)\",\n hiddenFromList: false,\n },\n blurFrames: {\n type: \"number\",\n min: 10,\n max: 120,\n step: 5,\n default: 60,\n description: \"Focus frames\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#cfc2ff\",\n description: \"Color\",\n },\n fontWeight: {\n type: \"enum\",\n default: \"400\",\n variants: {\n \"400\": {},\n \"500\": {},\n \"600\": {},\n \"700\": {},\n },\n description: \"Font weight\",\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"text\",\"fontSize\",\"wordGap\",\"zoom\",\"anchor\",\"blur\",\"blurFrames\",\"color\",\"fontWeight\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n text: \"Still piecing together tools\",\n fontSize: 64,\n wordGap: 12,\n zoom: 2.2,\n anchor: 0.5,\n blur: 0.04,\n blurFrames: 60,\n color: \"#cfc2ff\",\n fontWeight: \"400\",\n speed: 1,\n};\n\ntype ZoomWordsElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof ZoomWordsBase>;\n\nconst ZoomWordsInner = forwardRef<\n HTMLDivElement,\n ZoomWordsElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<ZoomWords>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <ZoomWordsBase\n {...(componentProps as unknown as ComponentProps<typeof ZoomWordsBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const ZoomWords = Interactive.withSchema({\n Component: ZoomWordsInner,\n componentName: \"<ZoomWords>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"diff --git a/registry-artifacts/registry.json b/registry-artifacts/registry.jsonindex 1fe57bf7..484de8a0 100644--- a/registry-artifacts/registry.json+++ b/registry-artifacts/registry.json@@ -2572,6 +2572,485 @@],"type": "registry:component"},+ {+ "name": "caption-core",+ "title": "Caption Core",+ "description": "The timing engine every caption style shares: pages a timed transcript, finds the word being spoken and how far into it the voice is, and decides when a page leaves the screen.",+ "dependencies": ["remotion", "@remotion/captions"],+ "files": [+ {+ "path": "registry/remocn/caption-core/index.ts",+ "type": "registry:lib",+ "target": "lib/remocn/caption-core.ts"+ }+ ],+ "type": "registry:lib"+ },+ {+ "name": "caption-karaoke",+ "title": "Caption Karaoke",+ "description": "Transcript captions where each word fills with colour left to right exactly as it is spoken, the whole phrase readable before the voice reaches it.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "registry/remocn/caption-karaoke/index.tsx",+ "type": "registry:component",+ "target": "components/remocn/caption-karaoke.tsx"+ }+ ],+ "type": "registry:component"+ },+ {+ "name": "caption-highlight-box",+ "title": "Caption Highlight Box",+ "description": "A solid box travels behind the word being spoken, sliding from word to word as the voice moves on.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "registry/remocn/caption-highlight-box/index.tsx",+ "type": "registry:component",+ "target": "components/remocn/caption-highlight-box.tsx"+ }+ ],+ "type": "registry:component"+ },+ {+ "name": "caption-active-pop",+ "title": "Caption Active Pop",+ "description": "The word being spoken turns to the accent colour and springs up in scale, then settles back as the voice moves on.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "registry/remocn/caption-active-pop/index.tsx",+ "type": "registry:component",+ "target": "components/remocn/caption-active-pop.tsx"+ }+ ],+ "type": "registry:component"+ },+ {+ "name": "caption-word-pop",+ "title": "Caption Word Pop",+ "description": "One large word at a time, each popping in on a spring the moment it is spoken.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "registry/remocn/caption-word-pop/index.tsx",+ "type": "registry:component",+ "target": "components/remocn/caption-word-pop.tsx"+ }+ ],+ "type": "registry:component"+ },+ {+ "name": "caption-bounce-in",+ "title": "Caption Bounce In",+ "description": "Each word springs up into place with a little overshoot the moment it is spoken, and the phrase builds word by word.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "registry/remocn/caption-bounce-in/index.tsx",+ "type": "registry:component",+ "target": "components/remocn/caption-bounce-in.tsx"+ }+ ],+ "type": "registry:component"+ },+ {+ "name": "caption-blur-in",+ "title": "Caption Blur In",+ "description": "Each word resolves out of a soft blur the moment it is spoken, for captions that arrive quietly.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "registry/remocn/caption-blur-in/index.tsx",+ "type": "registry:component",+ "target": "components/remocn/caption-blur-in.tsx"+ }+ ],+ "type": "registry:component"+ },+ {+ "name": "caption-rise",+ "title": "Caption Rise",+ "description": "Each word slides up out of a mask at its baseline the moment it is spoken, with no bounce and no scale.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "registry/remocn/caption-rise/index.tsx",+ "type": "registry:component",+ "target": "components/remocn/caption-rise.tsx"+ }+ ],+ "type": "registry:component"+ },+ {+ "name": "caption-typewriter",+ "title": "Caption Typewriter",+ "description": "Each word types out character by character at the pace it is spoken, with a caret that blinks while the speaker pauses.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "registry/remocn/caption-typewriter/index.tsx",+ "type": "registry:component",+ "target": "components/remocn/caption-typewriter.tsx"+ }+ ],+ "type": "registry:component"+ },+ {+ "name": "caption-slot",+ "title": "Caption Slot",+ "description": "One short line at a time, each new phrase rolling up into place as the previous one rolls out the top.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "registry/remocn/caption-slot/index.tsx",+ "type": "registry:component",+ "target": "components/remocn/caption-slot.tsx"+ }+ ],+ "type": "registry:component"+ },+ {+ "name": "caption-subtitle",+ "title": "Caption Subtitle",+ "description": "Classic broadcast subtitles, a whole phrase on a translucent plate, with no word-level animation at all.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "registry/remocn/caption-subtitle/index.tsx",+ "type": "registry:component",+ "target": "components/remocn/caption-subtitle.tsx"+ }+ ],+ "type": "registry:component"+ },+ {+ "name": "caption-dim-progress",+ "title": "Caption Dim Progress",+ "description": "The whole phrase sits on screen dimmed and each word brightens the moment it is spoken, with no motion at all.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "registry/remocn/caption-dim-progress/index.tsx",+ "type": "registry:component",+ "target": "components/remocn/caption-dim-progress.tsx"+ }+ ],+ "type": "registry:component"+ },+ {+ "name": "caption-underline",+ "title": "Caption Underline",+ "description": "A bar slides under the word being spoken, travelling from word to word while the text itself stays untouched.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "registry/remocn/caption-underline/index.tsx",+ "type": "registry:component",+ "target": "components/remocn/caption-underline.tsx"+ }+ ],+ "type": "registry:component"+ },+ {+ "name": "caption-scramble",+ "title": "Caption Scramble",+ "description": "Each word arrives as random glyphs at the moment it is spoken and decodes left to right into the real letters.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "registry/remocn/caption-scramble/index.tsx",+ "type": "registry:component",+ "target": "components/remocn/caption-scramble.tsx"+ }+ ],+ "type": "registry:component"+ },+ {+ "name": "caption-weight",+ "title": "Caption Weight",+ "description": "The word being spoken swells from a light weight to a heavy one and relaxes as the voice moves on, with no layout shift.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "registry/remocn/caption-weight/index.tsx",+ "type": "registry:component",+ "target": "components/remocn/caption-weight.tsx"+ }+ ],+ "type": "registry:component"+ },+ {+ "name": "caption-emoji",+ "title": "Caption Emoji",+ "description": "An emoji pops up above a chosen word the moment it is spoken and stays until the phrase leaves.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "registry/remocn/caption-emoji/index.tsx",+ "type": "registry:component",+ "target": "components/remocn/caption-emoji.tsx"+ }+ ],+ "type": "registry:component"+ },+ {+ "name": "caption-speaker",+ "title": "Caption Speaker",+ "description": "Dialogue captions where every phrase takes its speaker's colour, so a conversation reads like a script.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "registry/remocn/caption-speaker/index.tsx",+ "type": "registry:component",+ "target": "components/remocn/caption-speaker.tsx"+ }+ ],+ "type": "registry:component"+ },+ {+ "name": "caption-stack",+ "title": "Caption Stack",+ "description": "Kinetic captions stacked a couple of words per line, with the keyword of each page set large on its own line.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "registry/remocn/caption-stack/index.tsx",+ "type": "registry:component",+ "target": "components/remocn/caption-stack.tsx"+ }+ ],+ "type": "registry:component"+ },+ {+ "name": "caption-outline",+ "title": "Caption Outline",+ "description": "Heavy-stroked captions that stay readable over any footage, with the spoken word switching to a contrast colour and nothing else moving.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "registry/remocn/caption-outline/index.tsx",+ "type": "registry:component",+ "target": "components/remocn/caption-outline.tsx"+ }+ ],+ "type": "registry:component"+ },+ {+ "name": "caption-marker",+ "title": "Caption Marker",+ "description": "Plain captions where the words that matter get a highlighter swipe the moment they are spoken.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "registry/remocn/caption-marker/index.tsx",+ "type": "registry:component",+ "target": "components/remocn/caption-marker.tsx"+ }+ ],+ "type": "registry:component"+ },+ {+ "name": "caption-stamp",+ "title": "Caption Stamp",+ "description": "Plain captions where the words that matter slam down as a rubber stamp the moment they are spoken.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "registry/remocn/caption-stamp/index.tsx",+ "type": "registry:component",+ "target": "components/remocn/caption-stamp.tsx"+ }+ ],+ "type": "registry:component"+ },+ {+ "name": "caption-handwrite",+ "title": "Caption Handwrite",+ "description": "Each word is inked in by hand from left to right at the pace it is spoken, every word sitting at its own slight angle.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "registry/remocn/caption-handwrite/index.tsx",+ "type": "registry:component",+ "target": "components/remocn/caption-handwrite.tsx"+ }+ ],+ "type": "registry:component"+ },+ {+ "name": "caption-redact",+ "title": "Caption Redact",+ "description": "The whole phrase starts blacked out like a declassified file, and each bar pulls away the moment its word is spoken.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "registry/remocn/caption-redact/index.tsx",+ "type": "registry:component",+ "target": "components/remocn/caption-redact.tsx"+ }+ ],+ "type": "registry:component"+ },+ {+ "name": "caption-prosody",+ "title": "Caption Prosody",+ "description": "Word size follows the delivery, so drawn-out words land large and rushed words stay small, and the rhythm of the voice is visible with the sound off.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "registry/remocn/caption-prosody/index.tsx",+ "type": "registry:component",+ "target": "components/remocn/caption-prosody.tsx"+ }+ ],+ "type": "registry:component"+ },+ {+ "name": "caption-timeline",+ "title": "Caption Timeline",+ "description": "The whole transcript laid out on a scrolling time strip that slides under a fixed playhead, so every pause shows up as space between words.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "registry/remocn/caption-timeline/index.tsx",+ "type": "registry:component",+ "target": "components/remocn/caption-timeline.tsx"+ }+ ],+ "type": "registry:component"+ },+ {+ "name": "caption-teleprompter",+ "title": "Caption Teleprompter",+ "description": "The whole transcript scrolls smoothly through a short window with the current line centred, past lines fading above and the next line waiting below.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "registry/remocn/caption-teleprompter/index.tsx",+ "type": "registry:component",+ "target": "components/remocn/caption-teleprompter.tsx"+ }+ ],+ "type": "registry:component"+ },+ {+ "name": "caption-knockout",+ "title": "Caption Knockout",+ "description": "A solid plate with the words cut clean through it, each word punching out the moment it is spoken so the footage shows through the letters.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "registry/remocn/caption-knockout/index.tsx",+ "type": "registry:component",+ "target": "components/remocn/caption-knockout.tsx"+ }+ ],+ "type": "registry:component"+ },+ {+ "name": "caption-slice",+ "title": "Caption Slice",+ "description": "Each word arrives cut in two, the top half sliding in from the left and the bottom from the right, locking together the moment it is spoken.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "registry/remocn/caption-slice/index.tsx",+ "type": "registry:component",+ "target": "components/remocn/caption-slice.tsx"+ }+ ],+ "type": "registry:component"+ },+ {+ "name": "caption-cube",+ "title": "Caption Cube",+ "description": "Each new phrase turns into view as the next face of a 3D cube, the previous phrase rotating up and away on a horizontal hinge.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "registry/remocn/caption-cube/index.tsx",+ "type": "registry:component",+ "target": "components/remocn/caption-cube.tsx"+ }+ ],+ "type": "registry:component"+ },+ {+ "name": "caption-split-flap",+ "title": "Caption Split Flap",+ "description": "Every letter sits on its own flap tile and clatters through a few characters before landing the moment the word is spoken, like a station departure board.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "registry/remocn/caption-split-flap/index.tsx",+ "type": "registry:component",+ "target": "components/remocn/caption-split-flap.tsx"+ }+ ],+ "type": "registry:component"+ },+ {+ "name": "caption-label-maker",+ "title": "Caption Label Maker",+ "description": "Each phrase is punched letter by letter into a strip of embossing tape at the pace it is spoken, the tape feeding out as the words arrive.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "registry/remocn/caption-label-maker/index.tsx",+ "type": "registry:component",+ "target": "components/remocn/caption-label-maker.tsx"+ }+ ],+ "type": "registry:component"+ },+ {+ "name": "caption-drop",+ "title": "Caption Drop",+ "description": "Each word falls into place from above and bounces as it lands the moment it is spoken, and the whole phrase drops out of frame when the speaker pauses.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "registry/remocn/caption-drop/index.tsx",+ "type": "registry:component",+ "target": "components/remocn/caption-drop.tsx"+ }+ ],+ "type": "registry:component"+ },{"name": "remocn-ui","title": "remocn UI Core",diff --git a/registry/__index__.tsx b/registry/__index__.tsxindex f8833537..54107a41 100644--- a/registry/__index__.tsx+++ b/registry/__index__.tsx@@ -3151,6 +3151,356 @@ const registry: Record<string, RegistryEntry> = {loadConfig: () =>import("@/registry/remocn/reel/config").then((m) => m.reelConfig),},+ "caption-karaoke": {+ load: () =>+ import("@/components/docs/examples/caption-karaoke-example").then(+ (m) => ({+ default: m.CaptionKaraokeExampleScene,+ }),+ ),+ loadConfig: () =>+ import("@/registry/remocn/caption-karaoke/config").then(+ (m) => m.captionKaraokeConfig,+ ),+ },+ "caption-highlight-box": {+ load: () =>+ import("@/components/docs/examples/caption-highlight-box-example").then(+ (m) => ({+ default: m.CaptionHighlightBoxExampleScene,+ }),+ ),+ loadConfig: () =>+ import("@/registry/remocn/caption-highlight-box/config").then(+ (m) => m.captionHighlightBoxConfig,+ ),+ },+ "caption-active-pop": {+ load: () =>+ import("@/components/docs/examples/caption-active-pop-example").then(+ (m) => ({+ default: m.CaptionActivePopExampleScene,+ }),+ ),+ loadConfig: () =>+ import("@/registry/remocn/caption-active-pop/config").then(+ (m) => m.captionActivePopConfig,+ ),+ },+ "caption-word-pop": {+ load: () =>+ import("@/components/docs/examples/caption-word-pop-example").then(+ (m) => ({+ default: m.CaptionWordPopExampleScene,+ }),+ ),+ loadConfig: () =>+ import("@/registry/remocn/caption-word-pop/config").then(+ (m) => m.captionWordPopConfig,+ ),+ },+ "caption-bounce-in": {+ load: () =>+ import("@/components/docs/examples/caption-bounce-in-example").then(+ (m) => ({+ default: m.CaptionBounceInExampleScene,+ }),+ ),+ loadConfig: () =>+ import("@/registry/remocn/caption-bounce-in/config").then(+ (m) => m.captionBounceInConfig,+ ),+ },+ "caption-blur-in": {+ load: () =>+ import("@/components/docs/examples/caption-blur-in-example").then(+ (m) => ({+ default: m.CaptionBlurInExampleScene,+ }),+ ),+ loadConfig: () =>+ import("@/registry/remocn/caption-blur-in/config").then(+ (m) => m.captionBlurInConfig,+ ),+ },+ "caption-rise": {+ load: () =>+ import("@/components/docs/examples/caption-rise-example").then((m) => ({+ default: m.CaptionRiseExampleScene,+ })),+ loadConfig: () =>+ import("@/registry/remocn/caption-rise/config").then(+ (m) => m.captionRiseConfig,+ ),+ },+ "caption-typewriter": {+ load: () =>+ import("@/components/docs/examples/caption-typewriter-example").then(+ (m) => ({+ default: m.CaptionTypewriterExampleScene,+ }),+ ),+ loadConfig: () =>+ import("@/registry/remocn/caption-typewriter/config").then(+ (m) => m.captionTypewriterConfig,+ ),+ },+ "caption-slot": {+ load: () =>+ import("@/components/docs/examples/caption-slot-example").then((m) => ({+ default: m.CaptionSlotExampleScene,+ })),+ loadConfig: () =>+ import("@/registry/remocn/caption-slot/config").then(+ (m) => m.captionSlotConfig,+ ),+ },+ "caption-subtitle": {+ load: () =>+ import("@/components/docs/examples/caption-subtitle-example").then(+ (m) => ({+ default: m.CaptionSubtitleExampleScene,+ }),+ ),+ loadConfig: () =>+ import("@/registry/remocn/caption-subtitle/config").then(+ (m) => m.captionSubtitleConfig,+ ),+ },+ "caption-dim-progress": {+ load: () =>+ import("@/components/docs/examples/caption-dim-progress-example").then(+ (m) => ({+ default: m.CaptionDimProgressExampleScene,+ }),+ ),+ loadConfig: () =>+ import("@/registry/remocn/caption-dim-progress/config").then(+ (m) => m.captionDimProgressConfig,+ ),+ },+ "caption-underline": {+ load: () =>+ import("@/components/docs/examples/caption-underline-example").then(+ (m) => ({+ default: m.CaptionUnderlineExampleScene,+ }),+ ),+ loadConfig: () =>+ import("@/registry/remocn/caption-underline/config").then(+ (m) => m.captionUnderlineConfig,+ ),+ },+ "caption-scramble": {+ load: () =>+ import("@/components/docs/examples/caption-scramble-example").then(+ (m) => ({+ default: m.CaptionScrambleExampleScene,+ }),+ ),+ loadConfig: () =>+ import("@/registry/remocn/caption-scramble/config").then(+ (m) => m.captionScrambleConfig,+ ),+ },+ "caption-weight": {+ load: () =>+ import("@/components/docs/examples/caption-weight-example").then((m) => ({+ default: m.CaptionWeightExampleScene,+ })),+ loadConfig: () =>+ import("@/registry/remocn/caption-weight/config").then(+ (m) => m.captionWeightConfig,+ ),+ },+ "caption-emoji": {+ load: () =>+ import("@/components/docs/examples/caption-emoji-example").then((m) => ({+ default: m.CaptionEmojiExampleScene,+ })),+ loadConfig: () =>+ import("@/registry/remocn/caption-emoji/config").then(+ (m) => m.captionEmojiConfig,+ ),+ },+ "caption-speaker": {+ load: () =>+ import("@/components/docs/examples/caption-speaker-example").then(+ (m) => ({+ default: m.CaptionSpeakerExampleScene,+ }),+ ),+ loadConfig: () =>+ import("@/registry/remocn/caption-speaker/config").then(+ (m) => m.captionSpeakerConfig,+ ),+ },+ "caption-stack": {+ load: () =>+ import("@/components/docs/examples/caption-stack-example").then((m) => ({+ default: m.CaptionStackExampleScene,+ })),+ loadConfig: () =>+ import("@/registry/remocn/caption-stack/config").then(+ (m) => m.captionStackConfig,+ ),+ },+ "caption-outline": {+ load: () =>+ import("@/components/docs/examples/caption-outline-example").then(+ (m) => ({+ default: m.CaptionOutlineExampleScene,+ }),+ ),+ loadConfig: () =>+ import("@/registry/remocn/caption-outline/config").then(+ (m) => m.captionOutlineConfig,+ ),+ },+ "caption-marker": {+ load: () =>+ import("@/components/docs/examples/caption-marker-example").then((m) => ({+ default: m.CaptionMarkerExampleScene,+ })),+ loadConfig: () =>+ import("@/registry/remocn/caption-marker/config").then(+ (m) => m.captionMarkerConfig,+ ),+ },+ "caption-stamp": {+ load: () =>+ import("@/components/docs/examples/caption-stamp-example").then((m) => ({+ default: m.CaptionStampExampleScene,+ })),+ loadConfig: () =>+ import("@/registry/remocn/caption-stamp/config").then(+ (m) => m.captionStampConfig,+ ),+ },+ "caption-handwrite": {+ load: () =>+ import("@/components/docs/examples/caption-handwrite-example").then(+ (m) => ({+ default: m.CaptionHandwriteExampleScene,+ }),+ ),+ loadConfig: () =>+ import("@/registry/remocn/caption-handwrite/config").then(+ (m) => m.captionHandwriteConfig,+ ),+ },+ "caption-redact": {+ load: () =>+ import("@/components/docs/examples/caption-redact-example").then((m) => ({+ default: m.CaptionRedactExampleScene,+ })),+ loadConfig: () =>+ import("@/registry/remocn/caption-redact/config").then(+ (m) => m.captionRedactConfig,+ ),+ },+ "caption-prosody": {+ load: () =>+ import("@/components/docs/examples/caption-prosody-example").then(+ (m) => ({+ default: m.CaptionProsodyExampleScene,+ }),+ ),+ loadConfig: () =>+ import("@/registry/remocn/caption-prosody/config").then(+ (m) => m.captionProsodyConfig,+ ),+ },+ "caption-timeline": {+ load: () =>+ import("@/components/docs/examples/caption-timeline-example").then(+ (m) => ({+ default: m.CaptionTimelineExampleScene,+ }),+ ),+ loadConfig: () =>+ import("@/registry/remocn/caption-timeline/config").then(+ (m) => m.captionTimelineConfig,+ ),+ },+ "caption-teleprompter": {+ load: () =>+ import("@/components/docs/examples/caption-teleprompter-example").then(+ (m) => ({+ default: m.CaptionTeleprompterExampleScene,+ }),+ ),+ loadConfig: () =>+ import("@/registry/remocn/caption-teleprompter/config").then(+ (m) => m.captionTeleprompterConfig,+ ),+ },+ "caption-knockout": {+ load: () =>+ import("@/components/docs/examples/caption-knockout-example").then(+ (m) => ({+ default: m.CaptionKnockoutExampleScene,+ }),+ ),+ loadConfig: () =>+ import("@/registry/remocn/caption-knockout/config").then(+ (m) => m.captionKnockoutConfig,+ ),+ },+ "caption-slice": {+ load: () =>+ import("@/components/docs/examples/caption-slice-example").then((m) => ({+ default: m.CaptionSliceExampleScene,+ })),+ loadConfig: () =>+ import("@/registry/remocn/caption-slice/config").then(+ (m) => m.captionSliceConfig,+ ),+ },+ "caption-cube": {+ load: () =>+ import("@/components/docs/examples/caption-cube-example").then((m) => ({+ default: m.CaptionCubeExampleScene,+ })),+ loadConfig: () =>+ import("@/registry/remocn/caption-cube/config").then(+ (m) => m.captionCubeConfig,+ ),+ },+ "caption-split-flap": {+ load: () =>+ import("@/components/docs/examples/caption-split-flap-example").then(+ (m) => ({+ default: m.CaptionSplitFlapExampleScene,+ }),+ ),+ loadConfig: () =>+ import("@/registry/remocn/caption-split-flap/config").then(+ (m) => m.captionSplitFlapConfig,+ ),+ },+ "caption-label-maker": {+ load: () =>+ import("@/components/docs/examples/caption-label-maker-example").then(+ (m) => ({+ default: m.CaptionLabelMakerExampleScene,+ }),+ ),+ loadConfig: () =>+ import("@/registry/remocn/caption-label-maker/config").then(+ (m) => m.captionLabelMakerConfig,+ ),+ },+ "caption-drop": {+ load: () =>+ import("@/components/docs/examples/caption-drop-example").then((m) => ({+ default: m.CaptionDropExampleScene,+ })),+ loadConfig: () =>+ import("@/registry/remocn/caption-drop/config").then(+ (m) => m.captionDropConfig,+ ),+ },};const configCache = new Map<string, Promise<ResolvedComponentConfig>>();diff --git a/registry/__manifest__.ts b/registry/__manifest__.tsindex cd64752f..e5211184 100644--- a/registry/__manifest__.ts+++ b/registry/__manifest__.ts@@ -271,6 +271,670 @@ export const previewManifest: Record<string, PreviewManifestEntry> = {speed: 1,},},+ "caption-active-pop": {+ durationInFrames: 279,+ fps: 30,+ compositionWidth: 1280,+ compositionHeight: 720,+ previewBackdrop: {+ type: "color",+ value: "#262626",+ },+ defaults: {+ captions:+ "So here's the thing. Most demo videos lose people in the first three seconds. Captions keep them watching, even with the sound off.",+ fontSize: 64,+ fontWeight: 800,+ color: "#ffffff",+ activeColor: "#facc15",+ popScale: 1.12,+ combineTokensWithinMilliseconds: 1200,+ holdMs: 600,+ shadow: true,+ },+ },+ "caption-blur-in": {+ durationInFrames: 279,+ fps: 30,+ compositionWidth: 1280,+ compositionHeight: 720,+ previewBackdrop: {+ type: "color",+ value: "#262626",+ },+ defaults: {+ captions:+ "So here's the thing. Most demo videos lose people in the first three seconds. Captions keep them watching, even with the sound off.",+ fontSize: 64,+ fontWeight: 800,+ color: "#ffffff",+ blur: 12,+ combineTokensWithinMilliseconds: 1200,+ holdMs: 600,+ shadow: true,+ },+ },+ "caption-bounce-in": {+ durationInFrames: 279,+ fps: 30,+ compositionWidth: 1280,+ compositionHeight: 720,+ previewBackdrop: {+ type: "color",+ value: "#262626",+ },+ defaults: {+ captions:+ "So here's the thing. Most demo videos lose people in the first three seconds. Captions keep them watching, even with the sound off.",+ fontSize: 64,+ fontWeight: 800,+ color: "#ffffff",+ bounce: 0.6,+ combineTokensWithinMilliseconds: 1200,+ holdMs: 600,+ shadow: true,+ },+ },+ "caption-cube": {+ durationInFrames: 279,+ fps: 30,+ compositionWidth: 1280,+ compositionHeight: 720,+ previewBackdrop: {+ type: "color",+ value: "#262626",+ },+ defaults: {+ captions:+ "So here's the thing. Most demo videos lose people in the first three seconds. Captions keep them watching, even with the sound off.",+ fontSize: 64,+ fontWeight: 800,+ color: "#ffffff",+ tintActive: false,+ activeColor: "#facc15",+ combineTokensWithinMilliseconds: 800,+ holdMs: 600,+ shadow: true,+ },+ },+ "caption-dim-progress": {+ durationInFrames: 279,+ fps: 30,+ compositionWidth: 1280,+ compositionHeight: 720,+ previewBackdrop: {+ type: "color",+ value: "#262626",+ },+ defaults: {+ captions:+ "So here's the thing. Most demo videos lose people in the first three seconds. Captions keep them watching, even with the sound off.",+ fontSize: 64,+ fontWeight: 800,+ color: "#ffffff",+ dimOpacity: 0.35,+ combineTokensWithinMilliseconds: 1200,+ holdMs: 600,+ shadow: true,+ },+ },+ "caption-drop": {+ durationInFrames: 279,+ fps: 30,+ compositionWidth: 1280,+ compositionHeight: 720,+ previewBackdrop: {+ type: "color",+ value: "#262626",+ },+ defaults: {+ captions:+ "So here's the thing. Most demo videos lose people in the first three seconds. Captions keep them watching, even with the sound off.",+ fontSize: 64,+ fontWeight: 800,+ color: "#ffffff",+ bounce: 0.6,+ combineTokensWithinMilliseconds: 1200,+ holdMs: 600,+ shadow: true,+ },+ },+ "caption-emoji": {+ durationInFrames: 279,+ fps: 30,+ compositionWidth: 1280,+ compositionHeight: 720,+ previewBackdrop: {+ type: "color",+ value: "#262626",+ },+ defaults: {+ captions:+ "So here's the thing. Most demo videos lose people in the first three seconds. Captions keep them watching, even with the sound off.",+ fontSize: 64,+ fontWeight: 800,+ color: "#ffffff",+ emojiSize: 0.9,+ combineTokensWithinMilliseconds: 1200,+ holdMs: 600,+ shadow: true,+ },+ },+ "caption-handwrite": {+ durationInFrames: 279,+ fps: 30,+ compositionWidth: 1280,+ compositionHeight: 720,+ previewBackdrop: {+ type: "color",+ value: "#262626",+ },+ defaults: {+ captions:+ "So here's the thing. Most demo videos lose people in the first three seconds. Captions keep them watching, even with the sound off.",+ fontSize: 64,+ fontWeight: 800,+ color: "#ffffff",+ wobble: 1,+ combineTokensWithinMilliseconds: 1200,+ holdMs: 600,+ shadow: true,+ },+ },+ "caption-highlight-box": {+ durationInFrames: 279,+ fps: 30,+ compositionWidth: 1280,+ compositionHeight: 720,+ previewBackdrop: {+ type: "color",+ value: "#262626",+ },+ defaults: {+ captions:+ "So here's the thing. Most demo videos lose people in the first three seconds. Captions keep them watching, even with the sound off.",+ fontSize: 64,+ fontWeight: 800,+ color: "#ffffff",+ activeColor: "#0a0a0a",+ boxColor: "#facc15",+ boxRadius: 0.16,+ boxPadding: 0.14,+ combineTokensWithinMilliseconds: 1200,+ holdMs: 600,+ shadow: true,+ },+ },+ "caption-karaoke": {+ durationInFrames: 279,+ fps: 30,+ compositionWidth: 1280,+ compositionHeight: 720,+ previewBackdrop: {+ type: "color",+ value: "#262626",+ },+ defaults: {+ captions:+ "So here's the thing. Most demo videos lose people in the first three seconds. Captions keep them watching, even with the sound off.",+ fontSize: 64,+ fontWeight: 800,+ color: "#ffffff",+ activeColor: "#facc15",+ combineTokensWithinMilliseconds: 1200,+ holdMs: 600,+ shadow: true,+ },+ },+ "caption-knockout": {+ durationInFrames: 279,+ fps: 30,+ compositionWidth: 1280,+ compositionHeight: 720,+ previewBackdrop: {+ type: "color",+ value: "#262626",+ },+ defaults: {+ captions:+ "So here's the thing. Most demo videos lose people in the first three seconds. Captions keep them watching, even with the sound off.",+ fontSize: 64,+ fontWeight: 800,+ plateColor: "#ffffff",+ upcomingOpacity: 0.15,+ combineTokensWithinMilliseconds: 1200,+ holdMs: 600,+ },+ },+ "caption-label-maker": {+ durationInFrames: 279,+ fps: 30,+ compositionWidth: 1280,+ compositionHeight: 720,+ previewBackdrop: {+ type: "color",+ value: "#262626",+ },+ defaults: {+ captions:+ "So here's the thing. Most demo videos lose people in the first three seconds. Captions keep them watching, even with the sound off.",+ fontSize: 64,+ fontWeight: 800,+ color: "#ffffff",+ tapeColor: "#18181b",+ combineTokensWithinMilliseconds: 1000,+ holdMs: 600,+ },+ },+ "caption-marker": {+ durationInFrames: 279,+ fps: 30,+ compositionWidth: 1280,+ compositionHeight: 720,+ previewBackdrop: {+ type: "color",+ value: "#262626",+ },+ defaults: {+ captions:+ "So here's the thing. Most demo videos lose people in the first three seconds. Captions keep them watching, even with the sound off.",+ fontSize: 64,+ fontWeight: 800,+ color: "#ffffff",+ markerColor: "#facc15",+ markerTextColor: "#0a0a0a",+ combineTokensWithinMilliseconds: 1200,+ holdMs: 600,+ shadow: true,+ },+ },+ "caption-outline": {+ durationInFrames: 279,+ fps: 30,+ compositionWidth: 1280,+ compositionHeight: 720,+ previewBackdrop: {+ type: "color",+ value: "#262626",+ },+ defaults: {+ captions:+ "So here's the thing. Most demo videos lose people in the first three seconds. Captions keep them watching, even with the sound off.",+ fontSize: 64,+ fontWeight: 800,+ color: "#ffffff",+ activeColor: "#facc15",+ strokeColor: "#000000",+ strokeWidth: 0.12,+ combineTokensWithinMilliseconds: 1200,+ holdMs: 600,+ },+ },+ "caption-prosody": {+ durationInFrames: 279,+ fps: 30,+ compositionWidth: 1280,+ compositionHeight: 720,+ previewBackdrop: {+ type: "color",+ value: "#262626",+ },+ defaults: {+ captions:+ "So here's the thing. Most demo videos lose people in the first three seconds. Captions keep them watching, even with the sound off.",+ fontSize: 64,+ fontWeight: 800,+ color: "#ffffff",+ activeColor: "#facc15",+ minScale: 0.75,+ maxScale: 1.6,+ combineTokensWithinMilliseconds: 1200,+ holdMs: 600,+ shadow: true,+ },+ },+ "caption-redact": {+ durationInFrames: 279,+ fps: 30,+ compositionWidth: 1280,+ compositionHeight: 720,+ previewBackdrop: {+ type: "color",+ value: "#262626",+ },+ defaults: {+ captions:+ "So here's the thing. Most demo videos lose people in the first three seconds. Captions keep them watching, even with the sound off.",+ fontSize: 64,+ fontWeight: 800,+ color: "#ffffff",+ barColor: "#0a0a0a",+ combineTokensWithinMilliseconds: 1200,+ holdMs: 600,+ shadow: true,+ },+ },+ "caption-rise": {+ durationInFrames: 279,+ fps: 30,+ compositionWidth: 1280,+ compositionHeight: 720,+ previewBackdrop: {+ type: "color",+ value: "#262626",+ },+ defaults: {+ captions:+ "So here's the thing. Most demo videos lose people in the first three seconds. Captions keep them watching, even with the sound off.",+ fontSize: 64,+ fontWeight: 800,+ color: "#ffffff",+ combineTokensWithinMilliseconds: 1200,+ holdMs: 600,+ shadow: true,+ },+ },+ "caption-scramble": {+ durationInFrames: 279,+ fps: 30,+ compositionWidth: 1280,+ compositionHeight: 720,+ previewBackdrop: {+ type: "color",+ value: "#262626",+ },+ defaults: {+ captions:+ "So here's the thing. Most demo videos lose people in the first three seconds. Captions keep them watching, even with the sound off.",+ fontSize: 64,+ fontWeight: 800,+ color: "#ffffff",+ glyphColor: "#a3a3a3",+ combineTokensWithinMilliseconds: 1200,+ holdMs: 600,+ shadow: true,+ },+ },+ "caption-slice": {+ durationInFrames: 279,+ fps: 30,+ compositionWidth: 1280,+ compositionHeight: 720,+ previewBackdrop: {+ type: "color",+ value: "#262626",+ },+ defaults: {+ captions:+ "So here's the thing. Most demo videos lose people in the first three seconds. Captions keep them watching, even with the sound off.",+ fontSize: 64,+ fontWeight: 800,+ color: "#ffffff",+ distance: 0.6,+ combineTokensWithinMilliseconds: 1200,+ holdMs: 600,+ shadow: true,+ },+ },+ "caption-slot": {+ durationInFrames: 279,+ fps: 30,+ compositionWidth: 1280,+ compositionHeight: 720,+ previewBackdrop: {+ type: "color",+ value: "#262626",+ },+ defaults: {+ captions:+ "So here's the thing. Most demo videos lose people in the first three seconds. Captions keep them watching, even with the sound off.",+ fontSize: 64,+ fontWeight: 800,+ color: "#ffffff",+ combineTokensWithinMilliseconds: 800,+ holdMs: 600,+ shadow: true,+ },+ },+ "caption-speaker": {+ durationInFrames: 282,+ fps: 30,+ compositionWidth: 1280,+ compositionHeight: 720,+ previewBackdrop: {+ type: "color",+ value: "#262626",+ },+ defaults: {+ captions:+ "So what made you add captions? Most people watch with the sound off. Really? Almost everyone. Captions keep them watching.",+ fontSize: 64,+ fontWeight: 800,+ upcomingOpacity: 0.4,+ combineTokensWithinMilliseconds: 1200,+ holdMs: 600,+ shadow: true,+ },+ },+ "caption-split-flap": {+ durationInFrames: 279,+ fps: 30,+ compositionWidth: 1280,+ compositionHeight: 720,+ previewBackdrop: {+ type: "color",+ value: "#262626",+ },+ defaults: {+ captions:+ "So here's the thing. Most demo videos lose people in the first three seconds. Captions keep them watching, even with the sound off.",+ fontSize: 56,+ fontWeight: 800,+ color: "#ffffff",+ tileColor: "#111111",+ combineTokensWithinMilliseconds: 1000,+ holdMs: 600,+ },+ },+ "caption-stack": {+ durationInFrames: 279,+ fps: 30,+ compositionWidth: 1280,+ compositionHeight: 720,+ previewBackdrop: {+ type: "color",+ value: "#262626",+ },+ defaults: {+ captions:+ "So here's the thing. Most demo videos lose people in the first three seconds. Captions keep them watching, even with the sound off.",+ fontSize: 64,+ fontWeight: 800,+ color: "#ffffff",+ emphasisColor: "#facc15",+ emphasisScale: 1.7,+ combineTokensWithinMilliseconds: 1600,+ holdMs: 600,+ shadow: true,+ },+ },+ "caption-stamp": {+ durationInFrames: 279,+ fps: 30,+ compositionWidth: 1280,+ compositionHeight: 720,+ previewBackdrop: {+ type: "color",+ value: "#262626",+ },+ defaults: {+ captions:+ "So here's the thing. Most demo videos lose people in the first three seconds. Captions keep them watching, even with the sound off.",+ fontSize: 64,+ fontWeight: 800,+ color: "#ffffff",+ stampColor: "#ef4444",+ texture: true,+ combineTokensWithinMilliseconds: 1200,+ holdMs: 600,+ shadow: true,+ },+ },+ "caption-subtitle": {+ durationInFrames: 279,+ fps: 30,+ compositionWidth: 1280,+ compositionHeight: 720,+ previewBackdrop: {+ type: "color",+ value: "#262626",+ },+ defaults: {+ captions:+ "So here's the thing. Most demo videos lose people in the first three seconds. Captions keep them watching, even with the sound off.",+ fontSize: 44,+ fontWeight: 600,+ color: "#ffffff",+ combineTokensWithinMilliseconds: 2500,+ holdMs: 600,+ box: true,+ boxColor: "#000000",+ boxOpacity: 0.72,+ },+ },+ "caption-teleprompter": {+ durationInFrames: 279,+ fps: 30,+ compositionWidth: 1280,+ compositionHeight: 720,+ previewBackdrop: {+ type: "color",+ value: "#262626",+ },+ defaults: {+ captions:+ "So here's the thing. Most demo videos lose people in the first three seconds. Captions keep them watching, even with the sound off.",+ fontSize: 64,+ fontWeight: 800,+ color: "#ffffff",+ visibleLines: 3,+ pastOpacity: 0.35,+ futureOpacity: 0.35,+ upcomingOpacity: 0.55,+ combineTokensWithinMilliseconds: 1500,+ holdMs: 600,+ shadow: true,+ },+ },+ "caption-timeline": {+ durationInFrames: 279,+ fps: 30,+ compositionWidth: 1280,+ compositionHeight: 720,+ previewBackdrop: {+ type: "color",+ value: "#262626",+ },+ defaults: {+ captions:+ "So here's the thing. Most demo videos lose people in the first three seconds. Captions keep them watching, even with the sound off.",+ fontSize: 64,+ fontWeight: 800,+ color: "#ffffff",+ playheadColor: "#facc15",+ width: 1100,+ pxPerSecond: 260,+ playheadPosition: 0.35,+ upcomingOpacity: 0.4,+ shadow: true,+ },+ },+ "caption-typewriter": {+ durationInFrames: 279,+ fps: 30,+ compositionWidth: 1280,+ compositionHeight: 720,+ previewBackdrop: {+ type: "color",+ value: "#262626",+ },+ defaults: {+ captions:+ "So here's the thing. Most demo videos lose people in the first three seconds. Captions keep them watching, even with the sound off.",+ fontSize: 64,+ fontWeight: 800,+ color: "#ffffff",+ combineTokensWithinMilliseconds: 1200,+ holdMs: 600,+ caret: true,+ shadow: true,+ },+ },+ "caption-underline": {+ durationInFrames: 279,+ fps: 30,+ compositionWidth: 1280,+ compositionHeight: 720,+ previewBackdrop: {+ type: "color",+ value: "#262626",+ },+ defaults: {+ captions:+ "So here's the thing. Most demo videos lose people in the first three seconds. Captions keep them watching, even with the sound off.",+ fontSize: 64,+ fontWeight: 800,+ color: "#ffffff",+ underlineColor: "#facc15",+ thickness: 0.08,+ underlineOffset: 0.02,+ combineTokensWithinMilliseconds: 1200,+ holdMs: 600,+ shadow: true,+ },+ },+ "caption-weight": {+ durationInFrames: 279,+ fps: 30,+ compositionWidth: 1280,+ compositionHeight: 720,+ previewBackdrop: {+ type: "color",+ value: "#262626",+ },+ defaults: {+ captions:+ "So here's the thing. Most demo videos lose people in the first three seconds. Captions keep them watching, even with the sound off.",+ fontSize: 64,+ fontWeight: 400,+ activeWeight: 900,+ color: "#ffffff",+ combineTokensWithinMilliseconds: 1200,+ holdMs: 600,+ shadow: true,+ },+ },+ "caption-word-pop": {+ durationInFrames: 279,+ fps: 30,+ compositionWidth: 1280,+ compositionHeight: 720,+ previewBackdrop: {+ type: "color",+ value: "#262626",+ },+ defaults: {+ captions:+ "So here's the thing. Most demo videos lose people in the first three seconds. Captions keep them watching, even with the sound off.",+ fontSize: 96,+ fontWeight: 800,+ color: "#ffffff",+ popScale: 0.6,+ combineTokensWithinMilliseconds: 0,+ holdMs: 600,+ shadow: true,+ },+ },caret: {durationInFrames: 120,fps: 30,diff --git a/registry/remocn/caption-active-pop/config.ts b/registry/remocn/caption-active-pop/config.tsnew file mode 100644index 00000000..6ddf5e46--- /dev/null+++ b/registry/remocn/caption-active-pop/config.ts@@ -0,0 +1,92 @@+import { captionActivePopExampleCode } from "@/components/docs/examples/caption-active-pop-example";+import {+ CAPTION_FIXTURE,+ previewCaptionsDuration,+ previewTailMs,+} from "@/components/docs/examples/caption-fixture";+import { type ComponentConfig, FPS, H, W } from "@/lib/customizer-config";++export const captionActivePopConfig: ComponentConfig = {+ componentName: "CaptionActivePop",+ importPath: "@/components/remocn/caption-active-pop",+ controls: {+ captions: {+ type: "remotion-captions",+ default: CAPTION_FIXTURE,+ description: "Transcript",+ keyframable: false,+ },+ fontSize: {+ type: "number",+ min: 24,+ max: 140,+ step: 1,+ default: 64,+ description: "Font size",+ hiddenFromList: false,+ },+ fontWeight: {+ type: "number",+ min: 400,+ max: 900,+ step: 100,+ default: 800,+ description: "Font weight",+ hiddenFromList: false,+ },+ color: {+ type: "color",+ default: "#ffffff",+ description: "Text color",+ },+ activeColor: {+ type: "color",+ default: "#facc15",+ description: "Active word color",+ },+ popScale: {+ type: "number",+ min: 1,+ max: 1.5,+ step: 0.01,+ default: 1.12,+ description: "Pop scale",+ hiddenFromList: false,+ },+ combineTokensWithinMilliseconds: {+ type: "number",+ min: 0,+ max: 3000,+ step: 100,+ default: 1200,+ description: "Page window (ms)",+ hiddenFromList: false,+ },+ holdMs: {+ type: "number",+ min: 0,+ max: 2000,+ step: 50,+ default: 600,+ description: "Hold (ms)",+ hiddenFromList: false,+ },+ shadow: {+ type: "boolean",+ default: true,+ description: "Shadow",+ },+ },+ durationInFrames: previewCaptionsDuration(undefined, FPS),+ getDurationInFrames: (values) =>+ previewCaptionsDuration(+ typeof values.captions === "string" ? values.captions : undefined,+ FPS,+ previewTailMs(values.holdMs),+ ),+ fps: FPS,+ compositionWidth: W,+ compositionHeight: H,+ previewBackdrop: { type: "color", value: "#262626" },+ snippet: captionActivePopExampleCode,+};diff --git a/registry/remocn/caption-active-pop/index.tsx b/registry/remocn/caption-active-pop/index.tsxnew file mode 100644index 00000000..6ed5c97e--- /dev/null+++ b/registry/remocn/caption-active-pop/index.tsx@@ -0,0 +1,153 @@+"use client";++import { Fragment } from "react";+import {+ Easing,+ interpolate,+ interpolateColors,+ spring,+ useVideoConfig,+} from "remotion";+import {+ type CaptionBaseProps,+ DEFAULT_HOLD_MS,+ getExitWindowMs,+ groupCaptionWords,+ useCaptions,+} from "@/lib/remocn/caption-core";++export interface CaptionActivePopProps extends CaptionBaseProps {+ activeColor?: string;+ popScale?: number;+ shadow?: boolean;+}++const ENTER_MS = 160;+const EXIT_MS = 220;+const RISE_EM = 0.14;+const LEGIBILITY_SHADOW =+ "0 2px 3px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.35)";++const POP_SPRING = { damping: 12, stiffness: 220, mass: 0.6 };+const RELEASE_SPRING = { damping: 20, stiffness: 200, mass: 0.6 };++const enterEasing = Easing.bezier(0.2, 0.8, 0.2, 1);++const clamp = {+ extrapolateLeft: "clamp",+ extrapolateRight: "clamp",+} as const;++export function CaptionActivePop({+ captions,+ combineTokensWithinMilliseconds = 1200,+ holdMs = DEFAULT_HOLD_MS,+ fontSize = 64,+ fontWeight = 800,+ color = "#ffffff",+ activeColor = "#facc15",+ popScale = 1.12,+ shadow = true,+ className,+}: CaptionActivePopProps) {+ const { fps } = useVideoConfig();+ const state = useCaptions({+ captions,+ combineTokensWithinMilliseconds,+ holdMs,+ });+ if (!state) return null;++ const enter = interpolate(+ state.previous ? ENTER_MS : state.sinceStartMs,+ [0, ENTER_MS],+ [0, 1],+ {+ ...clamp,+ easing: enterEasing,+ },+ );+ const exit = state.endsInSilence+ ? interpolate(+ state.untilEndMs,+ [0, getExitWindowMs(state, EXIT_MS)],+ [0, 1],+ clamp,+ )+ : 1;++ const words = groupCaptionWords(state.tokens);+ const activeWord = words.findIndex((word) =>+ word.some(({ index }) => index === state.activeIndex),+ );+ const toFrames = (ms: number) => (ms / 1000) * fps;++ const emphasis = (w: number): number => {+ if (activeWord < 0 || w > activeWord) return 0;+ const startMs = words[w][0].token.fromMs;+ if (w === activeWord) {+ return spring({+ frame: toFrames(state.timeMs - startMs),+ fps,+ config: POP_SPRING,+ });+ }+ if (w < activeWord - 1) return 0;+ const releaseMs = words[w + 1][0].token.fromMs;+ const peak = spring({+ frame: toFrames(releaseMs - startMs),+ fps,+ config: POP_SPRING,+ });+ const release = spring({+ frame: toFrames(state.timeMs - releaseMs),+ fps,+ config: RELEASE_SPRING,+ });+ return peak * (1 - release);+ };++ return (+ <div+ className={className}+ style={{+ fontSize,+ fontWeight,+ color,+ lineHeight: 1.2,+ textAlign: "center",+ opacity: Math.min(enter, exit),+ transform: `translateY(${(1 - enter) * RISE_EM}em)`,+ }}+ >+ {words.map((word, w) => {+ const amount = emphasis(w);+ return (+ <Fragment key={`${state.pageIndex}-${word[0].index}`}>+ {w > 0 && " "}+ <span+ style={{+ position: "relative",+ zIndex: w === activeWord ? 1 : 0,+ display: "inline-block",+ whiteSpace: "nowrap",+ transform: `scale(${1 + (popScale - 1) * amount})`,+ transformOrigin: "50% 60%",+ color: interpolateColors(+ Math.min(1, Math.max(0, amount)),+ [0, 1],+ [color, activeColor],+ ),+ textShadow: shadow ? LEGIBILITY_SHADOW : undefined,+ }}+ >+ {word.map(({ index, token }) => (+ <span key={index}>{token.text}</span>+ ))}+ </span>+ </Fragment>+ );+ })}+ </div>+ );+}diff --git a/registry/remocn/caption-blur-in/config.ts b/registry/remocn/caption-blur-in/config.tsnew file mode 100644index 00000000..8dcdc295--- /dev/null+++ b/registry/remocn/caption-blur-in/config.ts@@ -0,0 +1,87 @@+import { captionBlurInExampleCode } from "@/components/docs/examples/caption-blur-in-example";+import {+ CAPTION_FIXTURE,+ previewCaptionsDuration,+ previewTailMs,+} from "@/components/docs/examples/caption-fixture";+import { type ComponentConfig, FPS, H, W } from "@/lib/customizer-config";++export const captionBlurInConfig: ComponentConfig = {+ componentName: "CaptionBlurIn",+ importPath: "@/components/remocn/caption-blur-in",+ controls: {+ captions: {+ type: "remotion-captions",+ default: CAPTION_FIXTURE,+ description: "Transcript",+ keyframable: false,+ },+ fontSize: {+ type: "number",+ min: 24,+ max: 140,+ step: 1,+ default: 64,+ description: "Font size",+ hiddenFromList: false,+ },+ fontWeight: {+ type: "number",+ min: 400,+ max: 900,+ step: 100,+ default: 800,+ description: "Font weight",+ hiddenFromList: false,+ },+ color: {+ type: "color",+ default: "#ffffff",+ description: "Text color",+ },+ blur: {+ type: "number",+ min: 0,+ max: 32,+ step: 1,+ default: 12,+ description: "Blur (px)",+ hiddenFromList: false,+ },+ combineTokensWithinMilliseconds: {+ type: "number",+ min: 0,+ max: 3000,+ step: 100,+ default: 1200,+ description: "Page window (ms)",+ hiddenFromList: false,+ },+ holdMs: {+ type: "number",+ min: 0,+ max: 2000,+ step: 50,+ default: 600,+ description: "Hold (ms)",+ hiddenFromList: false,+ },+ shadow: {+ type: "boolean",+ default: true,+ description: "Shadow",+ },+ },+ durationInFrames: previewCaptionsDuration(undefined, FPS),+ getDurationInFrames: (values) =>+ previewCaptionsDuration(+ typeof values.captions === "string" ? values.captions : undefined,+ FPS,+ previewTailMs(values.holdMs),+ ),+ fps: FPS,+ compositionWidth: W,+ compositionHeight: H,+ previewBackdrop: { type: "color", value: "#262626" },+ snippet: captionBlurInExampleCode,+};diff --git a/registry/remocn/caption-blur-in/index.tsx b/registry/remocn/caption-blur-in/index.tsxnew file mode 100644index 00000000..f3077677--- /dev/null+++ b/registry/remocn/caption-blur-in/index.tsx@@ -0,0 +1,101 @@+"use client";++import { Fragment } from "react";+import { Easing, interpolate } from "remotion";+import {+ type CaptionBaseProps,+ DEFAULT_HOLD_MS,+ getExitWindowMs,+ groupCaptionWords,+ useCaptions,+} from "@/lib/remocn/caption-core";++export interface CaptionBlurInProps extends CaptionBaseProps {+ blur?: number;+ shadow?: boolean;+}++const EXIT_MS = 220;+const RESOLVE_MS = 220;+const LEGIBILITY_SHADOW =+ "0 2px 3px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.35)";++const resolveEasing = Easing.bezier(0.25, 0.6, 0.3, 1);++export function CaptionBlurIn({+ captions,+ combineTokensWithinMilliseconds = 1200,+ holdMs = DEFAULT_HOLD_MS,+ fontSize = 64,+ fontWeight = 800,+ color = "#ffffff",+ blur = 12,+ shadow = true,+ className,+}: CaptionBlurInProps) {+ const state = useCaptions({+ captions,+ combineTokensWithinMilliseconds,+ holdMs,+ });+ if (!state) return null;++ const exit = state.endsInSilence+ ? interpolate(+ state.untilEndMs,+ [0, getExitWindowMs(state, EXIT_MS)],+ [0, 1],+ {+ extrapolateLeft: "clamp",+ extrapolateRight: "clamp",+ },+ )+ : 1;++ return (+ <div+ className={className}+ style={{+ fontSize,+ fontWeight,+ color,+ lineHeight: 1.2,+ textAlign: "center",+ opacity: exit,+ }}+ >+ {groupCaptionWords(state.tokens).map((word, w) => (+ <Fragment key={`${state.pageIndex}-${word[0].index}`}>+ {w > 0 && " "}+ <span style={{ display: "inline-block", whiteSpace: "nowrap" }}>+ {word.map(({ index, token }) => {+ const sinceMs = state.timeMs - token.fromMs;+ const p =+ sinceMs < 0+ ? 0+ : interpolate(sinceMs, [0, RESOLVE_MS], [0, 1], {+ easing: resolveEasing,+ extrapolateLeft: "clamp",+ extrapolateRight: "clamp",+ });+ const radius = (1 - p) * blur;+ return (+ <span+ key={index}+ style={{+ display: "inline-block",+ opacity: p,+ filter: radius > 0.01 ? `blur(${radius}px)` : undefined,+ textShadow: shadow ? LEGIBILITY_SHADOW : undefined,+ }}+ >+ {token.text}+ </span>+ );+ })}+ </span>+ </Fragment>+ ))}+ </div>+ );+}diff --git a/registry/remocn/caption-bounce-in/config.ts b/registry/remocn/caption-bounce-in/config.tsnew file mode 100644index 00000000..cabada1e--- /dev/null+++ b/registry/remocn/caption-bounce-in/config.ts@@ -0,0 +1,87 @@+import { captionBounceInExampleCode } from "@/components/docs/examples/caption-bounce-in-example";+import {+ CAPTION_FIXTURE,+ previewCaptionsDuration,+ previewTailMs,+} from "@/components/docs/examples/caption-fixture";+import { type ComponentConfig, FPS, H, W } from "@/lib/customizer-config";++export const captionBounceInConfig: ComponentConfig = {+ componentName: "CaptionBounceIn",+ importPath: "@/components/remocn/caption-bounce-in",+ controls: {+ captions: {+ type: "remotion-captions",+ default: CAPTION_FIXTURE,+ description: "Transcript",+ keyframable: false,+ },+ fontSize: {+ type: "number",+ min: 24,+ max: 140,+ step: 1,+ default: 64,+ description: "Font size",+ hiddenFromList: false,+ },+ fontWeight: {+ type: "number",+ min: 400,+ max: 900,+ step: 100,+ default: 800,+ description: "Font weight",+ hiddenFromList: false,+ },+ color: {+ type: "color",+ default: "#ffffff",+ description: "Text color",+ },+ bounce: {+ type: "number",+ min: 0,+ max: 1,+ step: 0.05,+ default: 0.6,+ description: "Bounce",+ hiddenFromList: false,+ },+ combineTokensWithinMilliseconds: {+ type: "number",+ min: 0,+ max: 3000,+ step: 100,+ default: 1200,+ description: "Page window (ms)",+ hiddenFromList: false,+ },+ holdMs: {+ type: "number",+ min: 0,+ max: 2000,+ step: 50,+ default: 600,+ description: "Hold (ms)",+ hiddenFromList: false,+ },+ shadow: {+ type: "boolean",+ default: true,+ description: "Shadow",+ },+ },+ durationInFrames: previewCaptionsDuration(undefined, FPS),+ getDurationInFrames: (values) =>+ previewCaptionsDuration(+ typeof values.captions === "string" ? values.captions : undefined,+ FPS,+ previewTailMs(values.holdMs),+ ),+ fps: FPS,+ compositionWidth: W,+ compositionHeight: H,+ previewBackdrop: { type: "color", value: "#262626" },+ snippet: captionBounceInExampleCode,+};diff --git a/registry/remocn/caption-bounce-in/index.tsx b/registry/remocn/caption-bounce-in/index.tsxnew file mode 100644index 00000000..a8f097c5--- /dev/null+++ b/registry/remocn/caption-bounce-in/index.tsx@@ -0,0 +1,114 @@+"use client";++import { Fragment } from "react";+import { interpolate, spring, useVideoConfig } from "remotion";+import {+ type CaptionBaseProps,+ DEFAULT_HOLD_MS,+ getExitWindowMs,+ groupCaptionWords,+ useCaptions,+} from "@/lib/remocn/caption-core";++export interface CaptionBounceInProps extends CaptionBaseProps {+ bounce?: number;+ shadow?: boolean;+}++const EXIT_MS = 220;+const FADE_IN_MS = 90;+const DROP_EM = 0.35;+const START_SCALE = 0.7;+const LEGIBILITY_SHADOW =+ "0 2px 3px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.35)";++export function CaptionBounceIn({+ captions,+ combineTokensWithinMilliseconds = 1200,+ holdMs = DEFAULT_HOLD_MS,+ fontSize = 64,+ fontWeight = 800,+ color = "#ffffff",+ bounce = 0.6,+ shadow = true,+ className,+}: CaptionBounceInProps) {+ const { fps } = useVideoConfig();+ const state = useCaptions({+ captions,+ combineTokensWithinMilliseconds,+ holdMs,+ });+ if (!state) return null;++ const damping = interpolate(bounce, [0, 1], [22, 7], {+ extrapolateLeft: "clamp",+ extrapolateRight: "clamp",+ });+ const exit = state.endsInSilence+ ? interpolate(+ state.untilEndMs,+ [0, getExitWindowMs(state, EXIT_MS)],+ [0, 1],+ {+ extrapolateLeft: "clamp",+ extrapolateRight: "clamp",+ },+ )+ : 1;++ return (+ <div+ className={className}+ style={{+ fontSize,+ fontWeight,+ color,+ lineHeight: 1.2,+ textAlign: "center",+ opacity: exit,+ }}+ >+ {groupCaptionWords(state.tokens).map((word, w) => (+ <Fragment key={`${state.pageIndex}-${word[0].index}`}>+ {w > 0 && " "}+ <span style={{ display: "inline-block", whiteSpace: "nowrap" }}>+ {word.map(({ index, token }) => {+ const sinceMs = state.timeMs - token.fromMs;+ const arrived = sinceMs >= 0;+ const p = arrived+ ? spring({+ frame: (sinceMs / 1000) * fps,+ fps,+ config: { damping, stiffness: 220, mass: 0.6 },+ })+ : 0;+ const opacity = arrived+ ? interpolate(sinceMs, [0, FADE_IN_MS], [0, 1], {+ extrapolateLeft: "clamp",+ extrapolateRight: "clamp",+ })+ : 0;+ return (+ <span+ key={index}+ style={{+ display: "inline-block",+ opacity,+ transform: `translateY(${(1 - p) * DROP_EM}em) scale(${+ START_SCALE + (1 - START_SCALE) * p+ })`,+ transformOrigin: "50% 80%",+ textShadow: shadow ? LEGIBILITY_SHADOW : undefined,+ }}+ >+ {token.text}+ </span>+ );+ })}+ </span>+ </Fragment>+ ))}+ </div>+ );+}diff --git a/registry/remocn/caption-core/__tests__/caption-core.test.ts b/registry/remocn/caption-core/__tests__/caption-core.test.tsnew file mode 100644index 00000000..db0050b2--- /dev/null+++ b/registry/remocn/caption-core/__tests__/caption-core.test.ts@@ -0,0 +1,220 @@+import { describe, expect, it } from "bun:test";+import type { Caption } from "@remotion/captions";+import {+ buildCaptionPages,+ captionWordText,+ createKeywordMatcher,+ getCaptionsState,+ getExitWindowMs,+ groupCaptionWords,+ type SpeakerCaption,+} from "..";++const cap = (+ text: string,+ startMs: number,+ endMs: number,+ extra: Partial<Caption> = {},+): Caption => ({+ text,+ startMs,+ endMs,+ timestampMs: null,+ confidence: null,+ ...extra,+});++const SENTENCES = [+ cap(" So", 0, 200),+ cap(" here's", 200, 400),+ cap(" the", 400, 500),+ cap(" thing.", 500, 800),+ cap(" Most", 900, 1100),+ cap(" demo", 1100, 1300),+];++const paged = (captions: SpeakerCaption[], holdMs = 600) =>+ buildCaptionPages(captions, {+ combineTokensWithinMilliseconds: 1200,+ holdMs,+ });++describe("buildCaptionPages", () => {+ it("returns no pages for an empty transcript", () => {+ expect(paged([])).toEqual([]);+ expect(getCaptionsState([], 0)).toBeNull();+ });++ it("breaks a page at the end of a sentence", () => {+ const windows = paged(SENTENCES);+ expect(windows.map((w) => w.page.text)).toEqual([+ "So here's the thing.",+ "Most demo",+ ]);+ });++ it("respects an explicit pageBreakAfter of false", () => {+ const captions = SENTENCES.map((c) =>+ c.text === " thing." ? { ...c, pageBreakAfter: false } : c,+ );+ expect(paged(captions)).toHaveLength(1);+ });++ it("cuts straight to the next page when it starts within the hold", () => {+ const [first, second] = paged(SENTENCES);+ expect(first.speechEndMs).toBe(800);+ expect(first.endMs).toBe(900);+ expect(first.endsInSilence).toBe(false);+ expect(second.endMs).toBe(1900);+ expect(second.endsInSilence).toBe(true);+ });++ it("breaks on a silence longer than the hold and leaves after holding", () => {+ const windows = paged([cap(" One", 0, 300), cap(" two", 1000, 1300)]);+ expect(windows).toHaveLength(2);+ expect(windows[0].endMs).toBe(900);+ expect(windows[0].endsInSilence).toBe(true);+ expect(getCaptionsState(windows, 950)).toBeNull();+ expect(getCaptionsState(windows, 1000)?.pageIndex).toBe(1);+ });++ it("treats a silence exactly as long as the hold as a cut", () => {+ const windows = paged([cap(" a", 0, 400), cap(" b", 1000, 1200)]);+ expect(windows).toHaveLength(2);+ expect(windows[0].endMs).toBe(1000);+ expect(windows[0].endsInSilence).toBe(false);+ });++ it("keeps tiny gaps on one page even with no hold", () => {+ const windows = paged([cap(" a", 0, 100), cap(" b", 150, 250)], 0);+ expect(windows).toHaveLength(1);+ expect(windows[0].endMs).toBe(250);+ expect(getCaptionsState(windows, 249)).not.toBeNull();+ expect(getCaptionsState(windows, 250)).toBeNull();+ });+});++describe("getCaptionsState", () => {+ const windows = paged(SENTENCES);++ it("shows nothing before the first word", () => {+ expect(getCaptionsState(paged([cap(" late", 500, 800)]), 499)).toBeNull();+ });++ it("tracks the word being spoken and how far into it the voice is", () => {+ const state = getCaptionsState(windows, 300);+ expect(state?.activeIndex).toBe(1);+ expect(state?.tokens.map((t) => t.status)).toEqual([+ "spoken",+ "active",+ "upcoming",+ "upcoming",+ ]);+ expect(state?.tokens[1].progress).toBeCloseTo(0.5, 10);+ expect(state?.tokens[0].progress).toBe(1);+ expect(state?.tokens[2].progress).toBe(0);+ });++ it("keeps the last word active through a gap before the next page", () => {+ const state = getCaptionsState(windows, 850);+ expect(state?.pageIndex).toBe(0);+ expect(state?.activeIndex).toBe(3);+ expect(state?.tokens[3].progress).toBe(1);+ });++ it("reports time since the page started and until it ends", () => {+ const state = getCaptionsState(windows, 1000);+ expect(state?.pageIndex).toBe(1);+ expect(state?.sinceStartMs).toBe(100);+ expect(state?.untilEndMs).toBe(900);+ expect(state?.endsInSilence).toBe(true);+ });++ it("hands the previous page over only on a cut, not after a silence", () => {+ const state = getCaptionsState(windows, 1000);+ expect(state?.previous?.pageIndex).toBe(0);+ expect(state?.previous?.tokens.every((t) => t.status !== "upcoming")).toBe(+ true,+ );+ const silent = paged([cap(" One", 0, 300), cap(" two", 1000, 1300)]);+ expect(getCaptionsState(silent, 1000)?.previous).toBeNull();+ expect(getCaptionsState(windows, 300)?.previous).toBeNull();+ });++ it("fills a zero-length word as soon as it is reached", () => {+ const state = getCaptionsState(paged([cap(" x", 100, 100)]), 100);+ expect(state?.tokens[0].progress).toBe(1);+ });+});++describe("groupCaptionWords", () => {+ it("keeps sub-word tokens together and splits on spaces", () => {+ const state = getCaptionsState(+ paged([+ cap(" Remot", 0, 200),+ cap("ion", 200, 300),+ cap(" rocks", 300, 600),+ ]),+ 250,+ );+ expect(state?.tokens.map((t) => t.spaceBefore)).toEqual([+ false,+ false,+ true,+ ]);+ const words = groupCaptionWords(state?.tokens ?? []);+ expect(words.map((w) => w.map(({ index }) => index))).toEqual([+ [0, 1],+ [2],+ ]);+ });+});++describe("speakers", () => {+ it("breaks the page when the speaker changes and reports who speaks", () => {+ const windows = paged([+ { ...cap(" Ready", 0, 300), speaker: "host" },+ { ...cap(" when", 300, 500), speaker: "host" },+ { ...cap(" Always", 500, 800), speaker: "guest" },+ ]);+ expect(windows.map((w) => w.page.text)).toEqual(["Ready when", "Always"]);+ expect(windows.map((w) => w.speaker)).toEqual(["host", "guest"]);+ expect(getCaptionsState(windows, 600)?.speaker).toBe("guest");+ });++ it("leaves the speaker undefined for plain captions", () => {+ expect(paged(SENTENCES)[0].speaker).toBeUndefined();+ });+});++describe("keywords", () => {+ it("matches ignoring case and punctuation", () => {+ const isKeyword = createKeywordMatcher(["Sound", "three"]);+ expect(isKeyword("sound.")).toBe(true);+ expect(isKeyword("THREE,")).toBe(true);+ expect(isKeyword("seconds")).toBe(false);+ expect(createKeywordMatcher(["here's"])("Here\u2019s")).toBe(true);+ expect(createKeywordMatcher()("anything")).toBe(false);+ });++ it("joins sub-word tokens into one word", () => {+ const state = getCaptionsState(+ paged([cap(" Remot", 0, 200), cap("ion", 200, 300)]),+ 250,+ );+ const [word] = groupCaptionWords(state?.tokens ?? []);+ expect(captionWordText(word)).toBe("Remotion");+ });+});++describe("getExitWindowMs", () => {+ it("never lets the exit fade start before the last word ends", () => {+ const short = getCaptionsState(paged([cap(" a", 0, 400)], 100), 450);+ expect(short?.holdRoomMs).toBe(100);+ expect(short && getExitWindowMs(short, 220)).toBe(100);+ const none = getCaptionsState(paged([cap(" a", 0, 400)], 0), 399);+ expect(none && getExitWindowMs(none, 220)).toBe(1);+ const roomy = getCaptionsState(paged([cap(" a", 0, 400)]), 450);+ expect(roomy && getExitWindowMs(roomy, 220)).toBe(220);+ });+});diff --git a/registry/remocn/caption-core/index.ts b/registry/remocn/caption-core/index.tsnew file mode 100644index 00000000..6dea1b49--- /dev/null+++ b/registry/remocn/caption-core/index.ts@@ -0,0 +1,316 @@+import {+ type Caption,+ createTikTokStyleCaptions,+ type TikTokPage,+} from "@remotion/captions";+import { useLayoutEffect, useMemo, useRef, useState } from "react";+import { useCurrentFrame, useVideoConfig } from "remotion";++export type SpeakerCaption = Caption & { speaker?: string };++export interface CaptionBaseProps {+ captions: Caption[];+ combineTokensWithinMilliseconds?: number;+ holdMs?: number;+ fontSize?: number;+ fontWeight?: number;+ color?: string;+ className?: string;+}++export const DEFAULT_HOLD_MS = 600;+export const MIN_SILENCE_BREAK_MS = 300;++export interface CaptionPageWindow {+ page: TikTokPage;+ index: number;+ speaker: string | undefined;+ startMs: number;+ speechEndMs: number;+ endMs: number;+ endsInSilence: boolean;+}++export type CaptionTokenStatus = "upcoming" | "active" | "spoken";++export interface CaptionTokenState {+ text: string;+ spaceBefore: boolean;+ fromMs: number;+ toMs: number;+ progress: number;+ status: CaptionTokenStatus;+}++export interface CaptionPreviousPage {+ page: TikTokPage;+ pageIndex: number;+ tokens: CaptionTokenState[];+}++export interface CaptionsState {+ page: TikTokPage;+ pageIndex: number;+ speaker: string | undefined;+ timeMs: number;+ activeIndex: number;+ tokens: CaptionTokenState[];+ sinceStartMs: number;+ untilEndMs: number;+ holdRoomMs: number;+ endsInSilence: boolean;+ previous: CaptionPreviousPage | null;+}++export interface CaptionPagingOptions {+ combineTokensWithinMilliseconds: number;+ holdMs?: number;+}++const SENTENCE_END = /[.!?…]["')\]]*$/;++function markPageBreaks(captions: SpeakerCaption[]): Caption[] {+ return captions.map((caption, i) => {+ if (caption.pageBreakAfter !== undefined) return caption;+ const next = captions[i + 1];+ const speakerChanges =+ next !== undefined && next.speaker !== caption.speaker;+ return speakerChanges || SENTENCE_END.test(caption.text.trim())+ ? { ...caption, pageBreakAfter: true }+ : caption;+ });+}++export function buildCaptionPages(+ captions: SpeakerCaption[],+ {+ combineTokensWithinMilliseconds,+ holdMs = DEFAULT_HOLD_MS,+ }: CaptionPagingOptions,+): CaptionPageWindow[] {+ if (captions.length === 0) return [];+ const { pages } = createTikTokStyleCaptions({+ captions: markPageBreaks(captions),+ combineTokensWithinMilliseconds,+ breakOnSilenceAfterMilliseconds: Math.max(holdMs, MIN_SILENCE_BREAK_MS),+ });+ const speakers = new Map<number, string | undefined>();+ for (const caption of captions) {+ if (!speakers.has(caption.startMs)) {+ speakers.set(caption.startMs, caption.speaker);+ }+ }+ const spoken = pages.filter((page) => page.tokens.length > 0);+ return spoken.map((page, index) => {+ const last = page.tokens[page.tokens.length - 1];+ const speechEndMs = last ? last.toMs : page.startMs;+ const heldUntil = speechEndMs + Math.max(0, holdMs);+ const next = spoken[index + 1];+ const endsInSilence = !next || next.startMs > heldUntil;+ const endMs = endsInSilence+ ? heldUntil+ : Math.max(page.startMs, next.startMs);+ return {+ page,+ index,+ speaker: speakers.get(page.tokens[0].fromMs),+ startMs: page.startMs,+ speechEndMs,+ endMs,+ endsInSilence,+ };+ });+}++function findWindowIndex(windows: CaptionPageWindow[], timeMs: number): number {+ let lo = 0;+ let hi = windows.length - 1;+ let found = -1;+ while (lo <= hi) {+ const mid = (lo + hi) >> 1;+ if (windows[mid].startMs <= timeMs) {+ found = mid;+ lo = mid + 1;+ } else {+ hi = mid - 1;+ }+ }+ if (found === -1) return -1;+ return timeMs < windows[found].endMs ? found : -1;+}++function tokenProgress(fromMs: number, toMs: number, timeMs: number): number {+ if (timeMs < fromMs) return 0;+ if (toMs <= fromMs) return 1;+ return Math.min(1, (timeMs - fromMs) / (toMs - fromMs));+}++function getTokenStates(+ page: TikTokPage,+ timeMs: number,+): { activeIndex: number; tokens: CaptionTokenState[] } {+ let activeIndex = -1;+ page.tokens.forEach((token, i) => {+ if (token.fromMs <= timeMs) activeIndex = i;+ });+ const tokens = page.tokens.map(+ (token, i): CaptionTokenState => ({+ text: token.text.trim(),+ spaceBefore: i > 0 && /^\s/.test(token.text),+ fromMs: token.fromMs,+ toMs: token.toMs,+ progress: tokenProgress(token.fromMs, token.toMs, timeMs),+ status:+ i < activeIndex ? "spoken" : i === activeIndex ? "active" : "upcoming",+ }),+ );+ return { activeIndex, tokens };+}++export function getCaptionsState(+ windows: CaptionPageWindow[],+ timeMs: number,+): CaptionsState | null {+ const found = findWindowIndex(windows, timeMs);+ if (found === -1) return null;+ const window = windows[found];+ const { activeIndex, tokens } = getTokenStates(window.page, timeMs);+ const before = found > 0 ? windows[found - 1] : null;+ const previous =+ before && !before.endsInSilence+ ? {+ page: before.page,+ pageIndex: before.index,+ tokens: getTokenStates(before.page, before.endMs).tokens,+ }+ : null;+ return {+ page: window.page,+ pageIndex: window.index,+ speaker: window.speaker,+ timeMs,+ activeIndex,+ tokens,+ sinceStartMs: timeMs - window.startMs,+ untilEndMs: window.endMs - timeMs,+ holdRoomMs: window.endMs - window.speechEndMs,+ endsInSilence: window.endsInSilence,+ previous,+ };+}++export function getExitWindowMs(state: CaptionsState, exitMs: number): number {+ return Math.max(1, Math.min(exitMs, state.holdRoomMs));+}++export function groupCaptionWords(+ tokens: CaptionTokenState[],+): { index: number; token: CaptionTokenState }[][] {+ const words: { index: number; token: CaptionTokenState }[][] = [];+ tokens.forEach((token, index) => {+ const current = words[words.length - 1];+ if (!current || token.spaceBefore) {+ words.push([{ index, token }]);+ } else {+ current.push({ index, token });+ }+ });+ return words;+}++export function normalizeCaptionWord(text: string): string {+ return text+ .toLowerCase()+ .replace(/[\u2018\u2019]/g, "'")+ .replace(/[^\p{L}\p{N}']/gu, "");+}++export function createKeywordMatcher(+ keywords: readonly string[] = [],+): (text: string) => boolean {+ const set = new Set(keywords.map(normalizeCaptionWord).filter(Boolean));+ return (text) => set.has(normalizeCaptionWord(text));+}++export function captionWordText(word: { token: CaptionTokenState }[]): string {+ return word.map(({ token }) => token.text).join("");+}++export interface CaptionWordRect {+ left: number;+ top: number;+ width: number;+ height: number;+}++function sameRects(a: CaptionWordRect[], b: CaptionWordRect[]): boolean {+ return (+ a.length === b.length &&+ a.every(+ (r, i) =>+ r.left === b[i].left &&+ r.top === b[i].top &&+ r.width === b[i].width &&+ r.height === b[i].height,+ )+ );+}++export function useCaptionWordRects(+ pageIndex: number,+ count: number,+): {+ wordRef: (index: number) => (el: HTMLElement | null) => void;+ rects: CaptionWordRect[] | null;+} {+ const elements = useRef<(HTMLElement | null)[]>([]);+ const [measured, setMeasured] = useState<{+ pageIndex: number;+ rects: CaptionWordRect[];+ } | null>(null);++ useLayoutEffect(() => {+ if (pageIndex === -1) return;+ const rects = elements.current.slice(0, count).map((el) =>+ el+ ? {+ left: el.offsetLeft,+ top: el.offsetTop,+ width: el.offsetWidth,+ height: el.offsetHeight,+ }+ : { left: 0, top: 0, width: 0, height: 0 },+ );+ setMeasured((prev) =>+ prev && prev.pageIndex === pageIndex && sameRects(prev.rects, rects)+ ? prev+ : { pageIndex, rects },+ );+ });++ return {+ wordRef: (index) => (el) => {+ elements.current[index] = el;+ },+ rects: measured && measured.pageIndex === pageIndex ? measured.rects : null,+ };+}++export function useCaptions({+ captions,+ combineTokensWithinMilliseconds,+ holdMs = DEFAULT_HOLD_MS,+}: {+ captions: SpeakerCaption[];+ combineTokensWithinMilliseconds: number;+ holdMs?: number;+}): CaptionsState | null {+ const frame = useCurrentFrame();+ const { fps } = useVideoConfig();+ const windows = useMemo(+ () =>+ buildCaptionPages(captions, { combineTokensWithinMilliseconds, holdMs }),+ [captions, combineTokensWithinMilliseconds, holdMs],+ );+ return getCaptionsState(windows, (frame / fps) * 1000);+}diff --git a/registry/remocn/caption-cube/config.ts b/registry/remocn/caption-cube/config.tsnew file mode 100644index 00000000..3db3b759--- /dev/null+++ b/registry/remocn/caption-cube/config.ts@@ -0,0 +1,88 @@+import { captionCubeExampleCode } from "@/components/docs/examples/caption-cube-example";+import {+ CAPTION_FIXTURE,+ previewCaptionsDuration,+ previewTailMs,+} from "@/components/docs/examples/caption-fixture";+import { type ComponentConfig, FPS, H, W } from "@/lib/customizer-config";++export const captionCubeConfig: ComponentConfig = {+ componentName: "CaptionCube",+ importPath: "@/components/remocn/caption-cube",+ controls: {+ captions: {+ type: "remotion-captions",+ default: CAPTION_FIXTURE,+ description: "Transcript",+ keyframable: false,+ },+ fontSize: {+ type: "number",+ min: 24,+ max: 140,+ step: 1,+ default: 64,+ description: "Font size",+ hiddenFromList: false,+ },+ fontWeight: {+ type: "number",+ min: 400,+ max: 900,+ step: 100,+ default: 800,+ description: "Font weight",+ hiddenFromList: false,+ },+ color: {+ type: "color",+ default: "#ffffff",+ description: "Text color",+ },+ tintActive: {+ type: "boolean",+ default: false,+ description: "Tint active word",+ },+ activeColor: {+ type: "color",+ default: "#facc15",+ description: "Active color",+ },+ combineTokensWithinMilliseconds: {+ type: "number",+ min: 0,+ max: 3000,+ step: 100,+ default: 800,+ description: "Page window (ms)",+ hiddenFromList: false,+ },+ holdMs: {+ type: "number",+ min: 0,+ max: 2000,+ step: 50,+ default: 600,+ description: "Hold (ms)",+ hiddenFromList: false,+ },+ shadow: {+ type: "boolean",+ default: true,+ description: "Shadow",+ },+ },+ durationInFrames: previewCaptionsDuration(undefined, FPS),+ getDurationInFrames: (values) =>+ previewCaptionsDuration(+ typeof values.captions === "string" ? values.captions : undefined,+ FPS,+ previewTailMs(values.holdMs),+ ),+ fps: FPS,+ compositionWidth: W,+ compositionHeight: H,+ previewBackdrop: { type: "color", value: "#262626" },+ snippet: captionCubeExampleCode,+};diff --git a/registry/remocn/caption-cube/index.tsx b/registry/remocn/caption-cube/index.tsxnew file mode 100644index 00000000..ee769d66--- /dev/null+++ b/registry/remocn/caption-cube/index.tsx@@ -0,0 +1,163 @@+"use client";++import { type CSSProperties, Fragment } from "react";+import { Easing, interpolate } from "remotion";+import {+ type CaptionBaseProps,+ type CaptionTokenState,+ DEFAULT_HOLD_MS,+ getExitWindowMs,+ groupCaptionWords,+ useCaptions,+} from "@/lib/remocn/caption-core";++export interface CaptionCubeProps extends CaptionBaseProps {+ tintActive?: boolean;+ activeColor?: string;+ shadow?: boolean;+}++const LINE_HEIGHT = 1.3;+const DEPTH_EM = LINE_HEIGHT / 2;+const TURN_MS = 320;+const EXIT_MS = 280;+const PERSPECTIVE_EM = 10;+const LEGIBILITY_SHADOW =+ "0 2px 3px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.35)";++const turnEasing = Easing.bezier(0.65, 0, 0.35, 1);+const exitEasing = Easing.bezier(0.7, 0, 0.84, 0);++function CubeFace({+ tokens,+ activeIndex,+ activeColor,+ angle,+ before,+ style,+}: {+ tokens: CaptionTokenState[];+ activeIndex: number;+ activeColor: string | undefined;+ angle: number;+ before: string;+ style?: CSSProperties;+}) {+ const facing = Math.max(0, Math.cos((angle * Math.PI) / 180));+ return (+ <div+ style={{+ whiteSpace: "nowrap",+ backfaceVisibility: "hidden",+ WebkitBackfaceVisibility: "hidden",+ opacity: 0.35 + 0.65 * facing,+ transform: `${before}rotateX(${angle}deg) translateZ(${DEPTH_EM}em)`,+ ...style,+ }}+ >+ {groupCaptionWords(tokens).map((word, w) => (+ <Fragment key={word[0].index}>+ {w > 0 && " "}+ {word.map(({ index, token }) => (+ <span+ key={index}+ style={{+ color:+ activeColor !== undefined && index === activeIndex+ ? activeColor+ : undefined,+ }}+ >+ {token.text}+ </span>+ ))}+ </Fragment>+ ))}+ </div>+ );+}++export function CaptionCube({+ captions,+ combineTokensWithinMilliseconds = 800,+ holdMs = DEFAULT_HOLD_MS,+ fontSize = 64,+ fontWeight = 800,+ color = "#ffffff",+ tintActive = false,+ activeColor = "#facc15",+ shadow = true,+ className,+}: CaptionCubeProps) {+ const state = useCaptions({+ captions,+ combineTokensWithinMilliseconds,+ holdMs,+ });+ if (!state) return null;++ const turnMs = Math.max(+ 1,+ Math.min(TURN_MS, state.sinceStartMs + state.untilEndMs),+ );+ const turn = interpolate(state.sinceStartMs, [0, turnMs], [0, 1], {+ easing: turnEasing,+ extrapolateLeft: "clamp",+ extrapolateRight: "clamp",+ });+ const exitProgress = state.endsInSilence+ ? exitEasing(+ Math.min(+ 1,+ Math.max(0, 1 - state.untilEndMs / getExitWindowMs(state, EXIT_MS)),+ ),+ )+ : 0;+ const currentAngle = (turn - 1) * 90 + exitProgress * 90;++ return (+ <div+ className={className}+ style={{+ position: "relative",+ fontSize,+ fontWeight,+ color,+ lineHeight: LINE_HEIGHT,+ height: `${LINE_HEIGHT}em`,+ textAlign: "center",+ textShadow: shadow ? LEGIBILITY_SHADOW : undefined,+ perspective: `${PERSPECTIVE_EM}em`,+ }}+ >+ <div+ style={{+ position: "relative",+ height: "100%",+ transformStyle: "preserve-3d",+ transform: `translateZ(${-DEPTH_EM}em)`,+ }}+ >+ {state.previous && turn < 1 ? (+ <CubeFace+ key={`page-${state.previous.pageIndex}`}+ tokens={state.previous.tokens}+ activeIndex={-1}+ activeColor={undefined}+ angle={turn * 90}+ before="translateX(-50%) "+ style={{ position: "absolute", top: 0, left: "50%" }}+ />+ ) : null}+ <CubeFace+ key={`page-${state.pageIndex}`}+ tokens={state.tokens}+ activeIndex={state.activeIndex}+ activeColor={tintActive ? activeColor : undefined}+ angle={currentAngle}+ before=""+ />+ </div>+ </div>+ );+}diff --git a/registry/remocn/caption-dim-progress/config.ts b/registry/remocn/caption-dim-progress/config.tsnew file mode 100644index 00000000..455d918e--- /dev/null+++ b/registry/remocn/caption-dim-progress/config.ts@@ -0,0 +1,87 @@+import { captionDimProgressExampleCode } from "@/components/docs/examples/caption-dim-progress-example";+import {+ CAPTION_FIXTURE,+ previewCaptionsDuration,+ previewTailMs,+} from "@/components/docs/examples/caption-fixture";+import { type ComponentConfig, FPS, H, W } from "@/lib/customizer-config";++export const captionDimProgressConfig: ComponentConfig = {+ componentName: "CaptionDimProgress",+ importPath: "@/components/remocn/caption-dim-progress",+ controls: {+ captions: {+ type: "remotion-captions",+ default: CAPTION_FIXTURE,+ description: "Transcript",+ keyframable: false,+ },+ fontSize: {+ type: "number",+ min: 24,+ max: 140,+ step: 1,+ default: 64,+ description: "Font size",+ hiddenFromList: false,+ },+ fontWeight: {+ type: "number",+ min: 400,+ max: 900,+ step: 100,+ default: 800,+ description: "Font weight",+ hiddenFromList: false,+ },+ color: {+ type: "color",+ default: "#ffffff",+ description: "Text color",+ },+ dimOpacity: {+ type: "number",+ min: 0,+ max: 1,+ step: 0.05,+ default: 0.35,+ description: "Upcoming opacity",+ hiddenFromList: false,+ },+ combineTokensWithinMilliseconds: {+ type: "number",+ min: 0,+ max: 3000,+ step: 100,+ default: 1200,+ description: "Page window (ms)",+ hiddenFromList: false,+ },+ holdMs: {+ type: "number",+ min: 0,+ max: 2000,+ step: 50,+ default: 600,+ description: "Hold (ms)",+ hiddenFromList: false,+ },+ shadow: {+ type: "boolean",+ default: true,+ description: "Shadow",+ },+ },+ durationInFrames: previewCaptionsDuration(undefined, FPS),+ getDurationInFrames: (values) =>+ previewCaptionsDuration(+ typeof values.captions === "string" ? values.captions : undefined,+ FPS,+ previewTailMs(values.holdMs),+ ),+ fps: FPS,+ compositionWidth: W,+ compositionHeight: H,+ previewBackdrop: { type: "color", value: "#262626" },+ snippet: captionDimProgressExampleCode,+};diff --git a/registry/remocn/caption-dim-progress/index.tsx b/registry/remocn/caption-dim-progress/index.tsxnew file mode 100644index 00000000..1cdc6cdd--- /dev/null+++ b/registry/remocn/caption-dim-progress/index.tsx@@ -0,0 +1,106 @@+"use client";++import { Fragment } from "react";+import { Easing, interpolate } from "remotion";+import {+ type CaptionBaseProps,+ DEFAULT_HOLD_MS,+ getExitWindowMs,+ groupCaptionWords,+ useCaptions,+} from "@/lib/remocn/caption-core";++export interface CaptionDimProgressProps extends CaptionBaseProps {+ dimOpacity?: number;+ shadow?: boolean;+}++const ENTER_MS = 160;+const EXIT_MS = 220;+const RISE_EM = 0.14;+const BRIGHTEN_MS = 90;+const LEGIBILITY_SHADOW =+ "0 2px 3px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.35)";++const enterEasing = Easing.bezier(0.2, 0.8, 0.2, 1);++const clamp = {+ extrapolateLeft: "clamp",+ extrapolateRight: "clamp",+} as const;++export function CaptionDimProgress({+ captions,+ combineTokensWithinMilliseconds = 1200,+ holdMs = DEFAULT_HOLD_MS,+ fontSize = 64,+ fontWeight = 800,+ color = "#ffffff",+ dimOpacity = 0.35,+ shadow = true,+ className,+}: CaptionDimProgressProps) {+ const state = useCaptions({+ captions,+ combineTokensWithinMilliseconds,+ holdMs,+ });+ if (!state) return null;++ const enter = interpolate(+ state.previous ? ENTER_MS : state.sinceStartMs,+ [0, ENTER_MS],+ [0, 1],+ {+ ...clamp,+ easing: enterEasing,+ },+ );+ const exit = state.endsInSilence+ ? interpolate(+ state.untilEndMs,+ [0, getExitWindowMs(state, EXIT_MS)],+ [0, 1],+ clamp,+ )+ : 1;++ return (+ <div+ className={className}+ style={{+ fontSize,+ fontWeight,+ color,+ lineHeight: 1.2,+ textAlign: "center",+ opacity: Math.min(enter, exit),+ transform: `translateY(${(1 - enter) * RISE_EM}em)`,+ }}+ >+ {groupCaptionWords(state.tokens).map((word, w) => (+ <Fragment key={`${state.pageIndex}-${word[0].index}`}>+ {w > 0 && " "}+ <span style={{ display: "inline-block", whiteSpace: "nowrap" }}>+ {word.map(({ index, token }) => (+ <span+ key={index}+ style={{+ opacity: interpolate(+ state.timeMs - token.fromMs,+ [0, BRIGHTEN_MS],+ [dimOpacity, 1],+ clamp,+ ),+ textShadow: shadow ? LEGIBILITY_SHADOW : undefined,+ }}+ >+ {token.text}+ </span>+ ))}+ </span>+ </Fragment>+ ))}+ </div>+ );+}diff --git a/registry/remocn/caption-drop/config.ts b/registry/remocn/caption-drop/config.tsnew file mode 100644index 00000000..acce5570--- /dev/null+++ b/registry/remocn/caption-drop/config.ts@@ -0,0 +1,87 @@+import { captionDropExampleCode } from "@/components/docs/examples/caption-drop-example";+import {+ CAPTION_FIXTURE,+ previewCaptionsDuration,+ previewTailMs,+} from "@/components/docs/examples/caption-fixture";+import { type ComponentConfig, FPS, H, W } from "@/lib/customizer-config";++export const captionDropConfig: ComponentConfig = {+ componentName: "CaptionDrop",+ importPath: "@/components/remocn/caption-drop",+ controls: {+ captions: {+ type: "remotion-captions",+ default: CAPTION_FIXTURE,+ description: "Transcript",+ keyframable: false,+ },+ fontSize: {+ type: "number",+ min: 24,+ max: 140,+ step: 1,+ default: 64,+ description: "Font size",+ hiddenFromList: false,+ },+ fontWeight: {+ type: "number",+ min: 400,+ max: 900,+ step: 100,+ default: 800,+ description: "Font weight",+ hiddenFromList: false,+ },+ color: {+ type: "color",+ default: "#ffffff",+ description: "Text color",+ },+ bounce: {+ type: "number",+ min: 0,+ max: 1,+ step: 0.05,+ default: 0.6,+ description: "Bounce",+ hiddenFromList: false,+ },+ combineTokensWithinMilliseconds: {+ type: "number",+ min: 0,+ max: 3000,+ step: 100,+ default: 1200,+ description: "Page window (ms)",+ hiddenFromList: false,+ },+ holdMs: {+ type: "number",+ min: 0,+ max: 2000,+ step: 50,+ default: 600,+ description: "Hold (ms)",+ hiddenFromList: false,+ },+ shadow: {+ type: "boolean",+ default: true,+ description: "Shadow",+ },+ },+ durationInFrames: previewCaptionsDuration(undefined, FPS),+ getDurationInFrames: (values) =>+ previewCaptionsDuration(+ typeof values.captions === "string" ? values.captions : undefined,+ FPS,+ previewTailMs(values.holdMs),+ ),+ fps: FPS,+ compositionWidth: W,+ compositionHeight: H,+ previewBackdrop: { type: "color", value: "#262626" },+ snippet: captionDropExampleCode,+};diff --git a/registry/remocn/caption-drop/index.tsx b/registry/remocn/caption-drop/index.tsxnew file mode 100644index 00000000..9552f431--- /dev/null+++ b/registry/remocn/caption-drop/index.tsx@@ -0,0 +1,117 @@+"use client";++import { Fragment } from "react";+import { interpolate, random, spring, useVideoConfig } from "remotion";+import {+ type CaptionBaseProps,+ DEFAULT_HOLD_MS,+ getExitWindowMs,+ groupCaptionWords,+ useCaptions,+} from "@/lib/remocn/caption-core";++export interface CaptionDropProps extends CaptionBaseProps {+ bounce?: number;+ shadow?: boolean;+}++const EXIT_MS = 360;+const EXIT_STAGGER_MS = 120;+const FADE_IN_MS = 80;+const FALL_EM = 1.4;+const EXIT_FALL_EM = 1.8;+const MAX_TILT_DEG = 6;+const LEGIBILITY_SHADOW =+ "0 2px 3px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.35)";++const clamp = {+ extrapolateLeft: "clamp",+ extrapolateRight: "clamp",+} as const;++export function CaptionDrop({+ captions,+ combineTokensWithinMilliseconds = 1200,+ holdMs = DEFAULT_HOLD_MS,+ fontSize = 64,+ fontWeight = 800,+ color = "#ffffff",+ bounce = 0.6,+ shadow = true,+ className,+}: CaptionDropProps) {+ const { fps } = useVideoConfig();+ const state = useCaptions({+ captions,+ combineTokensWithinMilliseconds,+ holdMs,+ });+ if (!state) return null;++ const damping = interpolate(bounce, [0, 1], [20, 6], clamp);+ const words = groupCaptionWords(state.tokens);+ const exitWindow = getExitWindowMs(state, EXIT_MS);+ const exitElapsed = state.endsInSilence+ ? Math.max(0, exitWindow - state.untilEndMs)+ : 0;+ const stagger = Math.min(EXIT_STAGGER_MS, exitWindow * 0.4);+ const fallSpan = Math.max(1, exitWindow - stagger);++ return (+ <div+ className={className}+ style={{+ fontSize,+ fontWeight,+ color,+ lineHeight: 1.2,+ textAlign: "center",+ }}+ >+ {words.map((word, w) => {+ const first = word[0];+ const sinceMs = state.timeMs - first.token.fromMs;+ const arrived = sinceMs >= 0;+ const landed = arrived+ ? spring({+ frame: (sinceMs / 1000) * fps,+ fps,+ config: { damping, stiffness: 180, mass: 0.7 },+ })+ : 0;+ const fadeIn = arrived+ ? interpolate(sinceMs, [0, FADE_IN_MS], [0, 1], clamp)+ : 0;+ const tilt =+ (random(`${state.pageIndex}-${first.index}-tilt`) * 2 - 1) *+ MAX_TILT_DEG;+ const delay = words.length > 1 ? (w / (words.length - 1)) * stagger : 0;+ const out = state.endsInSilence+ ? Math.min(1, Math.max(0, (exitElapsed - delay) / fallSpan))+ : 0;+ const gravity = out * out;+ const y = -(1 - landed) * FALL_EM + gravity * EXIT_FALL_EM;+ const rotate = tilt * (1 - landed) - tilt * 0.6 * gravity;+ return (+ <Fragment key={`${state.pageIndex}-${first.index}`}>+ {w > 0 && " "}+ <span+ style={{+ display: "inline-block",+ whiteSpace: "nowrap",+ opacity: fadeIn * (1 - out ** 1.5),+ transform: `translateY(${y}em) rotate(${rotate}deg)`,+ transformOrigin: "50% 100%",+ textShadow: shadow ? LEGIBILITY_SHADOW : undefined,+ }}+ >+ {word.map(({ index, token }) => (+ <span key={index}>{token.text}</span>+ ))}+ </span>+ </Fragment>+ );+ })}+ </div>+ );+}diff --git a/registry/remocn/caption-emoji/config.ts b/registry/remocn/caption-emoji/config.tsnew file mode 100644index 00000000..1d1ccffd--- /dev/null+++ b/registry/remocn/caption-emoji/config.ts@@ -0,0 +1,87 @@+import { captionEmojiExampleCode } from "@/components/docs/examples/caption-emoji-example";+import {+ CAPTION_FIXTURE,+ previewCaptionsDuration,+ previewTailMs,+} from "@/components/docs/examples/caption-fixture";+import { type ComponentConfig, FPS, H, W } from "@/lib/customizer-config";++export const captionEmojiConfig: ComponentConfig = {+ componentName: "CaptionEmoji",+ importPath: "@/components/remocn/caption-emoji",+ controls: {+ captions: {+ type: "remotion-captions",+ default: CAPTION_FIXTURE,+ description: "Transcript",+ keyframable: false,+ },+ fontSize: {+ type: "number",+ min: 24,+ max: 140,+ step: 1,+ default: 64,+ description: "Font size",+ hiddenFromList: false,+ },+ fontWeight: {+ type: "number",+ min: 400,+ max: 900,+ step: 100,+ default: 800,+ description: "Font weight",+ hiddenFromList: false,+ },+ color: {+ type: "color",+ default: "#ffffff",+ description: "Text color",+ },+ emojiSize: {+ type: "number",+ min: 0.4,+ max: 2,+ step: 0.05,+ default: 0.9,+ description: "Emoji size (em)",+ hiddenFromList: false,+ },+ combineTokensWithinMilliseconds: {+ type: "number",+ min: 0,+ max: 3000,+ step: 100,+ default: 1200,+ description: "Page window (ms)",+ hiddenFromList: false,+ },+ holdMs: {+ type: "number",+ min: 0,+ max: 2000,+ step: 50,+ default: 600,+ description: "Hold (ms)",+ hiddenFromList: false,+ },+ shadow: {+ type: "boolean",+ default: true,+ description: "Shadow",+ },+ },+ durationInFrames: previewCaptionsDuration(undefined, FPS),+ getDurationInFrames: (values) =>+ previewCaptionsDuration(+ typeof values.captions === "string" ? values.captions : undefined,+ FPS,+ previewTailMs(values.holdMs),+ ),+ fps: FPS,+ compositionWidth: W,+ compositionHeight: H,+ previewBackdrop: { type: "color", value: "#262626" },+ snippet: captionEmojiExampleCode,+};diff --git a/registry/remocn/caption-emoji/index.tsx b/registry/remocn/caption-emoji/index.tsxnew file mode 100644index 00000000..7e5615cf--- /dev/null+++ b/registry/remocn/caption-emoji/index.tsx@@ -0,0 +1,142 @@+"use client";++import { Fragment } from "react";+import { Easing, interpolate, spring, useVideoConfig } from "remotion";+import {+ type CaptionBaseProps,+ captionWordText,+ DEFAULT_HOLD_MS,+ getExitWindowMs,+ groupCaptionWords,+ normalizeCaptionWord,+ useCaptions,+} from "@/lib/remocn/caption-core";++export interface CaptionEmojiProps extends CaptionBaseProps {+ emoji?: Record<string, string>;+ emojiSize?: number;+ shadow?: boolean;+}++const ENTER_MS = 160;+const EXIT_MS = 220;+const RISE_EM = 0.14;+const LEGIBILITY_SHADOW =+ "0 2px 3px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.35)";++const POP_SPRING = { damping: 9, stiffness: 180, mass: 0.6 };++const enterEasing = Easing.bezier(0.2, 0.8, 0.2, 1);++const clamp = {+ extrapolateLeft: "clamp",+ extrapolateRight: "clamp",+} as const;++export function CaptionEmoji({+ captions,+ combineTokensWithinMilliseconds = 1200,+ holdMs = DEFAULT_HOLD_MS,+ fontSize = 64,+ fontWeight = 800,+ color = "#ffffff",+ emoji = {},+ emojiSize = 0.9,+ shadow = true,+ className,+}: CaptionEmojiProps) {+ const { fps } = useVideoConfig();+ const state = useCaptions({+ captions,+ combineTokensWithinMilliseconds,+ holdMs,+ });+ if (!state) return null;++ const enter = interpolate(+ state.previous ? ENTER_MS : state.sinceStartMs,+ [0, ENTER_MS],+ [0, 1],+ {+ ...clamp,+ easing: enterEasing,+ },+ );+ const exit = state.endsInSilence+ ? interpolate(+ state.untilEndMs,+ [0, getExitWindowMs(state, EXIT_MS)],+ [0, 1],+ clamp,+ )+ : 1;++ const lookup = new Map(+ Object.entries(emoji).map(([word, glyph]) => [+ normalizeCaptionWord(word),+ glyph,+ ]),+ );++ return (+ <div+ className={className}+ style={{+ fontSize,+ fontWeight,+ color,+ lineHeight: 1.2,+ textAlign: "center",+ opacity: Math.min(enter, exit),+ transform: `translateY(${(1 - enter) * RISE_EM}em)`,+ }}+ >+ {groupCaptionWords(state.tokens).map((word, w) => {+ const first = word[0].token;+ const glyph = lookup.get(normalizeCaptionWord(captionWordText(word)));+ const pop =+ glyph && first.status !== "upcoming"+ ? spring({+ frame: ((state.timeMs - first.fromMs) / 1000) * fps,+ fps,+ config: POP_SPRING,+ })+ : 0;+ return (+ <Fragment key={`${state.pageIndex}-${word[0].index}`}>+ {w > 0 && " "}+ <span+ style={{+ position: "relative",+ display: "inline-block",+ whiteSpace: "nowrap",+ textShadow: shadow ? LEGIBILITY_SHADOW : undefined,+ }}+ >+ {glyph && pop > 0 && (+ <span+ aria-hidden+ style={{+ position: "absolute",+ left: "50%",+ bottom: "92%",+ fontSize: `${emojiSize}em`,+ lineHeight: 1,+ textShadow: "none",+ transformOrigin: "50% 100%",+ transform: `translateX(-50%) rotate(${14 - 20 * pop}deg) scale(${pop})`,+ }}+ >+ {glyph}+ </span>+ )}+ {word.map(({ index, token }) => (+ <span key={index}>{token.text}</span>+ ))}+ </span>+ </Fragment>+ );+ })}+ </div>+ );+}diff --git a/registry/remocn/caption-handwrite/config.ts b/registry/remocn/caption-handwrite/config.tsnew file mode 100644index 00000000..05426d28--- /dev/null+++ b/registry/remocn/caption-handwrite/config.ts@@ -0,0 +1,87 @@+import {+ CAPTION_FIXTURE,+ previewCaptionsDuration,+ previewTailMs,+} from "@/components/docs/examples/caption-fixture";+import { captionHandwriteExampleCode } from "@/components/docs/examples/caption-handwrite-example";+import { type ComponentConfig, FPS, H, W } from "@/lib/customizer-config";++export const captionHandwriteConfig: ComponentConfig = {+ componentName: "CaptionHandwrite",+ importPath: "@/components/remocn/caption-handwrite",+ controls: {+ captions: {+ type: "remotion-captions",+ default: CAPTION_FIXTURE,+ description: "Transcript",+ keyframable: false,+ },+ fontSize: {+ type: "number",+ min: 24,+ max: 140,+ step: 1,+ default: 64,+ description: "Font size",+ hiddenFromList: false,+ },+ fontWeight: {+ type: "number",+ min: 400,+ max: 900,+ step: 100,+ default: 800,+ description: "Font weight",+ hiddenFromList: false,+ },+ color: {+ type: "color",+ default: "#ffffff",+ description: "Text color",+ },+ wobble: {+ type: "number",+ min: 0,+ max: 2,+ step: 0.1,+ default: 1,+ description: "Wobble",+ hiddenFromList: false,+ },+ combineTokensWithinMilliseconds: {+ type: "number",+ min: 0,+ max: 3000,+ step: 100,+ default: 1200,+ description: "Page window (ms)",+ hiddenFromList: false,+ },+ holdMs: {+ type: "number",+ min: 0,+ max: 2000,+ step: 50,+ default: 600,+ description: "Hold (ms)",+ hiddenFromList: false,+ },+ shadow: {+ type: "boolean",+ default: true,+ description: "Shadow",+ },+ },+ durationInFrames: previewCaptionsDuration(undefined, FPS),+ getDurationInFrames: (values) =>+ previewCaptionsDuration(+ typeof values.captions === "string" ? values.captions : undefined,+ FPS,+ previewTailMs(values.holdMs),+ ),+ fps: FPS,+ compositionWidth: W,+ compositionHeight: H,+ previewBackdrop: { type: "color", value: "#262626" },+ snippet: captionHandwriteExampleCode,+};diff --git a/registry/remocn/caption-handwrite/index.tsx b/registry/remocn/caption-handwrite/index.tsxnew file mode 100644index 00000000..0af25885--- /dev/null+++ b/registry/remocn/caption-handwrite/index.tsx@@ -0,0 +1,135 @@+"use client";++import { Fragment } from "react";+import { Easing, interpolate, random } from "remotion";+import {+ type CaptionBaseProps,+ captionWordText,+ DEFAULT_HOLD_MS,+ getExitWindowMs,+ groupCaptionWords,+ useCaptions,+} from "@/lib/remocn/caption-core";++export interface CaptionHandwriteProps extends CaptionBaseProps {+ wobble?: number;+ shadow?: boolean;+}++const ENTER_MS = 160;+const EXIT_MS = 220;+const MIN_WRITE_MS = 200;+const EDGE_PERCENT = 22;+const MASK_PAD_EM = 0.4;+const LEGIBILITY_SHADOW =+ "0 2px 3px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.35)";++const enterEasing = Easing.bezier(0.2, 0.8, 0.2, 1);++const clamp = {+ extrapolateLeft: "clamp",+ extrapolateRight: "clamp",+} as const;++export function CaptionHandwrite({+ captions,+ combineTokensWithinMilliseconds = 1200,+ holdMs = DEFAULT_HOLD_MS,+ fontSize = 64,+ fontWeight = 800,+ color = "#ffffff",+ wobble = 1,+ shadow = true,+ className,+}: CaptionHandwriteProps) {+ const state = useCaptions({+ captions,+ combineTokensWithinMilliseconds,+ holdMs,+ });+ if (!state) return null;++ const enter = interpolate(+ state.previous ? ENTER_MS : state.sinceStartMs,+ [0, ENTER_MS],+ [0, 1],+ { ...clamp, easing: enterEasing },+ );+ const exit = state.endsInSilence+ ? interpolate(+ state.untilEndMs,+ [0, getExitWindowMs(state, EXIT_MS)],+ [0, 1],+ clamp,+ )+ : 1;+ const textShadow = shadow ? LEGIBILITY_SHADOW : undefined;++ return (+ <div+ className={className}+ style={{+ fontSize,+ fontWeight,+ color,+ lineHeight: 1.2,+ textAlign: "center",+ opacity: Math.min(enter, exit),+ }}+ >+ {groupCaptionWords(state.tokens).map((word, w) => {+ const text = captionWordText(word);+ const fromMs = word[0].token.fromMs;+ const toMs = word[word.length - 1].token.toMs;+ const writeMs = Math.max(toMs - fromMs, MIN_WRITE_MS);+ const written = interpolate(+ state.timeMs - fromMs,+ [0, writeMs],+ [0, 1],+ clamp,+ );+ const seed = `caption-handwrite-${state.pageIndex}-${word[0].index}`;+ const tilt = (random(`${seed}-tilt`) * 3 - 1.5) * wobble;+ const lift = (random(`${seed}-lift`) * 0.08 - 0.04) * wobble;+ const head = written * (100 + EDGE_PERCENT);+ const stop = (percent: number): string =>+ `calc(${MASK_PAD_EM}em + (100% - ${MASK_PAD_EM * 2}em) * ${percent / 100})`;+ const mask =+ written > 0 && written < 1+ ? `linear-gradient(90deg, #000 ${stop(head - EDGE_PERCENT)}, transparent ${stop(head)})`+ : undefined;+ return (+ <Fragment key={`${state.pageIndex}-${word[0].index}`}>+ {w > 0 && " "}+ <span+ style={{+ display: "inline-block",+ whiteSpace: "nowrap",+ opacity: written > 0 ? 1 : 0,+ padding: `${MASK_PAD_EM}em`,+ margin: `-${MASK_PAD_EM}em`,+ transform: `translateY(${lift}em) rotate(${tilt}deg)`,+ WebkitMaskImage: mask,+ maskImage: mask,+ textShadow,+ }}+ >+ {Array.from(text).map((char, c) => (+ <span+ key={c}+ style={{+ display: "inline-block",+ whiteSpace: "pre",+ transform: `rotate(${(random(`${seed}-${c}`) * 6 - 3) * wobble}deg)`,+ }}+ >+ {char}+ </span>+ ))}+ </span>+ </Fragment>+ );+ })}+ </div>+ );+}diff --git a/registry/remocn/caption-highlight-box/config.ts b/registry/remocn/caption-highlight-box/config.tsnew file mode 100644index 00000000..e74b22c1--- /dev/null+++ b/registry/remocn/caption-highlight-box/config.ts@@ -0,0 +1,106 @@+import {+ CAPTION_FIXTURE,+ previewCaptionsDuration,+ previewTailMs,+} from "@/components/docs/examples/caption-fixture";+import { captionHighlightBoxExampleCode } from "@/components/docs/examples/caption-highlight-box-example";+import { type ComponentConfig, FPS, H, W } from "@/lib/customizer-config";++export const captionHighlightBoxConfig: ComponentConfig = {+ componentName: "CaptionHighlightBox",+ importPath: "@/components/remocn/caption-highlight-box",+ controls: {+ captions: {+ type: "remotion-captions",+ default: CAPTION_FIXTURE,+ description: "Transcript",+ keyframable: false,+ },+ fontSize: {+ type: "number",+ min: 24,+ max: 140,+ step: 1,+ default: 64,+ description: "Font size",+ hiddenFromList: false,+ },+ fontWeight: {+ type: "number",+ min: 400,+ max: 900,+ step: 100,+ default: 800,+ description: "Font weight",+ hiddenFromList: false,+ },+ color: {+ type: "color",+ default: "#ffffff",+ description: "Text color",+ },+ activeColor: {+ type: "color",+ default: "#0a0a0a",+ description: "Text on box",+ },+ boxColor: {+ type: "color",+ default: "#facc15",+ description: "Box color",+ },+ boxRadius: {+ type: "number",+ min: 0,+ max: 0.5,+ step: 0.01,+ default: 0.16,+ description: "Box radius (em)",+ hiddenFromList: false,+ },+ boxPadding: {+ type: "number",+ min: 0,+ max: 0.4,+ step: 0.01,+ default: 0.14,+ description: "Box padding (em)",+ hiddenFromList: false,+ },+ combineTokensWithinMilliseconds: {+ type: "number",+ min: 0,+ max: 3000,+ step: 100,+ default: 1200,+ description: "Page window (ms)",+ hiddenFromList: false,+ },+ holdMs: {+ type: "number",+ min: 0,+ max: 2000,+ step: 50,+ default: 600,+ description: "Hold (ms)",+ hiddenFromList: false,+ },+ shadow: {+ type: "boolean",+ default: true,+ description: "Shadow",+ },+ },+ durationInFrames: previewCaptionsDuration(undefined, FPS),+ getDurationInFrames: (values) =>+ previewCaptionsDuration(+ typeof values.captions === "string" ? values.captions : undefined,+ FPS,+ previewTailMs(values.holdMs),+ ),+ fps: FPS,+ compositionWidth: W,+ compositionHeight: H,+ previewBackdrop: { type: "color", value: "#262626" },+ snippet: captionHighlightBoxExampleCode,+};diff --git a/registry/remocn/caption-highlight-box/index.tsx b/registry/remocn/caption-highlight-box/index.tsxnew file mode 100644index 00000000..dacc3585--- /dev/null+++ b/registry/remocn/caption-highlight-box/index.tsx@@ -0,0 +1,181 @@+"use client";++import { Fragment } from "react";+import { Easing, interpolate, interpolateColors } from "remotion";+import {+ type CaptionBaseProps,+ DEFAULT_HOLD_MS,+ getExitWindowMs,+ groupCaptionWords,+ useCaptions,+ useCaptionWordRects,+} from "@/lib/remocn/caption-core";++export interface CaptionHighlightBoxProps extends CaptionBaseProps {+ activeColor?: string;+ boxColor?: string;+ boxRadius?: number;+ boxPadding?: number;+ shadow?: boolean;+}++const ENTER_MS = 160;+const EXIT_MS = 220;+const RISE_EM = 0.14;+const TRAVEL_MS = 120;++const enterEasing = Easing.bezier(0.2, 0.8, 0.2, 1);+const travelEasing = Easing.bezier(0.3, 0, 0.2, 1);++const clamp = {+ extrapolateLeft: "clamp",+ extrapolateRight: "clamp",+} as const;++function legibilityShadow(strength: number): string | undefined {+ if (strength <= 0) return undefined;+ return `0 2px 3px rgba(0, 0, 0, ${0.5 * strength}), 0 4px 16px rgba(0, 0, 0, ${0.35 * strength})`;+}++function mix(a: number, b: number, t: number): number {+ return a + (b - a) * t;+}++export function CaptionHighlightBox({+ captions,+ combineTokensWithinMilliseconds = 1200,+ holdMs = DEFAULT_HOLD_MS,+ fontSize = 64,+ fontWeight = 800,+ color = "#ffffff",+ activeColor = "#0a0a0a",+ boxColor = "#facc15",+ boxRadius = 0.16,+ boxPadding = 0.14,+ shadow = true,+ className,+}: CaptionHighlightBoxProps) {+ const state = useCaptions({+ captions,+ combineTokensWithinMilliseconds,+ holdMs,+ });+ const words = state ? groupCaptionWords(state.tokens) : [];+ const pageIndex = state ? state.pageIndex : -1;+ const { wordRef, rects } = useCaptionWordRects(pageIndex, words.length);++ if (!state) return null;++ const enter = interpolate(+ state.previous ? ENTER_MS : state.sinceStartMs,+ [0, ENTER_MS],+ [0, 1],+ {+ ...clamp,+ easing: enterEasing,+ },+ );+ const exit = state.endsInSilence+ ? interpolate(+ state.untilEndMs,+ [0, getExitWindowMs(state, EXIT_MS)],+ [0, 1],+ clamp,+ )+ : 1;++ const activeWord = words.findIndex((word) =>+ word.some(({ index }) => index === state.activeIndex),+ );+ const travel =+ activeWord >= 0+ ? interpolate(+ state.timeMs - words[activeWord][0].token.fromMs,+ [0, TRAVEL_MS],+ [0, 1],+ { ...clamp, easing: travelEasing },+ )+ : 0;++ const target = rects && activeWord >= 0 ? rects[activeWord] : null;+ const origin = rects && activeWord > 0 ? rects[activeWord - 1] : null;+ const padX = boxPadding * fontSize;+ const padY = boxPadding * 0.3 * fontSize;+ const box = target+ ? {+ left: origin ? mix(origin.left, target.left, travel) : target.left,+ top: origin ? mix(origin.top, target.top, travel) : target.top,+ width: origin ? mix(origin.width, target.width, travel) : target.width,+ height: origin+ ? mix(origin.height, target.height, travel)+ : target.height,+ opacity: origin ? 1 : travel,+ }+ : null;++ const coverage = (w: number): number => {+ if (!box) return 0;+ if (w === activeWord) {+ return origin ? interpolate(travel, [0.3, 0.8], [0, 1], clamp) : travel;+ }+ if (origin && w === activeWord - 1) {+ return 1 - interpolate(travel, [0.2, 0.7], [0, 1], clamp);+ }+ return 0;+ };++ return (+ <div+ className={className}+ style={{+ position: "relative",+ isolation: "isolate",+ fontSize,+ fontWeight,+ color,+ lineHeight: 1.2,+ textAlign: "center",+ opacity: Math.min(enter, exit),+ transform: `translateY(${(1 - enter) * RISE_EM}em)`,+ }}+ >+ {box && (+ <span+ aria-hidden+ style={{+ position: "absolute",+ left: box.left - padX,+ top: box.top - padY,+ width: box.width + padX * 2,+ height: box.height + padY * 2,+ borderRadius: boxRadius * fontSize,+ background: boxColor,+ opacity: box.opacity,+ }}+ />+ )}+ {words.map((word, w) => {+ const covered = coverage(w);+ return (+ <Fragment key={`${state.pageIndex}-${word[0].index}`}>+ {w > 0 && " "}+ <span+ ref={wordRef(w)}+ style={{+ position: "relative",+ display: "inline-block",+ whiteSpace: "nowrap",+ color: interpolateColors(covered, [0, 1], [color, activeColor]),+ textShadow: legibilityShadow(shadow ? 1 - covered : 0),+ }}+ >+ {word.map(({ index, token }) => (+ <span key={index}>{token.text}</span>+ ))}+ </span>+ </Fragment>+ );+ })}+ </div>+ );+}diff --git a/registry/remocn/caption-karaoke/config.ts b/registry/remocn/caption-karaoke/config.tsnew file mode 100644index 00000000..a96d4346--- /dev/null+++ b/registry/remocn/caption-karaoke/config.ts@@ -0,0 +1,83 @@+import {+ CAPTION_FIXTURE,+ previewCaptionsDuration,+ previewTailMs,+} from "@/components/docs/examples/caption-fixture";+import { captionKaraokeExampleCode } from "@/components/docs/examples/caption-karaoke-example";+import { type ComponentConfig, FPS, H, W } from "@/lib/customizer-config";++export const captionKaraokeConfig: ComponentConfig = {+ componentName: "CaptionKaraoke",+ importPath: "@/components/remocn/caption-karaoke",+ controls: {+ captions: {+ type: "remotion-captions",+ default: CAPTION_FIXTURE,+ description: "Transcript",+ keyframable: false,+ },+ fontSize: {+ type: "number",+ min: 24,+ max: 140,+ step: 1,+ default: 64,+ description: "Font size",+ hiddenFromList: false,+ },+ fontWeight: {+ type: "number",+ min: 400,+ max: 900,+ step: 100,+ default: 800,+ description: "Font weight",+ hiddenFromList: false,+ },+ color: {+ type: "color",+ default: "#ffffff",+ description: "Text color",+ },+ activeColor: {+ type: "color",+ default: "#facc15",+ description: "Fill color",+ },+ combineTokensWithinMilliseconds: {+ type: "number",+ min: 0,+ max: 3000,+ step: 100,+ default: 1200,+ description: "Page window (ms)",+ hiddenFromList: false,+ },+ holdMs: {+ type: "number",+ min: 0,+ max: 2000,+ step: 50,+ default: 600,+ description: "Hold (ms)",+ hiddenFromList: false,+ },+ shadow: {+ type: "boolean",+ default: true,+ description: "Shadow",+ },+ },+ durationInFrames: previewCaptionsDuration(undefined, FPS),+ getDurationInFrames: (values) =>+ previewCaptionsDuration(+ typeof values.captions === "string" ? values.captions : undefined,+ FPS,+ previewTailMs(values.holdMs),+ ),+ fps: FPS,+ compositionWidth: W,+ compositionHeight: H,+ previewBackdrop: { type: "color", value: "#262626" },+ snippet: captionKaraokeExampleCode,+};diff --git a/registry/remocn/caption-karaoke/index.tsx b/registry/remocn/caption-karaoke/index.tsxnew file mode 100644index 00000000..97a901d3--- /dev/null+++ b/registry/remocn/caption-karaoke/index.tsx@@ -0,0 +1,111 @@+"use client";++import { Fragment } from "react";+import { Easing, interpolate } from "remotion";+import {+ type CaptionBaseProps,+ DEFAULT_HOLD_MS,+ getExitWindowMs,+ groupCaptionWords,+ useCaptions,+} from "@/lib/remocn/caption-core";++export interface CaptionKaraokeProps extends CaptionBaseProps {+ activeColor?: string;+ shadow?: boolean;+}++const ENTER_MS = 160;+const EXIT_MS = 220;+const RISE_EM = 0.14;+const LEGIBILITY_SHADOW =+ "0 2px 3px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.35)";++const enterEasing = Easing.bezier(0.2, 0.8, 0.2, 1);++export function CaptionKaraoke({+ captions,+ combineTokensWithinMilliseconds = 1200,+ holdMs = DEFAULT_HOLD_MS,+ fontSize = 64,+ fontWeight = 800,+ color = "#ffffff",+ activeColor = "#facc15",+ shadow = true,+ className,+}: CaptionKaraokeProps) {+ const state = useCaptions({+ captions,+ combineTokensWithinMilliseconds,+ holdMs,+ });+ if (!state) return null;++ const enter = interpolate(+ state.previous ? ENTER_MS : state.sinceStartMs,+ [0, ENTER_MS],+ [0, 1],+ {+ easing: enterEasing,+ extrapolateLeft: "clamp",+ extrapolateRight: "clamp",+ },+ );+ const exit = state.endsInSilence+ ? interpolate(+ state.untilEndMs,+ [0, getExitWindowMs(state, EXIT_MS)],+ [0, 1],+ {+ extrapolateLeft: "clamp",+ extrapolateRight: "clamp",+ },+ )+ : 1;++ return (+ <div+ className={className}+ style={{+ fontSize,+ fontWeight,+ color,+ lineHeight: 1.2,+ textAlign: "center",+ opacity: Math.min(enter, exit),+ transform: `translateY(${(1 - enter) * RISE_EM}em)`,+ }}+ >+ {groupCaptionWords(state.tokens).map((word, w) => (+ <Fragment key={`${state.pageIndex}-${word[0].index}`}>+ {w > 0 && " "}+ <span style={{ display: "inline-block", whiteSpace: "nowrap" }}>+ {word.map(({ index, token }) => (+ <span+ key={index}+ style={{ position: "relative", display: "inline-block" }}+ >+ <span+ style={{ textShadow: shadow ? LEGIBILITY_SHADOW : undefined }}+ >+ {token.text}+ </span>+ <span+ aria-hidden+ style={{+ position: "absolute",+ inset: 0,+ color: activeColor,+ clipPath: `inset(0 ${(1 - token.progress) * 100}% 0 0)`,+ }}+ >+ {token.text}+ </span>+ </span>+ ))}+ </span>+ </Fragment>+ ))}+ </div>+ );+}diff --git a/registry/remocn/caption-knockout/config.ts b/registry/remocn/caption-knockout/config.tsnew file mode 100644index 00000000..628c945d--- /dev/null+++ b/registry/remocn/caption-knockout/config.ts@@ -0,0 +1,82 @@+import {+ CAPTION_FIXTURE,+ previewCaptionsDuration,+ previewTailMs,+} from "@/components/docs/examples/caption-fixture";+import { captionKnockoutExampleCode } from "@/components/docs/examples/caption-knockout-example";+import { type ComponentConfig, FPS, H, W } from "@/lib/customizer-config";++export const captionKnockoutConfig: ComponentConfig = {+ componentName: "CaptionKnockout",+ importPath: "@/components/remocn/caption-knockout",+ controls: {+ captions: {+ type: "remotion-captions",+ default: CAPTION_FIXTURE,+ description: "Transcript",+ keyframable: false,+ },+ fontSize: {+ type: "number",+ min: 24,+ max: 140,+ step: 1,+ default: 64,+ description: "Font size",+ hiddenFromList: false,+ },+ fontWeight: {+ type: "number",+ min: 400,+ max: 900,+ step: 100,+ default: 800,+ description: "Font weight",+ hiddenFromList: false,+ },+ plateColor: {+ type: "color",+ default: "#ffffff",+ description: "Plate color",+ },+ upcomingOpacity: {+ type: "number",+ min: 0,+ max: 1,+ step: 0.05,+ default: 0.15,+ description: "Upcoming words",+ hiddenFromList: false,+ },+ combineTokensWithinMilliseconds: {+ type: "number",+ min: 0,+ max: 3000,+ step: 100,+ default: 1200,+ description: "Page window (ms)",+ hiddenFromList: false,+ },+ holdMs: {+ type: "number",+ min: 0,+ max: 2000,+ step: 50,+ default: 600,+ description: "Hold (ms)",+ hiddenFromList: false,+ },+ },+ durationInFrames: previewCaptionsDuration(undefined, FPS),+ getDurationInFrames: (values) =>+ previewCaptionsDuration(+ typeof values.captions === "string" ? values.captions : undefined,+ FPS,+ previewTailMs(values.holdMs),+ ),+ fps: FPS,+ compositionWidth: W,+ compositionHeight: H,+ previewBackdrop: { type: "color", value: "#262626" },+ snippet: captionKnockoutExampleCode,+};diff --git a/registry/remocn/caption-knockout/index.tsx b/registry/remocn/caption-knockout/index.tsxnew file mode 100644index 00000000..f0d90ad6--- /dev/null+++ b/registry/remocn/caption-knockout/index.tsx@@ -0,0 +1,180 @@+"use client";++import { Fragment, useId } from "react";+import { Easing, interpolate } from "remotion";+import {+ type CaptionBaseProps,+ type CaptionTokenState,+ DEFAULT_HOLD_MS,+ getExitWindowMs,+ groupCaptionWords,+ useCaptions,+ useCaptionWordRects,+} from "@/lib/remocn/caption-core";++export interface CaptionKnockoutProps extends Omit<CaptionBaseProps, "color"> {+ plateColor?: string;+ upcomingOpacity?: number;+ radius?: number;+}++const ENTER_MS = 160;+const EXIT_MS = 220;+const RISE_EM = 0.14;+const PUNCH_MS = 120;+const PAD_Y_EM = 0.22;+const PAD_X_EM = 0.42;++const enterEasing = Easing.bezier(0.2, 0.8, 0.2, 1);+const punchEasing = Easing.bezier(0.2, 0.8, 0.2, 1);++const clamp = {+ extrapolateLeft: "clamp",+ extrapolateRight: "clamp",+} as const;++function holeFill(+ token: CaptionTokenState,+ timeMs: number,+ upcomingOpacity: number,+): string {+ const since = timeMs - token.fromMs;+ const hole =+ since < 0+ ? upcomingOpacity+ : interpolate(since, [0, PUNCH_MS], [upcomingOpacity, 1], {+ ...clamp,+ easing: punchEasing,+ });+ const level = Math.round(255 * (1 - Math.min(1, Math.max(0, hole))));+ return `rgb(${level}, ${level}, ${level})`;+}++export function CaptionKnockout({+ captions,+ combineTokensWithinMilliseconds = 1200,+ holdMs = DEFAULT_HOLD_MS,+ fontSize = 64,+ fontWeight = 800,+ plateColor = "#ffffff",+ upcomingOpacity = 0.15,+ radius = 0.16,+ className,+}: CaptionKnockoutProps) {+ const maskId = `caption-knockout-${useId().replace(/[^a-zA-Z0-9-]/g, "")}`;+ const state = useCaptions({+ captions,+ combineTokensWithinMilliseconds,+ holdMs,+ });+ const words = state ? groupCaptionWords(state.tokens) : [];+ const { wordRef, rects } = useCaptionWordRects(+ state ? state.pageIndex : -1,+ words.length,+ );+ if (!state) return null;++ const enter = interpolate(+ state.previous ? ENTER_MS : state.sinceStartMs,+ [0, ENTER_MS],+ [0, 1],+ { ...clamp, easing: enterEasing },+ );+ const exit = state.endsInSilence+ ? interpolate(+ state.untilEndMs,+ [0, getExitWindowMs(state, EXIT_MS)],+ [0, 1],+ clamp,+ )+ : 1;++ return (+ <div+ className={className}+ style={{+ position: "relative",+ fontSize,+ fontWeight,+ lineHeight: 1.2,+ textAlign: "center",+ padding: `${PAD_Y_EM}em ${PAD_X_EM}em`,+ opacity: Math.min(enter, exit),+ transform: `translateY(${(1 - enter) * RISE_EM}em)`,+ }}+ >+ {rects && (+ <svg+ aria-hidden+ width="100%"+ height="100%"+ style={{+ position: "absolute",+ inset: 0,+ width: "100%",+ height: "100%",+ overflow: "visible",+ }}+ >+ <defs>+ <mask+ id={maskId}+ maskUnits="userSpaceOnUse"+ x="0"+ y="0"+ width="100%"+ height="100%"+ >+ <rect width="100%" height="100%" fill="#ffffff" />+ {words.map((word, w) => {+ const rect = rects[w];+ if (!rect) return null;+ return (+ <text+ key={`${state.pageIndex}-${word[0].index}`}+ x={rect.left}+ y={rect.top + rect.height / 2}+ dominantBaseline="central"+ >+ {word.map(({ index, token }) => (+ <tspan+ key={index}+ fill={holeFill(token, state.timeMs, upcomingOpacity)}+ >+ {token.text}+ </tspan>+ ))}+ </text>+ );+ })}+ </mask>+ </defs>+ <rect+ width="100%"+ height="100%"+ rx={radius * fontSize}+ fill={plateColor}+ mask={`url(#${maskId})`}+ />+ </svg>+ )}+ {words.map((word, w) => (+ <Fragment key={`${state.pageIndex}-${word[0].index}`}>+ {w > 0 && " "}+ <span+ ref={wordRef(w)}+ style={{+ display: "inline-block",+ whiteSpace: "nowrap",+ color: "transparent",+ }}+ >+ {word.map(({ index, token }) => (+ <span key={index}>{token.text}</span>+ ))}+ </span>+ </Fragment>+ ))}+ </div>+ );+}diff --git a/registry/remocn/caption-label-maker/config.ts b/registry/remocn/caption-label-maker/config.tsnew file mode 100644index 00000000..63707a35--- /dev/null+++ b/registry/remocn/caption-label-maker/config.ts@@ -0,0 +1,78 @@+import {+ CAPTION_FIXTURE,+ previewCaptionsDuration,+ previewTailMs,+} from "@/components/docs/examples/caption-fixture";+import { captionLabelMakerExampleCode } from "@/components/docs/examples/caption-label-maker-example";+import { type ComponentConfig, FPS, H, W } from "@/lib/customizer-config";++export const captionLabelMakerConfig: ComponentConfig = {+ componentName: "CaptionLabelMaker",+ importPath: "@/components/remocn/caption-label-maker",+ controls: {+ captions: {+ type: "remotion-captions",+ default: CAPTION_FIXTURE,+ description: "Transcript",+ keyframable: false,+ },+ fontSize: {+ type: "number",+ min: 24,+ max: 140,+ step: 1,+ default: 64,+ description: "Font size",+ hiddenFromList: false,+ },+ fontWeight: {+ type: "number",+ min: 400,+ max: 900,+ step: 100,+ default: 800,+ description: "Font weight",+ hiddenFromList: false,+ },+ color: {+ type: "color",+ default: "#ffffff",+ description: "Letter color",+ },+ tapeColor: {+ type: "color",+ default: "#18181b",+ description: "Tape color",+ },+ combineTokensWithinMilliseconds: {+ type: "number",+ min: 0,+ max: 3000,+ step: 100,+ default: 1000,+ description: "Page window (ms)",+ hiddenFromList: false,+ },+ holdMs: {+ type: "number",+ min: 0,+ max: 2000,+ step: 50,+ default: 600,+ description: "Hold (ms)",+ hiddenFromList: false,+ },+ },+ durationInFrames: previewCaptionsDuration(undefined, FPS),+ getDurationInFrames: (values) =>+ previewCaptionsDuration(+ typeof values.captions === "string" ? values.captions : undefined,+ FPS,+ previewTailMs(values.holdMs),+ ),+ fps: FPS,+ compositionWidth: W,+ compositionHeight: H,+ previewBackdrop: { type: "color", value: "#262626" },+ snippet: captionLabelMakerExampleCode,+};diff --git a/registry/remocn/caption-label-maker/index.tsx b/registry/remocn/caption-label-maker/index.tsxnew file mode 100644index 00000000..c359eb1d--- /dev/null+++ b/registry/remocn/caption-label-maker/index.tsx@@ -0,0 +1,198 @@+"use client";++import { type CSSProperties, Fragment } from "react";+import { Easing, interpolate } from "remotion";+import {+ type CaptionBaseProps,+ captionWordText,+ DEFAULT_HOLD_MS,+ getExitWindowMs,+ groupCaptionWords,+ useCaptions,+} from "@/lib/remocn/caption-core";++export interface CaptionLabelMakerProps extends CaptionBaseProps {+ tapeColor?: string;+}++const ENTER_MS = 160;+const EXIT_MS = 220;+const RISE_EM = 0.14;+const PRESS_MS = 50;+const PRESS_SCALE = 0.92;+const TILT_DEG = -1.5;+const PAD_Y = 0.16;+const LEAD_EM = 0.42;+const RADIUS = 0.16;+const EMBOSS = "0 1px 0 rgba(0, 0, 0, 0.55)";+const RELIEF =+ "inset 0 1px 0 rgba(255, 255, 255, 0.14), inset 0 -1px 0 rgba(0, 0, 0, 0.5)";++const enterEasing = Easing.bezier(0.2, 0.8, 0.2, 1);++const clamp = {+ extrapolateLeft: "clamp",+ extrapolateRight: "clamp",+} as const;++function revealedCount(+ count: number,+ fromMs: number,+ toMs: number,+ timeMs: number,+): number {+ if (timeMs < fromMs) return 0;+ const duration = Math.max(toMs - fromMs, 1);+ return Math.min(+ count,+ Math.floor(((timeMs - fromMs) / duration) * count) + 1,+ );+}++export function CaptionLabelMaker({+ captions,+ combineTokensWithinMilliseconds = 1000,+ holdMs = DEFAULT_HOLD_MS,+ fontSize = 64,+ fontWeight = 800,+ color = "#ffffff",+ tapeColor = "#18181b",+ className,+}: CaptionLabelMakerProps) {+ const state = useCaptions({+ captions,+ combineTokensWithinMilliseconds,+ holdMs,+ });+ if (!state) return null;++ const enter = interpolate(+ state.previous ? ENTER_MS : state.sinceStartMs,+ [0, ENTER_MS],+ [0, 1],+ { ...clamp, easing: enterEasing },+ );+ const exit = state.endsInSilence+ ? interpolate(+ state.untilEndMs,+ [0, getExitWindowMs(state, EXIT_MS)],+ [0, 1],+ clamp,+ )+ : 1;++ const segment: CSSProperties = {+ display: "inline-block",+ verticalAlign: "top",+ background: tapeColor,+ paddingBlock: `${PAD_Y}em`,+ paddingRight: 1,+ marginRight: -1,+ boxShadow: RELIEF,+ };++ const words = groupCaptionWords(state.tokens).map((word) => {+ const chars = Array.from(captionWordText(word));+ const fromMs = word[0].token.fromMs;+ const toMs = word[word.length - 1].token.toMs;+ return {+ key: `${state.pageIndex}-${word[0].index}`,+ chars,+ fromMs,+ toMs,+ revealed: revealedCount(chars.length, fromMs, toMs, state.timeMs),+ };+ });+ const last = words[words.length - 1];+ const finished = last !== undefined && last.revealed === last.chars.length;++ return (+ <div+ className={className}+ style={{+ fontSize,+ fontWeight,+ color,+ lineHeight: 1.1,+ textAlign: "center",+ opacity: Math.min(enter, exit),+ transform: `translateY(${(1 - enter) * RISE_EM}em)`,+ }}+ >+ <span+ style={{+ display: "inline-block",+ whiteSpace: "nowrap",+ transform: `rotate(${TILT_DEG}deg)`,+ filter: "drop-shadow(0 2px 4px rgba(0, 0, 0, 0.35))",+ }}+ >+ <span+ style={{+ ...segment,+ width: `${LEAD_EM}em`,+ borderRadius: `${RADIUS}em 0 0 ${RADIUS}em`,+ }}+ >+ {"\u00a0"}+ </span>+ {words.map((word, w) => {+ const duration = Math.max(word.toMs - word.fromMs, 1);+ return (+ <Fragment key={word.key}>+ {w > 0 && (+ <span+ style={{+ ...segment,+ visibility: word.revealed > 0 ? "visible" : "hidden",+ }}+ >+ {"\u00a0"}+ </span>+ )}+ {word.chars.map((char, c) => {+ const pressedAt =+ word.fromMs + (c / word.chars.length) * duration;+ const press = interpolate(+ state.timeMs - pressedAt,+ [0, PRESS_MS],+ [PRESS_SCALE, 1],+ clamp,+ );+ return (+ <span+ key={c}+ style={{+ ...segment,+ visibility: c < word.revealed ? "visible" : "hidden",+ }}+ >+ <span+ style={{+ display: "inline-block",+ transform: `scale(${press})`,+ textShadow: EMBOSS,+ }}+ >+ {char}+ </span>+ </span>+ );+ })}+ </Fragment>+ );+ })}+ <span+ style={{+ ...segment,+ width: `${LEAD_EM}em`,+ borderRadius: `0 ${RADIUS}em ${RADIUS}em 0`,+ visibility: finished ? "visible" : "hidden",+ }}+ >+ {"\u00a0"}+ </span>+ </span>+ </div>+ );+}diff --git a/registry/remocn/caption-marker/config.ts b/registry/remocn/caption-marker/config.tsnew file mode 100644index 00000000..e5032287--- /dev/null+++ b/registry/remocn/caption-marker/config.ts@@ -0,0 +1,88 @@+import {+ CAPTION_FIXTURE,+ previewCaptionsDuration,+ previewTailMs,+} from "@/components/docs/examples/caption-fixture";+import { captionMarkerExampleCode } from "@/components/docs/examples/caption-marker-example";+import { type ComponentConfig, FPS, H, W } from "@/lib/customizer-config";++export const captionMarkerConfig: ComponentConfig = {+ componentName: "CaptionMarker",+ importPath: "@/components/remocn/caption-marker",+ controls: {+ captions: {+ type: "remotion-captions",+ default: CAPTION_FIXTURE,+ description: "Transcript",+ keyframable: false,+ },+ fontSize: {+ type: "number",+ min: 24,+ max: 140,+ step: 1,+ default: 64,+ description: "Font size",+ hiddenFromList: false,+ },+ fontWeight: {+ type: "number",+ min: 400,+ max: 900,+ step: 100,+ default: 800,+ description: "Font weight",+ hiddenFromList: false,+ },+ color: {+ type: "color",+ default: "#ffffff",+ description: "Text color",+ },+ markerColor: {+ type: "color",+ default: "#facc15",+ description: "Marker color",+ },+ markerTextColor: {+ type: "color",+ default: "#0a0a0a",+ description: "Marked text color",+ },+ combineTokensWithinMilliseconds: {+ type: "number",+ min: 0,+ max: 3000,+ step: 100,+ default: 1200,+ description: "Page window (ms)",+ hiddenFromList: false,+ },+ holdMs: {+ type: "number",+ min: 0,+ max: 2000,+ step: 50,+ default: 600,+ description: "Hold (ms)",+ hiddenFromList: false,+ },+ shadow: {+ type: "boolean",+ default: true,+ description: "Shadow",+ },+ },+ durationInFrames: previewCaptionsDuration(undefined, FPS),+ getDurationInFrames: (values) =>+ previewCaptionsDuration(+ typeof values.captions === "string" ? values.captions : undefined,+ FPS,+ previewTailMs(values.holdMs),+ ),+ fps: FPS,+ compositionWidth: W,+ compositionHeight: H,+ previewBackdrop: { type: "color", value: "#262626" },+ snippet: captionMarkerExampleCode,+};diff --git a/registry/remocn/caption-marker/index.tsx b/registry/remocn/caption-marker/index.tsxnew file mode 100644index 00000000..1324a162--- /dev/null+++ b/registry/remocn/caption-marker/index.tsx@@ -0,0 +1,179 @@+"use client";++import { Fragment } from "react";+import { Easing, interpolate } from "remotion";+import {+ type CaptionBaseProps,+ captionWordText,+ createKeywordMatcher,+ DEFAULT_HOLD_MS,+ getExitWindowMs,+ groupCaptionWords,+ useCaptions,+} from "@/lib/remocn/caption-core";++export interface CaptionMarkerProps extends CaptionBaseProps {+ keywords?: string[];+ markerColor?: string;+ markerTextColor?: string;+ shadow?: boolean;+}++const ENTER_MS = 160;+const EXIT_MS = 220;+const RISE_EM = 0.14;+const MIN_DRAW_MS = 220;+const PAD_EM = 0.12;+const RADIUS_EM = 0.18;+const TILT_DEG = -1;+const BAND_TOP = "12%";+const BAND_BOTTOM = "2%";++const enterEasing = Easing.bezier(0.2, 0.8, 0.2, 1);+const drawEasing = Easing.bezier(0.25, 1, 0.5, 1);++const clamp = {+ extrapolateLeft: "clamp",+ extrapolateRight: "clamp",+} as const;++function legibilityShadow(strength: number): string | undefined {+ if (strength <= 0) return undefined;+ return `0 2px 3px rgba(0, 0, 0, ${0.5 * strength}), 0 4px 16px rgba(0, 0, 0, ${0.35 * strength})`;+}++export function CaptionMarker({+ captions,+ combineTokensWithinMilliseconds = 1200,+ holdMs = DEFAULT_HOLD_MS,+ fontSize = 64,+ fontWeight = 800,+ color = "#ffffff",+ keywords,+ markerColor = "#facc15",+ markerTextColor = "#0a0a0a",+ shadow = true,+ className,+}: CaptionMarkerProps) {+ const state = useCaptions({+ captions,+ combineTokensWithinMilliseconds,+ holdMs,+ });+ if (!state) return null;++ const isKeyword = createKeywordMatcher(keywords);+ const enter = interpolate(+ state.previous ? ENTER_MS : state.sinceStartMs,+ [0, ENTER_MS],+ [0, 1],+ {+ ...clamp,+ easing: enterEasing,+ },+ );+ const exit = state.endsInSilence+ ? interpolate(+ state.untilEndMs,+ [0, getExitWindowMs(state, EXIT_MS)],+ [0, 1],+ clamp,+ )+ : 1;+ const baseShadow = shadow ? 1 : 0;++ return (+ <div+ className={className}+ style={{+ fontSize,+ fontWeight,+ color,+ lineHeight: 1.2,+ textAlign: "center",+ opacity: Math.min(enter, exit),+ transform: `translateY(${(1 - enter) * RISE_EM}em)`,+ }}+ >+ {groupCaptionWords(state.tokens).map((word, w) => {+ const key = `${state.pageIndex}-${word[0].index}`;+ const text = word.map(({ index, token }) => (+ <span key={index}>{token.text}</span>+ ));+ if (!isKeyword(captionWordText(word))) {+ return (+ <Fragment key={key}>+ {w > 0 && " "}+ <span+ style={{+ display: "inline-block",+ whiteSpace: "nowrap",+ textShadow: legibilityShadow(baseShadow),+ }}+ >+ {text}+ </span>+ </Fragment>+ );+ }+ const fromMs = word[0].token.fromMs;+ const toMs = word[word.length - 1].token.toMs;+ const drawMs = Math.max(toMs - fromMs, MIN_DRAW_MS);+ const drawn = interpolate(state.timeMs - fromMs, [0, drawMs], [0, 1], {+ ...clamp,+ easing: drawEasing,+ });+ const hidden = `${(1 - drawn) * 100}%`;+ return (+ <Fragment key={key}>+ {w > 0 && " "}+ <span+ style={{+ position: "relative",+ display: "inline-block",+ whiteSpace: "nowrap",+ padding: `0 ${PAD_EM}em`,+ margin: `0 -${PAD_EM}em`,+ }}+ >+ <span+ aria-hidden+ style={{+ position: "absolute",+ left: 0,+ right: 0,+ top: BAND_TOP,+ bottom: BAND_BOTTOM,+ background: markerColor,+ borderRadius: `${RADIUS_EM}em`,+ transform: `rotate(${TILT_DEG}deg)`,+ clipPath: `inset(0 ${hidden} 0 0 round ${RADIUS_EM}em)`,+ }}+ />+ <span+ style={{+ position: "relative",+ textShadow: legibilityShadow(baseShadow * (1 - drawn)),+ }}+ >+ {text}+ </span>+ <span+ aria-hidden+ style={{+ position: "absolute",+ inset: 0,+ padding: `0 ${PAD_EM}em`,+ color: markerTextColor,+ clipPath: `inset(${BAND_TOP} ${hidden} ${BAND_BOTTOM} 0)`,+ }}+ >+ {text}+ </span>+ </span>+ </Fragment>+ );+ })}+ </div>+ );+}diff --git a/registry/remocn/caption-outline/config.ts b/registry/remocn/caption-outline/config.tsnew file mode 100644index 00000000..f337f9b9--- /dev/null+++ b/registry/remocn/caption-outline/config.ts@@ -0,0 +1,92 @@+import {+ CAPTION_FIXTURE,+ previewCaptionsDuration,+ previewTailMs,+} from "@/components/docs/examples/caption-fixture";+import { captionOutlineExampleCode } from "@/components/docs/examples/caption-outline-example";+import { type ComponentConfig, FPS, H, W } from "@/lib/customizer-config";++export const captionOutlineConfig: ComponentConfig = {+ componentName: "CaptionOutline",+ importPath: "@/components/remocn/caption-outline",+ controls: {+ captions: {+ type: "remotion-captions",+ default: CAPTION_FIXTURE,+ description: "Transcript",+ keyframable: false,+ },+ fontSize: {+ type: "number",+ min: 24,+ max: 140,+ step: 1,+ default: 64,+ description: "Font size",+ hiddenFromList: false,+ },+ fontWeight: {+ type: "number",+ min: 400,+ max: 900,+ step: 100,+ default: 800,+ description: "Font weight",+ hiddenFromList: false,+ },+ color: {+ type: "color",+ default: "#ffffff",+ description: "Text color",+ },+ activeColor: {+ type: "color",+ default: "#facc15",+ description: "Active color",+ },+ strokeColor: {+ type: "color",+ default: "#000000",+ description: "Stroke color",+ },+ strokeWidth: {+ type: "number",+ min: 0,+ max: 0.3,+ step: 0.01,+ default: 0.12,+ description: "Stroke width (em)",+ hiddenFromList: false,+ },+ combineTokensWithinMilliseconds: {+ type: "number",+ min: 0,+ max: 3000,+ step: 100,+ default: 1200,+ description: "Page window (ms)",+ hiddenFromList: false,+ },+ holdMs: {+ type: "number",+ min: 0,+ max: 2000,+ step: 50,+ default: 600,+ description: "Hold (ms)",+ hiddenFromList: false,+ },+ },+ durationInFrames: previewCaptionsDuration(undefined, FPS),+ getDurationInFrames: (values) =>+ previewCaptionsDuration(+ typeof values.captions === "string" ? values.captions : undefined,+ FPS,+ previewTailMs(values.holdMs),+ ),+ fps: FPS,+ compositionWidth: W,+ compositionHeight: H,+ previewBackdrop: { type: "color", value: "#262626" },+ snippet: captionOutlineExampleCode,+};diff --git a/registry/remocn/caption-outline/index.tsx b/registry/remocn/caption-outline/index.tsxnew file mode 100644index 00000000..e78c149b--- /dev/null+++ b/registry/remocn/caption-outline/index.tsx@@ -0,0 +1,120 @@+"use client";++import { Fragment } from "react";+import { Easing, interpolate, interpolateColors } from "remotion";+import {+ type CaptionBaseProps,+ captionWordText,+ DEFAULT_HOLD_MS,+ getExitWindowMs,+ groupCaptionWords,+ useCaptions,+} from "@/lib/remocn/caption-core";++export interface CaptionOutlineProps extends CaptionBaseProps {+ activeColor?: string;+ strokeColor?: string;+ strokeWidth?: number;+}++const ENTER_MS = 160;+const EXIT_MS = 220;+const RISE_EM = 0.14;+const SWITCH_MS = 70;++const enterEasing = Easing.bezier(0.2, 0.8, 0.2, 1);++const clamp = {+ extrapolateLeft: "clamp",+ extrapolateRight: "clamp",+} as const;++export function CaptionOutline({+ captions,+ combineTokensWithinMilliseconds = 1200,+ holdMs = DEFAULT_HOLD_MS,+ fontSize = 64,+ fontWeight = 800,+ color = "#ffffff",+ activeColor = "#facc15",+ strokeColor = "#000000",+ strokeWidth = 0.12,+ className,+}: CaptionOutlineProps) {+ const state = useCaptions({+ captions,+ combineTokensWithinMilliseconds,+ holdMs,+ });+ if (!state) return null;++ const enter = interpolate(+ state.previous ? ENTER_MS : state.sinceStartMs,+ [0, ENTER_MS],+ [0, 1],+ {+ ...clamp,+ easing: enterEasing,+ },+ );+ const exit = state.endsInSilence+ ? interpolate(+ state.untilEndMs,+ [0, getExitWindowMs(state, EXIT_MS)],+ [0, 1],+ clamp,+ )+ : 1;++ const words = groupCaptionWords(state.tokens);+ const activeWord = words.findIndex((word) =>+ word.some(({ index }) => index === state.activeIndex),+ );+ const activeSince =+ activeWord >= 0 ? state.timeMs - words[activeWord][0].token.fromMs : 0;+ const highlight = (w: number): number => {+ if (w === activeWord) {+ return interpolate(activeSince, [0, SWITCH_MS], [0, 1], clamp);+ }+ if (w === activeWord - 1) {+ return 1 - interpolate(activeSince, [0, SWITCH_MS], [0, 1], clamp);+ }+ return 0;+ };++ return (+ <div+ className={className}+ style={{+ fontSize,+ fontWeight,+ color,+ lineHeight: 1.2,+ textAlign: "center",+ WebkitTextStroke: `${strokeWidth * 2}em ${strokeColor}`,+ paintOrder: "stroke fill",+ opacity: Math.min(enter, exit),+ transform: `translateY(${(1 - enter) * RISE_EM}em)`,+ }}+ >+ {words.map((word, w) => (+ <Fragment key={`${state.pageIndex}-${word[0].index}`}>+ {w > 0 && " "}+ <span+ style={{+ display: "inline-block",+ whiteSpace: "nowrap",+ color: interpolateColors(+ highlight(w),+ [0, 1],+ [color, activeColor],+ ),+ }}+ >+ {captionWordText(word)}+ </span>+ </Fragment>+ ))}+ </div>+ );+}diff --git a/registry/remocn/caption-prosody/config.ts b/registry/remocn/caption-prosody/config.tsnew file mode 100644index 00000000..6ed2acda--- /dev/null+++ b/registry/remocn/caption-prosody/config.ts@@ -0,0 +1,101 @@+import {+ CAPTION_FIXTURE,+ previewCaptionsDuration,+ previewTailMs,+} from "@/components/docs/examples/caption-fixture";+import { captionProsodyExampleCode } from "@/components/docs/examples/caption-prosody-example";+import { type ComponentConfig, FPS, H, W } from "@/lib/customizer-config";++export const captionProsodyConfig: ComponentConfig = {+ componentName: "CaptionProsody",+ importPath: "@/components/remocn/caption-prosody",+ controls: {+ captions: {+ type: "remotion-captions",+ default: CAPTION_FIXTURE,+ description: "Transcript",+ keyframable: false,+ },+ fontSize: {+ type: "number",+ min: 24,+ max: 140,+ step: 1,+ default: 64,+ description: "Font size",+ hiddenFromList: false,+ },+ fontWeight: {+ type: "number",+ min: 400,+ max: 900,+ step: 100,+ default: 800,+ description: "Font weight",+ hiddenFromList: false,+ },+ color: {+ type: "color",+ default: "#ffffff",+ description: "Text color",+ },+ activeColor: {+ type: "color",+ default: "#facc15",+ description: "Active word color",+ },+ minScale: {+ type: "number",+ min: 0.4,+ max: 1,+ step: 0.05,+ default: 0.75,+ description: "Rushed word scale",+ hiddenFromList: false,+ },+ maxScale: {+ type: "number",+ min: 1,+ max: 2.5,+ step: 0.05,+ default: 1.6,+ description: "Drawn-out word scale",+ hiddenFromList: false,+ },+ combineTokensWithinMilliseconds: {+ type: "number",+ min: 0,+ max: 3000,+ step: 100,+ default: 1200,+ description: "Page window (ms)",+ hiddenFromList: false,+ },+ holdMs: {+ type: "number",+ min: 0,+ max: 2000,+ step: 50,+ default: 600,+ description: "Hold (ms)",+ hiddenFromList: false,+ },+ shadow: {+ type: "boolean",+ default: true,+ description: "Shadow",+ },+ },+ durationInFrames: previewCaptionsDuration(undefined, FPS),+ getDurationInFrames: (values) =>+ previewCaptionsDuration(+ typeof values.captions === "string" ? values.captions : undefined,+ FPS,+ previewTailMs(values.holdMs),+ ),+ fps: FPS,+ compositionWidth: W,+ compositionHeight: H,+ previewBackdrop: { type: "color", value: "#262626" },+ snippet: captionProsodyExampleCode,+};diff --git a/registry/remocn/caption-prosody/index.tsx b/registry/remocn/caption-prosody/index.tsxnew file mode 100644index 00000000..8183f41c--- /dev/null+++ b/registry/remocn/caption-prosody/index.tsx@@ -0,0 +1,137 @@+"use client";++import { Fragment } from "react";+import { Easing, interpolate } from "remotion";+import {+ type CaptionBaseProps,+ type CaptionTokenState,+ captionWordText,+ DEFAULT_HOLD_MS,+ getExitWindowMs,+ groupCaptionWords,+ useCaptions,+} from "@/lib/remocn/caption-core";++export interface CaptionProsodyProps extends CaptionBaseProps {+ minScale?: number;+ maxScale?: number;+ activeColor?: string;+ shadow?: boolean;+}++const EXIT_MS = 220;+const WORD_IN_MS = 180;+const RISE_EM = 0.2;+const LEGIBILITY_SHADOW =+ "0 2px 3px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.35)";++const appearEasing = Easing.bezier(0.2, 0.8, 0.2, 1);++const clamp = {+ extrapolateLeft: "clamp",+ extrapolateRight: "clamp",+} as const;++function letterCount(text: string): number {+ return Math.max(1, text.match(/[\p{L}\p{N}]/gu)?.length ?? 0);+}++function median(values: number[]): number {+ const sorted = [...values].sort((a, b) => a - b);+ const mid = sorted.length >> 1;+ return sorted.length % 2 === 1+ ? sorted[mid]+ : (sorted[mid - 1] + sorted[mid]) / 2;+}++export function getProsodyScales(+ words: { token: CaptionTokenState }[][],+ minScale: number,+ maxScale: number,+): number[] {+ const paces = words.map((word) => {+ const fromMs = word[0].token.fromMs;+ const toMs = word[word.length - 1].token.toMs;+ return Math.max(0, toMs - fromMs) / letterCount(captionWordText(word));+ });+ const typical = median(paces);+ if (!(typical > 0)) return words.map(() => 1);+ return paces.map((pace) => {+ const t = Math.max(-1, Math.min(1, Math.log2(Math.max(pace, 1) / typical)));+ return t >= 0 ? 1 + t * (maxScale - 1) : 1 + t * (1 - minScale);+ });+}++export function CaptionProsody({+ captions,+ combineTokensWithinMilliseconds = 1200,+ holdMs = DEFAULT_HOLD_MS,+ fontSize = 64,+ fontWeight = 800,+ color = "#ffffff",+ minScale = 0.75,+ maxScale = 1.6,+ activeColor = "#facc15",+ shadow = true,+ className,+}: CaptionProsodyProps) {+ const state = useCaptions({+ captions,+ combineTokensWithinMilliseconds,+ holdMs,+ });+ if (!state) return null;++ const exit = state.endsInSilence+ ? interpolate(+ state.untilEndMs,+ [0, getExitWindowMs(state, EXIT_MS)],+ [0, 1],+ clamp,+ )+ : 1;+ const words = groupCaptionWords(state.tokens);+ const scales = getProsodyScales(words, minScale, maxScale);++ return (+ <div+ className={className}+ style={{+ fontSize,+ fontWeight,+ color,+ lineHeight: 1.1,+ textAlign: "center",+ opacity: exit,+ }}+ >+ {words.map((word, w) => {+ const appear = interpolate(+ state.timeMs - word[0].token.fromMs,+ [0, WORD_IN_MS],+ [0, 1],+ { ...clamp, easing: appearEasing },+ );+ const active = word.some(({ index }) => index === state.activeIndex);+ return (+ <Fragment key={`${state.pageIndex}-${word[0].index}`}>+ {w > 0 && " "}+ <span+ style={{+ display: "inline-block",+ whiteSpace: "nowrap",+ fontSize: `${scales[w]}em`,+ color: active ? activeColor : color,+ opacity: appear,+ transform: `translateY(${(1 - appear) * RISE_EM}em)`,+ textShadow: shadow ? LEGIBILITY_SHADOW : undefined,+ }}+ >+ {captionWordText(word)}+ </span>+ </Fragment>+ );+ })}+ </div>+ );+}diff --git a/registry/remocn/caption-redact/config.ts b/registry/remocn/caption-redact/config.tsnew file mode 100644index 00000000..6f2d858a--- /dev/null+++ b/registry/remocn/caption-redact/config.ts@@ -0,0 +1,83 @@+import {+ CAPTION_FIXTURE,+ previewCaptionsDuration,+ previewTailMs,+} from "@/components/docs/examples/caption-fixture";+import { captionRedactExampleCode } from "@/components/docs/examples/caption-redact-example";+import { type ComponentConfig, FPS, H, W } from "@/lib/customizer-config";++export const captionRedactConfig: ComponentConfig = {+ componentName: "CaptionRedact",+ importPath: "@/components/remocn/caption-redact",+ controls: {+ captions: {+ type: "remotion-captions",+ default: CAPTION_FIXTURE,+ description: "Transcript",+ keyframable: false,+ },+ fontSize: {+ type: "number",+ min: 24,+ max: 140,+ step: 1,+ default: 64,+ description: "Font size",+ hiddenFromList: false,+ },+ fontWeight: {+ type: "number",+ min: 400,+ max: 900,+ step: 100,+ default: 800,+ description: "Font weight",+ hiddenFromList: false,+ },+ color: {+ type: "color",+ default: "#ffffff",+ description: "Text color",+ },+ barColor: {+ type: "color",+ default: "#0a0a0a",+ description: "Bar color",+ },+ combineTokensWithinMilliseconds: {+ type: "number",+ min: 0,+ max: 3000,+ step: 100,+ default: 1200,+ description: "Page window (ms)",+ hiddenFromList: false,+ },+ holdMs: {+ type: "number",+ min: 0,+ max: 2000,+ step: 50,+ default: 600,+ description: "Hold (ms)",+ hiddenFromList: false,+ },+ shadow: {+ type: "boolean",+ default: true,+ description: "Shadow",+ },+ },+ durationInFrames: previewCaptionsDuration(undefined, FPS),+ getDurationInFrames: (values) =>+ previewCaptionsDuration(+ typeof values.captions === "string" ? values.captions : undefined,+ FPS,+ previewTailMs(values.holdMs),+ ),+ fps: FPS,+ compositionWidth: W,+ compositionHeight: H,+ previewBackdrop: { type: "color", value: "#262626" },+ snippet: captionRedactExampleCode,+};diff --git a/registry/remocn/caption-redact/index.tsx b/registry/remocn/caption-redact/index.tsxnew file mode 100644index 00000000..57972fd2--- /dev/null+++ b/registry/remocn/caption-redact/index.tsx@@ -0,0 +1,139 @@+"use client";++import { Fragment } from "react";+import { Easing, interpolate } from "remotion";+import {+ type CaptionBaseProps,+ captionWordText,+ DEFAULT_HOLD_MS,+ getExitWindowMs,+ groupCaptionWords,+ useCaptions,+} from "@/lib/remocn/caption-core";++export interface CaptionRedactProps extends CaptionBaseProps {+ barColor?: string;+ shadow?: boolean;+}++const ENTER_MS = 160;+const EXIT_MS = 220;+const RISE_EM = 0.14;+const MIN_REVEAL_MS = 180;+const OVERHANG_EM = 0.06;+const RADIUS_EM = 0.06;+const BAR_TOP = "14%";+const BAR_BOTTOM = "6%";+const LEGIBILITY_SHADOW =+ "0 2px 3px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.35)";++const enterEasing = Easing.bezier(0.2, 0.8, 0.2, 1);+const revealEasing = Easing.inOut(Easing.cubic);++const clamp = {+ extrapolateLeft: "clamp",+ extrapolateRight: "clamp",+} as const;++export function CaptionRedact({+ captions,+ combineTokensWithinMilliseconds = 1200,+ holdMs = DEFAULT_HOLD_MS,+ fontSize = 64,+ fontWeight = 800,+ color = "#ffffff",+ barColor = "#0a0a0a",+ shadow = true,+ className,+}: CaptionRedactProps) {+ const state = useCaptions({+ captions,+ combineTokensWithinMilliseconds,+ holdMs,+ });+ if (!state) return null;++ const enter = interpolate(+ state.previous ? ENTER_MS : state.sinceStartMs,+ [0, ENTER_MS],+ [0, 1],+ { ...clamp, easing: enterEasing },+ );+ const exit = state.endsInSilence+ ? interpolate(+ state.untilEndMs,+ [0, getExitWindowMs(state, EXIT_MS)],+ [0, 1],+ clamp,+ )+ : 1;+ const textShadow = shadow ? LEGIBILITY_SHADOW : undefined;++ return (+ <div+ className={className}+ style={{+ fontSize,+ fontWeight,+ color,+ lineHeight: 1.2,+ textAlign: "center",+ opacity: Math.min(enter, exit),+ transform: `translateY(${(1 - enter) * RISE_EM}em)`,+ }}+ >+ {groupCaptionWords(state.tokens).map((word, w) => {+ const fromMs = word[0].token.fromMs;+ const toMs = word[word.length - 1].token.toMs;+ const revealMs = Math.max(toMs - fromMs, MIN_REVEAL_MS);+ const revealed = interpolate(+ state.timeMs - fromMs,+ [0, revealMs],+ [0, 1],+ { ...clamp, easing: revealEasing },+ );+ return (+ <Fragment key={`${state.pageIndex}-${word[0].index}`}>+ {w > 0 && " "}+ <span+ style={{+ position: "relative",+ display: "inline-block",+ whiteSpace: "nowrap",+ }}+ >+ <span+ style={{+ textShadow,+ visibility: revealed > 0 ? "visible" : "hidden",+ clipPath:+ revealed >= 1+ ? undefined+ : `inset(-50% ${(1 - revealed) * 100}% -50% -50%)`,+ }}+ >+ {captionWordText(word)}+ </span>+ {revealed < 1 && (+ <span+ aria-hidden+ style={{+ position: "absolute",+ left: `-${OVERHANG_EM}em`,+ right: `-${OVERHANG_EM}em`,+ top: BAR_TOP,+ bottom: BAR_BOTTOM,+ background: barColor,+ borderRadius: `${RADIUS_EM}em`,+ transformOrigin: "right center",+ transform: `scaleX(${1 - revealed})`,+ }}+ />+ )}+ </span>+ </Fragment>+ );+ })}+ </div>+ );+}diff --git a/registry/remocn/caption-rise/config.ts b/registry/remocn/caption-rise/config.tsnew file mode 100644index 00000000..b5fe5fa0--- /dev/null+++ b/registry/remocn/caption-rise/config.ts@@ -0,0 +1,78 @@+import {+ CAPTION_FIXTURE,+ previewCaptionsDuration,+ previewTailMs,+} from "@/components/docs/examples/caption-fixture";+import { captionRiseExampleCode } from "@/components/docs/examples/caption-rise-example";+import { type ComponentConfig, FPS, H, W } from "@/lib/customizer-config";++export const captionRiseConfig: ComponentConfig = {+ componentName: "CaptionRise",+ importPath: "@/components/remocn/caption-rise",+ controls: {+ captions: {+ type: "remotion-captions",+ default: CAPTION_FIXTURE,+ description: "Transcript",+ keyframable: false,+ },+ fontSize: {+ type: "number",+ min: 24,+ max: 140,+ step: 1,+ default: 64,+ description: "Font size",+ hiddenFromList: false,+ },+ fontWeight: {+ type: "number",+ min: 400,+ max: 900,+ step: 100,+ default: 800,+ description: "Font weight",+ hiddenFromList: false,+ },+ color: {+ type: "color",+ default: "#ffffff",+ description: "Text color",+ },+ combineTokensWithinMilliseconds: {+ type: "number",+ min: 0,+ max: 3000,+ step: 100,+ default: 1200,+ description: "Page window (ms)",+ hiddenFromList: false,+ },+ holdMs: {+ type: "number",+ min: 0,+ max: 2000,+ step: 50,+ default: 600,+ description: "Hold (ms)",+ hiddenFromList: false,+ },+ shadow: {+ type: "boolean",+ default: true,+ description: "Shadow",+ },+ },+ durationInFrames: previewCaptionsDuration(undefined, FPS),+ getDurationInFrames: (values) =>+ previewCaptionsDuration(+ typeof values.captions === "string" ? values.captions : undefined,+ FPS,+ previewTailMs(values.holdMs),+ ),+ fps: FPS,+ compositionWidth: W,+ compositionHeight: H,+ previewBackdrop: { type: "color", value: "#262626" },+ snippet: captionRiseExampleCode,+};diff --git a/registry/remocn/caption-rise/index.tsx b/registry/remocn/caption-rise/index.tsxnew file mode 100644index 00000000..c55bcfd5--- /dev/null+++ b/registry/remocn/caption-rise/index.tsx@@ -0,0 +1,107 @@+"use client";++import { Fragment } from "react";+import { Easing, interpolate } from "remotion";+import {+ type CaptionBaseProps,+ DEFAULT_HOLD_MS,+ getExitWindowMs,+ groupCaptionWords,+ useCaptions,+} from "@/lib/remocn/caption-core";++export interface CaptionRiseProps extends CaptionBaseProps {+ shadow?: boolean;+}++const EXIT_MS = 220;+const RISE_MS = 260;+const START_EM = 1.6;+const CLIP = "inset(-0.2em -0.6em -0.35em -0.6em)";+const LEGIBILITY_SHADOW =+ "0 2px 3px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.35)";++const riseEasing = Easing.bezier(0.16, 1, 0.3, 1);++export function CaptionRise({+ captions,+ combineTokensWithinMilliseconds = 1200,+ holdMs = DEFAULT_HOLD_MS,+ fontSize = 64,+ fontWeight = 800,+ color = "#ffffff",+ shadow = true,+ className,+}: CaptionRiseProps) {+ const state = useCaptions({+ captions,+ combineTokensWithinMilliseconds,+ holdMs,+ });+ if (!state) return null;++ const exit = state.endsInSilence+ ? interpolate(+ state.untilEndMs,+ [0, getExitWindowMs(state, EXIT_MS)],+ [0, 1],+ {+ extrapolateLeft: "clamp",+ extrapolateRight: "clamp",+ },+ )+ : 1;++ return (+ <div+ className={className}+ style={{+ fontSize,+ fontWeight,+ color,+ lineHeight: 1.2,+ textAlign: "center",+ opacity: exit,+ }}+ >+ {groupCaptionWords(state.tokens).map((word, w) => (+ <Fragment key={`${state.pageIndex}-${word[0].index}`}>+ {w > 0 && " "}+ <span style={{ display: "inline-block", whiteSpace: "nowrap" }}>+ {word.map(({ index, token }) => {+ const sinceMs = state.timeMs - token.fromMs;+ const p =+ sinceMs < 0+ ? 0+ : interpolate(sinceMs, [0, RISE_MS], [0, 1], {+ easing: riseEasing,+ extrapolateLeft: "clamp",+ extrapolateRight: "clamp",+ });+ return (+ <span+ key={index}+ style={{+ display: "inline-block",+ clipPath: CLIP,+ }}+ >+ <span+ style={{+ display: "inline-block",+ opacity: sinceMs < 0 ? 0 : 1,+ transform: `translateY(${(1 - p) * START_EM}em)`,+ textShadow: shadow ? LEGIBILITY_SHADOW : undefined,+ }}+ >+ {token.text}+ </span>+ </span>+ );+ })}+ </span>+ </Fragment>+ ))}+ </div>+ );+}diff --git a/registry/remocn/caption-scramble/config.ts b/registry/remocn/caption-scramble/config.tsnew file mode 100644index 00000000..9077a11e--- /dev/null+++ b/registry/remocn/caption-scramble/config.ts@@ -0,0 +1,83 @@+import {+ CAPTION_FIXTURE,+ previewCaptionsDuration,+ previewTailMs,+} from "@/components/docs/examples/caption-fixture";+import { captionScrambleExampleCode } from "@/components/docs/examples/caption-scramble-example";+import { type ComponentConfig, FPS, H, W } from "@/lib/customizer-config";++export const captionScrambleConfig: ComponentConfig = {+ componentName: "CaptionScramble",+ importPath: "@/components/remocn/caption-scramble",+ controls: {+ captions: {+ type: "remotion-captions",+ default: CAPTION_FIXTURE,+ description: "Transcript",+ keyframable: false,+ },+ fontSize: {+ type: "number",+ min: 24,+ max: 140,+ step: 1,+ default: 64,+ description: "Font size",+ hiddenFromList: false,+ },+ fontWeight: {+ type: "number",+ min: 400,+ max: 900,+ step: 100,+ default: 800,+ description: "Font weight",+ hiddenFromList: false,+ },+ color: {+ type: "color",+ default: "#ffffff",+ description: "Text color",+ },+ glyphColor: {+ type: "color",+ default: "#a3a3a3",+ description: "Glyph color",+ },+ combineTokensWithinMilliseconds: {+ type: "number",+ min: 0,+ max: 3000,+ step: 100,+ default: 1200,+ description: "Page window (ms)",+ hiddenFromList: false,+ },+ holdMs: {+ type: "number",+ min: 0,+ max: 2000,+ step: 50,+ default: 600,+ description: "Hold (ms)",+ hiddenFromList: false,+ },+ shadow: {+ type: "boolean",+ default: true,+ description: "Shadow",+ },+ },+ durationInFrames: previewCaptionsDuration(undefined, FPS),+ getDurationInFrames: (values) =>+ previewCaptionsDuration(+ typeof values.captions === "string" ? values.captions : undefined,+ FPS,+ previewTailMs(values.holdMs),+ ),+ fps: FPS,+ compositionWidth: W,+ compositionHeight: H,+ previewBackdrop: { type: "color", value: "#262626" },+ snippet: captionScrambleExampleCode,+};diff --git a/registry/remocn/caption-scramble/index.tsx b/registry/remocn/caption-scramble/index.tsxnew file mode 100644index 00000000..64bf9bed--- /dev/null+++ b/registry/remocn/caption-scramble/index.tsx@@ -0,0 +1,163 @@+"use client";++import { Fragment } from "react";+import { Easing, interpolate, random, useVideoConfig } from "remotion";+import {+ type CaptionBaseProps,+ DEFAULT_HOLD_MS,+ getExitWindowMs,+ groupCaptionWords,+ useCaptions,+} from "@/lib/remocn/caption-core";++export interface CaptionScrambleProps extends CaptionBaseProps {+ glyphColor?: string;+ shadow?: boolean;+}++const ENTER_MS = 160;+const EXIT_MS = 220;+const RISE_EM = 0.14;+const MAX_RESOLVE_MS = 300;+const FRAMES_PER_ROLL = 2;+const GLYPHS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789#%&*/+=";+const LEGIBILITY_SHADOW =+ "0 2px 3px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.35)";++const enterEasing = Easing.bezier(0.2, 0.8, 0.2, 1);++const clamp = {+ extrapolateLeft: "clamp",+ extrapolateRight: "clamp",+} as const;++function resolveProgress(sinceMs: number, fromMs: number, toMs: number) {+ const duration = Math.min(toMs - fromMs, MAX_RESOLVE_MS);+ if (duration <= 0) return 1;+ return Math.min(1, sinceMs / duration);+}++export function CaptionScramble({+ captions,+ combineTokensWithinMilliseconds = 1200,+ holdMs = DEFAULT_HOLD_MS,+ fontSize = 64,+ fontWeight = 800,+ color = "#ffffff",+ glyphColor = "#a3a3a3",+ shadow = true,+ className,+}: CaptionScrambleProps) {+ const { fps } = useVideoConfig();+ const state = useCaptions({+ captions,+ combineTokensWithinMilliseconds,+ holdMs,+ });+ if (!state) return null;++ const enter = interpolate(+ state.previous ? ENTER_MS : state.sinceStartMs,+ [0, ENTER_MS],+ [0, 1],+ {+ ...clamp,+ easing: enterEasing,+ },+ );+ const exit = state.endsInSilence+ ? interpolate(+ state.untilEndMs,+ [0, getExitWindowMs(state, EXIT_MS)],+ [0, 1],+ clamp,+ )+ : 1;+ const step = Math.floor(((state.timeMs / 1000) * fps) / FRAMES_PER_ROLL);+ const textShadow = shadow ? LEGIBILITY_SHADOW : undefined;++ return (+ <div+ className={className}+ style={{+ fontSize,+ fontWeight,+ color,+ lineHeight: 1.2,+ textAlign: "center",+ opacity: Math.min(enter, exit),+ transform: `translateY(${(1 - enter) * RISE_EM}em)`,+ }}+ >+ {groupCaptionWords(state.tokens).map((word, w) => (+ <Fragment key={`${state.pageIndex}-${word[0].index}`}>+ {w > 0 && " "}+ <span style={{ display: "inline-block", whiteSpace: "nowrap" }}>+ {word.map(({ index, token }) => {+ const sinceMs = state.timeMs - token.fromMs;+ if (sinceMs < 0) {+ return (+ <span key={index} style={{ opacity: 0 }}>+ {token.text}+ </span>+ );+ }+ const progress = resolveProgress(+ sinceMs,+ token.fromMs,+ token.toMs,+ );+ if (progress >= 1) {+ return (+ <span key={index} style={{ textShadow }}>+ {token.text}+ </span>+ );+ }+ const chars = Array.from(token.text);+ const resolved = Math.floor(progress * chars.length);+ return (+ <span+ key={index}+ style={{ position: "relative", display: "inline-block" }}+ >+ <span style={{ color: "transparent" }}>{token.text}</span>+ <span+ aria-hidden+ style={{+ position: "absolute",+ left: 0,+ right: 0,+ top: 0,+ whiteSpace: "nowrap",+ clipPath: "inset(-50% 0 -50% 0)",+ textShadow,+ }}+ >+ <span>{chars.slice(0, resolved).join("")}</span>+ <span style={{ color: glyphColor }}>+ {chars+ .slice(resolved)+ .map((char, c) =>+ /\s/.test(char)+ ? char+ : GLYPHS[+ Math.floor(+ random(+ `${state.pageIndex}-${index}-${resolved + c}-${step}`,+ ) * GLYPHS.length,+ )+ ],+ )+ .join("")}+ </span>+ </span>+ </span>+ );+ })}+ </span>+ </Fragment>+ ))}+ </div>+ );+}diff --git a/registry/remocn/caption-slice/config.ts b/registry/remocn/caption-slice/config.tsnew file mode 100644index 00000000..9c7a2dd8--- /dev/null+++ b/registry/remocn/caption-slice/config.ts@@ -0,0 +1,87 @@+import {+ CAPTION_FIXTURE,+ previewCaptionsDuration,+ previewTailMs,+} from "@/components/docs/examples/caption-fixture";+import { captionSliceExampleCode } from "@/components/docs/examples/caption-slice-example";+import { type ComponentConfig, FPS, H, W } from "@/lib/customizer-config";++export const captionSliceConfig: ComponentConfig = {+ componentName: "CaptionSlice",+ importPath: "@/components/remocn/caption-slice",+ controls: {+ captions: {+ type: "remotion-captions",+ default: CAPTION_FIXTURE,+ description: "Transcript",+ keyframable: false,+ },+ fontSize: {+ type: "number",+ min: 24,+ max: 140,+ step: 1,+ default: 64,+ description: "Font size",+ hiddenFromList: false,+ },+ fontWeight: {+ type: "number",+ min: 400,+ max: 900,+ step: 100,+ default: 800,+ description: "Font weight",+ hiddenFromList: false,+ },+ color: {+ type: "color",+ default: "#ffffff",+ description: "Text color",+ },+ distance: {+ type: "number",+ min: 0.1,+ max: 2,+ step: 0.05,+ default: 0.6,+ description: "Slide distance (em)",+ hiddenFromList: false,+ },+ combineTokensWithinMilliseconds: {+ type: "number",+ min: 0,+ max: 3000,+ step: 100,+ default: 1200,+ description: "Page window (ms)",+ hiddenFromList: false,+ },+ holdMs: {+ type: "number",+ min: 0,+ max: 2000,+ step: 50,+ default: 600,+ description: "Hold (ms)",+ hiddenFromList: false,+ },+ shadow: {+ type: "boolean",+ default: true,+ description: "Shadow",+ },+ },+ durationInFrames: previewCaptionsDuration(undefined, FPS),+ getDurationInFrames: (values) =>+ previewCaptionsDuration(+ typeof values.captions === "string" ? values.captions : undefined,+ FPS,+ previewTailMs(values.holdMs),+ ),+ fps: FPS,+ compositionWidth: W,+ compositionHeight: H,+ previewBackdrop: { type: "color", value: "#262626" },+ snippet: captionSliceExampleCode,+};diff --git a/registry/remocn/caption-slice/index.tsx b/registry/remocn/caption-slice/index.tsxnew file mode 100644index 00000000..b14f75dd--- /dev/null+++ b/registry/remocn/caption-slice/index.tsx@@ -0,0 +1,147 @@+"use client";++import { Fragment } from "react";+import { Easing, interpolate } from "remotion";+import {+ type CaptionBaseProps,+ DEFAULT_HOLD_MS,+ getExitWindowMs,+ groupCaptionWords,+ useCaptions,+} from "@/lib/remocn/caption-core";++export interface CaptionSliceProps extends CaptionBaseProps {+ distance?: number;+ shadow?: boolean;+}++const SLIDE_MS = 240;+const FADE_MS = 90;+const EXIT_MS = 220;+const LEGIBILITY_SHADOW =+ "0 2px 3px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.35)";+const TOP_HALF = "inset(-0.5em -0.5em 50% -0.5em)";+const BOTTOM_HALF = "inset(50% -0.5em -0.5em -0.5em)";++const slideEasing = Easing.bezier(0.16, 1, 0.3, 1);++const clamp = {+ extrapolateLeft: "clamp",+ extrapolateRight: "clamp",+} as const;++export function CaptionSlice({+ captions,+ combineTokensWithinMilliseconds = 1200,+ holdMs = DEFAULT_HOLD_MS,+ fontSize = 64,+ fontWeight = 800,+ color = "#ffffff",+ distance = 0.6,+ shadow = true,+ className,+}: CaptionSliceProps) {+ const state = useCaptions({+ captions,+ combineTokensWithinMilliseconds,+ holdMs,+ });+ if (!state) return null;++ const exit = state.endsInSilence+ ? interpolate(+ state.untilEndMs,+ [0, getExitWindowMs(state, EXIT_MS)],+ [0, 1],+ clamp,+ )+ : 1;+ const textShadow = shadow ? LEGIBILITY_SHADOW : undefined;++ return (+ <div+ className={className}+ style={{+ fontSize,+ fontWeight,+ color,+ lineHeight: 1.2,+ textAlign: "center",+ opacity: exit,+ }}+ >+ {groupCaptionWords(state.tokens).map((word, w) => (+ <Fragment key={`${state.pageIndex}-${word[0].index}`}>+ {w > 0 && " "}+ <span style={{ display: "inline-block", whiteSpace: "nowrap" }}>+ {word.map(({ index, token }) => {+ const sinceMs = state.timeMs - token.fromMs;+ if (sinceMs < 0) {+ return (+ <span+ key={index}+ style={{ display: "inline-block", color: "transparent" }}+ >+ {token.text}+ </span>+ );+ }+ const slide = interpolate(sinceMs, [0, SLIDE_MS], [0, 1], {+ ...clamp,+ easing: slideEasing,+ });+ if (slide >= 1) {+ return (+ <span+ key={index}+ style={{ display: "inline-block", textShadow }}+ >+ {token.text}+ </span>+ );+ }+ const opacity = interpolate(sinceMs, [0, FADE_MS], [0, 1], clamp);+ const offset = (1 - slide) * distance;+ return (+ <span+ key={index}+ style={{ position: "relative", display: "inline-block" }}+ >+ <span style={{ color: "transparent" }}>{token.text}</span>+ <span+ aria-hidden+ style={{+ position: "absolute",+ inset: 0,+ whiteSpace: "nowrap",+ clipPath: TOP_HALF,+ opacity,+ transform: `translateX(${-offset}em)`,+ textShadow,+ }}+ >+ {token.text}+ </span>+ <span+ aria-hidden+ style={{+ position: "absolute",+ inset: 0,+ whiteSpace: "nowrap",+ clipPath: BOTTOM_HALF,+ opacity,+ transform: `translateX(${offset}em)`,+ textShadow,+ }}+ >+ {token.text}+ </span>+ </span>+ );+ })}+ </span>+ </Fragment>+ ))}+ </div>+ );+}diff --git a/registry/remocn/caption-slot/config.ts b/registry/remocn/caption-slot/config.tsnew file mode 100644index 00000000..35c51bef--- /dev/null+++ b/registry/remocn/caption-slot/config.ts@@ -0,0 +1,78 @@+import {+ CAPTION_FIXTURE,+ previewCaptionsDuration,+ previewTailMs,+} from "@/components/docs/examples/caption-fixture";+import { captionSlotExampleCode } from "@/components/docs/examples/caption-slot-example";+import { type ComponentConfig, FPS, H, W } from "@/lib/customizer-config";++export const captionSlotConfig: ComponentConfig = {+ componentName: "CaptionSlot",+ importPath: "@/components/remocn/caption-slot",+ controls: {+ captions: {+ type: "remotion-captions",+ default: CAPTION_FIXTURE,+ description: "Transcript",+ keyframable: false,+ },+ fontSize: {+ type: "number",+ min: 24,+ max: 140,+ step: 1,+ default: 64,+ description: "Font size",+ hiddenFromList: false,+ },+ fontWeight: {+ type: "number",+ min: 400,+ max: 900,+ step: 100,+ default: 800,+ description: "Font weight",+ hiddenFromList: false,+ },+ color: {+ type: "color",+ default: "#ffffff",+ description: "Text color",+ },+ combineTokensWithinMilliseconds: {+ type: "number",+ min: 0,+ max: 2000,+ step: 100,+ default: 800,+ description: "Page window (ms)",+ hiddenFromList: false,+ },+ holdMs: {+ type: "number",+ min: 0,+ max: 2000,+ step: 50,+ default: 600,+ description: "Hold (ms)",+ hiddenFromList: false,+ },+ shadow: {+ type: "boolean",+ default: true,+ description: "Shadow",+ },+ },+ durationInFrames: previewCaptionsDuration(undefined, FPS),+ getDurationInFrames: (values) =>+ previewCaptionsDuration(+ typeof values.captions === "string" ? values.captions : undefined,+ FPS,+ previewTailMs(values.holdMs),+ ),+ fps: FPS,+ compositionWidth: W,+ compositionHeight: H,+ previewBackdrop: { type: "color", value: "#262626" },+ snippet: captionSlotExampleCode,+};diff --git a/registry/remocn/caption-slot/index.tsx b/registry/remocn/caption-slot/index.tsxnew file mode 100644index 00000000..73ea4565--- /dev/null+++ b/registry/remocn/caption-slot/index.tsx@@ -0,0 +1,133 @@+"use client";++import { type CSSProperties, Fragment } from "react";+import { Easing, interpolate } from "remotion";+import {+ type CaptionBaseProps,+ type CaptionTokenState,+ DEFAULT_HOLD_MS,+ getExitWindowMs,+ groupCaptionWords,+ useCaptions,+} from "@/lib/remocn/caption-core";++export interface CaptionSlotProps extends CaptionBaseProps {+ activeColor?: string;+ shadow?: boolean;+}++const LINE_HEIGHT = 1.3;+const CLIP_MARGIN_EM = 0.2;+const TRAVEL_EM = LINE_HEIGHT + CLIP_MARGIN_EM * 2;+const ROLL_MS = 260;+const EXIT_MS = 220;+const LEGIBILITY_SHADOW =+ "0 2px 3px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.35)";++const rollIn = Easing.bezier(0.16, 1, 0.3, 1);+const rollOut = Easing.bezier(0.7, 0, 0.84, 0);++function SlotLine({+ tokens,+ activeIndex,+ activeColor,+ style,+}: {+ tokens: CaptionTokenState[];+ activeIndex: number;+ activeColor?: string;+ style: CSSProperties;+}) {+ return (+ <div style={{ whiteSpace: "nowrap", ...style }}>+ {groupCaptionWords(tokens).map((word, w) => (+ <Fragment key={word[0].index}>+ {w > 0 && " "}+ {word.map(({ index, token }) => (+ <span+ key={index}+ style={{+ color:+ activeColor !== undefined && index === activeIndex+ ? activeColor+ : undefined,+ }}+ >+ {token.text}+ </span>+ ))}+ </Fragment>+ ))}+ </div>+ );+}++export function CaptionSlot({+ captions,+ combineTokensWithinMilliseconds = 800,+ holdMs = DEFAULT_HOLD_MS,+ fontSize = 64,+ fontWeight = 800,+ color = "#ffffff",+ activeColor,+ shadow = true,+ className,+}: CaptionSlotProps) {+ const state = useCaptions({+ captions,+ combineTokensWithinMilliseconds,+ holdMs,+ });+ if (!state) return null;++ const roll = interpolate(state.sinceStartMs, [0, ROLL_MS], [0, 1], {+ easing: rollIn,+ extrapolateLeft: "clamp",+ extrapolateRight: "clamp",+ });+ const exitProgress = Math.min(+ 1,+ Math.max(0, 1 - state.untilEndMs / getExitWindowMs(state, EXIT_MS)),+ );+ const exit = state.endsInSilence ? rollOut(exitProgress) : 0;++ return (+ <div+ className={className}+ style={{+ position: "relative",+ fontSize,+ fontWeight,+ color,+ lineHeight: LINE_HEIGHT,+ height: `${LINE_HEIGHT}em`,+ textAlign: "center",+ textShadow: shadow ? LEGIBILITY_SHADOW : undefined,+ clipPath: `inset(-${CLIP_MARGIN_EM}em -100000px)`,+ }}+ >+ {state.previous && roll < 1 ? (+ <SlotLine+ key={`page-${state.previous.pageIndex}`}+ tokens={state.previous.tokens}+ activeIndex={-1}+ style={{+ position: "absolute",+ top: 0,+ left: "50%",+ transform: `translate(-50%, ${-roll * TRAVEL_EM}em)`,+ }}+ />+ ) : null}+ <SlotLine+ key={`page-${state.pageIndex}`}+ tokens={state.tokens}+ activeIndex={state.activeIndex}+ activeColor={activeColor}+ style={{+ transform: `translateY(${(1 - roll - exit) * TRAVEL_EM}em)`,+ }}+ />+ </div>+ );+}diff --git a/registry/remocn/caption-speaker/config.ts b/registry/remocn/caption-speaker/config.tsnew file mode 100644index 00000000..70160253--- /dev/null+++ b/registry/remocn/caption-speaker/config.ts@@ -0,0 +1,82 @@+import { previewTailMs } from "@/components/docs/examples/caption-fixture";+import {+ CAPTION_DIALOGUE_FIXTURE,+ captionSpeakerExampleCode,+ speakerPreviewDuration,+} from "@/components/docs/examples/caption-speaker-example";+import { type ComponentConfig, FPS, H, W } from "@/lib/customizer-config";++export const captionSpeakerConfig: ComponentConfig = {+ componentName: "CaptionSpeaker",+ importPath: "@/components/remocn/caption-speaker",+ controls: {+ captions: {+ type: "remotion-captions",+ default: CAPTION_DIALOGUE_FIXTURE,+ description: "Transcript",+ keyframable: false,+ },+ fontSize: {+ type: "number",+ min: 24,+ max: 140,+ step: 1,+ default: 64,+ description: "Font size",+ hiddenFromList: false,+ },+ fontWeight: {+ type: "number",+ min: 400,+ max: 900,+ step: 100,+ default: 800,+ description: "Font weight",+ hiddenFromList: false,+ },+ upcomingOpacity: {+ type: "number",+ min: 0,+ max: 1,+ step: 0.05,+ default: 0.4,+ description: "Upcoming opacity",+ hiddenFromList: false,+ },+ combineTokensWithinMilliseconds: {+ type: "number",+ min: 0,+ max: 3000,+ step: 100,+ default: 1200,+ description: "Page window (ms)",+ hiddenFromList: false,+ },+ holdMs: {+ type: "number",+ min: 0,+ max: 2000,+ step: 50,+ default: 600,+ description: "Hold (ms)",+ hiddenFromList: false,+ },+ shadow: {+ type: "boolean",+ default: true,+ description: "Shadow",+ },+ },+ durationInFrames: speakerPreviewDuration(undefined, FPS),+ getDurationInFrames: (values) =>+ speakerPreviewDuration(+ typeof values.captions === "string" ? values.captions : undefined,+ FPS,+ previewTailMs(values.holdMs),+ ),+ fps: FPS,+ compositionWidth: W,+ compositionHeight: H,+ previewBackdrop: { type: "color", value: "#262626" },+ snippet: captionSpeakerExampleCode,+};diff --git a/registry/remocn/caption-speaker/index.tsx b/registry/remocn/caption-speaker/index.tsxnew file mode 100644index 00000000..a740339b--- /dev/null+++ b/registry/remocn/caption-speaker/index.tsx@@ -0,0 +1,141 @@+"use client";++import { Fragment, useMemo } from "react";+import { Easing, interpolate } from "remotion";+import {+ type CaptionBaseProps,+ DEFAULT_HOLD_MS,+ getExitWindowMs,+ groupCaptionWords,+ type SpeakerCaption,+ useCaptions,+} from "@/lib/remocn/caption-core";++export interface CaptionSpeakerProps extends CaptionBaseProps {+ captions: SpeakerCaption[];+ speakerColors?: Record<string, string>;+ upcomingOpacity?: number;+ shadow?: boolean;+}++const SPEAKER_PALETTE = ["#facc15", "#38bdf8", "#f472b6", "#4ade80"];++const ENTER_MS = 160;+const EXIT_MS = 220;+const RISE_EM = 0.14;+const REVEAL_MS = 100;+const LEGIBILITY_SHADOW =+ "0 2px 3px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.35)";++const enterEasing = Easing.bezier(0.2, 0.8, 0.2, 1);++const clamp = {+ extrapolateLeft: "clamp",+ extrapolateRight: "clamp",+} as const;++export function CaptionSpeaker({+ captions,+ combineTokensWithinMilliseconds = 1200,+ holdMs = DEFAULT_HOLD_MS,+ fontSize = 64,+ fontWeight = 800,+ color = "#ffffff",+ speakerColors,+ upcomingOpacity = 0.4,+ shadow = true,+ className,+}: CaptionSpeakerProps) {+ const state = useCaptions({+ captions,+ combineTokensWithinMilliseconds,+ holdMs,+ });+ const autoColors = useMemo(() => {+ const pinned = new Set(Object.values(speakerColors ?? {}));+ const free = SPEAKER_PALETTE.filter((c) => !pinned.has(c));+ const palette = free.length > 0 ? free : SPEAKER_PALETTE;+ const assigned = new Map<string, string>();+ for (const caption of captions) {+ const { speaker } = caption;+ if (+ speaker === undefined ||+ speakerColors?.[speaker] !== undefined ||+ assigned.has(speaker)+ ) {+ continue;+ }+ assigned.set(speaker, palette[assigned.size % palette.length]);+ }+ return assigned;+ }, [captions, speakerColors]);+ if (!state) return null;++ const enter = interpolate(+ state.previous ? ENTER_MS : state.sinceStartMs,+ [0, ENTER_MS],+ [0, 1],+ {+ ...clamp,+ easing: enterEasing,+ },+ );+ const exit = state.endsInSilence+ ? interpolate(+ state.untilEndMs,+ [0, getExitWindowMs(state, EXIT_MS)],+ [0, 1],+ clamp,+ )+ : 1;++ const { speaker } = state;+ const speakerColor =+ speaker === undefined+ ? color+ : (speakerColors?.[speaker] ?? autoColors.get(speaker) ?? color);++ return (+ <div+ className={className}+ style={{+ fontSize,+ fontWeight,+ color: speakerColor,+ lineHeight: 1.2,+ textAlign: "center",+ opacity: Math.min(enter, exit),+ transform: `translateY(${(1 - enter) * RISE_EM}em)`,+ }}+ >+ {groupCaptionWords(state.tokens).map((word, w) => (+ <Fragment key={`${state.pageIndex}-${word[0].index}`}>+ {w > 0 && " "}+ <span+ style={{+ display: "inline-block",+ whiteSpace: "nowrap",+ textShadow: shadow ? LEGIBILITY_SHADOW : undefined,+ }}+ >+ {word.map(({ index, token }) => (+ <span+ key={index}+ style={{+ opacity: interpolate(+ state.timeMs - token.fromMs,+ [0, REVEAL_MS],+ [upcomingOpacity, 1],+ clamp,+ ),+ }}+ >+ {token.text}+ </span>+ ))}+ </span>+ </Fragment>+ ))}+ </div>+ );+}diff --git a/registry/remocn/caption-split-flap/config.ts b/registry/remocn/caption-split-flap/config.tsnew file mode 100644index 00000000..f4924bd1--- /dev/null+++ b/registry/remocn/caption-split-flap/config.ts@@ -0,0 +1,78 @@+import {+ CAPTION_FIXTURE,+ previewCaptionsDuration,+ previewTailMs,+} from "@/components/docs/examples/caption-fixture";+import { captionSplitFlapExampleCode } from "@/components/docs/examples/caption-split-flap-example";+import { type ComponentConfig, FPS, H, W } from "@/lib/customizer-config";++export const captionSplitFlapConfig: ComponentConfig = {+ componentName: "CaptionSplitFlap",+ importPath: "@/components/remocn/caption-split-flap",+ controls: {+ captions: {+ type: "remotion-captions",+ default: CAPTION_FIXTURE,+ description: "Transcript",+ keyframable: false,+ },+ fontSize: {+ type: "number",+ min: 24,+ max: 120,+ step: 1,+ default: 56,+ description: "Font size",+ hiddenFromList: false,+ },+ fontWeight: {+ type: "number",+ min: 400,+ max: 900,+ step: 100,+ default: 800,+ description: "Font weight",+ hiddenFromList: false,+ },+ color: {+ type: "color",+ default: "#ffffff",+ description: "Glyph color",+ },+ tileColor: {+ type: "color",+ default: "#111111",+ description: "Tile color",+ },+ combineTokensWithinMilliseconds: {+ type: "number",+ min: 0,+ max: 3000,+ step: 100,+ default: 1000,+ description: "Page window (ms)",+ hiddenFromList: false,+ },+ holdMs: {+ type: "number",+ min: 0,+ max: 2000,+ step: 50,+ default: 600,+ description: "Hold (ms)",+ hiddenFromList: false,+ },+ },+ durationInFrames: previewCaptionsDuration(undefined, FPS),+ getDurationInFrames: (values) =>+ previewCaptionsDuration(+ typeof values.captions === "string" ? values.captions : undefined,+ FPS,+ previewTailMs(values.holdMs),+ ),+ fps: FPS,+ compositionWidth: W,+ compositionHeight: H,+ previewBackdrop: { type: "color", value: "#262626" },+ snippet: captionSplitFlapExampleCode,+};diff --git a/registry/remocn/caption-split-flap/index.tsx b/registry/remocn/caption-split-flap/index.tsxnew file mode 100644index 00000000..25d04117--- /dev/null+++ b/registry/remocn/caption-split-flap/index.tsx@@ -0,0 +1,244 @@+"use client";++import { type CSSProperties, Fragment } from "react";+import { Easing, interpolate, random } from "remotion";+import {+ type CaptionBaseProps,+ captionWordText,+ DEFAULT_HOLD_MS,+ getExitWindowMs,+ groupCaptionWords,+ useCaptions,+} from "@/lib/remocn/caption-core";++export interface CaptionSplitFlapProps extends CaptionBaseProps {+ tileColor?: string;+}++const ENTER_MS = 160;+const EXIT_MS = 220;+const RISE_EM = 0.14;+const FLIP_MS = 60;+const MIN_SETTLE_MS = 350;+const TILE_W = 0.78;+const TILE_H = 1.2;+const TILE_GAP = 0.06;+const GLYPH_SCALE = 0.8;+const RADIUS = 0.08;+const GLYPHS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";++const enterEasing = Easing.bezier(0.2, 0.8, 0.2, 1);++const clamp = {+ extrapolateLeft: "clamp",+ extrapolateRight: "clamp",+} as const;++interface FlapFrame {+ current: string;+ next: string;+ progress: number | null;+}++function flapFrame(+ target: string,+ seed: string,+ index: number,+ count: number,+ fromMs: number,+ windowMs: number,+ timeMs: number,+): FlapFrame {+ const flips = 3 + Math.floor(random(`${seed}-flips`) * 4);+ const share = count > 1 ? index / (count - 1) : 1;+ const endMs = fromMs + windowMs * (0.55 + 0.45 * share);+ const flipMs = Math.min(FLIP_MS, (endMs - fromMs) / flips);+ const startMs = endMs - flips * flipMs;+ if (timeMs < startMs) return { current: "", next: "", progress: null };+ if (timeMs >= endMs) return { current: target, next: target, progress: null };+ const glyphAt = (k: number): string => {+ if (k <= 0) return "";+ if (k >= flips) return target;+ return GLYPHS[Math.floor(random(`${seed}-${k}`) * GLYPHS.length)];+ };+ const elapsed = (timeMs - startMs) / flipMs;+ const k = Math.floor(elapsed);+ return { current: glyphAt(k), next: glyphAt(k + 1), progress: elapsed - k };+}++const TOP_HALF = "inset(0 0 50% 0)";+const BOTTOM_HALF = "inset(50% 0 0 0)";++function Leaf({+ char,+ tileColor,+ clipPath,+ transform,+ brightness = 1,+}: {+ char: string;+ tileColor: string;+ clipPath?: string;+ transform?: string;+ brightness?: number;+}) {+ const style: CSSProperties = {+ position: "absolute",+ inset: 0,+ display: "flex",+ alignItems: "center",+ justifyContent: "center",+ background: tileColor,+ borderRadius: `${RADIUS}em`,+ clipPath,+ transform,+ transformOrigin: "50% 50%",+ filter: brightness < 1 ? `brightness(${brightness})` : undefined,+ };+ return (+ <span style={style}>+ <span style={{ fontSize: `${GLYPH_SCALE}em`, lineHeight: 1 }}>+ {char}+ </span>+ </span>+ );+}++function Tile({ frame, tileColor }: { frame: FlapFrame; tileColor: string }) {+ const perspective = `perspective(${TILE_H * 4}em)`;+ const { current, next, progress } = frame;+ return (+ <span+ style={{+ position: "relative",+ display: "inline-block",+ width: `${TILE_W}em`,+ height: `${TILE_H}em`,+ flexShrink: 0,+ }}+ >+ {progress === null ? (+ <Leaf char={current} tileColor={tileColor} />+ ) : (+ <>+ <Leaf char={next} tileColor={tileColor} clipPath={TOP_HALF} />+ <Leaf char={current} tileColor={tileColor} clipPath={BOTTOM_HALF} />+ {progress < 0.5 ? (+ <Leaf+ char={current}+ tileColor={tileColor}+ clipPath={TOP_HALF}+ transform={`${perspective} rotateX(${-180 * progress}deg)`}+ brightness={1 - 0.7 * progress}+ />+ ) : (+ <Leaf+ char={next}+ tileColor={tileColor}+ clipPath={BOTTOM_HALF}+ transform={`${perspective} rotateX(${180 * (1 - progress)}deg)`}+ brightness={0.65 + 0.7 * (progress - 0.5)}+ />+ )}+ </>+ )}+ <span+ aria-hidden+ style={{+ position: "absolute",+ left: 0,+ right: 0,+ top: "50%",+ height: "max(1px, 0.025em)",+ transform: "translateY(-50%)",+ background: "rgba(0, 0, 0, 0.6)",+ }}+ />+ </span>+ );+}++export function CaptionSplitFlap({+ captions,+ combineTokensWithinMilliseconds = 1000,+ holdMs = DEFAULT_HOLD_MS,+ fontSize = 56,+ fontWeight = 800,+ color = "#ffffff",+ tileColor = "#111111",+ className,+}: CaptionSplitFlapProps) {+ const state = useCaptions({+ captions,+ combineTokensWithinMilliseconds,+ holdMs,+ });+ if (!state) return null;++ const enter = interpolate(+ state.previous ? ENTER_MS : state.sinceStartMs,+ [0, ENTER_MS],+ [0, 1],+ { ...clamp, easing: enterEasing },+ );+ const exit = state.endsInSilence+ ? interpolate(+ state.untilEndMs,+ [0, getExitWindowMs(state, EXIT_MS)],+ [0, 1],+ clamp,+ )+ : 1;++ return (+ <div+ className={className}+ style={{+ fontSize,+ fontWeight,+ color,+ lineHeight: TILE_H + 0.24,+ textAlign: "center",+ opacity: Math.min(enter, exit),+ transform: `translateY(${(1 - enter) * RISE_EM}em)`,+ }}+ >+ {groupCaptionWords(state.tokens).map((word, w) => {+ const first = word[0];+ const fromMs = first.token.fromMs;+ const toMs = word[word.length - 1].token.toMs;+ const windowMs = Math.max(toMs - fromMs, MIN_SETTLE_MS);+ const chars = Array.from(captionWordText(word));+ return (+ <Fragment key={`${state.pageIndex}-${first.index}`}>+ {w > 0 && " "}+ <span+ style={{+ display: "inline-flex",+ gap: `${TILE_GAP}em`,+ verticalAlign: "top",+ paddingInline: `${TILE_GAP}em`,+ }}+ >+ {chars.map((char, c) => (+ <Tile+ key={c}+ tileColor={tileColor}+ frame={flapFrame(+ char,+ `${state.pageIndex}-${first.index}-${c}`,+ c,+ chars.length,+ fromMs,+ windowMs,+ state.timeMs,+ )}+ />+ ))}+ </span>+ </Fragment>+ );+ })}+ </div>+ );+}diff --git a/registry/remocn/caption-stack/config.ts b/registry/remocn/caption-stack/config.tsnew file mode 100644index 00000000..1e9980b2--- /dev/null+++ b/registry/remocn/caption-stack/config.ts@@ -0,0 +1,92 @@+import {+ CAPTION_FIXTURE,+ previewCaptionsDuration,+ previewTailMs,+} from "@/components/docs/examples/caption-fixture";+import { captionStackExampleCode } from "@/components/docs/examples/caption-stack-example";+import { type ComponentConfig, FPS, H, W } from "@/lib/customizer-config";++export const captionStackConfig: ComponentConfig = {+ componentName: "CaptionStack",+ importPath: "@/components/remocn/caption-stack",+ controls: {+ captions: {+ type: "remotion-captions",+ default: CAPTION_FIXTURE,+ description: "Transcript",+ keyframable: false,+ },+ fontSize: {+ type: "number",+ min: 24,+ max: 140,+ step: 1,+ default: 64,+ description: "Font size",+ hiddenFromList: false,+ },+ fontWeight: {+ type: "number",+ min: 400,+ max: 900,+ step: 100,+ default: 800,+ description: "Font weight",+ hiddenFromList: false,+ },+ color: {+ type: "color",+ default: "#ffffff",+ description: "Text color",+ },+ emphasisColor: {+ type: "color",+ default: "#facc15",+ description: "Emphasis color",+ },+ emphasisScale: {+ type: "number",+ min: 1,+ max: 2.5,+ step: 0.05,+ default: 1.7,+ description: "Emphasis scale",+ hiddenFromList: false,+ },+ combineTokensWithinMilliseconds: {+ type: "number",+ min: 0,+ max: 3000,+ step: 100,+ default: 1600,+ description: "Page window (ms)",+ hiddenFromList: false,+ },+ holdMs: {+ type: "number",+ min: 0,+ max: 2000,+ step: 50,+ default: 600,+ description: "Hold (ms)",+ hiddenFromList: false,+ },+ shadow: {+ type: "boolean",+ default: true,+ description: "Shadow",+ },+ },+ durationInFrames: previewCaptionsDuration(undefined, FPS),+ getDurationInFrames: (values) =>+ previewCaptionsDuration(+ typeof values.captions === "string" ? values.captions : undefined,+ FPS,+ previewTailMs(values.holdMs),+ ),+ fps: FPS,+ compositionWidth: W,+ compositionHeight: H,+ previewBackdrop: { type: "color", value: "#262626" },+ snippet: captionStackExampleCode,+};diff --git a/registry/remocn/caption-stack/index.tsx b/registry/remocn/caption-stack/index.tsxnew file mode 100644index 00000000..069edc64--- /dev/null+++ b/registry/remocn/caption-stack/index.tsx@@ -0,0 +1,175 @@+"use client";++import { Fragment } from "react";+import { Easing, interpolate } from "remotion";+import {+ type CaptionBaseProps,+ captionWordText,+ createKeywordMatcher,+ DEFAULT_HOLD_MS,+ getExitWindowMs,+ groupCaptionWords,+ normalizeCaptionWord,+ useCaptions,+} from "@/lib/remocn/caption-core";++export interface CaptionStackProps extends CaptionBaseProps {+ keywords?: string[];+ emphasisScale?: number;+ emphasisColor?: string;+ shadow?: boolean;+}++type CaptionWord = ReturnType<typeof groupCaptionWords>[number];++interface StackLine {+ words: CaptionWord[];+ emphasis: boolean;+}++const WORDS_PER_LINE = 2;+const EXIT_MS = 220;+const FADE_IN_MS = 120;+const RISE_MS = 220;+const RISE_EM = 0.3;+const LEGIBILITY_SHADOW =+ "0 2px 3px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.35)";++const riseEasing = Easing.bezier(0.2, 0.8, 0.2, 1);++const clamp = {+ extrapolateLeft: "clamp",+ extrapolateRight: "clamp",+} as const;++function buildLines(+ words: CaptionWord[],+ isEmphasis: (word: CaptionWord, index: number) => boolean,+): StackLine[] {+ const lines: StackLine[] = [];+ let current: CaptionWord[] = [];+ const flush = () => {+ if (current.length > 0) {+ lines.push({ words: current, emphasis: false });+ current = [];+ }+ };+ words.forEach((word, i) => {+ if (isEmphasis(word, i)) {+ flush();+ lines.push({ words: [word], emphasis: true });+ return;+ }+ current.push(word);+ if (current.length >= WORDS_PER_LINE) flush();+ });+ flush();+ return lines;+}++function longestWordIndex(words: CaptionWord[]): number {+ let longest = -1;+ let longestLength = 0;+ words.forEach((word, i) => {+ const length = normalizeCaptionWord(captionWordText(word)).length;+ if (length > longestLength) {+ longest = i;+ longestLength = length;+ }+ });+ return longest;+}++export function CaptionStack({+ captions,+ combineTokensWithinMilliseconds = 1600,+ holdMs = DEFAULT_HOLD_MS,+ fontSize = 64,+ fontWeight = 800,+ color = "#ffffff",+ keywords,+ emphasisScale = 1.7,+ emphasisColor = "#facc15",+ shadow = true,+ className,+}: CaptionStackProps) {+ const state = useCaptions({+ captions,+ combineTokensWithinMilliseconds,+ holdMs,+ });+ if (!state) return null;++ const words = groupCaptionWords(state.tokens);+ const hasKeywords = keywords !== undefined && keywords.length > 0;+ const isKeyword = createKeywordMatcher(keywords);+ const longest = hasKeywords ? -1 : longestWordIndex(words);+ const lines = buildLines(words, (word, i) =>+ hasKeywords ? isKeyword(captionWordText(word)) : i === longest,+ );++ const exit = state.endsInSilence+ ? interpolate(+ state.untilEndMs,+ [0, getExitWindowMs(state, EXIT_MS)],+ [0, 1],+ clamp,+ )+ : 1;++ return (+ <div+ className={className}+ style={{+ fontSize,+ fontWeight,+ color,+ lineHeight: 1,+ textAlign: "center",+ opacity: exit,+ }}+ >+ {lines.map((line) => (+ <div+ key={`${state.pageIndex}-${line.words[0][0].index}`}+ style={{+ fontSize: line.emphasis ? `${emphasisScale}em` : undefined,+ color: line.emphasis ? emphasisColor : undefined,+ }}+ >+ {line.words.map((word, w) => {+ const sinceMs = state.timeMs - word[0].token.fromMs;+ const arrived = sinceMs >= 0;+ const rise = arrived+ ? interpolate(sinceMs, [0, RISE_MS], [0, 1], {+ ...clamp,+ easing: riseEasing,+ })+ : 0;+ const opacity = arrived+ ? interpolate(sinceMs, [0, FADE_IN_MS], [0, 1], clamp)+ : 0;+ return (+ <Fragment key={word[0].index}>+ {w > 0 && " "}+ <span+ style={{+ display: "inline-block",+ whiteSpace: "nowrap",+ opacity,+ transform: `translateY(${(1 - rise) * RISE_EM}em)`,+ textShadow: shadow ? LEGIBILITY_SHADOW : undefined,+ }}+ >+ {word.map(({ index, token }) => (+ <span key={index}>{token.text}</span>+ ))}+ </span>+ </Fragment>+ );+ })}+ </div>+ ))}+ </div>+ );+}diff --git a/registry/remocn/caption-stamp/config.ts b/registry/remocn/caption-stamp/config.tsnew file mode 100644index 00000000..e4d001f3--- /dev/null+++ b/registry/remocn/caption-stamp/config.ts@@ -0,0 +1,88 @@+import {+ CAPTION_FIXTURE,+ previewCaptionsDuration,+ previewTailMs,+} from "@/components/docs/examples/caption-fixture";+import { captionStampExampleCode } from "@/components/docs/examples/caption-stamp-example";+import { type ComponentConfig, FPS, H, W } from "@/lib/customizer-config";++export const captionStampConfig: ComponentConfig = {+ componentName: "CaptionStamp",+ importPath: "@/components/remocn/caption-stamp",+ controls: {+ captions: {+ type: "remotion-captions",+ default: CAPTION_FIXTURE,+ description: "Transcript",+ keyframable: false,+ },+ fontSize: {+ type: "number",+ min: 24,+ max: 140,+ step: 1,+ default: 64,+ description: "Font size",+ hiddenFromList: false,+ },+ fontWeight: {+ type: "number",+ min: 400,+ max: 900,+ step: 100,+ default: 800,+ description: "Font weight",+ hiddenFromList: false,+ },+ color: {+ type: "color",+ default: "#ffffff",+ description: "Text color",+ },+ stampColor: {+ type: "color",+ default: "#ef4444",+ description: "Stamp color",+ },+ texture: {+ type: "boolean",+ default: true,+ description: "Ink texture",+ },+ combineTokensWithinMilliseconds: {+ type: "number",+ min: 0,+ max: 3000,+ step: 100,+ default: 1200,+ description: "Page window (ms)",+ hiddenFromList: false,+ },+ holdMs: {+ type: "number",+ min: 0,+ max: 2000,+ step: 50,+ default: 600,+ description: "Hold (ms)",+ hiddenFromList: false,+ },+ shadow: {+ type: "boolean",+ default: true,+ description: "Shadow",+ },+ },+ durationInFrames: previewCaptionsDuration(undefined, FPS),+ getDurationInFrames: (values) =>+ previewCaptionsDuration(+ typeof values.captions === "string" ? values.captions : undefined,+ FPS,+ previewTailMs(values.holdMs),+ ),+ fps: FPS,+ compositionWidth: W,+ compositionHeight: H,+ previewBackdrop: { type: "color", value: "#262626" },+ snippet: captionStampExampleCode,+};diff --git a/registry/remocn/caption-stamp/index.tsx b/registry/remocn/caption-stamp/index.tsxnew file mode 100644index 00000000..c70ec463--- /dev/null+++ b/registry/remocn/caption-stamp/index.tsx@@ -0,0 +1,239 @@+"use client";++import { Fragment, useId } from "react";+import { Easing, interpolate, random } from "remotion";+import {+ type CaptionBaseProps,+ captionWordText,+ createKeywordMatcher,+ DEFAULT_HOLD_MS,+ getExitWindowMs,+ groupCaptionWords,+ normalizeCaptionWord,+ useCaptions,+} from "@/lib/remocn/caption-core";++export interface CaptionStampProps extends CaptionBaseProps {+ keywords?: string[];+ stampColor?: string;+ texture?: boolean;+ shadow?: boolean;+}++const ENTER_MS = 160;+const EXIT_MS = 220;+const RISE_EM = 0.14;+const SLAM_MS = 90;+const SETTLE_MS = 170;+const INK_MS = 50;+const PAD_EM = 0.16;+const BORDER_EM = 0.06;+const RADIUS_EM = 0.08;+const LEGIBILITY_SHADOW =+ "0 2px 3px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.35)";++const enterEasing = Easing.bezier(0.2, 0.8, 0.2, 1);+const slamEasing = Easing.in(Easing.quad);+const settleEasing = Easing.out(Easing.quad);++const clamp = {+ extrapolateLeft: "clamp",+ extrapolateRight: "clamp",+} as const;++function stampScale(sinceMs: number): number {+ if (sinceMs <= SLAM_MS) {+ return interpolate(sinceMs, [0, SLAM_MS], [1.8, 0.96], {+ ...clamp,+ easing: slamEasing,+ });+ }+ return interpolate(sinceMs, [SLAM_MS, SETTLE_MS], [0.96, 1], {+ ...clamp,+ easing: settleEasing,+ });+}++export function CaptionStamp({+ captions,+ combineTokensWithinMilliseconds = 1200,+ holdMs = DEFAULT_HOLD_MS,+ fontSize = 64,+ fontWeight = 800,+ color = "#ffffff",+ keywords,+ stampColor = "#ef4444",+ texture = true,+ shadow = true,+ className,+}: CaptionStampProps) {+ const filterId = `caption-stamp-${useId().replace(/[^a-zA-Z0-9_-]/g, "")}`;+ const state = useCaptions({+ captions,+ combineTokensWithinMilliseconds,+ holdMs,+ });+ if (!state) return null;++ const enter = interpolate(+ state.previous ? ENTER_MS : state.sinceStartMs,+ [0, ENTER_MS],+ [0, 1],+ { ...clamp, easing: enterEasing },+ );+ const exit = state.endsInSilence+ ? interpolate(+ state.untilEndMs,+ [0, getExitWindowMs(state, EXIT_MS)],+ [0, 1],+ clamp,+ )+ : 1;++ const words = groupCaptionWords(state.tokens);+ const isKeyword = createKeywordMatcher(keywords);+ const byKeyword = keywords !== undefined && keywords.length > 0;+ let longest = -1;+ let longestLength = 0;+ if (!byKeyword) {+ words.forEach((word, w) => {+ const length = normalizeCaptionWord(captionWordText(word)).length;+ if (length > longestLength) {+ longest = w;+ longestLength = length;+ }+ });+ }+ const textShadow = shadow ? LEGIBILITY_SHADOW : undefined;++ return (+ <div+ className={className}+ style={{+ position: "relative",+ fontSize,+ fontWeight,+ color,+ lineHeight: 1.2,+ textAlign: "center",+ opacity: Math.min(enter, exit),+ transform: `translateY(${(1 - enter) * RISE_EM}em)`,+ }}+ >+ {texture && (+ <svg+ aria-hidden+ width={0}+ height={0}+ style={{ position: "absolute", overflow: "hidden" }}+ >+ <filter id={filterId} x="-10%" y="-20%" width="120%" height="140%">+ <feTurbulence+ type="fractalNoise"+ baseFrequency="0.45"+ numOctaves={2}+ seed={4}+ result="warp"+ />+ <feDisplacementMap+ in="SourceGraphic"+ in2="warp"+ scale={fontSize * 0.035}+ xChannelSelector="R"+ yChannelSelector="G"+ result="rough"+ />+ <feTurbulence+ type="fractalNoise"+ baseFrequency="0.8"+ numOctaves={1}+ seed={9}+ result="grain"+ />+ <feColorMatrix+ in="grain"+ type="matrix"+ values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -10 6.8"+ result="holes"+ />+ <feComposite in="rough" in2="holes" operator="in" />+ </filter>+ </svg>+ )}+ {words.map((word, w) => {+ const key = `${state.pageIndex}-${word[0].index}`;+ const text = captionWordText(word);+ const stamped = byKeyword ? isKeyword(text) : w === longest;+ if (!stamped) {+ return (+ <Fragment key={key}>+ {w > 0 && " "}+ <span+ style={{+ display: "inline-block",+ whiteSpace: "nowrap",+ textShadow,+ }}+ >+ {text}+ </span>+ </Fragment>+ );+ }+ const sinceMs = state.timeMs - word[0].token.fromMs;+ const rotation =+ -8 + random(`caption-stamp-${state.pageIndex}-${word[0].index}`) * 5;+ return (+ <Fragment key={key}>+ {w > 0 && " "}+ <span+ style={{+ position: "relative",+ display: "inline-block",+ whiteSpace: "nowrap",+ }}+ >+ <span+ style={{+ opacity: interpolate(+ sinceMs,+ [SLAM_MS * 0.6, SLAM_MS],+ [1, 0],+ clamp,+ ),+ textShadow,+ }}+ >+ {text}+ </span>+ {sinceMs >= 0 && (+ <span+ aria-hidden+ style={{+ position: "absolute",+ left: `-${PAD_EM}em`,+ right: `-${PAD_EM}em`,+ top: "8%",+ bottom: "4%",+ display: "flex",+ alignItems: "center",+ justifyContent: "center",+ lineHeight: 1,+ color: stampColor,+ border: `${BORDER_EM}em solid ${stampColor}`,+ borderRadius: `${RADIUS_EM}em`,+ opacity: interpolate(sinceMs, [0, INK_MS], [0, 1], clamp),+ transform: `rotate(${rotation}deg) scale(${stampScale(sinceMs)})`,+ filter: texture ? `url(#${filterId})` : undefined,+ }}+ >+ {text}+ </span>+ )}+ </span>+ </Fragment>+ );+ })}+ </div>+ );+}diff --git a/registry/remocn/caption-subtitle/config.ts b/registry/remocn/caption-subtitle/config.tsnew file mode 100644index 00000000..9ad93fa6--- /dev/null+++ b/registry/remocn/caption-subtitle/config.ts@@ -0,0 +1,92 @@+import {+ CAPTION_FIXTURE,+ previewCaptionsDuration,+ previewTailMs,+} from "@/components/docs/examples/caption-fixture";+import { captionSubtitleExampleCode } from "@/components/docs/examples/caption-subtitle-example";+import { type ComponentConfig, FPS, H, W } from "@/lib/customizer-config";++export const captionSubtitleConfig: ComponentConfig = {+ componentName: "CaptionSubtitle",+ importPath: "@/components/remocn/caption-subtitle",+ controls: {+ captions: {+ type: "remotion-captions",+ default: CAPTION_FIXTURE,+ description: "Transcript",+ keyframable: false,+ },+ fontSize: {+ type: "number",+ min: 16,+ max: 100,+ step: 1,+ default: 44,+ description: "Font size",+ hiddenFromList: false,+ },+ fontWeight: {+ type: "number",+ min: 400,+ max: 900,+ step: 100,+ default: 600,+ description: "Font weight",+ hiddenFromList: false,+ },+ color: {+ type: "color",+ default: "#ffffff",+ description: "Text color",+ },+ combineTokensWithinMilliseconds: {+ type: "number",+ min: 0,+ max: 6000,+ step: 100,+ default: 2500,+ description: "Page window (ms)",+ hiddenFromList: false,+ },+ holdMs: {+ type: "number",+ min: 0,+ max: 2000,+ step: 50,+ default: 600,+ description: "Hold (ms)",+ hiddenFromList: false,+ },+ box: {+ type: "boolean",+ default: true,+ description: "Box",+ },+ boxColor: {+ type: "color",+ default: "#000000",+ description: "Box color",+ },+ boxOpacity: {+ type: "number",+ min: 0,+ max: 1,+ step: 0.02,+ default: 0.72,+ description: "Box opacity",+ hiddenFromList: false,+ },+ },+ durationInFrames: previewCaptionsDuration(undefined, FPS),+ getDurationInFrames: (values) =>+ previewCaptionsDuration(+ typeof values.captions === "string" ? values.captions : undefined,+ FPS,+ previewTailMs(values.holdMs),+ ),+ fps: FPS,+ compositionWidth: W,+ compositionHeight: H,+ previewBackdrop: { type: "color", value: "#262626" },+ snippet: captionSubtitleExampleCode,+};diff --git a/registry/remocn/caption-subtitle/index.tsx b/registry/remocn/caption-subtitle/index.tsxnew file mode 100644index 00000000..94085d17--- /dev/null+++ b/registry/remocn/caption-subtitle/index.tsx@@ -0,0 +1,90 @@+"use client";++import { interpolate } from "remotion";+import {+ type CaptionBaseProps,+ DEFAULT_HOLD_MS,+ getExitWindowMs,+ useCaptions,+} from "@/lib/remocn/caption-core";++export interface CaptionSubtitleProps extends CaptionBaseProps {+ box?: boolean;+ boxColor?: string;+ boxOpacity?: number;+}++const ENTER_MS = 120;+const EXIT_MS = 160;+const LEGIBILITY_SHADOW =+ "0 2px 3px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.35)";++export function CaptionSubtitle({+ captions,+ combineTokensWithinMilliseconds = 2500,+ holdMs = DEFAULT_HOLD_MS,+ fontSize = 44,+ fontWeight = 600,+ color = "#ffffff",+ box = true,+ boxColor = "#000000",+ boxOpacity = 0.72,+ className,+}: CaptionSubtitleProps) {+ const state = useCaptions({+ captions,+ combineTokensWithinMilliseconds,+ holdMs,+ });+ if (!state) return null;++ const enter = state.previous+ ? 1+ : interpolate(state.sinceStartMs, [0, ENTER_MS], [0, 1], {+ extrapolateLeft: "clamp",+ extrapolateRight: "clamp",+ });+ const exit = state.endsInSilence+ ? interpolate(+ state.untilEndMs,+ [0, getExitWindowMs(state, EXIT_MS)],+ [0, 1],+ {+ extrapolateLeft: "clamp",+ extrapolateRight: "clamp",+ },+ )+ : 1;+ const opacityPercent = Math.round(Math.min(1, Math.max(0, boxOpacity)) * 100);++ return (+ <div+ className={className}+ style={{+ fontSize,+ fontWeight,+ color,+ lineHeight: 1.4,+ textAlign: "center",+ textWrap: "balance",+ opacity: Math.min(enter, exit),+ }}+ >+ <span+ style={+ box+ ? {+ backgroundColor: `color-mix(in srgb, ${boxColor} ${opacityPercent}%, transparent)`,+ padding: "0.06em 0.36em",+ borderRadius: "0.16em",+ boxDecorationBreak: "clone",+ WebkitBoxDecorationBreak: "clone",+ }+ : { textShadow: LEGIBILITY_SHADOW }+ }+ >+ {state.page.text}+ </span>+ </div>+ );+}diff --git a/registry/remocn/caption-teleprompter/config.ts b/registry/remocn/caption-teleprompter/config.tsnew file mode 100644index 00000000..1e7070a5--- /dev/null+++ b/registry/remocn/caption-teleprompter/config.ts@@ -0,0 +1,114 @@+import {+ CAPTION_FIXTURE,+ previewCaptionsDuration,+ previewTailMs,+} from "@/components/docs/examples/caption-fixture";+import { captionTeleprompterExampleCode } from "@/components/docs/examples/caption-teleprompter-example";+import { type ComponentConfig, FPS, H, W } from "@/lib/customizer-config";++export const captionTeleprompterConfig: ComponentConfig = {+ componentName: "CaptionTeleprompter",+ importPath: "@/components/remocn/caption-teleprompter",+ controls: {+ captions: {+ type: "remotion-captions",+ default: CAPTION_FIXTURE,+ description: "Transcript",+ keyframable: false,+ },+ fontSize: {+ type: "number",+ min: 24,+ max: 140,+ step: 1,+ default: 64,+ description: "Font size",+ hiddenFromList: false,+ },+ fontWeight: {+ type: "number",+ min: 400,+ max: 900,+ step: 100,+ default: 800,+ description: "Font weight",+ hiddenFromList: false,+ },+ color: {+ type: "color",+ default: "#ffffff",+ description: "Text color",+ },+ visibleLines: {+ type: "number",+ min: 1,+ max: 6,+ step: 1,+ default: 3,+ description: "Visible lines",+ hiddenFromList: false,+ },+ pastOpacity: {+ type: "number",+ min: 0,+ max: 1,+ step: 0.05,+ default: 0.35,+ description: "Past line opacity",+ hiddenFromList: false,+ },+ futureOpacity: {+ type: "number",+ min: 0,+ max: 1,+ step: 0.05,+ default: 0.35,+ description: "Next line opacity",+ hiddenFromList: false,+ },+ upcomingOpacity: {+ type: "number",+ min: 0,+ max: 1,+ step: 0.05,+ default: 0.55,+ description: "Unspoken word opacity",+ hiddenFromList: false,+ },+ combineTokensWithinMilliseconds: {+ type: "number",+ min: 0,+ max: 4000,+ step: 100,+ default: 1500,+ description: "Line window (ms)",+ hiddenFromList: false,+ },+ holdMs: {+ type: "number",+ min: 0,+ max: 2000,+ step: 50,+ default: 600,+ description: "Silence break (ms)",+ hiddenFromList: false,+ },+ shadow: {+ type: "boolean",+ default: true,+ description: "Shadow",+ },+ },+ durationInFrames: previewCaptionsDuration(undefined, FPS),+ getDurationInFrames: (values) =>+ previewCaptionsDuration(+ typeof values.captions === "string" ? values.captions : undefined,+ FPS,+ previewTailMs(values.holdMs),+ ),+ fps: FPS,+ compositionWidth: W,+ compositionHeight: H,+ previewBackdrop: { type: "color", value: "#262626" },+ snippet: captionTeleprompterExampleCode,+};diff --git a/registry/remocn/caption-teleprompter/index.tsx b/registry/remocn/caption-teleprompter/index.tsxnew file mode 100644index 00000000..f8f16c3b--- /dev/null+++ b/registry/remocn/caption-teleprompter/index.tsx@@ -0,0 +1,194 @@+"use client";++import type { TikTokPage } from "@remotion/captions";+import { Fragment, useMemo } from "react";+import { Easing, interpolate, useCurrentFrame, useVideoConfig } from "remotion";+import {+ buildCaptionPages,+ type CaptionBaseProps,+ DEFAULT_HOLD_MS,+ useCaptionWordRects,+} from "@/lib/remocn/caption-core";++export interface CaptionTeleprompterProps extends CaptionBaseProps {+ visibleLines?: number;+ pastOpacity?: number;+ futureOpacity?: number;+ upcomingOpacity?: number;+ shadow?: boolean;+}++interface PrompterWord {+ key: number;+ text: string;+ fromMs: number;+}++const LINE_HEIGHT = 1.3;+const LINE_GAP_EM = 0.2;+const SCROLL_MS = 320;+const LIGHT_MS = 80;+const EDGE_FADE_LINES = 0.66;++function edgeFade(visibleLines: number): string | undefined {+ const fadeLines = Math.min(+ EDGE_FADE_LINES,+ Math.max(0, visibleLines - 1) / 3,+ );+ if (fadeLines <= 0) return undefined;+ const pct = (fadeLines / visibleLines) * 100;+ return `linear-gradient(to bottom, transparent, #000 ${pct}%, #000 ${100 - pct}%, transparent)`;+}+const LEGIBILITY_SHADOW =+ "0 2px 3px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.35)";++const scrollEasing = Easing.bezier(0.45, 0, 0.2, 1);++const clamp = {+ extrapolateLeft: "clamp",+ extrapolateRight: "clamp",+} as const;++function lineWords(page: TikTokPage): PrompterWord[] {+ const words: PrompterWord[] = [];+ page.tokens.forEach((token, i) => {+ const last = words[words.length - 1];+ if (last && !/^\s/.test(token.text)) {+ last.text += token.text;+ } else {+ words.push({ key: i, text: token.text.trim(), fromMs: token.fromMs });+ }+ });+ return words;+}++export function CaptionTeleprompter({+ captions,+ combineTokensWithinMilliseconds = 1500,+ holdMs = DEFAULT_HOLD_MS,+ fontSize = 64,+ fontWeight = 800,+ color = "#ffffff",+ visibleLines = 3,+ pastOpacity = 0.35,+ futureOpacity = 0.35,+ upcomingOpacity = 0.55,+ shadow = true,+ className,+}: CaptionTeleprompterProps) {+ const frame = useCurrentFrame();+ const { fps } = useVideoConfig();+ const timeMs = (frame / fps) * 1000;+ const lines = useMemo(+ () =>+ buildCaptionPages(captions, {+ combineTokensWithinMilliseconds,+ holdMs,+ }).map((line) => ({ ...line, words: lineWords(line.page) })),+ [captions, combineTokensWithinMilliseconds, holdMs],+ );+ const { wordRef: lineRef, rects } = useCaptionWordRects(0, lines.length);++ const step = (LINE_HEIGHT + LINE_GAP_EM) * fontSize;+ const windowHeight = visibleLines * step;+ const center = (i: number): number => {+ const rect = rects?.[i];+ return rect+ ? rect.top + rect.height / 2+ : i * step + (LINE_HEIGHT * fontSize) / 2;+ };++ const scrollMsAt = (i: number): number => {+ const before =+ i > 0+ ? lines[i].startMs - lines[i - 1].startMs+ : Number.POSITIVE_INFINITY;+ const after =+ i < lines.length - 1+ ? lines[i + 1].startMs - lines[i].startMs+ : Number.POSITIVE_INFINITY;+ return Math.max(1, Math.min(SCROLL_MS, before, after));+ };+ let k = -1;+ lines.forEach((line, i) => {+ if (line.startMs - scrollMsAt(i) / 2 <= timeMs) k = i;+ });+ const scrollMs = k > 0 ? scrollMsAt(k) : SCROLL_MS;+ const progress =+ k <= 0+ ? 1+ : interpolate(+ timeMs - (lines[k].startMs - scrollMs / 2),+ [0, scrollMs],+ [0, 1],+ { ...clamp, easing: scrollEasing },+ );+ const focus = Math.max(k, 0);+ const centerY =+ lines.length === 0+ ? 0+ : k <= 0+ ? center(0)+ : center(k - 1) + (center(k) - center(k - 1)) * progress;++ return (+ <div+ className={className}+ style={{+ position: "relative",+ height: windowHeight,+ fontSize,+ fontWeight,+ color,+ textAlign: "center",+ overflow: "hidden",+ maskImage: edgeFade(visibleLines),+ WebkitMaskImage: edgeFade(visibleLines),+ }}+ >+ <div+ style={{+ position: "absolute",+ left: 0,+ right: 0,+ top: 0,+ transform: `translateY(${windowHeight / 2 - centerY}px)`,+ }}+ >+ {lines.map((line, i) => {+ const weight =+ i === focus ? progress : i === focus - 1 ? 1 - progress : 0;+ const rest = i < focus ? pastOpacity : futureOpacity;+ return (+ <div+ key={line.index}+ ref={lineRef(i)}+ style={{+ lineHeight: LINE_HEIGHT,+ marginBottom: `${LINE_GAP_EM}em`,+ textShadow: shadow ? LEGIBILITY_SHADOW : undefined,+ }}+ >+ {line.words.map((word, w) => {+ const lit = interpolate(+ timeMs - word.fromMs,+ [-LIGHT_MS, 0],+ [upcomingOpacity, 1],+ clamp,+ );+ return (+ <Fragment key={word.key}>+ {w > 0 && " "}+ <span style={{ opacity: rest + (lit - rest) * weight }}>+ {word.text}+ </span>+ </Fragment>+ );+ })}+ </div>+ );+ })}+ </div>+ </div>+ );+}diff --git a/registry/remocn/caption-timeline/config.ts b/registry/remocn/caption-timeline/config.tsnew file mode 100644index 00000000..4a76735a--- /dev/null+++ b/registry/remocn/caption-timeline/config.ts@@ -0,0 +1,101 @@+import {+ CAPTION_FIXTURE,+ previewCaptionsDuration,+ previewTailMs,+} from "@/components/docs/examples/caption-fixture";+import { captionTimelineExampleCode } from "@/components/docs/examples/caption-timeline-example";+import { type ComponentConfig, FPS, H, W } from "@/lib/customizer-config";++export const captionTimelineConfig: ComponentConfig = {+ componentName: "CaptionTimeline",+ importPath: "@/components/remocn/caption-timeline",+ controls: {+ captions: {+ type: "remotion-captions",+ default: CAPTION_FIXTURE,+ description: "Transcript",+ keyframable: false,+ },+ fontSize: {+ type: "number",+ min: 24,+ max: 140,+ step: 1,+ default: 64,+ description: "Font size",+ hiddenFromList: false,+ },+ fontWeight: {+ type: "number",+ min: 400,+ max: 900,+ step: 100,+ default: 800,+ description: "Font weight",+ hiddenFromList: false,+ },+ color: {+ type: "color",+ default: "#ffffff",+ description: "Text color",+ },+ playheadColor: {+ type: "color",+ default: "#facc15",+ description: "Playhead color",+ },+ width: {+ type: "number",+ min: 400,+ max: 1800,+ step: 10,+ default: 1100,+ description: "Strip width (px)",+ hiddenFromList: false,+ },+ pxPerSecond: {+ type: "number",+ min: 100,+ max: 600,+ step: 10,+ default: 260,+ description: "Pixels per second",+ hiddenFromList: false,+ },+ playheadPosition: {+ type: "number",+ min: 0.1,+ max: 0.9,+ step: 0.05,+ default: 0.35,+ description: "Playhead position",+ hiddenFromList: false,+ },+ upcomingOpacity: {+ type: "number",+ min: 0,+ max: 1,+ step: 0.05,+ default: 0.4,+ description: "Upcoming opacity",+ hiddenFromList: false,+ },+ shadow: {+ type: "boolean",+ default: true,+ description: "Shadow",+ },+ },+ durationInFrames: previewCaptionsDuration(undefined, FPS),+ getDurationInFrames: (values) =>+ previewCaptionsDuration(+ typeof values.captions === "string" ? values.captions : undefined,+ FPS,+ previewTailMs(values.holdMs),+ ),+ fps: FPS,+ compositionWidth: W,+ compositionHeight: H,+ previewBackdrop: { type: "color", value: "#262626" },+ snippet: captionTimelineExampleCode,+};diff --git a/registry/remocn/caption-timeline/index.tsx b/registry/remocn/caption-timeline/index.tsxnew file mode 100644index 00000000..ea6f214d--- /dev/null+++ b/registry/remocn/caption-timeline/index.tsx@@ -0,0 +1,201 @@+"use client";++import type { Caption } from "@remotion/captions";+import { useLayoutEffect, useMemo, useRef, useState } from "react";+import { interpolate, useCurrentFrame, useVideoConfig } from "remotion";+import type { CaptionBaseProps } from "@/lib/remocn/caption-core";++export interface CaptionTimelineProps extends CaptionBaseProps {+ width?: number;+ pxPerSecond?: number;+ playheadPosition?: number;+ playheadColor?: string;+ upcomingOpacity?: number;+ shadow?: boolean;+}++interface TimelineWord {+ id: number;+ text: string;+ startMs: number;+ endMs: number;+}++const LINE_HEIGHT = 1.3;+const GAP_EM = 0.32;+const LIGHT_MS = 80;+const EDGE_FADE =+ "linear-gradient(to right, transparent, #000 12%, #000 88%, transparent)";+const LEGIBILITY_SHADOW =+ "0 2px 3px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.35)";++const clamp = {+ extrapolateLeft: "clamp",+ extrapolateRight: "clamp",+} as const;++export function getTimelineWords(captions: Caption[]): TimelineWord[] {+ const words: TimelineWord[] = [];+ for (const caption of captions) {+ if (caption.text.trim() === "") continue;+ const last = words[words.length - 1];+ if (last && !/^\s/.test(caption.text)) {+ last.text += caption.text;+ last.endMs = caption.endMs;+ } else {+ words.push({+ id: words.length,+ text: caption.text.trim(),+ startMs: caption.startMs,+ endMs: caption.endMs,+ });+ }+ }+ return words;+}++export function layoutTimeline(+ words: TimelineWord[],+ widths: number[],+ pxPerSecond: number,+ gap: number,+): number[] {+ const xs: number[] = [];+ words.forEach((word, i) => {+ const ideal = (word.startMs / 1000) * pxPerSecond;+ xs.push(i === 0 ? ideal : Math.max(ideal, xs[i - 1] + widths[i - 1] + gap));+ });+ return xs;+}++export function timelineOffset(+ words: TimelineWord[],+ xs: number[],+ timeMs: number,+ pxPerSecond: number,+): number {+ if (words.length === 0) return (timeMs / 1000) * pxPerSecond;+ let i = -1;+ while (i + 1 < words.length && words[i + 1].startMs <= timeMs) i++;+ if (i === -1) {+ return xs[0] - ((words[0].startMs - timeMs) / 1000) * pxPerSecond;+ }+ const next = words[i + 1];+ if (!next) {+ return xs[i] + ((timeMs - words[i].startMs) / 1000) * pxPerSecond;+ }+ const span = next.startMs - words[i].startMs;+ const t = span > 0 ? (timeMs - words[i].startMs) / span : 1;+ return xs[i] + (xs[i + 1] - xs[i]) * t;+}++function sameWidths(a: number[], b: number[]): boolean {+ return a.length === b.length && a.every((w, i) => w === b[i]);+}++export function CaptionTimeline({+ captions,+ fontSize = 64,+ fontWeight = 800,+ color = "#ffffff",+ width = 1100,+ pxPerSecond = 260,+ playheadPosition = 0.35,+ playheadColor = "#facc15",+ upcomingOpacity = 0.4,+ shadow = true,+ className,+}: CaptionTimelineProps) {+ const frame = useCurrentFrame();+ const { fps } = useVideoConfig();+ const timeMs = (frame / fps) * 1000;+ const words = useMemo(() => getTimelineWords(captions), [captions]);+ const elements = useRef<(HTMLSpanElement | null)[]>([]);+ const [widths, setWidths] = useState<number[]>([]);++ useLayoutEffect(() => {+ const measured = words.map((_, i) => elements.current[i]?.offsetWidth ?? 0);+ setWidths((prev) => (sameWidths(prev, measured) ? prev : measured));+ });++ const gap = fontSize * GAP_EM;+ const resolved =+ widths.length === words.length+ ? widths+ : words.map((word) => word.text.length * fontSize * 0.55);+ const xs = layoutTimeline(words, resolved, pxPerSecond, gap);+ const playheadX = width * playheadPosition;+ const offset = timelineOffset(words, xs, timeMs, pxPerSecond);+ const thickness = Math.max(2, Math.round(fontSize * 0.04));++ if (words.length === 0) return null;++ return (+ <div+ className={className}+ style={{+ position: "relative",+ width,+ height: `${LINE_HEIGHT}em`,+ fontSize,+ fontWeight,+ color,+ lineHeight: LINE_HEIGHT,+ }}+ >+ <div+ style={{+ position: "absolute",+ inset: 0,+ overflow: "hidden",+ maskImage: EDGE_FADE,+ WebkitMaskImage: EDGE_FADE,+ }}+ >+ <div+ style={{+ position: "absolute",+ inset: 0,+ transform: `translateX(${playheadX - offset}px)`,+ }}+ >+ {words.map((word, i) => (+ <span+ key={word.id}+ ref={(el) => {+ elements.current[i] = el;+ }}+ style={{+ position: "absolute",+ left: xs[i],+ top: 0,+ whiteSpace: "nowrap",+ opacity: interpolate(+ timeMs - word.startMs,+ [-LIGHT_MS, 0],+ [upcomingOpacity, 1],+ clamp,+ ),+ textShadow: shadow ? LEGIBILITY_SHADOW : undefined,+ }}+ >+ {word.text}+ </span>+ ))}+ </div>+ </div>+ <div+ aria-hidden+ style={{+ position: "absolute",+ top: "8%",+ bottom: "8%",+ left: playheadX - thickness / 2,+ width: thickness,+ borderRadius: thickness,+ background: playheadColor,+ }}+ />+ </div>+ );+}diff --git a/registry/remocn/caption-typewriter/config.ts b/registry/remocn/caption-typewriter/config.tsnew file mode 100644index 00000000..dd3b0be4--- /dev/null+++ b/registry/remocn/caption-typewriter/config.ts@@ -0,0 +1,83 @@+import {+ CAPTION_FIXTURE,+ previewCaptionsDuration,+ previewTailMs,+} from "@/components/docs/examples/caption-fixture";+import { captionTypewriterExampleCode } from "@/components/docs/examples/caption-typewriter-example";+import { type ComponentConfig, FPS, H, W } from "@/lib/customizer-config";++export const captionTypewriterConfig: ComponentConfig = {+ componentName: "CaptionTypewriter",+ importPath: "@/components/remocn/caption-typewriter",+ controls: {+ captions: {+ type: "remotion-captions",+ default: CAPTION_FIXTURE,+ description: "Transcript",+ keyframable: false,+ },+ fontSize: {+ type: "number",+ min: 24,+ max: 140,+ step: 1,+ default: 64,+ description: "Font size",+ hiddenFromList: false,+ },+ fontWeight: {+ type: "number",+ min: 400,+ max: 900,+ step: 100,+ default: 800,+ description: "Font weight",+ hiddenFromList: false,+ },+ color: {+ type: "color",+ default: "#ffffff",+ description: "Text color",+ },+ combineTokensWithinMilliseconds: {+ type: "number",+ min: 0,+ max: 3000,+ step: 100,+ default: 1200,+ description: "Page window (ms)",+ hiddenFromList: false,+ },+ holdMs: {+ type: "number",+ min: 0,+ max: 2000,+ step: 50,+ default: 600,+ description: "Hold (ms)",+ hiddenFromList: false,+ },+ caret: {+ type: "boolean",+ default: true,+ description: "Caret",+ },+ shadow: {+ type: "boolean",+ default: true,+ description: "Shadow",+ },+ },+ durationInFrames: previewCaptionsDuration(undefined, FPS),+ getDurationInFrames: (values) =>+ previewCaptionsDuration(+ typeof values.captions === "string" ? values.captions : undefined,+ FPS,+ previewTailMs(values.holdMs),+ ),+ fps: FPS,+ compositionWidth: W,+ compositionHeight: H,+ previewBackdrop: { type: "color", value: "#262626" },+ snippet: captionTypewriterExampleCode,+};diff --git a/registry/remocn/caption-typewriter/index.tsx b/registry/remocn/caption-typewriter/index.tsxnew file mode 100644index 00000000..2e537a63--- /dev/null+++ b/registry/remocn/caption-typewriter/index.tsx@@ -0,0 +1,119 @@+"use client";++import { Fragment } from "react";+import { interpolate } from "remotion";+import {+ type CaptionBaseProps,+ DEFAULT_HOLD_MS,+ getExitWindowMs,+ groupCaptionWords,+ useCaptions,+} from "@/lib/remocn/caption-core";++export interface CaptionTypewriterProps extends CaptionBaseProps {+ caret?: boolean;+ shadow?: boolean;+}++const EXIT_MS = 220;+const BLINK_MS = 500;+const LEGIBILITY_SHADOW =+ "0 2px 3px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.35)";+const CARET_SHADOW = "0 2px 6px rgba(0, 0, 0, 0.45)";++function typedCount(text: string, progress: number): number {+ const length = Array.from(text).length;+ return Math.min(length, Math.ceil(progress * length));+}++export function CaptionTypewriter({+ captions,+ combineTokensWithinMilliseconds = 1200,+ holdMs = DEFAULT_HOLD_MS,+ fontSize = 64,+ fontWeight = 800,+ color = "#ffffff",+ caret = true,+ shadow = true,+ className,+}: CaptionTypewriterProps) {+ const state = useCaptions({+ captions,+ combineTokensWithinMilliseconds,+ holdMs,+ });+ if (!state) return null;++ const exit = state.endsInSilence+ ? interpolate(+ state.untilEndMs,+ [0, getExitWindowMs(state, EXIT_MS)],+ [0, 1],+ {+ extrapolateLeft: "clamp",+ extrapolateRight: "clamp",+ },+ )+ : 1;++ const active = state.tokens[state.activeIndex];+ const typing = active !== undefined && active.progress < 1;+ const idleMs = active ? state.timeMs - active.toMs : 0;+ const caretOn = typing || Math.floor(idleMs / BLINK_MS) % 2 === 0;++ return (+ <div+ className={className}+ style={{+ fontSize,+ fontWeight,+ color,+ lineHeight: 1.2,+ textAlign: "center",+ opacity: exit,+ }}+ >+ {groupCaptionWords(state.tokens).map((word, w) => (+ <Fragment key={`${state.pageIndex}-${word[0].index}`}>+ {w > 0 && " "}+ <span style={{ display: "inline-block", whiteSpace: "nowrap" }}>+ {word.map(({ index, token }) => {+ const chars = Array.from(token.text);+ const typed = typedCount(token.text, token.progress);+ return (+ <Fragment key={index}>+ <span+ style={{+ textShadow: shadow ? LEGIBILITY_SHADOW : undefined,+ }}+ >+ {chars.slice(0, typed).join("")}+ </span>+ {caret && index === state.activeIndex ? (+ <span style={{ position: "relative" }}>+ <span+ style={{+ position: "absolute",+ left: "0.03em",+ top: "0.1em",+ bottom: "0.1em",+ width: "0.07em",+ backgroundColor: color,+ boxShadow: shadow ? CARET_SHADOW : undefined,+ opacity: caretOn ? 1 : 0,+ }}+ />+ </span>+ ) : null}+ <span aria-hidden style={{ color: "transparent" }}>+ {chars.slice(typed).join("")}+ </span>+ </Fragment>+ );+ })}+ </span>+ </Fragment>+ ))}+ </div>+ );+}diff --git a/registry/remocn/caption-underline/config.ts b/registry/remocn/caption-underline/config.tsnew file mode 100644index 00000000..dd3e5c0b--- /dev/null+++ b/registry/remocn/caption-underline/config.ts@@ -0,0 +1,101 @@+import {+ CAPTION_FIXTURE,+ previewCaptionsDuration,+ previewTailMs,+} from "@/components/docs/examples/caption-fixture";+import { captionUnderlineExampleCode } from "@/components/docs/examples/caption-underline-example";+import { type ComponentConfig, FPS, H, W } from "@/lib/customizer-config";++export const captionUnderlineConfig: ComponentConfig = {+ componentName: "CaptionUnderline",+ importPath: "@/components/remocn/caption-underline",+ controls: {+ captions: {+ type: "remotion-captions",+ default: CAPTION_FIXTURE,+ description: "Transcript",+ keyframable: false,+ },+ fontSize: {+ type: "number",+ min: 24,+ max: 140,+ step: 1,+ default: 64,+ description: "Font size",+ hiddenFromList: false,+ },+ fontWeight: {+ type: "number",+ min: 400,+ max: 900,+ step: 100,+ default: 800,+ description: "Font weight",+ hiddenFromList: false,+ },+ color: {+ type: "color",+ default: "#ffffff",+ description: "Text color",+ },+ underlineColor: {+ type: "color",+ default: "#facc15",+ description: "Underline color",+ },+ thickness: {+ type: "number",+ min: 0.02,+ max: 0.3,+ step: 0.01,+ default: 0.08,+ description: "Thickness (em)",+ hiddenFromList: false,+ },+ underlineOffset: {+ type: "number",+ min: -0.2,+ max: 0.4,+ step: 0.01,+ default: 0.02,+ description: "Offset (em)",+ hiddenFromList: false,+ },+ combineTokensWithinMilliseconds: {+ type: "number",+ min: 0,+ max: 3000,+ step: 100,+ default: 1200,+ description: "Page window (ms)",+ hiddenFromList: false,+ },+ holdMs: {+ type: "number",+ min: 0,+ max: 2000,+ step: 50,+ default: 600,+ description: "Hold (ms)",+ hiddenFromList: false,+ },+ shadow: {+ type: "boolean",+ default: true,+ description: "Shadow",+ },+ },+ durationInFrames: previewCaptionsDuration(undefined, FPS),+ getDurationInFrames: (values) =>+ previewCaptionsDuration(+ typeof values.captions === "string" ? values.captions : undefined,+ FPS,+ previewTailMs(values.holdMs),+ ),+ fps: FPS,+ compositionWidth: W,+ compositionHeight: H,+ previewBackdrop: { type: "color", value: "#262626" },+ snippet: captionUnderlineExampleCode,+};diff --git a/registry/remocn/caption-underline/index.tsx b/registry/remocn/caption-underline/index.tsxnew file mode 100644index 00000000..acda25f6--- /dev/null+++ b/registry/remocn/caption-underline/index.tsx@@ -0,0 +1,168 @@+"use client";++import { Fragment } from "react";+import { Easing, interpolate } from "remotion";+import {+ type CaptionBaseProps,+ DEFAULT_HOLD_MS,+ getExitWindowMs,+ groupCaptionWords,+ useCaptions,+ useCaptionWordRects,+} from "@/lib/remocn/caption-core";++export interface CaptionUnderlineProps extends CaptionBaseProps {+ underlineColor?: string;+ thickness?: number;+ underlineOffset?: number;+ shadow?: boolean;+}++const ENTER_MS = 160;+const EXIT_MS = 220;+const RISE_EM = 0.14;+const TRAVEL_MS = 120;+const LEGIBILITY_SHADOW =+ "0 2px 3px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.35)";++const enterEasing = Easing.bezier(0.2, 0.8, 0.2, 1);+const travelEasing = Easing.bezier(0.3, 0, 0.2, 1);++const clamp = {+ extrapolateLeft: "clamp",+ extrapolateRight: "clamp",+} as const;++function mix(a: number, b: number, t: number): number {+ return a + (b - a) * t;+}++export function CaptionUnderline({+ captions,+ combineTokensWithinMilliseconds = 1200,+ holdMs = DEFAULT_HOLD_MS,+ fontSize = 64,+ fontWeight = 800,+ color = "#ffffff",+ underlineColor = "#facc15",+ thickness = 0.08,+ underlineOffset = 0.02,+ shadow = true,+ className,+}: CaptionUnderlineProps) {+ const state = useCaptions({+ captions,+ combineTokensWithinMilliseconds,+ holdMs,+ });+ const words = state ? groupCaptionWords(state.tokens) : [];+ const pageIndex = state ? state.pageIndex : -1;+ const { wordRef, rects } = useCaptionWordRects(pageIndex, words.length);++ if (!state) return null;++ const enter = interpolate(+ state.previous ? ENTER_MS : state.sinceStartMs,+ [0, ENTER_MS],+ [0, 1],+ {+ ...clamp,+ easing: enterEasing,+ },+ );+ const exit = state.endsInSilence+ ? interpolate(+ state.untilEndMs,+ [0, getExitWindowMs(state, EXIT_MS)],+ [0, 1],+ clamp,+ )+ : 1;++ const activeWord = words.findIndex((word) =>+ word.some(({ index }) => index === state.activeIndex),+ );+ const travel =+ activeWord >= 0+ ? interpolate(+ state.timeMs - words[activeWord][0].token.fromMs,+ [0, TRAVEL_MS],+ [0, 1],+ { ...clamp, easing: travelEasing },+ )+ : 0;++ const target = rects && activeWord >= 0 ? rects[activeWord] : null;+ const origin = rects && activeWord > 0 ? rects[activeWord - 1] : null;+ const barHeight = thickness * fontSize;+ const gap = underlineOffset * fontSize;+ const bar = target+ ? origin+ ? {+ left: mix(origin.left, target.left, travel),+ top: mix(+ origin.top + origin.height,+ target.top + target.height,+ travel,+ ),+ width: mix(origin.width, target.width, travel),+ opacity: 1,+ }+ : {+ left: target.left,+ top: target.top + target.height,+ width: target.width * travel,+ opacity: travel,+ }+ : null;++ return (+ <div+ className={className}+ style={{+ position: "relative",+ fontSize,+ fontWeight,+ color,+ lineHeight: 1.2,+ textAlign: "center",+ opacity: Math.min(enter, exit),+ transform: `translateY(${(1 - enter) * RISE_EM}em)`,+ }}+ >+ {words.map((word, w) => (+ <Fragment key={`${state.pageIndex}-${word[0].index}`}>+ {w > 0 && " "}+ <span+ ref={wordRef(w)}+ style={{+ position: "relative",+ display: "inline-block",+ whiteSpace: "nowrap",+ textShadow: shadow ? LEGIBILITY_SHADOW : undefined,+ }}+ >+ {word.map(({ index, token }) => (+ <span key={index}>{token.text}</span>+ ))}+ </span>+ </Fragment>+ ))}+ {bar && (+ <span+ aria-hidden+ style={{+ position: "absolute",+ left: bar.left,+ top: bar.top + gap,+ width: bar.width,+ height: barHeight,+ borderRadius: barHeight / 2,+ background: underlineColor,+ opacity: bar.opacity,+ }}+ />+ )}+ </div>+ );+}diff --git a/registry/remocn/caption-weight/config.ts b/registry/remocn/caption-weight/config.tsnew file mode 100644index 00000000..2e99a93b--- /dev/null+++ b/registry/remocn/caption-weight/config.ts@@ -0,0 +1,87 @@+import {+ CAPTION_FIXTURE,+ previewCaptionsDuration,+ previewTailMs,+} from "@/components/docs/examples/caption-fixture";+import { captionWeightExampleCode } from "@/components/docs/examples/caption-weight-example";+import { type ComponentConfig, FPS, H, W } from "@/lib/customizer-config";++export const captionWeightConfig: ComponentConfig = {+ componentName: "CaptionWeight",+ importPath: "@/components/remocn/caption-weight",+ controls: {+ captions: {+ type: "remotion-captions",+ default: CAPTION_FIXTURE,+ description: "Transcript",+ keyframable: false,+ },+ fontSize: {+ type: "number",+ min: 24,+ max: 140,+ step: 1,+ default: 64,+ description: "Font size",+ hiddenFromList: false,+ },+ fontWeight: {+ type: "number",+ min: 100,+ max: 900,+ step: 100,+ default: 400,+ description: "Resting weight",+ hiddenFromList: false,+ },+ activeWeight: {+ type: "number",+ min: 100,+ max: 900,+ step: 100,+ default: 900,+ description: "Active weight",+ hiddenFromList: false,+ },+ color: {+ type: "color",+ default: "#ffffff",+ description: "Text color",+ },+ combineTokensWithinMilliseconds: {+ type: "number",+ min: 0,+ max: 3000,+ step: 100,+ default: 1200,+ description: "Page window (ms)",+ hiddenFromList: false,+ },+ holdMs: {+ type: "number",+ min: 0,+ max: 2000,+ step: 50,+ default: 600,+ description: "Hold (ms)",+ hiddenFromList: false,+ },+ shadow: {+ type: "boolean",+ default: true,+ description: "Shadow",+ },+ },+ durationInFrames: previewCaptionsDuration(undefined, FPS),+ getDurationInFrames: (values) =>+ previewCaptionsDuration(+ typeof values.captions === "string" ? values.captions : undefined,+ FPS,+ previewTailMs(values.holdMs),+ ),+ fps: FPS,+ compositionWidth: W,+ compositionHeight: H,+ previewBackdrop: { type: "color", value: "#262626" },+ snippet: captionWeightExampleCode,+};diff --git a/registry/remocn/caption-weight/index.tsx b/registry/remocn/caption-weight/index.tsxnew file mode 100644index 00000000..2f4c373f--- /dev/null+++ b/registry/remocn/caption-weight/index.tsx@@ -0,0 +1,146 @@+"use client";++import { Fragment } from "react";+import { Easing, interpolate } from "remotion";+import {+ type CaptionBaseProps,+ captionWordText,+ DEFAULT_HOLD_MS,+ getExitWindowMs,+ groupCaptionWords,+ useCaptions,+} from "@/lib/remocn/caption-core";++export interface CaptionWeightProps extends CaptionBaseProps {+ activeWeight?: number;+ shadow?: boolean;+}++const ENTER_MS = 160;+const EXIT_MS = 220;+const RISE_EM = 0.14;+const RAMP_MS = 150;+const RELEASE_MS = 220;+const LEGIBILITY_SHADOW =+ "0 2px 3px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.35)";++const enterEasing = Easing.bezier(0.2, 0.8, 0.2, 1);+const rampEasing = Easing.bezier(0.2, 0.8, 0.3, 1);+const releaseEasing = Easing.bezier(0.4, 0, 0.2, 1);++const clamp = {+ extrapolateLeft: "clamp",+ extrapolateRight: "clamp",+} as const;++export function CaptionWeight({+ captions,+ combineTokensWithinMilliseconds = 1200,+ holdMs = DEFAULT_HOLD_MS,+ fontSize = 64,+ fontWeight = 400,+ activeWeight = 900,+ color = "#ffffff",+ shadow = true,+ className,+}: CaptionWeightProps) {+ const state = useCaptions({+ captions,+ combineTokensWithinMilliseconds,+ holdMs,+ });+ if (!state) return null;++ const enter = interpolate(+ state.previous ? ENTER_MS : state.sinceStartMs,+ [0, ENTER_MS],+ [0, 1],+ {+ ...clamp,+ easing: enterEasing,+ },+ );+ const exit = state.endsInSilence+ ? interpolate(+ state.untilEndMs,+ [0, getExitWindowMs(state, EXIT_MS)],+ [0, 1],+ clamp,+ )+ : 1;++ const words = groupCaptionWords(state.tokens);+ const activeWord = words.findIndex((word) =>+ word.some(({ index }) => index === state.activeIndex),+ );++ const emphasis = (w: number): number => {+ if (activeWord < 0 || w > activeWord) return 0;+ const startMs = words[w][0].token.fromMs;+ const rise = interpolate(state.timeMs - startMs, [0, RAMP_MS], [0, 1], {+ ...clamp,+ easing: rampEasing,+ });+ if (w === activeWord) return rise;+ const releaseMs = words[w + 1][0].token.fromMs;+ const peak = interpolate(releaseMs - startMs, [0, RAMP_MS], [0, 1], {+ ...clamp,+ easing: rampEasing,+ });+ const release = interpolate(+ state.timeMs - releaseMs,+ [0, RELEASE_MS],+ [0, 1],+ { ...clamp, easing: releaseEasing },+ );+ return peak * (1 - release);+ };++ return (+ <div+ className={className}+ style={{+ fontSize,+ fontWeight,+ color,+ lineHeight: 1.2,+ textAlign: "center",+ opacity: Math.min(enter, exit),+ transform: `translateY(${(1 - enter) * RISE_EM}em)`,+ }}+ >+ {words.map((word, w) => {+ const weight = fontWeight + (activeWeight - fontWeight) * emphasis(w);+ return (+ <Fragment key={`${state.pageIndex}-${word[0].index}`}>+ {w > 0 && " "}+ <span style={{ display: "inline-grid", whiteSpace: "nowrap" }}>+ <span+ aria-hidden+ style={{+ gridArea: "1 / 1",+ fontWeight: Math.max(fontWeight, activeWeight),+ visibility: "hidden",+ }}+ >+ {captionWordText(word)}+ </span>+ <span+ style={{+ gridArea: "1 / 1",+ justifySelf: "center",+ fontWeight: weight,+ textShadow: shadow ? LEGIBILITY_SHADOW : undefined,+ }}+ >+ {word.map(({ index, token }) => (+ <span key={index}>{token.text}</span>+ ))}+ </span>+ </span>+ </Fragment>+ );+ })}+ </div>+ );+}diff --git a/registry/remocn/caption-word-pop/config.ts b/registry/remocn/caption-word-pop/config.tsnew file mode 100644index 00000000..6c06d4db--- /dev/null+++ b/registry/remocn/caption-word-pop/config.ts@@ -0,0 +1,87 @@+import {+ CAPTION_FIXTURE,+ previewCaptionsDuration,+ previewTailMs,+} from "@/components/docs/examples/caption-fixture";+import { captionWordPopExampleCode } from "@/components/docs/examples/caption-word-pop-example";+import { type ComponentConfig, FPS, H, W } from "@/lib/customizer-config";++export const captionWordPopConfig: ComponentConfig = {+ componentName: "CaptionWordPop",+ importPath: "@/components/remocn/caption-word-pop",+ controls: {+ captions: {+ type: "remotion-captions",+ default: CAPTION_FIXTURE,+ description: "Transcript",+ keyframable: false,+ },+ fontSize: {+ type: "number",+ min: 24,+ max: 220,+ step: 1,+ default: 96,+ description: "Font size",+ hiddenFromList: false,+ },+ fontWeight: {+ type: "number",+ min: 400,+ max: 900,+ step: 100,+ default: 800,+ description: "Font weight",+ hiddenFromList: false,+ },+ color: {+ type: "color",+ default: "#ffffff",+ description: "Text color",+ },+ popScale: {+ type: "number",+ min: 0.2,+ max: 1,+ step: 0.05,+ default: 0.6,+ description: "Start scale",+ hiddenFromList: false,+ },+ combineTokensWithinMilliseconds: {+ type: "number",+ min: 0,+ max: 3000,+ step: 100,+ default: 0,+ description: "Page window (ms)",+ hiddenFromList: false,+ },+ holdMs: {+ type: "number",+ min: 0,+ max: 2000,+ step: 50,+ default: 600,+ description: "Hold (ms)",+ hiddenFromList: false,+ },+ shadow: {+ type: "boolean",+ default: true,+ description: "Shadow",+ },+ },+ durationInFrames: previewCaptionsDuration(undefined, FPS),+ getDurationInFrames: (values) =>+ previewCaptionsDuration(+ typeof values.captions === "string" ? values.captions : undefined,+ FPS,+ previewTailMs(values.holdMs),+ ),+ fps: FPS,+ compositionWidth: W,+ compositionHeight: H,+ previewBackdrop: { type: "color", value: "#262626" },+ snippet: captionWordPopExampleCode,+};diff --git a/registry/remocn/caption-word-pop/index.tsx b/registry/remocn/caption-word-pop/index.tsxnew file mode 100644index 00000000..77515be7--- /dev/null+++ b/registry/remocn/caption-word-pop/index.tsx@@ -0,0 +1,92 @@+"use client";++import { Fragment } from "react";+import { interpolate, spring, useVideoConfig } from "remotion";+import {+ type CaptionBaseProps,+ DEFAULT_HOLD_MS,+ getExitWindowMs,+ groupCaptionWords,+ useCaptions,+} from "@/lib/remocn/caption-core";++export interface CaptionWordPopProps extends CaptionBaseProps {+ popScale?: number;+ shadow?: boolean;+}++const FADE_MS = 50;+const EXIT_MS = 180;+const LEGIBILITY_SHADOW =+ "0 2px 3px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.35)";++const POP_SPRING = { damping: 11, stiffness: 240, mass: 0.6 };++const clamp = {+ extrapolateLeft: "clamp",+ extrapolateRight: "clamp",+} as const;++export function CaptionWordPop({+ captions,+ combineTokensWithinMilliseconds = 0,+ holdMs = DEFAULT_HOLD_MS,+ fontSize = 96,+ fontWeight = 800,+ color = "#ffffff",+ popScale = 0.6,+ shadow = true,+ className,+}: CaptionWordPopProps) {+ const { fps } = useVideoConfig();+ const state = useCaptions({+ captions,+ combineTokensWithinMilliseconds,+ holdMs,+ });+ if (!state) return null;++ const pop = spring({+ frame: (state.sinceStartMs / 1000) * fps,+ fps,+ config: POP_SPRING,+ });+ const fadeIn = state.previous+ ? 1+ : interpolate(state.sinceStartMs, [0, FADE_MS], [0, 1], clamp);+ const exit = state.endsInSilence+ ? interpolate(+ state.untilEndMs,+ [0, getExitWindowMs(state, EXIT_MS)],+ [0, 1],+ clamp,+ )+ : 1;++ return (+ <div+ className={className}+ style={{+ fontSize,+ fontWeight,+ color,+ lineHeight: 1.1,+ textAlign: "center",+ opacity: Math.min(fadeIn, exit),+ transform: `scale(${popScale + (1 - popScale) * pop})`,+ textShadow: shadow ? LEGIBILITY_SHADOW : undefined,+ }}+ >+ {groupCaptionWords(state.tokens).map((word, w) => (+ <Fragment key={`${state.pageIndex}-${word[0].index}`}>+ {w > 0 && " "}+ <span style={{ display: "inline-block", whiteSpace: "nowrap" }}>+ {word.map(({ index, token }) => (+ <span key={index}>{token.text}</span>+ ))}+ </span>+ </Fragment>+ ))}+ </div>+ );+}diff --git a/registry/remocn/registry.json b/registry/remocn/registry.jsonindex ff19c09a..a39ad3eb 100644--- a/registry/remocn/registry.json+++ b/registry/remocn/registry.json@@ -2571,6 +2571,485 @@"target": "components/remocn/type-repeater.tsx"}]+ },+ {+ "name": "caption-core",+ "type": "registry:lib",+ "title": "Caption Core",+ "description": "The timing engine every caption style shares: pages a timed transcript, finds the word being spoken and how far into it the voice is, and decides when a page leaves the screen.",+ "dependencies": ["remotion", "@remotion/captions"],+ "files": [+ {+ "path": "caption-core/index.ts",+ "type": "registry:lib",+ "target": "lib/remocn/caption-core.ts"+ }+ ]+ },+ {+ "name": "caption-karaoke",+ "type": "registry:component",+ "title": "Caption Karaoke",+ "description": "Transcript captions where each word fills with colour left to right exactly as it is spoken, the whole phrase readable before the voice reaches it.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "caption-karaoke/index.tsx",+ "type": "registry:component",+ "target": "components/remocn/caption-karaoke.tsx"+ }+ ]+ },+ {+ "name": "caption-highlight-box",+ "type": "registry:component",+ "title": "Caption Highlight Box",+ "description": "A solid box travels behind the word being spoken, sliding from word to word as the voice moves on.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "caption-highlight-box/index.tsx",+ "type": "registry:component",+ "target": "components/remocn/caption-highlight-box.tsx"+ }+ ]+ },+ {+ "name": "caption-active-pop",+ "type": "registry:component",+ "title": "Caption Active Pop",+ "description": "The word being spoken turns to the accent colour and springs up in scale, then settles back as the voice moves on.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "caption-active-pop/index.tsx",+ "type": "registry:component",+ "target": "components/remocn/caption-active-pop.tsx"+ }+ ]+ },+ {+ "name": "caption-word-pop",+ "type": "registry:component",+ "title": "Caption Word Pop",+ "description": "One large word at a time, each popping in on a spring the moment it is spoken.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "caption-word-pop/index.tsx",+ "type": "registry:component",+ "target": "components/remocn/caption-word-pop.tsx"+ }+ ]+ },+ {+ "name": "caption-bounce-in",+ "type": "registry:component",+ "title": "Caption Bounce In",+ "description": "Each word springs up into place with a little overshoot the moment it is spoken, and the phrase builds word by word.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "caption-bounce-in/index.tsx",+ "type": "registry:component",+ "target": "components/remocn/caption-bounce-in.tsx"+ }+ ]+ },+ {+ "name": "caption-blur-in",+ "type": "registry:component",+ "title": "Caption Blur In",+ "description": "Each word resolves out of a soft blur the moment it is spoken, for captions that arrive quietly.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "caption-blur-in/index.tsx",+ "type": "registry:component",+ "target": "components/remocn/caption-blur-in.tsx"+ }+ ]+ },+ {+ "name": "caption-rise",+ "type": "registry:component",+ "title": "Caption Rise",+ "description": "Each word slides up out of a mask at its baseline the moment it is spoken, with no bounce and no scale.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "caption-rise/index.tsx",+ "type": "registry:component",+ "target": "components/remocn/caption-rise.tsx"+ }+ ]+ },+ {+ "name": "caption-typewriter",+ "type": "registry:component",+ "title": "Caption Typewriter",+ "description": "Each word types out character by character at the pace it is spoken, with a caret that blinks while the speaker pauses.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "caption-typewriter/index.tsx",+ "type": "registry:component",+ "target": "components/remocn/caption-typewriter.tsx"+ }+ ]+ },+ {+ "name": "caption-slot",+ "type": "registry:component",+ "title": "Caption Slot",+ "description": "One short line at a time, each new phrase rolling up into place as the previous one rolls out the top.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "caption-slot/index.tsx",+ "type": "registry:component",+ "target": "components/remocn/caption-slot.tsx"+ }+ ]+ },+ {+ "name": "caption-subtitle",+ "type": "registry:component",+ "title": "Caption Subtitle",+ "description": "Classic broadcast subtitles, a whole phrase on a translucent plate, with no word-level animation at all.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "caption-subtitle/index.tsx",+ "type": "registry:component",+ "target": "components/remocn/caption-subtitle.tsx"+ }+ ]+ },+ {+ "name": "caption-dim-progress",+ "type": "registry:component",+ "title": "Caption Dim Progress",+ "description": "The whole phrase sits on screen dimmed and each word brightens the moment it is spoken, with no motion at all.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "caption-dim-progress/index.tsx",+ "type": "registry:component",+ "target": "components/remocn/caption-dim-progress.tsx"+ }+ ]+ },+ {+ "name": "caption-underline",+ "type": "registry:component",+ "title": "Caption Underline",+ "description": "A bar slides under the word being spoken, travelling from word to word while the text itself stays untouched.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "caption-underline/index.tsx",+ "type": "registry:component",+ "target": "components/remocn/caption-underline.tsx"+ }+ ]+ },+ {+ "name": "caption-scramble",+ "type": "registry:component",+ "title": "Caption Scramble",+ "description": "Each word arrives as random glyphs at the moment it is spoken and decodes left to right into the real letters.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "caption-scramble/index.tsx",+ "type": "registry:component",+ "target": "components/remocn/caption-scramble.tsx"+ }+ ]+ },+ {+ "name": "caption-weight",+ "type": "registry:component",+ "title": "Caption Weight",+ "description": "The word being spoken swells from a light weight to a heavy one and relaxes as the voice moves on, with no layout shift.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "caption-weight/index.tsx",+ "type": "registry:component",+ "target": "components/remocn/caption-weight.tsx"+ }+ ]+ },+ {+ "name": "caption-emoji",+ "type": "registry:component",+ "title": "Caption Emoji",+ "description": "An emoji pops up above a chosen word the moment it is spoken and stays until the phrase leaves.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "caption-emoji/index.tsx",+ "type": "registry:component",+ "target": "components/remocn/caption-emoji.tsx"+ }+ ]+ },+ {+ "name": "caption-speaker",+ "type": "registry:component",+ "title": "Caption Speaker",+ "description": "Dialogue captions where every phrase takes its speaker's colour, so a conversation reads like a script.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "caption-speaker/index.tsx",+ "type": "registry:component",+ "target": "components/remocn/caption-speaker.tsx"+ }+ ]+ },+ {+ "name": "caption-stack",+ "type": "registry:component",+ "title": "Caption Stack",+ "description": "Kinetic captions stacked a couple of words per line, with the keyword of each page set large on its own line.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "caption-stack/index.tsx",+ "type": "registry:component",+ "target": "components/remocn/caption-stack.tsx"+ }+ ]+ },+ {+ "name": "caption-outline",+ "type": "registry:component",+ "title": "Caption Outline",+ "description": "Heavy-stroked captions that stay readable over any footage, with the spoken word switching to a contrast colour and nothing else moving.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "caption-outline/index.tsx",+ "type": "registry:component",+ "target": "components/remocn/caption-outline.tsx"+ }+ ]+ },+ {+ "name": "caption-marker",+ "type": "registry:component",+ "title": "Caption Marker",+ "description": "Plain captions where the words that matter get a highlighter swipe the moment they are spoken.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "caption-marker/index.tsx",+ "type": "registry:component",+ "target": "components/remocn/caption-marker.tsx"+ }+ ]+ },+ {+ "name": "caption-stamp",+ "type": "registry:component",+ "title": "Caption Stamp",+ "description": "Plain captions where the words that matter slam down as a rubber stamp the moment they are spoken.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "caption-stamp/index.tsx",+ "type": "registry:component",+ "target": "components/remocn/caption-stamp.tsx"+ }+ ]+ },+ {+ "name": "caption-handwrite",+ "type": "registry:component",+ "title": "Caption Handwrite",+ "description": "Each word is inked in by hand from left to right at the pace it is spoken, every word sitting at its own slight angle.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "caption-handwrite/index.tsx",+ "type": "registry:component",+ "target": "components/remocn/caption-handwrite.tsx"+ }+ ]+ },+ {+ "name": "caption-redact",+ "type": "registry:component",+ "title": "Caption Redact",+ "description": "The whole phrase starts blacked out like a declassified file, and each bar pulls away the moment its word is spoken.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "caption-redact/index.tsx",+ "type": "registry:component",+ "target": "components/remocn/caption-redact.tsx"+ }+ ]+ },+ {+ "name": "caption-prosody",+ "type": "registry:component",+ "title": "Caption Prosody",+ "description": "Word size follows the delivery, so drawn-out words land large and rushed words stay small, and the rhythm of the voice is visible with the sound off.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "caption-prosody/index.tsx",+ "type": "registry:component",+ "target": "components/remocn/caption-prosody.tsx"+ }+ ]+ },+ {+ "name": "caption-timeline",+ "type": "registry:component",+ "title": "Caption Timeline",+ "description": "The whole transcript laid out on a scrolling time strip that slides under a fixed playhead, so every pause shows up as space between words.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "caption-timeline/index.tsx",+ "type": "registry:component",+ "target": "components/remocn/caption-timeline.tsx"+ }+ ]+ },+ {+ "name": "caption-teleprompter",+ "type": "registry:component",+ "title": "Caption Teleprompter",+ "description": "The whole transcript scrolls smoothly through a short window with the current line centred, past lines fading above and the next line waiting below.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "caption-teleprompter/index.tsx",+ "type": "registry:component",+ "target": "components/remocn/caption-teleprompter.tsx"+ }+ ]+ },+ {+ "name": "caption-knockout",+ "type": "registry:component",+ "title": "Caption Knockout",+ "description": "A solid plate with the words cut clean through it, each word punching out the moment it is spoken so the footage shows through the letters.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "caption-knockout/index.tsx",+ "type": "registry:component",+ "target": "components/remocn/caption-knockout.tsx"+ }+ ]+ },+ {+ "name": "caption-slice",+ "type": "registry:component",+ "title": "Caption Slice",+ "description": "Each word arrives cut in two, the top half sliding in from the left and the bottom from the right, locking together the moment it is spoken.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "caption-slice/index.tsx",+ "type": "registry:component",+ "target": "components/remocn/caption-slice.tsx"+ }+ ]+ },+ {+ "name": "caption-cube",+ "type": "registry:component",+ "title": "Caption Cube",+ "description": "Each new phrase turns into view as the next face of a 3D cube, the previous phrase rotating up and away on a horizontal hinge.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "caption-cube/index.tsx",+ "type": "registry:component",+ "target": "components/remocn/caption-cube.tsx"+ }+ ]+ },+ {+ "name": "caption-split-flap",+ "type": "registry:component",+ "title": "Caption Split Flap",+ "description": "Every letter sits on its own flap tile and clatters through a few characters before landing the moment the word is spoken, like a station departure board.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "caption-split-flap/index.tsx",+ "type": "registry:component",+ "target": "components/remocn/caption-split-flap.tsx"+ }+ ]+ },+ {+ "name": "caption-label-maker",+ "type": "registry:component",+ "title": "Caption Label Maker",+ "description": "Each phrase is punched letter by letter into a strip of embossing tape at the pace it is spoken, the tape feeding out as the words arrive.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "caption-label-maker/index.tsx",+ "type": "registry:component",+ "target": "components/remocn/caption-label-maker.tsx"+ }+ ]+ },+ {+ "name": "caption-drop",+ "type": "registry:component",+ "title": "Caption Drop",+ "description": "Each word falls into place from above and bounces as it lands the moment it is spoken, and the whole phrase drops out of frame when the speaker pauses.",+ "dependencies": ["remotion", "@remotion/captions"],+ "registryDependencies": ["@remocn/caption-core"],+ "files": [+ {+ "path": "caption-drop/index.tsx",+ "type": "registry:component",+ "target": "components/remocn/caption-drop.tsx"+ }+ ]}]}diff --git a/scripts/build-elements.mts b/scripts/build-elements.mtsindex 9e90c0a2..6c5ed0e4 100644--- a/scripts/build-elements.mts+++ b/scripts/build-elements.mts@@ -26,6 +26,10 @@ const INLINABLE_LIBS: Record<string, { artifact: string; importPath: string }> =artifact: "canvas-presentation",importPath: "@/lib/remocn/canvas-presentation",},+ "@remocn/caption-core": {+ artifact: "caption-core",+ importPath: "@/lib/remocn/caption-core",+ },};interface RegistryItem {diff --git a/skills/remocn/SKILL.md b/skills/remocn/SKILL.mdindex 4f4ca4de..60188633 100644--- a/skills/remocn/SKILL.md+++ b/skills/remocn/SKILL.md@@ -182,7 +182,12 @@ Don't dump components — compose one story. When asked to build a full video ("`<TransitionSeries>` skeleton.4. **Pick each beat's component** from `https://remocn.dev/llms-components.txt`; match the `vibe` tagto the brand and budget its `Sequence` per Canvas & timing above.-5. **Check the quality bar** — one accent, sentence-case kinetic type, real content, no glow halos, no+5. **Caption the voice** — if the video has a voiceover or a talking head, transcribe it+ (`https://remocn.dev/docs/captions/getting-started/get-a-transcript.md`), pick a `caption-*` from the+ Captions table in the component index, and place it per+ `https://remocn.dev/docs/captions/getting-started/positioning.md`. Scripted on-screen text with no+ audio stays typography.+6. **Check the quality bar** — one accent, sentence-case kinetic type, real content, no glow halos, nofeature-list enumeration. See `references/anatomy.md` §3.## Referencediff --git a/source.tsx b/source.tsxindex 815e46aa..97f1d5bd 100644--- a/source.tsx+++ b/source.tsx@@ -2,6 +2,7 @@ import {ArtificialIntelligence04Icon,BlurIcon,BookOpen01Icon,+ ClosedCaptionIcon,ColorsIcon,DashboardSquare01Icon,GeometricShapes01Icon,@@ -24,6 +25,7 @@ const DOCS_ICONS: Record<string, IconSvgElement> = {ArtificialIntelligence04Icon,BlurIcon,BookOpen01Icon,+ ClosedCaptionIcon,ColorsIcon,DashboardSquare01Icon,GeometricShapes01Icon,diff --git a/tsconfig.json b/tsconfig.jsonindex b5b4a387..bc7ba164 100644--- a/tsconfig.json+++ b/tsconfig.json@@ -34,6 +34,7 @@"@/lib/remocn/canvas-presentation": ["./registry/remocn/canvas-presentation/index.tsx"],+ "@/lib/remocn/caption-core": ["./registry/remocn/caption-core/index.ts"],"@/components/remocn/brush": ["./registry/remocn/brush/index.tsx"],"@/components/remocn/handwrite": ["./registry/remocn/handwrite/index.tsx"