import type { ContextRPC } from '../../types/rpc'
import type { WorkerContext, WorkerGlobalState } from '../../types/worker'
import type { VitestWorker, WorkerRpcOptions } from './types'
import { createThreadsRpcOptions } from './utils'
import { runVmTests } from './vm'

class ThreadsVmWorker implements VitestWorker {
  getRpcOptions(ctx: ContextRPC): WorkerRpcOptions {
    return createThreadsRpcOptions(ctx as WorkerContext)
  }

  runTests(state: WorkerGlobalState): unknown {
    return runVmTests(state)
  }
}

export default new ThreadsVmWorker()
