lightweight-charts-drawing 0.2.2 → 0.2.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/CHANGELOG.md +13 -0
- package/README.md +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/lightweight-charts-drawing.es.js +14 -15
- package/dist/lightweight-charts-drawing.es.js.map +1 -1
- package/dist/lightweight-charts-drawing.umd.cjs +7 -7
- package/dist/lightweight-charts-drawing.umd.cjs.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.2.3 (01/10/2026)
|
|
4
|
+
|
|
5
|
+
### Changed
|
|
6
|
+
|
|
7
|
+
- The drawing core folder is `src/core` (was `src/tv`). Internal only: the
|
|
8
|
+
package entry and its exports are unchanged.
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
- Long / short position: the stop and target handles are hit where they are
|
|
13
|
+
drawn (entry x). The hit test used the middle of the box, so dragging a
|
|
14
|
+
drawn stop or target square moved the whole drawing.
|
|
15
|
+
|
|
3
16
|
## 0.2.2 (28/09/2026)
|
|
4
17
|
|
|
5
18
|
### Changed
|
package/README.md
CHANGED
|
@@ -90,7 +90,7 @@ dialogs, text / table editors, toolbar, context menu.
|
|
|
90
90
|
## Architecture
|
|
91
91
|
|
|
92
92
|
```
|
|
93
|
-
src/
|
|
93
|
+
src/core/ shared drawing core, no UI and no lightweight-charts runtime:
|
|
94
94
|
tool model + TradingView factory defaults (specs), hit tests,
|
|
95
95
|
placement and drag rules (interact), saved-drawing migration
|
|
96
96
|
(serialize), renderer-neutral scenes per tool (scene)
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* lightweight-charts-drawing 0.2
|
|
3
3
|
*
|
|
4
4
|
* TradingView-style drawing tools for lightweight-charts v5, built on a shared
|
|
5
|
-
* drawing core (src/
|
|
5
|
+
* drawing core (src/core: tool model + TradingView factory defaults, hit tests,
|
|
6
6
|
* placement / drag rules, renderer-neutral scenes) and a canvas runtime
|
|
7
7
|
* (src/runtime: DrawingManager).
|
|
8
8
|
*
|
|
@@ -1358,7 +1358,7 @@ declare type UnitVisibility = {
|
|
|
1358
1358
|
to: number;
|
|
1359
1359
|
};
|
|
1360
1360
|
|
|
1361
|
-
export declare const VERSION = "0.2.
|
|
1361
|
+
export declare const VERSION = "0.2.3";
|
|
1362
1362
|
|
|
1363
1363
|
declare type WithId<T> = T & {
|
|
1364
1364
|
id: string;
|
|
@@ -517,7 +517,7 @@ function gr(e, t, n, o, i) {
|
|
|
517
517
|
` : "") + (r ? String(i) : `Risk/reward ratio: ${i}`)), l;
|
|
518
518
|
}
|
|
519
519
|
const pe = { accountSize: 1e3, risk: 25, leverage: 1e4 };
|
|
520
|
-
function
|
|
520
|
+
function Wo(e, t) {
|
|
521
521
|
const n = e.points[0], o = e.points[1], i = n && o ? Math.abs(o.price - n.price) : 0;
|
|
522
522
|
return {
|
|
523
523
|
stop: e.style.stopLevel ?? (i || t * 100),
|
|
@@ -537,9 +537,9 @@ function kr(e, t, n) {
|
|
|
537
537
|
const o = e.accountSize ?? pe.accountSize, i = e.leverage ?? pe.leverage, r = n > 0 ? wr(e) / n : 1 / 0, l = t > 0 ? i * o / t : 1 / 0, s = Math.min(r, l), a = Number.isFinite(s) ? s : 0, c = e.lotSize && e.lotSize > 0 ? e.lotSize : 1;
|
|
538
538
|
return { qty: a, shown: Mr(a / c, e.qtyPrecision) };
|
|
539
539
|
}
|
|
540
|
-
function
|
|
540
|
+
function $n(e, t, n) {
|
|
541
541
|
if (e.kind !== "long-position" && e.kind !== "short-position") return null;
|
|
542
|
-
const [o, i] = t, r = e.points[0].price, { stop: l, profit: s } =
|
|
542
|
+
const [o, i] = t, r = e.points[0].price, { stop: l, profit: s } = Wo(e, (n == null ? void 0 : n.pipSize()) ?? 0.01), a = e.kind === "long-position" ? 1 : -1, c = (n == null ? void 0 : n.priceToY(r + a * s)) ?? o.y - 40, f = (n == null ? void 0 : n.priceToY(r - a * l)) ?? o.y + 40;
|
|
543
543
|
return c == null || f == null ? null : {
|
|
544
544
|
anchors: [o, { x: i.x, y: o.y }, { x: o.x, y: f }, { x: o.x, y: c }],
|
|
545
545
|
yStop: f,
|
|
@@ -1477,14 +1477,13 @@ function ki(e, t, n = L) {
|
|
|
1477
1477
|
return o || (_(t.x, t.y, e[0], e[1]) <= n ? { hit: "body" } : null);
|
|
1478
1478
|
}
|
|
1479
1479
|
function hl(e, t, n, o) {
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
return n.x >= b - L && n.x <= m + L && n.y >= g - L && n.y <= w + L ? { hit: "body" } : null;
|
|
1480
|
+
if (!e.points[0] || !e.points[1]) return null;
|
|
1481
|
+
const i = $n(e, t, o);
|
|
1482
|
+
if (!i) return null;
|
|
1483
|
+
const { anchors: r, yStop: l, yTarget: s } = i, [a, c] = t, f = z(r, n);
|
|
1484
|
+
if (f) return f;
|
|
1485
|
+
const h = Math.min(a.x, c.x), u = Math.max(a.x, c.x), x = Math.min(s, l), d = Math.max(s, l);
|
|
1486
|
+
return n.x >= h - L && n.x <= u + L && n.y >= x - L && n.y <= d + L ? { hit: "body" } : null;
|
|
1488
1487
|
}
|
|
1489
1488
|
function Ve(e, t, n, o, i) {
|
|
1490
1489
|
const r = t.x - e.x, l = t.y - e.y, s = Math.hypot(r, l) || 1;
|
|
@@ -2194,7 +2193,7 @@ function ql(e, t, n) {
|
|
|
2194
2193
|
const o = e.style, i = [], r = [];
|
|
2195
2194
|
if ((e.kind === "vertical-line" || e.kind === "cross-line") && o.showTime && e.points[0] && r.push(Gt({ time: e.points[0].time }, ct(o.color).hex)), e.kind === "long-position" || e.kind === "short-position") {
|
|
2196
2195
|
if (o.showPriceLabels !== !1) {
|
|
2197
|
-
const l =
|
|
2196
|
+
const l = $n(e, t, n);
|
|
2198
2197
|
if (l) {
|
|
2199
2198
|
const s = e.points[0].price, a = e.kind === "long-position" ? 1 : -1;
|
|
2200
2199
|
i.push(Gt({ price: s }, "#787b86"), Gt({ price: s + a * l.profit }, "#089981"), Gt({ price: s - a * l.stop }, "#f23645"));
|
|
@@ -3894,7 +3893,7 @@ function Qe(e, t, n, o, i, r, l, s) {
|
|
|
3894
3893
|
};
|
|
3895
3894
|
}
|
|
3896
3895
|
function mo(e, t, n, o, i, r) {
|
|
3897
|
-
const l =
|
|
3896
|
+
const l = $n(e, t, r);
|
|
3898
3897
|
if (!l) return [];
|
|
3899
3898
|
const [s, a] = t, c = e.points[0].price, f = Math.min(s.x, a.x), h = Math.max(s.x, a.x), u = Math.max(8, h - f), x = (f + h) / 2, d = ct(i.stopColor ?? "#f23645").hex, p = ct(i.targetColor ?? "#089981").hex, y = i.stopTransparency ?? 80, b = i.targetTransparency ?? 80, m = kt(p, 100 - b), g = kt(d, 100 - y), { yStop: w, yTarget: M, stop: k, profit: v } = l, S = i.accountSize ?? 1e3, { qty: T, shown: E } = kr(i, c, k), A = (fe) => parseFloat(fe.toFixed(2)), F = A(S + v * T), O = A(S - k * T), C = k > 0 ? Math.round(100 * v / k) / 100 : 0, P = o === "long" ? 1 : -1, I = vr(e, o, c - P * k, c + P * v, r), B = I ? (I.closePrice - c) * P : null, R = (r == null ? void 0 : r.pipSize()) ?? 0.01, Y = Math.max(0, Math.min(8, Math.round(-Math.log10(R)))), K = Kn(i, "tp", v, c, R, Y, F, v * T), xt = Kn(i, "sl", k, c, R, Y, O, -k * T), Ut = gr(i, B != null ? bt(B, Y) : null, !!(I != null && I.closed), E, C), wt = Ut ? Ut.split(`
|
|
3900
3899
|
`) : [], Vt = B != null && B < 0 ? d : B != null && B > 0 ? p : i.color, le = (fe) => {
|
|
@@ -5030,7 +5029,7 @@ function sa(e, t, n) {
|
|
|
5030
5029
|
function ca(e, t, n, o) {
|
|
5031
5030
|
const i = e.start;
|
|
5032
5031
|
if (i.kind !== "long-position" && i.kind !== "short-position" || e.mode.hit !== "handle") return null;
|
|
5033
|
-
const r = e.mode.handleIndex, [l, s] = i.points, a = n.pipSize(), c = i.kind === "long-position" ? 1 : -1, { stop: f, profit: h } =
|
|
5032
|
+
const r = e.mode.handleIndex, [l, s] = i.points, a = n.pipSize(), c = i.kind === "long-position" ? 1 : -1, { stop: f, profit: h } = Wo(i, a);
|
|
5034
5033
|
if (r === 0) {
|
|
5035
5034
|
const x = D(n, t);
|
|
5036
5035
|
if (!x) return null;
|
|
@@ -6318,7 +6317,7 @@ class za {
|
|
|
6318
6317
|
});
|
|
6319
6318
|
}
|
|
6320
6319
|
}
|
|
6321
|
-
const Va = "0.2.
|
|
6320
|
+
const Va = "0.2.3";
|
|
6322
6321
|
export {
|
|
6323
6322
|
pa as ANCHORABLE_KINDS,
|
|
6324
6323
|
wn as DEFAULT_STYLE,
|