velo-plot 3.1.0 → 4.0.0-alpha.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/{ChartCore-AnR_3Xkb.js → ChartCore-KYG2HTcK.js} +1349 -1213
- package/dist/ChartCore-KYG2HTcK.js.map +1 -0
- package/dist/{PluginRegistry-CzMHebYP.js → PluginRegistry-CDf_jcnp.js} +2 -2
- package/dist/{PluginRegistry-CzMHebYP.js.map → PluginRegistry-CDf_jcnp.js.map} +1 -1
- package/dist/SVGDocumentBuilder-C-uLkcFW.js +83 -0
- package/dist/SVGDocumentBuilder-C-uLkcFW.js.map +1 -0
- package/dist/angular-hooks.js +1 -1
- package/dist/angular.js +4 -4
- package/dist/{chartSyncBridge-D_rCtbFq.js → chartSyncBridge-C1uRy0ZS.js} +3 -3
- package/dist/{chartSyncBridge-D_rCtbFq.js.map → chartSyncBridge-C1uRy0ZS.js.map} +1 -1
- package/dist/core/chart/ChartCore.d.ts +7 -3
- package/dist/core/chart/ChartRenderLoop.d.ts +5 -0
- package/dist/core/chart/ChartRenderer.d.ts +9 -0
- package/dist/core/chart/ChartSetup.d.ts +1 -0
- package/dist/core/chart/exporter/SVGExporter.d.ts +9 -7
- package/dist/core/chart/exporter/svg/SVGDocumentBuilder.d.ts +27 -0
- package/dist/core/chart/exporter/svg/SVGExportContext.d.ts +147 -0
- package/dist/core/chart/exporter/svg/SVGOrchestrator.d.ts +3 -0
- package/dist/core/chart/exporter/svg/SVGThemeAdapter.d.ts +22 -0
- package/dist/core/chart/exporter/svg/__tests__/testFixtures.d.ts +46 -0
- package/dist/core/chart/exporter/svg/__tests__/visualTestUtils.d.ts +12 -0
- package/dist/core/chart/exporter/svg/overlay/axes.d.ts +4 -0
- package/dist/core/chart/exporter/svg/overlay/border.d.ts +4 -0
- package/dist/core/chart/exporter/svg/overlay/errorBars.d.ts +7 -0
- package/dist/core/chart/exporter/svg/overlay/grid.d.ts +4 -0
- package/dist/core/chart/exporter/svg/overlay/index.d.ts +12 -0
- package/dist/core/chart/exporter/svg/overlay/legend.d.ts +4 -0
- package/dist/core/chart/exporter/svg/overlay/pluginCharts.d.ts +6 -0
- package/dist/core/chart/exporter/svg/overlay/polarGrid.d.ts +4 -0
- package/dist/core/chart/exporter/svg/overlay/specialChart.d.ts +15 -0
- package/dist/core/chart/exporter/svg/overlay/title.d.ts +4 -0
- package/dist/core/chart/exporter/svg/plugins/annotations.d.ts +5 -0
- package/dist/core/chart/exporter/svg/plugins/brokenAxis.d.ts +20 -0
- package/dist/core/chart/exporter/svg/plugins/latex.d.ts +9 -0
- package/dist/core/chart/exporter/svg/plugins/register.d.ts +8 -0
- package/dist/core/chart/exporter/svg/plugins/regression.d.ts +33 -0
- package/dist/core/chart/exporter/svg/plugins/roi.d.ts +12 -0
- package/dist/core/chart/exporter/svg/plugins/tradeMarkers.d.ts +3 -0
- package/dist/core/chart/exporter/svg/plugins/types.d.ts +28 -0
- package/dist/core/chart/exporter/svg/plugins/watermark.d.ts +13 -0
- package/dist/core/chart/exporter/svg/series/band.d.ts +6 -0
- package/dist/core/chart/exporter/svg/series/bar.d.ts +6 -0
- package/dist/core/chart/exporter/svg/series/boxplot.d.ts +6 -0
- package/dist/core/chart/exporter/svg/series/candlestick.d.ts +6 -0
- package/dist/core/chart/exporter/svg/series/finitePoints.d.ts +6 -0
- package/dist/core/chart/exporter/svg/series/gauge.d.ts +5 -0
- package/dist/core/chart/exporter/svg/series/heatmap.d.ts +6 -0
- package/dist/core/chart/exporter/svg/series/indicator.d.ts +6 -0
- package/dist/core/chart/exporter/svg/series/line.d.ts +12 -0
- package/dist/core/chart/exporter/svg/series/polar.d.ts +6 -0
- package/dist/core/chart/exporter/svg/series/radar.d.ts +5 -0
- package/dist/core/chart/exporter/svg/series/registry.d.ts +10 -0
- package/dist/core/chart/exporter/svg/series/sankey.d.ts +5 -0
- package/dist/core/chart/exporter/svg/series/scatter.d.ts +1 -0
- package/dist/core/chart/exporter/svg/series/ternary.d.ts +7 -0
- package/dist/core/chart/exporter/svg/series/waterfall.d.ts +6 -0
- package/dist/core/chart/exporter/svg/seriesAtTimestamp.d.ts +4 -0
- package/dist/core/chart/exporter/svg/seriesUtils.d.ts +3 -0
- package/dist/core/chart/exporter/svg/symbols.d.ts +5 -0
- package/dist/core/chart/exporter/svg/tickUtils.d.ts +9 -0
- package/dist/core/chart/mountSVGString.d.ts +5 -0
- package/dist/core/chart/types.d.ts +2 -2
- package/dist/core/stacked/StackSVGComposer.d.ts +14 -0
- package/dist/core/stacked/index.d.ts +3 -2
- package/dist/core/stacked/types.d.ts +12 -4
- package/dist/createStackedChart-DjA3aJAu.js +2761 -0
- package/dist/createStackedChart-DjA3aJAu.js.map +1 -0
- package/dist/{hooks-DH-3bewj.js → hooks-4wQH27r9.js} +3 -3
- package/dist/{hooks-DH-3bewj.js.map → hooks-4wQH27r9.js.map} +1 -1
- package/dist/index-Bj-xyXY6.js +582 -0
- package/dist/index-Bj-xyXY6.js.map +1 -0
- package/dist/plugins/PluginManager.d.ts +5 -0
- package/dist/plugins/annotations.js +8 -7
- package/dist/plugins/annotations.js.map +1 -1
- package/dist/plugins/broken-axis.js +198 -152
- package/dist/plugins/broken-axis.js.map +1 -1
- package/dist/plugins/forecasting.js +273 -258
- package/dist/plugins/forecasting.js.map +1 -1
- package/dist/plugins/ml-integration.js +107 -93
- package/dist/plugins/ml-integration.js.map +1 -1
- package/dist/plugins/radar/types.d.ts +11 -0
- package/dist/plugins/radar.js +64 -53
- package/dist/plugins/radar.js.map +1 -1
- package/dist/plugins/roi/index.d.ts +2 -0
- package/dist/plugins/roi.js +184 -145
- package/dist/plugins/roi.js.map +1 -1
- package/dist/plugins/snapshot.js +20 -15
- package/dist/plugins/snapshot.js.map +1 -1
- package/dist/plugins/types.d.ts +4 -0
- package/dist/react.js +2 -2
- package/dist/regression-HNdyk1Dm.js +28 -0
- package/dist/regression-HNdyk1Dm.js.map +1 -0
- package/dist/renderer/ChartSeriesRenderer.d.ts +3 -2
- package/dist/renderer/SVGChartRenderer.d.ts +15 -0
- package/dist/renderer/SankeyRenderer.d.ts +1 -0
- package/dist/renderer/registerSVG.d.ts +5 -0
- package/dist/renderer/sankeyLayout.d.ts +29 -0
- package/dist/scientific.js +2 -2
- package/dist/solid.js +2 -2
- package/dist/svelte.js +2 -2
- package/dist/tickUtils-B_X-ha13.js +41 -0
- package/dist/tickUtils-B_X-ha13.js.map +1 -0
- package/dist/trading.js +3 -3
- package/dist/types.d.ts +2 -1
- package/dist/velo-plot.full.js +1107 -1292
- package/dist/velo-plot.full.js.map +1 -1
- package/dist/velo-plot.js +2 -2
- package/dist/vue/VeloPlot.vue.d.ts +1 -1
- package/dist/vue/index.d.ts +33 -33
- package/dist/vue.js +2 -2
- package/package.json +6 -1
- package/dist/ChartCore-AnR_3Xkb.js.map +0 -1
- package/dist/createStackedChart-DqcLCFGS.js +0 -1338
- package/dist/createStackedChart-DqcLCFGS.js.map +0 -1
- package/dist/index-Cv6ZDLWf.js +0 -521
- package/dist/index-Cv6ZDLWf.js.map +0 -1
package/dist/index-Cv6ZDLWf.js
DELETED
|
@@ -1,521 +0,0 @@
|
|
|
1
|
-
function it(r) {
|
|
2
|
-
const e = r.close.length, s = new Float32Array(e), n = new Float32Array(e), i = new Float32Array(e), c = new Float32Array(e);
|
|
3
|
-
for (let l = 0; l < e; l++) {
|
|
4
|
-
const d = r.open[l], h = r.high[l], u = r.low[l], x = r.close[l];
|
|
5
|
-
c[l] = (d + h + u + x) / 4, s[l] = l === 0 ? (d + x) / 2 : (s[l - 1] + c[l - 1]) / 2, n[l] = Math.max(h, s[l], c[l]), i[l] = Math.min(u, s[l], c[l]);
|
|
6
|
-
}
|
|
7
|
-
return { open: s, high: n, low: i, close: c };
|
|
8
|
-
}
|
|
9
|
-
function lt(r) {
|
|
10
|
-
const e = r.length, s = new Float64Array(e), n = new Float32Array(e), i = new Float32Array(e), c = new Float32Array(e), l = new Float32Array(e), d = new Float32Array(e);
|
|
11
|
-
for (let h = 0; h < e; h++) {
|
|
12
|
-
const u = r[h];
|
|
13
|
-
s[h] = u.time, n[h] = u.open, i[h] = u.high, c[h] = u.low, l[h] = u.close, d[h] = u.volume ?? 0;
|
|
14
|
-
}
|
|
15
|
-
return { x: s, open: n, high: i, low: c, close: l, volume: d };
|
|
16
|
-
}
|
|
17
|
-
function j(r) {
|
|
18
|
-
let e = r;
|
|
19
|
-
return () => (e = e * 16807 % 2147483647, (e - 1) / 2147483646);
|
|
20
|
-
}
|
|
21
|
-
function J(r, e, s, n, i) {
|
|
22
|
-
const c = [];
|
|
23
|
-
let l = n;
|
|
24
|
-
for (let d = r; d <= e; d += s) {
|
|
25
|
-
const h = l, u = (i() - 0.48) * 2, x = Math.max(1, h + u), y = Math.max(h, x) + i() * 1.5, k = Math.min(h, x) - i() * 1.5;
|
|
26
|
-
c.push({
|
|
27
|
-
time: d,
|
|
28
|
-
open: h,
|
|
29
|
-
high: y,
|
|
30
|
-
low: k,
|
|
31
|
-
close: x,
|
|
32
|
-
volume: 1e3 + i() * 5e3
|
|
33
|
-
}), l = x;
|
|
34
|
-
}
|
|
35
|
-
return c;
|
|
36
|
-
}
|
|
37
|
-
function ct(r = {}) {
|
|
38
|
-
const e = r.barMs ?? 6e4, s = r.basePrice ?? 100, n = j(r.seed ?? 42), i = /* @__PURE__ */ new Map();
|
|
39
|
-
return {
|
|
40
|
-
async resolveSymbol(c) {
|
|
41
|
-
return {
|
|
42
|
-
symbol: c,
|
|
43
|
-
name: c,
|
|
44
|
-
description: `Mock symbol ${c}`,
|
|
45
|
-
timezone: "UTC",
|
|
46
|
-
session: "24x7",
|
|
47
|
-
pricescale: 100
|
|
48
|
-
};
|
|
49
|
-
},
|
|
50
|
-
async getBars(c) {
|
|
51
|
-
const l = `${c.symbol}:${c.from}:${c.to}`;
|
|
52
|
-
return i.has(l) || i.set(
|
|
53
|
-
l,
|
|
54
|
-
J(c.from, c.to, e, s, n)
|
|
55
|
-
), i.get(l);
|
|
56
|
-
},
|
|
57
|
-
subscribeBars(c) {
|
|
58
|
-
let l = s + n() * 5;
|
|
59
|
-
const d = setInterval(() => {
|
|
60
|
-
const h = l, u = Math.max(1, h + (n() - 0.5) * 2), x = Math.max(h, u) + n(), y = Math.min(h, u) - n();
|
|
61
|
-
c.onBar({
|
|
62
|
-
time: Date.now(),
|
|
63
|
-
open: h,
|
|
64
|
-
high: x,
|
|
65
|
-
low: y,
|
|
66
|
-
close: u,
|
|
67
|
-
volume: 1e3 + n() * 3e3
|
|
68
|
-
}), l = u;
|
|
69
|
-
}, e);
|
|
70
|
-
return () => clearInterval(d);
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
function K(r, e) {
|
|
75
|
-
if (r.length === 0) return -1;
|
|
76
|
-
let s = 0, n = Math.abs(r[0] - e);
|
|
77
|
-
for (let i = 1; i < r.length; i++) {
|
|
78
|
-
const c = Math.abs(r[i] - e);
|
|
79
|
-
c < n && (n = c, s = i);
|
|
80
|
-
}
|
|
81
|
-
return s;
|
|
82
|
-
}
|
|
83
|
-
function Q(r) {
|
|
84
|
-
if (r.barX.length === 0)
|
|
85
|
-
return { x: r.x, y: r.y };
|
|
86
|
-
const e = K(r.barX, r.x);
|
|
87
|
-
if (e < 0) return { x: r.x, y: r.y };
|
|
88
|
-
const s = r.barX[e], n = [
|
|
89
|
-
r.open[e],
|
|
90
|
-
r.high[e],
|
|
91
|
-
r.low[e],
|
|
92
|
-
r.close[e]
|
|
93
|
-
], i = r.dataToPixelY(r.y), c = r.pixelThreshold ?? 12;
|
|
94
|
-
let l = r.y, d = 1 / 0;
|
|
95
|
-
for (const h of n) {
|
|
96
|
-
const u = r.dataToPixelY(h), x = Math.abs(u - i);
|
|
97
|
-
x < d && x <= c && (d = x, l = h);
|
|
98
|
-
}
|
|
99
|
-
return { x: s, y: l };
|
|
100
|
-
}
|
|
101
|
-
function L(r, e) {
|
|
102
|
-
const s = e.y - r.y, n = Math.abs(r.y), i = n > 0 ? s / n * 100 : 0, c = Math.round(Math.abs(e.x - r.x));
|
|
103
|
-
return { change: s, percent: i, bars: c, up: s >= 0 };
|
|
104
|
-
}
|
|
105
|
-
function U(r) {
|
|
106
|
-
const e = r.change >= 0 ? "+" : "";
|
|
107
|
-
return `${e}${r.change.toFixed(2)} (${e}${r.percent.toFixed(2)}%) · ${r.bars} bars`;
|
|
108
|
-
}
|
|
109
|
-
function Y(r) {
|
|
110
|
-
const e = Math.abs(r), s = e >= 1e3 ? 0 : e >= 1 ? 2 : 4;
|
|
111
|
-
return r.toLocaleString("en-US", {
|
|
112
|
-
minimumFractionDigits: s,
|
|
113
|
-
maximumFractionDigits: s
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
const E = [0, 0.236, 0.382, 0.5, 0.618, 0.786, 1], Z = 4, C = "#26a69a", tt = "#ef5350";
|
|
117
|
-
function B(r, e) {
|
|
118
|
-
return r.startsWith("#") && r.length === 7 ? r + e : r;
|
|
119
|
-
}
|
|
120
|
-
const et = {
|
|
121
|
-
name: "velo-plot-drawing-tools",
|
|
122
|
-
version: "1.0.0",
|
|
123
|
-
description: "Interactive trendline, horizontal, vertical, rectangle, and fibonacci drawing",
|
|
124
|
-
provides: ["drawing"],
|
|
125
|
-
tags: ["drawing", "annotations", "trading"]
|
|
126
|
-
};
|
|
127
|
-
function W(r) {
|
|
128
|
-
return r !== "none" && r !== "pan";
|
|
129
|
-
}
|
|
130
|
-
function nt(r) {
|
|
131
|
-
for (const e of r.data.getAllSeries())
|
|
132
|
-
if (e.getType() === "candlestick") return e;
|
|
133
|
-
}
|
|
134
|
-
function ht(r = {}) {
|
|
135
|
-
let e = null;
|
|
136
|
-
const s = r.autoDeselect !== !1, n = {
|
|
137
|
-
mode: "none",
|
|
138
|
-
pending: null,
|
|
139
|
-
start: null,
|
|
140
|
-
dragging: !1,
|
|
141
|
-
dragMoved: !1,
|
|
142
|
-
dragStartPixel: null,
|
|
143
|
-
cursor: null,
|
|
144
|
-
magnet: r.magnet ?? !1,
|
|
145
|
-
undoStack: [],
|
|
146
|
-
redoStack: []
|
|
147
|
-
}, i = r.color ?? "#38bdf8", c = r.measureUpColor ?? C, l = r.measureDownColor ?? tt;
|
|
148
|
-
function d() {
|
|
149
|
-
var t, o;
|
|
150
|
-
return ((o = e == null ? void 0 : (t = e.chart).getAnnotations) == null ? void 0 : o.call(t)) ?? [];
|
|
151
|
-
}
|
|
152
|
-
function h() {
|
|
153
|
-
n.undoStack.push(d()), n.redoStack = [];
|
|
154
|
-
}
|
|
155
|
-
function u() {
|
|
156
|
-
n.pending = null, n.start = null, n.dragging = !1, n.dragMoved = !1, n.dragStartPixel = null;
|
|
157
|
-
}
|
|
158
|
-
function x(t) {
|
|
159
|
-
var o, a;
|
|
160
|
-
n.mode = t, u(), (o = r.onModeChange) == null || o.call(r, t), (a = e == null ? void 0 : e.requestRender) == null || a.call(e);
|
|
161
|
-
}
|
|
162
|
-
function y() {
|
|
163
|
-
var t;
|
|
164
|
-
u(), s ? x("none") : (t = e == null ? void 0 : e.requestRender) == null || t.call(e);
|
|
165
|
-
}
|
|
166
|
-
function k(t, o) {
|
|
167
|
-
if (!e || !n.magnet) return { x: t, y: o };
|
|
168
|
-
const a = nt(e);
|
|
169
|
-
if (!a) return { x: t, y: o };
|
|
170
|
-
const f = a.getData();
|
|
171
|
-
return !f.open || !f.high || !f.low || !f.close ? { x: t, y: o } : Q({
|
|
172
|
-
x: t,
|
|
173
|
-
y: o,
|
|
174
|
-
barX: f.x,
|
|
175
|
-
open: f.open,
|
|
176
|
-
high: f.high,
|
|
177
|
-
low: f.low,
|
|
178
|
-
close: f.close,
|
|
179
|
-
dataToPixelX: e.coords.dataToPixelX,
|
|
180
|
-
dataToPixelY: (m) => e.coords.dataToPixelY(m),
|
|
181
|
-
enabled: !0
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
function b(t, o) {
|
|
185
|
-
return k(
|
|
186
|
-
t.coords.pixelToDataX(o.pixelX),
|
|
187
|
-
t.coords.pixelToDataY(o.pixelY)
|
|
188
|
-
);
|
|
189
|
-
}
|
|
190
|
-
function D(t) {
|
|
191
|
-
e && (h(), e.chart.addAnnotation({
|
|
192
|
-
type: "horizontal-line",
|
|
193
|
-
y: t,
|
|
194
|
-
color: i,
|
|
195
|
-
interactive: !0
|
|
196
|
-
}));
|
|
197
|
-
}
|
|
198
|
-
function z(t) {
|
|
199
|
-
e && (h(), e.chart.addAnnotation({
|
|
200
|
-
type: "vertical-line",
|
|
201
|
-
x: t,
|
|
202
|
-
color: i,
|
|
203
|
-
interactive: !0
|
|
204
|
-
}));
|
|
205
|
-
}
|
|
206
|
-
function _(t, o) {
|
|
207
|
-
if (!e) return;
|
|
208
|
-
h();
|
|
209
|
-
const a = L(t, o), f = a.up ? c : l, m = (t.x + o.x) / 2;
|
|
210
|
-
e.chart.addAnnotation({
|
|
211
|
-
type: "rectangle",
|
|
212
|
-
xMin: Math.min(t.x, o.x),
|
|
213
|
-
xMax: Math.max(t.x, o.x),
|
|
214
|
-
yMin: Math.min(t.y, o.y),
|
|
215
|
-
yMax: Math.max(t.y, o.y),
|
|
216
|
-
strokeColor: f,
|
|
217
|
-
fillColor: B(f, "33"),
|
|
218
|
-
interactive: !0
|
|
219
|
-
}), e.chart.addAnnotation({
|
|
220
|
-
type: "arrow",
|
|
221
|
-
x1: m,
|
|
222
|
-
y1: t.y,
|
|
223
|
-
x2: m,
|
|
224
|
-
y2: o.y,
|
|
225
|
-
color: f,
|
|
226
|
-
headStyle: "filled",
|
|
227
|
-
interactive: !0
|
|
228
|
-
}), e.chart.addAnnotation({
|
|
229
|
-
type: "text",
|
|
230
|
-
x: m,
|
|
231
|
-
y: o.y,
|
|
232
|
-
text: U(a),
|
|
233
|
-
color: "#ffffff",
|
|
234
|
-
backgroundColor: f,
|
|
235
|
-
padding: 4,
|
|
236
|
-
fontWeight: "bold",
|
|
237
|
-
anchor: a.up ? "bottom-center" : "top-center",
|
|
238
|
-
interactive: !0
|
|
239
|
-
});
|
|
240
|
-
}
|
|
241
|
-
function I(t, o) {
|
|
242
|
-
if (e) {
|
|
243
|
-
if (n.mode === "measure") {
|
|
244
|
-
_(t, o);
|
|
245
|
-
return;
|
|
246
|
-
}
|
|
247
|
-
if (h(), n.mode === "trendline")
|
|
248
|
-
e.chart.addAnnotation({
|
|
249
|
-
type: "arrow",
|
|
250
|
-
x1: t.x,
|
|
251
|
-
y1: t.y,
|
|
252
|
-
x2: o.x,
|
|
253
|
-
y2: o.y,
|
|
254
|
-
color: i,
|
|
255
|
-
interactive: !0
|
|
256
|
-
});
|
|
257
|
-
else if (n.mode === "rectangle")
|
|
258
|
-
e.chart.addAnnotation({
|
|
259
|
-
type: "rectangle",
|
|
260
|
-
xMin: Math.min(t.x, o.x),
|
|
261
|
-
xMax: Math.max(t.x, o.x),
|
|
262
|
-
yMin: Math.min(t.y, o.y),
|
|
263
|
-
yMax: Math.max(t.y, o.y),
|
|
264
|
-
strokeColor: i,
|
|
265
|
-
fillColor: i + "22",
|
|
266
|
-
interactive: !0
|
|
267
|
-
});
|
|
268
|
-
else if (n.mode === "fibonacci") {
|
|
269
|
-
const a = Math.min(t.y, o.y), f = Math.max(t.y, o.y);
|
|
270
|
-
for (const m of E) {
|
|
271
|
-
const M = f - (f - a) * m;
|
|
272
|
-
e.chart.addAnnotation({
|
|
273
|
-
type: "horizontal-line",
|
|
274
|
-
y: M,
|
|
275
|
-
color: i,
|
|
276
|
-
lineDash: m === 0 || m === 1 ? void 0 : [4, 4],
|
|
277
|
-
label: `${(m * 100).toFixed(1)}% ${Y(M)}`,
|
|
278
|
-
labelPosition: "right",
|
|
279
|
-
interactive: !0
|
|
280
|
-
});
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
function H(t, o, a) {
|
|
286
|
-
const f = n.mode;
|
|
287
|
-
if (!W(f) || !n.cursor) return;
|
|
288
|
-
const m = n.cursor, M = n.pending ?? n.start;
|
|
289
|
-
t.save(), t.strokeStyle = i, t.lineWidth = 1.5, t.setLineDash([6, 4]), t.globalAlpha = 0.85;
|
|
290
|
-
const v = (g, w) => ({
|
|
291
|
-
px: a.dataToPixelX(g),
|
|
292
|
-
py: a.dataToPixelY(w)
|
|
293
|
-
});
|
|
294
|
-
if (f === "horizontal") {
|
|
295
|
-
const { py: g } = v(0, m.y);
|
|
296
|
-
t.beginPath(), t.moveTo(o.x, g), t.lineTo(o.x + o.width, g), t.stroke();
|
|
297
|
-
} else if (f === "vertical") {
|
|
298
|
-
const { px: g } = v(m.x, 0);
|
|
299
|
-
t.beginPath(), t.moveTo(g, o.y), t.lineTo(g, o.y + o.height), t.stroke();
|
|
300
|
-
} else if (M) {
|
|
301
|
-
const g = v(M.x, M.y), w = v(m.x, m.y);
|
|
302
|
-
if (f === "trendline")
|
|
303
|
-
t.beginPath(), t.moveTo(g.px, g.py), t.lineTo(w.px, w.py), t.stroke();
|
|
304
|
-
else if (f === "rectangle") {
|
|
305
|
-
const A = Math.min(g.px, w.px), P = Math.min(g.py, w.py), p = Math.abs(w.px - g.px), S = Math.abs(w.py - g.py);
|
|
306
|
-
t.strokeRect(A, P, p, S), t.fillStyle = i + "22", t.fillRect(A, P, p, S);
|
|
307
|
-
} else if (f === "fibonacci") {
|
|
308
|
-
const A = Math.min(M.y, m.y), P = Math.max(M.y, m.y);
|
|
309
|
-
t.font = "11px sans-serif", t.textAlign = "left", t.textBaseline = "bottom";
|
|
310
|
-
for (const p of E) {
|
|
311
|
-
const S = P - (P - A) * p, { py: T } = v(0, S);
|
|
312
|
-
t.beginPath(), t.moveTo(o.x, T), t.lineTo(o.x + o.width, T), t.stroke(), t.save(), t.setLineDash([]), t.globalAlpha = 1, t.fillStyle = i, t.fillText(
|
|
313
|
-
`${(p * 100).toFixed(1)}% ${Y(S)}`,
|
|
314
|
-
o.x + 4,
|
|
315
|
-
T - 2
|
|
316
|
-
), t.restore();
|
|
317
|
-
}
|
|
318
|
-
} else f === "measure" && O(t, g, w, M, m);
|
|
319
|
-
}
|
|
320
|
-
t.restore();
|
|
321
|
-
}
|
|
322
|
-
function O(t, o, a, f, m) {
|
|
323
|
-
const M = L(f, m), v = M.up ? c : l, g = Math.min(o.px, a.px), w = Math.min(o.py, a.py), A = Math.abs(a.px - o.px), P = Math.abs(a.py - o.py);
|
|
324
|
-
t.setLineDash([]), t.globalAlpha = 0.9, t.fillStyle = B(v, "33"), t.fillRect(g, w, A, P), t.strokeStyle = v, t.lineWidth = 1.5, t.strokeRect(g, w, A, P);
|
|
325
|
-
const p = (o.px + a.px) / 2;
|
|
326
|
-
t.beginPath(), t.moveTo(p, o.py), t.lineTo(p, a.py), t.stroke();
|
|
327
|
-
const S = 7, T = a.py >= o.py ? 1 : -1;
|
|
328
|
-
t.beginPath(), t.moveTo(p, a.py), t.lineTo(p - 4, a.py - T * S), t.lineTo(p + 4, a.py - T * S), t.closePath(), t.fillStyle = v, t.fill();
|
|
329
|
-
const R = U(M);
|
|
330
|
-
t.font = "12px sans-serif";
|
|
331
|
-
const X = t.measureText(R).width + 6 * 2, F = 20, G = p - X / 2, $ = M.up ? a.py - F - 8 : a.py + 8;
|
|
332
|
-
t.globalAlpha = 1, t.fillStyle = v, t.fillRect(G, $, X, F), t.fillStyle = "#ffffff", t.textAlign = "center", t.textBaseline = "middle", t.fillText(R, p, $ + F / 2);
|
|
333
|
-
}
|
|
334
|
-
function N(t, o) {
|
|
335
|
-
var f;
|
|
336
|
-
if (!o.inPlotArea) return;
|
|
337
|
-
o.preventDefault();
|
|
338
|
-
const a = b(t, o);
|
|
339
|
-
if (n.mode === "horizontal") {
|
|
340
|
-
D(a.y), y();
|
|
341
|
-
return;
|
|
342
|
-
}
|
|
343
|
-
if (n.mode === "vertical") {
|
|
344
|
-
z(a.x), y();
|
|
345
|
-
return;
|
|
346
|
-
}
|
|
347
|
-
if (n.pending) {
|
|
348
|
-
I(n.pending, a), y();
|
|
349
|
-
return;
|
|
350
|
-
}
|
|
351
|
-
n.start = a, n.dragging = !0, n.dragMoved = !1, n.dragStartPixel = { x: o.pixelX, y: o.pixelY }, n.cursor = a, (f = t.requestRender) == null || f.call(t);
|
|
352
|
-
}
|
|
353
|
-
function V(t, o) {
|
|
354
|
-
var f;
|
|
355
|
-
const a = b(t, o);
|
|
356
|
-
if (n.cursor = a, n.dragging && n.dragStartPixel) {
|
|
357
|
-
const m = o.pixelX - n.dragStartPixel.x, M = o.pixelY - n.dragStartPixel.y;
|
|
358
|
-
Math.hypot(m, M) >= Z && (n.dragMoved = !0);
|
|
359
|
-
}
|
|
360
|
-
o.preventDefault(), (f = t.requestRender) == null || f.call(t);
|
|
361
|
-
}
|
|
362
|
-
function q(t, o) {
|
|
363
|
-
var m;
|
|
364
|
-
if (!n.dragging || !n.start) return;
|
|
365
|
-
const a = b(t, o), f = n.start;
|
|
366
|
-
if (n.dragging = !1, n.dragStartPixel = null, n.dragMoved) {
|
|
367
|
-
I(f, a), y();
|
|
368
|
-
return;
|
|
369
|
-
}
|
|
370
|
-
n.pending = f, n.start = null, n.cursor = a, (m = t.requestRender) == null || m.call(t);
|
|
371
|
-
}
|
|
372
|
-
return {
|
|
373
|
-
manifest: et,
|
|
374
|
-
api: {
|
|
375
|
-
setMode(t) {
|
|
376
|
-
x(t);
|
|
377
|
-
},
|
|
378
|
-
getMode() {
|
|
379
|
-
return n.mode;
|
|
380
|
-
},
|
|
381
|
-
setMagnet(t) {
|
|
382
|
-
n.magnet = t;
|
|
383
|
-
},
|
|
384
|
-
isMagnet() {
|
|
385
|
-
return n.magnet;
|
|
386
|
-
},
|
|
387
|
-
undo() {
|
|
388
|
-
if (!e || n.undoStack.length === 0) return !1;
|
|
389
|
-
n.redoStack.push(d());
|
|
390
|
-
const t = n.undoStack.pop(), o = d();
|
|
391
|
-
for (const a of o) e.chart.removeAnnotation(a.id);
|
|
392
|
-
for (const a of t) e.chart.addAnnotation(a);
|
|
393
|
-
return !0;
|
|
394
|
-
},
|
|
395
|
-
redo() {
|
|
396
|
-
if (!e || n.redoStack.length === 0) return !1;
|
|
397
|
-
n.undoStack.push(d());
|
|
398
|
-
const t = n.redoStack.pop(), o = d();
|
|
399
|
-
for (const a of o) e.chart.removeAnnotation(a.id);
|
|
400
|
-
for (const a of t) e.chart.addAnnotation(a);
|
|
401
|
-
return !0;
|
|
402
|
-
},
|
|
403
|
-
clear() {
|
|
404
|
-
if (e) {
|
|
405
|
-
h();
|
|
406
|
-
for (const t of d()) e.chart.removeAnnotation(t.id);
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
},
|
|
410
|
-
onInit(t) {
|
|
411
|
-
e = t;
|
|
412
|
-
},
|
|
413
|
-
onDestroy() {
|
|
414
|
-
e = null;
|
|
415
|
-
},
|
|
416
|
-
onInteraction(t, o) {
|
|
417
|
-
if (W(n.mode)) {
|
|
418
|
-
if (o.type === "mousedown") {
|
|
419
|
-
N(t, o);
|
|
420
|
-
return;
|
|
421
|
-
}
|
|
422
|
-
if (o.type === "mousemove") {
|
|
423
|
-
V(t, o);
|
|
424
|
-
return;
|
|
425
|
-
}
|
|
426
|
-
o.type === "mouseup" && q(t, o);
|
|
427
|
-
}
|
|
428
|
-
},
|
|
429
|
-
onRenderOverlay(t) {
|
|
430
|
-
const o = t.render.ctx2d;
|
|
431
|
-
o && H(o, t.render.plotArea, t.coords);
|
|
432
|
-
}
|
|
433
|
-
};
|
|
434
|
-
}
|
|
435
|
-
const ot = {
|
|
436
|
-
name: "velo-plot-replay",
|
|
437
|
-
version: "1.0.0",
|
|
438
|
-
description: "Bar-by-bar chart replay with speed control",
|
|
439
|
-
provides: ["replay"],
|
|
440
|
-
tags: ["replay", "trading"]
|
|
441
|
-
};
|
|
442
|
-
function ft(r) {
|
|
443
|
-
let e = null, s = null, n = 0, i = null, c = 1;
|
|
444
|
-
const l = r.frameMs ?? 250;
|
|
445
|
-
function d(u) {
|
|
446
|
-
const x = e, y = s, k = Math.min(u + 1, y.x.length), b = (D) => D ? D.subarray(0, k) : void 0;
|
|
447
|
-
x.chart.updateSeries(r.seriesId, {
|
|
448
|
-
x: b(y.x),
|
|
449
|
-
y: b(y.y),
|
|
450
|
-
open: b(y.open),
|
|
451
|
-
high: b(y.high),
|
|
452
|
-
low: b(y.low),
|
|
453
|
-
close: b(y.close)
|
|
454
|
-
});
|
|
455
|
-
}
|
|
456
|
-
const h = {
|
|
457
|
-
play(u = 1) {
|
|
458
|
-
s && (c = Math.max(0.1, u), i && clearInterval(i), i = setInterval(() => {
|
|
459
|
-
if (!e || !s) {
|
|
460
|
-
h.pause();
|
|
461
|
-
return;
|
|
462
|
-
}
|
|
463
|
-
if (n >= s.x.length - 1) {
|
|
464
|
-
h.pause();
|
|
465
|
-
return;
|
|
466
|
-
}
|
|
467
|
-
n++, d(n);
|
|
468
|
-
}, l / c));
|
|
469
|
-
},
|
|
470
|
-
pause() {
|
|
471
|
-
i && (clearInterval(i), i = null);
|
|
472
|
-
},
|
|
473
|
-
step(u = 1) {
|
|
474
|
-
s && (n = Math.min(s.x.length - 1, n + u), d(n));
|
|
475
|
-
},
|
|
476
|
-
seek(u) {
|
|
477
|
-
s && (n = Math.max(0, Math.min(s.x.length - 1, u)), d(n));
|
|
478
|
-
},
|
|
479
|
-
getIndex() {
|
|
480
|
-
return n;
|
|
481
|
-
},
|
|
482
|
-
getLength() {
|
|
483
|
-
return (s == null ? void 0 : s.x.length) ?? 0;
|
|
484
|
-
},
|
|
485
|
-
isPlaying() {
|
|
486
|
-
return i != null;
|
|
487
|
-
}
|
|
488
|
-
};
|
|
489
|
-
return {
|
|
490
|
-
manifest: ot,
|
|
491
|
-
api: h,
|
|
492
|
-
onInit(u) {
|
|
493
|
-
e = u;
|
|
494
|
-
const x = e.chart.getSeries(r.seriesId);
|
|
495
|
-
if (!x) {
|
|
496
|
-
console.warn(`[PluginReplay] Series "${r.seriesId}" not found`);
|
|
497
|
-
return;
|
|
498
|
-
}
|
|
499
|
-
const y = x.getData();
|
|
500
|
-
s = {
|
|
501
|
-
x: Float32Array.from(y.x),
|
|
502
|
-
y: y.y ? Float32Array.from(y.y) : void 0,
|
|
503
|
-
open: y.open ? Float32Array.from(y.open) : void 0,
|
|
504
|
-
high: y.high ? Float32Array.from(y.high) : void 0,
|
|
505
|
-
low: y.low ? Float32Array.from(y.low) : void 0,
|
|
506
|
-
close: y.close ? Float32Array.from(y.close) : void 0
|
|
507
|
-
}, n = Math.max(0, s.x.length - 1);
|
|
508
|
-
},
|
|
509
|
-
onDestroy() {
|
|
510
|
-
h.pause(), e = null, s = null;
|
|
511
|
-
}
|
|
512
|
-
};
|
|
513
|
-
}
|
|
514
|
-
export {
|
|
515
|
-
ht as P,
|
|
516
|
-
ft as a,
|
|
517
|
-
lt as b,
|
|
518
|
-
it as c,
|
|
519
|
-
ct as d
|
|
520
|
-
};
|
|
521
|
-
//# sourceMappingURL=index-Cv6ZDLWf.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-Cv6ZDLWf.js","sources":["../src/core/chart/heikinAshi.ts","../src/trading/datafeed.ts","../src/trading/mockDatafeed.ts","../src/plugins/drawing-tools/snapToCandle.ts","../src/plugins/drawing-tools/measure.ts","../src/plugins/drawing-tools/index.ts","../src/plugins/replay/index.ts"],"sourcesContent":["/**\n * Heikin-Ashi OHLC transform (Stage 2.20).\n */\n\nexport interface OhlcArrays {\n open: Float32Array | Float64Array;\n high: Float32Array | Float64Array;\n low: Float32Array | Float64Array;\n close: Float32Array | Float64Array;\n}\n\nexport function computeHeikinAshi(ohlc: OhlcArrays): OhlcArrays {\n const n = ohlc.close.length;\n const haOpen = new Float32Array(n);\n const haHigh = new Float32Array(n);\n const haLow = new Float32Array(n);\n const haClose = new Float32Array(n);\n\n for (let i = 0; i < n; i++) {\n const o = ohlc.open[i];\n const h = ohlc.high[i];\n const l = ohlc.low[i];\n const c = ohlc.close[i];\n\n haClose[i] = (o + h + l + c) / 4;\n haOpen[i] = i === 0 ? (o + c) / 2 : (haOpen[i - 1] + haClose[i - 1]) / 2;\n haHigh[i] = Math.max(h, haOpen[i], haClose[i]);\n haLow[i] = Math.min(l, haOpen[i], haClose[i]);\n }\n\n return { open: haOpen, high: haHigh, low: haLow, close: haClose };\n}\n","/**\n * UDF-inspired datafeed contract for trading charts (Stage 2.24).\n */\n\nexport interface SymbolInfo {\n symbol: string;\n name: string;\n description?: string;\n timezone?: string;\n session?: string;\n pricescale?: number;\n minmov?: number;\n}\n\nexport interface Bar {\n time: number;\n open: number;\n high: number;\n low: number;\n close: number;\n volume?: number;\n}\n\nexport interface HistoryRequest {\n symbol: string;\n resolution: string;\n from: number;\n to: number;\n}\n\nexport interface SubscribeBarsRequest {\n symbol: string;\n resolution: string;\n onBar: (bar: Bar) => void;\n}\n\n/**\n * TradingView UDF-style adapter surface.\n */\nexport interface DatafeedAdapter {\n resolveSymbol(symbol: string): Promise<SymbolInfo>;\n getBars(request: HistoryRequest): Promise<Bar[]>;\n subscribeBars(request: SubscribeBarsRequest): () => void;\n}\n\n/** Convert bars to typed OHLC arrays for velo-plot series. */\nexport function barsToOhlc(bars: Bar[]): {\n x: Float64Array;\n open: Float32Array;\n high: Float32Array;\n low: Float32Array;\n close: Float32Array;\n volume: Float32Array;\n} {\n const n = bars.length;\n const x = new Float64Array(n);\n const open = new Float32Array(n);\n const high = new Float32Array(n);\n const low = new Float32Array(n);\n const close = new Float32Array(n);\n const volume = new Float32Array(n);\n for (let i = 0; i < n; i++) {\n const b = bars[i];\n x[i] = b.time;\n open[i] = b.open;\n high[i] = b.high;\n low[i] = b.low;\n close[i] = b.close;\n volume[i] = b.volume ?? 0;\n }\n return { x, open, high, low, close, volume };\n}\n","/**\n * Mock datafeed for demos and tests (Stage 2.25).\n */\n\nimport type {\n Bar,\n DatafeedAdapter,\n HistoryRequest,\n SubscribeBarsRequest,\n SymbolInfo,\n} from \"./datafeed\";\n\nexport interface MockDatafeedOptions {\n symbol?: string;\n barMs?: number;\n basePrice?: number;\n seed?: number;\n}\n\nfunction pseudoRandom(seed: number): () => number {\n let s = seed;\n return () => {\n s = (s * 16807) % 2147483647;\n return (s - 1) / 2147483646;\n };\n}\n\nfunction generateBars(from: number, to: number, barMs: number, base: number, rand: () => number): Bar[] {\n const bars: Bar[] = [];\n let price = base;\n for (let t = from; t <= to; t += barMs) {\n const open = price;\n const delta = (rand() - 0.48) * 2;\n const close = Math.max(1, open + delta);\n const high = Math.max(open, close) + rand() * 1.5;\n const low = Math.min(open, close) - rand() * 1.5;\n bars.push({\n time: t,\n open,\n high,\n low,\n close,\n volume: 1000 + rand() * 5000,\n });\n price = close;\n }\n return bars;\n}\n\nexport function createMockDatafeed(options: MockDatafeedOptions = {}): DatafeedAdapter {\n const barMs = options.barMs ?? 60_000;\n const basePrice = options.basePrice ?? 100;\n const rand = pseudoRandom(options.seed ?? 42);\n const cache = new Map<string, Bar[]>();\n\n return {\n async resolveSymbol(sym: string): Promise<SymbolInfo> {\n return {\n symbol: sym,\n name: sym,\n description: `Mock symbol ${sym}`,\n timezone: \"UTC\",\n session: \"24x7\",\n pricescale: 100,\n };\n },\n\n async getBars(request: HistoryRequest): Promise<Bar[]> {\n const key = `${request.symbol}:${request.from}:${request.to}`;\n if (!cache.has(key)) {\n cache.set(\n key,\n generateBars(request.from, request.to, barMs, basePrice, rand),\n );\n }\n return cache.get(key)!;\n },\n\n subscribeBars(request: SubscribeBarsRequest): () => void {\n let last = basePrice + rand() * 5;\n const timer = setInterval(() => {\n const open = last;\n const close = Math.max(1, open + (rand() - 0.5) * 2);\n const high = Math.max(open, close) + rand();\n const low = Math.min(open, close) - rand();\n request.onBar({\n time: Date.now(),\n open,\n high,\n low,\n close,\n volume: 1000 + rand() * 3000,\n });\n last = close;\n }, barMs);\n return () => clearInterval(timer);\n },\n };\n}\n","/**\n * Snap drawing points to nearest candlestick O/H/L/C (TradingView-style magnet).\n */\n\nexport interface CandleSnapInput {\n x: number;\n y: number;\n barX: Float32Array | Float64Array;\n open: Float32Array | Float64Array;\n high: Float32Array | Float64Array;\n low: Float32Array | Float64Array;\n close: Float32Array | Float64Array;\n dataToPixelX: (x: number) => number;\n dataToPixelY: (y: number) => number;\n pixelThreshold?: number;\n enabled?: boolean;\n}\n\nexport function findNearestBarIndex(\n barX: Float32Array | Float64Array,\n x: number,\n): number {\n if (barX.length === 0) return -1;\n let bestIdx = 0;\n let bestDist = Math.abs(barX[0] - x);\n for (let i = 1; i < barX.length; i++) {\n const d = Math.abs(barX[i] - x);\n if (d < bestDist) {\n bestDist = d;\n bestIdx = i;\n }\n }\n return bestIdx;\n}\n\nexport function snapToCandle(input: CandleSnapInput): { x: number; y: number } {\n if (input.enabled === false || input.barX.length === 0) {\n return { x: input.x, y: input.y };\n }\n\n const idx = findNearestBarIndex(input.barX, input.x);\n if (idx < 0) return { x: input.x, y: input.y };\n\n const barX = input.barX[idx];\n const candidates = [\n input.open[idx],\n input.high[idx],\n input.low[idx],\n input.close[idx],\n ];\n\n const clickPy = input.dataToPixelY(input.y);\n const threshold = input.pixelThreshold ?? 12;\n let bestY = input.y;\n let bestPyDist = Infinity;\n\n for (const cy of candidates) {\n const py = input.dataToPixelY(cy);\n const dist = Math.abs(py - clickPy);\n if (dist < bestPyDist && dist <= threshold) {\n bestPyDist = dist;\n bestY = cy;\n }\n }\n\n return { x: barX, y: bestY };\n}\n","/**\n * Measurement helper for the price-range / measure tool (TradingView-style).\n */\n\nexport interface MeasurePoint {\n x: number;\n y: number;\n}\n\nexport interface Measurement {\n /** Absolute price change (end - start) */\n change: number;\n /** Percentage change relative to the start price */\n percent: number;\n /** Number of bars spanned (rounded X distance) */\n bars: number;\n /** True when the range moves up (change >= 0) */\n up: boolean;\n}\n\nexport function computeMeasurement(a: MeasurePoint, b: MeasurePoint): Measurement {\n const change = b.y - a.y;\n const denom = Math.abs(a.y);\n const percent = denom > 0 ? (change / denom) * 100 : 0;\n const bars = Math.round(Math.abs(b.x - a.x));\n return { change, percent, bars, up: change >= 0 };\n}\n\nexport function formatMeasurement(m: Measurement): string {\n const sign = m.change >= 0 ? \"+\" : \"\";\n return `${sign}${m.change.toFixed(2)} (${sign}${m.percent.toFixed(2)}%) · ${m.bars} bars`;\n}\n\n/** Compact price formatting used for level labels. */\nexport function formatPrice(value: number): string {\n const abs = Math.abs(value);\n const decimals = abs >= 1000 ? 0 : abs >= 1 ? 2 : 4;\n return value.toLocaleString(\"en-US\", {\n minimumFractionDigits: decimals,\n maximumFractionDigits: decimals,\n });\n}\n","/**\n * PluginDrawingTools — interactive drawing on chart (Stage 2.9).\n * TradingView-style live preview, drag-to-draw, optional candle magnet.\n */\n\nimport type { ChartPlugin, InteractionEvent, PluginContext, PluginManifest } from \"../types\";\nimport type { Annotation } from \"../../core/annotations/types\";\nimport type { Series } from \"../../core/Series\";\nimport { snapToCandle } from \"./snapToCandle\";\nimport { computeMeasurement, formatMeasurement, formatPrice } from \"./measure\";\n\nexport type DrawingMode =\n | \"none\"\n | \"pan\"\n | \"trendline\"\n | \"horizontal\"\n | \"vertical\"\n | \"rectangle\"\n | \"fibonacci\"\n | \"measure\";\n\nconst FIB_LEVELS = [0, 0.236, 0.382, 0.5, 0.618, 0.786, 1];\nconst DRAG_THRESHOLD_PX = 4;\nconst DEFAULT_MEASURE_UP = \"#26a69a\";\nconst DEFAULT_MEASURE_DOWN = \"#ef5350\";\n\nexport interface PluginDrawingToolsConfig {\n /** Default stroke color */\n color?: string;\n /** Enable candle magnet by default */\n magnet?: boolean;\n /** Return to pan mode after each completed stroke (default true) */\n autoDeselect?: boolean;\n /** Notified when drawing mode changes (including auto-deselect to none) */\n onModeChange?: (mode: DrawingMode) => void;\n /** Color for upward measurements (default green) */\n measureUpColor?: string;\n /** Color for downward measurements (default red) */\n measureDownColor?: string;\n}\n\nfunction withAlpha(color: string, alpha: string): string {\n return color.startsWith(\"#\") && color.length === 7 ? color + alpha : color;\n}\n\nexport interface DrawingToolsAPI {\n setMode(mode: DrawingMode): void;\n getMode(): DrawingMode;\n setMagnet(enabled: boolean): void;\n isMagnet(): boolean;\n undo(): boolean;\n redo(): boolean;\n clear(): void;\n}\n\nconst manifest: PluginManifest = {\n name: \"velo-plot-drawing-tools\",\n version: \"1.0.0\",\n description: \"Interactive trendline, horizontal, vertical, rectangle, and fibonacci drawing\",\n provides: [\"drawing\"],\n tags: [\"drawing\", \"annotations\", \"trading\"],\n};\n\ninterface DrawPoint {\n x: number;\n y: number;\n}\n\ninterface DrawState {\n mode: DrawingMode;\n pending: DrawPoint | null;\n start: DrawPoint | null;\n dragging: boolean;\n dragMoved: boolean;\n dragStartPixel: { x: number; y: number } | null;\n cursor: DrawPoint | null;\n magnet: boolean;\n undoStack: Annotation[][];\n redoStack: Annotation[][];\n}\n\nfunction isDrawingMode(mode: DrawingMode): boolean {\n return mode !== \"none\" && mode !== \"pan\";\n}\n\nfunction findCandlestickSeries(ctx: PluginContext): Series | undefined {\n for (const s of ctx.data.getAllSeries()) {\n if (s.getType() === \"candlestick\") return s;\n }\n return undefined;\n}\n\nexport function PluginDrawingTools(\n config: PluginDrawingToolsConfig = {},\n): ChartPlugin<PluginDrawingToolsConfig> {\n let ctx: PluginContext | null = null;\n const autoDeselect = config.autoDeselect !== false;\n const state: DrawState = {\n mode: \"none\",\n pending: null,\n start: null,\n dragging: false,\n dragMoved: false,\n dragStartPixel: null,\n cursor: null,\n magnet: config.magnet ?? false,\n undoStack: [],\n redoStack: [],\n };\n\n const stroke = config.color ?? \"#38bdf8\";\n const measureUp = config.measureUpColor ?? DEFAULT_MEASURE_UP;\n const measureDown = config.measureDownColor ?? DEFAULT_MEASURE_DOWN;\n\n function snapshot(): Annotation[] {\n return ctx?.chart.getAnnotations?.() ?? [];\n }\n\n function pushUndo(): void {\n state.undoStack.push(snapshot());\n state.redoStack = [];\n }\n\n function resetInteractionState(): void {\n state.pending = null;\n state.start = null;\n state.dragging = false;\n state.dragMoved = false;\n state.dragStartPixel = null;\n }\n\n function setModeInternal(mode: DrawingMode): void {\n state.mode = mode;\n resetInteractionState();\n config.onModeChange?.(mode);\n ctx?.requestRender?.();\n }\n\n function finishStroke(): void {\n resetInteractionState();\n if (autoDeselect) {\n setModeInternal(\"none\");\n } else {\n ctx?.requestRender?.();\n }\n }\n\n function resolvePoint(x: number, y: number): DrawPoint {\n if (!ctx || !state.magnet) return { x, y };\n const series = findCandlestickSeries(ctx);\n if (!series) return { x, y };\n const d = series.getData();\n if (!d.open || !d.high || !d.low || !d.close) return { x, y };\n return snapToCandle({\n x,\n y,\n barX: d.x,\n open: d.open,\n high: d.high,\n low: d.low,\n close: d.close,\n dataToPixelX: ctx.coords.dataToPixelX,\n dataToPixelY: (dy) => ctx!.coords.dataToPixelY(dy),\n enabled: true,\n });\n }\n\n function pointFromEvent(pluginCtx: PluginContext, event: InteractionEvent): DrawPoint {\n return resolvePoint(\n pluginCtx.coords.pixelToDataX(event.pixelX),\n pluginCtx.coords.pixelToDataY(event.pixelY),\n );\n }\n\n function commitHorizontal(y: number): void {\n if (!ctx) return;\n pushUndo();\n ctx.chart.addAnnotation({\n type: \"horizontal-line\",\n y,\n color: stroke,\n interactive: true,\n });\n }\n\n function commitVertical(x: number): void {\n if (!ctx) return;\n pushUndo();\n ctx.chart.addAnnotation({\n type: \"vertical-line\",\n x,\n color: stroke,\n interactive: true,\n });\n }\n\n function commitMeasure(p0: DrawPoint, p1: DrawPoint): void {\n if (!ctx) return;\n pushUndo();\n\n const m = computeMeasurement(p0, p1);\n const color = m.up ? measureUp : measureDown;\n const midX = (p0.x + p1.x) / 2;\n ctx.chart.addAnnotation({\n type: \"rectangle\",\n xMin: Math.min(p0.x, p1.x),\n xMax: Math.max(p0.x, p1.x),\n yMin: Math.min(p0.y, p1.y),\n yMax: Math.max(p0.y, p1.y),\n strokeColor: color,\n fillColor: withAlpha(color, \"33\"),\n interactive: true,\n });\n ctx.chart.addAnnotation({\n type: \"arrow\",\n x1: midX,\n y1: p0.y,\n x2: midX,\n y2: p1.y,\n color,\n headStyle: \"filled\",\n interactive: true,\n });\n ctx.chart.addAnnotation({\n type: \"text\",\n x: midX,\n y: p1.y,\n text: formatMeasurement(m),\n color: \"#ffffff\",\n backgroundColor: color,\n padding: 4,\n fontWeight: \"bold\",\n anchor: m.up ? \"bottom-center\" : \"top-center\",\n interactive: true,\n });\n }\n\n function commitTwoPoint(p0: DrawPoint, p1: DrawPoint): void {\n if (!ctx) return;\n\n if (state.mode === \"measure\") {\n commitMeasure(p0, p1);\n return;\n }\n\n pushUndo();\n\n if (state.mode === \"trendline\") {\n ctx.chart.addAnnotation({\n type: \"arrow\",\n x1: p0.x,\n y1: p0.y,\n x2: p1.x,\n y2: p1.y,\n color: stroke,\n interactive: true,\n });\n } else if (state.mode === \"rectangle\") {\n ctx.chart.addAnnotation({\n type: \"rectangle\",\n xMin: Math.min(p0.x, p1.x),\n xMax: Math.max(p0.x, p1.x),\n yMin: Math.min(p0.y, p1.y),\n yMax: Math.max(p0.y, p1.y),\n strokeColor: stroke,\n fillColor: stroke + \"22\",\n interactive: true,\n });\n } else if (state.mode === \"fibonacci\") {\n const yMin = Math.min(p0.y, p1.y);\n const yMax = Math.max(p0.y, p1.y);\n for (const level of FIB_LEVELS) {\n const fy = yMax - (yMax - yMin) * level;\n ctx.chart.addAnnotation({\n type: \"horizontal-line\",\n y: fy,\n color: stroke,\n lineDash: level === 0 || level === 1 ? undefined : [4, 4],\n label: `${(level * 100).toFixed(1)}% ${formatPrice(fy)}`,\n labelPosition: \"right\",\n interactive: true,\n });\n }\n }\n }\n\n function drawPreview(\n c2d: CanvasRenderingContext2D,\n plotArea: { x: number; y: number; width: number; height: number },\n coords: PluginContext[\"coords\"],\n ): void {\n const mode = state.mode;\n if (!isDrawingMode(mode) || !state.cursor) return;\n\n const cursor = state.cursor;\n const anchor = state.pending ?? state.start;\n\n c2d.save();\n c2d.strokeStyle = stroke;\n c2d.lineWidth = 1.5;\n c2d.setLineDash([6, 4]);\n c2d.globalAlpha = 0.85;\n\n const toPx = (x: number, y: number) => ({\n px: coords.dataToPixelX(x),\n py: coords.dataToPixelY(y),\n });\n\n if (mode === \"horizontal\") {\n const { py } = toPx(0, cursor.y);\n c2d.beginPath();\n c2d.moveTo(plotArea.x, py);\n c2d.lineTo(plotArea.x + plotArea.width, py);\n c2d.stroke();\n } else if (mode === \"vertical\") {\n const { px } = toPx(cursor.x, 0);\n c2d.beginPath();\n c2d.moveTo(px, plotArea.y);\n c2d.lineTo(px, plotArea.y + plotArea.height);\n c2d.stroke();\n } else if (anchor) {\n const a = toPx(anchor.x, anchor.y);\n const b = toPx(cursor.x, cursor.y);\n\n if (mode === \"trendline\") {\n c2d.beginPath();\n c2d.moveTo(a.px, a.py);\n c2d.lineTo(b.px, b.py);\n c2d.stroke();\n } else if (mode === \"rectangle\") {\n const x = Math.min(a.px, b.px);\n const y = Math.min(a.py, b.py);\n const w = Math.abs(b.px - a.px);\n const h = Math.abs(b.py - a.py);\n c2d.strokeRect(x, y, w, h);\n c2d.fillStyle = stroke + \"22\";\n c2d.fillRect(x, y, w, h);\n } else if (mode === \"fibonacci\") {\n const yMin = Math.min(anchor.y, cursor.y);\n const yMax = Math.max(anchor.y, cursor.y);\n c2d.font = \"11px sans-serif\";\n c2d.textAlign = \"left\";\n c2d.textBaseline = \"bottom\";\n for (const level of FIB_LEVELS) {\n const fy = yMax - (yMax - yMin) * level;\n const { py } = toPx(0, fy);\n c2d.beginPath();\n c2d.moveTo(plotArea.x, py);\n c2d.lineTo(plotArea.x + plotArea.width, py);\n c2d.stroke();\n c2d.save();\n c2d.setLineDash([]);\n c2d.globalAlpha = 1;\n c2d.fillStyle = stroke;\n c2d.fillText(\n `${(level * 100).toFixed(1)}% ${formatPrice(fy)}`,\n plotArea.x + 4,\n py - 2,\n );\n c2d.restore();\n }\n } else if (mode === \"measure\") {\n drawMeasurePreview(c2d, a, b, anchor, cursor);\n }\n }\n\n c2d.restore();\n }\n\n function drawMeasurePreview(\n c2d: CanvasRenderingContext2D,\n a: { px: number; py: number },\n b: { px: number; py: number },\n anchor: DrawPoint,\n cursor: DrawPoint,\n ): void {\n const m = computeMeasurement(anchor, cursor);\n const color = m.up ? measureUp : measureDown;\n const x = Math.min(a.px, b.px);\n const y = Math.min(a.py, b.py);\n const w = Math.abs(b.px - a.px);\n const h = Math.abs(b.py - a.py);\n\n c2d.setLineDash([]);\n c2d.globalAlpha = 0.9;\n c2d.fillStyle = withAlpha(color, \"33\");\n c2d.fillRect(x, y, w, h);\n c2d.strokeStyle = color;\n c2d.lineWidth = 1.5;\n c2d.strokeRect(x, y, w, h);\n\n // Vertical direction arrow at the horizontal center.\n const midX = (a.px + b.px) / 2;\n c2d.beginPath();\n c2d.moveTo(midX, a.py);\n c2d.lineTo(midX, b.py);\n c2d.stroke();\n const headLen = 7;\n const dir = b.py >= a.py ? 1 : -1;\n c2d.beginPath();\n c2d.moveTo(midX, b.py);\n c2d.lineTo(midX - 4, b.py - dir * headLen);\n c2d.lineTo(midX + 4, b.py - dir * headLen);\n c2d.closePath();\n c2d.fillStyle = color;\n c2d.fill();\n\n // Label with change / percent / bars.\n const label = formatMeasurement(m);\n c2d.font = \"12px sans-serif\";\n const textW = c2d.measureText(label).width;\n const padX = 6;\n const boxW = textW + padX * 2;\n const boxH = 20;\n const boxX = midX - boxW / 2;\n const boxY = m.up ? b.py - boxH - 8 : b.py + 8;\n c2d.globalAlpha = 1;\n c2d.fillStyle = color;\n c2d.fillRect(boxX, boxY, boxW, boxH);\n c2d.fillStyle = \"#ffffff\";\n c2d.textAlign = \"center\";\n c2d.textBaseline = \"middle\";\n c2d.fillText(label, midX, boxY + boxH / 2);\n }\n\n function handleMouseDown(pluginCtx: PluginContext, event: InteractionEvent): void {\n if (!event.inPlotArea) return;\n\n event.preventDefault();\n const point = pointFromEvent(pluginCtx, event);\n\n if (state.mode === \"horizontal\") {\n commitHorizontal(point.y);\n finishStroke();\n return;\n }\n\n if (state.mode === \"vertical\") {\n commitVertical(point.x);\n finishStroke();\n return;\n }\n\n if (state.pending) {\n commitTwoPoint(state.pending, point);\n finishStroke();\n return;\n }\n\n state.start = point;\n state.dragging = true;\n state.dragMoved = false;\n state.dragStartPixel = { x: event.pixelX, y: event.pixelY };\n state.cursor = point;\n pluginCtx.requestRender?.();\n }\n\n function handleMouseMove(pluginCtx: PluginContext, event: InteractionEvent): void {\n const point = pointFromEvent(pluginCtx, event);\n state.cursor = point;\n\n if (state.dragging && state.dragStartPixel) {\n const dx = event.pixelX - state.dragStartPixel.x;\n const dy = event.pixelY - state.dragStartPixel.y;\n if (Math.hypot(dx, dy) >= DRAG_THRESHOLD_PX) {\n state.dragMoved = true;\n }\n }\n\n event.preventDefault();\n pluginCtx.requestRender?.();\n }\n\n function handleMouseUp(pluginCtx: PluginContext, event: InteractionEvent): void {\n if (!state.dragging || !state.start) return;\n\n const point = pointFromEvent(pluginCtx, event);\n const start = state.start;\n state.dragging = false;\n state.dragStartPixel = null;\n\n if (state.dragMoved) {\n commitTwoPoint(start, point);\n finishStroke();\n return;\n }\n\n state.pending = start;\n state.start = null;\n state.cursor = point;\n pluginCtx.requestRender?.();\n }\n\n const api: DrawingToolsAPI & Record<string, unknown> = {\n setMode(mode) {\n setModeInternal(mode);\n },\n getMode() {\n return state.mode;\n },\n setMagnet(enabled) {\n state.magnet = enabled;\n },\n isMagnet() {\n return state.magnet;\n },\n undo() {\n if (!ctx || state.undoStack.length === 0) return false;\n state.redoStack.push(snapshot());\n const prev = state.undoStack.pop()!;\n const current = snapshot();\n for (const a of current) ctx.chart.removeAnnotation(a.id!);\n for (const a of prev) ctx.chart.addAnnotation(a);\n return true;\n },\n redo() {\n if (!ctx || state.redoStack.length === 0) return false;\n state.undoStack.push(snapshot());\n const next = state.redoStack.pop()!;\n const current = snapshot();\n for (const a of current) ctx.chart.removeAnnotation(a.id!);\n for (const a of next) ctx.chart.addAnnotation(a);\n return true;\n },\n clear() {\n if (!ctx) return;\n pushUndo();\n for (const a of snapshot()) ctx.chart.removeAnnotation(a.id!);\n },\n };\n\n return {\n manifest,\n api,\n onInit(pluginCtx) {\n ctx = pluginCtx;\n },\n onDestroy() {\n ctx = null;\n },\n onInteraction(pluginCtx, event) {\n if (!isDrawingMode(state.mode)) return;\n\n if (event.type === \"mousedown\") {\n handleMouseDown(pluginCtx, event);\n return;\n }\n\n if (event.type === \"mousemove\") {\n handleMouseMove(pluginCtx, event);\n return;\n }\n\n if (event.type === \"mouseup\") {\n handleMouseUp(pluginCtx, event);\n }\n },\n onRenderOverlay(pluginCtx) {\n const c2d = pluginCtx.render.ctx2d;\n if (!c2d) return;\n drawPreview(c2d, pluginCtx.render.plotArea, pluginCtx.coords);\n },\n };\n}\n\nexport { snapToCandle, findNearestBarIndex } from \"./snapToCandle\";\nexport default PluginDrawingTools;\n","/**\n * PluginReplay — bar-by-bar playback (Stage 2.17 MVP).\n */\n\nimport type { ChartPlugin, PluginContext, PluginManifest } from \"../types\";\n\nexport interface PluginReplayConfig {\n /** Series id to replay */\n seriesId: string;\n /** Milliseconds between frames at 1x speed */\n frameMs?: number;\n}\n\nexport interface ReplayAPI {\n play(speed?: number): void;\n pause(): void;\n step(count?: number): void;\n seek(index: number): void;\n getIndex(): number;\n getLength(): number;\n isPlaying(): boolean;\n}\n\nconst manifest: PluginManifest = {\n name: \"velo-plot-replay\",\n version: \"1.0.0\",\n description: \"Bar-by-bar chart replay with speed control\",\n provides: [\"replay\"],\n tags: [\"replay\", \"trading\"],\n};\n\ninterface ReplayBuffer {\n x: Float32Array;\n open?: Float32Array;\n high?: Float32Array;\n low?: Float32Array;\n close?: Float32Array;\n y?: Float32Array;\n}\n\nexport function PluginReplay(config: PluginReplayConfig): ChartPlugin<PluginReplayConfig> {\n let ctx: PluginContext | null = null;\n let buffer: ReplayBuffer | null = null;\n let index = 0;\n let timer: ReturnType<typeof setInterval> | null = null;\n let speed = 1;\n const frameMs = config.frameMs ?? 250;\n\n function applyWindow(end: number): void {\n const c = ctx!;\n const buf = buffer!;\n const n = Math.min(end + 1, buf.x.length);\n const slice = (arr?: Float32Array) => (arr ? arr.subarray(0, n) : undefined);\n c.chart.updateSeries(config.seriesId, {\n x: slice(buf.x)!,\n y: slice(buf.y),\n open: slice(buf.open),\n high: slice(buf.high),\n low: slice(buf.low),\n close: slice(buf.close),\n });\n }\n\n const api: ReplayAPI & Record<string, unknown> = {\n play(s = 1) {\n if (!buffer) return;\n speed = Math.max(0.1, s);\n if (timer) clearInterval(timer);\n timer = setInterval(() => {\n if (!ctx || !buffer) {\n api.pause();\n return;\n }\n if (index >= buffer.x.length - 1) {\n api.pause();\n return;\n }\n index++;\n applyWindow(index);\n }, frameMs / speed);\n },\n pause() {\n if (timer) {\n clearInterval(timer);\n timer = null;\n }\n },\n step(count = 1) {\n if (!buffer) return;\n index = Math.min(buffer.x.length - 1, index + count);\n applyWindow(index);\n },\n seek(i) {\n if (!buffer) return;\n index = Math.max(0, Math.min(buffer.x.length - 1, i));\n applyWindow(index);\n },\n getIndex() {\n return index;\n },\n getLength() {\n return buffer?.x.length ?? 0;\n },\n isPlaying() {\n return timer != null;\n },\n };\n\n return {\n manifest,\n api,\n onInit(pluginCtx) {\n ctx = pluginCtx;\n const series = ctx.chart.getSeries(config.seriesId);\n if (!series) {\n console.warn(`[PluginReplay] Series \"${config.seriesId}\" not found`);\n return;\n }\n const d = series.getData();\n buffer = {\n x: Float32Array.from(d.x),\n y: d.y ? Float32Array.from(d.y) : undefined,\n open: d.open ? Float32Array.from(d.open) : undefined,\n high: d.high ? Float32Array.from(d.high) : undefined,\n low: d.low ? Float32Array.from(d.low) : undefined,\n close: d.close ? Float32Array.from(d.close) : undefined,\n };\n index = Math.max(0, buffer.x.length - 1);\n },\n onDestroy() {\n api.pause();\n ctx = null;\n buffer = null;\n },\n };\n}\n\nexport default PluginReplay;\n"],"names":["computeHeikinAshi","ohlc","n","haOpen","haHigh","haLow","haClose","i","o","l","c","barsToOhlc","bars","x","open","high","low","close","volume","b","pseudoRandom","seed","s","generateBars","from","to","barMs","base","rand","price","t","delta","createMockDatafeed","options","basePrice","cache","sym","request","key","last","timer","findNearestBarIndex","barX","bestIdx","bestDist","d","snapToCandle","input","idx","candidates","clickPy","threshold","bestY","bestPyDist","cy","py","dist","computeMeasurement","a","change","denom","percent","formatMeasurement","m","sign","formatPrice","value","abs","decimals","FIB_LEVELS","DRAG_THRESHOLD_PX","DEFAULT_MEASURE_UP","DEFAULT_MEASURE_DOWN","withAlpha","color","alpha","manifest","isDrawingMode","mode","findCandlestickSeries","ctx","PluginDrawingTools","config","autoDeselect","state","stroke","measureUp","measureDown","snapshot","_a","_b","pushUndo","resetInteractionState","setModeInternal","finishStroke","resolvePoint","y","series","dy","pointFromEvent","pluginCtx","event","commitHorizontal","commitVertical","commitMeasure","p0","p1","midX","commitTwoPoint","yMin","yMax","level","fy","drawPreview","c2d","plotArea","coords","cursor","anchor","toPx","px","w","h","drawMeasurePreview","headLen","dir","label","boxW","boxH","boxX","boxY","handleMouseDown","point","handleMouseMove","dx","handleMouseUp","start","enabled","prev","current","next","PluginReplay","buffer","index","speed","frameMs","applyWindow","end","buf","slice","arr","api","count"],"mappings":"AAWO,SAASA,GAAkBC,GAA8B;AAC9D,QAAMC,IAAID,EAAK,MAAM,QACfE,IAAS,IAAI,aAAaD,CAAC,GAC3BE,IAAS,IAAI,aAAaF,CAAC,GAC3BG,IAAQ,IAAI,aAAaH,CAAC,GAC1BI,IAAU,IAAI,aAAaJ,CAAC;AAElC,WAASK,IAAI,GAAGA,IAAIL,GAAGK,KAAK;AAC1B,UAAMC,IAAIP,EAAK,KAAKM,CAAC,GACf,IAAIN,EAAK,KAAKM,CAAC,GACfE,IAAIR,EAAK,IAAIM,CAAC,GACdG,IAAIT,EAAK,MAAMM,CAAC;AAEtB,IAAAD,EAAQC,CAAC,KAAKC,IAAI,IAAIC,IAAIC,KAAK,GAC/BP,EAAOI,CAAC,IAAIA,MAAM,KAAKC,IAAIE,KAAK,KAAKP,EAAOI,IAAI,CAAC,IAAID,EAAQC,IAAI,CAAC,KAAK,GACvEH,EAAOG,CAAC,IAAI,KAAK,IAAI,GAAGJ,EAAOI,CAAC,GAAGD,EAAQC,CAAC,CAAC,GAC7CF,EA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