MCPcopy
hub / github.com/witheve/Eve / onmessage

Function onmessage

src/runtime/webworker.ts:57–80  ·  view source on GitHub ↗
(event)

Source from the content-addressed store, hash-verified

55//---------------------------------------------------------------------
56
57export function onmessage(event) {
58 let data = JSON.parse(event.data);
59 if(typeof data !== "object") {
60 console.error("WORKER: Unknown message: " + data);
61 return;
62 }
63
64 if(data.type === "init") {
65 // since we're working in a totally different context, we need to load the
66 // workspace information that the browser normally has into the webworker
67 // context
68 eveSource.loadWorkspaces(data.workspaces);
69 global["_workspaceCache"] = data.workspaceCache;
70 initConfig(data.config);
71 init(data.code, data.showIDE);
72 } else if(data.type === "save") {
73 let workspace = eveSource.getWorkspaceFromPath(data.path);
74 global["_workspaceCache"][workspace][data.path] = data.code;
75 } else if(data.type !== undefined) {
76 responder.handleEvent(event.data);
77 } else {
78 console.error("WORKER: Unknown message type: " + data.type);
79 }
80}

Callers 1

loadWorker.jsFile · 0.85

Calls 2

initFunction · 0.90
errorMethod · 0.80

Tested by

no test coverage detected