MCPcopy Create free account
hub / github.com/heygen-com/hyperframes / runLocalStudioMode

Function runLocalStudioMode

packages/cli/src/commands/preview.ts:801–826  ·  view source on GitHub ↗

* Local studio mode: spawn Vite using a locally installed @hyperframes/studio. * Provides full Vite HMR and the complete studio experience.

(dir: string, options?: StudioLaunchOptions)

Source from the content-addressed store, hash-verified

799 * Provides full Vite HMR and the complete studio experience.
800 */
801async function runLocalStudioMode(dir: string, options?: StudioLaunchOptions): Promise<void> {
802 const req = createRequire(join(dir, "package.json"));
803 const studioPkgPath = dirname(req.resolve("@hyperframes/studio/package.json"));
804 const pName = options?.projectName ?? basename(dir);
805
806 // Symlink project into studio's data directory
807 const projectsDir = join(studioPkgPath, "data", "projects");
808 const { symlinkPath, createdSymlink } = linkProjectIntoStudioData(dir, projectsDir, pName);
809
810 clack.intro(c.bold("hyperframes preview") + c.dim(" (local studio)"));
811 const s = clack.spinner();
812 s.start("Starting studio...");
813
814 const viteCommand = buildNpxCommand(["vite"]);
815 const child = spawn(viteCommand.command, viteCommand.args, {
816 cwd: studioPkgPath,
817 stdio: ["ignore", "pipe", "pipe"],
818 });
819
820 attachStudioReadyHandler(child, s, pName, options);
821 removeSymlinkOnExit(createdSymlink, symlinkPath);
822
823 // Same tree-kill handler as dev mode. No-op on Windows (see comment above).
824 registerChildTreeShutdown(child);
825 return waitForChildClose(child);
826}
827
828/**
829 * Embedded mode: serve the pre-built studio SPA with a standalone Hono server.

Callers 1

runFunction · 0.85

Calls 9

basenameFunction · 0.85
buildNpxCommandFunction · 0.85
attachStudioReadyHandlerFunction · 0.85
removeSymlinkOnExitFunction · 0.85
waitForChildCloseFunction · 0.85
spawnFunction · 0.50
startMethod · 0.45

Tested by

no test coverage detected