oss-ecosystem-data / code /web /src /lib /galaxy.worker.ts
saladday1's picture
code: sync from git
2471af3 verified
Raw History Blame Contribute Delete
528 Bytes
import { layoutGalaxy } from "./galaxy"
import type { Repo } from "./types"
// The force layout takes a second or two for ~1,300 bubbles; doing it here keeps the page responsive.
self.onmessage = (e: MessageEvent<{ key: string; repos: Repo[]; base: string; officialDl: number }>) => {
const { key, repos, base, officialDl } = e.data
const g = layoutGalaxy(repos, base, officialDl)
const pos = g.nodes.map((n) => [n.id, n.x, n.y, n.r, n.ring] as const)
self.postMessage({ key, pos, rings: g.rings, extent: g.extent })
}