MCPcopy Index your code
hub / github.com/CapSoftware/Cap / handleWorkerMessage

Function handleWorkerMessage

apps/desktop/src/utils/socket.ts:999–1049  ·  view source on GitHub ↗
(e: MessageEvent<WorkerMessage>)

Source from the content-addressed store, hash-verified

997 };
998
999 function handleWorkerMessage(e: MessageEvent<WorkerMessage>) {
1000 if (e.data.type === "ready") {
1001 setIsWorkerReady(true);
1002 return;
1003 }
1004
1005 if (e.data.type === "error") {
1006 console.error("[FrameWorker]", e.data.message);
1007 isProcessingSharedFrame = false;
1008 isProcessing = false;
1009 processNextFrame();
1010 return;
1011 }
1012
1013 if (e.data.type === "frame-queued") {
1014 const { width, height } = e.data;
1015 onmessage({ width, height });
1016 isProcessingSharedFrame = false;
1017 isProcessing = false;
1018 processNextFrame();
1019 return;
1020 }
1021
1022 if (e.data.type === "frame-rendered") {
1023 const { width, height } = e.data;
1024 if (!hasRenderedFrame()) {
1025 setHasRenderedFrame(true);
1026 }
1027 onmessage({ width, height });
1028 recordRender(0, "worker");
1029 if (isProcessingSharedFrame) {
1030 isProcessingSharedFrame = false;
1031 isProcessing = false;
1032 processNextFrame();
1033 }
1034 return;
1035 }
1036
1037 if (e.data.type === "request-frame") {
1038 onRequestFrame?.();
1039 return;
1040 }
1041
1042 if (e.data.type === "decoded") {
1043 const { bitmap, width, height } = e.data;
1044 onmessage({ width, height, bitmap });
1045 isProcessingSharedFrame = false;
1046 isProcessing = false;
1047 processNextFrame();
1048 }
1049 }
1050
1051 function processNextFrame() {
1052 if (isProcessing) return;

Callers

nothing calls this directly

Calls 3

processNextFrameFunction · 0.85
hasRenderedFrameFunction · 0.85
recordRenderFunction · 0.85

Tested by

no test coverage detected