@christtrade/depth 0.18.0 → 0.20.0
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/README.md +175 -96
- package/depth.cjs +67 -68
- package/depth.css +1 -1
- package/depth.mjs +67 -68
- package/depth.nopreflight.css +1 -1
- package/package.json +1 -1
- package/types/components/ui/collapse.d.ts +10 -0
- package/types/components/ui/resizable.d.ts +1 -1
- package/types/core/BarStore.d.ts +69 -0
- package/types/core/CellEngines.d.ts +15 -0
- package/types/core/ChartModel.d.ts +3 -2
- package/types/core/DataEngine.d.ts +15 -2
- package/types/core/DepthChart.d.ts +50 -6
- package/types/core/ExecutionEngine.d.ts +3 -2
- package/types/core/PluginSchedule.d.ts +11 -0
- package/types/core/RenderEngine.d.ts +44 -14
- package/types/core/ThemeRegistry.d.ts +18 -0
- package/types/core/TypedEventBus.d.ts +27 -10
- package/types/core/builtin-themes.d.ts +7 -0
- package/types/core/index.d.ts +6 -4
- package/types/core/plugin-startup.d.ts +4 -2
- package/types/core/theme-style.d.ts +9 -0
- package/types/hooks/useChartData.d.ts +11 -10
- package/types/hooks/useChartHandlers.d.ts +5 -4
- package/types/hooks/useChartInteraction.d.ts +5 -4
- package/types/hooks/useChartSettings.d.ts +5 -4
- package/types/hooks/useChartSubscriptions.d.ts +6 -4
- package/types/hooks/useChartView.d.ts +5 -4
- package/types/hooks/useRenderEngine.d.ts +2 -50
- package/types/interfaces/ICoordinateTransformer.d.ts +0 -1
- package/types/interfaces/plugins/IChartPlugin.d.ts +32 -5
- package/types/interfaces/plugins/IDrawingPlugin.d.ts +2 -2
- package/types/lib/matchingEngine.d.ts +3 -2
- package/types/lib/renderers/renderer.d.ts +6 -39
- package/types/lib/types/chart-settings.d.ts +16 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { TypedEventBus } from './TypedEventBus';
|
|
2
|
+
import { BarStore } from './BarStore';
|
|
2
3
|
import type { IDataAdapter, SymbolInfo, DataLevel, OhlcvBar, TickEvent } from '../interfaces/IDataAdapter';
|
|
3
4
|
import type { FootprintOptions } from '../lib/types/footprint';
|
|
4
5
|
import type { SerialTrade } from '../lib/types';
|
|
@@ -32,7 +33,17 @@ export interface ChartDataSnapshot {
|
|
|
32
33
|
readonly trades: SerialTrade[];
|
|
33
34
|
readonly footprintBars: FootprintBar[];
|
|
34
35
|
readonly priceHistory: PriceHistory[];
|
|
35
|
-
/**
|
|
36
|
+
/**
|
|
37
|
+
* Every loaded bar, at the fetch resolution. Populated for ohlcv, derived
|
|
38
|
+
* from footprintBars for l3/tick, empty for l2. Read the columns off it each
|
|
39
|
+
* time - see `BarStore`. It's the store the chart draws from, so read it and
|
|
40
|
+
* don't change it. `clone()` it for your own copy.
|
|
41
|
+
*/
|
|
42
|
+
readonly bars: BarStore;
|
|
43
|
+
/**
|
|
44
|
+
* `bars` as objects, built on first read and kept until the bars change.
|
|
45
|
+
* @deprecated ~176 bytes a bar and a full copy - use `bars`.
|
|
46
|
+
*/
|
|
36
47
|
readonly ohlcvBars: OhlcvBar[];
|
|
37
48
|
/** Populated for tick and l3 (derived from trades). */
|
|
38
49
|
readonly ticks: TickEvent[];
|
|
@@ -71,7 +82,7 @@ export declare class DataEngine {
|
|
|
71
82
|
trades: SerialTrade[];
|
|
72
83
|
priceHistory: PriceHistory[];
|
|
73
84
|
footprintBars: FootprintBar[];
|
|
74
|
-
ohlcvBars:
|
|
85
|
+
ohlcvBars: BarStore;
|
|
75
86
|
barNs: bigint;
|
|
76
87
|
dataStart: number;
|
|
77
88
|
dataEnd: number;
|
|
@@ -128,6 +139,8 @@ export declare class DataEngine {
|
|
|
128
139
|
hasMore: boolean;
|
|
129
140
|
coveredTo: bigint | null;
|
|
130
141
|
}>;
|
|
142
|
+
private readonly _arrays;
|
|
143
|
+
private readonly _barsAsArray;
|
|
131
144
|
getSnapshot(): ChartDataSnapshot;
|
|
132
145
|
destroy(): void;
|
|
133
146
|
private _fetchForward;
|
|
@@ -10,7 +10,7 @@ import { ExecutionEngine } from './ExecutionEngine';
|
|
|
10
10
|
import type { FillSearchOptions } from '../lib/matchingEngine';
|
|
11
11
|
import { LiveTransformer } from '../interfaces/ICoordinateTransformer';
|
|
12
12
|
import { BottomBarItem, ChartPlugin, InstalledPlugin, PluginType, ToolbarItem } from './PluginRegistry';
|
|
13
|
-
import { RenderEngine } from './RenderEngine';
|
|
13
|
+
import { RenderEngine, type DrawHook, type DrawPhase } from './RenderEngine';
|
|
14
14
|
import { ChartEvents, TypedEventBus } from './TypedEventBus';
|
|
15
15
|
import { ChartState } from './ChartState';
|
|
16
16
|
import type { SyncInLayout } from '../lib/types/layout-sync';
|
|
@@ -18,6 +18,8 @@ import { ChartModel, type ChartPaneState } from './ChartModel';
|
|
|
18
18
|
import { DrawingStore } from './DrawingStore';
|
|
19
19
|
import { ChartPane, Indicator } from '../lib/types/indicator-types';
|
|
20
20
|
import { AccountManager, LedgerAdjustment, LedgerFill, LedgerOrder, LedgerPosition, type AccountSaveState } from './AccountManager';
|
|
21
|
+
import type { ThemeDef } from '../interfaces/plugins/IChartPlugin';
|
|
22
|
+
import type { StyleField } from '../components/drawings/drawing-settings-dialog';
|
|
21
23
|
import { PlaybackMode, type PrefetchOptions } from '../hooks/usePlaybackEngine';
|
|
22
24
|
import { type ChartPreferences } from '../lib/storage';
|
|
23
25
|
import { type PluginCatalogEntry, type PluginStartupEntry, type PluginStartupRecord } from './plugin-startup';
|
|
@@ -101,6 +103,8 @@ export interface ChartOptions {
|
|
|
101
103
|
*/
|
|
102
104
|
restore?: ChartSaveState;
|
|
103
105
|
toolbar?: (chart: DepthChart) => React.ReactNode[];
|
|
106
|
+
/** Theme id to start on. Register custom ones with `chart.registerTheme()` first. */
|
|
107
|
+
theme?: string;
|
|
104
108
|
}
|
|
105
109
|
/** Bump when the save document shape changes incompatibly; handled in migrate(). */
|
|
106
110
|
export declare const SAVE_VERSION = 1;
|
|
@@ -175,12 +179,15 @@ export declare class DepthChart {
|
|
|
175
179
|
private readonly options;
|
|
176
180
|
readonly id: string;
|
|
177
181
|
readonly eventBus: TypedEventBus;
|
|
182
|
+
private readonly _themes;
|
|
183
|
+
private readonly _themeStyle;
|
|
178
184
|
readonly executionEngine: ExecutionEngine;
|
|
179
185
|
private readonly dataEngine;
|
|
180
186
|
readonly transformer: LiveTransformer;
|
|
181
187
|
private features;
|
|
182
188
|
private readonly pluginRegistry;
|
|
183
|
-
private
|
|
189
|
+
private readonly _engines;
|
|
190
|
+
private _pluginRenderEngine;
|
|
184
191
|
private _panelRegistry;
|
|
185
192
|
private _toolbarRegistry;
|
|
186
193
|
private _bottomBarRegistry;
|
|
@@ -192,9 +199,11 @@ export declare class DepthChart {
|
|
|
192
199
|
private registeredPlugins;
|
|
193
200
|
private _pluginStateListeners;
|
|
194
201
|
private _pluginCatalog;
|
|
202
|
+
private _panesRestored;
|
|
195
203
|
private playbackController;
|
|
196
204
|
private readonly playbackStateRegistry;
|
|
197
205
|
private readonly pluginSchedules;
|
|
206
|
+
private readonly extensionParams;
|
|
198
207
|
readonly state: ChartState;
|
|
199
208
|
private readonly _panes;
|
|
200
209
|
readonly drawingStore: DrawingStore;
|
|
@@ -218,14 +227,14 @@ export declare class DepthChart {
|
|
|
218
227
|
* The bar still being built at the playback horizon, on the focused pane, or
|
|
219
228
|
* `null` before any data has arrived.
|
|
220
229
|
*
|
|
221
|
-
* Unlike the
|
|
230
|
+
* Unlike the last of `getData().bars` - which is the last bar that was
|
|
222
231
|
* *loaded*, at the fetch resolution and possibly past the horizon - this is
|
|
223
232
|
* the candle the chart is actually drawing on the right edge.
|
|
224
233
|
*/
|
|
225
234
|
openBar(): OhlcvBar | null;
|
|
226
235
|
/** What the chart holds for the active symbol - the same snapshot a plugin's `ctx.getData()` returns. */
|
|
227
236
|
getData(): ChartDataSnapshot;
|
|
228
|
-
/** The paint loop, once a
|
|
237
|
+
/** The focused cell's paint loop, once a cell has mounted one. Every cell's: `getRenderEngines()`. */
|
|
229
238
|
get renderEngine(): RenderEngine | null;
|
|
230
239
|
getMaxLookbackBars(): number;
|
|
231
240
|
horizon(): number;
|
|
@@ -402,6 +411,7 @@ export declare class DepthChart {
|
|
|
402
411
|
* document decide again.
|
|
403
412
|
*/
|
|
404
413
|
setPluginStartup(id: string, entry: Partial<PluginStartupEntry> | null): this;
|
|
414
|
+
private _deactivateRemoved;
|
|
405
415
|
/**
|
|
406
416
|
* Install what this session should open with: every plugin a restored pane
|
|
407
417
|
* references, plus every plugin marked autostart. Idempotent - already-loaded
|
|
@@ -438,6 +448,18 @@ export declare class DepthChart {
|
|
|
438
448
|
* set of ids actually changes - pane models notify on unrelated churn (axis
|
|
439
449
|
* drags rewrite settings every frame) that callers shouldn't re-render on.
|
|
440
450
|
*/
|
|
451
|
+
/**
|
|
452
|
+
* The settings a loaded extension declared with `params`, and their current
|
|
453
|
+
* values. Null when it declared none. A script holding several extensions
|
|
454
|
+
* gets one combined set.
|
|
455
|
+
*/
|
|
456
|
+
getExtensionParams(id: string): {
|
|
457
|
+
schema: StyleField[];
|
|
458
|
+
defaults: Record<string, unknown>;
|
|
459
|
+
values: Record<string, unknown>;
|
|
460
|
+
} | null;
|
|
461
|
+
/** Save some of an extension's params, and hand the new values to the extension. */
|
|
462
|
+
setExtensionParams(id: string, patch: Record<string, unknown>): void;
|
|
441
463
|
onPluginStateChange(cb: (state: {
|
|
442
464
|
installed: Set<string>;
|
|
443
465
|
active: Set<string>;
|
|
@@ -454,11 +476,33 @@ export declare class DepthChart {
|
|
|
454
476
|
visible: boolean;
|
|
455
477
|
}>;
|
|
456
478
|
getToolbarRegistry(): ReadonlyMap<string, ToolbarItem>;
|
|
479
|
+
/** The theme the chart is on. */
|
|
480
|
+
getTheme(): ThemeDef;
|
|
481
|
+
/** Every theme it can switch to, built-in and registered. */
|
|
482
|
+
getThemes(): ThemeDef[];
|
|
483
|
+
/**
|
|
484
|
+
* Switch theme. Emits `theme:change`. False for an id that isn't registered,
|
|
485
|
+
* and the chart stays where it was.
|
|
486
|
+
*/
|
|
487
|
+
setTheme(id: string): boolean;
|
|
488
|
+
/**
|
|
489
|
+
* Add a theme, or replace one with the same id. Returns the unregister - if
|
|
490
|
+
* the chart is on that theme, it falls back to the default.
|
|
491
|
+
*/
|
|
492
|
+
registerTheme(theme: ThemeDef): () => void;
|
|
457
493
|
getBottomBarRegistry(): ReadonlyMap<string, BottomBarItem>;
|
|
458
494
|
attachRenderEngine(engine: RenderEngine): void;
|
|
495
|
+
/** Every cell's paint loop, by cell id. */
|
|
496
|
+
getRenderEngines(): ReadonlyMap<number, RenderEngine>;
|
|
497
|
+
/**
|
|
498
|
+
* Draw on every cell, including cells that mount later - a layout switch
|
|
499
|
+
* keeps the overlay on all of them. Returns the remove.
|
|
500
|
+
*/
|
|
501
|
+
addOverlay(phase: DrawPhase, hook: DrawHook): () => void;
|
|
502
|
+
private get pluginRenderEngine();
|
|
459
503
|
/**
|
|
460
|
-
* Snapshot of the
|
|
461
|
-
* Returns null until
|
|
504
|
+
* Snapshot of the focused cell with every layer composited (base, drawings, UI).
|
|
505
|
+
* Returns null until a render engine has attached.
|
|
462
506
|
*/
|
|
463
507
|
screenshot(): HTMLCanvasElement | null;
|
|
464
508
|
private _focusedCellId;
|
|
@@ -6,6 +6,7 @@ import type { BracketAmendment, Order, Position } from '../lib/types/trading-typ
|
|
|
6
6
|
import type { MboEvent, PriceHistory } from '../lib/types';
|
|
7
7
|
import type { OhlcvBar } from '../interfaces/IDataAdapter';
|
|
8
8
|
import type { SerialTrade } from '../lib/types';
|
|
9
|
+
import { BarStore } from './BarStore';
|
|
9
10
|
/**
|
|
10
11
|
* Vetoes an order before it reaches a book. Return a reason to refuse it, or
|
|
11
12
|
* null to let it through. Pre-trade risk lives here rather than in the caller,
|
|
@@ -58,8 +59,8 @@ export declare class ExecutionEngine {
|
|
|
58
59
|
private targetFor;
|
|
59
60
|
private eachBuiltIn;
|
|
60
61
|
ingestCompactBuf(buf: ArrayBuffer, symbol?: string): void;
|
|
61
|
-
ingestOhlcvBars(bars: OhlcvBar[], barNs?: bigint, symbol?: string): void;
|
|
62
|
-
appendOhlcvBars(bars: OhlcvBar[], barNs?: bigint, symbol?: string): void;
|
|
62
|
+
ingestOhlcvBars(bars: OhlcvBar[] | BarStore, barNs?: bigint, symbol?: string): void;
|
|
63
|
+
appendOhlcvBars(bars: OhlcvBar[] | BarStore, barNs?: bigint, symbol?: string): void;
|
|
63
64
|
ingestSupplementalBars(bars: Array<{
|
|
64
65
|
time: number;
|
|
65
66
|
open: number;
|
|
@@ -2,14 +2,25 @@ export interface PluginSchedule {
|
|
|
2
2
|
interval(ms: number, fn: () => void): () => void;
|
|
3
3
|
timeout(ms: number, fn: () => void): () => void;
|
|
4
4
|
raf(fn: () => void): () => void;
|
|
5
|
+
frames(fps: number, fn: (time: number, dt: number) => void): () => void;
|
|
5
6
|
}
|
|
6
7
|
export declare class PluginScheduleImpl implements PluginSchedule {
|
|
8
|
+
private readonly getElements;
|
|
7
9
|
private readonly intervals;
|
|
8
10
|
private readonly timeouts;
|
|
9
11
|
private readonly rafIds;
|
|
12
|
+
private readonly frameLoops;
|
|
10
13
|
private destroyed;
|
|
14
|
+
private observer;
|
|
15
|
+
private readonly observed;
|
|
16
|
+
private readonly visible;
|
|
17
|
+
/** `getElements` - every cell the plugin draws on. Frames run while any is on screen */
|
|
18
|
+
constructor(getElements?: () => readonly Element[]);
|
|
19
|
+
private get onScreen();
|
|
11
20
|
interval(ms: number, fn: () => void): () => void;
|
|
12
21
|
timeout(ms: number, fn: () => void): () => void;
|
|
13
22
|
raf(fn: () => void): () => void;
|
|
23
|
+
frames(fps: number, fn: (time: number, dt: number) => void): () => void;
|
|
24
|
+
private watchVisibility;
|
|
14
25
|
destroy(): void;
|
|
15
26
|
}
|
|
@@ -3,16 +3,36 @@ import type { ChartPane, Rect } from '../lib/types/indicator-types';
|
|
|
3
3
|
import type { Indicator } from '../lib/types/indicator-types';
|
|
4
4
|
import type { TradePoint, PriceHistory, ViewBounds } from '../lib/types';
|
|
5
5
|
import type { FootprintBar } from '../lib/types/footprint';
|
|
6
|
-
import type
|
|
6
|
+
import { type ChartColors, type ChartSettings } from '../lib/types/chart-settings';
|
|
7
7
|
import type { Crosshair } from '../lib/renderers/renderer';
|
|
8
8
|
import type { Drawing, DraftDrawing, DrawingAnchorId, ActiveDrawingTool } from '../lib/types/drawing-types';
|
|
9
9
|
import type { TradeLine } from '../lib/types';
|
|
10
10
|
import { LiveTransformer } from '../interfaces/ICoordinateTransformer';
|
|
11
11
|
import { ChartTypePlugin } from './PluginRegistry';
|
|
12
12
|
import { SessionMapper } from './SessionMapper';
|
|
13
|
+
import type { BarStore } from './BarStore';
|
|
13
14
|
import { AccountSnapshot, DataLevel, SymbolInfo } from '.';
|
|
14
15
|
import type { CrosshairSync } from '../lib/types/layout-sync';
|
|
15
|
-
|
|
16
|
+
/** Layout of the frame a draw hook runs in. Everything in css px */
|
|
17
|
+
export interface DrawInfo {
|
|
18
|
+
width: number;
|
|
19
|
+
height: number;
|
|
20
|
+
dpr: number;
|
|
21
|
+
/** The main plot - the canvas minus the price and time axis */
|
|
22
|
+
plot: Rect;
|
|
23
|
+
/** Every panes box by id, `main` included */
|
|
24
|
+
panes: Readonly<Record<string, Rect>>;
|
|
25
|
+
/** The resolved background color */
|
|
26
|
+
background: string;
|
|
27
|
+
/** `performance.now()` at the start of the frame */
|
|
28
|
+
time: number;
|
|
29
|
+
/** The layout cell being painted - a hook runs once per cell */
|
|
30
|
+
cell: number;
|
|
31
|
+
/** Whether that cell is the focused one */
|
|
32
|
+
focused: boolean;
|
|
33
|
+
}
|
|
34
|
+
export type DrawHook = (ctx: CanvasRenderingContext2D, view: ViewBounds, transformer: LiveTransformer, info: DrawInfo) => void;
|
|
35
|
+
export type DrawPhase = 'before-base' | 'after-background' | 'after-base' | 'after-ui';
|
|
16
36
|
export interface DrawParams {
|
|
17
37
|
panes: ChartPane[];
|
|
18
38
|
layouts: Record<string, Rect>;
|
|
@@ -32,15 +52,7 @@ export interface DrawParams {
|
|
|
32
52
|
horizon: bigint;
|
|
33
53
|
candleCache: Map<bigint, any> | null;
|
|
34
54
|
openBar: FootprintBar | null;
|
|
35
|
-
|
|
36
|
-
ohlcvBars: {
|
|
37
|
-
time: number;
|
|
38
|
-
open: number;
|
|
39
|
-
high: number;
|
|
40
|
-
low: number;
|
|
41
|
-
close: number;
|
|
42
|
-
volume: number;
|
|
43
|
-
}[];
|
|
55
|
+
ohlcvBars: BarStore;
|
|
44
56
|
crosshair: Crosshair | null;
|
|
45
57
|
drawings: Drawing[];
|
|
46
58
|
draft: DraftDrawing | null;
|
|
@@ -95,11 +107,17 @@ export interface DrawParams {
|
|
|
95
107
|
syncCrosshair: CrosshairSync | null;
|
|
96
108
|
}
|
|
97
109
|
export declare class RenderEngine {
|
|
110
|
+
private readonly backgroundCanvas;
|
|
98
111
|
private readonly baseCanvas;
|
|
99
112
|
private readonly drawingsCanvas;
|
|
100
113
|
private readonly uiCanvas;
|
|
101
114
|
private readonly eventBus;
|
|
102
115
|
private readonly chartId;
|
|
116
|
+
/** The layout cell this engine paints */
|
|
117
|
+
get cellId(): number;
|
|
118
|
+
private focused;
|
|
119
|
+
/** Set by the chart. Repaints if there are hooks, they might draw differently on the focused cell */
|
|
120
|
+
setFocused(focused: boolean): void;
|
|
103
121
|
private rafId;
|
|
104
122
|
/** The element the canvases sit in, for overlays that want to draw over the chart without touching it */
|
|
105
123
|
get container(): HTMLElement | null;
|
|
@@ -115,10 +133,14 @@ export declare class RenderEngine {
|
|
|
115
133
|
maxMs: number;
|
|
116
134
|
};
|
|
117
135
|
private dirty;
|
|
136
|
+
private paintedBackgroundColor;
|
|
118
137
|
private beforeBaseDraw;
|
|
138
|
+
private afterBackgroundDraw;
|
|
119
139
|
private afterBaseDraw;
|
|
120
140
|
private afterUIDraw;
|
|
121
141
|
private drawParams;
|
|
142
|
+
private rawDrawParams;
|
|
143
|
+
private themeColors;
|
|
122
144
|
private view;
|
|
123
145
|
private readonly priceTransition;
|
|
124
146
|
private resizeObserver;
|
|
@@ -129,11 +151,18 @@ export declare class RenderEngine {
|
|
|
129
151
|
private readonly onDprChange;
|
|
130
152
|
private watchDpr;
|
|
131
153
|
private startLoop;
|
|
132
|
-
markDirty(layer: 'base' | 'drawings' | 'ui'): void;
|
|
154
|
+
markDirty(layer: 'background' | 'base' | 'drawings' | 'ui'): void;
|
|
133
155
|
markAllDirty(): void;
|
|
134
156
|
setDrawParams(params: DrawParams): void;
|
|
157
|
+
/** Set by the chart. Colors the user didn't pick come from here. */
|
|
158
|
+
setThemeColors(colors: Partial<ChartColors> | undefined): void;
|
|
135
159
|
setView(v: ViewBounds): void;
|
|
136
160
|
getView(): ViewBounds | null;
|
|
161
|
+
/** The transformer this cell paints with, once it has drawn */
|
|
162
|
+
get transformer(): LiveTransformer | null;
|
|
163
|
+
private doBackgroundRedraw;
|
|
164
|
+
private readonly failedHooks;
|
|
165
|
+
private runHooks;
|
|
137
166
|
private doBaseRedraw;
|
|
138
167
|
/**
|
|
139
168
|
* Draws the ChristTrade banner into the base layer, in the same pass that
|
|
@@ -146,15 +175,16 @@ export declare class RenderEngine {
|
|
|
146
175
|
private drawAttribution;
|
|
147
176
|
private doDrawingsRedraw;
|
|
148
177
|
private doUIRedraw;
|
|
149
|
-
addDrawHook(phase:
|
|
178
|
+
addDrawHook(phase: DrawPhase, hook: DrawHook): () => void;
|
|
150
179
|
private handleResize;
|
|
151
180
|
private flushSync;
|
|
152
181
|
toDataURL(type?: string): string;
|
|
153
182
|
/**
|
|
154
|
-
*
|
|
183
|
+
* Every layer flattened onto a fresh canvas, in paint order. Use this
|
|
155
184
|
* rather than `toDataURL` when the snapshot should include the drawings and
|
|
156
185
|
* the crosshair/UI layer.
|
|
157
186
|
*/
|
|
158
187
|
captureComposite(): HTMLCanvasElement;
|
|
188
|
+
private flatten;
|
|
159
189
|
destroy(): void;
|
|
160
190
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ThemeDef } from '../interfaces/plugins/IChartPlugin';
|
|
2
|
+
import type { TypedEventBus } from './TypedEventBus';
|
|
3
|
+
import { BASE_DARK_VARS, BUILTIN_THEMES } from './builtin-themes';
|
|
4
|
+
export { BASE_DARK_VARS, BUILTIN_THEMES };
|
|
5
|
+
export declare const DEFAULT_THEME_ID = "dark";
|
|
6
|
+
export declare class ThemeRegistry {
|
|
7
|
+
private readonly bus;
|
|
8
|
+
private readonly themes;
|
|
9
|
+
private currentId;
|
|
10
|
+
constructor(bus: TypedEventBus, builtins?: readonly ThemeDef[], initial?: string);
|
|
11
|
+
get current(): ThemeDef;
|
|
12
|
+
get(id: string): ThemeDef | undefined;
|
|
13
|
+
list(): ThemeDef[];
|
|
14
|
+
/** Same id replaces, so a hot-reloaded theme updates in place. Returns the unregister. */
|
|
15
|
+
register(theme: ThemeDef): () => void;
|
|
16
|
+
/** False for an unknown id. Setting the current theme again does nothing. */
|
|
17
|
+
set(id: string): boolean;
|
|
18
|
+
}
|
|
@@ -8,6 +8,8 @@ import { IExecutionAdapter } from '../interfaces/IExecutionAdapter';
|
|
|
8
8
|
import { ActiveDrawingTool, Anchor, Drawing } from '../lib/types/drawing-types';
|
|
9
9
|
import { TradeLineHitMap } from '../lib/renderers/drawTradeLines';
|
|
10
10
|
import type { TradeLine } from '../lib/types';
|
|
11
|
+
import type { StyleField } from '../components/drawings/drawing-settings-dialog';
|
|
12
|
+
import type { ThemeDef } from '../interfaces/plugins/IChartPlugin';
|
|
11
13
|
import { FootprintBar } from '../lib/types/footprint';
|
|
12
14
|
import { ChartPane, Indicator } from '../lib/types/indicator-types';
|
|
13
15
|
import { SerialTrade } from '../lib/types';
|
|
@@ -16,6 +18,7 @@ import { Fill, Order, Position, PositionClose, TradingEvent } from '../lib/types
|
|
|
16
18
|
import { PriceHistory, TradePoint, type ViewBounds } from '../lib/types';
|
|
17
19
|
import { BottomBarItem, ChartTypePlugin, ToolbarItem } from './PluginRegistry';
|
|
18
20
|
import { RenderEngine } from './RenderEngine';
|
|
21
|
+
import type { BarStore } from './BarStore';
|
|
19
22
|
import { PlaybackMode } from '../hooks/usePlaybackEngine';
|
|
20
23
|
import type { CrosshairSync, TimeRangeSync } from '../lib/types/layout-sync';
|
|
21
24
|
import type { PlaceOrderRequest } from '../lib/matchingEngine';
|
|
@@ -69,7 +72,8 @@ export interface ChartEvents {
|
|
|
69
72
|
old: string;
|
|
70
73
|
new: string;
|
|
71
74
|
};
|
|
72
|
-
'theme:change':
|
|
75
|
+
'theme:change': ThemeDef;
|
|
76
|
+
'theme:list': ThemeDef[];
|
|
73
77
|
'chart:focused': {
|
|
74
78
|
id: number;
|
|
75
79
|
};
|
|
@@ -122,14 +126,7 @@ export interface ChartEvents {
|
|
|
122
126
|
volume: number;
|
|
123
127
|
delta: number;
|
|
124
128
|
}> | null;
|
|
125
|
-
bars:
|
|
126
|
-
time: number;
|
|
127
|
-
open: number;
|
|
128
|
-
high: number;
|
|
129
|
-
low: number;
|
|
130
|
-
close: number;
|
|
131
|
-
volume: number;
|
|
132
|
-
}[];
|
|
129
|
+
bars: BarStore;
|
|
133
130
|
openBar: FootprintBar;
|
|
134
131
|
horizon: bigint;
|
|
135
132
|
dataLevel: DataLevel;
|
|
@@ -177,7 +174,8 @@ export interface ChartEvents {
|
|
|
177
174
|
trades: SerialTrade[];
|
|
178
175
|
priceHistory: PriceHistory[];
|
|
179
176
|
footprintBars: FootprintBar[];
|
|
180
|
-
|
|
177
|
+
/** Every loaded bar. Derived from footprintBars at l3/tick, empty at l2. */
|
|
178
|
+
bars: BarStore;
|
|
181
179
|
barNs: bigint;
|
|
182
180
|
dataStart: number;
|
|
183
181
|
dataEnd: number;
|
|
@@ -217,7 +215,10 @@ export interface ChartEvents {
|
|
|
217
215
|
trades: SerialTrade[];
|
|
218
216
|
priceHistory: PriceHistory[];
|
|
219
217
|
footprintBars: FootprintBar[];
|
|
218
|
+
/** This chunk's new bars at ohlcv, empty at every other level. */
|
|
220
219
|
ohlcvBars: OhlcvBar[];
|
|
220
|
+
/** Every loaded bar, this chunk included. */
|
|
221
|
+
bars: BarStore;
|
|
221
222
|
barNs: bigint;
|
|
222
223
|
dataStart: number;
|
|
223
224
|
dataEnd: number;
|
|
@@ -262,7 +263,10 @@ export interface ChartEvents {
|
|
|
262
263
|
trades: SerialTrade[];
|
|
263
264
|
priceHistory: PriceHistory[];
|
|
264
265
|
footprintBars: FootprintBar[];
|
|
266
|
+
/** This page's new bars at ohlcv, empty at every other level. */
|
|
265
267
|
ohlcvBars: OhlcvBar[];
|
|
268
|
+
/** Every loaded bar, this page included. */
|
|
269
|
+
bars: BarStore;
|
|
266
270
|
barNs: bigint;
|
|
267
271
|
dataStart: number;
|
|
268
272
|
viewMin: bigint;
|
|
@@ -373,6 +377,9 @@ export interface ChartEvents {
|
|
|
373
377
|
'render-engine:ready': {
|
|
374
378
|
engine: RenderEngine;
|
|
375
379
|
};
|
|
380
|
+
'render-engine:destroyed': {
|
|
381
|
+
engine: RenderEngine;
|
|
382
|
+
};
|
|
376
383
|
/**
|
|
377
384
|
* A cell handing over its forming-bar getter. The bar mutates in place, so
|
|
378
385
|
* this is a getter and not a value - read it, dont keep it. `get: null`
|
|
@@ -594,6 +601,16 @@ export interface ChartEvents {
|
|
|
594
601
|
id: string;
|
|
595
602
|
params: Record<string, unknown>;
|
|
596
603
|
};
|
|
604
|
+
'plugin:extension-params': {
|
|
605
|
+
id: string;
|
|
606
|
+
entry: string;
|
|
607
|
+
schema: StyleField[] | null;
|
|
608
|
+
defaults: Record<string, unknown>;
|
|
609
|
+
};
|
|
610
|
+
'plugin:extension-params-change': {
|
|
611
|
+
id: string;
|
|
612
|
+
values: Record<string, unknown>;
|
|
613
|
+
};
|
|
597
614
|
/** @console command */
|
|
598
615
|
'plugin:strategy-range': {
|
|
599
616
|
id: string;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ThemeDef } from '../interfaces/plugins/IChartPlugin';
|
|
2
|
+
/**
|
|
3
|
+
* What every built-in dark theme starts from. Spread it and override what's
|
|
4
|
+
* different: `vars: { ...BASE_DARK_VARS, primary: '207 82% 66%' }`.
|
|
5
|
+
*/
|
|
6
|
+
export declare const BASE_DARK_VARS: Readonly<Record<string, string>>;
|
|
7
|
+
export declare const BUILTIN_THEMES: readonly ThemeDef[];
|
package/types/core/index.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export type { DepthProps } from '../ChartOuter';
|
|
|
10
10
|
export { ExecutionEngine } from './ExecutionEngine';
|
|
11
11
|
export { DataEngine } from './DataEngine';
|
|
12
12
|
export type { DataEngineConfig, ChartDataSnapshot } from './DataEngine';
|
|
13
|
+
export { BarStore } from './BarStore';
|
|
13
14
|
export { TypedEventBus } from './TypedEventBus';
|
|
14
15
|
export type { ChartEvents } from './TypedEventBus';
|
|
15
16
|
export type { AuditResult, AuditFnEntry } from './script-audit';
|
|
@@ -18,7 +19,7 @@ export type { DrawParams } from './RenderEngine';
|
|
|
18
19
|
export type { IDataAdapter, DataLevel, TickEvent, OhlcvBar, L2Snapshot, MboEvent, } from '../interfaces/IDataAdapter';
|
|
19
20
|
export type { IExecutionAdapter } from '../interfaces/IExecutionAdapter';
|
|
20
21
|
export { LiveTransformer } from '../interfaces/ICoordinateTransformer';
|
|
21
|
-
export type { ICoordinateTransformer, PriceScaleMode,
|
|
22
|
+
export type { ICoordinateTransformer, PriceScaleMode, } from '../interfaces/ICoordinateTransformer';
|
|
22
23
|
export { PluginRegistry } from './PluginRegistry';
|
|
23
24
|
export type { PluginIcon, InstalledPlugin } from './PluginRegistry';
|
|
24
25
|
export type { PluginCatalogEntry, PluginStartupEntry, PluginStartupRecord, } from './plugin-startup';
|
|
@@ -53,8 +54,8 @@ export type { TradePoint, PriceHistory, ViewBounds, OhlcvBarMs } from '../lib/ty
|
|
|
53
54
|
export type { Timeframe } from '../lib/timeframes';
|
|
54
55
|
export type { DrawingTool } from '../lib/types/drawing-types';
|
|
55
56
|
export type { FootprintBar, FootprintOptions } from '../lib/types/footprint';
|
|
56
|
-
export type { ChartSettings } from '../lib/types/chart-settings';
|
|
57
|
-
export { DEFAULT_CHART_SETTINGS } from '../lib/types/chart-settings';
|
|
57
|
+
export type { ChartColorKey, ChartColors, ChartSettings } from '../lib/types/chart-settings';
|
|
58
|
+
export { CHART_COLOR_KEYS, DEFAULT_CHART_SETTINGS, themedSettings } from '../lib/types/chart-settings';
|
|
58
59
|
export type { PlaceOrderRequest, L3EngineOptions, FeeSchedule, BookDepth, BookLevel } from '../lib/matchingEngine';
|
|
59
60
|
export { createL3MatchingEngine, feeScheduleFor, MICRO_FEE_SCHEDULE, NQ_FEE_SCHEDULE, ZERO_FEE_SCHEDULE, } from '../lib/matchingEngine';
|
|
60
61
|
export { SimulatedMarketAdapter, createSimulatedAdapter } from '../lib/createSimulatedAdapter';
|
|
@@ -93,6 +94,7 @@ export type { FootprintLevel, FootprintMode, PriceRange } from '../lib/types/foo
|
|
|
93
94
|
export type { BarPreviewResponse, BarResponse, DataAdapterErrorCode, FetchRequest, PreProcessedPayload, SupplementalBarSet, SymbolIconSpec, TimeRange, } from '../interfaces/IDataAdapter';
|
|
94
95
|
export { SymbolIcon } from '../components/chart/symbol-icon';
|
|
95
96
|
export type { BottomBarHandle, BottomBarItem, ContextMenuItem, FloatingPanelOpts, NotifyLevel, NotifyOptions, PaneOptions, PluginExecutionSurface, PluginLifecycle, PluginServices, PluginStorage, ServiceApi, ServiceObserver, SettingSchema, SettingSchemaType, ThemeDef, ToolbarItem, } from '../interfaces/plugins/IChartPlugin';
|
|
97
|
+
export { BASE_DARK_VARS, BUILTIN_THEMES, DEFAULT_THEME_ID } from './ThemeRegistry';
|
|
96
98
|
export type { ChartTypeActiveContext, ChartTypeKeyEvent, ChartTypePointerEvent, } from '../interfaces/plugins/IChartTypePlugin';
|
|
97
99
|
export type { AnchorConfig, Point } from '../interfaces/plugins/IDrawingPlugin';
|
|
98
100
|
export type { IndicatorCrosshair } from '../interfaces/plugins/IIndicatorPlugin';
|
|
@@ -111,6 +113,6 @@ export type { ChartPane, Indicator, Rect } from '../lib/types/indicator-types';
|
|
|
111
113
|
export type { CrosshairSync, TimeRangeSync } from '../lib/types/layout-sync';
|
|
112
114
|
export type { TradeLineHitMap } from '../lib/renderers/drawTradeLines';
|
|
113
115
|
export type { PlaybackMode } from '../hooks/usePlaybackEngine';
|
|
114
|
-
export type { DrawHook } from './RenderEngine';
|
|
116
|
+
export type { DrawHook, DrawInfo, DrawPhase } from './RenderEngine';
|
|
115
117
|
export type { InterceptableEvent, Interceptor } from './TypedEventBus';
|
|
116
118
|
export { ChartState } from './ChartState';
|
|
@@ -23,11 +23,13 @@ export interface PluginCatalogEntry {
|
|
|
23
23
|
export interface PluginStartupEntry {
|
|
24
24
|
/** Install the plugin when the chart opens. */
|
|
25
25
|
autostart: boolean;
|
|
26
|
-
/**
|
|
26
|
+
/**
|
|
27
|
+
* Indicators only: also put an instance on a pane. Ignored when the chart was
|
|
28
|
+
* restored with pane state - the save decides what's on its panes.
|
|
29
|
+
*/
|
|
27
30
|
activate?: boolean;
|
|
28
31
|
}
|
|
29
32
|
export type PluginStartupRecord = Record<string, PluginStartupEntry>;
|
|
30
|
-
export declare function ptrace(...args: unknown[]): void;
|
|
31
33
|
export declare function readPluginStartup(): PluginStartupRecord;
|
|
32
34
|
/** Merge a patch into one plugin's entry. `null` forgets the plugin entirely. */
|
|
33
35
|
export declare function writePluginStartup(id: string, patch: Partial<PluginStartupEntry> | null): PluginStartupRecord;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ThemeDef } from '../interfaces/plugins/IChartPlugin';
|
|
2
|
+
export declare function themeCss(theme: ThemeDef): string | null;
|
|
3
|
+
export declare class ThemeStyle {
|
|
4
|
+
private readonly id;
|
|
5
|
+
private el;
|
|
6
|
+
constructor(id: string);
|
|
7
|
+
apply(theme: ThemeDef): void;
|
|
8
|
+
remove(): void;
|
|
9
|
+
}
|
|
@@ -14,17 +14,19 @@ import { type ChartSettings } from '../lib/types/chart-settings';
|
|
|
14
14
|
import { type TypedEventBus } from '../core/TypedEventBus';
|
|
15
15
|
import { type RenderEngine } from '../core/RenderEngine';
|
|
16
16
|
import { type SessionMapper } from '../core/SessionMapper';
|
|
17
|
+
import { BarStore } from '../core/BarStore';
|
|
17
18
|
import { ohlcvBucketRange } from '../lib/bar-grid';
|
|
18
19
|
import { type SessionStatus } from '../core/SessionUtils';
|
|
19
20
|
export { ohlcvBucketRange };
|
|
20
|
-
export declare function aggregateOhlcvBars(bars:
|
|
21
|
+
export declare function aggregateOhlcvBars(bars: BarStore, targetBarNs: bigint, sessionMapper?: SessionMapper | null, from?: number): BarStore;
|
|
22
|
+
export declare function isAggregated(bars: BarStore, targetBarNs: bigint, sessionMapper?: SessionMapper | null, from?: number, to?: number): boolean;
|
|
23
|
+
export declare function displayFor(bars: BarStore, targetBarNs: bigint, sessionMapper?: SessionMapper | null): BarStore;
|
|
21
24
|
/**
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* Handles the boundary bucket that might straddle the old/new data boundary.
|
|
25
|
+
* Prepend fetched bars to an aggregated display store in place, merging the
|
|
26
|
+
* bucket that straddles the boundary. Costs the new bars only.
|
|
25
27
|
*/
|
|
26
|
-
export declare function prependAggregatedOhlcvBars(newBars: OhlcvBarMs[],
|
|
27
|
-
export declare function autoFitPriceAxis(view: ViewBounds, priceHistory: PriceHistory[], trades: TradePoint[], bars:
|
|
28
|
+
export declare function prependAggregatedOhlcvBars(newBars: OhlcvBarMs[], display: BarStore, targetBarNs: bigint, sessionMapper?: SessionMapper | null): BarStore;
|
|
29
|
+
export declare function autoFitPriceAxis(view: ViewBounds, priceHistory: PriceHistory[], trades: TradePoint[], bars: BarStore, openBar: FootprintBar | null, settings: ChartSettings, horizon: bigint, dataLevel?: DataLevel): void;
|
|
28
30
|
export declare function applyHorizonScrollEasing(t: number, type: string): number;
|
|
29
31
|
export interface UseChartDataParams {
|
|
30
32
|
eventBus: TypedEventBus;
|
|
@@ -52,7 +54,6 @@ export interface UseChartDataParams {
|
|
|
52
54
|
updateSettingsBarPosRef: MutableRefObject<(id: string | null) => void>;
|
|
53
55
|
resetViewRef: MutableRefObject<() => void>;
|
|
54
56
|
syncPixelLayoutsRef: MutableRefObject<(panes?: ChartPane[]) => void>;
|
|
55
|
-
doBaseRedrawRef: MutableRefObject<() => void>;
|
|
56
57
|
setIndicators: (inds: Indicator[]) => void;
|
|
57
58
|
setPanes: (updater: ((prev: ChartPane[]) => ChartPane[]) | ChartPane[]) => void;
|
|
58
59
|
getPanel: () => DomPanelHandle | null;
|
|
@@ -77,10 +78,10 @@ export interface ChartDataResult {
|
|
|
77
78
|
footprintBarsRef: MutableRefObject<FootprintBar[]>;
|
|
78
79
|
ohlcvBarsRef: MutableRefObject<{
|
|
79
80
|
barNs: bigint;
|
|
80
|
-
bars:
|
|
81
|
-
display:
|
|
81
|
+
bars: BarStore;
|
|
82
|
+
display: BarStore;
|
|
82
83
|
}>;
|
|
83
|
-
previewBarsRef: MutableRefObject<
|
|
84
|
+
previewBarsRef: MutableRefObject<BarStore>;
|
|
84
85
|
openBarRef: MutableRefObject<FootprintBar | null>;
|
|
85
86
|
openBarTsRef: MutableRefObject<bigint>;
|
|
86
87
|
openBarTradeCountRef: MutableRefObject<number>;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { type MutableRefObject, type RefObject } from 'react';
|
|
2
2
|
import { type Drawing } from '../lib/types/drawing-types';
|
|
3
3
|
import { type ChartPane, type Indicator, type Rect } from '../lib/types/indicator-types';
|
|
4
|
-
import { type ViewBounds, type TradeLine, type TradePoint, type PriceHistory
|
|
4
|
+
import { type ViewBounds, type TradeLine, type TradePoint, type PriceHistory } from '../lib/types';
|
|
5
5
|
import { type Timeframe } from '../lib/timeframes';
|
|
6
6
|
import { type RenderEngine } from '../core/RenderEngine';
|
|
7
|
+
import { type BarStore } from '../core/BarStore';
|
|
7
8
|
import { type LiveTransformer } from '../interfaces/ICoordinateTransformer';
|
|
8
9
|
import { type DataLevel } from '../interfaces/IDataAdapter';
|
|
9
10
|
import { type CompactBuffer } from '../lib/compact-buffer';
|
|
@@ -20,8 +21,8 @@ export interface UseChartHandlersParams {
|
|
|
20
21
|
panesRef: MutableRefObject<ChartPane[]>;
|
|
21
22
|
ohlcvBarsRef: MutableRefObject<{
|
|
22
23
|
barNs: bigint;
|
|
23
|
-
bars:
|
|
24
|
-
display:
|
|
24
|
+
bars: BarStore;
|
|
25
|
+
display: BarStore;
|
|
25
26
|
}>;
|
|
26
27
|
sessionMapperRef: MutableRefObject<SessionMapper>;
|
|
27
28
|
activeTimeframeRef: MutableRefObject<Timeframe>;
|
|
@@ -36,7 +37,7 @@ export interface UseChartHandlersParams {
|
|
|
36
37
|
isYAxisAutoRef: MutableRefObject<boolean>;
|
|
37
38
|
priceHistoryRef: MutableRefObject<PriceHistory[]>;
|
|
38
39
|
dataLevelRef: MutableRefObject<DataLevel | null>;
|
|
39
|
-
previewBarsRef: MutableRefObject<
|
|
40
|
+
previewBarsRef: MutableRefObject<BarStore>;
|
|
40
41
|
chartSettingsRef: MutableRefObject<ChartSettings>;
|
|
41
42
|
tradeLinesRef: MutableRefObject<TradeLine[]>;
|
|
42
43
|
hoveringLegend: MutableRefObject<boolean>;
|