From 69b62d070dca17178dbcd9f3de4630cd84ed16e2 Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Sat, 21 Jan 2023 12:32:34 -0500 Subject: [PATCH] feat(runPipeline): Support passing null pipelineWorkerUrl Adds the ability to use a bundler vendored pipeline worker. --- src/core/createWebWorkerPromise.ts | 2 +- src/pipeline/runPipeline.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/createWebWorkerPromise.ts b/src/core/createWebWorkerPromise.ts index e03d01936..d5f5d7052 100644 --- a/src/core/createWebWorkerPromise.ts +++ b/src/core/createWebWorkerPromise.ts @@ -13,7 +13,7 @@ interface itkWorker extends Worker { } // Internal function to create a web worker promise -async function createWebWorkerPromise (existingWorker: Worker | null, pipelineWorkerUrl?: string): Promise { +async function createWebWorkerPromise (existingWorker: Worker | null, pipelineWorkerUrl?: string | null): Promise { let workerPromise: typeof WebworkerPromise if (existingWorker != null) { // See if we have a worker promise attached the worker, if so reuse it. This ensures diff --git a/src/pipeline/runPipeline.ts b/src/pipeline/runPipeline.ts index 0ff8d6cc2..39a9ea44e 100644 --- a/src/pipeline/runPipeline.ts +++ b/src/pipeline/runPipeline.ts @@ -48,7 +48,7 @@ async function runPipeline ( outputs: PipelineOutput[] | null, inputs: PipelineInput[] | null, pipelineBaseUrl: string | URL = 'pipelinesUrl', - pipelineWorkerUrl?: string | URL + pipelineWorkerUrl?: string | URL | null ): Promise { if (webWorker === false) { const pipelineModule = await loadPipelineModule(pipelinePath.toString()) @@ -58,7 +58,7 @@ async function runPipeline ( let worker = webWorker const pipelineWorkerUrlString = typeof pipelineWorkerUrl !== 'string' && typeof pipelineWorkerUrl?.href !== 'undefined' ? pipelineWorkerUrl.href : pipelineWorkerUrl const { webworkerPromise, worker: usedWorker } = await createWebWorkerPromise( - worker as Worker | null, pipelineWorkerUrlString as string | undefined + worker as Worker | null, pipelineWorkerUrlString as string | undefined | null ) worker = usedWorker const transferables: ArrayBuffer[] = []