@tradecanvas/commons 1.4.0 → 1.10.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/dist/constants/themes.d.ts +19 -0
- package/dist/constants/themes.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +659 -126
- package/dist/index.js.map +1 -1
- package/dist/types/a11y.d.ts +18 -0
- package/dist/types/a11y.d.ts.map +1 -0
- package/dist/types/chart.d.ts +113 -2
- package/dist/types/chart.d.ts.map +1 -1
- package/dist/types/drawing.d.ts +85 -1
- package/dist/types/drawing.d.ts.map +1 -1
- package/dist/types/events.d.ts +150 -1
- package/dist/types/events.d.ts.map +1 -1
- package/dist/types/execution.d.ts +20 -1
- package/dist/types/execution.d.ts.map +1 -1
- package/dist/types/index.d.ts +4 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/indicator.d.ts +81 -0
- package/dist/types/indicator.d.ts.map +1 -1
- package/dist/types/layout.d.ts +8 -0
- package/dist/types/layout.d.ts.map +1 -1
- package/dist/types/news.d.ts +18 -0
- package/dist/types/news.d.ts.map +1 -0
- package/dist/types/ohlc.d.ts +11 -1
- package/dist/types/ohlc.d.ts.map +1 -1
- package/dist/types/quote.d.ts +40 -0
- package/dist/types/quote.d.ts.map +1 -0
- package/dist/types/realtime.d.ts +50 -0
- package/dist/types/realtime.d.ts.map +1 -1
- package/dist/types/rendering.d.ts +11 -0
- package/dist/types/rendering.d.ts.map +1 -1
- package/dist/types/symbol.d.ts +42 -0
- package/dist/types/symbol.d.ts.map +1 -0
- package/dist/types/theme.d.ts +6 -0
- package/dist/types/theme.d.ts.map +1 -1
- package/dist/types/trading.d.ts +33 -2
- package/dist/types/trading.d.ts.map +1 -1
- package/dist/utils/chartTypeOptions.d.ts +9 -0
- package/dist/utils/chartTypeOptions.d.ts.map +1 -0
- package/dist/utils/color.d.ts +4 -0
- package/dist/utils/color.d.ts.map +1 -1
- package/dist/utils/drawingOptions.d.ts +8 -0
- package/dist/utils/drawingOptions.d.ts.map +1 -0
- package/dist/utils/drawingStyle.d.ts +9 -0
- package/dist/utils/drawingStyle.d.ts.map +1 -0
- package/dist/utils/index.d.ts +8 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/marketStatus.d.ts +16 -0
- package/dist/utils/marketStatus.d.ts.map +1 -0
- package/dist/utils/precision.d.ts +18 -0
- package/dist/utils/precision.d.ts.map +1 -1
- package/dist/utils/priceSource.d.ts +15 -0
- package/dist/utils/priceSource.d.ts.map +1 -0
- package/dist/utils/resample.d.ts +13 -0
- package/dist/utils/resample.d.ts.map +1 -0
- package/dist/utils/symbols.d.ts +13 -0
- package/dist/utils/symbols.d.ts.map +1 -0
- package/dist/utils/time.d.ts +29 -8
- package/dist/utils/time.d.ts.map +1 -1
- package/dist/utils/timezone.d.ts +28 -0
- package/dist/utils/timezone.d.ts.map +1 -0
- package/package.json +1 -1
package/dist/types/chart.d.ts
CHANGED
|
@@ -1,7 +1,36 @@
|
|
|
1
1
|
import { Theme, ThemeName } from './theme.js';
|
|
2
2
|
import { DrawingToolType } from './drawing.js';
|
|
3
3
|
import { TimeFrame } from './ohlc.js';
|
|
4
|
-
export type ChartType = 'candlestick' | 'line' | 'area' | 'bar' | 'heikinAshi' | 'hollowCandle' | 'baseline' | 'renko' | 'lineBreak' | 'kagi' | 'pointAndFigure' | 'rangeBars' | 'volumeCandles' | 'hlcArea' | 'stepLine' | 'lineWithMarkers' | 'equivolume';
|
|
4
|
+
export type ChartType = 'candlestick' | 'line' | 'area' | 'bar' | 'heikinAshi' | 'hollowCandle' | 'baseline' | 'renko' | 'lineBreak' | 'kagi' | 'pointAndFigure' | 'rangeBars' | 'volumeCandles' | 'hlcArea' | 'stepLine' | 'lineWithMarkers' | 'equivolume' | 'hiLo';
|
|
5
|
+
/**
|
|
6
|
+
* Settings of the chart types that build bars of their own. What isn't set
|
|
7
|
+
* is worked out from the data.
|
|
8
|
+
*/
|
|
9
|
+
export interface ChartTypeOptions {
|
|
10
|
+
/** Box size in price, or 'atr' (default): the average true range of the last `atrPeriod` bars (14). */
|
|
11
|
+
renko?: {
|
|
12
|
+
boxSize?: number | 'atr';
|
|
13
|
+
atrPeriod?: number;
|
|
14
|
+
};
|
|
15
|
+
/** How many lines a reversal has to break (3). */
|
|
16
|
+
lineBreak?: {
|
|
17
|
+
lines?: number;
|
|
18
|
+
};
|
|
19
|
+
/** The reversal: percent of the line's start (4), or an amount of price with `reversalType` 'price'. */
|
|
20
|
+
kagi?: {
|
|
21
|
+
reversal?: number;
|
|
22
|
+
reversalType?: 'percent' | 'price';
|
|
23
|
+
};
|
|
24
|
+
/** Box size in price ('auto': 1% of the average close) and boxes to reverse (3). */
|
|
25
|
+
pointAndFigure?: {
|
|
26
|
+
boxSize?: number | 'auto';
|
|
27
|
+
reversal?: number;
|
|
28
|
+
};
|
|
29
|
+
/** Each bar's range in price ('auto': 0.5% of the average close). */
|
|
30
|
+
rangeBars?: {
|
|
31
|
+
range?: number | 'auto';
|
|
32
|
+
};
|
|
33
|
+
}
|
|
5
34
|
export type LineStyle = 'solid' | 'dashed' | 'dotted';
|
|
6
35
|
/**
|
|
7
36
|
* Controls which features are available to the end user.
|
|
@@ -21,6 +50,11 @@ export interface FeaturesConfig {
|
|
|
21
50
|
trading?: boolean;
|
|
22
51
|
/** Right-click menu for placing orders. Default `false` — opt in explicitly. */
|
|
23
52
|
tradingContextMenu?: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* A "+" by the price axis, level with the crosshair; a click on it emits
|
|
55
|
+
* `priceAxisAdd` with the price. Default `false` (ChartWidget turns it on).
|
|
56
|
+
*/
|
|
57
|
+
priceAxisAddButton?: boolean;
|
|
24
58
|
/** Enable indicator overlays and panels */
|
|
25
59
|
indicators?: boolean;
|
|
26
60
|
/** Whitelist of allowed indicator IDs. When set, only these are available. */
|
|
@@ -48,6 +82,8 @@ export interface FeaturesConfig {
|
|
|
48
82
|
grid?: boolean;
|
|
49
83
|
/** Show OHLCV legend overlay */
|
|
50
84
|
legend?: boolean;
|
|
85
|
+
/** Tag each indicator line's latest value on its value axis. Default true. */
|
|
86
|
+
indicatorValueLabels?: boolean;
|
|
51
87
|
/** Show volume bars below candles */
|
|
52
88
|
volume?: boolean;
|
|
53
89
|
/** Show watermark text */
|
|
@@ -81,7 +117,8 @@ export interface FeaturesConfig {
|
|
|
81
117
|
export interface ChartOptions {
|
|
82
118
|
width?: number;
|
|
83
119
|
height?: number;
|
|
84
|
-
|
|
120
|
+
/** Default `'candlestick'`. */
|
|
121
|
+
chartType?: ChartType;
|
|
85
122
|
theme?: ThemeName | Theme;
|
|
86
123
|
autoScale?: boolean;
|
|
87
124
|
rightMargin?: number;
|
|
@@ -107,11 +144,85 @@ export interface ChartOptions {
|
|
|
107
144
|
* resting position).
|
|
108
145
|
*/
|
|
109
146
|
freePan?: boolean;
|
|
147
|
+
/**
|
|
148
|
+
* Timezone for the time axis, crosshair, tooltip, day breaks and range
|
|
149
|
+
* presets: an IANA zone (`'America/New_York'`, daylight saving included), a
|
|
150
|
+
* fixed offset in minutes east of UTC, or null (default) for the browser's.
|
|
151
|
+
*/
|
|
152
|
+
timeZone?: string | number | null;
|
|
153
|
+
/**
|
|
154
|
+
* Show a price scale on the left too. It carries the overlays put on it
|
|
155
|
+
* (`addIndicator(…, { scale: 'left' })`), else it mirrors the price scale.
|
|
156
|
+
* It shows by itself once an overlay is on it.
|
|
157
|
+
*/
|
|
158
|
+
leftPriceScale?: boolean;
|
|
110
159
|
/** Bounds for free panning. */
|
|
111
160
|
panLimits?: {
|
|
112
161
|
minVisibleBars?: number;
|
|
113
162
|
};
|
|
163
|
+
/**
|
|
164
|
+
* How prices read on the price scale and everything that prints one (axis,
|
|
165
|
+
* crosshair, last-price tag, legend, tooltip, orders, alerts, drawings): a
|
|
166
|
+
* function of yours, or fractions of a point (a bond in 32nds: `101'16`).
|
|
167
|
+
* Indicator panes keep their own numbers. Default: decimals.
|
|
168
|
+
*/
|
|
169
|
+
priceFormat?: PriceFormatter | PriceFraction;
|
|
170
|
+
/** How times read on the time axis, the crosshair and the tooltip. Default: the chart's own. */
|
|
171
|
+
timeFormatter?: TimeFormatter;
|
|
172
|
+
/** Settings of Renko, Line Break, Kagi, Point & Figure and range bars. */
|
|
173
|
+
chartTypeOptions?: ChartTypeOptions;
|
|
174
|
+
/** Mark the highest high and lowest low on screen with a line and a price tag. */
|
|
175
|
+
highLowLines?: boolean;
|
|
176
|
+
/** The shapes the chart draws: price tags, axis pills and order badges square (default), rounded or pills. */
|
|
177
|
+
shapes?: import('./theme.js').ShapeConfig;
|
|
178
|
+
/**
|
|
179
|
+
* The chart for screen readers: a summary, what is on screen after the keys
|
|
180
|
+
* move it, comma and period to read the bars. On by default; labels in your
|
|
181
|
+
* language here; `false` leaves it out.
|
|
182
|
+
*/
|
|
183
|
+
a11y?: false | {
|
|
184
|
+
labels?: Partial<import('./a11y.js').ChartA11yLabels>;
|
|
185
|
+
};
|
|
186
|
+
/**
|
|
187
|
+
* What draws the plot and panes: `'canvas'` (Canvas 2D, the default),
|
|
188
|
+
* `'webgl'` (WebGL 2 on the GPU, Canvas 2D where it can't be had) or
|
|
189
|
+
* `'auto'` (WebGL 2 where the GPU is a real one). On the GPU go the grid,
|
|
190
|
+
* sessions, series, compare lines, indicators and panes; text, drawings,
|
|
191
|
+
* orders, axes and the crosshair stay Canvas 2D, as does anything the GPU
|
|
192
|
+
* can't draw the same. The WebGL code loads only when asked for. See
|
|
193
|
+
* `rendererChange`.
|
|
194
|
+
*/
|
|
195
|
+
renderer?: 'canvas' | 'webgl' | 'auto';
|
|
196
|
+
/**
|
|
197
|
+
* Show the bars outside the symbol's regular hours (`SymbolInfo.sessions`):
|
|
198
|
+
* pre- and post-market. Default true; bars a day or longer are never left out.
|
|
199
|
+
*/
|
|
200
|
+
extendedHours?: boolean;
|
|
201
|
+
}
|
|
202
|
+
/** A price in your words, e.g. `(p) => '$' + p.toFixed(2)`. */
|
|
203
|
+
export type PriceFormatter = (price: number) => string;
|
|
204
|
+
/**
|
|
205
|
+
* Prices in fractions of a point: `denominator` 32 prints 101.5 as `101'16`.
|
|
206
|
+
* `subDenominator` 2 or 4 splits each fraction in halves or quarters, printed
|
|
207
|
+
* as a last digit the way futures quote them (`101'165` is 101 and 16½ 32nds).
|
|
208
|
+
*/
|
|
209
|
+
export interface PriceFraction {
|
|
210
|
+
denominator: number;
|
|
211
|
+
subDenominator?: number;
|
|
212
|
+
}
|
|
213
|
+
/** Where a time is printed, for a `TimeFormatter`. */
|
|
214
|
+
export interface TimeFormatContext {
|
|
215
|
+
/**
|
|
216
|
+
* `'date'`: an axis label of a bar a day or longer; `'day'`: an axis label
|
|
217
|
+
* where a new day starts; `'time'`: an axis label within a day;
|
|
218
|
+
* `'crosshair'`: the crosshair's label and the tooltip.
|
|
219
|
+
*/
|
|
220
|
+
kind: 'date' | 'day' | 'time' | 'crosshair';
|
|
221
|
+
/** The chart's time zone: an IANA name, minutes east of UTC, or null for the browser's. */
|
|
222
|
+
timeZone: string | number | null;
|
|
114
223
|
}
|
|
224
|
+
/** A time (ms since the epoch) in your words. */
|
|
225
|
+
export type TimeFormatter = (time: number, context: TimeFormatContext) => string;
|
|
115
226
|
export interface SessionBreakOptions {
|
|
116
227
|
visible?: boolean;
|
|
117
228
|
color?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chart.d.ts","sourceRoot":"","sources":["../../src/types/chart.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAE3C,MAAM,MAAM,SAAS,GACjB,aAAa,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,GACvC,YAAY,GAAG,cAAc,GAAG,UAAU,GAC1C,OAAO,GA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MAAM,WAAW,eAAe;IAC9B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,OAAO,GAAG,SAAS,GAAG,QAAQ,CAAC;IACrC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB"}
|
package/dist/types/drawing.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Point, ViewportState } from './rendering.js';
|
|
2
|
-
|
|
2
|
+
import { OHLCBar } from './ohlc.js';
|
|
3
|
+
export type DrawingToolType = 'trendLine' | 'horizontalLine' | 'horizontalRay' | 'verticalLine' | 'ray' | 'extendedLine' | 'crossLine' | 'trendAngle' | 'infoLine' | 'parallelChannel' | 'regressionChannel' | 'fibRetracement' | 'fibExtension' | 'fibTimeZones' | 'fibChannel' | 'fibSpeedResistanceFan' | 'rectangle' | 'ellipse' | 'triangle' | 'circle' | 'pitchfork' | 'schiffPitchfork' | 'modifiedSchiffPitchfork' | 'elliottWave' | 'xabcdPattern' | 'abcdPattern' | 'headAndShoulders' | 'priceRange' | 'dateRange' | 'dateAndPriceRange' | 'measure' | 'text' | 'arrow' | 'priceLabel' | 'gannFan' | 'gannBox' | 'cyclicLines' | 'anchoredVWAP' | 'volumeProfileRange' | 'riskReward' | 'note' | 'callout' | 'flag' | 'arrowMark' | 'icon' | 'brush' | 'highlighter' | 'path' | 'polyline' | 'curve' | 'arc' | 'fibCircles' | 'fibSpiral' | 'fibArcs' | 'fibWedge' | 'pitchfan' | 'gannSquare' | 'elliottImpulse' | 'elliottCorrection' | 'elliottTriangle' | 'elliottDoubleCombo' | 'elliottTripleCombo' | 'threeDrives' | 'cypherPattern' | 'timeCycles' | 'sineLine' | 'forecast' | 'projection' | 'barsPattern';
|
|
3
4
|
export interface AnchorPoint {
|
|
4
5
|
time: number;
|
|
5
6
|
price: number;
|
|
@@ -20,19 +21,102 @@ export interface DrawingState {
|
|
|
20
21
|
style: DrawingStyle;
|
|
21
22
|
visible: boolean;
|
|
22
23
|
locked: boolean;
|
|
24
|
+
/** The tool's own settings (levels, extend left/right…); see `DrawingDescriptor.options`. */
|
|
25
|
+
options?: DrawingOptions;
|
|
26
|
+
/** The group it belongs to: drawings selected, hidden and locked together. */
|
|
27
|
+
group?: {
|
|
28
|
+
id: string;
|
|
29
|
+
name: string;
|
|
30
|
+
};
|
|
23
31
|
meta?: Record<string, unknown>;
|
|
24
32
|
}
|
|
33
|
+
/** One level of a Fibonacci or Gann tool: a ratio, shown or not, in its own colour. */
|
|
34
|
+
export interface DrawingLevel {
|
|
35
|
+
value: number;
|
|
36
|
+
visible: boolean;
|
|
37
|
+
/** CSS colour; the drawing's colour when left out. */
|
|
38
|
+
color?: string;
|
|
39
|
+
}
|
|
40
|
+
export type DrawingOptionValue = boolean | number | string | DrawingLevel[];
|
|
41
|
+
/** A drawing's settings beyond the shared style, by key. Missing keys take the tool's defaults. */
|
|
42
|
+
export type DrawingOptions = Record<string, DrawingOptionValue>;
|
|
43
|
+
/** A setting a drawing tool offers beyond the shared style, with its default. */
|
|
44
|
+
export type DrawingOptionDef = {
|
|
45
|
+
kind: 'boolean';
|
|
46
|
+
label: string;
|
|
47
|
+
default: boolean;
|
|
48
|
+
} | {
|
|
49
|
+
kind: 'number';
|
|
50
|
+
label: string;
|
|
51
|
+
default: number;
|
|
52
|
+
min?: number;
|
|
53
|
+
max?: number;
|
|
54
|
+
step?: number;
|
|
55
|
+
} | {
|
|
56
|
+
kind: 'choice';
|
|
57
|
+
label: string;
|
|
58
|
+
default: string;
|
|
59
|
+
choices: readonly {
|
|
60
|
+
value: string;
|
|
61
|
+
label: string;
|
|
62
|
+
}[];
|
|
63
|
+
} | {
|
|
64
|
+
kind: 'levels';
|
|
65
|
+
label: string;
|
|
66
|
+
default: readonly DrawingLevel[];
|
|
67
|
+
} | {
|
|
68
|
+
kind: 'text';
|
|
69
|
+
label: string;
|
|
70
|
+
default: string;
|
|
71
|
+
};
|
|
72
|
+
export type DrawingOptionDefs = Readonly<Record<string, DrawingOptionDef>>;
|
|
25
73
|
export interface DrawingDescriptor {
|
|
26
74
|
type: DrawingToolType;
|
|
27
75
|
name: string;
|
|
28
76
|
requiredAnchors: number;
|
|
29
77
|
singleClick?: boolean;
|
|
78
|
+
/** Settings the tool offers beyond the shared style; a settings dialog is built from them. */
|
|
79
|
+
options?: DrawingOptionDefs;
|
|
80
|
+
/** It fills an area with `style.fillColor` (a settings dialog offers the fill). */
|
|
81
|
+
fill?: boolean;
|
|
82
|
+
/** It draws `style.text` (a settings dialog offers the text and its size). */
|
|
83
|
+
text?: boolean;
|
|
84
|
+
/**
|
|
85
|
+
* How it is drawn with the pointer. 'clicks' (the default): a click per
|
|
86
|
+
* anchor up to `requiredAnchors`. 'freehand': press and drag, a point every
|
|
87
|
+
* few pixels, release to finish. 'path': a click per point, at least
|
|
88
|
+
* `requiredAnchors` and at most `maxAnchors`; a double-click, Enter or a
|
|
89
|
+
* click on the last point finishes it.
|
|
90
|
+
*/
|
|
91
|
+
creation?: 'clicks' | 'freehand' | 'path';
|
|
92
|
+
/** Most points a 'path' takes (100 when left out). */
|
|
93
|
+
maxAnchors?: number;
|
|
30
94
|
}
|
|
31
95
|
export interface DrawingPlugin {
|
|
32
96
|
descriptor: DrawingDescriptor;
|
|
33
97
|
render(ctx: CanvasRenderingContext2D, state: DrawingState, viewport: ViewportState, selected: boolean): void;
|
|
34
98
|
hitTest(point: Point, state: DrawingState, viewport: ViewportState, tolerance: number): boolean;
|
|
35
99
|
hitTestAnchor(point: Point, state: DrawingState, viewport: ViewportState, tolerance: number): number;
|
|
100
|
+
/**
|
|
101
|
+
* The drawing after handle `index` (from `hitTestAnchor`) is dragged to
|
|
102
|
+
* `anchor`. Without it, the handle is anchor `index` and moves there. A
|
|
103
|
+
* tool with handles that are not anchors (a position's target, say)
|
|
104
|
+
* changes its options instead.
|
|
105
|
+
*/
|
|
106
|
+
moveHandle?(state: DrawingState, index: number, anchor: AnchorPoint): DrawingState;
|
|
107
|
+
/**
|
|
108
|
+
* The prices of the drawing's lines at `time` (what an alert on it
|
|
109
|
+
* crosses), or null where it doesn't reach. Tools without it take no alerts.
|
|
110
|
+
* With `viewport` the lines follow the chart as drawn: straight across bars
|
|
111
|
+
* (not clock time, so a weekend gap doesn't bend them) and on a log scale
|
|
112
|
+
* straight in log price.
|
|
113
|
+
*/
|
|
114
|
+
priceAt?(state: DrawingState, time: number, viewport?: ViewportState): number[] | null;
|
|
115
|
+
/**
|
|
116
|
+
* For a tool drawn from the chart's bars (an anchored VWAP, a volume
|
|
117
|
+
* profile): the chart hands it a getter for them when it is registered.
|
|
118
|
+
*/
|
|
119
|
+
setDataGetter?(getter: () => readonly OHLCBar[]): void;
|
|
36
120
|
}
|
|
37
121
|
export declare const DEFAULT_DRAWING_STYLE: DrawingStyle;
|
|
38
122
|
//# sourceMappingURL=drawing.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"drawing.d.ts","sourceRoot":"","sources":["../../src/types/drawing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"drawing.d.ts","sourceRoot":"","sources":["../../src/types/drawing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,MAAM,MAAM,eAAe,GACvB,WAAW,GAAG,gBAAgB,GAAG,eAAe,GAAG,cAAc,GAAG,KAAK,GAAG,cAAc,GAC1F,WAAW,GA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M,GAChB,MAAM,CAAC;IACV;;;;;OAKG;IACH,UAAU,CAAC,CAAC,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,GAAG,YAAY,CAAC;IACnF;;;;;;OAMG;IACH,OAAO,CAAC,CAAC,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,aAAa,GAAG,MAAM,EAAE,GAAG,IAAI,CAAC;IACvF;;;OAGG;IACH,aAAa,CAAC,CAAC,MAAM,EAAE,MAAM,SAAS,OAAO,EAAE,GAAG,IAAI,CAAC;CACxD;AAED,eAAO,MAAM,qBAAqB,EAAE,YAOnC,CAAC"}
|
package/dist/types/events.d.ts
CHANGED
|
@@ -2,7 +2,37 @@ import { OHLCBar, DataSeries } from './ohlc.js';
|
|
|
2
2
|
import { Point } from './rendering.js';
|
|
3
3
|
import { IndicatorValue } from './indicator.js';
|
|
4
4
|
import { DrawingToolType } from './drawing.js';
|
|
5
|
-
|
|
5
|
+
import { SymbolInfo } from './symbol.js';
|
|
6
|
+
export type ChartEventType = 'crosshairMove' | 'crosshairLeave' | 'click' | 'barClick' | 'visibleRangeChange' | 'priceRangeChange' | 'zoomChange' | 'dataUpdate' | 'historyLoad' | 'symbolInfoChange' | 'indicatorAdd' | 'indicatorRemove' | 'paneResize'
|
|
7
|
+
/** A pane was folded or opened, maximised or put back, or moved up or down. */
|
|
8
|
+
| 'paneChange' | 'indicatorUpdate' | 'indicatorChange' | 'themeChange' | 'resize' | 'orderPlace' | 'orderModify' | 'orderCancel' | 'positionClose' | 'positionReverse' | 'positionModify' | 'executionFill' | 'ordersChange' | 'positionsChange' | 'executionError' | 'bracketPlace' | 'drawingCreate' | 'drawingUpdate' | 'drawingDoubleClick' | 'drawingContextMenu' | 'toolModeChange' | 'chartContextMenu' | 'priceAxisAdd' | 'drawingRemove' | 'drawingToolChange' | 'signalMarkerAdd' | 'signalMarkerRemove'
|
|
9
|
+
/** The pointer went onto a signal marker, or off it (`marker: null`). */
|
|
10
|
+
| 'signalMarkerHover'
|
|
11
|
+
/** A signal marker was clicked. */
|
|
12
|
+
| 'signalMarkerClick' | 'tradeZoneAdd' | 'tradeZoneRemove' | 'alertAdd' | 'alertRemove' | 'alertTriggered'
|
|
13
|
+
/** An alert reached its `expiresAt` without firing. */
|
|
14
|
+
| 'alertExpired' | 'symbolSeriesRequest'
|
|
15
|
+
/** A replay step: the bar forming, when it opened, and up to when the replay has shown. */
|
|
16
|
+
| 'replayStep'
|
|
17
|
+
/** A replay started playing, paused or ended. */
|
|
18
|
+
| 'replayState' | 'alertUpdate'
|
|
19
|
+
/**
|
|
20
|
+
* Something a saved layout holds may have changed: drawings, indicators,
|
|
21
|
+
* alerts, the chart type or the theme. Fires often; debounce it.
|
|
22
|
+
*/
|
|
23
|
+
| 'stateChange'
|
|
24
|
+
/** The chart type changed (`setChartType`). */
|
|
25
|
+
| 'chartTypeChange'
|
|
26
|
+
/** The stream moved to another symbol (`connect`, `switchStream`). */
|
|
27
|
+
| 'symbolChange'
|
|
28
|
+
/** The stream moved to another timeframe (`connect`, `setTimeframe`, `switchStream`). */
|
|
29
|
+
| 'timeframeChange'
|
|
30
|
+
/** The undo history changed: whether there is something to undo or redo. */
|
|
31
|
+
| 'historyChange'
|
|
32
|
+
/** The drawings selected changed. */
|
|
33
|
+
| 'drawingSelect'
|
|
34
|
+
/** The chart started drawing with another renderer (`renderer` option, `setRenderer`, a lost GPU). */
|
|
35
|
+
| 'rendererChange';
|
|
6
36
|
export interface ChartEvent<T = unknown> {
|
|
7
37
|
type: ChartEventType;
|
|
8
38
|
timestamp: number;
|
|
@@ -107,6 +137,28 @@ export interface DrawingCreatePayload {
|
|
|
107
137
|
export interface DrawingRemovePayload {
|
|
108
138
|
id: string;
|
|
109
139
|
}
|
|
140
|
+
/** Where a right-click landed: the price pane, another pane, or an axis. */
|
|
141
|
+
export type ChartContextArea = 'plot' | 'pane' | 'priceAxis' | 'timeAxis';
|
|
142
|
+
/**
|
|
143
|
+
* Payload for `chartContextMenu`: a right-click off any drawing, where it was
|
|
144
|
+
* (`x`, `y` in the chart's pixels), and the price and bar time there when the
|
|
145
|
+
* area has them (the price pane: both; the price axis: price; the time axis: time).
|
|
146
|
+
*/
|
|
147
|
+
export interface ChartContextMenuPayload {
|
|
148
|
+
area: ChartContextArea;
|
|
149
|
+
x: number;
|
|
150
|
+
y: number;
|
|
151
|
+
price?: number;
|
|
152
|
+
time?: number;
|
|
153
|
+
/** For a pane: the indicator whose pane it is. */
|
|
154
|
+
pane?: string;
|
|
155
|
+
}
|
|
156
|
+
/** Payload for `priceAxisAdd`: the "+" by the price axis was clicked at `price`. */
|
|
157
|
+
export interface PriceAxisAddPayload {
|
|
158
|
+
price: number;
|
|
159
|
+
x: number;
|
|
160
|
+
y: number;
|
|
161
|
+
}
|
|
110
162
|
export interface SignalMarkerAddPayload {
|
|
111
163
|
id: string;
|
|
112
164
|
source: string;
|
|
@@ -124,10 +176,36 @@ export interface TradeZoneRemovePayload {
|
|
|
124
176
|
}
|
|
125
177
|
export interface AlertPayload {
|
|
126
178
|
id: string;
|
|
179
|
+
/** The level; for an alert on another line, that line's latest value; NaN for a move. */
|
|
127
180
|
price: number;
|
|
128
181
|
condition: string;
|
|
129
182
|
message?: string;
|
|
130
183
|
triggered: boolean;
|
|
184
|
+
/** What it watches: `'price'` or `<instanceId>:<key>`. */
|
|
185
|
+
channel?: string;
|
|
186
|
+
label?: string;
|
|
187
|
+
/** The line it compares with. */
|
|
188
|
+
target?: string;
|
|
189
|
+
/** The drawing it watches. */
|
|
190
|
+
drawingId?: string;
|
|
191
|
+
/** A move: the percent, within how many bars. */
|
|
192
|
+
percent?: number;
|
|
193
|
+
bars?: number;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Payload for `historyLoad`: paging older bars in. `loading` when a request
|
|
197
|
+
* starts, then `loaded` (`count` bars added), `end` (no older bars) or
|
|
198
|
+
* `error`.
|
|
199
|
+
*/
|
|
200
|
+
export interface HistoryLoadPayload {
|
|
201
|
+
state: 'loading' | 'loaded' | 'end' | 'error';
|
|
202
|
+
count: number;
|
|
203
|
+
error?: string;
|
|
204
|
+
}
|
|
205
|
+
/** What changed on an indicator (`indicatorChange`). */
|
|
206
|
+
export interface IndicatorSettingsChangePayload {
|
|
207
|
+
instanceId: string;
|
|
208
|
+
change: 'visible' | 'style' | 'levels' | 'params' | 'pane' | 'scale';
|
|
131
209
|
}
|
|
132
210
|
export interface ChartEventMap {
|
|
133
211
|
crosshairMove: CrosshairMovePayload;
|
|
@@ -142,6 +220,42 @@ export interface ChartEventMap {
|
|
|
142
220
|
priceRangeChange: PriceRangeChangePayload;
|
|
143
221
|
zoomChange: ZoomChangePayload;
|
|
144
222
|
dataUpdate: DataSeries;
|
|
223
|
+
/** Older bars are being paged in, or finished loading. */
|
|
224
|
+
historyLoad: HistoryLoadPayload;
|
|
225
|
+
/** What is known about the symbol on the chart changed (`setSymbolInfo`, or the stream's adapter). */
|
|
226
|
+
symbolInfoChange: {
|
|
227
|
+
info: SymbolInfo | null;
|
|
228
|
+
};
|
|
229
|
+
chartTypeChange: {
|
|
230
|
+
type: string;
|
|
231
|
+
previous: string;
|
|
232
|
+
};
|
|
233
|
+
/**
|
|
234
|
+
* What draws the chart now. `reason` says why it isn't what was asked for:
|
|
235
|
+
* no WebGL 2 here (or only a slow software one, with 'auto'), or the GPU
|
|
236
|
+
* context was lost.
|
|
237
|
+
*/
|
|
238
|
+
rendererChange: {
|
|
239
|
+
renderer: 'canvas' | 'webgl';
|
|
240
|
+
reason?: 'unsupported' | 'contextLost';
|
|
241
|
+
};
|
|
242
|
+
symbolChange: {
|
|
243
|
+
symbol: string;
|
|
244
|
+
previous: string | null;
|
|
245
|
+
};
|
|
246
|
+
timeframeChange: {
|
|
247
|
+
timeframe: string;
|
|
248
|
+
previous: string | null;
|
|
249
|
+
};
|
|
250
|
+
historyChange: {
|
|
251
|
+
canUndo: boolean;
|
|
252
|
+
canRedo: boolean;
|
|
253
|
+
};
|
|
254
|
+
/** The selected drawings' ids, the primary (its handles show) first; none: nothing selected. */
|
|
255
|
+
drawingSelect: {
|
|
256
|
+
ids: string[];
|
|
257
|
+
primary: string | null;
|
|
258
|
+
};
|
|
145
259
|
indicatorAdd: IndicatorChangePayload;
|
|
146
260
|
indicatorRemove: IndicatorChangePayload;
|
|
147
261
|
/** An indicator pane was resized (by dragging its divider or `setPanelSize`). */
|
|
@@ -149,10 +263,17 @@ export interface ChartEventMap {
|
|
|
149
263
|
instanceId: string;
|
|
150
264
|
size: number;
|
|
151
265
|
};
|
|
266
|
+
/** A pane was folded or opened, maximised or put back, or moved up or down. */
|
|
267
|
+
paneChange: {
|
|
268
|
+
instanceId: string;
|
|
269
|
+
change: 'collapsed' | 'maximized' | 'order' | 'scale';
|
|
270
|
+
};
|
|
152
271
|
/** Indicator values were recomputed from bar index `from` on: new bars, a live tick, a replay step. */
|
|
153
272
|
indicatorUpdate: {
|
|
154
273
|
from: number;
|
|
155
274
|
};
|
|
275
|
+
/** One indicator's settings changed: shown or hidden, restyled, new levels or inputs, moved to another pane. */
|
|
276
|
+
indicatorChange: IndicatorSettingsChangePayload;
|
|
156
277
|
themeChange: ThemeChangePayload;
|
|
157
278
|
resize: ResizePayload;
|
|
158
279
|
orderPlace: OrderPlacePayload;
|
|
@@ -170,13 +291,41 @@ export interface ChartEventMap {
|
|
|
170
291
|
};
|
|
171
292
|
signalMarkerAdd: SignalMarkerAddPayload;
|
|
172
293
|
signalMarkerRemove: SignalMarkerRemovePayload;
|
|
294
|
+
signalMarkerHover: {
|
|
295
|
+
marker: import('./signal.js').SignalMarker | null;
|
|
296
|
+
x: number;
|
|
297
|
+
y: number;
|
|
298
|
+
};
|
|
299
|
+
signalMarkerClick: {
|
|
300
|
+
marker: import('./signal.js').SignalMarker;
|
|
301
|
+
x: number;
|
|
302
|
+
y: number;
|
|
303
|
+
};
|
|
173
304
|
tradeZoneAdd: TradeZoneAddPayload;
|
|
174
305
|
tradeZoneRemove: TradeZoneRemovePayload;
|
|
175
306
|
alertAdd: AlertPayload;
|
|
176
307
|
alertRemove: AlertRemovePayload;
|
|
177
308
|
alertTriggered: AlertPayload;
|
|
309
|
+
alertExpired: AlertPayload;
|
|
310
|
+
/** An indicator reads a symbol the chart has no bars of: give them with `setSymbolSeries`. */
|
|
311
|
+
symbolSeriesRequest: {
|
|
312
|
+
symbol: string;
|
|
313
|
+
};
|
|
314
|
+
replayStep: ReplayStepPayload;
|
|
315
|
+
replayState: {
|
|
316
|
+
state: 'playing' | 'paused' | 'stopped';
|
|
317
|
+
};
|
|
178
318
|
alertUpdate: AlertPayload;
|
|
179
319
|
}
|
|
320
|
+
/** Payload for `replayStep`. */
|
|
321
|
+
export interface ReplayStepPayload {
|
|
322
|
+
/** The chart's bar forming now. */
|
|
323
|
+
barIndex: number;
|
|
324
|
+
/** When it opened. */
|
|
325
|
+
time: number;
|
|
326
|
+
/** The replay has shown everything before this time (the next step's). */
|
|
327
|
+
until: number;
|
|
328
|
+
}
|
|
180
329
|
export interface AlertRemovePayload {
|
|
181
330
|
id: string;
|
|
182
331
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/types/events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACrD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/types/events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACrD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,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EAAE,kBAAkB,CAAC;IAChC,cAAc,EAAE,YAAY,CAAC;IAC7B,YAAY,EAAE,YAAY,CAAC;IAC3B,8FAA8F;IAC9F,mBAAmB,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IACxC,UAAU,EAAE,iBAAiB,CAAC;IAC9B,WAAW,EAAE;QAAE,KAAK,EAAE,SAAS,GAAG,QAAQ,GAAG,SAAS,CAAA;KAAE,CAAC;IACzD,WAAW,EAAE,YAAY,CAAC;CAC3B;AAED,gCAAgC;AAChC,MAAM,WAAW,iBAAiB;IAChC,mCAAmC;IACnC,QAAQ,EAAE,MAAM,CAAC;IACjB,sBAAsB;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,0EAA0E;IAC1E,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,MAAM,iBAAiB,CAAC,CAAC,GAAG,OAAO,IAAI,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ConnectionState } from './realtime.js';
|
|
2
|
-
import { TradingOrder, OrderSide, OrderPlaceIntent, OrderModifyIntent, OrderCancelIntent, PositionModifyIntent, PositionCloseIntent } from './trading.js';
|
|
2
|
+
import { TradingOrder, OrderSide, OrderPlaceIntent, OrderModifyIntent, OrderCancelIntent, PositionModifyIntent, PositionCloseIntent, PositionReverseIntent } from './trading.js';
|
|
3
3
|
export interface ExecutionConfig {
|
|
4
4
|
/** Account identifier, when the broker scopes by account. */
|
|
5
5
|
account?: string;
|
|
@@ -8,12 +8,20 @@ export interface ExecutionConfig {
|
|
|
8
8
|
meta?: Record<string, unknown>;
|
|
9
9
|
}
|
|
10
10
|
export type ExecutionEventType = 'orders' | 'positions' | 'fill' | 'connectionChange' | 'error';
|
|
11
|
+
/** Why a fill happened: an order, a position closed by hand or reversed, or its stop-loss or take-profit. */
|
|
12
|
+
export type FillReason = 'order' | 'close' | 'reverse' | 'stopLoss' | 'takeProfit';
|
|
11
13
|
export interface FillEvent {
|
|
12
14
|
orderId: string;
|
|
13
15
|
side: OrderSide;
|
|
14
16
|
price: number;
|
|
15
17
|
quantity: number;
|
|
18
|
+
/** When it filled (ms since the epoch). */
|
|
16
19
|
time: number;
|
|
20
|
+
/** The position it opened or closed. */
|
|
21
|
+
positionId?: string;
|
|
22
|
+
reason?: FillReason;
|
|
23
|
+
/** Profit or loss it realised, for a fill that closes a position. */
|
|
24
|
+
pnl?: number;
|
|
17
25
|
}
|
|
18
26
|
export interface ExecutionError {
|
|
19
27
|
message: string;
|
|
@@ -51,6 +59,17 @@ export interface ExecutionAdapter {
|
|
|
51
59
|
modifyPosition(intent: PositionModifyIntent): Promise<void>;
|
|
52
60
|
/** Close a position (full close). */
|
|
53
61
|
closePosition(intent: PositionCloseIntent): Promise<void>;
|
|
62
|
+
/**
|
|
63
|
+
* Close a position and open the same size the other way. Optional: without
|
|
64
|
+
* it, the chart closes the position and places a market order instead.
|
|
65
|
+
*/
|
|
66
|
+
reversePosition?(intent: PositionReverseIntent): Promise<void>;
|
|
67
|
+
/**
|
|
68
|
+
* The market price, live or replayed, and its time (ms). Optional: a paper
|
|
69
|
+
* adapter fills pending orders and stops against it and stamps fills with
|
|
70
|
+
* the time. The chart calls it with the replayed price during a replay.
|
|
71
|
+
*/
|
|
72
|
+
setMarkPrice?(price: number, time?: number): void;
|
|
54
73
|
on<T = unknown>(event: ExecutionEventType, listener: ExecutionListener<T>): void;
|
|
55
74
|
off<T = unknown>(event: ExecutionEventType, listener: ExecutionListener<T>): void;
|
|
56
75
|
dispose(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execution.d.ts","sourceRoot":"","sources":["../../src/types/execution.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,KAAK,EACV,YAAY,EACZ,SAAS,EACT,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,oBAAoB,EACpB,mBAAmB,
|
|
1
|
+
{"version":3,"file":"execution.d.ts","sourceRoot":"","sources":["../../src/types/execution.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,KAAK,EACV,YAAY,EACZ,SAAS,EACT,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,oBAAoB,EACpB,mBAAmB,EACnB,qBAAqB,EACtB,MAAM,cAAc,CAAC;AAWtB,MAAM,WAAW,eAAe;IAC9B,6DAA6D;IAC7D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iDAAiD;IACjD,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC;AAED,MAAM,MAAM,kBAAkB,GAC1B,QAAQ,GACR,WAAW,GACX,MAAM,GACN,kBAAkB,GAClB,OAAO,CAAC;AAEZ,6GAA6G;AAC7G,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,OAAO,GAAG,SAAS,GAAG,UAAU,GAAG,YAAY,CAAC;AAEnF,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,SAAS,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,2CAA2C;IAC3C,IAAI,EAAE,MAAM,CAAC;IACb,wCAAwC;IACxC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,qEAAqE;IACrE,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,cAAc;IAC7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E,CAAC,CAAC,GAAG,OAAO,EAAE,KAAK,EAAE,kBAAkB,EAAE,QAAQ,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IACjF,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,KAAK,EAAE,kBAAkB,EAAE,QAAQ,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IAElF,OAAO,IAAI,IAAI,CAAC;CACjB"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -12,4 +12,8 @@ export * from './execution.js';
|
|
|
12
12
|
export * from './signal.js';
|
|
13
13
|
export * from './realtime.js';
|
|
14
14
|
export * from './finance.js';
|
|
15
|
+
export * from './symbol.js';
|
|
16
|
+
export * from './quote.js';
|
|
17
|
+
export * from './news.js';
|
|
18
|
+
export * from './a11y.js';
|
|
15
19
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC"}
|