Skip to content

OpenReel Video - Professional browser-based video editor. Open source CapCut alternative. 100% browser-based, no installation, no cloud uploads, no watermarks.

TypeScript

fix: restore missing setKeyframeEditorOpen, remove dead code files

Augustus Otu3e50483abfb3
diff --git a/apps/web/src/components/audio-mixer/AudioMixer.tsx b/apps/web/src/components/audio-mixer/AudioMixer.tsx
index 6bae947a..bd29058d 100644
--- a/apps/web/src/components/audio-mixer/AudioMixer.tsx
+++ b/apps/web/src/components/audio-mixer/AudioMixer.tsx
@@ -150,8 +150,7 @@ export const AudioMixer: React.FC<AudioMixerProps> = ({
useEffect(() => {
try {
audioGraphRef.current = getRealtimeAudioGraph();
- } catch (err) {
- console.warn("[AudioMixer] Realtime audio graph not available:", err);
+ } catch {
audioGraphRef.current = null;
}
}, []);
@@ -180,8 +179,8 @@ export const AudioMixer: React.FC<AudioMixerProps> = ({
return next;
});
}
- } catch (err) {
- console.warn("[AudioMixer] Failed to sync levels from graph:", err);
+ } catch {
+ // Graph not ready yet
}
}, [visible, audioTracks]);
diff --git a/apps/web/src/components/editor.tsx b/apps/web/src/components/editor.tsx
deleted file mode 100644
index 83812b3c..00000000
--- a/apps/web/src/components/editor.tsx
+++ /dev/null
@@ -1,204 +0,0 @@
-import React, { useEffect } from "react";
-import { Toolbar } from "./editor/Toolbar";
-import { AssetsPanel } from "./editor/AssetsPanel";
-import { Preview } from "./editor/Preview";
-import { InspectorPanel } from "./editor/InspectorPanel";
-import { Timeline } from "./editor/Timeline";
-import { useProjectStore } from "../stores/project-store";
-import { useTimelineStore } from "../stores/timeline-store";
-import { useUIStore } from "../stores/ui-store";
-
-/**
- * Keyboard shortcut handler hook
- */
-const useKeyboardShortcuts = () => {
- const { undo, redo, canUndo, canRedo, splitClip } = useProjectStore();
- const { togglePlayback, seekRelative } = useTimelineStore();
- const { getSelectedClipIds, clearSelection } = useUIStore();
-
- useEffect(() => {
- const handleKeyDown = (e: KeyboardEvent) => {
- // Ignore if typing in an input
- if (
- e.target instanceof HTMLInputElement ||
- e.target instanceof HTMLTextAreaElement
- ) {
- return;
- }
-
- const isMeta = e.metaKey || e.ctrlKey;
-
- // Space - Play/Pause
- if (e.code === "Space" && !isMeta) {
- e.preventDefault();
- togglePlayback();
- return;
- }
-
- // Cmd/Ctrl + Z - Undo
- if (isMeta && e.key === "z" && !e.shiftKey) {
- e.preventDefault();
- if (canUndo()) undo();
- return;
- }
-
- // Cmd/Ctrl + Shift + Z - Redo
- if (isMeta && e.key === "z" && e.shiftKey) {
- e.preventDefault();
- if (canRedo()) redo();
- return;
- }
-
- // S - Split clip at playhead
- if (e.key === "s" && !isMeta) {
- const selectedClipIds = getSelectedClipIds();
- if (selectedClipIds.length === 1) {
- e.preventDefault();
- const { playheadPosition } = useTimelineStore.getState();
- splitClip(selectedClipIds[0], playheadPosition);
- }
- return;
- }
-
- // Delete/Backspace - Delete selected clips
- if (e.key === "Delete" || e.key === "Backspace") {
- const selectedClipIds = getSelectedClipIds();
- if (selectedClipIds.length > 0) {
- e.preventDefault();
- // Delete clips
- const { removeClip } = useProjectStore.getState();
- selectedClipIds.forEach((id) => removeClip(id));
- clearSelection();
- }
- return;
- }
-
- // Escape - Clear selection
- if (e.key === "Escape") {
- clearSelection();
- return;
- }
-
- // Arrow keys - Seek
- if (e.key === "ArrowLeft") {
- e.preventDefault();
- seekRelative(e.shiftKey ? -1 : -0.1);
- return;
- }
-
- if (e.key === "ArrowRight") {
- e.preventDefault();
- seekRelative(e.shiftKey ? 1 : 0.1);
- return;
- }
- };
-
- window.addEventListener("keydown", handleKeyDown);
- return () => window.removeEventListener("keydown", handleKeyDown);
- }, [
- undo,
- redo,
- canUndo,
- canRedo,
- splitClip,
- togglePlayback,
- seekRelative,
- getSelectedClipIds,
- clearSelection,
- ]);
-};
-
-/**
- * Auto-save initialization hook
- */
-const useAutoSave = () => {
- const { initializeAutoSave } = useProjectStore();
-
- useEffect(() => {
- initializeAutoSave().catch(console.error);
- }, [initializeAutoSave]);
-};
-
-/**
- * Main Editor Interface Component
- */
-export const EditorInterface: React.FC = () => {
- // Initialize keyboard shortcuts
- useKeyboardShortcuts();
-
- // Initialize auto-save
- useAutoSave();
-
- // Resizable Timeline State
- const [timelineHeight, setTimelineHeight] = React.useState(280);
- const isDraggingRef = React.useRef(false);
-
- const handleMouseDown = React.useCallback((e: React.MouseEvent) => {
- e.preventDefault();
- isDraggingRef.current = true;
- document.body.style.cursor = "row-resize";
- document.body.style.userSelect = "none";
- }, []);
-
- React.useEffect(() => {
- const handleMouseMove = (e: MouseEvent) => {
- if (!isDraggingRef.current) return;
-
- const newHeight = window.innerHeight - e.clientY;
- // Clamp height between 200px and 60% of screen height
- const maxHeight = window.innerHeight * 0.6;
- setTimelineHeight(Math.max(200, Math.min(newHeight, maxHeight)));
- };
-
- const handleMouseUp = () => {
- isDraggingRef.current = false;
- document.body.style.cursor = "";
- document.body.style.userSelect = "";
- };
-
- window.addEventListener("mousemove", handleMouseMove);
- window.addEventListener("mouseup", handleMouseUp);
-
- return () => {
- window.removeEventListener("mousemove", handleMouseMove);
- window.removeEventListener("mouseup", handleMouseUp);
- };
- }, []);
-
- return (
- <div className="w-full h-full bg-background flex flex-col overflow-hidden font-sans select-none relative z-20 text-xs text-text-secondary">
- {/* Main App Toolbar */}
- <Toolbar />
-
- {/* Workspace Area */}
- <div className="flex-1 flex overflow-hidden min-h-0">
- {/* LEFT PANEL: Assets */}
- <AssetsPanel />
-
- {/* CENTER PANEL: Preview */}
- <Preview />
-
- {/* RIGHT PANEL: Inspector */}
- <InspectorPanel />
- </div>
-
- {/* Resizable Handle */}
- <div
- className="h-1 bg-border hover:bg-primary/50 cursor-row-resize transition-colors z-10 relative group"
- onMouseDown={handleMouseDown}
- >
- <div className="absolute inset-x-0 -top-1 -bottom-1 bg-transparent" />
- </div>
-
- {/* BOTTOM PANEL: Timeline */}
- <div
- style={{ height: timelineHeight }}
- className="shrink-0 flex flex-col"
- >
- <Timeline />
- </div>
- </div>
- );
-};
-
-export default EditorInterface;
diff --git a/apps/web/src/components/editor/EditorInterface.tsx b/apps/web/src/components/editor/EditorInterface.tsx
index 9a6c98e2..7d3bdfbb 100644
--- a/apps/web/src/components/editor/EditorInterface.tsx
+++ b/apps/web/src/components/editor/EditorInterface.tsx
@@ -168,6 +168,7 @@ export const EditorInterface: React.FC = () => {
const {
keyframeEditorOpen,
+ setKeyframeEditorOpen,
getSelectedClipIds,
panels,
setPanelVisible,
diff --git a/apps/web/src/components/editor/PerformanceOverlay.tsx b/apps/web/src/components/editor/PerformanceOverlay.tsx
deleted file mode 100644
index 11ea5312..00000000
--- a/apps/web/src/components/editor/PerformanceOverlay.tsx
+++ /dev/null
@@ -1,211 +0,0 @@
-import React, { useState, useEffect } from "react";
-import { Activity, Cpu, HardDrive, X, AlertTriangle } from "lucide-react";
-import {
- performanceMonitor,
- formatBytes,
- type PerformanceMetrics,
- type PerformanceWarning,
-} from "../../services/performance-monitor";
-
-interface PerformanceOverlayProps {
- isVisible: boolean;
- onClose: () => void;
- compact?: boolean;
-}
-
-export const PerformanceOverlay: React.FC<PerformanceOverlayProps> = ({
- isVisible,
- onClose,
- compact = false,
-}) => {
- const [metrics, setMetrics] = useState<PerformanceMetrics | null>(null);
- const [warnings, setWarnings] = useState<PerformanceWarning[]>([]);
-
- useEffect(() => {
- if (isVisible) {
- performanceMonitor.start();
- const unsubMetrics = performanceMonitor.onMetrics(setMetrics);
- const unsubWarnings = performanceMonitor.onWarning((warning) => {
- setWarnings((prev) => [...prev.slice(-4), warning]);
- });
-
- return () => {
- unsubMetrics();
- unsubWarnings();
- };
- } else {
- performanceMonitor.stop();
- }
- }, [isVisible]);
-
- if (!isVisible) return null;
-
- const fpsColor =
- !metrics || metrics.fps >= 30
- ? "text-green-400"
- : metrics.fps >= 24
- ? "text-yellow-400"
- : "text-red-400";
-
- const memoryColor =
- !metrics || metrics.memoryPercent < 0.7
- ? "text-green-400"
- : metrics.memoryPercent < 0.9
- ? "text-yellow-400"
- : "text-red-400";
-
- const score = performanceMonitor.getPerformanceScore();
- const scoreColor =
- score >= 70
- ? "text-green-400"
- : score >= 40
- ? "text-yellow-400"
- : "text-red-400";
-
- if (compact) {
- return (
- <div className="fixed bottom-4 right-4 z-40 bg-black/80 rounded-lg px-3 py-2 backdrop-blur-sm border border-border">
- <div className="flex items-center gap-4 text-xs">
- <div className={`flex items-center gap-1 ${fpsColor}`}>
- <Activity size={12} />
- <span>{metrics?.fps ?? 0} fps</span>
- </div>
- <div className={`flex items-center gap-1 ${memoryColor}`}>
- <HardDrive size={12} />
- <span>{metrics ? formatBytes(metrics.memoryUsed) : "0 MB"}</span>
- </div>
- <button
- onClick={onClose}
- className="text-text-muted hover:text-text-primary transition-colors"
- >
- <X size={12} />
- </button>
- </div>
- </div>
- );
- }
-
- return (
- <div className="fixed bottom-4 right-4 z-40 w-80 bg-background-secondary rounded-xl border border-border shadow-2xl overflow-hidden">
- <div className="flex items-center justify-between p-3 border-b border-border bg-background-tertiary">
- <div className="flex items-center gap-2">
- <Activity size={14} className="text-primary" />
- <span className="text-sm font-medium text-text-primary">
- Performance
- </span>
- </div>
- <div className="flex items-center gap-2">
- <span className={`text-xs font-medium ${scoreColor}`}>
- Score: {score}
- </span>
- <button
- onClick={onClose}
- className="p-1 text-text-muted hover:text-text-primary rounded transition-colors"
- >
- <X size={14} />
- </button>
- </div>
- </div>
-
- <div className="p-3 space-y-3">
- <div className="grid grid-cols-2 gap-3">
- <div className="p-2 bg-background-tertiary rounded-lg">
- <div className="flex items-center gap-1 text-[10px] text-text-muted mb-1">
- <Activity size={10} />
- Frame Rate
- </div>
- <div className={`text-lg font-bold ${fpsColor}`}>
- {metrics?.fps ?? 0}
- <span className="text-xs font-normal ml-1">fps</span>
- </div>
- <div className="text-[10px] text-text-muted">
- {metrics
- ? `${metrics.frameTime.toFixed(1)}ms/frame`
- : "0ms/frame"}
- </div>
- </div>
-
- <div className="p-2 bg-background-tertiary rounded-lg">
- <div className="flex items-center gap-1 text-[10px] text-text-muted mb-1">
- <HardDrive size={10} />
- Memory
- </div>
- <div className={`text-lg font-bold ${memoryColor}`}>
- {metrics ? Math.round(metrics.memoryPercent * 100) : 0}
- <span className="text-xs font-normal ml-1">%</span>
- </div>
- <div className="text-[10px] text-text-muted">
- {metrics ? formatBytes(metrics.memoryUsed) : "0 MB"}
- </div>
- </div>
-
- <div className="p-2 bg-background-tertiary rounded-lg">
- <div className="flex items-center gap-1 text-[10px] text-text-muted mb-1">
- <Cpu size={10} />
- Render Time
- </div>
- <div className="text-lg font-bold text-text-primary">
- {metrics?.renderTime ?? 0}
- <span className="text-xs font-normal ml-1">ms</span>
- </div>
- </div>
-
- <div className="p-2 bg-background-tertiary rounded-lg">
- <div className="flex items-center gap-1 text-[10px] text-text-muted mb-1">
- <Activity size={10} />
- Active Clips
- </div>
- <div className="text-lg font-bold text-text-primary">
- {metrics?.activeClips ?? 0}
- </div>
- </div>
- </div>
-
- {warnings.length > 0 && (
- <div className="space-y-1">
- <div className="text-[10px] text-text-muted flex items-center gap-1">
- <AlertTriangle size={10} />
- Recent Warnings
- </div>
- {warnings.slice(-3).map((warning, i) => (
- <div
- key={i}
- className={`p-2 rounded text-[10px] ${
- warning.severity === "high"
- ? "bg-red-500/10 text-red-400 border border-red-500/20"
- : warning.severity === "medium"
- ? "bg-yellow-500/10 text-yellow-400 border border-yellow-500/20"
- : "bg-blue-500/10 text-blue-400 border border-blue-500/20"
- }`}
- >
- <p className="font-medium">{warning.message}</p>
- {warning.suggestion && (
- <p className="mt-0.5 opacity-80">{warning.suggestion}</p>
- )}
- </div>
- ))}
- </div>
- )}
-
- {performanceMonitor.getOptimizationSuggestions().length > 0 && (
- <div className="space-y-1">
- <div className="text-[10px] text-text-muted">Suggestions</div>
- <ul className="text-[10px] text-text-secondary space-y-0.5">
- {performanceMonitor
- .getOptimizationSuggestions()
- .slice(0, 3)
- .map((suggestion, i) => (
- <li key={i} className="flex items-start gap-1">
- <span className="text-primary">•</span>
- {suggestion}
- </li>
- ))}
- </ul>
- </div>
- )}
- </div>
- </div>
- );
-};
-
-export default PerformanceOverlay;
diff --git a/apps/web/src/components/editor/ProjectDialog.tsx b/apps/web/src/components/editor/ProjectDialog.tsx
deleted file mode 100644
index de282591..00000000
--- a/apps/web/src/components/editor/ProjectDialog.tsx
+++ /dev/null
@@ -1,333 +0,0 @@
-import { useState, useEffect, useCallback } from "react";
-import {
- Plus,
- FolderOpen,
- Clock,
- Trash2,
- Film,
- Music,
- Smartphone,
- Monitor,
- ChevronRight,
- FileVideo,
-} from "lucide-react";
-import {
- Dialog,
- DialogContent,
- DialogHeader,
- DialogTitle,
- Button,
- Input,
- Label,
- Tabs,
- TabsList,
- TabsTrigger,
- TabsContent,
-} from "@openreel/ui";
-import {
- projectManager,
- type RecentProject,
- type ProjectTemplate,
-} from "../../services/project-manager";
-import { useProjectStore } from "../../stores/project-store";
-
-interface ProjectDialogProps {
- isOpen: boolean;
- onClose: () => void;
- mode?: "new" | "open" | "recent";
-}
-
-const CATEGORY_ICONS: Record<string, React.ReactNode> = {
- General: <Film size={14} />,
- "Social Media": <Smartphone size={14} />,
- Professional: <Monitor size={14} />,
- Audio: <Music size={14} />,
- Educational: <Monitor size={14} />,
-};
-
-export const ProjectDialog: React.FC<ProjectDialogProps> = ({
- isOpen,
- onClose,
- mode = "new",
-}) => {
- const { loadProject } = useProjectStore();
- const [activeTab, setActiveTab] = useState<"new" | "recent">(
- mode === "recent" ? "recent" : "new",
- );
- const [selectedTemplate, setSelectedTemplate] = useState<string>("blank");
- const [projectName, setProjectName] = useState("Untitled Project");
- const [recentProjects, setRecentProjects] = useState<RecentProject[]>([]);
- const [templates, setTemplates] = useState<Map<string, ProjectTemplate[]>>(
- new Map(),
- );
- const [isLoading, setIsLoading] = useState(false);
-
- useEffect(() => {
- if (isOpen) {
- loadData();
- }
- }, [isOpen]);
-
- const loadData = async () => {
- const recent = await projectManager.getRecentProjects();
- setRecentProjects(recent);
- setTemplates(projectManager.getTemplatesByCategory());
- };
-
- const handleCreateProject = useCallback(async () => {
- setIsLoading(true);
- try {
- const project = await projectManager.createProject({
- name: projectName,
- templateId: selectedTemplate,
- });
- loadProject(project);
- onClose();
- } catch (error) {
- console.error("Failed to create project:", error);
- } finally {
- setIsLoading(false);
- }
- }, [projectName, selectedTemplate, loadProject, onClose]);
-
- const handleOpenProject = useCallback(async () => {
- setIsLoading(true);
- try {
- const project = await projectManager.openProject();
- if (project) {
- loadProject(project);
- onClose();
- }
- } catch (error) {
- console.error("Failed to open project:", error);
- } finally {
- setIsLoading(false);
- }
- }, [loadProject, onClose]);
-
- const handleOpenRecent = useCallback(
- async (recent: RecentProject) => {
- setIsLoading(true);
- try {
- const project = await projectManager.openRecentProject(recent);
- if (project) {
- loadProject(project);
- onClose();
- }
- } catch (error) {
- console.error("Failed to open recent project:", error);
- } finally {
- setIsLoading(false);
- }
- },
- [loadProject, onClose],
- );
-
- const handleRemoveRecent = useCallback(
- async (id: string, e: React.MouseEvent) => {
- e.stopPropagation();
- await projectManager.removeFromRecent(id);
- setRecentProjects((prev) => prev.filter((p) => p.id !== id));
- },
- [],
- );
-
- const formatDate = (timestamp: number): string => {
- const date = new Date(timestamp);
- const now = new Date();
- const diff = now.getTime() - timestamp;
- const days = Math.floor(diff / (1000 * 60 * 60 * 24));
-
- if (days === 0) return "Today";
- if (days === 1) return "Yesterday";
- if (days < 7) return `${days} days ago`;
- return date.toLocaleDateString();
- };
-
- if (!isOpen) return null;
-
- return (
- <Dialog open onOpenChange={(open) => !open && onClose()}>
- <DialogContent className="max-w-3xl max-h-[80vh] p-0 gap-0 bg-background-secondary border-border overflow-hidden flex flex-col">
- <DialogHeader className="p-4 border-b border-border bg-background-tertiary space-y-0">
- <div className="flex items-center gap-3">
- <FileVideo size={20} className="text-primary" />
- <DialogTitle className="text-lg font-bold text-text-primary">
- {mode === "open" ? "Open Project" : "Project"}
- </DialogTitle>
- </div>
- </DialogHeader>
-
- <Tabs
- value={activeTab}
- onValueChange={(v) => setActiveTab(v as "new" | "recent")}
- className="flex-1 flex flex-col overflow-hidden"
- >
- <TabsList className="flex border-b border-border bg-transparent rounded-none">
- <TabsTrigger
- value="new"
- className="flex-1 flex items-center justify-center gap-2 p-3 text-sm font-medium rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:text-primary text-text-secondary hover:text-text-primary"
- >
- <Plus size={16} />
- New Project
- </TabsTrigger>
- <TabsTrigger
- value="recent"
- className="flex-1 flex items-center justify-center gap-2 p-3 text-sm font-medium rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:text-primary text-text-secondary hover:text-text-primary"
- >
- <Clock size={16} />
- Recent ({recentProjects.length})
- </TabsTrigger>
- </TabsList>
-
- <TabsContent value="new" className="flex-1 overflow-y-auto p-4 mt-0">
- <div className="space-y-6">
- <div>
- <Label className="block text-xs font-medium text-text-secondary mb-2">
- Project Name
- </Label>
- <Input
- type="text"
- value={projectName}
- onChange={(e) => setProjectName(e.target.value)}
- className="bg-background-tertiary border-border text-text-primary"
- placeholder="Enter project name"
- />
- </div>
-
- <div>
- <Label className="block text-xs font-medium text-text-secondary mb-3">
- Choose a Template
- </Label>
- <div className="space-y-4">
- {Array.from(templates.entries()).map(
- ([category, categoryTemplates]) => (
- <div key={category}>
- <div className="flex items-center gap-2 mb-2">
- <span className="text-text-muted">
- {CATEGORY_ICONS[category] || <Film size={14} />}
- </span>
- <span className="text-xs font-medium text-text-muted uppercase tracking-wider">
- {category}
- </span>
- </div>
- <div className="grid grid-cols-2 gap-2">
- {categoryTemplates.map((template) => (
- <button
- key={template.id}
- onClick={() => setSelectedTemplate(template.id)}
- className={`p-3 rounded-lg border text-left transition-colors ${
- selectedTemplate === template.id
- ? "border-primary bg-primary/10"
- : "border-border hover:border-primary/50 hover:bg-background-tertiary"
- }`}
- >
- <div className="flex items-center justify-between mb-1">
- <span className="text-sm font-medium text-text-primary">
- {template.name}
- </span>
- {selectedTemplate === template.id && (
- <div className="w-2 h-2 rounded-full bg-primary" />
- )}
- </div>
- <p className="text-[10px] text-text-muted">
- {template.description}
- </p>
- {template.settings && (
- <p className="text-[10px] text-primary mt-1">
- {template.settings.width}x
- {template.settings.height} @{" "}
- {template.settings.frameRate}fps
- </p>
- )}
- </button>
- ))}
- </div>
- </div>
- ),
- )}
- </div>
- </div>
- </div>
- </TabsContent>
-
- <TabsContent value="recent" className="flex-1 overflow-y-auto p-4 mt-0">
- {recentProjects.length === 0 ? (
- <div className="flex flex-col items-center justify-center py-12 text-text-muted">
- <Clock size={32} className="mb-3 opacity-30" />
- <p className="text-sm">No recent projects</p>
- <p className="text-xs mt-1">
- Projects you open will appear here
- </p>
- </div>
- ) : (
- <div className="space-y-2">
- {recentProjects.map((project) => (
- <button
- key={project.id}
- onClick={() => handleOpenRecent(project)}
- disabled={isLoading}
- className="w-full flex items-center gap-3 p-3 rounded-lg border border-border hover:border-primary/50 hover:bg-background-tertiary transition-colors group disabled:opacity-50"
- >
- <div className="w-12 h-12 bg-background-tertiary rounded-lg flex items-center justify-center">
- <FileVideo size={20} className="text-text-muted" />
- </div>
- <div className="flex-1 text-left min-w-0">
- <p className="text-sm font-medium text-text-primary truncate">
- {project.name}
- </p>
- <p className="text-[10px] text-text-muted">
- {formatDate(project.lastOpened)}
- {project.trackCount !== undefined && (
- <> · {project.trackCount} tracks</>
- )}
- </p>
- </div>
- <ChevronRight
- size={16}
- className="text-text-muted group-hover:text-primary transition-colors"
- />
- <button
- onClick={(e) => handleRemoveRecent(project.id, e)}
- className="p-1 rounded hover:bg-red-500/20 text-text-muted hover:text-red-400 opacity-0 group-hover:opacity-100 transition-all"
- title="Remove from recent"
- >
- <Trash2 size={14} />
- </button>
- </button>
- ))}
- </div>
- )}
- </TabsContent>
- </Tabs>
-
- <div className="flex items-center justify-between p-4 border-t border-border bg-background-tertiary">
- <Button
- variant="ghost"
- onClick={handleOpenProject}
- disabled={isLoading}
- >
- <FolderOpen size={16} />
- Open from File...
- </Button>
- <div className="flex items-center gap-2">
- <Button variant="ghost" onClick={onClose}>
- Cancel
- </Button>
- {activeTab === "new" && (
- <Button
- onClick={handleCreateProject}
- disabled={isLoading || !projectName.trim()}
- >
- <Plus size={16} />
- Create Project
- </Button>
- )}
- </div>
- </div>
- </DialogContent>
- </Dialog>
- );
-};
-
-export default ProjectDialog;
diff --git a/apps/web/src/components/editor/ShareDialog.tsx b/apps/web/src/components/editor/ShareDialog.tsx
deleted file mode 100644
index 33ea9148..00000000
--- a/apps/web/src/components/editor/ShareDialog.tsx
+++ /dev/null
@@ -1,267 +0,0 @@
-import { useState, useCallback } from "react";
-import {
- Upload,
- Link,
- Check,
- Clock,
- Copy,
- Twitter,
- Linkedin,
- AlertCircle,
- Loader2,
-} from "lucide-react";
-import {
- Dialog,
- DialogContent,
- DialogHeader,
- DialogTitle,
- Button,
- Input,
-} from "@openreel/ui";
-import {
- uploadForSharing,
- getSharePageUrl,
- formatExpiresIn,
- type ShareResult,
-} from "../../services/share-service";
-
-interface ShareDialogProps {
- isOpen: boolean;
- onClose: () => void;
- videoBlob: Blob | null;
- filename: string;
-}
-
-type ShareStatus = "idle" | "uploading" | "success" | "error";
-
-export const ShareDialog: React.FC<ShareDialogProps> = ({
- isOpen,
- onClose,
- videoBlob,
- filename,
-}) => {
- const [status, setStatus] = useState<ShareStatus>("idle");
- const [progress, setProgress] = useState(0);
- const [error, setError] = useState<string | null>(null);
- const [shareResult, setShareResult] = useState<ShareResult | null>(null);
- const [copied, setCopied] = useState(false);
-
- const handleUpload = useCallback(async () => {
- if (!videoBlob) return;
-
- setStatus("uploading");
- setProgress(0);
- setError(null);
-
- try {
- const result = await uploadForSharing(videoBlob, filename, (p) =>
- setProgress(p),
- );
- setShareResult(result);
- setStatus("success");
- } catch (err) {
- setError(err instanceof Error ? err.message : "Upload failed");
- setStatus("error");
- }
- }, [videoBlob, filename]);
-
- const shareUrl = shareResult ? getSharePageUrl(shareResult.shareId) : "";
-
- const handleCopy = useCallback(async () => {
- if (!shareUrl) return;
-
- try {
- await navigator.clipboard.writeText(shareUrl);
- setCopied(true);
- setTimeout(() => setCopied(false), 2000);
- } catch {
- const textArea = document.createElement("textarea");
- textArea.value = shareUrl;
- document.body.appendChild(textArea);
- textArea.select();
- document.execCommand("copy");
- document.body.removeChild(textArea);
- setCopied(true);
- setTimeout(() => setCopied(false), 2000);
- }
- }, [shareUrl]);
-
- const handleTwitterShare = useCallback(() => {
- const text = "Check out my video!";
- const url = `https://twitter.com/intent/tweet?text=${encodeURIComponent(text)}&url=${encodeURIComponent(shareUrl)}`;
- window.open(url, "_blank");
- }, [shareUrl]);
-
- const handleLinkedInShare = useCallback(() => {
- const url = `https://www.linkedin.com/sharing/share-offsite/?url=${encodeURIComponent(shareUrl)}`;
- window.open(url, "_blank");
- }, [shareUrl]);
-
- const handleClose = useCallback(() => {
- setStatus("idle");
- setProgress(0);
- setError(null);
- setShareResult(null);
- onClose();
- }, [onClose]);
-
- if (!isOpen) return null;
-
- return (
- <Dialog open onOpenChange={(open) => !open && handleClose()}>
- <DialogContent className="max-w-md p-0 gap-0 bg-background-secondary border-border overflow-hidden">
- <DialogHeader className="p-4 border-b border-border bg-background-tertiary space-y-0">
- <div className="flex items-center gap-3">
- <Upload size={20} className="text-primary" />
- <DialogTitle className="text-lg font-bold text-text-primary">
- Share Video
- </DialogTitle>
- </div>
- </DialogHeader>
-
- <div className="p-6 space-y-6">
- {status === "idle" && (
- <>
- <div className="text-center space-y-4">
- <div className="w-16 h-16 mx-auto bg-primary/10 rounded-full flex items-center justify-center">
- <Link size={28} className="text-primary" />
- </div>
- <div>
- <p className="text-sm text-text-primary font-medium">
- Create a shareable link
- </p>
- <p className="text-xs text-text-muted mt-1">
- Link expires in 24 hours
- </p>
- </div>
- </div>
-
- <div className="p-3 bg-background-tertiary rounded-lg">
- <div className="flex items-center justify-between">
- <span className="text-sm text-text-secondary truncate">
- {filename}
- </span>
- <span className="text-xs text-text-muted">
- {videoBlob
- ? `${(videoBlob.size / (1024 * 1024)).toFixed(1)} MB`
- : ""}
- </span>
- </div>
- </div>
-
- <Button
- onClick={handleUpload}
- disabled={!videoBlob}
- className="w-full"
- >
- Generate Share Link
- </Button>
- </>
- )}
-
- {status === "uploading" && (
- <div className="text-center space-y-4">
- <div className="w-16 h-16 mx-auto bg-primary/10 rounded-full flex items-center justify-center">
- <Loader2 size={28} className="text-primary animate-spin" />
- </div>
- <div>
- <p className="text-sm text-text-primary font-medium">
- Uploading video...
- </p>
- <p className="text-xs text-text-muted mt-1">
- {Math.round(progress)}% complete
- </p>
- </div>
- <div className="h-2 bg-background-tertiary rounded-full overflow-hidden">
- <div
- className="h-full bg-primary transition-all duration-300"
- style={{ width: `${progress}%` }}
- />
- </div>
- </div>
- )}
-
- {status === "success" && shareResult && (
- <div className="space-y-4">
- <div className="text-center space-y-2">
- <div className="w-16 h-16 mx-auto bg-primary/10 rounded-full flex items-center justify-center">
- <Check size={28} className="text-primary" />
- </div>
- <p className="text-sm text-text-primary font-medium">
- Link created!
- </p>
- </div>
-
- <div className="p-3 bg-background-tertiary rounded-lg">
- <div className="flex items-center gap-2">
- <Input
- type="text"
- value={shareUrl}
- readOnly
- className="flex-1 bg-transparent border-0 text-text-primary focus-visible:ring-0 truncate"
- />
- <button
- onClick={handleCopy}
- className="p-2 bg-background-secondary hover:bg-background-elevated rounded-lg transition-colors"
- >
- {copied ? (
- <Check size={16} className="text-primary" />
- ) : (
- <Copy size={16} className="text-text-muted" />
- )}
- </button>
- </div>
- </div>
-
- <div className="flex items-center justify-center gap-2 text-xs text-text-muted">
- <Clock size={14} />
- <span>{formatExpiresIn(shareResult.expiresAt)}</span>
- </div>
-
- <div className="flex gap-3">
- <button
- onClick={handleTwitterShare}
- className="flex-1 flex items-center justify-center gap-2 py-2 bg-[#1DA1F2]/10 hover:bg-[#1DA1F2]/20 text-[#1DA1F2] rounded-lg transition-colors"
- >
- <Twitter size={16} />
- <span className="text-sm">Twitter</span>
- </button>
- <button
- onClick={handleLinkedInShare}
- className="flex-1 flex items-center justify-center gap-2 py-2 bg-[#0A66C2]/10 hover:bg-[#0A66C2]/20 text-[#0A66C2] rounded-lg transition-colors"
- >
- <Linkedin size={16} />
- <span className="text-sm">LinkedIn</span>
- </button>
- </div>
- </div>
- )}
-
- {status === "error" && (
- <div className="space-y-4">
- <div className="text-center space-y-2">
- <div className="w-16 h-16 mx-auto bg-error/10 rounded-full flex items-center justify-center">
- <AlertCircle size={28} className="text-error" />
- </div>
- <p className="text-sm text-error font-medium">Upload failed</p>
- <p className="text-xs text-text-muted">{error}</p>
- </div>
-
- <Button onClick={handleUpload} className="w-full">
- Try Again
- </Button>
- </div>
- )}
- </div>
-
- {status === "success" && (
- <div className="px-6 py-4 border-t border-border bg-background-tertiary">
- <Button variant="ghost" onClick={handleClose} className="w-full">
- Done
- </Button>
- </div>
- )}
- </DialogContent>
- </Dialog>
- );
-};
diff --git a/apps/web/src/components/editor/TitleBar.tsx b/apps/web/src/components/editor/TitleBar.tsx
deleted file mode 100644
index 614c6ac9..00000000
--- a/apps/web/src/components/editor/TitleBar.tsx
+++ /dev/null
@@ -1,33 +0,0 @@
-import React from "react";
-import { useProjectStore } from "../../stores/project-store";
-
-export const TitleBar: React.FC = () => {
- const { project } = useProjectStore();
-
- // Get active clip name (placeholder for now)
- const activeFileName = project.name;
-
- return (
- <div className="h-8 bg-reel-dark border-b border-reel-border flex items-center px-4 justify-between shrink-0">
- {/* Window Controls (Mac Style) */}
- <div className="flex gap-2">
- <div className="w-3 h-3 rounded-full bg-[#ff5f57] hover:brightness-90 cursor-pointer" />
- <div className="w-3 h-3 rounded-full bg-[#febc2e] hover:brightness-90 cursor-pointer" />
- <div className="w-3 h-3 rounded-full bg-[#28c840] hover:brightness-90 cursor-pointer" />
- </div>
-
- {/* Center: App Name and File */}
- <div className="flex gap-2 items-center opacity-0 md:opacity-100">
- <span className="text-acid-green font-bold">OR</span>
- <span className="text-reel-text-secondary">Open Reel Video</span>
- <span className="mx-2 text-reel-text-secondary">/</span>
- <span className="text-reel-text-primary">{activeFileName}</span>
- </div>
-
- {/* Spacer */}
- <div className="w-10" />
- </div>
- );
-};
-
-export default TitleBar;
diff --git a/apps/web/src/components/editor/index.ts b/apps/web/src/components/editor/index.ts
deleted file mode 100644
index fc26dbea..00000000
--- a/apps/web/src/components/editor/index.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-/**
- * Editor Components - Main editor UI components
- */
-
-export { Timeline } from "./Timeline";
-export { Preview } from "./Preview";
-export { AssetsPanel } from "./AssetsPanel";
-export { InspectorPanel } from "./InspectorPanel";
-export { Toolbar } from "./Toolbar";
-export { TitleBar } from "./TitleBar";
-export { EditorInterface } from "./EditorInterface";
diff --git a/apps/web/src/components/editor/preview/CropOverlay.tsx b/apps/web/src/components/editor/preview/CropOverlay.tsx
deleted file mode 100644
index 3a5c3eb1..00000000
--- a/apps/web/src/components/editor/preview/CropOverlay.tsx
+++ /dev/null
@@ -1,469 +0,0 @@
-import React, { useState, useRef, useEffect } from "react";
-import { Check, X, Maximize2 } from "lucide-react";
-import type { Clip } from "@openreel/core";
-
-interface CropOverlayProps {
- clip: Clip;
- canvasWidth: number;
- canvasHeight: number;
- videoWidth: number;
- videoHeight: number;
- onCropChange: (crop: {
- x: number;
- y: number;
- width: number;
- height: number;
- }) => void;
- onComplete: () => void;
- onCancel: () => void;
-}
-
-type DragHandle =
- | "nw"
- | "ne"
- | "sw"
- | "se"
- | "n"
- | "s"
- | "e"
- | "w"
- | "center"
- | null;
-
-const ASPECT_RATIOS = [
- { label: "Free", value: null },
- { label: "9:16", value: 9 / 16 },
- { label: "16:9", value: 16 / 9 },
- { label: "1:1", value: 1 },
- { label: "4:3", value: 4 / 3 },
- { label: "3:4", value: 3 / 4 },
-];
-
-export const CropOverlay: React.FC<CropOverlayProps> = ({
- clip,
- canvasWidth,
- canvasHeight,
- videoWidth,
- videoHeight,
- onCropChange,
- onComplete,
- onCancel,
-}) => {
- const initialCrop = clip.transform.crop || {
- x: 0,
- y: 0,
- width: 1,
- height: 1,
- };
-
- const [crop, setCrop] = useState(initialCrop);
- const [isDragging, setIsDragging] = useState(false);
- const [dragHandle, setDragHandle] = useState<DragHandle>(null);
- const [dragStart, setDragStart] = useState({ x: 0, y: 0 });
- const [cropStart, setCropStart] = useState(initialCrop);
- const [lockedAspect, setLockedAspect] = useState<number | null>(null);
-
- const overlayRef = useRef<HTMLDivElement>(null);
-
- // Calculate video frame bounds on canvas (cover fit mode)
- const videoAspect = videoWidth / videoHeight;
- const canvasAspect = canvasWidth / canvasHeight;
-
- let frameWidth: number;
- let frameHeight: number;
- let frameX: number;
- let frameY: number;
-
- if (videoAspect > canvasAspect) {
- // Video is wider - fit to canvas height
- frameHeight = canvasHeight;
- frameWidth = canvasHeight * videoAspect;
- frameX = (canvasWidth - frameWidth) / 2;
- frameY = 0;
- } else {
- // Video is taller - fit to canvas width
- frameWidth = canvasWidth;
- frameHeight = canvasWidth / videoAspect;
- frameX = 0;
- frameY = (canvasHeight - frameHeight) / 2;
- }
-
- // Apply transform position and scale
- const transform = clip.transform;
- const scaleX = transform.scale?.x ?? 1;
- const scaleY = transform.scale?.y ?? 1;
- const posX = transform.position?.x ?? 0;
- const posY = transform.position?.y ?? 0;
-
- frameWidth *= scaleX;
- frameHeight *= scaleY;
- frameX += posX + canvasWidth / 2 - frameWidth / 2;
- frameY += posY + canvasHeight / 2 - frameHeight / 2;
-
- const cropPixels = {
- x: frameX + crop.x * frameWidth,
- y: frameY + crop.y * frameHeight,
- width: crop.width * frameWidth,
- height: crop.height * frameHeight,
- };
-
- const handleMouseDown = (e: React.MouseEvent, handle: DragHandle) => {
- e.preventDefault();
- e.stopPropagation();
- setIsDragging(true);
- setDragHandle(handle);
- setDragStart({ x: e.clientX, y: e.clientY });
- setCropStart(crop);
- };
-
- const handleMouseMove = (e: MouseEvent) => {
- if (!isDragging || !dragHandle || !overlayRef.current) return;
-
- // Calculate delta relative to frame size, not canvas size
- const deltaX = (e.clientX - dragStart.x) / frameWidth;
- const deltaY = (e.clientY - dragStart.y) / frameHeight;
-
- let newCrop = { ...cropStart };
-
- if (dragHandle === "center") {
- newCrop.x = Math.max(
- 0,
- Math.min(1 - cropStart.width, cropStart.x + deltaX),
- );
- newCrop.y = Math.max(
- 0,
- Math.min(1 - cropStart.height, cropStart.y + deltaY),
- );
- } else if (dragHandle === "nw") {
- const maxDeltaX = cropStart.x;
- const maxDeltaY = cropStart.y;
- const clampedDeltaX = Math.min(deltaX, maxDeltaX);
- const clampedDeltaY = Math.min(deltaY, maxDeltaY);
-
- if (lockedAspect) {
- const avgDelta = (clampedDeltaX + clampedDeltaY) / 2;
- newCrop.x = cropStart.x + avgDelta;
- newCrop.y = cropStart.y + avgDelta;
- newCrop.width = cropStart.width - avgDelta;
- newCrop.height = cropStart.height - avgDelta;
- } else {
- newCrop.x = cropStart.x + clampedDeltaX;
- newCrop.y = cropStart.y + clampedDeltaY;
- newCrop.width = cropStart.width - clampedDeltaX;
- newCrop.height = cropStart.height - clampedDeltaY;
- }
- } else if (dragHandle === "ne") {
- const maxDeltaY = cropStart.y;
- const clampedDeltaY = Math.min(deltaY, maxDeltaY);
-
- if (lockedAspect) {
- const avgDelta = (-deltaX + clampedDeltaY) / 2;
- newCrop.y = cropStart.y + avgDelta;
- newCrop.width = cropStart.width - avgDelta;
- newCrop.height = cropStart.height - avgDelta;
- } else {
- newCrop.y = cropStart.y + clampedDeltaY;
- newCrop.width = Math.min(1 - cropStart.x, cropStart.width + deltaX);
- newCrop.height = cropStart.height - clampedDeltaY;
- }
- } else if (dragHandle === "sw") {
- const maxDeltaX = cropStart.x;
- const clampedDeltaX = Math.min(deltaX, maxDeltaX);
-
- if (lockedAspect) {
- const avgDelta = (clampedDeltaX - deltaY) / 2;
- newCrop.x = cropStart.x + avgDelta;
- newCrop.width = cropStart.width - avgDelta;
- newCrop.height = cropStart.height - avgDelta;
- } else {
- newCrop.x = cropStart.x + clampedDeltaX;
- newCrop.width = cropStart.width - clampedDeltaX;
- newCrop.height = Math.min(1 - cropStart.y, cropStart.height + deltaY);
- }
- } else if (dragHandle === "se") {
- if (lockedAspect) {
- const avgDelta = (deltaX + deltaY) / 2;
- newCrop.width = Math.min(
- 1 - cropStart.x,
- Math.max(0.1, cropStart.width + avgDelta),
- );
- newCrop.height = Math.min(
- 1 - cropStart.y,
- Math.max(0.1, cropStart.height + avgDelta),
- );
- } else {
- newCrop.width = Math.min(
- 1 - cropStart.x,
- Math.max(0.1, cropStart.width + deltaX),
- );
- newCrop.height = Math.min(
- 1 - cropStart.y,
- Math.max(0.1, cropStart.height + deltaY),
- );
- }
- } else if (dragHandle === "n") {
- const maxDelta = cropStart.y;
- const clampedDelta = Math.min(deltaY, maxDelta);
- newCrop.y = cropStart.y + clampedDelta;
- newCrop.height = cropStart.height - clampedDelta;
- } else if (dragHandle === "s") {
- newCrop.height = Math.min(
- 1 - cropStart.y,
- Math.max(0.1, cropStart.height + deltaY),
- );
- } else if (dragHandle === "w") {
- const maxDelta = cropStart.x;
- const clampedDelta = Math.min(deltaX, maxDelta);
- newCrop.x = cropStart.x + clampedDelta;
- newCrop.width = cropStart.width - clampedDelta;
- } else if (dragHandle === "e") {
- newCrop.width = Math.min(
- 1 - cropStart.x,
- Math.max(0.1, cropStart.width + deltaX),
- );
- }
-
- newCrop.width = Math.max(0.05, Math.min(1, newCrop.width));
- newCrop.height = Math.max(0.05, Math.min(1, newCrop.height));
- newCrop.x = Math.max(0, Math.min(1 - newCrop.width, newCrop.x));
- newCrop.y = Math.max(0, Math.min(1 - newCrop.height, newCrop.y));
-
- setCrop(newCrop);
- };
-
- const handleMouseUp = () => {
- if (isDragging && dragHandle) {
- onCropChange(crop);
- }
- setIsDragging(false);
- setDragHandle(null);
- };
-
- useEffect(() => {
- if (isDragging) {
- window.addEventListener("mousemove", handleMouseMove);
- window.addEventListener("mouseup", handleMouseUp);
- return () => {
- window.removeEventListener("mousemove", handleMouseMove);
- window.removeEventListener("mouseup", handleMouseUp);
- };
- }
- }, [isDragging, dragHandle, dragStart, cropStart, lockedAspect]);
-
- const handleAspectRatio = (ratio: number | null) => {
- setLockedAspect(ratio);
- if (ratio) {
- const currentAspect = crop.width / crop.height;
- let newCrop;
- if (currentAspect > ratio) {
- const newWidth = crop.height * ratio;
- newCrop = {
- ...crop,
- x: crop.x + (crop.width - newWidth) / 2,
- width: newWidth,
- };
- } else {
- const newHeight = crop.width / ratio;
- newCrop = {
- ...crop,
- y: crop.y + (crop.height - newHeight) / 2,
- height: newHeight,
- };
- }
- setCrop(newCrop);
- onCropChange(newCrop);
- }
- };
-
- const handleReset = () => {
- const resetCrop = { x: 0, y: 0, width: 1, height: 1 };
- setCrop(resetCrop);
- setLockedAspect(null);
- onCropChange(resetCrop);
- };
-
- return (
- <>
- {/* Full canvas overlay for darkening */}
- <svg
- className="absolute inset-0 pointer-events-none"
- width={canvasWidth}
- height={canvasHeight}
- style={{ left: 0, top: 0 }}
- >
- <defs>
- <mask id="crop-mask">
- <rect
- x="0"
- y="0"
- width={canvasWidth}
- height={canvasHeight}
- fill="white"
- />
- <rect
- x={cropPixels.x}
- y={cropPixels.y}
- width={cropPixels.width}
- height={cropPixels.height}
- fill="black"
- />
- </mask>
- </defs>
- <rect
- x="0"
- y="0"
- width={canvasWidth}
- height={canvasHeight}
- fill="black"
- opacity="0.5"
- mask="url(#crop-mask)"
- />
- </svg>
-
- {/* Video frame overlay for crop handles */}
- <div
- ref={overlayRef}
- className="absolute cursor-move"
- style={{
- left: frameX,
- top: frameY,
- width: frameWidth,
- height: frameHeight,
- }}
- >
- <div
- className="absolute border-2 border-white pointer-events-auto"
- style={{
- left: crop.x * frameWidth,
- top: crop.y * frameHeight,
- width: crop.width * frameWidth,
- height: crop.height * frameHeight,
- }}
- onMouseDown={(e) => handleMouseDown(e, "center")}
- >
- <svg
- className="absolute inset-0 pointer-events-none"
- width="100%"
- height="100%"
- >
- <line
- x1="33.33%"
- y1="0"
- x2="33.33%"
- y2="100%"
- stroke="white"
- strokeWidth="1"
- opacity="0.5"
- />
- <line
- x1="66.66%"
- y1="0"
- x2="66.66%"
- y2="100%"
- stroke="white"
- strokeWidth="1"
- opacity="0.5"
- />
- <line
- x1="0"
- y1="33.33%"
- x2="100%"
- y2="33.33%"
- stroke="white"
- strokeWidth="1"
- opacity="0.5"
- />
- <line
- x1="0"
- y1="66.66%"
- x2="100%"
- y2="66.66%"
- stroke="white"
- strokeWidth="1"
- opacity="0.5"
- />
- </svg>
-
- {/* Corner Handles */}
- {["nw", "ne", "sw", "se"].map((handle) => (
- <div
- key={handle}
- className="absolute w-3 h-3 bg-white border border-gray-800 rounded-sm cursor-nwse-resize pointer-events-auto"
- style={{
- top: handle.includes("n") ? -6 : undefined,
- bottom: handle.includes("s") ? -6 : undefined,
- left: handle.includes("w") ? -6 : undefined,
- right: handle.includes("e") ? -6 : undefined,
- }}
- onMouseDown={(e) => handleMouseDown(e, handle as DragHandle)}
- />
- ))}
-
- {/* Edge Handles */}
- <div
- className="absolute w-12 h-3 bg-white border border-gray-800 rounded-sm cursor-ns-resize pointer-events-auto -top-1.5 left-1/2 -translate-x-1/2"
- onMouseDown={(e) => handleMouseDown(e, "n")}
- />
- <div
- className="absolute w-12 h-3 bg-white border border-gray-800 rounded-sm cursor-ns-resize pointer-events-auto -bottom-1.5 left-1/2 -translate-x-1/2"
- onMouseDown={(e) => handleMouseDown(e, "s")}
- />
- <div
- className="absolute w-3 h-12 bg-white border border-gray-800 rounded-sm cursor-ew-resize pointer-events-auto -left-1.5 top-1/2 -translate-y-1/2"
- onMouseDown={(e) => handleMouseDown(e, "w")}
- />
- <div
- className="absolute w-3 h-12 bg-white border border-gray-800 rounded-sm cursor-ew-resize pointer-events-auto -right-1.5 top-1/2 -translate-y-1/2"
- onMouseDown={(e) => handleMouseDown(e, "e")}
- />
- </div>
- </div>
-
- <div className="absolute top-4 left-1/2 -translate-x-1/2 flex items-center gap-2 bg-black/80 backdrop-blur-sm rounded-lg p-2 border border-white/20">
- <div className="flex items-center gap-1">
- {ASPECT_RATIOS.map((ratio) => (
- <button
- key={ratio.label}
- onClick={() => handleAspectRatio(ratio.value)}
- className={`px-3 py-1.5 text-xs rounded transition-colors ${
- lockedAspect === ratio.value
- ? "bg-primary text-white font-medium"
- : "bg-white/10 text-white hover:bg-white/20"
- }`}
- >
- {ratio.label}
- </button>
- ))}
- </div>
-
- <div className="w-px h-6 bg-white/20" />
-
- <button
- onClick={handleReset}
- className="p-1.5 text-white hover:bg-white/20 rounded transition-colors"
- title="Reset crop"
- >
- <Maximize2 size={16} />
- </button>
-
- <div className="w-px h-6 bg-white/20" />
-
- <button
- onClick={onCancel}
- className="px-3 py-1.5 text-xs bg-white/10 hover:bg-white/20 text-white rounded transition-colors flex items-center gap-1.5"
- >
- <X size={14} />
- Cancel
- </button>
-
- <button
- onClick={onComplete}
- className="px-3 py-1.5 text-xs bg-primary hover:bg-primary/80 text-black font-medium rounded transition-colors flex items-center gap-1.5"
- >
- <Check size={14} />
- Apply
- </button>
- </div>
- </>
- );
-};
diff --git a/apps/web/src/components/editor/timeline/SubtitleClip.tsx b/apps/web/src/components/editor/timeline/SubtitleClip.tsx
deleted file mode 100644
index 2321eaac..00000000
--- a/apps/web/src/components/editor/timeline/SubtitleClip.tsx
+++ /dev/null
@@ -1,38 +0,0 @@
-import React from "react";
-import type { Subtitle } from "@openreel/core";
-
-interface SubtitleClipProps {
- subtitle: Subtitle;
- pixelsPerSecond: number;
- isSelected: boolean;
- onSelect: (id: string, addToSelection: boolean) => void;
-}
-
-export const SubtitleClip: React.FC<SubtitleClipProps> = ({
- subtitle,
- pixelsPerSecond,
- isSelected,
- onSelect,
-}) => {
- const width = (subtitle.endTime - subtitle.startTime) * pixelsPerSecond;
- const left = subtitle.startTime * pixelsPerSecond;
-
- return (
- <div
- className={`absolute top-1 bottom-1 rounded px-2 py-0.5 cursor-pointer transition-all group ${
- isSelected
- ? "bg-purple-500/40 border-2 border-purple-400"
- : "bg-purple-500/20 border border-purple-500/30 hover:bg-purple-500/30"
- }`}
- style={{ left, width: Math.max(width, 30) }}
- onClick={(e) => {
- e.stopPropagation();
- onSelect(subtitle.id, e.metaKey || e.ctrlKey);
- }}
- >
- <p className="text-[9px] text-purple-200 truncate leading-tight">
- {subtitle.text}
- </p>
- </div>
- );
-};
diff --git a/apps/web/src/components/editor/timeline/SubtitleTrackLane.tsx b/apps/web/src/components/editor/timeline/SubtitleTrackLane.tsx
deleted file mode 100644
index f2f313f8..00000000
--- a/apps/web/src/components/editor/timeline/SubtitleTrackLane.tsx
+++ /dev/null
@@ -1,60 +0,0 @@
-import React, { useRef, useCallback } from "react";
-import type { Subtitle } from "@openreel/core";
-import { SubtitleClip } from "./SubtitleClip";
-
-interface SubtitleTrackLaneProps {
- subtitles: Subtitle[];
- pixelsPerSecond: number;
- selectedSubtitleIds: string[];
- onSelectSubtitle: (id: string, addToSelection: boolean) => void;
- onAddSubtitle: (startTime: number) => void;
- scrollX: number;
-}
-
-export const SubtitleTrackLane: React.FC<SubtitleTrackLaneProps> = ({
- subtitles,
- pixelsPerSecond,
- selectedSubtitleIds,
- onSelectSubtitle,
- onAddSubtitle,
- scrollX,
-}) => {
- const laneRef = useRef<HTMLDivElement>(null);
-
- const handleDoubleClick = useCallback(
- (e: React.MouseEvent) => {
- const rect = laneRef.current?.getBoundingClientRect();
- if (!rect) return;
-
- const x = e.clientX - rect.left + scrollX;
- const startTime = Math.max(0, x / pixelsPerSecond);
- onAddSubtitle(startTime);
- },
- [scrollX, pixelsPerSecond, onAddSubtitle],
- );
-
- return (
- <div
- ref={laneRef}
- className="h-10 border-b border-border/50 relative bg-purple-500/5"
- onDoubleClick={handleDoubleClick}
- >
- {subtitles.map((subtitle) => (
- <SubtitleClip
- key={subtitle.id}
- subtitle={subtitle}
- pixelsPerSecond={pixelsPerSecond}
- isSelected={selectedSubtitleIds.includes(subtitle.id)}
- onSelect={onSelectSubtitle}
- />
- ))}
- {subtitles.length === 0 && (
- <div className="absolute inset-0 flex items-center justify-center pointer-events-none">
- <span className="text-[9px] text-purple-400/50">
- Double-click to add subtitle
- </span>
- </div>
- )}
- </div>
- );
-};
diff --git a/apps/web/src/components/index.ts b/apps/web/src/components/index.ts
deleted file mode 100644
index 19e45b27..00000000
--- a/apps/web/src/components/index.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-/**
- * Components Exports
- */
-
-export * from "./audio-mixer";
diff --git a/apps/web/src/services/error-handler.ts b/apps/web/src/services/error-handler.ts
deleted file mode 100644
index cd6e1af7..00000000
--- a/apps/web/src/services/error-handler.ts
+++ /dev/null
@@ -1,304 +0,0 @@
-export interface AppError {
- id: string;
- type: ErrorType;
- severity: ErrorSeverity;
- message: string;
- details?: string;
- stack?: string;
- timestamp: number;
- recoverable: boolean;
- recoveryAction?: () => Promise<void>;
- context?: Record<string, unknown>;
-}
-
-export type ErrorType =
- | "render"
- | "playback"
- | "export"
- | "media"
- | "storage"
- | "network"
- | "system"
- | "unknown";
-
-export type ErrorSeverity = "info" | "warning" | "error" | "critical";
-
-type ErrorCallback = (error: AppError) => void;
-
-const ERROR_STORAGE_KEY = "openreel-error-log";
-const MAX_STORED_ERRORS = 50;
-
-class ErrorHandler {
- private errors: AppError[] = [];
- private listeners: Set<ErrorCallback> = new Set();
- private isInitialized = false;
-
- initialize(): void {
- if (this.isInitialized) return;
-
- window.addEventListener("error", this.handleGlobalError);
- window.addEventListener(
- "unhandledrejection",
- this.handleUnhandledRejection,
- );
-
- this.loadStoredErrors();
- this.isInitialized = true;
- }
-
- dispose(): void {
- window.removeEventListener("error", this.handleGlobalError);
- window.removeEventListener(
- "unhandledrejection",
- this.handleUnhandledRejection,
- );
- this.isInitialized = false;
- }
-
- private handleGlobalError = (event: ErrorEvent): void => {
- this.captureError({
- type: "unknown",
- severity: "error",
- message: event.message || "An unexpected error occurred",
- stack: event.error?.stack,
- recoverable: true,
- context: {
- filename: event.filename,
- lineno: event.lineno,
- colno: event.colno,
- },
- });
- };
-
- private handleUnhandledRejection = (event: PromiseRejectionEvent): void => {
- const error = event.reason;
- this.captureError({
- type: "unknown",
- severity: "error",
- message: error?.message || "Unhandled promise rejection",
- stack: error?.stack,
- recoverable: true,
- });
- };
-
- captureError(options: {
- type: ErrorType;
- severity: ErrorSeverity;
- message: string;
- details?: string;
- stack?: string;
- recoverable?: boolean;
- recoveryAction?: () => Promise<void>;
- context?: Record<string, unknown>;
- }): AppError {
- const error: AppError = {
- id: `error-${Date.now()}-${Math.random().toString(36).slice(2, 11)}`,
- type: options.type,
- severity: options.severity,
- message: options.message,
- details: options.details,
- stack: options.stack,
- timestamp: Date.now(),
- recoverable: options.recoverable ?? true,
- recoveryAction: options.recoveryAction,
- context: options.context,
- };
-
- this.errors.push(error);
- if (this.errors.length > MAX_STORED_ERRORS) {
- this.errors.shift();
- }
-
- this.storeErrors();
- this.notifyListeners(error);
-
- if (options.severity === "critical") {
- console.error("[ErrorHandler] Critical error:", error);
- } else if (options.severity === "error") {
- console.error("[ErrorHandler] Error:", error.message);
- } else if (options.severity === "warning") {
- console.warn("[ErrorHandler] Warning:", error.message);
- }
-
- return error;
- }
-
- captureRenderError(
- message: string,
- context?: Record<string, unknown>,
- ): AppError {
- return this.captureError({
- type: "render",
- severity: "error",
- message,
- context,
- recoverable: true,
- recoveryAction: async () => {
- window.location.reload();
- },
- });
- }
-
- capturePlaybackError(
- message: string,
- context?: Record<string, unknown>,
- ): AppError {
- return this.captureError({
- type: "playback",
- severity: "warning",
- message,
- context,
- recoverable: true,
- });
- }
-
- captureExportError(
- message: string,
- context?: Record<string, unknown>,
- ): AppError {
- return this.captureError({
- type: "export",
- severity: "error",
- message,
- context,
- recoverable: true,
- });
- }
-
- captureMediaError(
- message: string,
- context?: Record<string, unknown>,
- ): AppError {
- return this.captureError({
- type: "media",
- severity: "warning",
- message,
- context,
- recoverable: true,
- });
- }
-
- captureStorageError(
- message: string,
- context?: Record<string, unknown>,
- ): AppError {
- return this.captureError({
- type: "storage",
- severity: "error",
- message,
- context,
- recoverable: true,
- });
- }
-
- async attemptRecovery(errorId: string): Promise<boolean> {
- const error = this.errors.find((e) => e.id === errorId);
- if (!error || !error.recoveryAction) {
- return false;
- }
-
- try {
- await error.recoveryAction();
- this.dismissError(errorId);
- return true;
- } catch (e) {
- console.error("[ErrorHandler] Recovery failed:", e);
- return false;
- }
- }
-
- dismissError(errorId: string): void {
- const index = this.errors.findIndex((e) => e.id === errorId);
- if (index !== -1) {
- this.errors.splice(index, 1);
- this.storeErrors();
- }
- }
-
- clearAllErrors(): void {
- this.errors = [];
- this.storeErrors();
- }
-
- getErrors(): AppError[] {
- return [...this.errors];
- }
-
- getErrorsByType(type: ErrorType): AppError[] {
- return this.errors.filter((e) => e.type === type);
- }
-
- getErrorsBySeverity(severity: ErrorSeverity): AppError[] {
- return this.errors.filter((e) => e.severity === severity);
- }
-
- getRecentErrors(count: number = 10): AppError[] {
- return this.errors.slice(-count);
- }
-
- hasUnresolvedErrors(): boolean {
- return this.errors.some(
- (e) => e.severity === "error" || e.severity === "critical",
- );
- }
-
- onError(callback: ErrorCallback): () => void {
- this.listeners.add(callback);
- return () => this.listeners.delete(callback);
- }
-
- private notifyListeners(error: AppError): void {
- this.listeners.forEach((cb) => {
- try {
- cb(error);
- } catch (e) {
- console.error("[ErrorHandler] Listener error:", e);
- }
- });
- }
-
- private storeErrors(): void {
- try {
- const storable = this.errors.map(({ recoveryAction, ...rest }) => rest);
- localStorage.setItem(ERROR_STORAGE_KEY, JSON.stringify(storable));
- } catch (e) {
- console.warn("[ErrorHandler] Failed to store errors:", e);
- }
- }
-
- private loadStoredErrors(): void {
- try {
- const stored = localStorage.getItem(ERROR_STORAGE_KEY);
- if (stored) {
- this.errors = JSON.parse(stored);
- }
- } catch (e) {
- console.warn("[ErrorHandler] Failed to load stored errors:", e);
- }
- }
-
- generateErrorReport(): string {
- const report = {
- timestamp: new Date().toISOString(),
- userAgent: navigator.userAgent,
- url: window.location.href,
- errors: this.errors.map(({ recoveryAction, ...rest }) => rest),
- };
- return JSON.stringify(report, null, 2);
- }
-
- downloadErrorReport(): void {
- const report = this.generateErrorReport();
- const blob = new Blob([report], { type: "application/json" });
- const url = URL.createObjectURL(blob);
- const a = document.createElement("a");
- a.href = url;
- a.download = `openreel-error-report-${Date.now()}.json`;
- document.body.appendChild(a);
- a.click();
- document.body.removeChild(a);
- URL.revokeObjectURL(url);
- }
-}
-
-export const errorHandler = new ErrorHandler();
diff --git a/apps/web/src/services/index.ts b/apps/web/src/services/index.ts
deleted file mode 100644
index 2dffdf67..00000000
--- a/apps/web/src/services/index.ts
+++ /dev/null
@@ -1,25 +0,0 @@
-/**
- * Services index
- *
- * Exports all service modules for the web application.
- */
-
-export {
- serviceWorkerManager,
- registerServiceWorker,
- isAIAvailable,
- type ServiceWorkerStatus,
- type CacheStatus,
-} from "./service-worker";
-
-export {
- autoSaveManager,
- initializeAutoSave,
- startAutoSave,
- stopAutoSave,
- markProjectDirty,
- checkForRecovery,
- recoverProject,
- type AutoSaveConfig,
- type AutoSaveMetadata,
-} from "./auto-save";
diff --git a/apps/web/src/services/performance-monitor.ts b/apps/web/src/services/performance-monitor.ts
deleted file mode 100644
index 2a5a28b2..00000000
--- a/apps/web/src/services/performance-monitor.ts
+++ /dev/null
@@ -1,337 +0,0 @@
-interface PerformanceMemory {
- usedJSHeapSize: number;
- totalJSHeapSize: number;
- jsHeapSizeLimit: number;
-}
-
-interface PerformanceWithMemory extends Performance {
- memory?: PerformanceMemory;
-}
-
-interface WindowWithGC extends Window {
- gc?: () => void;
-}
-
-export interface PerformanceMetrics {
- fps: number;
- frameTime: number;
- memoryUsed: number;
- memoryLimit: number;
- memoryPercent: number;
- gpuMemoryUsed?: number;
- renderTime: number;
- drawCalls: number;
- activeClips: number;
- timestamp: number;
-}
-
-export interface PerformanceWarning {
- type: "fps" | "memory" | "render" | "general";
- severity: "low" | "medium" | "high";
- message: string;
- suggestion?: string;
- timestamp: number;
-}
-
-const FPS_SAMPLES = 60;
-const MEMORY_CHECK_INTERVAL = 5000;
-const FPS_LOW_THRESHOLD = 24;
-const FPS_CRITICAL_THRESHOLD = 15;
-const MEMORY_WARNING_THRESHOLD = 0.7;
-const MEMORY_CRITICAL_THRESHOLD = 0.9;
-const RENDER_TIME_WARNING = 32;
-const RENDER_TIME_CRITICAL = 50;
-
-type MetricsCallback = (metrics: PerformanceMetrics) => void;
-type WarningCallback = (warning: PerformanceWarning) => void;
-
-class PerformanceMonitor {
- private frameTimestamps: number[] = [];
- private renderTimes: number[] = [];
- private isRunning = false;
- private animationFrameId: number | null = null;
- private memoryCheckIntervalId: ReturnType<typeof setInterval> | null = null;
- private metricsListeners: Set<MetricsCallback> = new Set();
- private warningListeners: Set<WarningCallback> = new Set();
- private lastMetrics: PerformanceMetrics | null = null;
- private drawCallCount = 0;
- private activeClipCount = 0;
- private lastWarningTime: Record<string, number> = {};
- private warningCooldown = 10000;
-
- start(): void {
- if (this.isRunning) return;
- this.isRunning = true;
- this.frameTimestamps = [];
- this.renderTimes = [];
- this.measureFrame();
- this.startMemoryMonitoring();
- }
-
- stop(): void {
- if (!this.isRunning) return;
- this.isRunning = false;
-
- if (this.animationFrameId !== null) {
- cancelAnimationFrame(this.animationFrameId);
- this.animationFrameId = null;
- }
-
- if (this.memoryCheckIntervalId !== null) {
- clearInterval(this.memoryCheckIntervalId);
- this.memoryCheckIntervalId = null;
- }
- }
-
- private measureFrame(): void {
- if (!this.isRunning) return;
-
- const now = performance.now();
- this.frameTimestamps.push(now);
-
- if (this.frameTimestamps.length > FPS_SAMPLES) {
- this.frameTimestamps.shift();
- }
-
- if (this.frameTimestamps.length >= 2) {
- const metrics = this.calculateMetrics(now);
- this.lastMetrics = metrics;
- this.notifyMetrics(metrics);
- this.checkPerformanceWarnings(metrics);
- }
-
- this.animationFrameId = requestAnimationFrame(() => this.measureFrame());
- }
-
- private calculateMetrics(now: number): PerformanceMetrics {
- const frameCount = this.frameTimestamps.length;
- const timeSpan =
- frameCount > 1
- ? this.frameTimestamps[frameCount - 1] - this.frameTimestamps[0]
- : 0;
- const fps = frameCount > 1 ? ((frameCount - 1) / timeSpan) * 1000 : 0;
- const frameTime = frameCount > 1 ? timeSpan / (frameCount - 1) : 0;
-
- const avgRenderTime =
- this.renderTimes.length > 0
- ? this.renderTimes.reduce((a, b) => a + b, 0) / this.renderTimes.length
- : 0;
-
- const memory = this.getMemoryInfo();
-
- return {
- fps: Math.round(fps * 10) / 10,
- frameTime: Math.round(frameTime * 100) / 100,
- memoryUsed: memory.used,
- memoryLimit: memory.limit,
- memoryPercent: memory.percent,
- renderTime: Math.round(avgRenderTime * 100) / 100,
- drawCalls: this.drawCallCount,
- activeClips: this.activeClipCount,
- timestamp: now,
- };
- }
-
- private getMemoryInfo(): {
- used: number;
- limit: number;
- percent: number;
- } {
- const perf = performance as PerformanceWithMemory;
- if (perf.memory) {
- const used = perf.memory.usedJSHeapSize;
- const limit = perf.memory.jsHeapSizeLimit;
- return {
- used,
- limit,
- percent: limit > 0 ? used / limit : 0,
- };
- }
- return { used: 0, limit: 0, percent: 0 };
- }
-
- private startMemoryMonitoring(): void {
- this.memoryCheckIntervalId = setInterval(() => {
- const memory = this.getMemoryInfo();
- if (memory.percent >= MEMORY_CRITICAL_THRESHOLD) {
- this.emitWarning({
- type: "memory",
- severity: "high",
- message: `Critical memory usage: ${Math.round(memory.percent * 100)}%`,
- suggestion:
- "Consider closing unused media, reducing preview quality, or splitting your project.",
- });
- } else if (memory.percent >= MEMORY_WARNING_THRESHOLD) {
- this.emitWarning({
- type: "memory",
- severity: "medium",
- message: `High memory usage: ${Math.round(memory.percent * 100)}%`,
- suggestion: "Close unused browser tabs or reduce media library size.",
- });
- }
- }, MEMORY_CHECK_INTERVAL);
- }
-
- private checkPerformanceWarnings(metrics: PerformanceMetrics): void {
- if (metrics.fps < FPS_CRITICAL_THRESHOLD && metrics.fps > 0) {
- this.emitWarning({
- type: "fps",
- severity: "high",
- message: `Very low frame rate: ${metrics.fps} fps`,
- suggestion:
- "Reduce preview resolution, disable effects, or use proxy media.",
- });
- } else if (metrics.fps < FPS_LOW_THRESHOLD && metrics.fps > 0) {
- this.emitWarning({
- type: "fps",
- severity: "medium",
- message: `Low frame rate: ${metrics.fps} fps`,
- suggestion: "Consider reducing preview quality for smoother playback.",
- });
- }
-
- if (metrics.renderTime > RENDER_TIME_CRITICAL) {
- this.emitWarning({
- type: "render",
- severity: "high",
- message: `Slow render time: ${metrics.renderTime}ms`,
- suggestion: "Disable complex effects or reduce clip count in view.",
- });
- } else if (metrics.renderTime > RENDER_TIME_WARNING) {
- this.emitWarning({
- type: "render",
- severity: "medium",
- message: `High render time: ${metrics.renderTime}ms`,
- suggestion:
- "Consider simplifying effects or reducing preview resolution.",
- });
- }
- }
-
- private emitWarning(warning: Omit<PerformanceWarning, "timestamp">): void {
- const key = `${warning.type}-${warning.severity}`;
- const now = Date.now();
-
- if (
- this.lastWarningTime[key] &&
- now - this.lastWarningTime[key] < this.warningCooldown
- ) {
- return;
- }
-
- this.lastWarningTime[key] = now;
- const fullWarning: PerformanceWarning = { ...warning, timestamp: now };
- this.warningListeners.forEach((cb) => cb(fullWarning));
- }
-
- recordRenderTime(time: number): void {
- this.renderTimes.push(time);
- if (this.renderTimes.length > FPS_SAMPLES) {
- this.renderTimes.shift();
- }
- }
-
- recordDrawCalls(count: number): void {
- this.drawCallCount = count;
- }
-
- recordActiveClips(count: number): void {
- this.activeClipCount = count;
- }
-
- getLastMetrics(): PerformanceMetrics | null {
- return this.lastMetrics;
- }
-
- getAverageFPS(): number {
- return this.lastMetrics?.fps ?? 0;
- }
-
- onMetrics(callback: MetricsCallback): () => void {
- this.metricsListeners.add(callback);
- return () => this.metricsListeners.delete(callback);
- }
-
- onWarning(callback: WarningCallback): () => void {
- this.warningListeners.add(callback);
- return () => this.warningListeners.delete(callback);
- }
-
- private notifyMetrics(metrics: PerformanceMetrics): void {
- this.metricsListeners.forEach((cb) => cb(metrics));
- }
-
- forceGC(): void {
- const win = window as WindowWithGC;
- if (win.gc) {
- win.gc();
- }
- }
-
- getPerformanceScore(): number {
- if (!this.lastMetrics) return 100;
-
- let score = 100;
-
- if (this.lastMetrics.fps < FPS_LOW_THRESHOLD) {
- score -= 30;
- } else if (this.lastMetrics.fps < 30) {
- score -= 15;
- }
-
- if (this.lastMetrics.memoryPercent > MEMORY_CRITICAL_THRESHOLD) {
- score -= 30;
- } else if (this.lastMetrics.memoryPercent > MEMORY_WARNING_THRESHOLD) {
- score -= 15;
- }
-
- if (this.lastMetrics.renderTime > RENDER_TIME_CRITICAL) {
- score -= 20;
- } else if (this.lastMetrics.renderTime > RENDER_TIME_WARNING) {
- score -= 10;
- }
-
- return Math.max(0, score);
- }
-
- getOptimizationSuggestions(): string[] {
- const suggestions: string[] = [];
-
- if (!this.lastMetrics) return suggestions;
-
- if (this.lastMetrics.fps < FPS_LOW_THRESHOLD) {
- suggestions.push("Lower preview resolution to 720p or 480p");
- suggestions.push("Disable real-time effects preview");
- suggestions.push("Use proxy media for large files");
- }
-
- if (this.lastMetrics.memoryPercent > MEMORY_WARNING_THRESHOLD) {
- suggestions.push("Clear unused media from library");
- suggestions.push("Close other browser tabs");
- suggestions.push("Split large projects into smaller sequences");
- }
-
- if (this.lastMetrics.renderTime > RENDER_TIME_WARNING) {
- suggestions.push("Reduce number of simultaneous effects");
- suggestions.push("Use simpler transitions");
- suggestions.push("Lower color grading complexity");
- }
-
- if (this.lastMetrics.activeClips > 10) {
- suggestions.push("Pre-render complex sections as nested sequences");
- suggestions.push("Reduce overlapping clips on multiple tracks");
- }
-
- return suggestions;
- }
-}
-
-export const performanceMonitor = new PerformanceMonitor();
-
-export function formatBytes(bytes: number): string {
- if (bytes === 0) return "0 B";
- const k = 1024;
- const sizes = ["B", "KB", "MB", "GB"];
- const i = Math.floor(Math.log(bytes) / Math.log(k));
- return `${(bytes / Math.pow(k, i)).toFixed(1)} ${sizes[i]}`;
-}
diff --git a/apps/web/src/stores/index.ts b/apps/web/src/stores/index.ts
deleted file mode 100644
index 8eee6a50..00000000
--- a/apps/web/src/stores/index.ts
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- * Zustand stores for OpenReel
- *
- * Exports all stores for project, timeline, UI, and engine state management.
- */
-
-export { useProjectStore } from "./project-store";
-export type { ProjectState } from "./project-store";
-
-export { useTimelineStore, ZOOM_PRESETS } from "./timeline-store";
-export type { TimelineState, PlaybackState } from "./timeline-store";
-
-export { useUIStore } from "./ui-store";
-export type {
- UIState,
- SelectionType,
- PanelState,
- SnapSettings,
-} from "./ui-store";
-
-export { useThemeStore } from "./theme-store";
-export type { ThemeMode } from "./theme-store";
-
-export { useEngineStore } from "./engine-store";
-export type {
- EngineState,
- AudioLevelData,
- PlaybackStats,
-} from "./engine-store";
diff --git a/apps/web/src/stores/utils/engine-helpers.ts b/apps/web/src/stores/utils/engine-helpers.ts
deleted file mode 100644
index 2b17b60a..00000000
--- a/apps/web/src/stores/utils/engine-helpers.ts
+++ /dev/null
@@ -1,184 +0,0 @@
-import { useEngineStore } from "../engine-store";
-
-type EngineStoreState = ReturnType<typeof useEngineStore.getState>;
-
-type EngineType<K extends keyof EngineStoreState> =
- EngineStoreState[K] extends () => infer T
- ? T extends Promise<infer U>
- ? NonNullable<U>
- : NonNullable<T>
- : never;
-
-export function withEngine<T, R>(
- getEngine: () => T | null,
- engineName: string,
- operation: (engine: T) => R,
-): R | null {
- const engine = getEngine();
- if (!engine) {
- if (process.env.NODE_ENV === "development") {
- console.warn(`${engineName} not initialized`);
- }
- return null;
- }
- return operation(engine);
-}
-
-export async function withAsyncEngine<T, R>(
- getEngine: () => Promise<T>,
- _engineName: string,
- operation: (engine: T) => R | Promise<R>,
-): Promise<R> {
- const engine = await getEngine();
- return operation(engine);
-}
-
-export function withTitleEngine<R>(
- operation: (engine: EngineType<"getTitleEngine">) => R,
-): R | null {
- return withEngine(
- useEngineStore.getState().getTitleEngine,
- "TitleEngine",
- operation,
- );
-}
-
-export function withGraphicsEngine<R>(
- operation: (engine: EngineType<"getGraphicsEngine">) => R,
-): R | null {
- return withEngine(
- useEngineStore.getState().getGraphicsEngine,
- "GraphicsEngine",
- operation,
- );
-}
-
-export async function withSubtitleEngine<R>(
- operation: (engine: EngineType<"getSubtitleEngine">) => R | Promise<R>,
-): Promise<R> {
- return withAsyncEngine(
- useEngineStore.getState().getSubtitleEngine,
- "SubtitleEngine",
- operation,
- );
-}
-
-export function withVideoEngine<R>(
- operation: (engine: EngineType<"getVideoEngine">) => R,
-): R | null {
- return withEngine(
- useEngineStore.getState().getVideoEngine,
- "VideoEngine",
- operation,
- );
-}
-
-export function withAudioEngine<R>(
- operation: (engine: EngineType<"getAudioEngine">) => R,
-): R | null {
- return withEngine(
- useEngineStore.getState().getAudioEngine,
- "AudioEngine",
- operation,
- );
-}
-
-export function withPhotoEngine<R>(
- operation: (engine: EngineType<"getPhotoEngine">) => R,
-): R | null {
- return withEngine(
- useEngineStore.getState().getPhotoEngine,
- "PhotoEngine",
- operation,
- );
-}
-
-export function withExportEngine<R>(
- operation: (engine: EngineType<"getExportEngine">) => R,
-): R | null {
- return withEngine(
- useEngineStore.getState().getExportEngine,
- "ExportEngine",
- operation,
- );
-}
-
-export async function withMaskEngine<R>(
- operation: (engine: EngineType<"getMaskEngine">) => R | Promise<R>,
-): Promise<R> {
- return withAsyncEngine(
- useEngineStore.getState().getMaskEngine,
- "MaskEngine",
- operation,
- );
-}
-
-export async function withChromaKeyEngine<R>(
- operation: (engine: EngineType<"getChromaKeyEngine">) => R | Promise<R>,
-): Promise<R> {
- return withAsyncEngine(
- useEngineStore.getState().getChromaKeyEngine,
- "ChromaKeyEngine",
- operation,
- );
-}
-
-export async function withMultiCamEngine<R>(
- operation: (engine: EngineType<"getMultiCamEngine">) => R | Promise<R>,
-): Promise<R> {
- return withAsyncEngine(
- useEngineStore.getState().getMultiCamEngine,
- "MultiCamEngine",
- operation,
- );
-}
-
-export async function withTemplateEngine<R>(
- operation: (engine: EngineType<"getTemplateEngine">) => R | Promise<R>,
-): Promise<R> {
- return withAsyncEngine(
- useEngineStore.getState().getTemplateEngine,
- "TemplateEngine",
- operation,
- );
-}
-
-export async function withSoundLibraryEngine<R>(
- operation: (engine: EngineType<"getSoundLibraryEngine">) => R | Promise<R>,
-): Promise<R> {
- return withAsyncEngine(
- useEngineStore.getState().getSoundLibraryEngine,
- "SoundLibraryEngine",
- operation,
- );
-}
-
-export async function withSpeechToTextEngine<R>(
- operation: (engine: EngineType<"getSpeechToTextEngine">) => R | Promise<R>,
-): Promise<R> {
- return withAsyncEngine(
- useEngineStore.getState().getSpeechToTextEngine,
- "SpeechToTextEngine",
- operation,
- );
-}
-
-export async function withNestedSequenceEngine<R>(
- operation: (engine: EngineType<"getNestedSequenceEngine">) => R | Promise<R>,
-): Promise<R> {
- return withAsyncEngine(
- useEngineStore.getState().getNestedSequenceEngine,
- "NestedSequenceEngine",
- operation,
- );
-}
-
-export async function withAdjustmentLayerEngine<R>(
- operation: (engine: EngineType<"getAdjustmentLayerEngine">) => R | Promise<R>,
-): Promise<R> {
- return withAsyncEngine(
- useEngineStore.getState().getAdjustmentLayerEngine,
- "AdjustmentLayerEngine",
- operation,
- );
-}
diff --git a/apps/web/src/stores/utils/index.ts b/apps/web/src/stores/utils/index.ts
deleted file mode 100644
index a2a6dc15..00000000
--- a/apps/web/src/stores/utils/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from "./engine-helpers";
diff --git a/apps/web/src/workers/processing.worker.ts b/apps/web/src/workers/processing.worker.ts
deleted file mode 100644
index b11ffd37..00000000
--- a/apps/web/src/workers/processing.worker.ts
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- * Processing Web Worker
- * Handles heavy media processing tasks off the main thread
- */
-
-export interface WorkerMessage {
- type: string;
- payload: unknown;
-}
-
-export interface WorkerResponse {
- type: string;
- payload: unknown;
- error?: string;
-}
-
-self.onmessage = (event: MessageEvent<WorkerMessage>) => {
- const { type } = event.data;
-
- try {
- switch (type) {
- case "ping":
- self.postMessage({ type: "pong", payload: { timestamp: Date.now() } });
- break;
- default:
- self.postMessage({
- type: "error",
- payload: null,
- error: `Unknown message type: ${type}`,
- });
- }
- } catch (error) {
- self.postMessage({
- type: "error",
- payload: null,
- error: error instanceof Error ? error.message : "Unknown error",
- });
- }
-};
-
-export {};
diff --git a/packages/core/src/graphics/svg-animation-example.ts b/packages/core/src/graphics/svg-animation-example.ts
deleted file mode 100644
index 9a0b172b..00000000
--- a/packages/core/src/graphics/svg-animation-example.ts
+++ /dev/null
@@ -1,74 +0,0 @@
-import { GraphicsEngine } from "./graphics-engine";
-import type { SVGClip, GraphicAnimation, SVGColorStyle } from "./types";
-
-const engine = new GraphicsEngine();
-
-const svgContent = `
- <svg viewBox="0 0 100 100">
- <circle cx="50" cy="50" r="40" fill="#3b82f6" />
- </svg>
-`;
-
-const svgClip = engine.importSVG(svgContent, "track-1", 0, 5);
-
-const fadeInAnimation: GraphicAnimation = engine.createGraphicAnimation(
- "fade",
- 0.5,
- "ease-out",
-);
-
-const slideOutAnimation: GraphicAnimation = engine.createGraphicAnimation(
- "slide-left",
- 0.5,
- "ease-in",
-);
-
-let animatedSVG = engine.setSVGAnimation(svgClip, "entry", fadeInAnimation);
-animatedSVG = engine.setSVGAnimation(animatedSVG, "exit", slideOutAnimation);
-
-const tintStyle: SVGColorStyle = {
- colorMode: "tint",
- tintColor: "#ef4444",
- tintOpacity: 0.8,
-};
-
-animatedSVG = engine.setSVGColorStyle(animatedSVG, tintStyle);
-
-const replaceColorStyle: SVGColorStyle = {
- colorMode: "replace",
- tintColor: "#10b981",
- tintOpacity: 1,
-};
-
-animatedSVG = engine.setSVGColorStyle(animatedSVG, replaceColorStyle);
-
-const popAnimation: GraphicAnimation = {
- type: "pop",
- duration: 0.8,
- easing: "ease-out",
-};
-
-const bounceAnimation: GraphicAnimation = {
- type: "bounce",
- duration: 1,
- easing: "ease-out",
-};
-
-engine.updateSVGClip(animatedSVG.id, {
- entryAnimation: popAnimation,
- exitAnimation: bounceAnimation,
- colorStyle: {
- colorMode: "tint",
- tintColor: "#8b5cf6",
- tintOpacity: 0.9,
- },
-});
-
-export async function renderAnimatedSVG(
- svg: SVGClip,
- time: number,
- width: number,
- height: number,
-) {
- return await engine.renderGraphic(svg, time, width, height);
-}
diff --git a/packages/core/src/templates/template-engine.ts b/packages/core/src/templates/template-engine.ts
deleted file mode 100644
index 3457ba22..00000000
--- a/packages/core/src/templates/template-engine.ts
+++ /dev/null
@@ -1,256 +0,0 @@
-import type {
- Template,
- Composition,
- Layer,
- Variable,
- TextLayer,
- ShapeLayer,
- ImageLayer,
-} from "../types/composition";
-
-export class TemplateEngine {
- applyVariables(template: Template, values: Record<string, any>): Composition {
- const composition = this.cloneComposition(template.composition);
-
- for (const variable of template.variables) {
- const value = values[variable.name] ?? variable.defaultValue;
-
- for (const layerId of variable.targetLayerIds) {
- const layer = this.findLayerById(composition.layers, layerId);
- if (!layer) continue;
-
- this.applyVariableToLayer(layer, variable, value);
- }
- }
-
- return composition;
- }
-
- private cloneComposition(composition: Composition): Composition {
- return JSON.parse(JSON.stringify(composition));
- }
-
- private findLayerById(layers: Layer[], layerId: string): Layer | null {
- for (const layer of layers) {
- if (layer.id === layerId) {
- return layer;
- }
-
- if (layer.type === "group") {
- const childLayer = this.findLayerById(
- layers.filter((l) => layer.children?.includes(l.id)),
- layerId,
- );
- if (childLayer) return childLayer;
- }
- }
- return null;
- }
-
- private applyVariableToLayer(
- layer: Layer,
- variable: Variable,
- value: any,
- ): void {
- switch (variable.type) {
- case "text":
- this.applyTextVariable(layer as TextLayer, variable, value);
- break;
- case "color":
- this.applyColorVariable(layer, variable, value);
- break;
- case "image":
- this.applyImageVariable(layer as ImageLayer, variable, value);
- break;
- case "number":
- this.applyNumberVariable(layer, variable, value);
- break;
- case "boolean":
- this.applyBooleanVariable(layer, variable, value);
- break;
- }
- }
-
- private applyTextVariable(
- layer: TextLayer,
- variable: Variable,
- value: string,
- ): void {
- if (layer.type !== "text") return;
-
- if (variable.targetProperty === "content" || !variable.targetProperty) {
- layer.content = value;
- } else if (variable.targetProperty === "fontFamily") {
- layer.style.fontFamily = value;
- } else if (variable.targetProperty === "fontSize") {
- layer.style.fontSize = parseFloat(value);
- } else if (variable.targetProperty === "color") {
- layer.style.color = value;
- }
- }
-
- private applyColorVariable(
- layer: Layer,
- variable: Variable,
- value: string,
- ): void {
- if (!variable.targetProperty) return;
-
- if (layer.type === "shape") {
- const shapeLayer = layer as ShapeLayer;
- if (variable.targetProperty === "fill.color") {
- if (shapeLayer.fill.type === "solid") {
- shapeLayer.fill.color = value;
- }
- } else if (variable.targetProperty === "stroke.color") {
- if (shapeLayer.stroke) {
- shapeLayer.stroke.color = value;
- }
- }
- } else if (layer.type === "text") {
- const textLayer = layer as TextLayer;
- if (variable.targetProperty === "style.color") {
- textLayer.style.color = value;
- }
- }
- }
-
- private applyImageVariable(
- layer: ImageLayer,
- variable: Variable,
- value: string,
- ): void {
- if (layer.type !== "image") return;
-
- if (variable.targetProperty === "imageUrl" || !variable.targetProperty) {
- layer.imageUrl = value;
- }
- }
-
- private applyNumberVariable(
- layer: Layer,
- variable: Variable,
- value: number,
- ): void {
- if (!variable.targetProperty) return;
-
- const properties = variable.targetProperty.split(".");
- let target: any = layer;
-
- for (let i = 0; i < properties.length - 1; i++) {
- target = target[properties[i]];
- if (!target) return;
- }
-
- const finalProperty = properties[properties.length - 1];
- target[finalProperty] = value;
- }
-
- private applyBooleanVariable(
- layer: Layer,
- variable: Variable,
- value: boolean,
- ): void {
- if (!variable.targetProperty) return;
-
- const properties = variable.targetProperty.split(".");
- let target: any = layer;
-
- for (let i = 0; i < properties.length - 1; i++) {
- target = target[properties[i]];
- if (!target) return;
- }
-
- const finalProperty = properties[properties.length - 1];
- target[finalProperty] = value;
- }
-
- validateTemplate(template: Template): {
- valid: boolean;
- errors: string[];
- } {
- const errors: string[] = [];
-
- if (!template.id || !template.name) {
- errors.push("Template must have an id and name");
- }
-
- if (!template.composition) {
- errors.push("Template must have a composition");
- }
-
- if (template.composition) {
- if (
- !template.composition.width ||
- !template.composition.height ||
- !template.composition.frameRate ||
- !template.composition.duration
- ) {
- errors.push(
- "Composition must have width, height, frameRate, and duration",
- );
- }
-
- if (
- !template.composition.layers ||
- template.composition.layers.length === 0
- ) {
- errors.push("Composition must have at least one layer");
- }
- }
-
- for (const variable of template.variables) {
- if (!variable.name || !variable.type || !variable.label) {
- errors.push(
- `Variable must have name, type, and label: ${JSON.stringify(variable)}`,
- );
- }
-
- if (!variable.targetLayerIds || variable.targetLayerIds.length === 0) {
- errors.push(`Variable ${variable.name} must target at least one layer`);
- }
-
- for (const layerId of variable.targetLayerIds) {
- const layer = this.findLayerById(template.composition.layers, layerId);
- if (!layer) {
- errors.push(
- `Variable ${variable.name} targets non-existent layer: ${layerId}`,
- );
- }
- }
- }
-
- return {
- valid: errors.length === 0,
- errors,
- };
- }
-
- createTemplateFromComposition(
- composition: Composition,
- metadata: {
- name: string;
- description?: string;
- category: Template["category"];
- tags?: string[];
- thumbnailUrl: string;
- },
- variables: Variable[] = [],
- ): Template {
- return {
- id: `template-${Date.now()}-${Math.random().toString(36).slice(2, 11)}`,
- name: metadata.name,
- description: metadata.description,
- category: metadata.category,
- tags: metadata.tags || [],
- thumbnailUrl: metadata.thumbnailUrl,
- composition: this.cloneComposition(composition),
- variables,
- createdAt: Date.now(),
- updatedAt: Date.now(),
- version: "1.0.0",
- };
- }
-}
-
-export const templateEngine = new TemplateEngine();
diff --git a/packages/core/src/templates/template-presets/lower-third.json b/packages/core/src/templates/template-presets/lower-third.json
deleted file mode 100644
index bafb6324..00000000
--- a/packages/core/src/templates/template-presets/lower-third.json
+++ /dev/null
@@ -1,216 +0,0 @@
-{
- "id": "lower-third-01",
- "name": "Lower Third - Clean",
- "description": "Professional lower third for name and title overlays",
- "category": "callout",
- "tags": ["lower-third", "title", "name", "overlay", "broadcast"],
- "thumbnailUrl": "/templates/thumbnails/lower-third-01.png",
- "composition": {
- "id": "comp-lower-third-01",
- "name": "Lower Third",
- "width": 1920,
- "height": 1080,
- "frameRate": 30,
- "duration": 6,
- "backgroundColor": "#00000000",
- "layers": [
- {
- "id": "layer-bg-bar",
- "name": "Background Bar",
- "type": "shape",
- "startTime": 0,
- "duration": 6,
- "transform": {
- "position": { "x": 200, "y": 880 },
- "scale": { "x": 1, "y": 1 },
- "rotation": 0,
- "opacity": 0.95,
- "anchorPoint": { "x": 0, "y": 0.5 }
- },
- "visible": true,
- "locked": false,
- "keyframes": [
- {
- "property": "transform.scale.x",
- "keyframes": [
- { "time": 0, "value": 0, "ease": "ease-out-cubic" },
- { "time": 0.5, "value": 1, "ease": "ease-out-cubic" },
- { "time": 5.5, "value": 1, "ease": "ease-in-cubic" },
- { "time": 6, "value": 0, "ease": "ease-in-cubic" }
- ]
- }
- ],
- "shapeType": "rectangle",
- "fill": {
- "type": "solid",
- "color": "#1a1a1a"
- }
- },
- {
- "id": "layer-accent-bar",
- "name": "Accent Bar",
- "type": "shape",
- "startTime": 0,
- "duration": 6,
- "transform": {
- "position": { "x": 200, "y": 880 },
- "scale": { "x": 1, "y": 1 },
- "rotation": 0,
- "opacity": 1,
- "anchorPoint": { "x": 0, "y": 0.5 }
- },
- "visible": true,
- "locked": false,
- "keyframes": [
- {
- "property": "transform.scale.x",
- "keyframes": [
- { "time": 0, "value": 0, "ease": "ease-out-cubic" },
- { "time": 0.4, "value": 1, "ease": "ease-out-cubic" },
- { "time": 5.6, "value": 1, "ease": "ease-in-cubic" },
- { "time": 6, "value": 0, "ease": "ease-in-cubic" }
- ]
- }
- ],
- "shapeType": "rectangle",
- "fill": {
- "type": "solid",
- "color": "#8b5cf6"
- }
- },
- {
- "id": "layer-name-text",
- "name": "Name Text",
- "type": "text",
- "startTime": 0,
- "duration": 6,
- "transform": {
- "position": { "x": 240, "y": 860 },
- "scale": { "x": 1, "y": 1 },
- "rotation": 0,
- "opacity": 1,
- "anchorPoint": { "x": 0, "y": 0.5 }
- },
- "visible": true,
- "locked": false,
- "keyframes": [
- {
- "property": "transform.position.x",
- "keyframes": [
- { "time": 0.3, "value": 180, "ease": "ease-out-cubic" },
- { "time": 0.7, "value": 240, "ease": "ease-out-cubic" },
- { "time": 5.3, "value": 240, "ease": "ease-in-cubic" },
- { "time": 5.7, "value": 180, "ease": "ease-in-cubic" }
- ]
- },
- {
- "property": "transform.opacity",
- "keyframes": [
- { "time": 0.3, "value": 0, "ease": "ease-out" },
- { "time": 0.7, "value": 1, "ease": "ease-out" },
- { "time": 5.3, "value": 1, "ease": "ease-in" },
- { "time": 5.7, "value": 0, "ease": "ease-in" }
- ]
- }
- ],
- "content": "John Doe",
- "style": {
- "fontFamily": "Geist",
- "fontSize": 42,
- "fontWeight": 700,
- "fontStyle": "normal",
- "color": "#ffffff",
- "textAlign": "left",
- "lineHeight": 1.2,
- "letterSpacing": -0.5
- },
- "autoSize": true
- },
- {
- "id": "layer-title-text",
- "name": "Title Text",
- "type": "text",
- "startTime": 0,
- "duration": 6,
- "transform": {
- "position": { "x": 240, "y": 900 },
- "scale": { "x": 1, "y": 1 },
- "rotation": 0,
- "opacity": 1,
- "anchorPoint": { "x": 0, "y": 0.5 }
- },
- "visible": true,
- "locked": false,
- "keyframes": [
- {
- "property": "transform.position.x",
- "keyframes": [
- { "time": 0.4, "value": 180, "ease": "ease-out-cubic" },
- { "time": 0.8, "value": 240, "ease": "ease-out-cubic" },
- { "time": 5.2, "value": 240, "ease": "ease-in-cubic" },
- { "time": 5.6, "value": 180, "ease": "ease-in-cubic" }
- ]
- },
- {
- "property": "transform.opacity",
- "keyframes": [
- { "time": 0.4, "value": 0, "ease": "ease-out" },
- { "time": 0.8, "value": 1, "ease": "ease-out" },
- { "time": 5.2, "value": 1, "ease": "ease-in" },
- { "time": 5.6, "value": 0, "ease": "ease-in" }
- ]
- }
- ],
- "content": "CEO & Founder",
- "style": {
- "fontFamily": "Geist",
- "fontSize": 28,
- "fontWeight": 400,
- "fontStyle": "normal",
- "color": "#e0e0e0",
- "textAlign": "left",
- "lineHeight": 1.4,
- "letterSpacing": 0
- },
- "autoSize": true
- }
- ]
- },
- "variables": [
- {
- "name": "personName",
- "type": "text",
- "label": "Name",
- "defaultValue": "John Doe",
- "targetLayerIds": ["layer-name-text"],
- "targetProperty": "content"
- },
- {
- "name": "personTitle",
- "type": "text",
- "label": "Title",
- "defaultValue": "CEO & Founder",
- "targetLayerIds": ["layer-title-text"],
- "targetProperty": "content"
- },
- {
- "name": "accentColor",
- "type": "color",
- "label": "Accent Color",
- "defaultValue": "#8b5cf6",
- "targetLayerIds": ["layer-accent-bar"],
- "targetProperty": "fill.color"
- },
- {
- "name": "backgroundColor",
- "type": "color",
- "label": "Background Color",
- "defaultValue": "#1a1a1a",
- "targetLayerIds": ["layer-bg-bar"],
- "targetProperty": "fill.color"
- }
- ],
- "createdAt": 1704067200000,
- "version": "1.0.0",
- "author": "OpenReel"
-}
diff --git a/packages/core/src/templates/template-presets/tiktok-vertical.json b/packages/core/src/templates/template-presets/tiktok-vertical.json
deleted file mode 100644
index 54ee48d2..00000000
--- a/packages/core/src/templates/template-presets/tiktok-vertical.json
+++ /dev/null
@@ -1,250 +0,0 @@
-{
- "id": "tiktok-vertical-01",
- "name": "TikTok Vertical - Bold Text",
- "description": "Vertical format with bold animated text perfect for TikTok and Instagram Reels",
- "category": "social",
- "tags": ["tiktok", "reels", "vertical", "social", "9:16"],
- "thumbnailUrl": "/templates/thumbnails/tiktok-vertical-01.png",
- "composition": {
- "id": "comp-tiktok-vertical-01",
- "name": "TikTok Vertical",
- "width": 1080,
- "height": 1920,
- "frameRate": 30,
- "duration": 4,
- "backgroundColor": "#000000",
- "layers": [
- {
- "id": "layer-bg-gradient",
- "name": "Background Gradient",
- "type": "shape",
- "startTime": 0,
- "duration": 4,
- "transform": {
- "position": { "x": 540, "y": 960 },
- "scale": { "x": 1, "y": 1 },
- "rotation": 0,
- "opacity": 0.8,
- "anchorPoint": { "x": 0.5, "y": 0.5 }
- },
- "visible": true,
- "locked": false,
- "keyframes": [],
- "shapeType": "rectangle",
- "fill": {
- "type": "gradient",
- "gradient": {
- "type": "linear",
- "stops": [
- { "offset": 0, "color": "#ff0050" },
- { "offset": 0.5, "color": "#00f5ff" },
- { "offset": 1, "color": "#ff0050" }
- ],
- "start": { "x": 0, "y": 0 },
- "end": { "x": 1080, "y": 1920 }
- }
- }
- },
- {
- "id": "layer-overlay",
- "name": "Dark Overlay",
- "type": "shape",
- "startTime": 0,
- "duration": 4,
- "transform": {
- "position": { "x": 540, "y": 960 },
- "scale": { "x": 1, "y": 1 },
- "rotation": 0,
- "opacity": 0.6,
- "anchorPoint": { "x": 0.5, "y": 0.5 }
- },
- "visible": true,
- "locked": false,
- "keyframes": [],
- "shapeType": "rectangle",
- "fill": {
- "type": "solid",
- "color": "#000000"
- }
- },
- {
- "id": "layer-main-text",
- "name": "Main Text",
- "type": "text",
- "startTime": 0,
- "duration": 4,
- "transform": {
- "position": { "x": 540, "y": 960 },
- "scale": { "x": 1, "y": 1 },
- "rotation": 0,
- "opacity": 1,
- "anchorPoint": { "x": 0.5, "y": 0.5 }
- },
- "visible": true,
- "locked": false,
- "keyframes": [
- {
- "property": "transform.position.y",
- "keyframes": [
- { "time": 0, "value": 1060, "ease": "ease-out-cubic" },
- { "time": 0.6, "value": 960, "ease": "ease-out-cubic" }
- ]
- },
- {
- "property": "transform.opacity",
- "keyframes": [
- { "time": 0, "value": 0, "ease": "ease-out" },
- { "time": 0.3, "value": 1, "ease": "ease-out" }
- ]
- },
- {
- "property": "transform.scale.x",
- "keyframes": [
- { "time": 0, "value": 0.9, "ease": "ease-out-back" },
- { "time": 0.6, "value": 1, "ease": "ease-out-back" }
- ]
- },
- {
- "property": "transform.scale.y",
- "keyframes": [
- { "time": 0, "value": 0.9, "ease": "ease-out-back" },
- { "time": 0.6, "value": 1, "ease": "ease-out-back" }
- ]
- }
- ],
- "content": "YOUR TEXT HERE",
- "style": {
- "fontFamily": "Geist",
- "fontSize": 96,
- "fontWeight": 800,
- "fontStyle": "normal",
- "color": "#ffffff",
- "textAlign": "center",
- "lineHeight": 1.1,
- "letterSpacing": -2,
- "textTransform": "uppercase"
- },
- "maxWidth": 900,
- "autoSize": false
- },
- {
- "id": "layer-subtitle-text",
- "name": "Subtitle Text",
- "type": "text",
- "startTime": 0,
- "duration": 4,
- "transform": {
- "position": { "x": 540, "y": 1120 },
- "scale": { "x": 1, "y": 1 },
- "rotation": 0,
- "opacity": 1,
- "anchorPoint": { "x": 0.5, "y": 0.5 }
- },
- "visible": true,
- "locked": false,
- "keyframes": [
- {
- "property": "transform.position.y",
- "keyframes": [
- { "time": 0.3, "value": 1220, "ease": "ease-out-cubic" },
- { "time": 0.9, "value": 1120, "ease": "ease-out-cubic" }
- ]
- },
- {
- "property": "transform.opacity",
- "keyframes": [
- { "time": 0.3, "value": 0, "ease": "ease-out" },
- { "time": 0.6, "value": 1, "ease": "ease-out" }
- ]
- }
- ],
- "content": "Tap to learn more",
- "style": {
- "fontFamily": "Geist",
- "fontSize": 36,
- "fontWeight": 500,
- "fontStyle": "normal",
- "color": "#ffffff",
- "textAlign": "center",
- "lineHeight": 1.4,
- "letterSpacing": 0
- },
- "autoSize": true
- },
- {
- "id": "layer-accent-shape",
- "name": "Accent Shape",
- "type": "shape",
- "startTime": 0,
- "duration": 4,
- "transform": {
- "position": { "x": 540, "y": 860 },
- "scale": { "x": 1, "y": 1 },
- "rotation": 0,
- "opacity": 1,
- "anchorPoint": { "x": 0.5, "y": 0.5 }
- },
- "visible": true,
- "locked": false,
- "keyframes": [
- {
- "property": "transform.scale.x",
- "keyframes": [
- { "time": 0, "value": 0, "ease": "ease-out-cubic" },
- { "time": 0.5, "value": 1, "ease": "ease-out-cubic" }
- ]
- },
- {
- "property": "transform.opacity",
- "keyframes": [
- { "time": 0, "value": 0, "ease": "ease-out" },
- { "time": 0.3, "value": 1, "ease": "ease-out" }
- ]
- }
- ],
- "shapeType": "rectangle",
- "fill": {
- "type": "solid",
- "color": "#ff0050"
- }
- }
- ]
- },
- "variables": [
- {
- "name": "mainText",
- "type": "text",
- "label": "Main Text",
- "defaultValue": "YOUR TEXT HERE",
- "targetLayerIds": ["layer-main-text"],
- "targetProperty": "content"
- },
- {
- "name": "subtitleText",
- "type": "text",
- "label": "Subtitle Text",
- "defaultValue": "Tap to learn more",
- "targetLayerIds": ["layer-subtitle-text"],
- "targetProperty": "content"
- },
- {
- "name": "accentColor",
- "type": "color",
- "label": "Accent Color",
- "defaultValue": "#ff0050",
- "targetLayerIds": ["layer-accent-shape"],
- "targetProperty": "fill.color"
- },
- {
- "name": "textColor",
- "type": "color",
- "label": "Text Color",
- "defaultValue": "#ffffff",
- "targetLayerIds": ["layer-main-text", "layer-subtitle-text"],
- "targetProperty": "style.color"
- }
- ],
- "createdAt": 1704067200000,
- "version": "1.0.0",
- "author": "OpenReel"
-}
diff --git a/packages/core/src/templates/template-presets/youtube-intro.json b/packages/core/src/templates/template-presets/youtube-intro.json
deleted file mode 100644
index cab04f1b..00000000
--- a/packages/core/src/templates/template-presets/youtube-intro.json
+++ /dev/null
@@ -1,230 +0,0 @@
-{
- "id": "youtube-intro-01",
- "name": "YouTube Intro - Modern",
- "description": "A clean and modern YouTube intro with animated title and logo",
- "category": "logo",
- "tags": ["youtube", "intro", "logo", "modern", "clean"],
- "thumbnailUrl": "/templates/thumbnails/youtube-intro-01.png",
- "composition": {
- "id": "comp-youtube-intro-01",
- "name": "YouTube Intro",
- "width": 1920,
- "height": 1080,
- "frameRate": 30,
- "duration": 5,
- "backgroundColor": "#1a1a1a",
- "layers": [
- {
- "id": "layer-bg",
- "name": "Background",
- "type": "shape",
- "startTime": 0,
- "duration": 5,
- "transform": {
- "position": { "x": 960, "y": 540 },
- "scale": { "x": 1, "y": 1 },
- "rotation": 0,
- "opacity": 1,
- "anchorPoint": { "x": 0.5, "y": 0.5 }
- },
- "visible": true,
- "locked": false,
- "keyframes": [],
- "shapeType": "rectangle",
- "fill": {
- "type": "gradient",
- "gradient": {
- "type": "linear",
- "stops": [
- { "offset": 0, "color": "#667eea" },
- { "offset": 1, "color": "#764ba2" }
- ],
- "start": { "x": 0, "y": 0 },
- "end": { "x": 1920, "y": 1080 }
- }
- }
- },
- {
- "id": "layer-logo",
- "name": "Logo Shape",
- "type": "shape",
- "startTime": 0,
- "duration": 5,
- "transform": {
- "position": { "x": 960, "y": 450 },
- "scale": { "x": 1, "y": 1 },
- "rotation": 0,
- "opacity": 1,
- "anchorPoint": { "x": 0.5, "y": 0.5 }
- },
- "visible": true,
- "locked": false,
- "keyframes": [
- {
- "property": "transform.opacity",
- "keyframes": [
- { "time": 0, "value": 0, "ease": "ease-out" },
- { "time": 0.5, "value": 1, "ease": "ease-out" }
- ]
- },
- {
- "property": "transform.scale.x",
- "keyframes": [
- { "time": 0, "value": 0.5, "ease": "ease-out-back" },
- { "time": 0.5, "value": 1, "ease": "ease-out-back" }
- ]
- },
- {
- "property": "transform.scale.y",
- "keyframes": [
- { "time": 0, "value": 0.5, "ease": "ease-out-back" },
- { "time": 0.5, "value": 1, "ease": "ease-out-back" }
- ]
- }
- ],
- "shapeType": "circle",
- "fill": {
- "type": "solid",
- "color": "#8b5cf6"
- },
- "stroke": {
- "color": "#ffffff",
- "width": 8
- }
- },
- {
- "id": "layer-title",
- "name": "Title",
- "type": "text",
- "startTime": 0,
- "duration": 5,
- "transform": {
- "position": { "x": 960, "y": 540 },
- "scale": { "x": 1, "y": 1 },
- "rotation": 0,
- "opacity": 1,
- "anchorPoint": { "x": 0.5, "y": 0.5 }
- },
- "visible": true,
- "locked": false,
- "keyframes": [
- {
- "property": "transform.opacity",
- "keyframes": [
- { "time": 0.8, "value": 0, "ease": "ease-out" },
- { "time": 1.5, "value": 1, "ease": "ease-out" }
- ]
- },
- {
- "property": "transform.position.y",
- "keyframes": [
- { "time": 0.8, "value": 580, "ease": "ease-out-cubic" },
- { "time": 1.5, "value": 540, "ease": "ease-out-cubic" }
- ]
- }
- ],
- "content": "YOUR CHANNEL NAME",
- "style": {
- "fontFamily": "Geist",
- "fontSize": 72,
- "fontWeight": 700,
- "fontStyle": "normal",
- "color": "#ffffff",
- "textAlign": "center",
- "lineHeight": 1.2,
- "letterSpacing": -1
- },
- "autoSize": true
- },
- {
- "id": "layer-subtitle",
- "name": "Subtitle",
- "type": "text",
- "startTime": 0,
- "duration": 5,
- "transform": {
- "position": { "x": 960, "y": 620 },
- "scale": { "x": 1, "y": 1 },
- "rotation": 0,
- "opacity": 1,
- "anchorPoint": { "x": 0.5, "y": 0.5 }
- },
- "visible": true,
- "locked": false,
- "keyframes": [
- {
- "property": "transform.opacity",
- "keyframes": [
- { "time": 1.3, "value": 0, "ease": "ease-out" },
- { "time": 2, "value": 1, "ease": "ease-out" }
- ]
- },
- {
- "property": "transform.position.y",
- "keyframes": [
- { "time": 1.3, "value": 660, "ease": "ease-out-cubic" },
- { "time": 2, "value": 620, "ease": "ease-out-cubic" }
- ]
- }
- ],
- "content": "Subscribe for More Content",
- "style": {
- "fontFamily": "Geist",
- "fontSize": 32,
- "fontWeight": 400,
- "fontStyle": "normal",
- "color": "#e0e0e0",
- "textAlign": "center",
- "lineHeight": 1.4,
- "letterSpacing": 0
- },
- "autoSize": true
- }
- ]
- },
- "variables": [
- {
- "name": "channelName",
- "type": "text",
- "label": "Channel Name",
- "defaultValue": "YOUR CHANNEL NAME",
- "targetLayerIds": ["layer-title"],
- "targetProperty": "content"
- },
- {
- "name": "subtitle",
- "type": "text",
- "label": "Subtitle",
- "defaultValue": "Subscribe for More Content",
- "targetLayerIds": ["layer-subtitle"],
- "targetProperty": "content"
- },
- {
- "name": "logoColor",
- "type": "color",
- "label": "Logo Color",
- "defaultValue": "#8b5cf6",
- "targetLayerIds": ["layer-logo"],
- "targetProperty": "fill.color"
- },
- {
- "name": "backgroundColor1",
- "type": "color",
- "label": "Background Color (Start)",
- "defaultValue": "#667eea",
- "targetLayerIds": ["layer-bg"],
- "targetProperty": "fill.gradient.stops.0.color"
- },
- {
- "name": "backgroundColor2",
- "type": "color",
- "label": "Background Color (End)",
- "defaultValue": "#764ba2",
- "targetLayerIds": ["layer-bg"],
- "targetProperty": "fill.gradient.stops.1.color"
- }
- ],
- "createdAt": 1704067200000,
- "version": "1.0.0",
- "author": "OpenReel"
-}
diff --git a/packages/core/src/video/gpu-device-manager.ts b/packages/core/src/video/gpu-device-manager.ts
deleted file mode 100644
index 8fbb0aeb..00000000
--- a/packages/core/src/video/gpu-device-manager.ts
+++ /dev/null
@@ -1,309 +0,0 @@
-export interface GPUDeviceOptions {
- powerPreference?: "low-power" | "high-performance";
- requiredFeatures?: GPUFeatureName[];
- requiredLimits?: Record<string, number>;
- maxTextureDimension?: number;
- onDeviceLost?: (reason: string, message: string) => void;
- onDeviceRecovered?: () => void;
- maxRecreationAttempts?: number;
- recreationDelayMs?: number;
-}
-
-export type DeviceState =
- | "uninitialized"
- | "initializing"
- | "ready"
- | "lost"
- | "recovering"
- | "failed";
-
-export interface ShaderCompilationResult {
- success: boolean;
- module: GPUShaderModule | null;
- errors: string[];
- warnings: string[];
-}
-
-export class GPUDeviceManager {
- private adapter: GPUAdapter | null = null;
- private device: GPUDevice | null = null;
- private options: Required<GPUDeviceOptions>;
- private state: DeviceState = "uninitialized";
- private _recreationAttempts = 0;
- private deviceLostCallbacks: Array<
- (reason: string, message: string) => void
- > = [];
- private deviceRecoveredCallbacks: Array<() => void> = [];
-
- constructor(options: GPUDeviceOptions = {}) {
- this.options = {
- powerPreference: options.powerPreference ?? "high-performance",
- requiredFeatures: options.requiredFeatures ?? [],
- requiredLimits: options.requiredLimits ?? {},
- maxTextureDimension: options.maxTextureDimension ?? 4096,
- onDeviceLost: options.onDeviceLost ?? (() => {}),
- onDeviceRecovered: options.onDeviceRecovered ?? (() => {}),
- maxRecreationAttempts: options.maxRecreationAttempts ?? 3,
- recreationDelayMs: options.recreationDelayMs ?? 1000,
- };
- }
-
- static isSupported(): boolean {
- return (
- typeof navigator !== "undefined" &&
- "gpu" in navigator &&
- navigator.gpu !== undefined
- );
- }
-
- async initialize(): Promise<boolean> {
- if (this.state === "ready") {
- return true;
- }
-
- if (!GPUDeviceManager.isSupported()) {
- console.warn("[GPUDeviceManager] WebGPU not supported");
- this.state = "failed";
- return false;
- }
-
- this.state = "initializing";
-
- try {
- // Request adapter with specified power preference
- this.adapter = await navigator.gpu.requestAdapter({
- powerPreference: this.options.powerPreference,
- });
-
- if (!this.adapter) {
- console.warn("[GPUDeviceManager] No GPU adapter available");
- this.state = "failed";
- return false;
- }
- const requiredLimits: Record<string, number> = {
- maxTextureDimension2D: this.options.maxTextureDimension,
- maxBindGroups: 4,
- maxSampledTexturesPerShaderStage: 16,
- ...this.options.requiredLimits,
- };
-
- // Request device with required features and limits
- this.device = await this.adapter.requestDevice({
- requiredFeatures: this.options.requiredFeatures,
- requiredLimits,
- });
- this.setupDeviceLossHandling();
-
- this.state = "ready";
- this._recreationAttempts = 0;
-
- return true;
- } catch (error) {
- console.error("[GPUDeviceManager] Initialization failed:", error);
- this.state = "failed";
- return false;
- }
- }
-
- private setupDeviceLossHandling(): void {
- if (!this.device) return;
-
- this.device.lost.then((info: GPUDeviceLostInfo) => {
- console.warn(
- `[GPUDeviceManager] Device lost: ${info.reason}`,
- info.message,
- );
- this.state = "lost";
-
- this.options.onDeviceLost(info.reason, info.message);
- for (const callback of this.deviceLostCallbacks) {
- callback(info.reason, info.message);
- }
-
- this.attemptRecovery().catch((error) => {
- console.error("[GPUDeviceManager] Recovery failed:", error);
- this.state = "failed";
- });
- });
- }
-
- private async attemptRecovery(): Promise<void> {
- if (this.state === "recovering") {
- return;
- }
-
- this.state = "recovering";
-
- for (
- let attempt = 1;
- attempt <= this.options.maxRecreationAttempts;
- attempt++
- ) {
- this._recreationAttempts = attempt;
-
- // Wait before attempting
- await new Promise((resolve) =>
- setTimeout(resolve, this.options.recreationDelayMs),
- );
-
- // Clean up old resources
- this.cleanup();
- const success = await this.initialize();
- if (success) {
- this.options.onDeviceRecovered();
- for (const callback of this.deviceRecoveredCallbacks) {
- callback();
- }
- return;
- }
- }
-
- console.error(
- `[GPUDeviceManager] Failed to recover device after ${this.options.maxRecreationAttempts} attempts`,
- );
- this.state = "failed";
- }
-
- async compileShader(
- code: string,
- label?: string,
- ): Promise<ShaderCompilationResult> {
- if (!this.device || this.state !== "ready") {
- return {
- success: false,
- module: null,
- errors: ["Device not ready"],
- warnings: [],
- };
- }
-
- try {
- const module = this.device.createShaderModule({
- code,
- label,
- });
- // We return the module and let pipeline creation handle validation
-
- return {
- success: true,
- module,
- errors: [],
- warnings: [],
- };
- } catch (error) {
- const errorMessage =
- error instanceof Error ? error.message : String(error);
- console.error(
- `[GPUDeviceManager] Shader compilation failed: ${errorMessage}`,
- );
-
- return {
- success: false,
- module: null,
- errors: [errorMessage],
- warnings: [],
- };
- }
- }
-
- createTexture(
- descriptor: GPUTextureDescriptor,
- onMemoryExhausted?: () => void,
- ): GPUTexture | null {
- if (!this.device || this.state !== "ready") {
- return null;
- }
-
- try {
- return this.device.createTexture(descriptor);
- } catch (error) {
- const errorMessage =
- error instanceof Error ? error.message : String(error);
- if (
- errorMessage.includes("out of memory") ||
- errorMessage.includes("allocation failed") ||
- errorMessage.includes("memory")
- ) {
- console.warn(
- "[GPUDeviceManager] GPU memory exhausted, triggering cleanup",
- );
-
- // Notify caller to release unused textures
- if (onMemoryExhausted) {
- onMemoryExhausted();
- }
-
- // Retry texture creation after cleanup
- try {
- return this.device.createTexture(descriptor);
- } catch (retryError) {
- console.error(
- "[GPUDeviceManager] Texture creation failed after cleanup:",
- retryError,
- );
- return null;
- }
- }
-
- console.error("[GPUDeviceManager] Texture creation failed:", error);
- return null;
- }
- }
-
- onDeviceLost(callback: (reason: string, message: string) => void): void {
- this.deviceLostCallbacks.push(callback);
- }
-
- onDeviceRecovered(callback: () => void): void {
- this.deviceRecoveredCallbacks.push(callback);
- }
-
- getState(): DeviceState {
- return this.state;
- }
-
- getDevice(): GPUDevice | null {
- return this.device;
- }
-
- getAdapter(): GPUAdapter | null {
- return this.adapter;
- }
-
- isReady(): boolean {
- return this.state === "ready" && this.device !== null;
- }
-
- getRecreationAttempts(): number {
- return this._recreationAttempts;
- }
-
- cleanup(): void {
- if (this.device) {
- this.device.destroy();
- this.device = null;
- }
- this.adapter = null;
- }
-
- destroy(): void {
- this.cleanup();
- this.deviceLostCallbacks = [];
- this.deviceRecoveredCallbacks = [];
- this.state = "uninitialized";
- }
-}
-
-export async function createGPUDeviceManager(
- options?: GPUDeviceOptions,
-): Promise<GPUDeviceManager | null> {
- const manager = new GPUDeviceManager(options);
- const success = await manager.initialize();
-
- if (!success) {
- manager.destroy();
- return null;
- }
-
- return manager;
-}
diff --git a/packages/core/src/video/texture-manager.ts b/packages/core/src/video/texture-manager.ts
deleted file mode 100644
index 9a4bc26f..00000000
--- a/packages/core/src/video/texture-manager.ts
+++ /dev/null
@@ -1,179 +0,0 @@
-import {
- TextureCache,
- calculateTextureSize,
- type CachedTexture,
-} from "./texture-cache";
-
-export interface TextureManagerConfig {
- device: GPUDevice;
- maxCacheSize?: number;
- cleanupDelayMs?: number;
- onTextureCreated?: (clipId: string, frameTime: number, size: number) => void;
- onTextureReleased?: (clipId: string, frameTime: number) => void;
-}
-
-interface PendingCleanup {
- clipId: string;
- timeoutId: ReturnType<typeof setTimeout>;
- scheduledAt: number;
-}
-
-const DEFAULT_CLEANUP_DELAY_MS = 5000;
-
-export class TextureManager {
- private device: GPUDevice;
- private cache: TextureCache;
- private cleanupDelayMs: number;
- private pendingCleanups: Map<string, PendingCleanup> = new Map();
- private onTextureCreated?: (
- clipId: string,
- frameTime: number,
- size: number,
- ) => void;
- private onTextureReleased?: (clipId: string, frameTime: number) => void;
-
- constructor(config: TextureManagerConfig) {
- this.device = config.device;
- this.cleanupDelayMs = config.cleanupDelayMs ?? DEFAULT_CLEANUP_DELAY_MS;
- this.onTextureCreated = config.onTextureCreated;
- this.onTextureReleased = config.onTextureReleased;
-
- this.cache = new TextureCache({
- maxSize: config.maxCacheSize,
- onEvict: (entry: CachedTexture) => {
- if (this.onTextureReleased) {
- this.onTextureReleased(entry.clipId, entry.frameTime);
- }
- },
- });
- }
-
- createTextureFromImage(
- image: ImageBitmap,
- clipId: string,
- frameTime: number,
- ): GPUTexture {
- const cached = this.cache.get(clipId, frameTime);
- if (cached) {
- // Cancel any pending cleanup for this clip
- this.cancelPendingCleanup(clipId);
- return cached;
- }
- const texture = this.device.createTexture({
- size: { width: image.width, height: image.height },
- format: "rgba8unorm",
- usage:
- GPUTextureUsage.TEXTURE_BINDING |
- GPUTextureUsage.COPY_DST |
- GPUTextureUsage.RENDER_ATTACHMENT,
- label: `texture-${clipId}-${frameTime}`,
- });
-
- // Use copyExternalImageToTexture for zero-copy transfer
- this.device.queue.copyExternalImageToTexture(
- { source: image },
- { texture },
- { width: image.width, height: image.height },
- );
- const size = calculateTextureSize(image.width, image.height, "rgba8unorm");
- this.cache.set(clipId, frameTime, texture, size);
-
- // Cancel any pending cleanup for this clip
- this.cancelPendingCleanup(clipId);
-
- // Notify callback
- if (this.onTextureCreated) {
- this.onTextureCreated(clipId, frameTime, size);
- }
-
- return texture;
- }
-
- getTexture(clipId: string, frameTime: number): GPUTexture | null {
- const texture = this.cache.get(clipId, frameTime);
- if (texture) {
- // Cancel any pending cleanup for this clip
- this.cancelPendingCleanup(clipId);
- }
- return texture;
- }
-
- hasTexture(clipId: string, frameTime: number): boolean {
- return this.cache.has(clipId, frameTime);
- }
-
- scheduleCleanup(clipId: string): void {
- // Cancel any existing pending cleanup
- this.cancelPendingCleanup(clipId);
-
- // Schedule new cleanup
- const timeoutId = setTimeout(() => {
- this.executeCleanup(clipId);
- }, this.cleanupDelayMs);
-
- this.pendingCleanups.set(clipId, {
- clipId,
- timeoutId,
- scheduledAt: Date.now(),
- });
- }
-
- cancelPendingCleanup(clipId: string): void {
- const pending = this.pendingCleanups.get(clipId);
- if (pending) {
- clearTimeout(pending.timeoutId);
- this.pendingCleanups.delete(clipId);
- }
- }
-
- private executeCleanup(clipId: string): void {
- this.pendingCleanups.delete(clipId);
- this.cache.evict(clipId);
- }
-
- releaseClip(clipId: string): void {
- this.cancelPendingCleanup(clipId);
- this.cache.evict(clipId);
- }
-
- releaseTexture(_clipId: string, _frameTime: number): void {
- // so we just let LRU handle it
- }
-
- getMemoryUsage(): number {
- return this.cache.getMemoryUsage();
- }
-
- getCachedCount(): number {
- return this.cache.getCount();
- }
-
- getPendingCleanupCount(): number {
- return this.pendingCleanups.size;
- }
-
- hasPendingCleanup(clipId: string): boolean {
- return this.pendingCleanups.has(clipId);
- }
-
- getCleanupDelayMs(): number {
- return this.cleanupDelayMs;
- }
-
- clear(): void {
- // Cancel all pending cleanups
- for (const pending of this.pendingCleanups.values()) {
- clearTimeout(pending.timeoutId);
- }
- this.pendingCleanups.clear();
- this.cache.clear();
- }
-
- destroy(): void {
- this.clear();
- }
-
- getCache(): TextureCache {
- return this.cache;
- }
-}