@chartgpu/chartgpu 0.2.5
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/LICENSE +21 -0
- package/README.md +208 -0
- package/dist/ChartGPU.d.ts +146 -0
- package/dist/ChartGPU.d.ts.map +1 -0
- package/dist/components/createAnnotationConfigDialog.d.ts +24 -0
- package/dist/components/createAnnotationConfigDialog.d.ts.map +1 -0
- package/dist/components/createDataZoomSlider.d.ts +14 -0
- package/dist/components/createDataZoomSlider.d.ts.map +1 -0
- package/dist/components/createLegend.d.ts +9 -0
- package/dist/components/createLegend.d.ts.map +1 -0
- package/dist/components/createTextOverlay.d.ts +17 -0
- package/dist/components/createTextOverlay.d.ts.map +1 -0
- package/dist/components/createTooltip.d.ts +12 -0
- package/dist/components/createTooltip.d.ts.map +1 -0
- package/dist/components/formatTooltip.d.ts +19 -0
- package/dist/components/formatTooltip.d.ts.map +1 -0
- package/dist/config/OptionResolver.d.ts +137 -0
- package/dist/config/OptionResolver.d.ts.map +1 -0
- package/dist/config/defaults.d.ts +56 -0
- package/dist/config/defaults.d.ts.map +1 -0
- package/dist/config/types.d.ts +553 -0
- package/dist/config/types.d.ts.map +1 -0
- package/dist/core/GPUContext.d.ts +242 -0
- package/dist/core/GPUContext.d.ts.map +1 -0
- package/dist/core/RenderScheduler.d.ts +174 -0
- package/dist/core/RenderScheduler.d.ts.map +1 -0
- package/dist/core/createAnimationController.d.ts +15 -0
- package/dist/core/createAnimationController.d.ts.map +1 -0
- package/dist/core/createRenderCoordinator.d.ts +78 -0
- package/dist/core/createRenderCoordinator.d.ts.map +1 -0
- package/dist/core/renderCoordinator/animation/animationHelpers.d.ts +183 -0
- package/dist/core/renderCoordinator/animation/animationHelpers.d.ts.map +1 -0
- package/dist/core/renderCoordinator/annotations/processAnnotations.d.ts +88 -0
- package/dist/core/renderCoordinator/annotations/processAnnotations.d.ts.map +1 -0
- package/dist/core/renderCoordinator/axis/axisLabelHelpers.d.ts +91 -0
- package/dist/core/renderCoordinator/axis/axisLabelHelpers.d.ts.map +1 -0
- package/dist/core/renderCoordinator/axis/computeAxisTicks.d.ts +53 -0
- package/dist/core/renderCoordinator/axis/computeAxisTicks.d.ts.map +1 -0
- package/dist/core/renderCoordinator/data/computeVisibleSlice.d.ts +66 -0
- package/dist/core/renderCoordinator/data/computeVisibleSlice.d.ts.map +1 -0
- package/dist/core/renderCoordinator/gpu/textureManager.d.ts +69 -0
- package/dist/core/renderCoordinator/gpu/textureManager.d.ts.map +1 -0
- package/dist/core/renderCoordinator/interaction/interactionHelpers.d.ts +160 -0
- package/dist/core/renderCoordinator/interaction/interactionHelpers.d.ts.map +1 -0
- package/dist/core/renderCoordinator/render/renderAnnotationLabels.d.ts +36 -0
- package/dist/core/renderCoordinator/render/renderAnnotationLabels.d.ts.map +1 -0
- package/dist/core/renderCoordinator/render/renderAxisLabels.d.ts +40 -0
- package/dist/core/renderCoordinator/render/renderAxisLabels.d.ts.map +1 -0
- package/dist/core/renderCoordinator/render/renderOverlays.d.ts +70 -0
- package/dist/core/renderCoordinator/render/renderOverlays.d.ts.map +1 -0
- package/dist/core/renderCoordinator/render/renderSeries.d.ts +146 -0
- package/dist/core/renderCoordinator/render/renderSeries.d.ts.map +1 -0
- package/dist/core/renderCoordinator/renderers/rendererPool.d.ts +112 -0
- package/dist/core/renderCoordinator/renderers/rendererPool.d.ts.map +1 -0
- package/dist/core/renderCoordinator/types.d.ts +19 -0
- package/dist/core/renderCoordinator/types.d.ts.map +1 -0
- package/dist/core/renderCoordinator/ui/tooltipLegendHelpers.d.ts +104 -0
- package/dist/core/renderCoordinator/ui/tooltipLegendHelpers.d.ts.map +1 -0
- package/dist/core/renderCoordinator/utils/axisUtils.d.ts +122 -0
- package/dist/core/renderCoordinator/utils/axisUtils.d.ts.map +1 -0
- package/dist/core/renderCoordinator/utils/boundsComputation.d.ts +69 -0
- package/dist/core/renderCoordinator/utils/boundsComputation.d.ts.map +1 -0
- package/dist/core/renderCoordinator/utils/canvasUtils.d.ts +52 -0
- package/dist/core/renderCoordinator/utils/canvasUtils.d.ts.map +1 -0
- package/dist/core/renderCoordinator/utils/dataPointUtils.d.ts +71 -0
- package/dist/core/renderCoordinator/utils/dataPointUtils.d.ts.map +1 -0
- package/dist/core/renderCoordinator/utils/index.d.ts +12 -0
- package/dist/core/renderCoordinator/utils/index.d.ts.map +1 -0
- package/dist/core/renderCoordinator/utils/timeAxisUtils.d.ts +149 -0
- package/dist/core/renderCoordinator/utils/timeAxisUtils.d.ts.map +1 -0
- package/dist/core/renderCoordinator/zoom/zoomHelpers.d.ts +129 -0
- package/dist/core/renderCoordinator/zoom/zoomHelpers.d.ts.map +1 -0
- package/dist/data/cartesianData.d.ts +72 -0
- package/dist/data/cartesianData.d.ts.map +1 -0
- package/dist/data/createDataStore.d.ts +27 -0
- package/dist/data/createDataStore.d.ts.map +1 -0
- package/dist/data/createStreamBuffer.d.ts +20 -0
- package/dist/data/createStreamBuffer.d.ts.map +1 -0
- package/dist/data/lttbSample.d.ts +5 -0
- package/dist/data/lttbSample.d.ts.map +1 -0
- package/dist/data/ohlcSample.d.ts +21 -0
- package/dist/data/ohlcSample.d.ts.map +1 -0
- package/dist/data/packDataPoints.d.ts +65 -0
- package/dist/data/packDataPoints.d.ts.map +1 -0
- package/dist/data/sampleSeries.d.ts +20 -0
- package/dist/data/sampleSeries.d.ts.map +1 -0
- package/dist/esm/ChartGPUWorkerController-B50J-8sx.js +772 -0
- package/dist/esm/ChartGPUWorkerController-B50J-8sx.js.map +1 -0
- package/dist/esm/OptionResolver-R_gJDRSD.js +7150 -0
- package/dist/esm/OptionResolver-R_gJDRSD.js.map +1 -0
- package/dist/esm/assets/worker-entry-Wg897auv.js +779 -0
- package/dist/esm/assets/worker-entry-Wg897auv.js.map +1 -0
- package/dist/esm/createChartInWorker-C4fEeJL8.js +1224 -0
- package/dist/esm/createChartInWorker-C4fEeJL8.js.map +1 -0
- package/dist/esm/index.js +795 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/index.cjs +1270 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10504 -0
- package/dist/index.js.map +1 -0
- package/dist/interaction/createAnnotationAuthoring.d.ts +115 -0
- package/dist/interaction/createAnnotationAuthoring.d.ts.map +1 -0
- package/dist/interaction/createAnnotationDragHandler.d.ts +28 -0
- package/dist/interaction/createAnnotationDragHandler.d.ts.map +1 -0
- package/dist/interaction/createAnnotationHitTester.d.ts +32 -0
- package/dist/interaction/createAnnotationHitTester.d.ts.map +1 -0
- package/dist/interaction/createChartSync.d.ts +27 -0
- package/dist/interaction/createChartSync.d.ts.map +1 -0
- package/dist/interaction/createEventManager.d.ts +24 -0
- package/dist/interaction/createEventManager.d.ts.map +1 -0
- package/dist/interaction/createHoverState.d.ts +20 -0
- package/dist/interaction/createHoverState.d.ts.map +1 -0
- package/dist/interaction/createInsideZoom.d.ts +14 -0
- package/dist/interaction/createInsideZoom.d.ts.map +1 -0
- package/dist/interaction/createZoomState.d.ts +63 -0
- package/dist/interaction/createZoomState.d.ts.map +1 -0
- package/dist/interaction/findCandlestick.d.ts +41 -0
- package/dist/interaction/findCandlestick.d.ts.map +1 -0
- package/dist/interaction/findNearestPoint.d.ts +61 -0
- package/dist/interaction/findNearestPoint.d.ts.map +1 -0
- package/dist/interaction/findPieSlice.d.ts +36 -0
- package/dist/interaction/findPieSlice.d.ts.map +1 -0
- package/dist/interaction/findPointsAtX.d.ts +37 -0
- package/dist/interaction/findPointsAtX.d.ts.map +1 -0
- package/dist/renderers/createAnnotationMarkerRenderer.d.ts +58 -0
- package/dist/renderers/createAnnotationMarkerRenderer.d.ts.map +1 -0
- package/dist/renderers/createAreaRenderer.d.ts +19 -0
- package/dist/renderers/createAreaRenderer.d.ts.map +1 -0
- package/dist/renderers/createAxisRenderer.d.ts +19 -0
- package/dist/renderers/createAxisRenderer.d.ts.map +1 -0
- package/dist/renderers/createBarRenderer.d.ts +20 -0
- package/dist/renderers/createBarRenderer.d.ts.map +1 -0
- package/dist/renderers/createCandlestickRenderer.d.ts +19 -0
- package/dist/renderers/createCandlestickRenderer.d.ts.map +1 -0
- package/dist/renderers/createCrosshairRenderer.d.ts +43 -0
- package/dist/renderers/createCrosshairRenderer.d.ts.map +1 -0
- package/dist/renderers/createGridRenderer.d.ts +45 -0
- package/dist/renderers/createGridRenderer.d.ts.map +1 -0
- package/dist/renderers/createHighlightRenderer.d.ts +41 -0
- package/dist/renderers/createHighlightRenderer.d.ts.map +1 -0
- package/dist/renderers/createLineRenderer.d.ts +18 -0
- package/dist/renderers/createLineRenderer.d.ts.map +1 -0
- package/dist/renderers/createPieRenderer.d.ts +18 -0
- package/dist/renderers/createPieRenderer.d.ts.map +1 -0
- package/dist/renderers/createReferenceLineRenderer.d.ts +81 -0
- package/dist/renderers/createReferenceLineRenderer.d.ts.map +1 -0
- package/dist/renderers/createScatterDensityRenderer.d.ts +14 -0
- package/dist/renderers/createScatterDensityRenderer.d.ts.map +1 -0
- package/dist/renderers/createScatterRenderer.d.ts +20 -0
- package/dist/renderers/createScatterRenderer.d.ts.map +1 -0
- package/dist/renderers/rendererUtils.d.ts +100 -0
- package/dist/renderers/rendererUtils.d.ts.map +1 -0
- package/dist/themes/darkTheme.d.ts +11 -0
- package/dist/themes/darkTheme.d.ts.map +1 -0
- package/dist/themes/index.d.ts +8 -0
- package/dist/themes/index.d.ts.map +1 -0
- package/dist/themes/lightTheme.d.ts +11 -0
- package/dist/themes/lightTheme.d.ts.map +1 -0
- package/dist/themes/types.d.ts +14 -0
- package/dist/themes/types.d.ts.map +1 -0
- package/dist/types/ChartGPU.d.ts +99 -0
- package/dist/types/ChartGPU.d.ts.map +1 -0
- package/dist/types/components/createDataZoomSlider.d.ts +14 -0
- package/dist/types/components/createDataZoomSlider.d.ts.map +1 -0
- package/dist/types/components/createLegend.d.ts +9 -0
- package/dist/types/components/createLegend.d.ts.map +1 -0
- package/dist/types/components/createTextOverlay.d.ts +17 -0
- package/dist/types/components/createTextOverlay.d.ts.map +1 -0
- package/dist/types/components/createTooltip.d.ts +12 -0
- package/dist/types/components/createTooltip.d.ts.map +1 -0
- package/dist/types/components/formatTooltip.d.ts +19 -0
- package/dist/types/components/formatTooltip.d.ts.map +1 -0
- package/dist/types/config/OptionResolver.d.ts +134 -0
- package/dist/types/config/OptionResolver.d.ts.map +1 -0
- package/dist/types/config/defaults.d.ts +55 -0
- package/dist/types/config/defaults.d.ts.map +1 -0
- package/dist/types/config/types.d.ts +485 -0
- package/dist/types/config/types.d.ts.map +1 -0
- package/dist/types/core/GPUContext.d.ts +242 -0
- package/dist/types/core/GPUContext.d.ts.map +1 -0
- package/dist/types/core/RenderScheduler.d.ts +174 -0
- package/dist/types/core/RenderScheduler.d.ts.map +1 -0
- package/dist/types/core/createAnimationController.d.ts +15 -0
- package/dist/types/core/createAnimationController.d.ts.map +1 -0
- package/dist/types/core/createRenderCoordinator.d.ts +129 -0
- package/dist/types/core/createRenderCoordinator.d.ts.map +1 -0
- package/dist/types/data/createDataStore.d.ts +33 -0
- package/dist/types/data/createDataStore.d.ts.map +1 -0
- package/dist/types/data/createStreamBuffer.d.ts +20 -0
- package/dist/types/data/createStreamBuffer.d.ts.map +1 -0
- package/dist/types/data/lttbSample.d.ts +5 -0
- package/dist/types/data/lttbSample.d.ts.map +1 -0
- package/dist/types/data/ohlcSample.d.ts +21 -0
- package/dist/types/data/ohlcSample.d.ts.map +1 -0
- package/dist/types/data/packDataPoints.d.ts +79 -0
- package/dist/types/data/packDataPoints.d.ts.map +1 -0
- package/dist/types/data/sampleSeries.d.ts +3 -0
- package/dist/types/data/sampleSeries.d.ts.map +1 -0
- package/dist/types/index.d.ts +35 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/interaction/createChartSync.d.ts +12 -0
- package/dist/types/interaction/createChartSync.d.ts.map +1 -0
- package/dist/types/interaction/createEventManager.d.ts +24 -0
- package/dist/types/interaction/createEventManager.d.ts.map +1 -0
- package/dist/types/interaction/createHoverState.d.ts +20 -0
- package/dist/types/interaction/createHoverState.d.ts.map +1 -0
- package/dist/types/interaction/createInsideZoom.d.ts +14 -0
- package/dist/types/interaction/createInsideZoom.d.ts.map +1 -0
- package/dist/types/interaction/createZoomState.d.ts +63 -0
- package/dist/types/interaction/createZoomState.d.ts.map +1 -0
- package/dist/types/interaction/findCandlestick.d.ts +41 -0
- package/dist/types/interaction/findCandlestick.d.ts.map +1 -0
- package/dist/types/interaction/findNearestPoint.d.ts +61 -0
- package/dist/types/interaction/findNearestPoint.d.ts.map +1 -0
- package/dist/types/interaction/findPieSlice.d.ts +36 -0
- package/dist/types/interaction/findPieSlice.d.ts.map +1 -0
- package/dist/types/interaction/findPointsAtX.d.ts +37 -0
- package/dist/types/interaction/findPointsAtX.d.ts.map +1 -0
- package/dist/types/renderers/createAreaRenderer.d.ts +18 -0
- package/dist/types/renderers/createAreaRenderer.d.ts.map +1 -0
- package/dist/types/renderers/createAxisRenderer.d.ts +19 -0
- package/dist/types/renderers/createAxisRenderer.d.ts.map +1 -0
- package/dist/types/renderers/createBarRenderer.d.ts +20 -0
- package/dist/types/renderers/createBarRenderer.d.ts.map +1 -0
- package/dist/types/renderers/createCandlestickRenderer.d.ts +19 -0
- package/dist/types/renderers/createCandlestickRenderer.d.ts.map +1 -0
- package/dist/types/renderers/createCrosshairRenderer.d.ts +43 -0
- package/dist/types/renderers/createCrosshairRenderer.d.ts.map +1 -0
- package/dist/types/renderers/createGridRenderer.d.ts +45 -0
- package/dist/types/renderers/createGridRenderer.d.ts.map +1 -0
- package/dist/types/renderers/createHighlightRenderer.d.ts +41 -0
- package/dist/types/renderers/createHighlightRenderer.d.ts.map +1 -0
- package/dist/types/renderers/createLineRenderer.d.ts +18 -0
- package/dist/types/renderers/createLineRenderer.d.ts.map +1 -0
- package/dist/types/renderers/createPieRenderer.d.ts +18 -0
- package/dist/types/renderers/createPieRenderer.d.ts.map +1 -0
- package/dist/types/renderers/createScatterDensityRenderer.d.ts +14 -0
- package/dist/types/renderers/createScatterDensityRenderer.d.ts.map +1 -0
- package/dist/types/renderers/createScatterRenderer.d.ts +19 -0
- package/dist/types/renderers/createScatterRenderer.d.ts.map +1 -0
- package/dist/types/renderers/rendererUtils.d.ts +100 -0
- package/dist/types/renderers/rendererUtils.d.ts.map +1 -0
- package/dist/types/themes/darkTheme.d.ts +11 -0
- package/dist/types/themes/darkTheme.d.ts.map +1 -0
- package/dist/types/themes/index.d.ts +8 -0
- package/dist/types/themes/index.d.ts.map +1 -0
- package/dist/types/themes/lightTheme.d.ts +11 -0
- package/dist/types/themes/lightTheme.d.ts.map +1 -0
- package/dist/types/themes/types.d.ts +14 -0
- package/dist/types/themes/types.d.ts.map +1 -0
- package/dist/types/utils/axisLabelStyling.d.ts +27 -0
- package/dist/types/utils/axisLabelStyling.d.ts.map +1 -0
- package/dist/types/utils/checkWebGPU.d.ts +39 -0
- package/dist/types/utils/checkWebGPU.d.ts.map +1 -0
- package/dist/types/utils/colors.d.ts +14 -0
- package/dist/types/utils/colors.d.ts.map +1 -0
- package/dist/types/utils/easing.d.ts +9 -0
- package/dist/types/utils/easing.d.ts.map +1 -0
- package/dist/types/utils/scales.d.ts +79 -0
- package/dist/types/utils/scales.d.ts.map +1 -0
- package/dist/utils/axisLabelStyling.d.ts +20 -0
- package/dist/utils/axisLabelStyling.d.ts.map +1 -0
- package/dist/utils/checkWebGPU.d.ts +39 -0
- package/dist/utils/checkWebGPU.d.ts.map +1 -0
- package/dist/utils/colors.d.ts +14 -0
- package/dist/utils/colors.d.ts.map +1 -0
- package/dist/utils/easing.d.ts +9 -0
- package/dist/utils/easing.d.ts.map +1 -0
- package/dist/utils/scales.d.ts +79 -0
- package/dist/utils/scales.d.ts.map +1 -0
- package/package.json +64 -0
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GPUContext - WebGPU device and adapter management
|
|
3
|
+
*
|
|
4
|
+
* Handles WebGPU initialization, adapter selection, and device creation
|
|
5
|
+
* following WebGPU best practices for resource management and error handling.
|
|
6
|
+
*
|
|
7
|
+
* This module provides both functional and class-based APIs for maximum flexibility.
|
|
8
|
+
*/
|
|
9
|
+
/** Canvas types supported by GPUContext. */
|
|
10
|
+
export type SupportedCanvas = HTMLCanvasElement | OffscreenCanvas;
|
|
11
|
+
/** Options for GPU context initialization. */
|
|
12
|
+
export interface GPUContextOptions {
|
|
13
|
+
/** DPR for high-DPI displays. Auto-detects on main thread, defaults to 1.0 in workers. */
|
|
14
|
+
readonly devicePixelRatio?: number;
|
|
15
|
+
/** Canvas alpha mode. Default: 'opaque' (faster, no transparency). */
|
|
16
|
+
readonly alphaMode?: 'opaque' | 'premultiplied';
|
|
17
|
+
/** GPU power preference for adapter selection. */
|
|
18
|
+
readonly powerPreference?: 'low-power' | 'high-performance';
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Represents the state of a GPU context.
|
|
22
|
+
* All properties are readonly to ensure immutability.
|
|
23
|
+
*/
|
|
24
|
+
export interface GPUContextState {
|
|
25
|
+
readonly adapter: GPUAdapter | null;
|
|
26
|
+
readonly device: GPUDevice | null;
|
|
27
|
+
readonly initialized: boolean;
|
|
28
|
+
readonly canvas: SupportedCanvas | null;
|
|
29
|
+
readonly canvasContext: GPUCanvasContext | null;
|
|
30
|
+
readonly preferredFormat: GPUTextureFormat | null;
|
|
31
|
+
readonly devicePixelRatio: number;
|
|
32
|
+
readonly alphaMode: 'opaque' | 'premultiplied';
|
|
33
|
+
readonly powerPreference: 'low-power' | 'high-performance';
|
|
34
|
+
}
|
|
35
|
+
/** Reliable type guard - instanceof works in workers where HTMLCanvasElement is undefined. */
|
|
36
|
+
export declare function isHTMLCanvasElement(canvas: SupportedCanvas): canvas is HTMLCanvasElement;
|
|
37
|
+
/**
|
|
38
|
+
* Creates a new GPUContext state with initial values.
|
|
39
|
+
*
|
|
40
|
+
* @param canvas - Optional canvas element (HTMLCanvasElement or OffscreenCanvas) to configure for WebGPU rendering
|
|
41
|
+
* @param options - Optional configuration for device pixel ratio, alpha mode, and power preference
|
|
42
|
+
* @returns A new GPUContextState instance
|
|
43
|
+
*/
|
|
44
|
+
export declare function createGPUContext(canvas?: SupportedCanvas, options?: GPUContextOptions): GPUContextState;
|
|
45
|
+
/**
|
|
46
|
+
* Initializes the WebGPU context by requesting an adapter and device.
|
|
47
|
+
* Returns a new state object with initialized values.
|
|
48
|
+
*
|
|
49
|
+
* @param context - The GPU context state to initialize
|
|
50
|
+
* @returns A new GPUContextState with initialized adapter and device
|
|
51
|
+
* @throws {Error} If WebGPU is not available in the browser
|
|
52
|
+
* @throws {Error} If adapter request fails
|
|
53
|
+
* @throws {Error} If device request fails
|
|
54
|
+
* @throws {Error} If already initialized
|
|
55
|
+
*/
|
|
56
|
+
export declare function initializeGPUContext(context: GPUContextState): Promise<GPUContextState>;
|
|
57
|
+
/**
|
|
58
|
+
* Gets the current texture from the canvas context.
|
|
59
|
+
*
|
|
60
|
+
* @param context - The GPU context state
|
|
61
|
+
* @returns The current canvas texture
|
|
62
|
+
* @throws {Error} If canvas is not configured or context is not initialized
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```typescript
|
|
66
|
+
* const texture = getCanvasTexture(context);
|
|
67
|
+
* // Use texture in render pass
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
export declare function getCanvasTexture(context: GPUContextState): GPUTexture;
|
|
71
|
+
/**
|
|
72
|
+
* Clears the canvas to a solid color.
|
|
73
|
+
* Creates a command encoder, begins a render pass with the specified clear color,
|
|
74
|
+
* ends the pass, and submits it to the queue.
|
|
75
|
+
*
|
|
76
|
+
* @param context - The GPU context state
|
|
77
|
+
* @param r - Red component (0.0 to 1.0)
|
|
78
|
+
* @param g - Green component (0.0 to 1.0)
|
|
79
|
+
* @param b - Blue component (0.0 to 1.0)
|
|
80
|
+
* @param a - Alpha component (0.0 to 1.0)
|
|
81
|
+
* @throws {Error} If canvas is not configured or context is not initialized
|
|
82
|
+
* @throws {Error} If device is not available
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* ```typescript
|
|
86
|
+
* // Clear to dark purple (#1a1a2e)
|
|
87
|
+
* clearScreen(context, 0x1a / 255, 0x1a / 255, 0x2e / 255, 1.0);
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
export declare function clearScreen(context: GPUContextState, r: number, g: number, b: number, a: number): void;
|
|
91
|
+
/**
|
|
92
|
+
* Destroys the WebGPU device and cleans up resources.
|
|
93
|
+
* Returns a new state object with reset values.
|
|
94
|
+
* After calling this, the context must be reinitialized before use.
|
|
95
|
+
*
|
|
96
|
+
* @param context - The GPU context state to destroy
|
|
97
|
+
* @returns A new GPUContextState with reset values
|
|
98
|
+
*/
|
|
99
|
+
export declare function destroyGPUContext(context: GPUContextState): GPUContextState;
|
|
100
|
+
/**
|
|
101
|
+
* Convenience function that creates and initializes a GPU context in one step.
|
|
102
|
+
*
|
|
103
|
+
* @param canvas - Optional canvas element (HTMLCanvasElement or OffscreenCanvas) to configure for WebGPU rendering
|
|
104
|
+
* @param options - Optional configuration for device pixel ratio, alpha mode, and power preference
|
|
105
|
+
* @returns A fully initialized GPUContextState
|
|
106
|
+
* @throws {Error} If initialization fails
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* ```typescript
|
|
110
|
+
* const context = await createGPUContextAsync();
|
|
111
|
+
* const device = context.device;
|
|
112
|
+
* ```
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* ```typescript
|
|
116
|
+
* const canvas = document.querySelector('canvas');
|
|
117
|
+
* const context = await createGPUContextAsync(canvas);
|
|
118
|
+
* const texture = getCanvasTexture(context);
|
|
119
|
+
* ```
|
|
120
|
+
*/
|
|
121
|
+
export declare function createGPUContextAsync(canvas?: SupportedCanvas, options?: GPUContextOptions): Promise<GPUContextState>;
|
|
122
|
+
/**
|
|
123
|
+
* GPUContext class wrapper for backward compatibility.
|
|
124
|
+
*
|
|
125
|
+
* This class provides a class-based API that internally uses the functional implementation.
|
|
126
|
+
* Use the functional API directly for better type safety and immutability.
|
|
127
|
+
*/
|
|
128
|
+
export declare class GPUContext {
|
|
129
|
+
private _state;
|
|
130
|
+
/**
|
|
131
|
+
* Gets the WebGPU adapter, or null if not initialized.
|
|
132
|
+
*/
|
|
133
|
+
get adapter(): GPUAdapter | null;
|
|
134
|
+
/**
|
|
135
|
+
* Gets the WebGPU device, or null if not initialized.
|
|
136
|
+
*/
|
|
137
|
+
get device(): GPUDevice | null;
|
|
138
|
+
/**
|
|
139
|
+
* Checks if the context has been initialized.
|
|
140
|
+
*/
|
|
141
|
+
get initialized(): boolean;
|
|
142
|
+
/**
|
|
143
|
+
* Gets the canvas element, or null if not provided.
|
|
144
|
+
*/
|
|
145
|
+
get canvas(): SupportedCanvas | null;
|
|
146
|
+
/**
|
|
147
|
+
* Gets the WebGPU canvas context, or null if canvas is not configured.
|
|
148
|
+
*/
|
|
149
|
+
get canvasContext(): GPUCanvasContext | null;
|
|
150
|
+
/**
|
|
151
|
+
* Gets the preferred canvas format, or null if canvas is not configured.
|
|
152
|
+
*/
|
|
153
|
+
get preferredFormat(): GPUTextureFormat | null;
|
|
154
|
+
/**
|
|
155
|
+
* Gets the device pixel ratio used for canvas sizing.
|
|
156
|
+
*/
|
|
157
|
+
get devicePixelRatio(): number;
|
|
158
|
+
/**
|
|
159
|
+
* Gets the canvas alpha mode.
|
|
160
|
+
*/
|
|
161
|
+
get alphaMode(): 'opaque' | 'premultiplied';
|
|
162
|
+
/**
|
|
163
|
+
* Gets the GPU power preference.
|
|
164
|
+
*/
|
|
165
|
+
get powerPreference(): 'low-power' | 'high-performance';
|
|
166
|
+
/**
|
|
167
|
+
* Creates a new GPUContext instance.
|
|
168
|
+
*
|
|
169
|
+
* @param canvas - Optional canvas element (HTMLCanvasElement or OffscreenCanvas) to configure for WebGPU rendering
|
|
170
|
+
* @param options - Optional configuration for device pixel ratio, alpha mode, and power preference
|
|
171
|
+
*/
|
|
172
|
+
constructor(canvas?: SupportedCanvas, options?: GPUContextOptions);
|
|
173
|
+
/**
|
|
174
|
+
* Initializes the WebGPU context by requesting an adapter and device.
|
|
175
|
+
*
|
|
176
|
+
* @throws {Error} If WebGPU is not available in the browser
|
|
177
|
+
* @throws {Error} If adapter request fails
|
|
178
|
+
* @throws {Error} If device request fails
|
|
179
|
+
* @throws {Error} If already initialized
|
|
180
|
+
*/
|
|
181
|
+
initialize(): Promise<void>;
|
|
182
|
+
/**
|
|
183
|
+
* Static factory method to create and initialize a GPUContext instance.
|
|
184
|
+
*
|
|
185
|
+
* @param canvas - Optional canvas element (HTMLCanvasElement or OffscreenCanvas) to configure for WebGPU rendering
|
|
186
|
+
* @param options - Optional configuration for device pixel ratio, alpha mode, and power preference
|
|
187
|
+
* @returns A fully initialized GPUContext instance
|
|
188
|
+
* @throws {Error} If initialization fails
|
|
189
|
+
*
|
|
190
|
+
* @example
|
|
191
|
+
* ```typescript
|
|
192
|
+
* const context = await GPUContext.create();
|
|
193
|
+
* const device = context.device;
|
|
194
|
+
* ```
|
|
195
|
+
*
|
|
196
|
+
* @example
|
|
197
|
+
* ```typescript
|
|
198
|
+
* const canvas = document.querySelector('canvas');
|
|
199
|
+
* const context = await GPUContext.create(canvas);
|
|
200
|
+
* const texture = context.getCanvasTexture();
|
|
201
|
+
* ```
|
|
202
|
+
*/
|
|
203
|
+
static create(canvas?: SupportedCanvas, options?: GPUContextOptions): Promise<GPUContext>;
|
|
204
|
+
/**
|
|
205
|
+
* Gets the current texture from the canvas context.
|
|
206
|
+
*
|
|
207
|
+
* @returns The current canvas texture
|
|
208
|
+
* @throws {Error} If canvas is not configured or context is not initialized
|
|
209
|
+
*
|
|
210
|
+
* @example
|
|
211
|
+
* ```typescript
|
|
212
|
+
* const texture = context.getCanvasTexture();
|
|
213
|
+
* // Use texture in render pass
|
|
214
|
+
* ```
|
|
215
|
+
*/
|
|
216
|
+
getCanvasTexture(): GPUTexture;
|
|
217
|
+
/**
|
|
218
|
+
* Clears the canvas to a solid color.
|
|
219
|
+
* Creates a command encoder, begins a render pass with the specified clear color,
|
|
220
|
+
* ends the pass, and submits it to the queue.
|
|
221
|
+
*
|
|
222
|
+
* @param r - Red component (0.0 to 1.0)
|
|
223
|
+
* @param g - Green component (0.0 to 1.0)
|
|
224
|
+
* @param b - Blue component (0.0 to 1.0)
|
|
225
|
+
* @param a - Alpha component (0.0 to 1.0)
|
|
226
|
+
* @throws {Error} If canvas is not configured or context is not initialized
|
|
227
|
+
* @throws {Error} If device is not available
|
|
228
|
+
*
|
|
229
|
+
* @example
|
|
230
|
+
* ```typescript
|
|
231
|
+
* // Clear to dark purple (#1a1a2e)
|
|
232
|
+
* context.clearScreen(0x1a / 255, 0x1a / 255, 0x2e / 255, 1.0);
|
|
233
|
+
* ```
|
|
234
|
+
*/
|
|
235
|
+
clearScreen(r: number, g: number, b: number, a: number): void;
|
|
236
|
+
/**
|
|
237
|
+
* Destroys the WebGPU device and cleans up resources.
|
|
238
|
+
* After calling destroy(), the context must be reinitialized before use.
|
|
239
|
+
*/
|
|
240
|
+
destroy(): void;
|
|
241
|
+
}
|
|
242
|
+
//# sourceMappingURL=GPUContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GPUContext.d.ts","sourceRoot":"","sources":["../../../src/core/GPUContext.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,4CAA4C;AAC5C,MAAM,MAAM,eAAe,GAAG,iBAAiB,GAAG,eAAe,CAAC;AAElE,8CAA8C;AAC9C,MAAM,WAAW,iBAAiB;IAChC,0FAA0F;IAC1F,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IACnC,sEAAsE;IACtE,QAAQ,CAAC,SAAS,CAAC,EAAE,QAAQ,GAAG,eAAe,CAAC;IAChD,kDAAkD;IAClD,QAAQ,CAAC,eAAe,CAAC,EAAE,WAAW,GAAG,kBAAkB,CAAC;CAC7D;AAED;;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IACH,OAAO,IAAI,IAAI;CAGhB"}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RenderScheduler - 60fps render loop management
|
|
3
|
+
*
|
|
4
|
+
* Manages a requestAnimationFrame-based render loop that runs at 60fps,
|
|
5
|
+
* providing delta time tracking and frame scheduling control.
|
|
6
|
+
*
|
|
7
|
+
* This module provides both functional and class-based APIs for maximum flexibility.
|
|
8
|
+
* The functional API is preferred for better type safety and immutability.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Callback function type for render frames.
|
|
12
|
+
* Receives delta time in milliseconds since the last frame.
|
|
13
|
+
*/
|
|
14
|
+
export type RenderCallback = (deltaTime: number) => void;
|
|
15
|
+
import type { ExactFPS, Milliseconds, FrameTimeStats, FrameDropStats } from '../config/types';
|
|
16
|
+
/**
|
|
17
|
+
* Represents the state of a render scheduler.
|
|
18
|
+
* All properties are readonly to ensure immutability.
|
|
19
|
+
*/
|
|
20
|
+
export interface RenderSchedulerState {
|
|
21
|
+
readonly id: symbol;
|
|
22
|
+
readonly running: boolean;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Creates a new RenderScheduler state with initial values.
|
|
26
|
+
*
|
|
27
|
+
* @returns A new RenderSchedulerState instance
|
|
28
|
+
*/
|
|
29
|
+
export declare function createRenderScheduler(): RenderSchedulerState;
|
|
30
|
+
/**
|
|
31
|
+
* Starts the render loop.
|
|
32
|
+
*
|
|
33
|
+
* Begins a requestAnimationFrame loop that calls the provided callback
|
|
34
|
+
* every frame with the delta time in milliseconds since the last frame.
|
|
35
|
+
* Returns a new state object with running set to true.
|
|
36
|
+
*
|
|
37
|
+
* @param state - The scheduler state to start
|
|
38
|
+
* @param callback - Function to call each frame with delta time
|
|
39
|
+
* @returns A new RenderSchedulerState with running set to true
|
|
40
|
+
* @throws {Error} If callback is not provided
|
|
41
|
+
* @throws {Error} If scheduler is already running
|
|
42
|
+
* @throws {Error} If state is invalid
|
|
43
|
+
*/
|
|
44
|
+
export declare function startRenderScheduler(state: RenderSchedulerState, callback: RenderCallback): RenderSchedulerState;
|
|
45
|
+
/**
|
|
46
|
+
* Stops the render loop.
|
|
47
|
+
*
|
|
48
|
+
* Cancels any pending requestAnimationFrame calls and stops the loop.
|
|
49
|
+
* Returns a new state object with running set to false.
|
|
50
|
+
* The scheduler can be restarted by calling startRenderScheduler() again.
|
|
51
|
+
*
|
|
52
|
+
* @param state - The scheduler state to stop
|
|
53
|
+
* @returns A new RenderSchedulerState with running set to false
|
|
54
|
+
* @throws {Error} If state is invalid
|
|
55
|
+
*/
|
|
56
|
+
export declare function stopRenderScheduler(state: RenderSchedulerState): RenderSchedulerState;
|
|
57
|
+
/**
|
|
58
|
+
* Marks the current frame as dirty and schedules a render if idle.
|
|
59
|
+
*
|
|
60
|
+
* This function implements render-on-demand: it schedules a frame when the
|
|
61
|
+
* scheduler is idle. Multiple calls coalesce into a single frame.
|
|
62
|
+
*
|
|
63
|
+
* @param state - The scheduler state
|
|
64
|
+
* @throws {Error} If state is invalid
|
|
65
|
+
*/
|
|
66
|
+
export declare function requestRender(state: RenderSchedulerState): void;
|
|
67
|
+
/**
|
|
68
|
+
* Calculates exact FPS from frame timestamp deltas.
|
|
69
|
+
*
|
|
70
|
+
* Uses the circular buffer of performance.now() timestamps to calculate
|
|
71
|
+
* frame-perfect FPS. Algorithm:
|
|
72
|
+
* 1. Sum all frame time deltas in the buffer
|
|
73
|
+
* 2. Divide by (count - 1) to get average frame time
|
|
74
|
+
* 3. Convert to FPS: 1000ms / avg_frame_time
|
|
75
|
+
*
|
|
76
|
+
* Returns 0 if insufficient data (< 2 frames).
|
|
77
|
+
*
|
|
78
|
+
* @param state - The scheduler state
|
|
79
|
+
* @returns Exact FPS measurement
|
|
80
|
+
*/
|
|
81
|
+
export declare function getCurrentFPS(state: RenderSchedulerState): ExactFPS;
|
|
82
|
+
/**
|
|
83
|
+
* Calculates frame time statistics from the circular buffer.
|
|
84
|
+
*
|
|
85
|
+
* Computes min, max, avg, and percentiles (p50, p95, p99) for frame times.
|
|
86
|
+
* Returns zero stats if insufficient data.
|
|
87
|
+
*
|
|
88
|
+
* @param state - The scheduler state
|
|
89
|
+
* @returns Frame time statistics
|
|
90
|
+
*/
|
|
91
|
+
export declare function getFrameStats(state: RenderSchedulerState): FrameTimeStats;
|
|
92
|
+
/**
|
|
93
|
+
* Gets frame drop statistics for the scheduler.
|
|
94
|
+
*
|
|
95
|
+
* @param state - The scheduler state
|
|
96
|
+
* @returns Frame drop statistics
|
|
97
|
+
*/
|
|
98
|
+
export declare function getFrameDropStats(state: RenderSchedulerState): FrameDropStats;
|
|
99
|
+
/**
|
|
100
|
+
* Gets total frames rendered and elapsed time.
|
|
101
|
+
*
|
|
102
|
+
* @param state - The scheduler state
|
|
103
|
+
* @returns Object with totalFrames and elapsedTime
|
|
104
|
+
*/
|
|
105
|
+
export declare function getTotalFrames(state: RenderSchedulerState): {
|
|
106
|
+
totalFrames: number;
|
|
107
|
+
elapsedTime: Milliseconds;
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* Destroys the render scheduler and cleans up resources.
|
|
111
|
+
* Stops the loop if running and removes internal state from the map.
|
|
112
|
+
* Returns a new state object with reset values.
|
|
113
|
+
* After calling this, the scheduler must be recreated before use.
|
|
114
|
+
*
|
|
115
|
+
* **Important:** Always call this function when done with a scheduler to prevent memory leaks.
|
|
116
|
+
* The internal state map will retain entries until explicitly destroyed.
|
|
117
|
+
*
|
|
118
|
+
* @param state - The scheduler state to destroy
|
|
119
|
+
* @returns A new RenderSchedulerState with reset values
|
|
120
|
+
*/
|
|
121
|
+
export declare function destroyRenderScheduler(state: RenderSchedulerState): RenderSchedulerState;
|
|
122
|
+
/**
|
|
123
|
+
* Convenience function that creates a scheduler and starts it in one step.
|
|
124
|
+
*
|
|
125
|
+
* @param callback - Function to call each frame with delta time
|
|
126
|
+
* @returns A RenderSchedulerState with the loop running
|
|
127
|
+
* @throws {Error} If callback is not provided
|
|
128
|
+
*
|
|
129
|
+
* @example
|
|
130
|
+
* ```typescript
|
|
131
|
+
* const scheduler = createRenderSchedulerAsync((deltaTime) => {
|
|
132
|
+
* renderFrame(deltaTime);
|
|
133
|
+
* });
|
|
134
|
+
* ```
|
|
135
|
+
*/
|
|
136
|
+
export declare function createRenderSchedulerAsync(callback: RenderCallback): RenderSchedulerState;
|
|
137
|
+
/**
|
|
138
|
+
* RenderScheduler class wrapper for backward compatibility.
|
|
139
|
+
*
|
|
140
|
+
* This class provides a class-based API that internally uses the functional implementation.
|
|
141
|
+
* Use the functional API directly for better type safety and immutability.
|
|
142
|
+
*/
|
|
143
|
+
export declare class RenderScheduler {
|
|
144
|
+
private _state;
|
|
145
|
+
/**
|
|
146
|
+
* Checks if the scheduler is currently running.
|
|
147
|
+
*/
|
|
148
|
+
get running(): boolean;
|
|
149
|
+
/**
|
|
150
|
+
* Creates a new RenderScheduler instance.
|
|
151
|
+
*/
|
|
152
|
+
constructor();
|
|
153
|
+
/**
|
|
154
|
+
* Starts the render loop.
|
|
155
|
+
*
|
|
156
|
+
* @param callback - Function to call each frame with delta time
|
|
157
|
+
* @throws {Error} If callback is not provided or scheduler already running
|
|
158
|
+
*/
|
|
159
|
+
start(callback: RenderCallback): void;
|
|
160
|
+
/**
|
|
161
|
+
* Stops the render loop.
|
|
162
|
+
*/
|
|
163
|
+
stop(): void;
|
|
164
|
+
/**
|
|
165
|
+
* Marks the current frame as dirty, indicating it needs to be rendered.
|
|
166
|
+
*/
|
|
167
|
+
requestRender(): void;
|
|
168
|
+
/**
|
|
169
|
+
* Destroys the render scheduler and cleans up resources.
|
|
170
|
+
* After calling destroy(), the scheduler must be recreated before use.
|
|
171
|
+
*/
|
|
172
|
+
destroy(): void;
|
|
173
|
+
}
|
|
174
|
+
//# sourceMappingURL=RenderScheduler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RenderScheduler.d.ts","sourceRoot":"","sources":["../../../src/core/RenderSc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;;;GAaG;AACH,wBAAgB,0BAA0B,CAAC,QAAQ,EAAE,cAAc,GAAG,oBAAoB,CAGzF;AAED;;;;;GAKG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,MAAM,CAAuB;IAErC;;OAEG;IACH,IAAI,OAAO,IAAI,OAAO,CAErB;IAED;;OAEG;;IAKH;;;;;OAKG;IACH,KAAK,CAAC,QAAQ,EAAE,cAAc,GAAG,IAAI;IAIrC;;OAEG;IACH,IAAI,IAAI,IAAI;IAIZ;;OAEG;IACH,aAAa,IAAI,IAAI;IAIrB;;;OAGG;IACH,OAAO,IAAI,IAAI;CAGhB"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { EasingFunction } from '../utils/easing';
|
|
2
|
+
export type AnimationId = symbol;
|
|
3
|
+
export interface AnimationController {
|
|
4
|
+
animate(from: number, to: number, duration: number, easing: EasingFunction, onUpdate: (value: number) => void, onComplete?: () => void): AnimationId;
|
|
5
|
+
animate(from: ReadonlyArray<number>, to: ReadonlyArray<number>, duration: number, easing: EasingFunction, onUpdate: (value: ReadonlyArray<number>) => void, onComplete?: () => void): AnimationId;
|
|
6
|
+
cancel(animationId: AnimationId): void;
|
|
7
|
+
cancelAll(): void;
|
|
8
|
+
/**
|
|
9
|
+
* Progresses all active animations to `timestamp` (ms).
|
|
10
|
+
* Intended to be called once per frame by the caller (e.g. a render loop).
|
|
11
|
+
*/
|
|
12
|
+
update(timestamp: number): void;
|
|
13
|
+
}
|
|
14
|
+
export declare function createAnimationController(): AnimationController;
|
|
15
|
+
//# sourceMappingURL=createAnimationController.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createAnimationController.d.ts","sourceRoot":"","sources":["../../../src/core/createAnimationController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEtD,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC;AAEjC,MAAM,WAAW,mBAAmB;IAClC,OAAO,CACL,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,EACV,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,cAAc,EACtB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,EACjC,UAAU,CAAC,EAAE,MAAM,IAAI,GACtB,WAAW,CAAC;IACf,OAAO,CACL,IAAI,EAAE,aAAa,CAAC,MAAM,CAAC,EAC3B,EAAE,EAAE,aAAa,CAAC,MAAM,CAAC,EACzB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,cAAc,EACtB,QAAQ,EAAE,CAAC,KAAK,EAAE,aAAa,CAAC,MAAM,CAAC,KAAK,IAAI,EAChD,UAAU,CAAC,EAAE,MAAM,IAAI,GACtB,WAAW,CAAC;IAEf,MAAM,CAAC,WAAW,EAAE,WAAW,GAAG,IAAI,CAAC;IACvC,SAAS,IAAI,IAAI,CAAC;IAElB;;;OAGG;IACH,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CACjC;AAiCD,wBAAgB,yBAAyB,IAAI,mBAAmB,CAoH/D"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import type { ResolvedChartGPUOptions } from '../config/OptionResolver';
|
|
2
|
+
import type { AxisLabel, DataPoint, LegendItem, PointerEventData, OHLCDataPoint, TooltipData } from '../config/types';
|
|
3
|
+
import type { SupportedCanvas } from './GPUContext';
|
|
4
|
+
import type { ChartGPUEventPayload } from '../interaction/createEventManager';
|
|
5
|
+
import type { NearestPointMatch } from '../interaction/findNearestPoint';
|
|
6
|
+
import type { CandlestickMatch } from '../interaction/findCandlestick';
|
|
7
|
+
import type { PieSliceMatch } from '../interaction/findPieSlice';
|
|
8
|
+
export interface GPUContextLike {
|
|
9
|
+
readonly device: GPUDevice | null;
|
|
10
|
+
readonly canvas: SupportedCanvas | null;
|
|
11
|
+
readonly canvasContext: GPUCanvasContext | null;
|
|
12
|
+
readonly preferredFormat: GPUTextureFormat | null;
|
|
13
|
+
readonly initialized: boolean;
|
|
14
|
+
readonly devicePixelRatio?: number;
|
|
15
|
+
}
|
|
16
|
+
export interface RenderCoordinator {
|
|
17
|
+
setOptions(resolvedOptions: ResolvedChartGPUOptions): void;
|
|
18
|
+
/**
|
|
19
|
+
* Appends new points to a cartesian series’ runtime data without requiring a full `setOptions(...)`
|
|
20
|
+
* resolver pass.
|
|
21
|
+
*
|
|
22
|
+
* Appends are coalesced and flushed once per render frame.
|
|
23
|
+
*/
|
|
24
|
+
appendData(seriesIndex: number, newPoints: ReadonlyArray<DataPoint> | ReadonlyArray<OHLCDataPoint>): void;
|
|
25
|
+
/**
|
|
26
|
+
* Gets the current “interaction x” in domain units (or `null` when inactive).
|
|
27
|
+
*
|
|
28
|
+
* This is derived from pointer movement inside the plot grid and can also be driven
|
|
29
|
+
* externally via `setInteractionX(...)` (e.g. chart sync).
|
|
30
|
+
*/
|
|
31
|
+
getInteractionX(): number | null;
|
|
32
|
+
/**
|
|
33
|
+
* Drives the chart’s crosshair + tooltip from a domain-space x value.
|
|
34
|
+
*
|
|
35
|
+
* Passing `null` clears the interaction (hides crosshair/tooltip).
|
|
36
|
+
*/
|
|
37
|
+
setInteractionX(x: number | null, source?: unknown): void;
|
|
38
|
+
/**
|
|
39
|
+
* Subscribes to interaction x changes (domain units).
|
|
40
|
+
*
|
|
41
|
+
* Returns an unsubscribe function.
|
|
42
|
+
*/
|
|
43
|
+
onInteractionXChange(callback: (x: number | null, source?: unknown) => void): () => void;
|
|
44
|
+
/**
|
|
45
|
+
* Returns the current percent-space zoom window (or `null` when zoom is disabled).
|
|
46
|
+
*/
|
|
47
|
+
getZoomRange(): Readonly<{
|
|
48
|
+
start: number;
|
|
49
|
+
end: number;
|
|
50
|
+
}> | null;
|
|
51
|
+
/**
|
|
52
|
+
* Sets the percent-space zoom window.
|
|
53
|
+
*
|
|
54
|
+
* No-op when zoom is disabled.
|
|
55
|
+
*/
|
|
56
|
+
setZoomRange(start: number, end: number): void;
|
|
57
|
+
/**
|
|
58
|
+
* Subscribes to zoom window changes (percent space).
|
|
59
|
+
*
|
|
60
|
+
* Returns an unsubscribe function.
|
|
61
|
+
*/
|
|
62
|
+
onZoomRangeChange(cb: (range: Readonly<{
|
|
63
|
+
start: number;
|
|
64
|
+
end: number;
|
|
65
|
+
}>) => void): () => void;
|
|
66
|
+
/**
|
|
67
|
+
* Accepts a pointer event with pre-computed grid coordinates for worker thread event forwarding.
|
|
68
|
+
* Only available when domOverlays is false.
|
|
69
|
+
*/
|
|
70
|
+
handlePointerEvent(event: PointerEventData): void;
|
|
71
|
+
render(): void;
|
|
72
|
+
dispose(): void;
|
|
73
|
+
}
|
|
74
|
+
export type RenderCoordinatorCallbacks = Readonly<{
|
|
75
|
+
/**
|
|
76
|
+
* Optional hook for render-on-demand systems (like `ChartGPU`) to re-render when
|
|
77
|
+
* interaction state changes (e.g. crosshair on pointer move).
|
|
78
|
+
*/
|
|
79
|
+
readonly onRequestRender?: () => void;
|
|
80
|
+
/**
|
|
81
|
+
* When false, DOM overlays (tooltip, legend, text overlay, event manager) are disabled.
|
|
82
|
+
* Instead, callbacks are used to emit data for external rendering.
|
|
83
|
+
* Default: true (DOM overlays enabled).
|
|
84
|
+
*/
|
|
85
|
+
readonly domOverlays?: boolean;
|
|
86
|
+
/**
|
|
87
|
+
* Called when tooltip data changes (only when domOverlays is false).
|
|
88
|
+
* Receives tooltip data including content, params array, and position, or null when hidden.
|
|
89
|
+
*/
|
|
90
|
+
readonly onTooltipUpdate?: (data: TooltipData | null) => void;
|
|
91
|
+
/**
|
|
92
|
+
* Called when legend items change (only when domOverlays is false).
|
|
93
|
+
*/
|
|
94
|
+
readonly onLegendUpdate?: (items: ReadonlyArray<LegendItem>) => void;
|
|
95
|
+
/**
|
|
96
|
+
* Called when axis labels change (only when domOverlays is false).
|
|
97
|
+
*/
|
|
98
|
+
readonly onAxisLabelsUpdate?: (xLabels: ReadonlyArray<AxisLabel>, yLabels: ReadonlyArray<AxisLabel>) => void;
|
|
99
|
+
/**
|
|
100
|
+
* Called when hover state changes (only when domOverlays is false).
|
|
101
|
+
*/
|
|
102
|
+
readonly onHoverChange?: (payload: ChartGPUEventPayload | null) => void;
|
|
103
|
+
/**
|
|
104
|
+
* Called when crosshair moves (only when domOverlays is false).
|
|
105
|
+
* Receives canvas-local CSS pixel x coordinate, or null when crosshair is hidden.
|
|
106
|
+
*/
|
|
107
|
+
readonly onCrosshairMove?: (x: number | null) => void;
|
|
108
|
+
/**
|
|
109
|
+
* Called when user taps/clicks (only when domOverlays is false).
|
|
110
|
+
* Includes hit test result with seriesIndex, dataIndex, and value.
|
|
111
|
+
* Main thread is responsible for tap detection; worker thread performs hit testing.
|
|
112
|
+
*/
|
|
113
|
+
readonly onClickData?: (payload: {
|
|
114
|
+
readonly x: number;
|
|
115
|
+
readonly y: number;
|
|
116
|
+
readonly gridX: number;
|
|
117
|
+
readonly gridY: number;
|
|
118
|
+
readonly isInGrid: boolean;
|
|
119
|
+
readonly nearest: NearestPointMatch | null;
|
|
120
|
+
readonly pieSlice: PieSliceMatch | null;
|
|
121
|
+
readonly candlestick: CandlestickMatch | null;
|
|
122
|
+
}) => void;
|
|
123
|
+
/**
|
|
124
|
+
* Called when GPU device is lost.
|
|
125
|
+
*/
|
|
126
|
+
readonly onDeviceLost?: (reason: string) => void;
|
|
127
|
+
}>;
|
|
128
|
+
export declare function createRenderCoordinator(gpuContext: GPUContextLike, options: ResolvedChartGPUOptions, callbacks?: RenderCoordinatorCallbacks): RenderCoordinator;
|
|
129
|
+
//# sourceMappingURL=createRenderCoordinator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createRenderCoordinator.d.ts","sourceRoot":"","sources":["../../../src/core/createRenderCoordinator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAIV,uBAAuB,EAExB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAmB,SAAS,EAAE,SAAS,EAAkB,UAAU,EAAE,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;IACxE;;;OAGG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IACtD;;;;OAIG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC,OAAO,EAAE;QAC/B,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;QACnB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;QACnB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;QACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;QACvB,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;QAC3B,QAAQ,CAAC,OAAO,EAAE,iBAAiB,GAAG,IAAI,CAAC;QAC3C,QAAQ,CAAC,QAAQ,EAAE,aAAa,GAAG,IAAI,CAAC;QACxC,QAAQ,CAAC,WAAW,EAAE,gBAAgB,GAAG,IAAI,CAAC;KAC/C,KAAK,IAAI,CAAC;IACX;;OAEG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;CAClD,CAAC,CAAC;AAynCH,wBAAgB,uBAAuB,CACrC,UAAU,EAAE,cAAc,EAC1B,OAAO,EAAE,uBAAuB,EAChC,SAAS,CAAC,EAAE,0BAA0B,GACrC,iBAAiB,CA21FnB"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { DataPoint } from '../config/types';
|
|
2
|
+
export interface DataStore {
|
|
3
|
+
setSeries(index: number, data: ReadonlyArray<DataPoint>): void;
|
|
4
|
+
/**
|
|
5
|
+
* Appends new points to an existing series without re-uploading the entire buffer when possible.
|
|
6
|
+
*
|
|
7
|
+
* - Reuses the same geometric growth policy as `setSeries`.
|
|
8
|
+
* - When no reallocation is needed, writes only the appended byte range via `queue.writeBuffer(...)`.
|
|
9
|
+
* - Maintains `pointCount` and a CPU-side combined data array so `getSeriesData(...)` remains correct.
|
|
10
|
+
*
|
|
11
|
+
* Throws if the series has not been set yet.
|
|
12
|
+
*/
|
|
13
|
+
appendSeries(index: number, newPoints: ReadonlyArray<DataPoint>): void;
|
|
14
|
+
removeSeries(index: number): void;
|
|
15
|
+
getSeriesBuffer(index: number): GPUBuffer;
|
|
16
|
+
/**
|
|
17
|
+
* Returns the number of points last set for the given series index.
|
|
18
|
+
*
|
|
19
|
+
* Throws if the series has not been set yet.
|
|
20
|
+
*/
|
|
21
|
+
getSeriesPointCount(index: number): number;
|
|
22
|
+
/**
|
|
23
|
+
* Returns the last CPU-side data set for the given series index.
|
|
24
|
+
*
|
|
25
|
+
* This is intended for internal metadata/hit-testing paths that need the same
|
|
26
|
+
* input array that was packed into the GPU buffer (without re-threading it
|
|
27
|
+
* through other state). Throws if the series has not been set yet.
|
|
28
|
+
*/
|
|
29
|
+
getSeriesData(index: number): ReadonlyArray<DataPoint>;
|
|
30
|
+
dispose(): void;
|
|
31
|
+
}
|
|
32
|
+
export declare function createDataStore(device: GPUDevice): DataStore;
|
|
33
|
+
//# sourceMappingURL=createDataStore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createDataStore.d.ts","sourceRoot":"","sources":["../../../src/data/createDataStore.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAGjD,MAAM,WAAW,SAAS;IACxB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC;IAC/D;;;;;;;;OAQG;IACH,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,aAAa,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC;IACvE,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1C;;;;OAIG;IACH,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IAC3C;;;;;;OAMG;IACH,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,aAAa,CAAC,SAAS,CAAC,CAAC;IACvD,OAAO,IAAI,IAAI,CAAC;CACjB;AAiDD,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS,GAAG,SAAS,CAmN5D"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface StreamBuffer {
|
|
2
|
+
/**
|
|
3
|
+
* Writes a new vertex payload into the streaming buffer.
|
|
4
|
+
*
|
|
5
|
+
* Notes:
|
|
6
|
+
* - `data` is interpreted as interleaved `vec2<f32>` vertices: `[x0, y0, x1, y1, ...]`.
|
|
7
|
+
* - Uses double buffering (alternates GPU buffers each write) to avoid writing into the same
|
|
8
|
+
* buffer the GPU might still be reading from the prior frame.
|
|
9
|
+
* - Uses a per-buffer CPU mirror (Uint32 bit patterns) to compute partial updates.
|
|
10
|
+
*/
|
|
11
|
+
write(data: Float32Array): void;
|
|
12
|
+
/** Returns the GPUBuffer that contains the most recently written data. */
|
|
13
|
+
getBuffer(): GPUBuffer;
|
|
14
|
+
/** Returns the vertex count for the most recently written data. */
|
|
15
|
+
getVertexCount(): number;
|
|
16
|
+
/** Destroys GPU resources (best-effort). Safe to call multiple times. */
|
|
17
|
+
dispose(): void;
|
|
18
|
+
}
|
|
19
|
+
export declare function createStreamBuffer(device: GPUDevice, maxSize: number): StreamBuffer;
|
|
20
|
+
//# sourceMappingURL=createStreamBuffer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createStreamBuffer.d.ts","sourceRoot":"","sources":["../../../src/data/createStreamBuffer.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IAC3B;;;;;;;;OAQG;IACH,KAAK,CAAC,IAAI,EAAE,YAAY,GAAG,IAAI,CAAC;IAChC,0EAA0E;IAC1E,SAAS,IAAI,SAAS,CAAC;IACvB,mEAAmE;IACnE,cAAc,IAAI,MAAM,CAAC;IACzB,yEAAyE;IACzE,OAAO,IAAI,IAAI,CAAC;CACjB;AAoBD,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,GAAG,YAAY,CAiKnF"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { DataPoint } from '../config/types';
|
|
2
|
+
export declare function lttbSample(data: Float32Array, targetPoints: number): Float32Array;
|
|
3
|
+
export declare function lttbSample(data: DataPoint[], targetPoints: number): DataPoint[];
|
|
4
|
+
export declare function lttbSample(data: ReadonlyArray<DataPoint>, targetPoints: number): ReadonlyArray<DataPoint>;
|
|
5
|
+
//# sourceMappingURL=lttbSample.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lttbSample.d.ts","sourceRoot":"","sources":["../../../src/data/lttbSample.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAkB,MAAM,iBAAiB,CAAC;AA6KjE,wBAAgB,UAAU,CAAC,IAAI,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,GAAG,YAAY,CAAC;AACnF,wBAAgB,UAAU,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE,YAAY,EAAE,MAAM,GAAG,SAAS,EAAE,CAAC;AACjF,wBAAgB,UAAU,CAAC,IAAI,EAAE,aAAa,CAAC,SAAS,CAAC,EAAE,YAAY,EAAE,MAAM,GAAG,aAAa,CAAC,SAAS,CAAC,CAAC"}
|