velo-plot 2.0.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -8
- package/dist/{ChartCore-BhQ4j7f5.js → ChartCore-BpzRvN4Y.js} +998 -855
- package/dist/ChartCore-BpzRvN4Y.js.map +1 -0
- package/dist/a11y-Bw6urYpr.js +105 -0
- package/dist/a11y-Bw6urYpr.js.map +1 -0
- package/dist/angular/hooks-entry.d.ts +1 -0
- package/dist/angular/hooks.d.ts +26 -0
- package/dist/angular/index.d.ts +8 -0
- package/dist/angular/velo-plot.component.d.ts +46 -0
- package/dist/angular-hooks.d.ts +1 -0
- package/dist/angular-hooks.js +9 -0
- package/dist/angular-hooks.js.map +1 -0
- package/dist/angular.d.ts +1 -0
- package/dist/angular.js +166 -0
- package/dist/angular.js.map +1 -0
- package/dist/assets/indicator.worker-bv0zC4EX.js.map +1 -1
- package/dist/astro/StackedPlot.astro +19 -0
- package/dist/astro/VeloPlot.astro +23 -0
- package/dist/{axisFormat-SPX-CD5s.js → axisFormat-CzumxpCL.js} +3 -3
- package/dist/axisFormat-CzumxpCL.js.map +1 -0
- package/dist/bindings/shared/a11y.d.ts +26 -0
- package/dist/bindings/shared/chartLifecycle.d.ts +16 -0
- package/dist/bindings/shared/chartSyncBridge.d.ts +8 -0
- package/dist/bindings/shared/dimensions.d.ts +1 -0
- package/dist/bindings/shared/index.d.ts +9 -0
- package/dist/bindings/shared/indicatorBridge.d.ts +11 -0
- package/dist/bindings/shared/optionsSync.d.ts +7 -0
- package/dist/bindings/shared/seriesDiff.d.ts +8 -0
- package/dist/bindings/shared/stackedSync.d.ts +9 -0
- package/dist/bindings/shared/types.d.ts +46 -0
- package/dist/bindings/test-utils/index.d.ts +35 -0
- package/dist/bindings/test-utils/mockLifecycle.d.ts +120 -0
- package/dist/bindings/test-utils/vitestSveltePlugin.d.ts +3 -0
- package/dist/chartSyncBridge-DbWrwtyP.js +57 -0
- package/dist/chartSyncBridge-DbWrwtyP.js.map +1 -0
- package/dist/core/Chart.d.ts +1 -1
- package/dist/core/InteractionManager.d.ts +7 -1
- package/dist/core/OverlayRenderer.d.ts +5 -0
- package/dist/core/annotations/types.d.ts +1 -1
- package/dist/core/chart/ChartAxisManager.d.ts +2 -0
- package/dist/core/chart/ChartCore.d.ts +17 -2
- package/dist/core/chart/ChartPluginBridge.d.ts +1 -0
- package/dist/core/chart/ChartRenderLoop.d.ts +2 -0
- package/dist/core/chart/ChartStateManager.d.ts +2 -0
- package/dist/core/chart/types.d.ts +6 -1
- package/dist/core/clipboard/index.d.ts +1 -1
- package/dist/core/debug/index.d.ts +1 -1
- package/dist/core/keybindings/index.d.ts +1 -1
- package/dist/core/loading/index.d.ts +1 -1
- package/dist/core/locale/index.d.ts +1 -1
- package/dist/core/stacked/paneResize.d.ts +3 -0
- package/dist/core/stacked/types.d.ts +10 -0
- package/dist/core/sync/index.d.ts +0 -1
- package/dist/core/theme-editor/index.d.ts +1 -1
- package/dist/createStackedChart-Dm-YqUT7.js +756 -0
- package/dist/createStackedChart-Dm-YqUT7.js.map +1 -0
- package/dist/examples/PluginDemonstration.d.ts +1 -1
- package/dist/gpuRenderer-BpaMYz-k.js.map +1 -1
- package/dist/hooks-CYPCxoZx.js +69 -0
- package/dist/hooks-CYPCxoZx.js.map +1 -0
- package/dist/{index-D7dTq6VB.js → index-0InEyj0q.js} +130 -134
- package/dist/index-0InEyj0q.js.map +1 -0
- package/dist/index-BMiZoKmm.js.map +1 -1
- package/dist/{index-DoYxf1cV.js → index-CWxIHdwX.js} +38 -98
- package/dist/index-CWxIHdwX.js.map +1 -0
- package/dist/{index-CUGS98p4.js → index-CaXWSOTk.js} +3 -6
- package/dist/index-CaXWSOTk.js.map +1 -0
- package/dist/index-Dag88bW4.js.map +1 -1
- package/dist/index-qhscKTDy.js.map +1 -1
- package/dist/{index-CWipqOLP.js → index-qunX30Xu.js} +2 -2
- package/dist/index-qunX30Xu.js.map +1 -0
- package/dist/index-x4stH3jD.js.map +1 -1
- package/dist/{index.core-fpZ1dYN0.js → index.core-BmZe2jRQ.js} +30 -29
- package/dist/index.core-BmZe2jRQ.js.map +1 -0
- package/dist/index.core.d.ts +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/indicators--eJGmVox.js.map +1 -1
- package/dist/{mockDatafeed-Cdg5hKEo.js → mockDatafeed-DHIDPcpX.js} +150 -146
- package/dist/mockDatafeed-DHIDPcpX.js.map +1 -0
- package/dist/optionsSync-QUiN4Inw.js +119 -0
- package/dist/optionsSync-QUiN4Inw.js.map +1 -0
- package/dist/plugins/3d/index.d.ts +2 -2
- package/dist/plugins/3d.d.ts +2 -2
- package/dist/plugins/3d.js.map +1 -1
- package/dist/plugins/analysis/contours.d.ts +31 -0
- package/dist/plugins/analysis/index.d.ts +1 -1
- package/dist/plugins/analysis/indicators.d.ts +1 -1
- package/dist/plugins/analysis.d.ts +2 -2
- package/dist/plugins/analysis.js +495 -408
- package/dist/plugins/analysis.js.map +1 -1
- package/dist/plugins/annotations/index.d.ts +1 -1
- package/dist/plugins/annotations.d.ts +2 -2
- package/dist/plugins/annotations.js.map +1 -1
- package/dist/plugins/anomaly-detection.js +1 -1
- package/dist/plugins/anomaly-detection.js.map +1 -1
- package/dist/plugins/broken-axis.d.ts +2 -2
- package/dist/plugins/broken-axis.js +170 -181
- package/dist/plugins/broken-axis.js.map +1 -1
- package/dist/plugins/builtins/crosshair/CrosshairPlugin.d.ts +1 -1
- package/dist/plugins/builtins/index.d.ts +1 -1
- package/dist/plugins/caching.d.ts +2 -2
- package/dist/plugins/clipboard/index.d.ts +2 -2
- package/dist/plugins/clipboard.d.ts +2 -2
- package/dist/plugins/clipboard.js.map +1 -1
- package/dist/plugins/context-menu/index.d.ts +1 -1
- package/dist/plugins/context-menu.d.ts +2 -2
- package/dist/plugins/context-menu.js +1 -1
- package/dist/plugins/context-menu.js.map +1 -1
- package/dist/plugins/data-export/index.d.ts +1 -1
- package/dist/plugins/data-export.d.ts +2 -2
- package/dist/plugins/data-export.js +2 -2
- package/dist/plugins/data-export.js.map +1 -1
- package/dist/plugins/data-transform.d.ts +2 -2
- package/dist/plugins/data-transform.js +19 -19
- package/dist/plugins/data-transform.js.map +1 -1
- package/dist/plugins/debug/index.d.ts +2 -2
- package/dist/plugins/debug.d.ts +2 -2
- package/dist/plugins/debug.js +2 -2
- package/dist/plugins/debug.js.map +1 -1
- package/dist/plugins/forecasting/algorithms.d.ts +7 -2
- package/dist/plugins/forecasting/index.d.ts +1 -1
- package/dist/plugins/forecasting/types.d.ts +13 -3
- package/dist/plugins/forecasting.js +355 -175
- package/dist/plugins/forecasting.js.map +1 -1
- package/dist/plugins/gpu/index.d.ts +2 -2
- package/dist/plugins/gpu.d.ts +2 -2
- package/dist/plugins/gpu.js.map +1 -1
- package/dist/plugins/i18n/index.d.ts +2 -2
- package/dist/plugins/i18n.d.ts +2 -2
- package/dist/plugins/i18n.js.map +1 -1
- package/dist/plugins/index.d.ts +1 -1
- package/dist/plugins/keyboard.d.ts +2 -2
- package/dist/plugins/keyboard.js +65 -5
- package/dist/plugins/keyboard.js.map +1 -1
- package/dist/plugins/latex/symbols.d.ts +50 -0
- package/dist/plugins/latex/types.d.ts +13 -1
- package/dist/plugins/latex.js +351 -331
- package/dist/plugins/latex.js.map +1 -1
- package/dist/plugins/lazy-load.d.ts +2 -2
- package/dist/plugins/loading/index.d.ts +1 -1
- package/dist/plugins/loading.d.ts +2 -2
- package/dist/plugins/ml-integration/native-algorithms.d.ts +24 -4
- package/dist/plugins/ml-integration/types.d.ts +19 -0
- package/dist/plugins/ml-integration.d.ts +2 -2
- package/dist/plugins/ml-integration.js +190 -139
- package/dist/plugins/ml-integration.js.map +1 -1
- package/dist/plugins/offscreen.d.ts +2 -2
- package/dist/plugins/pattern-recognition/types.d.ts +28 -1
- package/dist/plugins/pattern-recognition.d.ts +2 -2
- package/dist/plugins/pattern-recognition.js +417 -344
- package/dist/plugins/pattern-recognition.js.map +1 -1
- package/dist/plugins/radar.d.ts +2 -2
- package/dist/plugins/regression.d.ts +2 -2
- package/dist/plugins/regression.js +1 -1
- package/dist/plugins/regression.js.map +1 -1
- package/dist/plugins/roi.js +9 -9
- package/dist/plugins/roi.js.map +1 -1
- package/dist/plugins/snapshot/index.d.ts +1 -1
- package/dist/plugins/snapshot/types.d.ts +1 -1
- package/dist/plugins/snapshot.d.ts +2 -2
- package/dist/plugins/snapshot.js +36 -36
- package/dist/plugins/snapshot.js.map +1 -1
- package/dist/plugins/streaming/index.d.ts +2 -2
- package/dist/plugins/streaming.d.ts +2 -2
- package/dist/plugins/sync/index.d.ts +3 -2
- package/dist/plugins/sync.d.ts +2 -2
- package/dist/plugins/sync.js +1 -1
- package/dist/plugins/sync.js.map +1 -1
- package/dist/plugins/theme-editor/index.d.ts +1 -1
- package/dist/plugins/theme-editor.d.ts +2 -2
- package/dist/plugins/tools/index.d.ts +1 -1
- package/dist/plugins/tools/tooltip/index.d.ts +1 -1
- package/dist/plugins/tools.d.ts +2 -2
- package/dist/plugins/tools.js +1 -1
- package/dist/plugins/types.d.ts +1 -1
- package/dist/plugins/video-recorder.d.ts +2 -2
- package/dist/plugins/virtualization.d.ts +2 -2
- package/dist/plugins/virtualization.js +1 -1
- package/dist/pool-DZ8shSqv.js +109 -0
- package/dist/pool-DZ8shSqv.js.map +1 -0
- package/dist/react/StackedPlot.d.ts +31 -0
- package/dist/react/VeloPlot.d.ts +29 -0
- package/dist/react/index.d.ts +25 -3
- package/dist/react/useChartSync.d.ts +8 -0
- package/dist/react/useIndicator.d.ts +12 -0
- package/dist/react/useVeloPlot.d.ts +19 -0
- package/dist/react.js +328 -24
- package/dist/react.js.map +1 -1
- package/dist/scientific/index.d.ts +48 -0
- package/dist/scientific.d.ts +1 -0
- package/dist/scientific.js +91 -0
- package/dist/scientific.js.map +1 -0
- package/dist/solid/VeloPlot.d.ts +16 -0
- package/dist/solid/index.d.ts +13 -0
- package/dist/solid/useChartSync.d.ts +6 -0
- package/dist/solid/useIndicator.d.ts +11 -0
- package/dist/solid/useStackedPlot.d.ts +14 -0
- package/dist/solid/useVeloPlot.d.ts +18 -0
- package/dist/solid.d.ts +1 -0
- package/dist/solid.js +172 -0
- package/dist/solid.js.map +1 -0
- package/dist/stackedSync-tnrunZMt.js +100 -0
- package/dist/stackedSync-tnrunZMt.js.map +1 -0
- package/dist/svelte/StackedPlot.svelte +29 -0
- package/dist/svelte/StackedPlot.test.ts +114 -0
- package/dist/svelte/VeloPlot.svelte +44 -0
- package/dist/svelte/VeloPlot.test.ts +105 -0
- package/dist/svelte/index.d.ts +11 -0
- package/dist/svelte/index.test.ts +20 -0
- package/dist/svelte/index.ts +15 -0
- package/dist/svelte/useChartSync.d.ts +8 -0
- package/dist/svelte/useChartSync.test.ts +49 -0
- package/dist/svelte/useChartSync.ts +29 -0
- package/dist/svelte/useIndicator.d.ts +13 -0
- package/dist/svelte/useIndicator.test.ts +67 -0
- package/dist/svelte/useIndicator.ts +43 -0
- package/dist/svelte/useStackedPlot.d.ts +16 -0
- package/dist/svelte/useStackedPlot.test.ts +76 -0
- package/dist/svelte/useStackedPlot.ts +54 -0
- package/dist/svelte/useVeloPlot.d.ts +21 -0
- package/dist/svelte/useVeloPlot.test.ts +100 -0
- package/dist/svelte/useVeloPlot.ts +81 -0
- package/dist/svelte.d.ts +1 -0
- package/dist/svelte.js +143 -0
- package/dist/svelte.js.map +1 -0
- package/dist/symbols-DT0eLlpW.js +568 -0
- package/dist/symbols-DT0eLlpW.js.map +1 -0
- package/dist/testing/index.d.ts +1 -1
- package/dist/theme/index.d.ts +2 -1
- package/dist/trading.js +7 -7
- package/dist/types.d.ts +1 -1
- package/dist/{utils-BK5UUXxj.js → utils-Dx0h0bgQ.js} +9 -9
- package/dist/{utils-BK5UUXxj.js.map → utils-Dx0h0bgQ.js.map} +1 -1
- package/dist/velo-plot.full.js +444 -433
- package/dist/velo-plot.full.js.map +1 -1
- package/dist/velo-plot.js +15 -15
- package/dist/vue/StackedPlot.vue.d.ts +48 -0
- package/dist/vue/VeloPlot.vue.d.ts +64 -0
- package/dist/vue/index.d.ts +250 -0
- package/dist/vue/useChartSync.d.ts +52 -0
- package/dist/vue/useIndicator.d.ts +23 -0
- package/dist/vue/useStackedPlot.d.ts +15 -0
- package/dist/vue/useVeloPlot.d.ts +20 -0
- package/dist/vue.d.ts +1 -0
- package/dist/vue.js +312 -0
- package/dist/vue.js.map +1 -0
- package/dist/workers/indicatorsAsync.d.ts +26 -0
- package/dist/workers/pool.d.ts +9 -0
- package/package.json +88 -10
- package/dist/ChartCore-BhQ4j7f5.js.map +0 -1
- package/dist/SciPlot-GJvw7GJo.js +0 -463
- package/dist/SciPlot-GJvw7GJo.js.map +0 -1
- package/dist/axisFormat-SPX-CD5s.js.map +0 -1
- package/dist/createStackedChart-DJSmqerD.js +0 -706
- package/dist/createStackedChart-DJSmqerD.js.map +0 -1
- package/dist/index-CUGS98p4.js.map +0 -1
- package/dist/index-CWipqOLP.js.map +0 -1
- package/dist/index-D7dTq6VB.js.map +0 -1
- package/dist/index-DoYxf1cV.js.map +0 -1
- package/dist/index.core-fpZ1dYN0.js.map +0 -1
- package/dist/mockDatafeed-Cdg5hKEo.js.map +0 -1
- package/dist/pool-15HMCNv8.js +0 -88
- package/dist/pool-15HMCNv8.js.map +0 -1
- package/dist/react/SciPlot.d.ts +0 -60
- package/dist/react/useSciPlot.d.ts +0 -56
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gpuRenderer-BpaMYz-k.js","sources":["../src/gpu/backends/webgpu/pipelines/triangleShader.ts","../src/gpu/backends/webgpu/pipelines/trianglePipeline.ts","../src/gpu/backends/webgpu/shaders/line.wgsl.ts","../src/gpu/backends/webgpu/pipelines/linePipeline.ts","../src/gpu/backends/webgpu/shaders/point.wgsl.ts","../src/gpu/backends/webgpu/pipelines/pointPipeline.ts","../src/gpu/backends/webgpu/pipelines/bandPipeline.ts","../src/gpu/backends/webgpu/shaders/heatmap.wgsl.ts","../src/gpu/backends/webgpu/pipelines/heatmapPipeline.ts","../src/gpu/backends/webgpu/WebGPUBackend.ts","../src/gpu/backends/webgl/shaders.ts","../src/gpu/backends/webgl/programFactory.ts","../src/gpu/backends/webgl/WebGLBackend.ts","../src/gpu/adapter/seriesAdapter.ts","../src/gpu/adapter/gpuRenderer.ts"],"sourcesContent":["export const TRIANGLE_SHADER_WGSL = `\nstruct VSOut {\n @builtin(position) pos: vec4<f32>,\n @location(0) color: vec4<f32>,\n};\n\n@vertex\nfn vs_main(\n @location(0) position: vec2<f32>,\n @location(1) color: vec4<f32>\n) -> VSOut {\n var out: VSOut;\n out.pos = vec4<f32>(position, 0.0, 1.0);\n out.color = color;\n return out;\n}\n\n@fragment\nfn fs_main(in: VSOut) -> @location(0) vec4<f32> {\n return in.color;\n}\n`;\n","import { TRIANGLE_SHADER_WGSL } from \"./triangleShader\";\n\nexport interface TrianglePipelineBundle {\n pipeline: any;\n vertexStride: number;\n}\n\nexport function createTrianglePipeline(\n device: any,\n format: string\n): TrianglePipelineBundle {\n const module = device.createShaderModule({ code: TRIANGLE_SHADER_WGSL });\n\n const vertexStride = 6 * 4;\n\n const pipeline = device.createRenderPipeline({\n layout: \"auto\",\n vertex: {\n module,\n entryPoint: \"vs_main\",\n buffers: [\n {\n arrayStride: vertexStride,\n attributes: [\n { shaderLocation: 0, offset: 0, format: \"float32x2\" },\n { shaderLocation: 1, offset: 2 * 4, format: \"float32x4\" },\n ],\n },\n ],\n },\n fragment: {\n module,\n entryPoint: \"fs_main\",\n targets: [{ format }],\n },\n primitive: {\n topology: \"triangle-list\",\n cullMode: \"none\",\n },\n });\n\n return { pipeline, vertexStride };\n}\n","/**\n * Line Shader - WGSL for WebGPU\n * \n * Renders simple line strips with uniform color.\n * Uses uniform buffer for transform (scale + translate).\n */\n\nexport const LINE_SHADER_WGSL = `\n// Uniform buffer for transforms and color\nstruct Uniforms {\n scale: vec2<f32>,\n translate: vec2<f32>,\n color: vec4<f32>,\n};\n\n@group(0) @binding(0)\nvar<uniform> uniforms: Uniforms;\n\nstruct VSInput {\n @location(0) position: vec2<f32>,\n};\n\nstruct VSOutput {\n @builtin(position) pos: vec4<f32>,\n};\n\n@vertex\nfn vs_main(in: VSInput) -> VSOutput {\n var out: VSOutput;\n let transformed = in.position * uniforms.scale + uniforms.translate;\n out.pos = vec4<f32>(transformed, 0.0, 1.0);\n return out;\n}\n\n@fragment\nfn fs_main(in: VSOutput) -> @location(0) vec4<f32> {\n return uniforms.color;\n}\n`;\n\nexport const LINE_VERTEX_STRIDE = 2 * 4; // 2 floats (x, y)\n","/**\n * Line Pipeline - WebGPU pipeline for rendering lines with uniform buffer\n * \n * Uses `any` types for WebGPU objects to avoid requiring @webgpu/types\n * (following the pattern of the original WebGPUBackend.ts)\n */\n\nimport { LINE_SHADER_WGSL, LINE_VERTEX_STRIDE } from \"../shaders/line.wgsl\";\n\nexport interface LinePipelineBundle {\n pipeline: any; // GPURenderPipeline\n bindGroupLayout: any; // GPUBindGroupLayout\n uniformBuffer: any; // GPUBuffer\n bindGroup: any; // GPUBindGroup\n vertexStride: number;\n}\n\nexport interface LineUniforms {\n scale: [number, number];\n translate: [number, number];\n color: [number, number, number, number];\n}\n\n// Uniform buffer layout: scale(2) + translate(2) + color(4) = 8 floats = 32 bytes\nconst UNIFORM_BUFFER_SIZE = 32;\n\nexport function createLinePipeline(\n device: any, // GPUDevice\n format: string // GPUTextureFormat\n): LinePipelineBundle {\n const module = device.createShaderModule({ code: LINE_SHADER_WGSL });\n\n const GPUShaderStageAny = (globalThis as any).GPUShaderStage;\n const GPUBufferUsageAny = (globalThis as any).GPUBufferUsage;\n\n // Create bind group layout explicitly\n const bindGroupLayout = device.createBindGroupLayout({\n entries: [\n {\n binding: 0,\n visibility: GPUShaderStageAny.VERTEX | GPUShaderStageAny.FRAGMENT,\n buffer: { type: \"uniform\" },\n },\n ],\n });\n\n // Create uniform buffer\n const uniformBuffer = device.createBuffer({\n size: UNIFORM_BUFFER_SIZE,\n usage: GPUBufferUsageAny.UNIFORM | GPUBufferUsageAny.COPY_DST,\n });\n\n // Create bind group\n const bindGroup = device.createBindGroup({\n layout: bindGroupLayout,\n entries: [\n {\n binding: 0,\n resource: { buffer: uniformBuffer },\n },\n ],\n });\n\n // Create pipeline layout\n const pipelineLayout = device.createPipelineLayout({\n bindGroupLayouts: [bindGroupLayout],\n });\n\n const pipeline = device.createRenderPipeline({\n layout: pipelineLayout,\n vertex: {\n module,\n entryPoint: \"vs_main\",\n buffers: [\n {\n arrayStride: LINE_VERTEX_STRIDE,\n attributes: [\n { shaderLocation: 0, offset: 0, format: \"float32x2\" },\n ],\n },\n ],\n },\n fragment: {\n module,\n entryPoint: \"fs_main\",\n targets: [\n {\n format,\n blend: {\n color: {\n srcFactor: \"src-alpha\",\n dstFactor: \"one-minus-src-alpha\",\n operation: \"add\",\n },\n alpha: {\n srcFactor: \"one\",\n dstFactor: \"one-minus-src-alpha\",\n operation: \"add\",\n },\n },\n },\n ],\n },\n primitive: {\n topology: \"line-strip\",\n stripIndexFormat: undefined,\n },\n });\n\n return {\n pipeline,\n bindGroupLayout,\n uniformBuffer,\n bindGroup,\n vertexStride: LINE_VERTEX_STRIDE,\n };\n}\n\nexport function updateLineUniforms(\n device: any, // GPUDevice\n uniformBuffer: any, // GPUBuffer\n uniforms: LineUniforms\n): void {\n const data = new Float32Array([\n uniforms.scale[0],\n uniforms.scale[1],\n uniforms.translate[0],\n uniforms.translate[1],\n uniforms.color[0],\n uniforms.color[1],\n uniforms.color[2],\n uniforms.color[3],\n ]);\n device.queue.writeBuffer(uniformBuffer, 0, data);\n}\n","/**\n * Point Shader - WGSL for WebGPU\n * \n * Renders scatter points with SDF-based symbols.\n * Supports: circle, square, diamond, triangle, triangleDown, cross, x, star\n */\n\nexport const POINT_SHADER_WGSL = `\n// Uniform buffer for transforms, color, point properties\nstruct Uniforms {\n scale: vec2<f32>,\n translate: vec2<f32>,\n color: vec4<f32>,\n pointSize: f32,\n symbol: i32, // 0=circle, 1=square, 2=diamond, 3=triangle, 4=triangleDown, 5=cross, 6=x, 7=star\n _padding: vec2<f32>,\n};\n\n@group(0) @binding(0)\nvar<uniform> uniforms: Uniforms;\n\nstruct VSInput {\n @location(0) position: vec2<f32>,\n};\n\nstruct VSOutput {\n @builtin(position) pos: vec4<f32>,\n @location(0) @interpolate(flat) pointSize: f32,\n @location(1) @interpolate(flat) symbol: i32,\n};\n\n@vertex\nfn vs_main(in: VSInput, @builtin(vertex_index) vertexIndex: u32) -> VSOutput {\n var out: VSOutput;\n let transformed = in.position * uniforms.scale + uniforms.translate;\n out.pos = vec4<f32>(transformed, 0.0, 1.0);\n out.pointSize = uniforms.pointSize;\n out.symbol = uniforms.symbol;\n return out;\n}\n\n// SDF functions for symbols\nfn sdCircle(p: vec2<f32>, r: f32) -> f32 {\n return length(p) - r;\n}\n\nfn sdBox(p: vec2<f32>, b: vec2<f32>) -> f32 {\n let d = abs(p) - b;\n return length(max(d, vec2<f32>(0.0))) + min(max(d.x, d.y), 0.0);\n}\n\nfn sdDiamond(p: vec2<f32>, r: f32) -> f32 {\n return (abs(p.x) + abs(p.y)) - r;\n}\n\nfn sdTriangle(p_in: vec2<f32>, r: f32) -> f32 {\n let k = sqrt(3.0);\n var p = p_in;\n p.x = abs(p.x) - r;\n p.y = p.y + r / k;\n if (p.x + k * p.y > 0.0) {\n p = vec2<f32>(p.x - k * p.y, -k * p.x - p.y) / 2.0;\n }\n p.x = p.x - clamp(p.x, -2.0 * r, 0.0);\n return -length(p) * sign(p.y);\n}\n\nfn sdCross(p: vec2<f32>, r: f32, thickness: f32) -> f32 {\n let d = abs(p);\n let s1 = sdBox(d, vec2<f32>(r, thickness));\n let s2 = sdBox(d, vec2<f32>(thickness, r));\n return min(s1, s2);\n}\n\nfn sdX(p: vec2<f32>, r: f32, thickness: f32) -> f32 {\n let c = cos(0.785398);\n let s = sin(0.785398);\n let m = mat2x2<f32>(c, -s, s, c);\n return sdCross(m * p, r, thickness);\n}\n\nfn sdStar(p_in: vec2<f32>, r: f32, rf: f32) -> f32 {\n let k1 = vec2<f32>(0.80901699, -0.58778525);\n let k2 = vec2<f32>(-k1.x, k1.y);\n var p = p_in;\n p.x = abs(p.x);\n p = p - 2.0 * max(dot(k1, p), 0.0) * k1;\n p = p - 2.0 * max(dot(k2, p), 0.0) * k2;\n p.x = abs(p.x);\n p.y = p.y - r;\n let ba = rf * vec2<f32>(-k1.y, k1.x) - vec2<f32>(0.0, 1.0);\n let h = clamp(dot(p, ba) / dot(ba, ba), 0.0, r);\n return length(p - ba * h) * sign(p.y * ba.x - p.x * ba.y);\n}\n\n@fragment\nfn fs_main(in: VSOutput) -> @location(0) vec4<f32> {\n // Note: WebGPU doesn't have gl_PointCoord directly\n // Points in WebGPU require rendering quads instead\n // This shader needs instanced rendering with quads for proper point rendering\n // For now, return the color directly\n return uniforms.color;\n}\n`;\n\n// For proper point rendering we need quad instances\n// Each point becomes 6 vertices (2 triangles forming a quad)\nexport const POINT_QUAD_SHADER_WGSL = `\n// Uniform buffer for transforms, color, point properties\nstruct Uniforms {\n scale: vec2<f32>,\n translate: vec2<f32>,\n color: vec4<f32>,\n pointSize: f32,\n symbol: i32,\n viewport: vec2<f32>, // viewport dimensions for proper sizing\n};\n\n@group(0) @binding(0)\nvar<uniform> uniforms: Uniforms;\n\nstruct VSInput {\n @location(0) position: vec2<f32>, // point center position\n @location(1) quadOffset: vec2<f32>, // quad vertex offset (-1 to 1)\n};\n\nstruct VSOutput {\n @builtin(position) pos: vec4<f32>,\n @location(0) uv: vec2<f32>, // -0.5 to 0.5 for SDF\n};\n\n@vertex\nfn vs_main(in: VSInput) -> VSOutput {\n var out: VSOutput;\n \n // Transform point position to NDC\n let transformed = in.position * uniforms.scale + uniforms.translate;\n \n // Calculate point size in NDC\n let pointSizeNDC = vec2<f32>(\n uniforms.pointSize / uniforms.viewport.x * 2.0,\n uniforms.pointSize / uniforms.viewport.y * 2.0\n );\n \n // Apply quad offset\n let offset = in.quadOffset * pointSizeNDC * 0.5;\n \n out.pos = vec4<f32>(transformed + offset, 0.0, 1.0);\n out.uv = in.quadOffset * 0.5; // -0.5 to 0.5\n \n return out;\n}\n\n// SDF functions\nfn sdCircle(p: vec2<f32>, r: f32) -> f32 {\n return length(p) - r;\n}\n\nfn sdBox(p: vec2<f32>, b: vec2<f32>) -> f32 {\n let d = abs(p) - b;\n return length(max(d, vec2<f32>(0.0))) + min(max(d.x, d.y), 0.0);\n}\n\nfn sdDiamond(p: vec2<f32>, r: f32) -> f32 {\n return (abs(p.x) + abs(p.y)) - r;\n}\n\nfn sdTriangle(p_in: vec2<f32>, r: f32) -> f32 {\n let k = sqrt(3.0);\n var p = p_in;\n p.x = abs(p.x) - r;\n p.y = p.y + r / k;\n if (p.x + k * p.y > 0.0) {\n p = vec2<f32>(p.x - k * p.y, -k * p.x - p.y) / 2.0;\n }\n p.x = p.x - clamp(p.x, -2.0 * r, 0.0);\n return -length(p) * sign(p.y);\n}\n\nfn sdCross(p: vec2<f32>, r: f32, thickness: f32) -> f32 {\n let d = abs(p);\n let s1 = sdBox(d, vec2<f32>(r, thickness));\n let s2 = sdBox(d, vec2<f32>(thickness, r));\n return min(s1, s2);\n}\n\nfn sdX(p: vec2<f32>, r: f32, thickness: f32) -> f32 {\n let c = cos(0.785398);\n let s = sin(0.785398);\n let m = mat2x2<f32>(c, -s, s, c);\n return sdCross(m * p, r, thickness);\n}\n\nfn sdStar(p_in: vec2<f32>, r: f32, rf: f32) -> f32 {\n let k1 = vec2<f32>(0.80901699, -0.58778525);\n let k2 = vec2<f32>(-k1.x, k1.y);\n var p = p_in;\n p.x = abs(p.x);\n p = p - 2.0 * max(dot(k1, p), 0.0) * k1;\n p = p - 2.0 * max(dot(k2, p), 0.0) * k2;\n p.x = abs(p.x);\n p.y = p.y - r;\n let ba = rf * vec2<f32>(-k1.y, k1.x) - vec2<f32>(0.0, 1.0);\n let h = clamp(dot(p, ba) / dot(ba, ba), 0.0, r);\n return length(p - ba * h) * sign(p.y * ba.x - p.x * ba.y);\n}\n\n@fragment\nfn fs_main(in: VSOutput) -> @location(0) vec4<f32> {\n var d: f32 = 0.0;\n \n if (uniforms.symbol == 0) {\n d = sdCircle(in.uv, 0.45);\n } else if (uniforms.symbol == 1) {\n d = sdBox(in.uv, vec2<f32>(0.35));\n } else if (uniforms.symbol == 2) {\n d = sdDiamond(in.uv, 0.45);\n } else if (uniforms.symbol == 3) {\n d = sdTriangle(vec2<f32>(in.uv.x, in.uv.y + 0.1), 0.4);\n } else if (uniforms.symbol == 4) {\n d = sdTriangle(vec2<f32>(in.uv.x, -in.uv.y + 0.1), 0.4);\n } else if (uniforms.symbol == 5) {\n d = sdCross(in.uv, 0.45, 0.15);\n } else if (uniforms.symbol == 6) {\n d = sdX(in.uv, 0.45, 0.15);\n } else if (uniforms.symbol == 7) {\n d = sdStar(in.uv, 0.45, 0.4);\n }\n \n if (d > 0.02) {\n discard;\n }\n \n let alpha = 1.0 - smoothstep(0.0, 0.02, d);\n return vec4<f32>(uniforms.color.rgb, uniforms.color.a * alpha);\n}\n`;\n\nexport const POINT_VERTEX_STRIDE = 2 * 4; // 2 floats (x, y)\n","/**\n * Point Pipeline - WebGPU pipeline for rendering scatter points with SDF symbols\n * \n * Uses instanced rendering where each point is rendered as a quad (2 triangles).\n * Uses `any` types for WebGPU objects to avoid requiring @webgpu/types.\n */\n\nimport { POINT_QUAD_SHADER_WGSL, POINT_VERTEX_STRIDE } from \"../shaders/point.wgsl\";\n\nexport interface PointPipelineBundle {\n pipeline: any; // GPURenderPipeline\n bindGroupLayout: any; // GPUBindGroupLayout\n uniformBuffer: any; // GPUBuffer\n bindGroup: any; // GPUBindGroup\n quadBuffer: any; // GPUBuffer - Pre-generated quad vertices\n vertexStride: number;\n}\n\nexport interface PointUniforms {\n scale: [number, number];\n translate: [number, number];\n color: [number, number, number, number];\n pointSize: number;\n symbol: number; // 0=circle, 1=square, 2=diamond, 3=triangle, 4=triangleDown, 5=cross, 6=x, 7=star\n viewport: [number, number];\n}\n\n// Uniform buffer layout:\n// scale(2) + translate(2) + color(4) + pointSize(1) + symbol(1) + viewport(2) = 12 floats = 48 bytes\nconst UNIFORM_BUFFER_SIZE = 48;\n\n// Quad vertex offsets (6 vertices for 2 triangles)\nconst QUAD_VERTICES = new Float32Array([\n -1, -1, // bottom-left\n 1, -1, // bottom-right\n -1, 1, // top-left\n -1, 1, // top-left\n 1, -1, // bottom-right\n 1, 1, // top-right\n]);\n\nexport function createPointPipeline(\n device: any, // GPUDevice\n format: string // GPUTextureFormat\n): PointPipelineBundle {\n const module = device.createShaderModule({ code: POINT_QUAD_SHADER_WGSL });\n\n const GPUShaderStageAny = (globalThis as any).GPUShaderStage;\n const GPUBufferUsageAny = (globalThis as any).GPUBufferUsage;\n\n // Create bind group layout\n const bindGroupLayout = device.createBindGroupLayout({\n entries: [\n {\n binding: 0,\n visibility: GPUShaderStageAny.VERTEX | GPUShaderStageAny.FRAGMENT,\n buffer: { type: \"uniform\" },\n },\n ],\n });\n\n // Create uniform buffer\n const uniformBuffer = device.createBuffer({\n size: UNIFORM_BUFFER_SIZE,\n usage: GPUBufferUsageAny.UNIFORM | GPUBufferUsageAny.COPY_DST,\n });\n\n // Create quad vertex buffer\n const quadBuffer = device.createBuffer({\n size: QUAD_VERTICES.byteLength,\n usage: GPUBufferUsageAny.VERTEX | GPUBufferUsageAny.COPY_DST,\n mappedAtCreation: true,\n });\n new Float32Array(quadBuffer.getMappedRange()).set(QUAD_VERTICES);\n quadBuffer.unmap();\n\n // Create bind group\n const bindGroup = device.createBindGroup({\n layout: bindGroupLayout,\n entries: [\n {\n binding: 0,\n resource: { buffer: uniformBuffer },\n },\n ],\n });\n\n // Create pipeline layout\n const pipelineLayout = device.createPipelineLayout({\n bindGroupLayouts: [bindGroupLayout],\n });\n\n const pipeline = device.createRenderPipeline({\n layout: pipelineLayout,\n vertex: {\n module,\n entryPoint: \"vs_main\",\n buffers: [\n // Point positions (instanced)\n {\n arrayStride: POINT_VERTEX_STRIDE,\n stepMode: \"instance\",\n attributes: [\n { shaderLocation: 0, offset: 0, format: \"float32x2\" },\n ],\n },\n // Quad vertex offsets (per-vertex)\n {\n arrayStride: 8, // 2 floats\n stepMode: \"vertex\",\n attributes: [\n { shaderLocation: 1, offset: 0, format: \"float32x2\" },\n ],\n },\n ],\n },\n fragment: {\n module,\n entryPoint: \"fs_main\",\n targets: [\n {\n format,\n blend: {\n color: {\n srcFactor: \"src-alpha\",\n dstFactor: \"one-minus-src-alpha\",\n operation: \"add\",\n },\n alpha: {\n srcFactor: \"one\",\n dstFactor: \"one-minus-src-alpha\",\n operation: \"add\",\n },\n },\n },\n ],\n },\n primitive: {\n topology: \"triangle-list\",\n cullMode: \"none\",\n },\n });\n\n return {\n pipeline,\n bindGroupLayout,\n uniformBuffer,\n bindGroup,\n quadBuffer,\n vertexStride: POINT_VERTEX_STRIDE,\n };\n}\n\nexport function updatePointUniforms(\n device: any, // GPUDevice\n uniformBuffer: any, // GPUBuffer\n uniforms: PointUniforms\n): void {\n // Pack data: scale(2) + translate(2) + color(4) + pointSize(1) + symbol(1 as float) + viewport(2)\n const data = new Float32Array([\n uniforms.scale[0],\n uniforms.scale[1],\n uniforms.translate[0],\n uniforms.translate[1],\n uniforms.color[0],\n uniforms.color[1],\n uniforms.color[2],\n uniforms.color[3],\n uniforms.pointSize,\n uniforms.symbol, // Will be cast to i32 in shader via bitcast\n uniforms.viewport[0],\n uniforms.viewport[1],\n ]);\n device.queue.writeBuffer(uniformBuffer, 0, data);\n}\n\nexport const SYMBOL_MAP: Record<string, number> = {\n circle: 0,\n square: 1,\n diamond: 2,\n triangle: 3,\n triangleDown: 4,\n cross: 5,\n x: 6,\n star: 7,\n};\n","/**\n * Band Pipeline - WebGPU pipeline for rendering band/area fills\n * \n * Uses triangle-strip topology for efficient area rendering.\n * Reuses the line shader with different primitive topology.\n * Uses `any` types for WebGPU objects to avoid requiring @webgpu/types.\n */\n\nimport { LINE_SHADER_WGSL, LINE_VERTEX_STRIDE } from \"../shaders/line.wgsl\";\n\nexport interface BandPipelineBundle {\n pipeline: any; // GPURenderPipeline\n bindGroupLayout: any; // GPUBindGroupLayout\n uniformBuffer: any; // GPUBuffer\n bindGroup: any; // GPUBindGroup\n vertexStride: number;\n}\n\nexport interface BandUniforms {\n scale: [number, number];\n translate: [number, number];\n color: [number, number, number, number];\n}\n\n// Same as line uniforms\nconst UNIFORM_BUFFER_SIZE = 32;\n\nexport function createBandPipeline(\n device: any, // GPUDevice\n format: string // GPUTextureFormat\n): BandPipelineBundle {\n const module = device.createShaderModule({ code: LINE_SHADER_WGSL });\n\n const GPUShaderStageAny = (globalThis as any).GPUShaderStage;\n const GPUBufferUsageAny = (globalThis as any).GPUBufferUsage;\n\n // Create bind group layout\n const bindGroupLayout = device.createBindGroupLayout({\n entries: [\n {\n binding: 0,\n visibility: GPUShaderStageAny.VERTEX | GPUShaderStageAny.FRAGMENT,\n buffer: { type: \"uniform\" },\n },\n ],\n });\n\n // Create uniform buffer\n const uniformBuffer = device.createBuffer({\n size: UNIFORM_BUFFER_SIZE,\n usage: GPUBufferUsageAny.UNIFORM | GPUBufferUsageAny.COPY_DST,\n });\n\n // Create bind group\n const bindGroup = device.createBindGroup({\n layout: bindGroupLayout,\n entries: [\n {\n binding: 0,\n resource: { buffer: uniformBuffer },\n },\n ],\n });\n\n // Create pipeline layout\n const pipelineLayout = device.createPipelineLayout({\n bindGroupLayouts: [bindGroupLayout],\n });\n\n const pipeline = device.createRenderPipeline({\n layout: pipelineLayout,\n vertex: {\n module,\n entryPoint: \"vs_main\",\n buffers: [\n {\n arrayStride: LINE_VERTEX_STRIDE,\n attributes: [\n { shaderLocation: 0, offset: 0, format: \"float32x2\" },\n ],\n },\n ],\n },\n fragment: {\n module,\n entryPoint: \"fs_main\",\n targets: [\n {\n format,\n blend: {\n color: {\n srcFactor: \"src-alpha\",\n dstFactor: \"one-minus-src-alpha\",\n operation: \"add\",\n },\n alpha: {\n srcFactor: \"one\",\n dstFactor: \"one-minus-src-alpha\",\n operation: \"add\",\n },\n },\n },\n ],\n },\n primitive: {\n topology: \"triangle-strip\", // Key difference from line pipeline\n stripIndexFormat: undefined,\n },\n });\n\n return {\n pipeline,\n bindGroupLayout,\n uniformBuffer,\n bindGroup,\n vertexStride: LINE_VERTEX_STRIDE,\n };\n}\n\nexport function updateBandUniforms(\n device: any, // GPUDevice\n uniformBuffer: any, // GPUBuffer\n uniforms: BandUniforms\n): void {\n const data = new Float32Array([\n uniforms.scale[0],\n uniforms.scale[1],\n uniforms.translate[0],\n uniforms.translate[1],\n uniforms.color[0],\n uniforms.color[1],\n uniforms.color[2],\n uniforms.color[3],\n ]);\n device.queue.writeBuffer(uniformBuffer, 0, data);\n}\n","/**\n * Heatmap Shader - WGSL for WebGPU\n * \n * Renders heatmap cells with colormap texture lookup.\n * Each vertex has position (x, y) and value (z) for color mapping.\n */\n\nexport const HEATMAP_SHADER_WGSL = `\n// Uniform buffer for transforms and value range\nstruct Uniforms {\n scale: vec2<f32>,\n translate: vec2<f32>,\n minValue: f32,\n maxValue: f32,\n _padding: vec2<f32>,\n};\n\n@group(0) @binding(0)\nvar<uniform> uniforms: Uniforms;\n\n@group(0) @binding(1)\nvar colormapSampler: sampler;\n\n@group(0) @binding(2)\nvar colormapTexture: texture_1d<f32>;\n\nstruct VSInput {\n @location(0) position: vec2<f32>,\n @location(1) value: f32,\n};\n\nstruct VSOutput {\n @builtin(position) pos: vec4<f32>,\n @location(0) value: f32,\n};\n\n@vertex\nfn vs_main(in: VSInput) -> VSOutput {\n var out: VSOutput;\n let transformed = in.position * uniforms.scale + uniforms.translate;\n out.pos = vec4<f32>(transformed, 0.0, 1.0);\n out.value = in.value;\n return out;\n}\n\n@fragment\nfn fs_main(in: VSOutput) -> @location(0) vec4<f32> {\n let range = uniforms.maxValue - uniforms.minValue;\n var t: f32;\n if (range != 0.0) {\n t = (in.value - uniforms.minValue) / range;\n } else {\n t = 0.0;\n }\n t = clamp(t, 0.0, 1.0);\n \n return textureSample(colormapTexture, colormapSampler, t);\n}\n`;\n\n// Heatmap vertex: position (2 floats) + value (1 float) = 12 bytes\nexport const HEATMAP_VERTEX_STRIDE = 3 * 4; // 12 bytes\n","/**\n * Heatmap Pipeline - WebGPU pipeline for rendering heatmaps with colormap textures\n * \n * Uses `any` types for WebGPU objects to avoid requiring @webgpu/types.\n */\n\nimport { HEATMAP_SHADER_WGSL, HEATMAP_VERTEX_STRIDE } from \"../shaders/heatmap.wgsl\";\n\nexport interface HeatmapPipelineBundle {\n pipeline: any; // GPURenderPipeline\n bindGroupLayout: any; // GPUBindGroupLayout\n uniformBuffer: any; // GPUBuffer\n sampler: any; // GPUSampler\n vertexStride: number;\n}\n\nexport interface HeatmapUniforms {\n scale: [number, number];\n translate: [number, number];\n minValue: number;\n maxValue: number;\n}\n\n// Uniform buffer layout: scale(2) + translate(2) + minValue(1) + maxValue(1) + padding(2) = 8 floats = 32 bytes\nconst UNIFORM_BUFFER_SIZE = 32;\n\nexport function createHeatmapPipeline(\n device: any, // GPUDevice\n format: string // GPUTextureFormat\n): HeatmapPipelineBundle {\n const module = device.createShaderModule({ code: HEATMAP_SHADER_WGSL });\n\n const GPUShaderStageAny = (globalThis as any).GPUShaderStage;\n const GPUBufferUsageAny = (globalThis as any).GPUBufferUsage;\n\n // Create bind group layout\n const bindGroupLayout = device.createBindGroupLayout({\n entries: [\n {\n binding: 0,\n visibility: GPUShaderStageAny.VERTEX | GPUShaderStageAny.FRAGMENT,\n buffer: { type: \"uniform\" },\n },\n {\n binding: 1,\n visibility: GPUShaderStageAny.FRAGMENT,\n sampler: {},\n },\n {\n binding: 2,\n visibility: GPUShaderStageAny.FRAGMENT,\n texture: { \n sampleType: \"float\",\n viewDimension: \"1d\",\n },\n },\n ],\n });\n\n // Create uniform buffer\n const uniformBuffer = device.createBuffer({\n size: UNIFORM_BUFFER_SIZE,\n usage: GPUBufferUsageAny.UNIFORM | GPUBufferUsageAny.COPY_DST,\n });\n\n // Create sampler\n const sampler = device.createSampler({\n magFilter: \"linear\",\n minFilter: \"linear\",\n addressModeU: \"clamp-to-edge\",\n });\n\n // Create pipeline layout\n const pipelineLayout = device.createPipelineLayout({\n bindGroupLayouts: [bindGroupLayout],\n });\n\n const pipeline = device.createRenderPipeline({\n layout: pipelineLayout,\n vertex: {\n module,\n entryPoint: \"vs_main\",\n buffers: [\n {\n arrayStride: HEATMAP_VERTEX_STRIDE,\n attributes: [\n { shaderLocation: 0, offset: 0, format: \"float32x2\" }, // position\n { shaderLocation: 1, offset: 8, format: \"float32\" }, // value\n ],\n },\n ],\n },\n fragment: {\n module,\n entryPoint: \"fs_main\",\n targets: [\n {\n format,\n blend: {\n color: {\n srcFactor: \"src-alpha\",\n dstFactor: \"one-minus-src-alpha\",\n operation: \"add\",\n },\n alpha: {\n srcFactor: \"one\",\n dstFactor: \"one-minus-src-alpha\",\n operation: \"add\",\n },\n },\n },\n ],\n },\n primitive: {\n topology: \"triangle-list\",\n cullMode: \"none\",\n },\n });\n\n return {\n pipeline,\n bindGroupLayout,\n uniformBuffer,\n sampler,\n vertexStride: HEATMAP_VERTEX_STRIDE,\n };\n}\n\nexport function createHeatmapBindGroup(\n device: any, // GPUDevice\n layout: any, // GPUBindGroupLayout\n uniformBuffer: any, // GPUBuffer\n sampler: any, // GPUSampler\n colormapTexture: any // GPUTexture\n): any { // GPUBindGroup\n return device.createBindGroup({\n layout,\n entries: [\n { binding: 0, resource: { buffer: uniformBuffer } },\n { binding: 1, resource: sampler },\n { binding: 2, resource: colormapTexture.createView() },\n ],\n });\n}\n\nexport function updateHeatmapUniforms(\n device: any, // GPUDevice\n uniformBuffer: any, // GPUBuffer\n uniforms: HeatmapUniforms\n): void {\n const data = new Float32Array([\n uniforms.scale[0],\n uniforms.scale[1],\n uniforms.translate[0],\n uniforms.translate[1],\n uniforms.minValue,\n uniforms.maxValue,\n 0, // padding\n 0, // padding\n ]);\n device.queue.writeBuffer(uniformBuffer, 0, data);\n}\n","import type {\n BufferDescriptor,\n BufferId,\n GpuBackend,\n GpuBackendInfo,\n GpuViewport,\n Texture1DDescriptor,\n TextureId,\n} from \"../../types\";\nimport type { DrawCall, DrawList, PointStyle, HeatmapStyle } from \"../../drawList\";\nimport type { FrameUniforms } from \"../../frame\";\nimport {\n createTrianglePipeline,\n type TrianglePipelineBundle,\n} from \"./pipelines/trianglePipeline\";\nimport {\n createLinePipeline,\n updateLineUniforms,\n type LinePipelineBundle,\n} from \"./pipelines/linePipeline\";\nimport {\n createPointPipeline,\n updatePointUniforms,\n SYMBOL_MAP,\n type PointPipelineBundle,\n} from \"./pipelines/pointPipeline\";\nimport {\n createBandPipeline,\n updateBandUniforms,\n type BandPipelineBundle,\n} from \"./pipelines/bandPipeline\";\nimport {\n createHeatmapPipeline,\n createHeatmapBindGroup,\n updateHeatmapUniforms,\n type HeatmapPipelineBundle,\n} from \"./pipelines/heatmapPipeline\";\n\nexport interface WebGPUBackendOptions {\n powerPreference?: \"low-power\" | \"high-performance\";\n preferredFormat?: string;\n}\n\n/**\n * Calculate transform uniforms from bounds\n */\nfunction calculateUniforms(bounds: {\n xMin: number;\n xMax: number;\n yMin: number;\n yMax: number;\n}): { scale: [number, number]; translate: [number, number] } {\n const dataWidth = bounds.xMax - bounds.xMin;\n const dataHeight = bounds.yMax - bounds.yMin;\n\n const scaleX = dataWidth > 0 ? 2 / dataWidth : 1;\n const scaleY = dataHeight > 0 ? 2 / dataHeight : 1;\n\n const translateX = -1 - bounds.xMin * scaleX;\n const translateY = -1 - bounds.yMin * scaleY;\n\n return {\n scale: [scaleX, scaleY],\n translate: [translateX, translateY],\n };\n}\n\n/**\n * Parse color from style, returning RGBA values 0-1\n */\nfunction getColorFromStyle(style: any): [number, number, number, number] {\n const color = style?.color ?? [1, 0, 0.3, 1];\n const opacity = style?.opacity ?? 1;\n \n // If color is already RGBA tuple\n if (Array.isArray(color)) {\n return [color[0], color[1], color[2], (color[3] ?? 1) * opacity];\n }\n \n return [1, 0, 0.3, opacity]; // Default magenta\n}\n\nexport class WebGPUBackend implements GpuBackend {\n public readonly info: GpuBackendInfo;\n\n private canvas: HTMLCanvasElement;\n private opts: WebGPUBackendOptions;\n\n private viewport: GpuViewport | null = null;\n\n private adapter: any;\n private device: any;\n private context: any;\n private format: string | null = null;\n\n private buffers = new Map<string, any>();\n private textures = new Map<string, any>();\n\n // Pipelines for different draw types\n private trianglePipeline: TrianglePipelineBundle | null = null;\n private linePipeline: LinePipelineBundle | null = null;\n private pointPipeline: PointPipelineBundle | null = null;\n private bandPipeline: BandPipelineBundle | null = null;\n private heatmapPipeline: HeatmapPipelineBundle | null = null;\n\n // Heatmap bind groups (per texture)\n private heatmapBindGroups = new Map<string, any>();\n\n constructor(canvas: HTMLCanvasElement, opts: WebGPUBackendOptions = {}) {\n this.canvas = canvas;\n this.opts = opts;\n this.info = {\n type: \"webgpu\",\n available: WebGPUBackend.isSupported(),\n };\n }\n\n static isSupported(): boolean {\n return (\n typeof (globalThis as any).navigator !== \"undefined\" &&\n typeof (globalThis as any).navigator.gpu !== \"undefined\"\n );\n }\n\n async init(): Promise<void> {\n if (!this.info.available) {\n throw new Error(\"[gpu] WebGPU not supported\");\n }\n\n const gpu = (globalThis as any).navigator.gpu;\n\n this.adapter = await gpu.requestAdapter({\n powerPreference: this.opts.powerPreference ?? \"high-performance\",\n });\n\n if (!this.adapter) {\n throw new Error(\"[gpu] Failed to request WebGPU adapter\");\n }\n\n this.device = await this.adapter.requestDevice();\n\n const ctx = (this.canvas as any).getContext(\"webgpu\");\n if (!ctx) {\n throw new Error(\"[gpu] Failed to get WebGPU canvas context\");\n }\n\n this.context = ctx;\n\n const format =\n this.opts.preferredFormat ??\n (gpu.getPreferredCanvasFormat\n ? gpu.getPreferredCanvasFormat()\n : \"bgra8unorm\");\n\n this.format = format;\n\n this.context.configure({\n device: this.device,\n format,\n alphaMode: \"premultiplied\",\n });\n }\n\n setViewport(viewport: GpuViewport): void {\n this.viewport = viewport;\n const w = Math.max(1, Math.floor(viewport.width * viewport.dpr));\n const h = Math.max(1, Math.floor(viewport.height * viewport.dpr));\n if (this.canvas.width !== w) this.canvas.width = w;\n if (this.canvas.height !== h) this.canvas.height = h;\n }\n\n createOrUpdateBuffer(\n id: BufferId,\n data: ArrayBufferView,\n desc?: Partial<BufferDescriptor>\n ): void {\n if (!this.device) {\n throw new Error(\"[gpu] WebGPUBackend not initialized\");\n }\n\n const usage = desc?.usage ?? \"vertex\";\n const GPUBufferUsageAny = (globalThis as any).GPUBufferUsage;\n if (!GPUBufferUsageAny) {\n throw new Error(\n \"[gpu] GPUBufferUsage not available (missing WebGPU runtime)\"\n );\n }\n\n const usageFlags =\n usage === \"index\"\n ? GPUBufferUsageAny.INDEX | GPUBufferUsageAny.COPY_DST\n : usage === \"uniform\"\n ? GPUBufferUsageAny.UNIFORM | GPUBufferUsageAny.COPY_DST\n : GPUBufferUsageAny.VERTEX | GPUBufferUsageAny.COPY_DST;\n\n const byteLength = data.byteLength;\n\n let buf = this.buffers.get(id);\n if (!buf || buf.size < byteLength) {\n if (buf) {\n try {\n buf.destroy();\n } catch {}\n }\n buf = this.device.createBuffer({\n size: Math.max(4, byteLength),\n usage: usageFlags,\n });\n this.buffers.set(id, buf);\n }\n\n this.device.queue.writeBuffer(\n buf,\n 0,\n data.buffer,\n data.byteOffset,\n data.byteLength\n );\n }\n\n deleteBuffer(id: BufferId): void {\n const buf = this.buffers.get(id);\n if (buf) {\n try {\n buf.destroy();\n } catch {}\n this.buffers.delete(id);\n }\n }\n\n createOrUpdateTexture1D(\n id: TextureId,\n data: Uint8Array,\n desc?: Partial<Texture1DDescriptor>\n ): void {\n if (!this.device) {\n throw new Error(\"[gpu] WebGPUBackend not initialized\");\n }\n\n const width = desc?.width ?? Math.floor(data.length / 4);\n const format = desc?.format ?? \"rgba8unorm\";\n\n const GPUTextureUsageAny = (globalThis as any).GPUTextureUsage;\n if (!GPUTextureUsageAny) {\n throw new Error(\n \"[gpu] GPUTextureUsage not available (missing WebGPU runtime)\"\n );\n }\n\n let tex = this.textures.get(id);\n if (!tex) {\n tex = this.device.createTexture({\n size: { width, height: 1, depthOrArrayLayers: 1 },\n format,\n dimension: \"1d\",\n usage: GPUTextureUsageAny.TEXTURE_BINDING | GPUTextureUsageAny.COPY_DST,\n });\n this.textures.set(id, tex);\n \n // Invalidate heatmap bind group for this texture\n this.heatmapBindGroups.delete(id);\n }\n\n this.device.queue.writeTexture(\n { texture: tex },\n data,\n { bytesPerRow: width * 4 },\n { width, height: 1, depthOrArrayLayers: 1 }\n );\n }\n\n deleteTexture(id: TextureId): void {\n const tex = this.textures.get(id);\n if (tex) {\n try {\n tex.destroy();\n } catch {}\n this.textures.delete(id);\n this.heatmapBindGroups.delete(id);\n }\n }\n\n /**\n * Initialize all pipelines lazily\n */\n private ensurePipelines(): void {\n if (!this.trianglePipeline) {\n this.trianglePipeline = createTrianglePipeline(this.device, this.format!);\n }\n if (!this.linePipeline) {\n this.linePipeline = createLinePipeline(this.device, this.format!);\n }\n if (!this.pointPipeline) {\n this.pointPipeline = createPointPipeline(this.device, this.format!);\n }\n if (!this.bandPipeline) {\n this.bandPipeline = createBandPipeline(this.device, this.format!);\n }\n if (!this.heatmapPipeline) {\n this.heatmapPipeline = createHeatmapPipeline(this.device, this.format!);\n }\n }\n\n render(drawList: DrawList, frame: FrameUniforms): void {\n if (!this.device || !this.context || !this.format) {\n throw new Error(\"[gpu] WebGPUBackend not initialized\");\n }\n\n if (!this.viewport) {\n this.setViewport(frame.viewport);\n }\n\n this.ensurePipelines();\n\n const encoder = this.device.createCommandEncoder();\n const view = this.context.getCurrentTexture().createView();\n\n const pass = encoder.beginRenderPass({\n colorAttachments: [\n {\n view,\n clearValue: {\n r: frame.clearColor[0],\n g: frame.clearColor[1],\n b: frame.clearColor[2],\n a: frame.clearColor[3],\n },\n loadOp: \"clear\",\n storeOp: \"store\",\n },\n ],\n });\n\n // Default bounds (NDC if not specified)\n const defaultBounds = { xMin: -1, xMax: 1, yMin: -1, yMax: 1 };\n\n for (const item of drawList.items) {\n if (!item.visible) continue;\n\n const buf = this.buffers.get(item.bufferId);\n if (!buf) continue;\n\n this.renderDrawCall(pass, item, buf, defaultBounds);\n }\n\n pass.end();\n this.device.queue.submit([encoder.finish()]);\n }\n\n /**\n * Render with explicit bounds (for integration with chart system)\n */\n renderWithBounds(\n drawList: DrawList,\n frame: FrameUniforms,\n bounds: { xMin: number; xMax: number; yMin: number; yMax: number }\n ): void {\n if (!this.device || !this.context || !this.format) {\n throw new Error(\"[gpu] WebGPUBackend not initialized\");\n }\n\n if (!this.viewport) {\n this.setViewport(frame.viewport);\n }\n\n this.ensurePipelines();\n\n const encoder = this.device.createCommandEncoder();\n const view = this.context.getCurrentTexture().createView();\n\n const pass = encoder.beginRenderPass({\n colorAttachments: [\n {\n view,\n clearValue: {\n r: frame.clearColor[0],\n g: frame.clearColor[1],\n b: frame.clearColor[2],\n a: frame.clearColor[3],\n },\n loadOp: \"clear\",\n storeOp: \"store\",\n },\n ],\n });\n\n for (const item of drawList.items) {\n if (!item.visible) continue;\n\n const buf = this.buffers.get(item.bufferId);\n if (!buf) continue;\n\n // Use item's yBounds if specified, otherwise use global bounds\n const itemBounds = item.yBounds\n ? { ...bounds, yMin: item.yBounds.min, yMax: item.yBounds.max }\n : bounds;\n\n this.renderDrawCall(pass, item, buf, itemBounds);\n }\n\n pass.end();\n this.device.queue.submit([encoder.finish()]);\n }\n\n /**\n * Render a single draw call\n */\n private renderDrawCall(\n pass: any,\n item: DrawCall,\n buf: any,\n bounds: { xMin: number; xMax: number; yMin: number; yMax: number }\n ): void {\n const uniforms = calculateUniforms(bounds);\n const color = getColorFromStyle(item.style);\n\n switch (item.kind) {\n case \"triangles\":\n case \"bar\":\n this.renderSolidTriangles(pass, buf, item.count, uniforms, color);\n break;\n\n case \"line\":\n this.renderLine(pass, buf, item.count, uniforms, color);\n break;\n\n case \"scatter\":\n case \"points\":\n this.renderPoints(pass, buf, item.count, uniforms, color, item.style as PointStyle);\n break;\n\n case \"line+scatter\":\n this.renderLine(pass, buf, item.count, uniforms, color);\n this.renderPoints(pass, buf, item.count, uniforms, color, item.style as PointStyle);\n break;\n\n case \"step\":\n // Use step buffer if available\n if (item.stepBufferId && item.stepCount) {\n const stepBuf = this.buffers.get(item.stepBufferId);\n if (stepBuf) {\n this.renderLine(pass, stepBuf, item.stepCount, uniforms, color);\n }\n } else {\n this.renderLine(pass, buf, item.count, uniforms, color);\n }\n break;\n\n case \"step+scatter\":\n if (item.stepBufferId && item.stepCount) {\n const stepBuf = this.buffers.get(item.stepBufferId);\n if (stepBuf) {\n this.renderLine(pass, stepBuf, item.stepCount, uniforms, color);\n }\n } else {\n this.renderLine(pass, buf, item.count, uniforms, color);\n }\n this.renderPoints(pass, buf, item.count, uniforms, color, item.style as PointStyle);\n break;\n\n case \"band\":\n // Band uses semi-transparent color\n const bandColor: [number, number, number, number] = [\n color[0],\n color[1],\n color[2],\n color[3] * 0.4,\n ];\n this.renderBand(pass, buf, item.count, uniforms, bandColor);\n break;\n\n case \"heatmap\":\n this.renderHeatmap(pass, buf, item.count, uniforms, item.style as HeatmapStyle, item.textureId);\n break;\n }\n }\n\n /** Triangle list with line-pipeline uniforms (xy vertices, uniform color). */\n private renderSolidTriangles(\n pass: any,\n buf: any,\n count: number,\n uniforms: { scale: [number, number]; translate: [number, number] },\n color: [number, number, number, number],\n ): void {\n updateLineUniforms(this.device, this.linePipeline!.uniformBuffer, {\n scale: uniforms.scale,\n translate: uniforms.translate,\n color,\n });\n pass.setPipeline(this.linePipeline!.pipeline);\n pass.setBindGroup(0, this.linePipeline!.bindGroup);\n pass.setVertexBuffer(0, buf);\n pass.draw(count);\n }\n\n private renderLine(\n pass: any,\n buf: any,\n count: number,\n uniforms: { scale: [number, number]; translate: [number, number] },\n color: [number, number, number, number]\n ): void {\n updateLineUniforms(this.device, this.linePipeline!.uniformBuffer, {\n scale: uniforms.scale,\n translate: uniforms.translate,\n color,\n });\n pass.setPipeline(this.linePipeline!.pipeline);\n pass.setBindGroup(0, this.linePipeline!.bindGroup);\n pass.setVertexBuffer(0, buf);\n pass.draw(count);\n }\n\n private renderPoints(\n pass: any,\n buf: any,\n count: number,\n uniforms: { scale: [number, number]; translate: [number, number] },\n color: [number, number, number, number],\n style?: PointStyle\n ): void {\n const pointSize = (style?.pointSize ?? 4) * (this.viewport?.dpr ?? 1);\n const symbol = SYMBOL_MAP[style?.symbol ?? \"circle\"] ?? 0;\n const viewport: [number, number] = [\n this.canvas.width,\n this.canvas.height,\n ];\n\n updatePointUniforms(this.device, this.pointPipeline!.uniformBuffer, {\n scale: uniforms.scale,\n translate: uniforms.translate,\n color,\n pointSize,\n symbol,\n viewport,\n });\n\n pass.setPipeline(this.pointPipeline!.pipeline);\n pass.setBindGroup(0, this.pointPipeline!.bindGroup);\n pass.setVertexBuffer(0, buf); // Point positions (instanced)\n pass.setVertexBuffer(1, this.pointPipeline!.quadBuffer); // Quad vertices\n pass.draw(6, count); // 6 vertices per quad, count instances\n }\n\n private renderBand(\n pass: any,\n buf: any,\n count: number,\n uniforms: { scale: [number, number]; translate: [number, number] },\n color: [number, number, number, number]\n ): void {\n updateBandUniforms(this.device, this.bandPipeline!.uniformBuffer, {\n scale: uniforms.scale,\n translate: uniforms.translate,\n color,\n });\n pass.setPipeline(this.bandPipeline!.pipeline);\n pass.setBindGroup(0, this.bandPipeline!.bindGroup);\n pass.setVertexBuffer(0, buf);\n pass.draw(count);\n }\n\n private renderHeatmap(\n pass: any,\n buf: any,\n count: number,\n uniforms: { scale: [number, number]; translate: [number, number] },\n style?: HeatmapStyle,\n textureId?: string\n ): void {\n if (!textureId) return;\n \n const tex = this.textures.get(textureId);\n if (!tex) return;\n\n const zBounds = style?.zBounds ?? { min: 0, max: 1 };\n\n updateHeatmapUniforms(this.device, this.heatmapPipeline!.uniformBuffer, {\n scale: uniforms.scale,\n translate: uniforms.translate,\n minValue: zBounds.min,\n maxValue: zBounds.max,\n });\n\n // Get or create bind group for this texture\n let bindGroup = this.heatmapBindGroups.get(textureId);\n if (!bindGroup) {\n bindGroup = createHeatmapBindGroup(\n this.device,\n this.heatmapPipeline!.bindGroupLayout,\n this.heatmapPipeline!.uniformBuffer,\n this.heatmapPipeline!.sampler,\n tex\n );\n this.heatmapBindGroups.set(textureId, bindGroup);\n }\n\n pass.setPipeline(this.heatmapPipeline!.pipeline);\n pass.setBindGroup(0, bindGroup);\n pass.setVertexBuffer(0, buf);\n pass.draw(count);\n }\n\n destroy(): void {\n for (const id of Array.from(this.buffers.keys())) {\n this.deleteBuffer(id);\n }\n for (const id of Array.from(this.textures.keys())) {\n this.deleteTexture(id);\n }\n\n this.trianglePipeline = null;\n this.linePipeline = null;\n this.pointPipeline = null;\n this.bandPipeline = null;\n this.heatmapPipeline = null;\n this.heatmapBindGroups.clear();\n\n this.device = undefined;\n this.adapter = undefined;\n this.context = undefined;\n this.format = null;\n }\n}\n","/**\n * WebGL Shader Sources\n * \n * GLSL shaders for the WebGL backend.\n * These match the functionality of the WebGPU WGSL shaders.\n */\n\n// ============================================\n// Line Shader\n// ============================================\n\nexport const LINE_VERT_GLSL = `\nprecision highp float;\nattribute vec2 aPosition;\nuniform vec2 uScale;\nuniform vec2 uTranslate;\n\nvoid main() {\n vec2 pos = aPosition * uScale + uTranslate;\n gl_Position = vec4(pos, 0.0, 1.0);\n}\n`;\n\nexport const LINE_FRAG_GLSL = `\nprecision highp float;\nuniform vec4 uColor;\n\nvoid main() {\n gl_FragColor = uColor;\n}\n`;\n\n// ============================================\n// Point Shader (with SDF symbols)\n// ============================================\n\nexport const POINT_VERT_GLSL = `\nprecision highp float;\nattribute vec2 aPosition;\nuniform vec2 uScale;\nuniform vec2 uTranslate;\nuniform float uPointSize;\n\nvoid main() {\n vec2 pos = aPosition * uScale + uTranslate;\n gl_Position = vec4(pos, 0.0, 1.0);\n gl_PointSize = uPointSize;\n}\n`;\n\nexport const POINT_FRAG_GLSL = `\nprecision highp float;\nuniform vec4 uColor;\nuniform int uSymbol;\n\nfloat sdCircle(vec2 p, float r) {\n return length(p) - r;\n}\n\nfloat sdBox(vec2 p, vec2 b) {\n vec2 d = abs(p) - b;\n return length(max(d, 0.0)) + min(max(d.x, d.y), 0.0);\n}\n\nfloat sdTriangle(vec2 p, float r) {\n const float k = sqrt(3.0);\n p.x = abs(p.x) - r;\n p.y = p.y + r / k;\n if (p.x + k * p.y > 0.0) p = vec2(p.x - k * p.y, -k * p.x - p.y) / 2.0;\n p.x -= clamp(p.x, -2.0 * r, 0.0);\n return -length(p) * sign(p.y);\n}\n\nfloat sdDiamond(vec2 p, float r) {\n return (abs(p.x) + abs(p.y)) - r;\n}\n\nfloat sdCross(vec2 p, float r, float thickness) {\n vec2 d = abs(p);\n float s1 = sdBox(d, vec2(r, thickness));\n float s2 = sdBox(d, vec2(thickness, r));\n return min(s1, s2);\n}\n\nfloat sdX(vec2 p, float r, float thickness) {\n float c = cos(0.785398);\n float s = sin(0.785398);\n mat2 m = mat2(c, -s, s, c);\n return sdCross(m * p, r, thickness);\n}\n\nfloat sdStar(vec2 p, float r, float rf) {\n const vec2 k1 = vec2(0.80901699, -0.58778525);\n const vec2 k2 = vec2(-k1.x, k1.y);\n p.x = abs(p.x);\n p -= 2.0 * max(dot(k1, p), 0.0) * k1;\n p -= 2.0 * max(dot(k2, p), 0.0) * k2;\n p.x = abs(p.x);\n p.y -= r;\n vec2 ba = rf * vec2(-k1.y, k1.x) - vec2(0, 1);\n float h = clamp(dot(p, ba) / dot(ba, ba), 0.0, r);\n return length(p - ba * h) * sign(p.y * ba.x - p.x * ba.y);\n}\n\nvoid main() {\n vec2 p = gl_PointCoord - vec2(0.5);\n float d = 0.0;\n\n if (uSymbol == 0) {\n d = sdCircle(p, 0.45);\n } else if (uSymbol == 1) {\n d = sdBox(p, vec2(0.35));\n } else if (uSymbol == 2) {\n d = sdDiamond(p, 0.45);\n } else if (uSymbol == 3) {\n d = sdTriangle(vec2(p.x, p.y + 0.1), 0.4);\n } else if (uSymbol == 4) {\n d = sdTriangle(vec2(p.x, -p.y + 0.1), 0.4);\n } else if (uSymbol == 5) {\n d = sdCross(p, 0.45, 0.15);\n } else if (uSymbol == 6) {\n d = sdX(p, 0.45, 0.15);\n } else if (uSymbol == 7) {\n d = sdStar(p, 0.45, 0.4);\n }\n\n if (d > 0.02) discard;\n\n float alpha = 1.0 - smoothstep(0.0, 0.02, d);\n gl_FragColor = vec4(uColor.rgb, uColor.a * alpha);\n}\n`;\n\n// ============================================\n// Heatmap Shader\n// ============================================\n\nexport const HEATMAP_VERT_GLSL = `\nprecision highp float;\nattribute vec2 aPosition;\nattribute float aValue;\nuniform vec2 uScale;\nuniform vec2 uTranslate;\nvarying float vValue;\n\nvoid main() {\n gl_Position = vec4(aPosition * uScale + uTranslate, 0.0, 1.0);\n vValue = aValue;\n}\n`;\n\nexport const HEATMAP_FRAG_GLSL = `\nprecision highp float;\nvarying float vValue;\nuniform float uMinValue;\nuniform float uMaxValue;\nuniform sampler2D uColormap;\n\nvoid main() {\n float range = uMaxValue - uMinValue;\n float t = (vValue - uMinValue) / (range != 0.0 ? range : 1.0);\n t = clamp(t, 0.0, 1.0);\n gl_FragColor = texture2D(uColormap, vec2(t, 0.5));\n}\n`;\n\n// ============================================\n// Triangle Shader (for bands and bars)\n// ============================================\n\nexport const TRIANGLE_VERT_GLSL = `\nprecision highp float;\nattribute vec2 aPosition;\nattribute vec4 aColor;\nuniform vec2 uScale;\nuniform vec2 uTranslate;\nvarying vec4 vColor;\n\nvoid main() {\n vec2 pos = aPosition * uScale + uTranslate;\n gl_Position = vec4(pos, 0.0, 1.0);\n vColor = aColor;\n}\n`;\n\nexport const TRIANGLE_FRAG_GLSL = `\nprecision highp float;\nvarying vec4 vColor;\n\nvoid main() {\n gl_FragColor = vColor;\n}\n`;\n","/**\n * WebGL Program Factory\n * \n * Utilities for compiling and linking WebGL shader programs.\n */\n\nimport {\n LINE_VERT_GLSL,\n LINE_FRAG_GLSL,\n POINT_VERT_GLSL,\n POINT_FRAG_GLSL,\n HEATMAP_VERT_GLSL,\n HEATMAP_FRAG_GLSL,\n} from \"./shaders\";\n\nexport interface ShaderProgram {\n program: WebGLProgram;\n attributes: Record<string, number>;\n uniforms: Record<string, WebGLUniformLocation | null>;\n}\n\n/**\n * Compile a shader\n */\nfunction compileShader(\n gl: WebGLRenderingContext,\n type: number,\n source: string\n): WebGLShader {\n const shader = gl.createShader(type);\n if (!shader) {\n throw new Error(\"[WebGL] Failed to create shader\");\n }\n\n gl.shaderSource(shader, source);\n gl.compileShader(shader);\n\n if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {\n const info = gl.getShaderInfoLog(shader);\n gl.deleteShader(shader);\n throw new Error(`[WebGL] Shader compilation error: ${info}`);\n }\n\n return shader;\n}\n\n/**\n * Link a shader program\n */\nfunction linkProgram(\n gl: WebGLRenderingContext,\n vertShader: WebGLShader,\n fragShader: WebGLShader\n): WebGLProgram {\n const program = gl.createProgram();\n if (!program) {\n throw new Error(\"[WebGL] Failed to create program\");\n }\n\n gl.attachShader(program, vertShader);\n gl.attachShader(program, fragShader);\n gl.linkProgram(program);\n\n if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {\n const info = gl.getProgramInfoLog(program);\n gl.deleteProgram(program);\n throw new Error(`[WebGL] Program link error: ${info}`);\n }\n\n return program;\n}\n\n/**\n * Create a shader program from source\n */\nexport function createProgram(\n gl: WebGLRenderingContext,\n vertSource: string,\n fragSource: string,\n attributeNames: string[],\n uniformNames: string[]\n): ShaderProgram {\n const vertShader = compileShader(gl, gl.VERTEX_SHADER, vertSource);\n const fragShader = compileShader(gl, gl.FRAGMENT_SHADER, fragSource);\n const program = linkProgram(gl, vertShader, fragShader);\n\n // Clean up individual shaders (they're linked now)\n gl.deleteShader(vertShader);\n gl.deleteShader(fragShader);\n\n // Get attribute locations\n const attributes: Record<string, number> = {};\n for (const name of attributeNames) {\n attributes[name] = gl.getAttribLocation(program, name);\n }\n\n // Get uniform locations\n const uniforms: Record<string, WebGLUniformLocation | null> = {};\n for (const name of uniformNames) {\n uniforms[name] = gl.getUniformLocation(program, name);\n }\n\n return { program, attributes, uniforms };\n}\n\n/**\n * All programs used by the WebGL backend\n */\nexport interface ProgramBundle {\n line: ShaderProgram;\n point: ShaderProgram;\n heatmap: ShaderProgram;\n}\n\n/**\n * Create all shader programs\n */\nexport function createAllPrograms(gl: WebGLRenderingContext): ProgramBundle {\n const line = createProgram(\n gl,\n LINE_VERT_GLSL,\n LINE_FRAG_GLSL,\n [\"aPosition\"],\n [\"uScale\", \"uTranslate\", \"uColor\"]\n );\n\n const point = createProgram(\n gl,\n POINT_VERT_GLSL,\n POINT_FRAG_GLSL,\n [\"aPosition\"],\n [\"uScale\", \"uTranslate\", \"uColor\", \"uPointSize\", \"uSymbol\"]\n );\n\n const heatmap = createProgram(\n gl,\n HEATMAP_VERT_GLSL,\n HEATMAP_FRAG_GLSL,\n [\"aPosition\", \"aValue\"],\n [\"uScale\", \"uTranslate\", \"uMinValue\", \"uMaxValue\", \"uColormap\"]\n );\n\n return { line, point, heatmap };\n}\n\n/**\n * Destroy all programs\n */\nexport function destroyPrograms(gl: WebGLRenderingContext, bundle: ProgramBundle): void {\n gl.deleteProgram(bundle.line.program);\n gl.deleteProgram(bundle.point.program);\n gl.deleteProgram(bundle.heatmap.program);\n}\n","/**\n * WebGL Backend - GPU abstraction layer implementation for WebGL\n * \n * Provides the same interface as WebGPUBackend for compatibility.\n * This serves as a fallback for browsers without WebGPU support.\n */\n\nimport type {\n BufferDescriptor,\n BufferId,\n GpuBackend,\n GpuBackendInfo,\n GpuViewport,\n Texture1DDescriptor,\n TextureId,\n} from \"../../types\";\nimport type { DrawCall, DrawList, PointStyle, HeatmapStyle } from \"../../drawList\";\nimport type { FrameUniforms } from \"../../frame\";\nimport { createAllPrograms, destroyPrograms, type ProgramBundle } from \"./programFactory\";\n\nexport interface WebGLBackendOptions {\n antialias?: boolean;\n preserveDrawingBuffer?: boolean;\n powerPreference?: \"default\" | \"low-power\" | \"high-performance\";\n}\n\n/**\n * Symbol name to number mapping\n */\nconst SYMBOL_MAP: Record<string, number> = {\n circle: 0,\n square: 1,\n diamond: 2,\n triangle: 3,\n triangleDown: 4,\n cross: 5,\n x: 6,\n star: 7,\n};\n\n/**\n * Calculate transform uniforms from bounds\n */\nfunction calculateUniforms(bounds: {\n xMin: number;\n xMax: number;\n yMin: number;\n yMax: number;\n}): { scale: [number, number]; translate: [number, number] } {\n const dataWidth = bounds.xMax - bounds.xMin;\n const dataHeight = bounds.yMax - bounds.yMin;\n\n const scaleX = dataWidth > 0 ? 2 / dataWidth : 1;\n const scaleY = dataHeight > 0 ? 2 / dataHeight : 1;\n\n const translateX = -1 - bounds.xMin * scaleX;\n const translateY = -1 - bounds.yMin * scaleY;\n\n return {\n scale: [scaleX, scaleY],\n translate: [translateX, translateY],\n };\n}\n\n/**\n * Get color from style\n */\nfunction getColorFromStyle(style: any): [number, number, number, number] {\n const color = style?.color ?? [1, 0, 0.3, 1];\n const opacity = style?.opacity ?? 1;\n \n if (Array.isArray(color)) {\n return [color[0], color[1], color[2], (color[3] ?? 1) * opacity];\n }\n \n return [1, 0, 0.3, opacity];\n}\n\nexport class WebGLBackend implements GpuBackend {\n public readonly info: GpuBackendInfo;\n\n private canvas: HTMLCanvasElement;\n private opts: WebGLBackendOptions;\n private gl: WebGLRenderingContext | null = null;\n \n private viewport: GpuViewport | null = null;\n private dpr: number = 1;\n\n private programs: ProgramBundle | null = null;\n private buffers = new Map<string, WebGLBuffer>();\n private textures = new Map<string, WebGLTexture>();\n\n constructor(canvas: HTMLCanvasElement, opts: WebGLBackendOptions = {}) {\n this.canvas = canvas;\n this.opts = opts;\n this.info = {\n type: \"webgl\",\n available: WebGLBackend.isSupported(),\n };\n }\n\n static isSupported(): boolean {\n if (typeof document === \"undefined\") return false;\n \n try {\n const canvas = document.createElement(\"canvas\");\n const gl = canvas.getContext(\"webgl\") || canvas.getContext(\"experimental-webgl\");\n return !!gl;\n } catch {\n return false;\n }\n }\n\n async init(): Promise<void> {\n if (!this.info.available) {\n throw new Error(\"[gpu] WebGL not supported\");\n }\n\n const gl = this.canvas.getContext(\"webgl\", {\n alpha: true,\n antialias: this.opts.antialias ?? true,\n preserveDrawingBuffer: this.opts.preserveDrawingBuffer ?? true,\n powerPreference: this.opts.powerPreference ?? \"high-performance\",\n });\n\n if (!gl) {\n throw new Error(\"[gpu] Failed to get WebGL context\");\n }\n\n this.gl = gl;\n\n // Enable blending\n gl.enable(gl.BLEND);\n gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);\n\n // Create shader programs\n this.programs = createAllPrograms(gl);\n }\n\n setViewport(viewport: GpuViewport): void {\n this.viewport = viewport;\n this.dpr = viewport.dpr;\n \n const w = Math.max(1, Math.floor(viewport.width * viewport.dpr));\n const h = Math.max(1, Math.floor(viewport.height * viewport.dpr));\n \n if (this.canvas.width !== w) this.canvas.width = w;\n if (this.canvas.height !== h) this.canvas.height = h;\n \n if (this.gl) {\n this.gl.viewport(0, 0, w, h);\n }\n }\n\n createOrUpdateBuffer(\n id: BufferId,\n data: ArrayBufferView,\n desc?: Partial<BufferDescriptor>\n ): void {\n if (!this.gl) {\n throw new Error(\"[gpu] WebGLBackend not initialized\");\n }\n\n const gl = this.gl;\n \n let buffer = this.buffers.get(id);\n if (!buffer) {\n buffer = gl.createBuffer()!;\n this.buffers.set(id, buffer);\n }\n\n const target = desc?.usage === \"index\" ? gl.ELEMENT_ARRAY_BUFFER : gl.ARRAY_BUFFER;\n \n gl.bindBuffer(target, buffer);\n gl.bufferData(target, data, gl.DYNAMIC_DRAW);\n gl.bindBuffer(target, null);\n }\n\n deleteBuffer(id: BufferId): void {\n if (!this.gl) return;\n \n const buffer = this.buffers.get(id);\n if (buffer) {\n this.gl.deleteBuffer(buffer);\n this.buffers.delete(id);\n }\n }\n\n createOrUpdateTexture1D(\n id: TextureId,\n data: Uint8Array,\n desc?: Partial<Texture1DDescriptor>\n ): void {\n if (!this.gl) {\n throw new Error(\"[gpu] WebGLBackend not initialized\");\n }\n\n const gl = this.gl;\n const width = desc?.width ?? Math.floor(data.length / 4);\n\n let texture = this.textures.get(id);\n if (!texture) {\n texture = gl.createTexture()!;\n this.textures.set(id, texture);\n }\n\n gl.bindTexture(gl.TEXTURE_2D, texture);\n gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, data);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);\n gl.bindTexture(gl.TEXTURE_2D, null);\n }\n\n deleteTexture(id: TextureId): void {\n if (!this.gl) return;\n \n const texture = this.textures.get(id);\n if (texture) {\n this.gl.deleteTexture(texture);\n this.textures.delete(id);\n }\n }\n\n render(drawList: DrawList, frame: FrameUniforms): void {\n this.renderWithBounds(drawList, frame, { xMin: -1, xMax: 1, yMin: -1, yMax: 1 });\n }\n\n renderWithBounds(\n drawList: DrawList,\n frame: FrameUniforms,\n bounds: { xMin: number; xMax: number; yMin: number; yMax: number }\n ): void {\n if (!this.gl || !this.programs) {\n throw new Error(\"[gpu] WebGLBackend not initialized\");\n }\n\n const gl = this.gl;\n\n if (!this.viewport) {\n this.setViewport(frame.viewport);\n }\n\n // Clear\n gl.clearColor(\n frame.clearColor[0],\n frame.clearColor[1],\n frame.clearColor[2],\n frame.clearColor[3]\n );\n gl.clear(gl.COLOR_BUFFER_BIT);\n\n // Render each draw call\n for (const item of drawList.items) {\n if (!item.visible) continue;\n\n const buffer = this.buffers.get(item.bufferId);\n if (!buffer) continue;\n\n // Use item's yBounds if specified\n const itemBounds = item.yBounds\n ? { ...bounds, yMin: item.yBounds.min, yMax: item.yBounds.max }\n : bounds;\n\n this.renderDrawCall(item, buffer, itemBounds);\n }\n }\n\n private renderDrawCall(\n item: DrawCall,\n buffer: WebGLBuffer,\n bounds: { xMin: number; xMax: number; yMin: number; yMax: number }\n ): void {\n const uniforms = calculateUniforms(bounds);\n const color = getColorFromStyle(item.style);\n\n switch (item.kind) {\n case \"line\":\n case \"step\":\n this.renderLine(buffer, item.count, uniforms, color);\n break;\n\n case \"scatter\":\n case \"points\":\n this.renderPoints(buffer, item.count, uniforms, color, item.style as PointStyle);\n break;\n\n case \"line+scatter\":\n this.renderLine(buffer, item.count, uniforms, color);\n this.renderPoints(buffer, item.count, uniforms, color, item.style as PointStyle);\n break;\n\n case \"step+scatter\":\n if (item.stepBufferId && item.stepCount) {\n const stepBuffer = this.buffers.get(item.stepBufferId);\n if (stepBuffer) {\n this.renderLine(stepBuffer, item.stepCount, uniforms, color);\n }\n } else {\n this.renderLine(buffer, item.count, uniforms, color);\n }\n this.renderPoints(buffer, item.count, uniforms, color, item.style as PointStyle);\n break;\n\n case \"band\":\n const bandColor: [number, number, number, number] = [\n color[0], color[1], color[2], color[3] * 0.4\n ];\n this.renderBand(buffer, item.count, uniforms, bandColor);\n break;\n\n case \"triangles\":\n case \"bar\":\n this.renderTriangles(buffer, item.count, uniforms, color);\n break;\n\n case \"heatmap\":\n this.renderHeatmap(buffer, item.count, uniforms, item.style as HeatmapStyle, item.textureId);\n break;\n }\n }\n\n private renderLine(\n buffer: WebGLBuffer,\n count: number,\n uniforms: { scale: [number, number]; translate: [number, number] },\n color: [number, number, number, number]\n ): void {\n const gl = this.gl!;\n const prog = this.programs!.line;\n\n gl.useProgram(prog.program);\n gl.bindBuffer(gl.ARRAY_BUFFER, buffer);\n\n gl.enableVertexAttribArray(prog.attributes.aPosition);\n gl.vertexAttribPointer(prog.attributes.aPosition, 2, gl.FLOAT, false, 0, 0);\n\n gl.uniform2f(prog.uniforms.uScale!, uniforms.scale[0], uniforms.scale[1]);\n gl.uniform2f(prog.uniforms.uTranslate!, uniforms.translate[0], uniforms.translate[1]);\n gl.uniform4f(prog.uniforms.uColor!, color[0], color[1], color[2], color[3]);\n\n gl.drawArrays(gl.LINE_STRIP, 0, count);\n gl.disableVertexAttribArray(prog.attributes.aPosition);\n }\n\n private renderPoints(\n buffer: WebGLBuffer,\n count: number,\n uniforms: { scale: [number, number]; translate: [number, number] },\n color: [number, number, number, number],\n style?: PointStyle\n ): void {\n const gl = this.gl!;\n const prog = this.programs!.point;\n\n const pointSize = (style?.pointSize ?? 4) * this.dpr;\n const symbol = SYMBOL_MAP[style?.symbol ?? \"circle\"] ?? 0;\n\n gl.useProgram(prog.program);\n gl.bindBuffer(gl.ARRAY_BUFFER, buffer);\n\n gl.enableVertexAttribArray(prog.attributes.aPosition);\n gl.vertexAttribPointer(prog.attributes.aPosition, 2, gl.FLOAT, false, 0, 0);\n\n gl.uniform2f(prog.uniforms.uScale!, uniforms.scale[0], uniforms.scale[1]);\n gl.uniform2f(prog.uniforms.uTranslate!, uniforms.translate[0], uniforms.translate[1]);\n gl.uniform4f(prog.uniforms.uColor!, color[0], color[1], color[2], color[3]);\n gl.uniform1f(prog.uniforms.uPointSize!, pointSize);\n gl.uniform1i(prog.uniforms.uSymbol!, symbol);\n\n gl.drawArrays(gl.POINTS, 0, count);\n gl.disableVertexAttribArray(prog.attributes.aPosition);\n }\n\n private renderBand(\n buffer: WebGLBuffer,\n count: number,\n uniforms: { scale: [number, number]; translate: [number, number] },\n color: [number, number, number, number]\n ): void {\n const gl = this.gl!;\n const prog = this.programs!.line;\n\n gl.useProgram(prog.program);\n gl.bindBuffer(gl.ARRAY_BUFFER, buffer);\n\n gl.enableVertexAttribArray(prog.attributes.aPosition);\n gl.vertexAttribPointer(prog.attributes.aPosition, 2, gl.FLOAT, false, 0, 0);\n\n gl.uniform2f(prog.uniforms.uScale!, uniforms.scale[0], uniforms.scale[1]);\n gl.uniform2f(prog.uniforms.uTranslate!, uniforms.translate[0], uniforms.translate[1]);\n gl.uniform4f(prog.uniforms.uColor!, color[0], color[1], color[2], color[3]);\n\n gl.drawArrays(gl.TRIANGLE_STRIP, 0, count);\n gl.disableVertexAttribArray(prog.attributes.aPosition);\n }\n\n private renderTriangles(\n buffer: WebGLBuffer,\n count: number,\n uniforms: { scale: [number, number]; translate: [number, number] },\n color: [number, number, number, number]\n ): void {\n const gl = this.gl!;\n const prog = this.programs!.line;\n\n gl.useProgram(prog.program);\n gl.bindBuffer(gl.ARRAY_BUFFER, buffer);\n\n gl.enableVertexAttribArray(prog.attributes.aPosition);\n gl.vertexAttribPointer(prog.attributes.aPosition, 2, gl.FLOAT, false, 0, 0);\n\n gl.uniform2f(prog.uniforms.uScale!, uniforms.scale[0], uniforms.scale[1]);\n gl.uniform2f(prog.uniforms.uTranslate!, uniforms.translate[0], uniforms.translate[1]);\n gl.uniform4f(prog.uniforms.uColor!, color[0], color[1], color[2], color[3]);\n\n gl.drawArrays(gl.TRIANGLES, 0, count);\n gl.disableVertexAttribArray(prog.attributes.aPosition);\n }\n\n private renderHeatmap(\n buffer: WebGLBuffer,\n count: number,\n uniforms: { scale: [number, number]; translate: [number, number] },\n style?: HeatmapStyle,\n textureId?: string\n ): void {\n if (!textureId) return;\n \n const texture = this.textures.get(textureId);\n if (!texture) return;\n\n const gl = this.gl!;\n const prog = this.programs!.heatmap;\n\n const zBounds = style?.zBounds ?? { min: 0, max: 1 };\n\n gl.useProgram(prog.program);\n gl.bindBuffer(gl.ARRAY_BUFFER, buffer);\n\n gl.enableVertexAttribArray(prog.attributes.aPosition);\n gl.vertexAttribPointer(prog.attributes.aPosition, 2, gl.FLOAT, false, 12, 0);\n\n if (prog.attributes.aValue !== -1) {\n gl.enableVertexAttribArray(prog.attributes.aValue);\n gl.vertexAttribPointer(prog.attributes.aValue, 1, gl.FLOAT, false, 12, 8);\n }\n\n gl.uniform2f(prog.uniforms.uScale!, uniforms.scale[0], uniforms.scale[1]);\n gl.uniform2f(prog.uniforms.uTranslate!, uniforms.translate[0], uniforms.translate[1]);\n gl.uniform1f(prog.uniforms.uMinValue!, zBounds.min);\n gl.uniform1f(prog.uniforms.uMaxValue!, zBounds.max);\n\n gl.activeTexture(gl.TEXTURE0);\n gl.bindTexture(gl.TEXTURE_2D, texture);\n gl.uniform1i(prog.uniforms.uColormap!, 0);\n\n gl.drawArrays(gl.TRIANGLES, 0, count);\n\n gl.disableVertexAttribArray(prog.attributes.aPosition);\n if (prog.attributes.aValue !== -1) {\n gl.disableVertexAttribArray(prog.attributes.aValue);\n }\n }\n\n destroy(): void {\n if (!this.gl) return;\n\n const gl = this.gl;\n\n // Delete all buffers\n for (const buffer of this.buffers.values()) {\n gl.deleteBuffer(buffer);\n }\n this.buffers.clear();\n\n // Delete all textures\n for (const texture of this.textures.values()) {\n gl.deleteTexture(texture);\n }\n this.textures.clear();\n\n // Delete programs\n if (this.programs) {\n destroyPrograms(gl, this.programs);\n this.programs = null;\n }\n\n this.gl = null;\n }\n}\n","/**\n * Series Adapter - Converts SciPlot series data to GPU DrawCalls\n * \n * This adapter bridges the gap between the existing SciPlot series system\n * and the new backend-agnostic GPU abstraction layer.\n */\n\nimport type { \n DrawCall, \n DrawList, \n DrawKind, \n PointStyle,\n HeatmapStyle,\n} from \"../drawList\";\nimport type { GpuBackend, BufferId, TextureId, RGBA } from \"../types\";\n\n/**\n * Series style from the original renderer\n */\nexport interface SeriesStyle {\n color?: string | RGBA;\n opacity?: number;\n lineWidth?: number;\n pointSize?: number;\n symbol?: string;\n}\n\n/**\n * Series render data from the chart system\n */\nexport interface SeriesData {\n id: string;\n type: \"line\" | \"scatter\" | \"line+scatter\" | \"step\" | \"step+scatter\" | \"band\" | \"bar\" | \"heatmap\";\n visible: boolean;\n \n /** Main vertex data */\n data: Float32Array;\n \n /** Style properties */\n style: SeriesStyle;\n \n /** For step charts */\n stepData?: Float32Array;\n \n /** Y-axis bounds for multi-axis support */\n yBounds?: { min: number; max: number };\n \n /** For heatmaps */\n zBounds?: { min: number; max: number };\n colormapData?: Uint8Array;\n colormap?: string;\n}\n\n/**\n * Mutable color tuple for internal use\n */\ntype MutableRGBA = [number, number, number, number];\n\n/**\n * Parse color from various formats to RGBA\n */\nexport function parseColorToRGBA(color: string | RGBA | undefined): MutableRGBA {\n if (!color) {\n return [1, 0, 0.3, 1]; // Default magenta\n }\n \n // If already an RGBA tuple, return a copy\n if (Array.isArray(color)) {\n return [color[0], color[1], color[2], color[3] ?? 1];\n }\n \n // At this point, color must be a string\n const colorStr = color as string;\n \n // Parse hex color\n if (colorStr.startsWith(\"#\")) {\n const hex = colorStr.slice(1);\n if (hex.length === 3) {\n const r = parseInt(hex[0] + hex[0], 16) / 255;\n const g = parseInt(hex[1] + hex[1], 16) / 255;\n const b = parseInt(hex[2] + hex[2], 16) / 255;\n return [r, g, b, 1];\n }\n if (hex.length === 6) {\n const r = parseInt(hex.slice(0, 2), 16) / 255;\n const g = parseInt(hex.slice(2, 4), 16) / 255;\n const b = parseInt(hex.slice(4, 6), 16) / 255;\n return [r, g, b, 1];\n }\n if (hex.length === 8) {\n const r = parseInt(hex.slice(0, 2), 16) / 255;\n const g = parseInt(hex.slice(2, 4), 16) / 255;\n const b = parseInt(hex.slice(4, 6), 16) / 255;\n const a = parseInt(hex.slice(6, 8), 16) / 255;\n return [r, g, b, a];\n }\n }\n \n // Parse rgb/rgba\n const rgbaMatch = colorStr.match(/rgba?\\((\\d+),\\s*(\\d+),\\s*(\\d+)(?:,\\s*([\\d.]+))?\\)/);\n if (rgbaMatch) {\n const r = parseInt(rgbaMatch[1]) / 255;\n const g = parseInt(rgbaMatch[2]) / 255;\n const b = parseInt(rgbaMatch[3]) / 255;\n const a = rgbaMatch[4] ? parseFloat(rgbaMatch[4]) : 1;\n return [r, g, b, a];\n }\n \n return [1, 0, 0.3, 1]; // Fallback\n}\n\n/**\n * Map series type to draw kind\n */\nfunction mapSeriesTypeToDrawKind(type: SeriesData[\"type\"]): DrawKind {\n return type as DrawKind;\n}\n\n/**\n * Convert SeriesStyle to GPU styles\n */\nfunction convertStyle(style: SeriesStyle, type: SeriesData[\"type\"]): DrawCall[\"style\"] {\n const baseColor = parseColorToRGBA(style.color);\n const opacity = style.opacity ?? 1;\n const color: MutableRGBA = [baseColor[0], baseColor[1], baseColor[2], baseColor[3] * opacity];\n \n if (type === \"scatter\" || type === \"line+scatter\" || type === \"step+scatter\") {\n return {\n color: color as RGBA,\n opacity,\n pointSize: style.pointSize ?? 4,\n symbol: (style.symbol ?? \"circle\") as PointStyle[\"symbol\"],\n } as PointStyle;\n }\n \n return {\n color: color as RGBA,\n opacity,\n lineWidth: style.lineWidth ?? 1,\n };\n}\n\n/**\n * Series Adapter class\n * \n * Manages the conversion of chart series to GPU resources and draw calls.\n */\nexport class SeriesAdapter {\n private backend: GpuBackend;\n private seriesBufferMap = new Map<string, BufferId>();\n private seriesStepBufferMap = new Map<string, BufferId>();\n private seriesTextureMap = new Map<string, TextureId>();\n \n constructor(backend: GpuBackend) {\n this.backend = backend;\n }\n \n /**\n * Get buffer ID for a series\n */\n private getBufferId(seriesId: string): BufferId {\n if (!this.seriesBufferMap.has(seriesId)) {\n this.seriesBufferMap.set(seriesId, `series:${seriesId}`);\n }\n return this.seriesBufferMap.get(seriesId)!;\n }\n \n /**\n * Get step buffer ID for a series\n */\n private getStepBufferId(seriesId: string): BufferId {\n if (!this.seriesStepBufferMap.has(seriesId)) {\n this.seriesStepBufferMap.set(seriesId, `series:${seriesId}:step`);\n }\n return this.seriesStepBufferMap.get(seriesId)!;\n }\n \n /**\n * Get texture ID for a series\n */\n private getTextureId(seriesId: string): TextureId {\n if (!this.seriesTextureMap.has(seriesId)) {\n this.seriesTextureMap.set(seriesId, `texture:${seriesId}`);\n }\n return this.seriesTextureMap.get(seriesId)!;\n }\n \n /**\n * Update series data in GPU buffers\n */\n updateSeries(series: SeriesData): void {\n const bufferId = this.getBufferId(series.id);\n \n // Update main buffer\n this.backend.createOrUpdateBuffer(bufferId, series.data, { usage: \"vertex\" });\n \n // Update step buffer if present\n if (series.stepData && (series.type === \"step\" || series.type === \"step+scatter\")) {\n const stepBufferId = this.getStepBufferId(series.id);\n this.backend.createOrUpdateBuffer(stepBufferId, series.stepData, { usage: \"vertex\" });\n }\n \n // Update colormap texture if present\n if (series.type === \"heatmap\" && series.colormapData) {\n const textureId = this.getTextureId(series.id);\n this.backend.createOrUpdateTexture1D(textureId, series.colormapData, {\n width: series.colormapData.length / 4,\n });\n }\n }\n \n /**\n * Remove a series from GPU resources\n */\n removeSeries(seriesId: string): void {\n const bufferId = this.seriesBufferMap.get(seriesId);\n if (bufferId) {\n this.backend.deleteBuffer(bufferId);\n this.seriesBufferMap.delete(seriesId);\n }\n \n const stepBufferId = this.seriesStepBufferMap.get(seriesId);\n if (stepBufferId) {\n this.backend.deleteBuffer(stepBufferId);\n this.seriesStepBufferMap.delete(seriesId);\n }\n \n const textureId = this.seriesTextureMap.get(seriesId);\n if (textureId) {\n this.backend.deleteTexture(textureId);\n this.seriesTextureMap.delete(seriesId);\n }\n }\n \n /**\n * Build draw list from series array\n */\n buildDrawList(seriesArray: SeriesData[]): DrawList {\n const items: DrawCall[] = [];\n \n for (const series of seriesArray) {\n // Update GPU resources\n this.updateSeries(series);\n \n const bufferId = this.getBufferId(series.id);\n const pointCount = series.data.length / 2; // Assuming x,y pairs\n \n const drawCall: DrawCall = {\n id: series.id,\n kind: mapSeriesTypeToDrawKind(series.type),\n bufferId,\n count: series.type === \"heatmap\" ? series.data.length / 3 : pointCount,\n visible: series.visible,\n style: convertStyle(series.style, series.type),\n yBounds: series.yBounds,\n };\n \n // Step buffer\n if (series.stepData && (series.type === \"step\" || series.type === \"step+scatter\")) {\n drawCall.stepBufferId = this.getStepBufferId(series.id);\n drawCall.stepCount = series.stepData.length / 2;\n }\n \n // Heatmap texture\n if (series.type === \"heatmap\") {\n drawCall.textureId = this.getTextureId(series.id);\n (drawCall.style as HeatmapStyle) = {\n zBounds: series.zBounds,\n colormap: series.colormap,\n };\n }\n \n items.push(drawCall);\n }\n \n return { items };\n }\n \n /**\n * Cleanup all resources\n */\n destroy(): void {\n for (const bufferId of this.seriesBufferMap.values()) {\n this.backend.deleteBuffer(bufferId);\n }\n for (const stepBufferId of this.seriesStepBufferMap.values()) {\n this.backend.deleteBuffer(stepBufferId);\n }\n for (const textureId of this.seriesTextureMap.values()) {\n this.backend.deleteTexture(textureId);\n }\n \n this.seriesBufferMap.clear();\n this.seriesStepBufferMap.clear();\n this.seriesTextureMap.clear();\n }\n}\n","/**\n * GPU Renderer Facade - Drop-in replacement for NativeWebGLRenderer\n * \n * Provides the same interface as NativeWebGLRenderer but uses the\n * backend-agnostic GPU abstraction layer. Supports both WebGPU and WebGL.\n */\n\nimport type { GpuBackend, RGBA } from \"../types\";\nimport type { DrawList, DrawCall, PointStyle } from \"../drawList\";\nimport type { FrameUniforms } from \"../frame\";\nimport { WebGPUBackend } from \"../backends/webgpu/WebGPUBackend\";\nimport { WebGLBackend } from \"../backends/webgl/WebGLBackend\";\nimport { SeriesAdapter, parseColorToRGBA } from \"./seriesAdapter\";\nimport type { SeriesStyle } from \"./seriesAdapter\";\nimport type { NativeSeriesRenderData } from \"../../renderer/native/types\";\n\n/**\n * Bounds interface matching the original\n */\nexport interface Bounds {\n xMin: number;\n xMax: number;\n yMin: number;\n yMax: number;\n}\n\n/**\n * Series render data matching NativeSeriesRenderData\n */\nexport interface GpuSeriesRenderData {\n id: string;\n type: \"line\" | \"scatter\" | \"line+scatter\" | \"step\" | \"step+scatter\" | \"band\" | \"bar\" | \"heatmap\";\n visible: boolean;\n style: SeriesStyle;\n \n /** Y-bounds for multi-axis support */\n yBounds?: { min: number; max: number };\n \n /** Heatmap specific */\n zBounds?: { min: number; max: number };\n colormap?: string;\n}\n\n/**\n * Render options matching NativeRenderOptions\n */\nexport interface GpuRenderOptions {\n bounds: Bounds;\n backgroundColor?: [number, number, number, number];\n plotArea?: { x: number; y: number; width: number; height: number };\n}\n\nexport interface GpuNativeRenderOptions extends GpuRenderOptions {\n invertX?: boolean;\n plotAreaBackground?: [number, number, number, number];\n dpr?: number;\n}\n\n/**\n * Backend preference\n */\nexport type BackendPreference = \"webgpu\" | \"webgl\" | \"auto\";\n\n/**\n * GPU Renderer options\n */\nexport interface GpuRendererOptions {\n backend?: BackendPreference;\n powerPreference?: \"low-power\" | \"high-performance\";\n}\n\n/**\n * GPU Renderer - Unified renderer using the GPU abstraction layer\n */\nexport class GpuRenderer {\n private canvas: HTMLCanvasElement;\n private options: GpuRendererOptions;\n private backend: GpuBackend | null = null;\n private adapter: SeriesAdapter | null = null;\n \n private dpr: number;\n private isInitialized = false;\n private backendType: \"webgpu\" | \"webgl\" | null = null;\n \n // Buffer management\n private bufferDataMap = new Map<string, Float32Array>();\n private stepBufferDataMap = new Map<string, Float32Array>();\n private colormapDataMap = new Map<string, Uint8Array>();\n \n constructor(canvas: HTMLCanvasElement, options: GpuRendererOptions = {}) {\n this.canvas = canvas;\n this.options = options;\n this.dpr = window.devicePixelRatio || 1;\n }\n \n /**\n * Initialize the renderer\n */\n async init(): Promise<boolean> {\n const preference = this.options.backend ?? \"auto\";\n \n // Try WebGPU first if preferred or auto\n if (preference === \"webgpu\" || preference === \"auto\") {\n if (WebGPUBackend.isSupported()) {\n try {\n const backend = new WebGPUBackend(this.canvas, {\n powerPreference: this.options.powerPreference ?? \"high-performance\",\n });\n await backend.init();\n \n this.backend = backend;\n this.backendType = \"webgpu\";\n this.adapter = new SeriesAdapter(backend);\n this.isInitialized = true;\n \n this.resize();\n return true;\n } catch (e) {\n console.warn(\"[GpuRenderer] WebGPU init failed:\", e);\n }\n }\n }\n \n // Fallback to WebGL\n if (preference === \"webgl\" || preference === \"auto\") {\n if (WebGLBackend.isSupported()) {\n try {\n const backend = new WebGLBackend(this.canvas, {\n powerPreference: this.options.powerPreference ?? \"high-performance\",\n });\n await backend.init();\n \n this.backend = backend;\n this.backendType = \"webgl\";\n this.adapter = new SeriesAdapter(backend);\n this.isInitialized = true;\n \n this.resize();\n console.info(\"[GpuRenderer] Using WebGL backend (WebGPU not available)\");\n return true;\n } catch (e) {\n console.warn(\"[GpuRenderer] WebGL init failed:\", e);\n }\n }\n }\n \n return false;\n }\n \n /**\n * Check if renderer is available\n */\n get available(): boolean {\n return this.isInitialized;\n }\n \n /**\n * Get the active backend type\n */\n get activeBackend(): \"webgpu\" | \"webgl\" | null {\n return this.backendType;\n }\n \n /**\n * Set device pixel ratio\n */\n setDPR(dpr: number): void {\n this.dpr = dpr;\n this.resize();\n }\n \n /**\n * Check if vertex data exists for a buffer id\n */\n hasBuffer(id: string): boolean {\n return this.bufferDataMap.has(id) || this.stepBufferDataMap.has(id);\n }\n\n hasColormap(id: string): boolean {\n return this.colormapDataMap.has(id);\n }\n\n /**\n * Render from NativeWebGLRenderer-compatible series descriptors (chart integration path).\n */\n renderNativeSeries(\n series: NativeSeriesRenderData[],\n options: GpuNativeRenderOptions,\n ): void {\n if (!this.isInitialized || !this.backend) return;\n\n const items: DrawCall[] = [];\n\n for (const s of series) {\n if (!s.visible) continue;\n\n if (s.type === \"boxplot\") {\n this.appendBoxplotDraws(s, items);\n continue;\n }\n if (s.type === \"waterfall\") {\n this.appendWaterfallDraws(s, items);\n continue;\n }\n\n if (s.count === 0) continue;\n\n const data = this.bufferDataMap.get(s.id);\n if (!data) continue;\n\n this.backend.createOrUpdateBuffer(s.id, data, { usage: \"vertex\" });\n\n const baseColor = parseColorToRGBA(\n typeof s.style?.color === \"string\" ? s.style.color : \"#00f2ff\",\n );\n const opacity = s.style?.opacity ?? 1;\n const color: [number, number, number, number] = [\n baseColor[0],\n baseColor[1],\n baseColor[2],\n baseColor[3] * opacity,\n ];\n\n const kind = this.mapNativeDrawKind(s.type);\n const drawCall: DrawCall = {\n id: s.id,\n kind,\n bufferId: s.id,\n count: s.count,\n visible: true,\n yBounds: s.yBounds,\n };\n\n if (\n kind === \"scatter\" ||\n kind === \"line+scatter\" ||\n kind === \"step+scatter\" ||\n kind === \"points\"\n ) {\n drawCall.style = {\n color: color as RGBA,\n opacity,\n pointSize: s.style?.pointSize ?? 4,\n symbol: (s.style?.symbol ?? \"circle\") as PointStyle[\"symbol\"],\n };\n } else if (kind === \"heatmap\") {\n drawCall.textureId = `${s.id}_colormap`;\n drawCall.style = {\n zBounds: s.zBounds,\n colormap: s.colormap,\n };\n const colormapData = this.colormapDataMap.get(`${s.id}_colormap`);\n if (colormapData) {\n this.backend.createOrUpdateTexture1D(drawCall.textureId, colormapData, {\n width: colormapData.length / 4,\n });\n }\n } else {\n drawCall.style = {\n color: color as RGBA,\n opacity,\n lineWidth: s.style?.width ?? s.style?.lineWidth ?? 1,\n };\n }\n\n if ((kind === \"step\" || kind === \"step+scatter\") && s.stepBuffer && s.stepCount) {\n const stepId = `${s.id}_step`;\n const stepData = this.stepBufferDataMap.get(stepId);\n if (stepData) {\n this.backend.createOrUpdateBuffer(stepId, stepData, { usage: \"vertex\" });\n drawCall.stepBufferId = stepId;\n drawCall.stepCount = s.stepCount;\n }\n }\n\n items.push(drawCall);\n }\n\n const dpr = options.dpr ?? this.dpr;\n const frame: FrameUniforms = {\n viewport: {\n width: this.canvas.clientWidth,\n height: this.canvas.clientHeight,\n dpr,\n },\n clearColor: (options.backgroundColor ?? [0.1, 0.1, 0.18, 1]) as RGBA,\n bounds: options.bounds,\n plotArea: options.plotArea,\n };\n\n if (\"renderWithBounds\" in this.backend) {\n (this.backend as GpuBackend & {\n renderWithBounds: (\n drawList: DrawList,\n frame: FrameUniforms,\n bounds: GpuRenderOptions[\"bounds\"],\n ) => void;\n }).renderWithBounds({ items }, frame, options.bounds);\n } else {\n this.backend.render({ items }, frame);\n }\n }\n\n private appendBoxplotDraws(s: NativeSeriesRenderData, items: DrawCall[]): void {\n const color = this.seriesColor(s.style);\n const lineStyle = { color, opacity: s.style?.opacity ?? 1, lineWidth: s.style?.width ?? 1 };\n const fillStyle = { color, opacity: (s.style?.opacity ?? 1) * 0.85, lineWidth: 1 };\n\n this.pushDraw(items, `${s.id}_box_faces`, \"bar\", s.boxCount ?? 0, fillStyle, s.yBounds);\n this.pushDraw(items, `${s.id}_box_lines`, \"line\", s.boxLinesCount ?? 0, lineStyle, s.yBounds);\n }\n\n private appendWaterfallDraws(s: NativeSeriesRenderData, items: DrawCall[]): void {\n const style = s.style ?? {};\n const positive = this.colorFromHex(style.positiveColor ?? \"#22c55e\", 0.9);\n const negative = this.colorFromHex(style.negativeColor ?? \"#ef4444\", 0.9);\n const subtotal = this.colorFromHex(style.subtotalColor ?? \"#3b82f6\", 0.9);\n const connector = this.colorFromHex(style.connectorColor ?? \"#64748b\", 0.6);\n\n this.pushDraw(items, `${s.id}_wf_positive`, \"bar\", s.wfPositiveCount ?? 0, { color: positive, opacity: 0.9, lineWidth: 1 }, s.yBounds);\n this.pushDraw(items, `${s.id}_wf_negative`, \"bar\", s.wfNegativeCount ?? 0, { color: negative, opacity: 0.9, lineWidth: 1 }, s.yBounds);\n this.pushDraw(items, `${s.id}_wf_subtotal`, \"bar\", s.wfSubtotalCount ?? 0, { color: subtotal, opacity: 0.9, lineWidth: 1 }, s.yBounds);\n if (style.showConnectors !== false) {\n this.pushDraw(items, `${s.id}_wf_connectors`, \"line\", s.wfConnectorCount ?? 0, { color: connector, opacity: 0.6, lineWidth: 1 }, s.yBounds);\n }\n }\n\n private pushDraw(\n items: DrawCall[],\n bufferId: string,\n kind: DrawCall[\"kind\"],\n count: number,\n style: DrawCall[\"style\"],\n yBounds?: { min: number; max: number },\n ): void {\n if (count <= 0) return;\n const data = this.bufferDataMap.get(bufferId);\n if (!data || !this.backend) return;\n this.backend.createOrUpdateBuffer(bufferId, data, { usage: \"vertex\" });\n items.push({\n id: bufferId,\n kind,\n bufferId,\n count,\n visible: true,\n style,\n yBounds,\n });\n }\n\n private seriesColor(style: NativeSeriesRenderData[\"style\"]): [number, number, number, number] {\n const base = parseColorToRGBA(typeof style?.color === \"string\" ? style.color : \"#00f2ff\");\n const opacity = style?.opacity ?? 1;\n return [base[0], base[1], base[2], base[3] * opacity];\n }\n\n private colorFromHex(hex: string, opacity: number): [number, number, number, number] {\n const c = parseColorToRGBA(hex);\n return [c[0], c[1], c[2], c[3] * opacity];\n }\n\n private mapNativeDrawKind(\n type: NativeSeriesRenderData[\"type\"],\n ): DrawCall[\"kind\"] {\n switch (type) {\n case \"scatter\":\n return \"scatter\";\n case \"line+scatter\":\n return \"line+scatter\";\n case \"step\":\n return \"step\";\n case \"step+scatter\":\n return \"step+scatter\";\n case \"band\":\n return \"band\";\n case \"bar\":\n return \"bar\";\n case \"heatmap\":\n return \"heatmap\";\n default:\n return \"line\";\n }\n }\n\n /**\n * Create or update a buffer\n */\n createBuffer(id: string, data: Float32Array): void {\n this.bufferDataMap.set(id, data);\n }\n \n /**\n * Update a buffer partially\n */\n updateBuffer(id: string, data: Float32Array, offsetInBytes: number): boolean {\n const existing = this.bufferDataMap.get(id);\n if (!existing) return false;\n \n const offsetFloats = offsetInBytes / 4;\n existing.set(data, offsetFloats);\n return true;\n }\n \n /**\n * Get a buffer's data\n */\n getBuffer(id: string): Float32Array | undefined {\n return this.bufferDataMap.get(id);\n }\n \n /**\n * Delete a buffer\n */\n deleteBuffer(id: string): void {\n this.bufferDataMap.delete(id);\n if (this.backend) {\n this.backend.deleteBuffer(id);\n }\n }\n \n /**\n * Create or update a step buffer\n */\n createStepBuffer(id: string, data: Float32Array): void {\n this.stepBufferDataMap.set(id, data);\n }\n \n /**\n * Create colormap texture\n */\n createColormapTexture(id: string, data: Uint8Array): void {\n this.colormapDataMap.set(id, data);\n if (this.backend) {\n this.backend.createOrUpdateTexture1D(id, data, {\n width: data.length / 4,\n });\n }\n }\n \n /**\n * Render a frame\n */\n render(series: GpuSeriesRenderData[], options: GpuRenderOptions): void {\n if (!this.isInitialized || !this.backend) return;\n \n // Build draw list\n const drawList = this.buildDrawList(series);\n \n // Create frame uniforms\n const frame: FrameUniforms = {\n viewport: {\n width: this.canvas.clientWidth,\n height: this.canvas.clientHeight,\n dpr: this.dpr,\n },\n clearColor: (options.backgroundColor ?? [0.1, 0.1, 0.18, 1]) as RGBA,\n bounds: options.bounds,\n plotArea: options.plotArea,\n };\n \n // Render using the backend\n if (\"renderWithBounds\" in this.backend) {\n (this.backend as any).renderWithBounds(drawList, frame, options.bounds);\n } else {\n this.backend.render(drawList, frame);\n }\n }\n \n /**\n * Build draw list from series data\n */\n private buildDrawList(series: GpuSeriesRenderData[]): DrawList {\n const items: DrawCall[] = [];\n \n for (const s of series) {\n const bufferData = this.bufferDataMap.get(s.id);\n if (!bufferData) continue;\n \n // Upload buffer to GPU\n this.backend!.createOrUpdateBuffer(s.id, bufferData, { usage: \"vertex\" });\n \n const pointCount = s.type === \"heatmap\" \n ? bufferData.length / 3 \n : bufferData.length / 2;\n \n const baseColor = parseColorToRGBA(s.style.color);\n const opacity = s.style.opacity ?? 1;\n const color: [number, number, number, number] = [\n baseColor[0], \n baseColor[1], \n baseColor[2], \n baseColor[3] * opacity\n ];\n \n const drawCall: DrawCall = {\n id: s.id,\n kind: s.type,\n bufferId: s.id,\n count: pointCount,\n visible: s.visible,\n yBounds: s.yBounds,\n };\n \n // Set style based on type\n if (s.type === \"scatter\" || s.type === \"line+scatter\" || s.type === \"step+scatter\") {\n drawCall.style = {\n color: color as RGBA,\n opacity,\n pointSize: s.style.pointSize ?? 4,\n symbol: (s.style.symbol ?? \"circle\") as PointStyle[\"symbol\"],\n };\n } else if (s.type === \"heatmap\") {\n drawCall.textureId = `colormap:${s.id}`;\n drawCall.style = {\n zBounds: s.zBounds,\n colormap: s.colormap,\n };\n \n // Upload colormap if available\n const colormapData = this.colormapDataMap.get(s.id);\n if (colormapData) {\n this.backend!.createOrUpdateTexture1D(drawCall.textureId, colormapData, {\n width: colormapData.length / 4,\n });\n }\n } else {\n drawCall.style = {\n color: color as RGBA,\n opacity,\n lineWidth: s.style.lineWidth ?? 1,\n };\n }\n \n // Handle step buffer\n if ((s.type === \"step\" || s.type === \"step+scatter\") && this.stepBufferDataMap.has(s.id)) {\n const stepData = this.stepBufferDataMap.get(s.id)!;\n const stepBufferId = `${s.id}:step`;\n this.backend!.createOrUpdateBuffer(stepBufferId, stepData, { usage: \"vertex\" });\n drawCall.stepBufferId = stepBufferId;\n drawCall.stepCount = stepData.length / 2;\n }\n \n items.push(drawCall);\n }\n \n return { items };\n }\n \n /**\n * Handle canvas resize\n */\n resize(): void {\n if (!this.backend) return;\n \n const rect = this.canvas.getBoundingClientRect();\n this.backend.setViewport({\n width: rect.width,\n height: rect.height,\n dpr: this.dpr,\n });\n }\n \n /**\n * Get renderer limits\n */\n getLimits(): Record<string, unknown> {\n return {\n backend: this.backendType,\n available: this.isInitialized,\n };\n }\n \n /**\n * Destroy the renderer\n */\n destroy(): void {\n this.adapter?.destroy();\n this.backend?.destroy();\n \n this.bufferDataMap.clear();\n this.stepBufferDataMap.clear();\n this.colormapDataMap.clear();\n \n this.adapter = null;\n this.backend = null;\n this.isInitialized = false;\n this.backendType = null;\n }\n}\n\n/**\n * Create a GPU renderer (async)\n */\nexport async function createGpuRenderer(\n canvas: HTMLCanvasElement,\n options?: GpuRendererOptions\n): Promise<GpuRenderer | null> {\n const renderer = new GpuRenderer(canvas, options);\n const success = await renderer.init();\n return success ? renderer : null;\n}\n"],"names":["TRIANGLE_SHADER_WGSL","createTrianglePipeline","device","format","module","vertexStride","LINE_SHADER_WGSL","LINE_VERTEX_STRIDE","UNIFORM_BUFFER_SIZE","createLinePipeline","GPUShaderStageAny","GPUBufferUsageAny","bindGroupLayout","uniformBuffer","bindGroup","pipelineLayout","updateLineUniforms","uniforms","data","POINT_QUAD_SHADER_WGSL","POINT_VERTEX_STRIDE","QUAD_VERTICES","createPointPipeline","quadBuffer","updatePointUniforms","SYMBOL_MAP","createBandPipeline","updateBandUniforms","HEATMAP_SHADER_WGSL","HEATMAP_VERTEX_STRIDE","createHeatmapPipeline","sampler","createHeatmapBindGroup","layout","colormapTexture","updateHeatmapUniforms","calculateUniforms","bounds","dataWidth","dataHeight","scaleX","scaleY","translateX","translateY","getColorFromStyle","style","color","opacity","WebGPUBackend","canvas","opts","__publicField","gpu","ctx","viewport","w","h","id","desc","usage","usageFlags","byteLength","buf","width","GPUTextureUsageAny","tex","drawList","frame","encoder","view","pass","defaultBounds","item","itemBounds","stepBuf","bandColor","count","_a","pointSize","symbol","textureId","zBounds","LINE_VERT_GLSL","LINE_FRAG_GLSL","POINT_VERT_GLSL","POINT_FRAG_GLSL","HEATMAP_VERT_GLSL","HEATMAP_FRAG_GLSL","compileShader","gl","type","source","shader","info","linkProgram","vertShader","fragShader","program","createProgram","vertSource","fragSource","attributeNames","uniformNames","attributes","name","createAllPrograms","line","point","heatmap","destroyPrograms","bundle","WebGLBackend","buffer","target","texture","stepBuffer","prog","parseColorToRGBA","colorStr","hex","r","g","b","a","rgbaMatch","convertStyle","baseColor","SeriesAdapter","backend","seriesId","series","bufferId","stepBufferId","seriesArray","items","pointCount","drawCall","GpuRenderer","options","preference","e","dpr","_b","_c","_d","_e","_f","s","kind","colormapData","stepId","stepData","lineStyle","fillStyle","positive","negative","subtotal","connector","yBounds","base","c","offsetInBytes","existing","offsetFloats","bufferData","rect","createGpuRenderer","renderer"],"mappings":";;;AAAO,MAAMA,IAAuB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACO7B,SAASC,EACdC,GACAC,GACwB;AACxB,QAAMC,IAASF,EAAO,mBAAmB,EAAE,MAAMF,GAAsB,GAEjEK,IAAe,IAAI;AA4BzB,SAAO,EAAE,UA1BQH,EAAO,qBAAqB;AAAA,IAC3C,QAAQ;AAAA,IACR,QAAQ;AAAA,MACN,QAAAE;AAAA,MACA,YAAY;AAAA,MACZ,SAAS;AAAA,QACP;AAAA,UACE,aAAaC;AAAA,UACb,YAAY;AAAA,YACV,EAAE,gBAAgB,GAAG,QAAQ,GAAG,QAAQ,YAAA;AAAA,YACxC,EAAE,gBAAgB,GAAG,QAAQ,IAAI,GAAG,QAAQ,YAAA;AAAA,UAAY;AAAA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,EAAc,WAEd,KAAK,cAAc,MAAA,GACnB,KAAK,kBAAkB,MAAA,GACvB,KAAK,gBAAgB,MAAA,GAErB,KAAK,UAAU,MACf,KAAK,UAAU,MACf,KAAK,gBAAgB,IACrB,KAAK,cAAc;AAAA,EACrB;AACF;AAKA,eAAsBwB,GACpBrH,GACAyF,GAC6B;AAC7B,QAAM6B,IAAW,IAAI9B,GAAYxF,GAAQyF,CAAO;AAEhD,SADgB,MAAM6B,EAAS,KAAA,IACdA,IAAW;AAC9B;"}
|
|
1
|
+
{"version":3,"file":"gpuRenderer-BpaMYz-k.js","sources":["../src/gpu/backends/webgpu/pipelines/triangleShader.ts","../src/gpu/backends/webgpu/pipelines/trianglePipeline.ts","../src/gpu/backends/webgpu/shaders/line.wgsl.ts","../src/gpu/backends/webgpu/pipelines/linePipeline.ts","../src/gpu/backends/webgpu/shaders/point.wgsl.ts","../src/gpu/backends/webgpu/pipelines/pointPipeline.ts","../src/gpu/backends/webgpu/pipelines/bandPipeline.ts","../src/gpu/backends/webgpu/shaders/heatmap.wgsl.ts","../src/gpu/backends/webgpu/pipelines/heatmapPipeline.ts","../src/gpu/backends/webgpu/WebGPUBackend.ts","../src/gpu/backends/webgl/shaders.ts","../src/gpu/backends/webgl/programFactory.ts","../src/gpu/backends/webgl/WebGLBackend.ts","../src/gpu/adapter/seriesAdapter.ts","../src/gpu/adapter/gpuRenderer.ts"],"sourcesContent":["export const TRIANGLE_SHADER_WGSL = `\nstruct VSOut {\n @builtin(position) pos: vec4<f32>,\n @location(0) color: vec4<f32>,\n};\n\n@vertex\nfn vs_main(\n @location(0) position: vec2<f32>,\n @location(1) color: vec4<f32>\n) -> VSOut {\n var out: VSOut;\n out.pos = vec4<f32>(position, 0.0, 1.0);\n out.color = color;\n return out;\n}\n\n@fragment\nfn fs_main(in: VSOut) -> @location(0) vec4<f32> {\n return in.color;\n}\n`;\n","import { TRIANGLE_SHADER_WGSL } from \"./triangleShader\";\n\nexport interface TrianglePipelineBundle {\n pipeline: any;\n vertexStride: number;\n}\n\nexport function createTrianglePipeline(\n device: any,\n format: string\n): TrianglePipelineBundle {\n const module = device.createShaderModule({ code: TRIANGLE_SHADER_WGSL });\n\n const vertexStride = 6 * 4;\n\n const pipeline = device.createRenderPipeline({\n layout: \"auto\",\n vertex: {\n module,\n entryPoint: \"vs_main\",\n buffers: [\n {\n arrayStride: vertexStride,\n attributes: [\n { shaderLocation: 0, offset: 0, format: \"float32x2\" },\n { shaderLocation: 1, offset: 2 * 4, format: \"float32x4\" },\n ],\n },\n ],\n },\n fragment: {\n module,\n entryPoint: \"fs_main\",\n targets: [{ format }],\n },\n primitive: {\n topology: \"triangle-list\",\n cullMode: \"none\",\n },\n });\n\n return { pipeline, vertexStride };\n}\n","/**\n * Line Shader - WGSL for WebGPU\n * \n * Renders simple line strips with uniform color.\n * Uses uniform buffer for transform (scale + translate).\n */\n\nexport const LINE_SHADER_WGSL = `\n// Uniform buffer for transforms and color\nstruct Uniforms {\n scale: vec2<f32>,\n translate: vec2<f32>,\n color: vec4<f32>,\n};\n\n@group(0) @binding(0)\nvar<uniform> uniforms: Uniforms;\n\nstruct VSInput {\n @location(0) position: vec2<f32>,\n};\n\nstruct VSOutput {\n @builtin(position) pos: vec4<f32>,\n};\n\n@vertex\nfn vs_main(in: VSInput) -> VSOutput {\n var out: VSOutput;\n let transformed = in.position * uniforms.scale + uniforms.translate;\n out.pos = vec4<f32>(transformed, 0.0, 1.0);\n return out;\n}\n\n@fragment\nfn fs_main(in: VSOutput) -> @location(0) vec4<f32> {\n return uniforms.color;\n}\n`;\n\nexport const LINE_VERTEX_STRIDE = 2 * 4; // 2 floats (x, y)\n","/**\n * Line Pipeline - WebGPU pipeline for rendering lines with uniform buffer\n * \n * Uses `any` types for WebGPU objects to avoid requiring @webgpu/types\n * (following the pattern of the original WebGPUBackend.ts)\n */\n\nimport { LINE_SHADER_WGSL, LINE_VERTEX_STRIDE } from \"../shaders/line.wgsl\";\n\nexport interface LinePipelineBundle {\n pipeline: any; // GPURenderPipeline\n bindGroupLayout: any; // GPUBindGroupLayout\n uniformBuffer: any; // GPUBuffer\n bindGroup: any; // GPUBindGroup\n vertexStride: number;\n}\n\nexport interface LineUniforms {\n scale: [number, number];\n translate: [number, number];\n color: [number, number, number, number];\n}\n\n// Uniform buffer layout: scale(2) + translate(2) + color(4) = 8 floats = 32 bytes\nconst UNIFORM_BUFFER_SIZE = 32;\n\nexport function createLinePipeline(\n device: any, // GPUDevice\n format: string // GPUTextureFormat\n): LinePipelineBundle {\n const module = device.createShaderModule({ code: LINE_SHADER_WGSL });\n\n const GPUShaderStageAny = (globalThis as any).GPUShaderStage;\n const GPUBufferUsageAny = (globalThis as any).GPUBufferUsage;\n\n // Create bind group layout explicitly\n const bindGroupLayout = device.createBindGroupLayout({\n entries: [\n {\n binding: 0,\n visibility: GPUShaderStageAny.VERTEX | GPUShaderStageAny.FRAGMENT,\n buffer: { type: \"uniform\" },\n },\n ],\n });\n\n // Create uniform buffer\n const uniformBuffer = device.createBuffer({\n size: UNIFORM_BUFFER_SIZE,\n usage: GPUBufferUsageAny.UNIFORM | GPUBufferUsageAny.COPY_DST,\n });\n\n // Create bind group\n const bindGroup = device.createBindGroup({\n layout: bindGroupLayout,\n entries: [\n {\n binding: 0,\n resource: { buffer: uniformBuffer },\n },\n ],\n });\n\n // Create pipeline layout\n const pipelineLayout = device.createPipelineLayout({\n bindGroupLayouts: [bindGroupLayout],\n });\n\n const pipeline = device.createRenderPipeline({\n layout: pipelineLayout,\n vertex: {\n module,\n entryPoint: \"vs_main\",\n buffers: [\n {\n arrayStride: LINE_VERTEX_STRIDE,\n attributes: [\n { shaderLocation: 0, offset: 0, format: \"float32x2\" },\n ],\n },\n ],\n },\n fragment: {\n module,\n entryPoint: \"fs_main\",\n targets: [\n {\n format,\n blend: {\n color: {\n srcFactor: \"src-alpha\",\n dstFactor: \"one-minus-src-alpha\",\n operation: \"add\",\n },\n alpha: {\n srcFactor: \"one\",\n dstFactor: \"one-minus-src-alpha\",\n operation: \"add\",\n },\n },\n },\n ],\n },\n primitive: {\n topology: \"line-strip\",\n stripIndexFormat: undefined,\n },\n });\n\n return {\n pipeline,\n bindGroupLayout,\n uniformBuffer,\n bindGroup,\n vertexStride: LINE_VERTEX_STRIDE,\n };\n}\n\nexport function updateLineUniforms(\n device: any, // GPUDevice\n uniformBuffer: any, // GPUBuffer\n uniforms: LineUniforms\n): void {\n const data = new Float32Array([\n uniforms.scale[0],\n uniforms.scale[1],\n uniforms.translate[0],\n uniforms.translate[1],\n uniforms.color[0],\n uniforms.color[1],\n uniforms.color[2],\n uniforms.color[3],\n ]);\n device.queue.writeBuffer(uniformBuffer, 0, data);\n}\n","/**\n * Point Shader - WGSL for WebGPU\n * \n * Renders scatter points with SDF-based symbols.\n * Supports: circle, square, diamond, triangle, triangleDown, cross, x, star\n */\n\nexport const POINT_SHADER_WGSL = `\n// Uniform buffer for transforms, color, point properties\nstruct Uniforms {\n scale: vec2<f32>,\n translate: vec2<f32>,\n color: vec4<f32>,\n pointSize: f32,\n symbol: i32, // 0=circle, 1=square, 2=diamond, 3=triangle, 4=triangleDown, 5=cross, 6=x, 7=star\n _padding: vec2<f32>,\n};\n\n@group(0) @binding(0)\nvar<uniform> uniforms: Uniforms;\n\nstruct VSInput {\n @location(0) position: vec2<f32>,\n};\n\nstruct VSOutput {\n @builtin(position) pos: vec4<f32>,\n @location(0) @interpolate(flat) pointSize: f32,\n @location(1) @interpolate(flat) symbol: i32,\n};\n\n@vertex\nfn vs_main(in: VSInput, @builtin(vertex_index) vertexIndex: u32) -> VSOutput {\n var out: VSOutput;\n let transformed = in.position * uniforms.scale + uniforms.translate;\n out.pos = vec4<f32>(transformed, 0.0, 1.0);\n out.pointSize = uniforms.pointSize;\n out.symbol = uniforms.symbol;\n return out;\n}\n\n// SDF functions for symbols\nfn sdCircle(p: vec2<f32>, r: f32) -> f32 {\n return length(p) - r;\n}\n\nfn sdBox(p: vec2<f32>, b: vec2<f32>) -> f32 {\n let d = abs(p) - b;\n return length(max(d, vec2<f32>(0.0))) + min(max(d.x, d.y), 0.0);\n}\n\nfn sdDiamond(p: vec2<f32>, r: f32) -> f32 {\n return (abs(p.x) + abs(p.y)) - r;\n}\n\nfn sdTriangle(p_in: vec2<f32>, r: f32) -> f32 {\n let k = sqrt(3.0);\n var p = p_in;\n p.x = abs(p.x) - r;\n p.y = p.y + r / k;\n if (p.x + k * p.y > 0.0) {\n p = vec2<f32>(p.x - k * p.y, -k * p.x - p.y) / 2.0;\n }\n p.x = p.x - clamp(p.x, -2.0 * r, 0.0);\n return -length(p) * sign(p.y);\n}\n\nfn sdCross(p: vec2<f32>, r: f32, thickness: f32) -> f32 {\n let d = abs(p);\n let s1 = sdBox(d, vec2<f32>(r, thickness));\n let s2 = sdBox(d, vec2<f32>(thickness, r));\n return min(s1, s2);\n}\n\nfn sdX(p: vec2<f32>, r: f32, thickness: f32) -> f32 {\n let c = cos(0.785398);\n let s = sin(0.785398);\n let m = mat2x2<f32>(c, -s, s, c);\n return sdCross(m * p, r, thickness);\n}\n\nfn sdStar(p_in: vec2<f32>, r: f32, rf: f32) -> f32 {\n let k1 = vec2<f32>(0.80901699, -0.58778525);\n let k2 = vec2<f32>(-k1.x, k1.y);\n var p = p_in;\n p.x = abs(p.x);\n p = p - 2.0 * max(dot(k1, p), 0.0) * k1;\n p = p - 2.0 * max(dot(k2, p), 0.0) * k2;\n p.x = abs(p.x);\n p.y = p.y - r;\n let ba = rf * vec2<f32>(-k1.y, k1.x) - vec2<f32>(0.0, 1.0);\n let h = clamp(dot(p, ba) / dot(ba, ba), 0.0, r);\n return length(p - ba * h) * sign(p.y * ba.x - p.x * ba.y);\n}\n\n@fragment\nfn fs_main(in: VSOutput) -> @location(0) vec4<f32> {\n // Note: WebGPU doesn't have gl_PointCoord directly\n // Points in WebGPU require rendering quads instead\n // This shader needs instanced rendering with quads for proper point rendering\n // For now, return the color directly\n return uniforms.color;\n}\n`;\n\n// For proper point rendering we need quad instances\n// Each point becomes 6 vertices (2 triangles forming a quad)\nexport const POINT_QUAD_SHADER_WGSL = `\n// Uniform buffer for transforms, color, point properties\nstruct Uniforms {\n scale: vec2<f32>,\n translate: vec2<f32>,\n color: vec4<f32>,\n pointSize: f32,\n symbol: i32,\n viewport: vec2<f32>, // viewport dimensions for proper sizing\n};\n\n@group(0) @binding(0)\nvar<uniform> uniforms: Uniforms;\n\nstruct VSInput {\n @location(0) position: vec2<f32>, // point center position\n @location(1) quadOffset: vec2<f32>, // quad vertex offset (-1 to 1)\n};\n\nstruct VSOutput {\n @builtin(position) pos: vec4<f32>,\n @location(0) uv: vec2<f32>, // -0.5 to 0.5 for SDF\n};\n\n@vertex\nfn vs_main(in: VSInput) -> VSOutput {\n var out: VSOutput;\n \n // Transform point position to NDC\n let transformed = in.position * uniforms.scale + uniforms.translate;\n \n // Calculate point size in NDC\n let pointSizeNDC = vec2<f32>(\n uniforms.pointSize / uniforms.viewport.x * 2.0,\n uniforms.pointSize / uniforms.viewport.y * 2.0\n );\n \n // Apply quad offset\n let offset = in.quadOffset * pointSizeNDC * 0.5;\n \n out.pos = vec4<f32>(transformed + offset, 0.0, 1.0);\n out.uv = in.quadOffset * 0.5; // -0.5 to 0.5\n \n return out;\n}\n\n// SDF functions\nfn sdCircle(p: vec2<f32>, r: f32) -> f32 {\n return length(p) - r;\n}\n\nfn sdBox(p: vec2<f32>, b: vec2<f32>) -> f32 {\n let d = abs(p) - b;\n return length(max(d, vec2<f32>(0.0))) + min(max(d.x, d.y), 0.0);\n}\n\nfn sdDiamond(p: vec2<f32>, r: f32) -> f32 {\n return (abs(p.x) + abs(p.y)) - r;\n}\n\nfn sdTriangle(p_in: vec2<f32>, r: f32) -> f32 {\n let k = sqrt(3.0);\n var p = p_in;\n p.x = abs(p.x) - r;\n p.y = p.y + r / k;\n if (p.x + k * p.y > 0.0) {\n p = vec2<f32>(p.x - k * p.y, -k * p.x - p.y) / 2.0;\n }\n p.x = p.x - clamp(p.x, -2.0 * r, 0.0);\n return -length(p) * sign(p.y);\n}\n\nfn sdCross(p: vec2<f32>, r: f32, thickness: f32) -> f32 {\n let d = abs(p);\n let s1 = sdBox(d, vec2<f32>(r, thickness));\n let s2 = sdBox(d, vec2<f32>(thickness, r));\n return min(s1, s2);\n}\n\nfn sdX(p: vec2<f32>, r: f32, thickness: f32) -> f32 {\n let c = cos(0.785398);\n let s = sin(0.785398);\n let m = mat2x2<f32>(c, -s, s, c);\n return sdCross(m * p, r, thickness);\n}\n\nfn sdStar(p_in: vec2<f32>, r: f32, rf: f32) -> f32 {\n let k1 = vec2<f32>(0.80901699, -0.58778525);\n let k2 = vec2<f32>(-k1.x, k1.y);\n var p = p_in;\n p.x = abs(p.x);\n p = p - 2.0 * max(dot(k1, p), 0.0) * k1;\n p = p - 2.0 * max(dot(k2, p), 0.0) * k2;\n p.x = abs(p.x);\n p.y = p.y - r;\n let ba = rf * vec2<f32>(-k1.y, k1.x) - vec2<f32>(0.0, 1.0);\n let h = clamp(dot(p, ba) / dot(ba, ba), 0.0, r);\n return length(p - ba * h) * sign(p.y * ba.x - p.x * ba.y);\n}\n\n@fragment\nfn fs_main(in: VSOutput) -> @location(0) vec4<f32> {\n var d: f32 = 0.0;\n \n if (uniforms.symbol == 0) {\n d = sdCircle(in.uv, 0.45);\n } else if (uniforms.symbol == 1) {\n d = sdBox(in.uv, vec2<f32>(0.35));\n } else if (uniforms.symbol == 2) {\n d = sdDiamond(in.uv, 0.45);\n } else if (uniforms.symbol == 3) {\n d = sdTriangle(vec2<f32>(in.uv.x, in.uv.y + 0.1), 0.4);\n } else if (uniforms.symbol == 4) {\n d = sdTriangle(vec2<f32>(in.uv.x, -in.uv.y + 0.1), 0.4);\n } else if (uniforms.symbol == 5) {\n d = sdCross(in.uv, 0.45, 0.15);\n } else if (uniforms.symbol == 6) {\n d = sdX(in.uv, 0.45, 0.15);\n } else if (uniforms.symbol == 7) {\n d = sdStar(in.uv, 0.45, 0.4);\n }\n \n if (d > 0.02) {\n discard;\n }\n \n let alpha = 1.0 - smoothstep(0.0, 0.02, d);\n return vec4<f32>(uniforms.color.rgb, uniforms.color.a * alpha);\n}\n`;\n\nexport const POINT_VERTEX_STRIDE = 2 * 4; // 2 floats (x, y)\n","/**\n * Point Pipeline - WebGPU pipeline for rendering scatter points with SDF symbols\n * \n * Uses instanced rendering where each point is rendered as a quad (2 triangles).\n * Uses `any` types for WebGPU objects to avoid requiring @webgpu/types.\n */\n\nimport { POINT_QUAD_SHADER_WGSL, POINT_VERTEX_STRIDE } from \"../shaders/point.wgsl\";\n\nexport interface PointPipelineBundle {\n pipeline: any; // GPURenderPipeline\n bindGroupLayout: any; // GPUBindGroupLayout\n uniformBuffer: any; // GPUBuffer\n bindGroup: any; // GPUBindGroup\n quadBuffer: any; // GPUBuffer - Pre-generated quad vertices\n vertexStride: number;\n}\n\nexport interface PointUniforms {\n scale: [number, number];\n translate: [number, number];\n color: [number, number, number, number];\n pointSize: number;\n symbol: number; // 0=circle, 1=square, 2=diamond, 3=triangle, 4=triangleDown, 5=cross, 6=x, 7=star\n viewport: [number, number];\n}\n\n// Uniform buffer layout:\n// scale(2) + translate(2) + color(4) + pointSize(1) + symbol(1) + viewport(2) = 12 floats = 48 bytes\nconst UNIFORM_BUFFER_SIZE = 48;\n\n// Quad vertex offsets (6 vertices for 2 triangles)\nconst QUAD_VERTICES = new Float32Array([\n -1, -1, // bottom-left\n 1, -1, // bottom-right\n -1, 1, // top-left\n -1, 1, // top-left\n 1, -1, // bottom-right\n 1, 1, // top-right\n]);\n\nexport function createPointPipeline(\n device: any, // GPUDevice\n format: string // GPUTextureFormat\n): PointPipelineBundle {\n const module = device.createShaderModule({ code: POINT_QUAD_SHADER_WGSL });\n\n const GPUShaderStageAny = (globalThis as any).GPUShaderStage;\n const GPUBufferUsageAny = (globalThis as any).GPUBufferUsage;\n\n // Create bind group layout\n const bindGroupLayout = device.createBindGroupLayout({\n entries: [\n {\n binding: 0,\n visibility: GPUShaderStageAny.VERTEX | GPUShaderStageAny.FRAGMENT,\n buffer: { type: \"uniform\" },\n },\n ],\n });\n\n // Create uniform buffer\n const uniformBuffer = device.createBuffer({\n size: UNIFORM_BUFFER_SIZE,\n usage: GPUBufferUsageAny.UNIFORM | GPUBufferUsageAny.COPY_DST,\n });\n\n // Create quad vertex buffer\n const quadBuffer = device.createBuffer({\n size: QUAD_VERTICES.byteLength,\n usage: GPUBufferUsageAny.VERTEX | GPUBufferUsageAny.COPY_DST,\n mappedAtCreation: true,\n });\n new Float32Array(quadBuffer.getMappedRange()).set(QUAD_VERTICES);\n quadBuffer.unmap();\n\n // Create bind group\n const bindGroup = device.createBindGroup({\n layout: bindGroupLayout,\n entries: [\n {\n binding: 0,\n resource: { buffer: uniformBuffer },\n },\n ],\n });\n\n // Create pipeline layout\n const pipelineLayout = device.createPipelineLayout({\n bindGroupLayouts: [bindGroupLayout],\n });\n\n const pipeline = device.createRenderPipeline({\n layout: pipelineLayout,\n vertex: {\n module,\n entryPoint: \"vs_main\",\n buffers: [\n // Point positions (instanced)\n {\n arrayStride: POINT_VERTEX_STRIDE,\n stepMode: \"instance\",\n attributes: [\n { shaderLocation: 0, offset: 0, format: \"float32x2\" },\n ],\n },\n // Quad vertex offsets (per-vertex)\n {\n arrayStride: 8, // 2 floats\n stepMode: \"vertex\",\n attributes: [\n { shaderLocation: 1, offset: 0, format: \"float32x2\" },\n ],\n },\n ],\n },\n fragment: {\n module,\n entryPoint: \"fs_main\",\n targets: [\n {\n format,\n blend: {\n color: {\n srcFactor: \"src-alpha\",\n dstFactor: \"one-minus-src-alpha\",\n operation: \"add\",\n },\n alpha: {\n srcFactor: \"one\",\n dstFactor: \"one-minus-src-alpha\",\n operation: \"add\",\n },\n },\n },\n ],\n },\n primitive: {\n topology: \"triangle-list\",\n cullMode: \"none\",\n },\n });\n\n return {\n pipeline,\n bindGroupLayout,\n uniformBuffer,\n bindGroup,\n quadBuffer,\n vertexStride: POINT_VERTEX_STRIDE,\n };\n}\n\nexport function updatePointUniforms(\n device: any, // GPUDevice\n uniformBuffer: any, // GPUBuffer\n uniforms: PointUniforms\n): void {\n // Pack data: scale(2) + translate(2) + color(4) + pointSize(1) + symbol(1 as float) + viewport(2)\n const data = new Float32Array([\n uniforms.scale[0],\n uniforms.scale[1],\n uniforms.translate[0],\n uniforms.translate[1],\n uniforms.color[0],\n uniforms.color[1],\n uniforms.color[2],\n uniforms.color[3],\n uniforms.pointSize,\n uniforms.symbol, // Will be cast to i32 in shader via bitcast\n uniforms.viewport[0],\n uniforms.viewport[1],\n ]);\n device.queue.writeBuffer(uniformBuffer, 0, data);\n}\n\nexport const SYMBOL_MAP: Record<string, number> = {\n circle: 0,\n square: 1,\n diamond: 2,\n triangle: 3,\n triangleDown: 4,\n cross: 5,\n x: 6,\n star: 7,\n};\n","/**\n * Band Pipeline - WebGPU pipeline for rendering band/area fills\n * \n * Uses triangle-strip topology for efficient area rendering.\n * Reuses the line shader with different primitive topology.\n * Uses `any` types for WebGPU objects to avoid requiring @webgpu/types.\n */\n\nimport { LINE_SHADER_WGSL, LINE_VERTEX_STRIDE } from \"../shaders/line.wgsl\";\n\nexport interface BandPipelineBundle {\n pipeline: any; // GPURenderPipeline\n bindGroupLayout: any; // GPUBindGroupLayout\n uniformBuffer: any; // GPUBuffer\n bindGroup: any; // GPUBindGroup\n vertexStride: number;\n}\n\nexport interface BandUniforms {\n scale: [number, number];\n translate: [number, number];\n color: [number, number, number, number];\n}\n\n// Same as line uniforms\nconst UNIFORM_BUFFER_SIZE = 32;\n\nexport function createBandPipeline(\n device: any, // GPUDevice\n format: string // GPUTextureFormat\n): BandPipelineBundle {\n const module = device.createShaderModule({ code: LINE_SHADER_WGSL });\n\n const GPUShaderStageAny = (globalThis as any).GPUShaderStage;\n const GPUBufferUsageAny = (globalThis as any).GPUBufferUsage;\n\n // Create bind group layout\n const bindGroupLayout = device.createBindGroupLayout({\n entries: [\n {\n binding: 0,\n visibility: GPUShaderStageAny.VERTEX | GPUShaderStageAny.FRAGMENT,\n buffer: { type: \"uniform\" },\n },\n ],\n });\n\n // Create uniform buffer\n const uniformBuffer = device.createBuffer({\n size: UNIFORM_BUFFER_SIZE,\n usage: GPUBufferUsageAny.UNIFORM | GPUBufferUsageAny.COPY_DST,\n });\n\n // Create bind group\n const bindGroup = device.createBindGroup({\n layout: bindGroupLayout,\n entries: [\n {\n binding: 0,\n resource: { buffer: uniformBuffer },\n },\n ],\n });\n\n // Create pipeline layout\n const pipelineLayout = device.createPipelineLayout({\n bindGroupLayouts: [bindGroupLayout],\n });\n\n const pipeline = device.createRenderPipeline({\n layout: pipelineLayout,\n vertex: {\n module,\n entryPoint: \"vs_main\",\n buffers: [\n {\n arrayStride: LINE_VERTEX_STRIDE,\n attributes: [\n { shaderLocation: 0, offset: 0, format: \"float32x2\" },\n ],\n },\n ],\n },\n fragment: {\n module,\n entryPoint: \"fs_main\",\n targets: [\n {\n format,\n blend: {\n color: {\n srcFactor: \"src-alpha\",\n dstFactor: \"one-minus-src-alpha\",\n operation: \"add\",\n },\n alpha: {\n srcFactor: \"one\",\n dstFactor: \"one-minus-src-alpha\",\n operation: \"add\",\n },\n },\n },\n ],\n },\n primitive: {\n topology: \"triangle-strip\", // Key difference from line pipeline\n stripIndexFormat: undefined,\n },\n });\n\n return {\n pipeline,\n bindGroupLayout,\n uniformBuffer,\n bindGroup,\n vertexStride: LINE_VERTEX_STRIDE,\n };\n}\n\nexport function updateBandUniforms(\n device: any, // GPUDevice\n uniformBuffer: any, // GPUBuffer\n uniforms: BandUniforms\n): void {\n const data = new Float32Array([\n uniforms.scale[0],\n uniforms.scale[1],\n uniforms.translate[0],\n uniforms.translate[1],\n uniforms.color[0],\n uniforms.color[1],\n uniforms.color[2],\n uniforms.color[3],\n ]);\n device.queue.writeBuffer(uniformBuffer, 0, data);\n}\n","/**\n * Heatmap Shader - WGSL for WebGPU\n * \n * Renders heatmap cells with colormap texture lookup.\n * Each vertex has position (x, y) and value (z) for color mapping.\n */\n\nexport const HEATMAP_SHADER_WGSL = `\n// Uniform buffer for transforms and value range\nstruct Uniforms {\n scale: vec2<f32>,\n translate: vec2<f32>,\n minValue: f32,\n maxValue: f32,\n _padding: vec2<f32>,\n};\n\n@group(0) @binding(0)\nvar<uniform> uniforms: Uniforms;\n\n@group(0) @binding(1)\nvar colormapSampler: sampler;\n\n@group(0) @binding(2)\nvar colormapTexture: texture_1d<f32>;\n\nstruct VSInput {\n @location(0) position: vec2<f32>,\n @location(1) value: f32,\n};\n\nstruct VSOutput {\n @builtin(position) pos: vec4<f32>,\n @location(0) value: f32,\n};\n\n@vertex\nfn vs_main(in: VSInput) -> VSOutput {\n var out: VSOutput;\n let transformed = in.position * uniforms.scale + uniforms.translate;\n out.pos = vec4<f32>(transformed, 0.0, 1.0);\n out.value = in.value;\n return out;\n}\n\n@fragment\nfn fs_main(in: VSOutput) -> @location(0) vec4<f32> {\n let range = uniforms.maxValue - uniforms.minValue;\n var t: f32;\n if (range != 0.0) {\n t = (in.value - uniforms.minValue) / range;\n } else {\n t = 0.0;\n }\n t = clamp(t, 0.0, 1.0);\n \n return textureSample(colormapTexture, colormapSampler, t);\n}\n`;\n\n// Heatmap vertex: position (2 floats) + value (1 float) = 12 bytes\nexport const HEATMAP_VERTEX_STRIDE = 3 * 4; // 12 bytes\n","/**\n * Heatmap Pipeline - WebGPU pipeline for rendering heatmaps with colormap textures\n * \n * Uses `any` types for WebGPU objects to avoid requiring @webgpu/types.\n */\n\nimport { HEATMAP_SHADER_WGSL, HEATMAP_VERTEX_STRIDE } from \"../shaders/heatmap.wgsl\";\n\nexport interface HeatmapPipelineBundle {\n pipeline: any; // GPURenderPipeline\n bindGroupLayout: any; // GPUBindGroupLayout\n uniformBuffer: any; // GPUBuffer\n sampler: any; // GPUSampler\n vertexStride: number;\n}\n\nexport interface HeatmapUniforms {\n scale: [number, number];\n translate: [number, number];\n minValue: number;\n maxValue: number;\n}\n\n// Uniform buffer layout: scale(2) + translate(2) + minValue(1) + maxValue(1) + padding(2) = 8 floats = 32 bytes\nconst UNIFORM_BUFFER_SIZE = 32;\n\nexport function createHeatmapPipeline(\n device: any, // GPUDevice\n format: string // GPUTextureFormat\n): HeatmapPipelineBundle {\n const module = device.createShaderModule({ code: HEATMAP_SHADER_WGSL });\n\n const GPUShaderStageAny = (globalThis as any).GPUShaderStage;\n const GPUBufferUsageAny = (globalThis as any).GPUBufferUsage;\n\n // Create bind group layout\n const bindGroupLayout = device.createBindGroupLayout({\n entries: [\n {\n binding: 0,\n visibility: GPUShaderStageAny.VERTEX | GPUShaderStageAny.FRAGMENT,\n buffer: { type: \"uniform\" },\n },\n {\n binding: 1,\n visibility: GPUShaderStageAny.FRAGMENT,\n sampler: {},\n },\n {\n binding: 2,\n visibility: GPUShaderStageAny.FRAGMENT,\n texture: { \n sampleType: \"float\",\n viewDimension: \"1d\",\n },\n },\n ],\n });\n\n // Create uniform buffer\n const uniformBuffer = device.createBuffer({\n size: UNIFORM_BUFFER_SIZE,\n usage: GPUBufferUsageAny.UNIFORM | GPUBufferUsageAny.COPY_DST,\n });\n\n // Create sampler\n const sampler = device.createSampler({\n magFilter: \"linear\",\n minFilter: \"linear\",\n addressModeU: \"clamp-to-edge\",\n });\n\n // Create pipeline layout\n const pipelineLayout = device.createPipelineLayout({\n bindGroupLayouts: [bindGroupLayout],\n });\n\n const pipeline = device.createRenderPipeline({\n layout: pipelineLayout,\n vertex: {\n module,\n entryPoint: \"vs_main\",\n buffers: [\n {\n arrayStride: HEATMAP_VERTEX_STRIDE,\n attributes: [\n { shaderLocation: 0, offset: 0, format: \"float32x2\" }, // position\n { shaderLocation: 1, offset: 8, format: \"float32\" }, // value\n ],\n },\n ],\n },\n fragment: {\n module,\n entryPoint: \"fs_main\",\n targets: [\n {\n format,\n blend: {\n color: {\n srcFactor: \"src-alpha\",\n dstFactor: \"one-minus-src-alpha\",\n operation: \"add\",\n },\n alpha: {\n srcFactor: \"one\",\n dstFactor: \"one-minus-src-alpha\",\n operation: \"add\",\n },\n },\n },\n ],\n },\n primitive: {\n topology: \"triangle-list\",\n cullMode: \"none\",\n },\n });\n\n return {\n pipeline,\n bindGroupLayout,\n uniformBuffer,\n sampler,\n vertexStride: HEATMAP_VERTEX_STRIDE,\n };\n}\n\nexport function createHeatmapBindGroup(\n device: any, // GPUDevice\n layout: any, // GPUBindGroupLayout\n uniformBuffer: any, // GPUBuffer\n sampler: any, // GPUSampler\n colormapTexture: any // GPUTexture\n): any { // GPUBindGroup\n return device.createBindGroup({\n layout,\n entries: [\n { binding: 0, resource: { buffer: uniformBuffer } },\n { binding: 1, resource: sampler },\n { binding: 2, resource: colormapTexture.createView() },\n ],\n });\n}\n\nexport function updateHeatmapUniforms(\n device: any, // GPUDevice\n uniformBuffer: any, // GPUBuffer\n uniforms: HeatmapUniforms\n): void {\n const data = new Float32Array([\n uniforms.scale[0],\n uniforms.scale[1],\n uniforms.translate[0],\n uniforms.translate[1],\n uniforms.minValue,\n uniforms.maxValue,\n 0, // padding\n 0, // padding\n ]);\n device.queue.writeBuffer(uniformBuffer, 0, data);\n}\n","import type {\n BufferDescriptor,\n BufferId,\n GpuBackend,\n GpuBackendInfo,\n GpuViewport,\n Texture1DDescriptor,\n TextureId,\n} from \"../../types\";\nimport type { DrawCall, DrawList, PointStyle, HeatmapStyle } from \"../../drawList\";\nimport type { FrameUniforms } from \"../../frame\";\nimport {\n createTrianglePipeline,\n type TrianglePipelineBundle,\n} from \"./pipelines/trianglePipeline\";\nimport {\n createLinePipeline,\n updateLineUniforms,\n type LinePipelineBundle,\n} from \"./pipelines/linePipeline\";\nimport {\n createPointPipeline,\n updatePointUniforms,\n SYMBOL_MAP,\n type PointPipelineBundle,\n} from \"./pipelines/pointPipeline\";\nimport {\n createBandPipeline,\n updateBandUniforms,\n type BandPipelineBundle,\n} from \"./pipelines/bandPipeline\";\nimport {\n createHeatmapPipeline,\n createHeatmapBindGroup,\n updateHeatmapUniforms,\n type HeatmapPipelineBundle,\n} from \"./pipelines/heatmapPipeline\";\n\nexport interface WebGPUBackendOptions {\n powerPreference?: \"low-power\" | \"high-performance\";\n preferredFormat?: string;\n}\n\n/**\n * Calculate transform uniforms from bounds\n */\nfunction calculateUniforms(bounds: {\n xMin: number;\n xMax: number;\n yMin: number;\n yMax: number;\n}): { scale: [number, number]; translate: [number, number] } {\n const dataWidth = bounds.xMax - bounds.xMin;\n const dataHeight = bounds.yMax - bounds.yMin;\n\n const scaleX = dataWidth > 0 ? 2 / dataWidth : 1;\n const scaleY = dataHeight > 0 ? 2 / dataHeight : 1;\n\n const translateX = -1 - bounds.xMin * scaleX;\n const translateY = -1 - bounds.yMin * scaleY;\n\n return {\n scale: [scaleX, scaleY],\n translate: [translateX, translateY],\n };\n}\n\n/**\n * Parse color from style, returning RGBA values 0-1\n */\nfunction getColorFromStyle(style: any): [number, number, number, number] {\n const color = style?.color ?? [1, 0, 0.3, 1];\n const opacity = style?.opacity ?? 1;\n \n // If color is already RGBA tuple\n if (Array.isArray(color)) {\n return [color[0], color[1], color[2], (color[3] ?? 1) * opacity];\n }\n \n return [1, 0, 0.3, opacity]; // Default magenta\n}\n\nexport class WebGPUBackend implements GpuBackend {\n public readonly info: GpuBackendInfo;\n\n private canvas: HTMLCanvasElement;\n private opts: WebGPUBackendOptions;\n\n private viewport: GpuViewport | null = null;\n\n private adapter: any;\n private device: any;\n private context: any;\n private format: string | null = null;\n\n private buffers = new Map<string, any>();\n private textures = new Map<string, any>();\n\n // Pipelines for different draw types\n private trianglePipeline: TrianglePipelineBundle | null = null;\n private linePipeline: LinePipelineBundle | null = null;\n private pointPipeline: PointPipelineBundle | null = null;\n private bandPipeline: BandPipelineBundle | null = null;\n private heatmapPipeline: HeatmapPipelineBundle | null = null;\n\n // Heatmap bind groups (per texture)\n private heatmapBindGroups = new Map<string, any>();\n\n constructor(canvas: HTMLCanvasElement, opts: WebGPUBackendOptions = {}) {\n this.canvas = canvas;\n this.opts = opts;\n this.info = {\n type: \"webgpu\",\n available: WebGPUBackend.isSupported(),\n };\n }\n\n static isSupported(): boolean {\n return (\n typeof (globalThis as any).navigator !== \"undefined\" &&\n typeof (globalThis as any).navigator.gpu !== \"undefined\"\n );\n }\n\n async init(): Promise<void> {\n if (!this.info.available) {\n throw new Error(\"[gpu] WebGPU not supported\");\n }\n\n const gpu = (globalThis as any).navigator.gpu;\n\n this.adapter = await gpu.requestAdapter({\n powerPreference: this.opts.powerPreference ?? \"high-performance\",\n });\n\n if (!this.adapter) {\n throw new Error(\"[gpu] Failed to request WebGPU adapter\");\n }\n\n this.device = await this.adapter.requestDevice();\n\n const ctx = (this.canvas as any).getContext(\"webgpu\");\n if (!ctx) {\n throw new Error(\"[gpu] Failed to get WebGPU canvas context\");\n }\n\n this.context = ctx;\n\n const format =\n this.opts.preferredFormat ??\n (gpu.getPreferredCanvasFormat\n ? gpu.getPreferredCanvasFormat()\n : \"bgra8unorm\");\n\n this.format = format;\n\n this.context.configure({\n device: this.device,\n format,\n alphaMode: \"premultiplied\",\n });\n }\n\n setViewport(viewport: GpuViewport): void {\n this.viewport = viewport;\n const w = Math.max(1, Math.floor(viewport.width * viewport.dpr));\n const h = Math.max(1, Math.floor(viewport.height * viewport.dpr));\n if (this.canvas.width !== w) this.canvas.width = w;\n if (this.canvas.height !== h) this.canvas.height = h;\n }\n\n createOrUpdateBuffer(\n id: BufferId,\n data: ArrayBufferView,\n desc?: Partial<BufferDescriptor>\n ): void {\n if (!this.device) {\n throw new Error(\"[gpu] WebGPUBackend not initialized\");\n }\n\n const usage = desc?.usage ?? \"vertex\";\n const GPUBufferUsageAny = (globalThis as any).GPUBufferUsage;\n if (!GPUBufferUsageAny) {\n throw new Error(\n \"[gpu] GPUBufferUsage not available (missing WebGPU runtime)\"\n );\n }\n\n const usageFlags =\n usage === \"index\"\n ? GPUBufferUsageAny.INDEX | GPUBufferUsageAny.COPY_DST\n : usage === \"uniform\"\n ? GPUBufferUsageAny.UNIFORM | GPUBufferUsageAny.COPY_DST\n : GPUBufferUsageAny.VERTEX | GPUBufferUsageAny.COPY_DST;\n\n const byteLength = data.byteLength;\n\n let buf = this.buffers.get(id);\n if (!buf || buf.size < byteLength) {\n if (buf) {\n try {\n buf.destroy();\n } catch {}\n }\n buf = this.device.createBuffer({\n size: Math.max(4, byteLength),\n usage: usageFlags,\n });\n this.buffers.set(id, buf);\n }\n\n this.device.queue.writeBuffer(\n buf,\n 0,\n data.buffer,\n data.byteOffset,\n data.byteLength\n );\n }\n\n deleteBuffer(id: BufferId): void {\n const buf = this.buffers.get(id);\n if (buf) {\n try {\n buf.destroy();\n } catch {}\n this.buffers.delete(id);\n }\n }\n\n createOrUpdateTexture1D(\n id: TextureId,\n data: Uint8Array,\n desc?: Partial<Texture1DDescriptor>\n ): void {\n if (!this.device) {\n throw new Error(\"[gpu] WebGPUBackend not initialized\");\n }\n\n const width = desc?.width ?? Math.floor(data.length / 4);\n const format = desc?.format ?? \"rgba8unorm\";\n\n const GPUTextureUsageAny = (globalThis as any).GPUTextureUsage;\n if (!GPUTextureUsageAny) {\n throw new Error(\n \"[gpu] GPUTextureUsage not available (missing WebGPU runtime)\"\n );\n }\n\n let tex = this.textures.get(id);\n if (!tex) {\n tex = this.device.createTexture({\n size: { width, height: 1, depthOrArrayLayers: 1 },\n format,\n dimension: \"1d\",\n usage: GPUTextureUsageAny.TEXTURE_BINDING | GPUTextureUsageAny.COPY_DST,\n });\n this.textures.set(id, tex);\n \n // Invalidate heatmap bind group for this texture\n this.heatmapBindGroups.delete(id);\n }\n\n this.device.queue.writeTexture(\n { texture: tex },\n data,\n { bytesPerRow: width * 4 },\n { width, height: 1, depthOrArrayLayers: 1 }\n );\n }\n\n deleteTexture(id: TextureId): void {\n const tex = this.textures.get(id);\n if (tex) {\n try {\n tex.destroy();\n } catch {}\n this.textures.delete(id);\n this.heatmapBindGroups.delete(id);\n }\n }\n\n /**\n * Initialize all pipelines lazily\n */\n private ensurePipelines(): void {\n if (!this.trianglePipeline) {\n this.trianglePipeline = createTrianglePipeline(this.device, this.format!);\n }\n if (!this.linePipeline) {\n this.linePipeline = createLinePipeline(this.device, this.format!);\n }\n if (!this.pointPipeline) {\n this.pointPipeline = createPointPipeline(this.device, this.format!);\n }\n if (!this.bandPipeline) {\n this.bandPipeline = createBandPipeline(this.device, this.format!);\n }\n if (!this.heatmapPipeline) {\n this.heatmapPipeline = createHeatmapPipeline(this.device, this.format!);\n }\n }\n\n render(drawList: DrawList, frame: FrameUniforms): void {\n if (!this.device || !this.context || !this.format) {\n throw new Error(\"[gpu] WebGPUBackend not initialized\");\n }\n\n if (!this.viewport) {\n this.setViewport(frame.viewport);\n }\n\n this.ensurePipelines();\n\n const encoder = this.device.createCommandEncoder();\n const view = this.context.getCurrentTexture().createView();\n\n const pass = encoder.beginRenderPass({\n colorAttachments: [\n {\n view,\n clearValue: {\n r: frame.clearColor[0],\n g: frame.clearColor[1],\n b: frame.clearColor[2],\n a: frame.clearColor[3],\n },\n loadOp: \"clear\",\n storeOp: \"store\",\n },\n ],\n });\n\n // Default bounds (NDC if not specified)\n const defaultBounds = { xMin: -1, xMax: 1, yMin: -1, yMax: 1 };\n\n for (const item of drawList.items) {\n if (!item.visible) continue;\n\n const buf = this.buffers.get(item.bufferId);\n if (!buf) continue;\n\n this.renderDrawCall(pass, item, buf, defaultBounds);\n }\n\n pass.end();\n this.device.queue.submit([encoder.finish()]);\n }\n\n /**\n * Render with explicit bounds (for integration with chart system)\n */\n renderWithBounds(\n drawList: DrawList,\n frame: FrameUniforms,\n bounds: { xMin: number; xMax: number; yMin: number; yMax: number }\n ): void {\n if (!this.device || !this.context || !this.format) {\n throw new Error(\"[gpu] WebGPUBackend not initialized\");\n }\n\n if (!this.viewport) {\n this.setViewport(frame.viewport);\n }\n\n this.ensurePipelines();\n\n const encoder = this.device.createCommandEncoder();\n const view = this.context.getCurrentTexture().createView();\n\n const pass = encoder.beginRenderPass({\n colorAttachments: [\n {\n view,\n clearValue: {\n r: frame.clearColor[0],\n g: frame.clearColor[1],\n b: frame.clearColor[2],\n a: frame.clearColor[3],\n },\n loadOp: \"clear\",\n storeOp: \"store\",\n },\n ],\n });\n\n for (const item of drawList.items) {\n if (!item.visible) continue;\n\n const buf = this.buffers.get(item.bufferId);\n if (!buf) continue;\n\n // Use item's yBounds if specified, otherwise use global bounds\n const itemBounds = item.yBounds\n ? { ...bounds, yMin: item.yBounds.min, yMax: item.yBounds.max }\n : bounds;\n\n this.renderDrawCall(pass, item, buf, itemBounds);\n }\n\n pass.end();\n this.device.queue.submit([encoder.finish()]);\n }\n\n /**\n * Render a single draw call\n */\n private renderDrawCall(\n pass: any,\n item: DrawCall,\n buf: any,\n bounds: { xMin: number; xMax: number; yMin: number; yMax: number }\n ): void {\n const uniforms = calculateUniforms(bounds);\n const color = getColorFromStyle(item.style);\n\n switch (item.kind) {\n case \"triangles\":\n case \"bar\":\n this.renderSolidTriangles(pass, buf, item.count, uniforms, color);\n break;\n\n case \"line\":\n this.renderLine(pass, buf, item.count, uniforms, color);\n break;\n\n case \"scatter\":\n case \"points\":\n this.renderPoints(pass, buf, item.count, uniforms, color, item.style as PointStyle);\n break;\n\n case \"line+scatter\":\n this.renderLine(pass, buf, item.count, uniforms, color);\n this.renderPoints(pass, buf, item.count, uniforms, color, item.style as PointStyle);\n break;\n\n case \"step\":\n // Use step buffer if available\n if (item.stepBufferId && item.stepCount) {\n const stepBuf = this.buffers.get(item.stepBufferId);\n if (stepBuf) {\n this.renderLine(pass, stepBuf, item.stepCount, uniforms, color);\n }\n } else {\n this.renderLine(pass, buf, item.count, uniforms, color);\n }\n break;\n\n case \"step+scatter\":\n if (item.stepBufferId && item.stepCount) {\n const stepBuf = this.buffers.get(item.stepBufferId);\n if (stepBuf) {\n this.renderLine(pass, stepBuf, item.stepCount, uniforms, color);\n }\n } else {\n this.renderLine(pass, buf, item.count, uniforms, color);\n }\n this.renderPoints(pass, buf, item.count, uniforms, color, item.style as PointStyle);\n break;\n\n case \"band\":\n // Band uses semi-transparent color\n const bandColor: [number, number, number, number] = [\n color[0],\n color[1],\n color[2],\n color[3] * 0.4,\n ];\n this.renderBand(pass, buf, item.count, uniforms, bandColor);\n break;\n\n case \"heatmap\":\n this.renderHeatmap(pass, buf, item.count, uniforms, item.style as HeatmapStyle, item.textureId);\n break;\n }\n }\n\n /** Triangle list with line-pipeline uniforms (xy vertices, uniform color). */\n private renderSolidTriangles(\n pass: any,\n buf: any,\n count: number,\n uniforms: { scale: [number, number]; translate: [number, number] },\n color: [number, number, number, number],\n ): void {\n updateLineUniforms(this.device, this.linePipeline!.uniformBuffer, {\n scale: uniforms.scale,\n translate: uniforms.translate,\n color,\n });\n pass.setPipeline(this.linePipeline!.pipeline);\n pass.setBindGroup(0, this.linePipeline!.bindGroup);\n pass.setVertexBuffer(0, buf);\n pass.draw(count);\n }\n\n private renderLine(\n pass: any,\n buf: any,\n count: number,\n uniforms: { scale: [number, number]; translate: [number, number] },\n color: [number, number, number, number]\n ): void {\n updateLineUniforms(this.device, this.linePipeline!.uniformBuffer, {\n scale: uniforms.scale,\n translate: uniforms.translate,\n color,\n });\n pass.setPipeline(this.linePipeline!.pipeline);\n pass.setBindGroup(0, this.linePipeline!.bindGroup);\n pass.setVertexBuffer(0, buf);\n pass.draw(count);\n }\n\n private renderPoints(\n pass: any,\n buf: any,\n count: number,\n uniforms: { scale: [number, number]; translate: [number, number] },\n color: [number, number, number, number],\n style?: PointStyle\n ): void {\n const pointSize = (style?.pointSize ?? 4) * (this.viewport?.dpr ?? 1);\n const symbol = SYMBOL_MAP[style?.symbol ?? \"circle\"] ?? 0;\n const viewport: [number, number] = [\n this.canvas.width,\n this.canvas.height,\n ];\n\n updatePointUniforms(this.device, this.pointPipeline!.uniformBuffer, {\n scale: uniforms.scale,\n translate: uniforms.translate,\n color,\n pointSize,\n symbol,\n viewport,\n });\n\n pass.setPipeline(this.pointPipeline!.pipeline);\n pass.setBindGroup(0, this.pointPipeline!.bindGroup);\n pass.setVertexBuffer(0, buf); // Point positions (instanced)\n pass.setVertexBuffer(1, this.pointPipeline!.quadBuffer); // Quad vertices\n pass.draw(6, count); // 6 vertices per quad, count instances\n }\n\n private renderBand(\n pass: any,\n buf: any,\n count: number,\n uniforms: { scale: [number, number]; translate: [number, number] },\n color: [number, number, number, number]\n ): void {\n updateBandUniforms(this.device, this.bandPipeline!.uniformBuffer, {\n scale: uniforms.scale,\n translate: uniforms.translate,\n color,\n });\n pass.setPipeline(this.bandPipeline!.pipeline);\n pass.setBindGroup(0, this.bandPipeline!.bindGroup);\n pass.setVertexBuffer(0, buf);\n pass.draw(count);\n }\n\n private renderHeatmap(\n pass: any,\n buf: any,\n count: number,\n uniforms: { scale: [number, number]; translate: [number, number] },\n style?: HeatmapStyle,\n textureId?: string\n ): void {\n if (!textureId) return;\n \n const tex = this.textures.get(textureId);\n if (!tex) return;\n\n const zBounds = style?.zBounds ?? { min: 0, max: 1 };\n\n updateHeatmapUniforms(this.device, this.heatmapPipeline!.uniformBuffer, {\n scale: uniforms.scale,\n translate: uniforms.translate,\n minValue: zBounds.min,\n maxValue: zBounds.max,\n });\n\n // Get or create bind group for this texture\n let bindGroup = this.heatmapBindGroups.get(textureId);\n if (!bindGroup) {\n bindGroup = createHeatmapBindGroup(\n this.device,\n this.heatmapPipeline!.bindGroupLayout,\n this.heatmapPipeline!.uniformBuffer,\n this.heatmapPipeline!.sampler,\n tex\n );\n this.heatmapBindGroups.set(textureId, bindGroup);\n }\n\n pass.setPipeline(this.heatmapPipeline!.pipeline);\n pass.setBindGroup(0, bindGroup);\n pass.setVertexBuffer(0, buf);\n pass.draw(count);\n }\n\n destroy(): void {\n for (const id of Array.from(this.buffers.keys())) {\n this.deleteBuffer(id);\n }\n for (const id of Array.from(this.textures.keys())) {\n this.deleteTexture(id);\n }\n\n this.trianglePipeline = null;\n this.linePipeline = null;\n this.pointPipeline = null;\n this.bandPipeline = null;\n this.heatmapPipeline = null;\n this.heatmapBindGroups.clear();\n\n this.device = undefined;\n this.adapter = undefined;\n this.context = undefined;\n this.format = null;\n }\n}\n","/**\n * WebGL Shader Sources\n * \n * GLSL shaders for the WebGL backend.\n * These match the functionality of the WebGPU WGSL shaders.\n */\n\n// ============================================\n// Line Shader\n// ============================================\n\nexport const LINE_VERT_GLSL = `\nprecision highp float;\nattribute vec2 aPosition;\nuniform vec2 uScale;\nuniform vec2 uTranslate;\n\nvoid main() {\n vec2 pos = aPosition * uScale + uTranslate;\n gl_Position = vec4(pos, 0.0, 1.0);\n}\n`;\n\nexport const LINE_FRAG_GLSL = `\nprecision highp float;\nuniform vec4 uColor;\n\nvoid main() {\n gl_FragColor = uColor;\n}\n`;\n\n// ============================================\n// Point Shader (with SDF symbols)\n// ============================================\n\nexport const POINT_VERT_GLSL = `\nprecision highp float;\nattribute vec2 aPosition;\nuniform vec2 uScale;\nuniform vec2 uTranslate;\nuniform float uPointSize;\n\nvoid main() {\n vec2 pos = aPosition * uScale + uTranslate;\n gl_Position = vec4(pos, 0.0, 1.0);\n gl_PointSize = uPointSize;\n}\n`;\n\nexport const POINT_FRAG_GLSL = `\nprecision highp float;\nuniform vec4 uColor;\nuniform int uSymbol;\n\nfloat sdCircle(vec2 p, float r) {\n return length(p) - r;\n}\n\nfloat sdBox(vec2 p, vec2 b) {\n vec2 d = abs(p) - b;\n return length(max(d, 0.0)) + min(max(d.x, d.y), 0.0);\n}\n\nfloat sdTriangle(vec2 p, float r) {\n const float k = sqrt(3.0);\n p.x = abs(p.x) - r;\n p.y = p.y + r / k;\n if (p.x + k * p.y > 0.0) p = vec2(p.x - k * p.y, -k * p.x - p.y) / 2.0;\n p.x -= clamp(p.x, -2.0 * r, 0.0);\n return -length(p) * sign(p.y);\n}\n\nfloat sdDiamond(vec2 p, float r) {\n return (abs(p.x) + abs(p.y)) - r;\n}\n\nfloat sdCross(vec2 p, float r, float thickness) {\n vec2 d = abs(p);\n float s1 = sdBox(d, vec2(r, thickness));\n float s2 = sdBox(d, vec2(thickness, r));\n return min(s1, s2);\n}\n\nfloat sdX(vec2 p, float r, float thickness) {\n float c = cos(0.785398);\n float s = sin(0.785398);\n mat2 m = mat2(c, -s, s, c);\n return sdCross(m * p, r, thickness);\n}\n\nfloat sdStar(vec2 p, float r, float rf) {\n const vec2 k1 = vec2(0.80901699, -0.58778525);\n const vec2 k2 = vec2(-k1.x, k1.y);\n p.x = abs(p.x);\n p -= 2.0 * max(dot(k1, p), 0.0) * k1;\n p -= 2.0 * max(dot(k2, p), 0.0) * k2;\n p.x = abs(p.x);\n p.y -= r;\n vec2 ba = rf * vec2(-k1.y, k1.x) - vec2(0, 1);\n float h = clamp(dot(p, ba) / dot(ba, ba), 0.0, r);\n return length(p - ba * h) * sign(p.y * ba.x - p.x * ba.y);\n}\n\nvoid main() {\n vec2 p = gl_PointCoord - vec2(0.5);\n float d = 0.0;\n\n if (uSymbol == 0) {\n d = sdCircle(p, 0.45);\n } else if (uSymbol == 1) {\n d = sdBox(p, vec2(0.35));\n } else if (uSymbol == 2) {\n d = sdDiamond(p, 0.45);\n } else if (uSymbol == 3) {\n d = sdTriangle(vec2(p.x, p.y + 0.1), 0.4);\n } else if (uSymbol == 4) {\n d = sdTriangle(vec2(p.x, -p.y + 0.1), 0.4);\n } else if (uSymbol == 5) {\n d = sdCross(p, 0.45, 0.15);\n } else if (uSymbol == 6) {\n d = sdX(p, 0.45, 0.15);\n } else if (uSymbol == 7) {\n d = sdStar(p, 0.45, 0.4);\n }\n\n if (d > 0.02) discard;\n\n float alpha = 1.0 - smoothstep(0.0, 0.02, d);\n gl_FragColor = vec4(uColor.rgb, uColor.a * alpha);\n}\n`;\n\n// ============================================\n// Heatmap Shader\n// ============================================\n\nexport const HEATMAP_VERT_GLSL = `\nprecision highp float;\nattribute vec2 aPosition;\nattribute float aValue;\nuniform vec2 uScale;\nuniform vec2 uTranslate;\nvarying float vValue;\n\nvoid main() {\n gl_Position = vec4(aPosition * uScale + uTranslate, 0.0, 1.0);\n vValue = aValue;\n}\n`;\n\nexport const HEATMAP_FRAG_GLSL = `\nprecision highp float;\nvarying float vValue;\nuniform float uMinValue;\nuniform float uMaxValue;\nuniform sampler2D uColormap;\n\nvoid main() {\n float range = uMaxValue - uMinValue;\n float t = (vValue - uMinValue) / (range != 0.0 ? range : 1.0);\n t = clamp(t, 0.0, 1.0);\n gl_FragColor = texture2D(uColormap, vec2(t, 0.5));\n}\n`;\n\n// ============================================\n// Triangle Shader (for bands and bars)\n// ============================================\n\nexport const TRIANGLE_VERT_GLSL = `\nprecision highp float;\nattribute vec2 aPosition;\nattribute vec4 aColor;\nuniform vec2 uScale;\nuniform vec2 uTranslate;\nvarying vec4 vColor;\n\nvoid main() {\n vec2 pos = aPosition * uScale + uTranslate;\n gl_Position = vec4(pos, 0.0, 1.0);\n vColor = aColor;\n}\n`;\n\nexport const TRIANGLE_FRAG_GLSL = `\nprecision highp float;\nvarying vec4 vColor;\n\nvoid main() {\n gl_FragColor = vColor;\n}\n`;\n","/**\n * WebGL Program Factory\n * \n * Utilities for compiling and linking WebGL shader programs.\n */\n\nimport {\n LINE_VERT_GLSL,\n LINE_FRAG_GLSL,\n POINT_VERT_GLSL,\n POINT_FRAG_GLSL,\n HEATMAP_VERT_GLSL,\n HEATMAP_FRAG_GLSL,\n} from \"./shaders\";\n\nexport interface ShaderProgram {\n program: WebGLProgram;\n attributes: Record<string, number>;\n uniforms: Record<string, WebGLUniformLocation | null>;\n}\n\n/**\n * Compile a shader\n */\nfunction compileShader(\n gl: WebGLRenderingContext,\n type: number,\n source: string\n): WebGLShader {\n const shader = gl.createShader(type);\n if (!shader) {\n throw new Error(\"[WebGL] Failed to create shader\");\n }\n\n gl.shaderSource(shader, source);\n gl.compileShader(shader);\n\n if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {\n const info = gl.getShaderInfoLog(shader);\n gl.deleteShader(shader);\n throw new Error(`[WebGL] Shader compilation error: ${info}`);\n }\n\n return shader;\n}\n\n/**\n * Link a shader program\n */\nfunction linkProgram(\n gl: WebGLRenderingContext,\n vertShader: WebGLShader,\n fragShader: WebGLShader\n): WebGLProgram {\n const program = gl.createProgram();\n if (!program) {\n throw new Error(\"[WebGL] Failed to create program\");\n }\n\n gl.attachShader(program, vertShader);\n gl.attachShader(program, fragShader);\n gl.linkProgram(program);\n\n if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {\n const info = gl.getProgramInfoLog(program);\n gl.deleteProgram(program);\n throw new Error(`[WebGL] Program link error: ${info}`);\n }\n\n return program;\n}\n\n/**\n * Create a shader program from source\n */\nexport function createProgram(\n gl: WebGLRenderingContext,\n vertSource: string,\n fragSource: string,\n attributeNames: string[],\n uniformNames: string[]\n): ShaderProgram {\n const vertShader = compileShader(gl, gl.VERTEX_SHADER, vertSource);\n const fragShader = compileShader(gl, gl.FRAGMENT_SHADER, fragSource);\n const program = linkProgram(gl, vertShader, fragShader);\n\n // Clean up individual shaders (they're linked now)\n gl.deleteShader(vertShader);\n gl.deleteShader(fragShader);\n\n // Get attribute locations\n const attributes: Record<string, number> = {};\n for (const name of attributeNames) {\n attributes[name] = gl.getAttribLocation(program, name);\n }\n\n // Get uniform locations\n const uniforms: Record<string, WebGLUniformLocation | null> = {};\n for (const name of uniformNames) {\n uniforms[name] = gl.getUniformLocation(program, name);\n }\n\n return { program, attributes, uniforms };\n}\n\n/**\n * All programs used by the WebGL backend\n */\nexport interface ProgramBundle {\n line: ShaderProgram;\n point: ShaderProgram;\n heatmap: ShaderProgram;\n}\n\n/**\n * Create all shader programs\n */\nexport function createAllPrograms(gl: WebGLRenderingContext): ProgramBundle {\n const line = createProgram(\n gl,\n LINE_VERT_GLSL,\n LINE_FRAG_GLSL,\n [\"aPosition\"],\n [\"uScale\", \"uTranslate\", \"uColor\"]\n );\n\n const point = createProgram(\n gl,\n POINT_VERT_GLSL,\n POINT_FRAG_GLSL,\n [\"aPosition\"],\n [\"uScale\", \"uTranslate\", \"uColor\", \"uPointSize\", \"uSymbol\"]\n );\n\n const heatmap = createProgram(\n gl,\n HEATMAP_VERT_GLSL,\n HEATMAP_FRAG_GLSL,\n [\"aPosition\", \"aValue\"],\n [\"uScale\", \"uTranslate\", \"uMinValue\", \"uMaxValue\", \"uColormap\"]\n );\n\n return { line, point, heatmap };\n}\n\n/**\n * Destroy all programs\n */\nexport function destroyPrograms(gl: WebGLRenderingContext, bundle: ProgramBundle): void {\n gl.deleteProgram(bundle.line.program);\n gl.deleteProgram(bundle.point.program);\n gl.deleteProgram(bundle.heatmap.program);\n}\n","/**\n * WebGL Backend - GPU abstraction layer implementation for WebGL\n * \n * Provides the same interface as WebGPUBackend for compatibility.\n * This serves as a fallback for browsers without WebGPU support.\n */\n\nimport type {\n BufferDescriptor,\n BufferId,\n GpuBackend,\n GpuBackendInfo,\n GpuViewport,\n Texture1DDescriptor,\n TextureId,\n} from \"../../types\";\nimport type { DrawCall, DrawList, PointStyle, HeatmapStyle } from \"../../drawList\";\nimport type { FrameUniforms } from \"../../frame\";\nimport { createAllPrograms, destroyPrograms, type ProgramBundle } from \"./programFactory\";\n\nexport interface WebGLBackendOptions {\n antialias?: boolean;\n preserveDrawingBuffer?: boolean;\n powerPreference?: \"default\" | \"low-power\" | \"high-performance\";\n}\n\n/**\n * Symbol name to number mapping\n */\nconst SYMBOL_MAP: Record<string, number> = {\n circle: 0,\n square: 1,\n diamond: 2,\n triangle: 3,\n triangleDown: 4,\n cross: 5,\n x: 6,\n star: 7,\n};\n\n/**\n * Calculate transform uniforms from bounds\n */\nfunction calculateUniforms(bounds: {\n xMin: number;\n xMax: number;\n yMin: number;\n yMax: number;\n}): { scale: [number, number]; translate: [number, number] } {\n const dataWidth = bounds.xMax - bounds.xMin;\n const dataHeight = bounds.yMax - bounds.yMin;\n\n const scaleX = dataWidth > 0 ? 2 / dataWidth : 1;\n const scaleY = dataHeight > 0 ? 2 / dataHeight : 1;\n\n const translateX = -1 - bounds.xMin * scaleX;\n const translateY = -1 - bounds.yMin * scaleY;\n\n return {\n scale: [scaleX, scaleY],\n translate: [translateX, translateY],\n };\n}\n\n/**\n * Get color from style\n */\nfunction getColorFromStyle(style: any): [number, number, number, number] {\n const color = style?.color ?? [1, 0, 0.3, 1];\n const opacity = style?.opacity ?? 1;\n \n if (Array.isArray(color)) {\n return [color[0], color[1], color[2], (color[3] ?? 1) * opacity];\n }\n \n return [1, 0, 0.3, opacity];\n}\n\nexport class WebGLBackend implements GpuBackend {\n public readonly info: GpuBackendInfo;\n\n private canvas: HTMLCanvasElement;\n private opts: WebGLBackendOptions;\n private gl: WebGLRenderingContext | null = null;\n \n private viewport: GpuViewport | null = null;\n private dpr: number = 1;\n\n private programs: ProgramBundle | null = null;\n private buffers = new Map<string, WebGLBuffer>();\n private textures = new Map<string, WebGLTexture>();\n\n constructor(canvas: HTMLCanvasElement, opts: WebGLBackendOptions = {}) {\n this.canvas = canvas;\n this.opts = opts;\n this.info = {\n type: \"webgl\",\n available: WebGLBackend.isSupported(),\n };\n }\n\n static isSupported(): boolean {\n if (typeof document === \"undefined\") return false;\n \n try {\n const canvas = document.createElement(\"canvas\");\n const gl = canvas.getContext(\"webgl\") || canvas.getContext(\"experimental-webgl\");\n return !!gl;\n } catch {\n return false;\n }\n }\n\n async init(): Promise<void> {\n if (!this.info.available) {\n throw new Error(\"[gpu] WebGL not supported\");\n }\n\n const gl = this.canvas.getContext(\"webgl\", {\n alpha: true,\n antialias: this.opts.antialias ?? true,\n preserveDrawingBuffer: this.opts.preserveDrawingBuffer ?? true,\n powerPreference: this.opts.powerPreference ?? \"high-performance\",\n });\n\n if (!gl) {\n throw new Error(\"[gpu] Failed to get WebGL context\");\n }\n\n this.gl = gl;\n\n // Enable blending\n gl.enable(gl.BLEND);\n gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);\n\n // Create shader programs\n this.programs = createAllPrograms(gl);\n }\n\n setViewport(viewport: GpuViewport): void {\n this.viewport = viewport;\n this.dpr = viewport.dpr;\n \n const w = Math.max(1, Math.floor(viewport.width * viewport.dpr));\n const h = Math.max(1, Math.floor(viewport.height * viewport.dpr));\n \n if (this.canvas.width !== w) this.canvas.width = w;\n if (this.canvas.height !== h) this.canvas.height = h;\n \n if (this.gl) {\n this.gl.viewport(0, 0, w, h);\n }\n }\n\n createOrUpdateBuffer(\n id: BufferId,\n data: ArrayBufferView,\n desc?: Partial<BufferDescriptor>\n ): void {\n if (!this.gl) {\n throw new Error(\"[gpu] WebGLBackend not initialized\");\n }\n\n const gl = this.gl;\n \n let buffer = this.buffers.get(id);\n if (!buffer) {\n buffer = gl.createBuffer()!;\n this.buffers.set(id, buffer);\n }\n\n const target = desc?.usage === \"index\" ? gl.ELEMENT_ARRAY_BUFFER : gl.ARRAY_BUFFER;\n \n gl.bindBuffer(target, buffer);\n gl.bufferData(target, data, gl.DYNAMIC_DRAW);\n gl.bindBuffer(target, null);\n }\n\n deleteBuffer(id: BufferId): void {\n if (!this.gl) return;\n \n const buffer = this.buffers.get(id);\n if (buffer) {\n this.gl.deleteBuffer(buffer);\n this.buffers.delete(id);\n }\n }\n\n createOrUpdateTexture1D(\n id: TextureId,\n data: Uint8Array,\n desc?: Partial<Texture1DDescriptor>\n ): void {\n if (!this.gl) {\n throw new Error(\"[gpu] WebGLBackend not initialized\");\n }\n\n const gl = this.gl;\n const width = desc?.width ?? Math.floor(data.length / 4);\n\n let texture = this.textures.get(id);\n if (!texture) {\n texture = gl.createTexture()!;\n this.textures.set(id, texture);\n }\n\n gl.bindTexture(gl.TEXTURE_2D, texture);\n gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, data);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);\n gl.bindTexture(gl.TEXTURE_2D, null);\n }\n\n deleteTexture(id: TextureId): void {\n if (!this.gl) return;\n \n const texture = this.textures.get(id);\n if (texture) {\n this.gl.deleteTexture(texture);\n this.textures.delete(id);\n }\n }\n\n render(drawList: DrawList, frame: FrameUniforms): void {\n this.renderWithBounds(drawList, frame, { xMin: -1, xMax: 1, yMin: -1, yMax: 1 });\n }\n\n renderWithBounds(\n drawList: DrawList,\n frame: FrameUniforms,\n bounds: { xMin: number; xMax: number; yMin: number; yMax: number }\n ): void {\n if (!this.gl || !this.programs) {\n throw new Error(\"[gpu] WebGLBackend not initialized\");\n }\n\n const gl = this.gl;\n\n if (!this.viewport) {\n this.setViewport(frame.viewport);\n }\n\n // Clear\n gl.clearColor(\n frame.clearColor[0],\n frame.clearColor[1],\n frame.clearColor[2],\n frame.clearColor[3]\n );\n gl.clear(gl.COLOR_BUFFER_BIT);\n\n // Render each draw call\n for (const item of drawList.items) {\n if (!item.visible) continue;\n\n const buffer = this.buffers.get(item.bufferId);\n if (!buffer) continue;\n\n // Use item's yBounds if specified\n const itemBounds = item.yBounds\n ? { ...bounds, yMin: item.yBounds.min, yMax: item.yBounds.max }\n : bounds;\n\n this.renderDrawCall(item, buffer, itemBounds);\n }\n }\n\n private renderDrawCall(\n item: DrawCall,\n buffer: WebGLBuffer,\n bounds: { xMin: number; xMax: number; yMin: number; yMax: number }\n ): void {\n const uniforms = calculateUniforms(bounds);\n const color = getColorFromStyle(item.style);\n\n switch (item.kind) {\n case \"line\":\n case \"step\":\n this.renderLine(buffer, item.count, uniforms, color);\n break;\n\n case \"scatter\":\n case \"points\":\n this.renderPoints(buffer, item.count, uniforms, color, item.style as PointStyle);\n break;\n\n case \"line+scatter\":\n this.renderLine(buffer, item.count, uniforms, color);\n this.renderPoints(buffer, item.count, uniforms, color, item.style as PointStyle);\n break;\n\n case \"step+scatter\":\n if (item.stepBufferId && item.stepCount) {\n const stepBuffer = this.buffers.get(item.stepBufferId);\n if (stepBuffer) {\n this.renderLine(stepBuffer, item.stepCount, uniforms, color);\n }\n } else {\n this.renderLine(buffer, item.count, uniforms, color);\n }\n this.renderPoints(buffer, item.count, uniforms, color, item.style as PointStyle);\n break;\n\n case \"band\":\n const bandColor: [number, number, number, number] = [\n color[0], color[1], color[2], color[3] * 0.4\n ];\n this.renderBand(buffer, item.count, uniforms, bandColor);\n break;\n\n case \"triangles\":\n case \"bar\":\n this.renderTriangles(buffer, item.count, uniforms, color);\n break;\n\n case \"heatmap\":\n this.renderHeatmap(buffer, item.count, uniforms, item.style as HeatmapStyle, item.textureId);\n break;\n }\n }\n\n private renderLine(\n buffer: WebGLBuffer,\n count: number,\n uniforms: { scale: [number, number]; translate: [number, number] },\n color: [number, number, number, number]\n ): void {\n const gl = this.gl!;\n const prog = this.programs!.line;\n\n gl.useProgram(prog.program);\n gl.bindBuffer(gl.ARRAY_BUFFER, buffer);\n\n gl.enableVertexAttribArray(prog.attributes.aPosition);\n gl.vertexAttribPointer(prog.attributes.aPosition, 2, gl.FLOAT, false, 0, 0);\n\n gl.uniform2f(prog.uniforms.uScale!, uniforms.scale[0], uniforms.scale[1]);\n gl.uniform2f(prog.uniforms.uTranslate!, uniforms.translate[0], uniforms.translate[1]);\n gl.uniform4f(prog.uniforms.uColor!, color[0], color[1], color[2], color[3]);\n\n gl.drawArrays(gl.LINE_STRIP, 0, count);\n gl.disableVertexAttribArray(prog.attributes.aPosition);\n }\n\n private renderPoints(\n buffer: WebGLBuffer,\n count: number,\n uniforms: { scale: [number, number]; translate: [number, number] },\n color: [number, number, number, number],\n style?: PointStyle\n ): void {\n const gl = this.gl!;\n const prog = this.programs!.point;\n\n const pointSize = (style?.pointSize ?? 4) * this.dpr;\n const symbol = SYMBOL_MAP[style?.symbol ?? \"circle\"] ?? 0;\n\n gl.useProgram(prog.program);\n gl.bindBuffer(gl.ARRAY_BUFFER, buffer);\n\n gl.enableVertexAttribArray(prog.attributes.aPosition);\n gl.vertexAttribPointer(prog.attributes.aPosition, 2, gl.FLOAT, false, 0, 0);\n\n gl.uniform2f(prog.uniforms.uScale!, uniforms.scale[0], uniforms.scale[1]);\n gl.uniform2f(prog.uniforms.uTranslate!, uniforms.translate[0], uniforms.translate[1]);\n gl.uniform4f(prog.uniforms.uColor!, color[0], color[1], color[2], color[3]);\n gl.uniform1f(prog.uniforms.uPointSize!, pointSize);\n gl.uniform1i(prog.uniforms.uSymbol!, symbol);\n\n gl.drawArrays(gl.POINTS, 0, count);\n gl.disableVertexAttribArray(prog.attributes.aPosition);\n }\n\n private renderBand(\n buffer: WebGLBuffer,\n count: number,\n uniforms: { scale: [number, number]; translate: [number, number] },\n color: [number, number, number, number]\n ): void {\n const gl = this.gl!;\n const prog = this.programs!.line;\n\n gl.useProgram(prog.program);\n gl.bindBuffer(gl.ARRAY_BUFFER, buffer);\n\n gl.enableVertexAttribArray(prog.attributes.aPosition);\n gl.vertexAttribPointer(prog.attributes.aPosition, 2, gl.FLOAT, false, 0, 0);\n\n gl.uniform2f(prog.uniforms.uScale!, uniforms.scale[0], uniforms.scale[1]);\n gl.uniform2f(prog.uniforms.uTranslate!, uniforms.translate[0], uniforms.translate[1]);\n gl.uniform4f(prog.uniforms.uColor!, color[0], color[1], color[2], color[3]);\n\n gl.drawArrays(gl.TRIANGLE_STRIP, 0, count);\n gl.disableVertexAttribArray(prog.attributes.aPosition);\n }\n\n private renderTriangles(\n buffer: WebGLBuffer,\n count: number,\n uniforms: { scale: [number, number]; translate: [number, number] },\n color: [number, number, number, number]\n ): void {\n const gl = this.gl!;\n const prog = this.programs!.line;\n\n gl.useProgram(prog.program);\n gl.bindBuffer(gl.ARRAY_BUFFER, buffer);\n\n gl.enableVertexAttribArray(prog.attributes.aPosition);\n gl.vertexAttribPointer(prog.attributes.aPosition, 2, gl.FLOAT, false, 0, 0);\n\n gl.uniform2f(prog.uniforms.uScale!, uniforms.scale[0], uniforms.scale[1]);\n gl.uniform2f(prog.uniforms.uTranslate!, uniforms.translate[0], uniforms.translate[1]);\n gl.uniform4f(prog.uniforms.uColor!, color[0], color[1], color[2], color[3]);\n\n gl.drawArrays(gl.TRIANGLES, 0, count);\n gl.disableVertexAttribArray(prog.attributes.aPosition);\n }\n\n private renderHeatmap(\n buffer: WebGLBuffer,\n count: number,\n uniforms: { scale: [number, number]; translate: [number, number] },\n style?: HeatmapStyle,\n textureId?: string\n ): void {\n if (!textureId) return;\n \n const texture = this.textures.get(textureId);\n if (!texture) return;\n\n const gl = this.gl!;\n const prog = this.programs!.heatmap;\n\n const zBounds = style?.zBounds ?? { min: 0, max: 1 };\n\n gl.useProgram(prog.program);\n gl.bindBuffer(gl.ARRAY_BUFFER, buffer);\n\n gl.enableVertexAttribArray(prog.attributes.aPosition);\n gl.vertexAttribPointer(prog.attributes.aPosition, 2, gl.FLOAT, false, 12, 0);\n\n if (prog.attributes.aValue !== -1) {\n gl.enableVertexAttribArray(prog.attributes.aValue);\n gl.vertexAttribPointer(prog.attributes.aValue, 1, gl.FLOAT, false, 12, 8);\n }\n\n gl.uniform2f(prog.uniforms.uScale!, uniforms.scale[0], uniforms.scale[1]);\n gl.uniform2f(prog.uniforms.uTranslate!, uniforms.translate[0], uniforms.translate[1]);\n gl.uniform1f(prog.uniforms.uMinValue!, zBounds.min);\n gl.uniform1f(prog.uniforms.uMaxValue!, zBounds.max);\n\n gl.activeTexture(gl.TEXTURE0);\n gl.bindTexture(gl.TEXTURE_2D, texture);\n gl.uniform1i(prog.uniforms.uColormap!, 0);\n\n gl.drawArrays(gl.TRIANGLES, 0, count);\n\n gl.disableVertexAttribArray(prog.attributes.aPosition);\n if (prog.attributes.aValue !== -1) {\n gl.disableVertexAttribArray(prog.attributes.aValue);\n }\n }\n\n destroy(): void {\n if (!this.gl) return;\n\n const gl = this.gl;\n\n // Delete all buffers\n for (const buffer of this.buffers.values()) {\n gl.deleteBuffer(buffer);\n }\n this.buffers.clear();\n\n // Delete all textures\n for (const texture of this.textures.values()) {\n gl.deleteTexture(texture);\n }\n this.textures.clear();\n\n // Delete programs\n if (this.programs) {\n destroyPrograms(gl, this.programs);\n this.programs = null;\n }\n\n this.gl = null;\n }\n}\n","/**\n * Series Adapter - Converts VeloPlot series data to GPU DrawCalls\n * \n * This adapter bridges the gap between the existing VeloPlot series system\n * and the new backend-agnostic GPU abstraction layer.\n */\n\nimport type { \n DrawCall, \n DrawList, \n DrawKind, \n PointStyle,\n HeatmapStyle,\n} from \"../drawList\";\nimport type { GpuBackend, BufferId, TextureId, RGBA } from \"../types\";\n\n/**\n * Series style from the original renderer\n */\nexport interface SeriesStyle {\n color?: string | RGBA;\n opacity?: number;\n lineWidth?: number;\n pointSize?: number;\n symbol?: string;\n}\n\n/**\n * Series render data from the chart system\n */\nexport interface SeriesData {\n id: string;\n type: \"line\" | \"scatter\" | \"line+scatter\" | \"step\" | \"step+scatter\" | \"band\" | \"bar\" | \"heatmap\";\n visible: boolean;\n \n /** Main vertex data */\n data: Float32Array;\n \n /** Style properties */\n style: SeriesStyle;\n \n /** For step charts */\n stepData?: Float32Array;\n \n /** Y-axis bounds for multi-axis support */\n yBounds?: { min: number; max: number };\n \n /** For heatmaps */\n zBounds?: { min: number; max: number };\n colormapData?: Uint8Array;\n colormap?: string;\n}\n\n/**\n * Mutable color tuple for internal use\n */\ntype MutableRGBA = [number, number, number, number];\n\n/**\n * Parse color from various formats to RGBA\n */\nexport function parseColorToRGBA(color: string | RGBA | undefined): MutableRGBA {\n if (!color) {\n return [1, 0, 0.3, 1]; // Default magenta\n }\n \n // If already an RGBA tuple, return a copy\n if (Array.isArray(color)) {\n return [color[0], color[1], color[2], color[3] ?? 1];\n }\n \n // At this point, color must be a string\n const colorStr = color as string;\n \n // Parse hex color\n if (colorStr.startsWith(\"#\")) {\n const hex = colorStr.slice(1);\n if (hex.length === 3) {\n const r = parseInt(hex[0] + hex[0], 16) / 255;\n const g = parseInt(hex[1] + hex[1], 16) / 255;\n const b = parseInt(hex[2] + hex[2], 16) / 255;\n return [r, g, b, 1];\n }\n if (hex.length === 6) {\n const r = parseInt(hex.slice(0, 2), 16) / 255;\n const g = parseInt(hex.slice(2, 4), 16) / 255;\n const b = parseInt(hex.slice(4, 6), 16) / 255;\n return [r, g, b, 1];\n }\n if (hex.length === 8) {\n const r = parseInt(hex.slice(0, 2), 16) / 255;\n const g = parseInt(hex.slice(2, 4), 16) / 255;\n const b = parseInt(hex.slice(4, 6), 16) / 255;\n const a = parseInt(hex.slice(6, 8), 16) / 255;\n return [r, g, b, a];\n }\n }\n \n // Parse rgb/rgba\n const rgbaMatch = colorStr.match(/rgba?\\((\\d+),\\s*(\\d+),\\s*(\\d+)(?:,\\s*([\\d.]+))?\\)/);\n if (rgbaMatch) {\n const r = parseInt(rgbaMatch[1]) / 255;\n const g = parseInt(rgbaMatch[2]) / 255;\n const b = parseInt(rgbaMatch[3]) / 255;\n const a = rgbaMatch[4] ? parseFloat(rgbaMatch[4]) : 1;\n return [r, g, b, a];\n }\n \n return [1, 0, 0.3, 1]; // Fallback\n}\n\n/**\n * Map series type to draw kind\n */\nfunction mapSeriesTypeToDrawKind(type: SeriesData[\"type\"]): DrawKind {\n return type as DrawKind;\n}\n\n/**\n * Convert SeriesStyle to GPU styles\n */\nfunction convertStyle(style: SeriesStyle, type: SeriesData[\"type\"]): DrawCall[\"style\"] {\n const baseColor = parseColorToRGBA(style.color);\n const opacity = style.opacity ?? 1;\n const color: MutableRGBA = [baseColor[0], baseColor[1], baseColor[2], baseColor[3] * opacity];\n \n if (type === \"scatter\" || type === \"line+scatter\" || type === \"step+scatter\") {\n return {\n color: color as RGBA,\n opacity,\n pointSize: style.pointSize ?? 4,\n symbol: (style.symbol ?? \"circle\") as PointStyle[\"symbol\"],\n } as PointStyle;\n }\n \n return {\n color: color as RGBA,\n opacity,\n lineWidth: style.lineWidth ?? 1,\n };\n}\n\n/**\n * Series Adapter class\n * \n * Manages the conversion of chart series to GPU resources and draw calls.\n */\nexport class SeriesAdapter {\n private backend: GpuBackend;\n private seriesBufferMap = new Map<string, BufferId>();\n private seriesStepBufferMap = new Map<string, BufferId>();\n private seriesTextureMap = new Map<string, TextureId>();\n \n constructor(backend: GpuBackend) {\n this.backend = backend;\n }\n \n /**\n * Get buffer ID for a series\n */\n private getBufferId(seriesId: string): BufferId {\n if (!this.seriesBufferMap.has(seriesId)) {\n this.seriesBufferMap.set(seriesId, `series:${seriesId}`);\n }\n return this.seriesBufferMap.get(seriesId)!;\n }\n \n /**\n * Get step buffer ID for a series\n */\n private getStepBufferId(seriesId: string): BufferId {\n if (!this.seriesStepBufferMap.has(seriesId)) {\n this.seriesStepBufferMap.set(seriesId, `series:${seriesId}:step`);\n }\n return this.seriesStepBufferMap.get(seriesId)!;\n }\n \n /**\n * Get texture ID for a series\n */\n private getTextureId(seriesId: string): TextureId {\n if (!this.seriesTextureMap.has(seriesId)) {\n this.seriesTextureMap.set(seriesId, `texture:${seriesId}`);\n }\n return this.seriesTextureMap.get(seriesId)!;\n }\n \n /**\n * Update series data in GPU buffers\n */\n updateSeries(series: SeriesData): void {\n const bufferId = this.getBufferId(series.id);\n \n // Update main buffer\n this.backend.createOrUpdateBuffer(bufferId, series.data, { usage: \"vertex\" });\n \n // Update step buffer if present\n if (series.stepData && (series.type === \"step\" || series.type === \"step+scatter\")) {\n const stepBufferId = this.getStepBufferId(series.id);\n this.backend.createOrUpdateBuffer(stepBufferId, series.stepData, { usage: \"vertex\" });\n }\n \n // Update colormap texture if present\n if (series.type === \"heatmap\" && series.colormapData) {\n const textureId = this.getTextureId(series.id);\n this.backend.createOrUpdateTexture1D(textureId, series.colormapData, {\n width: series.colormapData.length / 4,\n });\n }\n }\n \n /**\n * Remove a series from GPU resources\n */\n removeSeries(seriesId: string): void {\n const bufferId = this.seriesBufferMap.get(seriesId);\n if (bufferId) {\n this.backend.deleteBuffer(bufferId);\n this.seriesBufferMap.delete(seriesId);\n }\n \n const stepBufferId = this.seriesStepBufferMap.get(seriesId);\n if (stepBufferId) {\n this.backend.deleteBuffer(stepBufferId);\n this.seriesStepBufferMap.delete(seriesId);\n }\n \n const textureId = this.seriesTextureMap.get(seriesId);\n if (textureId) {\n this.backend.deleteTexture(textureId);\n this.seriesTextureMap.delete(seriesId);\n }\n }\n \n /**\n * Build draw list from series array\n */\n buildDrawList(seriesArray: SeriesData[]): DrawList {\n const items: DrawCall[] = [];\n \n for (const series of seriesArray) {\n // Update GPU resources\n this.updateSeries(series);\n \n const bufferId = this.getBufferId(series.id);\n const pointCount = series.data.length / 2; // Assuming x,y pairs\n \n const drawCall: DrawCall = {\n id: series.id,\n kind: mapSeriesTypeToDrawKind(series.type),\n bufferId,\n count: series.type === \"heatmap\" ? series.data.length / 3 : pointCount,\n visible: series.visible,\n style: convertStyle(series.style, series.type),\n yBounds: series.yBounds,\n };\n \n // Step buffer\n if (series.stepData && (series.type === \"step\" || series.type === \"step+scatter\")) {\n drawCall.stepBufferId = this.getStepBufferId(series.id);\n drawCall.stepCount = series.stepData.length / 2;\n }\n \n // Heatmap texture\n if (series.type === \"heatmap\") {\n drawCall.textureId = this.getTextureId(series.id);\n (drawCall.style as HeatmapStyle) = {\n zBounds: series.zBounds,\n colormap: series.colormap,\n };\n }\n \n items.push(drawCall);\n }\n \n return { items };\n }\n \n /**\n * Cleanup all resources\n */\n destroy(): void {\n for (const bufferId of this.seriesBufferMap.values()) {\n this.backend.deleteBuffer(bufferId);\n }\n for (const stepBufferId of this.seriesStepBufferMap.values()) {\n this.backend.deleteBuffer(stepBufferId);\n }\n for (const textureId of this.seriesTextureMap.values()) {\n this.backend.deleteTexture(textureId);\n }\n \n this.seriesBufferMap.clear();\n this.seriesStepBufferMap.clear();\n this.seriesTextureMap.clear();\n }\n}\n","/**\n * GPU Renderer Facade - Drop-in replacement for NativeWebGLRenderer\n * \n * Provides the same interface as NativeWebGLRenderer but uses the\n * backend-agnostic GPU abstraction layer. Supports both WebGPU and WebGL.\n */\n\nimport type { GpuBackend, RGBA } from \"../types\";\nimport type { DrawList, DrawCall, PointStyle } from \"../drawList\";\nimport type { FrameUniforms } from \"../frame\";\nimport { WebGPUBackend } from \"../backends/webgpu/WebGPUBackend\";\nimport { WebGLBackend } from \"../backends/webgl/WebGLBackend\";\nimport { SeriesAdapter, parseColorToRGBA } from \"./seriesAdapter\";\nimport type { SeriesStyle } from \"./seriesAdapter\";\nimport type { NativeSeriesRenderData } from \"../../renderer/native/types\";\n\n/**\n * Bounds interface matching the original\n */\nexport interface Bounds {\n xMin: number;\n xMax: number;\n yMin: number;\n yMax: number;\n}\n\n/**\n * Series render data matching NativeSeriesRenderData\n */\nexport interface GpuSeriesRenderData {\n id: string;\n type: \"line\" | \"scatter\" | \"line+scatter\" | \"step\" | \"step+scatter\" | \"band\" | \"bar\" | \"heatmap\";\n visible: boolean;\n style: SeriesStyle;\n \n /** Y-bounds for multi-axis support */\n yBounds?: { min: number; max: number };\n \n /** Heatmap specific */\n zBounds?: { min: number; max: number };\n colormap?: string;\n}\n\n/**\n * Render options matching NativeRenderOptions\n */\nexport interface GpuRenderOptions {\n bounds: Bounds;\n backgroundColor?: [number, number, number, number];\n plotArea?: { x: number; y: number; width: number; height: number };\n}\n\nexport interface GpuNativeRenderOptions extends GpuRenderOptions {\n invertX?: boolean;\n plotAreaBackground?: [number, number, number, number];\n dpr?: number;\n}\n\n/**\n * Backend preference\n */\nexport type BackendPreference = \"webgpu\" | \"webgl\" | \"auto\";\n\n/**\n * GPU Renderer options\n */\nexport interface GpuRendererOptions {\n backend?: BackendPreference;\n powerPreference?: \"low-power\" | \"high-performance\";\n}\n\n/**\n * GPU Renderer - Unified renderer using the GPU abstraction layer\n */\nexport class GpuRenderer {\n private canvas: HTMLCanvasElement;\n private options: GpuRendererOptions;\n private backend: GpuBackend | null = null;\n private adapter: SeriesAdapter | null = null;\n \n private dpr: number;\n private isInitialized = false;\n private backendType: \"webgpu\" | \"webgl\" | null = null;\n \n // Buffer management\n private bufferDataMap = new Map<string, Float32Array>();\n private stepBufferDataMap = new Map<string, Float32Array>();\n private colormapDataMap = new Map<string, Uint8Array>();\n \n constructor(canvas: HTMLCanvasElement, options: GpuRendererOptions = {}) {\n this.canvas = canvas;\n this.options = options;\n this.dpr = window.devicePixelRatio || 1;\n }\n \n /**\n * Initialize the renderer\n */\n async init(): Promise<boolean> {\n const preference = this.options.backend ?? \"auto\";\n \n // Try WebGPU first if preferred or auto\n if (preference === \"webgpu\" || preference === \"auto\") {\n if (WebGPUBackend.isSupported()) {\n try {\n const backend = new WebGPUBackend(this.canvas, {\n powerPreference: this.options.powerPreference ?? \"high-performance\",\n });\n await backend.init();\n \n this.backend = backend;\n this.backendType = \"webgpu\";\n this.adapter = new SeriesAdapter(backend);\n this.isInitialized = true;\n \n this.resize();\n return true;\n } catch (e) {\n console.warn(\"[GpuRenderer] WebGPU init failed:\", e);\n }\n }\n }\n \n // Fallback to WebGL\n if (preference === \"webgl\" || preference === \"auto\") {\n if (WebGLBackend.isSupported()) {\n try {\n const backend = new WebGLBackend(this.canvas, {\n powerPreference: this.options.powerPreference ?? \"high-performance\",\n });\n await backend.init();\n \n this.backend = backend;\n this.backendType = \"webgl\";\n this.adapter = new SeriesAdapter(backend);\n this.isInitialized = true;\n \n this.resize();\n console.info(\"[GpuRenderer] Using WebGL backend (WebGPU not available)\");\n return true;\n } catch (e) {\n console.warn(\"[GpuRenderer] WebGL init failed:\", e);\n }\n }\n }\n \n return false;\n }\n \n /**\n * Check if renderer is available\n */\n get available(): boolean {\n return this.isInitialized;\n }\n \n /**\n * Get the active backend type\n */\n get activeBackend(): \"webgpu\" | \"webgl\" | null {\n return this.backendType;\n }\n \n /**\n * Set device pixel ratio\n */\n setDPR(dpr: number): void {\n this.dpr = dpr;\n this.resize();\n }\n \n /**\n * Check if vertex data exists for a buffer id\n */\n hasBuffer(id: string): boolean {\n return this.bufferDataMap.has(id) || this.stepBufferDataMap.has(id);\n }\n\n hasColormap(id: string): boolean {\n return this.colormapDataMap.has(id);\n }\n\n /**\n * Render from NativeWebGLRenderer-compatible series descriptors (chart integration path).\n */\n renderNativeSeries(\n series: NativeSeriesRenderData[],\n options: GpuNativeRenderOptions,\n ): void {\n if (!this.isInitialized || !this.backend) return;\n\n const items: DrawCall[] = [];\n\n for (const s of series) {\n if (!s.visible) continue;\n\n if (s.type === \"boxplot\") {\n this.appendBoxplotDraws(s, items);\n continue;\n }\n if (s.type === \"waterfall\") {\n this.appendWaterfallDraws(s, items);\n continue;\n }\n\n if (s.count === 0) continue;\n\n const data = this.bufferDataMap.get(s.id);\n if (!data) continue;\n\n this.backend.createOrUpdateBuffer(s.id, data, { usage: \"vertex\" });\n\n const baseColor = parseColorToRGBA(\n typeof s.style?.color === \"string\" ? s.style.color : \"#00f2ff\",\n );\n const opacity = s.style?.opacity ?? 1;\n const color: [number, number, number, number] = [\n baseColor[0],\n baseColor[1],\n baseColor[2],\n baseColor[3] * opacity,\n ];\n\n const kind = this.mapNativeDrawKind(s.type);\n const drawCall: DrawCall = {\n id: s.id,\n kind,\n bufferId: s.id,\n count: s.count,\n visible: true,\n yBounds: s.yBounds,\n };\n\n if (\n kind === \"scatter\" ||\n kind === \"line+scatter\" ||\n kind === \"step+scatter\" ||\n kind === \"points\"\n ) {\n drawCall.style = {\n color: color as RGBA,\n opacity,\n pointSize: s.style?.pointSize ?? 4,\n symbol: (s.style?.symbol ?? \"circle\") as PointStyle[\"symbol\"],\n };\n } else if (kind === \"heatmap\") {\n drawCall.textureId = `${s.id}_colormap`;\n drawCall.style = {\n zBounds: s.zBounds,\n colormap: s.colormap,\n };\n const colormapData = this.colormapDataMap.get(`${s.id}_colormap`);\n if (colormapData) {\n this.backend.createOrUpdateTexture1D(drawCall.textureId, colormapData, {\n width: colormapData.length / 4,\n });\n }\n } else {\n drawCall.style = {\n color: color as RGBA,\n opacity,\n lineWidth: s.style?.width ?? s.style?.lineWidth ?? 1,\n };\n }\n\n if ((kind === \"step\" || kind === \"step+scatter\") && s.stepBuffer && s.stepCount) {\n const stepId = `${s.id}_step`;\n const stepData = this.stepBufferDataMap.get(stepId);\n if (stepData) {\n this.backend.createOrUpdateBuffer(stepId, stepData, { usage: \"vertex\" });\n drawCall.stepBufferId = stepId;\n drawCall.stepCount = s.stepCount;\n }\n }\n\n items.push(drawCall);\n }\n\n const dpr = options.dpr ?? this.dpr;\n const frame: FrameUniforms = {\n viewport: {\n width: this.canvas.clientWidth,\n height: this.canvas.clientHeight,\n dpr,\n },\n clearColor: (options.backgroundColor ?? [0.1, 0.1, 0.18, 1]) as RGBA,\n bounds: options.bounds,\n plotArea: options.plotArea,\n };\n\n if (\"renderWithBounds\" in this.backend) {\n (this.backend as GpuBackend & {\n renderWithBounds: (\n drawList: DrawList,\n frame: FrameUniforms,\n bounds: GpuRenderOptions[\"bounds\"],\n ) => void;\n }).renderWithBounds({ items }, frame, options.bounds);\n } else {\n this.backend.render({ items }, frame);\n }\n }\n\n private appendBoxplotDraws(s: NativeSeriesRenderData, items: DrawCall[]): void {\n const color = this.seriesColor(s.style);\n const lineStyle = { color, opacity: s.style?.opacity ?? 1, lineWidth: s.style?.width ?? 1 };\n const fillStyle = { color, opacity: (s.style?.opacity ?? 1) * 0.85, lineWidth: 1 };\n\n this.pushDraw(items, `${s.id}_box_faces`, \"bar\", s.boxCount ?? 0, fillStyle, s.yBounds);\n this.pushDraw(items, `${s.id}_box_lines`, \"line\", s.boxLinesCount ?? 0, lineStyle, s.yBounds);\n }\n\n private appendWaterfallDraws(s: NativeSeriesRenderData, items: DrawCall[]): void {\n const style = s.style ?? {};\n const positive = this.colorFromHex(style.positiveColor ?? \"#22c55e\", 0.9);\n const negative = this.colorFromHex(style.negativeColor ?? \"#ef4444\", 0.9);\n const subtotal = this.colorFromHex(style.subtotalColor ?? \"#3b82f6\", 0.9);\n const connector = this.colorFromHex(style.connectorColor ?? \"#64748b\", 0.6);\n\n this.pushDraw(items, `${s.id}_wf_positive`, \"bar\", s.wfPositiveCount ?? 0, { color: positive, opacity: 0.9, lineWidth: 1 }, s.yBounds);\n this.pushDraw(items, `${s.id}_wf_negative`, \"bar\", s.wfNegativeCount ?? 0, { color: negative, opacity: 0.9, lineWidth: 1 }, s.yBounds);\n this.pushDraw(items, `${s.id}_wf_subtotal`, \"bar\", s.wfSubtotalCount ?? 0, { color: subtotal, opacity: 0.9, lineWidth: 1 }, s.yBounds);\n if (style.showConnectors !== false) {\n this.pushDraw(items, `${s.id}_wf_connectors`, \"line\", s.wfConnectorCount ?? 0, { color: connector, opacity: 0.6, lineWidth: 1 }, s.yBounds);\n }\n }\n\n private pushDraw(\n items: DrawCall[],\n bufferId: string,\n kind: DrawCall[\"kind\"],\n count: number,\n style: DrawCall[\"style\"],\n yBounds?: { min: number; max: number },\n ): void {\n if (count <= 0) return;\n const data = this.bufferDataMap.get(bufferId);\n if (!data || !this.backend) return;\n this.backend.createOrUpdateBuffer(bufferId, data, { usage: \"vertex\" });\n items.push({\n id: bufferId,\n kind,\n bufferId,\n count,\n visible: true,\n style,\n yBounds,\n });\n }\n\n private seriesColor(style: NativeSeriesRenderData[\"style\"]): [number, number, number, number] {\n const base = parseColorToRGBA(typeof style?.color === \"string\" ? style.color : \"#00f2ff\");\n const opacity = style?.opacity ?? 1;\n return [base[0], base[1], base[2], base[3] * opacity];\n }\n\n private colorFromHex(hex: string, opacity: number): [number, number, number, number] {\n const c = parseColorToRGBA(hex);\n return [c[0], c[1], c[2], c[3] * opacity];\n }\n\n private mapNativeDrawKind(\n type: NativeSeriesRenderData[\"type\"],\n ): DrawCall[\"kind\"] {\n switch (type) {\n case \"scatter\":\n return \"scatter\";\n case \"line+scatter\":\n return \"line+scatter\";\n case \"step\":\n return \"step\";\n case \"step+scatter\":\n return \"step+scatter\";\n case \"band\":\n return \"band\";\n case \"bar\":\n return \"bar\";\n case \"heatmap\":\n return \"heatmap\";\n default:\n return \"line\";\n }\n }\n\n /**\n * Create or update a buffer\n */\n createBuffer(id: string, data: Float32Array): void {\n this.bufferDataMap.set(id, data);\n }\n \n /**\n * Update a buffer partially\n */\n updateBuffer(id: string, data: Float32Array, offsetInBytes: number): boolean {\n const existing = this.bufferDataMap.get(id);\n if (!existing) return false;\n \n const offsetFloats = offsetInBytes / 4;\n existing.set(data, offsetFloats);\n return true;\n }\n \n /**\n * Get a buffer's data\n */\n getBuffer(id: string): Float32Array | undefined {\n return this.bufferDataMap.get(id);\n }\n \n /**\n * Delete a buffer\n */\n deleteBuffer(id: string): void {\n this.bufferDataMap.delete(id);\n if (this.backend) {\n this.backend.deleteBuffer(id);\n }\n }\n \n /**\n * Create or update a step buffer\n */\n createStepBuffer(id: string, data: Float32Array): void {\n this.stepBufferDataMap.set(id, data);\n }\n \n /**\n * Create colormap texture\n */\n createColormapTexture(id: string, data: Uint8Array): void {\n this.colormapDataMap.set(id, data);\n if (this.backend) {\n this.backend.createOrUpdateTexture1D(id, data, {\n width: data.length / 4,\n });\n }\n }\n \n /**\n * Render a frame\n */\n render(series: GpuSeriesRenderData[], options: GpuRenderOptions): void {\n if (!this.isInitialized || !this.backend) return;\n \n // Build draw list\n const drawList = this.buildDrawList(series);\n \n // Create frame uniforms\n const frame: FrameUniforms = {\n viewport: {\n width: this.canvas.clientWidth,\n height: this.canvas.clientHeight,\n dpr: this.dpr,\n },\n clearColor: (options.backgroundColor ?? [0.1, 0.1, 0.18, 1]) as RGBA,\n bounds: options.bounds,\n plotArea: options.plotArea,\n };\n \n // Render using the backend\n if (\"renderWithBounds\" in this.backend) {\n (this.backend as any).renderWithBounds(drawList, frame, options.bounds);\n } else {\n this.backend.render(drawList, frame);\n }\n }\n \n /**\n * Build draw list from series data\n */\n private buildDrawList(series: GpuSeriesRenderData[]): DrawList {\n const items: DrawCall[] = [];\n \n for (const s of series) {\n const bufferData = this.bufferDataMap.get(s.id);\n if (!bufferData) continue;\n \n // Upload buffer to GPU\n this.backend!.createOrUpdateBuffer(s.id, bufferData, { usage: \"vertex\" });\n \n const pointCount = s.type === \"heatmap\" \n ? bufferData.length / 3 \n : bufferData.length / 2;\n \n const baseColor = parseColorToRGBA(s.style.color);\n const opacity = s.style.opacity ?? 1;\n const color: [number, number, number, number] = [\n baseColor[0], \n baseColor[1], \n baseColor[2], \n baseColor[3] * opacity\n ];\n \n const drawCall: DrawCall = {\n id: s.id,\n kind: s.type,\n bufferId: s.id,\n count: pointCount,\n visible: s.visible,\n yBounds: s.yBounds,\n };\n \n // Set style based on type\n if (s.type === \"scatter\" || s.type === \"line+scatter\" || s.type === \"step+scatter\") {\n drawCall.style = {\n color: color as RGBA,\n opacity,\n pointSize: s.style.pointSize ?? 4,\n symbol: (s.style.symbol ?? \"circle\") as PointStyle[\"symbol\"],\n };\n } else if (s.type === \"heatmap\") {\n drawCall.textureId = `colormap:${s.id}`;\n drawCall.style = {\n zBounds: s.zBounds,\n colormap: s.colormap,\n };\n \n // Upload colormap if available\n const colormapData = this.colormapDataMap.get(s.id);\n if (colormapData) {\n this.backend!.createOrUpdateTexture1D(drawCall.textureId, colormapData, {\n width: colormapData.length / 4,\n });\n }\n } else {\n drawCall.style = {\n color: color as RGBA,\n opacity,\n lineWidth: s.style.lineWidth ?? 1,\n };\n }\n \n // Handle step buffer\n if ((s.type === \"step\" || s.type === \"step+scatter\") && this.stepBufferDataMap.has(s.id)) {\n const stepData = this.stepBufferDataMap.get(s.id)!;\n const stepBufferId = `${s.id}:step`;\n this.backend!.createOrUpdateBuffer(stepBufferId, stepData, { usage: \"vertex\" });\n drawCall.stepBufferId = stepBufferId;\n drawCall.stepCount = stepData.length / 2;\n }\n \n items.push(drawCall);\n }\n \n return { items };\n }\n \n /**\n * Handle canvas resize\n */\n resize(): void {\n if (!this.backend) return;\n \n const rect = this.canvas.getBoundingClientRect();\n this.backend.setViewport({\n width: rect.width,\n height: rect.height,\n dpr: this.dpr,\n });\n }\n \n /**\n * Get renderer limits\n */\n getLimits(): Record<string, unknown> {\n return {\n backend: this.backendType,\n available: this.isInitialized,\n };\n }\n \n /**\n * Destroy the renderer\n */\n destroy(): void {\n this.adapter?.destroy();\n this.backend?.destroy();\n \n this.bufferDataMap.clear();\n this.stepBufferDataMap.clear();\n this.colormapDataMap.clear();\n \n this.adapter = null;\n this.backend = null;\n this.isInitialized = false;\n this.backendType = null;\n }\n}\n\n/**\n * Create a GPU renderer (async)\n */\nexport async function createGpuRenderer(\n canvas: HTMLCanvasElement,\n options?: GpuRendererOptions\n): Promise<GpuRenderer | null> {\n const renderer = new GpuRenderer(canvas, options);\n const success = await renderer.init();\n return success ? renderer : null;\n}\n"],"names":["TRIANGLE_SHADER_WGSL","createTrianglePipeline","device","format","module","vertexStride","LINE_SHADER_WGSL","LINE_VERTEX_STRIDE","UNIFORM_BUFFER_SIZE","createLinePipeline","GPUShaderStageAny","GPUBufferUsageAny","bindGroupLayout","uniformBuffer","bindGroup","pipelineLayout","updateLineUniforms","uniforms","data","POINT_QUAD_SHADER_WGSL","POINT_VERTEX_STRIDE","QUAD_VERTICES","createPointPipeline","quadBuffer","updatePointUniforms","SYMBOL_MAP","createBandPipeline","updateBandUniforms","HEATMAP_SHADER_WGSL","HEATMAP_VERTEX_STRIDE","createHeatmapPipeline","sampler","createHeatmapBindGroup","layout","colormapTexture","updateHeatmapUniforms","calculateUniforms","bounds","dataWidth","dataHeight","scaleX","scaleY","translateX","translateY","getColorFromStyle","style","color","opacity","WebGPUBackend","canvas","opts","__publicField","gpu","ctx","viewport","w","h","id","desc","usage","usageFlags","byteLength","buf","width","GPUTextureUsageAny","tex","drawList","frame","encoder","view","pass","defaultBounds","item","itemBounds","stepBuf","bandColor","count","_a","pointSize","symbol","textureId","zBounds","LINE_VERT_GLSL","LINE_FRAG_GLSL","POINT_VERT_GLSL","POINT_FRAG_GLSL","HEATMAP_VERT_GLSL","HEATMAP_FRAG_GLSL","compileShader","gl","type","source","shader","info","linkProgram","vertShader","fragShader","program","createProgram","vertSource","fragSource","attributeNames","uniformNames","attributes","name","createAllPrograms","line","point","heatmap","destroyPrograms","bundle","WebGLBackend","buffer","target","texture","stepBuffer","prog","parseColorToRGBA","colorStr","hex","r","g","b","a","rgbaMatch","convertStyle","baseColor","SeriesAdapter","backend","seriesId","series","bufferId","stepBufferId","seriesArray","items","pointCount","drawCall","GpuRenderer","options","preference","e","dpr","_b","_c","_d","_e","_f","s","kind","colormapData","stepId","stepData","lineStyle","fillStyle","positive","negative","subtotal","connector","yBounds","base","c","offsetInBytes","existing","offsetFloats","bufferData","rect","createGpuRenderer","renderer"],"mappings":";;;AAAO,MAAMA,IAAuB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACO7B,SAASC,EACdC,GACAC,GACwB;AACxB,QAAMC,IAASF,EAAO,mBAAmB,EAAE,MAAMF,GAAsB,GAEjEK,IAAe,IAAI;AA4BzB,SAAO,EAAE,UA1BQH,EAAO,qBAAqB;AAAA,IAC3C,QAAQ;AAAA,IACR,QAAQ;AAAA,MACN,QAAAE;AAAA,MACA,YAAY;AAAA,MACZ,SAAS;AAAA,QACP;AAAA,UACE,aAAaC;AAAA,UACb,YAAY;AAAA,YACV,EAAE,gBAAgB,GAAG,QAAQ,GAAG,QAAQ,YAAA;AAAA,YACxC,EAAE,gBAAgB,GAAG,QAAQ,IAAI,GAAG,QAAQ,YAAA;AAAA,UAAY;AAAA,QAC1D;AAAA,MACF;AAAA,IACF;AAAA,IAEF,UAAU;AAAA,MACR,QAAAD;AAAA,MACA,YAAY;AAAA,MACZ,SAAS,CAAC,EAAE,QAAAD,EAAA,CAAQ;AAAA,IAAA;AAAA,IAEtB,WAAW;AAAA,MACT,UAAU;AAAA,MACV,UAAU;AAAA,IAAA;AAAA,EACZ,CACD,GAEkB,cAAAE,EAAA;AACrB;ACnCO,MAAMC,IAAmB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GAiCnBC,IAAqB,IAAI,GChBhCC,IAAsB;AAErB,SAASC,EACdP,GACAC,GACoB;AACpB,QAAMC,IAASF,EAAO,mBAAmB,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