@pipsend/charts 1.1.3 → 1.2.1

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/typings.d.ts CHANGED
@@ -24,6 +24,7 @@ declare abstract class DrawingToolBase implements IDrawingTool {
24
24
  isVisible(): boolean;
25
25
  getState(): DrawingToolState;
26
26
  abstract remove(): void;
27
+ abstract serialize(): SerializedDrawingTool;
27
28
  protected abstract _update(): void;
28
29
  }
29
30
  declare const areaSeries: SeriesDefinition<"Area">;
@@ -73,6 +74,7 @@ export declare class ArrowTool extends DrawingToolBase {
73
74
  getPoints(): ArrowPoint[];
74
75
  addPoint(point: ArrowPoint): void;
75
76
  isVisible(): boolean;
77
+ serialize(): SerializedDrawingTool;
76
78
  private _requestUpdate;
77
79
  protected _update(): void;
78
80
  remove(): void;
@@ -119,6 +121,7 @@ export declare class BrushTool extends DrawingToolBase {
119
121
  stopDrag(): void;
120
122
  updateDrag(time: Time, price: number): void;
121
123
  isVisible(): boolean;
124
+ serialize(): SerializedDrawingTool;
122
125
  private _requestUpdate;
123
126
  protected _update(): void;
124
127
  remove(): void;
@@ -153,12 +156,13 @@ export declare class CircleTool extends DrawingToolBase {
153
156
  stopDrag(): void;
154
157
  updateDrag(time: Time, price: number): void;
155
158
  isVisible(): boolean;
159
+ serialize(): SerializedDrawingTool;
156
160
  private _requestUpdate;
157
161
  protected _update(): void;
158
162
  remove(): void;
159
163
  }
160
164
  /**
161
- * Draggable Price Line - Línea de precio que se puede arrastrar con el mouse
165
+ * Draggable Price Line - Línea de precio que se puede arrastrar y/o hacer click
162
166
  */
163
167
  export declare class DraggablePriceLine {
164
168
  private _chart;
@@ -170,9 +174,11 @@ export declare class DraggablePriceLine {
170
174
  private _unsubscribeHandlers;
171
175
  private _isHovering;
172
176
  private _originalColor;
177
+ private _mouseDownPos;
178
+ private _mouseDownOnLine;
173
179
  constructor(chart: IChartApi, series: ISeriesApi<SeriesType>, options: DraggablePriceLineOptions);
174
180
  private _createPriceLine;
175
- private _setupDragHandlers;
181
+ private _setupInteractionHandlers;
176
182
  private _getPriceFromY;
177
183
  /**
178
184
  * Verifica si el mouse está EN la línea (no cerca, sino exactamente sobre ella)
@@ -283,6 +289,27 @@ export declare class DrawingToolsManager {
283
289
  * Check if a tool is selected
284
290
  */
285
291
  isToolSelected(id: string): boolean;
292
+ /**
293
+ * Serialize all managed tools into a JSON-safe array
294
+ */
295
+ serializeAll(): SerializedDrawingTool[];
296
+ /**
297
+ * Restore a single tool from serialized data
298
+ */
299
+ restoreTool(context: DrawingContext, data: SerializedDrawingTool): DrawingToolBase;
300
+ /**
301
+ * Restore all tools from a serialized array, optionally clearing existing tools first
302
+ */
303
+ restoreAll(context: DrawingContext, tools: SerializedDrawingTool[], clearExisting?: boolean): void;
304
+ /**
305
+ * Create a tool instance from serialized data (static helper).
306
+ *
307
+ * IMPORTANT: Uses bracket notation (`p['time']`, `p['price']`) when reading
308
+ * from serialized JSON data. This prevents the build-time property mangler
309
+ * from rewriting these accesses to `p._internal_time` / `p._internal_price`,
310
+ * which would fail on plain JSON objects that have literal `time`/`price` keys.
311
+ */
312
+ private static _createToolFromData;
286
313
  /**
287
314
  * Destroy the manager and cleanup
288
315
  */
@@ -378,6 +405,7 @@ export declare class FibonacciExtensionTool extends DrawingToolBase {
378
405
  }>;
379
406
  drawToCanvas(ctx: CanvasRenderingContext2D, horizontalPixelRatio: number, verticalPixelRatio: number): void;
380
407
  isVisible(): boolean;
408
+ serialize(): SerializedDrawingTool;
381
409
  private _requestUpdate;
382
410
  protected _update(): void;
383
411
  remove(): void;
@@ -413,6 +441,7 @@ export declare class FibonacciFanTool extends DrawingToolBase {
413
441
  stopDrag(): void;
414
442
  updateDrag(time: Time, price: number): void;
415
443
  isVisible(): boolean;
444
+ serialize(): SerializedDrawingTool;
416
445
  private _requestUpdate;
417
446
  protected _update(): void;
418
447
  remove(): void;
@@ -445,6 +474,7 @@ export declare class FibonacciTool extends DrawingToolBase {
445
474
  getMetrics(): FibonacciMetrics | null;
446
475
  getLevels(): FibonacciLevel[];
447
476
  isVisible(): boolean;
477
+ serialize(): SerializedDrawingTool;
448
478
  useExtendedLevels(extended: boolean): void;
449
479
  private _initializeInteractiveMode;
450
480
  private _drawPreview;
@@ -486,6 +516,7 @@ export declare class GanttTool extends DrawingToolBase {
486
516
  setHovered(hovered: boolean): void;
487
517
  hitTest(x: number, y: number): boolean;
488
518
  isVisible(): boolean;
519
+ serialize(): SerializedDrawingTool;
489
520
  private _requestUpdate;
490
521
  protected _update(): void;
491
522
  remove(): void;
@@ -514,6 +545,7 @@ export declare class HorizontalLineTool extends DrawingToolBase {
514
545
  setPrice(price: number): void;
515
546
  setLabel(text: string): void;
516
547
  isVisible(): boolean;
548
+ serialize(): SerializedDrawingTool;
517
549
  private _requestUpdate;
518
550
  protected _update(): void;
519
551
  remove(): void;
@@ -698,6 +730,7 @@ export declare class PositionTool extends DrawingToolBase {
698
730
  * Set entry price
699
731
  */
700
732
  setEntryPrice(price: number): void;
733
+ serialize(): SerializedDrawingTool;
701
734
  setSelected(selected: boolean): void;
702
735
  isSelected(): boolean;
703
736
  setHovered(hovered: boolean): void;
@@ -743,6 +776,7 @@ export declare class RectangleTool extends DrawingToolBase {
743
776
  stopDrag(): void;
744
777
  updateDrag(time: Time, price: number): void;
745
778
  isVisible(): boolean;
779
+ serialize(): SerializedDrawingTool;
746
780
  private _requestUpdate;
747
781
  protected _update(): void;
748
782
  remove(): void;
@@ -835,6 +869,7 @@ export declare class RulerTool extends DrawingToolBase {
835
869
  hitTestEndpoint(x: number, y: number): "point1" | "point2" | null;
836
870
  private _requestUpdate;
837
871
  protected _update(): void;
872
+ serialize(): SerializedDrawingTool;
838
873
  setSelected(selected: boolean): void;
839
874
  isSelected(): boolean;
840
875
  isComplete(): boolean;
@@ -882,6 +917,7 @@ export declare class TextTool extends DrawingToolBase {
882
917
  updateDrag(time: Time, price: number): void;
883
918
  drawToCanvas(ctx: CanvasRenderingContext2D, horizontalPixelRatio: number, verticalPixelRatio: number): void;
884
919
  private _hexToRgba;
920
+ serialize(): SerializedDrawingTool;
885
921
  remove(): void;
886
922
  }
887
923
  export declare class TradingSessionsIndicator {
@@ -943,6 +979,7 @@ export declare class TrendLineTool extends DrawingToolBase {
943
979
  stopDrag(): void;
944
980
  updateDrag(time: Time, price: number): void;
945
981
  isVisible(): boolean;
982
+ serialize(): SerializedDrawingTool;
946
983
  private _requestUpdate;
947
984
  protected _update(): void;
948
985
  remove(): void;
@@ -971,6 +1008,7 @@ export declare class VerticalLineTool extends DrawingToolBase {
971
1008
  setTime(time: Time): void;
972
1009
  setLabel(text: string): void;
973
1010
  isVisible(): boolean;
1011
+ serialize(): SerializedDrawingTool;
974
1012
  private _requestUpdate;
975
1013
  protected _update(): void;
976
1014
  remove(): void;
@@ -2441,6 +2479,12 @@ export interface DraggablePriceLineOptions {
2441
2479
  onDragStart?: (price: number) => void;
2442
2480
  onDragMove?: (price: number) => void;
2443
2481
  onDragEnd?: (price: number) => void;
2482
+ /**
2483
+ * Fires when the user clicks the line without dragging it.
2484
+ * Triggered on mouseup if the mouse moved less than CLICK_TOLERANCE_PX
2485
+ * from the initial mousedown position. Works regardless of `draggable`.
2486
+ */
2487
+ onClick?: (price: number) => void;
2444
2488
  }
2445
2489
  /**
2446
2490
  * Context passed to drawing tools
@@ -3180,6 +3224,7 @@ export interface IDrawingTool {
3180
3224
  isLocked(): boolean;
3181
3225
  isVisible(): boolean;
3182
3226
  getState(): DrawingToolState;
3227
+ serialize(): SerializedDrawingTool;
3183
3228
  }
3184
3229
  /**
3185
3230
  * Class interface for Horizontal scale behavior
@@ -5231,6 +5276,19 @@ export interface SMAOptions {
5231
5276
  color?: string;
5232
5277
  lineWidth?: number;
5233
5278
  }
5279
+ /**
5280
+ * Serialized drawing tool data — plain JSON-safe object
5281
+ * with everything needed to recreate a tool.
5282
+ */
5283
+ export interface SerializedDrawingTool {
5284
+ type: string;
5285
+ points: Array<{
5286
+ price: number;
5287
+ time: Time | null;
5288
+ }>;
5289
+ style: Record<string, any>;
5290
+ extra?: Record<string, any>;
5291
+ }
5234
5292
  /**
5235
5293
  * Object containing references to the chart and series instances, and a requestUpdate method for triggering
5236
5294
  * a refresh of the chart.
@@ -5907,6 +5965,8 @@ export interface TradingLineOptions {
5907
5965
  onDragStart?: (price: number) => void;
5908
5966
  onDragMove?: (price: number) => void;
5909
5967
  onDragEnd?: (price: number) => void;
5968
+ /** Fires on a click that didn't drag (works for non-draggable lines too). */
5969
+ onClick?: (price: number) => void;
5910
5970
  }
5911
5971
  /**
5912
5972
  * Representa una posición de trading con punto de entrada y salida opcional
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "private": false,
3
- "version": "1.1.3",
3
+ "version": "1.2.1",
4
4
  "name": "@pipsend/charts",
5
5
  "author": "Pipsend",
6
6
  "license": "SEE LICENSE IN LICENSE",
@@ -114,7 +114,7 @@
114
114
  "bundle-dts": "dts-bundle-generator --config dts-config.json",
115
115
  "tsc": "tspc -p tsconfig.prod.json",
116
116
  "tsc-watch": "npm run tsc -- --watch --preserveWatchOutput",
117
- "tsc-verify": "node website/scripts/generate-versions-dts.js && tsc -b tsconfig.composite.json",
117
+ "tsc-verify": "node -e \"const fs=require('fs');const p='website/scripts/generate-versions-dts.js'; if(fs.existsSync(p)){require('child_process').execSync('node '+p,{stdio:'inherit'});} else {console.warn('[tsc-verify] skip: '+p+' not found');}\" && tsc -b tsconfig.composite.json",
118
118
  "lint": "npm-run-all -p lint:**",
119
119
  "lint:eslint": "eslint --format=unix ./",
120
120
  "lint:md": "markdownlint -i \"**/node_modules/**\" -i \"**/website/docs/api/**\" -i \"**/website/versioned_docs/**/api/**\" -i \"**/*.mdx\" \"**/*.md\"",