@vroomchart/core-wasm 0.1.0 → 0.1.2

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.
Binary file
package/dist/index.d.ts CHANGED
@@ -9,7 +9,13 @@ declare enum ColorKey {
9
9
  Crosshair = 6,
10
10
  TooltipBg = 7,
11
11
  TooltipText = 8,
12
- CrosshairTarget = 9
12
+ CrosshairTarget = 9,
13
+ BorderBull = 10,
14
+ BorderBear = 11,
15
+ WickBull = 12,
16
+ WickBear = 13,
17
+ AccentBull = 14,
18
+ AccentBear = 15
13
19
  }
14
20
  /** OHLCV readout for the candle under the crosshair. */
15
21
  type CrosshairCandle = {
@@ -20,6 +26,16 @@ type CrosshairCandle = {
20
26
  close: number;
21
27
  volume: number;
22
28
  };
29
+ /**
30
+ * What the crosshair currently snaps to. `timeMs` is the snapped slot's
31
+ * period-start time — set even in the empty space ahead of the most recent
32
+ * candle. `candle` holds the OHLCV when a real candle sits at that slot, and is
33
+ * null when the crosshair is parked on a future candle-aligned slot.
34
+ */
35
+ type CrosshairInfo = {
36
+ timeMs: number;
37
+ candle: CrosshairCandle | null;
38
+ };
23
39
  /** Axis region sizes in CSS px, for hit-testing gestures on the JS side. */
24
40
  type AxisMetrics = {
25
41
  yAxisWidth: number;
@@ -62,6 +78,18 @@ interface VroomChartHandle {
62
78
  scalePriceAxis(dy: number): void;
63
79
  /** Drag-on-x-axis time scaling; dx>0 widens the time window. */
64
80
  scaleTimeAxis(dx: number): void;
81
+ /**
82
+ * Drag the separator between the price pane and the below-chart indicator
83
+ * band. dy>0 (drag down) grows the price pane and shrinks the indicator band,
84
+ * preserving candle pixel scale (the price range adjusts instead).
85
+ */
86
+ resizeIndicatorPane(dy: number): void;
87
+ /**
88
+ * Scale the y-axis of the below-chart indicator pane containing `y` (px).
89
+ * dy>0 (drag down) zooms out (widens the value range); dy<0 zooms in. RSI
90
+ * scales about 50, MACD about its zero line. No-op when `y` is not over a pane.
91
+ */
92
+ scaleIndicatorAxis(y: number, dy: number): void;
65
93
  /** Current axis dimensions for hit-testing in JS gestures. */
66
94
  getAxisMetrics(): AxisMetrics;
67
95
  /** Show the crosshair at (x, y) CSS px (y already lifted above the pointer). */
@@ -70,6 +98,12 @@ interface VroomChartHandle {
70
98
  clearCrosshair(): void;
71
99
  /** OHLCV of the candle the crosshair snaps to, or null when inactive. */
72
100
  getCrosshairCandle(): CrosshairCandle | null;
101
+ /**
102
+ * The slot the crosshair snaps to (real candle or future candle-aligned
103
+ * slot), or null when inactive. Unlike getCrosshairCandle this reports a
104
+ * timeMs even in the empty space ahead of the most recent candle.
105
+ */
106
+ getCrosshairInfo(): CrosshairInfo | null;
73
107
  setRSI(enabled: boolean, period: number, upperBand: number, lowerBand: number, maEnabled: boolean, maPeriod: number): void;
74
108
  setMACD(enabled: boolean, fast: number, slow: number, signal: number): void;
75
109
  setOverlays(overlays: OverlaySpec[]): void;
@@ -121,10 +155,22 @@ type VroomColor = string | number;
121
155
  type VroomTheme = {
122
156
  /** Chart + axis-strip background. */
123
157
  background?: VroomColor;
124
- /** Up candles (also bull wicks, bull volume bars, rising price indicator). */
158
+ /** Up candle body fill. Wick and border default to this unless overridden. */
125
159
  bull?: VroomColor;
126
- /** Down candles (also bear wicks, bear volume bars, falling price indicator). */
160
+ /** Down candle body fill. Wick and border default to this unless overridden. */
127
161
  bear?: VroomColor;
162
+ /** Generic up color for the price indicator, volume bars, and MACD histogram. Defaults to teal-green; independent of `bull`. */
163
+ accentBull?: VroomColor;
164
+ /** Generic down color for the price indicator, volume bars, and MACD histogram. Defaults to red; independent of `bear`. */
165
+ accentBear?: VroomColor;
166
+ /** Up candle body 1px border. Defaults to the bull fill color. */
167
+ borderBull?: VroomColor;
168
+ /** Down candle body 1px border. Defaults to the bear fill color. */
169
+ borderBear?: VroomColor;
170
+ /** Up candle wick color. Defaults to the bull fill color. */
171
+ wickBull?: VroomColor;
172
+ /** Down candle wick color. Defaults to the bear fill color. */
173
+ wickBear?: VroomColor;
128
174
  /** Gridlines. */
129
175
  grid?: VroomColor;
130
176
  /** Axis label text (price + time). */
@@ -138,7 +184,7 @@ type VroomTheme = {
138
184
  declare const BYTES_PER_CANDLE = 48;
139
185
  /** Serialize candles into the packed little-endian buffer the core expects. */
140
186
  declare function packCandles(candles: Candle[]): ArrayBuffer;
141
- /** Decode the packed buffer back to candles (used by the Canvas2D stub core). */
187
+ /** Decode the packed buffer back to candles (inverse of packCandles). */
142
188
  declare function unpackCandles(buf: ArrayBuffer): Candle[];
143
189
 
144
190
  declare const COLOR_KEYS: Record<keyof VroomTheme, ColorKey>;
@@ -160,24 +206,19 @@ type LoadVroomOptions = {
160
206
  /**
161
207
  * Override where the Skia-WASM core is loaded from. By default the core uses
162
208
  * the WASM build bundled in this package (turnkey, no asset hosting needed);
163
- * pass `wasm` to load it from your own URLs instead. On load failure the
164
- * Canvas2D stub is used unless `fallbackToStub: false`.
209
+ * pass `wasm` to load it from your own URLs instead.
165
210
  */
166
211
  wasm?: WasmConfig;
167
- /** When wasm loading fails, fall back to the stub (default true). */
168
- fallbackToStub?: boolean;
169
- /** Force the Canvas2D stub instead of the WASM core (tests / SSR). */
170
- forceStub?: boolean;
171
212
  };
172
213
  /**
173
214
  * Load the chart core. Cached: repeated calls share one module instance.
174
215
  *
175
- * Defaults to the real Skia-WASM core bundled in this package. Pass
176
- * `forceStub` for the Canvas2D stub, or `wasm` to load the core from custom
177
- * URLs. WASM load failures fall back to the stub unless `fallbackToStub: false`.
216
+ * Resolves to the Skia-WASM core bundled in this package, or the core at the
217
+ * URLs in `opts.wasm`. The returned promise rejects if the WASM module fails to
218
+ * load (and the cache is cleared so a later call can retry).
178
219
  */
179
220
  declare function loadVroom(opts?: LoadVroomOptions): Promise<VroomModule>;
180
221
  /** Test/HMR helper: drop the cached module so the next loadVroom() re-creates it. */
181
222
  declare function resetVroomForTesting(): void;
182
223
 
183
- export { type AxisMetrics, BYTES_PER_CANDLE, COLOR_KEYS, ColorKey, type CrosshairCandle, type LoadVroomOptions, type OverlaySpec, type VroomChartHandle, type VroomModule, type WasmConfig, applyTheme, argbToCss, loadVroom, packCandles, parseColor, resetVroomForTesting, unpackCandles };
224
+ export { type AxisMetrics, BYTES_PER_CANDLE, COLOR_KEYS, ColorKey, type CrosshairCandle, type CrosshairInfo, type LoadVroomOptions, type OverlaySpec, type VroomChartHandle, type VroomModule, type WasmConfig, applyTheme, argbToCss, loadVroom, packCandles, parseColor, resetVroomForTesting, unpackCandles };