hyperprop-charting-library 0.1.139 → 0.1.140

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/dist/index.d.cts CHANGED
@@ -81,6 +81,8 @@ interface ChartOptions {
81
81
  keyboard?: KeyboardOptions;
82
82
  accessibility?: AccessibilityOptions;
83
83
  downsampling?: DownsamplingOptions;
84
+ touch?: TouchOptions;
85
+ datafeedOptions?: DatafeedOptions;
84
86
  crosshair?: CrosshairOptions;
85
87
  grid?: GridOptions;
86
88
  watermark?: WatermarkOptions;
@@ -503,6 +505,19 @@ interface CrosshairPriceActionEvent {
503
505
  y: number;
504
506
  price: number;
505
507
  }
508
+ /** Press-and-hold on touch; also fired while the finger scrubs afterwards. */
509
+ interface ChartLongPressEvent {
510
+ x: number;
511
+ y: number;
512
+ clientX: number;
513
+ clientY: number;
514
+ price?: number;
515
+ index?: number;
516
+ time?: string;
517
+ point?: OhlcDataPoint;
518
+ /** False for the initial press, true for subsequent scrub updates. */
519
+ scrubbing: boolean;
520
+ }
506
521
  /**
507
522
  * What the pointer was over when the context menu was requested. Hosts switch
508
523
  * on this to show the right menu instead of re-deriving it from coordinates.
@@ -592,6 +607,61 @@ interface CompareSeriesOptions {
592
607
  /** Let this series widen the price scale. Default true. */
593
608
  includeInAutoScale?: boolean;
594
609
  }
