// Only the main Relationships workspace starts this worker. Shared family code is read-only. self.window = self; self.onmessage = (event) => { const input = event.data; if (input.init) { importScripts(input.engineUrl, input.familyUrl); postMessage({ ready: true }); return; } try { if (input.routes) { postMessage({ id: input.id, result: { routes: input.routes.edges.map((edge) => ({ id: edge.id, ...self.PlotDirectorMainRelationshipLayout.route( input.routes.nodes, edge, input.routes.style, edge.lane, edge.path, ), })), }, }); return; } postMessage({ id: input.id, result: self.PlotDirectorMainRelationshipLayout.layout(input.graph), }); } catch (error) { postMessage({ id: input.id, error: error.message }); } };