Skip to content

Commit

Permalink
feat(runPipeline): Support passing null pipelineWorkerUrl
Browse files Browse the repository at this point in the history
Adds the ability to use a bundler vendored pipeline worker.
  • Loading branch information
thewtex committed Jan 21, 2023
1 parent 5d9c32d commit 69b62d0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/core/createWebWorkerPromise.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<createWebWorkerPromiseResult> {
async function createWebWorkerPromise (existingWorker: Worker | null, pipelineWorkerUrl?: string | null): Promise<createWebWorkerPromiseResult> {
let workerPromise: typeof WebworkerPromise
if (existingWorker != null) {
// See if we have a worker promise attached the worker, if so reuse it. This ensures
Expand Down
4 changes: 2 additions & 2 deletions src/pipeline/runPipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<RunPipelineResult> {
if (webWorker === false) {
const pipelineModule = await loadPipelineModule(pipelinePath.toString())
Expand All @@ -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[] = []
Expand Down

0 comments on commit 69b62d0

Please sign in to comment.