import addMethods from "workerize-loader/dist/rpc-wrapper.js"
const methods = ["createTaskController", "destoryTaskController", "addCourseWareTask", "getRunJobIds", "initOssResource", "destroyOssResource"]
export default function (strs: any[]) {
  const urlBlob = new Blob(strs)
  const w = new Worker(URL.createObjectURL(urlBlob), { name: "worker/mine1-coursewares.[contenthash:8].worker.js" })
  URL.revokeObjectURL(URL.createObjectURL(urlBlob))
  addMethods(w, methods)
  w.ready = new Promise(function (r) {
    w.addEventListener("ready", function () {
      r(w)
    })
  })
  return w
}