610
+ /** Touch ergonomics. Fingers are blunter than a mouse cursor. */
611
+ interface TouchOptions {
612
+ /**
613
+ * Multiplier applied to drawing/handle/divider hit tolerances for touch and
614
+ * pen input, so grabbing a line doesn't demand pixel accuracy. Mouse input
615
+ * is unaffected. Default 2.2 (≈16px handles become ≈35px targets).
616
+ */
617
+ hitToleranceScale?: number;
618
+ /** Press-and-hold on the plot shows an OHLC tooltip. Default true. */
619
+ longPressTooltip?: boolean;
620
+ /** How long the finger must rest before the tooltip appears. Default 400ms. */
621
+ longPressMs?: number;
622
+ }
623
+ /** Bar window the chart is asking a datafeed for. */
624
+ interface DatafeedBarsRequest {
625
+ /** Start of the wanted window in epoch ms (hint; `countBack` is authoritative). */
626
+ fromMs: number;
627
+ /** End of the wanted window in epoch ms, exclusive. */
628
+ toMs: number;
629
+ /** Roughly how many bars to return, counting back from `toMs`. */
630
+ countBack: number;
631
+ /** True for the initial load, false for older-history backfills. */
632
+ firstRequest: boolean;
633
+ }
634
+ /**
635
+ * Optional pull-based data source, shaped after TradingView's datafeed. Supply
636
+ * one and the chart loads its own history — including fetching older bars as
637
+ * the user scrolls left — instead of the host pushing everything through
638
+ * `setData`. `setData`/`upsertBar` keep working and take precedence, so this
639
+ * can be adopted one host at a time.
640
+ */
641
+ interface ChartDatafeed {
642
+ /** Awaited once before the first `getBars`, like TradingView's onReady. */
643
+ onReady?: () => Promise<void> | void;
644
+ /**
645
+ * Return bars for the requested window, oldest first. Return an empty array
646
+ * to signal there is no more history — the chart stops asking.
647
+ */
648
+ getBars: (request: DatafeedBarsRequest) => Promise<OhlcDataPoint[]> | OhlcDataPoint[];
649
+ /** Stream live updates; return a teardown function. */
650
+ subscribeBars?: (onBar: (bar: OhlcDataPoint) => void) => (() => void) | void;
651
+ /** Called when `getBars` rejects; the chart just stops that request. */
652
+ onError?: (error: unknown, request: DatafeedBarsRequest) => void;
653
+ }
654
+ interface DatafeedOptions {
655
+ /**
656
+ * Start fetching older bars when fewer than this many remain to the left of
657
+ * the viewport. Default 150.
658
+ */
659
+ prefetchThresholdBars?: number;
660
+ /** Minimum gap between backfill requests. Default 1200ms. */
661
+ cooldownMs?: number;
662
+ /** Bars requested per backfill. Default 1500. */
663
+ chunkBars?: number;
664
+ }
595
665
  interface AccessibilityOptions {
596
666
  /** aria-label on the canvas. Default "Price chart". */
597
667
  label?: string;
@@ -755,6 +825,15 @@ interface ChartInstance {
755
825
  * visible bar so differently-priced instruments stay comparable. Data is not
756
826
  * part of `saveState()` — the host re-supplies it.
757
827
  */
828
+ /**
829
+ * Attach (or clear with `null`) a pull-based datafeed. The chart loads the
830
+ * initial window, subscribes to live bars, and fetches older history as the
831
+ * user scrolls left. Returns a promise that resolves once the first batch is
832
+ * on screen.
833
+ */
834
+ setDatafeed: (datafeed: ChartDatafeed | null) => Promise<void>;
835
+ /** Fires when press-and-hold inspects a bar on touch. */
836
+ onLongPress: (handler: ((event: ChartLongPressEvent) => void) | null) => void;
758
837
  setCompareSeries: (series: CompareSeriesOptions[]) => void;
759
838
  addCompareSeries: (series: CompareSeriesOptions) => void;
760
839
  removeCompareSeries: (id: string) => void;
@@ -948,4 +1027,4 @@ declare const compileScriptIndicator: (definition: ScriptIndicatorDefinition) =>
948
1027
 
949
1028
  declare function createChart(element: HTMLElement, options?: ChartOptions): ChartInstance;
950
1029
 
951
- export { type AccessibilityOptions, type AxisOptions, type BuiltInIndicatorInfo, type ChartClickEvent, type ChartContextMenuEvent, type ChartContextMenuRegion, type ChartInstance, type ChartKeyboardAction, type ChartKeyboardShortcutEvent, type ChartOptions, type ChartSavedState, type ChartType, type CompareSeriesOptions, type CrosshairMoveEvent, type CrosshairOptions, type CrosshairPriceActionEvent, type DashPatternOptions, type DownsamplingOptions, type DrawingBounds, type DrawingDefaults, type DrawingHoverEvent, type DrawingObjectOptions, type DrawingPoint, type DrawingSelectEvent, type DrawingSelectionChangeEvent, type DrawingToolType, FIB_DEFAULT_PALETTE, type GridOptions, type IndicatorInstanceOptions, type IndicatorPane, type IndicatorPaneActionEvent, type IndicatorPaneAxisOptions, type IndicatorPaneGuideLine, type IndicatorPaneHeightChangeEvent, type IndicatorPaneRenderInfo, type IndicatorPaneValue, type IndicatorPaneValueLabel, type IndicatorPlugin, type IndicatorRenderContext, type KeyboardOptions, type LabelsOptions, type OhlcDataPoint, type OrderActionButton, type OrderActionEvent, type OrderLineOptions, POSITION_DEFAULT_COLORS, type PriceLineOptions, type PriceScaleMode, type PriceScaleOptions, SCRIPT_SOURCE_INPUT_VALUES, type ScriptComputeResult, type ScriptIndicatorDefinition, type ScriptIndicatorInputDef, type ScriptInputHelper, type ScriptInputOptions, type ScriptPlotSpec, type TickerLineOptions, type TradeMarkerOptions, type ViewportState, type WatermarkOptions, compileScriptIndicator, createChart, extractScriptInputs, validateScriptSource };
1030
+ export { type AccessibilityOptions, type AxisOptions, type BuiltInIndicatorInfo, type ChartClickEvent, type ChartContextMenuEvent, type ChartContextMenuRegion, type ChartDatafeed, type ChartInstance, type ChartKeyboardAction, type ChartKeyboardShortcutEvent, type ChartLongPressEvent, type ChartOptions, type ChartSavedState, type ChartType, type CompareSeriesOptions, type CrosshairMoveEvent, type CrosshairOptions, type CrosshairPriceActionEvent, type DashPatternOptions, type DatafeedBarsRequest, type DatafeedOptions, type DownsamplingOptions, type DrawingBounds, type DrawingDefaults, type DrawingHoverEvent, type DrawingObjectOptions, type DrawingPoint, type DrawingSelectEvent, type DrawingSelectionChangeEvent, type DrawingToolType, FIB_DEFAULT_PALETTE, type GridOptions, type IndicatorInstanceOptions, type IndicatorPane, type IndicatorPaneActionEvent, type IndicatorPaneAxisOptions, type IndicatorPaneGuideLine, type IndicatorPaneHeightChangeEvent, type IndicatorPaneRenderInfo, type IndicatorPaneValue, type IndicatorPaneValueLabel, type IndicatorPlugin, type IndicatorRenderContext, type KeyboardOptions, type LabelsOptions, type OhlcDataPoint, type OrderActionButton, type OrderActionEvent, type OrderLineOptions, POSITION_DEFAULT_COLORS, type PriceLineOptions, type PriceScaleMode, type PriceScaleOptions, SCRIPT_SOURCE_INPUT_VALUES, type ScriptComputeResult, type ScriptIndicatorDefinition, type ScriptIndicatorInputDef, type ScriptInputHelper, type ScriptInputOptions, type ScriptPlotSpec, type TickerLineOptions, type TouchOptions, type TradeMarkerOptions, type ViewportState, type WatermarkOptions, compileScriptIndicator, createChart, extractScriptInputs, validateScriptSource };
package/dist/index.d.ts CHANGED
@@ -81,6 +81,8 @@ interface ChartOptions {
81
81
  keyboard?: KeyboardOptions;
82
82
  accessibility?: AccessibilityOptions;
83
83
  downsampling?: DownsamplingOptions;
84
+ touch?: TouchOptions;
85
+ datafeedOptions?: DatafeedOptions;
84
86
  crosshair?: CrosshairOptions;
85
87
  grid?: GridOptions;
86
88
  watermark?: WatermarkOptions;
@@ -503,6 +505,19 @@ interface CrosshairPriceActionEvent {
503
505
  y: number;
504
506
  price: number;
505
507
  }
508
+ /** Press-and-hold on touch; also fired while the finger scrubs afterwards. */
509
+ interface ChartLongPressEvent {
510
+ x: number;
511
+ y: number;
512
+ clientX: number;
513
+ clientY: number;
514
+ price?: number;
515
+ index?: number;
516
+ time?: string;
517
+ point?: OhlcDataPoint;
518
+ /** False for the initial press, true for subsequent scrub updates. */
519
+ scrubbing: boolean;
520
+ }
506
521
  /**
507
522
  * What the pointer was over when the context menu was requested. Hosts switch
508
523
  * on this to show the right menu instead of re-deriving it from coordinates.
@@ -592,6 +607,61 @@ interface CompareSeriesOptions {
592
607
  /** Let this series widen the price scale. Default true. */
593
608
  includeInAutoScale?: boolean;
594
609
  }
610
+ /** Touch ergonomics. Fingers are blunter than a mouse cursor. */
611
+ interface TouchOptions {
612
+ /**
613
+ * Multiplier applied to drawing/handle/divider hit tolerances for touch and
614
+ * pen input, so grabbing a line doesn't demand pixel accuracy. Mouse input
615
+ * is unaffected. Default 2.2 (≈16px handles become ≈35px targets).
616
+ */
617
+ hitToleranceScale?: number;
618
+ /** Press-and-hold on the plot shows an OHLC tooltip. Default true. */
619
+ longPressTooltip?: boolean;
620
+ /** How long the finger must rest before the tooltip appears. Default 400ms. */
621
+ longPressMs?: number;
622
+ }
623
+ /** Bar window the chart is asking a datafeed for. */
624
+ interface DatafeedBarsRequest {
625
+ /** Start of the wanted window in epoch ms (hint; `countBack` is authoritative). */
626
+ fromMs: number;
627
+ /** End of the wanted window in epoch ms, exclusive. */
628
+ toMs: number;
629
+ /** Roughly how many bars to return, counting back from `toMs`. */
630
+ countBack: number;
631
+ /** True for the initial load, false for older-history backfills. */
632
+ firstRequest: boolean;
633
+ }
634
+ /**
635
+ * Optional pull-based data source, shaped after TradingView's datafeed. Supply
636
+ * one and the chart loads its own history — including fetching older bars as
637
+ * the user scrolls left — instead of the host pushing everything through
638
+ * `setData`. `setData`/`upsertBar` keep working and take precedence, so this
639
+ * can be adopted one host at a time.
640
+ */
641
+ interface ChartDatafeed {
642
+ /** Awaited once before the first `getBars`, like TradingView's onReady. */
643
+ onReady?: () => Promise<void> | void;
644
+ /**
645
+ * Return bars for the requested window, oldest first. Return an empty array
646
+ * to signal there is no more history — the chart stops asking.
647
+ */
648
+ getBars: (request: DatafeedBarsRequest) => Promise<OhlcDataPoint[]> | OhlcDataPoint[];
649
+ /** Stream live updates; return a teardown function. */
650
+ subscribeBars?: (onBar: (bar: OhlcDataPoint) => void) => (() => void) | void;
651
+ /** Called when `getBars` rejects; the chart just stops that request. */
652
+ onError?: (error: unknown, request: DatafeedBarsRequest) => void;
653
+ }
654
+ interface DatafeedOptions {
655
+ /**
656
+ * Start fetching older bars when fewer than this many remain to the left of
657
+ * the viewport. Default 150.
658
+ */
659
+ prefetchThresholdBars?: number;
660
+ /** Minimum gap between backfill requests. Default 1200ms. */
661
+ cooldownMs?: number;
662
+ /** Bars requested per backfill. Default 1500. */
663
+ chunkBars?: number;
664
+ }
595
665
  interface AccessibilityOptions {
596
666
  /** aria-label on the canvas. Default "Price chart". */
597
667
  label?: string;
@@ -755,6 +825,15 @@ interface ChartInstance {
755
825
  * visible bar so differently-priced instruments stay comparable. Data is not
756
826
  * part of `saveState()` — the host re-supplies it.
757
827
  */
828
+ /**
829
+ * Attach (or clear with `null`) a pull-based datafeed. The chart loads the
830
+ * initial window, subscribes to live bars, and fetches older history as the
831
+ * user scrolls left. Returns a promise that resolves once the first batch is
832
+ * on screen.
833
+ */
834
+ setDatafeed: (datafeed: ChartDatafeed | null) => Promise<void>;
835
+ /** Fires when press-and-hold inspects a bar on touch. */
836
+ onLongPress: (handler: ((event: ChartLongPressEvent) => void) | null) => void;
758
837
  setCompareSeries: (series: CompareSeriesOptions[]) => void;
759
838
  addCompareSeries: (series: CompareSeriesOptions) => void;
760
839
  removeCompareSeries: (id: string) => void;
@@ -948,4 +1027,4 @@ declare const compileScriptIndicator: (definition: ScriptIndicatorDefinition) =>
948
1027
 
949
1028
  declare function createChart(element: HTMLElement, options?: ChartOptions): ChartInstance;
950
1029
 
951
- export { type AccessibilityOptions, type AxisOptions, type BuiltInIndicatorInfo, type ChartClickEvent, type ChartContextMenuEvent, type ChartContextMenuRegion, type ChartInstance, type ChartKeyboardAction, type ChartKeyboardShortcutEvent, type ChartOptions, type ChartSavedState, type ChartType, type CompareSeriesOptions, type CrosshairMoveEvent, type CrosshairOptions, type CrosshairPriceActionEvent, type DashPatternOptions, type DownsamplingOptions, type DrawingBounds, type DrawingDefaults, type DrawingHoverEvent, type DrawingObjectOptions, type DrawingPoint, type DrawingSelectEvent, type DrawingSelectionChangeEvent, type DrawingToolType, FIB_DEFAULT_PALETTE, type GridOptions, type IndicatorInstanceOptions, type IndicatorPane, type IndicatorPaneActionEvent, type IndicatorPaneAxisOptions, type IndicatorPaneGuideLine, type IndicatorPaneHeightChangeEvent, type IndicatorPaneRenderInfo, type IndicatorPaneValue, type IndicatorPaneValueLabel, type IndicatorPlugin, type IndicatorRenderContext, type KeyboardOptions, type LabelsOptions, type OhlcDataPoint, type OrderActionButton, type OrderActionEvent, type OrderLineOptions, POSITION_DEFAULT_COLORS, type PriceLineOptions, type PriceScaleMode, type PriceScaleOptions, SCRIPT_SOURCE_INPUT_VALUES, type ScriptComputeResult, type ScriptIndicatorDefinition, type ScriptIndicatorInputDef, type ScriptInputHelper, type ScriptInputOptions, type ScriptPlotSpec, type TickerLineOptions, type TradeMarkerOptions, type ViewportState, type WatermarkOptions, compileScriptIndicator, createChart, extractScriptInputs, validateScriptSource };
1030
+ export { type AccessibilityOptions, type AxisOptions, type BuiltInIndicatorInfo, type ChartClickEvent, type ChartContextMenuEvent, type ChartContextMenuRegion, type ChartDatafeed, type ChartInstance, type ChartKeyboardAction, type ChartKeyboardShortcutEvent, type ChartLongPressEvent, type ChartOptions, type ChartSavedState, type ChartType, type CompareSeriesOptions, type CrosshairMoveEvent, type CrosshairOptions, type CrosshairPriceActionEvent, type DashPatternOptions, type DatafeedBarsRequest, type DatafeedOptions, type DownsamplingOptions, type DrawingBounds, type DrawingDefaults, type DrawingHoverEvent, type DrawingObjectOptions, type DrawingPoint, type DrawingSelectEvent, type DrawingSelectionChangeEvent, type DrawingToolType, FIB_DEFAULT_PALETTE, type GridOptions, type IndicatorInstanceOptions, type IndicatorPane, type IndicatorPaneActionEvent, type IndicatorPaneAxisOptions, type IndicatorPaneGuideLine, type IndicatorPaneHeightChangeEvent, type IndicatorPaneRenderInfo, type IndicatorPaneValue, type IndicatorPaneValueLabel, type IndicatorPlugin, type IndicatorRenderContext, type KeyboardOptions, type LabelsOptions, type OhlcDataPoint, type OrderActionButton, type OrderActionEvent, type OrderLineOptions, POSITION_DEFAULT_COLORS, type PriceLineOptions, type PriceScaleMode, type PriceScaleOptions, SCRIPT_SOURCE_INPUT_VALUES, type ScriptComputeResult, type ScriptIndicatorDefinition, type ScriptIndicatorInputDef, type ScriptInputHelper, type ScriptInputOptions, type ScriptPlotSpec, type TickerLineOptions, type TouchOptions, type TradeMarkerOptions, type ViewportState, type WatermarkOptions, compileScriptIndicator, createChart, extractScriptInputs, validateScriptSource };