Skip to content

Commit

Permalink
fix(create-web-worker): allow undefined workerUrl
Browse files Browse the repository at this point in the history
  • Loading branch information
floryst committed Apr 10, 2024
1 parent 607eb83 commit cdd95a4
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ import RunPipelineOptions from './run-pipeline-options'
async function createWebWorker (pipelineWorkerUrl?: string | null, queryParams?: RunPipelineOptions['pipelineQueryParams']): Promise<Worker> {
const workerUrl = pipelineWorkerUrl
let worker = null
if (workerUrl === null) {
if (workerUrl == null) {
// Use the version built with the bundler
//
// Bundlers, e.g. WebPack, Vite, Rollup, see these paths at build time
worker = new Worker(new URL('./web-workers/itk-wasm-pipeline.worker.js', import.meta.url), { type: 'module' })
} else {
if ((workerUrl as string).startsWith('http')) {
const response = await axios.get((workerUrl as string), { responseType: 'blob', params: queryParams })
if (workerUrl.startsWith('http')) {
const response = await axios.get(workerUrl, { responseType: 'blob', params: queryParams })
const workerObjectUrl = URL.createObjectURL(response.data as Blob)
worker = new Worker(workerObjectUrl, { type: 'module' })
} else {
worker = new Worker((workerUrl as string), { type: 'module' })
worker = new Worker(workerUrl, { type: 'module' })
}
}

Expand Down

0 comments on commit cdd95a4

Please sign in to comment.