All files / dicomImageLoader/src/types WebWorkerTypes.ts

0% Statements 0/0
0% Branches 0/0
0% Functions 0/0
0% Lines 0/0

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80                                                                                                                                                               
import type { ByteArray } from 'dicom-parser';
import type { Types } from '@cornerstonejs/core';
import type { LoaderOptions } from './LoaderOptions';
import type { LoaderDecodeOptions } from './LoaderDecodeOptions';
 
export interface WebWorkerOptions {
  maxWebWorkers?: number;
  startWebWorkersOnDemand?: boolean;
  webWorkerTaskPaths?: string[];
  taskConfiguration?: WebWorkerTaskOptions;
}
 
export interface WebWorkerDecodeConfig {
  initializeCodecsOnStartup: boolean;
  strict?: boolean;
}
 
export interface WebWorkerTaskOptions {
  decodeTask: WebWorkerDecodeConfig;
}
 
export interface WebWorkerDeferredObject<T = unknown> {
  resolve: (arg: T | PromiseLike<T>) => void;
  reject: (err) => void;
}
export type WorkerTaskTypes = 'decodeTask' | 'loadWebWorkerTask' | 'initialize';
 
// array of queued tasks sorted with highest priority task first
export interface WorkerTask {
  taskId: number;
  taskType: WorkerTaskTypes;
  status: 'ready' | 'success' | 'failed';
  added: number;
  start?: number;
  data: WebWorkerDecodeTaskData;
  deferred: WebWorkerDeferredObject;
  priority: number;
  transferList: Transferable[];
}
 
export interface WebWorkerDecodeTaskData {
  imageFrame: Types.IImageFrame;
  transferSyntax: string;
  pixelData: ByteArray;
  options: LoaderOptions;
  decodeConfig: LoaderDecodeOptions;
}
 
export interface WebWorkerDecodeData {
  taskType: 'decodeTask';
  workerIndex: number;
  data: WebWorkerDecodeTaskData;
}
 
export interface WebWorkerLoadData {
  taskType: 'loadWebWorkerTask';
  workerIndex: number;
  sourcePath: string;
  config: WebWorkerOptions;
}
 
export interface WebWorkerInitializeData {
  taskType: 'initialize';
  workerIndex: number;
  config: WebWorkerOptions;
}
 
export type WebWorkerData =
  | WebWorkerDecodeData
  | WebWorkerLoadData
  | WebWorkerInitializeData;
 
export interface WebWorkerResponse {
  taskType: WorkerTaskTypes;
  status: 'failed' | 'success';
  workerIndex: number;
  data?: Types.IImageFrame;
  result: string | Types.IImageFrame;
}