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

Function attachStudioReadyHandler

packages/cli/src/commands/preview.ts:718–744  ·  view source on GitHub ↗
(
  child: StudioChildProcess,
  spinner: ReturnType<typeof clack.spinner>,
  projectName: string,
  options?: BrowserLaunchOptions,
)

Source from the content-addressed store, hash-verified

716}
717
718function attachStudioReadyHandler(
719 child: StudioChildProcess,
720 spinner: ReturnType<typeof clack.spinner>,
721 projectName: string,
722 options?: BrowserLaunchOptions,
723): void {
724 let detected = false;
725
726 function handleOutput(data: Buffer): void {
727 const url = data.toString().match(/Local:\s+(http:\/\/localhost:\d+)/)?.[1];
728 if (!url || detected) return;
729
730 detected = true;
731 spinner.stop(c.success("Studio running"));
732 printStudioSummary(projectName, url, { footer: "Press Ctrl+C to stop" });
733 openStudioBrowser(url, projectName, options);
734 child.stdout.removeListener("data", handleOutput);
735 child.stderr.removeListener("data", handleOutput);
736 }
737
738 child.stdout.on("data", handleOutput);
739 child.stderr.on("data", handleOutput);
740 child.on("error", (err) => {
741 spinner.stop(c.error("Failed to start studio"));
742 console.error(c.dim(err.message));
743 });
744}
745
746/**
747 * Dev mode: spawn the studio dev server from the monorepo.

Callers 2

runDevModeFunction · 0.85
runLocalStudioModeFunction · 0.85

Calls 3

errorMethod · 0.80
onMethod · 0.65
stopMethod · 0.45

Tested by

no test coverage detected