react-native-vroom-chart 0.6.0 → 0.7.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/cpp/VroomChartHostObject.cpp +150 -32
- package/cpp/_core_include/vroom/vroom_chart.h +180 -22
- package/cpp/_core_src/bollinger.h +1 -1
- package/cpp/_core_src/candles.cpp +138 -41
- package/cpp/_core_src/candles.h +11 -1
- package/cpp/_core_src/chart.cpp +91 -40
- package/cpp/_core_src/chart.h +55 -20
- package/cpp/_core_src/chart_facade.cpp +206 -66
- package/cpp/_core_src/gradient.cpp +46 -0
- package/cpp/_core_src/gradient.h +31 -0
- package/cpp/_core_src/labels.cpp +49 -16
- package/cpp/_core_src/labels.h +33 -4
- package/cpp/_core_src/liquidity.cpp +3 -37
- package/cpp/_core_src/ma_overlay.cpp +174 -12
- package/cpp/_core_src/ma_overlay.h +55 -3
- package/cpp/_core_src/macd.cpp +13 -42
- package/cpp/_core_src/macd.h +11 -8
- package/cpp/_core_src/macd_pane.cpp +57 -27
- package/cpp/_core_src/price_line_layout.h +1 -1
- package/cpp/_core_src/rsi.cpp +4 -18
- package/cpp/_core_src/rsi.h +6 -6
- package/cpp/_core_src/rsi_pane.cpp +34 -19
- package/cpp/_core_src/series_ma.cpp +64 -0
- package/cpp/_core_src/series_ma.h +30 -0
- package/cpp/_core_src/style_inherit.h +35 -0
- package/cpp/_core_src/theme.cpp +2 -1
- package/cpp/_core_src/viewport.cpp +36 -12
- package/cpp/_core_src/viewport.h +50 -0
- package/cpp/_core_src/volume.cpp +33 -8
- package/cpp/_core_src/volume.h +12 -1
- package/cpp/_core_src/volume_anim.cpp +32 -0
- package/cpp/_core_src/volume_anim.h +41 -0
- package/lib/index.d.mts +161 -28
- package/lib/index.d.ts +161 -28
- package/lib/index.js +156 -31
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +156 -31
- package/lib/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/VroomChart.tsx +69 -3
- package/src/easing.ts +40 -0
- package/src/index.ts +3 -0
- package/src/jsi.d.ts +76 -20
- package/src/theme.ts +1 -0
- package/src/types.ts +3 -0
- package/src/useChartCore.ts +103 -27
package/lib/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/VroomChart.tsx","../src/useChartCore.ts","../src/NativeVroomChart.ts","../src/packCandles.ts","../src/theme.ts"],"sourcesContent":["// VroomChart — Phase 3.\n//\n// Owns a SharedValue<SkPicture> driven by:\n// - useChartCore's \"initial\" picture (when data/size/range change), AND\n// - Pan gesture callbacks that call handle.pan(dx, dy) → fresh picture.\n//\n// Reanimated 4 + RN-Skia 2 propagate SharedValue<SkPicture> changes to\n// <Picture> without a React re-render, so gesture-driven redraws are cheap.\n//\n// Gestures run on the JS thread for now (`runOnJS(true)`) — installing the\n// JSI bindings on the worklet runtime is a later perf optimization.\n\nimport React, { useEffect, useRef, useCallback, useState, useMemo } from 'react';\nimport { View, type LayoutChangeEvent } from 'react-native';\nimport { Canvas, Picture, Skia, type SkPicture } from '@shopify/react-native-skia';\nimport {\n Gesture,\n GestureDetector,\n GestureHandlerRootView,\n} from 'react-native-gesture-handler';\nimport { useSharedValue } from 'react-native-reanimated';\n\nimport { useChartCore } from './useChartCore';\nimport type { VroomChartProps } from './types';\nimport './jsi.d';\n\n/**\n * Skia-rendered candlestick chart. Pass OHLCV `candles` and size it via `style`\n * (it fills its parent by default). Pan to scroll, pinch to zoom, drag the\n * price/time axes to rescale, and long-press for the crosshair. Optional\n * indicators (`rsi`, `macd`, `movingAverages`, `vwap`), colors (`theme`), and\n * events (`onCrosshair`, `onViewportChange`) are configured through props.\n *\n * @see {@link VroomChartProps} for the full prop reference.\n */\nexport function VroomChart(props: VroomChartProps) {\n const {\n candles,\n width: widthProp,\n height: heightProp,\n style,\n visibleRange,\n defaultCandleWidth,\n chartType,\n transitionMs,\n theme,\n rsi,\n macd,\n movingAverages,\n vwap,\n bollingerBands,\n crosshairOffset = 40,\n onCrosshair,\n onViewportChange,\n priceLines,\n priceLinesStyle,\n onPriceLineDrag,\n onPriceLineDragEnd,\n onPriceLineClose,\n } = props;\n\n // Fill the parent by default: measure via onLayout. Explicit width/height\n // props (if given) win per-axis. Until the first layout, dims are 0 and we\n // render nothing (one frame).\n const [measured, setMeasured] = useState({ width: 0, height: 0 });\n const width = widthProp ?? measured.width;\n const height = heightProp ?? measured.height;\n\n const onLayout = useCallback((e: LayoutChangeEvent) => {\n const w = Math.round(e.nativeEvent.layout.width);\n const h = Math.round(e.nativeEvent.layout.height);\n setMeasured((prev) =>\n prev.width === w && prev.height === h ? prev : { width: w, height: h },\n );\n }, []);\n\n // The close button is callback-gated, so whether a handler exists is part of\n // what gets rendered.\n const priceLinesProp = useMemo(\n () =>\n priceLines\n ? {\n lines: priceLines,\n style: priceLinesStyle,\n hasCloseHandler: onPriceLineClose != null,\n }\n : undefined,\n [priceLines, priceLinesStyle, onPriceLineClose],\n );\n\n const { handle, picture } = useChartCore(\n candles,\n { width, height },\n visibleRange,\n defaultCandleWidth,\n chartType,\n theme,\n rsi,\n macd,\n movingAverages,\n vwap,\n bollingerBands,\n priceLinesProp,\n );\n\n // RN-Skia's recorder reads this SharedValue on the UI/render runtime, a beat\n // behind JS-thread writes. If it ever reads null it throws (\"Invalid prop\n // value for SkTextBlob received\" — RN-Skia's mislabeled SkPicture error), so\n // we seed it with an empty picture and *never* assign null into it.\n const emptyPicture = useMemo(() => {\n const rec = Skia.PictureRecorder();\n rec.beginRecording(Skia.XYWHRect(0, 0, 1, 1));\n return rec.finishRecordingAsPicture();\n }, []);\n const pictureSV = useSharedValue<SkPicture>(emptyPicture);\n\n // When the crosshair is showing, pan moves it (instead of scrolling) and\n // pinch is disabled. A ref (not state) so gesture callbacks read it\n // synchronously without re-subscribing. Tap dismisses it.\n const crosshairActive = useRef(false);\n\n // timeMs of the candle last reported through onCrosshair, so a drag fires a\n // 'move' event only when it crosses into a *different* candle (one per\n // candle, not per frame). Null while the crosshair is hidden.\n const lastCrosshairTime = useRef<number | null>(null);\n\n // Sync the initial picture from useChartCore into the SV whenever it\n // refreshes (data load, size change, externally-controlled range change).\n // Only ever assign a non-null picture (see emptyPicture note above).\n useEffect(() => {\n if (picture) pictureSV.value = picture;\n }, [picture, pictureSV]);\n\n // Momentum scroll. After Pan ends with non-trivial velocity, we run a RAF\n // loop that calls handle.pan(dx, 0) each frame with an exponentially\n // decaying velocity. A new pan (or unmount) cancels the loop.\n const decayRaf = useRef<number | null>(null);\n const cancelDecay = useCallback(() => {\n if (decayRaf.current != null) {\n cancelAnimationFrame(decayRaf.current);\n decayRaf.current = null;\n }\n }, []);\n useEffect(() => cancelDecay, [cancelDecay]);\n\n // Axis-label fade animation loop. When a gesture changes which labels are\n // active, the C++ side starts ramping their opacities. We keep calling\n // render() on every frame until handle.isAnimating() returns false. The\n // loop is started by gesture callbacks (and the momentum tick) after they\n // update the picture, and self-stops when fades settle.\n const animRaf = useRef<number | null>(null);\n const animTick = useCallback(() => {\n animRaf.current = null;\n if (!handle) return;\n const next = handle.render();\n if (next) pictureSV.value = next;\n if (handle.isAnimating()) {\n animRaf.current = requestAnimationFrame(animTick);\n }\n }, [handle, pictureSV]);\n const maybeStartAnim = useCallback(() => {\n if (animRaf.current != null) return;\n if (!handle?.isAnimating()) return;\n animRaf.current = requestAnimationFrame(animTick);\n }, [handle, animTick]);\n useEffect(() => {\n return () => {\n if (animRaf.current != null) {\n cancelAnimationFrame(animRaf.current);\n animRaf.current = null;\n }\n };\n }, []);\n\n // Candle↔line morph. When `chartType` changes we drive the core per-frame with\n // a (collapse, fade) blend and push a fresh picture into the SV each frame — the\n // JS side owns the eased clock (see plan). A fresh handle snaps to the target;\n // transitionMs=0 snaps. Mirrors the web driver in react/src/useChartCore.ts.\n const morphRaf = useRef<number | null>(null);\n const morphFade = useRef<number | null>(null);\n const morphHandle = useRef<typeof handle>(null);\n useEffect(() => {\n if (!handle) return undefined;\n const target = chartType === 'line' ? 1 : 0;\n\n // Fresh handle (first load / recreate): snap, don't animate.\n if (morphHandle.current !== handle || morphFade.current == null) {\n morphHandle.current = handle;\n morphFade.current = target;\n handle.setChartType(target);\n const p = handle.render();\n if (p) pictureSV.value = p;\n return undefined;\n }\n if (morphFade.current === target) return undefined;\n\n if (morphRaf.current != null) {\n cancelAnimationFrame(morphRaf.current);\n morphRaf.current = null;\n }\n const dur = Math.max(0, transitionMs ?? 300);\n if (dur === 0) {\n morphFade.current = target;\n handle.setChartType(target);\n const p = handle.render();\n if (p) pictureSV.value = p;\n return undefined;\n }\n\n const from = morphFade.current;\n let startTs: number | null = null;\n const step = (now: number) => {\n if (startTs == null) startTs = now;\n const prog = Math.min(1, (now - startTs) / dur);\n const e = prog * prog * (3 - 2 * prog); // smoothstep ease-in-out\n const fade = from + (target - from) * e;\n morphFade.current = fade;\n handle.setMorph(fade, fade);\n const p = handle.render();\n if (p) pictureSV.value = p;\n if (prog < 1) {\n morphRaf.current = requestAnimationFrame(step);\n } else {\n morphRaf.current = null;\n morphFade.current = target;\n handle.setChartType(target); // lock the exact endpoint\n const q = handle.render();\n if (q) pictureSV.value = q;\n }\n };\n morphRaf.current = requestAnimationFrame(step);\n\n return () => {\n if (morphRaf.current != null) {\n cancelAnimationFrame(morphRaf.current);\n morphRaf.current = null;\n }\n };\n }, [handle, chartType, transitionMs, pictureSV]);\n\n // Classifies a touch point into the candle area vs. an axis strip. Axis\n // strips always own their gesture (scale price/time) and take priority over\n // the crosshair: an axis touch never opens, moves, or dismisses it.\n const hitAxis = useCallback(\n (x: number, y: number): 'chart' | 'price-axis' | 'time-axis' | 'indicator' => {\n if (!handle) return 'chart';\n const { yAxisWidth, xAxisHeight, indicatorHeight } =\n handle.getAxisMetrics();\n if (x > width - yAxisWidth) return 'price-axis';\n if (y > height - xAxisHeight) return 'time-axis';\n // The indicator pane sits just above the time-axis strip. A drag here\n // scrolls the candles horizontally (no vertical price change).\n if (indicatorHeight > 0 && y > height - xAxisHeight - indicatorHeight) {\n return 'indicator';\n }\n return 'chart';\n },\n [handle, width, height],\n );\n\n // Hit-tests the price lines at a touch point, resolving the core's index back\n // to the line it belongs to. Null when nothing was hit.\n const hitPriceLine = useCallback(\n (x: number, y: number) => {\n if (!handle || !priceLines?.length) return null;\n const hit = handle.hitTestPriceLine(x, y);\n const line = hit ? priceLines[hit.index] : undefined;\n return hit && line ? { index: hit.index, part: hit.part, line } : null;\n },\n [handle, priceLines],\n );\n\n // A price line being dragged vertically: its core index, its id, and the last\n // previewed price (the payload for the drop).\n const priceDrag = useRef<{ index: number; id: string; price: number } | null>(\n null,\n );\n\n // Pan routes to different C++ mutators depending on where it started: the\n // candle area (chart scroll / crosshair move), the y-axis strip (price\n // scale), the x-axis strip (time scale), the indicator pane (horizontal\n // scroll only), or a draggable price line. We classify on onStart.\n const panMode = useRef<\n 'chart' | 'price-axis' | 'time-axis' | 'indicator' | 'price-line'\n >('chart');\n\n const pan = Gesture.Pan()\n .runOnJS(true)\n .maxPointers(1) // don't fight Pinch's two-finger gesture\n .onStart((e) => {\n cancelDecay();\n // Always classify — an axis drag controls the axis even while the\n // crosshair is up. Only a chart-area drag interacts with the crosshair.\n panMode.current = hitAxis(e.x, e.y);\n // A draggable price line takes the drag over from the chart. Seeding the\n // preview at the committed price puts the label in drag styling before the\n // first move, so the grab registers immediately.\n priceDrag.current = null;\n if (handle && panMode.current === 'chart' && !crosshairActive.current) {\n const pl = hitPriceLine(e.x, e.y);\n if (pl && pl.part === 0) {\n panMode.current = 'price-line';\n priceDrag.current = { index: pl.index, id: pl.line.id, price: pl.line.price };\n handle.setPriceLineDrag(pl.index, pl.line.price);\n const p = handle.render();\n if (p) pictureSV.value = p;\n }\n }\n })\n .onChange((e) => {\n if (!handle) return;\n let next: ReturnType<typeof handle.pan> = null;\n if (panMode.current === 'price-axis') {\n next = handle.scalePriceAxis(e.changeY);\n } else if (panMode.current === 'time-axis') {\n next = handle.scaleTimeAxis(e.changeX);\n } else if (panMode.current === 'indicator') {\n // Drag in an indicator pane scrolls the candles horizontally only —\n // no vertical price slide (the pane's scale is fixed).\n next = handle.pan(e.changeX, 0);\n } else if (panMode.current === 'price-line') {\n // Preview the price under the finger; nothing is committed until the drop.\n const g = priceDrag.current;\n if (!g) return;\n const c = handle.coordAt(e.x, e.y);\n if (!c) return;\n g.price = c.price;\n handle.setPriceLineDrag(g.index, c.price);\n onPriceLineDrag?.(g.id, c.price);\n next = handle.render();\n } else if (crosshairActive.current) {\n // Chart area + crosshair up → the drag moves the crosshair instead of\n // scrolling. Vertical line tracks the finger x; the dot/horizontal line\n // stay lifted `crosshairOffset` px above the fingertip.\n const ch = handle.setCrosshair(e.x, e.y - crosshairOffset);\n if (ch) pictureSV.value = ch;\n // The line follows the finger every frame (above), but only notify the\n // host when the snapped slot actually changes. The slot has a timeMs\n // even in the empty space ahead of the last candle, where candle=null.\n const info = handle.getCrosshairInfo();\n const t = info?.timeMs ?? null;\n if (t !== lastCrosshairTime.current) {\n lastCrosshairTime.current = t;\n // price is web-only for now (see @vroomchart/react); RN reports null.\n onCrosshair?.({ active: true, candle: info?.candle ?? null, timeMs: t, price: null, reason: 'move' });\n }\n return;\n } else {\n // Chart area: 1-finger drag translates both axes. Horizontal\n // component scrolls time, vertical component slides price bounds\n // (axes follow). Diagonal works naturally.\n next = handle.translate(e.changeX, e.changeY);\n }\n if (next) pictureSV.value = next;\n maybeStartAnim();\n })\n .onEnd((e) => {\n if (!handle) return;\n // Price-line drop. The preview always clears here: the line is a controlled\n // prop, so it only really moves once the host restates it — which means a\n // rejected (or ignored) move reverts on its own.\n if (panMode.current === 'price-line') {\n const g = priceDrag.current;\n priceDrag.current = null;\n handle.setPriceLineDrag(-1, 0);\n const p = handle.render();\n if (p) pictureSV.value = p;\n if (g) onPriceLineDragEnd?.(g.id, g.price);\n return;\n }\n // A chart-area drag with the crosshair up just moved the crosshair —\n // nothing about the viewport changed, and no momentum.\n if (panMode.current === 'chart' && crosshairActive.current) return;\n onViewportChange?.(0, 0);\n\n // Axis drags don't get momentum — they're a precise size adjustment.\n // Chart and indicator-pane drags both get horizontal fling momentum.\n if (panMode.current !== 'chart' && panMode.current !== 'indicator') return;\n\n let velocity = e.velocityX; // px/s\n const MIN_LAUNCH = 80; // ignore tiny flicks\n const MIN_STOP = 8; // px/s — stop threshold\n const HALF_LIFE_S = 0.35; // velocity halves every 0.35s\n if (Math.abs(velocity) < MIN_LAUNCH) return;\n\n let lastTime = performance.now();\n const tick = () => {\n const now = performance.now();\n const dt = (now - lastTime) / 1000;\n lastTime = now;\n\n // Frame-time-independent exponential decay.\n velocity *= Math.pow(0.5, dt / HALF_LIFE_S);\n const dx = velocity * dt;\n const next = handle.pan(dx, 0);\n if (next) pictureSV.value = next;\n maybeStartAnim();\n\n if (Math.abs(velocity) > MIN_STOP) {\n decayRaf.current = requestAnimationFrame(tick);\n } else {\n decayRaf.current = null;\n }\n };\n decayRaf.current = requestAnimationFrame(tick);\n });\n\n // Directional pinch. A single Pinch scale is uniform, so we read the two\n // touch points and track their horizontal/vertical spans independently: a\n // vertical pinch scales price (y), a horizontal pinch scales the time window\n // (x), and a diagonal pinch does both. An axis whose initial span is tiny\n // (fingers ~collinear on that axis) is left alone.\n // Lock the scalable axes at gesture start by orientation: an axis only\n // scales if its initial span is meaningful AND at least AXIS_RATIO of the\n // other axis. This keeps a vertical pinch from ever touching x (and vice\n // versa) — critical because during a vertical pinch the fingers' x-coords\n // drift and cross, sending spanX through ~0 and otherwise exploding frameX.\n const MIN_SPAN = 24; // px — minimum span for an axis to scale at all\n const AXIS_RATIO = 0.5; // axis scales only if its span ≥ this × the other's\n const pinchStart = useRef({\n spanX: 1,\n spanY: 1,\n ratioX: 1,\n ratioY: 1,\n enableX: false,\n enableY: false,\n });\n const pinch = Gesture.Pinch()\n .runOnJS(true)\n .onTouchesDown((e) => {\n if (e.numberOfTouches < 2) return;\n const [a, b] = e.allTouches;\n const spanX = Math.abs(a.x - b.x);\n const spanY = Math.abs(a.y - b.y);\n pinchStart.current = {\n spanX,\n spanY,\n ratioX: 1,\n ratioY: 1,\n enableX: spanX >= MIN_SPAN && spanX >= spanY * AXIS_RATIO,\n enableY: spanY >= MIN_SPAN && spanY >= spanX * AXIS_RATIO,\n };\n })\n .onTouchesMove((e) => {\n if (!handle || crosshairActive.current) return;\n if (e.numberOfTouches < 2) return;\n const [a, b] = e.allTouches;\n const start = pinchStart.current;\n const focalX = (a.x + b.x) * 0.5;\n const focalY = (a.y + b.y) * 0.5;\n\n // Per-frame factor = current cumulative ratio / previous. Floor the\n // current span at MIN_SPAN so a near-zero span (fingers crossing on that\n // axis) can't blow the ratio up.\n let frameX = 1;\n if (start.enableX) {\n const ratioX = Math.max(Math.abs(a.x - b.x), MIN_SPAN) / start.spanX;\n frameX = ratioX / start.ratioX;\n start.ratioX = ratioX;\n }\n let frameY = 1;\n if (start.enableY) {\n const ratioY = Math.max(Math.abs(a.y - b.y), MIN_SPAN) / start.spanY;\n frameY = ratioY / start.ratioY;\n start.ratioY = ratioY;\n }\n if (frameX === 1 && frameY === 1) return;\n\n const next = handle.zoom(frameX, frameY, focalX, focalY);\n if (next) pictureSV.value = next;\n maybeStartAnim();\n });\n\n // Long press shows the crosshair at the press point. A stationary hold never\n // activates `pan` (it needs movement first), so the chart won't scroll under\n // the hold. The dot/horizontal line are lifted above the fingertip.\n const longPress = Gesture.LongPress()\n .runOnJS(true)\n .onStart((e) => {\n if (!handle) return;\n // A long press on an axis strip controls the axis, never the crosshair.\n if (hitAxis(e.x, e.y) !== 'chart') return;\n // A press on a price line belongs to that line — dragging it or tapping its\n // close button — so it must not raise the crosshair over the top.\n if (hitPriceLine(e.x, e.y)) return;\n cancelDecay();\n crosshairActive.current = true;\n const ch = handle.setCrosshair(e.x, e.y - crosshairOffset);\n if (ch) pictureSV.value = ch;\n const info = handle.getCrosshairInfo();\n lastCrosshairTime.current = info?.timeMs ?? null;\n onCrosshair?.({\n active: true,\n candle: info?.candle ?? null,\n timeMs: info?.timeMs ?? null,\n price: null, // web-only for now (see @vroomchart/react)\n reason: 'show',\n });\n });\n\n // A tap activates a price line's close button, and otherwise dismisses the\n // crosshair while it's up. Any other tap is a no-op, so it never interferes\n // with normal pan/pinch.\n const tap = Gesture.Tap()\n .runOnJS(true)\n .onStart((e) => {\n if (!handle) return;\n // The close button is a tap target whether or not the crosshair is up.\n const pl = hitPriceLine(e.x, e.y);\n if (pl && pl.part === 1) {\n onPriceLineClose?.(pl.line.id);\n return;\n }\n if (!crosshairActive.current) return;\n // A tap on an axis strip controls the axis, never dismisses the crosshair.\n if (hitAxis(e.x, e.y) !== 'chart') return;\n crosshairActive.current = false;\n const ch = handle.clearCrosshair();\n if (ch) pictureSV.value = ch;\n lastCrosshairTime.current = null;\n onCrosshair?.({ active: false, candle: null, timeMs: null, price: null, reason: 'hide' });\n });\n\n const gesture = Gesture.Simultaneous(pan, pinch, longPress, tap);\n\n return (\n <GestureHandlerRootView\n onLayout={onLayout}\n style={[\n { width: widthProp, height: heightProp },\n widthProp == null && heightProp == null ? { flex: 1 } : null,\n style,\n ]}\n >\n <GestureDetector gesture={gesture}>\n <View style={{ flex: 1 }}>\n <Canvas style={{ flex: 1 }}>\n {width > 0 && height > 0 ? (\n // pictureSV is always a valid picture (seeded empty, never null),\n // so RN-Skia's UI-thread reader never sees null.\n <Picture picture={pictureSV} />\n ) : null}\n </Canvas>\n </View>\n </GestureDetector>\n </GestureHandlerRootView>\n );\n}\n","import { useEffect, useRef, useState } from 'react';\nimport type { SkPicture } from '@shopify/react-native-skia';\n\nimport NativeVroomChart from './NativeVroomChart';\nimport type { ChartHandle } from './jsi.d';\nimport { packCandles } from './packCandles';\nimport { applyTheme, parseColor } from './theme';\nimport type {\n BollingerBandsConfig,\n Candle,\n ChartType,\n MACDConfig,\n MovingAverageOverlay,\n PriceLine,\n PriceLinesStyle,\n RSIConfig,\n VisibleRange,\n VroomTheme,\n VWAPConfig,\n} from './types';\n\n// Mirrors vroom::ma::Source order in packages/core/src/ma.h.\nconst MA_SOURCES = [\n 'close',\n 'open',\n 'high',\n 'low',\n 'hl2',\n 'hlc3',\n 'ohlc4',\n] as const;\n\nfunction overlayToNumeric(o: MovingAverageOverlay) {\n const srcIdx = o.source ? MA_SOURCES.indexOf(o.source) : 0;\n return {\n kind: o.kind === 'ema' ? 1 : 0,\n period: o.length,\n source: srcIdx < 0 ? 0 : srcIdx,\n color: (o.color != null ? parseColor(o.color) : null) ?? 0xff2962ff,\n width: o.width ?? 1.5,\n };\n}\n\n// Bollinger defaults: blue bands / orange basis, matching the repo palette.\nconst DEFAULT_BB_BAND_COLOR = 0xff2962ff;\nconst DEFAULT_BB_BASIS_COLOR = 0xffff6d00;\n\nfunction bollingerToSpec(cfg: BollingerBandsConfig | undefined) {\n const srcIdx = cfg?.source ? MA_SOURCES.indexOf(cfg.source) : 0;\n return {\n enabled: cfg?.enabled ?? false,\n period: cfg?.period ?? 20,\n mult: cfg?.stdDev ?? 2,\n source: srcIdx < 0 ? 0 : srcIdx,\n basisKind: cfg?.basis === 'ema' ? 1 : 0,\n upperColor:\n (cfg?.upperColor != null ? parseColor(cfg.upperColor) : null) ??\n DEFAULT_BB_BAND_COLOR,\n upperWidth: cfg?.upperWidth ?? 1,\n middleColor:\n (cfg?.middleColor != null ? parseColor(cfg.middleColor) : null) ??\n DEFAULT_BB_BASIS_COLOR,\n middleWidth: cfg?.middleWidth ?? 1,\n lowerColor:\n (cfg?.lowerColor != null ? parseColor(cfg.lowerColor) : null) ??\n DEFAULT_BB_BAND_COLOR,\n lowerWidth: cfg?.lowerWidth ?? 1,\n fillEnabled: cfg?.fill ?? true,\n fillOpacity: cfg?.fillOpacity ?? 0.1,\n };\n}\n\n// Price-line defaults: a soft red dotted rule with a dark translucent label,\n// close in weight to the current-price indicator it sits beside.\nconst DEFAULT_PRICE_LINE_COLOR = 0xffef5350;\nconst DEFAULT_PRICE_LINE_BODY_BG = 0xd91c2128;\nconst DEFAULT_PRICE_LINE_HOVER_BOOST = 1.25;\n\nconst LINE_STYLES = { solid: 0, dotted: 1, dashed: 2 } as const;\n\n// Mirrors VroomPriceLineFlags in packages/core/include/vroom/vroom_chart.h.\nconst PRICE_LINE_DRAGGABLE = 1 << 0;\nconst PRICE_LINE_CLOSABLE = 1 << 1;\nconst PRICE_LINE_AXIS_LABEL = 1 << 2;\nconst PRICE_LINE_EXTEND_LEFT = 1 << 3;\n\n/** The price lines + their shared style, as the chart's props express them. */\nexport type PriceLinesProp = {\n lines: PriceLine[];\n style?: PriceLinesStyle;\n /**\n * Whether the host supplied a close handler. The close button is\n * callback-gated, so with nothing for it to do it isn't drawn at all.\n */\n hasCloseHandler: boolean;\n};\n\nfunction priceLinesToSpec(cfg: PriceLinesProp) {\n return {\n lines: cfg.lines.map((l) => ({\n price: l.price,\n color:\n (l.color != null ? parseColor(l.color) : null) ?? DEFAULT_PRICE_LINE_COLOR,\n width: l.width ?? 1,\n lineStyle: LINE_STYLES[l.lineStyle ?? 'dotted'],\n text: l.text ?? '',\n quantity: l.quantity ?? '',\n flags:\n (l.draggable ? PRICE_LINE_DRAGGABLE : 0) |\n (cfg.hasCloseHandler && l.closable !== false ? PRICE_LINE_CLOSABLE : 0) |\n (l.axisLabel !== false ? PRICE_LINE_AXIS_LABEL : 0) |\n (l.extendLeft !== false ? PRICE_LINE_EXTEND_LEFT : 0),\n })),\n bodyBg:\n (cfg.style?.bodyBackground != null ? parseColor(cfg.style.bodyBackground) : null) ??\n DEFAULT_PRICE_LINE_BODY_BG,\n fontSizePx: cfg.style?.fontSize ?? 0,\n lineLengthFrac: cfg.style?.inset ?? 0,\n align: cfg.style?.align === 'left' ? 0 : cfg.style?.align === 'center' ? 1 : 2,\n hoverBoost: cfg.style?.hoverBoost ?? DEFAULT_PRICE_LINE_HOVER_BOOST,\n };\n}\n\n// Cleared overlay: no lines (the style values are irrelevant, but the spec shape\n// requires them).\nconst EMPTY_PRICE_LINES = priceLinesToSpec({ lines: [], hasCloseHandler: false });\n\nlet installed = false;\nfunction ensureInstalled(): void {\n if (installed) return;\n const ok = NativeVroomChart.install();\n if (!ok) throw new Error('VroomChartModule.install() returned false');\n if (typeof globalThis.VroomChartJSI === 'undefined') {\n throw new Error('global.VroomChartJSI undefined after install()');\n }\n installed = true;\n}\n\nexport type ChartCoreState = {\n handle: ChartHandle | null;\n /** Picture freshly rendered after the latest data/size/range push. */\n picture: SkPicture | null;\n};\n\n// Owns a ChartHandle and produces an \"initial\" picture whenever data, size,\n// or the externally-controlled visible range changes. Gesture-driven updates\n// happen outside this hook by calling handle.pan(...) directly and assigning\n// the result into a SharedValue.\nexport function useChartCore(\n candles: Candle[],\n size: { width: number; height: number; pxRatio?: number },\n visibleRange?: VisibleRange,\n defaultCandleWidth?: number,\n chartType?: ChartType,\n theme?: VroomTheme,\n rsi?: RSIConfig,\n macd?: MACDConfig,\n movingAverages?: MovingAverageOverlay[],\n vwap?: VWAPConfig,\n bollingerBands?: BollingerBandsConfig,\n priceLines?: PriceLinesProp,\n): ChartCoreState {\n const handleRef = useRef<ChartHandle | null>(null);\n // Push setDefaultCandleWidth only once (first load): setCandles re-runs on\n // every data change, and the core setter re-frames when candles are present,\n // so re-pushing would snap the view away from the user's pan/zoom.\n const defaultWidthAppliedRef = useRef(false);\n const [picture, setPicture] = useState<SkPicture | null>(null);\n\n if (!handleRef.current && size.width > 0 && size.height > 0) {\n ensureInstalled();\n handleRef.current = globalThis.VroomChartJSI!.create();\n }\n\n // When no visibleRange is provided, leave the range entirely to the C++\n // side (which defaults to a sensible recent window on first setCandles).\n // Only push setVisibleRange when the caller is actively controlling it,\n // so it doesn't clobber the default or fight gesture-driven pans.\n const explicit = visibleRange != null;\n const startMs = visibleRange?.startMs ?? 0;\n const endMs = visibleRange?.endMs ?? 0;\n\n // Stable deps so inline `theme={{...}}` / `rsi={{...}}` literals don't re-run\n // the effect every render — only when the actual values change.\n const themeKey = theme ? JSON.stringify(theme) : '';\n const rsiKey = rsi ? JSON.stringify(rsi) : '';\n const macdKey = macd ? JSON.stringify(macd) : '';\n const maKey = movingAverages ? JSON.stringify(movingAverages) : '';\n const vwapKey = vwap ? JSON.stringify(vwap) : '';\n const bollingerKey = bollingerBands ? JSON.stringify(bollingerBands) : '';\n const priceLinesKey = priceLines ? JSON.stringify(priceLines) : '';\n\n useEffect(() => {\n const h = handleRef.current;\n if (!h) return;\n h.setSize(size.width, size.height, size.pxRatio ?? 1);\n // Drive the initial zoom from a target candle width. Pushed once, before the\n // first setCandles (while the core window is still 0/0), and only when the\n // caller isn't explicitly controlling the range.\n if (\n !defaultWidthAppliedRef.current &&\n !explicit &&\n defaultCandleWidth != null &&\n defaultCandleWidth > 0\n ) {\n h.setDefaultCandleWidth(defaultCandleWidth);\n defaultWidthAppliedRef.current = true;\n }\n if (candles.length > 0) {\n h.setCandles(packCandles(candles));\n }\n if (explicit) {\n h.setVisibleRange(startMs, endMs);\n }\n // chartType / the candle↔line morph is driven separately (VroomChart owns the\n // per-frame animation loop so it can update the picture SharedValue directly).\n if (theme) {\n applyTheme(h, theme);\n }\n h.setRSI(\n rsi?.enabled ?? false,\n rsi?.period ?? 14,\n rsi?.upperBand ?? 70,\n rsi?.lowerBand ?? 30,\n rsi?.maEnabled ?? true,\n rsi?.maPeriod ?? 14,\n );\n h.setMACD(\n macd?.enabled ?? false,\n macd?.fast ?? 12,\n macd?.slow ?? 26,\n macd?.signal ?? 9,\n );\n h.setOverlays((movingAverages ?? []).map(overlayToNumeric));\n h.setVWAP(\n vwap?.enabled ?? false,\n vwap?.resetMinutes ?? 0,\n (vwap?.color != null ? parseColor(vwap.color) : null) ?? 0xff00bcd4,\n vwap?.width ?? 1.5,\n );\n h.setBollinger(bollingerToSpec(bollingerBands));\n h.setPriceLines(\n priceLines?.lines.length ? priceLinesToSpec(priceLines) : EMPTY_PRICE_LINES,\n );\n // TODO(rn-parity): mirror the web `liquidity` overlay here (setLiquidity +\n // the VroomBand structs in the JSI handle) — web-only for now.\n setPicture(h.render());\n // theme/rsi/macd/movingAverages/vwap/bollingerBands/priceLines are\n // represented by their *Key deps.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [candles, size.width, size.height, size.pxRatio, explicit, startMs, endMs, defaultCandleWidth, themeKey, rsiKey, macdKey, maKey, vwapKey, bollingerKey, priceLinesKey]);\n\n return { handle: handleRef.current, picture };\n}\n","import type { TurboModule } from 'react-native';\nimport { TurboModuleRegistry } from 'react-native';\n\n// TurboModule spec consumed by codegen. The only method is `install`, which\n// the native side uses to install the `global.VroomChartJSI` host object the\n// first time it's called from JS. All real chart operations go through that\n// host object, not through the TurboModule itself.\nexport interface Spec extends TurboModule {\n install(): boolean;\n}\n\nexport default TurboModuleRegistry.getEnforcing<Spec>('VroomChartModule');\n","import type { Candle } from './types';\n\n// Wire format must match `VroomCandle` in packages/core/include/vroom/vroom_chart.h:\n// int64_t time_ms; double open, high, low, close, volume;\n// = 48 bytes per candle, 8-byte aligned, little-endian on iOS/Android.\nexport const BYTES_PER_CANDLE = 48;\n\n// Serializes candles into the packed little-endian buffer the C++ core expects.\n// Pure (no native/Skia deps) so it can be unit-tested in isolation.\nexport function packCandles(candles: Candle[]): ArrayBuffer {\n const buf = new ArrayBuffer(candles.length * BYTES_PER_CANDLE);\n const view = new DataView(buf);\n for (let i = 0; i < candles.length; i++) {\n const c = candles[i]!;\n const off = i * BYTES_PER_CANDLE;\n view.setBigInt64(off, BigInt(c.timeMs), true);\n view.setFloat64(off + 8, c.open, true);\n view.setFloat64(off + 16, c.high, true);\n view.setFloat64(off + 24, c.low, true);\n view.setFloat64(off + 32, c.close, true);\n view.setFloat64(off + 40, c.volume, true);\n }\n return buf;\n}\n","import type { ChartHandle } from './jsi.d';\nimport type { VroomColor, VroomTheme } from './types';\n\n// Maps each color VroomTheme field to its VroomColorKey index in the C++ enum\n// (packages/core/include/vroom/vroom_chart.h). Keep in sync with that enum;\n// new keys are appended there so existing indices never shift.\nexport const COLOR_KEYS: Partial<Record<keyof VroomTheme, number>> = {\n background: 0, // VROOM_COLOR_BACKGROUND\n bull: 1, // VROOM_COLOR_BULL\n bear: 2, // VROOM_COLOR_BEAR\n grid: 4, // VROOM_COLOR_GRID\n axisText: 5, // VROOM_COLOR_AXIS_TEXT\n crosshair: 6, // VROOM_COLOR_CROSSHAIR\n crosshairTarget: 9, // VROOM_COLOR_CROSSHAIR_TARGET\n borderBull: 10, // VROOM_COLOR_BORDER_BULL\n borderBear: 11, // VROOM_COLOR_BORDER_BEAR\n wickBull: 12, // VROOM_COLOR_WICK_BULL\n wickBear: 13, // VROOM_COLOR_WICK_BEAR\n accentBull: 14, // VROOM_COLOR_ACCENT_BULL\n accentBear: 15, // VROOM_COLOR_ACCENT_BEAR\n lineColor: 16, // VROOM_COLOR_LINE\n};\n\n// Maps each numeric VroomTheme field to its VroomFloatKey index.\nexport const FLOAT_KEYS: Partial<Record<keyof VroomTheme, number>> = {\n wickWidth: 1, // VROOM_FLOAT_WICK_WIDTH_PX\n candleRadius: 8, // VROOM_FLOAT_CANDLE_RADIUS_PX\n volumeRadius: 10, // VROOM_FLOAT_VOLUME_RADIUS_PX\n lineWidth: 11, // VROOM_FLOAT_LINE_WIDTH_PX\n};\n\n// Maps each boolean VroomTheme field to its VroomFloatKey index (pushed as 0/1).\nexport const BOOL_KEYS: Partial<Record<keyof VroomTheme, number>> = {\n wickRoundCap: 9, // VROOM_FLOAT_WICK_ROUND_CAP\n};\n\n// Parses a color into a packed 0xAARRGGBB integer (Skia's ARGB order).\n// - number → taken as already-packed ARGB\n// - '#rgb'-style 6-digit hex → opaque (alpha forced to ff)\n// - 8-digit hex → interpreted as AARRGGBB\n// Returns null for anything malformed so the caller can skip it.\nexport function parseColor(value: VroomColor): number | null {\n if (typeof value === 'number') {\n return Number.isFinite(value) ? value >>> 0 : null;\n }\n let s = value.trim();\n if (s.startsWith('#')) s = s.slice(1);\n if (s.length === 6) s = `ff${s}`; // assume opaque\n if (s.length !== 8 || !/^[0-9a-fA-F]{8}$/.test(s)) return null;\n return parseInt(s, 16) >>> 0;\n}\n\n// Pushes every provided theme color + numeric float into the chart core via\n// handle.setColor / handle.setFloat. Unspecified or unparseable values are\n// skipped (they keep their default).\nexport function applyTheme(handle: ChartHandle, theme: VroomTheme): void {\n (Object.keys(COLOR_KEYS) as (keyof VroomTheme)[]).forEach((field) => {\n const value = theme[field];\n if (typeof value !== 'string' && typeof value !== 'number') return;\n const argb = parseColor(value);\n if (argb == null) return;\n handle.setColor(COLOR_KEYS[field]!, argb);\n });\n (Object.keys(FLOAT_KEYS) as (keyof VroomTheme)[]).forEach((field) => {\n const value = theme[field];\n if (typeof value !== 'number' || !Number.isFinite(value)) return;\n handle.setFloat(FLOAT_KEYS[field]!, value);\n });\n (Object.keys(BOOL_KEYS) as (keyof VroomTheme)[]).forEach((field) => {\n const value = theme[field];\n if (typeof value !== 'boolean') return;\n handle.setFloat(BOOL_KEYS[field]!, value ? 1 : 0);\n });\n}\n"],"mappings":";AAYA,OAAO,SAAS,aAAAA,YAAW,UAAAC,SAAQ,aAAa,YAAAC,WAAU,eAAe;AACzE,SAAS,YAAoC;AAC7C,SAAS,QAAQ,SAAS,YAA4B;AACtD;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,sBAAsB;;;ACpB/B,SAAS,WAAW,QAAQ,gBAAgB;;;ACC5C,SAAS,2BAA2B;AAUpC,IAAO,2BAAQ,oBAAoB,aAAmB,kBAAkB;;;ACNjE,IAAM,mBAAmB;AAIzB,SAAS,YAAY,SAAgC;AAC1D,QAAM,MAAM,IAAI,YAAY,QAAQ,SAAS,gBAAgB;AAC7D,QAAM,OAAO,IAAI,SAAS,GAAG;AAC7B,WAAS,IAAI,GAAG,IAAI,QAAQ,QAAQ,KAAK;AACvC,UAAM,IAAI,QAAQ,CAAC;AACnB,UAAM,MAAM,IAAI;AAChB,SAAK,YAAY,KAAK,OAAO,EAAE,MAAM,GAAG,IAAI;AAC5C,SAAK,WAAW,MAAM,GAAG,EAAE,MAAM,IAAI;AACrC,SAAK,WAAW,MAAM,IAAI,EAAE,MAAM,IAAI;AACtC,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Q,MAAM,QAAQ,MAAM,OAAO,MAAM,QAAQ,OAAO,CAAC;AAAA,EAC1F,CAAC;AAEH,QAAM,UAAU,QAAQ,aAAa,KAAK,OAAO,WAAW,GAAG;AAE/D,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA,OAAO;AAAA,QACL,EAAE,OAAO,WAAW,QAAQ,WAAW;AAAA,QACvC,aAAa,QAAQ,cAAc,OAAO,EAAE,MAAM,EAAE,IAAI;AAAA,QACxD;AAAA,MACF;AAAA;AAAA,IAEA,oCAAC,mBAAgB,WACf,oCAAC,QAAK,OAAO,EAAE,MAAM,EAAE,KACrB,oCAAC,UAAO,OAAO,EAAE,MAAM,EAAE,KACtB,QAAQ,KAAK,SAAS;AAAA;AAAA;AAAA,MAGrB,oCAAC,WAAQ,SAAS,WAAW;AAAA,QAC3B,IACN,CACF,CACF;AAAA,EACF;AAEJ;","names":["useEffect","useRef","useState","useState","useRef","useEffect"]}
|
|
1
|
+
{"version":3,"sources":["../src/VroomChart.tsx","../src/useChartCore.ts","../src/NativeVroomChart.ts","../src/packCandles.ts","../src/theme.ts","../src/easing.ts"],"sourcesContent":["// VroomChart — Phase 3.\n//\n// Owns a SharedValue<SkPicture> driven by:\n// - useChartCore's \"initial\" picture (when data/size/range change), AND\n// - Pan gesture callbacks that call handle.pan(dx, dy) → fresh picture.\n//\n// Reanimated 4 + RN-Skia 2 propagate SharedValue<SkPicture> changes to\n// <Picture> without a React re-render, so gesture-driven redraws are cheap.\n//\n// Gestures run on the JS thread for now (`runOnJS(true)`) — installing the\n// JSI bindings on the worklet runtime is a later perf optimization.\n\nimport React, { useEffect, useRef, useCallback, useState, useMemo } from 'react';\nimport { View, type LayoutChangeEvent } from 'react-native';\nimport { Canvas, Picture, Skia, type SkPicture } from '@shopify/react-native-skia';\nimport {\n Gesture,\n GestureDetector,\n GestureHandlerRootView,\n} from 'react-native-gesture-handler';\nimport { useSharedValue } from 'react-native-reanimated';\n\nimport { useChartCore } from './useChartCore';\nimport { ease, easingIndex } from './easing';\nimport type { VroomChartProps } from './types';\nimport './jsi.d';\n\n/**\n * Skia-rendered candlestick chart. Pass OHLCV `candles` and size it via `style`\n * (it fills its parent by default). Pan to scroll, pinch to zoom, drag the\n * price/time axes to rescale, and long-press for the crosshair. Optional\n * indicators (`rsi`, `macd`, `movingAverages`, `vwap`), colors (`theme`), and\n * events (`onCrosshair`, `onViewportChange`) are configured through props.\n *\n * @see {@link VroomChartProps} for the full prop reference.\n */\nexport function VroomChart(props: VroomChartProps) {\n const {\n candles,\n width: widthProp,\n height: heightProp,\n style,\n visibleRange,\n defaultCandleWidth,\n chartType,\n transitionMs,\n transitionEasing,\n theme,\n rsi,\n macd,\n movingAverages,\n vwap,\n bollingerBands,\n volume,\n crosshairOffset = 40,\n onCrosshair,\n onViewportChange,\n priceLines,\n priceLinesStyle,\n onPriceLineDrag,\n onPriceLineDragEnd,\n onPriceLineClose,\n } = props;\n\n // Fill the parent by default: measure via onLayout. Explicit width/height\n // props (if given) win per-axis. Until the first layout, dims are 0 and we\n // render nothing (one frame).\n const [measured, setMeasured] = useState({ width: 0, height: 0 });\n const width = widthProp ?? measured.width;\n const height = heightProp ?? measured.height;\n\n const onLayout = useCallback((e: LayoutChangeEvent) => {\n const w = Math.round(e.nativeEvent.layout.width);\n const h = Math.round(e.nativeEvent.layout.height);\n setMeasured((prev) =>\n prev.width === w && prev.height === h ? prev : { width: w, height: h },\n );\n }, []);\n\n // The close button is callback-gated, so whether a handler exists is part of\n // what gets rendered.\n const priceLinesProp = useMemo(\n () =>\n priceLines\n ? {\n lines: priceLines,\n style: priceLinesStyle,\n hasCloseHandler: onPriceLineClose != null,\n }\n : undefined,\n [priceLines, priceLinesStyle, onPriceLineClose],\n );\n\n const { handle, picture, volumeCollapseRef } = useChartCore(\n candles,\n { width, height },\n visibleRange,\n defaultCandleWidth,\n chartType,\n theme,\n rsi,\n macd,\n movingAverages,\n vwap,\n bollingerBands,\n volume,\n priceLinesProp,\n );\n\n // RN-Skia's recorder reads this SharedValue on the UI/render runtime, a beat\n // behind JS-thread writes. If it ever reads null it throws (\"Invalid prop\n // value for SkTextBlob received\" — RN-Skia's mislabeled SkPicture error), so\n // we seed it with an empty picture and *never* assign null into it.\n const emptyPicture = useMemo(() => {\n const rec = Skia.PictureRecorder();\n rec.beginRecording(Skia.XYWHRect(0, 0, 1, 1));\n return rec.finishRecordingAsPicture();\n }, []);\n const pictureSV = useSharedValue<SkPicture>(emptyPicture);\n\n // When the crosshair is showing, pan moves it (instead of scrolling) and\n // pinch is disabled. A ref (not state) so gesture callbacks read it\n // synchronously without re-subscribing. Tap dismisses it.\n const crosshairActive = useRef(false);\n\n // timeMs of the candle last reported through onCrosshair, so a drag fires a\n // 'move' event only when it crosses into a *different* candle (one per\n // candle, not per frame). Null while the crosshair is hidden.\n const lastCrosshairTime = useRef<number | null>(null);\n\n // Sync the initial picture from useChartCore into the SV whenever it\n // refreshes (data load, size change, externally-controlled range change).\n // Only ever assign a non-null picture (see emptyPicture note above).\n useEffect(() => {\n if (picture) pictureSV.value = picture;\n }, [picture, pictureSV]);\n\n // Momentum scroll. After Pan ends with non-trivial velocity, we run a RAF\n // loop that calls handle.pan(dx, 0) each frame with an exponentially\n // decaying velocity. A new pan (or unmount) cancels the loop.\n const decayRaf = useRef<number | null>(null);\n const cancelDecay = useCallback(() => {\n if (decayRaf.current != null) {\n cancelAnimationFrame(decayRaf.current);\n decayRaf.current = null;\n }\n }, []);\n useEffect(() => cancelDecay, [cancelDecay]);\n\n // Axis-label fade animation loop. When a gesture changes which labels are\n // active, the C++ side starts ramping their opacities. We keep calling\n // render() on every frame until handle.isAnimating() returns false. The\n // loop is started by gesture callbacks (and the momentum tick) after they\n // update the picture, and self-stops when fades settle.\n const animRaf = useRef<number | null>(null);\n const animTick = useCallback(() => {\n animRaf.current = null;\n if (!handle) return;\n const next = handle.render();\n if (next) pictureSV.value = next;\n if (handle.isAnimating()) {\n animRaf.current = requestAnimationFrame(animTick);\n }\n }, [handle, pictureSV]);\n const maybeStartAnim = useCallback(() => {\n if (animRaf.current != null) return;\n if (!handle?.isAnimating()) return;\n animRaf.current = requestAnimationFrame(animTick);\n }, [handle, animTick]);\n useEffect(() => {\n return () => {\n if (animRaf.current != null) {\n cancelAnimationFrame(animRaf.current);\n animRaf.current = null;\n }\n };\n }, []);\n\n // Candle↔line morph. When `chartType` changes we drive the core per-frame with\n // a (collapse, fade) blend and push a fresh picture into the SV each frame — the\n // JS side owns the eased clock (see plan). A fresh handle snaps to the target;\n // transitionMs=0 snaps. Mirrors the web driver in react/src/useChartCore.ts.\n const morphRaf = useRef<number | null>(null);\n const morphFade = useRef<number | null>(null);\n const morphHandle = useRef<typeof handle>(null);\n // In a ref so changing the curve mid-animation doesn't restart the clock.\n const easingRef = useRef(transitionEasing);\n easingRef.current = transitionEasing;\n useEffect(() => {\n if (!handle) return undefined;\n const target = chartType === 'line' ? 1 : 0;\n\n // Fresh handle (first load / recreate): snap, don't animate.\n if (morphHandle.current !== handle || morphFade.current == null) {\n morphHandle.current = handle;\n morphFade.current = target;\n handle.setChartType(target);\n const p = handle.render();\n if (p) pictureSV.value = p;\n return undefined;\n }\n if (morphFade.current === target) return undefined;\n\n if (morphRaf.current != null) {\n cancelAnimationFrame(morphRaf.current);\n morphRaf.current = null;\n }\n const dur = Math.max(0, transitionMs ?? 300);\n if (dur === 0) {\n morphFade.current = target;\n handle.setChartType(target);\n const p = handle.render();\n if (p) pictureSV.value = p;\n return undefined;\n }\n\n const from = morphFade.current;\n let startTs: number | null = null;\n const step = (now: number) => {\n if (startTs == null) startTs = now;\n const prog = Math.min(1, (now - startTs) / dur);\n const fade = from + (target - from) * ease(easingRef.current, prog);\n morphFade.current = fade;\n handle.setMorph(fade, fade);\n const p = handle.render();\n if (p) pictureSV.value = p;\n if (prog < 1) {\n morphRaf.current = requestAnimationFrame(step);\n } else {\n morphRaf.current = null;\n morphFade.current = target;\n handle.setChartType(target); // lock the exact endpoint\n const q = handle.render();\n if (q) pictureSV.value = q;\n }\n };\n morphRaf.current = requestAnimationFrame(step);\n\n return () => {\n if (morphRaf.current != null) {\n cancelAnimationFrame(morphRaf.current);\n morphRaf.current = null;\n }\n };\n }, [handle, chartType, transitionMs, pictureSV]);\n\n // Volume-bar collapse. The core staggers the bars itself — tallest falling\n // first, all landing together — so unlike the loop above this one hands it\n // *linear* progress plus the curve; pre-easing here would compound the two.\n // Hiding drives 0→1, revealing 1→0, which is the same cascade backwards.\n // Mirrors the web driver in react/src/useChartCore.ts.\n const volumeRaf = useRef<number | null>(null);\n const volumeHandle = useRef<typeof handle>(null);\n useEffect(() => {\n if (!handle) return undefined;\n const target = (volume?.enabled ?? true) ? 0 : 1;\n const easing = easingIndex(easingRef.current);\n\n // Fresh handle (first load / recreate): the data effect's setVolume already\n // snapped it, so a chart that mounts with bars doesn't animate them in.\n if (volumeHandle.current !== handle || volumeCollapseRef.current == null) {\n volumeHandle.current = handle;\n volumeCollapseRef.current = { t: target, easing };\n return undefined;\n }\n if (volumeCollapseRef.current.t === target) return undefined;\n\n if (volumeRaf.current != null) {\n cancelAnimationFrame(volumeRaf.current);\n volumeRaf.current = null;\n }\n\n const dur = Math.max(0, transitionMs ?? 300);\n if (dur === 0) {\n volumeCollapseRef.current = { t: target, easing };\n handle.setVolumeCollapse(target, easing);\n const p = handle.render();\n if (p) pictureSV.value = p;\n return undefined;\n }\n\n // From wherever the last frame left off, so toggling mid-flight reverses\n // instead of jumping. A partial trip covers less ground in the same time.\n const from = volumeCollapseRef.current.t;\n let startTs: number | null = null;\n const step = (now: number) => {\n if (startTs == null) startTs = now;\n const prog = Math.min(1, (now - startTs) / dur);\n const t = prog < 1 ? from + (target - from) * prog : target;\n const kind = easingIndex(easingRef.current);\n volumeCollapseRef.current = { t, easing: kind };\n handle.setVolumeCollapse(t, kind);\n const p = handle.render();\n if (p) pictureSV.value = p;\n volumeRaf.current = prog < 1 ? requestAnimationFrame(step) : null;\n };\n volumeRaf.current = requestAnimationFrame(step);\n\n return () => {\n if (volumeRaf.current != null) {\n cancelAnimationFrame(volumeRaf.current);\n volumeRaf.current = null;\n }\n };\n }, [handle, volume?.enabled, transitionMs, pictureSV, volumeCollapseRef]);\n\n // Classifies a touch point into the candle area vs. an axis strip. Axis\n // strips always own their gesture (scale price/time) and take priority over\n // the crosshair: an axis touch never opens, moves, or dismisses it.\n const hitAxis = useCallback(\n (x: number, y: number): 'chart' | 'price-axis' | 'time-axis' | 'indicator' => {\n if (!handle) return 'chart';\n const { yAxisWidth, xAxisHeight, indicatorHeight } =\n handle.getAxisMetrics();\n if (x > width - yAxisWidth) return 'price-axis';\n if (y > height - xAxisHeight) return 'time-axis';\n // The indicator pane sits just above the time-axis strip. A drag here\n // scrolls the candles horizontally (no vertical price change).\n if (indicatorHeight > 0 && y > height - xAxisHeight - indicatorHeight) {\n return 'indicator';\n }\n return 'chart';\n },\n [handle, width, height],\n );\n\n // Hit-tests the price lines at a touch point, resolving the core's index back\n // to the line it belongs to. Null when nothing was hit.\n const hitPriceLine = useCallback(\n (x: number, y: number) => {\n if (!handle || !priceLines?.length) return null;\n const hit = handle.hitTestPriceLine(x, y);\n const line = hit ? priceLines[hit.index] : undefined;\n return hit && line ? { index: hit.index, part: hit.part, line } : null;\n },\n [handle, priceLines],\n );\n\n // A price line being dragged vertically: its core index, its id, and the last\n // previewed price (the payload for the drop).\n const priceDrag = useRef<{ index: number; id: string; price: number } | null>(\n null,\n );\n\n // Pan routes to different C++ mutators depending on where it started: the\n // candle area (chart scroll / crosshair move), the y-axis strip (price\n // scale), the x-axis strip (time scale), the indicator pane (horizontal\n // scroll only), or a draggable price line. We classify on onStart.\n const panMode = useRef<\n 'chart' | 'price-axis' | 'time-axis' | 'indicator' | 'price-line'\n >('chart');\n\n const pan = Gesture.Pan()\n .runOnJS(true)\n .maxPointers(1) // don't fight Pinch's two-finger gesture\n .onStart((e) => {\n cancelDecay();\n // Always classify — an axis drag controls the axis even while the\n // crosshair is up. Only a chart-area drag interacts with the crosshair.\n panMode.current = hitAxis(e.x, e.y);\n // A draggable price line takes the drag over from the chart. Seeding the\n // preview at the committed price puts the label in drag styling before the\n // first move, so the grab registers immediately.\n priceDrag.current = null;\n if (handle && panMode.current === 'chart' && !crosshairActive.current) {\n const pl = hitPriceLine(e.x, e.y);\n if (pl && pl.part === 0) {\n panMode.current = 'price-line';\n priceDrag.current = { index: pl.index, id: pl.line.id, price: pl.line.price };\n handle.setPriceLineDrag(pl.index, pl.line.price);\n const p = handle.render();\n if (p) pictureSV.value = p;\n }\n }\n })\n .onChange((e) => {\n if (!handle) return;\n let next: ReturnType<typeof handle.pan> = null;\n if (panMode.current === 'price-axis') {\n next = handle.scalePriceAxis(e.changeY);\n } else if (panMode.current === 'time-axis') {\n next = handle.scaleTimeAxis(e.changeX);\n } else if (panMode.current === 'indicator') {\n // Drag in an indicator pane scrolls the candles horizontally only —\n // no vertical price slide (the pane's scale is fixed).\n next = handle.pan(e.changeX, 0);\n } else if (panMode.current === 'price-line') {\n // Preview the price under the finger; nothing is committed until the drop.\n const g = priceDrag.current;\n if (!g) return;\n const c = handle.coordAt(e.x, e.y);\n if (!c) return;\n g.price = c.price;\n handle.setPriceLineDrag(g.index, c.price);\n onPriceLineDrag?.(g.id, c.price);\n next = handle.render();\n } else if (crosshairActive.current) {\n // Chart area + crosshair up → the drag moves the crosshair instead of\n // scrolling. Vertical line tracks the finger x; the dot/horizontal line\n // stay lifted `crosshairOffset` px above the fingertip.\n const ch = handle.setCrosshair(e.x, e.y - crosshairOffset);\n if (ch) pictureSV.value = ch;\n // The line follows the finger every frame (above), but only notify the\n // host when the snapped slot actually changes. The slot has a timeMs\n // even in the empty space ahead of the last candle, where candle=null.\n const info = handle.getCrosshairInfo();\n const t = info?.timeMs ?? null;\n if (t !== lastCrosshairTime.current) {\n lastCrosshairTime.current = t;\n // price is web-only for now (see @vroomchart/react); RN reports null.\n onCrosshair?.({ active: true, candle: info?.candle ?? null, timeMs: t, price: null, reason: 'move' });\n }\n return;\n } else {\n // Chart area: 1-finger drag translates both axes. Horizontal\n // component scrolls time, vertical component slides price bounds\n // (axes follow). Diagonal works naturally.\n next = handle.translate(e.changeX, e.changeY);\n }\n if (next) pictureSV.value = next;\n maybeStartAnim();\n })\n .onEnd((e) => {\n if (!handle) return;\n // Price-line drop. The preview always clears here: the line is a controlled\n // prop, so it only really moves once the host restates it — which means a\n // rejected (or ignored) move reverts on its own.\n if (panMode.current === 'price-line') {\n const g = priceDrag.current;\n priceDrag.current = null;\n handle.setPriceLineDrag(-1, 0);\n const p = handle.render();\n if (p) pictureSV.value = p;\n if (g) onPriceLineDragEnd?.(g.id, g.price);\n return;\n }\n // A chart-area drag with the crosshair up just moved the crosshair —\n // nothing about the viewport changed, and no momentum.\n if (panMode.current === 'chart' && crosshairActive.current) return;\n onViewportChange?.(0, 0);\n\n // Axis drags don't get momentum — they're a precise size adjustment.\n // Chart and indicator-pane drags both get horizontal fling momentum.\n if (panMode.current !== 'chart' && panMode.current !== 'indicator') return;\n\n let velocity = e.velocityX; // px/s\n const MIN_LAUNCH = 80; // ignore tiny flicks\n const MIN_STOP = 8; // px/s — stop threshold\n const HALF_LIFE_S = 0.35; // velocity halves every 0.35s\n if (Math.abs(velocity) < MIN_LAUNCH) return;\n\n let lastTime = performance.now();\n const tick = () => {\n const now = performance.now();\n const dt = (now - lastTime) / 1000;\n lastTime = now;\n\n // Frame-time-independent exponential decay.\n velocity *= Math.pow(0.5, dt / HALF_LIFE_S);\n const dx = velocity * dt;\n const next = handle.pan(dx, 0);\n if (next) pictureSV.value = next;\n maybeStartAnim();\n\n if (Math.abs(velocity) > MIN_STOP) {\n decayRaf.current = requestAnimationFrame(tick);\n } else {\n decayRaf.current = null;\n }\n };\n decayRaf.current = requestAnimationFrame(tick);\n });\n\n // Directional pinch. A single Pinch scale is uniform, so we read the two\n // touch points and track their horizontal/vertical spans independently: a\n // vertical pinch scales price (y), a horizontal pinch scales the time window\n // (x), and a diagonal pinch does both. An axis whose initial span is tiny\n // (fingers ~collinear on that axis) is left alone.\n // Lock the scalable axes at gesture start by orientation: an axis only\n // scales if its initial span is meaningful AND at least AXIS_RATIO of the\n // other axis. This keeps a vertical pinch from ever touching x (and vice\n // versa) — critical because during a vertical pinch the fingers' x-coords\n // drift and cross, sending spanX through ~0 and otherwise exploding frameX.\n const MIN_SPAN = 24; // px — minimum span for an axis to scale at all\n const AXIS_RATIO = 0.5; // axis scales only if its span ≥ this × the other's\n const pinchStart = useRef({\n spanX: 1,\n spanY: 1,\n ratioX: 1,\n ratioY: 1,\n enableX: false,\n enableY: false,\n });\n const pinch = Gesture.Pinch()\n .runOnJS(true)\n .onTouchesDown((e) => {\n if (e.numberOfTouches < 2) return;\n const [a, b] = e.allTouches;\n const spanX = Math.abs(a.x - b.x);\n const spanY = Math.abs(a.y - b.y);\n pinchStart.current = {\n spanX,\n spanY,\n ratioX: 1,\n ratioY: 1,\n enableX: spanX >= MIN_SPAN && spanX >= spanY * AXIS_RATIO,\n enableY: spanY >= MIN_SPAN && spanY >= spanX * AXIS_RATIO,\n };\n })\n .onTouchesMove((e) => {\n if (!handle || crosshairActive.current) return;\n if (e.numberOfTouches < 2) return;\n const [a, b] = e.allTouches;\n const start = pinchStart.current;\n const focalX = (a.x + b.x) * 0.5;\n const focalY = (a.y + b.y) * 0.5;\n\n // Per-frame factor = current cumulative ratio / previous. Floor the\n // current span at MIN_SPAN so a near-zero span (fingers crossing on that\n // axis) can't blow the ratio up.\n let frameX = 1;\n if (start.enableX) {\n const ratioX = Math.max(Math.abs(a.x - b.x), MIN_SPAN) / start.spanX;\n frameX = ratioX / start.ratioX;\n start.ratioX = ratioX;\n }\n let frameY = 1;\n if (start.enableY) {\n const ratioY = Math.max(Math.abs(a.y - b.y), MIN_SPAN) / start.spanY;\n frameY = ratioY / start.ratioY;\n start.ratioY = ratioY;\n }\n if (frameX === 1 && frameY === 1) return;\n\n const next = handle.zoom(frameX, frameY, focalX, focalY);\n if (next) pictureSV.value = next;\n maybeStartAnim();\n });\n\n // Long press shows the crosshair at the press point. A stationary hold never\n // activates `pan` (it needs movement first), so the chart won't scroll under\n // the hold. The dot/horizontal line are lifted above the fingertip.\n const longPress = Gesture.LongPress()\n .runOnJS(true)\n .onStart((e) => {\n if (!handle) return;\n // A long press on an axis strip controls the axis, never the crosshair.\n if (hitAxis(e.x, e.y) !== 'chart') return;\n // A press on a price line belongs to that line — dragging it or tapping its\n // close button — so it must not raise the crosshair over the top.\n if (hitPriceLine(e.x, e.y)) return;\n cancelDecay();\n crosshairActive.current = true;\n const ch = handle.setCrosshair(e.x, e.y - crosshairOffset);\n if (ch) pictureSV.value = ch;\n const info = handle.getCrosshairInfo();\n lastCrosshairTime.current = info?.timeMs ?? null;\n onCrosshair?.({\n active: true,\n candle: info?.candle ?? null,\n timeMs: info?.timeMs ?? null,\n price: null, // web-only for now (see @vroomchart/react)\n reason: 'show',\n });\n });\n\n // A tap activates a price line's close button, and otherwise dismisses the\n // crosshair while it's up. Any other tap is a no-op, so it never interferes\n // with normal pan/pinch.\n const tap = Gesture.Tap()\n .runOnJS(true)\n .onStart((e) => {\n if (!handle) return;\n // The close button is a tap target whether or not the crosshair is up.\n const pl = hitPriceLine(e.x, e.y);\n if (pl && pl.part === 1) {\n onPriceLineClose?.(pl.line.id);\n return;\n }\n if (!crosshairActive.current) return;\n // A tap on an axis strip controls the axis, never dismisses the crosshair.\n if (hitAxis(e.x, e.y) !== 'chart') return;\n crosshairActive.current = false;\n const ch = handle.clearCrosshair();\n if (ch) pictureSV.value = ch;\n lastCrosshairTime.current = null;\n onCrosshair?.({ active: false, candle: null, timeMs: null, price: null, reason: 'hide' });\n });\n\n const gesture = Gesture.Simultaneous(pan, pinch, longPress, tap);\n\n return (\n <GestureHandlerRootView\n onLayout={onLayout}\n style={[\n { width: widthProp, height: heightProp },\n widthProp == null && heightProp == null ? { flex: 1 } : null,\n style,\n ]}\n >\n <GestureDetector gesture={gesture}>\n <View style={{ flex: 1 }}>\n <Canvas style={{ flex: 1 }}>\n {width > 0 && height > 0 ? (\n // pictureSV is always a valid picture (seeded empty, never null),\n // so RN-Skia's UI-thread reader never sees null.\n <Picture picture={pictureSV} />\n ) : null}\n </Canvas>\n </View>\n </GestureDetector>\n </GestureHandlerRootView>\n );\n}\n","import { useEffect, useRef, useState } from 'react';\nimport type { MutableRefObject } from 'react';\nimport type { SkPicture } from '@shopify/react-native-skia';\n\nimport NativeVroomChart from './NativeVroomChart';\nimport type { ChartHandle } from './jsi.d';\nimport { packCandles } from './packCandles';\nimport { applyTheme, parseColor } from './theme';\nimport type {\n BollingerBandsConfig,\n Candle,\n ChartType,\n MACDConfig,\n MovingAverageOverlay,\n PriceLine,\n PriceLinesStyle,\n RSIConfig,\n VisibleRange,\n VolumeConfig,\n VroomTheme,\n VWAPConfig,\n} from './types';\n\n// Mirrors vroom::ma::Source order in packages/core/src/ma.h.\nconst MA_SOURCES = [\n 'close',\n 'open',\n 'high',\n 'low',\n 'hl2',\n 'hlc3',\n 'ohlc4',\n] as const;\n\n// An unset style color marshals as the core's transparent inherit sentinel.\nconst inheritColor = (v: string | number | undefined): number =>\n (v != null ? parseColor(v) : null) ?? 0;\n\nfunction overlayToNumeric(o: MovingAverageOverlay) {\n const srcIdx = o.source ? MA_SOURCES.indexOf(o.source) : 0;\n return {\n kind: o.maType === 'ema' ? 1 : 0,\n period: o.period,\n source: srcIdx < 0 ? 0 : srcIdx,\n color: (o.color != null ? parseColor(o.color) : null) ?? 0xff2962ff,\n width: o.width ?? 1.5,\n };\n}\n\nfunction rsiToSpec(cfg: RSIConfig | undefined) {\n return {\n enabled: cfg?.enabled ?? false,\n period: cfg?.period ?? 14,\n upperBand: cfg?.upperBand ?? 70,\n lowerBand: cfg?.lowerBand ?? 30,\n maPeriod: cfg?.maPeriod ?? 14,\n maKind: cfg?.maType === 'ema' ? 1 : 0,\n maVisible: cfg?.maVisible ?? true,\n lineColor: inheritColor(cfg?.lineColor),\n lineWidth: cfg?.lineWidth ?? -1,\n lineVisible: cfg?.lineVisible ?? true,\n maColor: inheritColor(cfg?.maColor),\n maWidth: cfg?.maWidth ?? -1,\n bandColor: inheritColor(cfg?.bandColor),\n bandsVisible: cfg?.bandsVisible ?? true,\n };\n}\n\nfunction vwapToSpec(cfg: VWAPConfig | undefined) {\n return {\n enabled: cfg?.enabled ?? false,\n resetOffsetMin: cfg?.resetMinutes ?? 0,\n color: inheritColor(cfg?.color),\n width: cfg?.width ?? -1,\n };\n}\n\n// Bollinger defaults: blue bands / orange basis, matching the repo palette.\nconst DEFAULT_BB_BAND_COLOR = 0xff2962ff;\nconst DEFAULT_BB_BASIS_COLOR = 0xffff6d00;\n\nfunction bollingerToSpec(cfg: BollingerBandsConfig | undefined) {\n const srcIdx = cfg?.source ? MA_SOURCES.indexOf(cfg.source) : 0;\n return {\n enabled: cfg?.enabled ?? false,\n period: cfg?.period ?? 20,\n mult: cfg?.stdDev ?? 2,\n source: srcIdx < 0 ? 0 : srcIdx,\n basisKind: cfg?.maType === 'ema' ? 1 : 0,\n upperColor:\n (cfg?.upperColor != null ? parseColor(cfg.upperColor) : null) ??\n DEFAULT_BB_BAND_COLOR,\n upperWidth: cfg?.upperWidth ?? 1,\n middleColor:\n (cfg?.middleColor != null ? parseColor(cfg.middleColor) : null) ??\n DEFAULT_BB_BASIS_COLOR,\n middleWidth: cfg?.middleWidth ?? 1,\n lowerColor:\n (cfg?.lowerColor != null ? parseColor(cfg.lowerColor) : null) ??\n DEFAULT_BB_BAND_COLOR,\n lowerWidth: cfg?.lowerWidth ?? 1,\n fillEnabled: cfg?.fillVisible ?? true,\n fillOpacity: cfg?.fillOpacity ?? 0.1,\n };\n}\n\nfunction macdToSpec(cfg: MACDConfig | undefined) {\n const srcIdx = cfg?.source ? MA_SOURCES.indexOf(cfg.source) : 0;\n return {\n enabled: cfg?.enabled ?? false,\n fast: cfg?.fast ?? 12,\n slow: cfg?.slow ?? 26,\n signal: cfg?.signal ?? 9,\n source: srcIdx < 0 ? 0 : srcIdx,\n maKind: cfg?.maType === 'sma' ? 0 : 1,\n signalMaKind: cfg?.signalMaType === 'sma' ? 0 : 1,\n lineColor: inheritColor(cfg?.lineColor),\n lineWidth: cfg?.lineWidth ?? -1,\n lineVisible: cfg?.lineVisible ?? true,\n signalColor: inheritColor(cfg?.signalColor),\n signalWidth: cfg?.signalWidth ?? -1,\n signalVisible: cfg?.signalVisible ?? true,\n histVisible: cfg?.histogramVisible ?? true,\n histUpColor: inheritColor(cfg?.histogramUpColor),\n histUpFadingColor: inheritColor(cfg?.histogramUpFadingColor),\n histDownColor: inheritColor(cfg?.histogramDownColor),\n histDownFadingColor: inheritColor(cfg?.histogramDownFadingColor),\n zeroColor: inheritColor(cfg?.zeroLineColor),\n zeroVisible: cfg?.zeroLineVisible ?? true,\n };\n}\n\n// Unset style fields go down as the core's inherit sentinels (negative float,\n// transparent color) rather than as literal defaults, so the theme keys stay in\n// charge of anything the consumer didn't set.\nfunction volumeToSpec(cfg: VolumeConfig | undefined) {\n return {\n enabled: cfg?.enabled ?? true,\n heightFrac: cfg?.height ?? -1,\n opacity: cfg?.opacity ?? -1,\n radiusPx: cfg?.radius ?? -1,\n upColor: (cfg?.upColor != null ? parseColor(cfg.upColor) : null) ?? 0,\n downColor: (cfg?.downColor != null ? parseColor(cfg.downColor) : null) ?? 0,\n };\n}\n\n// Price-line defaults: a soft red dotted rule with a dark translucent label,\n// close in weight to the current-price indicator it sits beside.\nconst DEFAULT_PRICE_LINE_COLOR = 0xffef5350;\nconst DEFAULT_PRICE_LINE_BODY_BG = 0xd91c2128;\nconst DEFAULT_PRICE_LINE_HOVER_BOOST = 1.25;\n\nconst LINE_STYLES = { solid: 0, dotted: 1, dashed: 2 } as const;\n\n// Mirrors VroomPriceLineFlags in packages/core/include/vroom/vroom_chart.h.\nconst PRICE_LINE_DRAGGABLE = 1 << 0;\nconst PRICE_LINE_CLOSABLE = 1 << 1;\nconst PRICE_LINE_AXIS_LABEL = 1 << 2;\nconst PRICE_LINE_EXTEND_LEFT = 1 << 3;\n\n/** The price lines + their shared style, as the chart's props express them. */\nexport type PriceLinesProp = {\n lines: PriceLine[];\n style?: PriceLinesStyle;\n /**\n * Whether the host supplied a close handler. The close button is\n * callback-gated, so with nothing for it to do it isn't drawn at all.\n */\n hasCloseHandler: boolean;\n};\n\nfunction priceLinesToSpec(cfg: PriceLinesProp) {\n return {\n lines: cfg.lines.map((l) => ({\n price: l.price,\n color:\n (l.color != null ? parseColor(l.color) : null) ?? DEFAULT_PRICE_LINE_COLOR,\n width: l.width ?? 1,\n lineStyle: LINE_STYLES[l.lineStyle ?? 'dotted'],\n text: l.text ?? '',\n quantity: l.quantity ?? '',\n flags:\n (l.draggable ? PRICE_LINE_DRAGGABLE : 0) |\n (cfg.hasCloseHandler && l.closable !== false ? PRICE_LINE_CLOSABLE : 0) |\n (l.axisLabel !== false ? PRICE_LINE_AXIS_LABEL : 0) |\n (l.extendLeft !== false ? PRICE_LINE_EXTEND_LEFT : 0),\n })),\n bodyBg:\n (cfg.style?.bodyBackground != null ? parseColor(cfg.style.bodyBackground) : null) ??\n DEFAULT_PRICE_LINE_BODY_BG,\n fontSizePx: cfg.style?.fontSize ?? 0,\n lineLengthFrac: cfg.style?.inset ?? 0,\n align: cfg.style?.align === 'left' ? 0 : cfg.style?.align === 'center' ? 1 : 2,\n hoverBoost: cfg.style?.hoverBoost ?? DEFAULT_PRICE_LINE_HOVER_BOOST,\n };\n}\n\n// Cleared overlay: no lines (the style values are irrelevant, but the spec shape\n// requires them).\nconst EMPTY_PRICE_LINES = priceLinesToSpec({ lines: [], hasCloseHandler: false });\n\nlet installed = false;\nfunction ensureInstalled(): void {\n if (installed) return;\n const ok = NativeVroomChart.install();\n if (!ok) throw new Error('VroomChartModule.install() returned false');\n if (typeof globalThis.VroomChartJSI === 'undefined') {\n throw new Error('global.VroomChartJSI undefined after install()');\n }\n installed = true;\n}\n\n/** Progress + curve of the staggered volume-bar collapse. See setVolumeCollapse. */\nexport type VolumeCollapse = { t: number; easing: number };\n\nexport type ChartCoreState = {\n handle: ChartHandle | null;\n /** Picture freshly rendered after the latest data/size/range push. */\n picture: SkPicture | null;\n /**\n * The last volume collapse handed to the core, or null before the first push.\n * VroomChart's animation loop owns this — it lives here only so the data effect\n * can restore it, since setVolume snaps the scalar (see below).\n */\n volumeCollapseRef: MutableRefObject<VolumeCollapse | null>;\n};\n\n// Owns a ChartHandle and produces an \"initial\" picture whenever data, size,\n// or the externally-controlled visible range changes. Gesture-driven updates\n// happen outside this hook by calling handle.pan(...) directly and assigning\n// the result into a SharedValue.\nexport function useChartCore(\n candles: Candle[],\n size: { width: number; height: number; pxRatio?: number },\n visibleRange?: VisibleRange,\n defaultCandleWidth?: number,\n chartType?: ChartType,\n theme?: VroomTheme,\n rsi?: RSIConfig,\n macd?: MACDConfig,\n movingAverages?: MovingAverageOverlay[],\n vwap?: VWAPConfig,\n bollingerBands?: BollingerBandsConfig,\n volume?: VolumeConfig,\n priceLines?: PriceLinesProp,\n): ChartCoreState {\n const handleRef = useRef<ChartHandle | null>(null);\n // Push setDefaultCandleWidth only once (first load): setCandles re-runs on\n // every data change, and the core setter re-frames when candles are present,\n // so re-pushing would snap the view away from the user's pan/zoom.\n const defaultWidthAppliedRef = useRef(false);\n const volumeCollapseRef = useRef<VolumeCollapse | null>(null);\n const [picture, setPicture] = useState<SkPicture | null>(null);\n\n if (!handleRef.current && size.width > 0 && size.height > 0) {\n ensureInstalled();\n handleRef.current = globalThis.VroomChartJSI!.create();\n }\n\n // When no visibleRange is provided, leave the range entirely to the C++\n // side (which defaults to a sensible recent window on first setCandles).\n // Only push setVisibleRange when the caller is actively controlling it,\n // so it doesn't clobber the default or fight gesture-driven pans.\n const explicit = visibleRange != null;\n const startMs = visibleRange?.startMs ?? 0;\n const endMs = visibleRange?.endMs ?? 0;\n\n // Stable deps so inline `theme={{...}}` / `rsi={{...}}` literals don't re-run\n // the effect every render — only when the actual values change.\n const themeKey = theme ? JSON.stringify(theme) : '';\n const rsiKey = rsi ? JSON.stringify(rsi) : '';\n const macdKey = macd ? JSON.stringify(macd) : '';\n const maKey = movingAverages ? JSON.stringify(movingAverages) : '';\n const vwapKey = vwap ? JSON.stringify(vwap) : '';\n const bollingerKey = bollingerBands ? JSON.stringify(bollingerBands) : '';\n const volumeKey = volume ? JSON.stringify(volume) : '';\n const priceLinesKey = priceLines ? JSON.stringify(priceLines) : '';\n\n useEffect(() => {\n const h = handleRef.current;\n if (!h) return;\n h.setSize(size.width, size.height, size.pxRatio ?? 1);\n // Drive the initial zoom from a target candle width. Pushed once, before the\n // first setCandles (while the core window is still 0/0), and only when the\n // caller isn't explicitly controlling the range.\n if (\n !defaultWidthAppliedRef.current &&\n !explicit &&\n defaultCandleWidth != null &&\n defaultCandleWidth > 0\n ) {\n h.setDefaultCandleWidth(defaultCandleWidth);\n defaultWidthAppliedRef.current = true;\n }\n if (candles.length > 0) {\n h.setCandles(packCandles(candles));\n }\n if (explicit) {\n h.setVisibleRange(startMs, endMs);\n }\n // chartType / the candle↔line morph is driven separately (VroomChart owns the\n // per-frame animation loop so it can update the picture SharedValue directly).\n if (theme) {\n applyTheme(h, theme);\n }\n h.setRSI(rsiToSpec(rsi));\n h.setMACD(macdToSpec(macd));\n h.setOverlays((movingAverages ?? []).map(overlayToNumeric));\n h.setVWAP(vwapToSpec(vwap));\n h.setBollinger(bollingerToSpec(bollingerBands));\n h.setVolume(volumeToSpec(volume));\n // setVolume snaps the collapse scalar to its `enabled`, which would cut a\n // toggle animation short whenever this effect re-runs (a streaming candle, a\n // resize). Hand the in-flight value back; VroomChart's loop drives it from\n // there.\n const collapse = volumeCollapseRef.current;\n if (collapse) h.setVolumeCollapse(collapse.t, collapse.easing);\n h.setPriceLines(\n priceLines?.lines.length ? priceLinesToSpec(priceLines) : EMPTY_PRICE_LINES,\n );\n // TODO(rn-parity): mirror the web `liquidity` overlay here (setLiquidity +\n // the VroomBand structs in the JSI handle) — web-only for now.\n setPicture(h.render());\n // theme/rsi/macd/movingAverages/vwap/bollingerBands/volume/priceLines are\n // represented by their *Key deps.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [candles, size.width, size.height, size.pxRatio, explicit, startMs, endMs, defaultCandleWidth, themeKey, rsiKey, macdKey, maKey, vwapKey, bollingerKey, volumeKey, priceLinesKey]);\n\n return { handle: handleRef.current, picture, volumeCollapseRef };\n}\n","import type { TurboModule } from 'react-native';\nimport { TurboModuleRegistry } from 'react-native';\n\n// TurboModule spec consumed by codegen. The only method is `install`, which\n// the native side uses to install the `global.VroomChartJSI` host object the\n// first time it's called from JS. All real chart operations go through that\n// host object, not through the TurboModule itself.\nexport interface Spec extends TurboModule {\n install(): boolean;\n}\n\nexport default TurboModuleRegistry.getEnforcing<Spec>('VroomChartModule');\n","import type { Candle } from './types';\n\n// Wire format must match `VroomCandle` in packages/core/include/vroom/vroom_chart.h:\n// int64_t time_ms; double open, high, low, close, volume;\n// = 48 bytes per candle, 8-byte aligned, little-endian on iOS/Android.\nexport const BYTES_PER_CANDLE = 48;\n\n// Serializes candles into the packed little-endian buffer the C++ core expects.\n// Pure (no native/Skia deps) so it can be unit-tested in isolation.\nexport function packCandles(candles: Candle[]): ArrayBuffer {\n const buf = new ArrayBuffer(candles.length * BYTES_PER_CANDLE);\n const view = new DataView(buf);\n for (let i = 0; i < candles.length; i++) {\n const c = candles[i]!;\n const off = i * BYTES_PER_CANDLE;\n view.setBigInt64(off, BigInt(c.timeMs), true);\n view.setFloat64(off + 8, c.open, true);\n view.setFloat64(off + 16, c.high, true);\n view.setFloat64(off + 24, c.low, true);\n view.setFloat64(off + 32, c.close, true);\n view.setFloat64(off + 40, c.volume, true);\n }\n return buf;\n}\n","import type { ChartHandle } from './jsi.d';\nimport type { VroomColor, VroomTheme } from './types';\n\n// Maps each color VroomTheme field to its VroomColorKey index in the C++ enum\n// (packages/core/include/vroom/vroom_chart.h). Keep in sync with that enum;\n// new keys are appended there so existing indices never shift.\nexport const COLOR_KEYS: Partial<Record<keyof VroomTheme, number>> = {\n background: 0, // VROOM_COLOR_BACKGROUND\n bull: 1, // VROOM_COLOR_BULL\n bear: 2, // VROOM_COLOR_BEAR\n grid: 4, // VROOM_COLOR_GRID\n axisText: 5, // VROOM_COLOR_AXIS_TEXT\n crosshair: 6, // VROOM_COLOR_CROSSHAIR\n crosshairTarget: 9, // VROOM_COLOR_CROSSHAIR_TARGET\n borderBull: 10, // VROOM_COLOR_BORDER_BULL\n borderBear: 11, // VROOM_COLOR_BORDER_BEAR\n wickBull: 12, // VROOM_COLOR_WICK_BULL\n wickBear: 13, // VROOM_COLOR_WICK_BEAR\n accentBull: 14, // VROOM_COLOR_ACCENT_BULL\n accentBear: 15, // VROOM_COLOR_ACCENT_BEAR\n lineColor: 16, // VROOM_COLOR_LINE\n};\n\n// Maps each numeric VroomTheme field to its VroomFloatKey index.\nexport const FLOAT_KEYS: Partial<Record<keyof VroomTheme, number>> = {\n wickWidth: 1, // VROOM_FLOAT_WICK_WIDTH_PX\n candleRadius: 8, // VROOM_FLOAT_CANDLE_RADIUS_PX\n volumeRadius: 10, // VROOM_FLOAT_VOLUME_RADIUS_PX\n lineWidth: 11, // VROOM_FLOAT_LINE_WIDTH_PX\n lineGradientOpacity: 12, // VROOM_FLOAT_LINE_GRADIENT_OPACITY\n};\n\n// Maps each boolean VroomTheme field to its VroomFloatKey index (pushed as 0/1).\nexport const BOOL_KEYS: Partial<Record<keyof VroomTheme, number>> = {\n wickRoundCap: 9, // VROOM_FLOAT_WICK_ROUND_CAP\n};\n\n// Parses a color into a packed 0xAARRGGBB integer (Skia's ARGB order).\n// - number → taken as already-packed ARGB\n// - '#rgb'-style 6-digit hex → opaque (alpha forced to ff)\n// - 8-digit hex → interpreted as AARRGGBB\n// Returns null for anything malformed so the caller can skip it.\nexport function parseColor(value: VroomColor): number | null {\n if (typeof value === 'number') {\n return Number.isFinite(value) ? value >>> 0 : null;\n }\n let s = value.trim();\n if (s.startsWith('#')) s = s.slice(1);\n if (s.length === 6) s = `ff${s}`; // assume opaque\n if (s.length !== 8 || !/^[0-9a-fA-F]{8}$/.test(s)) return null;\n return parseInt(s, 16) >>> 0;\n}\n\n// Pushes every provided theme color + numeric float into the chart core via\n// handle.setColor / handle.setFloat. Unspecified or unparseable values are\n// skipped (they keep their default).\nexport function applyTheme(handle: ChartHandle, theme: VroomTheme): void {\n (Object.keys(COLOR_KEYS) as (keyof VroomTheme)[]).forEach((field) => {\n const value = theme[field];\n if (typeof value !== 'string' && typeof value !== 'number') return;\n const argb = parseColor(value);\n if (argb == null) return;\n handle.setColor(COLOR_KEYS[field]!, argb);\n });\n (Object.keys(FLOAT_KEYS) as (keyof VroomTheme)[]).forEach((field) => {\n const value = theme[field];\n if (typeof value !== 'number' || !Number.isFinite(value)) return;\n handle.setFloat(FLOAT_KEYS[field]!, value);\n });\n (Object.keys(BOOL_KEYS) as (keyof VroomTheme)[]).forEach((field) => {\n const value = theme[field];\n if (typeof value !== 'boolean') return;\n handle.setFloat(BOOL_KEYS[field]!, value ? 1 : 0);\n });\n}\n","// Mirror of packages/react/src/easing.ts — the platform packages don't depend on\n// each other, and @vroomchart/types carries types only.\n\nimport type { TransitionEasing } from '@vroomchart/types';\n\n/**\n * Maps linear animation progress (0..1) to eased progress (0..1) for the chart's\n * transitions. Unknown values fall back to `'ease-in-out'`, which is a\n * smoothstep — the curve the candle↔line transition has always used.\n */\nexport function ease(kind: TransitionEasing | undefined, p: number): number {\n switch (kind) {\n case 'linear':\n return p;\n case 'ease-in':\n return p * p;\n case 'ease-out':\n return p * (2 - p);\n default:\n return p * p * (3 - 2 * p);\n }\n}\n\n// Index order matches VroomEasing in vroom_chart.h.\nconst EASINGS: readonly TransitionEasing[] = [\n 'linear',\n 'ease-in',\n 'ease-out',\n 'ease-in-out',\n];\n\n/**\n * The curve as a `VroomEasing` index, for the animations the core paces itself\n * (see `setVolumeCollapse`) rather than taking pre-eased progress. Falls back to\n * `'ease-in-out'`, matching {@link ease}.\n */\nexport function easingIndex(kind: TransitionEasing | undefined): number {\n const i = kind ? EASINGS.indexOf(k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M,EAAE,KACtB,QAAQ,KAAK,SAAS;AAAA;AAAA;AAAA,MAGrB,oCAAC,WAAQ,SAAS,WAAW;AAAA,QAC3B,IACN,CACF,CACF;AAAA,EACF;AAEJ;","names":["useEffect","useRef","useState","useState","useRef","useEffect"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-vroom-chart",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Mobile-first Skia candlestick chart for React Native",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Darion Welch",
|
|
@@ -71,8 +71,8 @@
|
|
|
71
71
|
"react": "19.1.0",
|
|
72
72
|
"react-native": "0.81.5",
|
|
73
73
|
"react-native-gesture-handler": "~2.28.0",
|
|
74
|
-
"react-native-reanimated": "~4.
|
|
75
|
-
"react-native-worklets": "0.
|
|
74
|
+
"react-native-reanimated": "~4.5.3",
|
|
75
|
+
"react-native-worklets": "0.11.3",
|
|
76
76
|
"tsup": "^8.5.1",
|
|
77
77
|
"typescript": "~5.9.2",
|
|
78
78
|
"vitest": "^3.2.6",
|
package/src/VroomChart.tsx
CHANGED
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
import { useSharedValue } from 'react-native-reanimated';
|
|
22
22
|
|
|
23
23
|
import { useChartCore } from './useChartCore';
|
|
24
|
+
import { ease, easingIndex } from './easing';
|
|
24
25
|
import type { VroomChartProps } from './types';
|
|
25
26
|
import './jsi.d';
|
|
26
27
|
|
|
@@ -43,12 +44,14 @@ export function VroomChart(props: VroomChartProps) {
|
|
|
43
44
|
defaultCandleWidth,
|
|
44
45
|
chartType,
|
|
45
46
|
transitionMs,
|
|
47
|
+
transitionEasing,
|
|
46
48
|
theme,
|
|
47
49
|
rsi,
|
|
48
50
|
macd,
|
|
49
51
|
movingAverages,
|
|
50
52
|
vwap,
|
|
51
53
|
bollingerBands,
|
|
54
|
+
volume,
|
|
52
55
|
crosshairOffset = 40,
|
|
53
56
|
onCrosshair,
|
|
54
57
|
onViewportChange,
|
|
@@ -88,7 +91,7 @@ export function VroomChart(props: VroomChartProps) {
|
|
|
88
91
|
[priceLines, priceLinesStyle, onPriceLineClose],
|
|
89
92
|
);
|
|
90
93
|
|
|
91
|
-
const { handle, picture } = useChartCore(
|
|
94
|
+
const { handle, picture, volumeCollapseRef } = useChartCore(
|
|
92
95
|
candles,
|
|
93
96
|
{ width, height },
|
|
94
97
|
visibleRange,
|
|
@@ -100,6 +103,7 @@ export function VroomChart(props: VroomChartProps) {
|
|
|
100
103
|
movingAverages,
|
|
101
104
|
vwap,
|
|
102
105
|
bollingerBands,
|
|
106
|
+
volume,
|
|
103
107
|
priceLinesProp,
|
|
104
108
|
);
|
|
105
109
|
|
|
@@ -179,6 +183,9 @@ export function VroomChart(props: VroomChartProps) {
|
|
|
179
183
|
const morphRaf = useRef<number | null>(null);
|
|
180
184
|
const morphFade = useRef<number | null>(null);
|
|
181
185
|
const morphHandle = useRef<typeof handle>(null);
|
|
186
|
+
// In a ref so changing the curve mid-animation doesn't restart the clock.
|
|
187
|
+
const easingRef = useRef(transitionEasing);
|
|
188
|
+
easingRef.current = transitionEasing;
|
|
182
189
|
useEffect(() => {
|
|
183
190
|
if (!handle) return undefined;
|
|
184
191
|
const target = chartType === 'line' ? 1 : 0;
|
|
@@ -212,8 +219,7 @@ export function VroomChart(props: VroomChartProps) {
|
|
|
212
219
|
const step = (now: number) => {
|
|
213
220
|
if (startTs == null) startTs = now;
|
|
214
221
|
const prog = Math.min(1, (now - startTs) / dur);
|
|
215
|
-
const
|
|
216
|
-
const fade = from + (target - from) * e;
|
|
222
|
+
const fade = from + (target - from) * ease(easingRef.current, prog);
|
|
217
223
|
morphFade.current = fade;
|
|
218
224
|
handle.setMorph(fade, fade);
|
|
219
225
|
const p = handle.render();
|
|
@@ -238,6 +244,66 @@ export function VroomChart(props: VroomChartProps) {
|
|
|
238
244
|
};
|
|
239
245
|
}, [handle, chartType, transitionMs, pictureSV]);
|
|
240
246
|
|
|
247
|
+
// Volume-bar collapse. The core staggers the bars itself — tallest falling
|
|
248
|
+
// first, all landing together — so unlike the loop above this one hands it
|
|
249
|
+
// *linear* progress plus the curve; pre-easing here would compound the two.
|
|
250
|
+
// Hiding drives 0→1, revealing 1→0, which is the same cascade backwards.
|
|
251
|
+
// Mirrors the web driver in react/src/useChartCore.ts.
|
|
252
|
+
const volumeRaf = useRef<number | null>(null);
|
|
253
|
+
const volumeHandle = useRef<typeof handle>(null);
|
|
254
|
+
useEffect(() => {
|
|
255
|
+
if (!handle) return undefined;
|
|
256
|
+
const target = (volume?.enabled ?? true) ? 0 : 1;
|
|
257
|
+
const easing = easingIndex(easingRef.current);
|
|
258
|
+
|
|
259
|
+
// Fresh handle (first load / recreate): the data effect's setVolume already
|
|
260
|
+
// snapped it, so a chart that mounts with bars doesn't animate them in.
|
|
261
|
+
if (volumeHandle.current !== handle || volumeCollapseRef.current == null) {
|
|
262
|
+
volumeHandle.current = handle;
|
|
263
|
+
volumeCollapseRef.current = { t: target, easing };
|
|
264
|
+
return undefined;
|
|
265
|
+
}
|
|
266
|
+
if (volumeCollapseRef.current.t === target) return undefined;
|
|
267
|
+
|
|
268
|
+
if (volumeRaf.current != null) {
|
|
269
|
+
cancelAnimationFrame(volumeRaf.current);
|
|
270
|
+
volumeRaf.current = null;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
const dur = Math.max(0, transitionMs ?? 300);
|
|
274
|
+
if (dur === 0) {
|
|
275
|
+
volumeCollapseRef.current = { t: target, easing };
|
|
276
|
+
handle.setVolumeCollapse(target, easing);
|
|
277
|
+
const p = handle.render();
|
|
278
|
+
if (p) pictureSV.value = p;
|
|
279
|
+
return undefined;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
// From wherever the last frame left off, so toggling mid-flight reverses
|
|
283
|
+
// instead of jumping. A partial trip covers less ground in the same time.
|
|
284
|
+
const from = volumeCollapseRef.current.t;
|
|
285
|
+
let startTs: number | null = null;
|
|
286
|
+
const step = (now: number) => {
|
|
287
|
+
if (startTs == null) startTs = now;
|
|
288
|
+
const prog = Math.min(1, (now - startTs) / dur);
|
|
289
|
+
const t = prog < 1 ? from + (target - from) * prog : target;
|
|
290
|
+
const kind = easingIndex(easingRef.current);
|
|
291
|
+
volumeCollapseRef.current = { t, easing: kind };
|
|
292
|
+
handle.setVolumeCollapse(t, kind);
|
|
293
|
+
const p = handle.render();
|
|
294
|
+
if (p) pictureSV.value = p;
|
|
295
|
+
volumeRaf.current = prog < 1 ? requestAnimationFrame(step) : null;
|
|
296
|
+
};
|
|
297
|
+
volumeRaf.current = requestAnimationFrame(step);
|
|
298
|
+
|
|
299
|
+
return () => {
|
|
300
|
+
if (volumeRaf.current != null) {
|
|
301
|
+
cancelAnimationFrame(volumeRaf.current);
|
|
302
|
+
volumeRaf.current = null;
|
|
303
|
+
}
|
|
304
|
+
};
|
|
305
|
+
}, [handle, volume?.enabled, transitionMs, pictureSV, volumeCollapseRef]);
|
|
306
|
+
|
|
241
307
|
// Classifies a touch point into the candle area vs. an axis strip. Axis
|
|
242
308
|
// strips always own their gesture (scale price/time) and take priority over
|
|
243
309
|
// the crosshair: an axis touch never opens, moves, or dismisses it.
|
package/src/easing.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// Mirror of packages/react/src/easing.ts — the platform packages don't depend on
|
|
2
|
+
// each other, and @vroomchart/types carries types only.
|
|
3
|
+
|
|
4
|
+
import type { TransitionEasing } from '@vroomchart/types';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Maps linear animation progress (0..1) to eased progress (0..1) for the chart's
|
|
8
|
+
* transitions. Unknown values fall back to `'ease-in-out'`, which is a
|
|
9
|
+
* smoothstep — the curve the candle↔line transition has always used.
|
|
10
|
+
*/
|
|
11
|
+
export function ease(kind: TransitionEasing | undefined, p: number): number {
|
|
12
|
+
switch (kind) {
|
|
13
|
+
case 'linear':
|
|
14
|
+
return p;
|
|
15
|
+
case 'ease-in':
|
|
16
|
+
return p * p;
|
|
17
|
+
case 'ease-out':
|
|
18
|
+
return p * (2 - p);
|
|
19
|
+
default:
|
|
20
|
+
return p * p * (3 - 2 * p);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// Index order matches VroomEasing in vroom_chart.h.
|
|
25
|
+
const EASINGS: readonly TransitionEasing[] = [
|
|
26
|
+
'linear',
|
|
27
|
+
'ease-in',
|
|
28
|
+
'ease-out',
|
|
29
|
+
'ease-in-out',
|
|
30
|
+
];
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* The curve as a `VroomEasing` index, for the animations the core paces itself
|
|
34
|
+
* (see `setVolumeCollapse`) rather than taking pre-eased progress. Falls back to
|
|
35
|
+
* `'ease-in-out'`, matching {@link ease}.
|
|
36
|
+
*/
|
|
37
|
+
export function easingIndex(kind: TransitionEasing | undefined): number {
|
|
38
|
+
const i = kind ? EASINGS.indexOf(kind) : -1;
|
|
39
|
+
return i < 0 ? EASINGS.indexOf('ease-in-out') : i;
|
|
40
|
+
}
|
package/src/index.ts
CHANGED
package/src/jsi.d.ts
CHANGED
|
@@ -102,22 +102,53 @@ export interface ChartHandle {
|
|
|
102
102
|
} | null;
|
|
103
103
|
} | null;
|
|
104
104
|
/**
|
|
105
|
-
* Configures the RSI pane
|
|
106
|
-
*
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
maPeriod: number
|
|
115
|
-
|
|
105
|
+
* Configures the RSI pane. maKind mirrors setOverlays' kind encoding; colors
|
|
106
|
+
* are packed 0xAARRGGBB where 0 means inherit, and a non-positive width
|
|
107
|
+
* inherits the default stroke.
|
|
108
|
+
*/
|
|
109
|
+
setRSI(spec: {
|
|
110
|
+
enabled: boolean;
|
|
111
|
+
period: number;
|
|
112
|
+
upperBand: number;
|
|
113
|
+
lowerBand: number;
|
|
114
|
+
maPeriod: number;
|
|
115
|
+
maKind: number;
|
|
116
|
+
maVisible: boolean;
|
|
117
|
+
lineColor: number;
|
|
118
|
+
lineWidth: number;
|
|
119
|
+
lineVisible: boolean;
|
|
120
|
+
maColor: number;
|
|
121
|
+
maWidth: number;
|
|
122
|
+
bandColor: number;
|
|
123
|
+
bandsVisible: boolean;
|
|
124
|
+
}): void;
|
|
116
125
|
/**
|
|
117
|
-
* Configures the MACD pane
|
|
118
|
-
*
|
|
126
|
+
* Configures the MACD pane. source/maKind mirror setOverlays' encodings;
|
|
127
|
+
* colors are packed 0xAARRGGBB where 0 means inherit, and a non-positive
|
|
128
|
+
* width inherits the default stroke.
|
|
119
129
|
*/
|
|
120
|
-
setMACD(
|
|
130
|
+
setMACD(spec: {
|
|
131
|
+
enabled: boolean;
|
|
132
|
+
fast: number;
|
|
133
|
+
slow: number;
|
|
134
|
+
signal: number;
|
|
135
|
+
source: number;
|
|
136
|
+
maKind: number;
|
|
137
|
+
signalMaKind: number;
|
|
138
|
+
lineColor: number;
|
|
139
|
+
lineWidth: number;
|
|
140
|
+
lineVisible: boolean;
|
|
141
|
+
signalColor: number;
|
|
142
|
+
signalWidth: number;
|
|
143
|
+
signalVisible: boolean;
|
|
144
|
+
histVisible: boolean;
|
|
145
|
+
histUpColor: number;
|
|
146
|
+
histUpFadingColor: number;
|
|
147
|
+
histDownColor: number;
|
|
148
|
+
histDownFadingColor: number;
|
|
149
|
+
zeroColor: number;
|
|
150
|
+
zeroVisible: boolean;
|
|
151
|
+
}): void;
|
|
121
152
|
/**
|
|
122
153
|
* Replaces the full set of MA/EMA overlay lines drawn on the price pane.
|
|
123
154
|
* kind: 0=SMA, 1=EMA; source: 0=close,1=open,2=high,3=low,4=hl2,5=hlc3,6=ohlc4;
|
|
@@ -136,12 +167,12 @@ export interface ChartHandle {
|
|
|
136
167
|
* Configures the session VWAP overlay. `resetOffsetMin` shifts the session
|
|
137
168
|
* boundary from UTC midnight (minutes); `color` is packed 0xAARRGGBB.
|
|
138
169
|
*/
|
|
139
|
-
setVWAP(
|
|
140
|
-
enabled: boolean
|
|
141
|
-
resetOffsetMin: number
|
|
142
|
-
color: number
|
|
143
|
-
width: number
|
|
144
|
-
): void;
|
|
170
|
+
setVWAP(spec: {
|
|
171
|
+
enabled: boolean;
|
|
172
|
+
resetOffsetMin: number;
|
|
173
|
+
color: number;
|
|
174
|
+
width: number;
|
|
175
|
+
}): void;
|
|
145
176
|
/**
|
|
146
177
|
* Configures the Bollinger Bands overlay (three price-pane lines + optional
|
|
147
178
|
* fill between the bands). source/basisKind mirror setOverlays' encodings;
|
|
@@ -162,6 +193,31 @@ export interface ChartHandle {
|
|
|
162
193
|
fillEnabled: boolean;
|
|
163
194
|
fillOpacity: number;
|
|
164
195
|
}): void;
|
|
196
|
+
/**
|
|
197
|
+
* Configures the volume bars under the candles. `heightFrac` is the tallest
|
|
198
|
+
* bar as a fraction of the price pane. The style fields carry an inherit
|
|
199
|
+
* sentinel: a negative number or a transparent color falls back to the
|
|
200
|
+
* matching theme key.
|
|
201
|
+
*/
|
|
202
|
+
setVolume(spec: {
|
|
203
|
+
enabled: boolean;
|
|
204
|
+
heightFrac: number;
|
|
205
|
+
opacity: number;
|
|
206
|
+
radiusPx: number;
|
|
207
|
+
upColor: number;
|
|
208
|
+
downColor: number;
|
|
209
|
+
}): void;
|
|
210
|
+
/**
|
|
211
|
+
* Staggered volume-bar collapse: 0 = full height, 1 = all bars flat. Bars fall
|
|
212
|
+
* tallest-first and land together; drive 1 → 0 to reveal them, which plays the
|
|
213
|
+
* cascade in reverse (shortest bar home first).
|
|
214
|
+
*
|
|
215
|
+
* Unlike setMorph, `t` must be **linear** progress — the core eases each bar
|
|
216
|
+
* over its own slice of the timeline, so the curve is applied there. `easing`
|
|
217
|
+
* indexes `linear | ease-in | ease-out | ease-in-out`. setVolume snaps this to
|
|
218
|
+
* match its `enabled`, so it's only needed while animating.
|
|
219
|
+
*/
|
|
220
|
+
setVolumeCollapse(t: number, easing: number): void;
|
|
165
221
|
/**
|
|
166
222
|
* The continuous data coordinate at pixel (x, y) — not snapped to a candle
|
|
167
223
|
* slot. Null when there are no candles or the viewport is degenerate. Cheap to
|
package/src/theme.ts
CHANGED
|
@@ -27,6 +27,7 @@ export const FLOAT_KEYS: Partial<Record<keyof VroomTheme, number>> = {
|
|
|
27
27
|
candleRadius: 8, // VROOM_FLOAT_CANDLE_RADIUS_PX
|
|
28
28
|
volumeRadius: 10, // VROOM_FLOAT_VOLUME_RADIUS_PX
|
|
29
29
|
lineWidth: 11, // VROOM_FLOAT_LINE_WIDTH_PX
|
|
30
|
+
lineGradientOpacity: 12, // VROOM_FLOAT_LINE_GRADIENT_OPACITY
|
|
30
31
|
};
|
|
31
32
|
|
|
32
33
|
// Maps each boolean VroomTheme field to its VroomFloatKey index (pushed as 0/1).
|
package/src/types.ts
CHANGED
|
@@ -12,11 +12,14 @@ export type {
|
|
|
12
12
|
VisibleRange,
|
|
13
13
|
RSIConfig,
|
|
14
14
|
MASource,
|
|
15
|
+
MAKind,
|
|
15
16
|
MovingAverageOverlay,
|
|
16
17
|
VWAPConfig,
|
|
17
18
|
BollingerBandsConfig,
|
|
19
|
+
VolumeConfig,
|
|
18
20
|
MACDConfig,
|
|
19
21
|
ChartType,
|
|
22
|
+
TransitionEasing,
|
|
20
23
|
PriceLine,
|
|
21
24
|
PriceLinesStyle,
|
|
22
25
|
} from '@vroomchart/types';
|