import type { CandleGap, CandlePoint, LiveChartPoint } from "../types"; export interface EngineTickMutable { displayValue: number; displayMin: number; displayMax: number; displayWindow: number; timestamp: number; /** * The right-edge time the engine would use if it were following live — * `now (+ windowBuffer)`. Equals {@link timestamp} while following; when * scrolled back in time (see {@link EngineTickInput.viewEnd}) it keeps * advancing while `timestamp` stays frozen. Exposed so the pan-scroll gesture * can clamp against the live edge and detect catch-up. */ liveEdge: number; /** * Smoothed value at the visible window's right edge: the live value while * following, or the price at `viewEnd` while scrolled back. Lets a badge track * the last visible price as you pan (see `badge.followViewEdge`). */ edgeValue: number; /** * Value + time of the lowest / highest data point in the visible window — * the actual extrema, NOT the smoothed display bounds (which carry margin and * fold in the live value / reference lines). `NaN` when the window holds no * data. Used to float `topLabel` / `bottomLabel` at their occurrence point * (see {@link AxisLabelConfig.position} `"extrema"`). */ extremaMinValue: number; extremaMaxValue: number; extremaMinTime: number; extremaMaxTime: number; /** Previous frame's yRangeScale — detects an in-flight scale drag. */ lastYRangeScale?: number; } export interface EngineTickInput { dt: number; canvasWidth: number; canvasHeight: number; timeWindow: number; smoothing: number; exaggerate: boolean; /** Extra catch-up speed added to `smoothing` when the live value lags. Default `0.12`. */ adaptiveSpeedBoost?: number; referenceValue: number | undefined; /** Additional reference values (lines + bands) folded into the Y range. */ referenceValues?: number[]; /** * Time-varying threshold series (`threshold.includeInRange`): its min/max over * the visible window is folded into the Y range, like {@link referenceValues} * but windowed each tick. */ thresholdRangePoints?: LiveChartPoint[]; /** Whether {@link thresholdRangePoints} extends flat before its first point to * the visible window start (`threshold.extendToStart`). Default `true`. */ thresholdRangeExtendToStart?: boolean; /** Whether {@link thresholdRangePoints} extends flat past its last point to * "now" (`threshold.extendToNow`). Default `true`. */ thresholdRangeExtendToNow?: boolean; /** Clamp the computed lower bound at 0. */ nonNegative?: boolean; /** Hard cap for the computed upper bound. */ maxValue?: number; /** Positive, finite Y-range multiplier around the fitted midpoint (1 = auto-fit). */ yRangeScale?: number; targetValue: number; points: LiveChartPoint[]; /** Seconds since Unix epoch; defaults to `Date.now() / 1000` */ nowSeconds?: number; /** Override the engine's "now" (unix seconds) — e.g. fill historical data edge-to-edge. */ nowOverride?: number; /** Right-edge buffer as a fraction of the time window (pushes the live edge past "now"). */ windowBuffer?: number; /** When true, freeze the viewport timestamp and skip displayWindow lerp */ paused?: boolean; /** * Settle the framing in this one frame instead of easing into it: the time * window ({@link EngineTickMutable.displayWindow}), Y-range * ({@link EngineTickMutable.displayMin}/{@link EngineTickMutable.displayMax}), * and value ({@link EngineTickMutable.displayValue}/{@link EngineTickMutable.edgeValue}) * jump straight to their targets — `smoothing` is bypassed for this tick only. * Set for the single frame after a `snapKey` change so a timeframe / dataset * switch lands instantly while live ticks keep their normal smoothing. Leaves * the timestamp / pan-scroll state untouched. See {@link LiveChartProps.snapKey}. */ snap?: boolean; /** * Absolute right-edge time (unix seconds) to freeze the window at, or * `null`/`undefined` to follow the live edge. Set by the pan-scroll gesture * to scroll back in time; once it reaches (or passes) the live edge the engine * resumes following. Takes precedence over {@link paused}. */ viewEnd?: number | null; /** * Honor a {@link viewEnd} parked at or past the live edge (blank future space) * instead of falling through to following live. Set when `timeScroll.overscroll` * is active — the pan/pinch gestures may then park the right edge beyond the * live edge, and the engine must freeze there or the gestures render nothing. * The `viewEnd >= firstDataTime` strand-guard applies in both modes. Default * `false` (classic behavior: only a past `viewEnd` freezes). */ allowFutureViewEnd?: boolean; /** * "Return to live" glide (see #164). When time-scroll is disabled while scrolled * back, the engine hook clears {@link viewEnd} and animates {@link returnT} from * `0`→`1`; each frame the right edge interpolates from {@link returnFrom} (the * frozen edge captured at that moment) to the *current* live edge by `returnT`, * so the window glides forward and lands exactly on live (no end-snap). At * `1`/`undefined` it pins to the live edge — the normal follow behavior. */ returnT?: number; /** Frozen right-edge time the {@link returnT} glide starts from. See {@link returnT}. */ returnFrom?: number; /** * Absolute visible-window width (seconds) to freeze at, or `null`/`undefined` * to follow the configured {@link timeWindow}. Set by the pinch-zoom gesture * (see `usePinchZoom` / the `zoom` prop). The symmetric counterpart of * {@link viewEnd}: `viewEnd` overrides the window's right edge, `viewWindow` * overrides its width. `displayWindow` eases toward this when set. */ viewWindow?: number | null; /** Chart mode — `"candle"` uses OHLC bars for Y range instead of line points. */ mode?: "line" | "candle"; /** Committed OHLC bars (sorted by time). Used when mode is `"candle"`. */ candles?: CandlePoint[]; /** In-progress candle. Included in Y range when mode is `"candle"`. */ liveCandle?: CandlePoint | null; /** Explicit semantic gaps used only for previous-close range anchoring. */ candleGaps?: CandleGap[]; candleGapBridgeNoTrades?: boolean; candleGapBridgeUnavailable?: boolean; candleGapBridgeUnknown?: boolean; } /** * One frame of the live chart engine (mirrors `useLiveChartEngine` worklet body). * Mutates `state` in place for testability and reuse from the hook. */ export declare function tickLiveChartEngineFrame(state: EngineTickMutable, input: EngineTickInput): void; //# sourceMappingURL=liveChartEngineTick.d.ts.map