(event)
| 55 | //--------------------------------------------------------------------- |
| 56 | |
| 57 | export 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 | } |
no test coverage detected