import { useCallback, type RefObject } from "react"; import { SourceEditor } from "./editor/SourceEditor"; import { LeftSidebar, type LeftSidebarHandle } from "./sidebar/LeftSidebar"; import { MediaPreview } from "./MediaPreview"; import { isMediaFile } from "../utils/mediaTypes"; import { usePanelLayoutContext } from "../contexts/PanelLayoutContext"; import { useStudioShellContext } from "../contexts/StudioContext"; import { useFileManagerContext } from "../contexts/FileManagerContext"; import { getPersistedRenderSettings } from "./renders/renderSettings"; import type { BlockPreviewInfo } from "./sidebar/BlocksTab"; export interface StudioLeftSidebarProps { leftSidebarRef: RefObject; onSelectComposition: (comp: string) => void; onAddBlock: (blockName: string) => void; onPreviewBlock?: (preview: BlockPreviewInfo | null) => void; onLint: () => void; linting: boolean; lintFindingCount?: number; lintFindingsByFile?: Map; } // fallow-ignore-next-line complexity export function StudioLeftSidebar({ leftSidebarRef, onSelectComposition, onAddBlock, onPreviewBlock, onLint, linting, lintFindingCount, lintFindingsByFile, }: StudioLeftSidebarProps) { const { leftCollapsed, leftWidth, toggleLeftSidebar, handlePanelResizeStart, handlePanelResizeMove, handlePanelResizeEnd, } = usePanelLayoutContext(); const { projectId, renderQueue, waitForPendingDomEditSaves } = useStudioShellContext(); const { compositions, assets, editingFile, fileTree, revealSourceOffset, handleFileSelect, handleCreateFile, handleCreateFolder, handleDeleteFile, handleRenameFile, handleDuplicateFile, handleMoveFile, handleImportFiles, handleContentChange, } = useFileManagerContext(); const handleRenderComposition = useCallback( async (comp: string) => { await waitForPendingDomEditSaves(); const { format, quality, fps } = getPersistedRenderSettings(); await renderQueue.startRender({ composition: comp, format, quality, fps }); }, [renderQueue, waitForPendingDomEditSaves], ); if (leftCollapsed) { return (
); } return ( <> ) : ( ) ) : undefined } onRenderComposition={handleRenderComposition} isRendering={renderQueue.isRendering} onLint={onLint} linting={linting} lintFindingCount={lintFindingCount} lintFindingsByFile={lintFindingsByFile} onToggleCollapse={toggleLeftSidebar} onAddBlock={onAddBlock} onPreviewBlock={onPreviewBlock} />
handlePanelResizeStart("left", e)} onPointerMove={handlePanelResizeMove} onPointerUp={handlePanelResizeEnd} >
); }