@simahfud/klinecharts-pro 1.0.0 → 1.0.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.
Files changed (3) hide show
  1. package/README.md +14 -14
  2. package/dist/index.d.ts +556 -0
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -73,7 +73,7 @@ A professional-grade, TradingView-inspired charting component built on [KLineCha
73
73
  ### Using npm
74
74
 
75
75
  ```bash
76
- npm install klinecharts @klinecharts/pro
76
+ npm install klinecharts @simahfud/klinecharts-pro
77
77
  ```
78
78
 
79
79
  ### Using unpkg or jsDelivr (CDN)
@@ -86,12 +86,12 @@ The library is published as a UMD bundle, so you can load it directly via `<scri
86
86
 
87
87
  <!-- KLineChart Pro -->
88
88
  <!-- using unpkg -->
89
- <script src="https://unpkg.com/@klinecharts/pro/dist/klinecharts-pro.umd.js"></script>
89
+ <script src="https://unpkg.com/@simahfud/klinecharts-pro/dist/klinecharts-pro.umd.js"></script>
90
90
  <!-- OR using jsDelivr -->
91
- <script src="https://cdn.jsdelivr.net/npm/@klinecharts/pro/dist/klinecharts-pro.umd.js"></script>
91
+ <script src="https://cdn.jsdelivr.net/npm/@simahfud/klinecharts-pro/dist/klinecharts-pro.umd.js"></script>
92
92
 
93
93
  <!-- CSS styles (required) -->
94
- <link rel="stylesheet" href="https://unpkg.com/@klinecharts/pro/dist/klinecharts-pro.css" />
94
+ <link rel="stylesheet" href="https://unpkg.com/@simahfud/klinecharts-pro/dist/klinecharts-pro.css" />
95
95
  ```
96
96
 
97
97
  After loading, the global variable `klinechartspro` is available:
@@ -100,13 +100,13 @@ After loading, the global variable `klinechartspro` is available:
100
100
  <!DOCTYPE html>
101
101
  <html>
102
102
  <head>
103
- <link rel="stylesheet" href="https://unpkg.com/@klinecharts/pro/dist/klinecharts-pro.css" />
103
+ <link rel="stylesheet" href="https://unpkg.com/@simahfud/klinecharts-pro/dist/klinecharts-pro.css" />
104
104
  </head>
105
105
  <body>
106
106
  <div id="chart-container" style="width:100%;height:600px;"></div>
107
107
 
108
108
  <script src="https://unpkg.com/klinecharts/dist/klinecharts.min.js"></script>
109
- <script src="https://unpkg.com/@klinecharts/pro/dist/klinecharts-pro.umd.js"></script>
109
+ <script src="https://unpkg.com/@simahfud/klinecharts-pro/dist/klinecharts-pro.umd.js"></script>
110
110
  <script>
111
111
  // Access via global: klinechartspro
112
112
  const { KLineChartPro, DefaultDatafeed } = klinechartspro
@@ -140,7 +140,7 @@ npm run build-core # → dist/klinecharts-pro.umd.js + klinecharts-pro.js + kl
140
140
  ## 🚀 Quick Start
141
141
 
142
142
  ```typescript
143
- import { KLineChartPro, DefaultDatafeed } from 'klinecharts-pro'
143
+ import { KLineChartPro, DefaultDatafeed } from '@simahfud/klinecharts-pro'
144
144
 
145
145
  const chart = new KLineChartPro({
146
146
  container: 'chart-container',
@@ -210,7 +210,7 @@ chart.stopReplay()
210
210
  **Programmatic control via `BarReplayManager`:**
211
211
 
212
212
  ```typescript
213
- import { BarReplayManager } from 'klinecharts-pro'
213
+ import { BarReplayManager } from '@simahfud/klinecharts-pro'
214
214
 
215
215
  const replay = new BarReplayManager(chartWidget, datafeed)
216
216
 
@@ -255,7 +255,7 @@ chart.showStyleEditor('overlay_id_123')
255
255
  ### Keyboard Shortcuts
256
256
 
257
257
  ```typescript
258
- import { KeyboardShortcutManager } from 'klinecharts-pro'
258
+ import { KeyboardShortcutManager } from '@simahfud/klinecharts-pro'
259
259
 
260
260
  const shortcuts = new KeyboardShortcutManager(containerElement)
261
261
 
@@ -274,7 +274,7 @@ shortcuts.destroy()
274
274
  ### Chart Templates
275
275
 
276
276
  ```typescript
277
- import { ChartTemplateManager } from 'klinecharts-pro'
277
+ import { ChartTemplateManager } from '@simahfud/klinecharts-pro'
278
278
 
279
279
  const templates = new ChartTemplateManager(chartStore)
280
280
 
@@ -299,7 +299,7 @@ templates.deleteTemplate('My Scalping Setup')
299
299
  ### Crosshair Sync
300
300
 
301
301
  ```typescript
302
- import { CrosshairSyncManager } from 'klinecharts-pro'
302
+ import { CrosshairSyncManager } from '@simahfud/klinecharts-pro'
303
303
 
304
304
  const sync = new CrosshairSyncManager()
305
305
 
@@ -314,7 +314,7 @@ sync.destroy()
314
314
  ### Custom Indicators & Overlays
315
315
 
316
316
  ```typescript
317
- import { registerCustomIndicator, registerCustomOverlay } from 'klinecharts-pro'
317
+ import { registerCustomIndicator, registerCustomOverlay } from '@simahfud/klinecharts-pro'
318
318
 
319
319
  // Register a custom indicator (auto-appears in Indicator menu)
320
320
  registerCustomIndicator({
@@ -341,7 +341,7 @@ chart.removeAlert('alert1')
341
341
  ### Multi-Symbol Comparison
342
342
 
343
343
  ```typescript
344
- import { ComparisonManager } from 'klinecharts-pro'
344
+ import { ComparisonManager } from '@simahfud/klinecharts-pro'
345
345
 
346
346
  const comparison = new ComparisonManager(chartWidget, datafeed)
347
347
  await comparison.addSymbol({ ticker: 'MSFT' }, period, from, to)
@@ -356,7 +356,7 @@ comparison.destroy()
356
356
  ## 📊 DefaultDatafeed
357
357
 
358
358
  ```typescript
359
- import { DefaultDatafeed } from 'klinecharts-pro'
359
+ import { DefaultDatafeed } from '@simahfud/klinecharts-pro'
360
360
 
361
361
  // Uses Polygon.io API
362
362
  const datafeed = new DefaultDatafeed('YOUR_API_KEY')
@@ -0,0 +1,556 @@
1
+ import { Chart, DeepPartial, IndicatorTemplate, KLineData, Nullable, OverlayTemplate, Styles } from 'klinecharts';
2
+
3
+ export interface SymbolInfo {
4
+ ticker: string;
5
+ name?: string;
6
+ shortName?: string;
7
+ exchange?: string;
8
+ market?: string;
9
+ pricePrecision?: number;
10
+ volumePrecision?: number;
11
+ priceCurrency?: string;
12
+ type?: string;
13
+ logo?: string;
14
+ }
15
+ export interface Period {
16
+ multiplier: number;
17
+ timespan: string;
18
+ text: string;
19
+ }
20
+ export type DatafeedSubscribeCallback = (data: KLineData) => void;
21
+ export interface Datafeed {
22
+ searchSymbols(search?: string): Promise<SymbolInfo[]>;
23
+ getHistoryKLineData(symbol: SymbolInfo, period: Period, from: number, to: number): Promise<KLineData[]>;
24
+ subscribe(symbol: SymbolInfo, period: Period, callback: DatafeedSubscribeCallback): void;
25
+ unsubscribe(symbol: SymbolInfo, period: Period): void;
26
+ }
27
+ export interface PersistenceOptions {
28
+ enabled: boolean;
29
+ prefix?: string;
30
+ }
31
+ export type AlertCondition = "crosses_above" | "crosses_below" | "reaches";
32
+ export interface AlertConfig {
33
+ id: string;
34
+ symbol: string;
35
+ condition: AlertCondition;
36
+ price: number;
37
+ message?: string;
38
+ triggered?: boolean;
39
+ callback?: () => void;
40
+ }
41
+ export interface CustomIndicatorConfig {
42
+ name: string;
43
+ category: "main" | "sub";
44
+ shortName?: string;
45
+ calcParams?: any[];
46
+ figures?: any[];
47
+ calc?: (kLineDataList: KLineData[], params: any) => any[];
48
+ }
49
+ export interface ChartProOptions {
50
+ container: string | HTMLElement;
51
+ styles?: DeepPartial<Styles>;
52
+ watermark?: string | Node;
53
+ theme?: string;
54
+ locale?: string;
55
+ drawingBarVisible?: boolean;
56
+ symbol: SymbolInfo;
57
+ period: Period;
58
+ periods?: Period[];
59
+ timezone?: string;
60
+ mainIndicators?: string[];
61
+ subIndicators?: string[];
62
+ datafeed: Datafeed;
63
+ persistence?: PersistenceOptions;
64
+ onError?: (error: Error) => void;
65
+ }
66
+ export interface ChartPro {
67
+ setTheme(theme: string): void;
68
+ getTheme(): string;
69
+ setStyles(styles: DeepPartial<Styles>): void;
70
+ getStyles(): Styles;
71
+ setLocale(locale: string): void;
72
+ getLocale(): string;
73
+ setTimezone(timezone: string): void;
74
+ getTimezone(): string;
75
+ setSymbol(symbol: SymbolInfo): void;
76
+ getSymbol(): SymbolInfo;
77
+ setPeriod(period: Period): void;
78
+ getPeriod(): Period;
79
+ ready?(): Promise<void>;
80
+ destroy?(): void;
81
+ setAlert?(alert: AlertConfig): void;
82
+ removeAlert?(id: string): void;
83
+ getAlerts?(): AlertConfig[];
84
+ addComparisonSymbol?(symbol: SymbolInfo): void;
85
+ removeComparisonSymbol?(ticker: string): void;
86
+ registerCustomIndicator?(config: CustomIndicatorConfig): void;
87
+ setChartType?(type: string): void;
88
+ getChartType?(): string;
89
+ startReplay?(dataSource: "current" | "custom"): void;
90
+ stopReplay?(): void;
91
+ showObjectTree?(): void;
92
+ showStyleEditor?(overlayId: string): void;
93
+ }
94
+ export type ConnectionStatus = "disconnected" | "connecting" | "connected" | "reconnecting";
95
+ export type ConnectionStatusCallback = (status: ConnectionStatus) => void;
96
+ export declare class DefaultDatafeed implements Datafeed {
97
+ constructor(apiKey: string);
98
+ private _apiKey;
99
+ private _prevSymbolMarket?;
100
+ private _prevSymbolTicker?;
101
+ private _ws?;
102
+ private _callback?;
103
+ private _connectionStatusCallback?;
104
+ private _reconnectAttempts;
105
+ private _maxReconnectAttempts;
106
+ private _reconnectTimer?;
107
+ private _currentSymbol?;
108
+ private _connectionStatus;
109
+ onConnectionStatusChange(callback: ConnectionStatusCallback): void;
110
+ getConnectionStatus(): ConnectionStatus;
111
+ private _setConnectionStatus;
112
+ searchSymbols(search?: string): Promise<SymbolInfo[]>;
113
+ getHistoryKLineData(symbol: SymbolInfo, period: Period, from: number, to: number): Promise<KLineData[]>;
114
+ subscribe(symbol: SymbolInfo, period: Period, callback: DatafeedSubscribeCallback): void;
115
+ unsubscribe(symbol: SymbolInfo, _period: Period): void;
116
+ destroy(): void;
117
+ private _connectWebSocket;
118
+ private _attemptReconnect;
119
+ private _cleanupWebSocket;
120
+ }
121
+ export declare class KLineChartPro implements ChartPro {
122
+ constructor(options: ChartProOptions);
123
+ private _container;
124
+ private _chartApi;
125
+ private _readyPromise;
126
+ private _readyResolve;
127
+ ready(): Promise<void>;
128
+ setTheme(theme: string): void;
129
+ getTheme(): string;
130
+ setStyles(styles: DeepPartial<Styles>): void;
131
+ getStyles(): Styles;
132
+ setLocale(locale: string): void;
133
+ getLocale(): string;
134
+ setTimezone(timezone: string): void;
135
+ getTimezone(): string;
136
+ setSymbol(symbol: SymbolInfo): void;
137
+ getSymbol(): SymbolInfo;
138
+ setPeriod(period: Period): void;
139
+ getPeriod(): Period;
140
+ destroy(): void;
141
+ }
142
+ export interface StoredPreferences {
143
+ theme?: string;
144
+ locale?: string;
145
+ timezone?: string;
146
+ symbol?: SymbolInfo;
147
+ period?: Period;
148
+ mainIndicators?: string[];
149
+ subIndicators?: string[];
150
+ styles?: Record<string, any>;
151
+ drawings?: Record<string, any[]>;
152
+ alerts?: AlertConfig[];
153
+ }
154
+ /**
155
+ * Persistence layer using localStorage.
156
+ * All keys are namespaced with the storage prefix to avoid collisions.
157
+ */
158
+ export declare class ChartStore {
159
+ private _prefix;
160
+ private _enabled;
161
+ constructor(enabled?: boolean, prefix?: string);
162
+ private _key;
163
+ private _get;
164
+ private _set;
165
+ private _remove;
166
+ getTheme(): string | null;
167
+ setTheme(theme: string): void;
168
+ getLocale(): string | null;
169
+ setLocale(locale: string): void;
170
+ getTimezone(): string | null;
171
+ setTimezone(timezone: string): void;
172
+ getSymbol(): SymbolInfo | null;
173
+ setSymbol(symbol: SymbolInfo): void;
174
+ getPeriod(): Period | null;
175
+ setPeriod(period: Period): void;
176
+ getMainIndicators(): string[] | null;
177
+ setMainIndicators(indicators: string[]): void;
178
+ getSubIndicators(): Record<string, string> | null;
179
+ setSubIndicators(indicators: Record<string, string>): void;
180
+ getStyles(): Record<string, any> | null;
181
+ setStyles(styles: Record<string, any>): void;
182
+ getDrawings(ticker: string): any[] | null;
183
+ setDrawings(ticker: string, drawings: any[]): void;
184
+ getAlerts(): AlertConfig[];
185
+ setAlerts(alerts: AlertConfig[]): void;
186
+ addAlert(alert: AlertConfig): void;
187
+ removeAlert(id: string): void;
188
+ getAll(): StoredPreferences;
189
+ clear(): void;
190
+ }
191
+ export interface DrawingAction {
192
+ type: "add" | "remove" | "modify";
193
+ overlay: any;
194
+ previousState?: any;
195
+ }
196
+ /**
197
+ * Drawing persistence + undo/redo stack.
198
+ */
199
+ export declare class DrawingStore {
200
+ private _store;
201
+ private _undoStack;
202
+ private _redoStack;
203
+ private _maxHistory;
204
+ constructor(store: ChartStore);
205
+ pushAction(action: DrawingAction): void;
206
+ canUndo(): boolean;
207
+ canRedo(): boolean;
208
+ undo(): DrawingAction | null;
209
+ redo(): DrawingAction | null;
210
+ saveDrawings(ticker: string, drawings: any[]): void;
211
+ loadDrawings(ticker: string): any[];
212
+ exportDrawings(ticker: string): string;
213
+ importDrawings(json: string): {
214
+ ticker: string;
215
+ drawings: any[];
216
+ } | null;
217
+ clearHistory(): void;
218
+ }
219
+ export interface ComparisonSymbol {
220
+ symbol: SymbolInfo;
221
+ data: KLineData[];
222
+ color: string;
223
+ visible: boolean;
224
+ normalizedData?: {
225
+ timestamp: number;
226
+ value: number;
227
+ }[];
228
+ }
229
+ /**
230
+ * Multi-symbol comparison overlay.
231
+ * Normalizes prices to percentage change from the first visible candle.
232
+ */
233
+ export declare class ComparisonManager {
234
+ private _symbols;
235
+ private _widget;
236
+ private _datafeed;
237
+ private _colorIndex;
238
+ private _onChange?;
239
+ constructor(widget: Nullable<Chart>, datafeed: Nullable<Datafeed>);
240
+ setOnChange(callback: () => void): void;
241
+ getSymbols(): ComparisonSymbol[];
242
+ addSymbol(symbol: SymbolInfo, period: Period, from: number, to: number): Promise<boolean>;
243
+ removeSymbol(ticker: string): void;
244
+ toggleVisibility(ticker: string): void;
245
+ private _normalizeData;
246
+ clear(): void;
247
+ destroy(): void;
248
+ }
249
+ /**
250
+ * Retry a function with exponential backoff
251
+ */
252
+ export declare function withRetry<T>(fn: () => Promise<T>, options?: {
253
+ maxAttempts?: number;
254
+ baseDelay?: number;
255
+ maxDelay?: number;
256
+ onRetry?: (attempt: number, error: Error) => void;
257
+ }): Promise<T>;
258
+ /**
259
+ * Wrap a promise with a timeout
260
+ */
261
+ export declare function withTimeout<T>(promise: Promise<T>, timeoutMs: number, message?: string): Promise<T>;
262
+ export type ErrorHandler = (error: Error) => void;
263
+ /**
264
+ * Centralized error handler
265
+ */
266
+ export declare class ErrorManager {
267
+ private _handlers;
268
+ private _lastError;
269
+ onError(handler: ErrorHandler): () => void;
270
+ report(error: Error): void;
271
+ getLastError(): Error | null;
272
+ clear(): void;
273
+ }
274
+ /**
275
+ * Licensed under the Apache License, Version 2.0 (the "License");
276
+ * you may not use this file except in compliance with the License.
277
+ * You may obtain a copy of the License at
278
+
279
+ * http://www.apache.org/licenses/LICENSE-2.0
280
+
281
+ * Unless required by applicable law or agreed to in writing, software
282
+ * distributed under the License is distributed on an "AS IS" BASIS,
283
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
284
+ * See the License for the specific language governing permissions and
285
+ * limitations under the License.
286
+ */
287
+ /**
288
+ * Central registry for custom indicators and overlays.
289
+ * When users register custom tools via the public API,
290
+ * they are added here so the UI menus can dynamically display them.
291
+ */
292
+ export interface CustomRegistryItem {
293
+ /** Internal name used by klinecharts engine */
294
+ name: string;
295
+ /** Display label shown in menus */
296
+ label: string;
297
+ /** Whether this is a main chart or sub chart indicator (indicators only) */
298
+ paneType?: "main" | "sub";
299
+ }
300
+ declare class Registry {
301
+ private _customIndicators;
302
+ private _customOverlays;
303
+ private _listeners;
304
+ /** Register a custom indicator for UI display */
305
+ addIndicator(item: CustomRegistryItem): void;
306
+ /** Register a custom overlay for UI display */
307
+ addOverlay(item: CustomRegistryItem): void;
308
+ /** Get all registered custom indicators */
309
+ getCustomIndicators(): CustomRegistryItem[];
310
+ /** Get custom indicators filtered by pane type */
311
+ getCustomMainIndicators(): CustomRegistryItem[];
312
+ getCustomSubIndicators(): CustomRegistryItem[];
313
+ /** Get all registered custom overlays */
314
+ getCustomOverlays(): CustomRegistryItem[];
315
+ /** Subscribe to changes (for reactive UI updates) */
316
+ onChange(listener: () => void): () => void;
317
+ private _notify;
318
+ }
319
+ /** Singleton registry instance */
320
+ export declare const customRegistry: Registry;
321
+ /**
322
+ * Licensed under the Apache License, Version 2.0 (the "License");
323
+ * you may not use this file except in compliance with the License.
324
+ * You may obtain a copy of the License at
325
+
326
+ * http://www.apache.org/licenses/LICENSE-2.0
327
+
328
+ * Unless required by applicable law or agreed to in writing, software
329
+ * distributed under the License is distributed on an "AS IS" BASIS,
330
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
331
+ * See the License for the specific language governing permissions and
332
+ * limitations under the License.
333
+ */
334
+ export interface ShortcutBinding {
335
+ /** e.g. 'ctrl+z', 'alt+s', 'delete', 'escape', '1', 'f11' */
336
+ key: string;
337
+ description?: string;
338
+ callback: (e: KeyboardEvent) => void;
339
+ }
340
+ /**
341
+ * Keyboard shortcut manager for chart operations.
342
+ * Listens to keyboard events and dispatches registered callbacks.
343
+ */
344
+ export declare class KeyboardShortcutManager {
345
+ private _container?;
346
+ private _bindings;
347
+ private _parsedBindings;
348
+ private _handler;
349
+ private _enabled;
350
+ constructor(_container?: HTMLElement | undefined);
351
+ /** Register a keyboard shortcut */
352
+ register(binding: ShortcutBinding): void;
353
+ /** Remove a keyboard shortcut */
354
+ remove(key: string): void;
355
+ /** Enable/disable all shortcuts */
356
+ setEnabled(enabled: boolean): void;
357
+ /** Get all registered bindings */
358
+ getBindings(): ShortcutBinding[];
359
+ /** Clean up */
360
+ destroy(): void;
361
+ }
362
+ export interface ChartTemplate {
363
+ name: string;
364
+ mainIndicators: string[];
365
+ subIndicators: string[];
366
+ styles?: any;
367
+ period?: {
368
+ multiplier: number;
369
+ timespan: string;
370
+ text: string;
371
+ };
372
+ theme?: string;
373
+ createdAt: number;
374
+ }
375
+ /**
376
+ * Chart template manager.
377
+ * Save/load indicator + style configurations as reusable presets.
378
+ */
379
+ export declare class ChartTemplateManager {
380
+ private _store;
381
+ constructor(store: ChartStore);
382
+ /** Save a template */
383
+ saveTemplate(template: ChartTemplate): void;
384
+ /** Load a template by name */
385
+ loadTemplate(name: string): ChartTemplate | null;
386
+ /** Delete a template by name */
387
+ deleteTemplate(name: string): void;
388
+ /** Get all template names */
389
+ getTemplateNames(): string[];
390
+ /** Get all templates */
391
+ getTemplates(): ChartTemplate[];
392
+ private _getAll;
393
+ private _saveAll;
394
+ }
395
+ /**
396
+ * Crosshair sync manager.
397
+ * Links multiple Chart instances so that crosshair movement on one
398
+ * chart broadcasts the timestamp to all others.
399
+ */
400
+ export declare class CrosshairSyncManager {
401
+ private _charts;
402
+ private _isSyncing;
403
+ /** Add a chart to the sync group */
404
+ addChart(chart: Chart): void;
405
+ /** Remove a chart from the sync group */
406
+ removeChart(chart: Chart): void;
407
+ /** Get number of linked charts */
408
+ getChartCount(): number;
409
+ /** Clean up all subscriptions */
410
+ destroy(): void;
411
+ }
412
+ export type ReplayStatus = "idle" | "playing" | "paused" | "ended";
413
+ export type ReplayDataSource = "current" | "custom";
414
+ export interface ReplayOptions {
415
+ /** Data source: 'current' = use loaded chart data, 'custom' = load from datafeed */
416
+ dataSource: ReplayDataSource;
417
+ /** Speed in ms per bar (default 500) */
418
+ speed?: number;
419
+ /** Start index (for 'current' source) or start timestamp (for 'custom' source) */
420
+ startFrom?: number;
421
+ }
422
+ export interface ReplayEventHandlers {
423
+ onStep?: (index: number, total: number, bar: KLineData) => void;
424
+ onPlay?: () => void;
425
+ onPause?: () => void;
426
+ onEnd?: () => void;
427
+ onStatusChange?: (status: ReplayStatus) => void;
428
+ }
429
+ /**
430
+ * Bar Replay Manager.
431
+ * Allows replaying historical data bar by bar for trading practice.
432
+ * Supports two data sources:
433
+ * - 'current': Uses already-loaded chart data
434
+ * - 'custom': Loads data from datafeed for a specific time range
435
+ */
436
+ export declare class BarReplayManager {
437
+ private _chart;
438
+ private _datafeed;
439
+ private _fullData;
440
+ private _playbackIndex;
441
+ private _status;
442
+ private _speed;
443
+ private _timerId;
444
+ private _handlers;
445
+ private _originalData;
446
+ constructor(chart: Chart, datafeed?: Datafeed);
447
+ /** Set event handlers */
448
+ setHandlers(handlers: ReplayEventHandlers): void;
449
+ /** Start replay with the given options */
450
+ start(options: ReplayOptions): Promise<void>;
451
+ /** Load custom data from datafeed for replay */
452
+ loadData(symbol: SymbolInfo, period: Period, from: number, to: number): Promise<void>;
453
+ /** Play (auto-advance) */
454
+ play(): void;
455
+ /** Pause playback */
456
+ pause(): void;
457
+ /** Step one bar forward */
458
+ stepForward(): void;
459
+ /** Step one bar backward */
460
+ stepBackward(): void;
461
+ /** Jump to a specific index */
462
+ seekTo(index: number): void;
463
+ /** Set playback speed in ms per bar */
464
+ setSpeed(ms: number): void;
465
+ /** Get current state */
466
+ getStatus(): ReplayStatus;
467
+ getIndex(): number;
468
+ getTotal(): number;
469
+ getSpeed(): number;
470
+ getCurrentBar(): KLineData | null;
471
+ /** Stop replay and restore original data */
472
+ stop(): void;
473
+ /** Clean up */
474
+ destroy(): void;
475
+ private _applyData;
476
+ private _setStatus;
477
+ }
478
+ declare function load(key: string, ls: Record<string, string>): void;
479
+ export interface RegisterOverlayOptions {
480
+ /** The klinecharts OverlayTemplate */
481
+ template: OverlayTemplate;
482
+ /** Display label in the drawing toolbar menu. Defaults to template.name */
483
+ label?: string;
484
+ }
485
+ export interface RegisterIndicatorOptions {
486
+ /** The klinecharts IndicatorTemplate */
487
+ template: IndicatorTemplate;
488
+ /** Display label in the indicator menu. Defaults to template.shortName or template.name */
489
+ label?: string;
490
+ /** Where the indicator appears: 'main' (candle pane) or 'sub' (new pane). Defaults to 'sub' */
491
+ paneType?: "main" | "sub";
492
+ }
493
+ /**
494
+ * Register a custom overlay (drawing tool).
495
+ * It will be registered with klinecharts AND automatically appear
496
+ * in the drawing toolbar menu under the "Custom" group.
497
+ *
498
+ * @example
499
+ * ```ts
500
+ * import { registerCustomOverlay } from '@anthropic/klinecharts-pro'
501
+ *
502
+ * // Simple: just pass an OverlayTemplate directly
503
+ * registerCustomOverlay({
504
+ * name: 'myCustomTool',
505
+ * totalStep: 3,
506
+ * createPointFigures: ({ coordinates }) => {
507
+ * return [{ type: 'line', attrs: { coordinates: [coordinates[0], coordinates[1]] } }]
508
+ * }
509
+ * })
510
+ *
511
+ * // Advanced: pass options with custom label
512
+ * registerCustomOverlay({
513
+ * template: { name: 'myTool', totalStep: 2, ... },
514
+ * label: 'My Custom Tool'
515
+ * })
516
+ * ```
517
+ */
518
+ export declare function registerCustomOverlay(templateOrOptions: OverlayTemplate | RegisterOverlayOptions): void;
519
+ /**
520
+ * Register a custom technical indicator.
521
+ * It will be registered with klinecharts AND automatically appear
522
+ * in the indicator modal menu.
523
+ *
524
+ * @example
525
+ * ```ts
526
+ * import { registerCustomIndicator } from '@anthropic/klinecharts-pro'
527
+ *
528
+ * // Simple: just pass an IndicatorTemplate
529
+ * registerCustomIndicator({
530
+ * name: 'MyRSI',
531
+ * shortName: 'MRSI',
532
+ * calcParams: [14],
533
+ * figures: [{ key: 'rsi', title: 'RSI: ', type: 'line' }],
534
+ * calc: (dataList, indicator) => {
535
+ * // ... your calculation
536
+ * return dataList.map(() => ({ rsi: 50 }))
537
+ * }
538
+ * })
539
+ *
540
+ * // Advanced: with custom label and pane type
541
+ * registerCustomIndicator({
542
+ * template: { name: 'VWAP', ... },
543
+ * label: 'Volume Weighted Average Price',
544
+ * paneType: 'main' // appears on main candle chart
545
+ * })
546
+ * ```
547
+ */
548
+ export declare function registerCustomIndicator(templateOrOptions: IndicatorTemplate | RegisterIndicatorOptions): void;
549
+
550
+ export {
551
+ load as loadLocales,
552
+ };
553
+
554
+ export as namespace klinechartspro;
555
+
556
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simahfud/klinecharts-pro",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Professional TradingView-inspired charting component built on KLineChart. Features bar replay, keyboard shortcuts, 25 drawing tools, 6 chart types, and custom tool API.",
5
5
  "type": "module",
6
6
  "main": "./dist/klinecharts-pro.umd.js",