Production-ready animations, transitions, backgrounds, and scenes for Remotion
TypeScript ai-agentsclaude-codedemo-videomcpmcp-servermodel-context-protocolmotion-designproduct-demoreactremotionshadcnvideo
feat: added cursor component
dev_wandryd464de510792
diff --git a/components/docs/examples/cursor-example.tsx b/components/docs/examples/cursor-example.tsxnew file mode 100644index 00000000..ef7a0d69--- /dev/null+++ b/components/docs/examples/cursor-example.tsx@@ -0,0 +1,82 @@+"use client";++import { Cursor } from "@/registry/remocn-ui/cursor";+import { useCursorPath } from "@/registry/remocn-ui/cursor/use-cursor-path";+import { Button } from "@/registry/remocn-ui/button";+import { useButtonTransition } from "@/registry/remocn-ui/button/use-button-transition";++const BTN_X = 620; // button tip X (center of button, cursor arrives here)+const BTN_Y = 360; // button tip Y++export const CursorExampleScene = () => {+ const cursorStyle = useCursorPath([+ { at: 0, x: 80, y: 60 },+ { at: 40, x: BTN_X, y: BTN_Y, duration: 28 },+ { at: 72, x: BTN_X, y: BTN_Y, click: true, duration: 0 },+ ]);++ const buttonStyle = useButtonTransition([+ { at: 45, state: "hover", duration: 16 },+ { at: 73, state: "press", duration: 8 },+ { at: 81, state: "loading", duration: 6 },+ { at: 113, state: "success", duration: 16 },+ ]);++ return (+ <div style={{ position: "relative", width: "100%", height: "100%" }}>+ <div+ style={{+ position: "absolute",+ left: "50%",+ top: "50%",+ transform: "translate(-50%, -50%)",+ }}+ >+ <Button label="Continue" style={buttonStyle} />+ </div>+ <Cursor style={cursorStyle} variant="pointer" />+ </div>+ );+};++export const cursorExampleCode = `import { Cursor } from "@/components/remocn/cursor";+import { useCursorPath } from "@/components/remocn/use-cursor-path";+import { Button } from "@/components/remocn/button";+import { useButtonTransition } from "@/components/remocn/use-button-transition";++const BTN_X = 280;+const BTN_Y = 160;++export const Scene = () => {+ // The cursor is value-channel driven: useCursorPath reads the frame and+ // returns the animated CursorStyle; <Cursor> itself stays pure.+ const cursorStyle = useCursorPath([+ { at: 0, x: 80, y: 60 },+ { at: 40, x: BTN_X, y: BTN_Y, duration: 28 },+ { at: 72, x: BTN_X, y: BTN_Y, click: true, duration: 0 },+ ]);++ // Button timeline is frame-synced with the cursor path above.+ const buttonStyle = useButtonTransition([+ { at: 40, state: "hover", duration: 16 },+ { at: 68, state: "press", duration: 8 },+ { at: 76, state: "loading", duration: 6 },+ { at: 108, state: "success", duration: 16 },+ ]);++ return (+ <div style={{ position: "relative", width: "100%", height: "100%" }}>+ <div+ style={{+ position: "absolute",+ left: "50%",+ top: "50%",+ transform: "translate(-50%, -50%)",+ }}+ >+ <Button label="Continue" style={buttonStyle} />+ </div>+ <Cursor style={cursorStyle} variant="pointer" />+ </div>+ );+};`;diff --git a/components/docs/examples/index.tsx b/components/docs/examples/index.tsxindex 705d910c..c989b555 100644--- a/components/docs/examples/index.tsx+++ b/components/docs/examples/index.tsx@@ -25,6 +25,7 @@ import {dropdownMenuExampleCode,} from "./dropdown-menu-example";import { TabsExampleScene, tabsExampleCode } from "./tabs-example";+import { CursorExampleScene, cursorExampleCode } from "./cursor-example";export interface ExampleEntry {Component: ComponentType;@@ -148,4 +149,13 @@ export const examples: Record<string, ExampleEntry> = {width: W,height: H,},+ "cursor-example": {+ Component: CursorExampleScene,+ code: cursorExampleCode,+ // success transition completes at 108 + dur 16 = 124; a short settle then loop.+ durationInFrames: 140,+ fps: FPS,+ width: W,+ height: H,+ },};diff --git a/content/docs/ui/components/cursor.mdx b/content/docs/ui/components/cursor.mdxnew file mode 100644index 00000000..53fadf59--- /dev/null+++ b/content/docs/ui/components/cursor.mdx@@ -0,0 +1,176 @@+---+title: Cursor+description: An animated cursor that follows a scripted path with click ripple and press effects+---++<ComponentPreview name="cursor" />++A motion atom that renders an animated cursor as a pure function of the `CursorStyle` it receives. The cursor reads no frame itself — the single time source is `useCursorPath` on the caller's side, which folds a path of waypoints into a resolved position, ripple, and press-dip visual. This is the **value-channel** variant of the primitive pattern: instead of a string-state timeline it drives numeric position channels directly.++## Installation++<InstallBlock name="cursor" />++<Note>+Installing `cursor` automatically installs the shared `remocn-ui` core (`lib/remocn-ui/`) via `registryDependencies` (`["remocn-ui"]`). You do not need to install it separately. Both `cursor` (the renderer) and `use-cursor-path` (the hook) are copied into your project.+</Note>++## Example++<LiveExample name="cursor-example" />++## Waypoints++Instead of a string-state timeline, `useCursorPath` takes an array of `CursorWaypoint` objects that describe a scripted path:++```ts+interface CursorWaypoint {+ at: number; // LOCAL (Sequence-relative) authored frame the cursor finishes arriving here+ x: number; // Tip X in px, relative to the absolute wrapper's parent+ y: number; // Tip Y in px, relative to the absolute wrapper's parent+ duration?: number; // Frames the move INTO this waypoint takes. Omitted → DEFAULT_DURATION (24)+ click?: boolean; // Fire a click on arrival: ripple (~16 frames) + brief press dip+ press?: boolean; // Hold the pressed look from this waypoint until the next one (drag)+ easing?: EasingName; // Override easing for the move into this waypoint. Default "inOut"+}+```++`at` is the **arrival frame** — the frame when the cursor finishes its move. The move itself runs over `[at - duration, at)`. Before the first waypoint arrives, the cursor parks at the first waypoint's position.++### Numeric-channel deviation++`Cursor` differs from state atoms (Button, Input, etc.) in one key way: there is no string `state` union and no `useCurrentState` snap path. The cursor's visual is always numeric — a position plus ripple and press scalars — so `useCursorPath` folds the waypoint path directly into a `CursorStyle` value, analogous to how `useButtonTransition` returns a `ButtonStyle`. The snap equivalent is simply parking the cursor at a fixed position without calling the hook.++## Snap usage++Park the cursor at a fixed position without the hook:++```tsx+import { Cursor } from "@/components/remocn/cursor";++export const Scene = () => (+ <div style={{ position: "relative", width: "100%", height: "100%" }}>+ <Cursor+ style={{ x: 200, y: 150, scale: 1, rippleOpacity: 0, rippleScale: 0 }}+ variant="pointer"+ />+ </div>+);+```++## Smooth path usage++Drive the cursor along a scripted path with `useCursorPath`:++```tsx+import { Cursor } from "@/components/remocn/cursor";+import { useCursorPath } from "@/components/remocn/use-cursor-path";++export const Scene = () => {+ const style = useCursorPath([+ { at: 0, x: 80, y: 60 },+ { at: 40, x: 280, y: 160, duration: 28 },+ { at: 72, x: 280, y: 160, click: true, duration: 0 },+ ]);++ return (+ <div style={{ position: "relative", width: "100%", height: "100%" }}>+ <Cursor style={style} variant="pointer" />+ </div>+ );+};+```++Each `at` is a **Sequence-local authored frame**. The cursor eases from each waypoint's position to the next. A `click: true` waypoint fires a 16-frame ripple and a brief press dip starting at its `at` frame.++### Frame-syncing with other components++The power of the waypoint model is composing the cursor timeline with the state timelines of other components. When a `click` waypoint fires at frame 72, schedule a Button's `press` step to start a few frames earlier (around 68) so the button begins pressing just before the click lands:++```tsx+import { Cursor } from "@/components/remocn/cursor";+import { useCursorPath } from "@/components/remocn/use-cursor-path";+import { Button } from "@/components/remocn/button";+import { useButtonTransition } from "@/components/remocn/use-button-transition";++export const Scene = () => {+ const cursorStyle = useCursorPath([+ { at: 0, x: 80, y: 60 },+ { at: 40, x: 280, y: 160, duration: 28 },+ { at: 72, x: 280, y: 160, click: true, duration: 0 },+ ]);++ const buttonStyle = useButtonTransition([+ { at: 40, state: "hover", duration: 16 },+ { at: 68, state: "press", duration: 8 },+ { at: 76, state: "loading", duration: 6 },+ { at: 108, state: "success", duration: 16 },+ ]);++ return (+ <div style={{ position: "relative", width: "100%", height: "100%" }}>+ <div style={{ position: "absolute", left: "50%", top: "50%", transform: "translate(-50%, -50%)" }}>+ <Button label="Continue" style={buttonStyle} />+ </div>+ <Cursor style={cursorStyle} variant="pointer" />+ </div>+ );+};+```++### Drag / held press++Set `press: true` on a waypoint to hold the pressed look from that waypoint's arrival until the next waypoint arrives. Useful for simulating a drag gesture:++```tsx+const style = useCursorPath([+ { at: 0, x: 100, y: 100 },+ { at: 30, x: 200, y: 100, press: true }, // hold press from here…+ { at: 60, x: 300, y: 100 }, // …until cursor reaches here+]);+```++## Props++<PropsTable+ rows={[+ {+ name: "style",+ type: "CursorStyle",+ description: "Resolved animated visual. Feed it an interpolated CursorStyle from useCursorPath. When omitted the cursor parks at origin with no ripple.",+ },+ {+ name: "variant",+ type: "\"arrow\" | \"pointer\"",+ default: "\"arrow\"",+ description: "macOS arrow cursor or hand pointer. Static choice — not animated between waypoints.",+ },+ {+ name: "size",+ type: "number",+ default: "28",+ description: "Rendered cursor height in px. The SVG scales uniformly to this height.",+ },+ {+ name: "rippleColor",+ type: "string",+ description: "Color of the click ripple ring. Defaults to theme.primary.",+ },+ {+ name: "theme",+ type: "Partial<RemocnTheme>",+ description: "Per-component theme override. Must be concrete oklch/hex/rgb values — not CSS custom properties.",+ },+ {+ name: "mode",+ type: "\"light\" | \"dark\"",+ default: "\"light\"",+ description: "Sets the base palette. Overrides the mode on RemocnUIProvider when both are present.",+ },+ {+ name: "className",+ type: "string",+ description: "Optional className applied to the absolute wrapper div.",+ },+ ]}+/>diff --git a/content/docs/ui/components/meta.json b/content/docs/ui/components/meta.jsonindex 61ee6e08..e7024c1d 100644--- a/content/docs/ui/components/meta.json+++ b/content/docs/ui/components/meta.json@@ -1,5 +1,5 @@{"title": "Components","collapsible": false,- "pages": ["accordion", "alert-dialog", "button", "checkbox", "dialog", "drawer", "sheet", "dropdown-menu", "input", "radio", "select", "spinner", "switch", "tabs"]+ "pages": ["accordion", "alert-dialog", "button", "checkbox", "cursor", "dialog", "drawer", "sheet", "dropdown-menu", "input", "radio", "select", "spinner", "switch", "tabs"]}diff --git a/registry/__index__.tsx b/registry/__index__.tsxindex 25affea3..f889db4b 100644--- a/registry/__index__.tsx+++ b/registry/__index__.tsx@@ -137,6 +137,8 @@ import { DropdownMenuItem } from "@/registry/remocn-ui/dropdown-menu-item";import { dropdownMenuItemConfig } from "@/registry/remocn-ui/dropdown-menu-item/config";import { Tabs } from "@/registry/remocn-ui/tabs";import { tabsConfig } from "@/registry/remocn-ui/tabs/config";+import { CursorPreview } from "@/registry/remocn-ui/cursor/preview";+import { cursorConfig } from "@/registry/remocn-ui/cursor/config";import { ZoomThroughTransition } from "@/registry/remocn/zoom-through-transition";import { zoomThroughTransitionConfig } from "@/registry/remocn/zoom-through-transition/config";@@ -328,6 +330,9 @@ const registry: Record<string, RegistryEntry> = {config: dropdownMenuItemConfig,},"tabs": { Component: Tabs, config: tabsConfig },+ // cursor's customizer Component is the preview-only CursorPreview wrapper (it+ // runs a fixed demo path through useCursorPath); the shipped Cursor is pure.+ "cursor": { Component: CursorPreview, config: cursorConfig },"spinner": { Component: Spinner, config: spinnerConfig },};diff --git a/registry/remocn-ui/cursor/__tests__/README.md b/registry/remocn-ui/cursor/__tests__/README.mdnew file mode 100644index 00000000..7d9ae9cd--- /dev/null+++ b/registry/remocn-ui/cursor/__tests__/README.md@@ -0,0 +1,138 @@+# `cursor` — verification tests++Pure / deterministic verification for the `cursor` component+(`registry/remocn-ui/cursor/`). The render path (`index.tsx`) is a **pure+renderer** — it never reads the frame — but it imports `useRemocnTheme` which+pulls React context that cannot run headlessly. So render is NOT exercised+here. This suite covers the pieces that ARE pure: the exported `cursorPathAt`+core, the `ripplePhase` / `clickPress` phase presets, and `cursorConfig.snippet`+codegen.++## Animation model — value-channel cursor++Cursor follows the **value-channel** deviation from the state-atom pattern:++**Value path** (`style?: CursorStyle` prop):+`<Cursor>` is a frame-free pure renderer. The animated `CursorStyle` (position,+ripple phase, press scale) is fed in from the caller. The component does not+know whether the style came from a resting preset or a live interpolated frame.++**Hook** (`useCursorPath`):+The caller uses `useCursorPath(waypoints, opts)` which reads `useCurrentFrame()`+once and delegates to the pure core `cursorPathAt(waypoints, raw, opts)`. The+pure core is exported and directly tested here by injecting `raw`.++**Pure core** (`cursorPathAt`):+`useCursorPath` is exactly `cursorPathAt(waypoints, useCurrentFrame() * speed, opts)`.+The tests replicate this by calling `cursorPathAt` with an explicit `raw` frame.+This is the MIRROR pattern (see STYLE-GUIDE §10): no replica needed since the+pure core is directly exported.++**Phase presets** (`ripplePhase`, `clickPress`):+Exported pure functions — no frame reading, no side effects, tested directly.++## How to run++The repo uses **Bun**, which has a built-in test runner — runs TypeScript+natively, no test-framework dep.++```bash+bun install+bun test registry/remocn-ui/cursor/__tests__+```++`cursor.test.ts` imports `bun:test` (not `vitest`/`jest`), so no test script+or framework dep is added to `package.json`.++## What is covered++- **Constants** — `DEFAULT_DURATION=24`, `CLICK_FRAMES=16`, `PRESS_FRAMES=8`.++- **`ripplePhase(sinceClick)`** — exported pure preset (mirrors+ `use-cursor-path.ts` lines 59-71). Asserts: zero opacity/scale before a+ click and at/past `CLICK_FRAMES`; opacity=0.5 and scale=0 at the click+ moment (sinceClick=0); correct numeric values at the midpoint and near+ expiry; opacity decreases monotonically and scale increases monotonically+ across the full window.++- **`clickPress(sinceClick)`** — exported pure preset (mirrors+ `use-cursor-path.ts` lines 78-86). Asserts: returns 1 before the click and+ at/past `PRESS_FRAMES`; 1 at frame 0; 0 (fully pressed) at the half-way+ dip; non-zero and less-than-1 near the end; down-then-up triangle shape via+ monotonicity checks on the down and up phases.++- **`cursorPathAt(waypoints, raw, opts)`** — pure core of `useCursorPath`+ (mirrors `use-cursor-path.ts` lines 111-188). Asserts:+ - Empty waypoints: returns origin with scale=1, no ripple.+ - Before first arrival: cursor parks at `first.x/y`, pressScale=1.+ - Move window interpolation: correct lerped x/y at t=0, t=0.5, t=1 with+ default `inOut` easing.+ - Easing override: `linear` and `out` produce distinct positions at the+ midpoint; numerics match the easing formula.+ - Custom per-waypoint `duration`: narrower window shifts the interpolation+ midpoint; `opts.defaultDuration` changes the effective window.+ - `scale` invariant: always 1 (pressedScale is computed by the component).+ - Click visuals: rippleOpacity=0 before the click waypoint; 0.5 at arrival+ (sinceClick=0); decays to 0 after CLICK_FRAMES; pressScale dips to 0 at+ PRESS_FRAMES/2 and returns to 1 at PRESS_FRAMES.+ - Multiple clicks: only the most recent active click determines the ripple.+ - Press/drag: `press:true` on the FROM waypoint sets pressScale=0 until the+ next waypoint arrives; resets to 1 afterward.+ - Speed contract: `speed=2` halves the raw frame needed to reach a waypoint;+ `speed=0.5` doubles it; `speed=1` matches the no-option default.+ - Three-waypoint path: correct segment selection and position ranges at each+ boundary.++- **`cursorConfig.controls`** — control wiring assertions: `variant` is a+ `select` with options `["arrow","pointer"]` and default `"arrow"`; `size` is+ a `number` with default 28, min 16, max 64; `mode` is a `select` with+ options `["light","dark"]` and default `"light"`; `rippleColor` is a `color`+ with default `"#171717"`.++- **`cursorConfig.snippet`** — pure JSX string builder. Asserts: both import+ lines (`Cursor` and `useCursorPath`) are present with correct paths;+ `<Cursor` element and `style={style}` prop always appear; ends with `/>`;+ default props (`variant="arrow"`, `size=28`, `mode="light"`) are omitted;+ non-default props are emitted with correct JSX syntax.++**Cursor render** is a pure `(style) => visual` observable only via Remotion+render; it is not unit-tested here.++## Import strategy++`cursor.test.ts` imports via **relative paths**:++- `../use-cursor-path` — relative, for `cursorPathAt`, `ripplePhase`,+ `clickPress`, `DEFAULT_DURATION`, `CLICK_FRAMES`, `PRESS_FRAMES`,+ `CursorWaypoint`+- `../config` — relative, for `cursorConfig`++Neither `cursorPathAt` nor `ripplePhase` nor `clickPress` call+`useCurrentFrame()` at import time or at call time — `useCursorPath` is the+only frame-reading export, and we do not import it. `bun test` resolves tsconfig+`paths`, so the `@/lib/remocn-ui` alias is available when needed but not used+in this file.++## Determinism grep checklist (run manually; must print NOTHING)++`cursor/index.tsx` is a pure renderer — the component must contain **none** of+the following:++```bash+grep -nE "useState|useEffect|useCurrentFrame|onClick|onChange|addEventListener|Date\.now|Math\.random|requestAnimationFrame" \+ registry/remocn-ui/cursor/index.tsx+```++Expected: **no output**. Any match is a determinism violation.++`use-cursor-path.ts` is the frame-reading hook file. It intentionally calls+`useCurrentFrame()` inside `useCursorPath` — this is the correct and only place+in the cursor package where the frame is read. The pure exported surface+(`cursorPathAt`, `ripplePhase`, `clickPress`) does NOT call `useCurrentFrame`.++Tier-wide sweep for `index.tsx`:++```bash+grep -nE "useState|useEffect|onClick|onChange|addEventListener|Date\.now|Math\.random" \+ registry/remocn-ui/cursor/index.tsx registry/remocn-ui/core/*.ts+```diff --git a/registry/remocn-ui/cursor/__tests__/cursor.test.ts b/registry/remocn-ui/cursor/__tests__/cursor.test.tsnew file mode 100644index 00000000..4b7a1dbd--- /dev/null+++ b/registry/remocn-ui/cursor/__tests__/cursor.test.ts@@ -0,0 +1,767 @@+/**+ * Verification tests for the PURE / DETERMINISTIC parts of `cursor`.+ *+ * Scope:+ * - registry/remocn-ui/cursor/use-cursor-path.ts+ * cursorPathAt() — pure fold with injected frame (MIRROR of useCursorPath)+ * ripplePhase() — click ripple opacity + scale preset+ * clickPress() — momentary press-dip preset+ * Constants: DEFAULT_DURATION, CLICK_FRAMES, PRESS_FRAMES+ * - registry/remocn-ui/cursor/config.ts+ * cursorConfig.controls wiring + cursorConfig.snippet codegen+ *+ * The render path (index.tsx) is a PURE renderer of CursorStyle — it never+ * reads the frame and is NOT exercised here (it imports `useRemocnTheme` from+ * a Remotion context). The pure-testable surface is:+ * 1. cursorPathAt — the frame-injected pure core of useCursorPath+ * 2. ripplePhase / clickPress — exported pure phase presets+ * 3. cursorConfig.snippet — the customizer JSX codegen+ *+ * Runner: Bun's built-in test runner (TypeScript-native, no framework dep).+ * bun test registry/remocn-ui/cursor/__tests__+ *+ * --------------------------------------------------------------------------+ * IMPORT STRATEGY+ * --------------------------------------------------------------------------+ * We import via RELATIVE paths so tsconfig aliases aren't required for the+ * pure functions under test. cursorPathAt, ripplePhase, and clickPress are+ * all exported from use-cursor-path.ts and never call useCurrentFrame() at+ * call time (only useCursorPath does — cursorPathAt is the pure extracted+ * core). cursorConfig is a plain object; .snippet is a pure string builder.+ * --------------------------------------------------------------------------+ */++import { describe, expect, it } from "bun:test";+import {+ cursorPathAt,+ ripplePhase,+ clickPress,+ DEFAULT_DURATION,+ CLICK_FRAMES,+ PRESS_FRAMES,+ type CursorWaypoint,+} from "../use-cursor-path";+import { cursorConfig } from "../config";++// ===========================================================================+// Shared helpers+// ===========================================================================++/** Convenience wrapper — injects a raw frame into cursorPathAt. */+function pathAt(waypoints: CursorWaypoint[], raw: number, speed = 1) {+ return cursorPathAt(waypoints, raw, { speed });+}++/** Minimal shape mirroring the customizer's value bag passed to snippet(). */+type SnippetValues = {+ variant?: string;+ size?: number;+ mode?: string;+ rippleColor?: string;+};++const snippet = (values: SnippetValues): string =>+ cursorConfig.snippet(values as Record<string, unknown>);++// ===========================================================================+// 1. Exported constants+// ===========================================================================++describe("cursor constants", () => {+ it("DEFAULT_DURATION is 24 frames", () => {+ expect(DEFAULT_DURATION).toBe(24);+ });++ it("CLICK_FRAMES is 16 frames", () => {+ expect(CLICK_FRAMES).toBe(16);+ });++ it("PRESS_FRAMES is 8 frames", () => {+ expect(PRESS_FRAMES).toBe(8);+ });+});++// ===========================================================================+// 2. ripplePhase — PURE exported preset (use-cursor-path.ts lines 59-71)+// Opacity: 0.5*(1-p), Scale: 2.5*easings.out(p), where p = frame/CLICK_FRAMES+// ===========================================================================++describe("ripplePhase: out of range → zero ripple", () => {+ it("returns zero opacity and scale before a click (sinceClick < 0)", () => {+ const r = ripplePhase(-1);+ expect(r.rippleOpacity).toBe(0);+ expect(r.rippleScale).toBe(0);+ });++ it("returns zero opacity and scale exactly at CLICK_FRAMES (expired)", () => {+ const r = ripplePhase(CLICK_FRAMES);+ expect(r.rippleOpacity).toBe(0);+ expect(r.rippleScale).toBe(0);+ });++ it("returns zero opacity and scale well past CLICK_FRAMES", () => {+ const r = ripplePhase(CLICK_FRAMES + 10);+ expect(r.rippleOpacity).toBe(0);+ expect(r.rippleScale).toBe(0);+ });+});++describe("ripplePhase: at frame 0 (click moment)", () => {+ // p = 0/16 = 0 → opacity = 0.5*(1-0) = 0.5, scale = 2.5*out(0) = 0+ it("rippleOpacity is 0.5 at click moment", () => {+ expect(ripplePhase(0).rippleOpacity).toBeCloseTo(0.5, 10);+ });++ it("rippleScale is 0 at click moment (easing.out(0) = 0)", () => {+ expect(ripplePhase(0).rippleScale).toBeCloseTo(0, 10);+ });+});++describe("ripplePhase: mid-flight (frame = CLICK_FRAMES / 2)", () => {+ // p = 0.5 → opacity = 0.5*(1-0.5) = 0.25, scale = 2.5*out(0.5)+ // out(0.5) = 1-(1-0.5)^3 = 1-0.125 = 0.875 → scale = 2.5*0.875 = 2.1875+ const half = CLICK_FRAMES / 2; // 8++ it("rippleOpacity is 0.25 at mid-flight", () => {+ expect(ripplePhase(half).rippleOpacity).toBeCloseTo(0.25, 10);+ });++ it("rippleScale is 2.5 * (1 - (1-0.5)^3) at mid-flight", () => {+ const p = 0.5;+ const expected = 2.5 * (1 - (1 - p) ** 3);+ expect(ripplePhase(half).rippleScale).toBeCloseTo(expected, 10);+ });+});++describe("ripplePhase: just before expiry (frame = CLICK_FRAMES - 1)", () => {+ // p = 15/16 → opacity = 0.5*(1 - 15/16) = 0.5/16 ≈ 0.03125+ const lastFrame = CLICK_FRAMES - 1;++ it("rippleOpacity approaches 0 near expiry", () => {+ const p = lastFrame / CLICK_FRAMES;+ const expected = 0.5 * (1 - p);+ expect(ripplePhase(lastFrame).rippleOpacity).toBeCloseTo(expected, 10);+ });++ it("rippleScale approaches max near expiry", () => {+ const p = lastFrame / CLICK_FRAMES;+ const expected = 2.5 * (1 - (1 - p) ** 3);+ expect(ripplePhase(lastFrame).rippleScale).toBeCloseTo(expected, 10);+ });+});++describe("ripplePhase: monotonic invariants across the window", () => {+ it("opacity decreases monotonically across all frames in [0, CLICK_FRAMES)", () => {+ for (let f = 0; f < CLICK_FRAMES - 1; f++) {+ expect(ripplePhase(f).rippleOpacity).toBeGreaterThan(ripplePhase(f + 1).rippleOpacity);+ }+ });++ it("scale increases monotonically across all frames in [0, CLICK_FRAMES)", () => {+ for (let f = 0; f < CLICK_FRAMES - 1; f++) {+ expect(ripplePhase(f).rippleScale).toBeLessThan(ripplePhase(f + 1).rippleScale);+ }+ });+});++// ===========================================================================+// 3. clickPress — PURE exported preset (use-cursor-path.ts lines 78-86)+// Triangle down-up over PRESS_FRAMES, then holds at 1.+// half = 4; down: p = f/half; up: p = 1-(f-half)/half → pressScale = 1-p+// ===========================================================================++describe("clickPress: out of range → 1 (up)", () => {+ it("returns 1 before click (sinceClick < 0)", () => {+ expect(clickPress(-1)).toBe(1);+ });++ it("returns 1 at exactly PRESS_FRAMES (released)", () => {+ expect(clickPress(PRESS_FRAMES)).toBe(1);+ });++ it("returns 1 well past PRESS_FRAMES", () => {+ expect(clickPress(PRESS_FRAMES + 10)).toBe(1);+ });+});++describe("clickPress: at click moment (frame 0)", () => {+ // down half: p = 0/4 = 0 → pressScale = 1-0 = 1+ it("pressScale is 1 at frame 0 (not yet dipped)", () => {+ expect(clickPress(0)).toBeCloseTo(1, 10);+ });+});++describe("clickPress: fully pressed at half-way (frame = PRESS_FRAMES/2)", () => {+ // At the half-way boundary (frame = half = 4): entering the up phase+ // up: p = 1-(4-4)/4 = 1 → pressScale = 1-1 = 0+ const half = PRESS_FRAMES / 2; // 4++ it("pressScale is 0 at the bottom of the press dip", () => {+ expect(clickPress(half)).toBeCloseTo(0, 10);+ });+});++describe("clickPress: returning up at frame PRESS_FRAMES - 1", () => {+ // last frame (7): up phase, p = 1-(7-4)/4 = 1-0.75 = 0.25 → pressScale = 1-0.25 = 0.75+ const lastFrame = PRESS_FRAMES - 1;++ it("pressScale is back above 0 near the end of the press window", () => {+ expect(clickPress(lastFrame)).toBeGreaterThan(0);+ expect(clickPress(lastFrame)).toBeLessThan(1);+ });+});++describe("clickPress: dip then rise (down-up triangle shape)", () => {+ it("pressScale decreases from frame 0 to the midpoint", () => {+ // down phase: 0..3 (half=4, so frame 0,1,2,3 are in the down half)+ for (let f = 0; f < PRESS_FRAMES / 2 - 1; f++) {+ expect(clickPress(f)).toBeGreaterThan(clickPress(f + 1));+ }+ });++ it("pressScale increases from the midpoint back toward 1", () => {+ // up phase: 4..7+ const half = PRESS_FRAMES / 2;+ for (let f = half; f < PRESS_FRAMES - 1; f++) {+ expect(clickPress(f)).toBeLessThan(clickPress(f + 1));+ }+ });+});++// ===========================================================================+// 4. cursorPathAt — PURE core of useCursorPath+// MIRROR of use-cursor-path.ts lines 111-188.+// `raw` is the injected useCurrentFrame() * speed.+// Keep in lockstep with source.+// ===========================================================================++describe("cursorPathAt: empty waypoints", () => {+ it("returns origin with scale=1, no ripple, at any frame", () => {+ const result = cursorPathAt([], 0);+ expect(result.x).toBe(0);+ expect(result.y).toBe(0);+ expect(result.scale).toBe(1);+ expect(result.rippleOpacity).toBe(0);+ expect(result.rippleScale).toBe(0);+ });++ it("same result at a large frame with no waypoints", () => {+ const result = cursorPathAt([], 999);+ expect(result.x).toBe(0);+ expect(result.y).toBe(0);+ });+});++describe("cursorPathAt: before first arrival — cursor waits at first waypoint", () => {+ // MIRROR of use-cursor-path.ts lines 126-135 ("before the first arrival")+ const wps: CursorWaypoint[] = [{ at: 30, x: 100, y: 200 }];++ it("parks at first waypoint x/y at raw=0 (before at)", () => {+ const r = pathAt(wps, 0);+ expect(r.x).toBe(100);+ expect(r.y).toBe(200);+ expect(r.scale).toBe(1);+ expect(r.rippleOpacity).toBe(0);+ expect(r.rippleScale).toBe(0);+ expect(r.pressScale).toBe(1);+ });++ it("parks at first waypoint when raw equals first.at", () => {+ // raw <= first.at: at first.at exactly it should hold (≤ guard in source)+ const r = pathAt(wps, 30);+ expect(r.x).toBe(100);+ expect(r.y).toBe(200);+ });+});++describe("cursorPathAt: single waypoint — holds at arrival position past at", () => {+ const wps: CursorWaypoint[] = [{ at: 10, x: 50, y: 80 }];++ it("holds exactly at the waypoint after its arrival", () => {+ const r = pathAt(wps, 100);+ expect(r.x).toBe(50);+ expect(r.y).toBe(80);+ });+});++describe("cursorPathAt: two waypoints — interpolation window", () => {+ // Move from (0,0) at=0 to (100,200) at=24 with DEFAULT_DURATION=24+ // Window: [0, 24), start = 24-24 = 0+ // At raw=12: t_raw = (12-0)/24 = 0.5, then eased by inOut+ // inOut(0.5) = 4*0.5^3 = 0.5 (symmetric midpoint)+ // x = lerp(0, 100, 0.5) = 50, y = lerp(0, 200, 0.5) = 100+ const wps: CursorWaypoint[] = [+ { at: 0, x: 0, y: 0 },+ { at: 24, x: 100, y: 200 },+ ];++ it("position at midpoint uses inOut easing (default)", () => {+ const r = pathAt(wps, 12);+ // inOut(0.5) = 0.5 (cubic in-out midpoint is exact 0.5)+ expect(r.x).toBeCloseTo(50, 10);+ expect(r.y).toBeCloseTo(100, 10);+ });++ it("position at raw=0 is at the FROM waypoint (t=0)", () => {+ const r = pathAt(wps, 0);+ expect(r.x).toBeCloseTo(0, 10);+ expect(r.y).toBeCloseTo(0, 10);+ });++ it("position at raw=24 (arrival) holds at TO waypoint (t=1)", () => {+ const r = pathAt(wps, 24);+ expect(r.x).toBeCloseTo(100, 10);+ expect(r.y).toBeCloseTo(200, 10);+ });++ it("position past arrival holds at TO waypoint", () => {+ const r = pathAt(wps, 999);+ expect(r.x).toBeCloseTo(100, 10);+ expect(r.y).toBeCloseTo(200, 10);+ });+});++describe("cursorPathAt: easing override", () => {+ // Move from (0,0) at=0 to (100,0) at=24, easing=linear+ // At raw=12: t = linear(0.5) = 0.5, x = 50+ const wpsLinear: CursorWaypoint[] = [+ { at: 0, x: 0, y: 0 },+ { at: 24, x: 100, y: 0, easing: "linear" },+ ];+ // Move same path with easing=out+ // out(0.5) = 1-(1-0.5)^3 = 1-0.125 = 0.875, x = 87.5+ const wpsOut: CursorWaypoint[] = [+ { at: 0, x: 0, y: 0 },+ { at: 24, x: 100, y: 0, easing: "out" },+ ];++ it("linear easing: x=50 at midpoint", () => {+ expect(pathAt(wpsLinear, 12).x).toBeCloseTo(50, 10);+ });++ it("out easing: x = 100 * (1-(1-0.5)^3) at midpoint", () => {+ expect(pathAt(wpsOut, 12).x).toBeCloseTo(87.5, 10);+ });++ it("easing=linear gives different x than easing=out at midpoint", () => {+ expect(pathAt(wpsLinear, 12).x).not.toBeCloseTo(pathAt(wpsOut, 12).x, 3);+ });+});++describe("cursorPathAt: custom duration override", () => {+ // Waypoint with duration=12 instead of DEFAULT_DURATION=24+ // Window: [at - dur, at) = [12, 24), start=12+ // At raw=18: t=(18-12)/12=0.5+ const wps: CursorWaypoint[] = [+ { at: 0, x: 0, y: 0 },+ { at: 24, x: 100, y: 0, duration: 12 },+ ];++ it("duration=12 — cursor holds FROM position before the window start", () => {+ // Before window [12,24): raw=10 is before the move starts but after from.at=0+ // toIndex should be 1 (wps[1].at=24 > raw=10); from=wps[0], to=wps[1]+ // t=(10-12)/12 = negative → clamp01 = 0 → x = lerp(0,100,eased(0)) = 0+ const r = pathAt(wps, 10);+ expect(r.x).toBeCloseTo(0, 10);+ });++ it("duration=12 — x=50 at midpoint of the 12-frame window (raw=18)", () => {+ // inOut(0.5) = 0.5 → x = 50+ const r = pathAt(wps, 18);+ expect(r.x).toBeCloseTo(50, 10);+ });+});++describe("cursorPathAt: defaultDuration option", () => {+ // Two waypoints, no duration on second — uses defaultDuration from opts+ // With defaultDuration=12: window = [24-12, 24) = [12, 24)+ // At raw=18: t=(18-12)/12=0.5 → inOut(0.5)=0.5 → x=50+ // With defaultDuration=24 (default): t=(18-0)/24=0.75 → inOut(0.75)+ const wps: CursorWaypoint[] = [+ { at: 0, x: 0, y: 0 },+ { at: 24, x: 100, y: 0 },+ ];++ it("defaultDuration=12 gives x=50 at raw=18 (midpoint of 12-frame window)", () => {+ const r = cursorPathAt(wps, 18, { defaultDuration: 12 });+ expect(r.x).toBeCloseTo(50, 10);+ });++ it("changing defaultDuration changes the interpolated position at the same raw frame", () => {+ const r12 = cursorPathAt(wps, 18, { defaultDuration: 12 });+ const r24 = cursorPathAt(wps, 18, { defaultDuration: 24 });+ expect(r12.x).not.toBeCloseTo(r24.x, 3);+ });+});++describe("cursorPathAt: scale is always 1", () => {+ // scale=1 is an invariant in the source — the component applies pressedScale+ const wps: CursorWaypoint[] = [+ { at: 0, x: 0, y: 0 },+ { at: 24, x: 100, y: 200, click: true },+ ];++ it("scale is 1 before the path starts", () => {+ expect(pathAt(wps, 0).scale).toBe(1);+ });++ it("scale is 1 during motion", () => {+ expect(pathAt(wps, 12).scale).toBe(1);+ });++ it("scale is 1 after arrival with a click", () => {+ expect(pathAt(wps, 30).scale).toBe(1);+ });+});++// ===========================================================================+// 5. Click visuals — ripple and press-dip fire at a `click: true` waypoint+// MIRROR of use-cursor-path.ts lines 162-178+// ===========================================================================++describe("cursorPathAt: no click — ripple stays zero", () => {+ const wps: CursorWaypoint[] = [+ { at: 0, x: 0, y: 0 },+ { at: 24, x: 100, y: 0 },+ ];++ it("rippleOpacity is 0 at any frame when no waypoint has click:true", () => {+ expect(pathAt(wps, 0).rippleOpacity).toBe(0);+ expect(pathAt(wps, 24).rippleOpacity).toBe(0);+ expect(pathAt(wps, 30).rippleOpacity).toBe(0);+ });+});++describe("cursorPathAt: click:true — ripple and press-dip fire at arrival", () => {+ // Click fires at at=24. sinceClick at raw=24 is 0.+ const wps: CursorWaypoint[] = [+ { at: 0, x: 0, y: 0 },+ { at: 24, x: 100, y: 0, click: true },+ ];++ it("rippleOpacity is 0 before the click waypoint arrival", () => {+ expect(pathAt(wps, 20).rippleOpacity).toBe(0);+ expect(pathAt(wps, 23).rippleOpacity).toBe(0);+ });++ it("rippleOpacity is 0.5 exactly at click arrival (sinceClick=0)", () => {+ // ripplePhase(0).rippleOpacity = 0.5*(1-0) = 0.5+ expect(pathAt(wps, 24).rippleOpacity).toBeCloseTo(0.5, 10);+ });++ it("rippleOpacity decays to 0 after CLICK_FRAMES since click", () => {+ // raw = 24 + CLICK_FRAMES → sinceClick = CLICK_FRAMES → out of range → 0+ expect(pathAt(wps, 24 + CLICK_FRAMES).rippleOpacity).toBe(0);+ });++ it("pressScale is 1 at frame 0 of click dip (not yet dipped)", () => {+ // clickPress(0) = 1 (first frame hasn't dipped yet — down phase p=0)+ expect(pathAt(wps, 24).pressScale).toBeCloseTo(1, 10);+ });++ it("pressScale is 0 at the midpoint of the press dip", () => {+ // sinceClick = PRESS_FRAMES/2 = 4 → clickPress(4) = 0+ expect(pathAt(wps, 24 + PRESS_FRAMES / 2).pressScale).toBeCloseTo(0, 10);+ });++ it("pressScale returns to 1 after the press window completes", () => {+ // sinceClick = PRESS_FRAMES = 8 → clickPress(8) = 1+ expect(pathAt(wps, 24 + PRESS_FRAMES).pressScale).toBeCloseTo(1, 10);+ });+});++describe("cursorPathAt: multiple clicks — only the most recent active click fires", () => {+ // Two click waypoints; at raw = first.at + 5, only the first should be active.+ // At raw = second.at + 2, only the second should be active.+ const wps: CursorWaypoint[] = [+ { at: 0, x: 0, y: 0, click: true },+ { at: 48, x: 100, y: 100, click: true },+ ];++ it("ripple fires from the first click at raw=5 (sinceClick=5)", () => {+ const r = pathAt(wps, 5);+ const expected = ripplePhase(5);+ expect(r.rippleOpacity).toBeCloseTo(expected.rippleOpacity, 10);+ expect(r.rippleScale).toBeCloseTo(expected.rippleScale, 10);+ });++ it("ripple fires from the second click at raw=50 (sinceClick=2)", () => {+ const r = pathAt(wps, 50);+ const expected = ripplePhase(2);+ expect(r.rippleOpacity).toBeCloseTo(expected.rippleOpacity, 10);+ expect(r.rippleScale).toBeCloseTo(expected.rippleScale, 10);+ });++ it("between clicks, first ripple has expired at raw=40 (sinceClick=40 >= CLICK_FRAMES=16)", () => {+ const r = pathAt(wps, 40);+ expect(r.rippleOpacity).toBe(0);+ expect(r.rippleScale).toBe(0);+ });+});++// ===========================================================================+// 6. Press (drag) — held press visual channel+// MIRROR of use-cursor-path.ts lines 173-178+// ===========================================================================++describe("cursorPathAt: press:true — held press look", () => {+ // press:true on a segment means the FROM waypoint has press=true while we are+ // resting at or moving away from it. heldPress = holdWp.press ? 0 : 1.+ const wps: CursorWaypoint[] = [+ { at: 0, x: 0, y: 0, press: true },+ { at: 48, x: 100, y: 100 },+ ];++ it("pressScale is 0 (fully pressed) while the press segment is active", () => {+ // raw=10: toIndex=1 (wps[1].at=48>10), from=wps[0] (press:true), holdWp=from+ // heldPress=0, no click dip → pressScale = min(1, 0) = 0+ expect(pathAt(wps, 10).pressScale).toBe(0);+ });++ it("pressScale is 0 just before second waypoint arrives", () => {+ expect(pathAt(wps, 47).pressScale).toBe(0);+ });++ it("pressScale is 1 after the second (non-press) waypoint arrives", () => {+ // pastLast=true → holdWp = last waypoint (wps[1], press=undefined → falsy)+ // heldPress = 1, no click → pressScale = min(1,1) = 1+ expect(pathAt(wps, 48).pressScale).toBe(1);+ });+});++describe("cursorPathAt: no press flag — pressScale is always 1", () => {+ const wps: CursorWaypoint[] = [+ { at: 0, x: 0, y: 0 },+ { at: 24, x: 100, y: 0 },+ ];++ it("pressScale is 1 during motion (no press, no click)", () => {+ expect(pathAt(wps, 12).pressScale).toBe(1);+ });+});++// ===========================================================================+// 7. Speed contract — speed scales the playhead+// MIRROR of use-cursor-path.ts lines 97-104 (useCursorPath)+// effectiveFrame = raw * speed; cursorPathAt receives raw with speed in opts+// ===========================================================================++describe("cursorPathAt: speed contract", () => {+ // Single move: at=0 → at=24, DEFAULT_DURATION=24, no easing override (inOut)+ // At raw=6, speed=2: effectiveFrame=12. inOut(0.5)=0.5 → x=50.+ // At raw=24, speed=2: effectiveFrame=48, pastLast → x=100.+ const wps: CursorWaypoint[] = [+ { at: 0, x: 0, y: 0 },+ { at: 24, x: 100, y: 0 },+ ];++ it("speed=2: arrival reached at raw=12 (effectiveFrame=24)", () => {+ const r = pathAt(wps, 12, 2);+ expect(r.x).toBeCloseTo(100, 10);+ });++ it("speed=2: midpoint at raw=6 (effectiveFrame=12)", () => {+ const r = pathAt(wps, 6, 2);+ expect(r.x).toBeCloseTo(50, 10);+ });++ it("speed=0.5: arrival not reached at raw=24 (effectiveFrame=12)", () => {+ // effectiveFrame=12, t=(12-0)/24=0.5, inOut(0.5)=0.5 → x=50+ const r = pathAt(wps, 24, 0.5);+ expect(r.x).toBeCloseTo(50, 10);+ });++ it("speed=0.5: arrival reached at raw=48 (effectiveFrame=24)", () => {+ const r = pathAt(wps, 48, 0.5);+ expect(r.x).toBeCloseTo(100, 10);+ });++ it("speed=1 matches the default (no speed option) at every sample", () => {+ for (const raw of [0, 6, 12, 18, 24, 30]) {+ const withSpeed = pathAt(wps, raw, 1);+ const withDefault = cursorPathAt(wps, raw);+ expect(withSpeed.x).toBeCloseTo(withDefault.x, 10);+ expect(withSpeed.y).toBeCloseTo(withDefault.y, 10);+ }+ });+});++// ===========================================================================+// 8. Three-waypoint path — correct segment selection+// ===========================================================================++describe("cursorPathAt: three waypoints — segment selection", () => {+ const wps: CursorWaypoint[] = [+ { at: 0, x: 0, y: 0 },+ { at: 24, x: 100, y: 0 },+ { at: 48, x: 200, y: 0 },+ ];++ it("during first segment, x is between 0 and 100", () => {+ const r = pathAt(wps, 12);+ expect(r.x).toBeGreaterThan(0);+ expect(r.x).toBeLessThan(100);+ });++ it("at first arrival (raw=24), x is exactly 100", () => {+ expect(pathAt(wps, 24).x).toBeCloseTo(100, 10);+ });++ it("during second segment, x is between 100 and 200", () => {+ const r = pathAt(wps, 36);+ expect(r.x).toBeGreaterThan(100);+ expect(r.x).toBeLessThan(200);+ });++ it("at second arrival (raw=48), x is exactly 200", () => {+ expect(pathAt(wps, 48).x).toBeCloseTo(200, 10);+ });++ it("past last arrival, x holds at 200", () => {+ expect(pathAt(wps, 999).x).toBeCloseTo(200, 10);+ });+});++// ===========================================================================+// 9. cursorConfig.controls — customizer control wiring+// ===========================================================================++describe("cursorConfig.controls: variant", () => {+ it("variant is a select control", () => {+ expect(cursorConfig.controls.variant.type).toBe("select");+ });++ it("variant options are ['arrow', 'pointer']", () => {+ const ctrl = cursorConfig.controls.variant;+ if (ctrl.type !== "select") throw new Error("expected select");+ expect(ctrl.options).toEqual(["arrow", "pointer"]);+ });++ it("variant default is 'arrow'", () => {+ expect(cursorConfig.controls.variant.default).toBe("arrow");+ });+});++describe("cursorConfig.controls: size", () => {+ it("size is a number control", () => {+ expect(cursorConfig.controls.size.type).toBe("number");+ });++ it("size default is 28", () => {+ expect(cursorConfig.controls.size.default).toBe(28);+ });++ it("size min is 16", () => {+ const ctrl = cursorConfig.controls.size;+ if (ctrl.type !== "number") throw new Error("expected number");+ expect(ctrl.min).toBe(16);+ });++ it("size max is 64", () => {+ const ctrl = cursorConfig.controls.size;+ if (ctrl.type !== "number") throw new Error("expected number");+ expect(ctrl.max).toBe(64);+ });+});++describe("cursorConfig.controls: mode", () => {+ it("mode is a select control", () => {+ expect(cursorConfig.controls.mode.type).toBe("select");+ });++ it("mode options are ['light', 'dark']", () => {+ const ctrl = cursorConfig.controls.mode;+ if (ctrl.type !== "select") throw new Error("expected select");+ expect(ctrl.options).toEqual(["light", "dark"]);+ });++ it("mode default is 'light'", () => {+ expect(cursorConfig.controls.mode.default).toBe("light");+ });+});++describe("cursorConfig.controls: rippleColor", () => {+ it("rippleColor is a color control", () => {+ expect(cursorConfig.controls.rippleColor.type).toBe("color");+ });++ it("rippleColor default is '#171717'", () => {+ expect(cursorConfig.controls.rippleColor.default).toBe("#171717");+ });+});++// ===========================================================================+// 10. cursorConfig.snippet — pure JSX string builder+// ===========================================================================++describe("cursorConfig.snippet: import lines", () => {+ it("includes 'import { Cursor }' from the correct path", () => {+ const out = snippet({});+ expect(out).toContain("import { Cursor }");+ expect(out).toContain('from "@/components/remocn/cursor"');+ });++ it("includes 'import { useCursorPath }' from the correct path", () => {+ const out = snippet({});+ expect(out).toContain("import { useCursorPath }");+ expect(out).toContain('from "@/components/remocn/use-cursor-path"');+ });+});++describe("cursorConfig.snippet: structural invariants", () => {+ it("contains a <Cursor JSX element", () => {+ expect(snippet({})).toContain("<Cursor");+ });++ it("ends with a self-closing />", () => {+ expect(snippet({}).trimEnd().endsWith("/>")).toBe(true);+ });++ it("contains the useCursorPath invocation with an example waypoint array", () => {+ const out = snippet({});+ expect(out).toContain("useCursorPath(");+ });+});++describe("cursorConfig.snippet: default props are omitted", () => {+ // Defaults: variant=arrow, size=28, mode=light+ const allDefaults = snippet({ variant: "arrow", size: 28, mode: "light" });++ it("omits variant when it equals 'arrow'", () => {+ expect(allDefaults).not.toContain("variant=");+ });++ it("omits size when it equals 28", () => {+ expect(allDefaults).not.toContain("size=");+ });++ it("omits mode when it equals 'light'", () => {+ expect(allDefaults).not.toContain("mode=");+ });+});++describe("cursorConfig.snippet: non-default props are emitted", () => {+ it("emits variant='pointer' when non-default", () => {+ expect(snippet({ variant: "pointer" })).toContain('variant="pointer"');+ });++ it("emits size={32} when non-default", () => {+ expect(snippet({ size: 32 })).toContain("size={32}");+ });++ it("emits mode='dark' when non-default", () => {+ expect(snippet({ mode: "dark" })).toContain('mode="dark"');+ });++ it("does NOT emit variant for the default 'arrow' even when explicitly passed", () => {+ expect(snippet({ variant: "arrow" })).not.toContain("variant=");+ });+});++describe("cursorConfig.snippet: snippet always includes style={style} prop", () => {+ it("includes style={style} in every variant", () => {+ expect(snippet({})).toContain("style={style}");+ expect(snippet({ variant: "pointer" })).toContain("style={style}");+ expect(snippet({ mode: "dark", size: 40 })).toContain("style={style}");+ });+});diff --git a/registry/remocn-ui/cursor/config.ts b/registry/remocn-ui/cursor/config.tsnew file mode 100644index 00000000..64ac6fc1--- /dev/null+++ b/registry/remocn-ui/cursor/config.ts@@ -0,0 +1,51 @@+import { type ComponentConfig, FPS, H, W } from "@/lib/customizer-config";++export const cursorConfig: ComponentConfig = {+ componentName: "Cursor",+ importPath: "@/components/remocn/cursor",+ controls: {+ variant: {+ type: "select",+ default: "arrow",+ options: ["arrow", "pointer"],+ label: "Variant",+ },+ size: { type: "number", default: 28, min: 16, max: 64, step: 2, label: "Size" },+ mode: {+ type: "select",+ default: "light",+ options: ["light", "dark"],+ label: "Mode",+ },+ rippleColor: { type: "color", default: "#171717", label: "Ripple" },+ },+ durationInFrames: 120,+ fps: FPS,+ compositionWidth: W,+ compositionHeight: H,+ snippet: (values) => {+ const variant = values.variant as string | undefined;+ const size = values.size as number | undefined;+ const mode = values.mode as string | undefined;++ const props: string[] = [" style={style}"];+ if (variant !== undefined && variant !== "arrow")+ props.push(` variant="${variant}"`);+ if (size !== undefined && size !== 28) props.push(` size={${size}}`);+ if (mode !== undefined && mode !== "light") props.push(` mode="${mode}"`);++ return `import { Cursor } from "@/components/remocn/cursor";+import { useCursorPath } from "@/components/remocn/use-cursor-path";++// The cursor is value-channel driven: \`useCursorPath\` reads the frame and+// returns the animated \`CursorStyle\`; \`<Cursor>\` itself stays pure.+const style = useCursorPath([+ { at: 0, x: 120, y: 120 },+ { at: 24, x: 360, y: 200, click: true },+]);++<Cursor+${props.join("\n")}+/>`;+ },+};diff --git a/registry/remocn-ui/cursor/index.tsx b/registry/remocn-ui/cursor/index.tsxnew file mode 100644index 00000000..bf2e6e82--- /dev/null+++ b/registry/remocn-ui/cursor/index.tsx@@ -0,0 +1,154 @@+"use client";++import { type RemocnTheme, useRemocnTheme } from "@/lib/remocn-ui";++export type CursorVariant = "arrow" | "pointer";++// ===========================================================================+// Cursor visual — the COMPLETE animated look for a moment in time. The animated+// channel here is numeric (position + ripple phase), the accepted value-channel+// deviation from the string-`state` atoms (see STYLE-GUIDE §"value channel"):+// `useCursorPath` feeds an interpolated `CursorStyle` straight through, exactly+// like `style` on a state atom. The component is a pure renderer — it never+// reads the frame.+// ===========================================================================++export interface CursorStyle {+ /** Tip X in px, relative to the absolute wrapper's parent. */+ x: number;+ /** Tip Y in px, relative to the absolute wrapper's parent. */+ y: number;+ /** Cursor scale (1 = rest). A click dips this toward `pressScale` briefly. */+ scale: number;+ /** Ripple circle opacity (0 = gone). */+ rippleOpacity: number;+ /** Ripple circle scale (0 → ~2.5 over a click). */+ rippleScale: number;+ /**+ * Held press visual (1 = up, 0 = fully pressed). Drives the press dip while a+ * `press` segment (drag) is held; `useCursorPath` blends it with the click dip.+ */+ pressScale?: number;+}++export interface CursorProps {+ /**+ * Resolved animated visual (smooth path). When provided, takes precedence over+ * the resting `style` defaults — feed it an interpolated `CursorStyle` from+ * `useCursorPath`.+ */+ style?: CursorStyle;+ /** macOS arrow or hand pointer. Static choice, not animated. */+ variant?: CursorVariant;+ /** Rendered cursor height in px (the SVG scales to it). Default 28. */+ size?: number;+ theme?: Partial<RemocnTheme>;+ mode?: "light" | "dark";+ /** Ripple ring color. Defaults to `theme.primary`. */+ rippleColor?: string;+ className?: string;+}++/** The resting visual when no `style` is supplied (cursor parked at origin). */+const REST: CursorStyle = {+ x: 0,+ y: 0,+ scale: 1,+ rippleOpacity: 0,+ rippleScale: 0,+};++// Hand-drawn SVGs on a 24×24 grid; the tip (hotspot) sits at (0,0) so `x`/`y`+// position the pointing tip exactly, like a real cursor hotspot.+const ARROW_PATH =+ "M1 1 L1 18.5 L5.6 14.4 L8.7 21.6 L11.6 20.4 L8.5 13.2 L14.5 13.2 Z";+const POINTER_PATH =+ "M8 2.2 C8 1.3 8.7 0.7 9.5 0.7 C10.3 0.7 11 1.3 11 2.2 L11 9 " ++ "C11 9 11.3 8.4 12.2 8.4 C13 8.4 13.4 9 13.4 9.6 " ++ "C13.4 9.6 13.9 9.1 14.7 9.1 C15.5 9.1 15.9 9.7 15.9 10.3 " ++ "C15.9 10.3 16.4 9.9 17.1 9.9 C17.9 9.9 18.3 10.5 18.3 11.2 " ++ "L18.3 16.8 C18.3 19.8 16.3 22.3 12.8 22.3 L11.4 22.3 " ++ "C9 22.3 7.9 21.2 6.6 19.2 L4 15.2 C3.5 14.4 3.7 13.4 4.5 12.9 " ++ "C5.1 12.5 5.9 12.6 6.4 13.2 L8 15 Z";++/**+ * A deterministic animated cursor. Pure renderer of whatever `CursorStyle` it+ * receives — it reads no frame, holds no state, runs no effects. The single time+ * source is `useCursorPath`, on the caller's side; this component cannot tell+ * whether the `style` it got was a resting preset or an interpolated frame.+ */+export function Cursor({+ style,+ variant = "arrow",+ size = 28,+ theme: themeOverride,+ mode,+ rippleColor,+ className,+}: CursorProps) {+ const theme = useRemocnTheme(themeOverride, mode);+ const v = style ?? REST;++ // Press dips the cursor; click and held-press dips combine to one factor.+ const press = v.pressScale ?? 1;+ const pressedScale = v.scale * (0.9 + 0.1 * press);++ const ring = rippleColor ?? theme.primary;+ const fill = theme.foreground;+ const stroke = theme.background;+ // Ripple is centered on the cursor tip (the hotspot at the SVG origin).+ const rippleSize = size * 1.8;++ return (+ <div+ className={className}+ style={{+ position: "absolute",+ left: 0,+ top: 0,+ transform: `translate(${v.x}px, ${v.y}px)`,+ pointerEvents: "none",+ }}+ >+ {/* Ripple sits UNDER the tip and is centered on the hotspot. */}+ <div+ style={{+ position: "absolute",+ left: -rippleSize / 2,+ top: -rippleSize / 2,+ width: rippleSize,+ height: rippleSize,+ borderRadius: "50%",+ border: `2px solid ${ring}`,+ opacity: v.rippleOpacity,+ transform: `scale(${v.rippleScale})`,+ transformOrigin: "center",+ }}+ />+ {/* Cursor SVG, scaled about its tip so the hotspot stays anchored. */}+ <svg+ width={size}+ height={size}+ viewBox="0 0 24 24"+ fill="none"+ style={{+ position: "absolute",+ left: 0,+ top: 0,+ transform: `scale(${pressedScale})`,+ transformOrigin: "0 0",+ filter: "drop-shadow(0 1px 2px rgba(0,0,0,0.3))",+ overflow: "visible",+ }}+ >+ <path+ d={variant === "pointer" ? POINTER_PATH : ARROW_PATH}+ fill={fill}+ stroke={stroke}+ strokeWidth={1.4}+ strokeLinejoin="round"+ />+ </svg>+ </div>+ );+}diff --git a/registry/remocn-ui/cursor/preview.tsx b/registry/remocn-ui/cursor/preview.tsxnew file mode 100644index 00000000..a172c17d--- /dev/null+++ b/registry/remocn-ui/cursor/preview.tsx@@ -0,0 +1,55 @@+"use client";++import { Cursor, type CursorVariant } from "@/registry/remocn-ui/cursor";+import { useCursorPath } from "@/registry/remocn-ui/cursor/use-cursor-path";++export interface CursorPreviewProps {+ variant?: CursorVariant;+ size?: number;+ rippleColor?: string;+ mode?: "light" | "dark";+ speed?: number;+}++/**+ * Preview-only wrapper for the customizer. The shipped `Cursor` is a pure+ * renderer driven by `useCursorPath`; the customizer Player can only pass scalar+ * control values, so this thin wrapper runs a fixed demo path (move → click →+ * drag → move) and feeds the resulting `CursorStyle` to `<Cursor>`. NOT shipped:+ * not listed in registry.json files; users author their own path.+ */+export function CursorPreview({+ variant = "arrow",+ size = 28,+ rippleColor,+ mode,+ speed = 1,+}: CursorPreviewProps) {+ const style = useCursorPath(+ [+ { at: 0, x: 360, y: 220 },+ { at: 24, x: 720, y: 300, click: true },+ { at: 60, x: 720, y: 300, press: true },+ { at: 90, x: 540, y: 420 },+ ],+ { speed },+ );++ return (+ <div+ style={{+ position: "absolute",+ inset: 0,+ background: mode === "dark" ? "#0a0a0a" : "#ffffff",+ }}+ >+ <Cursor+ style={style}+ variant={variant}+ size={size}+ rippleColor={rippleColor}+ mode={mode}+ />+ </div>+ );+}diff --git a/registry/remocn-ui/cursor/use-cursor-path.ts b/registry/remocn-ui/cursor/use-cursor-path.tsnew file mode 100644index 00000000..3f9ba0fb--- /dev/null+++ b/registry/remocn-ui/cursor/use-cursor-path.ts@@ -0,0 +1,188 @@+"use client";++import { useCurrentFrame } from "remotion";+import {+ clamp01,+ type EasingName,+ easings,+} from "@/lib/remocn-ui";+import type { CursorStyle } from "@/components/remocn/cursor";+// ^ install path; resolves in-repo via the @/components/remocn/* tsconfig alias.++/**+ * A scripted point the cursor moves to. The cursor eases from the previous+ * waypoint's position to this one over `[at, at + (duration ?? DEFAULT_DURATION))`.+ */+export interface CursorWaypoint {+ /** LOCAL (Sequence-relative) authored frame the cursor finishes arriving here. */+ at: number;+ /** Tip X in px (parent-relative). */+ x: number;+ /** Tip Y in px (parent-relative). */+ y: number;+ /** Frames the move INTO this waypoint takes. Omitted → DEFAULT_DURATION. */+ duration?: number;+ /** Fire a click on arrival: a ripple (~CLICK_FRAMES) + a brief press dip. */+ click?: boolean;+ /** Hold the pressed look from this waypoint until the next one (drag). */+ press?: boolean;+ /** Override the easing for the move into this waypoint. Default `inOut`. */+ easing?: EasingName;+}++/** Default frames for a move into a waypoint when it omits `duration`. */+export const DEFAULT_DURATION = 24;++/** Frames a click ripple takes to scale up and fully fade out. */+export const CLICK_FRAMES = 16;++/** Frames the cursor's click press-dip lasts (a quick down-and-up). */+export const PRESS_FRAMES = 8;++export interface CursorPathOptions {+ /** Playhead scale (effectiveFrame = useCurrentFrame() * speed). */+ speed?: number;+ /** Move duration (frames) when a waypoint omits `duration`. */+ defaultDuration?: number;+}++/** Linear blend; numeric channels only. */+function lerp(a: number, b: number, t: number): number {+ return a + (b - a) * t;+}++/**+ * The ripple's opacity + scale for `framesSinceClick` into a click. Pure preset+ * of the click phase: scale ramps 0 → ~2.5 (eased out), opacity 0.5 → 0. Past+ * CLICK_FRAMES the ripple is fully gone. Exported for the pure-surface tests.+ */+export function ripplePhase(framesSinceClick: number): {+ rippleOpacity: number;+ rippleScale: number;+} {+ if (framesSinceClick < 0 || framesSinceClick >= CLICK_FRAMES) {+ return { rippleOpacity: 0, rippleScale: 0 };+ }+ const p = clamp01(framesSinceClick / CLICK_FRAMES);+ return {+ rippleOpacity: 0.5 * (1 - p),+ rippleScale: 2.5 * easings.out(p),+ };+}++/**+ * The momentary click press-dip for `framesSinceClick` into a click: dips+ * 1 → 0 → 1 over PRESS_FRAMES (a quick down-and-up), then holds at 1. Returned+ * as `pressScale` (1 = up, 0 = fully pressed). Pure; exported for tests.+ */+export function clickPress(framesSinceClick: number): number {+ if (framesSinceClick < 0 || framesSinceClick >= PRESS_FRAMES) return 1;+ const half = PRESS_FRAMES / 2;+ const p =+ framesSinceClick < half+ ? framesSinceClick / half // down+ : 1 - (framesSinceClick - half) / half; // up+ return 1 - clamp01(p);+}++/**+ * Resolve the cursor's `CursorStyle` for a path of waypoints. THIS is the only+ * frame-reading file in the component — `<Cursor>` itself stays pure. Mirrors+ * the value-channel deviation: instead of a string-state timeline it folds a+ * numeric position path plus click/press phases.+ *+ * The fold is a pure function of `raw = useCurrentFrame() * speed`; the tests+ * replicate `cursorPathAt(waypoints, raw, opts)` with the frame injected.+ */+export function useCursorPath(+ waypoints: CursorWaypoint[],+ opts: CursorPathOptions = {},+): CursorStyle {+ const { speed = 1 } = opts;+ const raw = useCurrentFrame() * speed;+ return cursorPathAt(waypoints, raw, opts);+}++/**+ * Pure core of `useCursorPath` with the effective frame injected as `raw`. Kept+ * separate so it can be unit-tested without a Remotion render. `useCursorPath`+ * is exactly `cursorPathAt(waypoints, useCurrentFrame() * speed, opts)`.+ */+export function cursorPathAt(+ waypoints: CursorWaypoint[],+ raw: number,+ opts: CursorPathOptions = {},+): CursorStyle {+ const { defaultDuration = DEFAULT_DURATION } = opts;++ if (waypoints.length === 0) {+ return { x: 0, y: 0, scale: 1, rippleOpacity: 0, rippleScale: 0 };+ }++ // Authored order is the path order; `at` is the arrival frame of each point.+ const first = waypoints[0];++ // Before the first arrival, the cursor waits parked at the first waypoint.+ if (raw <= first.at) {+ return {+ x: first.x,+ y: first.y,+ scale: 1,+ rippleOpacity: 0,+ rippleScale: 0,+ pressScale: 1,+ };+ }++ // Find the segment we're in: the move from waypoint i-1 into waypoint i, where+ // i is the first waypoint with at > raw. If none, we're resting at the last.+ let toIndex = waypoints.length - 1;+ for (let i = 1; i < waypoints.length; i++) {+ if (waypoints[i].at > raw) {+ toIndex = i;+ break;+ }+ }+ // If raw is past the last arrival, hold at the last waypoint.+ const pastLast = raw >= waypoints[waypoints.length - 1].at;+ const to = pastLast ? waypoints[waypoints.length - 1] : waypoints[toIndex];+ const from = pastLast+ ? waypoints[waypoints.length - 1]+ : waypoints[toIndex - 1];++ const dur = to.duration ?? defaultDuration;+ const ease = easings[to.easing ?? "inOut"];+ // The move runs over [start, to.at); start = to.at - dur.+ const start = to.at - dur;+ const t = pastLast || dur <= 0 ? 1 : ease(clamp01((raw - start) / dur));+ const x = lerp(from.x, to.x, t);+ const y = lerp(from.y, to.y, t);++ // Click visuals: ripple + press-dip start at the arrival of any waypoint with+ // `click`. Find the most recent such arrival at or before `raw`.+ let lastClickAt = -Infinity;+ for (const wp of waypoints) {+ if (wp.click && wp.at <= raw && wp.at > lastClickAt) lastClickAt = wp.at;+ }+ const sinceClick = lastClickAt === -Infinity ? -1 : raw - lastClickAt;+ const ripple = ripplePhase(sinceClick);+ const clickDip = clickPress(sinceClick);++ // Held press (drag): the segment we're resting at / arrived from is `pressed`+ // when the waypoint that STARTED the current hold has `press: true`. We hold+ // the look from a `press` waypoint's arrival until the next waypoint arrives.+ const holdWp = pastLast ? waypoints[waypoints.length - 1] : from;+ const heldPress = holdWp.press ? 0 : 1;++ // Combine the momentary click dip with the held drag press (min = most down).+ const pressScale = Math.min(clickDip, heldPress);++ return {+ x,+ y,+ scale: 1,+ rippleOpacity: ripple.rippleOpacity,+ rippleScale: ripple.rippleScale,+ pressScale,+ };+}diff --git a/registry/remocn-ui/registry.json b/registry/remocn-ui/registry.jsonindex 5a9ce006..97342847 100644--- a/registry/remocn-ui/registry.json+++ b/registry/remocn-ui/registry.json@@ -356,6 +356,26 @@"target": "components/remocn/use-dropdown-menu-transition.ts"}]+ },+ {+ "name": "cursor",+ "type": "registry:component",+ "title": "UI Cursor",+ "description": "An animated cursor that moves between waypoints, clicks (ripple), and drags. The Cursor renderer is a pure function of a numeric CursorStyle channel; useCursorPath reads the frame and eases the path, ripple, and press phases.",+ "dependencies": ["remotion"],+ "registryDependencies": ["remocn-ui"],+ "files": [+ {+ "path": "cursor/index.tsx",+ "type": "registry:component",+ "target": "components/remocn/cursor.tsx"+ },+ {+ "path": "cursor/use-cursor-path.ts",+ "type": "registry:component",+ "target": "components/remocn/use-cursor-path.ts"+ }+ ]}]}