@pipsend/charts 2.3.1 → 2.3.3

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
@@ -189,7 +189,19 @@ export declare class BrushTool extends DrawingToolBase {
189
189
  private _finishStroke;
190
190
  private _isOverAnotherDrawing;
191
191
  private _releasePointer;
192
+ /**
193
+ * Where a press lands relative to the drawing area, or null if it lands
194
+ * outside it. `clamp` pins the point to the edge instead, for a stroke that
195
+ * is already under way.
196
+ */
192
197
  private _toPanePoint;
198
+ /**
199
+ * The pane's element is the whole row, price axis cells included, so its
200
+ * bounds are not the drawing area's. Taking them for it is what let a press
201
+ * on an axis start a stroke — and be swallowed, leaving the chart unable to
202
+ * be stretched while the brush was armed.
203
+ */
204
+ private _drawArea;
193
205
  private _paneElement;
194
206
  /** At most one repaint per frame, however fast the samples arrive. */
195
207
  private _queueRepaint;
@@ -862,9 +874,6 @@ export declare class HorizontalLineTool extends DrawingToolBase {
862
874
  protected _update(): void;
863
875
  remove(): void;
864
876
  }
865
- /**
866
- * Interactive Line Manager - Permite crear líneas haciendo clic en el gráfico
867
- */
868
877
  export declare class InteractiveLineManager {
869
878
  private _chart;
870
879
  private _series;
@@ -880,24 +889,14 @@ export declare class InteractiveLineManager {
880
889
  */
881
890
  private _getPriceFromMouseEvent;
882
891
  /**
883
- * Activa el modo de creación de líneas por clic
884
- * @param mode - Tipo de línea a crear
885
- * @param customOptions - Opciones personalizadas para líneas custom
886
- * @returns Promesa que se resuelve cuando el usuario hace clic
892
+ * Arms the chart so the next click drops a line.
893
+ *
894
+ * @returns The line, once the user has clicked.
887
895
  */
888
896
  enableClickToCreate(mode: LineCreationMode, customOptions?: Partial<DraggablePriceLineOptions>): Promise<DraggablePriceLine | null>;
889
- /**
890
- * Desactiva el modo de creación por clic
891
- */
892
897
  disableClickToCreate(): void;
893
898
  private _createLineAtPrice;
894
- /**
895
- * Obtiene el modo actual de creación
896
- */
897
899
  getCreationMode(): LineCreationMode;
898
- /**
899
- * Verifica si está en modo de creación
900
- */
901
900
  isCreating(): boolean;
902
901
  }
903
902
  /**
@@ -1206,66 +1205,29 @@ export declare class PositionLine implements ISeriesPrimitive, ControllableLine
1206
1205
  private _applyPrice;
1207
1206
  private _buildRendererData;
1208
1207
  }
1209
- /**
1210
- * Gestor de marcadores de posiciones de trading
1211
- */
1212
1208
  export declare class PositionMarkersManager<TimeType> {
1213
1209
  private _markersPlugin;
1214
1210
  private _positions;
1215
1211
  private _options;
1216
1212
  constructor(series: ISeriesApi<SeriesType, TimeType>, options?: PositionMarkersOptions);
1217
- /**
1218
- * Agrega una posición al gráfico
1219
- */
1220
1213
  addPosition(position: TradingPosition<TimeType>): void;
1221
- /**
1222
- * Agrega múltiples posiciones al gráfico
1223
- */
1224
1214
  addPositions(positions: TradingPosition<TimeType>[]): void;
1225
- /**
1226
- * Establece las posiciones (reemplaza las existentes)
1227
- */
1215
+ /** Replaces every position currently on the chart. */
1228
1216
  setPositions(positions: TradingPosition<TimeType>[]): void;
1229
- /**
1230
- * Cierra una posición abierta agregando el punto de salida
1231
- */
1217
+ /** Closes an open position by giving it an exit point. */
1232
1218
  closePosition(id: string, exit: {
1233
1219
  time: TimeType;
1234
1220
  price: number;
1235
1221
  }, exitText?: string): void;
1236
- /**
1237
- * Elimina una posición por ID
1238
- */
1239
1222
  removePosition(id: string): void;
1240
- /**
1241
- * Limpia todas las posiciones
1242
- */
1243
1223
  clearPositions(): void;
1244
- /**
1245
- * Obtiene todas las posiciones actuales
1246
- */
1247
1224
  getPositions(): readonly TradingPosition<TimeType>[];
1248
- /**
1249
- * Actualiza las opciones del gestor
1250
- */
1251
1225
  applyOptions(options: PositionMarkersOptions): void;
1252
- /**
1253
- * Convierte las posiciones a marcadores de serie
1254
- */
1255
1226
  private _positionsToMarkers;
1256
- /**
1257
- * Actualiza los marcadores en el gráfico
1258
- */
1259
1227
  private _updateMarkers;
1260
- /**
1261
- * Desconecta el plugin y limpia recursos
1262
- */
1263
1228
  detach(): void;
1264
1229
  }
1265
- /**
1266
- * Position Tool - Herramienta unificada para marcar posiciones long/short
1267
- * Muestra dos rectángulos ajustables (profit/loss) con línea vertical conectora
1268
- */
1230
+ /** Two adjustable boxes, profit and loss, joined by a vertical connector. */
1269
1231
  export declare class PositionTool extends DrawingToolBase {
1270
1232
  private _positionOptions;
1271
1233
  private _calculator;
@@ -1424,10 +1386,7 @@ export declare class RulerCalculator {
1424
1386
  */
1425
1387
  getPipConfig(): PipConfig;
1426
1388
  }
1427
- /**
1428
- * Measurement Ruler Tool - Herramienta para medir distancia entre dos puntos
1429
- * Muestra pips, porcentaje, tiempo transcurrido y número de barras
1430
- */
1389
+ /** Measures two points: pips, percent, elapsed time and bar count. */
1431
1390
  export declare class RulerTool extends DrawingToolBase {
1432
1391
  private _rulerOptions;
1433
1392
  private _calculator;
@@ -2337,17 +2296,13 @@ export declare function createHorizontalLineTool(context: DrawingContext, option
2337
2296
  */
2338
2297
  export declare function createImageWatermark<T>(pane: IPaneApi<T>, imageUrl: string, options: DeepPartial<ImageWatermarkOptions>): IImageWatermarkPluginApi<T>;
2339
2298
  /**
2340
- * Crea un manager interactivo para añadir líneas con clics
2341
- * @param chart - Chart instance
2342
- * @param series - Series instance
2343
- * @returns InteractiveLineManager
2299
+ * Lets the user place draggable lines by clicking the chart.
2300
+ *
2344
2301
  * @example
2345
2302
  * ```typescript
2346
2303
  * const manager = createInteractiveLineManager(chart, candleSeries);
2347
- *
2348
- * // Activar modo de creación
2349
2304
  * const line = await manager.enableClickToCreate('stop-loss', {
2350
- * onDragEnd: (price) => console.log('SL:', price)
2305
+ * onDragEnd: (price) => console.log('SL:', price),
2351
2306
  * });
2352
2307
  * ```
2353
2308
  */
@@ -2388,47 +2343,18 @@ export declare function createPolygonTool(context: DrawingContext, options: Poly
2388
2343
  */
2389
2344
  export declare function createPositionLine(series: ISeriesApi<SeriesType>, chart: IChartApi, options: PositionLineOptions): PositionLine;
2390
2345
  /**
2391
- * Crea un gestor de marcadores de posiciones de trading
2392
- *
2393
- * @param series - Serie a la que se adjuntarán los marcadores
2394
- * @param positions - Posiciones iniciales (opcional)
2395
- * @param options - Opciones de configuración (opcional)
2396
- * @returns Instancia del gestor de posiciones
2346
+ * Marks trades on a series with an arrow at the entry and, once closed, at the
2347
+ * exit.
2397
2348
  *
2398
2349
  * @example
2399
2350
  * ```typescript
2400
- * // Crear el gestor
2401
- * const positionMarkers = createPositionMarkers(candleSeries);
2402
- *
2403
- * // Agregar una posición long
2404
- * positionMarkers.addPosition({
2405
- * type: 'long',
2406
- * entry: { time: '2023-01-01', price: 100.50 },
2407
- * exit: { time: '2023-01-05', price: 105.20 },
2408
- * id: 'pos-1'
2409
- * });
2410
- *
2411
- * // Agregar una posición short
2412
- * positionMarkers.addPosition({
2413
- * type: 'short',
2414
- * entry: { time: '2023-01-10', price: 110.00 },
2415
- * exit: { time: '2023-01-15', price: 107.50 },
2416
- * id: 'pos-2'
2417
- * });
2418
- *
2419
- * // Agregar múltiples posiciones
2420
- * positionMarkers.setPositions([
2421
- * {
2351
+ * const markers = createPositionMarkers(candleSeries);
2352
+ * markers.addPosition({
2422
2353
  * type: 'long',
2423
- * entry: { time: '2023-02-01', price: 95.00 },
2424
- * exit: { time: '2023-02-10', price: 98.50 }
2425
- * },
2426
- * {
2427
- * type: 'short',
2428
- * entry: { time: '2023-02-15', price: 102.00 },
2429
- * exit: { time: '2023-02-20', price: 99.00 }
2430
- * }
2431
- * ]);
2354
+ * entry: { time: '2023-01-01', price: 100.50 },
2355
+ * exit: { time: '2023-01-05', price: 105.20 },
2356
+ * id: 'pos-1',
2357
+ * });
2432
2358
  * ```
2433
2359
  */
2434
2360
  export declare function createPositionMarkers<TimeType>(series: ISeriesApi<SeriesType, TimeType>, positions?: TradingPosition<TimeType>[], options?: PositionMarkersOptions): PositionMarkersManager<TimeType>;
@@ -6092,9 +6018,6 @@ export interface ParallelChannelToolOptions extends DrawingToolOptions {
6092
6018
  onRemove?: () => void;
6093
6019
  onComplete?: () => void;
6094
6020
  }
6095
- /**
6096
- * Position Calculator - Cálculos de P&L, pips, R:R para trading
6097
- */
6098
6021
  export interface PipConfig {
6099
6022
  pipValue: number;
6100
6023
  decimals: number;
@@ -6344,37 +6267,19 @@ export interface PositionLineUpdate extends Partial<Omit<PositionLineOptions, "e
6344
6267
  takeProfit?: Partial<PositionLineLevelOptions>;
6345
6268
  stopLoss?: Partial<PositionLineLevelOptions>;
6346
6269
  }
6347
- /**
6348
- * Opciones para el gestor de posiciones
6349
- */
6350
6270
  export interface PositionMarkersOptions {
6351
- /**
6352
- * Colores predeterminados para posiciones long
6353
- */
6354
6271
  longColors?: {
6355
6272
  entry?: string;
6356
6273
  exit?: string;
6357
6274
  };
6358
- /**
6359
- * Colores predeterminados para posiciones short
6360
- */
6361
6275
  shortColors?: {
6362
6276
  entry?: string;
6363
6277
  exit?: string;
6364
6278
  };
6365
- /**
6366
- * Tamaño predeterminado de las flechas
6367
- */
6368
6279
  defaultSize?: number;
6369
- /**
6370
- * Offset vertical para las flechas de entrada (en puntos de precio)
6371
- * Positivo = arriba, Negativo = abajo
6372
- */
6280
+ /** Vertical offset of the entry arrow, in price points. Positive is up. */
6373
6281
  entryOffset?: number;
6374
- /**
6375
- * Offset vertical para las flechas de salida (en puntos de precio)
6376
- * Positivo = arriba, Negativo = abajo
6377
- */
6282
+ /** Vertical offset of the exit arrow, in price points. Positive is up. */
6378
6283
  exitOffset?: number;
6379
6284
  }
6380
6285
  export interface PositionMetrics {
@@ -7544,47 +7449,26 @@ export interface TradingLineOptions {
7544
7449
  */
7545
7450
  formatTitle?: (price: number) => string;
7546
7451
  }
7547
- /**
7548
- * Representa una posición de trading con punto de entrada y salida opcional
7549
- */
7452
+ /** A trade, with an exit once it is closed. */
7550
7453
  export interface TradingPosition<TimeType> {
7551
- /**
7552
- * Tipo de posición (long o short)
7553
- */
7554
7454
  type: PositionType;
7555
- /**
7556
- * Punto de entrada
7557
- */
7558
7455
  entry: {
7559
7456
  time: TimeType;
7560
7457
  price: number;
7561
7458
  };
7562
- /**
7563
- * Punto de salida (opcional - para posiciones abiertas)
7564
- */
7459
+ /** Absent while the position is still open. */
7565
7460
  exit?: {
7566
7461
  time: TimeType;
7567
7462
  price: number;
7568
7463
  };
7569
- /**
7570
- * ID opcional para identificar la posición
7571
- */
7572
7464
  id?: string;
7573
- /**
7574
- * Color personalizado para las flechas (opcional)
7575
- * Si no se especifica, se usarán colores predeterminados según el tipo
7576
- */
7465
+ /** Overrides the colours the position type would otherwise pick. */
7577
7466
  color?: {
7578
7467
  entry?: string;
7579
7468
  exit?: string;
7580
7469
  };
7581
- /**
7582
- * Tamaño de las flechas (opcional, por defecto 1)
7583
- */
7470
+ /** @defaultValue 1 */
7584
7471
  size?: number;
7585
- /**
7586
- * Texto opcional para las flechas
7587
- */
7588
7472
  text?: {
7589
7473
  entry?: string;
7590
7474
  exit?: string;
@@ -8050,9 +7934,6 @@ export type PositionLineLevel = "entry" | "takeProfit" | "stopLoss";
8050
7934
  * The parts of a level that respond to the pointer.
8051
7935
  */
8052
7936
  export type PositionLinePart = "line" | "body" | "close";
8053
- /**
8054
- * Tipo de posición de trading
8055
- */
8056
7937
  export type PositionType = "long" | "short";
8057
7938
  /**
8058
7939
  * Represents information used to format prices.
package/package.json CHANGED
@@ -1,5 +1,6 @@
1
1
  {
2
- "version": "2.3.1",
2
+ "private": false,
3
+ "version": "2.3.3",
3
4
  "name": "@pipsend/charts",
4
5
  "author": "Pipsend",
5
6
  "license": "SEE LICENSE IN LICENSE",
@@ -53,7 +54,88 @@
53
54
  "bollinger-bands",
54
55
  "financial-analysis"
55
56
  ],
57
+ "engines": {
58
+ "node": ">=22.3"
59
+ },
56
60
  "dependencies": {
57
61
  "fancy-canvas": "2.1.0"
62
+ },
63
+ "devDependencies": {
64
+ "@juggle/resize-observer": "3.4.0",
65
+ "@rollup/plugin-node-resolve": "16.0.1",
66
+ "@rollup/plugin-replace": "6.0.2",
67
+ "@rollup/plugin-terser": "0.4.4",
68
+ "@size-limit/file": "11.2.0",
69
+ "@size-limit/webpack": "11.2.0",
70
+ "@types/chai": "5.2.1",
71
+ "@types/express": "5.0.1",
72
+ "@types/glob": "8.1.0",
73
+ "@types/node": "22",
74
+ "@types/pixelmatch": "5.2.6",
75
+ "@types/pngjs": "6.0.5",
76
+ "@typescript-eslint/eslint-plugin": "7.18.0",
77
+ "@typescript-eslint/eslint-plugin-tslint": "7.0.2",
78
+ "@typescript-eslint/parser": "7.18.0",
79
+ "ajv": "7.2.4",
80
+ "bytes": "3.1.2",
81
+ "chai": "5.2.0",
82
+ "chai-exclude": "3.0.1",
83
+ "cross-env": "7.0.3",
84
+ "dts-bundle-generator": "9.5.1",
85
+ "eslint": "8",
86
+ "eslint-formatter-unix": "8.40.0",
87
+ "eslint-plugin-deprecation": "3.0.0",
88
+ "eslint-plugin-import": "2.31.0",
89
+ "eslint-plugin-unicorn": "56.0.1",
90
+ "esno": "4.8.0",
91
+ "glob": "11.0.1",
92
+ "markdown-it": "14.1.0",
93
+ "markdown-it-anchor": "9.2.0",
94
+ "markdownlint-cli": "0.44.0",
95
+ "npm-run-all": "4.1.5",
96
+ "rimraf": "6.0.1",
97
+ "rollup": "4.40.0",
98
+ "size-limit": "11.2.0",
99
+ "ts-node": "10.9.2",
100
+ "ts-patch": "3.3.0",
101
+ "ts-transformer-properties-rename": "0.17.0",
102
+ "ts-transformer-strip-const-enums": "2.0.0",
103
+ "tslib": "2.8.1",
104
+ "tslint": "6.1.3",
105
+ "tslint-eslint-rules": "5.4.0",
106
+ "tslint-microsoft-contrib": "6.2.0",
107
+ "tsx": "4.19.3",
108
+ "typescript": "5.5.4",
109
+ "yargs": "17.7.2"
110
+ },
111
+ "scripts": {
112
+ "prepare": "node scripts/githooks/install.js || true",
113
+ "clean": "rimraf lib/ dist/",
114
+ "bundle-dts": "dts-bundle-generator --config dts-config.json",
115
+ "tsc": "tspc -p tsconfig.prod.json",
116
+ "tsc-watch": "npm run tsc -- --watch --preserveWatchOutput",
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
+ "lint": "npm-run-all -p lint:**",
119
+ "lint:eslint": "eslint --format=unix ./",
120
+ "lint:md": "markdownlint -i \"**/node_modules/**\" -i \"**/website/docs/api/**\" -i \"**/website/versioned_docs/**/api/**\" -i \"**/*.mdx\" \"**/*.md\"",
121
+ "check-dts-docs": "npm-run-all -p check-dts-docs-duplicates check-dts-docs-eslint",
122
+ "check-dts-docs-duplicates": "node ./scripts/check-typings-for-duplicates.js ./dist/typings.d.ts",
123
+ "check-dts-docs-eslint": "eslint --format=unix ./dist/typings.d.ts --no-ignore",
124
+ "check-markdown-links": "node scripts/check-markdown-links.js",
125
+ "rollup": "rollup -c rollup.config.js",
126
+ "rollup-watch": "npm run rollup -- --watch",
127
+ "build": "npm-run-all tsc rollup bundle-dts",
128
+ "build:watch": "npm-run-all tsc -p tsc-watch rollup-watch",
129
+ "build:prod": "cross-env NODE_ENV=production npm run build",
130
+ "build:release": "cross-env BUILD_TAG=release npm run build:prod",
131
+ "prepare-release": "npm-run-all clean build:release && npm run prepare-package-json-for-release",
132
+ "prepare-package-json-for-release": "node ./scripts/clean-package-json.js",
133
+ "size-limit": "size-limit",
134
+ "verify": "npm-run-all clean -p build:prod check-markdown-links -p lint check-dts-docs tsc-verify test size-limit -p type-tests",
135
+ "test": "esno --import ./tests/unittests/setup.units.mjs --test './tests/unittests/**/*.spec.ts'",
136
+ "type-tests": "tsc -b ./src/tsconfig.composite.json && tsc -p ./tests/type-checks/tsconfig.composite.json --noEmit",
137
+ "e2e:coverage": "esno ./tests/e2e/coverage/runner.ts ./dist/pipsend-charts.standalone.development.js",
138
+ "e2e:interactions": "esno ./tests/e2e/interactions/runner.ts ./dist/pipsend-charts.standalone.development.js",
139
+ "e2e:memleaks": "esno ./tests/e2e/memleaks/runner.ts ./dist/pipsend-charts.standalone.development.js"
58
140
  }
59
141
  }