Production-ready animations, transitions, backgrounds, and scenes for Remotion
TypeScript ai-agentsclaude-codedemo-videomcpmcp-servermodel-context-protocolmotion-designproduct-demoreactremotionshadcnvideo
perf: use next/dynamic, create nextjs cache, optimizePackageImports
kapishdima587be3163428
diff --git a/app/(home)/components/hero-shader-bg.tsx b/app/(home)/components/hero-shader-bg.tsxindex d363ef7d..546fea38 100644--- a/app/(home)/components/hero-shader-bg.tsx+++ b/app/(home)/components/hero-shader-bg.tsx@@ -1,9 +1,17 @@"use client";-import { NeuroNoise } from "@paper-design/shaders-react";+import dynamic from "next/dynamic";import { useTheme } from "next-themes";import { useEffect, useState } from "react";+// `@paper-design/shaders-react` pulls in a WebGL runtime — heavy and useless on+// the server. Load it client-only so it stays out of the initial landing bundle;+// the `mounted` gate below already keeps it from rendering before hydration.+const NeuroNoise = dynamic(+ () => import("@paper-design/shaders-react").then((m) => m.NeuroNoise),+ { ssr: false },+);+const NEURO_COLORS = {light: { front: "#8f8f94", mid: "#e7e7e9", back: "#ffffff" },dark: { front: "#6e6e74", mid: "#28282c", back: "#191919" },diff --git a/app/(home)/components/sections/shaders-viz.tsx b/app/(home)/components/sections/shaders-viz.tsxnew file mode 100644index 00000000..3f4a0a24--- /dev/null+++ b/app/(home)/components/sections/shaders-viz.tsx@@ -0,0 +1,47 @@+"use client";++import { Player, type PlayerRef } from "@remotion/player";+import { useReducedMotion } from "motion/react";+import { useRef } from "react";+import { shaderGrainGradientConfig } from "@/registry/remocn/shader-grain-gradient/config";+import { useAutoplay } from "../use-autoplay";++const SHADER_PREVIEW_WIDTH = 480;+const SHADER_PREVIEW_HEIGHT = 270;+const SHADER_PREVIEW_FPS = 20;++const loadShaderGrainGradient = () =>+ import("@/registry/remocn/shader-grain-gradient").then((m) => ({+ default: m.ShaderGrainGradient,+ }));++export function ShadersViz({ play }: { play: boolean }) {+ const reduced = useReducedMotion();+ const playerRef = useRef<PlayerRef>(null);+ const { containerRef } = useAutoplay(playerRef, play && !reduced);++ const durationInFrames = Math.round(+ (shaderGrainGradientConfig.durationInFrames * SHADER_PREVIEW_FPS) /+ shaderGrainGradientConfig.fps,+ );++ return (+ <div ref={containerRef} className="absolute inset-0 overflow-hidden">+ <div className="absolute top-1/2 left-1/2 aspect-video min-h-full min-w-full -translate-x-1/2 -translate-y-1/2 will-change-transform">+ <Player+ ref={playerRef}+ lazyComponent={loadShaderGrainGradient}+ inputProps={{}}+ durationInFrames={durationInFrames}+ fps={SHADER_PREVIEW_FPS}+ compositionWidth={SHADER_PREVIEW_WIDTH}+ compositionHeight={SHADER_PREVIEW_HEIGHT}+ style={{ width: "100%", height: "100%" }}+ loop+ initiallyMuted+ acknowledgeRemotionLicense+ />+ </div>+ </div>+ );+}diff --git a/app/(home)/components/sections/whats-inside.tsx b/app/(home)/components/sections/whats-inside.tsxindex 9a6171db..843d9b35 100644--- a/app/(home)/components/sections/whats-inside.tsx+++ b/app/(home)/components/sections/whats-inside.tsx@@ -1,6 +1,5 @@"use client";-import { Player, type PlayerRef } from "@remotion/player";import {ArrowUpRight,Component,@@ -10,14 +9,24 @@ import {Waves,} from "lucide-react";import { motion, useInView, useReducedMotion } from "motion/react";+import dynamic from "next/dynamic";import Link from "next/link";import { type ComponentType, useRef } from "react";import { SPRING_SOFT } from "@/config/site";import { cn } from "@/lib/utils";-import { shaderGrainGradientConfig } from "@/registry/remocn/shader-grain-gradient/config";import { FadeUp } from "../fade-up";import { SectionHeading } from "../section-heading";-import { useAutoplay } from "../use-autoplay";++// The shader viz is the only tile that pulls @remotion/player + the shader+// runtime. Load it client-only so that weight leaves the initial landing+// bundle; the tile is below the fold and its text/links stay server-rendered.+const ShadersViz = dynamic(+ () => import("./shaders-viz").then((m) => ({ default: m.ShadersViz })),+ {+ ssr: false,+ loading: () => <div className="absolute inset-0 bg-muted/20" />,+ },+);const EYEBROW = "What's inside";const TITLE = "Five kinds of building blocks";@@ -134,46 +143,6 @@ function TransitionsViz({ play }: VizProps) {);}-const SHADER_PREVIEW_WIDTH = 480;-const SHADER_PREVIEW_HEIGHT = 270;-const SHADER_PREVIEW_FPS = 20;--const loadShaderGrainGradient = () =>- import("@/registry/remocn/shader-grain-gradient").then((m) => ({- default: m.ShaderGrainGradient,- }));--function ShadersViz({ play }: VizProps) {- const reduced = useReducedMotion();- const playerRef = useRef<PlayerRef>(null);- const { containerRef } = useAutoplay(playerRef, play && !reduced);-- const durationInFrames = Math.round(- (shaderGrainGradientConfig.durationInFrames * SHADER_PREVIEW_FPS) /- shaderGrainGradientConfig.fps,- );-- return (- <div ref={containerRef} className="absolute inset-0 overflow-hidden">- <div className="absolute top-1/2 left-1/2 aspect-video min-h-full min-w-full -translate-x-1/2 -translate-y-1/2 will-change-transform">- <Player- ref={playerRef}- lazyComponent={loadShaderGrainGradient}- inputProps={{}}- durationInFrames={durationInFrames}- fps={SHADER_PREVIEW_FPS}- compositionWidth={SHADER_PREVIEW_WIDTH}- compositionHeight={SHADER_PREVIEW_HEIGHT}- style={{ width: "100%", height: "100%" }}- loop- initiallyMuted- acknowledgeRemotionLicense- />- </div>- </div>- );-}-function AnimatedIconsViz({ play }: VizProps) {const reduced = useReducedMotion();const active = play && !reduced;diff --git a/app/docs/layout.tsx b/app/docs/layout.tsxindex 35221ff2..85ba3d44 100644--- a/app/docs/layout.tsx+++ b/app/docs/layout.tsx@@ -1,3 +1,4 @@+import { RootProvider } from "fumadocs-ui/provider/next";import type { ReactNode } from "react";import { DocsHeader } from "@/components/docs/docs-header";import { DocsShell } from "@/components/docs/docs-shell";@@ -16,7 +17,10 @@ export default async function Layout({ children }: { children: ReactNode }) {);return (- <>+ // fumadocs search + sidebar context lives here (docs-only) instead of the+ // root layout, so non-docs routes never compile fumadocs-ui. `theme.enabled:+ // false` defers to the root next-themes ThemeProvider — no double provider.+ <RootProvider theme={{ enabled: false }}>{/* Custom remocn chrome: the main header (logo + site nav + actions), thena thin bar holding the Components/Primitives switcher. Both are static(non-sticky) and content-aligned so they track the docs grid — logo@@ -31,6 +35,6 @@ export default async function Layout({ children }: { children: ReactNode }) {>{children}</DocsShell>- </>+ </RootProvider>);}diff --git a/app/layout.tsx b/app/layout.tsxindex b3562491..d3367553 100644--- a/app/layout.tsx+++ b/app/layout.tsx@@ -1,6 +1,6 @@-import { RootProvider } from "fumadocs-ui/provider/next";import type { Metadata } from "next";import { Geist, Geist_Mono, Manrope, Outfit } from "next/font/google";+import { ThemeProvider } from "next-themes";import { NuqsAdapter } from "nuqs/adapters/next/app";import "./globals.css";import { OpenPanelComponent } from "@openpanel/nextjs";@@ -82,15 +82,15 @@ export default function RootLayout({><body className="min-h-full flex flex-col"><NuqsAdapter>- <RootProvider- theme={{- defaultTheme: "system",- enableSystem: true,- }}+ <ThemeProvider+ attribute="class"+ defaultTheme="system"+ enableSystem+ disableTransitionOnChange><ThemeShortcut />{children}- </RootProvider>+ </ThemeProvider></NuqsAdapter><OpenPanelComponentclientId={process.env.NEXT_PUBLIC_OPENPANEL_CLIENT_ID as string}diff --git a/components/docs/examples/ui-preview-scenes.ts b/components/docs/examples/ui-preview-scenes.tsnew file mode 100644index 00000000..3c31e5e3--- /dev/null+++ b/components/docs/examples/ui-preview-scenes.ts@@ -0,0 +1,273 @@+import type { ComponentType } from "react";+import { FPS, H, W } from "@/lib/customizer-config";+import type { BackdropFill } from "@/registry/remocn/backdrop";++/**+ * Code-splitting source for `UiComponentPreview`. The preview renders ONE+ * component (`name`) but previously reached it through the `./examples` barrel+ * plus 28 direct `import { …ExampleCode, …ExampleControls }` statements — every+ * `/docs/ui/components/*` page therefore shipped the JS of ALL 28 scenes.+ *+ * Here the heavy part of each scene (the Remotion `…ExampleScene` component,+ * its honored-control list, and its code template) sits behind a `() => import`+ * so only the requested component's chunk is fetched. Timing metadata is tiny+ * (four numbers + a backdrop) so it stays eager in `UI_PREVIEW_TIMING`.+ *+ * Adding a UI component = one line in `UI_PREVIEW_TIMING` + one line in+ * `UI_SCENE_LOADERS`. The numbers here mirror the ui-tier entries in+ * `./examples/index.tsx` (still the source for the `ComponentExample` path);+ * keep the two in sync when a scene's duration changes.+ */++export interface UiPreviewTiming {+ durationInFrames: number;+ fps: number;+ width: number;+ height: number;+ previewBackdrop?: BackdropFill;+}++export interface LoadedUiScene {+ Scene: ComponentType;+ /** Function template emitting timeline code for the honored props. */+ code: (values: Record<string, unknown>) => string;+ /** Honored control keys (visible knobs); everything else is timeline-owned. */+ controls: readonly string[];+}++const WHITE: BackdropFill = { type: "color", value: "oklch(1 0 0)" };++const timing = (+ durationInFrames: number,+ previewBackdrop?: BackdropFill,+): UiPreviewTiming => ({+ durationInFrames,+ fps: FPS,+ width: W,+ height: H,+ previewBackdrop,+});++export const UI_PREVIEW_TIMING: Record<string, UiPreviewTiming> = {+ accordion: timing(100, WHITE),+ "alert-dialog": timing(120, WHITE),+ "blur-in": timing(40),+ button: timing(132, WHITE),+ checkbox: timing(100, WHITE),+ combobox: timing(120, WHITE),+ "command-menu": timing(130, WHITE),+ "context-menu": timing(135, WHITE),+ cursor: timing(140, WHITE),+ dialog: timing(120, WHITE),+ drawer: timing(120, WHITE),+ "dropdown-menu": timing(120, WHITE),+ input: timing(120, WHITE),+ "message-bubble": timing(90, WHITE),+ popover: timing(130, WHITE),+ progress: timing(160, WHITE),+ radio: timing(100, WHITE),+ resizable: timing(205, WHITE),+ select: timing(120, WHITE),+ sheet: timing(120, WHITE),+ skeleton: timing(220, WHITE),+ slider: timing(120, WHITE),+ stepper: timing(150, WHITE),+ switch: timing(100, WHITE),+ tabs: timing(120, WHITE),+ toast: timing(170, WHITE),+ "toggle-group": timing(115, WHITE),+ tooltip: timing(120, WHITE),+ "typing-indicator": timing(90, WHITE),+};++export const UI_SCENE_LOADERS: Record<string, () => Promise<LoadedUiScene>> = {+ accordion: () =>+ import("./accordion-example").then((m) => ({+ Scene: m.AccordionExampleScene,+ code: m.accordionExampleCode,+ controls: m.accordionExampleControls,+ })),+ "alert-dialog": () =>+ import("./alert-dialog-example").then((m) => ({+ Scene: m.AlertDialogExampleScene,+ code: m.alertDialogExampleCode,+ controls: m.alertDialogExampleControls,+ })),+ "blur-in": () =>+ import("./blur-in-example").then((m) => ({+ Scene: m.BlurInExampleScene,+ code: m.blurInExampleCode,+ controls: m.blurInExampleControls,+ })),+ button: () =>+ import("./button-example").then((m) => ({+ Scene: m.ButtonExampleScene,+ code: m.buttonExampleCode,+ controls: m.buttonExampleControls,+ })),+ checkbox: () =>+ import("./checkbox-example").then((m) => ({+ Scene: m.CheckboxExampleScene,+ code: m.checkboxExampleCode,+ controls: m.checkboxExampleControls,+ })),+ combobox: () =>+ import("./combobox-example").then((m) => ({+ Scene: m.ComboboxExampleScene,+ code: m.comboboxExampleCode,+ controls: m.comboboxExampleControls,+ })),+ "command-menu": () =>+ import("./command-menu-example").then((m) => ({+ Scene: m.CommandMenuExampleScene,+ code: m.commandMenuExampleCode,+ controls: m.commandMenuExampleControls,+ })),+ "context-menu": () =>+ import("./context-menu-example").then((m) => ({+ Scene: m.ContextMenuExampleScene,+ code: m.contextMenuExampleCode,+ controls: m.contextMenuExampleControls,+ })),+ cursor: () =>+ import("./cursor-example").then((m) => ({+ Scene: m.CursorExampleScene,+ code: m.cursorExampleCode,+ controls: m.cursorExampleControls,+ })),+ dialog: () =>+ import("./dialog-example").then((m) => ({+ Scene: m.DialogExampleScene,+ code: m.dialogExampleCode,+ controls: m.dialogExampleControls,+ })),+ drawer: () =>+ import("./drawer-example").then((m) => ({+ Scene: m.DrawerExampleScene,+ code: m.drawerExampleCode,+ controls: m.drawerExampleControls,+ })),+ "dropdown-menu": () =>+ import("./dropdown-menu-example").then((m) => ({+ Scene: m.DropdownMenuExampleScene,+ code: m.dropdownMenuExampleCode,+ controls: m.dropdownMenuExampleControls,+ })),+ input: () =>+ import("./input-example").then((m) => ({+ Scene: m.InputExampleScene,+ code: m.inputExampleCode,+ controls: m.inputExampleControls,+ })),+ "message-bubble": () =>+ import("./message-bubble-example").then((m) => ({+ Scene: m.MessageBubbleExampleScene,+ code: m.messageBubbleExampleCode,+ controls: m.messageBubbleExampleControls,+ })),+ popover: () =>+ import("./popover-example").then((m) => ({+ Scene: m.PopoverExampleScene,+ code: m.popoverExampleCode,+ controls: m.popoverExampleControls,+ })),+ progress: () =>+ import("./progress-example").then((m) => ({+ Scene: m.ProgressExampleScene,+ code: m.progressExampleCode,+ controls: m.progressExampleControls,+ })),+ radio: () =>+ import("./radio-example").then((m) => ({+ Scene: m.RadioExampleScene,+ code: m.radioExampleCode,+ controls: m.radioExampleControls,+ })),+ resizable: () =>+ import("./resizable-example").then((m) => ({+ Scene: m.ResizableExampleScene,+ code: m.resizableExampleCode,+ controls: m.resizableExampleControls,+ })),+ select: () =>+ import("./select-example").then((m) => ({+ Scene: m.SelectExampleScene,+ code: m.selectExampleCode,+ controls: m.selectExampleControls,+ })),+ sheet: () =>+ import("./sheet-example").then((m) => ({+ Scene: m.SheetExampleScene,+ code: m.sheetExampleCode,+ controls: m.sheetExampleControls,+ })),+ skeleton: () =>+ import("./skeleton-example").then((m) => ({+ Scene: m.SkeletonExampleScene,+ code: m.skeletonExampleCode,+ controls: m.skeletonExampleControls,+ })),+ slider: () =>+ import("./slider-example").then((m) => ({+ Scene: m.SliderExampleScene,+ code: m.sliderExampleCode,+ controls: m.sliderExampleControls,+ })),+ stepper: () =>+ import("./stepper-example").then((m) => ({+ Scene: m.StepperExampleScene,+ code: m.stepperExampleCode,+ controls: m.stepperExampleControls,+ })),+ switch: () =>+ import("./switch-example").then((m) => ({+ Scene: m.SwitchExampleScene,+ code: m.switchExampleCode,+ controls: m.switchExampleControls,+ })),+ tabs: () =>+ import("./tabs-example").then((m) => ({+ Scene: m.TabsExampleScene,+ code: m.tabsExampleCode,+ controls: m.tabsExampleControls,+ })),+ toast: () =>+ import("./toast-example").then((m) => ({+ Scene: m.ToastExampleScene,+ code: m.toastExampleCode,+ controls: m.toastExampleControls,+ })),+ "toggle-group": () =>+ import("./toggle-group-example").then((m) => ({+ Scene: m.ToggleGroupExampleScene,+ code: m.toggleGroupExampleCode,+ controls: m.toggleGroupExampleControls,+ })),+ tooltip: () =>+ import("./tooltip-example").then((m) => ({+ Scene: m.TooltipExampleScene,+ code: m.tooltipExampleCode,+ controls: m.tooltipExampleControls,+ })),+ "typing-indicator": () =>+ import("./typing-indicator-example").then((m) => ({+ Scene: m.TypingIndicatorExampleScene,+ code: m.typingIndicatorExampleCode,+ controls: m.typingIndicatorExampleControls,+ })),+};++const sceneCache = new Map<string, Promise<LoadedUiScene>>();++/**+ * Cached module loader for `use()` — returns the SAME promise per name so the+ * hook resolves synchronously after the first suspend instead of re-fetching.+ */+export function loadUiScene(name: string): Promise<LoadedUiScene> {+ let promise = sceneCache.get(name);+ if (!promise) {+ promise = UI_SCENE_LOADERS[name]();+ sceneCache.set(name, promise);+ }+ return promise;+}diff --git a/components/docs/ui-component-preview.tsx b/components/docs/ui-component-preview.tsxindex 6454c680..972a2349 100644--- a/components/docs/ui-component-preview.tsx+++ b/components/docs/ui-component-preview.tsx@@ -2,7 +2,7 @@import { CheckIcon, LinkIcon, RotateCcwIcon } from "lucide-react";import { useQueryStates } from "nuqs";-import { Suspense, useEffect, useMemo, useRef, useState } from "react";+import { Suspense, use, useEffect, useMemo, useRef, useState } from "react";import { CodeBlock } from "@/components/docs/code-block";import { Button } from "@/components/ui/button";import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";@@ -11,207 +11,12 @@ import { type ControlConfig, getDefaults } from "@/lib/customizer-config";import { buildParsers, PreviewStage } from "@/lib/ui-preview-internals";import registry from "@/registry/__index__";import { ComponentCustomizer } from "./component-customizer";-import { type ExampleEntry, examples } from "./examples";import {- accordionExampleCode,- accordionExampleControls,-} from "./examples/accordion-example";-import {- alertDialogExampleCode,- alertDialogExampleControls,-} from "./examples/alert-dialog-example";-import {- blurInExampleCode,- blurInExampleControls,-} from "./examples/blur-in-example";-import {- buttonExampleCode,- buttonExampleControls,-} from "./examples/button-example";-import {- checkboxExampleCode,- checkboxExampleControls,-} from "./examples/checkbox-example";-import {- comboboxExampleCode,- comboboxExampleControls,-} from "./examples/combobox-example";-import {- commandMenuExampleCode,- commandMenuExampleControls,-} from "./examples/command-menu-example";-import {- contextMenuExampleCode,- contextMenuExampleControls,-} from "./examples/context-menu-example";-import {- cursorExampleCode,- cursorExampleControls,-} from "./examples/cursor-example";-import {- dialogExampleCode,- dialogExampleControls,-} from "./examples/dialog-example";-import {- drawerExampleCode,- drawerExampleControls,-} from "./examples/drawer-example";-import {- dropdownMenuExampleCode,- dropdownMenuExampleControls,-} from "./examples/dropdown-menu-example";-import {- inputExampleCode,- inputExampleControls,-} from "./examples/input-example";-import {- messageBubbleExampleCode,- messageBubbleExampleControls,-} from "./examples/message-bubble-example";-import {- popoverExampleCode,- popoverExampleControls,-} from "./examples/popover-example";-import {- progressExampleCode,- progressExampleControls,-} from "./examples/progress-example";-import {- radioExampleCode,- radioExampleControls,-} from "./examples/radio-example";-import {- resizableExampleCode,- resizableExampleControls,-} from "./examples/resizable-example";-import {- selectExampleCode,- selectExampleControls,-} from "./examples/select-example";-import {- sheetExampleCode,- sheetExampleControls,-} from "./examples/sheet-example";-import {- skeletonExampleCode,- skeletonExampleControls,-} from "./examples/skeleton-example";-import {- sliderExampleCode,- sliderExampleControls,-} from "./examples/slider-example";-import {- stepperExampleCode,- stepperExampleControls,-} from "./examples/stepper-example";-import {- switchExampleCode,- switchExampleControls,-} from "./examples/switch-example";-import { tabsExampleCode, tabsExampleControls } from "./examples/tabs-example";-import {- toastExampleCode,- toastExampleControls,-} from "./examples/toast-example";-import {- toggleGroupExampleCode,- toggleGroupExampleControls,-} from "./examples/toggle-group-example";-import {- tooltipExampleCode,- tooltipExampleControls,-} from "./examples/tooltip-example";-import {- typingIndicatorExampleCode,- typingIndicatorExampleControls,-} from "./examples/typing-indicator-example";--/**- * Per-component honored-key allowlist + code template, co-located with each- * scene file (`<name>ExampleControls` + `<name>ExampleCode`). The preview shows- * ONLY the controls a scene actually threads into its component (visible =- * honored, never a blacklist), and the Code tab emits ONLY those honored props.- *- * Each fan-out worker adds one line here per migrated component (import the two- * exports from `./examples/<name>-example`, register them by registry name).- * Phase 0 seeds the button pilot.- */-interface UiSceneMeta {- /** Honored control keys (visible knobs); everything else is timeline-owned. */- controls: readonly string[];- /** Function template emitting the timeline code for the honored props. */- code: (values: Record<string, unknown>) => string;-}--const UI_SCENE_META: Record<string, UiSceneMeta> = {- button: { controls: buttonExampleControls, code: buttonExampleCode },- input: { controls: inputExampleControls, code: inputExampleCode },- toast: { controls: toastExampleControls, code: toastExampleCode },- "message-bubble": {- controls: messageBubbleExampleControls,- code: messageBubbleExampleCode,- },- "typing-indicator": {- controls: typingIndicatorExampleControls,- code: typingIndicatorExampleCode,- },- popover: { controls: popoverExampleControls, code: popoverExampleCode },- accordion: { controls: accordionExampleControls, code: accordionExampleCode },- tooltip: { controls: tooltipExampleControls, code: tooltipExampleCode },- dialog: { controls: dialogExampleControls, code: dialogExampleCode },- sheet: { controls: sheetExampleControls, code: sheetExampleCode },- drawer: { controls: drawerExampleControls, code: drawerExampleCode },- "alert-dialog": {- controls: alertDialogExampleControls,- code: alertDialogExampleCode,- },- checkbox: { controls: checkboxExampleControls, code: checkboxExampleCode },- radio: { controls: radioExampleControls, code: radioExampleCode },- switch: { controls: switchExampleControls, code: switchExampleCode },- slider: { controls: sliderExampleControls, code: sliderExampleCode },- progress: { controls: progressExampleControls, code: progressExampleCode },- combobox: { controls: comboboxExampleControls, code: comboboxExampleCode },- select: { controls: selectExampleControls, code: selectExampleCode },- "command-menu": {- controls: commandMenuExampleControls,- code: commandMenuExampleCode,- },- "dropdown-menu": {- controls: dropdownMenuExampleControls,- code: dropdownMenuExampleCode,- },- "context-menu": {- controls: contextMenuExampleControls,- code: contextMenuExampleCode,- },- cursor: { controls: cursorExampleControls, code: cursorExampleCode },- resizable: { controls: resizableExampleControls, code: resizableExampleCode },- skeleton: { controls: skeletonExampleControls, code: skeletonExampleCode },- stepper: { controls: stepperExampleControls, code: stepperExampleCode },- tabs: { controls: tabsExampleControls, code: tabsExampleCode },- "toggle-group": {- controls: toggleGroupExampleControls,- code: toggleGroupExampleCode,- },- "blur-in": { controls: blurInExampleControls, code: blurInExampleCode },-};--/**- * Honored-only code generator (Q4). Built from the scene's `<name>ExampleCode`- * function template — it interpolates ONLY honored keys, ONLY when a value- * differs from its control default, and NEVER emits a prop the component- * ignores. Same `visibleValues` feeds the Player + this generator → parity.- * Does NOT call the legacy `config.snippet`.- */-function generateUiCode(- name: string,- _exampleEntry: ExampleEntry,- visibleValues: Record<string, unknown>,-): string {- const meta = UI_SCENE_META[name];- if (!meta) return "";- return meta.code(visibleValues);-}+ loadUiScene,+ UI_PREVIEW_TIMING,+ UI_SCENE_LOADERS,+ type UiPreviewTiming,+} from "./examples/ui-preview-scenes";/** Shared "Unknown component" fallback — matches the existing docs widgets. */function UnknownComponent({ name }: { name: string }) {@@ -223,13 +28,13 @@ function UnknownComponent({ name }: { name: string }) {}export function UiComponentPreview({ name }: { name: string }) {- const exampleEntry = examples[`${name}-example`];+ const timing = UI_PREVIEW_TIMING[name];const entry = registry[name];- const meta = UI_SCENE_META[name];- // Q1 — join the example (scene + timing) with the registry config (controls)- // and the per-scene honored list. Any miss → the shared Unknown fallback.- if (!exampleEntry || !entry || !meta) {+ // Q1 — join the example timing with the registry config (controls) and a lazy+ // scene loader. The scene (component + honored list + code template) is fetched+ // inside `UiPreview` via `use()`. Any miss here → the shared Unknown fallback.+ if (!timing || !entry || !(name in UI_SCENE_LOADERS)) {return <UnknownComponent name={name} />;}@@ -239,27 +44,25 @@ export function UiComponentPreview({ name }: { name: string }) {<div className="not-prose mb-6 aspect-[1.9/1] w-full animate-pulse rounded-2xl bg-muted" />}>- <UiPreview- name={name}- exampleEntry={exampleEntry}- controls={entry.config.controls}- honored={meta.controls}- />+ <UiPreview name={name} timing={timing} controls={entry.config.controls} /></Suspense>);}function UiPreview({name,- exampleEntry,+ timing,controls,- honored,}: {name: string;- exampleEntry: ExampleEntry;+ timing: UiPreviewTiming;controls: ControlConfig;- honored: readonly string[];}) {+ // Suspends on first render until this component's scene chunk resolves, then+ // returns synchronously from the cached promise. Gives us the scene component,+ // its honored-control list, and its code template — no other scene is fetched.+ const scene = use(loadUiScene(name));+ const honored = scene.controls;const trackEvent = useTrackEvent();// visibleControls = config.controls ∩ honored[name]. This drops state/speed@@ -294,10 +97,10 @@ function UiPreview({[defaults, values],);- const code = useMemo(- () => generateUiCode(name, exampleEntry, values),- [name, exampleEntry, values],- );+ // Honored-only code (Q4): the scene's own template interpolates ONLY honored+ // keys, ONLY when a value differs from its default, and NEVER emits a prop the+ // component ignores. The same `values` feeds the Player → guaranteed parity.+ const code = useMemo(() => scene.code(values), [scene, values]);const [copied, setCopied] = useState(false);const handleCopyLink = () => {@@ -351,14 +154,14 @@ function UiPreview({<TabsContent value="preview" className="mt-0"><PreviewStagename={name}- Component={exampleEntry.Component}+ Component={scene.Scene}inputProps={values}// D2 — timing is sourced from the EXAMPLE, not the config.- durationInFrames={exampleEntry.durationInFrames}- fps={exampleEntry.fps}- compositionWidth={exampleEntry.width}- compositionHeight={exampleEntry.height}- previewBackdrop={exampleEntry.previewBackdrop}+ durationInFrames={timing.durationInFrames}+ fps={timing.fps}+ compositionWidth={timing.width}+ compositionHeight={timing.height}+ previewBackdrop={timing.previewBackdrop}/></TabsContent>diff --git a/next.config.ts b/next.config.tsindex 818ce230..ca01a625 100644--- a/next.config.ts+++ b/next.config.ts@@ -5,6 +5,13 @@ const withMDX = createMDX();const nextConfig: NextConfig = {reactStrictMode: true,+ // `motion` ships a barrel (motion/react re-exports the whole runtime). Next's+ // default optimizePackageImports list covers lucide-react/date-fns but not+ // motion, so name it explicitly to rewrite the 15 `from "motion/react"` sites+ // into direct imports and keep unused motion features out of the bundle.+ experimental: {+ optimizePackageImports: ["motion"],+ },// Remotion's server packages are Node-only and ship native binaries (esbuild +// the platform-specific @remotion/compositor-*). They must NOT be bundled by// Turbopack/webpack — keep them external so they're require()'d at runtime indiff --git a/package.json b/package.jsonindex 4234e1d4..f247af53 100644--- a/package.json+++ b/package.json@@ -4,6 +4,8 @@"private": true,"scripts": {"dev": "next dev",+ "dev:clean": "rm -rf .next && next dev",+ "clean": "rm -rf .next","build": "next build","start": "next start","test": "bun test",