@tradecanvas/core 0.1.1 → 0.1.3

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/index.js CHANGED
@@ -374,6 +374,12 @@ var w = class {
374
374
  updateData(e, t) {
375
375
  this.dataLength = e.length, this.dataLength !== 0 && (this.clampOffset(), this.updateVisibleRange(), t && (this.state.priceRange = l(e, this.state.visibleRange.from, Math.min(this.state.visibleRange.to, this.dataLength - 1), .08)));
376
376
  }
377
+ setPriceRange(e, t) {
378
+ this.state.priceRange = {
379
+ min: e,
380
+ max: t
381
+ };
382
+ }
377
383
  scrollBy(e) {
378
384
  this.state.offset += e, this.clampOffset(), this.updateVisibleRange();
379
385
  }
@@ -859,7 +865,7 @@ var k = class {
859
865
  addIndicator(e, t = {}, n) {
860
866
  let r = this.registry.get(e);
861
867
  if (!r) throw Error(`Unknown indicator: ${e}`);
862
- let i = `${e}_${he++}`, a = {
868
+ let i = `tc_${e}_${he++}`, a = {
863
869
  id: e,
864
870
  instanceId: i,
865
871
  params: {
@@ -925,6 +931,24 @@ var k = class {
925
931
  let n = this.instances.get(e);
926
932
  n && Object.assign(n.style, t);
927
933
  }
934
+ getOverlayPriceRange(e, t) {
935
+ let n = Infinity, r = -Infinity;
936
+ for (let i of this.instances.values()) {
937
+ if (!i.output || !i.config.visible || i.plugin.descriptor.placement !== "overlay") continue;
938
+ let a = 0;
939
+ for (let [, o] of i.output.values) {
940
+ if (a >= e && a <= t) for (let e in o) {
941
+ let t = o[e];
942
+ t !== void 0 && isFinite(t) && (t < n && (n = t), t > r && (r = t));
943
+ }
944
+ a++;
945
+ }
946
+ }
947
+ return n === Infinity ? null : {
948
+ min: n,
949
+ max: r
950
+ };
951
+ }
928
952
  getPanelIndicators() {
929
953
  let e = [];
930
954
  for (let [t, n] of this.instances) n.plugin.descriptor.placement === "panel" && e.push({
@@ -2671,7 +2695,7 @@ var He = class {
2671
2695
  }, r = this.listeners.get(e);
2672
2696
  if (r) for (let e of r) e(n);
2673
2697
  if (this.tauriBridge?.enabled && window.__TAURI__) {
2674
- let t = this.tauriBridge.eventPrefix ?? "chart";
2698
+ let t = this.tauriBridge.eventPrefix ?? "tc-chart";
2675
2699
  window.__TAURI__.event.emit(`${t}:${e}`, n).catch(() => {});
2676
2700
  }
2677
2701
  }
@@ -2944,7 +2968,7 @@ var He = class {
2944
2968
  let t = this.drawings.find((t) => t.id === e);
2945
2969
  if (!t) return null;
2946
2970
  let n = structuredClone(t);
2947
- return n.id = `drawing_${Ue++}`, n.anchors = n.anchors.map((e) => ({
2971
+ return n.id = `tc_drawing_${Ue++}`, n.anchors = n.anchors.map((e) => ({
2948
2972
  ...e,
2949
2973
  time: e.time + 3
2950
2974
  })), n.locked = !1, this.drawings.push(n), this.undoRedo?.push({
@@ -2986,7 +3010,7 @@ var He = class {
2986
3010
  if (!n) return !1;
2987
3011
  let r = x(e.x, t), i = S(e.y, t), a = this.snapToOHLC(r, i, t);
2988
3012
  return this.creatingDrawing ? (this.creatingDrawing.anchors.push(a), this.committedAnchors++, this.previewAnchor = null, this.committedAnchors >= n.descriptor.requiredAnchors && this.finalizeCreation(), this.requestRender?.(), !0) : (this.creatingDrawing = {
2989
- id: `drawing_${Ue++}`,
3013
+ id: `tc_drawing_${Ue++}`,
2990
3014
  type: this.activeTool,
2991
3015
  anchors: [a],
2992
3016
  style: { ...this.activeStyle },
@@ -4783,7 +4807,7 @@ var vt = class {
4783
4807
  this.pricePrecision = e;
4784
4808
  }
4785
4809
  addAlert(e, t = "crossing", n, r = !1) {
4786
- let i = `alert_${Lt++}`, a = {
4810
+ let i = `tc_alert_${Lt++}`, a = {
4787
4811
  id: i,
4788
4812
  price: e,
4789
4813
  condition: t,
@@ -4952,7 +4976,7 @@ var vt = class {
4952
4976
  let t = localStorage.getItem(e);
4953
4977
  return t ? this.deserialize(t) : null;
4954
4978
  }
4955
- static downloadFile(e, t = "chart-state.json") {
4979
+ static downloadFile(e, t = "tc-chart-state.json") {
4956
4980
  let n = new Blob([this.serialize(e)], { type: "application/json" }), r = URL.createObjectURL(n), i = document.createElement("a");
4957
4981
  i.href = r, i.download = t, document.body.appendChild(i), i.click(), document.body.removeChild(i), URL.revokeObjectURL(r);
4958
4982
  }