import type Comlink from "comlink" ; import type { ProxiedFn , RunnerWorker , RunResult } from "./worker" ; import getCSVFromCache from "src/utils/csvFetcher" ; import { Function } from "./shared" ; const comlink = require ( "comlink" ) ; let worker ; function getWorker ( ) { return ( worker ?? ( worker = comlink . wrap < typeof RunnerWorker > ( new Worker ( new URL ( "./worker.ts" , import . meta . url ) ) ) ) ) ; } declare module "comlink" { function proxy < T extends Function > ( f ) ; } export async function run ( source ) { globalThis . modelsDb = [ ] ; try { return await getWorker ( ) . run ( source , comlink . proxy ( getCSVFromCache ) ) ; } finally { currentHighlightedBlock = undefined ; } }