@tradecanvas/chart 1.26.0 → 1.29.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.
Files changed (34) hide show
  1. package/dist/Chart.d.ts +48 -1
  2. package/dist/Chart.d.ts.map +1 -1
  3. package/dist/LayoutSession-DhB5RGm1.cjs +2 -0
  4. package/dist/LayoutSession-DhB5RGm1.cjs.map +1 -0
  5. package/dist/{LayoutSession-BE7ZZGLi.js → LayoutSession-goRU8aOv.js} +99 -10
  6. package/dist/LayoutSession-goRU8aOv.js.map +1 -0
  7. package/dist/index.cjs +1 -1
  8. package/dist/index.js +1 -1
  9. package/dist/widget/ChartWidget.d.ts +28 -2
  10. package/dist/widget/ChartWidget.d.ts.map +1 -1
  11. package/dist/widget/WidgetCommandPalette.d.ts.map +1 -1
  12. package/dist/widget/WidgetDrawingSidebar.d.ts.map +1 -1
  13. package/dist/widget/WidgetHotkeySheet.d.ts.map +1 -1
  14. package/dist/widget/WidgetReplayBar.d.ts.map +1 -1
  15. package/dist/widget/WidgetSymbolSearch.d.ts.map +1 -1
  16. package/dist/widget/WidgetWatchlist.d.ts.map +1 -1
  17. package/dist/widget/footerHints.d.ts +7 -0
  18. package/dist/widget/footerHints.d.ts.map +1 -0
  19. package/dist/widget/iconSet.d.ts +1 -25
  20. package/dist/widget/iconSet.d.ts.map +1 -1
  21. package/dist/widget/index.cjs +80 -21
  22. package/dist/widget/index.cjs.map +1 -1
  23. package/dist/widget/index.js +832 -1278
  24. package/dist/widget/index.js.map +1 -1
  25. package/dist/widget/keyboardInset.d.ts +9 -0
  26. package/dist/widget/keyboardInset.d.ts.map +1 -0
  27. package/dist/widget/widgetFeatures.d.ts +2 -2
  28. package/dist/widget/widgetFeatures.d.ts.map +1 -1
  29. package/dist/widget/widgetTimeframes.d.ts +28 -0
  30. package/dist/widget/widgetTimeframes.d.ts.map +1 -1
  31. package/package.json +3 -3
  32. package/dist/LayoutSession-BE7ZZGLi.js.map +0 -1
  33. package/dist/LayoutSession-BnRz0zSL.cjs +0 -2
  34. package/dist/LayoutSession-BnRz0zSL.cjs.map +0 -1
@@ -901,7 +901,7 @@ function Pn(e) {
901
901
  if (typeof e == "number" && !Number.isFinite(e)) throw RangeError(`Invalid UTC offset: ${e}`);
902
902
  }
