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

Function installRuntimeControlBridge

packages/core/src/runtime/bridge.ts:75–92  ·  view source on GitHub ↗
(deps: BridgeDeps)

Source from the content-addressed store, hash-verified

73}
74
75export function installRuntimeControlBridge(deps: BridgeDeps): (event: MessageEvent) => void {
76 const handler = (event: MessageEvent) => {
77 const data = event.data as BridgeControlData | null;
78 if (!data || data.source !== "hf-parent" || data.type !== "control") return;
79 const action = data.action;
80 if (typeof action !== "string") return;
81 const fn = CONTROL_HANDLERS[action];
82 if (fn) fn(data, deps);
83 };
84 window.addEventListener("message", handler);
85 // Announce that the bridge listener is installed so the parent can replay
86 // any control messages it posted before the iframe runtime was ready
87 // (avoids losing the initial `set-muted` / `set-volume` / `set-playback-rate`
88 // when the parent finishes loading before the iframe does — a deterministic
89 // race on warm-cache reloads and inside the Claude desktop Electron client).
90 postRuntimeMessage({ source: "hf-preview", type: "ready" });
91 return handler;
92}
93
94/**
95 * Flash elements — briefly highlight them with a blue outline.

Callers 2

bridge.test.tsFile · 0.90

Calls 1

postRuntimeMessageFunction · 0.85

Tested by

no test coverage detected