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

Function run

packages/cli/src/commands/present.ts:47–168  ·  view source on GitHub ↗
({ args })

Source from the content-addressed store, hash-verified

45 },
46 },
47 async run({ args }) {
48 const project = resolveProject(args.dir);
49 const startPort = parseInt(args.port ?? "3004", 10);
50
51 if (args["user-data-dir"] && !args["browser-path"]) {
52 clack.log.error("--user-data-dir requires --browser-path");
53 process.exitCode = 1;
54 return;
55 }
56 const depsError = validateRemoteDebuggingPortDeps({
57 browserPath: args["browser-path"] as string | undefined,
58 userDataDir: args["user-data-dir"] as string | undefined,
59 remoteDebuggingPort: args["remote-debugging-port"] as string | undefined,
60 });
61 if (depsError) {
62 clack.log.error(depsError);
63 process.exitCode = 1;
64 return;
65 }
66 let remoteDebuggingPort: number | undefined;
67 try {
68 remoteDebuggingPort = parseRemoteDebuggingPort(
69 args["remote-debugging-port"] as string | undefined,
70 );
71 } catch (err) {
72 clack.log.error((err as Error).message);
73 process.exitCode = 1;
74 return;
75 }
76
77 const playerPath = resolvePlayerPath();
78 const slideshowPath = resolveSlideshowPath();
79 if (!playerPath || !slideshowPath) {
80 clack.log.error(
81 "@hyperframes/player not found. Run `bun run --cwd packages/player build` first.",
82 );
83 process.exitCode = 1;
84 return;
85 }
86
87 // The deck must carry a slideshow island; the presenter view is meaningless
88 // without one. Extract it here so we can inline it into the wrapper page.
89 const indexHtml = readFileSync(project.indexPath, "utf-8");
90 const { slideshowIslandRegex } = await import("@hyperframes/core/slideshow");
91 const islandMatch = slideshowIslandRegex("i").exec(indexHtml);
92 if (!islandMatch?.[1]) {
93 clack.log.error(
94 `No slideshow island found in ${project.indexPath}. ` +
95 `Add a <script type="application/hyperframes-slideshow+json"> block — see /hyperframes (slideshow).`,
96 );
97 process.exitCode = 1;
98 return;
99 }
100 const islandJson = islandMatch[1].trim();
101
102 const { Hono } = await import("hono");
103 const { createAdaptorServer } = await import("@hono/node-server");
104 const { isSafePath } = await import("@hyperframes/core/studio-api");

Callers

nothing calls this directly

Calls 15

parseRemoteDebuggingPortFunction · 0.85
resolvePlayerPathFunction · 0.85
resolveSlideshowPathFunction · 0.85
slideshowIslandRegexFunction · 0.85
resolveFunction · 0.85
isSafePathFunction · 0.85
assetContentTypeFunction · 0.85
buildPresentPageFunction · 0.85
listenOnFreePortFunction · 0.85
errorMethod · 0.80
getMethod · 0.80

Tested by

no test coverage detected