903
903
  var Fn = 2, In = .08, Ln = 800, Rn = 20, zn = 8, Bn = new Set(["horizontalLine", "crossLine"]), Vn = new Set(["verticalLine", "crossLine"]), Hn = class {
904
- static version = "1.26.0";
904
+ static version = "1.29.0";
905
905
  engine;
906
906
  viewport;
907
907
  dataManager;
@@ -925,6 +925,7 @@ var Fn = 2, In = .08, Ln = 800, Rn = 20, zn = 8, Bn = new Set(["horizontalLine",
925
925
  paneStyles = /* @__PURE__ */ new Map();
926
926
  lastBackground = null;
927
927
  renderScheduled = !1;
928
+ renderDeferred = !1;
928
929
  priceAxisWidth = a;
929
930
  measureCtx;
930
931
  containerSizeCache = null;
@@ -949,6 +950,12 @@ var Fn = 2, In = .08, Ln = 800, Rn = 20, zn = 8, Bn = new Set(["horizontalLine",
949
950
  hostSessionHours = { ...De };
950
951
  compareRenderer;
951
952
  countdownInterval = null;
953
+ pausedFor = {
954
+ host: !1,
955
+ page: !1,
956
+ offscreen: !1
957
+ };
958
+ stopWatchingVisibility = null;
952
959
  volumeRenderer;
953
960
  volumeProfile;
954
961
  marketProfile;
@@ -1084,12 +1091,12 @@ var Fn = 2, In = .08, Ln = 800, Rn = 20, zn = 8, Bn = new Set(["horizontalLine",
1084
1091
  contextMenu: { enabled: this.features.tradingContextMenu }
1085
1092
  }), this.tradingRenderer = new ut(this.tradingManager), this.tradingManager.setContainer(e), this.tradingManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.tradingManager.setEventCallback((e, t) => {
1086
1093
  this.eventBus.emit(e, t);
1087
- }), this.engine = new Xe(e);
1094
+ }), this.engine = new Xe(e, t.maxPixelRatio);
1088
1095
  let a = this.engine.dprManager.getContainerSize();
1089
1096
  if (this.viewport = new ft(a.width, a.height, t.minBarSpacing ?? 2, t.maxBarSpacing ?? 30, t.rightMargin ?? 5), this.viewport.setPanLimits({
1090
1097
  freePan: t.freePan ?? !0,
1091
1098
  minVisibleBars: t.panLimits?.minVisibleBars ?? 3
1092
- }), this.layoutManager.resize(a.width, a.height), this.engine.onContainerResize = (e) => {
1099
+ }), t.minBarUnit !== void 0 && this.viewport.setMinBarUnit(t.minBarUnit), this.layoutManager.resize(a.width, a.height), this.engine.onContainerResize = (e) => {
1093
1100
  if (e.width <= 0 || e.height <= 0) return;
1094
1101
  let t = this.viewport.isAtEnd();
1095
1102
  this.viewport.resize(e.width, e.height), this.layoutManager.resize(e.width, e.height), this.updateViewportAndRender(t);
@@ -1333,7 +1340,7 @@ var Fn = 2, In = .08, Ln = 800, Rn = 20, zn = 8, Bn = new Set(["horizontalLine",
1333
1340
  }
1334
1341
  }), this.interactionManager.setOverlayDirtyCallback((e) => {
1335
1342
  this.engine.requestRender(e ? r.Hover : r.Overlay);
1336
- }), 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", {
1343
+ }), this.interactionManager.setPageScroll(t.pageScroll ?? !1), 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.watchVisibility(e, t.pauseWhenHidden !== !1), this.engine.onGpuLost = () => this.eventBus.emit("rendererChange", {
1337
1344
  renderer: "canvas",
1338
1345
  reason: "contextLost"
1339
1346
  }), this.engine.onGpuRestored = () => this.eventBus.emit("rendererChange", {
@@ -2358,7 +2365,7 @@ var Fn = 2, In = .08, Ln = 800, Rn = 20, zn = 8, Bn = new Set(["horizontalLine",
2358
2365
  return;
2359
2366
  }
2360
2367
  let n = this.dataManager.getData();
2361
- this.recalcIndicatorsFrom(n, n.length - 1), this.scheduleRender();
2368
+ this.indicatorEngine.deferRecalculateFrom(n, n.length - 1), this.announceIndicatorUpdate(n.length - 1), this.scheduleRender();
2362
2369
  }), this.setBidAsk(null), this.streamManager.on("quote", (e) => {
2363
2370
  let t = this.priceLines.getBidAsk();
2364
2371
  this.setBidAsk({
@@ -2534,6 +2541,69 @@ var Fn = 2, In = .08, Ln = 800, Rn = 20, zn = 8, Bn = new Set(["horizontalLine",
2534
2541
  let r = N(Math.min(e, t), n), i = N(Math.max(e, t), n);
2535
2542
  this.viewport.zoomToBarRange(r, i), this.updateViewportAndRender();
2536
2543
  }
2544
+ suspend() {
2545
+ this.setPaused("host", !0);
2546
+ }
2547
+ resume() {
2548
+ this.setPaused("host", !1);
2549
+ }
2550
+ isSuspended() {
2551
+ return this.pausedFor.host || this.pausedFor.page || this.pausedFor.offscreen;
2552
+ }
2553
+ setPaused(e, t) {
2554
+ let n = this.isSuspended();
2555
+ this.pausedFor = {
2556
+ ...this.pausedFor,
2557
+ [e]: t
2558
+ };
2559
+ let r = this.isSuspended();
2560
+ if (!(n === r || this.disposed)) {
2561
+ if (r) {
2562
+ this.engine.renderLoop.pause();
2563
+ return;
2564
+ }
2565
+ this.renderDeferred && (this.renderDeferred = !1, this.scheduleRender()), this.engine.renderLoop.resume();
2566
+ }
2567
+ }
2568
+ watchVisibility(e, t) {
2569
+ let n = [];
2570
+ if (t && typeof IntersectionObserver < "u") {
2571
+ let t = new IntersectionObserver((e) => {
2572
+ let t = e[e.length - 1];
2573
+ t && this.setPaused("offscreen", !t.isIntersecting);
2574
+ });
2575
+ t.observe(e), n.push(() => t.disconnect());
2576
+ }
2577
+ if (typeof document < "u") {
2578
+ let e = () => {
2579
+ t && this.setPaused("page", document.hidden), document.hidden || this.streamManager?.wake("visible");
2580
+ };
2581
+ document.addEventListener("visibilitychange", e), n.push(() => document.removeEventListener("visibilitychange", e)), t && document.hidden && this.setPaused("page", !0);
2582
+ }
2583
+ if (typeof window < "u") {
2584
+ let e = () => this.streamManager?.wake("online");
2585
+ window.addEventListener("online", e), n.push(() => window.removeEventListener("online", e));
2586
+ }
2587
+ this.stopWatchingVisibility = () => n.forEach((e) => e());
2588
+ }
2589
+ setPageScroll(e) {
2590
+ this.options.pageScroll = e, this.interactionManager.setPageScroll(e);
2591
+ }
2592
+ getPageScroll() {
2593
+ return this.options.pageScroll ?? !1;
2594
+ }
2595
+ setMaxPixelRatio(e) {
2596
+ this.engine.dprManager.setMaxPixelRatio(e);
2597
+ }
2598
+ getMaxPixelRatio() {
2599
+ return this.engine.dprManager.getMaxPixelRatio();
2600
+ }
2601
+ setMinBarUnit(e) {
2602
+ this.viewport.setMinBarUnit(e), this.updateViewportAndRender();
2603
+ }
2604
+ getMinBarUnit() {
2605
+ return this.viewport.getMinBarUnit();
2606
+ }
2537
2607
  setPanLimits(e) {
2538
2608
  this.viewport.setPanLimits(e), this.updateViewportAndRender();
2539
2609
  }
@@ -2798,6 +2868,10 @@ var Fn = 2, In = .08, Ln = 800, Rn = 20, zn = 8, Bn = new Set(["horizontalLine",
2798
2868
  } : { renderer: r });
2799
2869
  }
2800
2870
  freshFrame() {
2871
+ if (this.isSuspended()) {
2872
+ this.renderDeferred && (this.renderDeferred = !1, this.refitForTick()), this.engine.renderNow();
2873
+ return;
2874
+ }
2801
2875
  this.engine.getGpu() && this.engine.renderNow();
2802
2876
  }
2803
2877
  screenshot(e) {
@@ -3392,7 +3466,7 @@ var Fn = 2, In = .08, Ln = 800, Rn = 20, zn = 8, Bn = new Set(["horizontalLine",
3392
3466
  this.viewport.resize(e.width, e.height), this.layoutManager.resize(e.width, e.height), this.updateViewportAndRender(n), this.eventBus.emit("resize", e);
3393
3467
  }
3394
3468
  destroy() {
3395
- 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 = "";
3469
+ this.disposed = !0, this.stopWatchingVisibility?.(), this.stopWatchingVisibility = null, 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 = "";
3396
3470
  }
3397
3471
  createChartRenderer(e) {
3398
3472
  let t = en(e, (e) => this.pluginManager.getChartType(e));
@@ -3428,9 +3502,24 @@ var Fn = 2, In = .08, Ln = 800, Rn = 20, zn = 8, Bn = new Set(["horizontalLine",
3428
3502
  this.scheduleRender();
3429
3503
  }
3430
3504
  scheduleRender() {
3431
- this.renderScheduled || this.disposed || (this.renderScheduled = !0, requestAnimationFrame(() => {
3432
- this.renderScheduled = !1, !this.disposed && (this.panelInfoCache = null, this.fitDataAndAxes(), this.syncRenderContext(), this.engine.requestRender(), this.emitViewportEvents());
3433
- }));
3505
+ if (!(this.renderScheduled || this.disposed)) {
3506
+ if (this.isSuspended()) {
3507
+ this.renderDeferred = !0;
3508
+ return;
3509
+ }
3510
+ this.renderScheduled = !0, requestAnimationFrame(() => {
3511
+ if (this.renderScheduled = !1, !this.disposed) {
3512
+ if (this.isSuspended()) {
3513
+ this.renderDeferred = !0;
3514
+ return;
3515
+ }
3516
+ this.refitForTick();
3517
+ }
3518
+ });
3519
+ }
3520
+ }
3521
+ refitForTick() {
3522
+ this.panelInfoCache = null, this.fitDataAndAxes(), this.syncRenderContext(), this.engine.requestRender(), this.emitViewportEvents();
3434
3523
  }
3435
3524
  applyDataToViewport(e = !1) {
3436
3525
  let t = this.getDisplayData(), n = this.options.autoScale !== !1;
@@ -4262,4 +4351,4 @@ var Er = class {
4262
4351
  //#endregion
4263
4352
  export { Jt as C, B as S, H as _, xr as a, sn as b, Hn as c, Dn as d, En as f, Cn as g, Sn as h, Sr as i, Nn as l, Tn as m, Cr as n, vr as o, wn as p, $ as r, ur as s, Er as t, On as u, mn as v, an as x, ln as y };
4264
4353
 
4265
- //# sourceMappingURL=LayoutSession-BE7ZZGLi.js.map
4354
+ //# sourceMappingURL=LayoutSession-goRU8aOv.js.map