Skip to content

Create polished demo videos without editing skills. Mac/Windows/Linux

feat(extensions): marketplace integration, wallpaper thumbnails, cursor packs, and bug fixes

webadderall3a11981bc2fe
diff --git a/EXTENSIONS.md b/EXTENSIONS.md
index 60b40493..2dc6f8d6 100644
--- a/EXTENSIONS.md
+++ b/EXTENSIONS.md
@@ -1,21 +1,19 @@
# Recordly Extension API
-Extensions add render hooks, device frames, click animations, audio cues, and custom settings UI to Recordly. They run in the renderer process and use a permission-gated host API to hook into the frame render pipeline.
+Recordly extensions run in the editor renderer and use a permission-gated host API. They can draw into the render pipeline, react to playback and export events, register cursor effects, add settings panels, and contribute packaged assets such as frames, wallpapers, and cursor styles.
## Quick Start
-Create a folder under `public/builtin-extensions/` (for built-ins) or install via the Extensions tab.
+For local user-installed extensions, use `Extensions -> Open Directory` in the app. Recordly stores them in the app `userData/extensions` directory. This repo also includes installable example bundles under `extension-examples/`.
### Minimum Extension
-```
+```text
my-extension/
recordly-extension.json
index.js
```
-**recordly-extension.json**
-
```json
{
"id": "com.example.my-extension",
@@ -29,318 +27,263 @@ my-extension/
}
```
-**index.js**
-
```js
export function activate(api) {
- api.log('Hello from my extension!');
+ api.log("Hello from my extension");
}
export function deactivate() {}
```
-## Extension Manifest
+### TypeScript
-| Field | Type | Required | Description |
-|-------|------|----------|-------------|
-| `id` | `string` | ✅ | Unique identifier (reverse-domain style) |
-| `name` | `string` | ✅ | Display name |
-| `version` | `string` | ✅ | Semver version |
-| `description` | `string` | ✅ | One-line summary |
-| `author` | `string` | | Author or org name |
-| `homepage` | `string` | | Repository/homepage URL |
-| `license` | `string` | | SPDX license identifier |
-| `engine` | `string` | | Minimum Recordly version |
-| `icon` | `string` | | Path to icon relative to extension root |
-| `main` | `string` | ✅ | Entry point JS file |
-| `permissions` | `string[]` | ✅ | Required API permissions |
-| `contributes` | `object` | | Optional metadata for bundled assets; behavior is still registered from `activate()` |
-
-### Permissions
+Extensions can be authored in TypeScript. Import the `RecordlyExtensionAPI` type from `types.ts` in this repo for full IDE auto-complete and compile-time checks:
-| Permission | Grants access to |
-|-----------|-----------------|
-| `render` | Frame render pipeline hooks |
-| `cursor` | Cursor telemetry & cursor effect registration |
-| `audio` | Sound playback |
-| `timeline` | Timeline lifecycle events |
-| `ui` | Settings panels & frames |
-| `assets` | Bundled asset path resolution |
-| `export` | Export lifecycle hooks |
+```ts
+import type { RecordlyExtensionAPI } from "./types";
+
+export function activate(api: RecordlyExtensionAPI) {
+ api.registerRenderHook("final", (ctx) => {
+ ctx.ctx.fillStyle = "rgba(255,255,255,0.1)";
+ ctx.ctx.fillRect(0, 0, ctx.width, 30);
+ });
+}
-Manifest `contributes` entries are metadata only today. Recordly does not auto-register them at runtime; extensions still need to call APIs like `registerFrame()`, `registerSettingsPanel()`, `resolveAsset()`, and `playSound()` from `activate()`.
+export function deactivate() {}
+```
-## API Reference
+Recordly loads the `main` entry from the manifest, which must be a `.js` file. If you author in TypeScript, compile or bundle to JavaScript before packaging. A `tsconfig.json` with `"module": "ESNext"` and `"target": "ESNext"` works well since extensions run in a Chromium renderer.
-The `api` object passed to `activate()` provides the following methods.
+### Manifest Screenshots
-### Render Hooks
+Extensions can include `screenshots` in the manifest to show preview images in the marketplace:
-```js
-const dispose = api.registerRenderHook(phase, (ctx) => {
- // Draw on ctx.ctx (a CanvasRenderingContext2D)
-});
+```json
+{
+ "id": "com.example.my-extension",
+ "screenshots": [
+ "screenshots/preview-1.png",
+ "screenshots/preview-2.png"
+ ]
+}
```
-**Phases** (in pipeline order):
+Paths are relative to the extension root. The marketplace displays screenshots in a carousel on both the in-app detail modal and the web detail page.
-| Phase | Timing |
-|-------|--------|
-| `background` | Before video frame (custom backgrounds) |
-| `post-video` | After video, before zoom |
-| `post-zoom` | After zoom transform |
-| `post-cursor` | After cursor (click effects, trails) |
-| `post-webcam` | After webcam overlay |
-| `post-annotations` | After annotations |
-| `final` | Last pass (watermarks, HUD overlays) |
+## Manifest
-**RenderHookContext** fields:
+`recordly-extension.json` is validated both when the extension loads and when a zip is uploaded to the marketplace.
-- `width`, `height` — output canvas dimensions
-- `timeMs` — current playback time in ms
-- `durationMs` — total video duration
-- `cursor` — `{ cx, cy, interactionType } | null` (normalized 0-1)
-- `smoothedCursor` — `{ cx, cy, trail } | null` using the live rendered cursor smoothing state
-- `ctx` — `CanvasRenderingContext2D` to draw on
-- `videoLayout` — `{ maskRect, borderRadius, padding }`
-- `zoom` — `{ scale, focusX, focusY, progress }`
-- `shadow` — `{ enabled, intensity }`
+| Field | Type | Required | Description |
+|-------|------|----------|-------------|
+| `id` | `string` | Yes | Unique identifier, for example `yourname.cool-effect` |
+| `name` | `string` | Yes | Human-readable name shown in the UI |
+| `version` | `string` | Yes | Strict semver version, for example `1.0.0` |
+| `description` | `string` | Yes | One-line summary |
+| `author` | `string` | No | Author or organisation |
+| `homepage` | `string` | No | HTTPS homepage or repository URL |
+| `license` | `string` | No | SPDX license identifier |
+| `engine` | `string` | No | Minimum supported Recordly version |
+| `icon` | `string` | No | Relative path to a PNG icon |
+| `screenshots` | `string[]` | No | Relative paths to preview images shown in the marketplace |
+| `main` | `string` | Yes | Relative entry point JS file |
+| `permissions` | `string[]` | Yes | Required capabilities |
+| `contributes` | `object` | No | Metadata for packaged frames, cursor styles, sounds, wallpapers, and webcam frames |
+
+`contributes` is metadata only today. Recordly does not auto-register runtime behavior from the manifest. Use `activate()` to call APIs such as `registerFrame()`, `registerWallpaper()`, `registerCursorStyle()`, `registerSettingsPanel()`, and `playSound()`.
+
+## Permissions
-### Cursor Effects
+| Permission | Grants access to |
+|-----------|------------------|
+| `render` | Render hook registration |
+| `cursor` | Cursor telemetry and cursor effect registration |
+| `audio` | Bundled sound playback |
+| `timeline` | Playback and timeline events |
+| `ui` | Settings panels and device frame registration |
+| `assets` | Bundled asset resolution plus wallpaper and cursor style registration |
+| `export` | Export lifecycle events |
-```js
-api.registerCursorEffect((ctx) => {
- // ctx.cx, ctx.cy — cursor position (normalized 0-1)
- // ctx.elapsedMs — time since the click
- // ctx.interactionType — 'click', 'double-click', 'right-click', 'mouseup'
- // ctx.ctx — CanvasRenderingContext2D
- // ctx.width, ctx.height — canvas dimensions
-
- // Return true to keep animating, false to stop
- return ctx.elapsedMs < 600;
-});
-```
+## Render Pipeline
-### Device Frames
+Render hooks draw into `hookCtx.ctx`, a `CanvasRenderingContext2D`, at specific phases.
-Register browser chrome, laptop bezels, or any device overlay.
+| Phase | Preview | Export | Notes |
+|-------|---------|--------|-------|
+| `background` | Reserved | Reserved | Exists in the type surface but is not dispatched yet |
+| `post-video` | Yes | Yes | Runs inside the scene transform |
+| `post-zoom` | Yes | Yes | Runs inside the scene transform |
+| `post-cursor` | Yes | Yes | Runs inside the scene transform |
+| `post-webcam` | Yes | Yes | Runs after the built-in transform |
+| `post-annotations` | Yes | Yes | Runs after the built-in transform |
+| `final` | Yes | Yes | Last pass for HUD-style overlays |
-**Preferred: draw function** (resolution-independent, no bitmap artifacts):
+### Inside vs Outside the Scene Transform
-```js
-api.registerFrame({
- id: 'my-frame',
- label: 'My Frame',
- category: 'browser', // 'browser' | 'laptop' | 'phone' | 'tablet' | 'desktop' | 'custom'
- appearance: 'dark', // 'light' | 'dark'
- screenInsets: { top: 0.05, right: 0.005, bottom: 0.005, left: 0.005 },
- draw(ctx, width, height) {
- // Draw frame chrome at the given dimensions.
- // Leave the screen area transparent (use globalCompositeOperation: 'destination-out').
- // All dimensions are proportional — the function is called at whatever
- // resolution is needed (preview, export, thumbnail).
- },
-});
-```
+- `post-video`, `post-zoom`, and `post-cursor` already follow zoom and motion in preview and export.
+- `post-webcam`, `post-annotations`, and `final` run after Recordly restores the canvas transform. Use `sceneTransform` manually if you want those overlays to move with the scene.
-**Legacy: static image** (scaled as bitmap — may produce artifacts):
+### RenderHookContext
-```js
-api.registerFrame({
- id: 'my-frame',
- label: 'My Frame',
- category: 'browser',
- file: 'frames/my-frame.png', // relative to extension root
- screenInsets: { top: 0.05, right: 0.01, bottom: 0.01, left: 0.01 },
-});
+```ts
+{
+ width: number;
+ height: number;
+ timeMs: number;
+ durationMs: number;
+ cursor: { cx: number; cy: number; interactionType?: string } | null;
+ smoothedCursor?: {
+ cx: number;
+ cy: number;
+ trail: Array<{ cx: number; cy: number }>;
+ } | null;
+ ctx: CanvasRenderingContext2D;
+ videoLayout?: {
+ maskRect: { x: number; y: number; width: number; height: number };
+ borderRadius: number;
+ padding: number;
+ };
+ zoom?: { scale: number; focusX: number; focusY: number; progress: number };
+ sceneTransform?: { scale: number; x: number; y: number };
+ shadow?: { enabled: boolean; intensity: number };
+ getPixelColor(x: number, y: number): { r: number; g: number; b: number; a: number };
+ getAverageSceneColor(): { r: number; g: number; b: number; a: number };
+ getEdgeAverageColor(edgeWidth?: number): { r: number; g: number; b: number; a: number };
+ getDominantColors(count?: number): Array<{ r: number; g: number; b: number; frequency: number }>;
+}
```
-**`screenInsets`** define where the video content sits inside the frame, as fractions (0–1) of the frame dimensions. Example: `{ top: 0.05 }` means the top 5% of the frame image is the title bar/bezel.
+Use `videoLayout.maskRect` and `videoLayout.borderRadius` for scene-relative sizing. That gives you true scene borders and correctly shaped rounded corners instead of canvas-wide overlays.
-### Settings Panels
+## Cursor Effects
-```js
-api.registerSettingsPanel({
- id: 'my-settings',
- label: 'My Extension',
- icon: 'sparkles', // Lucide icon name
- parentSection: 'cursor', // Nest inside an existing section
- fields: [
- { id: 'enabled', label: 'Enable', type: 'toggle', defaultValue: true },
- { id: 'color', label: 'Color', type: 'color', defaultValue: '#2563EB' },
- { id: 'size', label: 'Size', type: 'slider', defaultValue: 1.0, min: 0.1, max: 3.0, step: 0.1 },
- { id: 'style', label: 'Style', type: 'select', defaultValue: 'ripple',
- options: [{ label: 'Ripple', value: 'ripple' }, { label: 'Pulse', value: 'pulse' }] },
- { id: 'name', label: 'Label', type: 'text', defaultValue: '' },
- ],
-});
-```
-
-**`parentSection`** options:
-- `'cursor'` — appears inside the Cursor settings section
-- `'scene'` — inside Scene settings
-- Omit for a **standalone section** with its own icon in the settings rail
-
-**Reading/writing settings:**
+Cursor effect callbacks run each frame after a click until they return `false`.
```js
-const color = api.getSetting('color');
-api.setSetting('color', '#FF0000');
+api.registerCursorEffect((ctx) => {
+ const progress = ctx.elapsedMs / 400;
+ if (progress >= 1) return false;
+
+ const sceneWidth = ctx.videoLayout?.maskRect.width ?? ctx.width;
+ const x = ctx.cx * ctx.width;
+ const y = ctx.cy * ctx.height;
+ const radius = sceneWidth * 0.03 * progress;
+
+ ctx.ctx.beginPath();
+ ctx.ctx.arc(x, y, radius, 0, Math.PI * 2);
+ ctx.ctx.stroke();
+ return true;
+});
```
-### Events
+`CursorEffectContext` now includes `videoLayout`, `zoom`, and `sceneTransform`, so effects can scale relative to the scene instead of the full canvas.
-```js
-api.on('cursor:click', (event) => {
- // event.timeMs, event.data
-});
-```
+## API Surface
-- `timeline` permission is required for `playback:*` and `timeline:*` subscriptions.
-- `cursor` permission is required for `cursor:*` subscriptions.
-- `export` permission is required for `export:*` subscriptions.
-
-| Event | Description |
-|-------|-------------|
-| `playback:timeupdate` | Playback time changed |
-| `playback:play` | Playback started |
-| `playback:pause` | Playback paused |
-| `cursor:click` | Mouse click detected |
-| `cursor:move` | Cursor moved |
-| `timeline:region-added` | Zoom/trim region added |
-| `timeline:region-removed` | Region removed |
-| `export:start` | Export began |
-| `export:frame` | Frame exported |
-| `export:complete` | Export finished |
-
-### Sound Playback
+### Registration
```js
-const stop = api.playSound('sounds/click.mp3', { volume: 0.8 });
-// Call stop() to cancel playback early
+api.registerRenderHook(phase, hook);
+api.registerCursorEffect(effect);
+api.registerFrame(frame);
+api.registerWallpaper(wallpaper);
+api.registerCursorStyle(cursorStyle);
+api.registerSettingsPanel(panel);
+api.on(event, handler);
```
-### Query APIs
+Every registration returns a dispose function.
-Read-only access to project state:
+### Settings
```js
-api.getVideoInfo() // { width, height, durationMs, fps } | null
-api.getVideoLayout() // { maskRect, canvasWidth, canvasHeight, borderRadius, padding } | null
-api.getCursorAt(timeMs) // { cx, cy, timeMs, interactionType, pressure } | null
-api.getSmoothedCursor() // { cx, cy, timeMs, trail } | null
-api.getZoomState() // { scale, focusX, focusY, progress } | null
-api.getShadowConfig() // { enabled, intensity }
-api.getKeystrokesInRange(startMs, endMs) // [{ timeMs, key, modifiers }]
+api.getSetting(settingId);
+api.setSetting(settingId, value);
+api.onSettingChange((settingId, value) => {});
+api.getAllSettings();
```
-### Asset Resolution
+Supported settings field types are `toggle`, `slider`, `select`, `color`, and `text`.
+
+### Assets and Audio
```js
-const url = api.resolveAsset('images/overlay.png');
-// Returns a file:// URL scoped to the extension directory
+api.resolveAsset("images/overlay.png");
+api.playSound("sounds/click.mp3", { volume: 0.8 });
+api.log("hello", payload);
```
-### Logging
+### Read-only Queries
```js
-api.log('Debug message', someData);
-// Output: [ext:com.example.my-extension] Debug message ...
+api.getVideoInfo();
+api.getVideoLayout();
+api.getCursorAt(timeMs);
+api.getSmoothedCursor();
+api.getZoomState();
+api.getShadowConfig();
+api.getKeystrokesInRange(startMs, endMs);
+api.getAspectRatio();
+api.getActiveFrame();
+api.isExtensionActive(extensionId);
+api.getPlaybackState();
+api.getCanvasDimensions();
```
-## Lifecycle
-
-1. **Discovery**: Recordly scans `public/builtin-extensions/` and user extension directories
-2. **Activation**: `activate(api)` is called — register hooks, effects, panels
-3. **Runtime**: Hooks/effects execute each frame; settings panel renders in the UI
-4. **Deactivation**: `deactivate()` is called; all registered hooks are auto-disposed
-
-All `register*` methods return a dispose function for early cleanup:
+## Settings Panels
```js
-const dispose = api.registerRenderHook('final', myHook);
-// Later: dispose() to unregister
+api.registerSettingsPanel({
+ id: "my-settings",
+ label: "My Extension",
+ icon: "sparkles",
+ parentSection: "cursor",
+ fields: [
+ { id: "enabled", label: "Enable", type: "toggle", defaultValue: true },
+ { id: "size", label: "Size", type: "slider", defaultValue: 1, min: 0.1, max: 3, step: 0.1 },
+ {
+ id: "style",
+ label: "Style",
+ type: "select",
+ defaultValue: "ripple",
+ options: [{ label: "Ripple", value: "ripple" }, { label: "Pulse", value: "pulse" }],
+ },
+ { id: "color", label: "Color", type: "color", defaultValue: "#2563EB" },
+ ],
+});
```
-## Built-in Extensions
+Use `parentSection` to nest your panel inside an existing area such as `cursor` or `scene`.
-| Extension | What it does |
-|-----------|-------------|
-| `recordly.frames` | Browser chrome, macOS window, MacBook bezel frames |
-| `recordly.click-effects` | Animated ripple/sparkle/pulse effects at click positions |
+## Events
-## Example: Full Click Effect Extension
+| Event | Permission | Description |
+|-------|------------|-------------|
+| `playback:timeupdate` | `timeline` | Fires each playback tick |
+| `playback:play` | `timeline` | Playback started |
+| `playback:pause` | `timeline` | Playback paused |
+| `cursor:click` | `cursor` | Cursor click detected |
+| `cursor:move` | `cursor` | Cursor move detected |
+| `timeline:region-added` | `timeline` | Region added |
+| `timeline:region-removed` | `timeline` | Region removed |
+| `export:start` | `export` | Export started |
+| `export:frame` | `export` | A frame was rendered during export |
+| `export:complete` | `export` | Export finished |
-```js
-const DURATION = 600;
+## Frames, Wallpapers, and Cursor Styles
-export function activate(api) {
- api.registerSettingsPanel({
- id: 'settings',
- label: 'My Click Effect',
- icon: 'mouse-pointer-click',
- parentSection: 'cursor',
- fields: [
- { id: 'color', label: 'Color', type: 'color', defaultValue: '#FF6B6B' },
- ],
- });
-
- api.registerCursorEffect((ctx) => {
- const progress = ctx.elapsedMs / DURATION;
- if (progress >= 1) return false;
-
- const px = ctx.cx * ctx.width;
- const py = ctx.cy * ctx.height;
- const radius = 30 * progress;
- const alpha = 1 - progress;
- const color = api.getSetting('color') || '#FF6B6B';
-
- ctx.ctx.beginPath();
- ctx.ctx.arc(px, py, radius, 0, Math.PI * 2);
- ctx.ctx.strokeStyle = color;
- ctx.ctx.globalAlpha = alpha;
- ctx.ctx.lineWidth = 2;
- ctx.ctx.stroke();
- ctx.ctx.globalAlpha = 1;
-
- return true;
- });
-}
-
-export function deactivate() {}
-```
+- `registerFrame()` is the runtime API for device frames. Use a `draw(ctx, width, height)` function when possible for resolution-independent output.
+- `registerWallpaper()` contributes scene backgrounds.
+- `registerCursorStyle()` contributes cursor image packs.
+- All three rely on packaged files relative to the extension root.
-## Example: Resolution-Independent Device Frame
+## Lifecycle
-```js
-function drawMyFrame(ctx, W, H) {
- const titleBarH = Math.round(H * 0.04);
- const border = Math.round(H * 0.003);
- const radius = Math.round(W * 0.005);
-
- // Draw outer frame
- ctx.fillStyle = '#1E1E2E';
- ctx.beginPath();
- ctx.roundRect(0, 0, W, H, radius);
- ctx.fill();
-
- // Cut out screen area
- ctx.save();
- ctx.globalCompositeOperation = 'destination-out';
- ctx.fillStyle = '#000';
- ctx.fillRect(border, titleBarH, W - border * 2, H - titleBarH - border);
- ctx.restore();
-}
+1. Discovery: Recordly scans built-in extensions and the user extensions directory.
+2. Activation: `activate(api)` runs and you register hooks, effects, panels, and assets.
+3. Runtime: Registered callbacks execute in preview and export according to their phase.
+4. Deactivation: `deactivate()` runs and all registrations are automatically disposed.
-export function activate(api) {
- api.registerFrame({
- id: 'my-frame',
- label: 'My Custom Frame',
- category: 'custom',
- screenInsets: { top: 0.04, right: 0.003, bottom: 0.003, left: 0.003 },
- draw: drawMyFrame,
- });
-}
+## Examples
-export function deactivate() {}
-```
+- `extension-examples/webadderall.more-wallpapers` shows a user-installable wallpaper bundle that registers 180 packaged wallpapers through `registerWallpaper()`.
diff --git a/electron/electron-env.d.ts b/electron/electron-env.d.ts
index 97194dfa..d25fbafe 100644
--- a/electron/electron-env.d.ts
+++ b/electron/electron-env.d.ts
@@ -137,6 +137,9 @@ interface Window {
readLocalFile: (
filePath: string,
) => Promise<{ success: boolean; data?: Uint8Array; error?: string }>;
+ generateWallpaperThumbnail: (
+ filePath: string,
+ ) => Promise<{ success: boolean; data?: Uint8Array; error?: string }>;
nativeVideoExportStart: (options: {
width: number;
height: number;
diff --git a/electron/extensions/extensionMarketplace.ts b/electron/extensions/extensionMarketplace.ts
index 3bff07f6..f0e9bbd9 100644
--- a/electron/extensions/extensionMarketplace.ts
+++ b/electron/extensions/extensionMarketplace.ts
@@ -241,7 +241,10 @@ export async function downloadAndInstallExtension(
// Security: verify no extracted file escaped the extraction directory
// (protects against zip-slip / path traversal entries in malicious archives)
- const resolvedExtractDir = path.resolve(extractDir);
+ // Use fs.realpath so the root matches what fs.realpath returns for children
+ // (on macOS /var is a symlink to /private/var — path.resolve does not
+ // resolve symlinks, so root and children would mismatch).
+ const resolvedExtractDir = await fs.realpath(extractDir);
await assertNoEscapedFiles(resolvedExtractDir, resolvedExtractDir);
// Find the manifest — it might be in a subfolder
diff --git a/electron/ipc/handlers.ts b/electron/ipc/handlers.ts
index 3f12e880..4b6753b5 100644
--- a/electron/ipc/handlers.ts
+++ b/electron/ipc/handlers.ts
@@ -5169,6 +5169,70 @@ body{background:transparent;overflow:hidden;width:100vw;height:100vh}
}
})
+ // Generate a tiny thumbnail for a wallpaper image and cache it in userData.
+ // Returns the cached thumbnail as raw JPEG bytes for fast grid rendering.
+ // Serialized to prevent concurrent nativeImage operations from eating memory.
+ const THUMB_SIZE = 96
+ const thumbCacheDir = path.join(USER_DATA_PATH, 'wallpaper-thumbs')
+ let thumbGenerationQueue: Promise<void> = Promise.resolve()
+
+ ipcMain.handle('generate-wallpaper-thumbnail', async (_, filePath: string) => {
+ try {
+ const resolved = path.resolve(filePath)
+
+ // Security: only allow reads from known safe directories
+ const allowedPrefixes = [
+ RECORDINGS_DIR,
+ USER_DATA_PATH,
+ getAssetRootPath(),
+ app.getPath('temp'),
+ ]
+ if (!allowedPrefixes.some((prefix) => resolved.startsWith(path.resolve(prefix)))) {
+ return { success: false, error: 'Access denied' }
+ }
+
+ // Deterministic cache key from file path + mtime
+ const stat = await fs.stat(resolved)
+ const cacheKey = Buffer.from(`${resolved}:${stat.mtimeMs}`).toString('base64url')
+ const thumbPath = path.join(thumbCacheDir, `${cacheKey}.jpg`)
+
+ // Return cached thumbnail if it exists (no queue needed)
+ if (existsSync(thumbPath)) {
+ const data = await fs.readFile(thumbPath)
+ return { success: true, data }
+ }
+
+ // Serialize nativeImage operations to avoid OOM from concurrent full-res decodes
+ let jpegData: Buffer
+ const generation = thumbGenerationQueue.then(async () => {
+ const { nativeImage } = await import('electron')
+ const img = nativeImage.createFromPath(resolved)
+ if (img.isEmpty()) {
+ throw new Error('Failed to load image')
+ }
+ const { width, height } = img.getSize()
+ const scale = THUMB_SIZE / Math.min(width, height)
+ const resized = img.resize({
+ width: Math.round(width * scale),
+ height: Math.round(height * scale),
+ quality: 'good',
+ })
+ jpegData = resized.toJPEG(70)
+
+ // Cache to disk
+ await fs.mkdir(thumbCacheDir, { recursive: true })
+ await fs.writeFile(thumbPath, jpegData)
+ })
+ // Keep the queue moving even if one fails
+ thumbGenerationQueue = generation.catch(() => {})
+ await generation
+
+ return { success: true, data: jpegData! }
+ } catch (error) {
+ return { success: false, error: String(error) }
+ }
+ })
+
// Return base path for assets so renderer can resolve file:// paths in production
ipcMain.handle('get-asset-base-path', () => {
try {
diff --git a/electron/preload.ts b/electron/preload.ts
index d477fa82..7f6e69bc 100644
--- a/electron/preload.ts
+++ b/electron/preload.ts
@@ -99,6 +99,9 @@ contextBridge.exposeInMainWorld("electronAPI", {
readLocalFile: (filePath: string) => {
return ipcRenderer.invoke("read-local-file", filePath);
},
+ generateWallpaperThumbnail: (filePath: string) => {
+ return ipcRenderer.invoke("generate-wallpaper-thumbnail", filePath);
+ },
nativeVideoExportStart: (options: {
width: number;
height: number;
diff --git a/src/components/video-editor/ExtensionIcon.tsx b/src/components/video-editor/ExtensionIcon.tsx
index 6a0d8e47..2e8329fb 100644
--- a/src/components/video-editor/ExtensionIcon.tsx
+++ b/src/components/video-editor/ExtensionIcon.tsx
@@ -66,15 +66,16 @@ export function ExtensionIcon({
icon,
extensionPath,
className = "w-4 h-4",
+ imageClassName,
...rest
-}: { icon?: string | null; extensionPath?: string | null; className?: string } & Omit<LucideProps, "ref">) {
+}: { icon?: string | null; extensionPath?: string | null; className?: string; imageClassName?: string } & Omit<LucideProps, "ref">) {
if (!icon) {
return <Puzzle className={className} {...rest} />;
}
const iconSrc = resolveIconSrc(icon, extensionPath);
if (iconSrc) {
- return <img src={iconSrc} alt="" className={className} style={{ objectFit: "contain" }} />;
+ return <img src={iconSrc} alt="" className={imageClassName ?? className} style={{ objectFit: "cover" }} />;
}
// Try Lucide icon name (PascalCase)
diff --git a/src/components/video-editor/ExtensionManager.tsx b/src/components/video-editor/ExtensionManager.tsx
index ffc04b54..0bf246b2 100644
--- a/src/components/video-editor/ExtensionManager.tsx
+++ b/src/components/video-editor/ExtensionManager.tsx
@@ -28,6 +28,8 @@ import {
BookOpen,
Tag,
ExternalLink,
+ ChevronLeft,
+ ChevronRight,
} from "lucide-react";
import { toast } from "sonner";
import { cn } from "@/lib/utils";
@@ -76,8 +78,8 @@ function InstalledExtensionCard({
)}
onClick={onClick}
>
- <div className="flex-shrink-0 w-8 h-8 rounded-lg bg-white/5 border border-white/10 flex items-center justify-center">
- <ExtensionIcon icon={extension.manifest.icon} extensionPath={extension.path} className="w-3.5 h-3.5 text-slate-400" />
+ <div className="flex-shrink-0 w-8 h-8 rounded-lg bg-white/5 border border-white/10 flex items-center justify-center overflow-hidden">
+ <ExtensionIcon icon={extension.manifest.icon} extensionPath={extension.path} className="w-3.5 h-3.5 text-slate-400" imageClassName="w-8 h-8 rounded-lg" />
</div>
<div className="flex-1 min-w-0">
@@ -105,7 +107,7 @@ function InstalledExtensionCard({
</p>
)}
- <p className="text-[11px] text-slate-500 mt-0.5 line-clamp-1">
+ <p className="text-[11px] text-slate-500 mt-0.5 line-clamp-3">
{extension.manifest.description || "No description"}
</p>
@@ -164,9 +166,9 @@ function MarketplaceCard({
}) {
return (
<div className="flex items-start gap-3 p-3 rounded-xl border border-white/[0.06] bg-white/[0.02] hover:bg-white/[0.04] transition-colors cursor-pointer" onClick={onClick}>
- <div className="flex-shrink-0 w-8 h-8 rounded-lg bg-gradient-to-br from-white/10 to-white/5 border border-white/10 flex items-center justify-center">
+ <div className="flex-shrink-0 w-8 h-8 rounded-lg bg-gradient-to-br from-white/10 to-white/5 border border-white/10 flex items-center justify-center overflow-hidden">
{extension.iconUrl ? (
- <img src={extension.iconUrl} alt="" className="w-5 h-5 rounded" />
+ <img src={extension.iconUrl} alt="" className="w-8 h-8 rounded-lg object-cover" />
) : (
<ExtensionIcon icon={undefined} className="w-3.5 h-3.5 text-slate-400" />
)}
@@ -195,7 +197,7 @@ function MarketplaceCard({
)}
</p>
- <p className="text-[11px] text-slate-500 mt-0.5 line-clamp-2">
+ <p className="text-[11px] text-slate-500 mt-0.5 line-clamp-3">
{extension.description}
</p>
@@ -247,6 +249,62 @@ function MarketplaceCard({
);
}
+// ---------------------------------------------------------------------------
+// Screenshot Gallery Carousel
+// ---------------------------------------------------------------------------
+
+function ScreenshotGallery({ screenshots }: { screenshots: string[] }) {
+ const [index, setIndex] = useState(0);
+ const count = screenshots.length;
+ if (count === 0) return null;
+
+ return (
+ <div>
+ <p className="text-[10px] font-semibold uppercase tracking-widest text-slate-500 mb-1.5">
+ Preview
+ </p>
+ <div className="relative group rounded-lg overflow-hidden bg-black/20 border border-white/[0.06]">
+ <img
+ src={screenshots[index]}
+ alt={`Screenshot ${index + 1}`}
+ className="w-full aspect-video object-cover"
+ />
+ {count > 1 && (
+ <>
+ <button
+ type="button"
+ className="absolute left-1 top-1/2 -translate-y-1/2 w-6 h-6 rounded-full bg-black/60 text-white/80 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity hover:bg-black/80"
+ onClick={() => setIndex((i) => (i - 1 + count) % count)}
+ >
+ <ChevronLeft className="w-3.5 h-3.5" />
+ </button>
+ <button
+ type="button"
+ className="absolute right-1 top-1/2 -translate-y-1/2 w-6 h-6 rounded-full bg-black/60 text-white/80 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity hover:bg-black/80"
+ onClick={() => setIndex((i) => (i + 1) % count)}
+ >
+ <ChevronRight className="w-3.5 h-3.5" />
+ </button>
+ <div className="absolute bottom-1.5 left-1/2 -translate-x-1/2 flex gap-1">
+ {screenshots.map((_, i) => (
+ <button
+ type="button"
+ key={i}
+ className={cn(
+ "w-1.5 h-1.5 rounded-full transition-colors",
+ i === index ? "bg-white" : "bg-white/30 hover:bg-white/50",
+ )}
+ onClick={() => setIndex(i)}
+ />
+ ))}
+ </div>
+ </>
+ )}
+ </div>
+ </div>
+ );
+}
+
// ---------------------------------------------------------------------------
// Extension Detail (unified type for installed + marketplace)
// ---------------------------------------------------------------------------
@@ -276,6 +334,7 @@ function ExtensionDetailModal({
const author = isInstalled ? detail.ext.manifest.author : detail.ext.author;
const permissions = isInstalled ? detail.ext.manifest.permissions : detail.ext.permissions;
const homepage = isInstalled ? detail.ext.manifest.homepage : detail.ext.homepage;
+ const screenshots = detail.source === 'marketplace' ? detail.ext.screenshots ?? [] : [];
const isError = isInstalled ? detail.ext.status === 'error' : false;
return (
@@ -332,6 +391,9 @@ function ExtensionDetailModal({
{/* Body */}
<div className="px-5 pb-5 space-y-4 max-h-[50vh] overflow-y-auto custom-scrollbar">
+ {/* Screenshot gallery */}
+ {screenshots.length > 0 && <ScreenshotGallery screenshots={screenshots} />}
+
{/* Description */}
<div>
<p className="text-[10px] font-semibold uppercase tracking-widest text-slate-500 mb-1.5">
@@ -631,16 +693,6 @@ export default function ExtensionManager() {
[marketplaceInstall],
);
- if (!ready) {
- return (
- <div className="flex-[2] w-[332px] min-w-[280px] max-w-[332px] bg-[#161619] border border-white/10 rounded-2xl flex flex-col shadow-xl h-full overflow-hidden">
- <div className="flex-1 flex items-center justify-center">
- <Loader2 className="w-5 h-5 text-slate-600 animate-spin" />
- </div>
- </div>
- );
- }
-
return (
<div className="flex-[2] w-[332px] min-w-[280px] max-w-[332px] bg-[#161619] border border-white/10 rounded-2xl flex flex-col shadow-xl h-full overflow-hidden">
{/* Header */}
@@ -691,6 +743,11 @@ export default function ExtensionManager() {
{/* Content */}
<div className="flex-1 min-h-0 overflow-y-auto custom-scrollbar p-4 pb-0 pt-0" style={{ scrollbarGutter: "stable" }}>
+ {!ready ? (
+ <div className="flex-1 flex items-center justify-center py-12">
+ <Loader2 className="w-5 h-5 text-slate-600 animate-spin" />
+ </div>
+ ) : (
<AnimatePresence mode="wait" initial={false}>
<motion.div
key={activeTab}
@@ -728,6 +785,7 @@ export default function ExtensionManager() {
)}
</motion.div>
</AnimatePresence>
+ )}
</div>
{/* Extension Detail Modal */}
diff --git a/src/components/video-editor/SettingsPanel.tsx b/src/components/video-editor/SettingsPanel.tsx
index 8be273f6..18760efc 100644
--- a/src/components/video-editor/SettingsPanel.tsx
+++ b/src/components/video-editor/SettingsPanel.tsx
@@ -12,7 +12,7 @@ import {
} from "@/components/ui/select";
import { Switch } from "@/components/ui/switch";
import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group";
-import { getAssetPath, getRenderableAssetUrl } from "@/lib/assetPath";
+import { getAssetPath, getRenderableAssetUrl, getWallpaperThumbnailUrl } from "@/lib/assetPath";
import { cn } from "@/lib/utils";
import { extensionHost, type FrameInstance } from "@/lib/extensions";
import type { ExtensionSettingField } from "@/lib/extensions";
@@ -401,7 +401,16 @@ const WEBCAM_POSITION_PRESETS: Array<{
{ preset: "bottom-right", label: "↘" },
];
-const CURSOR_STYLE_OPTIONS: Array<{ value: CursorStyle; label: string }> = [
+type CursorStyleOption = { value: CursorStyle; label: string };
+
+type WallpaperTile = {
+ key: string;
+ label: string;
+ value: string;
+ previewUrl: string;
+};
+
+const BUILTIN_CURSOR_STYLE_OPTIONS: CursorStyleOption[] = [
{ value: "tahoe", label: "Tahoe" },
{ value: "dot", label: "Dot" },
{ value: "figma", label: "Minimal" },
@@ -568,12 +577,31 @@ function CursorStylePreview({
previewUrls,
}: {
style: CursorStyle;
- previewUrls: Partial<Record<"tahoe" | "figma" | "mono", string>>;
+ previewUrls: Partial<Record<string, string>>;
}) {
+ const previewSrc =
+ style === "tahoe"
+ ? previewUrls.tahoe ?? tahoeCursorUrl
+ : style === "figma"
+ ? previewUrls.figma ?? minimalCursorUrl
+ : style === "mono"
+ ? previewUrls.mono ?? tahoeCursorUrl
+ : style === "lavender"
+ ? lavenderCursorUrl
+ : style === "parched"
+ ? parchedCursorUrl
+ : style === "chooper"
+ ? chooperCursorUrl
+ : style === "amongus"
+ ? amongusCursorUrl
+ : style === "turtle"
+ ? turtleCursorUrl
+ : previewUrls[style];
+
if (style === "tahoe") {
return (
<img
- src={previewUrls.tahoe ?? tahoeCursorUrl}
+ src={previewSrc}
alt=""
className="h-7 w-7 object-contain drop-shadow-[0_8px_12px_rgba(15,23,42,0.18)]"
draggable={false}
@@ -584,7 +612,7 @@ function CursorStylePreview({
if (style === "figma") {
return (
<img
- src={previewUrls.figma ?? minimalCursorUrl}
+ src={previewSrc}
alt=""
className="h-7 w-7 object-contain"
draggable={false}
@@ -598,39 +626,9 @@ function CursorStylePreview({
);
}
- if (style === "lavender") {
- return (
- <img src={lavenderCursorUrl} alt="" className="h-7 w-7 object-contain" draggable={false} />
- );
- }
-
- if (style === "parched") {
- return (
- <img src={parchedCursorUrl} alt="" className="h-7 w-7 object-contain" draggable={false} />
- );
- }
-
- if (style === "chooper") {
- return (
- <img src={chooperCursorUrl} alt="" className="h-7 w-7 object-contain" draggable={false} />
- );
- }
-
- if (style === "amongus") {
- return (
- <img src={amongusCursorUrl} alt="" className="h-7 w-7 object-contain" draggable={false} />
- );
- }
-
- if (style === "turtle") {
- return (
- <img src={turtleCursorUrl} alt="" className="h-7 w-7 object-contain" draggable={false} />
- );
- }
-
return (
<img
- src={previewUrls.mono ?? tahoeCursorUrl}
+ src={previewSrc ?? tahoeCursorUrl}
alt=""
className="h-7 w-7 object-contain"
draggable={false}
@@ -729,7 +727,12 @@ export function SettingsPanel({
const initialEditorPreferences = useMemo(() => loadEditorPreferences(), []);
const [builtInWallpapers, setBuiltInWallpapers] =
useState<BuiltInWallpaper[]>(BUILT_IN_WALLPAPERS);
+ const [extensionWallpapers, setExtensionWallpapers] =
+ useState<ReturnType<typeof extensionHost.getContributedWallpapers>>([]);
const [wallpaperPreviewPaths, setWallpaperPreviewPaths] = useState<string[]>([]);
+ const [extensionWallpaperPreviewUrls, setExtensionWallpaperPreviewUrls] = useState<
+ Record<string, string>
+ >({});
const [customImages, setCustomImages] = useState<string[]>(
initialEditorPreferences.customWallpapers,
);
@@ -742,6 +745,10 @@ export function SettingsPanel({
() => builtInWallpapers.map((wallpaper) => wallpaper.publicPath),
[builtInWallpapers],
);
+ const extensionWallpaperPaths = useMemo(
+ () => extensionWallpapers.map((wallpaper) => wallpaper.resolvedUrl),
+ [extensionWallpapers],
+ );
const captionCueCount = autoCaptions.length;
const updateAutoCaptionSettings = (partial: Partial<AutoCaptionSettings>) => {
onAutoCaptionSettingsChange?.({
@@ -756,9 +763,14 @@ export function SettingsPanel({
try {
const availableWallpapers = await getAvailableWallpapers();
const resolved = await Promise.all(
- availableWallpapers.map(async (wallpaper) =>
- getRenderableAssetUrl(await getAssetPath(wallpaper.relativePath)),
- ),
+ availableWallpapers.map(async (wallpaper) => {
+ const assetUrl = await getAssetPath(wallpaper.relativePath);
+ // Use tiny thumbnails for the grid; full-res loads on selection
+ if (isVideoWallpaperSource(wallpaper.publicPath)) {
+ return getRenderableAssetUrl(assetUrl);
+ }
+ return getWallpaperThumbnailUrl(assetUrl);
+ }),
);
if (mounted) {
setBuiltInWallpapers(availableWallpapers);
@@ -775,6 +787,50 @@ export function SettingsPanel({
mounted = false;
};
}, []);
+
+ useEffect(() => {
+ let cancelled = false;
+
+ const updateExtensionAssets = async () => {
+ const wallpapers = extensionHost.getContributedWallpapers();
+ const cursorStyles = extensionHost.getContributedCursorStyles();
+ const [wallpaperPreviewEntries, cursorPreviewEntries] = await Promise.all([
+ Promise.all(
+ wallpapers.map(async (wallpaper) => [
+ wallpaper.id,
+ isVideoWallpaperSource(wallpaper.resolvedThumbnailUrl)
+ ? wallpaper.resolvedThumbnailUrl
+ : await getWallpaperThumbnailUrl(wallpaper.resolvedThumbnailUrl),
+ ] as const),
+ ),
+ Promise.all(
+ cursorStyles.map(async (cursorStyle) => [
+ cursorStyle.id,
+ await getRenderableAssetUrl(cursorStyle.resolvedDefaultUrl),
+ ] as const),
+ ),
+ ]);
+
+ if (cancelled) {
+ return;
+ }
+
+ setExtensionWallpapers(wallpapers);
+ setExtensionWallpaperPreviewUrls(Object.fromEntries(wallpaperPreviewEntries));
+ setExtensionCursorStyles(cursorStyles);
+ setExtensionCursorPreviewUrls(Object.fromEntries(cursorPreviewEntries));
+ };
+
+ void extensionHost.autoActivateBuiltins().then(updateExtensionAssets);
+ const unsubscribe = extensionHost.onChange(() => {
+ void updateExtensionAssets();
+ });
+
+ return () => {
+ cancelled = true;
+ unsubscribe();
+ };
+ }, []);
const colorPalette = [
"#FF0000",
"#FFD700",
@@ -840,9 +896,28 @@ export function SettingsPanel({
const defaultWebcam = initialEditorPreferences.webcam;
const [internalActiveEffectSection] = useState<EditorEffectSection>("scene");
const activeEffectSection = activeEffectSectionProp ?? internalActiveEffectSection;
- const [cursorPreviewUrls, setCursorPreviewUrls] = useState<
- Partial<Record<"tahoe" | "figma" | "mono", string>>
+ const [extensionCursorStyles, setExtensionCursorStyles] =
+ useState<ReturnType<typeof extensionHost.getContributedCursorStyles>>([]);
+ const [builtInCursorPreviewUrls, setBuiltInCursorPreviewUrls] = useState<
+ Partial<Record<string, string>>
+ >({});
+ const [extensionCursorPreviewUrls, setExtensionCursorPreviewUrls] = useState<
+ Partial<Record<string, string>>
>({});
+ const cursorPreviewUrls = useMemo(
+ () => ({ ...builtInCursorPreviewUrls, ...extensionCursorPreviewUrls }),
+ [builtInCursorPreviewUrls, extensionCursorPreviewUrls],
+ );
+ const cursorStyleOptions = useMemo<CursorStyleOption[]>(
+ () => [
+ ...BUILTIN_CURSOR_STYLE_OPTIONS,
+ ...extensionCursorStyles.map((cursorStyle) => ({
+ value: cursorStyle.id as CursorStyle,
+ label: cursorStyle.cursorStyle.label,
+ })),
+ ],
+ [extensionCursorStyles],
+ );
useEffect(() => {
let cancelled = false;
@@ -861,7 +936,7 @@ export function SettingsPanel({
const invertedPreview = await createInvertedPreview(tahoePreview);
if (!cancelled) {
- setCursorPreviewUrls({
+ setBuiltInCursorPreviewUrls({
tahoe: tahoePreview,
figma: minimalPreview,
mono: invertedPreview,
@@ -869,7 +944,7 @@ export function SettingsPanel({
}
} catch {
if (!cancelled) {
- setCursorPreviewUrls({
+ setBuiltInCursorPreviewUrls({
tahoe: tahoeCursorUrl,
figma: minimalCursorUrl,
mono: tahoeCursorUrl,
@@ -898,17 +973,86 @@ export function SettingsPanel({
setCustomImages((prev) => [selected, ...prev]);
}
- const isBuiltInWallpaper =
- builtInWallpaperPaths.includes(selected) || wallpaperPreviewPaths.includes(selected);
+ const isKnownWallpaper =
+ builtInWallpaperPaths.includes(selected) ||
+ wallpaperPreviewPaths.includes(selected) ||
+ extensionWallpaperPaths.includes(selected);
if (
- !isBuiltInWallpaper &&
+ !isKnownWallpaper &&
isVideoWallpaperSource(selected) &&
!customImages.includes(selected)
) {
setCustomImages((prev) => [selected, ...prev]);
}
- }, [builtInWallpaperPaths, customImages, selected, wallpaperPreviewPaths]);
+ }, [
+ builtInWallpaperPaths,
+ customImages,
+ extensionWallpaperPaths,
+ selected,
+ wallpaperPreviewPaths,
+ ]);
+
+ const imageWallpaperTiles = useMemo<WallpaperTile[]>(() => {
+ const imageWallpapers = builtInWallpapers.filter(
+ (wallpaper) => !isVideoWallpaperSource(wallpaper.publicPath),
+ );
+ const builtInTiles = (wallpaperPreviewPaths.length > 0
+ ? wallpaperPreviewPaths
+ : builtInWallpaperPaths
+ )
+ .filter((path) => !isVideoWallpaperSource(path))
+ .map((previewPath, index) => {
+ const wallpaper = imageWallpapers[index];
+ return {
+ key: wallpaper ? `builtin/${wallpaper.id}` : previewPath,
+ label: wallpaper?.label ?? `Wallpaper ${index + 1}`,
+ value: wallpaper?.publicPath ?? previewPath,
+ previewUrl: previewPath,
+ };
+ });
+
+ const extensionTiles = extensionWallpapers
+ .filter((wallpaper) => !isVideoWallpaperSource(wallpaper.resolvedUrl))
+ .map((wallpaper) => ({
+ key: wallpaper.id,
+ label: wallpaper.wallpaper.label,
+ value: wallpaper.resolvedUrl,
+ previewUrl:
+ extensionWallpaperPreviewUrls[wallpaper.id] ?? wallpaper.resolvedThumbnailUrl,
+ }));
+
+ return [...builtInTiles, ...extensionTiles];
+ }, [
+ builtInWallpaperPaths,
+ builtInWallpapers,
+ extensionWallpaperPreviewUrls,
+ extensionWallpapers,
+ wallpaperPreviewPaths,
+ ]);
+
+ const videoWallpaperTiles = useMemo<WallpaperTile[]>(() => {
+ const builtInTiles = builtInWallpapers
+ .filter((wallpaper) => isVideoWallpaperSource(wallpaper.publicPath))
+ .map((wallpaper) => ({
+ key: `builtin/${wallpaper.id}`,
+ label: wallpaper.label,
+ value: wallpaper.publicPath,
+ previewUrl: wallpaper.publicPath,
+ }));
+
+ const extensionTiles = extensionWallpapers
+ .filter((wallpaper) => isVideoWallpaperSource(wallpaper.resolvedUrl))
+ .map((wallpaper) => ({
+ key: wallpaper.id,
+ label: wallpaper.wallpaper.label,
+ value: wallpaper.resolvedUrl,
+ previewUrl:
+ extensionWallpaperPreviewUrls[wallpaper.id] ?? wallpaper.resolvedThumbnailUrl,
+ }));
+
+ return [...builtInTiles, ...extensionTiles];
+ }, [builtInWallpapers, extensionWallpaperPreviewUrls, extensionWallpapers]);
useEffect(() => {
saveEditorPreferences({ customWallpapers: customImages });
@@ -1191,7 +1335,12 @@ export function SettingsPanel({
setCustomImages((prev) => prev.filter((img) => img !== imageUrl));
// If the removed image was selected, clear selection
if (selected === imageUrl) {
- onWallpaperChange(builtInWallpaperPaths[0] ?? BUILT_IN_WALLPAPERS[0]?.publicPath ?? "");
+ onWallpaperChange(
+ builtInWallpaperPaths[0] ??
+ extensionWallpaperPaths[0] ??
+ BUILT_IN_WALLPAPERS[0]?.publicPath ??
+ "",
+ );
}
};
@@ -1316,20 +1465,13 @@ export function SettingsPanel({
});
})}
- {(wallpaperPreviewPaths.length > 0
- ? wallpaperPreviewPaths
- : builtInWallpaperPaths
- ).filter(p => !isVideoWallpaperSource(p)).map((previewPath, filteredIndex) => {
- const imageWallpapers = builtInWallpapers.filter(w => !isVideoWallpaperSource(w.publicPath));
- const wallpaper = imageWallpapers[filteredIndex];
- const wallpaperValue =
- wallpaper?.publicPath ?? previewPath;
- const isSelected = getWallpaperTileState(wallpaperValue, previewPath);
- return renderWallpaperImageTile(previewPath, isSelected, {
- key: wallpaperValue,
- ariaLabel: wallpaper?.label ?? `Wallpaper ${filteredIndex + 1}`,
- title: wallpaper?.label ?? `Wallpaper ${filteredIndex + 1}`,
- onClick: () => onWallpaperChange(wallpaperValue),
+ {imageWallpaperTiles.map((tile) => {
+ const isSelected = getWallpaperTileState(tile.value, tile.previewUrl);
+ return renderWallpaperImageTile(tile.previewUrl, isSelected, {
+ key: tile.key,
+ ariaLabel: tile.label,
+ title: tile.label,
+ onClick: () => onWallpaperChange(tile.value),
});
})}
</div>
@@ -1364,14 +1506,16 @@ export function SettingsPanel({
});
})}
- {BUILT_IN_WALLPAPERS.filter(w => isVideoWallpaperSource(w.publicPath)).map((wallpaper) => {
- const wallpaperValue = wallpaper.publicPath;
- const isSelected = selected === wallpaperValue;
- return renderWallpaperImageTile(wallpaperValue, isSelected, {
- key: wallpaperValue,
+ {videoWallpaperTiles.map((wallpaper) => {
+ const isSelected = getWallpaperTileState(
+ wallpaper.value,
+ wallpaper.previewUrl,
+ );
+ return renderWallpaperImageTile(wallpaper.previewUrl, isSelected, {
+ key: wallpaper.key,
ariaLabel: wallpaper.label,
title: wallpaper.label,
- onClick: () => onWallpaperChange(wallpaperValue),
+ onClick: () => onWallpaperChange(wallpaper.value),
});
})}
</div>
@@ -2028,7 +2172,7 @@ export function SettingsPanel({
className="grid grid-cols-4 gap-2"
aria-label={tSettings("effects.cursorStyle", "Cursor Style")}
>
- {CURSOR_STYLE_OPTIONS.map((option) => (
+ {cursorStyleOptions.map((option) => (
<ToggleGroupItem
key={option.value}
value={option.value}
diff --git a/src/components/video-editor/VideoPlayback.tsx b/src/components/video-editor/VideoPlayback.tsx
index 98ef0889..a4a4517c 100644
--- a/src/components/video-editor/VideoPlayback.tsx
+++ b/src/components/video-editor/VideoPlayback.tsx
@@ -68,6 +68,17 @@ import {
getCaptionWordVisualState,
} from "./captionStyle";
import { clamp01 } from "./videoPlayback/mathUtils";
+
+function getContributedCursorStylesSignature() {
+ return extensionHost
+ .getContributedCursorStyles()
+ .map(
+ (cursorStyle) =>
+ `${cursorStyle.id}:${cursorStyle.resolvedDefaultUrl}:${cursorStyle.resolvedClickUrl ?? ""}:${cursorStyle.cursorStyle.hotspot?.x ?? ""}:${cursorStyle.cursorStyle.hotspot?.y ?? ""}`,
+ )
+ .sort()
+ .join("|");
+}
import { findDominantRegion } from "./videoPlayback/zoomRegionUtils";
import {
type CursorFollowCameraState,
@@ -1905,14 +1916,34 @@ const VideoPlayback = forwardRef<VideoPlaybackRef, VideoPlaybackProps>(
return;
}
+ let cancelled = false;
+
overlay.setDotRadius(DEFAULT_CURSOR_CONFIG.dotRadius * cursorSize);
- overlay.setStyle(cursorStyle);
overlay.setSmoothingFactor(cursorSmoothing);
overlay.setMotionBlur(cursorMotionBlur);
overlay.setClickBounce(cursorClickBounce);
overlay.setClickBounceDuration(cursorClickBounceDuration);
overlay.setSway(cursorSway);
- overlay.reset();
+
+ void (async () => {
+ try {
+ await preloadCursorAssets();
+ } catch (error) {
+ console.warn("Failed to refresh cursor assets for preview:", error);
+ return;
+ }
+
+ if (cancelled || cursorOverlayRef.current !== overlay) {
+ return;
+ }
+
+ overlay.setStyle(cursorStyle);
+ overlay.reset();
+ })();
+
+ return () => {
+ cancelled = true;
+ };
}, [
cursorStyle,
cursorSize,
@@ -1923,6 +1954,47 @@ const VideoPlayback = forwardRef<VideoPlaybackRef, VideoPlaybackProps>(
cursorSway,
]);
+ useEffect(() => {
+ let cancelled = false;
+ let signature = getContributedCursorStylesSignature();
+
+ const refreshSelectedCursorStyle = async () => {
+ const overlay = cursorOverlayRef.current;
+ if (!overlay) {
+ return;
+ }
+
+ try {
+ await preloadCursorAssets();
+ } catch (error) {
+ console.warn("Failed to refresh contributed cursor styles in preview:", error);
+ return;
+ }
+
+ if (cancelled || cursorOverlayRef.current !== overlay) {
+ return;
+ }
+
+ overlay.setStyle(cursorStyleRef.current);
+ overlay.reset();
+ };
+
+ const unsubscribe = extensionHost.onChange(() => {
+ const nextSignature = getContributedCursorStylesSignature();
+ if (nextSignature === signature) {
+ return;
+ }
+
+ signature = nextSignature;
+ void refreshSelectedCursorStyle();
+ });
+
+ return () => {
+ cancelled = true;
+ unsubscribe();
+ };
+ }, []);
+
const handleLoadedMetadata = (
e: React.SyntheticEvent<HTMLVideoElement, Event>,
) => {
diff --git a/src/components/video-editor/projectPersistence.ts b/src/components/video-editor/projectPersistence.ts
index 273e4410..96977a38 100644
--- a/src/components/video-editor/projectPersistence.ts
+++ b/src/components/video-editor/projectPersistence.ts
@@ -618,15 +618,7 @@ export function normalizeProjectEditor(editor: Partial<ProjectEditorState>): Pro
showCursor: typeof editor.showCursor === "boolean" ? editor.showCursor : true,
loopCursor: typeof editor.loopCursor === "boolean" ? editor.loopCursor : false,
cursorStyle:
- editor.cursorStyle === "dot" ||
- editor.cursorStyle === "figma" ||
- editor.cursorStyle === "mono" ||
- editor.cursorStyle === "tahoe" ||
- editor.cursorStyle === "lavender" ||
- editor.cursorStyle === "parched" ||
- editor.cursorStyle === "chooper" ||
- editor.cursorStyle === "amongus" ||
- editor.cursorStyle === "turtle"
+ typeof editor.cursorStyle === "string" && editor.cursorStyle.trim().length > 0
? editor.cursorStyle
: DEFAULT_CURSOR_STYLE,
cursorSize: isFiniteNumber(editor.cursorSize)
diff --git a/src/components/video-editor/types.ts b/src/components/video-editor/types.ts
index 0e989b8c..3d273422 100644
--- a/src/components/video-editor/types.ts
+++ b/src/components/video-editor/types.ts
@@ -52,7 +52,8 @@ export type CursorStyle =
| "parched"
| "chooper"
| "amongus"
- | "turtle";
+ | "turtle"
+ | (string & {}); // extension-contributed cursor styles
export const DEFAULT_CURSOR_STYLE: CursorStyle = "tahoe";
export type ZoomTransitionEasing = "recordly" | "glide" | "smooth" | "snappy" | "linear";
diff --git a/src/components/video-editor/videoPlayback/cursorRenderer.ts b/src/components/video-editor/videoPlayback/cursorRenderer.ts
index 81135600..1ee19e82 100644
--- a/src/components/video-editor/videoPlayback/cursorRenderer.ts
+++ b/src/components/video-editor/videoPlayback/cursorRenderer.ts
@@ -1,5 +1,7 @@
import { Assets, BlurFilter, Container, Graphics, Sprite, Texture } from "pixi.js";
import { MotionBlurFilter } from "pixi-filters/motion-blur";
+import { getRenderableAssetUrl } from "@/lib/assetPath";
+import { extensionHost } from "@/lib/extensions";
import minimalCursorUrl from "../../../../Minimal Cursor.svg";
import amongusDefaultCursorUrl from "../../../assets/cursors/amongus/default.png";
import amongusPointerCursorUrl from "../../../assets/cursors/amongus/pointer.png";
@@ -105,11 +107,13 @@ const CURSOR_SHADOW_BLUR = 3;
const CURSOR_SHADOW_PADDING = 12;
let cursorAssetsPromise: Promise<void> | null = null;
+let cursorPackAssetsPromise: Promise<void> | null = null;
+let loadedCursorPackSourcesSignature = "";
let loadedCursorAssets: Partial<Record<CursorAssetKey, LoadedCursorAsset>> = {};
let loadedInvertedCursorAssets: Partial<Record<CursorAssetKey, LoadedCursorAsset>> = {};
let loadedCursorStyleAssets: Partial<Record<SingleCursorStyle, LoadedCursorAsset>> = {};
-let loadedCursorPackAssets: Partial<Record<CursorPackStyle, LoadedCursorPackAssets>> = {};
-const warnedMissingCursorPackStyles = new Set<CursorPackStyle>();
+let loadedCursorPackAssets: Partial<Record<string, LoadedCursorPackAssets>> = {};
+const warnedMissingCursorPackStyles = new Set<string>();
const SUPPORTED_CURSOR_KEYS: CursorAssetKey[] = [
"arrow",
"text",
@@ -126,7 +130,7 @@ const DEFAULT_CURSOR_PACK_ANCHOR = { x: 0.08, y: 0.08 } as const;
const POINTER_CURSOR_PACK_ANCHOR = { x: 0.48, y: 0.1 } as const;
const CENTERED_CURSOR_PACK_ANCHOR = { x: 0.5, y: 0.5 } as const;
const CURSOR_PACK_POINTER_TYPES = new Set<CursorAssetKey>(["pointer", "open-hand", "closed-hand"]);
-const CURSOR_PACK_SOURCES: Record<CursorPackStyle, CursorPackSource> = {
+const BUILTIN_CURSOR_PACK_SOURCES: Record<string, CursorPackSource> = {
lavender: {
defaultUrl: lavenderDefaultCursorUrl,
pointerUrl: lavenderPointerCursorUrl,
@@ -159,6 +163,32 @@ const CURSOR_PACK_SOURCES: Record<CursorPackStyle, CursorPackSource> = {
},
};
+function getCursorPackSources(): Record<string, CursorPackSource> {
+ const sources: Record<string, CursorPackSource> = { ...BUILTIN_CURSOR_PACK_SOURCES };
+
+ for (const cursorStyle of extensionHost.getContributedCursorStyles()) {
+ const hotspot = cursorStyle.cursorStyle.hotspot ?? DEFAULT_CURSOR_PACK_ANCHOR;
+ sources[cursorStyle.id] = {
+ defaultUrl: cursorStyle.resolvedDefaultUrl,
+ pointerUrl: cursorStyle.resolvedClickUrl ?? cursorStyle.resolvedDefaultUrl,
+ defaultAnchor: hotspot,
+ pointerAnchor: hotspot,
+ };
+ }
+
+ return sources;
+}
+
+function buildCursorPackSourcesSignature(sources: Record<string, CursorPackSource>): string {
+ return Object.entries(sources)
+ .sort(([left], [right]) => left.localeCompare(right))
+ .map(
+ ([style, source]) =>
+ `${style}:${source.defaultUrl}:${source.pointerUrl}:${source.defaultAnchor.x}:${source.defaultAnchor.y}:${source.pointerAnchor.x}:${source.pointerAnchor.y}`,
+ )
+ .join("|");
+}
+
function isStatefulCursorStyle(style: CursorStyle): style is StatefulCursorStyle {
return style === "tahoe" || style === "mono";
}
@@ -226,9 +256,10 @@ async function createCursorPackAsset(
url: string,
anchor: { x: number; y: number },
): Promise<LoadedCursorAsset> {
- await Assets.load(url);
- const image = await loadImage(url);
- const texture = Texture.from(url);
+ const renderableUrl = await getRenderableAssetUrl(url);
+ await Assets.load(renderableUrl);
+ const image = await loadImage(renderableUrl);
+ const texture = Texture.from(renderableUrl);
return {
texture,
@@ -459,6 +490,41 @@ function getStatefulCursorAsset(style: StatefulCursorStyle, key: CursorAssetKey)
return asset;
}
+async function ensureCursorPackAssetsLoaded() {
+ const sources = getCursorPackSources();
+ const signature = buildCursorPackSourcesSignature(sources);
+
+ if (!cursorPackAssetsPromise || loadedCursorPackSourcesSignature !== signature) {
+ loadedCursorPackSourcesSignature = signature;
+ warnedMissingCursorPackStyles.clear();
+ cursorPackAssetsPromise = (async () => {
+ const cursorPackEntries = await Promise.all(
+ Object.entries(sources).map(async ([style, source]) => {
+ try {
+ const [defaultAsset, pointerAsset] = await Promise.all([
+ createCursorPackAsset(source.defaultUrl, source.defaultAnchor),
+ createCursorPackAsset(source.pointerUrl, source.pointerAnchor),
+ ]);
+ return [style, { default: defaultAsset, pointer: pointerAsset }] as const;
+ } catch (error) {
+ console.warn(
+ `[CursorRenderer] Failed to load cursor pack style for: ${style}`,
+ error,
+ );
+ return null;
+ }
+ }),
+ );
+
+ loadedCursorPackAssets = Object.fromEntries(
+ cursorPackEntries.filter(Boolean).map((entry) => entry!),
+ ) as Partial<Record<string, LoadedCursorPackAssets>>;
+ })();
+ }
+
+ await cursorPackAssetsPromise;
+}
+
export async function preloadCursorAssets() {
if (!cursorAssetsPromise) {
cursorAssetsPromise = (async () => {
@@ -566,37 +632,14 @@ export async function preloadCursorAssets() {
Record<SingleCursorStyle, LoadedCursorAsset>
>;
- const cursorPackEntries = await Promise.all(
- (Object.entries(CURSOR_PACK_SOURCES) as Array<[CursorPackStyle, CursorPackSource]>).map(
- async ([style, source]) => {
- try {
- const [defaultAsset, pointerAsset] = await Promise.all([
- createCursorPackAsset(source.defaultUrl, source.defaultAnchor),
- createCursorPackAsset(source.pointerUrl, source.pointerAnchor),
- ]);
- return [style, { default: defaultAsset, pointer: pointerAsset }] as const;
- } catch (error) {
- console.warn(
- `[CursorRenderer] Failed to load cursor pack style for: ${style}`,
- error,
- );
- return null;
- }
- },
- ),
- );
-
- loadedCursorPackAssets = Object.fromEntries(
- cursorPackEntries.filter(Boolean).map((entry) => entry!),
- ) as Partial<Record<CursorPackStyle, LoadedCursorPackAssets>>;
-
if (!loadedCursorAssets.arrow) {
throw new Error("Failed to initialize the fallback arrow cursor asset");
}
})();
}
- return cursorAssetsPromise;
+ await cursorAssetsPromise;
+ await ensureCursorPackAssetsLoaded();
}
/**
diff --git a/src/lib/assetPath.ts b/src/lib/assetPath.ts
index 229e2ea4..30069b23 100644
--- a/src/lib/assetPath.ts
+++ b/src/lib/assetPath.ts
@@ -108,5 +108,63 @@ export async function getRenderableAssetUrl(asset: string): Promise<string> {
}
}
-export default getAssetPath;
+// ---------------------------------------------------------------------------
+// Wallpaper thumbnail helper — generates a tiny JPEG thumbnail via the main
+// process (nativeImage resize) and returns a data URL for fast grid rendering.
+// Concurrency is capped to avoid OOM from loading many full-res images at once.
+// ---------------------------------------------------------------------------
+
+const thumbnailCache = new Map<string, string>()
+
+const THUMB_CONCURRENCY = 3
+let thumbActive = 0
+const thumbQueue: Array<() => void> = []
+
+function acquireThumbSlot(): Promise<void> {
+ if (thumbActive < THUMB_CONCURRENCY) {
+ thumbActive++
+ return Promise.resolve()
+ }
+ return new Promise<void>((resolve) => thumbQueue.push(resolve))
+}
+
+function releaseThumbSlot(): void {
+ const next = thumbQueue.shift()
+ if (next) {
+ next()
+ } else {
+ thumbActive--
+ }
+}
+export async function getWallpaperThumbnailUrl(asset: string): Promise<string> {
+ if (!asset || asset.startsWith('data:') || asset.startsWith('http') || asset.startsWith('#') || asset.startsWith('linear-gradient') || asset.startsWith('radial-gradient')) {
+ return asset
+ }
+
+ const cached = thumbnailCache.get(asset)
+ if (cached) return cached
+
+ const localFilePath = toLocalFilePath(asset.startsWith('/') && !asset.startsWith('//') ? await getAssetPath(asset.replace(/^\//, '')) : asset)
+ if (!localFilePath || typeof window === 'undefined' || !window.electronAPI?.generateWallpaperThumbnail) {
+ return getRenderableAssetUrl(asset)
+ }
+
+ await acquireThumbSlot()
+ try {
+ const result = await window.electronAPI.generateWallpaperThumbnail(localFilePath)
+ if (!result.success || !result.data) {
+ return getRenderableAssetUrl(asset)
+ }
+ const bytes = result.data instanceof Uint8Array ? result.data : new Uint8Array(result.data)
+ const dataUrl = `data:image/jpeg;base64,${toBase64(bytes)}`
+ thumbnailCache.set(asset, dataUrl)
+ return dataUrl
+ } catch {
+ return getRenderableAssetUrl(asset)
+ } finally {
+ releaseThumbSlot()
+ }
+}
+
+export default getAssetPath;
diff --git a/src/lib/extensions/extensionHost.ts b/src/lib/extensions/extensionHost.ts
index 6443e393..29daf098 100644
--- a/src/lib/extensions/extensionHost.ts
+++ b/src/lib/extensions/extensionHost.ts
@@ -6,7 +6,9 @@
*/
import type {
+ ContributedCursorStyle,
ContributedFrame,
+ ContributedWallpaper,
CursorEffectContext,
CursorEffectFn,
ExtensionEvent,
@@ -59,11 +61,20 @@ function installElectronAPIGuard(): void {
},
});
- Object.defineProperty(window, "electronAPI", {
- value: proxy,
- writable: false,
- configurable: false,
- });
+ // contextBridge.exposeInMainWorld creates a non-configurable property on
+ // window. Attempting Object.defineProperty on it throws "Cannot redefine
+ // property: electronAPI" which crashes the renderer (and makes the
+ // transparent HUD window invisible). Only redefine when the descriptor
+ // allows it; otherwise the proxy is still used internally via
+ // _realElectronAPI so app code keeps working.
+ const desc = Object.getOwnPropertyDescriptor(window, "electronAPI");
+ if (!desc || desc.configurable) {
+ Object.defineProperty(window, "electronAPI", {
+ value: proxy,
+ writable: false,
+ configurable: false,
+ });
+ }
}
installElectronAPIGuard();
@@ -84,6 +95,26 @@ interface RegisteredSettingsPanel {
panel: ExtensionSettingsPanel;
}
+interface RegisteredWallpaper {
+ id: string;
+ extensionId: string;
+ wallpaper: ContributedWallpaper;
+ /** Resolved absolute URL to the wallpaper file */
+ resolvedUrl: string;
+ /** Resolved absolute URL to the thumbnail (or resolvedUrl if absent) */
+ resolvedThumbnailUrl: string;
+}
+
+interface RegisteredCursorStyle {
+ id: string;
+ extensionId: string;
+ cursorStyle: ContributedCursorStyle;
+ /** Resolved absolute URL to the default cursor image */
+ resolvedDefaultUrl: string;
+ /** Resolved absolute URL to the click image (if provided) */
+ resolvedClickUrl?: string;
+}
+
interface ActiveExtension {
info: ExtensionInfo;
module: RecordlyExtensionModule;
@@ -104,6 +135,8 @@ export class ExtensionHost {
{ extensionId: string; handler: ExtensionEventHandler }[]
>();
private settingsPanels: RegisteredSettingsPanel[] = [];
+ private wallpapers: RegisteredWallpaper[] = [];
+ private cursorStyles: RegisteredCursorStyle[] = [];
private extensionSettings = new Map<string, Record<string, unknown>>();
private settingChangeCallbacks = new Map<
string,
@@ -360,6 +393,20 @@ export class ExtensionHost {
return [...this.frames];
}
+ /**
+ * Get all contributed wallpapers from active extensions.
+ */
+ getContributedWallpapers(): RegisteredWallpaper[] {
+ return [...this.wallpapers];
+ }
+
+ /**
+ * Get all contributed cursor styles from active extensions.
+ */
+ getContributedCursorStyles(): RegisteredCursorStyle[] {
+ return [...this.cursorStyles];
+ }
+
/**
* Subscribe to changes in extensions (activation/deactivation).
*/
@@ -639,6 +686,59 @@ export class ExtensionHost {
return dispose;
},
+ registerWallpaper(wallpaper: ContributedWallpaper): () => void {
+ requirePermission("assets", "registerWallpaper");
+ const resolvedUrl = resolveExtensionRelativeFileUrl(extensionPath, wallpaper.file);
+ const resolvedThumbnailUrl = wallpaper.thumbnail
+ ? resolveExtensionRelativeFileUrl(extensionPath, wallpaper.thumbnail)
+ : resolvedUrl;
+ const entry: RegisteredWallpaper = {
+ id: `${extensionId}/${wallpaper.id}`,
+ extensionId,
+ wallpaper,
+ resolvedUrl,
+ resolvedThumbnailUrl,
+ };
+ host.wallpapers.push(entry);
+ host.notifyListeners();
+
+ const dispose = () => {
+ const index = host.wallpapers.indexOf(entry);
+ if (index >= 0) host.wallpapers.splice(index, 1);
+ host.notifyListeners();
+ };
+ disposables.push(dispose);
+ return dispose;
+ },
+
+ registerCursorStyle(cursorStyle: ContributedCursorStyle): () => void {
+ requirePermission("assets", "registerCursorStyle");
+ const resolvedDefaultUrl = resolveExtensionRelativeFileUrl(
+ extensionPath,
+ cursorStyle.defaultImage,
+ );
+ const resolvedClickUrl = cursorStyle.clickImage
+ ? resolveExtensionRelativeFileUrl(extensionPath, cursorStyle.clickImage)
+ : undefined;
+ const entry: RegisteredCursorStyle = {
+ id: `${extensionId}/${cursorStyle.id}`,
+ extensionId,
+ cursorStyle,
+ resolvedDefaultUrl,
+ resolvedClickUrl,
+ };
+ host.cursorStyles.push(entry);
+ host.notifyListeners();
+
+ const dispose = () => {
+ const index = host.cursorStyles.indexOf(entry);
+ if (index >= 0) host.cursorStyles.splice(index, 1);
+ host.notifyListeners();
+ };
+ disposables.push(dispose);
+ return dispose;
+ },
+
on(event: ExtensionEventType, handler: ExtensionEventHandler): () => void {
const requiredPermission = getEventPermission(event);
if (requiredPermission) {
diff --git a/src/lib/extensions/types.ts b/src/lib/extensions/types.ts
index 0836e1ea..5bf6a969 100644
--- a/src/lib/extensions/types.ts
+++ b/src/lib/extensions/types.ts
@@ -423,6 +423,12 @@ export interface RecordlyExtensionAPI {
/** Register a device frame (browser chrome, laptop bezel, etc.) */
registerFrame(frame: ContributedFrame): () => void;
+ /** Register a wallpaper/background image or video */
+ registerWallpaper(wallpaper: ContributedWallpaper): () => void;
+
+ /** Register a cursor style pack */
+ registerCursorStyle(cursorStyle: ContributedCursorStyle): () => void;
+
/** Listen to extension events */
on(event: ExtensionEventType, handler: ExtensionEventHandler): () => void;