fix(studio): split color grading inspector files

This commit is contained in:
ukimsanov
2026-07-06 13:56:37 -07:00
parent 139cf568b4
commit 30a944de34
13 changed files with 759 additions and 652 deletions
@@ -78,6 +78,24 @@ function shouldReloadForStudioFileChange(
return Date.now() - domEditSaveTimestampRef.current >= 4000;
}
// fallow-ignore-next-line complexity
async function clearLegacyStudioMotionFile(
readOptionalProjectFile: (path: string) => Promise<string>,
writeProjectFile: (path: string, content: string) => Promise<void>,
): Promise<void> {
const content = await readOptionalProjectFile(STUDIO_MOTION_PATH).catch(() => null);
if (!content) return;
try {
const parsed = JSON.parse(content) as { motions?: unknown[] };
if (!Array.isArray(parsed.motions) || parsed.motions.length === 0) return;
} catch {
return;
}
await writeProjectFile(STUDIO_MOTION_PATH, JSON.stringify({ version: 1, motions: [] })).catch(
() => {},
);
}
// ── Hook ──
export function usePreviewPersistence({
@@ -187,20 +205,7 @@ export function usePreviewPersistence({
// could still fire alongside the new seek-reapply runtime. Empty the file so
// the legacy codepath no-ops.
useMountEffect(() => {
_readOptionalProjectFile(STUDIO_MOTION_PATH)
.then((content) => {
if (!content) return;
try {
const parsed = JSON.parse(content) as { motions?: unknown[] };
if (!Array.isArray(parsed.motions) || parsed.motions.length === 0) return;
} catch {
return;
}
return _writeProjectFile(STUDIO_MOTION_PATH, JSON.stringify({ version: 1, motions: [] }));
})
.catch(() => {
/* best-effort migration — ignore failures */
});
void clearLegacyStudioMotionFile(_readOptionalProjectFile, _writeProjectFile);
});
// ── Listen for external file changes (HMR / SSE) ──
@@ -212,8 +217,10 @@ export function usePreviewPersistence({
pendingTimelineEditPathRef,
domEditSaveTimestampRef,
)
)
) {
// fallow-ignore-next-line code-duplication
reloadPreview();
}
};
if (import.meta.hot) {
import.meta.hot.on("hf:file-change", handler);