hyperprop-charting-library 0.1.136 → 0.1.138
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/hyperprop-charting-library.cjs +519 -43
- package/dist/hyperprop-charting-library.d.ts +172 -1
- package/dist/hyperprop-charting-library.js +517 -43
- package/dist/index.cjs +519 -43
- package/dist/index.d.cts +172 -1
- package/dist/index.d.ts +172 -1
- package/dist/index.js +517 -43
- package/docs/API.md +139 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -78,6 +78,8 @@ interface ChartOptions {
|
|
|
78
78
|
pinOutOfRangeLines?: boolean;
|
|
79
79
|
doubleClickEnabled?: boolean;
|
|
80
80
|
doubleClickAction?: "reset" | "placeLimitOrder";
|
|
81
|
+
keyboard?: KeyboardOptions;
|
|
82
|
+
accessibility?: AccessibilityOptions;
|
|
81
83
|
crosshair?: CrosshairOptions;
|
|
82
84
|
grid?: GridOptions;
|
|
83
85
|
watermark?: WatermarkOptions;
|
|
@@ -164,6 +166,36 @@ interface DrawingSelectEvent {
|
|
|
164
166
|
pointIndex?: number;
|
|
165
167
|
x: number;
|
|
166
168
|
y: number;
|
|
169
|
+
/** On-screen box of the drawing, for anchoring a host toolbar to it. */
|
|
170
|
+
bounds?: DrawingBounds;
|
|
171
|
+
}
|
|
172
|
+
/** Canvas-pixel bounding box of a drawing, relative to the chart canvas. */
|
|
173
|
+
interface DrawingBounds {
|
|
174
|
+
left: number;
|
|
175
|
+
top: number;
|
|
176
|
+
right: number;
|
|
177
|
+
bottom: number;
|
|
178
|
+
centerX: number;
|
|
179
|
+
centerY: number;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Emitted whenever the selected drawing's on-screen box moves — selection,
|
|
183
|
+
* deselection (payload `null`), drag, edit, pan, zoom or resize. Hosts render
|
|
184
|
+
* their own floating toolbar and position it from `bounds`, keeping it inside
|
|
185
|
+
* `plot`; the chart never has to draw toolbar chrome itself.
|
|
186
|
+
*/
|
|
187
|
+
interface DrawingSelectionChangeEvent {
|
|
188
|
+
drawing: DrawingObjectOptions;
|
|
189
|
+
bounds: DrawingBounds;
|
|
190
|
+
/** Plot rectangle, so a toolbar can be clamped inside the chart area. */
|
|
191
|
+
plot: {
|
|
192
|
+
left: number;
|
|
193
|
+
top: number;
|
|
194
|
+
right: number;
|
|
195
|
+
bottom: number;
|
|
196
|
+
};
|
|
197
|
+
/** True while the drawing is actively being dragged or resized. */
|
|
198
|
+
dragging: boolean;
|
|
167
199
|
}
|
|
168
200
|
interface DrawingHoverEvent {
|
|
169
201
|
drawing: DrawingObjectOptions | null;
|
|
@@ -470,6 +502,67 @@ interface CrosshairPriceActionEvent {
|
|
|
470
502
|
y: number;
|
|
471
503
|
price: number;
|
|
472
504
|
}
|
|
505
|
+
/**
|
|
506
|
+
* What the pointer was over when the context menu was requested. Hosts switch
|
|
507
|
+
* on this to show the right menu instead of re-deriving it from coordinates.
|
|
508
|
+
*/
|
|
509
|
+
type ChartContextMenuRegion = "plot" | "drawing" | "indicator-pane" | "x-axis" | "y-axis";
|
|
510
|
+
interface ChartContextMenuEvent {
|
|
511
|
+
region: ChartContextMenuRegion;
|
|
512
|
+
/** Canvas-relative position. */
|
|
513
|
+
x: number;
|
|
514
|
+
y: number;
|
|
515
|
+
/** Viewport position, ready to place a DOM menu without re-measuring. */
|
|
516
|
+
clientX: number;
|
|
517
|
+
clientY: number;
|
|
518
|
+
/** Price under the pointer (main pane regions only). */
|
|
519
|
+
price?: number;
|
|
520
|
+
index?: number;
|
|
521
|
+
time?: string;
|
|
522
|
+
point?: OhlcDataPoint;
|
|
523
|
+
/** Set for region "drawing"; the drawing is also selected by the chart. */
|
|
524
|
+
drawing?: DrawingObjectOptions;
|
|
525
|
+
drawingTarget?: "line" | "handle";
|
|
526
|
+
pointIndex?: number;
|
|
527
|
+
/** Set for region "indicator-pane". */
|
|
528
|
+
indicator?: {
|
|
529
|
+
id: string;
|
|
530
|
+
type: string;
|
|
531
|
+
};
|
|
532
|
+
}
|
|
533
|
+
/** Built-in keyboard actions, reported after the chart applies them. */
|
|
534
|
+
type ChartKeyboardAction = "delete-drawing" | "cancel" | "pan-left" | "pan-right" | "pan-up" | "pan-down" | "zoom-in" | "zoom-out" | "reset-viewport" | "scroll-to-realtime";
|
|
535
|
+
interface ChartKeyboardShortcutEvent {
|
|
536
|
+
action: ChartKeyboardAction;
|
|
537
|
+
/** The originating `KeyboardEvent.key`. */
|
|
538
|
+
key: string;
|
|
539
|
+
shiftKey: boolean;
|
|
540
|
+
/** The drawing that was removed, for "delete-drawing" (so hosts can undo). */
|
|
541
|
+
drawing?: DrawingObjectOptions;
|
|
542
|
+
}
|
|
543
|
+
interface KeyboardOptions {
|
|
544
|
+
/**
|
|
545
|
+
* Master switch for the built-in shortcuts. Shortcuts only fire while the
|
|
546
|
+
* chart canvas has focus, so they never swallow typing in host inputs.
|
|
547
|
+
* Default true.
|
|
548
|
+
*/
|
|
549
|
+
enabled?: boolean;
|
|
550
|
+
/** Bars panned per arrow-key press (Shift multiplies by 10). Default 1. */
|
|
551
|
+
panBars?: number;
|
|
552
|
+
/** Delete/Backspace removes the selected drawing. Default true. */
|
|
553
|
+
deleteSelectedDrawing?: boolean;
|
|
554
|
+
}
|
|
555
|
+
interface AccessibilityOptions {
|
|
556
|
+
/** aria-label on the canvas. Default "Price chart". */
|
|
557
|
+
label?: string;
|
|
558
|
+
/**
|
|
559
|
+
* Longer description exposed via aria-description, e.g. the symbol and
|
|
560
|
+
* interval currently shown.
|
|
561
|
+
*/
|
|
562
|
+
description?: string;
|
|
563
|
+
/** Make the canvas focusable so keyboard users can reach it. Default true. */
|
|
564
|
+
focusable?: boolean;
|
|
565
|
+
}
|
|
473
566
|
interface TickerLineOptions {
|
|
474
567
|
visible?: boolean;
|
|
475
568
|
style?: "solid" | "dotted" | "dashed";
|
|
@@ -581,8 +674,40 @@ interface ChartInstance {
|
|
|
581
674
|
onDrawingSelect: (handler: ((event: DrawingSelectEvent) => void) | null) => void;
|
|
582
675
|
onDrawingDoubleClick: (handler: ((event: DrawingSelectEvent) => void) | null) => void;
|
|
583
676
|
onDrawingEditText: (handler: ((event: DrawingSelectEvent) => void) | null) => void;
|
|
677
|
+
/**
|
|
678
|
+
* Selection geometry stream for a host-rendered floating toolbar. Fires on
|
|
679
|
+
* select/deselect and on every frame where the selected drawing's box moves
|
|
680
|
+
* (drag, pan, zoom, resize), so the toolbar can track the shape instead of
|
|
681
|
+
* sitting in a fixed corner. Payload is `null` when nothing is selected.
|
|
682
|
+
*/
|
|
683
|
+
onSelectionChange: (handler: ((event: DrawingSelectionChangeEvent | null) => void) | null) => void;
|
|
684
|
+
/** Current selection and its on-screen box, for imperative reads. */
|
|
685
|
+
getSelectedDrawing: () => {
|
|
686
|
+
drawing: DrawingObjectOptions;
|
|
687
|
+
bounds: DrawingBounds;
|
|
688
|
+
} | null;
|
|
689
|
+
/**
|
|
690
|
+
* Right-click (or long-press equivalent) with everything the host needs to
|
|
691
|
+
* open the correct menu: which region was hit, the price/bar under the
|
|
692
|
+
* pointer, and the drawing or indicator pane it landed on. The chart always
|
|
693
|
+
* suppresses the browser's native menu.
|
|
694
|
+
*/
|
|
695
|
+
onContextMenu: (handler: ((event: ChartContextMenuEvent) => void) | null) => void;
|
|
696
|
+
/** Fires after a built-in keyboard shortcut is applied. */
|
|
697
|
+
onKeyboardShortcut: (handler: ((event: ChartKeyboardShortcutEvent) => void) | null) => void;
|
|
698
|
+
/** Focus the chart canvas so keyboard shortcuts apply to it. */
|
|
699
|
+
focus: () => void;
|
|
584
700
|
setMagnetMode: (mode: "none" | "weak" | "strong") => void;
|
|
585
701
|
getMagnetMode: () => "none" | "weak" | "strong";
|
|
702
|
+
/**
|
|
703
|
+
* Change the price-scale mode ("linear" | "log" | "percent") and/or invert
|
|
704
|
+
* the axis. Log maps prices through log10, percent relabels the axis
|
|
705
|
+
* relative to the first visible bar's close (TradingView behavior), and
|
|
706
|
+
* invert flips the axis top-to-bottom. Only the main price pane is
|
|
707
|
+
* affected; indicator panes keep their own scales.
|
|
708
|
+
*/
|
|
709
|
+
setPriceScale: (options: Partial<PriceScaleOptions>) => void;
|
|
710
|
+
getPriceScale: () => PriceScaleOptions;
|
|
586
711
|
cancelDrawing: () => boolean;
|
|
587
712
|
setTradeMarkers: (markers: TradeMarkerOptions[]) => void;
|
|
588
713
|
onDrawingHover: (handler: ((event: DrawingHoverEvent) => void) | null) => void;
|
|
@@ -657,8 +782,15 @@ interface ChartSavedState {
|
|
|
657
782
|
drawings: DrawingObjectOptions[];
|
|
658
783
|
indicators: IndicatorInstanceOptions[];
|
|
659
784
|
magnetMode: "none" | "weak" | "strong";
|
|
785
|
+
/** Optional for backward compatibility with pre-0.1.137 blobs. */
|
|
786
|
+
priceScale?: PriceScaleOptions;
|
|
660
787
|
drawingDefaults: Partial<Record<DrawingToolType, DrawingDefaults>>;
|
|
661
788
|
}
|
|
789
|
+
type PriceScaleMode = "linear" | "log" | "percent";
|
|
790
|
+
interface PriceScaleOptions {
|
|
791
|
+
mode: PriceScaleMode;
|
|
792
|
+
inverted: boolean;
|
|
793
|
+
}
|
|
662
794
|
|
|
663
795
|
interface ScriptIndicatorInputDef {
|
|
664
796
|
key: string;
|
|
@@ -706,6 +838,45 @@ interface ScriptComputeResult {
|
|
|
706
838
|
guides?: number[];
|
|
707
839
|
decimals?: number;
|
|
708
840
|
}
|
|
841
|
+
interface ScriptInputOptions {
|
|
842
|
+
/** Stable settings key; defaults to a slug of the label. */
|
|
843
|
+
key?: string;
|
|
844
|
+
min?: number;
|
|
845
|
+
max?: number;
|
|
846
|
+
step?: number;
|
|
847
|
+
}
|
|
848
|
+
declare const SCRIPT_SOURCE_INPUT_VALUES: readonly ["open", "high", "low", "close", "hl2", "hlc3", "ohlc4"];
|
|
849
|
+
/**
|
|
850
|
+
* The `input` object passed to script top level. In value mode it resolves
|
|
851
|
+
* each declaration against the current settings; in recording mode it
|
|
852
|
+
* additionally appends every declaration to `registry`. Keys are assigned
|
|
853
|
+
* deterministically (same order both modes), so values always line up with
|
|
854
|
+
* the extracted schema.
|
|
855
|
+
*/
|
|
856
|
+
declare const createScriptInputHelper: (values: Record<string, unknown> | null, registry: ScriptIndicatorInputDef[] | null) => Readonly<{
|
|
857
|
+
int: (label: string, defaultValue: number, options?: ScriptInputOptions) => number;
|
|
858
|
+
float: (label: string, defaultValue: number, options?: ScriptInputOptions) => number;
|
|
859
|
+
bool: (label: string, defaultValue?: boolean, options?: ScriptInputOptions) => boolean;
|
|
860
|
+
color: (label: string, defaultValue: string, options?: ScriptInputOptions) => string;
|
|
861
|
+
string: (label: string, defaultValue?: string, options?: ScriptInputOptions) => string;
|
|
862
|
+
select: (label: string, defaultValue: string, choices: ReadonlyArray<string | {
|
|
863
|
+
value: string;
|
|
864
|
+
label: string;
|
|
865
|
+
}>, options?: ScriptInputOptions) => string;
|
|
866
|
+
source: (label?: string, defaultValue?: string, options?: ScriptInputOptions) => string;
|
|
867
|
+
}>;
|
|
868
|
+
type ScriptInputHelper = ReturnType<typeof createScriptInputHelper>;
|
|
869
|
+
/**
|
|
870
|
+
* Discover a script's Pine-style `input.*` declarations by running its top
|
|
871
|
+
* level with a recording helper. Returns the declared schema (empty when the
|
|
872
|
+
* script declares nothing) plus a compile/runtime error message when the
|
|
873
|
+
* script is broken. Runs under the standard execution guard, so an infinite
|
|
874
|
+
* top-level loop returns a budget error instead of hanging the caller.
|
|
875
|
+
*/
|
|
876
|
+
declare const extractScriptInputs: (source: string) => {
|
|
877
|
+
inputs: ScriptIndicatorInputDef[];
|
|
878
|
+
error: string | null;
|
|
879
|
+
};
|
|
709
880
|
/**
|
|
710
881
|
* Compile-check a script without registering it: returns an error message, or
|
|
711
882
|
* `null` when the script compiles. Runs with the same execution guard as the
|
|
@@ -726,4 +897,4 @@ declare const compileScriptIndicator: (definition: ScriptIndicatorDefinition) =>
|
|
|
726
897
|
|
|
727
898
|
declare function createChart(element: HTMLElement, options?: ChartOptions): ChartInstance;
|
|
728
899
|
|
|
729
|
-
export { type AxisOptions, type BuiltInIndicatorInfo, type ChartClickEvent, type ChartInstance, type ChartOptions, type ChartSavedState, type ChartType, type CrosshairMoveEvent, type CrosshairOptions, type CrosshairPriceActionEvent, type DashPatternOptions, type DrawingDefaults, type DrawingHoverEvent, type DrawingObjectOptions, type DrawingPoint, type DrawingSelectEvent, 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 LabelsOptions, type OhlcDataPoint, type OrderActionButton, type OrderActionEvent, type OrderLineOptions, POSITION_DEFAULT_COLORS, type PriceLineOptions, type ScriptComputeResult, type ScriptIndicatorDefinition, type ScriptIndicatorInputDef, type ScriptPlotSpec, type TickerLineOptions, type TradeMarkerOptions, type ViewportState, type WatermarkOptions, compileScriptIndicator, createChart, validateScriptSource };
|
|
900
|
+
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 CrosshairMoveEvent, type CrosshairOptions, type CrosshairPriceActionEvent, type DashPatternOptions, 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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -78,6 +78,8 @@ interface ChartOptions {
|
|
|
78
78
|
pinOutOfRangeLines?: boolean;
|
|
79
79
|
doubleClickEnabled?: boolean;
|
|
80
80
|
doubleClickAction?: "reset" | "placeLimitOrder";
|
|
81
|
+
keyboard?: KeyboardOptions;
|
|
82
|
+
accessibility?: AccessibilityOptions;
|
|
81
83
|
crosshair?: CrosshairOptions;
|
|
82
84
|
grid?: GridOptions;
|
|
83
85
|
watermark?: WatermarkOptions;
|
|
@@ -164,6 +166,36 @@ interface DrawingSelectEvent {
|
|
|
164
166
|
pointIndex?: number;
|
|
165
167
|
x: number;
|
|
166
168
|
y: number;
|
|
169
|
+
/** On-screen box of the drawing, for anchoring a host toolbar to it. */
|
|
170
|
+
bounds?: DrawingBounds;
|
|
171
|
+
}
|
|
172
|
+
/** Canvas-pixel bounding box of a drawing, relative to the chart canvas. */
|
|
173
|
+
interface DrawingBounds {
|
|
174
|
+
left: number;
|
|
175
|
+
top: number;
|
|
176
|
+
right: number;
|
|
177
|
+
bottom: number;
|
|
178
|
+
centerX: number;
|
|
179
|
+
centerY: number;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Emitted whenever the selected drawing's on-screen box moves — selection,
|
|
183
|
+
* deselection (payload `null`), drag, edit, pan, zoom or resize. Hosts render
|
|
184
|
+
* their own floating toolbar and position it from `bounds`, keeping it inside
|
|
185
|
+
* `plot`; the chart never has to draw toolbar chrome itself.
|
|
186
|
+
*/
|
|
187
|
+
interface DrawingSelectionChangeEvent {
|
|
188
|
+
drawing: DrawingObjectOptions;
|
|
189
|
+
bounds: DrawingBounds;
|
|
190
|
+
/** Plot rectangle, so a toolbar can be clamped inside the chart area. */
|
|
191
|
+
plot: {
|
|
192
|
+
left: number;
|
|
193
|
+
top: number;
|
|
194
|
+
right: number;
|
|
195
|
+
bottom: number;
|
|
196
|
+
};
|
|
197
|
+
/** True while the drawing is actively being dragged or resized. */
|
|
198
|
+
dragging: boolean;
|
|
167
199
|
}
|
|
168
200
|
interface DrawingHoverEvent {
|
|
169
201
|
drawing: DrawingObjectOptions | null;
|
|
@@ -470,6 +502,67 @@ interface CrosshairPriceActionEvent {
|
|
|
470
502
|
y: number;
|
|
471
503
|
price: number;
|
|
472
504
|
}
|
|
505
|
+
/**
|
|
506
|
+
* What the pointer was over when the context menu was requested. Hosts switch
|
|
507
|
+
* on this to show the right menu instead of re-deriving it from coordinates.
|
|
508
|
+
*/
|
|
509
|
+
type ChartContextMenuRegion = "plot" | "drawing" | "indicator-pane" | "x-axis" | "y-axis";
|
|
510
|
+
interface ChartContextMenuEvent {
|
|
511
|
+
region: ChartContextMenuRegion;
|
|
512
|
+
/** Canvas-relative position. */
|
|
513
|
+
x: number;
|
|
514
|
+
y: number;
|
|
515
|
+
/** Viewport position, ready to place a DOM menu without re-measuring. */
|
|
516
|
+
clientX: number;
|
|
517
|
+
clientY: number;
|
|
518
|
+
/** Price under the pointer (main pane regions only). */
|
|
519
|
+
price?: number;
|
|
520
|
+
index?: number;
|
|
521
|
+
time?: string;
|
|
522
|
+
point?: OhlcDataPoint;
|
|
523
|
+
/** Set for region "drawing"; the drawing is also selected by the chart. */
|
|
524
|
+
drawing?: DrawingObjectOptions;
|
|
525
|
+
drawingTarget?: "line" | "handle";
|
|
526
|
+
pointIndex?: number;
|
|
527
|
+
/** Set for region "indicator-pane". */
|
|
528
|
+
indicator?: {
|
|
529
|
+
id: string;
|
|
530
|
+
type: string;
|
|
531
|
+
};
|
|
532
|
+
}
|
|
533
|
+
/** Built-in keyboard actions, reported after the chart applies them. */
|
|
534
|
+
type ChartKeyboardAction = "delete-drawing" | "cancel" | "pan-left" | "pan-right" | "pan-up" | "pan-down" | "zoom-in" | "zoom-out" | "reset-viewport" | "scroll-to-realtime";
|
|
535
|
+
interface ChartKeyboardShortcutEvent {
|
|
536
|
+
action: ChartKeyboardAction;
|
|
537
|
+
/** The originating `KeyboardEvent.key`. */
|
|
538
|
+
key: string;
|
|
539
|
+
shiftKey: boolean;
|
|
540
|
+
/** The drawing that was removed, for "delete-drawing" (so hosts can undo). */
|
|
541
|
+
drawing?: DrawingObjectOptions;
|
|
542
|
+
}
|
|
543
|
+
interface KeyboardOptions {
|
|
544
|
+
/**
|
|
545
|
+
* Master switch for the built-in shortcuts. Shortcuts only fire while the
|
|
546
|
+
* chart canvas has focus, so they never swallow typing in host inputs.
|
|
547
|
+
* Default true.
|
|
548
|
+
*/
|
|
549
|
+
enabled?: boolean;
|
|
550
|
+
/** Bars panned per arrow-key press (Shift multiplies by 10). Default 1. */
|
|
551
|
+
panBars?: number;
|
|
552
|
+
/** Delete/Backspace removes the selected drawing. Default true. */
|
|
553
|
+
deleteSelectedDrawing?: boolean;
|
|
554
|
+
}
|
|
555
|
+
interface AccessibilityOptions {
|
|
556
|
+
/** aria-label on the canvas. Default "Price chart". */
|
|
557
|
+
label?: string;
|
|
558
|
+
/**
|
|
559
|
+
* Longer description exposed via aria-description, e.g. the symbol and
|
|
560
|
+
* interval currently shown.
|
|
561
|
+
*/
|
|
562
|
+
description?: string;
|
|
563
|
+
/** Make the canvas focusable so keyboard users can reach it. Default true. */
|
|
564
|
+
focusable?: boolean;
|
|
565
|
+
}
|
|
473
566
|
interface TickerLineOptions {
|
|
474
567
|
visible?: boolean;
|
|
475
568
|
style?: "solid" | "dotted" | "dashed";
|
|
@@ -581,8 +674,40 @@ interface ChartInstance {
|
|
|
581
674
|
onDrawingSelect: (handler: ((event: DrawingSelectEvent) => void) | null) => void;
|
|
582
675
|
onDrawingDoubleClick: (handler: ((event: DrawingSelectEvent) => void) | null) => void;
|
|
583
676
|
onDrawingEditText: (handler: ((event: DrawingSelectEvent) => void) | null) => void;
|
|
677
|
+
/**
|
|
678
|
+
* Selection geometry stream for a host-rendered floating toolbar. Fires on
|
|
679
|
+
* select/deselect and on every frame where the selected drawing's box moves
|
|
680
|
+
* (drag, pan, zoom, resize), so the toolbar can track the shape instead of
|
|
681
|
+
* sitting in a fixed corner. Payload is `null` when nothing is selected.
|
|
682
|
+
*/
|
|
683
|
+
onSelectionChange: (handler: ((event: DrawingSelectionChangeEvent | null) => void) | null) => void;
|
|
684
|
+
/** Current selection and its on-screen box, for imperative reads. */
|
|
685
|
+
getSelectedDrawing: () => {
|
|
686
|
+
drawing: DrawingObjectOptions;
|
|
687
|
+
bounds: DrawingBounds;
|
|
688
|
+
} | null;
|
|
689
|
+
/**
|
|
690
|
+
* Right-click (or long-press equivalent) with everything the host needs to
|
|
691
|
+
* open the correct menu: which region was hit, the price/bar under the
|
|
692
|
+
* pointer, and the drawing or indicator pane it landed on. The chart always
|
|
693
|
+
* suppresses the browser's native menu.
|
|
694
|
+
*/
|
|
695
|
+
onContextMenu: (handler: ((event: ChartContextMenuEvent) => void) | null) => void;
|
|
696
|
+
/** Fires after a built-in keyboard shortcut is applied. */
|
|
697
|
+
onKeyboardShortcut: (handler: ((event: ChartKeyboardShortcutEvent) => void) | null) => void;
|
|
698
|
+
/** Focus the chart canvas so keyboard shortcuts apply to it. */
|
|
699
|
+
focus: () => void;
|
|
584
700
|
setMagnetMode: (mode: "none" | "weak" | "strong") => void;
|
|
585
701
|
getMagnetMode: () => "none" | "weak" | "strong";
|
|
702
|
+
/**
|
|
703
|
+
* Change the price-scale mode ("linear" | "log" | "percent") and/or invert
|
|
704
|
+
* the axis. Log maps prices through log10, percent relabels the axis
|
|
705
|
+
* relative to the first visible bar's close (TradingView behavior), and
|
|
706
|
+
* invert flips the axis top-to-bottom. Only the main price pane is
|
|
707
|
+
* affected; indicator panes keep their own scales.
|
|
708
|
+
*/
|
|
709
|
+
setPriceScale: (options: Partial<PriceScaleOptions>) => void;
|
|
710
|
+
getPriceScale: () => PriceScaleOptions;
|
|
586
711
|
cancelDrawing: () => boolean;
|
|
587
712
|
setTradeMarkers: (markers: TradeMarkerOptions[]) => void;
|
|
588
713
|
onDrawingHover: (handler: ((event: DrawingHoverEvent) => void) | null) => void;
|
|
@@ -657,8 +782,15 @@ interface ChartSavedState {
|
|
|
657
782
|
drawings: DrawingObjectOptions[];
|
|
658
783
|
indicators: IndicatorInstanceOptions[];
|
|
659
784
|
magnetMode: "none" | "weak" | "strong";
|
|
785
|
+
/** Optional for backward compatibility with pre-0.1.137 blobs. */
|
|
786
|
+
priceScale?: PriceScaleOptions;
|
|
660
787
|
drawingDefaults: Partial<Record<DrawingToolType, DrawingDefaults>>;
|
|
661
788
|
}
|
|
789
|
+
type PriceScaleMode = "linear" | "log" | "percent";
|
|
790
|
+
interface PriceScaleOptions {
|
|
791
|
+
mode: PriceScaleMode;
|
|
792
|
+
inverted: boolean;
|
|
793
|
+
}
|
|
662
794
|
|
|
663
795
|
interface ScriptIndicatorInputDef {
|
|
664
796
|
key: string;
|
|
@@ -706,6 +838,45 @@ interface ScriptComputeResult {
|
|
|
706
838
|
guides?: number[];
|
|
707
839
|
decimals?: number;
|
|
708
840
|
}
|
|
841
|
+
interface ScriptInputOptions {
|
|
842
|
+
/** Stable settings key; defaults to a slug of the label. */
|
|
843
|
+
key?: string;
|
|
844
|
+
min?: number;
|
|
845
|
+
max?: number;
|
|
846
|
+
step?: number;
|
|
847
|
+
}
|
|
848
|
+
declare const SCRIPT_SOURCE_INPUT_VALUES: readonly ["open", "high", "low", "close", "hl2", "hlc3", "ohlc4"];
|
|
849
|
+
/**
|
|
850
|
+
* The `input` object passed to script top level. In value mode it resolves
|
|
851
|
+
* each declaration against the current settings; in recording mode it
|
|
852
|
+
* additionally appends every declaration to `registry`. Keys are assigned
|
|
853
|
+
* deterministically (same order both modes), so values always line up with
|
|
854
|
+
* the extracted schema.
|
|
855
|
+
*/
|
|
856
|
+
declare const createScriptInputHelper: (values: Record<string, unknown> | null, registry: ScriptIndicatorInputDef[] | null) => Readonly<{
|
|
857
|
+
int: (label: string, defaultValue: number, options?: ScriptInputOptions) => number;
|
|
858
|
+
float: (label: string, defaultValue: number, options?: ScriptInputOptions) => number;
|
|
859
|
+
bool: (label: string, defaultValue?: boolean, options?: ScriptInputOptions) => boolean;
|
|
860
|
+
color: (label: string, defaultValue: string, options?: ScriptInputOptions) => string;
|
|
861
|
+
string: (label: string, defaultValue?: string, options?: ScriptInputOptions) => string;
|
|
862
|
+
select: (label: string, defaultValue: string, choices: ReadonlyArray<string | {
|
|
863
|
+
value: string;
|
|
864
|
+
label: string;
|
|
865
|
+
}>, options?: ScriptInputOptions) => string;
|
|
866
|
+
source: (label?: string, defaultValue?: string, options?: ScriptInputOptions) => string;
|
|
867
|
+
}>;
|
|
868
|
+
type ScriptInputHelper = ReturnType<typeof createScriptInputHelper>;
|
|
869
|
+
/**
|
|
870
|
+
* Discover a script's Pine-style `input.*` declarations by running its top
|
|
871
|
+
* level with a recording helper. Returns the declared schema (empty when the
|
|
872
|
+
* script declares nothing) plus a compile/runtime error message when the
|
|
873
|
+
* script is broken. Runs under the standard execution guard, so an infinite
|
|
874
|
+
* top-level loop returns a budget error instead of hanging the caller.
|
|
875
|
+
*/
|
|
876
|
+
declare const extractScriptInputs: (source: string) => {
|
|
877
|
+
inputs: ScriptIndicatorInputDef[];
|
|
878
|
+
error: string | null;
|
|
879
|
+
};
|
|
709
880
|
/**
|
|
710
881
|
* Compile-check a script without registering it: returns an error message, or
|
|
711
882
|
* `null` when the script compiles. Runs with the same execution guard as the
|
|
@@ -726,4 +897,4 @@ declare const compileScriptIndicator: (definition: ScriptIndicatorDefinition) =>
|
|
|
726
897
|
|
|
727
898
|
declare function createChart(element: HTMLElement, options?: ChartOptions): ChartInstance;
|
|
728
899
|
|
|
729
|
-
export { type AxisOptions, type BuiltInIndicatorInfo, type ChartClickEvent, type ChartInstance, type ChartOptions, type ChartSavedState, type ChartType, type CrosshairMoveEvent, type CrosshairOptions, type CrosshairPriceActionEvent, type DashPatternOptions, type DrawingDefaults, type DrawingHoverEvent, type DrawingObjectOptions, type DrawingPoint, type DrawingSelectEvent, 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 LabelsOptions, type OhlcDataPoint, type OrderActionButton, type OrderActionEvent, type OrderLineOptions, POSITION_DEFAULT_COLORS, type PriceLineOptions, type ScriptComputeResult, type ScriptIndicatorDefinition, type ScriptIndicatorInputDef, type ScriptPlotSpec, type TickerLineOptions, type TradeMarkerOptions, type ViewportState, type WatermarkOptions, compileScriptIndicator, createChart, validateScriptSource };
|
|
900
|
+
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 CrosshairMoveEvent, type CrosshairOptions, type CrosshairPriceActionEvent, type DashPatternOptions, 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 };
|