forked from heygen-com/hyperframes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.studioMotion.ts
More file actions
47 lines (42 loc) · 1.55 KB
/
Copy pathvite.studioMotion.ts
File metadata and controls
47 lines (42 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import { existsSync, readFileSync } from "node:fs";
import { join } from "node:path";
import {
createStudioManualEditsRenderBodyScript,
type StudioManualEditsRenderScriptOptions,
} from "../core/src/studio-api/helpers/manualEditsRenderScript";
import {
createStudioMotionRenderBodyScript,
STUDIO_MOTION_PATH,
} from "../core/src/studio-api/helpers/studioMotionRenderScript";
const STUDIO_MANUAL_EDITS_PATH = ".hyperframes/studio-manual-edits.json";
function readManifestContent(projectDir: string, manifestPath: string): string {
const resolvedPath = join(projectDir, manifestPath);
if (!existsSync(resolvedPath)) return "";
try {
return readFileSync(resolvedPath, "utf-8");
} catch {
return "";
}
}
export function readStudioDevManualEditManifestContent(projectDir: string): string {
return readManifestContent(projectDir, STUDIO_MANUAL_EDITS_PATH);
}
export function readStudioDevMotionManifestContent(projectDir: string): string {
return readManifestContent(projectDir, STUDIO_MOTION_PATH);
}
export function createStudioDevRenderBodyScripts(
projectDir: string,
options: StudioManualEditsRenderScriptOptions = {},
): string[] {
const manualEditsRenderScript = createStudioManualEditsRenderBodyScript(
readStudioDevManualEditManifestContent(projectDir),
options,
);
const motionRenderScript = createStudioMotionRenderBodyScript(
readStudioDevMotionManifestContent(projectDir),
options,
);
return [manualEditsRenderScript, motionRenderScript].filter(
(script): script is string => typeof script === "string",
);
}