Skip to content

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

Disable the extension system

young0375b9c183b7
diff --git a/electron/electron-env.d.ts b/electron/electron-env.d.ts
index 8a4eedd6..7dce4fa0 100644
--- a/electron/electron-env.d.ts
+++ b/electron/electron-env.d.ts
@@ -64,13 +64,6 @@ interface UpdateStatusSummary {
detail?: string;
}
-type RendererExtensionInfo = import("./extensions/extensionTypes").ExtensionInfo;
-type RendererExtensionReview = import("./extensions/extensionTypes").ExtensionReview;
-type RendererMarketplaceExtension = import("./extensions/extensionTypes").MarketplaceExtension;
-type RendererMarketplaceReviewStatus =
- import("./extensions/extensionTypes").MarketplaceReviewStatus;
-type RendererMarketplaceSearchResult =
- import("./extensions/extensionTypes").MarketplaceSearchResult;
type RendererRecordingSessionData = import("./ipc/types").RecordingSessionData;
interface RendererFfmpegAudioMuxMetrics {
@@ -898,46 +891,6 @@ interface Window {
cancelCountdown: () => Promise<{ success: boolean }>;
getActiveCountdown: () => Promise<{ success: boolean; seconds: number | null }>;
onCountdownTick: (callback: (seconds: number) => void) => () => void;
- extensionsDiscover: () => Promise<RendererExtensionInfo[]>;
- extensionsList: () => Promise<RendererExtensionInfo[]>;
- extensionsGet: (id: string) => Promise<RendererExtensionInfo | null>;
- extensionsEnable: (id: string) => Promise<{ success: boolean; error?: string }>;
- extensionsDisable: (id: string) => Promise<{ success: boolean; error?: string }>;
- extensionsInstallFromFolder: () => Promise<{
- success: boolean;
- extension?: RendererExtensionInfo;
- message?: string;
- error?: string;
- canceled?: boolean;
- }>;
- extensionsUninstall: (id: string) => Promise<{ success: boolean; error?: string }>;
- extensionsGetDirectory: () => Promise<{ success: boolean; path?: string; error?: string }>;
- extensionsOpenDirectory: () => Promise<{ success: boolean; path?: string; error?: string }>;
- extensionsMarketplaceSearch: (params: {
- query?: string;
- tags?: string[];
- sort?: string;
- page?: number;
- pageSize?: number;
- }) => Promise<RendererMarketplaceSearchResult & { error?: string }>;
- extensionsMarketplaceGet: (id: string) => Promise<RendererMarketplaceExtension | null>;
- extensionsMarketplaceInstall: (
- extensionId: string,
- downloadUrl: string,
- ) => Promise<{ success: boolean; error?: string }>;
- extensionsMarketplaceSubmit: (
- extensionId: string,
- ) => Promise<{ success: boolean; reviewId?: string; error?: string }>;
- extensionsReviewsList: (params: {
- status?: RendererMarketplaceReviewStatus;
- page?: number;
- pageSize?: number;
- }) => Promise<{ reviews: RendererExtensionReview[]; total: number; error?: string }>;
- extensionsReviewUpdate: (
- reviewId: string,
- status: RendererMarketplaceReviewStatus,
- notes?: string,
- ) => Promise<{ success: boolean; error?: string }>;
};
}
diff --git a/electron/main.ts b/electron/main.ts
index 470fc824..60eb16bb 100644
--- a/electron/main.ts
+++ b/electron/main.ts
@@ -6,6 +6,7 @@ import {
BrowserWindow,
desktopCapturer,
dialog,
+ webContents as electronWebContents,
ipcMain,
Menu,
Notification,
@@ -14,11 +15,9 @@ import {
shell,
systemPreferences,
Tray,
- webContents as electronWebContents,
} from "electron";
import { RECORDINGS_DIR } from "./appPaths";
import { showCursor } from "./cursorHider";
-import { registerExtensionIpcHandlers } from "./extensions/extensionIpc";
import { getGpuSwitches } from "./gpuSwitches";
import {
cleanupAllExportStreams,
@@ -28,12 +27,9 @@ import {
registerIpcHandlers,
} from "./ipc/handlers";
import { ensureMediaServer } from "./mediaServer";
+import { hardenWebContentsNavigation, shouldHardenWebContentsType } from "./navigationPolicy";
import { shouldGrantDisplayCapture, shouldGrantMediaPermission } from "./permissionPolicy";
import { ensurePackagedRendererServer, getPackagedRendererBaseUrl } from "./rendererServer";
-import {
- hardenWebContentsNavigation,
- shouldHardenWebContentsType,
-} from "./navigationPolicy";
import type { UpdateToastPayload } from "./updater";
import {
checkForAppUpdates,
@@ -1055,8 +1051,6 @@ app.whenReady().then(async () => {
},
);
- registerExtensionIpcHandlers();
-
if (IS_SMOKE_EXPORT || process.env.RECORDLY_DEV_OPEN_RECORDING_INPUT) {
await logSmokeExportGpuDiagnostics();
if (IS_SMOKE_EXPORT) {
diff --git a/electron/preload.ts b/electron/preload.ts
index e55d42cb..d53edb54 100644
--- a/electron/preload.ts
+++ b/electron/preload.ts
@@ -983,35 +983,4 @@ contextBridge.exposeInMainWorld("electronAPI", {
ipcRenderer.on("countdown-tick", listener);
return () => ipcRenderer.removeListener("countdown-tick", listener);
},
-
- // ── Extensions ──────────────────────────────────────────────────────
- extensionsDiscover: () => ipcRenderer.invoke("extensions:discover"),
- extensionsList: () => ipcRenderer.invoke("extensions:list"),
- extensionsGet: (id: string) => ipcRenderer.invoke("extensions:get", id),
- extensionsEnable: (id: string) => ipcRenderer.invoke("extensions:enable", id),
- extensionsDisable: (id: string) => ipcRenderer.invoke("extensions:disable", id),
- extensionsInstallFromFolder: () => ipcRenderer.invoke("extensions:install-from-folder"),
- extensionsUninstall: (id: string) => ipcRenderer.invoke("extensions:uninstall", id),
- extensionsGetDirectory: () => ipcRenderer.invoke("extensions:get-directory"),
- extensionsOpenDirectory: () => ipcRenderer.invoke("extensions:open-directory"),
-
- // ── Extensions — Marketplace ────────────────────────────────────────
- extensionsMarketplaceSearch: (params: {
- query?: string;
- tags?: string[];
- sort?: string;
- page?: number;
- pageSize?: number;
- }) => ipcRenderer.invoke("extensions:marketplace-search", params),
- extensionsMarketplaceGet: (id: string) => ipcRenderer.invoke("extensions:marketplace-get", id),
- extensionsMarketplaceInstall: (extensionId: string, downloadUrl: string) =>
- ipcRenderer.invoke("extensions:marketplace-install", extensionId, downloadUrl),
- extensionsMarketplaceSubmit: (extensionId: string) =>
- ipcRenderer.invoke("extensions:marketplace-submit", extensionId),
-
- // ── Extensions — Admin Review ───────────────────────────────────────
- extensionsReviewsList: (params: { status?: string; page?: number; pageSize?: number }) =>
- ipcRenderer.invoke("extensions:reviews-list", params),
- extensionsReviewUpdate: (reviewId: string, status: string, notes?: string) =>
- ipcRenderer.invoke("extensions:review-update", reviewId, status, notes),
});
diff --git a/src/components/video-editor/ExtensionManager.tsx b/src/components/video-editor/ExtensionManager.tsx
index ef06fb8e..b8fc0f58 100644
--- a/src/components/video-editor/ExtensionManager.tsx
+++ b/src/components/video-editor/ExtensionManager.tsx
@@ -1,1113 +1,29 @@
-/**
- * ExtensionManager — Sidebar panel for browsing, installing, and managing extensions.
- *
- * Matches the SettingsPanel sidebar styling with tabs:
- * - Browse: Marketplace search and download
- * - Installed: Local extensions with toggle switches
- */
-
-import {
- BookOpen,
- Check,
- CaretLeft as ChevronLeft,
- CaretRight as ChevronRight,
- DownloadSimple as Download,
- ArrowSquareOut as ExternalLink,
- FolderOpen,
- SpinnerGap as Loader2,
- Plus,
- PuzzlePiece as Puzzle,
- ArrowsClockwise as RefreshCw,
- MagnifyingGlass as Search,
- ShieldWarning as ShieldAlert,
- Tag,
- Trash as Trash2,
-} from "@phosphor-icons/react";
-import { AnimatePresence, LayoutGroup, motion } from "motion/react";
-import { useCallback, useEffect, useRef, useState } from "react";
-import { toast } from "sonner";
-import { Button } from "@/components/ui/button";
-import { Dialog, DialogContent } from "@/components/ui/dialog";
-import { Switch } from "@/components/ui/switch";
+import { PuzzlePiece } from "@phosphor-icons/react";
import { useScopedT } from "@/contexts/I18nContext";
-import { useExtensions } from "@/hooks/useExtensions";
-import type { ExtensionInfo, MarketplaceExtension } from "@/lib/extensions";
-import { cn } from "@/lib/utils";
-import { ExtensionIcon } from "./ExtensionIcon";
-
-type ExtensionTab = "installed" | "browse";
-
-const TAB_OPTIONS: { value: ExtensionTab; labelKey: string }[] = [
- { value: "browse", labelKey: "tabs.browse" },
- { value: "installed", labelKey: "tabs.installed" },
-];
-
-const EXTENSIONS_DOCS_URL = "https://marketplace.recordly.dev/extensions";
-const EXTENSIONS_SUBMIT_URL = "https://marketplace.recordly.dev/extensions/submit";
-
-function toSafeHttpUrl(value?: string): string | null {
- if (!value) return null;
-
- try {
- const parsed = new URL(value);
- return parsed.protocol === "http:" || parsed.protocol === "https:"
- ? parsed.toString()
- : null;
- } catch {
- return null;
- }
-}
-
-// ---------------------------------------------------------------------------
-// Installed Extension Card
-// ---------------------------------------------------------------------------
-
-function InstalledExtensionCard({
- extension,
- isActive,
- onToggle,
- onUninstall,
- onClick,
-}: {
- extension: ExtensionInfo;
- isActive: boolean;
- onToggle: () => void;
- onUninstall?: () => void;
- onClick?: () => void;
-}) {
- const t = useScopedT("extensions");
- const isError = extension.status === "error";
- const isBuiltin = extension.builtin;
- const homepageUrl = toSafeHttpUrl(extension.manifest.homepage);
-
- return (
- <div
- className={cn(
- "flex items-start gap-3 p-3 rounded-xl border transition-colors cursor-pointer",
- isError
- ? "border-red-500/30 bg-red-500/5"
- : isActive
- ? "border-[#2563EB]/20 bg-[#2563EB]/5"
- : "border-foreground/[0.06] bg-white/[0.02] hover:bg-foreground/[0.04]",
- )}
- onClick={onClick}
- >
- <div className="flex-shrink-0 w-8 h-8 rounded-lg bg-foreground/5 border border-foreground/10 flex items-center justify-center overflow-hidden">
- <ExtensionIcon
- icon={extension.manifest.icon}
- extensionPath={extension.path}
- className="w-3.5 h-3.5 text-muted-foreground"
- imageClassName="w-8 h-8 rounded-lg"
- />
- </div>
-
- <div className="flex-1 min-w-0">
- <div className="flex items-center gap-1.5">
- <span className="text-[13px] font-medium text-foreground truncate">
- {extension.manifest.name}
- </span>
- </div>
-
- {extension.manifest.author && (
- <p className="text-[10px] text-muted-foreground/70 mt-0.5">
- {homepageUrl ? (
- <a
- href={homepageUrl}
- target="_blank"
- rel="noopener noreferrer"
- className="hover:text-muted-foreground transition-colors"
- onClick={(e) => e.stopPropagation()}
- >
- {t("detail.by", undefined, { author: extension.manifest.author })}
- </a>
- ) : (
- <>{t("detail.by", undefined, { author: extension.manifest.author })}</>
- )}
- </p>
- )}
-
- <p className="text-[11px] text-muted-foreground/70 mt-0.5 line-clamp-3">
- {extension.manifest.description || t("detail.noDescription")}
- </p>
-
- {isError && extension.error && (
- <p className="text-[10px] text-red-400 mt-1">
- {t("detail.error", undefined, { message: extension.error })}
- </p>
- )}
-
- {extension.manifest.permissions.length > 0 && (
- <div className="flex gap-1 mt-1.5 flex-wrap">
- {extension.manifest.permissions.map((perm) => (
- <span
- key={perm}
- className="text-[8px] px-1 py-[1px] rounded bg-foreground/5 text-muted-foreground font-mono"
- >
- {perm}
- </span>
- ))}
- </div>
- )}
- </div>
-
- <div className="flex items-center gap-1.5 flex-shrink-0">
- {!isBuiltin && onUninstall && (
- <Button
- variant="ghost"
- size="icon"
- className="h-6 w-6 text-muted-foreground hover:text-red-400 hover:bg-red-500/10"
- onClick={(e) => {
- e.stopPropagation();
- onUninstall();
- }}
- title={t("actions.uninstall")}
- >
- <Trash2 className="w-3 h-3" />
- </Button>
- )}
- <div onClick={(e) => e.stopPropagation()}>
- <Switch checked={isActive} onCheckedChange={onToggle} disabled={isError} />
- </div>
- </div>
- </div>
- );
-}
-
-// ---------------------------------------------------------------------------
-// Marketplace Extension Card
-// ---------------------------------------------------------------------------
-
-function MarketplaceCard({
- extension,
- isInstalling,
- onInstall,
- onClick,
-}: {
- extension: MarketplaceExtension;
- isInstalling: boolean;
- onInstall: () => void;
- onClick?: () => void;
-}) {
- const t = useScopedT("extensions");
- const homepageUrl = toSafeHttpUrl(extension.homepage);
- return (
- <div
- className="flex items-start gap-3 p-3 rounded-xl border border-foreground/[0.06] bg-white/[0.02] hover:bg-foreground/[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-foreground/10 flex items-center justify-center overflow-hidden">
- {extension.iconUrl ? (
- <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-muted-foreground" />
- )}
- </div>
-
- <div className="flex-1 min-w-0">
- <div className="flex items-center gap-1.5">
- <span className="text-[13px] font-medium text-foreground truncate">
- {extension.name}
- </span>
- </div>
-
- <p className="text-[10px] text-muted-foreground/70 mt-0.5">
- {homepageUrl ? (
- <a
- href={homepageUrl}
- target="_blank"
- rel="noopener noreferrer"
- className="hover:text-muted-foreground transition-colors"
- onClick={(e) => e.stopPropagation()}
- >
- {t("detail.by", undefined, { author: extension.author })}
- </a>
- ) : (
- <>{t("detail.by", undefined, { author: extension.author })}</>
- )}
- </p>
-
- <p className="text-[11px] text-muted-foreground/70 mt-0.5 line-clamp-3">
- {extension.description}
- </p>
-
- <div className="flex items-center gap-3 mt-1.5">
- <span className="flex items-center gap-0.5 text-[10px] text-muted-foreground">
- <Download className="w-2.5 h-2.5" />
- {extension.downloads.toLocaleString()}
- </span>
- </div>
-
- {extension.tags.length > 0 && (
- <div className="flex gap-1 mt-1.5 flex-wrap">
- {extension.tags.slice(0, 3).map((tag) => (
- <span
- key={tag}
- className="text-[8px] px-1 py-[1px] rounded bg-[#2563EB]/10 text-[#2563EB]/70 font-medium"
- >
- {tag}
- </span>
- ))}
- </div>
- )}
- </div>
-
- <div className="flex-shrink-0">
- {extension.installed ? (
- <span className="flex items-center gap-1 text-[10px] text-emerald-500 font-medium">
- <Check className="w-3 h-3" />
- {t("status.installed")}
- </span>
- ) : (
- <Button
- variant="ghost"
- size="sm"
- className="h-7 px-2.5 text-[11px] text-[#2563EB] hover:text-[#2563EB] hover:bg-[#2563EB]/10 font-medium gap-1"
- onClick={(e) => {
- e.stopPropagation();
- onInstall();
- }}
- disabled={isInstalling}
- >
- {isInstalling ? (
- <Loader2 className="w-3 h-3 animate-spin" />
- ) : (
- <Download className="w-3 h-3" />
- )}
- {isInstalling ? t("actions.installing") : t("actions.install")}
- </Button>
- )}
- </div>
- </div>
- );
-}
-
-// ---------------------------------------------------------------------------
-// Screenshot Gallery Carousel
-// ---------------------------------------------------------------------------
-
-function ScreenshotGallery({ screenshots }: { screenshots: string[] }) {
- const t = useScopedT("extensions");
- 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-muted-foreground/70 mb-1.5">
- {t("detail.preview")}
- </p>
- <div className="relative group rounded-lg overflow-hidden bg-black/20 border border-foreground/[0.06]">
- <img
- src={screenshots[index]}
- alt={t("detail.screenshotAlt", undefined, { number: String(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-editor-bg/80 text-foreground/80 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity hover:bg-editor-bg/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-editor-bg/80 text-foreground/80 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity hover:bg-editor-bg/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-foreground/50",
- )}
- onClick={() => setIndex(i)}
- />
- ))}
- </div>
- </>
- )}
- </div>
- </div>
- );
-}
-
-// ---------------------------------------------------------------------------
-// Extension Detail (unified type for installed + marketplace)
-// ---------------------------------------------------------------------------
-
-type ExtensionDetailData =
- | { source: "installed"; ext: ExtensionInfo; isActive: boolean }
- | { source: "marketplace"; ext: MarketplaceExtension };
-
-function ExtensionDetailModal({
- detail,
- onClose,
- onToggle,
- onInstall,
- isInstalling,
-}: {
- detail: ExtensionDetailData;
- onClose: () => void;
- onToggle?: () => void;
- onInstall?: () => void;
- isInstalling?: boolean;
-}) {
- const t = useScopedT("extensions");
- const isInstalled = detail.source === "installed";
- const name = isInstalled ? detail.ext.manifest.name : detail.ext.name;
- const description = isInstalled
- ? detail.ext.manifest.description || t("detail.noDescription")
- : detail.ext.description || t("detail.noDescription");
- 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 homepageUrl = toSafeHttpUrl(homepage);
- const screenshots = detail.source === "marketplace" ? (detail.ext.screenshots ?? []) : [];
- const isError = isInstalled ? detail.ext.status === "error" : false;
-
- return (
- <Dialog
- open
- onOpenChange={(open) => {
- if (!open) onClose();
- }}
- >
- <DialogContent className="max-w-md bg-editor-panel border-foreground/10 text-foreground p-0 gap-0 overflow-hidden">
- {/* Header */}
- <div className="p-5 pb-4">
- <div className="flex items-start gap-3.5">
- <div className="flex-shrink-0 w-12 h-12 rounded-xl bg-gradient-to-br from-[#2563EB]/20 to-[#2563EB]/5 border border-foreground/10 flex items-center justify-center">
- {detail.source === "marketplace" && detail.ext.iconUrl ? (
- <img
- src={detail.ext.iconUrl}
- alt=""
- className="w-7 h-7 rounded-lg"
- />
- ) : (
- <ExtensionIcon
- icon={isInstalled ? detail.ext.manifest.icon : undefined}
- extensionPath={isInstalled ? detail.ext.path : undefined}
- className="w-5 h-5 text-[#2563EB]/60"
- />
- )}
- </div>
- <div className="flex-1 min-w-0">
- <div className="flex items-center gap-1.5">
- <h2 className="text-[15px] font-semibold text-foreground truncate">
- {name}
- </h2>
- </div>
- <p className="text-[11px] text-muted-foreground/70 mt-0.5">
- {author ? (
- homepageUrl ? (
- <a
- href={homepageUrl}
- target="_blank"
- rel="noopener noreferrer"
- className="hover:text-muted-foreground transition-colors inline-flex items-center gap-1"
- >
- {t("detail.by", undefined, { author })}
- <ExternalLink className="w-2.5 h-2.5" />
- </a>
- ) : (
- <>{t("detail.by", undefined, { author })}</>
- )
- ) : (
- t("detail.unknownAuthor")
- )}
- </p>
- </div>
- </div>
-
- {/* Stats for marketplace extensions */}
- {detail.source === "marketplace" && (
- <div className="flex items-center gap-3 mt-3">
- <span className="flex items-center gap-1 text-[11px] text-muted-foreground/70">
- <Download className="w-3 h-3" />
- {t("detail.downloads", undefined, {
- count: detail.ext.downloads.toLocaleString(),
- })}
- </span>
- </div>
- )}
- </div>
-
- {/* 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-muted-foreground/70 mb-1.5">
- {t("detail.description")}
- </p>
- <p className="text-[12px] text-muted-foreground leading-relaxed whitespace-pre-wrap">
- {description}
- </p>
- </div>
-
- {/* Tags */}
- {detail.source === "marketplace" && detail.ext.tags.length > 0 && (
- <div>
- <p className="text-[10px] font-semibold uppercase tracking-widest text-muted-foreground/70 mb-1.5">
- {t("detail.tags")}
- </p>
- <div className="flex flex-wrap gap-1.5">
- {detail.ext.tags.map((tag) => (
- <span
- key={tag}
- className="inline-flex items-center gap-1 text-[10px] px-2 py-0.5 rounded-full bg-[#2563EB]/10 text-[#2563EB]/70 font-medium"
- >
- <Tag className="w-2.5 h-2.5" />
- {tag}
- </span>
- ))}
- </div>
- </div>
- )}
-
- {/* Permissions */}
- {permissions.length > 0 && (
- <div>
- <p className="text-[10px] font-semibold uppercase tracking-widest text-muted-foreground/70 mb-1.5">
- {t("detail.permissions")}
- </p>
- <div className="flex flex-wrap gap-1.5">
- {permissions.map((perm) => (
- <span
- key={perm}
- className="text-[10px] px-2 py-0.5 rounded bg-foreground/5 text-muted-foreground font-mono"
- >
- {perm}
- </span>
- ))}
- </div>
- </div>
- )}
-
- {/* Path (installed extensions) */}
- {isInstalled && (
- <div>
- <p className="text-[10px] font-semibold uppercase tracking-widest text-muted-foreground/70 mb-1.5">
- {t("detail.location")}
- </p>
- <p className="text-[10px] text-muted-foreground/70 font-mono break-all">
- {detail.ext.path}
- </p>
- </div>
- )}
-
- {/* Error */}
- {isError && isInstalled && detail.ext.error && (
- <div className="p-2.5 rounded-lg bg-red-500/10 border border-red-500/20">
- <p className="text-[11px] text-red-400">{detail.ext.error}</p>
- </div>
- )}
- </div>
-
- {/* Footer actions */}
- <div className="flex items-center gap-2 px-5 py-3 border-t border-foreground/[0.06] bg-white/[0.02]">
- {isInstalled && onToggle && (
- <div className="flex items-center gap-2">
- <Switch
- checked={detail.isActive}
- onCheckedChange={onToggle}
- disabled={isError}
- />
- <span className="text-[11px] text-muted-foreground">
- {detail.isActive ? t("status.enabled") : t("status.disabled")}
- </span>
- </div>
- )}
- {detail.source === "marketplace" && !detail.ext.installed && onInstall && (
- <Button
- size="sm"
- className="h-8 px-3 text-[12px] bg-[#2563EB] hover:bg-[#2563EB]/90 text-white gap-1.5"
- onClick={onInstall}
- disabled={isInstalling}
- >
- {isInstalling ? (
- <Loader2 className="w-3.5 h-3.5 animate-spin" />
- ) : (
- <Download className="w-3.5 h-3.5" />
- )}
- {isInstalling ? t("actions.installing") : t("actions.install")}
- </Button>
- )}
- {detail.source === "marketplace" && detail.ext.installed && (
- <span className="flex items-center gap-1 text-[11px] text-emerald-500 font-medium">
- <Check className="w-3.5 h-3.5" />
- {t("status.installed")}
- </span>
- )}
- <div className="flex-1" />
- <Button
- variant="ghost"
- size="sm"
- className="h-8 px-3 text-[12px] text-muted-foreground hover:text-foreground hover:bg-foreground/10"
- onClick={onClose}
- >
- {t("actions.close")}
- </Button>
- </div>
- </DialogContent>
- </Dialog>
- );
-}
-
-// ---------------------------------------------------------------------------
-// Tab Switcher (LayoutGroup pill animation — matches SettingsPanel pattern)
-// ---------------------------------------------------------------------------
-
-function TabSwitcher({
- activeTab,
- onTabChange,
- extensionCount,
-}: {
- activeTab: ExtensionTab;
- onTabChange: (tab: ExtensionTab) => void;
- extensionCount: number;
-}) {
- const t = useScopedT("extensions");
- return (
- <LayoutGroup id="extension-tab-switcher">
- <div className="grid h-8 w-full grid-cols-2 rounded-xl border border-foreground/10 bg-foreground/[0.04] p-1">
- {TAB_OPTIONS.map((option) => {
- const isActive = activeTab === option.value;
- const count = option.value === "installed" ? extensionCount : undefined;
- return (
- <button
- key={option.value}
- type="button"
- onClick={() => onTabChange(option.value)}
- className="relative rounded-lg text-[10px] font-semibold tracking-wide transition-colors"
- >
- {isActive ? (
- <motion.span
- layoutId="extension-tab-pill"
- className="absolute inset-0 rounded-lg bg-[#2563EB]"
- transition={{ type: "spring", stiffness: 420, damping: 34 }}
- />
- ) : null}
- <span
- className={cn(
- "relative z-10 flex items-center justify-center gap-1",
- isActive ? "text-white" : "text-muted-foreground hover:text-foreground",
- )}
- >
- {t(option.labelKey)}
- {count !== undefined && count > 0 && (
- <span
- className={cn(
- "text-[8px] px-1 rounded-full font-semibold min-w-[14px] text-center leading-[14px]",
- isActive
- ? "bg-white/20 text-white"
- : "bg-foreground/5 text-muted-foreground",
- )}
- >
- {count}
- </span>
- )}
- </span>
- </button>
- );
- })}
- </div>
- </LayoutGroup>
- );
-}
-
-// ---------------------------------------------------------------------------
-// Main Component
-// ---------------------------------------------------------------------------
export default function ExtensionManager() {
const t = useScopedT("extensions");
- const {
- extensions,
- activeIds,
- ready,
- refresh,
- toggleExtension,
- installFromFolder,
- uninstall,
- openDirectory,
- marketplaceSearch,
- marketplaceInstall,
- } = useExtensions();
-
- const [activeTab, setActiveTab] = useState<ExtensionTab>("browse");
- const [isRefreshing, setIsRefreshing] = useState(false);
-
- // Marketplace state
- const [searchQuery, setSearchQuery] = useState("");
- const [marketplaceResults, setMarketplaceResults] = useState<MarketplaceExtension[]>([]);
- const [marketplaceLoading, setMarketplaceLoading] = useState(false);
- const [marketplaceError, setMarketplaceError] = useState<string | null>(null);
- const [installingIds, setInstallingIds] = useState<Set<string>>(new Set());
-
- // Extension detail modal state
- const [detailData, setDetailData] = useState<ExtensionDetailData | null>(null);
- const hasAutoSearchedBrowseRef = useRef(false);
-
- const handleInstallFromFolder = useCallback(async () => {
- const success = await installFromFolder();
- if (success) {
- toast.success(t("toast.installedAndEnabled"));
- }
- }, [installFromFolder, t]);
-
- const handleUninstall = useCallback(
- async (id: string, name: string) => {
- const success = await uninstall(id);
- if (success) {
- toast.success(t("toast.uninstalled", undefined, { name }));
- // Clear installed flag in cached marketplace results
- setMarketplaceResults((prev) =>
- prev.map((e) => (e.id === id ? { ...e, installed: false } : e)),
- );
- } else {
- toast.error(t("toast.uninstallFailed", undefined, { name }));
- }
- },
- [uninstall, t],
- );
-
- // Marketplace search
- const handleSearch = useCallback(async () => {
- hasAutoSearchedBrowseRef.current = true;
- setMarketplaceLoading(true);
- setMarketplaceError(null);
- try {
- const result = await marketplaceSearch({
- query: searchQuery || undefined,
- sort: "popular",
- pageSize: 50,
- });
- setMarketplaceResults(result.extensions);
- } catch (err: unknown) {
- const message = err instanceof Error ? err.message : t("toast.searchFailed");
- setMarketplaceError(message);
- setMarketplaceResults([]);
- } finally {
- setMarketplaceLoading(false);
- }
- }, [searchQuery, marketplaceSearch, t]);
-
- const handleRefresh = useCallback(async () => {
- setIsRefreshing(true);
- try {
- await refresh();
-
- if (activeTab === "browse") {
- await handleSearch();
- }
-
- toast.success(t("toast.refreshed"));
- } catch {
- toast.error(t("toast.refreshFailed"));
- } finally {
- setIsRefreshing(false);
- }
- }, [activeTab, handleSearch, refresh, t]);
-
- // Auto-search when switching to browse tab
- useEffect(() => {
- if (activeTab !== "browse") {
- hasAutoSearchedBrowseRef.current = false;
- return;
- }
-
- if (
- !hasAutoSearchedBrowseRef.current &&
- marketplaceResults.length === 0 &&
- !marketplaceLoading
- ) {
- void handleSearch();
- }
- }, [activeTab, handleSearch, marketplaceLoading, marketplaceResults.length]);
-
- // Marketplace install
- const handleMarketplaceInstall = useCallback(
- async (ext: MarketplaceExtension) => {
- setInstallingIds((prev) => new Set(prev).add(ext.id));
- try {
- const result = await marketplaceInstall(ext.id, ext.downloadUrl);
- if (result.success) {
- toast.success(t("toast.marketplaceInstalled", undefined, { name: ext.name }));
- // Update the marketplace results to show installed state
- setMarketplaceResults((prev) =>
- prev.map((e) => (e.id === ext.id ? { ...e, installed: true } : e)),
- );
- setDetailData((prev) =>
- prev?.source === "marketplace" && prev.ext.id === ext.id
- ? { ...prev, ext: { ...prev.ext, installed: true } }
- : prev,
- );
- } else {
- toast.error(
- t("toast.marketplaceInstallFailed", undefined, { name: ext.name }),
- {
- description: result.error,
- },
- );
- }
- } finally {
- setInstallingIds((prev) => {
- const next = new Set(prev);
- next.delete(ext.id);
- return next;
- });
- }
- },
- [marketplaceInstall, t],
- );
return (
- <div className="flex-[2] w-[332px] min-w-[280px] max-w-[332px] bg-editor-panel border border-foreground/10 rounded-2xl flex flex-col shadow-xl h-full overflow-hidden">
- {/* Header */}
- <div className="flex-shrink-0 p-4 pb-3">
- <div className="flex items-center justify-between mb-3">
- <div className="flex items-center gap-2">
- <Puzzle className="w-4 h-4 text-[#2563EB]" />
- <h3 className="text-[13px] font-semibold text-foreground">{t("title")}</h3>
- </div>
- <div className="flex items-center gap-0.5">
- <Button
- variant="ghost"
- size="icon"
- className="h-6 w-6 text-muted-foreground/70 hover:text-muted-foreground hover:bg-foreground/10"
- onClick={() =>
- window.electronAPI?.openExternalUrl(EXTENSIONS_SUBMIT_URL)
- }
- title={t("actions.submit")}
- >
- <Plus className="w-3 h-3" />
- </Button>
- <Button
- variant="ghost"
- size="icon"
- className="h-6 w-6 text-muted-foreground/70 hover:text-muted-foreground hover:bg-foreground/10"
- onClick={() => window.electronAPI?.openExternalUrl(EXTENSIONS_DOCS_URL)}
- title={t("actions.docs")}
- >
- <BookOpen className="w-3 h-3" />
- </Button>
- <Button
- variant="ghost"
- size="icon"
- className="h-6 w-6 text-muted-foreground/70 hover:text-muted-foreground hover:bg-foreground/10"
- onClick={handleRefresh}
- disabled={isRefreshing}
- title={t("actions.refresh")}
- >
- <RefreshCw className={cn("w-3 h-3", isRefreshing && "animate-spin")} />
- </Button>
- <Button
- variant="ghost"
- size="icon"
- className="h-6 w-6 text-muted-foreground/70 hover:text-muted-foreground hover:bg-foreground/10"
- onClick={openDirectory}
- title={t("actions.openFolder")}
- >
- <FolderOpen className="w-3 h-3" />
- </Button>
- </div>
- </div>
-
- <TabSwitcher
- activeTab={activeTab}
- onTabChange={setActiveTab}
- extensionCount={extensions.length}
- />
+ <div className="flex h-full w-[332px] min-w-[280px] max-w-[332px] flex-[2] flex-col overflow-hidden rounded-2xl border border-foreground/10 bg-editor-panel shadow-xl">
+ <div className="flex h-12 shrink-0 items-center border-b border-foreground/10 px-4">
+ <h2 className="text-sm font-semibold text-foreground">{t("title")}</h2>
</div>
- {/* 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-muted-foreground animate-spin" />
+ <div className="flex flex-1 items-center justify-center p-6">
+ <div className="flex max-w-[240px] flex-col items-center text-center">
+ <div className="mb-4 flex h-12 w-12 items-center justify-center rounded-2xl border border-foreground/10 bg-foreground/[0.04]">
+ <PuzzlePiece className="h-6 w-6 text-muted-foreground" />
</div>
- ) : (
- <AnimatePresence mode="wait" initial={false}>
- <motion.div
- key={activeTab}
- initial={{ opacity: 0, y: 8 }}
- animate={{ opacity: 1, y: 0 }}
- exit={{ opacity: 0, y: -8 }}
- transition={{ duration: 0.18, ease: "easeOut" }}
- >
- {activeTab === "installed" && (
- <InstalledTab
- extensions={extensions}
- activeIds={activeIds}
- onToggle={toggleExtension}
- onUninstall={handleUninstall}
- onInstallFromFolder={handleInstallFromFolder}
- onOpenDirectory={openDirectory}
- onViewDetail={(ext) =>
- setDetailData({
- source: "installed",
- ext,
- isActive: activeIds.has(ext.manifest.id),
- })
- }
- />
- )}
-
- {activeTab === "browse" && (
- <BrowseTab
- searchQuery={searchQuery}
- onSearchQueryChange={setSearchQuery}
- onSearch={handleSearch}
- results={marketplaceResults}
- loading={marketplaceLoading}
- error={marketplaceError}
- installingIds={installingIds}
- onInstall={handleMarketplaceInstall}
- onViewDetail={(ext) =>
- setDetailData({ source: "marketplace", ext })
- }
- />
- )}
- </motion.div>
- </AnimatePresence>
- )}
- </div>
-
- {/* Extension Detail Modal */}
- {detailData && (
- <ExtensionDetailModal
- detail={detailData}
- onClose={() => setDetailData(null)}
- onToggle={
- detailData.source === "installed"
- ? () => {
- toggleExtension(detailData.ext.manifest.id);
- setDetailData((prev) =>
- prev?.source === "installed"
- ? { ...prev, isActive: !prev.isActive }
- : prev,
- );
- }
- : undefined
- }
- onInstall={
- detailData.source === "marketplace" && !detailData.ext.installed
- ? () => handleMarketplaceInstall(detailData.ext as MarketplaceExtension)
- : undefined
- }
- isInstalling={
- detailData.source === "marketplace"
- ? installingIds.has(detailData.ext.id)
- : false
- }
- />
- )}
- </div>
- );
-}
-
-// ---------------------------------------------------------------------------
-// Installed Tab
-// ---------------------------------------------------------------------------
-
-function InstalledTab({
- extensions,
- activeIds,
- onToggle,
- onUninstall,
- onInstallFromFolder,
- onOpenDirectory,
- onViewDetail,
-}: {
- extensions: ExtensionInfo[];
- activeIds: Set<string>;
- onToggle: (id: string) => Promise<void>;
- onUninstall: (id: string, name: string) => void;
- onInstallFromFolder: () => void;
- onOpenDirectory: () => void;
- onViewDetail: (ext: ExtensionInfo) => void;
-}) {
- const t = useScopedT("extensions");
- if (extensions.length === 0) {
- return (
- <div className="flex flex-col items-center justify-center gap-3 py-10">
- <div className="w-11 h-11 rounded-full bg-foreground/[0.04] flex items-center justify-center">
- <Puzzle className="w-5 h-5 text-muted-foreground" />
- </div>
- <div className="text-center">
- <p className="text-[13px] font-medium text-muted-foreground">{t("empty.title")}</p>
- <p className="text-[11px] text-muted-foreground mt-1 leading-relaxed max-w-[200px]">
- {t("empty.description")}
+ <h3 className="text-sm font-semibold text-foreground">
+ Extensions are no longer available
+ </h3>
+ <p className="mt-2 text-xs leading-relaxed text-muted-foreground">
+ Extension installation and marketplace access have been disabled. This area
+ is kept as a placeholder for existing projects and navigation.
</p>
</div>
- <div className="flex gap-2 mt-2">
- <Button
- variant="ghost"
- size="sm"
- className="h-7 px-2.5 text-[11px] text-muted-foreground hover:text-foreground hover:bg-foreground/10 gap-1"
- onClick={onInstallFromFolder}
- >
- <Plus className="w-3 h-3" />
- {t("actions.install")}
- </Button>
- <Button
- variant="ghost"
- size="sm"
- className="h-7 px-2.5 text-[11px] text-muted-foreground hover:text-foreground hover:bg-foreground/10 gap-1"
- onClick={onOpenDirectory}
- >
- <FolderOpen className="w-3 h-3" />
- {t("actions.folder")}
- </Button>
- </div>
- </div>
- );
- }
-
- return (
- <div className="flex flex-col gap-2">
- <div className="flex items-center justify-between mb-1">
- <p className="text-[10px] font-semibold uppercase tracking-widest text-muted-foreground">
- {t("tabs.installed")}
- </p>
- <Button
- variant="ghost"
- size="sm"
- className="h-6 px-2 text-[10px] text-muted-foreground/70 hover:text-muted-foreground hover:bg-foreground/10 gap-1"
- onClick={onInstallFromFolder}
- >
- <Plus className="w-2.5 h-2.5" />
- {t("actions.add")}
- </Button>
- </div>
- {extensions.map((ext) => (
- <InstalledExtensionCard
- key={ext.manifest.id}
- extension={ext}
- isActive={activeIds.has(ext.manifest.id)}
- onToggle={() => onToggle(ext.manifest.id)}
- onUninstall={
- ext.builtin
- ? undefined
- : () => onUninstall(ext.manifest.id, ext.manifest.name)
- }
- onClick={() => onViewDetail(ext)}
- />
- ))}
- </div>
- );
-}
-
-// ---------------------------------------------------------------------------
-// Browse Tab
-// ---------------------------------------------------------------------------
-
-function BrowseTab({
- searchQuery,
- onSearchQueryChange,
- onSearch,
- results,
- loading,
- error,
- installingIds,
- onInstall,
- onViewDetail,
-}: {
- searchQuery: string;
- onSearchQueryChange: (q: string) => void;
- onSearch: () => void;
- results: MarketplaceExtension[];
- loading: boolean;
- error: string | null;
- installingIds: Set<string>;
- onInstall: (ext: MarketplaceExtension) => void;
- onViewDetail: (ext: MarketplaceExtension) => void;
-}) {
- const t = useScopedT("extensions");
- return (
- <div className="flex flex-col gap-3">
- {/* Search */}
- <div className="relative">
- <Search className="absolute left-2.5 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-muted-foreground/70 pointer-events-none" />
- <input
- type="text"
- placeholder={t("search.placeholder")}
- value={searchQuery}
- onChange={(e) => onSearchQueryChange(e.target.value)}
- onKeyDown={(e) => {
- e.stopPropagation();
- if (e.key === "Enter") onSearch();
- }}
- className="w-full h-8 pl-8 pr-3 rounded-lg bg-foreground/[0.04] border border-foreground/[0.08] text-[12px] text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-[#2563EB]/50 focus:border-[#2563EB]/30 transition-colors"
- />
</div>
-
- {/* Results */}
- {loading && (
- <div className="flex items-center justify-center py-10">
- <Loader2 className="w-5 h-5 text-muted-foreground animate-spin" />
- </div>
- )}
-
- {error && (
- <div className="flex flex-col items-center gap-2 py-8">
- <ShieldAlert className="w-5 h-5 text-red-400/60" />
- <p className="text-[11px] text-red-400/80 text-center max-w-[200px]">{error}</p>
- <Button
- variant="ghost"
- size="sm"
- className="h-7 px-2.5 text-[11px] text-muted-foreground hover:text-foreground hover:bg-foreground/10"
- onClick={onSearch}
- >
- {t("actions.retry")}
- </Button>
- </div>
- )}
-
- {!loading && !error && results.length === 0 && (
- <div className="flex flex-col items-center gap-2 py-10">
- <Search className="w-5 h-5 text-muted-foreground" />
- <p className="text-[11px] text-muted-foreground text-center">
- {searchQuery ? t("search.noResults") : t("search.noMarketplace")}
- </p>
- </div>
- )}
-
- {!loading && !error && results.length > 0 && (
- <div className="flex flex-col gap-2">
- <p className="text-[10px] font-semibold uppercase tracking-widest text-muted-foreground">
- {results.length !== 1
- ? t("search.countPlural", undefined, { count: results.length })
- : t("search.count", undefined, { count: results.length })}
- </p>
- {results.map((ext) => (
- <MarketplaceCard
- key={ext.id}
- extension={ext}
- isInstalling={installingIds.has(ext.id)}
- onInstall={() => onInstall(ext)}
- onClick={() => onViewDetail(ext)}
- />
- ))}
- </div>
- )}
</div>
);
}
diff --git a/src/components/video-editor/SettingsPanel.tsx b/src/components/video-editor/SettingsPanel.tsx
index 36e9c701..5a6fa44a 100644
--- a/src/components/video-editor/SettingsPanel.tsx
+++ b/src/components/video-editor/SettingsPanel.tsx
@@ -1406,7 +1406,7 @@ export function SettingsPanel({
setExtensionCursorPreviewUrls(Object.fromEntries(cursorPreviewEntries));
};
- void extensionHost.autoActivateBuiltins().then(updateExtensionAssets);
+ void updateExtensionAssets();
const unsubscribe = extensionHost.onChange(() => {
void updateExtensionAssets();
});
diff --git a/src/components/video-editor/VideoEditor.tsx b/src/components/video-editor/VideoEditor.tsx
index b19280bc..4a5685a1 100644
--- a/src/components/video-editor/VideoEditor.tsx
+++ b/src/components/video-editor/VideoEditor.tsx
@@ -739,11 +739,6 @@ export default function VideoEditor() {
}
}, []);
- // Auto-activate builtin extensions at editor startup (idempotent)
- useEffect(() => {
- extensionHost.autoActivateBuiltins();
- }, []);
-
const [supportedMp4SourceDimensions, setSupportedMp4SourceDimensions] =
useState<SupportedMp4Dimensions>({
width: 1920,
diff --git a/src/hooks/useExtensions.ts b/src/hooks/useExtensions.ts
index 0f2c4754..4b198cd6 100644
--- a/src/hooks/useExtensions.ts
+++ b/src/hooks/useExtensions.ts
@@ -1,41 +1,21 @@
-/**
- * useExtensions — React hook for managing extensions in the editor.
- *
- * Handles discovery, activation/deactivation, marketplace browsing,
- * downloading, and provides the extension host instance to components
- * that need render hooks.
- */
-
-import { useCallback, useEffect, useRef, useState } from "react";
import type {
ExtensionInfo,
ExtensionReview,
MarketplaceReviewStatus,
MarketplaceSearchResult,
} from "@/lib/extensions";
-import { extensionHost } from "@/lib/extensions";
-import { createExtensionModuleUrl } from "@/lib/extensions/fileUrls";
-const electronAPI = typeof window === "undefined" ? undefined : window.electronAPI;
+const UNAVAILABLE_ERROR = "Extensions are no longer available in Recordly.";
export interface UseExtensionsResult {
- /** All discovered extensions */
extensions: ExtensionInfo[];
- /** Currently active extension IDs */
activeIds: Set<string>;
- /** Whether initial discovery is complete */
ready: boolean;
- /** Discover/refresh extensions from disk */
refresh: () => Promise<void>;
- /** Toggle an extension on/off */
toggleExtension: (id: string) => Promise<void>;
- /** Install an extension from a folder */
installFromFolder: () => Promise<boolean>;
- /** Uninstall an extension */
uninstall: (id: string) => Promise<boolean>;
- /** Open the extensions directory in Finder/Explorer */
openDirectory: () => Promise<void>;
- /** Search the marketplace */
marketplaceSearch: (params: {
query?: string;
tags?: string[];
@@ -43,20 +23,16 @@ export interface UseExtensionsResult {
page?: number;
pageSize?: number;
}) => Promise<MarketplaceSearchResult>;
- /** Download and install from marketplace */
marketplaceInstall: (
extensionId: string,
downloadUrl: string,
) => Promise<{ success: boolean; error?: string }>;
- /** Submit extension for review */
marketplaceSubmit: (extensionId: string) => Promise<{ success: boolean; error?: string }>;
- /** Fetch pending reviews (admin) */
fetchReviews: (params: {
status?: MarketplaceReviewStatus;
page?: number;
pageSize?: number;
}) => Promise<{ reviews: ExtensionReview[]; total: number }>;
- /** Update review status (admin) */
updateReview: (
reviewId: string,
status: MarketplaceReviewStatus,
@@ -64,231 +40,27 @@ export interface UseExtensionsResult {
) => Promise<{ success: boolean }>;
}
-export function useExtensions(): UseExtensionsResult {
- const [extensions, setExtensions] = useState<ExtensionInfo[]>([]);
- const [activeIds, setActiveIds] = useState<Set<string>>(new Set());
- const [ready, setReady] = useState(false);
- const activatingRef = useRef(new Set<string>());
-
- const discoverAndSync = useCallback(async (): Promise<ExtensionInfo[]> => {
- let discovered: ExtensionInfo[] = [];
-
- try {
- if (!electronAPI?.extensionsDiscover) {
- setExtensions([]);
- return [];
- }
-
- discovered = await electronAPI.extensionsDiscover();
- setExtensions(discovered);
- await extensionHost.syncConfiguredExtensions(discovered);
-
- return discovered;
- } catch (error) {
- console.error("[extensions] Failed to discover extensions:", error);
- return discovered;
- } finally {
- setReady(true);
- }
- }, []);
-
- const refresh = useCallback(async () => {
- await discoverAndSync();
- }, [discoverAndSync]);
-
- // Auto-discover on mount and restore extensions marked active.
- useEffect(() => {
- void discoverAndSync();
- }, [discoverAndSync]);
-
- // Sync activeIds with extension host (immediate + future changes)
- useEffect(() => {
- const sync = () => {
- const active = extensionHost.getActiveExtensions();
- setActiveIds(new Set(active.map((e) => e.manifest.id)));
- };
- // Immediately sync with any already-active extensions
- sync();
- return extensionHost.onChange(sync);
- }, []);
-
- const toggleExtension = useCallback(
- async (id: string) => {
- if (activatingRef.current.has(id)) return;
- activatingRef.current.add(id);
-
- try {
- if (activeIds.has(id)) {
- await extensionHost.deactivateExtension(id);
- await electronAPI?.extensionsDisable(id);
- setExtensions((prev) =>
- prev.map((ext) =>
- ext.manifest.id === id ? { ...ext, status: "disabled" } : ext,
- ),
- );
- } else {
- const ext = extensions.find((e) => e.manifest.id === id);
- if (!ext) return;
-
- try {
- await electronAPI?.extensionsEnable(id);
-
- const moduleUrl = createExtensionModuleUrl(ext.path, ext.manifest.main);
- await extensionHost.activateExtension(ext, moduleUrl);
- setExtensions((prev) =>
- prev.map((candidate) =>
- candidate.manifest.id === id
- ? { ...candidate, status: "active" }
- : candidate,
- ),
- );
- } catch (err) {
- await electronAPI?.extensionsDisable(id);
- setExtensions((prev) =>
- prev.map((candidate) =>
- candidate.manifest.id === id
- ? { ...candidate, status: "disabled" }
- : candidate,
- ),
- );
- throw err;
- }
- }
- } catch (err) {
- console.error(`[extensions] Failed to toggle ${id}:`, err);
- } finally {
- activatingRef.current.delete(id);
- }
- },
- [activeIds, extensions],
- );
-
- const installFromFolder = useCallback(async (): Promise<boolean> => {
- if (!electronAPI?.extensionsInstallFromFolder) return false;
- const result = await electronAPI.extensionsInstallFromFolder();
- if (result?.success) {
- const extensionId = result.extension?.manifest?.id;
- if (typeof extensionId === "string") {
- await electronAPI?.extensionsEnable(extensionId);
- }
- await discoverAndSync();
- return true;
- }
- return false;
- }, [discoverAndSync]);
-
- const uninstall = useCallback(
- async (id: string): Promise<boolean> => {
- // Always deactivate — avoids stale closure over activeIds
- await extensionHost.deactivateExtension(id);
- if (!electronAPI?.extensionsUninstall) return false;
- const result = await electronAPI.extensionsUninstall(id);
- if (result?.success) {
- await discoverAndSync();
- return true;
- }
- return false;
- },
- [discoverAndSync],
- );
-
- const openDirectory = useCallback(async () => {
- await electronAPI?.extensionsOpenDirectory();
- }, []);
-
- const marketplaceSearch = useCallback(
- async (params: {
- query?: string;
- tags?: string[];
- sort?: "popular" | "recent" | "rating";
- page?: number;
- pageSize?: number;
- }): Promise<MarketplaceSearchResult> => {
- if (!electronAPI?.extensionsMarketplaceSearch) {
- return { extensions: [], total: 0, page: 1, pageSize: 20 };
- }
-
- const result = (await electronAPI.extensionsMarketplaceSearch(
- params,
- )) as MarketplaceSearchResult & {
- error?: string;
- };
-
- if (result?.error) {
- throw new Error(result.error);
- }
-
- return result;
- },
- [],
- );
-
- const marketplaceInstall = useCallback(
- async (extensionId: string, downloadUrl: string) => {
- if (!electronAPI?.extensionsMarketplaceInstall) {
- return { success: false, error: "Not available" };
- }
- const result = await electronAPI.extensionsMarketplaceInstall(extensionId, downloadUrl);
- if (result.success) {
- await electronAPI?.extensionsEnable(extensionId);
- await discoverAndSync();
- }
- return result;
- },
- [discoverAndSync],
- );
-
- const marketplaceSubmit = useCallback(async (extensionId: string) => {
- if (!electronAPI?.extensionsMarketplaceSubmit) {
- return { success: false, error: "Not available" };
- }
- return electronAPI.extensionsMarketplaceSubmit(extensionId);
- }, []);
-
- const fetchReviews = useCallback(
- async (params: { status?: MarketplaceReviewStatus; page?: number; pageSize?: number }) => {
- if (!electronAPI?.extensionsReviewsList) {
- return { reviews: [] as ExtensionReview[], total: 0 };
- }
-
- const result = (await electronAPI.extensionsReviewsList(params)) as {
- reviews: ExtensionReview[];
- total: number;
- error?: string;
- };
-
- if (result?.error) {
- throw new Error(result.error);
- }
-
- return result;
- },
- [],
- );
-
- const updateReview = useCallback(
- async (reviewId: string, status: MarketplaceReviewStatus, notes?: string) => {
- if (!electronAPI?.extensionsReviewUpdate) {
- return { success: false };
- }
- return electronAPI.extensionsReviewUpdate(reviewId, status, notes);
- },
- [],
- );
+const unavailableResult = { success: false, error: UNAVAILABLE_ERROR } as const;
+export function useExtensions(): UseExtensionsResult {
return {
- extensions,
- activeIds,
- ready,
- refresh,
- toggleExtension,
- installFromFolder,
- uninstall,
- openDirectory,
- marketplaceSearch,
- marketplaceInstall,
- marketplaceSubmit,
- fetchReviews,
- updateReview,
+ extensions: [],
+ activeIds: new Set(),
+ ready: true,
+ refresh: async () => undefined,
+ toggleExtension: async () => undefined,
+ installFromFolder: async () => false,
+ uninstall: async () => false,
+ openDirectory: async () => undefined,
+ marketplaceSearch: async (params) => ({
+ extensions: [],
+ total: 0,
+ page: params.page ?? 1,
+ pageSize: params.pageSize ?? 20,
+ }),
+ marketplaceInstall: async () => unavailableResult,
+ marketplaceSubmit: async () => unavailableResult,
+ fetchReviews: async () => ({ reviews: [], total: 0 }),
+ updateReview: async () => ({ success: false }),
};
}
diff --git a/src/lib/extensions/extensionHost.ts b/src/lib/extensions/extensionHost.ts
index d0683e7e..f0a69163 100644
--- a/src/lib/extensions/extensionHost.ts
+++ b/src/lib/extensions/extensionHost.ts
@@ -1,15 +1,13 @@
/**
- * Extension Host — Renderer Process
+ * Disabled extension-host compatibility surface.
*
- * Manages the lifecycle of extensions in the renderer. Loads extension
- * modules, provides the permission-gated host API, and coordinates render hooks.
+ * The editor still calls several rendering and state methods while legacy
+ * extension contributions are phased out. Activation is deliberately blocked,
+ * so these methods remain empty unless old in-memory contributions are cleaned up.
*/
-import { createExtensionModuleUrl, resolveExtensionRelativeFileUrl } from "./fileUrls";
-import { resolveIconPath } from "./iconDraw";
import type {
ContributedCursorStyle,
- ContributedFrame,
ContributedWallpaper,
CursorEffectContext,
CursorEffectFn,
@@ -19,7 +17,6 @@ import type {
ExtensionInfo,
ExtensionSettingsPanel,
FrameInstance,
- RecordlyExtensionAPI,
RecordlyExtensionModule,
RenderHookContext,
RenderHookFn,
@@ -28,58 +25,6 @@ import type {
const EXTENSION_SETTINGS_STORAGE_KEY = "recordly.extension-settings.v1";
-// ---------------------------------------------------------------------------
-// Security: Hide electronAPI from extension code
-// ---------------------------------------------------------------------------
-// Extensions run via dynamic import() in the renderer's main world. Since
-// contextBridge.exposeInMainWorld puts electronAPI on window in the same
-// world, extensions could abuse it to read arbitrary files, open URLs, etc.
-// We replace the global with a Proxy that blocks access while extension code
-// is executing (import + activate). The reference is stashed so that only
-// app code (which runs outside of extension activation) can reach it.
-// ---------------------------------------------------------------------------
-
-let _extensionActivationDepth = 0;
-let _realElectronAPI: typeof window.electronAPI | undefined;
-
-function installElectronAPIGuard(): void {
- if (typeof window === "undefined" || _realElectronAPI !== undefined) return;
-
- const real = window.electronAPI;
- if (!real) return;
-
- _realElectronAPI = real;
-
- const proxy = new Proxy(real, {
- get(target, prop, receiver) {
- if (_extensionActivationDepth > 0) {
- console.warn(
- `[extensions] Blocked extension access to electronAPI.${String(prop)}`,
- );
- return undefined;
- }
- return Reflect.get(target, prop, receiver);
- },
- });
-
- // 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();
-
interface RegisteredRenderHook {
extensionId: string;
phase: RenderHookPhase;
@@ -146,44 +91,10 @@ export class ExtensionHost {
private listeners = new Set<() => void>();
private fullSettingsStore: Record<string, Record<string, unknown>> | null = null;
private persistTimeout: ReturnType<typeof setTimeout> | null = null;
- private iconPathCache = new Map<string, Path2D>();
- // Shared playback/project state — set by the app, queried by extensions
+ // Retained for the editor's existing video-info query path.
private _videoInfo: { width: number; height: number; durationMs: number; fps: number } | null =
null;
- private _videoLayout: {
- maskRect: { x: number; y: number; width: number; height: number };
- canvasWidth: number;
- canvasHeight: number;
- borderRadius: number;
- padding: number | { top: number; right: number; bottom: number; left: number };
- } | null = null;
- private _zoomState: { scale: number; focusX: number; focusY: number; progress: number } | null =
- null;
- private _shadowConfig: { enabled: boolean; intensity: number } = {
- enabled: false,
- intensity: 0,
- };
- private _cursorTelemetry: Array<{
- timeMs: number;
- cx: number;
- cy: number;
- interactionType?: string;
- pressure?: number;
- }> = [];
- private _smoothedCursor: {
- timeMs: number;
- cx: number;
- cy: number;
- trail: Array<{ cx: number; cy: number }>;
- } | null = null;
- private _keystrokeEvents: Array<{ timeMs: number; key: string; modifiers: string[] }> = [];
- private _activeFrame: string | null = null;
- private _playbackState: {
- currentTimeMs: number;
- durationMs: number;
- isPlaying: boolean;
- } | null = null;
constructor() {
if (typeof window !== "undefined") {
@@ -197,66 +108,8 @@ export class ExtensionHost {
* Activate an extension given its info and resolved module URL.
*/
async activateExtension(info: ExtensionInfo, moduleUrl: string): Promise<void> {
- if (this.activeExtensions.has(info.manifest.id)) {
- // Deactivate stale instance first so reinstall/reload works
- await this.deactivateExtension(info.manifest.id);
- }
-
- const disposables: (() => void)[] = [];
- let mod: RecordlyExtensionModule | null = null;
- try {
- this.ensureExtensionSettingsLoaded(info.manifest.id);
-
- // Block electronAPI access while extension code executes
- _extensionActivationDepth++;
- try {
- const loaded: RecordlyExtensionModule = await import(/* @vite-ignore */ moduleUrl);
- mod = loaded;
- const api = this.createAPI(
- info.manifest.id,
- info.path,
- info.manifest.permissions ?? [],
- disposables,
- );
-
- await loaded.activate(api);
- } finally {
- _extensionActivationDepth--;
- }
-
- if (!mod) {
- throw new Error("Extension module failed to load");
- }
-
- this.activeExtensions.set(info.manifest.id, {
- info,
- module: mod,
- disposables,
- });
-
- this.notifyListeners();
- console.log(`[extensions] Activated: ${info.manifest.name} v${info.manifest.version}`);
- } catch (err) {
- for (const dispose of disposables.reverse()) {
- try {
- dispose();
- } catch {
- /* ignore */
- }
- }
-
- if (mod) {
- try {
- await mod.deactivate?.();
- } catch {
- /* ignore */
- }
- }
-
- this.notifyListeners();
- console.error(`[extensions] Failed to activate ${info.manifest.id}:`, err);
- throw err;
- }
+ void moduleUrl;
+ throw new Error(`Extensions are no longer available in Recordly (${info.manifest.id}).`);
}
/**
@@ -440,7 +293,7 @@ export class ExtensionHost {
}
// ---------------------------------------------------------------------------
- // Shared State — set by the app, read by extensions via API
+ // Legacy shared-state setters retained until their editor call sites are removed.
// ---------------------------------------------------------------------------
setVideoInfo(
@@ -458,40 +311,17 @@ export class ExtensionHost {
padding: number | { top: number; right: number; bottom: number; left: number };
} | null,
): void {
- if (!layout) {
- this._videoLayout = null;
- return;
- }
-
- // Normalize and deep clone padding to exclude UI-only fields like 'linked'
- const p = layout.padding;
- const normalizedPadding =
- typeof p === "number"
- ? p
- : {
- top: Number(p.top) || 0,
- right: Number(p.right) || 0,
- bottom: Number(p.bottom) || 0,
- left: Number(p.left) || 0,
- };
-
- this._videoLayout = {
- maskRect: { ...layout.maskRect },
- canvasWidth: layout.canvasWidth,
- canvasHeight: layout.canvasHeight,
- borderRadius: layout.borderRadius,
- padding: normalizedPadding,
- };
+ void layout;
}
setZoomState(
state: { scale: number; focusX: number; focusY: number; progress: number } | null,
): void {
- this._zoomState = state;
+ void state;
}
setShadowConfig(config: { enabled: boolean; intensity: number }): void {
- this._shadowConfig = config;
+ void config;
}
setCursorTelemetry(
@@ -503,7 +333,7 @@ export class ExtensionHost {
pressure?: number;
}>,
): void {
- this._cursorTelemetry = telemetry;
+ void telemetry;
}
setSmoothedCursor(
@@ -514,28 +344,21 @@ export class ExtensionHost {
trail: Array<{ cx: number; cy: number }>;
} | null,
): void {
- this._smoothedCursor = cursor
- ? {
- timeMs: cursor.timeMs,
- cx: cursor.cx,
- cy: cursor.cy,
- trail: cursor.trail.map((point) => ({ ...point })),
- }
- : null;
+ void cursor;
}
setKeystrokeEvents(events: Array<{ timeMs: number; key: string; modifiers: string[] }>): void {
- this._keystrokeEvents = events;
+ void events;
}
setActiveFrame(frameId: string | null): void {
- this._activeFrame = frameId;
+ void frameId;
}
setPlaybackState(
state: { currentTimeMs: number; durationMs: number; isPlaying: boolean } | null,
): void {
- this._playbackState = state;
+ void state;
}
// ---------------------------------------------------------------------------
@@ -637,438 +460,9 @@ export class ExtensionHost {
this.writePersistedSettingsStore(this.getFullSettingsStore());
}
- /**
- * Create the permission-gated API object for an extension.
- */
- private createAPI(
- extensionId: string,
- extensionPath: string,
- permissions: string[],
- disposables: (() => void)[],
- ): RecordlyExtensionAPI {
- const host = this;
- const perms = new Set(permissions);
-
- function requirePermission(perm: string, method: string): void {
- if (!perms.has(perm)) {
- throw new Error(
- `Extension '${extensionId}' lacks '${perm}' permission required for ${method}()`,
- );
- }
- }
-
- function getEventPermission(
- event: ExtensionEventType,
- ): "cursor" | "timeline" | "export" | null {
- if (event.startsWith("cursor:")) {
- return "cursor";
- }
-
- if (event.startsWith("playback:") || event.startsWith("timeline:")) {
- return "timeline";
- }
-
- if (event.startsWith("export:")) {
- return "export";
- }
-
- return null;
- }
-
- return {
- registerRenderHook(phase: RenderHookPhase, hook: RenderHookFn): () => void {
- requirePermission("render", "registerRenderHook");
- const entry: RegisteredRenderHook = { extensionId, phase, hook };
- host.renderHooks.push(entry);
-
- const dispose = () => {
- const index = host.renderHooks.indexOf(entry);
- if (index >= 0) host.renderHooks.splice(index, 1);
- };
- disposables.push(dispose);
- return dispose;
- },
-
- registerCursorEffect(effect: CursorEffectFn): () => void {
- requirePermission("cursor", "registerCursorEffect");
- const entry: RegisteredCursorEffect = { extensionId, effect };
- host.cursorEffects.push(entry);
-
- const dispose = () => {
- const index = host.cursorEffects.indexOf(entry);
- if (index >= 0) host.cursorEffects.splice(index, 1);
- };
- disposables.push(dispose);
- return dispose;
- },
-
- registerFrame(frame: ContributedFrame): () => void {
- requirePermission("ui", "registerFrame");
- const resolveFramePath = (relativePath: string): string =>
- resolveExtensionRelativeFileUrl(extensionPath, relativePath);
-
- let filePath: string;
- if (frame.draw) {
- // Generate a small thumbnail for the picker UI
- const thumbW = 192;
- const thumbH = 108;
- const c = document.createElement("canvas");
- c.width = thumbW;
- c.height = thumbH;
- const ctx = c.getContext("2d");
- if (ctx) frame.draw(ctx, thumbW, thumbH);
- filePath = c.toDataURL("image/png");
- } else if (frame.dataUrl) {
- filePath = frame.dataUrl;
- } else if (frame.file) {
- filePath = resolveFramePath(frame.file);
- } else {
- throw new Error("Device frame must provide either draw, file, or dataUrl");
- }
-
- let thumbnailPath = filePath;
- if (frame.thumbnail) {
- thumbnailPath = resolveFramePath(frame.thumbnail);
- }
-
- const instance: FrameInstance = {
- id: `${extensionId}/${frame.id}`,
- extensionId,
- label: frame.label,
- category: frame.category,
- filePath,
- thumbnailPath,
- screenInsets: frame.screenInsets,
- appearance: frame.appearance,
- draw: frame.draw,
- };
- host.frames.push(instance);
- host.notifyListeners();
-
- const dispose = () => {
- const index = host.frames.indexOf(instance);
- if (index >= 0) host.frames.splice(index, 1);
- host.notifyListeners();
- };
- disposables.push(dispose);
- 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) {
- requirePermission(requiredPermission, `on(${event})`);
- }
-
- if (!host.eventHandlers.has(event)) {
- host.eventHandlers.set(event, []);
- }
- const entry = { extensionId, handler };
- host.eventHandlers.get(event)!.push(entry);
-
- const dispose = () => {
- const list = host.eventHandlers.get(event);
- if (!list) return;
- const index = list.indexOf(entry);
- if (index >= 0) list.splice(index, 1);
- };
- disposables.push(dispose);
- return dispose;
- },
-
- registerSettingsPanel(panel: ExtensionSettingsPanel): () => void {
- requirePermission("ui", "registerSettingsPanel");
- const entry: RegisteredSettingsPanel = { extensionId, panel };
- host.settingsPanels.push(entry);
- host.notifyListeners();
-
- const dispose = () => {
- const index = host.settingsPanels.indexOf(entry);
- if (index >= 0) host.settingsPanels.splice(index, 1);
- host.notifyListeners();
- };
- disposables.push(dispose);
- return dispose;
- },
-
- getSetting(settingId: string): unknown {
- host.ensureExtensionSettingsLoaded(extensionId);
- return host.extensionSettings.get(extensionId)?.[settingId];
- },
-
- setSetting(settingId: string, value: unknown): void {
- host.ensureExtensionSettingsLoaded(extensionId);
- host.extensionSettings.get(extensionId)![settingId] = value;
- host.persistExtensionSettings(extensionId);
- // Notify per-extension setting change listeners
- const cbs = host.settingChangeCallbacks.get(extensionId);
- if (cbs) {
- for (const cb of cbs) {
- try {
- cb(settingId, value);
- } catch {
- /* ignore */
- }
- }
- }
- host.notifyListeners();
- },
-
- resolveAsset(relativePath: string): string {
- requirePermission("assets", "resolveAsset");
- return resolveExtensionRelativeFileUrl(extensionPath, relativePath);
- },
-
- playSound(relativePath: string, options?: { volume?: number }): () => void {
- requirePermission("audio", "playSound");
- const audio = new Audio(
- resolveExtensionRelativeFileUrl(extensionPath, relativePath),
- );
- audio.volume = Math.max(0, Math.min(1, options?.volume ?? 1));
- audio.play().catch((err) => {
- console.warn(`[ext:${extensionId}] Failed to play sound:`, err);
- });
- return () => {
- audio.pause();
- audio.src = "";
- };
- },
-
- log(message: string, ...args: unknown[]): void {
- console.log(`[ext:${extensionId}]`, message, ...args);
- },
-
- // ----------------------------------------------------------------
- // Query APIs
- // ----------------------------------------------------------------
-
- getVideoInfo() {
- return host._videoInfo ? { ...host._videoInfo } : null;
- },
-
- getVideoLayout() {
- if (!host._videoLayout) return null;
- const p = host._videoLayout.padding;
- return {
- maskRect: { ...host._videoLayout.maskRect },
- canvasWidth: host._videoLayout.canvasWidth,
- canvasHeight: host._videoLayout.canvasHeight,
- borderRadius: host._videoLayout.borderRadius,
- padding: typeof p === "number" ? p : { ...p },
- };
- },
-
- getCursorAt(timeMs: number) {
- const t = host._cursorTelemetry;
- if (!t || t.length === 0) return null;
-
- if (timeMs <= t[0].timeMs) return { ...t[0], timeMs };
- if (timeMs >= t[t.length - 1].timeMs) return { ...t[t.length - 1], timeMs };
-
- let lo = 0;
- let hi = t.length - 1;
- while (lo < hi - 1) {
- const mid = (lo + hi) >> 1;
- if (t[mid].timeMs <= timeMs) {
- lo = mid;
- } else {
- hi = mid;
- }
- }
-
- const a = t[lo];
- const b = t[hi];
- const span = b.timeMs - a.timeMs;
- const frac = span > 0 ? (timeMs - a.timeMs) / span : 0;
-
- return {
- ...a,
- cx: a.cx + (b.cx - a.cx) * frac,
- cy: a.cy + (b.cy - a.cy) * frac,
- timeMs,
- };
- },
-
- getSmoothedCursor() {
- if (!host._smoothedCursor) {
- return null;
- }
-
- return {
- timeMs: host._smoothedCursor.timeMs,
- cx: host._smoothedCursor.cx,
- cy: host._smoothedCursor.cy,
- trail: host._smoothedCursor.trail.map((point) => ({ ...point })),
- };
- },
-
- getZoomState() {
- return host._zoomState ? { ...host._zoomState } : null;
- },
-
- getShadowConfig() {
- return { ...host._shadowConfig };
- },
-
- getKeystrokesInRange(startMs: number, endMs: number) {
- return host._keystrokeEvents
- .filter((e) => e.timeMs >= startMs && e.timeMs <= endMs)
- .map((e) => ({ ...e }));
- },
-
- getAspectRatio() {
- if (!host._videoLayout) return null;
- return host._videoLayout.canvasWidth / host._videoLayout.canvasHeight;
- },
-
- getActiveFrame() {
- return host._activeFrame;
- },
-
- isExtensionActive(extId: string) {
- return host.activeExtensions.has(extId);
- },
-
- getPlaybackState() {
- return host._playbackState ? { ...host._playbackState } : null;
- },
-
- getCanvasDimensions() {
- if (!host._videoLayout) return null;
- return {
- width: host._videoLayout.canvasWidth,
- height: host._videoLayout.canvasHeight,
- };
- },
-
- drawIcon(
- ctx: CanvasRenderingContext2D,
- name: string,
- x: number,
- y: number,
- size: number,
- color: string,
- weight: "thin" | "light" | "regular" | "bold" | "fill" = "regular",
- ): void {
- const path = resolveIconPath(name, weight, host.iconPathCache);
-
- if (path) {
- ctx.save();
- ctx.translate(x, y);
- const scale = size / 256; // Phosphor icons use a 256x256 grid
- ctx.scale(scale, scale);
- ctx.translate(-128, -128); // Center the icon
- ctx.fillStyle = color;
- ctx.fill(path);
- ctx.restore();
- }
- },
-
- onSettingChange(callback: (settingId: string, value: unknown) => void): () => void {
- if (!host.settingChangeCallbacks.has(extensionId)) {
- host.settingChangeCallbacks.set(extensionId, new Set());
- }
- host.settingChangeCallbacks.get(extensionId)!.add(callback);
-
- const dispose = () => {
- const cbs = host.settingChangeCallbacks.get(extensionId);
- if (cbs) {
- cbs.delete(callback);
- if (cbs.size === 0) host.settingChangeCallbacks.delete(extensionId);
- }
- };
- disposables.push(dispose);
- return dispose;
- },
-
- getAllSettings(): Record<string, unknown> {
- host.ensureExtensionSettingsLoaded(extensionId);
- return { ...(host.extensionSettings.get(extensionId) ?? {}) };
- },
- };
- }
-
async syncConfiguredExtensions(discovered: ExtensionInfo[]): Promise<void> {
- const desired = new Map(
- discovered
- .filter((ext) => ext.status === "active")
- .map((ext) => [ext.manifest.id, ext]),
- );
-
- for (const activeId of Array.from(this.activeExtensions.keys())) {
- if (!desired.has(activeId)) {
- await this.deactivateExtension(activeId);
- }
- }
-
- for (const ext of discovered) {
- if (ext.status !== "active" || this.activeExtensions.has(ext.manifest.id)) {
- continue;
- }
-
- try {
- const moduleUrl = createExtensionModuleUrl(ext.path, ext.manifest.main);
- await this.activateExtension(ext, moduleUrl);
- } catch (err) {
- console.error(
- `[extensions] Failed to activate configured extension ${ext.manifest.id}:`,
- err,
- );
- }
- }
+ void discovered;
+ await this.deactivateAll();
}
// ---------------------------------------------------------------------------
@@ -1082,20 +476,7 @@ export class ExtensionHost {
* the discovery/activation sequence once no matter how many callers invoke it.
*/
autoActivateBuiltins(): Promise<void> {
- if (this._autoActivatePromise) return this._autoActivatePromise;
-
- this._autoActivatePromise = (async () => {
- // Use the real (unproxied) reference — this is app code, not extension code
- const api = _realElectronAPI ?? window.electronAPI;
- if (!api?.extensionsDiscover) return;
- try {
- const discovered: ExtensionInfo[] = await api.extensionsDiscover();
- await this.syncConfiguredExtensions(discovered);
- } catch (err) {
- console.error("[extensions] Failed to discover extensions:", err);
- }
- })();
-
+ this._autoActivatePromise ??= Promise.resolve();
return this._autoActivatePromise;
}
}