/** * Downsampling Web Worker * * Performs CPU-intensive downsampling off the main thread. * * Usage: * ```typescript * const worker = new Worker(new URL('./downsample.worker.ts', import.meta.url)); * * worker.postMessage({ * type: 'downsample', * x: xArray, * y: yArray, * targetPoints: 1000, * algorithm: 'lttb' * }); * * worker.onmessage = (e) => { * const { x, y, indices } = e.data; * chart.setDownsampledData(x, y); * }; * ``` */ interface DownsampleRequestMessage { type: 'downsample'; id?: string; x: Float32Array | Float64Array; y: Float32Array | Float64Array; targetPoints: number; algorithm?: 'lttb' | 'minmax'; } interface DownsampleResponseMessage { type: 'downsample-result'; id?: string; x: Float32Array; y: Float32Array; indices: Uint32Array; originalLength: number; duration: number; } interface ErrorMessage { type: 'error'; id?: string; error: string; } export type { DownsampleRequestMessage, DownsampleResponseMessage, ErrorMessage };