@tradecanvas/chart 1.10.0 → 1.12.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 +18 -14
- package/dist/Chart.d.ts +16 -6
- package/dist/Chart.d.ts.map +1 -1
- package/dist/LayoutSession-1uhJw0L7.cjs +2 -0
- package/dist/LayoutSession-1uhJw0L7.cjs.map +1 -0
- package/dist/{LayoutSession-P9Vb-Jpb.js → LayoutSession-2yRujs2S.js} +298 -284
- package/dist/LayoutSession-2yRujs2S.js.map +1 -0
- package/dist/charts/ChartTypeStrategy.d.ts +2 -0
- package/dist/charts/ChartTypeStrategy.d.ts.map +1 -1
- package/dist/{i18n-CiQ8EDVs.js → i18n-BU-BoBDZ.js} +6 -2
- package/dist/i18n-BU-BoBDZ.js.map +1 -0
- package/dist/{i18n-WsLA9SmD.cjs → i18n-DkzAxytR.cjs} +2 -2
- package/dist/i18n-DkzAxytR.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +22 -22
- package/dist/index.js.map +1 -1
- package/dist/widget/ChartWidget.d.ts +5 -3
- package/dist/widget/ChartWidget.d.ts.map +1 -1
- package/dist/widget/i18n.d.ts.map +1 -1
- package/dist/widget/index.cjs +2 -2
- package/dist/widget/index.cjs.map +1 -1
- package/dist/widget/index.js +97 -3
- package/dist/widget/index.js.map +1 -1
- package/dist/widget/locales/ar.d.ts.map +1 -1
- package/dist/widget/locales/cs.d.ts +4 -0
- package/dist/widget/locales/cs.d.ts.map +1 -0
- package/dist/widget/locales/da.d.ts +4 -0
- package/dist/widget/locales/da.d.ts.map +1 -0
- package/dist/widget/locales/de.d.ts.map +1 -1
- package/dist/widget/locales/el.d.ts +4 -0
- package/dist/widget/locales/el.d.ts.map +1 -0
- package/dist/widget/locales/en.d.ts +2 -0
- package/dist/widget/locales/en.d.ts.map +1 -1
- package/dist/widget/locales/es.d.ts.map +1 -1
- package/dist/widget/locales/et.d.ts +4 -0
- package/dist/widget/locales/et.d.ts.map +1 -0
- package/dist/widget/locales/fa.d.ts +4 -0
- package/dist/widget/locales/fa.d.ts.map +1 -0
- package/dist/widget/locales/fr.d.ts.map +1 -1
- package/dist/widget/locales/he.d.ts.map +1 -1
- package/dist/widget/locales/hu.d.ts +4 -0
- package/dist/widget/locales/hu.d.ts.map +1 -0
- package/dist/widget/locales/id.d.ts.map +1 -1
- package/dist/widget/locales/index.cjs +1 -1
- package/dist/widget/locales/index.cjs.map +1 -1
- package/dist/widget/locales/index.d.ts +15 -1
- package/dist/widget/locales/index.d.ts.map +1 -1
- package/dist/widget/locales/index.js +10127 -5
- package/dist/widget/locales/index.js.map +1 -1
- package/dist/widget/locales/it.d.ts +4 -0
- package/dist/widget/locales/it.d.ts.map +1 -0
- package/dist/widget/locales/ja.d.ts.map +1 -1
- package/dist/widget/locales/ko.d.ts.map +1 -1
- package/dist/widget/locales/ms.d.ts +4 -0
- package/dist/widget/locales/ms.d.ts.map +1 -0
- package/dist/widget/locales/nb.d.ts +4 -0
- package/dist/widget/locales/nb.d.ts.map +1 -0
- package/dist/widget/locales/nl.d.ts +4 -0
- package/dist/widget/locales/nl.d.ts.map +1 -0
- package/dist/widget/locales/pl.d.ts +4 -0
- package/dist/widget/locales/pl.d.ts.map +1 -0
- package/dist/widget/locales/pt.d.ts.map +1 -1
- package/dist/widget/locales/ro.d.ts +4 -0
- package/dist/widget/locales/ro.d.ts.map +1 -0
- package/dist/widget/locales/ru.d.ts.map +1 -1
- package/dist/widget/locales/sk.d.ts +4 -0
- package/dist/widget/locales/sk.d.ts.map +1 -0
- package/dist/widget/locales/sv.d.ts +4 -0
- package/dist/widget/locales/sv.d.ts.map +1 -0
- package/dist/widget/locales/th.d.ts.map +1 -1
- package/dist/widget/locales/tr.d.ts.map +1 -1
- package/dist/widget/locales/vi.d.ts.map +1 -1
- package/dist/widget/locales/zh.d.ts.map +1 -1
- package/dist/widget/locales/zhHant.d.ts.map +1 -1
- package/dist/widget/widgetConfig.d.ts.map +1 -1
- package/package.json +3 -3
- package/dist/LayoutSession-BFqQwhvV.cjs +0 -2
- package/dist/LayoutSession-BFqQwhvV.cjs.map +0 -1
- package/dist/LayoutSession-P9Vb-Jpb.js.map +0 -1
- package/dist/i18n-CiQ8EDVs.js.map +0 -1
- package/dist/i18n-WsLA9SmD.cjs.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { DARK_THEME as e, DEFAULT_PANEL_HEIGHT as t, LIGHT_THEME as n, LayerType as r, MIN_PANEL_HEIGHT as i, PRICE_AXIS_WIDTH as a, TIME_AXIS_HEIGHT as o, autoPricePrecision as s, computePriceLimits as c, formatPrice as l, fractionTick as u, indicatorSource as d, isValidTimeZone as f, mergeBar as p, normalizeBarTime as m, parseIndicatorSource as h, priceFormatterFor as g, readChartTypeOptions as _, sessionMinute as v, setLocale as ee, stepDecimals as te, tickBarCount as ne, timeframeToMs as y, volumeColor as
|
|
2
|
-
import { AlertDragHandler as
|
|
1
|
+
import { DARK_THEME as e, DEFAULT_PANEL_HEIGHT as t, LIGHT_THEME as n, LayerType as r, MIN_PANEL_HEIGHT as i, PRICE_AXIS_WIDTH as a, TIME_AXIS_HEIGHT as o, autoPricePrecision as s, computePriceLimits as c, formatPrice as l, fractionTick as u, indicatorSource as d, isValidTimeZone as f, mergeBar as p, normalizeBarTime as m, parseIndicatorSource as h, priceFormatterFor as g, readChartTypeOptions as _, sessionMinute as v, setLocale as ee, stepDecimals as te, tickBarCount as ne, timeframeToMs as y, volumeColor as b, zonedDateFormatter as re } from "@tradecanvas/commons";
|
|
2
|
+
import { AlertDragHandler as ie, AlertManager as ae, Animator as oe, AreaRenderer as se, AxisDragHandler as ce, BarCountdown as le, BarRenderer as ue, BaselineRenderer as de, CandlestickRenderer as fe, ChartLegend as pe, ChartStateManager as x, CompareRenderer as me, CompareSymbolIndicator as he, CorrelationCoefficientIndicator as ge, CorrelationLogIndicator as _e, CrosshairHandler as ve, CrosshairTooltip as ye, CurrentPriceLine as be, DEFAULT_SESSION_HOURS as xe, DataExporter as S, DepthHeatmapRenderer as Se, DrawingManager as Ce, DrawingRenderer as we, EquivolumeRenderer as Te, EventBus as Ee, GridRenderer as De, HLCAreaRenderer as Oe, HiLoRenderer as C, HollowCandleRenderer as ke, IndicatorEngine as w, InteractionManager as Ae, KagiRenderer as je, KeyboardHandler as Me, LineRenderer as Ne, LineWithMarkersRenderer as Pe, MarketProfileRenderer as Fe, MeasureOverlay as Ie, PanHandler as Le, PaneResizeHandler as Re, PeriodLevelsRenderer as ze, PinnedTooltip as Be, PivotMarkersRenderer as Ve, PointAndFigureRenderer as T, PriceAxis as E, PriceAxisAddButton as He, PriceLines as Ue, RenderEngine as We, RenkoRenderer as Ge, ReplayManager as Ke, Screenshot as D, SelectionBoxOverlay as qe, SessionBreaks as Je, SessionShading as Ye, SignalMarkerManager as Xe, SpreadIndicator as Ze, StepLineRenderer as Qe, StreamManager as $e, SymbolSeriesStore as et, TimeAxis as tt, TradeZoneManager as nt, TradingManager as rt, TradingRenderer as it, UndoRedoManager as at, Viewport as ot, VolumeCandleRenderer as st, VolumeProfileRenderer as ct, VolumeRenderer as lt, Watermark as ut, ZoomHandler as dt, barTimeStepMs as ft, findDominantSwing as pt, gpuContextsLeft as mt, isRegularSession as ht, loadWebGL as gt, mergeSessionHours as _t, rangePresetStart as vt, readAlertOptions as yt, registerBuiltInDrawingTools as bt, registerBuiltInIndicators as O, servesTimeframe as k, sourceParam as A, timestampToBarIndex as j, toHeikinAshi as xt, toKagi as St, toLineBreak as Ct, toPointAndFigure as wt, toRangeBars as Tt, toRenko as M, whenGpuContextFree as Et, withResampling as Dt, xToBarIndex as Ot, xToTime as N, yToPrice as P } from "@tradecanvas/core";
|
|
3
3
|
//#region src/regularHours.ts
|
|
4
|
-
var
|
|
5
|
-
function
|
|
4
|
+
var kt = 864e5, At = 10;
|
|
5
|
+
function jt(e, t) {
|
|
6
6
|
let n = e?.timezone;
|
|
7
7
|
if (!n || !f(n) || t.length < 2) return null;
|
|
8
8
|
let r = (e?.sessions ?? []).flatMap((e) => {
|
|
@@ -14,34 +14,34 @@ function Pt(e, t) {
|
|
|
14
14
|
});
|
|
15
15
|
if (r.length === 0) return null;
|
|
16
16
|
let i = Infinity;
|
|
17
|
-
for (let e = Math.max(1, t.length -
|
|
17
|
+
for (let e = Math.max(1, t.length - At); e < t.length; e++) {
|
|
18
18
|
let n = m(t[e].time) - m(t[e - 1].time);
|
|
19
19
|
n > 0 && n < i && (i = n);
|
|
20
20
|
}
|
|
21
|
-
if (!(i <
|
|
21
|
+
if (!(i < kt)) return null;
|
|
22
22
|
let a = {
|
|
23
23
|
timeZone: n,
|
|
24
24
|
windows: r,
|
|
25
25
|
startMinute: r[0].startMinute,
|
|
26
26
|
endMinute: r[r.length - 1].endMinute
|
|
27
27
|
};
|
|
28
|
-
return (e) =>
|
|
28
|
+
return (e) => ht(m(e), a);
|
|
29
29
|
}
|
|
30
30
|
//#endregion
|
|
31
31
|
//#region src/chartA11y.ts
|
|
32
|
-
var
|
|
32
|
+
var F = {
|
|
33
33
|
role: "chart",
|
|
34
34
|
summary: "{what}. Last price {close}.",
|
|
35
35
|
empty: "Chart, no data.",
|
|
36
36
|
view: "Showing {count} bars, {from} to {to}. High {high}, low {low}.",
|
|
37
37
|
bar: "{time}: open {open}, high {high}, low {low}, close {close}, volume {volume}.",
|
|
38
38
|
keys: "Arrow keys scroll and zoom, Home and End go to the start and the end. Comma and period read the bars one at a time."
|
|
39
|
-
},
|
|
39
|
+
}, I = (e, t) => e.replace(/\{(\w+)\}/g, (e, n) => n in t ? String(t[n]) : e), Mt = [
|
|
40
40
|
"role",
|
|
41
41
|
"aria-roledescription",
|
|
42
42
|
"aria-label",
|
|
43
43
|
"aria-describedby"
|
|
44
|
-
],
|
|
44
|
+
], Nt = 400, Pt = 1e3, Ft = class {
|
|
45
45
|
live;
|
|
46
46
|
help;
|
|
47
47
|
labels;
|
|
@@ -55,20 +55,20 @@ var Ft = {
|
|
|
55
55
|
};
|
|
56
56
|
constructor(e, t, n = {}) {
|
|
57
57
|
this.container = e, this.source = t, this.labels = {
|
|
58
|
-
...
|
|
58
|
+
...F,
|
|
59
59
|
...n
|
|
60
60
|
};
|
|
61
|
-
for (let t of
|
|
62
|
-
e.setAttribute("role", "application"), this.help =
|
|
61
|
+
for (let t of Mt) this.before.set(t, e.getAttribute(t));
|
|
62
|
+
e.setAttribute("role", "application"), this.help = L("div", "tc-sr-only"), this.help.id = `tc-chart-keys-${Math.random().toString(36).slice(2, 10)}`, e.setAttribute("aria-describedby", this.help.id), this.live = L("div", "tc-sr-only tc-sr-live"), this.live.setAttribute("aria-live", "polite"), this.live.setAttribute("aria-atomic", "true"), e.append(this.help, this.live), e.addEventListener("blur", this.onBlur), this.applyLabels();
|
|
63
63
|
}
|
|
64
64
|
setLabels(e) {
|
|
65
65
|
this.labels = {
|
|
66
|
-
...
|
|
66
|
+
...F,
|
|
67
67
|
...e
|
|
68
68
|
}, this.applyLabels();
|
|
69
69
|
}
|
|
70
70
|
refresh(e = !1) {
|
|
71
|
-
let t =
|
|
71
|
+
let t = Pt - (Date.now() - this.summaryAt);
|
|
72
72
|
if (e || t <= 0 || this.container.getAttribute("aria-label") === this.labels.empty) {
|
|
73
73
|
this.summaryTimer && clearTimeout(this.summaryTimer), this.summaryTimer = null, this.summaryAt = Date.now(), this.container.setAttribute("aria-label", this.summary());
|
|
74
74
|
return;
|
|
@@ -80,7 +80,7 @@ var Ft = {
|
|
|
80
80
|
viewMoved() {
|
|
81
81
|
this.cursor = null, this.viewTimer && clearTimeout(this.viewTimer), this.viewTimer = setTimeout(() => {
|
|
82
82
|
this.viewTimer = null, this.say(this.viewText());
|
|
83
|
-
},
|
|
83
|
+
}, Nt);
|
|
84
84
|
}
|
|
85
85
|
readBar(e) {
|
|
86
86
|
let t = this.source.bars();
|
|
@@ -93,13 +93,13 @@ var Ft = {
|
|
|
93
93
|
let i = t[this.cursor];
|
|
94
94
|
this.source.showBar(i.time);
|
|
95
95
|
let a = this.source.formatPrice;
|
|
96
|
-
this.say(
|
|
96
|
+
this.say(I(this.labels.bar, {
|
|
97
97
|
time: this.source.formatTime(i.time),
|
|
98
98
|
open: a(i.open),
|
|
99
99
|
high: a(i.high),
|
|
100
100
|
low: a(i.low),
|
|
101
101
|
close: a(i.close),
|
|
102
|
-
volume:
|
|
102
|
+
volume: It(i.volume ?? 0)
|
|
103
103
|
}));
|
|
104
104
|
}
|
|
105
105
|
destroy() {
|
|
@@ -118,7 +118,7 @@ var Ft = {
|
|
|
118
118
|
this.labels.typeName ? this.labels.typeName(t) : t,
|
|
119
119
|
this.source.timeframe()
|
|
120
120
|
].filter(Boolean).join(", ");
|
|
121
|
-
return
|
|
121
|
+
return I(this.labels.summary, {
|
|
122
122
|
what: n,
|
|
123
123
|
close: this.source.formatPrice(e[e.length - 1].close)
|
|
124
124
|
});
|
|
@@ -128,7 +128,7 @@ var Ft = {
|
|
|
128
128
|
if (e.length === 0) return this.labels.empty;
|
|
129
129
|
let t = this.source.visibleRange(), n = Math.max(0, Math.min(e.length - 1, Math.ceil(t.from))), r = Math.max(n, Math.min(e.length - 1, Math.floor(t.to))), i = -Infinity, a = Infinity;
|
|
130
130
|
for (let t = n; t <= r; t++) i = Math.max(i, e[t].high), a = Math.min(a, e[t].low);
|
|
131
|
-
return
|
|
131
|
+
return I(this.labels.view, {
|
|
132
132
|
count: r - n + 1,
|
|
133
133
|
from: this.source.formatTime(e[n].time),
|
|
134
134
|
to: this.source.formatTime(e[r].time),
|
|
@@ -140,7 +140,7 @@ var Ft = {
|
|
|
140
140
|
this.live.textContent = e;
|
|
141
141
|
}
|
|
142
142
|
};
|
|
143
|
-
function
|
|
143
|
+
function L(e, t) {
|
|
144
144
|
let n = document.createElement(e);
|
|
145
145
|
return n.className = t, Object.assign(n.style, {
|
|
146
146
|
position: "absolute",
|
|
@@ -154,12 +154,12 @@ function Bt(e, t) {
|
|
|
154
154
|
border: "0"
|
|
155
155
|
}), n;
|
|
156
156
|
}
|
|
157
|
-
function
|
|
157
|
+
function It(e) {
|
|
158
158
|
return Number.isInteger(e) ? String(e) : e.toFixed(2);
|
|
159
159
|
}
|
|
160
160
|
//#endregion
|
|
161
161
|
//#region src/indicatorLabel.ts
|
|
162
|
-
function
|
|
162
|
+
function Lt(e, t, n, r) {
|
|
163
163
|
let i = Object.keys(n || t).map((e) => t[e]).filter((e) => typeof e == "number" && Number.isFinite(e)).slice(0, 3).map((e) => String(Number(e.toFixed(4)))), a = typeof t.symbol == "string" && t.symbol ? [t.symbol] : [];
|
|
164
164
|
return [
|
|
165
165
|
e === "spread" && t.mode === "ratio" ? "Ratio" : r ?? e.toUpperCase(),
|
|
@@ -169,55 +169,52 @@ function Ht(e, t, n, r) {
|
|
|
169
169
|
}
|
|
170
170
|
//#endregion
|
|
171
171
|
//#region src/charts/ChartTypeStrategy.ts
|
|
172
|
-
function
|
|
172
|
+
function Rt(e) {
|
|
173
173
|
switch (e) {
|
|
174
174
|
case "candlestick":
|
|
175
175
|
case "heikinAshi":
|
|
176
176
|
case "lineBreak":
|
|
177
|
-
case "rangeBars": return new
|
|
178
|
-
case "line": return new
|
|
179
|
-
case "area": return new
|
|
180
|
-
case "bar": return new
|
|
177
|
+
case "rangeBars": return new fe();
|
|
178
|
+
case "line": return new Ne();
|
|
179
|
+
case "area": return new se();
|
|
180
|
+
case "bar": return new ue();
|
|
181
181
|
case "hollowCandle": return new ke();
|
|
182
|
-
case "baseline": return new
|
|
183
|
-
case "renko": return new
|
|
184
|
-
case "kagi": return new
|
|
185
|
-
case "pointAndFigure": return new
|
|
186
|
-
case "volumeCandles": return new
|
|
187
|
-
case "equivolume": return new
|
|
188
|
-
case "hlcArea": return new
|
|
189
|
-
case "stepLine": return new
|
|
190
|
-
case "lineWithMarkers": return new
|
|
191
|
-
case "hiLo": return new
|
|
192
|
-
default: return new
|
|
182
|
+
case "baseline": return new de();
|
|
183
|
+
case "renko": return new Ge();
|
|
184
|
+
case "kagi": return new je();
|
|
185
|
+
case "pointAndFigure": return new T();
|
|
186
|
+
case "volumeCandles": return new st();
|
|
187
|
+
case "equivolume": return new Te();
|
|
188
|
+
case "hlcArea": return new Oe();
|
|
189
|
+
case "stepLine": return new Qe();
|
|
190
|
+
case "lineWithMarkers": return new Pe();
|
|
191
|
+
case "hiLo": return new C();
|
|
192
|
+
default: return new fe();
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
|
-
function
|
|
195
|
+
function zt(e, t, n = {}) {
|
|
196
196
|
if (t.length === 0) return t;
|
|
197
197
|
switch (e) {
|
|
198
|
-
case "heikinAshi": return
|
|
198
|
+
case "heikinAshi": return xt(t);
|
|
199
199
|
case "renko": {
|
|
200
200
|
let e = n.renko?.boxSize;
|
|
201
|
-
return typeof e == "number" ?
|
|
201
|
+
return typeof e == "number" ? M(t, { brickSize: e }) : M(t, {
|
|
202
202
|
brickSize: 0,
|
|
203
203
|
useATR: !0,
|
|
204
204
|
atrPeriod: n.renko?.atrPeriod ?? 14
|
|
205
205
|
});
|
|
206
206
|
}
|
|
207
|
-
case "lineBreak": return
|
|
208
|
-
case "kagi": return
|
|
209
|
-
case "pointAndFigure":
|
|
210
|
-
let e = n.pointAndFigure?.boxSize;
|
|
211
|
-
return Et(t, typeof e == "number" ? e : qt(t) * .01, n.pointAndFigure?.reversal ?? 3);
|
|
212
|
-
}
|
|
207
|
+
case "lineBreak": return Ct(t, n.lineBreak?.lines ?? 3);
|
|
208
|
+
case "kagi": return St(t, n.kagi?.reversal ?? 4, n.kagi?.reversalType ?? "percent");
|
|
209
|
+
case "pointAndFigure": return wt(t, Ht(t, n), n.pointAndFigure?.reversal ?? 3);
|
|
213
210
|
case "rangeBars": {
|
|
214
211
|
let e = n.rangeBars?.range;
|
|
215
|
-
return
|
|
212
|
+
return Tt(t, { rangeSize: typeof e == "number" ? e : Ut(t) * .005 });
|
|
216
213
|
}
|
|
217
214
|
default: return t;
|
|
218
215
|
}
|
|
219
216
|
}
|
|
220
|
-
function
|
|
217
|
+
function Bt(e) {
|
|
221
218
|
switch (e) {
|
|
222
219
|
case "heikinAshi":
|
|
223
220
|
case "renko":
|
|
@@ -228,26 +225,30 @@ function Gt(e) {
|
|
|
228
225
|
default: return !1;
|
|
229
226
|
}
|
|
230
227
|
}
|
|
231
|
-
function
|
|
232
|
-
return e !== "heikinAshi" &&
|
|
228
|
+
function Vt(e) {
|
|
229
|
+
return e !== "heikinAshi" && Bt(e);
|
|
233
230
|
}
|
|
234
|
-
function
|
|
231
|
+
function Ht(e, t = {}) {
|
|
232
|
+
let n = t.pointAndFigure?.boxSize;
|
|
233
|
+
return typeof n == "number" ? n : Ut(e) * .01;
|
|
234
|
+
}
|
|
235
|
+
function Ut(e) {
|
|
235
236
|
let t = 0;
|
|
236
237
|
for (let n of e) t += n.close;
|
|
237
238
|
return t / e.length;
|
|
238
239
|
}
|
|
239
|
-
function
|
|
240
|
+
function Wt(e, t) {
|
|
240
241
|
let n = t?.(e);
|
|
241
|
-
return n ? n.createRenderer() :
|
|
242
|
+
return n ? n.createRenderer() : Rt(e);
|
|
242
243
|
}
|
|
243
|
-
function
|
|
244
|
+
function Gt(e, t, n, r) {
|
|
244
245
|
if (t.length === 0) return t;
|
|
245
246
|
let i = n?.(e);
|
|
246
|
-
return i?.transform ? i.transform(t) :
|
|
247
|
+
return i?.transform ? i.transform(t) : zt(e, t, r);
|
|
247
248
|
}
|
|
248
249
|
//#endregion
|
|
249
250
|
//#region src/state/AutoSaveScheduler.ts
|
|
250
|
-
var
|
|
251
|
+
var Kt = class {
|
|
251
252
|
timer = null;
|
|
252
253
|
delayMs = 0;
|
|
253
254
|
key = null;
|
|
@@ -277,15 +278,15 @@ var Xt = class {
|
|
|
277
278
|
};
|
|
278
279
|
//#endregion
|
|
279
280
|
//#region src/DataManager.ts
|
|
280
|
-
function
|
|
281
|
+
function R(e) {
|
|
281
282
|
if (!e || typeof e.time != "number" || !Number.isFinite(e.time)) return !1;
|
|
282
283
|
let { open: t, high: n, low: r, close: i } = e;
|
|
283
284
|
return !(!isFinite(t) || !isFinite(n) || !isFinite(r) || !isFinite(i) || t < 0 || n < 0 || r < 0 || i < 0 || n < r || e.volume !== void 0 && (!isFinite(e.volume) || e.volume < 0));
|
|
284
285
|
}
|
|
285
|
-
function
|
|
286
|
+
function qt(e) {
|
|
286
287
|
return e.volume !== void 0 && e.high >= e.open && e.high >= e.close && e.low <= e.open && e.low <= e.close;
|
|
287
288
|
}
|
|
288
|
-
function
|
|
289
|
+
function z(e) {
|
|
289
290
|
return {
|
|
290
291
|
...e,
|
|
291
292
|
high: Math.max(e.open, e.high, e.low, e.close),
|
|
@@ -293,7 +294,7 @@ function A(e) {
|
|
|
293
294
|
volume: e.volume === void 0 ? 0 : Math.max(0, e.volume)
|
|
294
295
|
};
|
|
295
296
|
}
|
|
296
|
-
var
|
|
297
|
+
var B = class {
|
|
297
298
|
data = [];
|
|
298
299
|
getData() {
|
|
299
300
|
return this.data;
|
|
@@ -302,7 +303,7 @@ var j = class {
|
|
|
302
303
|
let t = [];
|
|
303
304
|
for (let n = 0; n < e.length; n++) {
|
|
304
305
|
let r = e[n];
|
|
305
|
-
|
|
306
|
+
R(r) && t.push(qt(r) ? r : z(r));
|
|
306
307
|
}
|
|
307
308
|
this.data = t;
|
|
308
309
|
}
|
|
@@ -310,7 +311,7 @@ var j = class {
|
|
|
310
311
|
let t = this.data.length > 0 ? this.data[0].time : Infinity, n = [];
|
|
311
312
|
for (let r = 0; r < e.length; r++) {
|
|
312
313
|
let i = e[r];
|
|
313
|
-
!
|
|
314
|
+
!R(i) || i.time >= t || n.push(qt(i) ? i : z(i));
|
|
314
315
|
}
|
|
315
316
|
if (n.length === 0) return 0;
|
|
316
317
|
n.sort((e, t) => e.time - t.time);
|
|
@@ -319,11 +320,11 @@ var j = class {
|
|
|
319
320
|
return n.length = r, this.data = n.concat(this.data), r;
|
|
320
321
|
}
|
|
321
322
|
appendBar(e) {
|
|
322
|
-
|
|
323
|
+
R(e) && this.data.push(z(e));
|
|
323
324
|
}
|
|
324
325
|
updateLastBar(e) {
|
|
325
|
-
if (!
|
|
326
|
-
let t =
|
|
326
|
+
if (!R(e)) return;
|
|
327
|
+
let t = z(e);
|
|
327
328
|
if (this.data.length === 0) {
|
|
328
329
|
this.data.push(t);
|
|
329
330
|
return;
|
|
@@ -339,7 +340,7 @@ var j = class {
|
|
|
339
340
|
clear() {
|
|
340
341
|
this.data = [];
|
|
341
342
|
}
|
|
342
|
-
},
|
|
343
|
+
}, Jt = 5e3, Yt = 6e4, Xt = 500, Zt = class {
|
|
343
344
|
loader = null;
|
|
344
345
|
pageSize = 500;
|
|
345
346
|
loading = !1;
|
|
@@ -380,7 +381,7 @@ var j = class {
|
|
|
380
381
|
try {
|
|
381
382
|
r = await e(t, this.pageSize);
|
|
382
383
|
} catch (e) {
|
|
383
|
-
return n === this.seq ? (this.loading = !1, this.failures++, this.retryAt = this.now() + Math.min(
|
|
384
|
+
return n === this.seq ? (this.loading = !1, this.failures++, this.retryAt = this.now() + Math.min(Yt, Jt * 2 ** (this.failures - 1)), this.emit({
|
|
384
385
|
state: "error",
|
|
385
386
|
count: 0,
|
|
386
387
|
error: e instanceof Error ? e.message : String(e)
|
|
@@ -410,7 +411,7 @@ var j = class {
|
|
|
410
411
|
now() {
|
|
411
412
|
return this.host.now ? this.host.now() : Date.now();
|
|
412
413
|
}
|
|
413
|
-
},
|
|
414
|
+
}, Qt = class {
|
|
414
415
|
theme;
|
|
415
416
|
shape = null;
|
|
416
417
|
constructor(t) {
|
|
@@ -437,7 +438,7 @@ var j = class {
|
|
|
437
438
|
} : this.theme.shape
|
|
438
439
|
};
|
|
439
440
|
}
|
|
440
|
-
},
|
|
441
|
+
}, $t = 200, en = 80, V = (e) => e.position === "top" || e.position === "bottom", tn = class {
|
|
441
442
|
panels = [];
|
|
442
443
|
containerWidth = 0;
|
|
443
444
|
containerHeight = 0;
|
|
@@ -453,8 +454,8 @@ var j = class {
|
|
|
453
454
|
this.panels.push({
|
|
454
455
|
id: e,
|
|
455
456
|
position: n,
|
|
456
|
-
size: r ?? (a ?
|
|
457
|
-
minSize: a ?
|
|
457
|
+
size: r ?? (a ? $t : t),
|
|
458
|
+
minSize: a ? en : i,
|
|
458
459
|
content: {
|
|
459
460
|
type: "indicator",
|
|
460
461
|
indicatorInstanceId: e
|
|
@@ -473,14 +474,14 @@ var j = class {
|
|
|
473
474
|
}
|
|
474
475
|
setPanelCollapsed(e, t) {
|
|
475
476
|
let n = this.panels.find((t) => t.id === e);
|
|
476
|
-
return !n || !
|
|
477
|
+
return !n || !V(n) || this.maximized === null && !!n.collapsed === t ? !1 : (this.maximized = null, n.collapsed = t || void 0, !0);
|
|
477
478
|
}
|
|
478
479
|
isPanelCollapsed(e) {
|
|
479
480
|
return !!this.panels.find((t) => t.id === e)?.collapsed;
|
|
480
481
|
}
|
|
481
482
|
isPanelShownCollapsed(e) {
|
|
482
483
|
let t = this.panels.find((t) => t.id === e);
|
|
483
|
-
return !t || !
|
|
484
|
+
return !t || !V(t) ? !1 : this.maximized === null ? !!t.collapsed : this.maximized !== e;
|
|
484
485
|
}
|
|
485
486
|
setPanelScale(e, t) {
|
|
486
487
|
let n = this.panels.find((t) => t.id === e);
|
|
@@ -496,7 +497,7 @@ var j = class {
|
|
|
496
497
|
}
|
|
497
498
|
setMaximizedPanel(e) {
|
|
498
499
|
let t = e === null ? null : this.panels.find((t) => t.id === e);
|
|
499
|
-
return e !== null && (!t || !
|
|
500
|
+
return e !== null && (!t || !V(t)) || this.maximized === e ? !1 : (this.maximized = e, t && (t.collapsed = void 0), !0);
|
|
500
501
|
}
|
|
501
502
|
getMaximizedPanel() {
|
|
502
503
|
return this.maximized;
|
|
@@ -517,19 +518,19 @@ var j = class {
|
|
|
517
518
|
this.panels = [...this.panels].sort((e, n) => t(e) - t(n));
|
|
518
519
|
}
|
|
519
520
|
shownSize(e, t) {
|
|
520
|
-
return
|
|
521
|
+
return V(e) ? this.maximized ? e.id === this.maximized ? t : 20 : e.collapsed ? 20 : e.size : e.size;
|
|
521
522
|
}
|
|
522
523
|
setPanelPosition(e, n) {
|
|
523
524
|
let r = this.panels.find((t) => t.id === e);
|
|
524
525
|
if (r) {
|
|
525
526
|
let a = r.position === "left" || r.position === "right", o = n === "left" || n === "right";
|
|
526
|
-
r.position = n, a !== o && (r.size = o ?
|
|
527
|
+
r.position = n, a !== o && (r.size = o ? $t : t, r.minSize = o ? en : i), o && (r.collapsed = void 0, this.maximized === e && (this.maximized = null));
|
|
527
528
|
}
|
|
528
529
|
}
|
|
529
530
|
setPanelSize(e, t) {
|
|
530
531
|
let n = this.panels.find((t) => t.id === e);
|
|
531
532
|
if (n) {
|
|
532
|
-
let e =
|
|
533
|
+
let e = V(n) ? this.containerHeight - o - 48 : this.containerWidth / 2, r = e > n.minSize ? Math.min(t, e) : t;
|
|
533
534
|
n.size = Math.max(n.minSize, r), n.collapsed = void 0, this.maximized = null;
|
|
534
535
|
}
|
|
535
536
|
}
|
|
@@ -639,8 +640,8 @@ var j = class {
|
|
|
639
640
|
getMainChartRect() {
|
|
640
641
|
return this.resolve().mainChartRect;
|
|
641
642
|
}
|
|
642
|
-
},
|
|
643
|
-
function
|
|
643
|
+
}, nn = 14, rn = 14, an = 22, on = 4;
|
|
644
|
+
function sn(e) {
|
|
644
645
|
let { min: t, max: n, lastPrice: r, locale: i, fontFamily: o, fontSizeSmall: c, measure: u } = e, d = s(t, n), f = e.tagPrecision ?? d, p = r === null ? [t, n] : [
|
|
645
646
|
t,
|
|
646
647
|
n,
|
|
@@ -649,14 +650,14 @@ function z(e) {
|
|
|
649
650
|
for (let t of p) {
|
|
650
651
|
if (!Number.isFinite(t)) continue;
|
|
651
652
|
let n = e.format ? e.format(t) : l(t, d, i), r = e.format ? n : l(t, f, i);
|
|
652
|
-
m = Math.max(m, u(n, `500 ${c}px ${o}`) +
|
|
653
|
+
m = Math.max(m, u(n, `500 ${c}px ${o}`) + nn, u(r, `bold 11px ${o}`) + rn, u(r, `600 ${c}px ${o}`) + an);
|
|
653
654
|
}
|
|
654
|
-
return m <= a ? a : Math.ceil(m /
|
|
655
|
+
return m <= a ? a : Math.ceil(m / on) * on;
|
|
655
656
|
}
|
|
656
|
-
function
|
|
657
|
+
function cn(e, t) {
|
|
657
658
|
return t > e || t <= e - 12 ? t : e;
|
|
658
659
|
}
|
|
659
|
-
var
|
|
660
|
+
var ln = class {
|
|
660
661
|
netY = 0;
|
|
661
662
|
travelX = 0;
|
|
662
663
|
engaged = !1;
|
|
@@ -672,8 +673,8 @@ var an = class {
|
|
|
672
673
|
}
|
|
673
674
|
return this.engaged;
|
|
674
675
|
}
|
|
675
|
-
},
|
|
676
|
-
function
|
|
676
|
+
}, un = 1;
|
|
677
|
+
function dn(e, t) {
|
|
677
678
|
return e.filter((e) => (e.descriptor.layer ?? "overlay") === t);
|
|
678
679
|
}
|
|
679
680
|
function H(e) {
|
|
@@ -687,24 +688,24 @@ function H(e) {
|
|
|
687
688
|
//#endregion
|
|
688
689
|
//#region src/plugins/registry.ts
|
|
689
690
|
var U = /* @__PURE__ */ new Map();
|
|
690
|
-
function
|
|
691
|
+
function fn(e) {
|
|
691
692
|
U.set(H(e), e);
|
|
692
693
|
}
|
|
693
|
-
function
|
|
694
|
+
function pn(e) {
|
|
694
695
|
return U.delete(e);
|
|
695
696
|
}
|
|
696
|
-
function
|
|
697
|
+
function mn() {
|
|
697
698
|
return [...U.values()];
|
|
698
699
|
}
|
|
699
|
-
function
|
|
700
|
+
function hn() {
|
|
700
701
|
U.clear();
|
|
701
702
|
}
|
|
702
703
|
//#endregion
|
|
703
704
|
//#region src/plugins/PluginManager.ts
|
|
704
|
-
var
|
|
705
|
+
var gn = class {
|
|
705
706
|
plugins = /* @__PURE__ */ new Map();
|
|
706
707
|
constructor(e, t = {}) {
|
|
707
|
-
if (this.indicatorEngine = e, t.inheritGlobal !== !1) for (let e of
|
|
708
|
+
if (this.indicatorEngine = e, t.inheritGlobal !== !1) for (let e of mn()) this.add(e);
|
|
708
709
|
for (let e of t.plugins ?? []) this.add(e);
|
|
709
710
|
}
|
|
710
711
|
register(e) {
|
|
@@ -734,15 +735,15 @@ var dn = class {
|
|
|
734
735
|
add(e) {
|
|
735
736
|
this.plugins.set(H(e), e), e.kind === "indicator" && this.indicatorEngine.register(e.plugin);
|
|
736
737
|
}
|
|
737
|
-
},
|
|
738
|
+
}, _n = {
|
|
738
739
|
orderPlace: (e, t) => e.placeOrder(t),
|
|
739
740
|
orderModify: (e, t) => e.modifyOrder(t),
|
|
740
741
|
orderCancel: (e, t) => e.cancelOrder(t),
|
|
741
742
|
positionModify: (e, t) => e.modifyPosition(t),
|
|
742
743
|
positionClose: (e, t) => e.closePosition(t),
|
|
743
|
-
positionReverse: (e, t, n) =>
|
|
744
|
+
positionReverse: (e, t, n) => vn(e, t, n)
|
|
744
745
|
};
|
|
745
|
-
async function
|
|
746
|
+
async function vn(e, t, n) {
|
|
746
747
|
let { reversing: r } = n;
|
|
747
748
|
if (!r.has(t.positionId)) {
|
|
748
749
|
r.add(t.positionId);
|
|
@@ -771,7 +772,7 @@ async function pn(e, t, n) {
|
|
|
771
772
|
}
|
|
772
773
|
}
|
|
773
774
|
}
|
|
774
|
-
function
|
|
775
|
+
function yn(e, t) {
|
|
775
776
|
let n = [], r = null, i = {
|
|
776
777
|
positions: () => r ?? t.getPositions?.() ?? [],
|
|
777
778
|
reversing: /* @__PURE__ */ new Set()
|
|
@@ -781,8 +782,8 @@ function mn(e, t) {
|
|
|
781
782
|
e.data && t.onFill?.(e.data);
|
|
782
783
|
};
|
|
783
784
|
e.on("orders", a), e.on("positions", o), e.on("error", s), e.on("fill", c), n.push(() => e.off("orders", a), () => e.off("positions", o), () => e.off("error", s), () => e.off("fill", c));
|
|
784
|
-
for (let r of Object.keys(
|
|
785
|
-
let a =
|
|
785
|
+
for (let r of Object.keys(_n)) {
|
|
786
|
+
let a = _n[r], o = t.onIntent(r, (n) => {
|
|
786
787
|
Promise.resolve(a(e, n, i)).catch((e) => t.onError({
|
|
787
788
|
message: `Execution command failed: ${r}`,
|
|
788
789
|
cause: e
|
|
@@ -796,16 +797,16 @@ function mn(e, t) {
|
|
|
796
797
|
}
|
|
797
798
|
//#endregion
|
|
798
799
|
//#region src/Chart.ts
|
|
799
|
-
var
|
|
800
|
+
var bn = {
|
|
800
801
|
min: 0,
|
|
801
802
|
max: 100
|
|
802
|
-
},
|
|
803
|
-
function
|
|
803
|
+
}, xn = 0xe8d4a51000, Sn = "exchange";
|
|
804
|
+
function Cn(e) {
|
|
804
805
|
if (typeof e == "string" && e !== "exchange" && !f(e)) throw RangeError(`Unknown time zone: ${e}`);
|
|
805
806
|
if (typeof e == "number" && !Number.isFinite(e)) throw RangeError(`Invalid UTC offset: ${e}`);
|
|
806
807
|
}
|
|
807
|
-
var
|
|
808
|
-
static version = "1.
|
|
808
|
+
var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
|
|
809
|
+
static version = "1.12.0";
|
|
809
810
|
engine;
|
|
810
811
|
viewport;
|
|
811
812
|
dataManager;
|
|
@@ -841,14 +842,14 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
|
|
|
841
842
|
indicatorHistoryDepth = 0;
|
|
842
843
|
removedDrawingAlerts = /* @__PURE__ */ new Map();
|
|
843
844
|
zoomAreaMode = !1;
|
|
844
|
-
priceAxisAddButton = new
|
|
845
|
+
priceAxisAddButton = new He();
|
|
845
846
|
displayTz = null;
|
|
846
847
|
timezoneSetting = null;
|
|
847
848
|
symbolInfo = null;
|
|
848
849
|
symbolInfoSeq = 0;
|
|
849
850
|
sessionBreaks;
|
|
850
851
|
sessionShading;
|
|
851
|
-
hostSessionHours = { ...
|
|
852
|
+
hostSessionHours = { ...xe };
|
|
852
853
|
compareRenderer;
|
|
853
854
|
countdownInterval = null;
|
|
854
855
|
volumeRenderer;
|
|
@@ -861,7 +862,7 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
|
|
|
861
862
|
signalMarkerManager;
|
|
862
863
|
tradeZoneManager;
|
|
863
864
|
measureOverlay;
|
|
864
|
-
selectionBoxOverlay = new
|
|
865
|
+
selectionBoxOverlay = new qe();
|
|
865
866
|
replayManager;
|
|
866
867
|
replayBarUnsub = null;
|
|
867
868
|
replaySeeking = !1;
|
|
@@ -869,7 +870,7 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
|
|
|
869
870
|
replayStepsSeries = null;
|
|
870
871
|
replayCoarse = null;
|
|
871
872
|
undoRedoManager;
|
|
872
|
-
autoSaveScheduler = new
|
|
873
|
+
autoSaveScheduler = new Kt((e) => this.saveState(e));
|
|
873
874
|
animator;
|
|
874
875
|
crosshairTooltip;
|
|
875
876
|
pinnedTooltip;
|
|
@@ -877,18 +878,19 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
|
|
|
877
878
|
crosshairHandler;
|
|
878
879
|
chartRenderer;
|
|
879
880
|
rendererToken = 0;
|
|
881
|
+
stopWaitingForGpu = null;
|
|
880
882
|
disposed = !1;
|
|
881
883
|
chartTypeOptions = {};
|
|
882
884
|
mainSeriesVisible = !0;
|
|
883
|
-
priceLines = new
|
|
884
|
-
symbolSeries = new
|
|
885
|
+
priceLines = new Ue();
|
|
886
|
+
symbolSeries = new et();
|
|
885
887
|
extendedHours = !0;
|
|
886
888
|
replayRestarting = !1;
|
|
887
889
|
fullSeries = null;
|
|
888
890
|
requestedSymbols = /* @__PURE__ */ new Set();
|
|
889
891
|
gridRenderer;
|
|
890
892
|
priceAxis;
|
|
891
|
-
leftPriceAxis = new
|
|
893
|
+
leftPriceAxis = new E();
|
|
892
894
|
leftScaleRequested = !1;
|
|
893
895
|
leftAxisWidth = a;
|
|
894
896
|
leftViewport = null;
|
|
@@ -918,7 +920,7 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
|
|
|
918
920
|
snapshotKey = null;
|
|
919
921
|
historyCheckQueued = !1;
|
|
920
922
|
constructor(e, t) {
|
|
921
|
-
t.timeZone != null &&
|
|
923
|
+
t.timeZone != null && Cn(t.timeZone), this.container = e, this.options = {
|
|
922
924
|
...t,
|
|
923
925
|
chartType: t.chartType ?? "candlestick"
|
|
924
926
|
}, this.numberLocale = t.numberLocale ?? "en-US", this.defaultAutoScale = t.autoScale !== !1;
|
|
@@ -956,15 +958,15 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
|
|
|
956
958
|
logScale: n.logScale ?? !0,
|
|
957
959
|
timeframes: n.timeframes ?? [],
|
|
958
960
|
defaultTimeframeFavorites: n.defaultTimeframeFavorites ?? []
|
|
959
|
-
}, e.style.position = "relative", e.style.overflow = "hidden", e.tabIndex = 0, e.style.outline = "none", e.style.userSelect = "none", e.style.webkitUserSelect = "none", this.dataManager = new
|
|
961
|
+
}, e.style.position = "relative", e.style.overflow = "hidden", e.tabIndex = 0, e.style.outline = "none", e.style.userSelect = "none", e.style.webkitUserSelect = "none", this.dataManager = new B(), this.history = new Zt({
|
|
960
962
|
oldestTime: () => this.dataManager.getData()[0]?.time ?? null,
|
|
961
963
|
prepend: (e) => this.prependBars(e),
|
|
962
964
|
emit: (e) => this.eventBus.emit("historyLoad", e)
|
|
963
|
-
}), this.themeManager = new
|
|
965
|
+
}), this.themeManager = new Qt(t.theme), this.layoutManager = new tn(), this.indicatorEngine = new w(), this.pluginManager = new gn(this.indicatorEngine, { plugins: t.plugins }), this.eventBus = new Ee(), O(this.indicatorEngine), this.indicatorEngine.register(new he(this.symbolSeries)), this.indicatorEngine.register(new Ze(this.symbolSeries)), this.indicatorEngine.register(new ge(this.symbolSeries)), this.indicatorEngine.register(new _e(this.symbolSeries)), this.drawingManager = new Ce(), bt(this.drawingManager), this.drawingRenderer = new we(this.drawingManager), this.drawingManager.setRequestRender(() => {
|
|
964
966
|
this.syncRenderContext(), this.engine.requestRender(r.Overlay), this.scheduleAutoSave();
|
|
965
967
|
}), this.drawingManager.setEventCallback((e, t) => {
|
|
966
968
|
this.followDrawingAlerts(e, t?.id), this.eventBus.emit(e, t), (e === "drawingCreate" || e === "drawingUpdate" || e === "drawingRemove") && this.announceStateChange();
|
|
967
|
-
}), this.drawingManager.setToolFilter((e) => this.features.drawings && (this.features.drawingTools.length === 0 || this.features.drawingTools.includes(e))), this.undoRedoManager = new
|
|
969
|
+
}), this.drawingManager.setToolFilter((e) => this.features.drawings && (this.features.drawingTools.length === 0 || this.features.drawingTools.includes(e))), this.undoRedoManager = new at();
|
|
968
970
|
let i = "";
|
|
969
971
|
this.undoRedoManager.setOnChange(() => {
|
|
970
972
|
let { canUndo: e, canRedo: t } = this.undoRedoManager.getState(), n = `${e}|${t}`;
|
|
@@ -977,21 +979,21 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
|
|
|
977
979
|
primary: e[0] ?? null
|
|
978
980
|
})), this.drawingManager.setForeignHistory((e, t) => {
|
|
979
981
|
e.type === "custom" ? e.custom?.[t]() : this.applyIndicatorStep(e, t);
|
|
980
|
-
}), this.drawingManager.setDataGetter(() => this.dataManager.getData()), this.drawingManager.setDisplayDataGetter(() => this.getDisplayData()), t.crosshair?.mode === "magnet" && this.features.drawingMagnet && this.drawingManager.setMagnetMode("magnet"), this.tradingManager = new
|
|
982
|
+
}), this.drawingManager.setDataGetter(() => this.dataManager.getData()), this.drawingManager.setDisplayDataGetter(() => this.getDisplayData()), t.crosshair?.mode === "magnet" && this.features.drawingMagnet && this.drawingManager.setMagnetMode("magnet"), this.tradingManager = new rt({
|
|
981
983
|
enabled: this.features.trading,
|
|
982
984
|
contextMenu: { enabled: this.features.tradingContextMenu }
|
|
983
|
-
}), this.tradingRenderer = new
|
|
985
|
+
}), this.tradingRenderer = new it(this.tradingManager), this.tradingManager.setContainer(e), this.tradingManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.tradingManager.setEventCallback((e, t) => {
|
|
984
986
|
this.eventBus.emit(e, t);
|
|
985
|
-
}), this.engine = new
|
|
987
|
+
}), this.engine = new We(e);
|
|
986
988
|
let a = this.engine.dprManager.getContainerSize();
|
|
987
|
-
if (this.viewport = new
|
|
989
|
+
if (this.viewport = new ot(a.width, a.height, t.minBarSpacing ?? 2, t.maxBarSpacing ?? 30, t.rightMargin ?? 5), this.viewport.setPanLimits({
|
|
988
990
|
freePan: t.freePan ?? !0,
|
|
989
991
|
minVisibleBars: t.panLimits?.minVisibleBars ?? 3
|
|
990
992
|
}), this.layoutManager.resize(a.width, a.height), this.engine.onContainerResize = (e) => {
|
|
991
993
|
if (e.width <= 0 || e.height <= 0) return;
|
|
992
994
|
let t = this.viewport.isAtEnd();
|
|
993
995
|
this.viewport.resize(e.width, e.height), this.layoutManager.resize(e.width, e.height), this.updateViewportAndRender(t);
|
|
994
|
-
}, this.chartRenderer = this.createChartRenderer(this.options.chartType), this.gridRenderer = new
|
|
996
|
+
}, this.chartRenderer = this.createChartRenderer(this.options.chartType), this.gridRenderer = new De(), t.grid?.visible === !1 && this.gridRenderer.setVisible(!1), this.priceAxis = new E(), this.priceAxis.setLocale(this.numberLocale), this.leftPriceAxis.setLocale(this.numberLocale), this.timeAxis = new tt(), this.crosshairHandler = new ve(), this.crosshairHandler.setLocale(this.numberLocale), t.crosshair?.mode && this.crosshairHandler.setMode(t.crosshair.mode), this.crosshairHandler.setCallback((e, t) => {
|
|
995
997
|
if (e !== null && t) {
|
|
996
998
|
let n = this.dataManager.getData(), r = e < n.length ? n[e] : void 0;
|
|
997
999
|
this.chartLegend.setHoverBar(r ?? null);
|
|
@@ -1000,19 +1002,19 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
|
|
|
1000
1002
|
prevClose: e > 0 ? n[e - 1]?.close : void 0,
|
|
1001
1003
|
priceRange: i.priceRange,
|
|
1002
1004
|
plot: i.chartRect,
|
|
1003
|
-
barStepMs:
|
|
1005
|
+
barStepMs: ft(n)
|
|
1004
1006
|
}) : this.crosshairTooltip.hide(), this.pinnedTooltip.isPinned() && this.pinnedTooltip.reposition(this.viewport.getState(), r ?? null, e, this.themeManager.getTheme()), this.eventBus.emit("crosshairMove", {
|
|
1005
1007
|
point: t,
|
|
1006
1008
|
bar: r,
|
|
1007
1009
|
barIndex: e
|
|
1008
1010
|
});
|
|
1009
1011
|
} else this.crosshairTooltip.hide(), this.chartLegend.setHoverBar(null), this.eventBus.emit("crosshairLeave", {});
|
|
1010
|
-
}), this.chartLegend = new
|
|
1012
|
+
}), this.chartLegend = new pe(), this.chartLegend.setChartType(this.options.chartType), this.chartLegend.setLocale(this.numberLocale), this.watermark = new ut(), t.watermark && this.watermark.setConfig(t.watermark), this.volumeRenderer = new lt(), this.volumeProfile = new ct(), this.marketProfile = new Fe(), this.depthHeatmap = new Se(), this.periodLevels = new ze(), this.pivotMarkers = new Ve(), this.barCountdown = new le(), this.barCountdown.setVisible(this.features.barCountdown), this.sessionBreaks = new Je(), this.sessionBreaks.setLocale(this.numberLocale), this.sessionShading = new Ye(), this.compareRenderer = new me(), t.sessionBreaks ? this.sessionBreaks.setConfig({
|
|
1011
1013
|
visible: t.sessionBreaks.visible ?? !0,
|
|
1012
1014
|
color: t.sessionBreaks.color,
|
|
1013
1015
|
lineStyle: t.sessionBreaks.lineStyle,
|
|
1014
1016
|
lineWidth: t.sessionBreaks.lineWidth
|
|
1015
|
-
}) : t.features?.sessionBreaks !== !1 && this.sessionBreaks.setVisible(!0), t.logScale && this.features.logScale && this.viewport.setLogScale(!0), this.animator = new
|
|
1017
|
+
}) : t.features?.sessionBreaks !== !1 && this.sessionBreaks.setVisible(!0), t.logScale && this.features.logScale && this.viewport.setLogScale(!0), this.animator = new oe(), this.crosshairTooltip = new ye(), this.crosshairTooltip.create(e), this.crosshairTooltip.setLocale(this.numberLocale), this.pinnedTooltip = new Be(), this.pinnedTooltip.create(e), t.priceFormat && this.applyPriceFormat(t.priceFormat), t.chartTypeOptions && (this.chartTypeOptions = _(t.chartTypeOptions)), t.highLowLines && this.priceLines.setHighLow(!0), t.shapes && this.themeManager.setShape(Mn(t.shapes)), this.priceLines.setPriceText((e) => this.formatPrice(e)), t.extendedHours === !1 && (this.extendedHours = !1), t.timeFormatter && this.applyTimeFormatter(t.timeFormatter), this.keyboardHandler = new Me({
|
|
1016
1018
|
scrollBars: (e) => {
|
|
1017
1019
|
let t = this.viewport.getState().barWidth + this.viewport.getState().barSpacing;
|
|
1018
1020
|
this.viewport.scrollBy(e * t), this.updateViewportAndRender();
|
|
@@ -1029,17 +1031,17 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
|
|
|
1029
1031
|
},
|
|
1030
1032
|
fitContent: () => this.fitContent()
|
|
1031
1033
|
}), this.keyboardHandler.setEnabled(this.features.keyboard), t.a11y !== !1) {
|
|
1032
|
-
this.a11y = new
|
|
1034
|
+
this.a11y = new Ft(e, {
|
|
1033
1035
|
symbol: () => this.currentSymbol || this.symbolInfo?.symbol || "",
|
|
1034
1036
|
timeframe: () => this.streamTimeframe ?? "",
|
|
1035
1037
|
chartType: () => this.options.chartType ?? "candlestick",
|
|
1036
1038
|
bars: () => this.getDisplayData(),
|
|
1037
1039
|
visibleRange: () => this.viewport.getState().visibleRange,
|
|
1038
1040
|
formatPrice: (e) => this.formatPrice(e),
|
|
1039
|
-
formatTime: (e) =>
|
|
1041
|
+
formatTime: (e) => re(this.numberLocale || "en-US", {
|
|
1040
1042
|
dateStyle: "medium",
|
|
1041
1043
|
timeStyle: "short"
|
|
1042
|
-
}, this.displayTz)(e >
|
|
1044
|
+
}, this.displayTz)(e > xn ? e : e * 1e3),
|
|
1043
1045
|
showBar: (e) => this.setCrosshairTime(e)
|
|
1044
1046
|
}, t.a11y?.labels);
|
|
1045
1047
|
for (let e of [
|
|
@@ -1059,7 +1061,7 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
|
|
|
1059
1061
|
}
|
|
1060
1062
|
this.keyboardHandler.handleKey(e) && (e.preventDefault(), this.a11y?.viewMoved());
|
|
1061
1063
|
}
|
|
1062
|
-
}, window.addEventListener("keydown", this.onWindowKeyDown), this.currentPriceLine = new
|
|
1064
|
+
}, window.addEventListener("keydown", this.onWindowKeyDown), this.currentPriceLine = new be(), this.currentPriceLine.setLocale(this.numberLocale), this.priceAxis.setReservedPriceProvider(() => this.currentPriceLine.isVisible() ? this.currentPriceLine.getPrice() : null), this.alertManager = new ae(), this.alertManager.setDrawingLevels((e) => this.drawingLevelsNow(e)), this.alertManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.alertManager.on("triggered", (e) => {
|
|
1063
1065
|
this.eventBus.emit("alertTriggered", G(e)), this.eventBus.emit("dataUpdate", {
|
|
1064
1066
|
alert: "triggered",
|
|
1065
1067
|
alertId: e.id,
|
|
@@ -1074,7 +1076,7 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
|
|
|
1074
1076
|
this.eventBus.emit("alertExpired", G(e));
|
|
1075
1077
|
}), this.alertManager.on("updated", (e) => {
|
|
1076
1078
|
this.eventBus.emit("alertUpdate", G(e));
|
|
1077
|
-
}), this.signalMarkerManager = new
|
|
1079
|
+
}), this.signalMarkerManager = new Xe(), this.signalMarkerManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.signalMarkerManager.setDataGetter(() => this.dataManager.getData()), this.signalMarkerManager.on("added", (e) => {
|
|
1078
1080
|
this.eventBus.emit("signalMarkerAdd", {
|
|
1079
1081
|
id: e.id,
|
|
1080
1082
|
source: e.source,
|
|
@@ -1082,18 +1084,18 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
|
|
|
1082
1084
|
});
|
|
1083
1085
|
}), this.signalMarkerManager.on("removed", (e) => {
|
|
1084
1086
|
this.eventBus.emit("signalMarkerRemove", { id: e });
|
|
1085
|
-
}), this.tradeZoneManager = new
|
|
1087
|
+
}), this.tradeZoneManager = new nt(), this.tradeZoneManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.tradeZoneManager.setDataGetter(() => this.dataManager.getData()), this.tradeZoneManager.on("added", (e) => {
|
|
1086
1088
|
this.eventBus.emit("tradeZoneAdd", {
|
|
1087
1089
|
id: e.id,
|
|
1088
1090
|
direction: e.direction
|
|
1089
1091
|
});
|
|
1090
1092
|
}), this.tradeZoneManager.on("removed", (e) => {
|
|
1091
1093
|
this.eventBus.emit("tradeZoneRemove", { id: e });
|
|
1092
|
-
}), this.replayManager = new
|
|
1094
|
+
}), this.replayManager = new Ke(), this.replayManager.on("stateChange", (e) => {
|
|
1093
1095
|
this.replayRestarting || this.eventBus.emit("replayState", { state: e });
|
|
1094
|
-
}), this.measureOverlay = new
|
|
1095
|
-
let e = new
|
|
1096
|
-
this.interactionManager.setPanHandler(new
|
|
1096
|
+
}), this.measureOverlay = new Ie(), this.interactionManager = new Ae(e), this.features.panning) {
|
|
1097
|
+
let e = new ln();
|
|
1098
|
+
this.interactionManager.setPanHandler(new Le((t, n) => {
|
|
1097
1099
|
t && this.viewport.scrollBy(t), e.step(t, n, this.options.autoScale !== !1) && n && (this.options.autoScale = !1, this.viewport.panPriceRange(n)), this.updateViewportAndRender();
|
|
1098
1100
|
}, () => e.reset()));
|
|
1099
1101
|
}
|
|
@@ -1105,10 +1107,10 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
|
|
|
1105
1107
|
scales: !this.indicatorEngine.hasLeftScaleOverlays()
|
|
1106
1108
|
}
|
|
1107
1109
|
})), this.features.zooming) {
|
|
1108
|
-
this.interactionManager.setZoomHandler(new
|
|
1110
|
+
this.interactionManager.setZoomHandler(new dt((e, t) => {
|
|
1109
1111
|
this.viewport.zoom(e, t - this.viewport.getState().chartRect.x), this.updateViewportAndRender();
|
|
1110
1112
|
}));
|
|
1111
|
-
let e = new
|
|
1113
|
+
let e = new ce((e) => {
|
|
1112
1114
|
this.options.autoScale = !1, this.viewport.scalePriceRange(e), this.syncRenderContext(), this.engine.requestRender(), this.emitViewportEvents();
|
|
1113
1115
|
}, (e) => {
|
|
1114
1116
|
let t = this.viewport.getState().chartRect.width;
|
|
@@ -1128,7 +1130,7 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
|
|
|
1128
1130
|
y: t.y
|
|
1129
1131
|
});
|
|
1130
1132
|
})), this.interactionManager.setChartContextMenu((e, t) => this.eventBus.hasListeners("chartContextMenu") ? (this.eventBus.emit("chartContextMenu", this.contextAt(e, t)), !0) : !1), this.priceAxisAddButton.setEnabled(this.features.priceAxisAddButton && this.features.crosshair), this.interactionManager.setPriceAxisAddButton(this.priceAxisAddButton, (e) => {
|
|
1131
|
-
let t =
|
|
1133
|
+
let t = P(e.y, this.viewport.getState());
|
|
1132
1134
|
Number.isFinite(t) && this.eventBus.emit("priceAxisAdd", {
|
|
1133
1135
|
price: t,
|
|
1134
1136
|
x: e.x,
|
|
@@ -1138,10 +1140,10 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
|
|
|
1138
1140
|
...this.viewport.getState(),
|
|
1139
1141
|
data: this.getDisplayData()
|
|
1140
1142
|
})), this.features.alerts) {
|
|
1141
|
-
let e = new
|
|
1143
|
+
let e = new ie(this.alertManager, () => this.viewport.getState());
|
|
1142
1144
|
this.interactionManager.setAlertDragHandler(e);
|
|
1143
1145
|
}
|
|
1144
|
-
let o = new
|
|
1146
|
+
let o = new Re();
|
|
1145
1147
|
o.configure(() => this.getResolvedLayout(), (e, t) => this.setPanelSize(e, t)), this.interactionManager.setPaneResizeHandler(o), this.interactionManager.setAltClickHandler((e) => {
|
|
1146
1148
|
let t = this.getDisplayData();
|
|
1147
1149
|
if (t.length === 0) return;
|
|
@@ -1165,7 +1167,7 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
|
|
|
1165
1167
|
x: e.x,
|
|
1166
1168
|
y: e.y
|
|
1167
1169
|
}), t.length === 0) return;
|
|
1168
|
-
let r =
|
|
1170
|
+
let r = Ot(e.x, this.viewport.getState());
|
|
1169
1171
|
r < 0 || r >= t.length || this.eventBus.emit("barClick", {
|
|
1170
1172
|
bar: t[r],
|
|
1171
1173
|
barIndex: r,
|
|
@@ -1205,7 +1207,7 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
|
|
|
1205
1207
|
end: () => {
|
|
1206
1208
|
let e = this.selectionBoxOverlay.end();
|
|
1207
1209
|
if (e && this.zoomAreaMode) {
|
|
1208
|
-
if (e.x1 - e.x0 <
|
|
1210
|
+
if (e.x1 - e.x0 < On) return;
|
|
1209
1211
|
this.zoomToBox(e), this.setZoomAreaMode(!1);
|
|
1210
1212
|
return;
|
|
1211
1213
|
}
|
|
@@ -1227,6 +1229,9 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
|
|
|
1227
1229
|
}), this.interactionManager.attach(), t.timeZone !== void 0 && t.timeZone !== null && this.setTimezone(t.timeZone), t.leftPriceScale && (this.leftScaleRequested = !0), this.syncRenderContext(), this.engine.start(), this.engine.onGpuLost = () => this.eventBus.emit("rendererChange", {
|
|
1228
1230
|
renderer: "canvas",
|
|
1229
1231
|
reason: "contextLost"
|
|
1232
|
+
}), this.engine.onGpuRestored = () => this.eventBus.emit("rendererChange", {
|
|
1233
|
+
renderer: "webgl",
|
|
1234
|
+
reason: "contextRestored"
|
|
1230
1235
|
}), this.options.renderer && this.options.renderer !== "canvas" && this.setRenderer(this.options.renderer);
|
|
1231
1236
|
}
|
|
1232
1237
|
setData(e) {
|
|
@@ -1239,7 +1244,7 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
|
|
|
1239
1244
|
if (this.replaySession) return 0;
|
|
1240
1245
|
let t = null;
|
|
1241
1246
|
if (this.fullSeries) {
|
|
1242
|
-
let n = this.fullSeries[0]?.time, r = /* @__PURE__ */ new Set(), i = e.filter((e) =>
|
|
1247
|
+
let n = this.fullSeries[0]?.time, r = /* @__PURE__ */ new Set(), i = e.filter((e) => zn(e) && (n === void 0 || e.time < n) && !r.has(e.time) && r.add(e.time)).sort((e, t) => e.time - t.time);
|
|
1243
1248
|
this.fullSeries = [...i, ...this.fullSeries];
|
|
1244
1249
|
let a = this.sessionKeep(this.fullSeries);
|
|
1245
1250
|
t = i.length, e = a ? i.filter((e) => a(e.time)) : i;
|
|
@@ -1248,7 +1253,7 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
|
|
|
1248
1253
|
if (a === 0) return t ?? 0;
|
|
1249
1254
|
let o = this.dataManager.getData();
|
|
1250
1255
|
if (this.crosshairHandler.setData(o), this.displayDataCache = null, this.sessionBreaks.invalidateCache(), this.pinnedTooltip.isPinned() && this.pinnedTooltip.unpin(), this.measureOverlay.end(), this.recalcIndicators(o), i !== void 0) {
|
|
1251
|
-
let e = Math.round(
|
|
1256
|
+
let e = Math.round(j(i, this.getDisplayData()));
|
|
1252
1257
|
this.viewport.prependBars(e - r);
|
|
1253
1258
|
}
|
|
1254
1259
|
return this.updateViewportAndRender(), t ?? a;
|
|
@@ -1279,14 +1284,14 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
|
|
|
1279
1284
|
}
|
|
1280
1285
|
checkHistory() {
|
|
1281
1286
|
this.historyCheckQueued || !this.history.hasLoader() || (this.historyCheckQueued = !0, queueMicrotask(() => {
|
|
1282
|
-
if (this.historyCheckQueued = !1, this.replaySession || !this.history.hasLoader() ||
|
|
1287
|
+
if (this.historyCheckQueued = !1, this.replaySession || !this.history.hasLoader() || Vt(this.options.chartType)) return;
|
|
1283
1288
|
let { from: e, to: t } = this.viewport.getState().visibleRange;
|
|
1284
|
-
this.history.maybeLoad(Math.max(0, Math.floor(e)), Math.max(
|
|
1289
|
+
this.history.maybeLoad(Math.max(0, Math.floor(e)), Math.max(Dn, t - e));
|
|
1285
1290
|
}));
|
|
1286
1291
|
}
|
|
1287
1292
|
useStreamHistory(e, t) {
|
|
1288
1293
|
if (this.hostHistoryLoader) return;
|
|
1289
|
-
let n =
|
|
1294
|
+
let n = Dt(e), r = n.fetchHistoryBefore, i = this.streamTimeframe;
|
|
1290
1295
|
if (!r || i === null || ne(i) !== null) {
|
|
1291
1296
|
this.historyFromStream && this.history.setLoader(null), this.historyFromStream = !1;
|
|
1292
1297
|
return;
|
|
@@ -1368,7 +1373,7 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
|
|
|
1368
1373
|
return this.extendedHours;
|
|
1369
1374
|
}
|
|
1370
1375
|
sessionKeep(e) {
|
|
1371
|
-
return this.extendedHours ? null :
|
|
1376
|
+
return this.extendedHours ? null : jt(this.symbolInfo, e);
|
|
1372
1377
|
}
|
|
1373
1378
|
shownBars(e) {
|
|
1374
1379
|
let t = this.sessionKeep(e);
|
|
@@ -1409,7 +1414,7 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
|
|
|
1409
1414
|
return this.priceLines.setQuoteShown(this.replaySession === null), this.priceLines;
|
|
1410
1415
|
}
|
|
1411
1416
|
setShapes(e) {
|
|
1412
|
-
let t =
|
|
1417
|
+
let t = Mn(e);
|
|
1413
1418
|
t.tagRadius !== void 0 && (this.themeManager.setShape({
|
|
1414
1419
|
...this.themeManager.getTheme().shape,
|
|
1415
1420
|
...t
|
|
@@ -1481,7 +1486,7 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
|
|
|
1481
1486
|
this.recordIndicators(e, () => this.updateIndicatorNow(e, t));
|
|
1482
1487
|
}
|
|
1483
1488
|
updateIndicatorNow(e, t) {
|
|
1484
|
-
let n = this.indicatorEngine.getIndicatorDescriptor(e), r = n ?
|
|
1489
|
+
let n = this.indicatorEngine.getIndicatorDescriptor(e), r = n ? A(n) : null, i = r ? this.indicatorEngine.getIndicatorConfig(e)?.params[r] : void 0;
|
|
1485
1490
|
this.indicatorEngine.updateIndicator(e, t, this.dataManager.getData()), this.announceIndicatorUpdate(0), this.markStateChanged(), this.eventBus.emit("indicatorChange", {
|
|
1486
1491
|
instanceId: e,
|
|
1487
1492
|
change: "params"
|
|
@@ -1499,7 +1504,7 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
|
|
|
1499
1504
|
paneFor(e, t, n, r) {
|
|
1500
1505
|
if (n) return this.paneHostOf(n, r);
|
|
1501
1506
|
if (e.placement !== "overlay") return null;
|
|
1502
|
-
let i =
|
|
1507
|
+
let i = A(e), a = i ? h(t[i]) : null;
|
|
1503
1508
|
return a ? this.paneHostOf(a.instanceId, r) : null;
|
|
1504
1509
|
}
|
|
1505
1510
|
paneHostOf(e, t) {
|
|
@@ -1542,8 +1547,8 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
|
|
|
1542
1547
|
return {
|
|
1543
1548
|
...e,
|
|
1544
1549
|
priceRange: {
|
|
1545
|
-
min: t.min - n *
|
|
1546
|
-
max: t.max + n *
|
|
1550
|
+
min: t.min - n * Tn,
|
|
1551
|
+
max: t.max + n * Tn
|
|
1547
1552
|
},
|
|
1548
1553
|
logScale: !1,
|
|
1549
1554
|
scaleMode: "regular",
|
|
@@ -1593,8 +1598,8 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
|
|
|
1593
1598
|
return this.pluginManager;
|
|
1594
1599
|
}
|
|
1595
1600
|
static indicators() {
|
|
1596
|
-
let e = new
|
|
1597
|
-
return
|
|
1601
|
+
let e = new w();
|
|
1602
|
+
return O(e), e.getAvailableIndicators();
|
|
1598
1603
|
}
|
|
1599
1604
|
setPanelPosition(e, t) {
|
|
1600
1605
|
this.layoutManager.setPanelPosition(e, t), this.updateViewportAndRender(), this.eventBus.emit("indicatorChange", {
|
|
@@ -1617,7 +1622,7 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
|
|
|
1617
1622
|
paneMoveHost(e, t) {
|
|
1618
1623
|
let n = this.indicatorEngine.getIndicatorConfig(e), r = this.indicatorEngine.getIndicatorDescriptor(e);
|
|
1619
1624
|
if (!n || !r) return;
|
|
1620
|
-
let i =
|
|
1625
|
+
let i = A(r);
|
|
1621
1626
|
if (r.placement === "overlay" && i && h(n.params[i])) return;
|
|
1622
1627
|
if (t === "price") return r.placement === "overlay" && n.pane ? null : void 0;
|
|
1623
1628
|
if (t === "new") {
|
|
@@ -1723,7 +1728,7 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
|
|
|
1723
1728
|
return this.features.legend ? e + this.chartLegend.getHeight() : e;
|
|
1724
1729
|
}
|
|
1725
1730
|
isTimeAligned() {
|
|
1726
|
-
return
|
|
1731
|
+
return Vt(this.options.chartType) ? !1 : this.getDisplayData().length === this.dataManager.getLength();
|
|
1727
1732
|
}
|
|
1728
1733
|
roundPrice(e) {
|
|
1729
1734
|
if (!Number.isFinite(e)) return e;
|
|
@@ -1795,7 +1800,7 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
|
|
|
1795
1800
|
}
|
|
1796
1801
|
autoFib() {
|
|
1797
1802
|
if (!this.features.drawings) return null;
|
|
1798
|
-
let e = this.getDisplayData(), t = this.viewport.getState(), n =
|
|
1803
|
+
let e = this.getDisplayData(), t = this.viewport.getState(), n = pt(e, t.visibleRange.from, t.visibleRange.to);
|
|
1799
1804
|
return n ? this.addDrawing({
|
|
1800
1805
|
type: "fibRetracement",
|
|
1801
1806
|
anchors: [n[0], n[1]]
|
|
@@ -1870,7 +1875,7 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
|
|
|
1870
1875
|
recordUndo(e) {
|
|
1871
1876
|
if (!this.features.drawingUndoRedo || typeof e?.undo != "function" || typeof e.redo != "function") return;
|
|
1872
1877
|
let t = performance.now(), n = this.undoRedoManager.last();
|
|
1873
|
-
if (e.subject !== void 0 && n?.type === "custom" && n.custom?.subject === e.subject && t - n.custom.at <
|
|
1878
|
+
if (e.subject !== void 0 && n?.type === "custom" && n.custom?.subject === e.subject && t - n.custom.at < En) {
|
|
1874
1879
|
this.undoRedoManager.replaceLast({
|
|
1875
1880
|
...n,
|
|
1876
1881
|
custom: {
|
|
@@ -1917,7 +1922,7 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
|
|
|
1917
1922
|
x: t.x,
|
|
1918
1923
|
y: t.y
|
|
1919
1924
|
};
|
|
1920
|
-
if ((e === "plot" || e === "priceAxis") && (r.price =
|
|
1925
|
+
if ((e === "plot" || e === "priceAxis") && (r.price = P(t.y, n)), (e === "plot" || e === "timeAxis") && n.data.length > 0 && (r.time = N(t.x, n)), e === "pane") {
|
|
1921
1926
|
let e = this.getIndicatorPanes().find((e) => t.y >= e.rect.y && t.y <= e.rect.y + e.rect.height);
|
|
1922
1927
|
e && (r.pane = e.instanceId);
|
|
1923
1928
|
}
|
|
@@ -1943,7 +1948,7 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
|
|
|
1943
1948
|
...this.viewport.getState(),
|
|
1944
1949
|
data: this.getDisplayData()
|
|
1945
1950
|
};
|
|
1946
|
-
this.setVisibleRange(
|
|
1951
|
+
this.setVisibleRange(N(e.x0, t), N(e.x1, t));
|
|
1947
1952
|
}
|
|
1948
1953
|
lockAllDrawings() {
|
|
1949
1954
|
this.drawingManager.lockAllDrawings();
|
|
@@ -1988,7 +1993,7 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
|
|
|
1988
1993
|
for (let e of this.indicatorEngine.getActiveIndicators()) {
|
|
1989
1994
|
let t = this.indicatorEngine.getOutput(e.instanceId)?.series;
|
|
1990
1995
|
if (!t) continue;
|
|
1991
|
-
let r =
|
|
1996
|
+
let r = Lt(e.id, e.params, e.descriptor.defaultConfig, e.descriptor.shortName), o = e.descriptor.plots ?? Object.keys(t.find((e) => e) ?? {}).map((e) => ({
|
|
1992
1997
|
key: e,
|
|
1993
1998
|
title: e
|
|
1994
1999
|
}));
|
|
@@ -2012,11 +2017,11 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
|
|
|
2012
2017
|
}
|
|
2013
2018
|
getExportText(e = "csv", t = {}) {
|
|
2014
2019
|
let { bars: n, columns: r } = this.getExportData(t);
|
|
2015
|
-
return e === "json" ?
|
|
2020
|
+
return e === "json" ? S.toJSON(n, r) : S.toCSV(n, r);
|
|
2016
2021
|
}
|
|
2017
2022
|
download(e, t, n) {
|
|
2018
2023
|
let r = this.getExportText(e, n);
|
|
2019
|
-
e === "json" ?
|
|
2024
|
+
e === "json" ? S.download(r, t ?? "chart-data.json", "application/json") : S.download(r, t ?? "chart-data.csv", "text/csv");
|
|
2020
2025
|
}
|
|
2021
2026
|
setAutoSave(e, t = 5e3) {
|
|
2022
2027
|
this.autoSaveScheduler.enable(e, t);
|
|
@@ -2172,8 +2177,8 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
|
|
|
2172
2177
|
this.features.trading && this.tradingManager.setConfig(e);
|
|
2173
2178
|
}
|
|
2174
2179
|
async connect(e) {
|
|
2175
|
-
if (!
|
|
2176
|
-
this.snapshotKey = null, this.replayStop(), this.disconnectStream(), this.streamManager = new
|
|
2180
|
+
if (!k(e.adapter, e.timeframe)) throw RangeError(`${e.adapter.name} cannot serve the ${e.timeframe} timeframe`);
|
|
2181
|
+
this.snapshotKey = null, this.replayStop(), this.disconnectStream(), this.streamManager = new $e(), this.streamManager.on("snapshot", (t) => {
|
|
2177
2182
|
let n = `${this.currentSymbol}|${this.streamTimeframe}`;
|
|
2178
2183
|
this.replaySession ? this.replaySession.live.setData(t) : n === this.snapshotKey && this.dataManager.getLength() > 0 ? this.mergeSnapshot(t) : this.setData(t), this.snapshotKey = n, this.useStreamHistory(e.adapter, e.historyPageSize);
|
|
2179
2184
|
}), this.streamManager.on("barClose", (e) => {
|
|
@@ -2240,7 +2245,7 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
|
|
|
2240
2245
|
async switchStream(e, t) {
|
|
2241
2246
|
if (!this.streamManager) return;
|
|
2242
2247
|
let n = this.streamAdapter;
|
|
2243
|
-
if (n && !
|
|
2248
|
+
if (n && !k(n, t)) throw RangeError(`${n.name} cannot serve the ${t} timeframe`);
|
|
2244
2249
|
this.setStreamTarget(e, t), this.historyFromStream && this.history.setLoader(null), this.barCountdown.setTimeframeMs(y(t)), n && this.resolveStreamSymbol(n, e), await this.streamManager.switchTo(e, t);
|
|
2245
2250
|
}
|
|
2246
2251
|
isTimeframeAllowed(e) {
|
|
@@ -2256,7 +2261,7 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
|
|
|
2256
2261
|
}
|
|
2257
2262
|
connectExecution(e, t = {}) {
|
|
2258
2263
|
if (!this.features.trading) throw Error("connectExecution requires features.trading to be enabled");
|
|
2259
|
-
this.disconnectExecution(), this.executionAdapter = e, this.execTeardown =
|
|
2264
|
+
this.disconnectExecution(), this.executionAdapter = e, this.execTeardown = yn(e, {
|
|
2260
2265
|
onIntent: (e, t) => {
|
|
2261
2266
|
let n = (e) => t(e.payload);
|
|
2262
2267
|
return this.eventBus.on(e, n), () => this.eventBus.off(e, n);
|
|
@@ -2347,18 +2352,18 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
|
|
|
2347
2352
|
goToTime(e) {
|
|
2348
2353
|
let t = this.getDisplayData();
|
|
2349
2354
|
if (t.length === 0 || !Number.isFinite(e)) return -1;
|
|
2350
|
-
let n = Math.max(0, Math.min(t.length - 1, Math.floor(
|
|
2355
|
+
let n = Math.max(0, Math.min(t.length - 1, Math.floor(j(e, t)))), r = this.viewport.getState(), i = n * (r.barWidth + r.barSpacing) + r.barWidth / 2 - r.chartRect.width / 2;
|
|
2351
2356
|
return this.viewport.scrollBy(i - r.offset), this.updateViewportAndRender(), n;
|
|
2352
2357
|
}
|
|
2353
2358
|
setVisibleRangePreset(e) {
|
|
2354
2359
|
let t = this.getDisplayData();
|
|
2355
2360
|
if (t.length === 0) return;
|
|
2356
|
-
let n = t.length - 1, r = t[n].time >
|
|
2361
|
+
let n = t.length - 1, r = t[n].time > xn ? 1 : 1e3, i = vt(e, t[n].time * r, this.displayTz), a = i === null ? null : i / r;
|
|
2357
2362
|
if (a === null || a < t[0].time) {
|
|
2358
2363
|
this.fitContent();
|
|
2359
2364
|
return;
|
|
2360
2365
|
}
|
|
2361
|
-
let o =
|
|
2366
|
+
let o = j(a, t), s = Math.min(n, e === "YTD" ? Math.ceil(o) : Math.floor(o) + 1);
|
|
2362
2367
|
this.viewport.zoomToBarRange(s, n + this.viewport.getRightMargin()), this.viewport.scrollToEnd(), this.updateViewportAndRender();
|
|
2363
2368
|
}
|
|
2364
2369
|
scrollToEnd() {
|
|
@@ -2372,7 +2377,7 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
|
|
|
2372
2377
|
setVisibleRange(e, t) {
|
|
2373
2378
|
let n = this.dataManager.getData();
|
|
2374
2379
|
if (n.length === 0) return;
|
|
2375
|
-
let r =
|
|
2380
|
+
let r = j(Math.min(e, t), n), i = j(Math.max(e, t), n);
|
|
2376
2381
|
this.viewport.zoomToBarRange(r, i), this.updateViewportAndRender();
|
|
2377
2382
|
}
|
|
2378
2383
|
setPanLimits(e) {
|
|
@@ -2433,7 +2438,7 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
|
|
|
2433
2438
|
e ? this.crosshairHandler.onPointerMove(e) : this.crosshairHandler.onPointerLeave(), this.engine.requestRender(r.Hover);
|
|
2434
2439
|
}
|
|
2435
2440
|
setCrosshairTime(e) {
|
|
2436
|
-
let t = this.getDisplayData(), n = e === null || t.length === 0 ? null : Math.floor(
|
|
2441
|
+
let t = this.getDisplayData(), n = e === null || t.length === 0 ? null : Math.floor(j(e, t));
|
|
2437
2442
|
n !== this.crosshairHandler.getSyncedSlot() && (this.crosshairHandler.setSyncedSlot(n), this.engine.requestRender(r.Hover));
|
|
2438
2443
|
}
|
|
2439
2444
|
getData() {
|
|
@@ -2478,9 +2483,9 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
|
|
|
2478
2483
|
setDepthHeatmapConfig(e) {
|
|
2479
2484
|
e.opacity !== void 0 && this.depthHeatmap.setOpacity(e.opacity), e.capacity !== void 0 && this.depthHeatmap.setCapacity(e.capacity), this.engine.requestRender(r.Main);
|
|
2480
2485
|
}
|
|
2481
|
-
pushDepthSnapshot(e) {
|
|
2482
|
-
let
|
|
2483
|
-
|
|
2486
|
+
pushDepthSnapshot(e, t) {
|
|
2487
|
+
let n = this.dataManager.getData(), i = t ?? n[n.length - 1]?.time;
|
|
2488
|
+
i === void 0 || !Number.isFinite(i) || (this.depthHeatmap.push(i, e), this.depthHeatmap.isVisible() && this.engine.requestRender(r.Main));
|
|
2484
2489
|
}
|
|
2485
2490
|
clearDepthHeatmap() {
|
|
2486
2491
|
this.depthHeatmap.clear(), this.engine.requestRender(r.Main);
|
|
@@ -2495,7 +2500,7 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
|
|
|
2495
2500
|
this.periodLevels.setPeriod(e), this.engine.requestRender(r.Main);
|
|
2496
2501
|
}
|
|
2497
2502
|
setTimezone(e) {
|
|
2498
|
-
|
|
2503
|
+
Cn(e), this.timezoneSetting = e, this.applyTimezone();
|
|
2499
2504
|
}
|
|
2500
2505
|
getTimezone() {
|
|
2501
2506
|
return this.timezoneSetting;
|
|
@@ -2558,7 +2563,7 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
|
|
|
2558
2563
|
return this.sessionShading.isVisible();
|
|
2559
2564
|
}
|
|
2560
2565
|
setSessionShadingConfig(e) {
|
|
2561
|
-
this.hostSessionHours =
|
|
2566
|
+
this.hostSessionHours = _t(this.hostSessionHours, e), this.sessionShading.replaceConfig(this.hostSessionHours), this.engine.requestRender(r.Background);
|
|
2562
2567
|
}
|
|
2563
2568
|
setTooltipVisible(e) {
|
|
2564
2569
|
e || this.crosshairTooltip.hide();
|
|
@@ -2574,10 +2579,14 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
|
|
|
2574
2579
|
}
|
|
2575
2580
|
async setRenderer(e) {
|
|
2576
2581
|
let t = ++this.rendererToken;
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2582
|
+
return this.waitForGpu(null), e === "canvas" ? (this.applyRenderer(null), "canvas") : this.engine.getGpu() ? "webgl" : this.takeGpu(e, t, !0);
|
|
2583
|
+
}
|
|
2584
|
+
async takeGpu(e, t, n) {
|
|
2585
|
+
let { gpu: r, reason: i } = await gt(e);
|
|
2586
|
+
return t !== this.rendererToken || this.disposed ? (r?.destroy(), this.getRenderer()) : i === "limit" ? mt() > 0 ? this.takeGpu(e, t, n) : (this.waitForGpu(() => void this.takeGpu(e, t, !1)), n && this.applyRenderer(null, "limit"), this.getRenderer()) : ((r || n) && this.applyRenderer(r, i), this.getRenderer());
|
|
2587
|
+
}
|
|
2588
|
+
waitForGpu(e) {
|
|
2589
|
+
this.stopWaitingForGpu?.(), this.stopWaitingForGpu = e ? Et(e) : null;
|
|
2581
2590
|
}
|
|
2582
2591
|
getRenderer() {
|
|
2583
2592
|
return this.engine.getGpu() ? "webgl" : "canvas";
|
|
@@ -2595,23 +2604,23 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
|
|
|
2595
2604
|
this.engine.getGpu() && this.engine.renderNow();
|
|
2596
2605
|
}
|
|
2597
2606
|
screenshot(e) {
|
|
2598
|
-
this.features.screenshot && (this.freshFrame(),
|
|
2607
|
+
this.features.screenshot && (this.freshFrame(), D.download(this.container, e, this.themeManager.getTheme().background));
|
|
2599
2608
|
}
|
|
2600
2609
|
async copyScreenshot() {
|
|
2601
2610
|
if (!this.features.screenshot) return !1;
|
|
2602
2611
|
try {
|
|
2603
2612
|
this.freshFrame();
|
|
2604
|
-
let e = await
|
|
2613
|
+
let e = await D.toBlob(this.container, this.themeManager.getTheme().background), t = globalThis.ClipboardItem;
|
|
2605
2614
|
return !e || !navigator.clipboard?.write || !t ? !1 : (await navigator.clipboard.write([new t({ "image/png": e })]), !0);
|
|
2606
2615
|
} catch {
|
|
2607
2616
|
return !1;
|
|
2608
2617
|
}
|
|
2609
2618
|
}
|
|
2610
2619
|
screenshotDataURL() {
|
|
2611
|
-
return this.features.screenshot ? (this.freshFrame(),
|
|
2620
|
+
return this.features.screenshot ? (this.freshFrame(), D.toDataURL(this.container, this.themeManager.getTheme().background)) : null;
|
|
2612
2621
|
}
|
|
2613
2622
|
async screenshotBlob() {
|
|
2614
|
-
return this.features.screenshot ? (this.freshFrame(),
|
|
2623
|
+
return this.features.screenshot ? (this.freshFrame(), D.toBlob(this.container, this.themeManager.getTheme().background)) : null;
|
|
2615
2624
|
}
|
|
2616
2625
|
addAlert(e, t = "crossing", n, r = "price", i, a = {}) {
|
|
2617
2626
|
if (!this.features.alerts) return null;
|
|
@@ -2737,27 +2746,27 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
|
|
|
2737
2746
|
if (!this.features.replay) return;
|
|
2738
2747
|
if (this.history.reset(), !this.replaySession) {
|
|
2739
2748
|
if (this.dataManager.getLength() === 0) return;
|
|
2740
|
-
let e = new
|
|
2749
|
+
let e = new B();
|
|
2741
2750
|
e.setData(this.fullSeries ?? this.dataManager.getData()), this.replaySession = {
|
|
2742
2751
|
live: e,
|
|
2743
2752
|
price: null,
|
|
2744
2753
|
fedTime: null
|
|
2745
2754
|
};
|
|
2746
2755
|
}
|
|
2747
|
-
let t = this.shownBars(this.replaySession.live.getData()), { steps: n, ...r } = e ?? {}, i = n ?
|
|
2756
|
+
let t = this.shownBars(this.replaySession.live.getData()), { steps: n, ...r } = e ?? {}, i = n ? Rn(n, t) : null;
|
|
2748
2757
|
this.replayStepsSeries = i, this.replayCoarse = t, this.options.autoScale = !0, this.replayRestarting = !0;
|
|
2749
2758
|
try {
|
|
2750
2759
|
this.replayManager.load(i ?? t);
|
|
2751
2760
|
} finally {
|
|
2752
2761
|
this.replayRestarting = !1;
|
|
2753
2762
|
}
|
|
2754
|
-
i && r.startIndex !== void 0 && (r.startIndex =
|
|
2763
|
+
i && r.startIndex !== void 0 && (r.startIndex = Vn(i, t, r.startIndex)), this.replayBarUnsub?.();
|
|
2755
2764
|
let a = -1, o = -1, s = null, c = i ?? t;
|
|
2756
2765
|
this.replayBarUnsub = this.replayManager.on("bar", ({ index: e }) => {
|
|
2757
2766
|
let n = e, r = t[e];
|
|
2758
2767
|
if (i) {
|
|
2759
2768
|
let c = i[e];
|
|
2760
|
-
n =
|
|
2769
|
+
n = Bn(t, c.time), s = s !== null && o === e - 1 && n === a - 1 && s ? Un(s, c) : Hn(t[n], i, e), r = s;
|
|
2761
2770
|
}
|
|
2762
2771
|
o = e;
|
|
2763
2772
|
let l = n + 1, u = a > 0 && l >= a && this.dataManager.getLength() === a, d = !(u && !this.replaySeeking) || this.autoScrollOnNewBar && this.viewport.isAtEnd();
|
|
@@ -2802,20 +2811,20 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
|
|
|
2802
2811
|
return;
|
|
2803
2812
|
}
|
|
2804
2813
|
if (i.time <= n.fedTime) return;
|
|
2805
|
-
let a = e.slice(
|
|
2814
|
+
let a = e.slice(Fn(e, n.fedTime), t + 1);
|
|
2806
2815
|
n.fedTime = i.time;
|
|
2807
|
-
let o = Math.ceil(a.length /
|
|
2808
|
-
for (let e = 0; e < a.length; e += o) for (let [t, n] of
|
|
2816
|
+
let o = Math.ceil(a.length / Pn);
|
|
2817
|
+
for (let e = 0; e < a.length; e += o) for (let [t, n] of In(a.slice(e, e + o))) r.setMarkPrice(t, n);
|
|
2809
2818
|
this.tradingManager.setCurrentPrice(i.close);
|
|
2810
2819
|
}
|
|
2811
2820
|
getReplayBarIndex() {
|
|
2812
2821
|
if (!this.replaySession) return -1;
|
|
2813
2822
|
let { current: e } = this.replayManager.getProgress(), t = this.replayStepsSeries;
|
|
2814
|
-
return t && this.replayCoarse ?
|
|
2823
|
+
return t && this.replayCoarse ? Bn(this.replayCoarse, t[e]?.time ?? -Infinity) : e;
|
|
2815
2824
|
}
|
|
2816
2825
|
replaySeekToBar(e) {
|
|
2817
2826
|
let t = this.replayStepsSeries;
|
|
2818
|
-
this.replaySeek(t && this.replayCoarse ?
|
|
2827
|
+
this.replaySeek(t && this.replayCoarse ? Vn(t, this.replayCoarse, e) : e);
|
|
2819
2828
|
}
|
|
2820
2829
|
replayPause() {
|
|
2821
2830
|
this.replayManager.pause();
|
|
@@ -2860,7 +2869,7 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
|
|
|
2860
2869
|
return this.replayManager.getProgress();
|
|
2861
2870
|
}
|
|
2862
2871
|
captureSnapshot() {
|
|
2863
|
-
return
|
|
2872
|
+
return x.capture({
|
|
2864
2873
|
getDrawings: () => this.getDrawings(),
|
|
2865
2874
|
getTheme: () => this.getTheme(),
|
|
2866
2875
|
getAlerts: () => this.getAlerts(),
|
|
@@ -2872,14 +2881,14 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
|
|
|
2872
2881
|
});
|
|
2873
2882
|
}
|
|
2874
2883
|
restoreIndicators(e, t) {
|
|
2875
|
-
let n =
|
|
2884
|
+
let n = An(e), r = /* @__PURE__ */ new Map();
|
|
2876
2885
|
this.unrestoredIndicators = [];
|
|
2877
2886
|
let i = new Set(this.indicatorEngine.getAvailableIndicators().map((e) => e.id)), a = [], o = /* @__PURE__ */ new Set();
|
|
2878
2887
|
if (t) {
|
|
2879
2888
|
let e = new Map(n.map((e) => [e.instanceId, e])), t = this.getIndicatorSetup();
|
|
2880
2889
|
for (let n of t) {
|
|
2881
2890
|
let t = e.get(n.instanceId);
|
|
2882
|
-
t &&
|
|
2891
|
+
t && jn(n, t) && o.add(n.instanceId);
|
|
2883
2892
|
}
|
|
2884
2893
|
for (let e of t) o.has(e.instanceId) || this.removeIndicator(e.instanceId);
|
|
2885
2894
|
for (let e of [...o]) this.indicatorEngine.getIndicatorConfig(e) || o.delete(e);
|
|
@@ -3015,7 +3024,7 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
|
|
|
3015
3024
|
if (this.indicatorHistoryDepth > 0 || !this.features.drawingUndoRedo) return t();
|
|
3016
3025
|
let n = this.getIndicatorSetup(), r = this.withoutIndicatorHistory(t), i = this.getIndicatorSetup();
|
|
3017
3026
|
if (JSON.stringify(n) === JSON.stringify(i)) return r;
|
|
3018
|
-
let a = performance.now(), o = this.undoRedoManager.last(), s = e !== void 0 && o?.type === "indicators" && o.indicators?.subject === e && a - (o.indicators.at ?? 0) <
|
|
3027
|
+
let a = performance.now(), o = this.undoRedoManager.last(), s = e !== void 0 && o?.type === "indicators" && o.indicators?.subject === e && a - (o.indicators.at ?? 0) < En && JSON.stringify(o.indicators.after) === JSON.stringify(n), c = {
|
|
3019
3028
|
type: "indicators",
|
|
3020
3029
|
before: null,
|
|
3021
3030
|
after: null
|
|
@@ -3043,12 +3052,12 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
|
|
|
3043
3052
|
}
|
|
3044
3053
|
saveState(e) {
|
|
3045
3054
|
if (!this.features.saveLoad) return null;
|
|
3046
|
-
let t = this.captureSnapshot(), n =
|
|
3047
|
-
return e &&
|
|
3055
|
+
let t = this.captureSnapshot(), n = x.serialize(t);
|
|
3056
|
+
return e && x.saveToStorage(e, t), n;
|
|
3048
3057
|
}
|
|
3049
3058
|
loadState(e) {
|
|
3050
3059
|
if (!this.features.saveLoad) return;
|
|
3051
|
-
let t =
|
|
3060
|
+
let t = x.deserialize(e);
|
|
3052
3061
|
this.chartTypeOptions = t.chartTypeOptions ?? {}, this.displayDataCache = null, t.chartType && this.setChartType(t.chartType), t.drawings && this.setDrawings(t.drawings), t.theme && this.setTheme(t.theme);
|
|
3053
3062
|
let n = t.version >= 2 && this.features.indicators ? this.withoutIndicatorHistory(() => this.restoreIndicators(t.indicators, !1)) : /* @__PURE__ */ new Map();
|
|
3054
3063
|
if (this.undoRedoManager.clear(), t.alerts && this.features.alerts) {
|
|
@@ -3059,7 +3068,7 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
|
|
|
3059
3068
|
let t = e.indexOf(":"), r = t > 0 ? n.get(e.slice(0, t)) : void 0;
|
|
3060
3069
|
return r ? r + e.slice(t) : e;
|
|
3061
3070
|
}, r = t(e.channel), i = {
|
|
3062
|
-
...
|
|
3071
|
+
...yt(e),
|
|
3063
3072
|
...e.target ? { target: t(e.target) } : {}
|
|
3064
3073
|
};
|
|
3065
3074
|
if (!e.expired) {
|
|
@@ -3079,16 +3088,16 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
|
|
|
3079
3088
|
}
|
|
3080
3089
|
loadStateFromStorage(e) {
|
|
3081
3090
|
if (!this.features.saveLoad) return !1;
|
|
3082
|
-
let t =
|
|
3083
|
-
return t ? (this.loadState(
|
|
3091
|
+
let t = x.loadFromStorage(e);
|
|
3092
|
+
return t ? (this.loadState(x.serialize(t)), !0) : !1;
|
|
3084
3093
|
}
|
|
3085
3094
|
downloadState(e) {
|
|
3086
|
-
this.features.saveLoad &&
|
|
3095
|
+
this.features.saveLoad && x.downloadFile(this.captureSnapshot(), e);
|
|
3087
3096
|
}
|
|
3088
3097
|
async loadStateFromFile() {
|
|
3089
3098
|
if (!this.features.saveLoad) return;
|
|
3090
|
-
let e = await
|
|
3091
|
-
this.loadState(
|
|
3099
|
+
let e = await x.loadFromFile();
|
|
3100
|
+
this.loadState(x.serialize(e));
|
|
3092
3101
|
}
|
|
3093
3102
|
setLocale(e) {
|
|
3094
3103
|
ee(e), this.engine.requestRender();
|
|
@@ -3107,15 +3116,15 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
|
|
|
3107
3116
|
candleDown: e.colorScheme.down,
|
|
3108
3117
|
candleUpWick: e.colorScheme.up,
|
|
3109
3118
|
candleDownWick: e.colorScheme.down,
|
|
3110
|
-
volumeUp:
|
|
3111
|
-
volumeDown:
|
|
3119
|
+
volumeUp: b(e.colorScheme.up),
|
|
3120
|
+
volumeDown: b(e.colorScheme.down)
|
|
3112
3121
|
};
|
|
3113
3122
|
this.themeManager.setTheme(t);
|
|
3114
3123
|
}
|
|
3115
3124
|
e.pricePrecision !== void 0 && this.applyPricePrecision(e.pricePrecision), this.updateViewportAndRender();
|
|
3116
3125
|
}
|
|
3117
3126
|
applyPricePrecision(e) {
|
|
3118
|
-
this.marketPricePrecision = e, this.tradingManager.setConfig({ pricePrecision: e ?? void 0 }), this.alertManager.setPricePrecision(e ??
|
|
3127
|
+
this.marketPricePrecision = e, this.tradingManager.setConfig({ pricePrecision: e ?? void 0 }), this.alertManager.setPricePrecision(e ?? wn), this.streamManager?.priceLine.setPricePrecision(e), this.currentPriceLine.setPricePrecision(e), this.crosshairHandler.setPricePrecision(e), this.chartLegend.setPricePrecision(e), this.crosshairTooltip.setPricePrecision(e);
|
|
3119
3128
|
}
|
|
3120
3129
|
getMarket() {
|
|
3121
3130
|
return this.marketConfig;
|
|
@@ -3142,18 +3151,18 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
|
|
|
3142
3151
|
this.viewport.resize(e.width, e.height), this.layoutManager.resize(e.width, e.height), this.updateViewportAndRender(n), this.eventBus.emit("resize", e);
|
|
3143
3152
|
}
|
|
3144
3153
|
destroy() {
|
|
3145
|
-
this.disposed = !0, this.countdownInterval && clearInterval(this.countdownInterval), this.history.setLoader(null), this.disableAutoSave(), this.disconnectStream(), this.disconnectExecution(), this.onWindowKeyDown &&= (window.removeEventListener("keydown", this.onWindowKeyDown), null), this.keyboardHandler = null, this.a11y?.destroy(), this.a11y = null, this.interactionManager.detach(), this.tradingManager.destroy(), this.animator.dispose(), this.crosshairTooltip.destroy(), this.pinnedTooltip.destroy(), this.replayRestarting = !0, this.replayManager.dispose(), this.alertManager.dispose(), this.undoRedoManager.clear(), this.engine.destroy(), this.eventBus.destroy(), this.container.innerHTML = "";
|
|
3154
|
+
this.disposed = !0, this.waitForGpu(null), this.countdownInterval && clearInterval(this.countdownInterval), this.history.setLoader(null), this.disableAutoSave(), this.disconnectStream(), this.disconnectExecution(), this.onWindowKeyDown &&= (window.removeEventListener("keydown", this.onWindowKeyDown), null), this.keyboardHandler = null, this.a11y?.destroy(), this.a11y = null, this.interactionManager.detach(), this.tradingManager.destroy(), this.animator.dispose(), this.crosshairTooltip.destroy(), this.pinnedTooltip.destroy(), this.replayRestarting = !0, this.replayManager.dispose(), this.alertManager.dispose(), this.undoRedoManager.clear(), this.engine.destroy(), this.eventBus.destroy(), this.container.innerHTML = "";
|
|
3146
3155
|
}
|
|
3147
3156
|
createChartRenderer(e) {
|
|
3148
|
-
let t =
|
|
3149
|
-
return t instanceof
|
|
3157
|
+
let t = Wt(e, (e) => this.pluginManager.getChartType(e));
|
|
3158
|
+
return t instanceof C && t.setPriceText((e) => this.formatPrice(e)), t;
|
|
3150
3159
|
}
|
|
3151
3160
|
getDisplayData() {
|
|
3152
3161
|
if (this.displayDataCache) return this.displayDataCache;
|
|
3153
3162
|
let e = this.dataManager.getData();
|
|
3154
3163
|
if (e.length === 0) return e;
|
|
3155
|
-
let t =
|
|
3156
|
-
return this.displayDataCache = t, t;
|
|
3164
|
+
let t = Gt(this.options.chartType, e, (e) => this.pluginManager.getChartType(e), this.chartTypeOptions);
|
|
3165
|
+
return this.chartRenderer instanceof T && !this.pluginManager.getChartType(this.options.chartType) && this.chartRenderer.setBoxSize(Ht(e, this.chartTypeOptions)), this.displayDataCache = t, t;
|
|
3157
3166
|
}
|
|
3158
3167
|
recalcIndicatorsFrom(e, t) {
|
|
3159
3168
|
this.indicatorEngine.recalculateFrom(e, t), this.announceIndicatorUpdate(t);
|
|
@@ -3185,7 +3194,7 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
|
|
|
3185
3194
|
this.viewport.setScaleBaseline(t[e]?.close);
|
|
3186
3195
|
}
|
|
3187
3196
|
if (n) {
|
|
3188
|
-
let e =
|
|
3197
|
+
let e = Nn(this.indicatorEngine.getOverlayPriceRange(r.visibleRange.from, Math.min(r.visibleRange.to, t.length - 1)), this.features.compareSymbols ? this.compareRenderer.getPriceRange(t, r) : null);
|
|
3189
3198
|
if (e) {
|
|
3190
3199
|
let t = r.priceRange, n = Math.min(t.min, e.min), i = Math.max(t.max, e.max);
|
|
3191
3200
|
if (n < t.min || i > t.max) {
|
|
@@ -3209,7 +3218,7 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
|
|
|
3209
3218
|
fitLeftAxisWidth() {
|
|
3210
3219
|
let e = this.leftViewport;
|
|
3211
3220
|
if (!e) return !1;
|
|
3212
|
-
let t = this.themeManager.getTheme(), n =
|
|
3221
|
+
let t = this.themeManager.getTheme(), n = sn({
|
|
3213
3222
|
min: e.priceRange.min,
|
|
3214
3223
|
max: e.priceRange.max,
|
|
3215
3224
|
lastPrice: null,
|
|
@@ -3218,12 +3227,12 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
|
|
|
3218
3227
|
fontFamily: t.font.family,
|
|
3219
3228
|
fontSizeSmall: t.font.sizeSmall,
|
|
3220
3229
|
measure: (e, t) => this.measureText(e, t)
|
|
3221
|
-
}), r =
|
|
3230
|
+
}), r = cn(this.leftAxisWidth, n);
|
|
3222
3231
|
return r === this.leftAxisWidth ? !1 : (this.leftAxisWidth = r, this.layoutManager.setLeftAxisWidth(r), this.resolvedLayoutCache = null, this.panelInfoCache = null, this.viewport.setChartRect(this.getResolvedLayout().mainChartRect), !0);
|
|
3223
3232
|
}
|
|
3224
3233
|
fitPriceAxisWidth() {
|
|
3225
3234
|
if (!this.features.priceAxis) return !1;
|
|
3226
|
-
let { priceRange: e } = this.viewport.getState(), t = this.themeManager.getTheme(), n =
|
|
3235
|
+
let { priceRange: e } = this.viewport.getState(), t = this.themeManager.getTheme(), n = sn({
|
|
3227
3236
|
min: e.min,
|
|
3228
3237
|
max: e.max,
|
|
3229
3238
|
lastPrice: this.currentPriceLine.getPrice(),
|
|
@@ -3233,7 +3242,7 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
|
|
|
3233
3242
|
fontFamily: t.font.family,
|
|
3234
3243
|
fontSizeSmall: t.font.sizeSmall,
|
|
3235
3244
|
measure: (e, t) => this.measureText(e, t)
|
|
3236
|
-
}), r =
|
|
3245
|
+
}), r = cn(this.priceAxisWidth, n);
|
|
3237
3246
|
return r === this.priceAxisWidth ? !1 : (this.priceAxisWidth = r, this.layoutManager.setPriceAxisWidth(r), this.viewport.setPriceAxisWidth(r), this.resolvedLayoutCache = null, this.panelInfoCache = null, this.viewport.setChartRect(this.getResolvedLayout().mainChartRect), !0);
|
|
3238
3247
|
}
|
|
3239
3248
|
measureText(e, t) {
|
|
@@ -3277,7 +3286,7 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
|
|
|
3277
3286
|
buildPanelRenderInfos() {
|
|
3278
3287
|
if (this.panelInfoCache) return this.panelInfoCache;
|
|
3279
3288
|
let e = this.getResolvedLayout(), t = this.viewport.getState(), { from: n, to: r } = t.visibleRange, i = e.panels.map((e) => {
|
|
3280
|
-
let i = e.config.logScale ? this.indicatorEngine.getPaneValueRange(e.config.id, n, r, !0) : null, a = i ?? this.indicatorEngine.getPaneValueRange(e.config.id, n, r) ?? { ...
|
|
3289
|
+
let i = e.config.logScale ? this.indicatorEngine.getPaneValueRange(e.config.id, n, r, !0) : null, a = i ?? this.indicatorEngine.getPaneValueRange(e.config.id, n, r) ?? { ...bn }, o = {
|
|
3281
3290
|
x: e.rect.x,
|
|
3282
3291
|
y: e.rect.y + 20,
|
|
3283
3292
|
width: e.rect.width,
|
|
@@ -3358,7 +3367,7 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
|
|
|
3358
3367
|
});
|
|
3359
3368
|
}
|
|
3360
3369
|
drawOverlayPlugins(e, t) {
|
|
3361
|
-
let n =
|
|
3370
|
+
let n = dn(this.pluginManager.getOverlays(), t);
|
|
3362
3371
|
if (n.length === 0) return;
|
|
3363
3372
|
let r = {
|
|
3364
3373
|
viewport: this.viewport.getState(),
|
|
@@ -3380,7 +3389,7 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
|
|
|
3380
3389
|
} : null;
|
|
3381
3390
|
}
|
|
3382
3391
|
};
|
|
3383
|
-
function
|
|
3392
|
+
function An(e) {
|
|
3384
3393
|
let t = new Map(e.map((e) => [e.instanceId, e])), n = [], r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), a = (e) => {
|
|
3385
3394
|
if (r.has(e.instanceId) || i.has(e.instanceId)) return;
|
|
3386
3395
|
i.add(e.instanceId);
|
|
@@ -3394,15 +3403,20 @@ function Tn(e) {
|
|
|
3394
3403
|
for (let t of e) a(t);
|
|
3395
3404
|
return n;
|
|
3396
3405
|
}
|
|
3397
|
-
function
|
|
3406
|
+
function jn(e, t) {
|
|
3398
3407
|
return e.id === t.id && (e.pane ?? null) === (t.pane ?? null) && (e.scale ?? null) === (t.scale ?? null) && e.position === void 0 == (t.position === void 0);
|
|
3399
3408
|
}
|
|
3400
|
-
function
|
|
3409
|
+
function Mn(e) {
|
|
3401
3410
|
let t = e.tagRadius;
|
|
3402
3411
|
return typeof t == "number" && Number.isFinite(t) && t >= 0 ? { tagRadius: Math.min(t, 999) } : {};
|
|
3403
3412
|
}
|
|
3404
|
-
var W = new Set([
|
|
3405
|
-
|
|
3413
|
+
var W = new Set([
|
|
3414
|
+
"compareSymbol",
|
|
3415
|
+
"spread",
|
|
3416
|
+
"correlation",
|
|
3417
|
+
"correlationlog"
|
|
3418
|
+
]);
|
|
3419
|
+
function Nn(e, t) {
|
|
3406
3420
|
return e ? t ? {
|
|
3407
3421
|
min: Math.min(e.min, t.min),
|
|
3408
3422
|
max: Math.max(e.max, t.max)
|
|
@@ -3423,8 +3437,8 @@ function G(e) {
|
|
|
3423
3437
|
bars: e.bars
|
|
3424
3438
|
};
|
|
3425
3439
|
}
|
|
3426
|
-
var
|
|
3427
|
-
function
|
|
3440
|
+
var Pn = 500;
|
|
3441
|
+
function Fn(e, t) {
|
|
3428
3442
|
let n = 0, r = e.length;
|
|
3429
3443
|
for (; n < r;) {
|
|
3430
3444
|
let i = n + r >> 1;
|
|
@@ -3432,20 +3446,20 @@ function An(e, t) {
|
|
|
3432
3446
|
}
|
|
3433
3447
|
return n;
|
|
3434
3448
|
}
|
|
3435
|
-
function
|
|
3449
|
+
function In(e) {
|
|
3436
3450
|
let t = 0, n = 0;
|
|
3437
3451
|
for (let r = 1; r < e.length; r++) e[r].low < e[t].low && (t = r), e[r].high > e[n].high && (n = r);
|
|
3438
3452
|
let r = [e[t].low, e[t].time], i = [e[n].high, e[n].time], a = t === n ? e[t].close >= e[t].open : t < n, o = e[e.length - 1];
|
|
3439
3453
|
return [...a ? [r, i] : [i, r], [o.close, o.time]];
|
|
3440
3454
|
}
|
|
3441
|
-
function
|
|
3455
|
+
function Ln(e) {
|
|
3442
3456
|
let t = 0;
|
|
3443
3457
|
for (let n = Math.max(1, e.length - 10); n < e.length; n++) t = Math.max(t, e[n].time - e[n - 1].time);
|
|
3444
3458
|
return t > 0 ? t : Infinity;
|
|
3445
3459
|
}
|
|
3446
|
-
function
|
|
3460
|
+
function Rn(e, t) {
|
|
3447
3461
|
if (t.length === 0) return null;
|
|
3448
|
-
let n = t[t.length - 1].time +
|
|
3462
|
+
let n = t[t.length - 1].time + Ln(t), r = e.filter((e) => zn(e) && e.time >= t[0].time && e.time < n).sort((e, t) => e.time - t.time), i = [];
|
|
3449
3463
|
for (let e of r) (i.length === 0 || i[i.length - 1].time !== e.time) && i.push(e);
|
|
3450
3464
|
if (i.length === 0) return null;
|
|
3451
3465
|
let a = t.findIndex((e) => e.time >= i[0].time);
|
|
@@ -3453,7 +3467,7 @@ function Nn(e, t) {
|
|
|
3453
3467
|
let o = t.slice(0, a), s = i.filter((e) => e.time >= t[a].time);
|
|
3454
3468
|
return [...o, ...s];
|
|
3455
3469
|
}
|
|
3456
|
-
function
|
|
3470
|
+
function zn(e) {
|
|
3457
3471
|
return [
|
|
3458
3472
|
e.time,
|
|
3459
3473
|
e.open,
|
|
@@ -3462,7 +3476,7 @@ function Pn(e) {
|
|
|
3462
3476
|
e.close
|
|
3463
3477
|
].every(Number.isFinite);
|
|
3464
3478
|
}
|
|
3465
|
-
function
|
|
3479
|
+
function Bn(e, t) {
|
|
3466
3480
|
let n = 0, r = e.length - 1;
|
|
3467
3481
|
for (; n < r;) {
|
|
3468
3482
|
let i = n + r + 1 >> 1;
|
|
@@ -3470,22 +3484,22 @@ function Fn(e, t) {
|
|
|
3470
3484
|
}
|
|
3471
3485
|
return n;
|
|
3472
3486
|
}
|
|
3473
|
-
function
|
|
3487
|
+
function Vn(e, t, n) {
|
|
3474
3488
|
let r = Math.max(0, Math.min(Math.floor(Number.isFinite(n) ? n : 0), t.length - 1)), i = r + 1 < t.length ? t[r + 1].time : Infinity, a = -1;
|
|
3475
3489
|
for (let t = 0; t < e.length && e[t].time < i; t++) a = t;
|
|
3476
3490
|
return Math.max(0, a);
|
|
3477
3491
|
}
|
|
3478
|
-
function
|
|
3492
|
+
function Hn(e, t, n) {
|
|
3479
3493
|
let r = n;
|
|
3480
3494
|
for (; r > 0 && t[r - 1].time >= e.time;) r--;
|
|
3481
3495
|
let i = {
|
|
3482
3496
|
...t[r],
|
|
3483
3497
|
time: e.time
|
|
3484
3498
|
};
|
|
3485
|
-
for (let e = r + 1; e <= n; e++) i =
|
|
3499
|
+
for (let e = r + 1; e <= n; e++) i = Un(i, t[e]);
|
|
3486
3500
|
return i;
|
|
3487
3501
|
}
|
|
3488
|
-
function
|
|
3502
|
+
function Un(e, t) {
|
|
3489
3503
|
return {
|
|
3490
3504
|
time: e.time,
|
|
3491
3505
|
open: e.open,
|
|
@@ -3503,26 +3517,26 @@ function K(e, t) {
|
|
|
3503
3517
|
}
|
|
3504
3518
|
//#endregion
|
|
3505
3519
|
//#region src/io/parseOHLCV.ts
|
|
3506
|
-
var
|
|
3520
|
+
var Wn = [
|
|
3507
3521
|
"time",
|
|
3508
3522
|
"timestamp",
|
|
3509
3523
|
"date",
|
|
3510
3524
|
"datetime",
|
|
3511
3525
|
"t"
|
|
3512
|
-
],
|
|
3526
|
+
], Gn = ["open", "o"], Kn = ["high", "h"], qn = ["low", "l"], Jn = ["close", "c"], Yn = [
|
|
3513
3527
|
"volume",
|
|
3514
3528
|
"vol",
|
|
3515
3529
|
"v"
|
|
3516
3530
|
];
|
|
3517
|
-
function
|
|
3531
|
+
function Xn(e) {
|
|
3518
3532
|
let t = e.trim();
|
|
3519
|
-
return t ? t[0] === "[" || t[0] === "{" ?
|
|
3533
|
+
return t ? t[0] === "[" || t[0] === "{" ? Zn(t) : Qn(t) : {
|
|
3520
3534
|
data: [],
|
|
3521
3535
|
rowCount: 0,
|
|
3522
3536
|
skipped: 0
|
|
3523
3537
|
};
|
|
3524
3538
|
}
|
|
3525
|
-
function
|
|
3539
|
+
function Zn(e) {
|
|
3526
3540
|
let t;
|
|
3527
3541
|
try {
|
|
3528
3542
|
t = JSON.parse(e);
|
|
@@ -3532,19 +3546,19 @@ function Kn(e) {
|
|
|
3532
3546
|
if (!Array.isArray(t)) throw Error("Expected a JSON array of OHLCV rows");
|
|
3533
3547
|
let n = [], r = 0;
|
|
3534
3548
|
for (let e of t) {
|
|
3535
|
-
let t = Array.isArray(e) ?
|
|
3549
|
+
let t = Array.isArray(e) ? nr(e) : tr(e);
|
|
3536
3550
|
t ? n.push(t) : r++;
|
|
3537
3551
|
}
|
|
3538
|
-
return
|
|
3552
|
+
return rr(n, t.length, r);
|
|
3539
3553
|
}
|
|
3540
|
-
function
|
|
3554
|
+
function Qn(e) {
|
|
3541
3555
|
let t = e.split(/\r?\n/).filter((e) => e.trim().length > 0);
|
|
3542
3556
|
if (t.length === 0) return {
|
|
3543
3557
|
data: [],
|
|
3544
3558
|
rowCount: 0,
|
|
3545
3559
|
skipped: 0
|
|
3546
3560
|
};
|
|
3547
|
-
let n =
|
|
3561
|
+
let n = $n(t[0]), r = q(t[0], n).map((e) => e.trim().toLowerCase()), i = r.some((e) => isNaN(Number(e)) && e.length > 0), a = i ? er(r) : {
|
|
3548
3562
|
time: 0,
|
|
3549
3563
|
open: 1,
|
|
3550
3564
|
high: 2,
|
|
@@ -3555,7 +3569,7 @@ function qn(e) {
|
|
|
3555
3569
|
if (a.time < 0 || a.open < 0 || a.high < 0 || a.low < 0 || a.close < 0) throw Error("CSV is missing required column(s): time, open, high, low, close");
|
|
3556
3570
|
let o = [], s = 0;
|
|
3557
3571
|
for (let e = +!!i; e < t.length; e++) {
|
|
3558
|
-
let r =
|
|
3572
|
+
let r = q(t[e], n), i = Y(r[a.time]), c = J(r[a.open]), l = J(r[a.high]), u = J(r[a.low]), d = J(r[a.close]), f = a.volume >= 0 ? Number(r[a.volume]) : 0;
|
|
3559
3573
|
if (i === null || ![
|
|
3560
3574
|
c,
|
|
3561
3575
|
l,
|
|
@@ -3574,9 +3588,9 @@ function qn(e) {
|
|
|
3574
3588
|
volume: Number.isFinite(f) ? f : 0
|
|
3575
3589
|
});
|
|
3576
3590
|
}
|
|
3577
|
-
return
|
|
3591
|
+
return rr(o, t.length - +!!i, s);
|
|
3578
3592
|
}
|
|
3579
|
-
function
|
|
3593
|
+
function $n(e) {
|
|
3580
3594
|
let t = {
|
|
3581
3595
|
",": 0,
|
|
3582
3596
|
";": 0,
|
|
@@ -3588,7 +3602,7 @@ function Jn(e) {
|
|
|
3588
3602
|
for (let [e, i] of Object.entries(t)) i > r && (n = e, r = i);
|
|
3589
3603
|
return n;
|
|
3590
3604
|
}
|
|
3591
|
-
function
|
|
3605
|
+
function q(e, t) {
|
|
3592
3606
|
let n = [], r = "", i = !1;
|
|
3593
3607
|
for (let a = 0; a < e.length; a++) {
|
|
3594
3608
|
let o = e[a];
|
|
@@ -3596,25 +3610,25 @@ function Yn(e, t) {
|
|
|
3596
3610
|
}
|
|
3597
3611
|
return n.push(r), n;
|
|
3598
3612
|
}
|
|
3599
|
-
function
|
|
3613
|
+
function er(e) {
|
|
3600
3614
|
let t = (t) => e.findIndex((e) => t.includes(e));
|
|
3601
3615
|
return {
|
|
3602
|
-
time: t(
|
|
3603
|
-
open: t(
|
|
3604
|
-
high: t(
|
|
3605
|
-
low: t(
|
|
3606
|
-
close: t(
|
|
3607
|
-
volume: t(
|
|
3616
|
+
time: t(Wn),
|
|
3617
|
+
open: t(Gn),
|
|
3618
|
+
high: t(Kn),
|
|
3619
|
+
low: t(qn),
|
|
3620
|
+
close: t(Jn),
|
|
3621
|
+
volume: t(Yn)
|
|
3608
3622
|
};
|
|
3609
3623
|
}
|
|
3610
|
-
function
|
|
3624
|
+
function tr(e) {
|
|
3611
3625
|
let t = (t) => {
|
|
3612
3626
|
for (let n of t) {
|
|
3613
3627
|
if (e[n] !== void 0) return e[n];
|
|
3614
3628
|
let t = n.toUpperCase();
|
|
3615
3629
|
if (e[t] !== void 0) return e[t];
|
|
3616
3630
|
}
|
|
3617
|
-
}, n =
|
|
3631
|
+
}, n = Y(String(t(Wn) ?? "")), r = Number(t(Gn)), i = Number(t(Kn)), a = Number(t(qn)), o = Number(t(Jn)), s = Number(t(Yn) ?? 0);
|
|
3618
3632
|
return n === null || ![
|
|
3619
3633
|
r,
|
|
3620
3634
|
i,
|
|
@@ -3629,9 +3643,9 @@ function Zn(e) {
|
|
|
3629
3643
|
volume: Number.isFinite(s) ? s : 0
|
|
3630
3644
|
};
|
|
3631
3645
|
}
|
|
3632
|
-
function
|
|
3646
|
+
function nr(e) {
|
|
3633
3647
|
if (e.length < 5) return null;
|
|
3634
|
-
let t =
|
|
3648
|
+
let t = Y(String(e[0])), n = Number(e[1]), r = Number(e[2]), i = Number(e[3]), a = Number(e[4]), o = e.length >= 6 ? Number(e[5]) : 0;
|
|
3635
3649
|
return t === null || ![
|
|
3636
3650
|
n,
|
|
3637
3651
|
r,
|
|
@@ -3646,10 +3660,10 @@ function Qn(e) {
|
|
|
3646
3660
|
volume: Number.isFinite(o) ? o : 0
|
|
3647
3661
|
};
|
|
3648
3662
|
}
|
|
3649
|
-
function
|
|
3663
|
+
function J(e) {
|
|
3650
3664
|
return e === void 0 || e.trim() === "" ? NaN : Number(e);
|
|
3651
3665
|
}
|
|
3652
|
-
function
|
|
3666
|
+
function Y(e) {
|
|
3653
3667
|
let t = e.trim();
|
|
3654
3668
|
if (!t) return null;
|
|
3655
3669
|
let n = Number(t);
|
|
@@ -3657,7 +3671,7 @@ function J(e) {
|
|
|
3657
3671
|
let r = Date.parse(t);
|
|
3658
3672
|
return Number.isFinite(r) ? r : null;
|
|
3659
3673
|
}
|
|
3660
|
-
function
|
|
3674
|
+
function rr(e, t, n) {
|
|
3661
3675
|
e.sort((e, t) => e.time - t.time);
|
|
3662
3676
|
let r = [];
|
|
3663
3677
|
for (let t of e) r.length > 0 && r[r.length - 1].time === t.time ? r[r.length - 1] = t : r.push(t);
|
|
@@ -3669,7 +3683,7 @@ function Y(e, t, n) {
|
|
|
3669
3683
|
}
|
|
3670
3684
|
//#endregion
|
|
3671
3685
|
//#region src/io/DragDropImporter.ts
|
|
3672
|
-
var
|
|
3686
|
+
var ir = class {
|
|
3673
3687
|
host;
|
|
3674
3688
|
overlay = null;
|
|
3675
3689
|
callbacks;
|
|
@@ -3702,7 +3716,7 @@ var $n = class {
|
|
|
3702
3716
|
e.preventDefault(), this.depth = 0, this.hideOverlay();
|
|
3703
3717
|
let t = e.dataTransfer?.files?.[0];
|
|
3704
3718
|
if (t) try {
|
|
3705
|
-
let e =
|
|
3719
|
+
let e = Xn(await t.text());
|
|
3706
3720
|
if (e.data.length === 0) throw Error(`No valid OHLCV rows found in "${t.name}"`);
|
|
3707
3721
|
this.callbacks.onData(e.data, e, t);
|
|
3708
3722
|
} catch (e) {
|
|
@@ -3746,7 +3760,7 @@ function Z(e) {
|
|
|
3746
3760
|
};
|
|
3747
3761
|
return e.symbol !== void 0 && (t.symbol = e.symbol), e.timeframe !== void 0 && (t.timeframe = e.timeframe), e.kind !== void 0 && (t.kind = e.kind), t;
|
|
3748
3762
|
}
|
|
3749
|
-
var
|
|
3763
|
+
var ar = (e, t) => t.updatedAt - e.updatedAt;
|
|
3750
3764
|
function Q(e) {
|
|
3751
3765
|
if (typeof e != "object" || !e) return null;
|
|
3752
3766
|
let t = e;
|
|
@@ -3759,17 +3773,17 @@ function Q(e) {
|
|
|
3759
3773
|
kind: typeof t.kind == "string" ? t.kind : void 0
|
|
3760
3774
|
});
|
|
3761
3775
|
}
|
|
3762
|
-
function
|
|
3776
|
+
function or(e) {
|
|
3763
3777
|
let t = Q(e), n = t ? e.content : void 0;
|
|
3764
3778
|
return t && typeof n == "string" ? {
|
|
3765
3779
|
...t,
|
|
3766
3780
|
content: n
|
|
3767
3781
|
} : null;
|
|
3768
3782
|
}
|
|
3769
|
-
function
|
|
3783
|
+
function sr(e = []) {
|
|
3770
3784
|
let t = new Map(e.map((e) => [e.id, { ...e }]));
|
|
3771
3785
|
return {
|
|
3772
|
-
list: () => [...t.values()].map(Z).sort(
|
|
3786
|
+
list: () => [...t.values()].map(Z).sort(ar),
|
|
3773
3787
|
load: (e) => {
|
|
3774
3788
|
let n = t.get(e);
|
|
3775
3789
|
return n ? { ...n } : null;
|
|
@@ -3782,7 +3796,7 @@ function nr(e = []) {
|
|
|
3782
3796
|
}
|
|
3783
3797
|
};
|
|
3784
3798
|
}
|
|
3785
|
-
function
|
|
3799
|
+
function cr(e = "tcw:layouts:") {
|
|
3786
3800
|
let t = `${e}index`, n = (t) => `${e}item:${t}`, r = () => {
|
|
3787
3801
|
let e;
|
|
3788
3802
|
try {
|
|
@@ -3793,7 +3807,7 @@ function rr(e = "tcw:layouts:") {
|
|
|
3793
3807
|
return Array.isArray(e) ? e.map(Q).filter((e) => e !== null) : [];
|
|
3794
3808
|
}, i = (e) => localStorage.setItem(t, JSON.stringify(e));
|
|
3795
3809
|
return {
|
|
3796
|
-
list: () => r().sort(
|
|
3810
|
+
list: () => r().sort(ar),
|
|
3797
3811
|
load: (e) => {
|
|
3798
3812
|
let t = r().find((t) => t.id === e), i = t ? localStorage.getItem(n(e)) : null;
|
|
3799
3813
|
return t && i !== null ? {
|
|
@@ -3811,14 +3825,14 @@ function rr(e = "tcw:layouts:") {
|
|
|
3811
3825
|
}
|
|
3812
3826
|
//#endregion
|
|
3813
3827
|
//#region src/state/LayoutSession.ts
|
|
3814
|
-
var
|
|
3828
|
+
var lr = 80;
|
|
3815
3829
|
function $(e) {
|
|
3816
3830
|
return e.replace(/\s+/g, " ").trim().slice(0, 80).trim() || null;
|
|
3817
3831
|
}
|
|
3818
|
-
function
|
|
3832
|
+
function ur() {
|
|
3819
3833
|
return globalThis.crypto?.randomUUID?.() ?? `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
|
|
3820
3834
|
}
|
|
3821
|
-
function
|
|
3835
|
+
function dr(e) {
|
|
3822
3836
|
let { id: t, name: n, symbol: r, timeframe: i, updatedAt: a, kind: o } = e;
|
|
3823
3837
|
return {
|
|
3824
3838
|
id: t,
|
|
@@ -3829,7 +3843,7 @@ function or(e) {
|
|
|
3829
3843
|
...o === void 0 ? {} : { kind: o }
|
|
3830
3844
|
};
|
|
3831
3845
|
}
|
|
3832
|
-
var
|
|
3846
|
+
var fr = class {
|
|
3833
3847
|
currentLayout = null;
|
|
3834
3848
|
savedContent = null;
|
|
3835
3849
|
dirty = !1;
|
|
@@ -3845,7 +3859,7 @@ var sr = class {
|
|
|
3845
3859
|
now;
|
|
3846
3860
|
newId;
|
|
3847
3861
|
constructor(e, t, n = {}) {
|
|
3848
|
-
this.storage = e, this.host = t, this.options = n, this.autoSave = n.autoSave ?? !0, this.debounceMs = n.debounceMs ?? 1500, this.kind = n.kind ?? "chart", this.now = n.now ?? Date.now, this.newId = n.newId ??
|
|
3862
|
+
this.storage = e, this.host = t, this.options = n, this.autoSave = n.autoSave ?? !0, this.debounceMs = n.debounceMs ?? 1500, this.kind = n.kind ?? "chart", this.now = n.now ?? Date.now, this.newId = n.newId ?? ur;
|
|
3849
3863
|
}
|
|
3850
3864
|
current() {
|
|
3851
3865
|
return this.currentLayout;
|
|
@@ -3875,7 +3889,7 @@ var sr = class {
|
|
|
3875
3889
|
}
|
|
3876
3890
|
open(e) {
|
|
3877
3891
|
return this.queue(async () => {
|
|
3878
|
-
let t =
|
|
3892
|
+
let t = or(await this.storage.load(e));
|
|
3879
3893
|
if (!t || t.id !== e || (t.kind ?? "chart") !== this.kind || this.destroyed) return !1;
|
|
3880
3894
|
this.cancelTimer(), this.applying++;
|
|
3881
3895
|
try {
|
|
@@ -3885,13 +3899,13 @@ var sr = class {
|
|
|
3885
3899
|
} finally {
|
|
3886
3900
|
this.applying--;
|
|
3887
3901
|
}
|
|
3888
|
-
return this.cancelTimer(), this.currentLayout =
|
|
3902
|
+
return this.cancelTimer(), this.currentLayout = dr(t), this.savedContent = this.host.capture().content, this.dirty = !1, this.notify(), !0;
|
|
3889
3903
|
});
|
|
3890
3904
|
}
|
|
3891
3905
|
rename(e, t) {
|
|
3892
3906
|
let n = $(t);
|
|
3893
3907
|
return n ? this.queue(async () => {
|
|
3894
|
-
let t =
|
|
3908
|
+
let t = or(await this.storage.load(e));
|
|
3895
3909
|
!t || t.id !== e || (await this.storage.save({
|
|
3896
3910
|
...t,
|
|
3897
3911
|
name: n
|
|
@@ -3969,7 +3983,7 @@ var sr = class {
|
|
|
3969
3983
|
content: n.content
|
|
3970
3984
|
};
|
|
3971
3985
|
await this.storage.save(r);
|
|
3972
|
-
let i =
|
|
3986
|
+
let i = dr(r);
|
|
3973
3987
|
return this.currentLayout = i, this.savedContent = n.content, this.dirty = !1, this.notify(), i;
|
|
3974
3988
|
}
|
|
3975
3989
|
forget() {
|
|
@@ -3990,6 +4004,6 @@ var sr = class {
|
|
|
3990
4004
|
}
|
|
3991
4005
|
};
|
|
3992
4006
|
//#endregion
|
|
3993
|
-
export {
|
|
4007
|
+
export { Lt as C, B as S, H as _, sr as a, Xt as b, kn as c, hn as d, mn as f, dn as g, un as h, cr as i, Sn as l, pn as m, lr as n, ir as o, fn as p, $ as r, Xn as s, fr as t, gn as u, tn as v, Jt as x, Qt as y };
|
|
3994
4008
|
|
|
3995
|
-
//# sourceMappingURL=LayoutSession-
|
|
4009
|
+
//# sourceMappingURL=LayoutSession-2yRujs2S.js.map
|