@tradecanvas/chart 1.48.0 → 1.49.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Chart.d.ts +38 -17
- package/dist/Chart.d.ts.map +1 -1
- package/dist/DataManager.d.ts +16 -8
- package/dist/DataManager.d.ts.map +1 -1
- package/dist/LayoutSession-B-IfDpYQ.cjs +2 -0
- package/dist/LayoutSession-B-IfDpYQ.cjs.map +1 -0
- package/dist/{LayoutSession-DSoR1CO8.js → LayoutSession-BlSkHp80.js} +442 -331
- package/dist/LayoutSession-BlSkHp80.js.map +1 -0
- package/dist/SeriesStore.d.ts +124 -0
- package/dist/SeriesStore.d.ts.map +1 -0
- package/dist/frameworks/syncIndicators.d.ts +4 -4
- package/dist/frameworks/syncIndicators.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/widget/index.cjs +1 -1
- package/dist/widget/index.cjs.map +1 -1
- package/dist/widget/index.js +1 -1
- package/dist/widget/index.js.map +1 -1
- package/dist/widget/types.d.ts +16 -11
- package/dist/widget/types.d.ts.map +1 -1
- package/dist/widget/widgetFeatures.d.ts +2 -0
- package/dist/widget/widgetFeatures.d.ts.map +1 -1
- package/package.json +3 -3
- package/dist/LayoutSession-DSoR1CO8.js.map +0 -1
- package/dist/LayoutSession-axKXx35N.cjs +0 -2
- package/dist/LayoutSession-axKXx35N.cjs.map +0 -1
|
@@ -294,19 +294,22 @@ function B(e) {
|
|
|
294
294
|
volume: e.volume === void 0 ? 0 : Math.max(0, e.volume)
|
|
295
295
|
};
|
|
296
296
|
}
|
|
297
|
+
function sn(e, t) {
|
|
298
|
+
if (e.length === 0) return t;
|
|
299
|
+
let n = v(t);
|
|
300
|
+
return l(e) === 1 ? n : n / 1e3;
|
|
301
|
+
}
|
|
302
|
+
function cn(e, t) {
|
|
303
|
+
let n = sn(e, t.time);
|
|
304
|
+
return n === t.time ? t : {
|
|
305
|
+
...t,
|
|
306
|
+
time: n
|
|
307
|
+
};
|
|
308
|
+
}
|
|
297
309
|
var V = class {
|
|
298
310
|
data = [];
|
|
299
|
-
inSeriesUnit(e) {
|
|
300
|
-
if (this.data.length === 0) return e;
|
|
301
|
-
let t = v(e);
|
|
302
|
-
return l(this.data) === 1 ? t : t / 1e3;
|
|
303
|
-
}
|
|
304
311
|
withSeriesTime(e) {
|
|
305
|
-
|
|
306
|
-
return t === e.time ? e : {
|
|
307
|
-
...e,
|
|
308
|
-
time: t
|
|
309
|
-
};
|
|
312
|
+
return cn(this.data, e);
|
|
310
313
|
}
|
|
311
314
|
getData() {
|
|
312
315
|
return this.data;
|
|
@@ -353,7 +356,199 @@ var V = class {
|
|
|
353
356
|
clear() {
|
|
354
357
|
this.data = [];
|
|
355
358
|
}
|
|
356
|
-
}
|
|
359
|
+
};
|
|
360
|
+
//#endregion
|
|
361
|
+
//#region src/SeriesStore.ts
|
|
362
|
+
function H(e, t) {
|
|
363
|
+
let n = e[e.length - 1];
|
|
364
|
+
if (!n) return "append";
|
|
365
|
+
let r = v(t.time), i = v(n.time);
|
|
366
|
+
return r > i ? "append" : r === i ? "update" : "stale";
|
|
367
|
+
}
|
|
368
|
+
function ln(e) {
|
|
369
|
+
return [
|
|
370
|
+
e.time,
|
|
371
|
+
e.open,
|
|
372
|
+
e.high,
|
|
373
|
+
e.low,
|
|
374
|
+
e.close
|
|
375
|
+
].every(Number.isFinite);
|
|
376
|
+
}
|
|
377
|
+
var un = class {
|
|
378
|
+
shown = new V();
|
|
379
|
+
whole = null;
|
|
380
|
+
aside = null;
|
|
381
|
+
constructor(e) {
|
|
382
|
+
this.hoursFilter = e;
|
|
383
|
+
}
|
|
384
|
+
bars() {
|
|
385
|
+
return this.shown.getData();
|
|
386
|
+
}
|
|
387
|
+
length() {
|
|
388
|
+
return this.shown.getLength();
|
|
389
|
+
}
|
|
390
|
+
liveBars() {
|
|
391
|
+
return this.aside?.getData() ?? this.whole ?? this.shown.getData();
|
|
392
|
+
}
|
|
393
|
+
load(e) {
|
|
394
|
+
this.shown.setData(this.regularOnly(e));
|
|
395
|
+
}
|
|
396
|
+
prepend(e) {
|
|
397
|
+
let t = null, n = e;
|
|
398
|
+
if (this.whole) {
|
|
399
|
+
let r = this.whole[0]?.time, i = /* @__PURE__ */ new Set(), a = e.filter(ln).map((e) => this.inSeriesUnit(e)).filter((e) => (r === void 0 || e.time < r) && !i.has(e.time) && i.add(e.time)).sort((e, t) => e.time - t.time);
|
|
400
|
+
this.whole = [...a, ...this.whole];
|
|
401
|
+
let o = this.hoursFilter(this.whole);
|
|
402
|
+
t = a.length, n = o ? a.filter((e) => o(e.time)) : a;
|
|
403
|
+
}
|
|
404
|
+
let r = this.shown.prependBars(n);
|
|
405
|
+
return {
|
|
406
|
+
added: r,
|
|
407
|
+
taken: t ?? r
|
|
408
|
+
};
|
|
409
|
+
}
|
|
410
|
+
mergeSnapshot(e) {
|
|
411
|
+
let t = this.whole ?? this.shown.getData(), n = e[0]?.time, r = 0;
|
|
412
|
+
for (; n !== void 0 && r < t.length && t[r].time < n;) r++;
|
|
413
|
+
return r === 0 || r === t.length ? !1 : (this.shown.setData(this.regularOnly(t.slice(0, r).concat(e))), !0);
|
|
414
|
+
}
|
|
415
|
+
refilter() {
|
|
416
|
+
if (this.aside) return !1;
|
|
417
|
+
let e = this.whole ?? this.shown.getData().slice();
|
|
418
|
+
return !this.whole && !this.hoursFilter(e) ? !1 : (this.shown.setData(this.regularOnly(e)), !0);
|
|
419
|
+
}
|
|
420
|
+
append(e) {
|
|
421
|
+
if (this.aside) return this.aside.appendBar(e), this.wrote("aside", !1);
|
|
422
|
+
let t = this.inSeriesUnit(e), n = this.startWholeSeries(t, "append");
|
|
423
|
+
if (!this.take(t, "append")) return this.wrote("hidden", n);
|
|
424
|
+
let r = this.shown.getLength();
|
|
425
|
+
return this.shown.appendBar(t), {
|
|
426
|
+
to: "shown",
|
|
427
|
+
before: r,
|
|
428
|
+
refiltered: n
|
|
429
|
+
};
|
|
430
|
+
}
|
|
431
|
+
appendMany(e) {
|
|
432
|
+
if (this.aside) {
|
|
433
|
+
for (let t of e) this.aside.appendBar(t);
|
|
434
|
+
return {
|
|
435
|
+
shown: 0,
|
|
436
|
+
before: this.shown.getLength(),
|
|
437
|
+
refiltered: !1,
|
|
438
|
+
aside: !0
|
|
439
|
+
};
|
|
440
|
+
}
|
|
441
|
+
let t = !1, n = [];
|
|
442
|
+
for (let r of e) {
|
|
443
|
+
let e = this.inSeriesUnit(r);
|
|
444
|
+
t = this.startWholeSeries(e, "append") || t, this.take(e, "append") && n.push(e);
|
|
445
|
+
}
|
|
446
|
+
let r = this.shown.getLength();
|
|
447
|
+
for (let e of n) this.shown.appendBar(e);
|
|
448
|
+
return {
|
|
449
|
+
shown: n.length,
|
|
450
|
+
before: r,
|
|
451
|
+
refiltered: t,
|
|
452
|
+
aside: !1
|
|
453
|
+
};
|
|
454
|
+
}
|
|
455
|
+
updateLast(e) {
|
|
456
|
+
if (this.aside) return this.aside.updateLastBar(e), this.wrote("aside", !1);
|
|
457
|
+
let t = this.inSeriesUnit(e), n = this.startWholeSeries(t, "update");
|
|
458
|
+
if (!this.take(t, "update")) return this.wrote("hidden", n);
|
|
459
|
+
let r = this.shown.getLength();
|
|
460
|
+
return this.shown.updateLastBar(t), {
|
|
461
|
+
to: "shown",
|
|
462
|
+
before: r,
|
|
463
|
+
refiltered: n
|
|
464
|
+
};
|
|
465
|
+
}
|
|
466
|
+
mergeTick(e) {
|
|
467
|
+
if (this.aside) return this.aside.updateLastBarFromTick(e), this.wrote("aside", !1);
|
|
468
|
+
let t = this.whole ? this.hoursFilter(this.whole) : null;
|
|
469
|
+
if (t && this.whole && !t(sn(this.whole, e.time))) return this.wrote("hidden", !1);
|
|
470
|
+
let n = this.shown.getLength();
|
|
471
|
+
this.shown.updateLastBarFromTick(e);
|
|
472
|
+
let r = this.whole, i = this.shown.getData()[this.shown.getLength() - 1];
|
|
473
|
+
return r && i && r.length > 0 && r[r.length - 1].time === i.time && (r[r.length - 1] = i), {
|
|
474
|
+
to: "shown",
|
|
475
|
+
before: n,
|
|
476
|
+
refiltered: !1
|
|
477
|
+
};
|
|
478
|
+
}
|
|
479
|
+
placeStreamBar(e) {
|
|
480
|
+
if (this.aside) {
|
|
481
|
+
let t = H(this.aside.getData(), e);
|
|
482
|
+
return t === "append" ? this.aside.appendBar(e) : t === "update" && this.aside.updateLastBar(e), this.wrote(t === "stale" ? "none" : "aside", !1);
|
|
483
|
+
}
|
|
484
|
+
let t = this.inSeriesUnit(e), n = H(this.whole ?? this.shown.getData(), t);
|
|
485
|
+
if (n === "stale") return this.wrote("none", !1);
|
|
486
|
+
let r = this.startWholeSeries(t, n);
|
|
487
|
+
if (!this.take(t, n)) return this.wrote("hidden", r);
|
|
488
|
+
let i = this.shown.getLength(), a = H(this.shown.getData(), t);
|
|
489
|
+
return a === "stale" ? {
|
|
490
|
+
to: "none",
|
|
491
|
+
before: i,
|
|
492
|
+
refiltered: r
|
|
493
|
+
} : (a === "append" ? this.shown.appendBar(t) : this.shown.updateLastBar(t), {
|
|
494
|
+
to: "shown",
|
|
495
|
+
before: i,
|
|
496
|
+
refiltered: r
|
|
497
|
+
});
|
|
498
|
+
}
|
|
499
|
+
loadAside(e) {
|
|
500
|
+
this.aside?.setData(e);
|
|
501
|
+
}
|
|
502
|
+
beginReplay() {
|
|
503
|
+
this.aside || (this.aside = new V(), this.aside.setData(this.whole ?? this.shown.getData()));
|
|
504
|
+
}
|
|
505
|
+
endReplay() {
|
|
506
|
+
let e = this.aside;
|
|
507
|
+
return this.aside = null, e ? e.getData() : null;
|
|
508
|
+
}
|
|
509
|
+
inHoursShown(e) {
|
|
510
|
+
let t = this.hoursFilter(e);
|
|
511
|
+
return t ? e.filter((e) => t(e.time)) : e.slice();
|
|
512
|
+
}
|
|
513
|
+
showReplayed(e) {
|
|
514
|
+
this.shown.setData(e);
|
|
515
|
+
}
|
|
516
|
+
appendReplayed(e) {
|
|
517
|
+
this.shown.appendBar(e);
|
|
518
|
+
}
|
|
519
|
+
updateReplayed(e) {
|
|
520
|
+
this.shown.updateLastBar(e);
|
|
521
|
+
}
|
|
522
|
+
inSeriesUnit(e) {
|
|
523
|
+
return cn(this.whole ?? this.shown.getData(), e);
|
|
524
|
+
}
|
|
525
|
+
wrote(e, t) {
|
|
526
|
+
return {
|
|
527
|
+
to: e,
|
|
528
|
+
before: this.shown.getLength(),
|
|
529
|
+
refiltered: t
|
|
530
|
+
};
|
|
531
|
+
}
|
|
532
|
+
regularOnly(e) {
|
|
533
|
+
let t = this.hoursFilter(e);
|
|
534
|
+
return this.whole = t ? e.slice() : null, t ? e.filter((e) => t(e.time)) : e;
|
|
535
|
+
}
|
|
536
|
+
startWholeSeries(e, t) {
|
|
537
|
+
if (this.whole) return !1;
|
|
538
|
+
let n = this.shown.getData(), r = n.slice(-12), i = t === "append" || r.length === 0 ? [...r, e] : [...r.slice(0, -1), e];
|
|
539
|
+
if (!this.hoursFilter(i)) return !1;
|
|
540
|
+
this.whole = n.slice();
|
|
541
|
+
let a = this.hoursFilter(this.whole.length > 1 ? this.whole : i);
|
|
542
|
+
return !a || !n.some((e) => !a(e.time)) ? !1 : (this.shown.setData(n.filter((e) => a(e.time))), !0);
|
|
543
|
+
}
|
|
544
|
+
take(e, t) {
|
|
545
|
+
let n = this.whole;
|
|
546
|
+
if (!n) return !0;
|
|
547
|
+
t === "append" || n.length === 0 ? n.push(e) : n[n.length - 1] = e;
|
|
548
|
+
let r = this.hoursFilter(n);
|
|
549
|
+
return !r || r(e.time);
|
|
550
|
+
}
|
|
551
|
+
}, dn = 5e3, fn = 6e4, pn = 500, mn = class {
|
|
357
552
|
loader = null;
|
|
358
553
|
pageSize = 500;
|
|
359
554
|
loading = !1;
|
|
@@ -394,7 +589,7 @@ var V = class {
|
|
|
394
589
|
try {
|
|
395
590
|
r = await e(t, this.pageSize);
|
|
396
591
|
} catch (e) {
|
|
397
|
-
return n === this.seq ? (this.loading = !1, this.failures++, this.retryAt = this.now() + Math.min(
|
|
592
|
+
return n === this.seq ? (this.loading = !1, this.failures++, this.retryAt = this.now() + Math.min(fn, dn * 2 ** (this.failures - 1)), this.emit({
|
|
398
593
|
state: "error",
|
|
399
594
|
count: 0,
|
|
400
595
|
error: e instanceof Error ? e.message : String(e)
|
|
@@ -424,7 +619,7 @@ var V = class {
|
|
|
424
619
|
now() {
|
|
425
620
|
return this.host.now ? this.host.now() : Date.now();
|
|
426
621
|
}
|
|
427
|
-
},
|
|
622
|
+
}, hn = class t {
|
|
428
623
|
base;
|
|
429
624
|
shape = null;
|
|
430
625
|
chartType = "candlestick";
|
|
@@ -510,7 +705,7 @@ var V = class {
|
|
|
510
705
|
};
|
|
511
706
|
//#endregion
|
|
512
707
|
//#region src/style/styleOptions.ts
|
|
513
|
-
function
|
|
708
|
+
function gn(e, t) {
|
|
514
709
|
return t ? {
|
|
515
710
|
...t.visible === void 0 ? {} : { [`crosshair.${e}.visible`]: t.visible },
|
|
516
711
|
...t.color === void 0 ? {} : { [`crosshair.${e}.color`]: t.color },
|
|
@@ -518,22 +713,22 @@ function fn(e, t) {
|
|
|
518
713
|
...t.width === void 0 ? {} : { [`crosshair.${e}.width`]: t.width }
|
|
519
714
|
} : {};
|
|
520
715
|
}
|
|
521
|
-
function
|
|
716
|
+
function _n(e) {
|
|
522
717
|
let { grid: t, crosshair: n } = e, r = n?.vLine?.labelBackground ?? n?.hLine?.labelBackground;
|
|
523
718
|
return {
|
|
524
719
|
...t?.hLineColor === void 0 ? {} : { "grid.horizontal.color": t.hLineColor },
|
|
525
720
|
...t?.hLineStyle === void 0 ? {} : { "grid.horizontal.style": t.hLineStyle },
|
|
526
721
|
...t?.vLineColor === void 0 ? {} : { "grid.vertical.color": t.vLineColor },
|
|
527
722
|
...t?.vLineStyle === void 0 ? {} : { "grid.vertical.style": t.vLineStyle },
|
|
528
|
-
...
|
|
529
|
-
...
|
|
723
|
+
...gn("horizontal", n?.hLine),
|
|
724
|
+
...gn("vertical", n?.vLine),
|
|
530
725
|
...r === void 0 ? {} : { "crosshair.labelBackground": r },
|
|
531
726
|
...e.overrides
|
|
532
727
|
};
|
|
533
728
|
}
|
|
534
729
|
//#endregion
|
|
535
730
|
//#region src/layout/LayoutManager.ts
|
|
536
|
-
var
|
|
731
|
+
var vn = 200, yn = 80, U = (e) => e.position === "top" || e.position === "bottom", bn = class {
|
|
537
732
|
panels = [];
|
|
538
733
|
containerWidth = 0;
|
|
539
734
|
containerHeight = 0;
|
|
@@ -549,8 +744,8 @@ var mn = 200, hn = 80, H = (e) => e.position === "top" || e.position === "bottom
|
|
|
549
744
|
this.panels.push({
|
|
550
745
|
id: e,
|
|
551
746
|
position: n,
|
|
552
|
-
size: r ?? (a ?
|
|
553
|
-
minSize: a ?
|
|
747
|
+
size: r ?? (a ? vn : t),
|
|
748
|
+
minSize: a ? yn : i,
|
|
554
749
|
content: {
|
|
555
750
|
type: "indicator",
|
|
556
751
|
indicatorInstanceId: e
|
|
@@ -569,14 +764,14 @@ var mn = 200, hn = 80, H = (e) => e.position === "top" || e.position === "bottom
|
|
|
569
764
|
}
|
|
570
765
|
setPanelCollapsed(e, t) {
|
|
571
766
|
let n = this.panels.find((t) => t.id === e);
|
|
572
|
-
return !n || !
|
|
767
|
+
return !n || !U(n) || this.maximized === null && !!n.collapsed === t ? !1 : (this.maximized = null, n.collapsed = t || void 0, !0);
|
|
573
768
|
}
|
|
574
769
|
isPanelCollapsed(e) {
|
|
575
770
|
return !!this.panels.find((t) => t.id === e)?.collapsed;
|
|
576
771
|
}
|
|
577
772
|
isPanelShownCollapsed(e) {
|
|
578
773
|
let t = this.panels.find((t) => t.id === e);
|
|
579
|
-
return !t || !
|
|
774
|
+
return !t || !U(t) ? !1 : this.maximized === null ? !!t.collapsed : this.maximized !== e;
|
|
580
775
|
}
|
|
581
776
|
setPanelScale(e, t) {
|
|
582
777
|
let n = this.panels.find((t) => t.id === e);
|
|
@@ -592,7 +787,7 @@ var mn = 200, hn = 80, H = (e) => e.position === "top" || e.position === "bottom
|
|
|
592
787
|
}
|
|
593
788
|
setMaximizedPanel(e) {
|
|
594
789
|
let t = e === null ? null : this.panels.find((t) => t.id === e);
|
|
595
|
-
return e !== null && (!t || !
|
|
790
|
+
return e !== null && (!t || !U(t)) || this.maximized === e ? !1 : (this.maximized = e, t && (t.collapsed = void 0), !0);
|
|
596
791
|
}
|
|
597
792
|
getMaximizedPanel() {
|
|
598
793
|
return this.maximized;
|
|
@@ -613,19 +808,19 @@ var mn = 200, hn = 80, H = (e) => e.position === "top" || e.position === "bottom
|
|
|
613
808
|
this.panels = [...this.panels].sort((e, n) => t(e) - t(n));
|
|
614
809
|
}
|
|
615
810
|
shownSize(e, t) {
|
|
616
|
-
return
|
|
811
|
+
return U(e) ? this.maximized ? e.id === this.maximized ? t : 20 : e.collapsed ? 20 : e.size : e.size;
|
|
617
812
|
}
|
|
618
813
|
setPanelPosition(e, n) {
|
|
619
814
|
let r = this.panels.find((t) => t.id === e);
|
|
620
815
|
if (r) {
|
|
621
816
|
let a = r.position === "left" || r.position === "right", o = n === "left" || n === "right";
|
|
622
|
-
r.position = n, a !== o && (r.size = o ?
|
|
817
|
+
r.position = n, a !== o && (r.size = o ? vn : t, r.minSize = o ? yn : i), o && (r.collapsed = void 0, this.maximized === e && (this.maximized = null));
|
|
623
818
|
}
|
|
624
819
|
}
|
|
625
820
|
setPanelSize(e, t) {
|
|
626
821
|
let n = this.panels.find((t) => t.id === e);
|
|
627
822
|
if (n) {
|
|
628
|
-
let e =
|
|
823
|
+
let e = U(n) ? this.containerHeight - s - 48 : this.containerWidth / 2, r = e > n.minSize ? Math.min(t, e) : t;
|
|
629
824
|
n.size = Math.max(n.minSize, r), n.collapsed = void 0, this.maximized = null;
|
|
630
825
|
}
|
|
631
826
|
}
|
|
@@ -735,8 +930,8 @@ var mn = 200, hn = 80, H = (e) => e.position === "top" || e.position === "bottom
|
|
|
735
930
|
getMainChartRect() {
|
|
736
931
|
return this.resolve().mainChartRect;
|
|
737
932
|
}
|
|
738
|
-
},
|
|
739
|
-
function
|
|
933
|
+
}, xn = 14, Sn = 14, Cn = 22, wn = 4;
|
|
934
|
+
function Tn(e) {
|
|
740
935
|
let { min: t, max: n, lastPrice: r, locale: i, fontFamily: a, fontSizeSmall: s, measure: l } = e, u = e.tagPrecision ?? c(t, n), d = u, f = r === null ? [t, n] : [
|
|
741
936
|
t,
|
|
742
937
|
n,
|
|
@@ -745,14 +940,14 @@ function xn(e) {
|
|
|
745
940
|
for (let t of f) {
|
|
746
941
|
if (!Number.isFinite(t)) continue;
|
|
747
942
|
let n = e.scaleLabel ? e.scaleLabel(t) : e.format ? e.format(t) : p(t, u, i), r = e.format ? n : p(t, d, i);
|
|
748
|
-
m = Math.max(m, l(n, `500 ${s}px ${a}`) +
|
|
943
|
+
m = Math.max(m, l(n, `500 ${s}px ${a}`) + xn, l(r, `bold 11px ${a}`) + Sn, l(r, `600 ${s}px ${a}`) + Cn);
|
|
749
944
|
}
|
|
750
|
-
return m <= o ? o : Math.ceil(m /
|
|
945
|
+
return m <= o ? o : Math.ceil(m / wn) * wn;
|
|
751
946
|
}
|
|
752
|
-
function
|
|
947
|
+
function En(e, t) {
|
|
753
948
|
return t > e || t <= e - 12 ? t : e;
|
|
754
949
|
}
|
|
755
|
-
var
|
|
950
|
+
var Dn = class {
|
|
756
951
|
netY = 0;
|
|
757
952
|
travelX = 0;
|
|
758
953
|
engaged = !1;
|
|
@@ -768,11 +963,11 @@ var Cn = class {
|
|
|
768
963
|
}
|
|
769
964
|
return this.engaged;
|
|
770
965
|
}
|
|
771
|
-
},
|
|
772
|
-
function
|
|
966
|
+
}, On = 1;
|
|
967
|
+
function kn(e, t) {
|
|
773
968
|
return e.filter((e) => e.enabled !== !1 && (e.descriptor.layer ?? "overlay") === t);
|
|
774
969
|
}
|
|
775
|
-
function
|
|
970
|
+
function W(e) {
|
|
776
971
|
switch (e.kind) {
|
|
777
972
|
case "indicator": return `indicator:${e.plugin.descriptor.id}`;
|
|
778
973
|
case "drawing": return `drawing:${e.plugin.descriptor.type}`;
|
|
@@ -782,25 +977,25 @@ function U(e) {
|
|
|
782
977
|
}
|
|
783
978
|
//#endregion
|
|
784
979
|
//#region src/plugins/registry.ts
|
|
785
|
-
var
|
|
786
|
-
function
|
|
787
|
-
|
|
980
|
+
var G = /* @__PURE__ */ new Map();
|
|
981
|
+
function An(e) {
|
|
982
|
+
G.set(W(e), e);
|
|
788
983
|
}
|
|
789
|
-
function
|
|
790
|
-
return
|
|
984
|
+
function jn(e) {
|
|
985
|
+
return G.delete(e);
|
|
791
986
|
}
|
|
792
|
-
function
|
|
793
|
-
return [...
|
|
987
|
+
function Mn() {
|
|
988
|
+
return [...G.values()];
|
|
794
989
|
}
|
|
795
|
-
function
|
|
796
|
-
|
|
990
|
+
function Nn() {
|
|
991
|
+
G.clear();
|
|
797
992
|
}
|
|
798
993
|
//#endregion
|
|
799
994
|
//#region src/plugins/PluginManager.ts
|
|
800
|
-
var
|
|
995
|
+
var Pn = class {
|
|
801
996
|
plugins = /* @__PURE__ */ new Map();
|
|
802
997
|
constructor(e, t = {}) {
|
|
803
|
-
if (this.indicatorEngine = e, t.inheritGlobal !== !1) for (let e of
|
|
998
|
+
if (this.indicatorEngine = e, t.inheritGlobal !== !1) for (let e of Mn()) this.add(e);
|
|
804
999
|
for (let e of t.plugins ?? []) this.add(e);
|
|
805
1000
|
}
|
|
806
1001
|
register(e) {
|
|
@@ -828,17 +1023,17 @@ var An = class {
|
|
|
828
1023
|
return e;
|
|
829
1024
|
}
|
|
830
1025
|
add(e) {
|
|
831
|
-
this.plugins.set(
|
|
1026
|
+
this.plugins.set(W(e), e), e.kind === "indicator" && this.indicatorEngine.register(e.plugin);
|
|
832
1027
|
}
|
|
833
|
-
},
|
|
1028
|
+
}, Fn = {
|
|
834
1029
|
orderPlace: (e, t) => e.placeOrder(t),
|
|
835
1030
|
orderModify: (e, t) => e.modifyOrder(t),
|
|
836
1031
|
orderCancel: (e, t) => e.cancelOrder(t),
|
|
837
1032
|
positionModify: (e, t) => e.modifyPosition(t),
|
|
838
1033
|
positionClose: (e, t) => e.closePosition(t),
|
|
839
|
-
positionReverse: (e, t, n) =>
|
|
1034
|
+
positionReverse: (e, t, n) => In(e, t, n)
|
|
840
1035
|
};
|
|
841
|
-
async function
|
|
1036
|
+
async function In(e, t, n) {
|
|
842
1037
|
let { reversing: r } = n;
|
|
843
1038
|
if (!r.has(t.positionId)) {
|
|
844
1039
|
r.add(t.positionId);
|
|
@@ -867,7 +1062,7 @@ async function Mn(e, t, n) {
|
|
|
867
1062
|
}
|
|
868
1063
|
}
|
|
869
1064
|
}
|
|
870
|
-
function
|
|
1065
|
+
function Ln(e, t) {
|
|
871
1066
|
let n = [], r = null, i = {
|
|
872
1067
|
positions: () => r ?? t.getPositions?.() ?? [],
|
|
873
1068
|
reversing: /* @__PURE__ */ new Set()
|
|
@@ -877,8 +1072,8 @@ function Nn(e, t) {
|
|
|
877
1072
|
e.data && t.onFill?.(e.data);
|
|
878
1073
|
};
|
|
879
1074
|
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));
|
|
880
|
-
for (let r of Object.keys(
|
|
881
|
-
let a =
|
|
1075
|
+
for (let r of Object.keys(Fn)) {
|
|
1076
|
+
let a = Fn[r], o = t.onIntent(r, (n) => {
|
|
882
1077
|
Promise.resolve(a(e, n, i)).catch((e) => t.onError({
|
|
883
1078
|
message: `Execution command failed: ${r}`,
|
|
884
1079
|
cause: e
|
|
@@ -892,15 +1087,15 @@ function Nn(e, t) {
|
|
|
892
1087
|
}
|
|
893
1088
|
//#endregion
|
|
894
1089
|
//#region src/Chart.ts
|
|
895
|
-
var
|
|
1090
|
+
var Rn = {
|
|
896
1091
|
min: 0,
|
|
897
1092
|
max: 100
|
|
898
|
-
},
|
|
899
|
-
function
|
|
1093
|
+
}, zn = "exchange", Bn = zn;
|
|
1094
|
+
function Vn(e) {
|
|
900
1095
|
if (typeof e == "string" && e !== "exchange" && !g(e)) throw RangeError(`Unknown time zone: ${e}`);
|
|
901
1096
|
if (typeof e == "number" && !Number.isFinite(e)) throw RangeError(`Invalid UTC offset: ${e}`);
|
|
902
1097
|
}
|
|
903
|
-
function
|
|
1098
|
+
function Hn(e, t) {
|
|
904
1099
|
let { timeZone: n, timezone: r } = e, i = n !== void 0 && r !== void 0 && n !== r && n === t ? r : w(e);
|
|
905
1100
|
return i === void 0 ? e : {
|
|
906
1101
|
...e,
|
|
@@ -908,11 +1103,11 @@ function Rn(e, t) {
|
|
|
908
1103
|
timezone: i
|
|
909
1104
|
};
|
|
910
1105
|
}
|
|
911
|
-
var
|
|
912
|
-
static version = "1.
|
|
1106
|
+
var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontalLine", "crossLine"]), Yn = new Set(["verticalLine", "crossLine"]), Xn = class {
|
|
1107
|
+
static version = "1.49.1";
|
|
913
1108
|
engine;
|
|
914
1109
|
viewport;
|
|
915
|
-
|
|
1110
|
+
series = new un((e) => this.sessionKeep(e));
|
|
916
1111
|
themeManager;
|
|
917
1112
|
layoutManager;
|
|
918
1113
|
pluginManager;
|
|
@@ -1001,7 +1196,6 @@ var zn = .08, Bn = a ** -7, Vn = 800, Hn = 20, Un = 8, Wn = new Set(["horizontal
|
|
|
1001
1196
|
symbolSeries = new at();
|
|
1002
1197
|
extendedHours = !0;
|
|
1003
1198
|
replayRestarting = !1;
|
|
1004
|
-
fullSeries = null;
|
|
1005
1199
|
requestedSymbols = /* @__PURE__ */ new Set();
|
|
1006
1200
|
gridRenderer;
|
|
1007
1201
|
priceAxis;
|
|
@@ -1036,7 +1230,7 @@ var zn = .08, Bn = a ** -7, Vn = 800, Hn = 20, Un = 8, Wn = new Set(["horizontal
|
|
|
1036
1230
|
snapshotKey = null;
|
|
1037
1231
|
historyCheckQueued = !1;
|
|
1038
1232
|
constructor(e, t) {
|
|
1039
|
-
t.timeZone != null &&
|
|
1233
|
+
t.timeZone != null && Vn(t.timeZone), this.container = e, this.options = {
|
|
1040
1234
|
...t,
|
|
1041
1235
|
chartType: t.chartType ?? "candlestick"
|
|
1042
1236
|
}, this.numberLocale = t.numberLocale ?? "en-US", this.defaultAutoScale = t.autoScale !== !1;
|
|
@@ -1074,11 +1268,11 @@ var zn = .08, Bn = a ** -7, Vn = 800, Hn = 20, Un = 8, Wn = new Set(["horizontal
|
|
|
1074
1268
|
logScale: n.logScale ?? !0,
|
|
1075
1269
|
timeframes: n.timeframes ?? [],
|
|
1076
1270
|
defaultTimeframeFavorites: n.defaultTimeframeFavorites ?? []
|
|
1077
|
-
}, e.style.position = "relative", e.style.overflow = "hidden", e.tabIndex = 0, e.style.outline = "none", e.style.userSelect = "none", e.style.webkitUserSelect = "none", this.
|
|
1078
|
-
oldestTime: () => this.
|
|
1271
|
+
}, e.style.position = "relative", e.style.overflow = "hidden", e.tabIndex = 0, e.style.outline = "none", e.style.userSelect = "none", e.style.webkitUserSelect = "none", this.history = new mn({
|
|
1272
|
+
oldestTime: () => this.series.bars()[0]?.time ?? null,
|
|
1079
1273
|
prepend: (e) => this.prependBars(e),
|
|
1080
1274
|
emit: (e) => this.eventBus.emit("historyLoad", e)
|
|
1081
|
-
}), this.themeManager = new
|
|
1275
|
+
}), this.themeManager = new hn(t.theme), this.themeManager.setChartType(this.options.chartType ?? "candlestick"), this.applyStyle(_n(t), "host", !1), this.layoutManager = new bn(), this.indicatorEngine = new O(), this.pluginManager = new Pn(this.indicatorEngine, { plugins: t.plugins }), this.eventBus = new je(), Dt(this.indicatorEngine), this.indicatorEngine.register(new be(this.symbolSeries)), this.indicatorEngine.register(new nt(this.symbolSeries)), this.indicatorEngine.register(new xe(this.symbolSeries)), this.indicatorEngine.register(new Se(this.symbolSeries)), this.drawingManager = new Oe(), Et(this.drawingManager), this.drawingRenderer = new ke(this.drawingManager), this.drawingManager.setRequestRender(() => {
|
|
1082
1276
|
this.syncRenderContext(), this.engine.requestRender(r.Overlay), this.scheduleAutoSave();
|
|
1083
1277
|
}), this.drawingManager.setEventCallback((e, t) => {
|
|
1084
1278
|
this.followDrawingAlerts(e, t?.id), this.eventBus.emit(e, t), (e === "drawingCreate" || e === "drawingUpdate" || e === "drawingRemove") && this.announceStateChange();
|
|
@@ -1095,7 +1289,7 @@ var zn = .08, Bn = a ** -7, Vn = 800, Hn = 20, Un = 8, Wn = new Set(["horizontal
|
|
|
1095
1289
|
primary: e[0] ?? null
|
|
1096
1290
|
})), this.drawingManager.setForeignHistory((e, t) => {
|
|
1097
1291
|
e.type === "custom" ? e.custom?.[t]() : this.applyIndicatorStep(e, t);
|
|
1098
|
-
}), this.drawingManager.setDataGetter(() => this.
|
|
1292
|
+
}), this.drawingManager.setDataGetter(() => this.series.bars()), this.drawingManager.setDisplayDataGetter(() => this.getDisplayData()), t.crosshair?.mode === "magnet" && this.features.drawingMagnet && this.drawingManager.setMagnetMode("magnet"), this.tradingManager = new ct({
|
|
1099
1293
|
enabled: this.features.trading,
|
|
1100
1294
|
contextMenu: { enabled: this.features.tradingContextMenu }
|
|
1101
1295
|
}), this.tradingRenderer = new lt(this.tradingManager), this.tradingManager.setContainer(e), this.tradingManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.tradingManager.setEventCallback((e, t) => {
|
|
@@ -1131,7 +1325,7 @@ var zn = .08, Bn = a ** -7, Vn = 800, Hn = 20, Un = 8, Wn = new Set(["horizontal
|
|
|
1131
1325
|
color: t.sessionBreaks.color,
|
|
1132
1326
|
lineStyle: t.sessionBreaks.lineStyle,
|
|
1133
1327
|
lineWidth: t.sessionBreaks.lineWidth
|
|
1134
|
-
}) : t.features?.sessionBreaks !== !1 && this.sessionBreaks.setVisible(!0), t.logScale && this.features.logScale && this.viewport.setLogScale(!0), this.animator = new de(), this.crosshairTooltip = new we(), this.crosshairTooltip.create(e), this.crosshairTooltip.setLocale(this.numberLocale), this.pinnedTooltip = new Ge(), this.pinnedTooltip.create(e), t.priceFormat && this.applyPriceFormat(t.priceFormat), t.chartTypeOptions && (this.chartTypeOptions = b(t.chartTypeOptions)), t.highLowLines && this.priceLines.setHighLow(!0), t.shapes && this.themeManager.setShape(
|
|
1328
|
+
}) : t.features?.sessionBreaks !== !1 && this.sessionBreaks.setVisible(!0), t.logScale && this.features.logScale && this.viewport.setLogScale(!0), this.animator = new de(), this.crosshairTooltip = new we(), this.crosshairTooltip.create(e), this.crosshairTooltip.setLocale(this.numberLocale), this.pinnedTooltip = new Ge(), this.pinnedTooltip.create(e), t.priceFormat && this.applyPriceFormat(t.priceFormat), t.chartTypeOptions && (this.chartTypeOptions = b(t.chartTypeOptions)), t.highLowLines && this.priceLines.setHighLow(!0), t.shapes && this.themeManager.setShape($n(t.shapes)), this.priceLines.setPriceText((e) => this.formatPrice(e)), t.extendedHours === !1 && (this.extendedHours = !1), t.timeFormatter && this.applyTimeFormatter(t.timeFormatter), this.keyboardHandler = new Le({
|
|
1135
1329
|
scrollBars: (e) => {
|
|
1136
1330
|
let t = this.viewport.getState().barWidth + this.viewport.getState().barSpacing;
|
|
1137
1331
|
this.viewport.scrollBy(e * t), this.updateViewportAndRender();
|
|
@@ -1179,7 +1373,7 @@ var zn = .08, Bn = a ** -7, Vn = 800, Hn = 20, Un = 8, Wn = new Set(["horizontal
|
|
|
1179
1373
|
this.keyboardHandler.handleKey(e) && (e.preventDefault(), this.a11y?.viewMoved());
|
|
1180
1374
|
}
|
|
1181
1375
|
}, window.addEventListener("keydown", this.onWindowKeyDown), this.currentPriceLine = new Te(), this.currentPriceLine.setLocale(this.numberLocale), this.priceAxis.setReservedPriceProvider(() => this.currentPriceLine.isVisible() ? this.currentPriceLine.getPrice() : null), this.alertManager = new ue(), this.alertManager.setDrawingLevels((e) => this.drawingLevelsNow(e)), this.alertManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.alertManager.on("triggered", (e) => {
|
|
1182
|
-
this.eventBus.emit("alertTriggered",
|
|
1376
|
+
this.eventBus.emit("alertTriggered", K(e)), this.eventBus.emit("dataUpdate", {
|
|
1183
1377
|
kind: "alert",
|
|
1184
1378
|
alert: "triggered",
|
|
1185
1379
|
alertId: e.id,
|
|
@@ -1187,14 +1381,14 @@ var zn = .08, Bn = a ** -7, Vn = 800, Hn = 20, Un = 8, Wn = new Set(["horizontal
|
|
|
1187
1381
|
message: e.message
|
|
1188
1382
|
});
|
|
1189
1383
|
}), this.alertManager.on("added", (e) => {
|
|
1190
|
-
this.eventBus.emit("alertAdd",
|
|
1384
|
+
this.eventBus.emit("alertAdd", K(e));
|
|
1191
1385
|
}), this.alertManager.on("removed", (e) => {
|
|
1192
1386
|
this.eventBus.emit("alertRemove", { id: e });
|
|
1193
1387
|
}), this.alertManager.on("expired", (e) => {
|
|
1194
|
-
this.eventBus.emit("alertExpired",
|
|
1388
|
+
this.eventBus.emit("alertExpired", K(e));
|
|
1195
1389
|
}), this.alertManager.on("updated", (e) => {
|
|
1196
|
-
this.eventBus.emit("alertUpdate",
|
|
1197
|
-
}), this.signalMarkerManager = new tt(), this.signalMarkerManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.signalMarkerManager.setDataGetter(() => this.
|
|
1390
|
+
this.eventBus.emit("alertUpdate", K(e));
|
|
1391
|
+
}), this.signalMarkerManager = new tt(), this.signalMarkerManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.signalMarkerManager.setDataGetter(() => this.series.bars()), this.signalMarkerManager.on("added", (e) => {
|
|
1198
1392
|
this.eventBus.emit("signalMarkerAdd", {
|
|
1199
1393
|
id: e.id,
|
|
1200
1394
|
source: e.source,
|
|
@@ -1202,7 +1396,7 @@ var zn = .08, Bn = a ** -7, Vn = 800, Hn = 20, Un = 8, Wn = new Set(["horizontal
|
|
|
1202
1396
|
});
|
|
1203
1397
|
}), this.signalMarkerManager.on("removed", (e) => {
|
|
1204
1398
|
this.eventBus.emit("signalMarkerRemove", { id: e });
|
|
1205
|
-
}), this.tradeZoneManager = new st(), this.tradeZoneManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.tradeZoneManager.setDataGetter(() => this.
|
|
1399
|
+
}), this.tradeZoneManager = new st(), this.tradeZoneManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.tradeZoneManager.setDataGetter(() => this.series.bars()), this.tradeZoneManager.on("added", (e) => {
|
|
1206
1400
|
this.eventBus.emit("tradeZoneAdd", {
|
|
1207
1401
|
id: e.id,
|
|
1208
1402
|
direction: e.direction
|
|
@@ -1218,7 +1412,7 @@ var zn = .08, Bn = a ** -7, Vn = 800, Hn = 20, Un = 8, Wn = new Set(["horizontal
|
|
|
1218
1412
|
}), this.replayManager.on("stateChange", (e) => {
|
|
1219
1413
|
this.replayRestarting || this.eventBus.emit("replayState", { state: e });
|
|
1220
1414
|
}), this.measureOverlay = new Ve(), this.interactionManager = new Fe(e), this.features.panning) {
|
|
1221
|
-
let e = new
|
|
1415
|
+
let e = new Dn();
|
|
1222
1416
|
this.interactionManager.setPanHandler(new He((t, n) => {
|
|
1223
1417
|
t && this.viewport.scrollBy(t), e.step(t, n, this.options.autoScale !== !1) && n && (this.options.autoScale = !1, this.viewport.panPriceRange(n)), this.updateViewportAndRender();
|
|
1224
1418
|
}, () => e.reset()));
|
|
@@ -1272,7 +1466,7 @@ var zn = .08, Bn = a ** -7, Vn = 800, Hn = 20, Un = 8, Wn = new Set(["horizontal
|
|
|
1272
1466
|
let t = this.getDisplayData();
|
|
1273
1467
|
if (t.length === 0) return;
|
|
1274
1468
|
let n = this.viewport.getState(), i = n.barWidth + n.barSpacing, a = Math.round((n.offset + e.x) / i);
|
|
1275
|
-
a < 0 || a >= t.length || (this.pinnedTooltip.isPinned() && this.pinnedTooltip.getPinnedIndex() === a ? this.pinnedTooltip.unpin() : this.pinnedTooltip.pin(t[a], a, this.themeManager.getTheme(), l(t)), this.pinnedTooltip.reposition(this.viewport.getState(), this.
|
|
1469
|
+
a < 0 || a >= t.length || (this.pinnedTooltip.isPinned() && this.pinnedTooltip.getPinnedIndex() === a ? this.pinnedTooltip.unpin() : this.pinnedTooltip.pin(t[a], a, this.themeManager.getTheme(), l(t)), this.pinnedTooltip.reposition(this.viewport.getState(), this.series.bars()[a] ?? null, a, this.themeManager.getTheme()), this.engine.requestRender(r.Overlay));
|
|
1276
1470
|
}), this.interactionManager.setSignalMarkerHitTest((e) => this.eventBus.hasListeners("signalMarkerHover") || this.eventBus.hasListeners("signalMarkerClick") ? this.signalMarkerManager.markerAt(e, this.viewport.getState()) : null, (e, t) => this.eventBus.emit("signalMarkerHover", {
|
|
1277
1471
|
marker: e,
|
|
1278
1472
|
x: t.x,
|
|
@@ -1334,7 +1528,7 @@ var zn = .08, Bn = a ** -7, Vn = 800, Hn = 20, Un = 8, Wn = new Set(["horizontal
|
|
|
1334
1528
|
end: () => {
|
|
1335
1529
|
let e = this.selectionBoxOverlay.end();
|
|
1336
1530
|
if (e && this.zoomAreaMode) {
|
|
1337
|
-
if (e.x1 - e.x0 <
|
|
1531
|
+
if (e.x1 - e.x0 < qn) return;
|
|
1338
1532
|
this.zoomToBox(e), this.setZoomAreaMode(!1);
|
|
1339
1533
|
return;
|
|
1340
1534
|
}
|
|
@@ -1365,39 +1559,29 @@ var zn = .08, Bn = a ** -7, Vn = 800, Hn = 20, Un = 8, Wn = new Set(["horizontal
|
|
|
1365
1559
|
this.loadSeries(e, !1);
|
|
1366
1560
|
}
|
|
1367
1561
|
loadSeries(e, t) {
|
|
1368
|
-
this.snapshotKey = null, this.endReplaySession(), this.history.reset(), this.
|
|
1369
|
-
let n = this.
|
|
1562
|
+
this.snapshotKey = null, this.endReplaySession(), this.history.reset(), this.series.load(e), this.crosshairHandler.setData(this.series.bars()), this.displayDataCache = null, this.sessionBreaks.invalidateCache(), this.options.autoScale = this.defaultAutoScale;
|
|
1563
|
+
let n = this.series.bars(), r = n[n.length - 1];
|
|
1370
1564
|
t || (this.alertManager.clearLastValues(), r && this.alertManager.seedLastValue("price", r.close)), this.recalcIndicators(n), r && this.currentPriceLine.setPrice(r.close), this.updateViewportAndRender(!0), this.emitBars(n.length);
|
|
1371
1565
|
}
|
|
1372
1566
|
prependBars(e) {
|
|
1373
1567
|
if (this.replaySession) return 0;
|
|
1374
|
-
let t =
|
|
1375
|
-
if (
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
let
|
|
1379
|
-
|
|
1568
|
+
let t = this.getDisplayData(), n = Math.max(0, Math.min(t.length - 1, Math.floor(this.viewport.getState().visibleRange.from))), r = t[n]?.time, { added: i, taken: a } = this.series.prepend(e);
|
|
1569
|
+
if (i === 0) return a;
|
|
1570
|
+
let o = this.series.bars();
|
|
1571
|
+
if (this.crosshairHandler.setData(o), this.displayDataCache = null, this.sessionBreaks.invalidateCache(), this.pinnedTooltip.isPinned() && this.pinnedTooltip.unpin(), this.measureOverlay.end(), this.recalcIndicators(o), r !== void 0) {
|
|
1572
|
+
let e = Math.round(F(r, this.getDisplayData()));
|
|
1573
|
+
this.viewport.prependBars(e - n);
|
|
1380
1574
|
}
|
|
1381
|
-
|
|
1382
|
-
if (a === 0) return t ?? 0;
|
|
1383
|
-
let o = this.dataManager.getData();
|
|
1384
|
-
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) {
|
|
1385
|
-
let e = Math.round(F(i, this.getDisplayData()));
|
|
1386
|
-
this.viewport.prependBars(e - r);
|
|
1387
|
-
}
|
|
1388
|
-
return this.updateViewportAndRender(), t ?? a;
|
|
1575
|
+
return this.updateViewportAndRender(), a;
|
|
1389
1576
|
}
|
|
1390
1577
|
mergeSnapshot(e) {
|
|
1391
|
-
let t = this.
|
|
1392
|
-
|
|
1393
|
-
if (r === 0 || r === t.length) {
|
|
1578
|
+
let t = this.viewport.isAtEnd();
|
|
1579
|
+
if (!this.series.mergeSnapshot(e)) {
|
|
1394
1580
|
this.setData(e);
|
|
1395
1581
|
return;
|
|
1396
1582
|
}
|
|
1397
|
-
let
|
|
1398
|
-
this.
|
|
1399
|
-
let a = this.dataManager.getData();
|
|
1400
|
-
this.crosshairHandler.setData(a), this.displayDataCache = null, this.sessionBreaks.invalidateCache(), this.recalcIndicators(a), a.length > 0 && this.currentPriceLine.setPrice(a[a.length - 1].close), this.updateViewportAndRender(i), this.emitBars(a.length);
|
|
1583
|
+
let n = this.series.bars();
|
|
1584
|
+
this.crosshairHandler.setData(n), this.displayDataCache = null, this.sessionBreaks.invalidateCache(), this.recalcIndicators(n), n.length > 0 && this.currentPriceLine.setPrice(n[n.length - 1].close), this.updateViewportAndRender(t), this.emitBars(n.length);
|
|
1401
1585
|
}
|
|
1402
1586
|
setHistoryLoader(e, t) {
|
|
1403
1587
|
this.historyFromStream = !1, this.hostHistoryLoader = e !== null, this.history.setLoader(e, t?.pageSize), this.checkHistory();
|
|
@@ -1417,7 +1601,7 @@ var zn = .08, Bn = a ** -7, Vn = 800, Hn = 20, Un = 8, Wn = new Set(["horizontal
|
|
|
1417
1601
|
let { visibleRange: e, chartRect: t } = this.viewport.getState();
|
|
1418
1602
|
if (t.width <= 0) return;
|
|
1419
1603
|
let { from: n, to: r } = e;
|
|
1420
|
-
this.history.maybeLoad(Math.max(0, Math.floor(n)), Math.max(
|
|
1604
|
+
this.history.maybeLoad(Math.max(0, Math.floor(n)), Math.max(Kn, r - n));
|
|
1421
1605
|
}));
|
|
1422
1606
|
}
|
|
1423
1607
|
useStreamHistory(e, t) {
|
|
@@ -1432,68 +1616,47 @@ var zn = .08, Bn = a ** -7, Vn = 800, Hn = 20, Un = 8, Wn = new Set(["horizontal
|
|
|
1432
1616
|
}
|
|
1433
1617
|
appendBar(e) {
|
|
1434
1618
|
if (!z(e)) return;
|
|
1435
|
-
|
|
1436
|
-
|
|
1619
|
+
let t = this.series.append(e);
|
|
1620
|
+
if (t.refiltered && (this.displayDataCache = null), t.to !== "shown") {
|
|
1621
|
+
this.takeLivePrice(e.close), t.to === "hidden" && this.scheduleRender();
|
|
1437
1622
|
return;
|
|
1438
1623
|
}
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
return;
|
|
1442
|
-
}
|
|
1443
|
-
let t = this.autoScrollOnNewBar && this.viewport.isAtEnd(), n = this.dataManager.getLength();
|
|
1444
|
-
this.dataManager.appendBar(e);
|
|
1445
|
-
let r = this.dataManager.getData();
|
|
1446
|
-
this.crosshairHandler.setData(r), this.displayDataCache = null, this.recalcIndicatorsFrom(r, r.length - 2), this.currentPriceLine.setPrice(e.close), this.updateViewportAndRender(t), r.length !== n && this.emitBars(r.length), this.followLivePrice(e.close);
|
|
1624
|
+
let n = this.autoScrollOnNewBar && this.viewport.isAtEnd(), r = t.before, i = this.series.bars();
|
|
1625
|
+
this.crosshairHandler.setData(i), this.displayDataCache = null, this.recalcIndicatorsFrom(i, i.length - 2), this.currentPriceLine.setPrice(e.close), this.updateViewportAndRender(n), i.length !== r && this.emitBars(i.length), this.followLivePrice(e.close);
|
|
1447
1626
|
}
|
|
1448
1627
|
appendBars(e) {
|
|
1449
1628
|
if (e = e.filter(z), e.length === 0) return;
|
|
1450
|
-
let t = e[e.length - 1].close;
|
|
1451
|
-
if (this.
|
|
1452
|
-
|
|
1453
|
-
this.takeLivePrice(t);
|
|
1454
|
-
return;
|
|
1455
|
-
}
|
|
1456
|
-
let n = e.filter((e) => this.takeBar(e, "append"));
|
|
1457
|
-
if (n.length === 0) {
|
|
1458
|
-
this.takeLivePrice(t), this.scheduleRender();
|
|
1629
|
+
let t = e[e.length - 1].close, n = this.series.appendMany(e);
|
|
1630
|
+
if (n.refiltered && (this.displayDataCache = null), n.shown === 0) {
|
|
1631
|
+
this.takeLivePrice(t), n.aside || this.scheduleRender();
|
|
1459
1632
|
return;
|
|
1460
1633
|
}
|
|
1461
|
-
let r = this.autoScrollOnNewBar && this.viewport.isAtEnd(), i =
|
|
1462
|
-
for (let e of n) this.dataManager.appendBar(e);
|
|
1634
|
+
let r = this.autoScrollOnNewBar && this.viewport.isAtEnd(), i = n.before;
|
|
1463
1635
|
this.displayDataCache = null;
|
|
1464
|
-
let a = this.
|
|
1636
|
+
let a = this.series.bars();
|
|
1465
1637
|
this.recalcIndicatorsFrom(a, i - 1), this.crosshairHandler.setData(a), this.currentPriceLine.setPrice(t), this.updateViewportAndRender(r), a.length !== i && this.emitBars(a.length), this.followLivePrice(t);
|
|
1466
1638
|
}
|
|
1467
1639
|
updateLastBar(e) {
|
|
1468
1640
|
if (!z(e)) return;
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
}
|
|
1473
|
-
if (!this.takeBar(e, "update")) {
|
|
1474
|
-
this.takeLivePrice(e.close), this.scheduleRender();
|
|
1641
|
+
let t = this.series.updateLast(e);
|
|
1642
|
+
if (t.refiltered && (this.displayDataCache = null), t.to !== "shown") {
|
|
1643
|
+
this.takeLivePrice(e.close), t.to === "hidden" && this.scheduleRender();
|
|
1475
1644
|
return;
|
|
1476
1645
|
}
|
|
1477
|
-
this.
|
|
1478
|
-
let
|
|
1479
|
-
this.recalcIndicatorsFrom(
|
|
1646
|
+
this.currentPriceLine.setPrice(e.close), this.options.chartType !== "candlestick" && this.options.chartType !== "line" && this.options.chartType !== "area" && this.options.chartType !== "bar" && this.options.chartType !== "hollowCandle" && (this.displayDataCache = null);
|
|
1647
|
+
let n = this.series.bars();
|
|
1648
|
+
this.recalcIndicatorsFrom(n, n.length - 1), this.followLivePrice(e.close), this.scheduleRender();
|
|
1480
1649
|
}
|
|
1481
1650
|
updateLastBarFromTick(e) {
|
|
1482
1651
|
if (!Number.isFinite(e.price) || e.price < 0 || e.volume !== void 0 && !(Number.isFinite(e.volume) && e.volume >= 0)) return;
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
}
|
|
1487
|
-
let t = this.fullSeries ? this.sessionKeep(this.fullSeries) : null;
|
|
1488
|
-
if (t && !t(e.time)) {
|
|
1489
|
-
this.takeLivePrice(e.price), this.scheduleRender();
|
|
1652
|
+
let t = this.series.mergeTick(e);
|
|
1653
|
+
if (t.to !== "shown") {
|
|
1654
|
+
this.takeLivePrice(e.price), t.to === "hidden" && this.scheduleRender();
|
|
1490
1655
|
return;
|
|
1491
1656
|
}
|
|
1492
|
-
this.
|
|
1493
|
-
let n = this.
|
|
1494
|
-
|
|
1495
|
-
let i = this.dataManager.getData();
|
|
1496
|
-
this.recalcIndicatorsFrom(i, i.length - 1), this.followLivePrice(e.price), this.scheduleRender();
|
|
1657
|
+
this.currentPriceLine.setPrice(e.price), this.options.chartType !== "candlestick" && this.options.chartType !== "line" && this.options.chartType !== "area" && this.options.chartType !== "bar" && this.options.chartType !== "hollowCandle" && (this.displayDataCache = null);
|
|
1658
|
+
let n = this.series.bars();
|
|
1659
|
+
this.recalcIndicatorsFrom(n, n.length - 1), this.followLivePrice(e.price), this.scheduleRender();
|
|
1497
1660
|
}
|
|
1498
1661
|
getChartType() {
|
|
1499
1662
|
return this.options.chartType ?? "candlestick";
|
|
@@ -1527,46 +1690,16 @@ var zn = .08, Bn = a ** -7, Vn = 800, Hn = 20, Un = 8, Wn = new Set(["horizontal
|
|
|
1527
1690
|
sessionKeep(e) {
|
|
1528
1691
|
return this.extendedHours ? null : Ht(this.symbolInfo, e);
|
|
1529
1692
|
}
|
|
1530
|
-
shownBars(e) {
|
|
1531
|
-
let t = this.sessionKeep(e);
|
|
1532
|
-
return t ? e.filter((e) => t(e.time)) : e.slice();
|
|
1533
|
-
}
|
|
1534
|
-
regularOnly(e) {
|
|
1535
|
-
let t = this.sessionKeep(e);
|
|
1536
|
-
return this.fullSeries = t ? e.slice() : null, t ? e.filter((e) => t(e.time)) : e;
|
|
1537
|
-
}
|
|
1538
|
-
placeStreamBar(e) {
|
|
1539
|
-
let t = K(this.dataManager.getData(), e);
|
|
1540
|
-
return t === "stale" ? !1 : (t === "append" ? this.dataManager.appendBar(e) : this.dataManager.updateLastBar(e), !0);
|
|
1541
|
-
}
|
|
1542
|
-
takeBar(e, t) {
|
|
1543
|
-
if (!this.fullSeries && !this.extendedHours && !this.replaySession) {
|
|
1544
|
-
let n = this.dataManager.getData(), r = n.slice(-12), i = t === "append" || r.length === 0 ? [...r, e] : [...r.slice(0, -1), e];
|
|
1545
|
-
if (this.sessionKeep(i)) {
|
|
1546
|
-
this.fullSeries = n.slice();
|
|
1547
|
-
let e = this.sessionKeep(this.fullSeries.length > 1 ? this.fullSeries : i);
|
|
1548
|
-
e && n.some((t) => !e(t.time)) && (this.dataManager.setData(n.filter((t) => e(t.time))), this.displayDataCache = null);
|
|
1549
|
-
}
|
|
1550
|
-
}
|
|
1551
|
-
let n = this.fullSeries;
|
|
1552
|
-
if (!n) return !0;
|
|
1553
|
-
t === "append" || n.length === 0 ? n.push(e) : n[n.length - 1] = e;
|
|
1554
|
-
let r = this.sessionKeep(n);
|
|
1555
|
-
return !r || r(e.time);
|
|
1556
|
-
}
|
|
1557
1693
|
reapplyExtendedHours() {
|
|
1558
|
-
if (this.
|
|
1559
|
-
let e = this.
|
|
1560
|
-
|
|
1561
|
-
this.dataManager.setData(this.regularOnly(e));
|
|
1562
|
-
let t = this.dataManager.getData();
|
|
1563
|
-
this.crosshairHandler.setData(t), this.displayDataCache = null, this.sessionBreaks.invalidateCache(), this.recalcIndicators(t), this.updateViewportAndRender(!0), this.emitBars(t.length);
|
|
1694
|
+
if (!this.series.refilter()) return;
|
|
1695
|
+
let e = this.series.bars();
|
|
1696
|
+
this.crosshairHandler.setData(e), this.displayDataCache = null, this.sessionBreaks.invalidateCache(), this.recalcIndicators(e), this.updateViewportAndRender(!0), this.emitBars(e.length);
|
|
1564
1697
|
}
|
|
1565
1698
|
quoteLines() {
|
|
1566
1699
|
return this.priceLines.setQuoteShown(this.replaySession === null), this.priceLines;
|
|
1567
1700
|
}
|
|
1568
1701
|
setShapes(e) {
|
|
1569
|
-
let t =
|
|
1702
|
+
let t = $n(e);
|
|
1570
1703
|
t.tagRadius !== void 0 && (this.themeManager.setShape({
|
|
1571
1704
|
...this.themeManager.getTheme().shape,
|
|
1572
1705
|
...t
|
|
@@ -1593,12 +1726,12 @@ var zn = .08, Bn = a ** -7, Vn = 800, Hn = 20, Un = 8, Wn = new Set(["horizontal
|
|
|
1593
1726
|
getBidAsk() {
|
|
1594
1727
|
return this.priceLines.getBidAsk();
|
|
1595
1728
|
}
|
|
1596
|
-
addIndicator(e, t
|
|
1597
|
-
return this.recordIndicators(void 0, () => this.addIndicatorNow(e, t, n, r));
|
|
1729
|
+
addIndicator(e, t, n = "bottom", r = {}) {
|
|
1730
|
+
return this.recordIndicators(void 0, () => this.addIndicatorNow(e, t ?? {}, n, r));
|
|
1598
1731
|
}
|
|
1599
1732
|
addIndicatorNow(e, t, n, r) {
|
|
1600
1733
|
if (!this.isIndicatorAllowed(e)) return null;
|
|
1601
|
-
let i = this.indicatorEngine.getAvailableIndicators().find((t) => t.id === e), a = i ? this.paneFor(i, t, r.pane) : null, o = this.indicatorEngine.addIndicator(e, t, this.
|
|
1734
|
+
let i = this.indicatorEngine.getAvailableIndicators().find((t) => t.id === e), a = i ? this.paneFor(i, t, r.pane) : null, o = this.indicatorEngine.addIndicator(e, t, this.series.bars(), {
|
|
1602
1735
|
...a ? { pane: a } : {},
|
|
1603
1736
|
...r.scale === "left" ? { scale: "left" } : {},
|
|
1604
1737
|
...r.instanceId ? { instanceId: r.instanceId } : {}
|
|
@@ -1610,7 +1743,7 @@ var zn = .08, Bn = a ** -7, Vn = 800, Hn = 20, Un = 8, Wn = new Set(["horizontal
|
|
|
1610
1743
|
}
|
|
1611
1744
|
setSymbolSeries(e, t) {
|
|
1612
1745
|
e = e.trim(), this.symbolSeries.set(e, t), this.requestedSymbols.delete(e);
|
|
1613
|
-
let n = this.
|
|
1746
|
+
let n = this.series.bars(), r = !1;
|
|
1614
1747
|
for (let t of this.indicatorEngine.getActiveIndicators()) !M.has(t.id) || String(t.params.symbol ?? "").trim() !== e.trim() || (this.indicatorEngine.updateIndicator(t.instanceId, {}, n), r = !0);
|
|
1615
1748
|
r && (this.announceIndicatorUpdate(0), this.updateViewportAndRender());
|
|
1616
1749
|
}
|
|
@@ -1639,7 +1772,7 @@ var zn = .08, Bn = a ** -7, Vn = 800, Hn = 20, Un = 8, Wn = new Set(["horizontal
|
|
|
1639
1772
|
}
|
|
1640
1773
|
updateIndicatorNow(e, t) {
|
|
1641
1774
|
let n = this.indicatorEngine.getIndicatorDescriptor(e), r = n ? P(n) : null, i = r ? this.indicatorEngine.getIndicatorConfig(e)?.params[r] : void 0;
|
|
1642
|
-
this.indicatorEngine.updateIndicator(e, t, this.
|
|
1775
|
+
this.indicatorEngine.updateIndicator(e, t, this.series.bars()), this.announceIndicatorUpdate(0), this.markStateChanged(), this.eventBus.emit("indicatorChange", {
|
|
1643
1776
|
instanceId: e,
|
|
1644
1777
|
change: "params"
|
|
1645
1778
|
}), this.requestMissingSymbols(e);
|
|
@@ -1699,8 +1832,8 @@ var zn = .08, Bn = a ** -7, Vn = 800, Hn = 20, Un = 8, Wn = new Set(["horizontal
|
|
|
1699
1832
|
return {
|
|
1700
1833
|
...e,
|
|
1701
1834
|
priceRange: {
|
|
1702
|
-
min: t.min - n *
|
|
1703
|
-
max: t.max + n *
|
|
1835
|
+
min: t.min - n * Un,
|
|
1836
|
+
max: t.max + n * Un
|
|
1704
1837
|
},
|
|
1705
1838
|
logScale: !1,
|
|
1706
1839
|
scaleMode: "regular",
|
|
@@ -1910,7 +2043,7 @@ var zn = .08, Bn = a ** -7, Vn = 800, Hn = 20, Un = 8, Wn = new Set(["horizontal
|
|
|
1910
2043
|
return this.features.legend ? e + this.chartLegend.getHeight() : e;
|
|
1911
2044
|
}
|
|
1912
2045
|
isTimeAligned() {
|
|
1913
|
-
return R(this.options.chartType) ? !1 : this.getDisplayData().length === this.
|
|
2046
|
+
return R(this.options.chartType) ? !1 : this.getDisplayData().length === this.series.length();
|
|
1914
2047
|
}
|
|
1915
2048
|
roundPrice(e) {
|
|
1916
2049
|
if (!Number.isFinite(e)) return e;
|
|
@@ -1920,7 +2053,7 @@ var zn = .08, Bn = a ** -7, Vn = 800, Hn = 20, Un = 8, Wn = new Set(["horizontal
|
|
|
1920
2053
|
return Number(e.toFixed(this.marketPricePrecision ?? c(n, r)));
|
|
1921
2054
|
}
|
|
1922
2055
|
lastClose() {
|
|
1923
|
-
let e = this.
|
|
2056
|
+
let e = this.series.bars();
|
|
1924
2057
|
return e[e.length - 1]?.close ?? 0;
|
|
1925
2058
|
}
|
|
1926
2059
|
stepAt(e) {
|
|
@@ -2077,7 +2210,7 @@ var zn = .08, Bn = a ** -7, Vn = 800, Hn = 20, Un = 8, Wn = new Set(["horizontal
|
|
|
2077
2210
|
recordUndo(e) {
|
|
2078
2211
|
if (!this.features.drawingUndoRedo || typeof e?.undo != "function" || typeof e.redo != "function") return;
|
|
2079
2212
|
let t = performance.now(), n = this.undoRedoManager.last();
|
|
2080
|
-
if (e.subject !== void 0 && n?.type === "custom" && n.custom?.subject === e.subject && t - n.custom.at <
|
|
2213
|
+
if (e.subject !== void 0 && n?.type === "custom" && n.custom?.subject === e.subject && t - n.custom.at < Gn) {
|
|
2081
2214
|
this.undoRedoManager.replaceLast({
|
|
2082
2215
|
...n,
|
|
2083
2216
|
custom: {
|
|
@@ -2181,7 +2314,7 @@ var zn = .08, Bn = a ** -7, Vn = 800, Hn = 20, Un = 8, Wn = new Set(["horizontal
|
|
|
2181
2314
|
});
|
|
2182
2315
|
}
|
|
2183
2316
|
getExportData(e = {}) {
|
|
2184
|
-
let t = this.
|
|
2317
|
+
let t = this.series.bars(), n = 0, r = t.length - 1;
|
|
2185
2318
|
if (e.range === "visible") {
|
|
2186
2319
|
let { visibleRange: e } = this.viewport.getState();
|
|
2187
2320
|
n = Math.max(0, e.from), r = Math.min(t.length - 1, e.to);
|
|
@@ -2299,7 +2432,7 @@ var zn = .08, Bn = a ** -7, Vn = 800, Hn = 20, Un = 8, Wn = new Set(["horizontal
|
|
|
2299
2432
|
}
|
|
2300
2433
|
startBracket(e, t) {
|
|
2301
2434
|
if (!this.features.trading) return !1;
|
|
2302
|
-
let n = this.
|
|
2435
|
+
let n = this.series.bars(), r = t ?? (n.length > 0 ? n[n.length - 1].close : null);
|
|
2303
2436
|
return r === null ? !1 : (this.tradingManager.startBracket(e, r), !0);
|
|
2304
2437
|
}
|
|
2305
2438
|
cancelBracket() {
|
|
@@ -2313,7 +2446,7 @@ var zn = .08, Bn = a ** -7, Vn = 800, Hn = 20, Un = 8, Wn = new Set(["horizontal
|
|
|
2313
2446
|
}
|
|
2314
2447
|
startOrderDraft(e, t) {
|
|
2315
2448
|
if (!this.features.trading) return !1;
|
|
2316
|
-
let n = this.
|
|
2449
|
+
let n = this.series.bars(), r = t ?? (n.length > 0 ? n[n.length - 1].close : null);
|
|
2317
2450
|
return r === null ? !1 : (this.tradingManager.startOrderDraft(e, r), !0);
|
|
2318
2451
|
}
|
|
2319
2452
|
cancelOrderDraft() {
|
|
@@ -2383,13 +2516,13 @@ var zn = .08, Bn = a ** -7, Vn = 800, Hn = 20, Un = 8, Wn = new Set(["horizontal
|
|
|
2383
2516
|
this.replayTrades() || this.tradingManager.setCurrentPrice(e), this.features.alerts && this.checkAlerts(e);
|
|
2384
2517
|
}
|
|
2385
2518
|
checkAlerts(e) {
|
|
2386
|
-
let t = this.replaySession ? this.
|
|
2519
|
+
let t = this.replaySession ? this.series.liveBars() : this.series.bars();
|
|
2387
2520
|
this.alertManager.setBarTime(t.length > 0 ? t[t.length - 1].time : null);
|
|
2388
2521
|
let n = new Map([["price", e]]);
|
|
2389
2522
|
this.replaySession || this.collectIndicatorValues(n), this.alertManager.checkChannels(n, { together: !0 }), this.alertManager.checkDrawings(e);
|
|
2390
2523
|
}
|
|
2391
2524
|
collectIndicatorValues(e) {
|
|
2392
|
-
let t = this.
|
|
2525
|
+
let t = this.series.bars();
|
|
2393
2526
|
if (t.length === 0) return;
|
|
2394
2527
|
let n = t.length - 1, r = this.alertManager.getAlerts().flatMap((e) => e.target ? [e.channel, e.target] : [e.channel]);
|
|
2395
2528
|
for (let t of r) {
|
|
@@ -2407,32 +2540,24 @@ var zn = .08, Bn = a ** -7, Vn = 800, Hn = 20, Un = 8, Wn = new Set(["horizontal
|
|
|
2407
2540
|
if (!Ot(e.adapter, e.timeframe)) throw RangeError(`${e.adapter.name} cannot serve the ${e.timeframe} timeframe`);
|
|
2408
2541
|
this.snapshotKey = null, this.replayStop(), this.disconnectStream(), this.streamManager = new it(), this.streamManager.on("snapshot", (t) => {
|
|
2409
2542
|
let n = `${this.currentSymbol}|${this.streamTimeframe}`;
|
|
2410
|
-
this.replaySession ? this.
|
|
2543
|
+
this.replaySession ? this.series.loadAside(t) : n === this.snapshotKey && this.series.length() > 0 ? this.mergeSnapshot(t) : this.setData(t), this.snapshotKey = n, this.useStreamHistory(e.adapter, e.historyPageSize);
|
|
2411
2544
|
}), this.streamManager.on("barClose", (e) => {
|
|
2412
2545
|
if (!z(e)) return;
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
}
|
|
2417
|
-
let t = K(this.fullSeries ?? this.dataManager.getData(), e);
|
|
2418
|
-
if (t === "stale" || !this.takeBar(e, t)) return;
|
|
2419
|
-
let n = this.autoScrollOnNewBar && this.viewport.isAtEnd(), r = this.dataManager.getLength();
|
|
2420
|
-
if (!this.placeStreamBar(e)) return;
|
|
2421
|
-
let i = this.dataManager.getData();
|
|
2546
|
+
let t = this.series.placeStreamBar(e);
|
|
2547
|
+
if (t.refiltered && (this.displayDataCache = null), t.to === "aside" && this.followLivePrice(e.close), t.to !== "shown") return;
|
|
2548
|
+
let n = this.autoScrollOnNewBar && this.viewport.isAtEnd(), r = t.before, i = this.series.bars();
|
|
2422
2549
|
this.crosshairHandler.setData(i), this.displayDataCache = null, this.recalcIndicatorsFrom(i, i.length - 2), this.updateViewportAndRender(n), i.length !== r && this.emitBars(i.length), this.followLivePrice(e.close);
|
|
2423
2550
|
}), this.streamManager.on("barUpdate", (e) => {
|
|
2424
2551
|
if (!z(e)) return;
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
let t = K(this.fullSeries ?? this.dataManager.getData(), e), n = this.dataManager.getLength();
|
|
2431
|
-
if (t === "stale" || !this.takeBar(e, t) || !this.placeStreamBar(e)) {
|
|
2552
|
+
this.replaySession || this.currentPriceLine.setPrice(e.close);
|
|
2553
|
+
let t = this.series.placeStreamBar(e);
|
|
2554
|
+
if (t.refiltered && (this.displayDataCache = null), this.replaySession) return;
|
|
2555
|
+
let n = t.before;
|
|
2556
|
+
if (t.to !== "shown") {
|
|
2432
2557
|
this.scheduleRender();
|
|
2433
2558
|
return;
|
|
2434
2559
|
}
|
|
2435
|
-
let r = this.
|
|
2560
|
+
let r = this.series.bars();
|
|
2436
2561
|
this.indicatorEngine.deferRecalculateFrom(r, r.length - 1), this.announceIndicatorUpdate(r.length - 1), r.length !== n && this.emitBars(r.length), this.scheduleRender();
|
|
2437
2562
|
}), this.setBidAsk(null), this.streamManager.on("quote", (e) => {
|
|
2438
2563
|
let t = this.priceLines.getBidAsk();
|
|
@@ -2509,7 +2634,7 @@ var zn = .08, Bn = a ** -7, Vn = 800, Hn = 20, Un = 8, Wn = new Set(["horizontal
|
|
|
2509
2634
|
}
|
|
2510
2635
|
connectExecution(e, t = {}) {
|
|
2511
2636
|
if (!this.features.trading) throw Error("connectExecution requires features.trading to be enabled");
|
|
2512
|
-
this.disconnectExecution(), this.executionAdapter = e, this.execTeardown =
|
|
2637
|
+
this.disconnectExecution(), this.executionAdapter = e, this.execTeardown = Ln(e, {
|
|
2513
2638
|
onIntent: (e, t) => {
|
|
2514
2639
|
let n = (e) => t(e.payload);
|
|
2515
2640
|
return this.eventBus.on(e, n), () => this.eventBus.off(e, n);
|
|
@@ -2590,7 +2715,7 @@ var zn = .08, Bn = a ** -7, Vn = 800, Hn = 20, Un = 8, Wn = new Set(["horizontal
|
|
|
2590
2715
|
this.autoScrollOnNewBar = e;
|
|
2591
2716
|
}
|
|
2592
2717
|
scrollTo(e) {
|
|
2593
|
-
let t = this.
|
|
2718
|
+
let t = this.series.bars();
|
|
2594
2719
|
for (let n = 0; n < t.length; n++) if (t[n].time >= e) {
|
|
2595
2720
|
let e = this.viewport.getState().barWidth + this.viewport.getState().barSpacing;
|
|
2596
2721
|
this.viewport.scrollBy(n * e - this.viewport.getState().offset), this.updateViewportAndRender();
|
|
@@ -2795,7 +2920,7 @@ var zn = .08, Bn = a ** -7, Vn = 800, Hn = 20, Un = 8, Wn = new Set(["horizontal
|
|
|
2795
2920
|
n !== this.crosshairHandler.getSyncedSlot() && (this.crosshairHandler.setSyncedSlot(n), this.engine.requestRender(r.Hover));
|
|
2796
2921
|
}
|
|
2797
2922
|
getData() {
|
|
2798
|
-
return this.
|
|
2923
|
+
return this.series.bars();
|
|
2799
2924
|
}
|
|
2800
2925
|
setGridVisible(e) {
|
|
2801
2926
|
this.gridRenderer.setVisible(e), this.engine.requestRender(r.Background);
|
|
@@ -2837,7 +2962,7 @@ var zn = .08, Bn = a ** -7, Vn = 800, Hn = 20, Un = 8, Wn = new Set(["horizontal
|
|
|
2837
2962
|
e.opacity !== void 0 && this.depthHeatmap.setOpacity(e.opacity), e.capacity !== void 0 && this.depthHeatmap.setCapacity(e.capacity), this.engine.requestRender(r.Main);
|
|
2838
2963
|
}
|
|
2839
2964
|
pushDepthSnapshot(e, t) {
|
|
2840
|
-
let n = this.
|
|
2965
|
+
let n = this.series.bars(), i = t ?? n[n.length - 1]?.time;
|
|
2841
2966
|
i === void 0 || !Number.isFinite(i) || (this.depthHeatmap.push(i, e), this.depthHeatmap.isVisible() && this.engine.requestRender(r.Main));
|
|
2842
2967
|
}
|
|
2843
2968
|
clearDepthHeatmap() {
|
|
@@ -2853,7 +2978,7 @@ var zn = .08, Bn = a ** -7, Vn = 800, Hn = 20, Un = 8, Wn = new Set(["horizontal
|
|
|
2853
2978
|
this.periodLevels.setPeriod(e), this.engine.requestRender(r.Main);
|
|
2854
2979
|
}
|
|
2855
2980
|
setTimeZone(e) {
|
|
2856
|
-
|
|
2981
|
+
Vn(e), this.timeZoneSetting = e, this.applyTimeZone();
|
|
2857
2982
|
}
|
|
2858
2983
|
getTimeZone() {
|
|
2859
2984
|
return this.timeZoneSetting;
|
|
@@ -2885,7 +3010,7 @@ var zn = .08, Bn = a ** -7, Vn = 800, Hn = 20, Un = 8, Wn = new Set(["horizontal
|
|
|
2885
3010
|
}
|
|
2886
3011
|
setSymbolInfo(e) {
|
|
2887
3012
|
let t = e && this.symbolInfo?.symbol === e.symbol ? w(this.symbolInfo) : void 0;
|
|
2888
|
-
this.symbolInfo = e ?
|
|
3013
|
+
this.symbolInfo = e ? Hn({
|
|
2889
3014
|
...e,
|
|
2890
3015
|
sessions: e.sessions?.map((e) => ({ ...e }))
|
|
2891
3016
|
}, t) : null, this.chartLegend.setExchange(this.symbolInfo?.exchange ?? ""), this.engine.requestRender(r.Hover), this.priceAxis.setPriceTick(this.symbolInfo?.minTick ?? null), this.marketConfig?.pricePrecision === void 0 && this.applyPricePrecision(this.symbolInfo?.pricePrecision ?? null);
|
|
@@ -2910,7 +3035,7 @@ var zn = .08, Bn = a ** -7, Vn = 800, Hn = 20, Un = 8, Wn = new Set(["horizontal
|
|
|
2910
3035
|
if (!e || typeof e != "object") return;
|
|
2911
3036
|
let t = this.currentSymbol, n = (e) => !e || e.toUpperCase() === t.toUpperCase();
|
|
2912
3037
|
if (!n(e.symbol)) return;
|
|
2913
|
-
let r = this.symbolInfo && n(this.symbolInfo.symbol) ? this.symbolInfo : null, i =
|
|
3038
|
+
let r = this.symbolInfo && n(this.symbolInfo.symbol) ? this.symbolInfo : null, i = Hn({
|
|
2914
3039
|
...r,
|
|
2915
3040
|
...e,
|
|
2916
3041
|
symbol: e.symbol || r?.symbol || t
|
|
@@ -3048,7 +3173,7 @@ var zn = .08, Bn = a ** -7, Vn = 800, Hn = 20, Un = 8, Wn = new Set(["horizontal
|
|
|
3048
3173
|
return this.features.alerts && this.drawingLevelsNow(e) !== null;
|
|
3049
3174
|
}
|
|
3050
3175
|
drawingLevelsNow(e) {
|
|
3051
|
-
let t = this.replaySession ? this.
|
|
3176
|
+
let t = this.replaySession ? this.series.liveBars() : this.getDisplayData();
|
|
3052
3177
|
if (t.length === 0) return null;
|
|
3053
3178
|
let n = {
|
|
3054
3179
|
...this.viewport.getState(),
|
|
@@ -3132,41 +3257,39 @@ var zn = .08, Bn = a ** -7, Vn = 800, Hn = 20, Un = 8, Wn = new Set(["horizontal
|
|
|
3132
3257
|
this.history.reset();
|
|
3133
3258
|
let t = this.replaySession ? this.replayOffset : 0;
|
|
3134
3259
|
if (!this.replaySession) {
|
|
3135
|
-
if (this.
|
|
3136
|
-
|
|
3137
|
-
e.setData(this.fullSeries ?? this.dataManager.getData()), this.replaySession = {
|
|
3138
|
-
live: e,
|
|
3260
|
+
if (this.series.length() === 0) return;
|
|
3261
|
+
this.series.beginReplay(), this.replaySession = {
|
|
3139
3262
|
price: null,
|
|
3140
3263
|
fedTime: null
|
|
3141
3264
|
};
|
|
3142
3265
|
}
|
|
3143
|
-
let { steps: n, startTime: r, hideHistory: i, revealMarks: a, ...o } = e ?? {}, s = this.
|
|
3144
|
-
r !== void 0 && l === void 0 ? l =
|
|
3266
|
+
let { steps: n, startTime: r, hideHistory: i, revealMarks: a, ...o } = e ?? {}, s = this.series.inHoursShown(this.series.liveBars()), c = t > 0 && r === void 0 && i !== !1, l = o.startIndex;
|
|
3267
|
+
r !== void 0 && l === void 0 ? l = rr(s, r) : c && l !== void 0 && (l += t);
|
|
3145
3268
|
let u = c ? t : i && l !== void 0 && l > 0 ? Math.min(Math.floor(l), s.length - 1) : 0, d = u > 0 ? s.slice(u) : s;
|
|
3146
3269
|
l !== void 0 && (o.startIndex = l - u), this.replayOffset = u, this.replayRevealMarks = a !== !1;
|
|
3147
|
-
let f = n ?
|
|
3270
|
+
let f = n ? sr(n, d) : null;
|
|
3148
3271
|
this.replayStepsSeries = f, this.replayCoarse = d, this.options.autoScale = !0, this.replayRestarting = !0;
|
|
3149
3272
|
try {
|
|
3150
3273
|
this.replayManager.load(f ?? d);
|
|
3151
3274
|
} finally {
|
|
3152
3275
|
this.replayRestarting = !1;
|
|
3153
3276
|
}
|
|
3154
|
-
f && o.startIndex !== void 0 && (o.startIndex =
|
|
3277
|
+
f && o.startIndex !== void 0 && (o.startIndex = q(f, d, o.startIndex)), this.replayBarUnsub?.();
|
|
3155
3278
|
let p = -1, m = -1, h = null, g = f ?? d;
|
|
3156
3279
|
this.replayBarUnsub = this.replayManager.on("bar", ({ index: e }) => {
|
|
3157
3280
|
let t = e, n = d[e];
|
|
3158
3281
|
if (f) {
|
|
3159
3282
|
let r = f[e];
|
|
3160
|
-
t =
|
|
3283
|
+
t = cr(d, r.time), h = h !== null && m === e - 1 && t === p - 1 && h ? ur(h, r) : lr(d[t], f, e), n = h;
|
|
3161
3284
|
}
|
|
3162
3285
|
m = e;
|
|
3163
|
-
let r = t + 1, i = p > 0 && r >= p && this.
|
|
3286
|
+
let r = t + 1, i = p > 0 && r >= p && this.series.length() === p, a = !(i && !this.replaySeeking) || this.autoScrollOnNewBar && this.viewport.isAtEnd();
|
|
3164
3287
|
if (i) {
|
|
3165
|
-
f && r > p && this.
|
|
3166
|
-
for (let e = p; e < r - 1; e++) this.
|
|
3167
|
-
r > p ? this.
|
|
3168
|
-
} else this.
|
|
3169
|
-
p = r, this.currentPriceLine.setPrice(n.close, t > 0 ? d[t - 1].close : void 0), this.crosshairHandler.setData(this.
|
|
3288
|
+
f && r > p && this.series.updateReplayed(d[p - 1]);
|
|
3289
|
+
for (let e = p; e < r - 1; e++) this.series.appendReplayed(d[e]);
|
|
3290
|
+
r > p ? this.series.appendReplayed(n) : this.series.updateReplayed(n), this.recalcIndicatorsFrom(this.series.bars(), Math.max(0, p - 1));
|
|
3291
|
+
} else this.series.showReplayed([...d.slice(0, t), n]), this.recalcIndicators(this.series.bars());
|
|
3292
|
+
p = r, this.currentPriceLine.setPrice(n.close, t > 0 ? d[t - 1].close : void 0), this.crosshairHandler.setData(this.series.bars());
|
|
3170
3293
|
let o = g[e + 1]?.time ?? g[e].time + (e > 0 ? g[e].time - g[e - 1].time : 1);
|
|
3171
3294
|
this.replayRevealMarks && this.revealReplayMarks(o), this.displayDataCache = null, this.updateViewportAndRender(a), this.feedReplaySteps(g, e), this.eventBus.emit("replayStep", {
|
|
3172
3295
|
barIndex: t,
|
|
@@ -3198,7 +3321,7 @@ var zn = .08, Bn = a ** -7, Vn = 800, Hn = 20, Un = 8, Wn = new Set(["horizontal
|
|
|
3198
3321
|
returnMarkToLive() {
|
|
3199
3322
|
let e = this.replaySession;
|
|
3200
3323
|
if (!e || !this.replayTrades()) return;
|
|
3201
|
-
let t =
|
|
3324
|
+
let t = this.series.liveBars(), n = e.price?.price ?? t[t.length - 1]?.close;
|
|
3202
3325
|
n !== void 0 && this.feedReplayPrice(n);
|
|
3203
3326
|
}
|
|
3204
3327
|
feedReplaySteps(e, t) {
|
|
@@ -3209,20 +3332,20 @@ var zn = .08, Bn = a ** -7, Vn = 800, Hn = 20, Un = 8, Wn = new Set(["horizontal
|
|
|
3209
3332
|
return;
|
|
3210
3333
|
}
|
|
3211
3334
|
if (i.time <= n.fedTime) return;
|
|
3212
|
-
let a = e.slice(
|
|
3335
|
+
let a = e.slice(ir(e, n.fedTime), t + 1);
|
|
3213
3336
|
n.fedTime = i.time;
|
|
3214
|
-
let o = Math.ceil(a.length /
|
|
3215
|
-
for (let e = 0; e < a.length; e += o) for (let [t, n] of
|
|
3337
|
+
let o = Math.ceil(a.length / nr);
|
|
3338
|
+
for (let e = 0; e < a.length; e += o) for (let [t, n] of ar(a.slice(e, e + o))) r.setMarkPrice(t, n);
|
|
3216
3339
|
this.tradingManager.setCurrentPrice(i.close);
|
|
3217
3340
|
}
|
|
3218
3341
|
getReplayBarIndex() {
|
|
3219
3342
|
if (!this.replaySession) return -1;
|
|
3220
3343
|
let { current: e } = this.replayManager.getProgress(), t = this.replayStepsSeries;
|
|
3221
|
-
return t && this.replayCoarse ?
|
|
3344
|
+
return t && this.replayCoarse ? cr(this.replayCoarse, t[e]?.time ?? -Infinity) : e;
|
|
3222
3345
|
}
|
|
3223
3346
|
replaySeekToBar(e) {
|
|
3224
3347
|
let t = this.replayStepsSeries;
|
|
3225
|
-
this.replaySeek(t && this.replayCoarse ?
|
|
3348
|
+
this.replaySeek(t && this.replayCoarse ? q(t, this.replayCoarse, e) : e);
|
|
3226
3349
|
}
|
|
3227
3350
|
replayPause() {
|
|
3228
3351
|
this.replayManager.pause();
|
|
@@ -3231,8 +3354,8 @@ var zn = .08, Bn = a ** -7, Vn = 800, Hn = 20, Un = 8, Wn = new Set(["horizontal
|
|
|
3231
3354
|
this.replayManager.resume();
|
|
3232
3355
|
}
|
|
3233
3356
|
replayStop() {
|
|
3234
|
-
let e = this.replaySession;
|
|
3235
|
-
|
|
3357
|
+
let e = this.replaySession, t = this.endReplaySession();
|
|
3358
|
+
!e || !t || (this.loadSeries(t, !0), e.price && this.currentPriceLine.setPrice(e.price.price, e.price.previousClose));
|
|
3236
3359
|
}
|
|
3237
3360
|
isReplayActive() {
|
|
3238
3361
|
return this.replaySession !== null;
|
|
@@ -3257,7 +3380,7 @@ var zn = .08, Bn = a ** -7, Vn = 800, Hn = 20, Un = 8, Wn = new Set(["horizontal
|
|
|
3257
3380
|
let t = kt(e.time, n), r = Ct(e.price, n);
|
|
3258
3381
|
i = Math.min(i, t), a = Math.max(a, t), o = Math.min(o, r), s = Math.max(s, r);
|
|
3259
3382
|
}
|
|
3260
|
-
return
|
|
3383
|
+
return Jn.has(t.type) ? [i, a] = [r.x, r.x + r.width] : t.type === "horizontalRay" && (a = r.x + r.width), Yn.has(t.type) && ([o, s] = [r.y, r.y + r.height]), i = Math.max(i, r.x), a = Math.min(a, r.x + r.width), o = Math.max(o, r.y), s = Math.min(s, r.y + r.height), i <= a && o <= s ? {
|
|
3261
3384
|
x: i,
|
|
3262
3385
|
y: o,
|
|
3263
3386
|
width: a - i,
|
|
@@ -3265,7 +3388,10 @@ var zn = .08, Bn = a ** -7, Vn = 800, Hn = 20, Un = 8, Wn = new Set(["horizontal
|
|
|
3265
3388
|
} : null;
|
|
3266
3389
|
}
|
|
3267
3390
|
endReplaySession() {
|
|
3268
|
-
|
|
3391
|
+
if (!this.replaySession) return null;
|
|
3392
|
+
this.returnMarkToLive();
|
|
3393
|
+
let e = this.series.endReplay();
|
|
3394
|
+
return this.replaySession = null, this.replayStepsSeries = null, this.replayCoarse = null, this.replayBarUnsub?.(), this.replayBarUnsub = null, this.replayManager.stop(), this.replayOffset = 0, this.revealReplayMarks(null), e;
|
|
3269
3395
|
}
|
|
3270
3396
|
replaySeek(e) {
|
|
3271
3397
|
this.replaySeeking = !0;
|
|
@@ -3298,14 +3424,14 @@ var zn = .08, Bn = a ** -7, Vn = 800, Hn = 20, Un = 8, Wn = new Set(["horizontal
|
|
|
3298
3424
|
});
|
|
3299
3425
|
}
|
|
3300
3426
|
restoreIndicators(e, t) {
|
|
3301
|
-
let n =
|
|
3427
|
+
let n = Zn(e), r = /* @__PURE__ */ new Map();
|
|
3302
3428
|
this.unrestoredIndicators = [];
|
|
3303
3429
|
let i = new Set(this.indicatorEngine.getAvailableIndicators().map((e) => e.id)), a = [], o = /* @__PURE__ */ new Set();
|
|
3304
3430
|
if (t) {
|
|
3305
3431
|
let e = new Map(n.map((e) => [e.instanceId, e])), t = this.getIndicatorSetup();
|
|
3306
3432
|
for (let n of t) {
|
|
3307
3433
|
let t = e.get(n.instanceId);
|
|
3308
|
-
t &&
|
|
3434
|
+
t && Qn(n, t) && o.add(n.instanceId);
|
|
3309
3435
|
}
|
|
3310
3436
|
for (let e of t) o.has(e.instanceId) || this.removeIndicator(e.instanceId);
|
|
3311
3437
|
for (let e of [...o]) this.indicatorEngine.getIndicatorConfig(e) || o.delete(e);
|
|
@@ -3472,7 +3598,7 @@ var zn = .08, Bn = a ** -7, Vn = 800, Hn = 20, Un = 8, Wn = new Set(["horizontal
|
|
|
3472
3598
|
if (this.indicatorHistoryDepth > 0 || !this.features.drawingUndoRedo) return t();
|
|
3473
3599
|
let n = this.getIndicatorSetup(), r = this.withoutIndicatorHistory(t), i = this.getIndicatorSetup();
|
|
3474
3600
|
if (JSON.stringify(n) === JSON.stringify(i)) return r;
|
|
3475
|
-
let a = performance.now(), o = this.undoRedoManager.last(), s = e !== void 0 && o?.type === "indicators" && o.indicators?.subject === e && a - (o.indicators.at ?? 0) <
|
|
3601
|
+
let a = performance.now(), o = this.undoRedoManager.last(), s = e !== void 0 && o?.type === "indicators" && o.indicators?.subject === e && a - (o.indicators.at ?? 0) < Gn && JSON.stringify(o.indicators.after) === JSON.stringify(n), c = {
|
|
3476
3602
|
type: "indicators",
|
|
3477
3603
|
before: null,
|
|
3478
3604
|
after: null
|
|
@@ -3611,11 +3737,11 @@ var zn = .08, Bn = a ** -7, Vn = 800, Hn = 20, Un = 8, Wn = new Set(["horizontal
|
|
|
3611
3737
|
return t instanceof D && t.setPriceText((e) => this.formatPrice(e)), t;
|
|
3612
3738
|
}
|
|
3613
3739
|
crosshairSeries() {
|
|
3614
|
-
return this.isTimeAligned() ? this.
|
|
3740
|
+
return this.isTimeAligned() ? this.series.bars() : this.getDisplayData();
|
|
3615
3741
|
}
|
|
3616
3742
|
getDisplayData() {
|
|
3617
3743
|
if (this.displayDataCache) return this.displayDataCache;
|
|
3618
|
-
let e = this.
|
|
3744
|
+
let e = this.series.bars();
|
|
3619
3745
|
if (e.length === 0) return e;
|
|
3620
3746
|
let t = rn(this.options.chartType, e, (e) => this.pluginManager.getChartType(e), this.chartTypeOptions);
|
|
3621
3747
|
return this.chartRenderer instanceof A && !this.pluginManager.getChartType(this.options.chartType) && this.chartRenderer.setBoxSize(en(e, this.chartTypeOptions)), this.displayDataCache = t, t;
|
|
@@ -3671,7 +3797,7 @@ var zn = .08, Bn = a ** -7, Vn = 800, Hn = 20, Un = 8, Wn = new Set(["horizontal
|
|
|
3671
3797
|
}
|
|
3672
3798
|
fitPriceScale(e, t) {
|
|
3673
3799
|
if (e.length === 0) return;
|
|
3674
|
-
let n = Math.max(0, t.visibleRange.from), r = Math.min(t.visibleRange.to, e.length - 1), i =
|
|
3800
|
+
let n = Math.max(0, t.visibleRange.from), r = Math.min(t.visibleRange.to, e.length - 1), i = tr(tr(f(e, n, r, 0), this.indicatorEngine.getOverlayPriceRange(n, r)), this.features.compareSymbols ? this.compareRenderer.getPriceRange(e, t) : null), a = this.features.volume && this.volumeRenderer.isVisible() && er(e, n, r) ? this.volumeRenderer.getHeightRatio() + Wn : k;
|
|
3675
3801
|
this.viewport.setScaleMargins(this.viewport.isInvertScale() ? {
|
|
3676
3802
|
top: a,
|
|
3677
3803
|
bottom: k
|
|
@@ -3693,7 +3819,7 @@ var zn = .08, Bn = a ** -7, Vn = 800, Hn = 20, Un = 8, Wn = new Set(["horizontal
|
|
|
3693
3819
|
fitLeftAxisWidth() {
|
|
3694
3820
|
let e = this.leftViewport;
|
|
3695
3821
|
if (!e) return !1;
|
|
3696
|
-
let t = this.themeManager.getTheme(), n =
|
|
3822
|
+
let t = this.themeManager.getTheme(), n = Tn({
|
|
3697
3823
|
min: e.priceRange.min,
|
|
3698
3824
|
max: e.priceRange.max,
|
|
3699
3825
|
lastPrice: null,
|
|
@@ -3702,12 +3828,12 @@ var zn = .08, Bn = a ** -7, Vn = 800, Hn = 20, Un = 8, Wn = new Set(["horizontal
|
|
|
3702
3828
|
fontFamily: t.font.family,
|
|
3703
3829
|
fontSizeSmall: t.font.sizeSmall,
|
|
3704
3830
|
measure: (e, t) => this.measureText(e, t)
|
|
3705
|
-
}), r =
|
|
3831
|
+
}), r = En(this.leftAxisWidth, n);
|
|
3706
3832
|
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);
|
|
3707
3833
|
}
|
|
3708
3834
|
fitPriceAxisWidth() {
|
|
3709
3835
|
if (!this.features.priceAxis) return !1;
|
|
3710
|
-
let { priceRange: e } = this.viewport.getState(), t = this.themeManager.getTheme(), n =
|
|
3836
|
+
let { priceRange: e } = this.viewport.getState(), t = this.themeManager.getTheme(), n = Tn({
|
|
3711
3837
|
min: e.min,
|
|
3712
3838
|
max: e.max,
|
|
3713
3839
|
lastPrice: this.currentPriceLine.getPrice(),
|
|
@@ -3718,7 +3844,7 @@ var zn = .08, Bn = a ** -7, Vn = 800, Hn = 20, Un = 8, Wn = new Set(["horizontal
|
|
|
3718
3844
|
fontFamily: t.font.family,
|
|
3719
3845
|
fontSizeSmall: t.font.sizeSmall,
|
|
3720
3846
|
measure: (e, t) => this.measureText(e, t)
|
|
3721
|
-
}), r =
|
|
3847
|
+
}), r = En(this.priceAxisWidth, n);
|
|
3722
3848
|
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);
|
|
3723
3849
|
}
|
|
3724
3850
|
measureText(e, t) {
|
|
@@ -3762,7 +3888,7 @@ var zn = .08, Bn = a ** -7, Vn = 800, Hn = 20, Un = 8, Wn = new Set(["horizontal
|
|
|
3762
3888
|
buildPanelRenderInfos() {
|
|
3763
3889
|
if (this.panelInfoCache) return this.panelInfoCache;
|
|
3764
3890
|
let e = this.getResolvedLayout(), t = this.viewport.getState(), { from: n, to: r } = t.visibleRange, i = e.panels.map((e) => {
|
|
3765
|
-
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) ?? { ...
|
|
3891
|
+
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) ?? { ...Rn }, o = {
|
|
3766
3892
|
x: e.rect.x,
|
|
3767
3893
|
y: e.rect.y + 20,
|
|
3768
3894
|
width: e.rect.width,
|
|
@@ -3844,7 +3970,7 @@ var zn = .08, Bn = a ** -7, Vn = 800, Hn = 20, Un = 8, Wn = new Set(["horizontal
|
|
|
3844
3970
|
});
|
|
3845
3971
|
}
|
|
3846
3972
|
drawOverlayPlugins(e, t) {
|
|
3847
|
-
let n =
|
|
3973
|
+
let n = kn(this.pluginManager.getOverlays(), t);
|
|
3848
3974
|
if (n.length === 0) return;
|
|
3849
3975
|
let r = {
|
|
3850
3976
|
viewport: this.viewport.getState(),
|
|
@@ -3865,7 +3991,7 @@ var zn = .08, Bn = a ** -7, Vn = 800, Hn = 20, Un = 8, Wn = new Set(["horizontal
|
|
|
3865
3991
|
};
|
|
3866
3992
|
}
|
|
3867
3993
|
};
|
|
3868
|
-
function
|
|
3994
|
+
function Zn(e) {
|
|
3869
3995
|
let t = new Map(e.map((e) => [e.instanceId, e])), n = [], r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), a = (e) => {
|
|
3870
3996
|
if (r.has(e.instanceId) || i.has(e.instanceId)) return;
|
|
3871
3997
|
i.add(e.instanceId);
|
|
@@ -3879,24 +4005,24 @@ function qn(e) {
|
|
|
3879
4005
|
for (let t of e) a(t);
|
|
3880
4006
|
return n;
|
|
3881
4007
|
}
|
|
3882
|
-
function
|
|
4008
|
+
function Qn(e, t) {
|
|
3883
4009
|
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);
|
|
3884
4010
|
}
|
|
3885
|
-
function
|
|
4011
|
+
function $n(e) {
|
|
3886
4012
|
let t = e.tagRadius;
|
|
3887
4013
|
return typeof t == "number" && Number.isFinite(t) && t >= 0 ? { tagRadius: Math.min(t, 999) } : {};
|
|
3888
4014
|
}
|
|
3889
|
-
function
|
|
4015
|
+
function er(e, t, n) {
|
|
3890
4016
|
for (let r = t; r <= n; r++) if (e[r].volume > 0) return !0;
|
|
3891
4017
|
return !1;
|
|
3892
4018
|
}
|
|
3893
|
-
function
|
|
4019
|
+
function tr(e, t) {
|
|
3894
4020
|
return e ? t ? {
|
|
3895
4021
|
min: Math.min(e.min, t.min),
|
|
3896
4022
|
max: Math.max(e.max, t.max)
|
|
3897
4023
|
} : e : t;
|
|
3898
4024
|
}
|
|
3899
|
-
function
|
|
4025
|
+
function K(e) {
|
|
3900
4026
|
return {
|
|
3901
4027
|
id: e.id,
|
|
3902
4028
|
price: e.price,
|
|
@@ -3911,8 +4037,8 @@ function G(e) {
|
|
|
3911
4037
|
bars: e.bars
|
|
3912
4038
|
};
|
|
3913
4039
|
}
|
|
3914
|
-
var
|
|
3915
|
-
function
|
|
4040
|
+
var nr = 500;
|
|
4041
|
+
function rr(e, t) {
|
|
3916
4042
|
let n = 0, r = e.length;
|
|
3917
4043
|
for (; n < r;) {
|
|
3918
4044
|
let i = n + r >> 1;
|
|
@@ -3920,7 +4046,7 @@ function $n(e, t) {
|
|
|
3920
4046
|
}
|
|
3921
4047
|
return n;
|
|
3922
4048
|
}
|
|
3923
|
-
function
|
|
4049
|
+
function ir(e, t) {
|
|
3924
4050
|
let n = 0, r = e.length;
|
|
3925
4051
|
for (; n < r;) {
|
|
3926
4052
|
let i = n + r >> 1;
|
|
@@ -3928,20 +4054,20 @@ function er(e, t) {
|
|
|
3928
4054
|
}
|
|
3929
4055
|
return n;
|
|
3930
4056
|
}
|
|
3931
|
-
function
|
|
4057
|
+
function ar(e) {
|
|
3932
4058
|
let t = 0, n = 0;
|
|
3933
4059
|
for (let r = 1; r < e.length; r++) e[r].low < e[t].low && (t = r), e[r].high > e[n].high && (n = r);
|
|
3934
4060
|
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];
|
|
3935
4061
|
return [...a ? [r, i] : [i, r], [o.close, o.time]];
|
|
3936
4062
|
}
|
|
3937
|
-
function
|
|
4063
|
+
function or(e) {
|
|
3938
4064
|
let t = 0;
|
|
3939
4065
|
for (let n = Math.max(1, e.length - 10); n < e.length; n++) t = Math.max(t, e[n].time - e[n - 1].time);
|
|
3940
4066
|
return t > 0 ? t : Infinity;
|
|
3941
4067
|
}
|
|
3942
|
-
function
|
|
4068
|
+
function sr(e, t) {
|
|
3943
4069
|
if (t.length === 0) return null;
|
|
3944
|
-
let n = t[t.length - 1].time +
|
|
4070
|
+
let n = t[t.length - 1].time + or(t), r = e.filter((e) => ln(e) && e.time >= t[0].time && e.time < n).sort((e, t) => e.time - t.time), i = [];
|
|
3945
4071
|
for (let e of r) (i.length === 0 || i[i.length - 1].time !== e.time) && i.push(e);
|
|
3946
4072
|
if (i.length === 0) return null;
|
|
3947
4073
|
let a = t.findIndex((e) => e.time >= i[0].time);
|
|
@@ -3949,16 +4075,7 @@ function rr(e, t) {
|
|
|
3949
4075
|
let o = t.slice(0, a), s = i.filter((e) => e.time >= t[a].time);
|
|
3950
4076
|
return [...o, ...s];
|
|
3951
4077
|
}
|
|
3952
|
-
function
|
|
3953
|
-
return [
|
|
3954
|
-
e.time,
|
|
3955
|
-
e.open,
|
|
3956
|
-
e.high,
|
|
3957
|
-
e.low,
|
|
3958
|
-
e.close
|
|
3959
|
-
].every(Number.isFinite);
|
|
3960
|
-
}
|
|
3961
|
-
function ar(e, t) {
|
|
4078
|
+
function cr(e, t) {
|
|
3962
4079
|
let n = 0, r = e.length - 1;
|
|
3963
4080
|
for (; n < r;) {
|
|
3964
4081
|
let i = n + r + 1 >> 1;
|
|
@@ -3966,22 +4083,22 @@ function ar(e, t) {
|
|
|
3966
4083
|
}
|
|
3967
4084
|
return n;
|
|
3968
4085
|
}
|
|
3969
|
-
function
|
|
4086
|
+
function q(e, t, n) {
|
|
3970
4087
|
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;
|
|
3971
4088
|
for (let t = 0; t < e.length && e[t].time < i; t++) a = t;
|
|
3972
4089
|
return Math.max(0, a);
|
|
3973
4090
|
}
|
|
3974
|
-
function
|
|
4091
|
+
function lr(e, t, n) {
|
|
3975
4092
|
let r = n;
|
|
3976
4093
|
for (; r > 0 && t[r - 1].time >= e.time;) r--;
|
|
3977
4094
|
let i = {
|
|
3978
4095
|
...t[r],
|
|
3979
4096
|
time: e.time
|
|
3980
4097
|
};
|
|
3981
|
-
for (let e = r + 1; e <= n; e++) i =
|
|
4098
|
+
for (let e = r + 1; e <= n; e++) i = ur(i, t[e]);
|
|
3982
4099
|
return i;
|
|
3983
4100
|
}
|
|
3984
|
-
function
|
|
4101
|
+
function ur(e, t) {
|
|
3985
4102
|
return {
|
|
3986
4103
|
time: e.time,
|
|
3987
4104
|
open: e.open,
|
|
@@ -3991,34 +4108,28 @@ function cr(e, t) {
|
|
|
3991
4108
|
volume: (e.volume ?? 0) + (t.volume ?? 0)
|
|
3992
4109
|
};
|
|
3993
4110
|
}
|
|
3994
|
-
function K(e, t) {
|
|
3995
|
-
let n = e[e.length - 1];
|
|
3996
|
-
if (!n) return "append";
|
|
3997
|
-
let r = v(t.time), i = v(n.time);
|
|
3998
|
-
return r > i ? "append" : r === i ? "update" : "stale";
|
|
3999
|
-
}
|
|
4000
4111
|
//#endregion
|
|
4001
4112
|
//#region src/io/parseOHLCV.ts
|
|
4002
|
-
var
|
|
4113
|
+
var dr = [
|
|
4003
4114
|
"time",
|
|
4004
4115
|
"timestamp",
|
|
4005
4116
|
"date",
|
|
4006
4117
|
"datetime",
|
|
4007
4118
|
"t"
|
|
4008
|
-
],
|
|
4119
|
+
], fr = ["open", "o"], pr = ["high", "h"], mr = ["low", "l"], hr = ["close", "c"], gr = [
|
|
4009
4120
|
"volume",
|
|
4010
4121
|
"vol",
|
|
4011
4122
|
"v"
|
|
4012
4123
|
];
|
|
4013
|
-
function
|
|
4124
|
+
function _r(e) {
|
|
4014
4125
|
let t = e.trim();
|
|
4015
|
-
return t ? t[0] === "[" || t[0] === "{" ?
|
|
4126
|
+
return t ? t[0] === "[" || t[0] === "{" ? vr(t) : yr(t) : {
|
|
4016
4127
|
data: [],
|
|
4017
4128
|
rowCount: 0,
|
|
4018
4129
|
skipped: 0
|
|
4019
4130
|
};
|
|
4020
4131
|
}
|
|
4021
|
-
function
|
|
4132
|
+
function vr(e) {
|
|
4022
4133
|
let t;
|
|
4023
4134
|
try {
|
|
4024
4135
|
t = JSON.parse(e);
|
|
@@ -4028,19 +4139,19 @@ function hr(e) {
|
|
|
4028
4139
|
if (!Array.isArray(t)) throw Error("Expected a JSON array of OHLCV rows");
|
|
4029
4140
|
let n = [], r = 0;
|
|
4030
4141
|
for (let e of t) {
|
|
4031
|
-
let t = Array.isArray(e) ?
|
|
4142
|
+
let t = Array.isArray(e) ? wr(e) : Cr(e);
|
|
4032
4143
|
t ? n.push(t) : r++;
|
|
4033
4144
|
}
|
|
4034
|
-
return
|
|
4145
|
+
return Tr(n, t.length, r);
|
|
4035
4146
|
}
|
|
4036
|
-
function
|
|
4147
|
+
function yr(e) {
|
|
4037
4148
|
let t = e.split(/\r?\n/).filter((e) => e.trim().length > 0);
|
|
4038
4149
|
if (t.length === 0) return {
|
|
4039
4150
|
data: [],
|
|
4040
4151
|
rowCount: 0,
|
|
4041
4152
|
skipped: 0
|
|
4042
4153
|
};
|
|
4043
|
-
let n =
|
|
4154
|
+
let n = br(t[0]), r = xr(t[0], n).map((e) => e.trim().toLowerCase()), i = r.some((e) => isNaN(Number(e)) && e.length > 0), a = i ? Sr(r) : {
|
|
4044
4155
|
time: 0,
|
|
4045
4156
|
open: 1,
|
|
4046
4157
|
high: 2,
|
|
@@ -4051,7 +4162,7 @@ function gr(e) {
|
|
|
4051
4162
|
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");
|
|
4052
4163
|
let o = [], s = 0;
|
|
4053
4164
|
for (let e = +!!i; e < t.length; e++) {
|
|
4054
|
-
let r =
|
|
4165
|
+
let r = xr(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;
|
|
4055
4166
|
if (i === null || ![
|
|
4056
4167
|
c,
|
|
4057
4168
|
l,
|
|
@@ -4070,9 +4181,9 @@ function gr(e) {
|
|
|
4070
4181
|
volume: Number.isFinite(f) ? f : 0
|
|
4071
4182
|
});
|
|
4072
4183
|
}
|
|
4073
|
-
return
|
|
4184
|
+
return Tr(o, t.length - +!!i, s);
|
|
4074
4185
|
}
|
|
4075
|
-
function
|
|
4186
|
+
function br(e) {
|
|
4076
4187
|
let t = {
|
|
4077
4188
|
",": 0,
|
|
4078
4189
|
";": 0,
|
|
@@ -4084,7 +4195,7 @@ function _r(e) {
|
|
|
4084
4195
|
for (let [e, i] of Object.entries(t)) i > r && (n = e, r = i);
|
|
4085
4196
|
return n;
|
|
4086
4197
|
}
|
|
4087
|
-
function
|
|
4198
|
+
function xr(e, t) {
|
|
4088
4199
|
let n = [], r = "", i = !1;
|
|
4089
4200
|
for (let a = 0; a < e.length; a++) {
|
|
4090
4201
|
let o = e[a];
|
|
@@ -4092,25 +4203,25 @@ function vr(e, t) {
|
|
|
4092
4203
|
}
|
|
4093
4204
|
return n.push(r), n;
|
|
4094
4205
|
}
|
|
4095
|
-
function
|
|
4206
|
+
function Sr(e) {
|
|
4096
4207
|
let t = (t) => e.findIndex((e) => t.includes(e));
|
|
4097
4208
|
return {
|
|
4098
|
-
time: t(
|
|
4099
|
-
open: t(
|
|
4100
|
-
high: t(
|
|
4101
|
-
low: t(
|
|
4102
|
-
close: t(
|
|
4103
|
-
volume: t(
|
|
4209
|
+
time: t(dr),
|
|
4210
|
+
open: t(fr),
|
|
4211
|
+
high: t(pr),
|
|
4212
|
+
low: t(mr),
|
|
4213
|
+
close: t(hr),
|
|
4214
|
+
volume: t(gr)
|
|
4104
4215
|
};
|
|
4105
4216
|
}
|
|
4106
|
-
function
|
|
4217
|
+
function Cr(e) {
|
|
4107
4218
|
let t = (t) => {
|
|
4108
4219
|
for (let n of t) {
|
|
4109
4220
|
if (e[n] !== void 0) return e[n];
|
|
4110
4221
|
let t = n.toUpperCase();
|
|
4111
4222
|
if (e[t] !== void 0) return e[t];
|
|
4112
4223
|
}
|
|
4113
|
-
}, n = Y(String(t(
|
|
4224
|
+
}, n = Y(String(t(dr) ?? "")), r = Number(t(fr)), i = Number(t(pr)), a = Number(t(mr)), o = Number(t(hr)), s = Number(t(gr) ?? 0);
|
|
4114
4225
|
return n === null || ![
|
|
4115
4226
|
r,
|
|
4116
4227
|
i,
|
|
@@ -4125,7 +4236,7 @@ function br(e) {
|
|
|
4125
4236
|
volume: Number.isFinite(s) ? s : 0
|
|
4126
4237
|
};
|
|
4127
4238
|
}
|
|
4128
|
-
function
|
|
4239
|
+
function wr(e) {
|
|
4129
4240
|
if (e.length < 5) return null;
|
|
4130
4241
|
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;
|
|
4131
4242
|
return t === null || ![
|
|
@@ -4153,7 +4264,7 @@ function Y(e) {
|
|
|
4153
4264
|
let r = Date.parse(t);
|
|
4154
4265
|
return Number.isFinite(r) ? r : null;
|
|
4155
4266
|
}
|
|
4156
|
-
function
|
|
4267
|
+
function Tr(e, t, n) {
|
|
4157
4268
|
e.sort((e, t) => e.time - t.time);
|
|
4158
4269
|
let r = [];
|
|
4159
4270
|
for (let t of e) r.length > 0 && r[r.length - 1].time === t.time ? r[r.length - 1] = t : r.push(t);
|
|
@@ -4165,7 +4276,7 @@ function Sr(e, t, n) {
|
|
|
4165
4276
|
}
|
|
4166
4277
|
//#endregion
|
|
4167
4278
|
//#region src/io/DragDropImporter.ts
|
|
4168
|
-
var
|
|
4279
|
+
var Er = class {
|
|
4169
4280
|
host;
|
|
4170
4281
|
overlay = null;
|
|
4171
4282
|
callbacks;
|
|
@@ -4198,7 +4309,7 @@ var Cr = class {
|
|
|
4198
4309
|
e.preventDefault(), this.depth = 0, this.hideOverlay();
|
|
4199
4310
|
let t = e.dataTransfer?.files?.[0];
|
|
4200
4311
|
if (t) try {
|
|
4201
|
-
let e =
|
|
4312
|
+
let e = _r(await t.text());
|
|
4202
4313
|
if (e.data.length === 0) throw Error(`No valid OHLCV rows found in "${t.name}"`);
|
|
4203
4314
|
this.callbacks.onData(e.data, e, t);
|
|
4204
4315
|
} catch (e) {
|
|
@@ -4242,7 +4353,7 @@ function Z(e) {
|
|
|
4242
4353
|
};
|
|
4243
4354
|
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;
|
|
4244
4355
|
}
|
|
4245
|
-
var
|
|
4356
|
+
var Dr = (e, t) => t.updatedAt - e.updatedAt;
|
|
4246
4357
|
function Q(e) {
|
|
4247
4358
|
if (typeof e != "object" || !e) return null;
|
|
4248
4359
|
let t = e;
|
|
@@ -4255,17 +4366,17 @@ function Q(e) {
|
|
|
4255
4366
|
kind: typeof t.kind == "string" ? t.kind : void 0
|
|
4256
4367
|
});
|
|
4257
4368
|
}
|
|
4258
|
-
function
|
|
4369
|
+
function Or(e) {
|
|
4259
4370
|
let t = Q(e), n = t ? e.content : void 0;
|
|
4260
4371
|
return t && typeof n == "string" ? {
|
|
4261
4372
|
...t,
|
|
4262
4373
|
content: n
|
|
4263
4374
|
} : null;
|
|
4264
4375
|
}
|
|
4265
|
-
function
|
|
4376
|
+
function kr(e = []) {
|
|
4266
4377
|
let t = new Map(e.map((e) => [e.id, { ...e }]));
|
|
4267
4378
|
return {
|
|
4268
|
-
list: () => [...t.values()].map(Z).sort(
|
|
4379
|
+
list: () => [...t.values()].map(Z).sort(Dr),
|
|
4269
4380
|
load: (e) => {
|
|
4270
4381
|
let n = t.get(e);
|
|
4271
4382
|
return n ? { ...n } : null;
|
|
@@ -4278,7 +4389,7 @@ function Er(e = []) {
|
|
|
4278
4389
|
}
|
|
4279
4390
|
};
|
|
4280
4391
|
}
|
|
4281
|
-
function
|
|
4392
|
+
function Ar(e = "tcw:layouts:") {
|
|
4282
4393
|
let t = `${e}index`, n = (t) => `${e}item:${t}`, r = () => {
|
|
4283
4394
|
let e;
|
|
4284
4395
|
try {
|
|
@@ -4289,7 +4400,7 @@ function Dr(e = "tcw:layouts:") {
|
|
|
4289
4400
|
return Array.isArray(e) ? e.map(Q).filter((e) => e !== null) : [];
|
|
4290
4401
|
}, i = (e) => localStorage.setItem(t, JSON.stringify(e));
|
|
4291
4402
|
return {
|
|
4292
|
-
list: () => r().sort(
|
|
4403
|
+
list: () => r().sort(Dr),
|
|
4293
4404
|
load: (e) => {
|
|
4294
4405
|
let t = r().find((t) => t.id === e), i = t ? localStorage.getItem(n(e)) : null;
|
|
4295
4406
|
return t && i !== null ? {
|
|
@@ -4307,14 +4418,14 @@ function Dr(e = "tcw:layouts:") {
|
|
|
4307
4418
|
}
|
|
4308
4419
|
//#endregion
|
|
4309
4420
|
//#region src/state/LayoutSession.ts
|
|
4310
|
-
var
|
|
4421
|
+
var jr = 80;
|
|
4311
4422
|
function $(e) {
|
|
4312
4423
|
return e.replace(/\s+/g, " ").trim().slice(0, 80).trim() || null;
|
|
4313
4424
|
}
|
|
4314
|
-
function
|
|
4425
|
+
function Mr() {
|
|
4315
4426
|
return globalThis.crypto?.randomUUID?.() ?? `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
|
|
4316
4427
|
}
|
|
4317
|
-
function
|
|
4428
|
+
function Nr(e) {
|
|
4318
4429
|
let { id: t, name: n, symbol: r, timeframe: i, updatedAt: a, kind: o } = e;
|
|
4319
4430
|
return {
|
|
4320
4431
|
id: t,
|
|
@@ -4325,7 +4436,7 @@ function Ar(e) {
|
|
|
4325
4436
|
...o === void 0 ? {} : { kind: o }
|
|
4326
4437
|
};
|
|
4327
4438
|
}
|
|
4328
|
-
var
|
|
4439
|
+
var Pr = class {
|
|
4329
4440
|
currentLayout = null;
|
|
4330
4441
|
savedContent = null;
|
|
4331
4442
|
dirty = !1;
|
|
@@ -4341,7 +4452,7 @@ var jr = class {
|
|
|
4341
4452
|
now;
|
|
4342
4453
|
newId;
|
|
4343
4454
|
constructor(e, t, n = {}) {
|
|
4344
|
-
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 ??
|
|
4455
|
+
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 ?? Mr;
|
|
4345
4456
|
}
|
|
4346
4457
|
current() {
|
|
4347
4458
|
return this.currentLayout;
|
|
@@ -4371,7 +4482,7 @@ var jr = class {
|
|
|
4371
4482
|
}
|
|
4372
4483
|
open(e) {
|
|
4373
4484
|
return this.queue(async () => {
|
|
4374
|
-
let t =
|
|
4485
|
+
let t = Or(await this.storage.load(e));
|
|
4375
4486
|
if (!t || t.id !== e || (t.kind ?? "chart") !== this.kind || this.destroyed) return !1;
|
|
4376
4487
|
this.cancelTimer(), this.applying++;
|
|
4377
4488
|
try {
|
|
@@ -4381,13 +4492,13 @@ var jr = class {
|
|
|
4381
4492
|
} finally {
|
|
4382
4493
|
this.applying--;
|
|
4383
4494
|
}
|
|
4384
|
-
return this.cancelTimer(), this.currentLayout =
|
|
4495
|
+
return this.cancelTimer(), this.currentLayout = Nr(t), this.savedContent = this.host.capture().content, this.dirty = !1, this.notify(), !0;
|
|
4385
4496
|
});
|
|
4386
4497
|
}
|
|
4387
4498
|
rename(e, t) {
|
|
4388
4499
|
let n = $(t);
|
|
4389
4500
|
return n ? this.queue(async () => {
|
|
4390
|
-
let t =
|
|
4501
|
+
let t = Or(await this.storage.load(e));
|
|
4391
4502
|
!t || t.id !== e || (await this.storage.save({
|
|
4392
4503
|
...t,
|
|
4393
4504
|
name: n
|
|
@@ -4465,7 +4576,7 @@ var jr = class {
|
|
|
4465
4576
|
content: n.content
|
|
4466
4577
|
};
|
|
4467
4578
|
await this.storage.save(r);
|
|
4468
|
-
let i =
|
|
4579
|
+
let i = Nr(r);
|
|
4469
4580
|
return this.currentLayout = i, this.savedContent = n.content, this.dirty = !1, this.notify(), i;
|
|
4470
4581
|
}
|
|
4471
4582
|
forget() {
|
|
@@ -4486,6 +4597,6 @@ var jr = class {
|
|
|
4486
4597
|
}
|
|
4487
4598
|
};
|
|
4488
4599
|
//#endregion
|
|
4489
|
-
export { V as C,
|
|
4600
|
+
export { V as C, dn as S, Xt as T, kn as _, kr as a, hn as b, Xn as c, Pn as d, Nn as f, On as g, jn as h, Ar as i, Bn as l, An as m, jr as n, Er as o, Mn as p, $ as r, _r as s, Pr as t, zn as u, W as v, z as w, pn as x, bn as y };
|
|
4490
4601
|
|
|
4491
|
-
//# sourceMappingURL=LayoutSession-
|
|
4602
|
+
//# sourceMappingURL=LayoutSession-BlSkHp80.js.map
|