Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions packages/studio/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dist/
node_modules/
data/projects/
12 changes: 9 additions & 3 deletions packages/studio/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hyperframes/studio",
"version": "0.1.2",
"version": "0.1.3",
"files": [
"src",
"dist"
Expand All @@ -15,7 +15,9 @@
"scripts": {
"dev": "vite",
"build": "vite build",
"typecheck": "tsc --noEmit"
"typecheck": "tsc --noEmit",
"test": "vitest run",
"test:watch": "vitest"
},
"dependencies": {
"@codemirror/autocomplete": "^6.20.1",
Expand All @@ -30,6 +32,7 @@
"@codemirror/view": "^6.40.0",
"@hyperframes/core": "workspace:*",
"@phosphor-icons/react": "^2.1.10",
"@use-gesture/react": "^10.3.1",
"codemirror": "^6.0.1"
},
"devDependencies": {
Expand All @@ -38,9 +41,12 @@
"@vitejs/plugin-react": "^4.0.0",
"autoprefixer": "^10.4.0",
"postcss": "^8.4.0",
"puppeteer-core": "^24.40.0",
"tailwindcss": "^3.4.0",
"typescript": "^5.0.0",
"vite": "^5.0.0"
"vite": "^5.0.0",
"vitest": "^3.2.4",
"zustand": "^5.0.0"
},
"peerDependencies": {
"react": "^18.0.0 || ^19.0.0",
Expand Down
96 changes: 87 additions & 9 deletions packages/studio/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import { useState, useCallback, useRef, useEffect } from "react";
import { useState, useCallback, useRef, useEffect, type ReactNode } from "react";
import { NLELayout } from "./components/nle/NLELayout";
import { SourceEditor } from "./components/editor/SourceEditor";
import { FileTree } from "./components/editor/FileTree";
import { CompositionThumbnail } from "./player/components/CompositionThumbnail";
import { TimelineToolbar } from "./components/timeline/TimelineToolbar";
import { usePlayerStore } from "./player/store/playerStore";

Check failure on line 7 in packages/studio/src/App.tsx

View workflow job for this annotation

GitHub Actions / Lint

eslint(no-unused-vars)

Identifier 'usePlayerStore' is imported but never used.
import { EditModal } from "./components/timeline/EditModal";
import { VideoThumbnail } from "./player/components/VideoThumbnail";
import type { TimelineElement } from "./player/store/playerStore";
import {
XIcon,
CodeIcon,
Expand Down Expand Up @@ -98,8 +104,8 @@
<WarningIcon size={18} className="text-red-400" weight="fill" />
</div>
) : (
<div className="w-8 h-8 rounded-full bg-green-500/10 flex items-center justify-center">
<CheckCircleIcon size={18} className="text-green-400" weight="fill" />
<div className="w-8 h-8 rounded-full bg-[#3CE6AC]/10 flex items-center justify-center">
<CheckCircleIcon size={18} className="text-[#3CE6AC]" weight="fill" />
</div>
)}
<div>
Expand Down Expand Up @@ -139,8 +145,8 @@
{f.file && <p className="text-xs text-neutral-600 font-mono mt-0.5">{f.file}</p>}
{f.fixHint && (
<div className="flex items-start gap-1 mt-1.5">
<CaretRightIcon size={10} className="text-blue-400 flex-shrink-0 mt-0.5" />
<p className="text-xs text-blue-400">{f.fixHint}</p>
<CaretRightIcon size={10} className="text-[#3CE6AC] flex-shrink-0 mt-0.5" />
<p className="text-xs text-[#3CE6AC]">{f.fixHint}</p>
</div>
)}
</div>
Expand All @@ -156,8 +162,8 @@
{f.file && <p className="text-xs text-neutral-600 font-mono mt-0.5">{f.file}</p>}
{f.fixHint && (
<div className="flex items-start gap-1 mt-1.5">
<CaretRightIcon size={10} className="text-blue-400 flex-shrink-0 mt-0.5" />
<p className="text-xs text-blue-400">{f.fixHint}</p>
<CaretRightIcon size={10} className="text-[#3CE6AC] flex-shrink-0 mt-0.5" />
<p className="text-xs text-[#3CE6AC]">{f.fixHint}</p>
</div>
)}
</div>
Expand Down Expand Up @@ -202,7 +208,69 @@
const [editingFile, setEditingFile] = useState<EditingFile | null>(null);
const [sidebarOpen, setSidebarOpen] = useState(false);
const [fileTree, setFileTree] = useState<string[]>([]);
const [compIdToSrc, setCompIdToSrc] = useState<Map<string, string>>(new Map());

const renderClipContent = useCallback(
(el: TimelineElement, style: { clip: string; label: string }): ReactNode => {
const pid = projectIdRef.current;
if (!pid) return null;

// Resolve composition source path using the compIdToSrc map
let compSrc = el.compositionSrc;
if (compSrc && compIdToSrc.size > 0) {
const resolved =
compIdToSrc.get(el.id) ||
compIdToSrc.get(compSrc.replace(/^compositions\//, "").replace(/\.html$/, ""));
if (resolved) compSrc = resolved;
}

if (compSrc) {
const previewUrl = `/api/projects/${pid}/preview/comp/${compSrc}`;
return (
<CompositionThumbnail
previewUrl={previewUrl}
label={el.id || el.tag}
labelColor={style.label}
seekTime={el.start}
duration={el.duration}
/>
);
}

if ((el.tag === "video" || el.tag === "img") && el.src) {
const mediaSrc = el.src.startsWith("http")
? el.src
: `/api/projects/${pid}/preview/${el.src}`;
return (
<VideoThumbnail
videoSrc={mediaSrc}
label={el.id || el.tag}
labelColor={style.label}
duration={el.duration}
/>
);
}

// HTML scene divs — render from index.html at the scene's time
if (el.tag === "div" && el.duration > 0) {
const previewUrl = `/api/projects/${pid}/preview`;
return (
<CompositionThumbnail
previewUrl={previewUrl}
label={el.id || el.tag}
labelColor={style.label}
seekTime={el.start}
duration={el.duration}
/>
);
}

return null;
},
[compIdToSrc],
);
const [lintModal, setLintModal] = useState<LintFinding[] | null>(null);
const [editModalOpen, setEditModalOpen] = useState(false);
const [linting, setLinting] = useState(false);
const [refreshKey, setRefreshKey] = useState(0);
const [renderState, setRenderState] = useState<"idle" | "rendering" | "complete" | "error">(
Expand All @@ -212,6 +280,7 @@
const [_renderError, setRenderError] = useState<string | null>(null);
const refreshTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
const projectIdRef = useRef(projectId);
const previewIframeRef = useRef<HTMLIFrameElement | null>(null);

// Listen for external file changes (user editing HTML outside the editor)
useEffect(() => {
Expand Down Expand Up @@ -458,6 +527,12 @@
activeCompositionPath={
editingFile?.path?.startsWith("compositions/") ? editingFile.path : null
}
renderClipContent={renderClipContent}
onCompIdToSrcChange={setCompIdToSrc}
onIframeRef={(iframe) => {
previewIframeRef.current = iframe;
}}
timelineToolbar={<TimelineToolbar onEdit={() => setEditModalOpen(true)} />}
/>
</div>

Expand All @@ -481,7 +556,7 @@
<button
onClick={handleRender}
disabled={renderState === "rendering"}
className="h-8 px-3 rounded-lg bg-blue-600 border border-blue-500 text-xs font-semibold text-white hover:bg-blue-500 transition-colors disabled:opacity-60 tabular-nums"
className="h-8 px-3 rounded-lg text-xs font-semibold text-[#09090B] bg-gradient-to-br from-[#3CE6AC] to-[#2BBFA0] hover:brightness-110 active:scale-[0.97] transition-colors disabled:opacity-60 tabular-nums"
>
{renderState === "rendering"
? `${Math.round(renderProgress)}%`
Expand Down Expand Up @@ -510,7 +585,7 @@
<button
onClick={handleRender}
disabled={renderState === "rendering"}
className="px-2 py-1 rounded text-[11px] font-semibold text-blue-400 hover:text-blue-300 transition-colors disabled:opacity-60 tabular-nums"
className="px-2 py-1 rounded text-[11px] font-semibold text-[#3CE6AC] hover:text-[#5EEFC0] transition-colors disabled:opacity-60 tabular-nums"
>
{renderState === "rendering" ? `${Math.round(renderProgress)}%` : "Export MP4"}
</button>
Expand Down Expand Up @@ -552,6 +627,9 @@

{/* Lint modal */}
{lintModal !== null && <LintModal findings={lintModal} onClose={() => setLintModal(null)} />}

{/* Edit modal */}
{editModalOpen && <EditModal onClose={() => setEditModalOpen(false)} />}
</div>
);
}
4 changes: 3 additions & 1 deletion packages/studio/src/components/editor/SourceEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ function getLanguageExtension(language: string) {
case "js":
case "typescript":
case "ts":
return javascript({ typescript: language === "typescript" || language === "ts" });
return javascript({
typescript: language === "typescript" || language === "ts",
});
default:
return html();
}
Expand Down
Loading
Loading