velo-plot 1.12.0 → 1.15.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.
- package/README.md +14 -0
- package/dist/{index.core-xiNcuFfJ.js → ChartCore-BimVvUEg.js} +922 -929
- package/dist/ChartCore-BimVvUEg.js.map +1 -0
- package/dist/core/chart/ChartCore.d.ts +1 -0
- package/dist/core/chart/exporter/SVGExporter.d.ts +7 -2
- package/dist/core/chart/types.d.ts +2 -0
- package/dist/core/render/pixelSnap.d.ts +8 -0
- package/dist/core/stacked/index.d.ts +3 -1
- package/dist/core/stacked/paneResize.d.ts +15 -18
- package/dist/core/stacked/stackExport.d.ts +18 -0
- package/dist/core/stacked/types.d.ts +34 -5
- package/dist/createStackedChart-CjsKcOvX.js +1088 -0
- package/dist/createStackedChart-CjsKcOvX.js.map +1 -0
- package/dist/index-CUGS98p4.js +277 -0
- package/dist/index-CUGS98p4.js.map +1 -0
- package/dist/index-ChgIdk3N.js +229 -0
- package/dist/index-ChgIdk3N.js.map +1 -0
- package/dist/index.core-C_-CFftD.js +167 -0
- package/dist/index.core-C_-CFftD.js.map +1 -0
- package/dist/math-Ddm2EZjj.js +85 -0
- package/dist/math-Ddm2EZjj.js.map +1 -0
- package/dist/plugins/analysis.js +132 -130
- package/dist/plugins/analysis.js.map +1 -1
- package/dist/plugins/anomaly-detection.d.ts +1 -0
- package/dist/plugins/anomaly-detection.js +221 -0
- package/dist/plugins/anomaly-detection.js.map +1 -0
- package/dist/plugins/broken-axis.d.ts +3 -0
- package/dist/plugins/broken-axis.js +262 -0
- package/dist/plugins/broken-axis.js.map +1 -0
- package/dist/plugins/caching.d.ts +3 -0
- package/dist/plugins/caching.js +182 -0
- package/dist/plugins/caching.js.map +1 -0
- package/dist/plugins/data-transform.d.ts +3 -0
- package/dist/plugins/data-transform.js +146 -0
- package/dist/plugins/data-transform.js.map +1 -0
- package/dist/plugins/debug.js +12 -11
- package/dist/plugins/debug.js.map +1 -1
- package/dist/plugins/forecasting.d.ts +1 -0
- package/dist/plugins/forecasting.js +236 -0
- package/dist/plugins/forecasting.js.map +1 -0
- package/dist/plugins/latex.d.ts +1 -0
- package/dist/plugins/latex.js +454 -0
- package/dist/plugins/latex.js.map +1 -0
- package/dist/plugins/lazy-load.d.ts +3 -0
- package/dist/plugins/lazy-load.js +189 -0
- package/dist/plugins/lazy-load.js.map +1 -0
- package/dist/plugins/ml-integration.d.ts +3 -0
- package/dist/plugins/ml-integration.js +355 -0
- package/dist/plugins/ml-integration.js.map +1 -0
- package/dist/plugins/offscreen.d.ts +3 -0
- package/dist/plugins/offscreen.js +169 -0
- package/dist/plugins/offscreen.js.map +1 -0
- package/dist/plugins/pattern-recognition.d.ts +3 -0
- package/dist/plugins/pattern-recognition.js +690 -0
- package/dist/plugins/pattern-recognition.js.map +1 -0
- package/dist/plugins/radar.d.ts +3 -0
- package/dist/plugins/radar.js +103 -0
- package/dist/plugins/radar.js.map +1 -0
- package/dist/plugins/regression.d.ts +3 -0
- package/dist/plugins/regression.js +634 -0
- package/dist/plugins/regression.js.map +1 -0
- package/dist/plugins/roi.d.ts +1 -0
- package/dist/plugins/roi.js +223 -0
- package/dist/plugins/roi.js.map +1 -0
- package/dist/plugins/snapshot/types.d.ts +1 -1
- package/dist/plugins/snapshot.d.ts +3 -0
- package/dist/plugins/snapshot.js +90 -0
- package/dist/plugins/snapshot.js.map +1 -0
- package/dist/plugins/sync/index.d.ts +2 -1
- package/dist/plugins/sync.js +13 -269
- package/dist/plugins/sync.js.map +1 -1
- package/dist/plugins/video-recorder.d.ts +3 -0
- package/dist/plugins/video-recorder.js +104 -0
- package/dist/plugins/video-recorder.js.map +1 -0
- package/dist/plugins/virtualization.d.ts +3 -0
- package/dist/plugins/virtualization.js +6 -0
- package/dist/plugins/virtualization.js.map +1 -0
- package/dist/react.d.ts +1 -0
- package/dist/react.js +31 -0
- package/dist/react.js.map +1 -0
- package/dist/utils-BK5UUXxj.js +172 -0
- package/dist/utils-BK5UUXxj.js.map +1 -0
- package/dist/velo-plot.full.js +920 -6003
- package/dist/velo-plot.full.js.map +1 -1
- package/dist/velo-plot.js +23 -22
- package/dist/velo-plot.js.map +1 -1
- package/package.json +9 -2
- package/dist/core/OverlayRenderer.test.d.ts +0 -1
- package/dist/core/chart/ChartScaling.test.d.ts +0 -1
- package/dist/core/chart/NavigationUtils.test.d.ts +0 -1
- package/dist/core/format/axisFormat.test.d.ts +0 -1
- package/dist/core/indicator/buildIndicatorSeries.test.d.ts +0 -1
- package/dist/core/series/SeriesBounds.test.d.ts +0 -1
- package/dist/core/stacked/createStackedChart.test.d.ts +0 -1
- package/dist/core/stacked/paneAxis.test.d.ts +0 -1
- package/dist/core/stacked/paneResize.test.d.ts +0 -1
- package/dist/core/sync/index.test.d.ts +0 -1
- package/dist/index.core-xiNcuFfJ.js.map +0 -1
- package/dist/plugins/tools/tooltip/format.test.d.ts +0 -1
- package/dist/utils-Dbro9-qM.js +0 -254
- package/dist/utils-Dbro9-qM.js.map +0 -1
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
function U(u, a, r) {
|
|
2
|
+
const i = u.length;
|
|
3
|
+
if (r >= i || r <= 2)
|
|
4
|
+
return {
|
|
5
|
+
x: new Float32Array(u),
|
|
6
|
+
y: new Float32Array(a),
|
|
7
|
+
indices: new Uint32Array(Array.from({ length: i }, (w, D) => D))
|
|
8
|
+
};
|
|
9
|
+
const x = new Float32Array(r), p = new Float32Array(r), l = new Uint32Array(r);
|
|
10
|
+
x[0] = u[0], p[0] = a[0], l[0] = 0;
|
|
11
|
+
const d = (i - 2) / (r - 2);
|
|
12
|
+
let m = 0, h = 1;
|
|
13
|
+
for (let w = 0; w < r - 2; w++) {
|
|
14
|
+
const D = Math.floor((w + 1) * d) + 1, b = Math.floor((w + 2) * d) + 1, g = Math.min(b, i - 1), y = Math.min(
|
|
15
|
+
Math.floor((w + 3) * d) + 1,
|
|
16
|
+
i
|
|
17
|
+
);
|
|
18
|
+
let f = 0, S = 0, z = 0;
|
|
19
|
+
for (let n = g; n < y; n++)
|
|
20
|
+
f += u[n], S += a[n], z++;
|
|
21
|
+
z > 0 && (f /= z, S /= z);
|
|
22
|
+
let F = -1, v = D;
|
|
23
|
+
const e = u[m], t = a[m];
|
|
24
|
+
for (let n = D; n < b && n < i; n++) {
|
|
25
|
+
const s = Math.abs(
|
|
26
|
+
(e - f) * (a[n] - t) - (e - u[n]) * (S - t)
|
|
27
|
+
);
|
|
28
|
+
s > F && (F = s, v = n);
|
|
29
|
+
}
|
|
30
|
+
x[h] = u[v], p[h] = a[v], l[h] = v, m = v, h++;
|
|
31
|
+
}
|
|
32
|
+
return x[r - 1] = u[i - 1], p[r - 1] = a[i - 1], l[r - 1] = i - 1, { x, y: p, indices: l };
|
|
33
|
+
}
|
|
34
|
+
function E(u, a, r) {
|
|
35
|
+
const i = u.length;
|
|
36
|
+
if (r >= i / 2)
|
|
37
|
+
return {
|
|
38
|
+
x: new Float32Array(u),
|
|
39
|
+
y: new Float32Array(a),
|
|
40
|
+
indices: new Uint32Array(Array.from({ length: i }, (m, h) => h))
|
|
41
|
+
};
|
|
42
|
+
const x = i / r, p = [], l = [], d = [];
|
|
43
|
+
for (let m = 0; m < r; m++) {
|
|
44
|
+
const h = Math.floor(m * x), w = Math.floor((m + 1) * x);
|
|
45
|
+
let D = 1 / 0, b = -1 / 0, g = h, y = h;
|
|
46
|
+
for (let f = h; f < w && f < i; f++)
|
|
47
|
+
a[f] < D && (D = a[f], g = f), a[f] > b && (b = a[f], y = f);
|
|
48
|
+
g <= y ? (p.push(u[g], u[y]), l.push(a[g], a[y]), d.push(g, y)) : (p.push(u[y], u[g]), l.push(a[y], a[g]), d.push(y, g));
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
x: new Float32Array(p),
|
|
52
|
+
y: new Float32Array(l),
|
|
53
|
+
indices: new Uint32Array(d)
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
function Y(u, a, r = 2) {
|
|
57
|
+
const i = a * r;
|
|
58
|
+
return Math.min(u, i);
|
|
59
|
+
}
|
|
60
|
+
const k = {
|
|
61
|
+
name: "velo-plot-virtualization",
|
|
62
|
+
version: "1.0.0",
|
|
63
|
+
description: "Viewport-aware data virtualization with LOD strategies",
|
|
64
|
+
provides: ["performance", "data-virtualization"],
|
|
65
|
+
tags: ["performance", "lod", "virtualization"]
|
|
66
|
+
}, V = {
|
|
67
|
+
enabled: !0,
|
|
68
|
+
mode: "lod",
|
|
69
|
+
targetPoints: "auto",
|
|
70
|
+
pointsPerPixel: 2,
|
|
71
|
+
lodLevels: [1, 4, 8, 16],
|
|
72
|
+
strategy: "lttb",
|
|
73
|
+
reuseOriginalData: !0,
|
|
74
|
+
syncWithLazyLoad: !0,
|
|
75
|
+
includeSeries: [],
|
|
76
|
+
excludeSeries: [],
|
|
77
|
+
debug: !1
|
|
78
|
+
};
|
|
79
|
+
function L(u = {}) {
|
|
80
|
+
const a = { ...V, ...u };
|
|
81
|
+
let r = null, i = !1;
|
|
82
|
+
const x = /* @__PURE__ */ new Map(), p = /* @__PURE__ */ new Map();
|
|
83
|
+
let l = null, d = null;
|
|
84
|
+
function m(e, ...t) {
|
|
85
|
+
a.debug && r && r.log.info(`[Virtualization] ${e}`, ...t);
|
|
86
|
+
}
|
|
87
|
+
function h(e) {
|
|
88
|
+
if (!a.enabled || a.includeSeries.length > 0 && !a.includeSeries.includes(e.getId()) || a.excludeSeries.includes(e.getId())) return !1;
|
|
89
|
+
const t = e.getType();
|
|
90
|
+
return t === "line" || t === "scatter" || t === "line+scatter" || t === "step" || t === "step+scatter";
|
|
91
|
+
}
|
|
92
|
+
function w(e) {
|
|
93
|
+
if (!r) return e;
|
|
94
|
+
if (a.targetPoints !== "auto") return Math.max(2, a.targetPoints);
|
|
95
|
+
const t = r.render.canvasSize.width / r.render.pixelRatio;
|
|
96
|
+
return Y(e, t, a.pointsPerPixel);
|
|
97
|
+
}
|
|
98
|
+
function D(e, t, n, s) {
|
|
99
|
+
if (n >= e.length || e.length <= 2)
|
|
100
|
+
return { x: new Float32Array(e), y: new Float32Array(t) };
|
|
101
|
+
if (s === "minmax") {
|
|
102
|
+
const c = Math.ceil(n / 2), A = E(e, t, c);
|
|
103
|
+
return { x: A.x, y: A.y };
|
|
104
|
+
}
|
|
105
|
+
const o = U(e, t, n);
|
|
106
|
+
return { x: o.x, y: o.y };
|
|
107
|
+
}
|
|
108
|
+
function b(e, t) {
|
|
109
|
+
a.reuseOriginalData && x.set(e, { x: t.x, y: t.y });
|
|
110
|
+
}
|
|
111
|
+
function g(e) {
|
|
112
|
+
return x.get(e) ?? null;
|
|
113
|
+
}
|
|
114
|
+
function y(e, t, n, s, o, c) {
|
|
115
|
+
p.set(e, {
|
|
116
|
+
seriesId: e,
|
|
117
|
+
originalPoints: t,
|
|
118
|
+
renderedPoints: n,
|
|
119
|
+
targetPoints: s,
|
|
120
|
+
lastUpdated: Date.now(),
|
|
121
|
+
mode: o,
|
|
122
|
+
strategy: c
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
function f(e) {
|
|
126
|
+
if (!r || !l) return;
|
|
127
|
+
const t = e.getId(), n = e.getData();
|
|
128
|
+
if (!(n != null && n.x) || !(n != null && n.y) || n.x.length === 0) return;
|
|
129
|
+
if (!h(e)) {
|
|
130
|
+
const c = g(t);
|
|
131
|
+
c && a.reuseOriginalData && (i = !0, l(t, { x: c.x, y: c.y }), i = !1);
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
b(t, { x: n.x, y: n.y });
|
|
135
|
+
const s = w(n.x.length), o = D(n.x, n.y, s, a.strategy);
|
|
136
|
+
i = !0, l(t, { x: o.x, y: o.y }), i = !1, y(t, n.x.length, o.x.length, s, a.mode, a.strategy);
|
|
137
|
+
}
|
|
138
|
+
function S() {
|
|
139
|
+
r && r.data.getAllSeries().forEach((e) => f(e));
|
|
140
|
+
}
|
|
141
|
+
function z(e, t) {
|
|
142
|
+
var c, A, I, M;
|
|
143
|
+
if (!r || !l) return;
|
|
144
|
+
if (!a.enabled || i) {
|
|
145
|
+
l(e, t);
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
if (!((A = (c = r.chart).getSeries) == null ? void 0 : A.call(c, e))) {
|
|
149
|
+
l(e, t);
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
const s = g(e);
|
|
153
|
+
s && a.reuseOriginalData && (i = !0, l(e, { x: s.x, y: s.y }), i = !1), l(e, t);
|
|
154
|
+
const o = (M = (I = r.chart).getSeries) == null ? void 0 : M.call(I, e);
|
|
155
|
+
o && (b(e, { x: o.getData().x, y: o.getData().y }), f(o));
|
|
156
|
+
}
|
|
157
|
+
function F(e, t, n) {
|
|
158
|
+
var A, I, M, O;
|
|
159
|
+
if (!r || !d || !l) return;
|
|
160
|
+
if (!a.enabled || i) {
|
|
161
|
+
d(e, t, n);
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
if (!((I = (A = r.chart).getSeries) == null ? void 0 : I.call(A, e))) {
|
|
165
|
+
d(e, t, n);
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
const o = g(e);
|
|
169
|
+
o && a.reuseOriginalData && (i = !0, l(e, { x: o.x, y: o.y }), i = !1), d(e, t, n);
|
|
170
|
+
const c = (O = (M = r.chart).getSeries) == null ? void 0 : O.call(M, e);
|
|
171
|
+
c && (b(e, { x: c.getData().x, y: c.getData().y }), f(c));
|
|
172
|
+
}
|
|
173
|
+
const v = {
|
|
174
|
+
enable() {
|
|
175
|
+
a.enabled = !0, S();
|
|
176
|
+
},
|
|
177
|
+
disable() {
|
|
178
|
+
if (a.enabled = !1, !r || !l) return;
|
|
179
|
+
const e = l;
|
|
180
|
+
r.data.getAllSeries().forEach((t) => {
|
|
181
|
+
const n = g(t.getId());
|
|
182
|
+
n && (i = !0, e(t.getId(), { x: n.x, y: n.y }), i = !1);
|
|
183
|
+
});
|
|
184
|
+
},
|
|
185
|
+
isEnabled() {
|
|
186
|
+
return a.enabled;
|
|
187
|
+
},
|
|
188
|
+
updateConfig(e) {
|
|
189
|
+
Object.assign(a, e), S();
|
|
190
|
+
},
|
|
191
|
+
invalidate(e) {
|
|
192
|
+
var t, n;
|
|
193
|
+
if (r) {
|
|
194
|
+
if (e) {
|
|
195
|
+
const s = (n = (t = r.chart).getSeries) == null ? void 0 : n.call(t, e);
|
|
196
|
+
s && f(s);
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
S();
|
|
200
|
+
}
|
|
201
|
+
},
|
|
202
|
+
getStats(e) {
|
|
203
|
+
return p.get(e) ?? null;
|
|
204
|
+
},
|
|
205
|
+
getAllStats() {
|
|
206
|
+
return Array.from(p.values());
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
return {
|
|
210
|
+
manifest: k,
|
|
211
|
+
onInit(e) {
|
|
212
|
+
var n, s;
|
|
213
|
+
r = e, r.chart.virtualization = v;
|
|
214
|
+
const t = r.chart;
|
|
215
|
+
l = ((n = t.updateSeries) == null ? void 0 : n.bind(t)) ?? null, d = ((s = t.appendData) == null ? void 0 : s.bind(t)) ?? null, l && (t.updateSeries = (o, c) => z(o, c)), d && (t.appendData = (o, c, A) => F(o, c, A)), r.events.on("zoom", () => S()), r.events.on("pan", () => S()), r.events.on("resize", () => S()), S(), m("Initialized");
|
|
216
|
+
},
|
|
217
|
+
onDestroy(e) {
|
|
218
|
+
l && (e.chart.updateSeries = l), d && (e.chart.appendData = d), delete e.chart.virtualization, r = null, x.clear(), p.clear();
|
|
219
|
+
},
|
|
220
|
+
api: v
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
export {
|
|
224
|
+
L as P,
|
|
225
|
+
Y as c,
|
|
226
|
+
U as l,
|
|
227
|
+
E as m
|
|
228
|
+
};
|
|
229
|
+
//# sourceMappingURL=index-ChgIdk3N.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-ChgIdk3N.js","sources":["../src/workers/downsample.ts","../src/plugins/virtualization/index.ts"],"sourcesContent":["/**\n * LTTB (Largest-Triangle-Three-Buckets) Downsampling Algorithm\n *\n * This algorithm downsamples time-series data while preserving visual features.\n * It's much better than naive sampling for preserving peaks and valleys.\n *\n * Reference: https://skemman.is/bitstream/1946/15343/3/SS_MSthesis.pdf\n */\n\nexport interface DownsampleResult {\n x: Float32Array;\n y: Float32Array;\n /** Original indices of selected points */\n indices: Uint32Array;\n}\n\n/**\n * Downsample data using LTTB algorithm\n *\n * @param x - X values (e.g., potential)\n * @param y - Y values (e.g., current)\n * @param targetPoints - Number of output points\n * @returns Downsampled data\n */\nexport function lttbDownsample(\n x: Float32Array | Float64Array,\n y: Float32Array | Float64Array,\n targetPoints: number\n): DownsampleResult {\n const length = x.length;\n\n // No need to downsample\n if (targetPoints >= length || targetPoints <= 2) {\n return {\n x: new Float32Array(x),\n y: new Float32Array(y),\n indices: new Uint32Array(Array.from({ length }, (_, i) => i)),\n };\n }\n\n const outX = new Float32Array(targetPoints);\n const outY = new Float32Array(targetPoints);\n const outIndices = new Uint32Array(targetPoints);\n\n // Always include first point\n outX[0] = x[0];\n outY[0] = y[0];\n outIndices[0] = 0;\n\n // Bucket size\n const bucketSize = (length - 2) / (targetPoints - 2);\n\n let a = 0; // Previous selected point index\n let outIdx = 1;\n\n for (let i = 0; i < targetPoints - 2; i++) {\n // Calculate bucket boundaries\n const bucketStart = Math.floor((i + 1) * bucketSize) + 1;\n const bucketEnd = Math.floor((i + 2) * bucketSize) + 1;\n\n // Calculate average point of next bucket\n const nextBucketStart = Math.min(bucketEnd, length - 1);\n const nextBucketEnd = Math.min(\n Math.floor((i + 3) * bucketSize) + 1,\n length\n );\n\n let avgX = 0;\n let avgY = 0;\n let avgCount = 0;\n\n for (let j = nextBucketStart; j < nextBucketEnd; j++) {\n avgX += x[j];\n avgY += y[j];\n avgCount++;\n }\n\n if (avgCount > 0) {\n avgX /= avgCount;\n avgY /= avgCount;\n }\n\n // Find point in current bucket with largest triangle area\n let maxArea = -1;\n let maxIndex = bucketStart;\n\n const aX = x[a];\n const aY = y[a];\n\n for (let j = bucketStart; j < bucketEnd && j < length; j++) {\n // Calculate triangle area (simplified: |x1(y2-y3) + x2(y3-y1) + x3(y1-y2)| / 2)\n const area = Math.abs(\n (aX - avgX) * (y[j] - aY) - (aX - x[j]) * (avgY - aY)\n );\n\n if (area > maxArea) {\n maxArea = area;\n maxIndex = j;\n }\n }\n\n // Store selected point\n outX[outIdx] = x[maxIndex];\n outY[outIdx] = y[maxIndex];\n outIndices[outIdx] = maxIndex;\n\n a = maxIndex;\n outIdx++;\n }\n\n // Always include last point\n outX[targetPoints - 1] = x[length - 1];\n outY[targetPoints - 1] = y[length - 1];\n outIndices[targetPoints - 1] = length - 1;\n\n return { x: outX, y: outY, indices: outIndices };\n}\n\n/**\n * Min-Max per bucket downsampling\n *\n * Simpler alternative to LTTB that preserves extremes in each bucket.\n * Uses 2 points per bucket (min and max), so output is ~2x target.\n */\nexport function minMaxDownsample(\n x: Float32Array | Float64Array,\n y: Float32Array | Float64Array,\n bucketCount: number\n): DownsampleResult {\n const length = x.length;\n\n if (bucketCount >= length / 2) {\n return {\n x: new Float32Array(x),\n y: new Float32Array(y),\n indices: new Uint32Array(Array.from({ length }, (_, i) => i)),\n };\n }\n\n const bucketSize = length / bucketCount;\n const outX: number[] = [];\n const outY: number[] = [];\n const outIndices: number[] = [];\n\n for (let b = 0; b < bucketCount; b++) {\n const start = Math.floor(b * bucketSize);\n const end = Math.floor((b + 1) * bucketSize);\n\n let minY = Infinity;\n let maxY = -Infinity;\n let minIdx = start;\n let maxIdx = start;\n\n for (let i = start; i < end && i < length; i++) {\n if (y[i] < minY) {\n minY = y[i];\n minIdx = i;\n }\n if (y[i] > maxY) {\n maxY = y[i];\n maxIdx = i;\n }\n }\n\n // Add points in order (min first if it comes before max)\n if (minIdx <= maxIdx) {\n outX.push(x[minIdx], x[maxIdx]);\n outY.push(y[minIdx], y[maxIdx]);\n outIndices.push(minIdx, maxIdx);\n } else {\n outX.push(x[maxIdx], x[minIdx]);\n outY.push(y[maxIdx], y[minIdx]);\n outIndices.push(maxIdx, minIdx);\n }\n }\n\n return {\n x: new Float32Array(outX),\n y: new Float32Array(outY),\n indices: new Uint32Array(outIndices),\n };\n}\n\n/**\n * Calculate optimal target points based on canvas width\n */\nexport function calculateTargetPoints(\n dataLength: number,\n canvasWidth: number,\n pointsPerPixel = 2\n): number {\n // Never draw more than pointsPerPixel per pixel\n const maxPoints = canvasWidth * pointsPerPixel;\n return Math.min(dataLength, maxPoints);\n}\n","/**\n * @fileoverview Data virtualization plugin (LOD/min-max)\n * @module plugins/virtualization\n */\n\nimport type {\n PluginVirtualizationConfig,\n VirtualizationAPI,\n VirtualizationStats,\n VirtualizationMode,\n VirtualizationStrategy,\n} from \"./types\";\nimport type { ChartPlugin, PluginContext, PluginManifest } from \"../types\";\nimport type { Series } from \"../../core/Series\";\nimport type { SeriesUpdateData } from \"../../types\";\nimport {\n lttbDownsample,\n minMaxDownsample,\n calculateTargetPoints,\n} from \"../../workers/downsample\";\n\nconst manifest: PluginManifest = {\n name: \"velo-plot-virtualization\",\n version: \"1.0.0\",\n description: \"Viewport-aware data virtualization with LOD strategies\",\n provides: [\"performance\", \"data-virtualization\"],\n tags: [\"performance\", \"lod\", \"virtualization\"],\n};\n\nconst DEFAULT_CONFIG: Required<PluginVirtualizationConfig> = {\n enabled: true,\n mode: \"lod\",\n targetPoints: \"auto\",\n pointsPerPixel: 2,\n lodLevels: [1, 4, 8, 16],\n strategy: \"lttb\",\n reuseOriginalData: true,\n syncWithLazyLoad: true,\n includeSeries: [],\n excludeSeries: [],\n debug: false,\n};\n\ntype SeriesCache = {\n x: Float32Array | Float64Array;\n y: Float32Array | Float64Array;\n};\n\nexport function PluginVirtualization(\n userConfig: Partial<PluginVirtualizationConfig> = {}\n): ChartPlugin<PluginVirtualizationConfig> {\n const config = { ...DEFAULT_CONFIG, ...userConfig };\n let ctx: PluginContext | null = null;\n let isInternalUpdate = false;\n\n const originalData = new Map<string, SeriesCache>();\n const stats = new Map<string, VirtualizationStats>();\n\n let originalUpdateSeries: ((id: string, data: SeriesUpdateData) => void) | null = null;\n let originalAppendData: ((id: string, x: number[] | Float32Array, y: number[] | Float32Array) => void) | null = null;\n\n function log(message: string, ...args: unknown[]) {\n if (config.debug && ctx) {\n ctx.log.info(`[Virtualization] ${message}`, ...args);\n }\n }\n\n function shouldVirtualize(series: Series): boolean {\n if (!config.enabled) return false;\n if (config.includeSeries.length > 0 && !config.includeSeries.includes(series.getId())) return false;\n if (config.excludeSeries.includes(series.getId())) return false;\n\n const type = series.getType();\n return (\n type === \"line\" ||\n type === \"scatter\" ||\n type === \"line+scatter\" ||\n type === \"step\" ||\n type === \"step+scatter\"\n );\n }\n\n function getTargetPoints(dataLength: number): number {\n if (!ctx) return dataLength;\n if (config.targetPoints !== \"auto\") return Math.max(2, config.targetPoints);\n const width = ctx.render.canvasSize.width / ctx.render.pixelRatio;\n return calculateTargetPoints(dataLength, width, config.pointsPerPixel);\n }\n\n function downsampleData(\n x: Float32Array | Float64Array,\n y: Float32Array | Float64Array,\n targetPoints: number,\n strategy: VirtualizationStrategy\n ): { x: Float32Array; y: Float32Array } {\n if (targetPoints >= x.length || x.length <= 2) {\n return { x: new Float32Array(x), y: new Float32Array(y) };\n }\n\n if (strategy === \"minmax\") {\n const bucketCount = Math.ceil(targetPoints / 2);\n const result = minMaxDownsample(x, y, bucketCount);\n return { x: result.x, y: result.y };\n }\n\n const result = lttbDownsample(x, y, targetPoints);\n return { x: result.x, y: result.y };\n }\n\n function cacheOriginal(seriesId: string, data: SeriesCache): void {\n if (!config.reuseOriginalData) return;\n originalData.set(seriesId, { x: data.x, y: data.y });\n }\n\n function restoreOriginal(seriesId: string): SeriesCache | null {\n return originalData.get(seriesId) ?? null;\n }\n\n function updateStats(\n seriesId: string,\n originalPoints: number,\n renderedPoints: number,\n targetPoints: number,\n mode: VirtualizationMode,\n strategy: VirtualizationStrategy\n ): void {\n stats.set(seriesId, {\n seriesId,\n originalPoints,\n renderedPoints,\n targetPoints,\n lastUpdated: Date.now(),\n mode,\n strategy,\n });\n }\n\n function applyVirtualization(series: Series): void {\n if (!ctx || !originalUpdateSeries) return;\n const seriesId = series.getId();\n const data = series.getData();\n if (!data?.x || !data?.y || data.x.length === 0) return;\n\n if (!shouldVirtualize(series)) {\n const original = restoreOriginal(seriesId);\n if (original && config.reuseOriginalData) {\n isInternalUpdate = true;\n originalUpdateSeries(seriesId, { x: original.x, y: original.y });\n isInternalUpdate = false;\n }\n return;\n }\n\n cacheOriginal(seriesId, { x: data.x, y: data.y });\n\n const targetPoints = getTargetPoints(data.x.length);\n const downsampled = downsampleData(data.x, data.y, targetPoints, config.strategy);\n\n isInternalUpdate = true;\n originalUpdateSeries(seriesId, { x: downsampled.x, y: downsampled.y });\n isInternalUpdate = false;\n\n updateStats(seriesId, data.x.length, downsampled.x.length, targetPoints, config.mode, config.strategy);\n }\n\n function refreshAll(): void {\n if (!ctx) return;\n ctx.data.getAllSeries().forEach((series) => applyVirtualization(series));\n }\n\n function handleUpdateSeries(id: string, data: SeriesUpdateData): void {\n if (!ctx || !originalUpdateSeries) return;\n if (!config.enabled || isInternalUpdate) {\n originalUpdateSeries(id, data);\n return;\n }\n\n const series = ctx.chart.getSeries?.(id) as Series | undefined;\n if (!series) {\n originalUpdateSeries(id, data);\n return;\n }\n\n const original = restoreOriginal(id);\n if (original && config.reuseOriginalData) {\n isInternalUpdate = true;\n originalUpdateSeries(id, { x: original.x, y: original.y });\n isInternalUpdate = false;\n }\n\n originalUpdateSeries(id, data);\n\n const updatedSeries = ctx.chart.getSeries?.(id) as Series | undefined;\n if (updatedSeries) {\n cacheOriginal(id, { x: updatedSeries.getData().x, y: updatedSeries.getData().y });\n applyVirtualization(updatedSeries);\n }\n }\n\n function handleAppendData(\n id: string,\n x: number[] | Float32Array,\n y: number[] | Float32Array\n ): void {\n if (!ctx || !originalAppendData || !originalUpdateSeries) return;\n\n if (!config.enabled || isInternalUpdate) {\n originalAppendData(id, x, y);\n return;\n }\n\n const series = ctx.chart.getSeries?.(id) as Series | undefined;\n if (!series) {\n originalAppendData(id, x, y);\n return;\n }\n\n const original = restoreOriginal(id);\n if (original && config.reuseOriginalData) {\n isInternalUpdate = true;\n originalUpdateSeries(id, { x: original.x, y: original.y });\n isInternalUpdate = false;\n }\n\n originalAppendData(id, x, y);\n\n const updatedSeries = ctx.chart.getSeries?.(id) as Series | undefined;\n if (updatedSeries) {\n cacheOriginal(id, { x: updatedSeries.getData().x, y: updatedSeries.getData().y });\n applyVirtualization(updatedSeries);\n }\n }\n\n const api: VirtualizationAPI & Record<string, unknown> = {\n enable() {\n config.enabled = true;\n refreshAll();\n },\n disable() {\n config.enabled = false;\n if (!ctx || !originalUpdateSeries) return;\n const updater = originalUpdateSeries;\n ctx.data.getAllSeries().forEach((series) => {\n const original = restoreOriginal(series.getId());\n if (original) {\n isInternalUpdate = true;\n updater(series.getId(), { x: original.x, y: original.y });\n isInternalUpdate = false;\n }\n });\n },\n isEnabled() {\n return config.enabled;\n },\n updateConfig(newConfig) {\n Object.assign(config, newConfig);\n refreshAll();\n },\n invalidate(seriesId) {\n if (!ctx) return;\n if (seriesId) {\n const series = ctx.chart.getSeries?.(seriesId) as Series | undefined;\n if (series) applyVirtualization(series);\n return;\n }\n refreshAll();\n },\n getStats(seriesId) {\n return stats.get(seriesId) ?? null;\n },\n getAllStats() {\n return Array.from(stats.values());\n },\n };\n\n return {\n manifest,\n onInit(pluginCtx: PluginContext) {\n ctx = pluginCtx;\n (ctx.chart as any).virtualization = api;\n\n const chart = ctx.chart as any;\n originalUpdateSeries = chart.updateSeries?.bind(chart) ?? null;\n originalAppendData = chart.appendData?.bind(chart) ?? null;\n\n if (originalUpdateSeries) {\n chart.updateSeries = (id: string, data: SeriesUpdateData) => handleUpdateSeries(id, data);\n }\n\n if (originalAppendData) {\n chart.appendData = (id: string, x: number[] | Float32Array, y: number[] | Float32Array) =>\n handleAppendData(id, x, y);\n }\n\n ctx.events.on(\"zoom\", () => refreshAll());\n ctx.events.on(\"pan\", () => refreshAll());\n ctx.events.on(\"resize\", () => refreshAll());\n\n refreshAll();\n log(\"Initialized\");\n },\n onDestroy(pluginCtx: PluginContext) {\n if (originalUpdateSeries) {\n (pluginCtx.chart as any).updateSeries = originalUpdateSeries;\n }\n if (originalAppendData) {\n (pluginCtx.chart as any).appendData = originalAppendData;\n }\n delete (pluginCtx.chart as any).virtualization;\n ctx = null;\n originalData.clear();\n stats.clear();\n },\n api,\n };\n}\n\nexport default PluginVirtualization;\n\n// Type exports\nexport type {\n PluginVirtualizationConfig,\n VirtualizationAPI,\n VirtualizationStats,\n VirtualizationMode,\n VirtualizationStrategy,\n} from \"./types\";\n"],"names":["lttbDownsample","x","y","targetPoints","length","_","i","outX","outY","outIndices","bucketSize","a","outIdx","bucketStart","bucketEnd","nextBucketStart","nextBucketEnd","avgX","avgY","avgCount","j","maxArea","maxIndex","aX","aY","area","minMaxDownsample","bucketCount","b","start","end","minY","maxY","minIdx","maxIdx","calculateTargetPoints","dataLength","canvasWidth","pointsPerPixel","maxPoints","manifest","DEFAULT_CONFIG","PluginVirtualization","userConfig","config","ctx","isInternalUpdate","originalData","stats","originalUpdateSeries","originalAppendData","log","message","args","shouldVirtualize","series","type","getTargetPoints","width","downsampleData","strategy","result","cacheOriginal","seriesId","data","restoreOriginal","updateStats","originalPoints","renderedPoints","mode","applyVirtualization","original","downsampled","refreshAll","handleUpdateSeries","id","_a","_b","_c","_d","updatedSeries","handleAppendData","api","updater","newConfig","pluginCtx","chart"],"mappings":"AAwBO,SAASA,EACdC,GACAC,GACAC,GACkB;AAClB,QAAMC,IAASH,EAAE;AAGjB,MAAIE,KAAgBC,KAAUD,KAAgB;AAC5C,WAAO;AAAA,MACL,GAAG,IAAI,aAAaF,CAAC;AAAA,MACrB,GAAG,IAAI,aAAaC,CAAC;AAAA,MACrB,SAAS,IAAI,YAAY,MAAM,KAAK,EAAE,QAAAE,EAAA,GAAU,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,EAAA;AAAA;AAAA,IACF;AAAA,IACA,SAASV,GAAU;AACjB,aAAOf,EAAM,IAAIe,CAAQ,KAAK;AAAA,IAChC;AAAA,IACA,cAAc;AACZ,aAAO,MAAM,KAAKf,EAAM,OAAA,CAAQ;AAAA,IAClC;AAAA,EAAA;AAGF,SAAO;AAAA,IACL,UAAAR;AAAA,IACA,OAAO6C,GAA0B;AD7P9B,UAAAT,GAAAC;AC8PD,MAAAhC,IAAMwC,GACLxC,EAAI,MAAc,iBAAiBqC;AAEpC,YAAMI,IAAQzC,EAAI;AAClB,MAAAI,MAAuB2B,IAAAU,EAAM,iBAAN,gBAAAV,EAAoB,KAAKU,OAAU,MAC1DpC,MAAqB2B,IAAAS,EAAM,eAAN,gBAAAT,EAAkB,KAAKS,OAAU,MAElDrC,MACFqC,EAAM,eAAe,CAACX,GAAYX,MAA2BU,EAAmBC,GAAIX,CAAI,IAGtFd,MACFoC,EAAM,aAAa,CAACX,GAAY1E,GAA4BC,MAC1D+E,EAAiBN,GAAI1E,GAAGC,CAAC,IAG7B2C,EAAI,OAAO,GAAG,QAAQ,MAAM4B,GAAY,GACxC5B,EAAI,OAAO,GAAG,OAAO,MAAM4B,GAAY,GACvC5B,EAAI,OAAO,GAAG,UAAU,MAAM4B,GAAY,GAE1CA,EAAA,GACAtB,EAAI,aAAa;AAAA,IACnB;AAAA,IACA,UAAUkC,GAA0B;AAClC,MAAIpC,MACDoC,EAAU,MAAc,eAAepC,IAEtCC,MACDmC,EAAU,MAAc,aAAanC,IAExC,OAAQmC,EAAU,MAAc,gBAChCxC,IAAM,MACNE,EAAa,MAAA,GACbC,EAAM,MAAA;AAAA,IACR;AAAA,IACA,KAAAkC;AAAA,EAAA;AAEJ;"}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
var l = Object.defineProperty;
|
|
2
|
+
var g = (i, e, r) => e in i ? l(i, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : i[e] = r;
|
|
3
|
+
var u = (i, e, r) => g(i, typeof e != "symbol" ? e + "" : e, r);
|
|
4
|
+
import { N as f } from "./ChartCore-BimVvUEg.js";
|
|
5
|
+
import "./axisFormat-B7o_uIEA.js";
|
|
6
|
+
import "./index-x4stH3jD.js";
|
|
7
|
+
function b(i) {
|
|
8
|
+
return new f(i);
|
|
9
|
+
}
|
|
10
|
+
class d {
|
|
11
|
+
constructor() {
|
|
12
|
+
u(this, "entries", /* @__PURE__ */ new Map());
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Register a plugin globally
|
|
16
|
+
*/
|
|
17
|
+
register(e) {
|
|
18
|
+
const r = e.manifest.name;
|
|
19
|
+
this.entries.has(r) && console.warn(
|
|
20
|
+
`[SciPlot Registry] Plugin "${r}" is already registered, overwriting`
|
|
21
|
+
), this.entries.set(r, e);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Unregister a plugin
|
|
25
|
+
*/
|
|
26
|
+
unregister(e) {
|
|
27
|
+
const r = this.entries.has(e);
|
|
28
|
+
return this.entries.delete(e), r;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Get a registered plugin factory by name
|
|
32
|
+
*/
|
|
33
|
+
get(e) {
|
|
34
|
+
var r;
|
|
35
|
+
return (r = this.entries.get(e)) == null ? void 0 : r.factory;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* List all registered plugins
|
|
39
|
+
*/
|
|
40
|
+
list() {
|
|
41
|
+
return Array.from(this.entries.values()).map((e) => e.manifest);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Search plugins by capability
|
|
45
|
+
*/
|
|
46
|
+
findByCapability(e) {
|
|
47
|
+
const r = [];
|
|
48
|
+
return this.entries.forEach((n) => {
|
|
49
|
+
var s;
|
|
50
|
+
(s = n.manifest.provides) != null && s.includes(e) && r.push(n.manifest);
|
|
51
|
+
}), r;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Search plugins by tag
|
|
55
|
+
*/
|
|
56
|
+
findByTag(e) {
|
|
57
|
+
const r = [], n = e.toLowerCase();
|
|
58
|
+
return this.entries.forEach((s) => {
|
|
59
|
+
var o;
|
|
60
|
+
(o = s.manifest.tags) != null && o.some((c) => c.toLowerCase().includes(n)) && r.push(s.manifest);
|
|
61
|
+
}), r;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Check if a plugin is registered
|
|
65
|
+
*/
|
|
66
|
+
has(e) {
|
|
67
|
+
return this.entries.has(e);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Get plugin count
|
|
71
|
+
*/
|
|
72
|
+
get size() {
|
|
73
|
+
return this.entries.size;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Clear all registrations
|
|
77
|
+
*/
|
|
78
|
+
clear() {
|
|
79
|
+
this.entries.clear();
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
let t = null;
|
|
83
|
+
function a() {
|
|
84
|
+
return t || (t = new d()), t;
|
|
85
|
+
}
|
|
86
|
+
function p(i) {
|
|
87
|
+
a().register(i);
|
|
88
|
+
}
|
|
89
|
+
function h(i, e) {
|
|
90
|
+
return (r) => ({
|
|
91
|
+
...e(r),
|
|
92
|
+
manifest: i
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
function w(i, e) {
|
|
96
|
+
const r = h(i, e);
|
|
97
|
+
return p({ manifest: i, factory: r }), r;
|
|
98
|
+
}
|
|
99
|
+
async function $(i, e) {
|
|
100
|
+
const r = a().get(i);
|
|
101
|
+
if (!r) {
|
|
102
|
+
console.warn(`[SciPlot] Plugin "${i}" not found in registry`);
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
return r(e);
|
|
106
|
+
}
|
|
107
|
+
function C() {
|
|
108
|
+
const i = a(), e = [
|
|
109
|
+
"analysis",
|
|
110
|
+
"visualization",
|
|
111
|
+
"interaction",
|
|
112
|
+
"data-source",
|
|
113
|
+
"export",
|
|
114
|
+
"ui",
|
|
115
|
+
"annotation",
|
|
116
|
+
"theme"
|
|
117
|
+
], r = {};
|
|
118
|
+
return e.forEach((n) => {
|
|
119
|
+
r[n] = i.findByCapability(n);
|
|
120
|
+
}), r;
|
|
121
|
+
}
|
|
122
|
+
function z(i) {
|
|
123
|
+
const e = [];
|
|
124
|
+
return i.name ? /^[@a-z0-9-]+\/[a-z0-9-]+$|^[a-z0-9-]+$/.test(i.name) || e.push(
|
|
125
|
+
'Invalid name format. Use lowercase with hyphens, optionally scoped (e.g., "@org/name")'
|
|
126
|
+
) : e.push("Missing required field: name"), i.version ? /^\d+\.\d+\.\d+$/.test(i.version) || e.push("Invalid version format. Use semantic versioning (e.g., 1.0.0)") : e.push("Missing required field: version"), i.dependencies && (Array.isArray(i.dependencies) || e.push("dependencies must be an array")), i.provides && (Array.isArray(i.provides) || e.push("provides must be an array")), e;
|
|
127
|
+
}
|
|
128
|
+
function A(i, e) {
|
|
129
|
+
const r = [];
|
|
130
|
+
if (i.engineVersion) {
|
|
131
|
+
const [n] = i.engineVersion.split(".").map(Number), [s] = e.split(".").map(Number);
|
|
132
|
+
if (n > s)
|
|
133
|
+
return {
|
|
134
|
+
compatible: !1,
|
|
135
|
+
warnings: [
|
|
136
|
+
`Plugin requires engine v${i.engineVersion}, current is v${e}`
|
|
137
|
+
]
|
|
138
|
+
};
|
|
139
|
+
n < s && r.push(
|
|
140
|
+
`Plugin was built for engine v${i.engineVersion}, may have compatibility issues`
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
return { compatible: !0, warnings: r };
|
|
144
|
+
}
|
|
145
|
+
function M(i) {
|
|
146
|
+
return i;
|
|
147
|
+
}
|
|
148
|
+
function R(i, e) {
|
|
149
|
+
return (r) => ({
|
|
150
|
+
...e(r),
|
|
151
|
+
manifest: i
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
export {
|
|
155
|
+
w as a,
|
|
156
|
+
C as b,
|
|
157
|
+
b as c,
|
|
158
|
+
h as d,
|
|
159
|
+
A as e,
|
|
160
|
+
M as f,
|
|
161
|
+
a as g,
|
|
162
|
+
R as h,
|
|
163
|
+
$ as l,
|
|
164
|
+
p as r,
|
|
165
|
+
z as v
|
|
166
|
+
};
|
|
167
|
+
//# sourceMappingURL=index.core-C_-CFftD.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.core-C_-CFftD.js","sources":["../src/renderer/RendererInterface.ts","../src/plugins/PluginRegistry.ts","../src/plugins/index.ts"],"sourcesContent":["/**\n * WebGL Renderer Interface & Factory\n *\n * This module provides a common interface for WebGL rendering.\n * Currently optimized for NativeWebGLRenderer (zero dependencies).\n */\n\nimport type { Bounds } from '../types';\nimport { NativeWebGLRenderer } from './NativeWebGLRenderer';\n\n// ============================================\n// Common Types\n// ============================================\n\nexport interface SeriesRenderData {\n id: string;\n buffer: WebGLBuffer;\n count: number;\n style: any;\n visible: boolean;\n type: string;\n zBounds?: { min: number; max: number };\n colormapTexture?: WebGLTexture;\n}\n\nexport interface RenderOptions {\n bounds: Bounds;\n backgroundColor?: [number, number, number, number];\n}\n\n// ============================================\n// Renderer Interface\n// ============================================\n\n/**\n * Common interface for all WebGL renderer implementations\n */\nexport interface IWebGLRenderer {\n /** Check if WebGL is available and initialized */\n readonly available: boolean;\n\n /**\n * Create or update a GPU buffer with interleaved X,Y data\n * @param id - Unique buffer identifier\n * @param data - Interleaved Float32Array [x0, y0, x1, y1, ...]\n */\n createBuffer(id: string, data: Float32Array): void;\n\n /**\n * Get a buffer by ID\n */\n getBuffer(id: string): WebGLBuffer | undefined;\n\n /**\n * Delete a buffer and free GPU memory\n */\n deleteBuffer(id: string): void;\n \n /** \n * Create a 1D texture for heatmaps \n */\n createColormapTexture(id: string, data: Uint8Array): WebGLTexture;\n\n /**\n * Render a frame with all visible series\n */\n render(series: SeriesRenderData[], options: RenderOptions): void;\n\n /**\n * Handle canvas resize\n */\n resize(): void;\n\n /**\n * Get WebGL capabilities/limits\n */\n getLimits(): Record<string, unknown>;\n\n /**\n * Cleanup and destroy all GPU resources\n */\n destroy(): void;\n}\n\n// ============================================\n// Factory Functions\n// ============================================\n\n/**\n * Create a WebGL renderer (Native WebGL)\n *\n * @param canvas - Target canvas element\n */\nexport function createRenderer(canvas: HTMLCanvasElement): IWebGLRenderer {\n return new NativeWebGLRenderer(canvas);\n}\n\n/**\n * Create a renderer synchronously (native only)\n */\nexport { NativeWebGLRenderer as createNativeRenderer } from './NativeWebGLRenderer';\n","/**\n * Sci Plot - Global Plugin Registry\n * \n * Provides a global registry for third-party plugins that can be\n * discovered and loaded by name without explicit imports.\n * \n * @module plugins/PluginRegistry\n */\n\nimport type {\n PluginFactory,\n PluginManifest,\n PluginCapability,\n PluginRegistry,\n PluginRegistryEntry,\n} from \"./types\";\n\n// ============================================\n// Global Registry Implementation\n// ============================================\n\nclass PluginRegistryImpl implements PluginRegistry {\n private entries = new Map<string, PluginRegistryEntry>();\n\n /**\n * Register a plugin globally\n */\n register(entry: PluginRegistryEntry): void {\n const name = entry.manifest.name;\n\n if (this.entries.has(name)) {\n console.warn(\n `[SciPlot Registry] Plugin \"${name}\" is already registered, overwriting`\n );\n }\n\n this.entries.set(name, entry);\n }\n\n /**\n * Unregister a plugin\n */\n unregister(name: string): boolean {\n const existed = this.entries.has(name);\n this.entries.delete(name);\n return existed;\n }\n\n /**\n * Get a registered plugin factory by name\n */\n get(name: string): PluginFactory | undefined {\n return this.entries.get(name)?.factory;\n }\n\n /**\n * List all registered plugins\n */\n list(): PluginManifest[] {\n return Array.from(this.entries.values()).map((e) => e.manifest);\n }\n\n /**\n * Search plugins by capability\n */\n findByCapability(capability: PluginCapability): PluginManifest[] {\n const results: PluginManifest[] = [];\n\n this.entries.forEach((entry) => {\n if (entry.manifest.provides?.includes(capability)) {\n results.push(entry.manifest);\n }\n });\n\n return results;\n }\n\n /**\n * Search plugins by tag\n */\n findByTag(tag: string): PluginManifest[] {\n const results: PluginManifest[] = [];\n const lowerTag = tag.toLowerCase();\n\n this.entries.forEach((entry) => {\n if (entry.manifest.tags?.some((t) => t.toLowerCase().includes(lowerTag))) {\n results.push(entry.manifest);\n }\n });\n\n return results;\n }\n\n /**\n * Check if a plugin is registered\n */\n has(name: string): boolean {\n return this.entries.has(name);\n }\n\n /**\n * Get plugin count\n */\n get size(): number {\n return this.entries.size;\n }\n\n /**\n * Clear all registrations\n */\n clear(): void {\n this.entries.clear();\n }\n}\n\n// ============================================\n// Singleton Instance\n// ============================================\n\nlet registryInstance: PluginRegistryImpl | null = null;\n\n/**\n * Get the global plugin registry singleton\n */\nexport function getPluginRegistry(): PluginRegistry {\n if (!registryInstance) {\n registryInstance = new PluginRegistryImpl();\n }\n return registryInstance;\n}\n\n/**\n * Register a plugin in the global registry\n * Shorthand for getPluginRegistry().register()\n */\nexport function registerPlugin(entry: PluginRegistryEntry): void {\n getPluginRegistry().register(entry);\n}\n\n/**\n * Create a plugin factory with manifest validation\n */\nexport function definePlugin<TConfig = unknown>(\n manifest: PluginManifest,\n factory: (config?: TConfig) => Omit<import(\"./types\").ChartPlugin<TConfig>, \"manifest\">\n): PluginFactory<TConfig> {\n return (config?: TConfig) => {\n const plugin = factory(config);\n return {\n ...plugin,\n manifest,\n };\n };\n}\n\n/**\n * Register a plugin from definition\n */\nexport function defineAndRegister<TConfig = unknown>(\n manifest: PluginManifest,\n factory: (config?: TConfig) => Omit<import(\"./types\").ChartPlugin<TConfig>, \"manifest\">\n): PluginFactory<TConfig> {\n const pluginFactory = definePlugin(manifest, factory);\n registerPlugin({ manifest, factory: pluginFactory as PluginFactory });\n return pluginFactory;\n}\n\n// ============================================\n// Plugin Discovery Helpers\n// ============================================\n\n/**\n * Load a plugin from the registry by name\n */\nexport async function loadPlugin<TConfig = unknown>(\n name: string,\n config?: TConfig\n): Promise<import(\"./types\").ChartPlugin<TConfig> | undefined> {\n const factory = getPluginRegistry().get(name);\n if (!factory) {\n console.warn(`[SciPlot] Plugin \"${name}\" not found in registry`);\n return undefined;\n }\n return factory(config) as import(\"./types\").ChartPlugin<TConfig>;\n}\n\n/**\n * List available plugins by category\n */\nexport function listPluginsByCategory(): Record<PluginCapability, PluginManifest[]> {\n const registry = getPluginRegistry();\n const categories: PluginCapability[] = [\n \"analysis\",\n \"visualization\",\n \"interaction\",\n \"data-source\",\n \"export\",\n \"ui\",\n \"annotation\",\n \"theme\",\n ];\n\n const result: Record<string, PluginManifest[]> = {};\n categories.forEach((cat) => {\n result[cat] = registry.findByCapability(cat);\n });\n\n return result as Record<PluginCapability, PluginManifest[]>;\n}\n\n// ============================================\n// Plugin Validation\n// ============================================\n\n/**\n * Validate a plugin manifest\n */\nexport function validateManifest(manifest: PluginManifest): string[] {\n const errors: string[] = [];\n\n if (!manifest.name) {\n errors.push(\"Missing required field: name\");\n } else if (!/^[@a-z0-9-]+\\/[a-z0-9-]+$|^[a-z0-9-]+$/.test(manifest.name)) {\n errors.push(\n 'Invalid name format. Use lowercase with hyphens, optionally scoped (e.g., \"@org/name\")'\n );\n }\n\n if (!manifest.version) {\n errors.push(\"Missing required field: version\");\n } else if (!/^\\d+\\.\\d+\\.\\d+$/.test(manifest.version)) {\n errors.push(\"Invalid version format. Use semantic versioning (e.g., 1.0.0)\");\n }\n\n if (manifest.dependencies) {\n if (!Array.isArray(manifest.dependencies)) {\n errors.push(\"dependencies must be an array\");\n }\n }\n\n if (manifest.provides) {\n if (!Array.isArray(manifest.provides)) {\n errors.push(\"provides must be an array\");\n }\n }\n\n return errors;\n}\n\n/**\n * Validate a plugin for compatibility\n */\nexport function checkPluginCompatibility(\n manifest: PluginManifest,\n engineVersion: string\n): { compatible: boolean; warnings: string[] } {\n const warnings: string[] = [];\n\n if (manifest.engineVersion) {\n const [reqMajor] = manifest.engineVersion.split(\".\").map(Number);\n const [curMajor] = engineVersion.split(\".\").map(Number);\n\n if (reqMajor > curMajor) {\n return {\n compatible: false,\n warnings: [\n `Plugin requires engine v${manifest.engineVersion}, current is v${engineVersion}`,\n ],\n };\n }\n\n if (reqMajor < curMajor) {\n warnings.push(\n `Plugin was built for engine v${manifest.engineVersion}, may have compatibility issues`\n );\n }\n }\n\n return { compatible: true, warnings };\n}\n","/**\n * Sci Plot - Plugin System\n * \n * Comprehensive plugin architecture for extending chart functionality.\n * \n * Features:\n * - Complete lifecycle hooks (init, render, data, view, interaction, destroy)\n * - Rich plugin context with access to all chart internals\n * - Plugin storage for persistent state\n * - Dependency management between plugins\n * - Global registry for third-party plugins\n * - Built-in plugins for common use cases\n * \n * @packageDocumentation\n * @module plugins\n */\n\n// ============================================\n// Core Types\n// ============================================\nexport type {\n // Manifest & Metadata\n PluginVersion,\n PluginCapability,\n PluginManifest,\n\n // Context Types\n PluginContext,\n RenderContext,\n CoordinateContext,\n DataContext,\n UIContext,\n EventContext,\n PluginStorage,\n PluginLogger,\n OverlayOptions,\n NotificationOptions,\n PickResult,\n\n // Hook Event Types\n BeforeRenderEvent,\n AfterRenderEvent,\n InteractionEvent,\n ViewChangeEvent,\n SeriesChangeEvent,\n DataUpdateEvent,\n\n // Plugin Types\n ChartPlugin,\n PluginFactory,\n TypedPlugin,\n\n // Manager Types\n PluginManager,\n PluginRegistry,\n PluginRegistryEntry,\n} from \"./types\";\n\n// ============================================\n// Core Implementation\n// ============================================\nexport { createPluginContext } from \"./PluginContext\";\nexport type { ContextDependencies } from \"./PluginContext\";\n\nexport { PluginManagerImpl } from \"./PluginManager\";\n\n// ============================================\n// Registry\n// ============================================\nexport {\n getPluginRegistry,\n registerPlugin,\n definePlugin,\n defineAndRegister,\n loadPlugin,\n listPluginsByCategory,\n validateManifest,\n checkPluginCompatibility,\n} from \"./PluginRegistry\";\n\n// ============================================\n// Built-in Plugins\n// ============================================\nexport {\n // Individual plugins\n CrosshairPlugin,\n StatsPlugin,\n WatermarkPlugin,\n GridHighlightPlugin,\n DataLoggerPlugin,\n DirectionIndicatorPlugin,\n\n // Plugin collection\n BuiltinPlugins,\n\n // Plugin configs\n type CrosshairPluginConfig,\n type StatsPluginConfig,\n type WatermarkPluginConfig,\n type GridHighlightConfig,\n type DataLoggerConfig,\n type DirectionIndicatorConfig,\n} from \"./builtins\";\n\n// ============================================\n// Modular Plugins\n// ============================================\nexport { Plugin3D, type Plugin3DConfig } from \"./3d\";\nexport { PluginGpu, type PluginGpuConfig } from \"./gpu\";\nexport { PluginAnalysis, type PluginAnalysisConfig } from \"./analysis\";\nexport { PluginTools, type PluginToolsConfig } from \"./tools\";\nexport { PluginAnnotations, type PluginAnnotationsConfig } from \"./annotations\";\nexport { PluginStreaming, type PluginStreamingConfig } from \"./streaming\";\nexport { PluginThemeEditor, type PluginThemeEditorConfig } from \"./theme-editor\";\nexport { PluginI18n, type PluginI18nConfig } from \"./i18n\";\nexport { PluginKeyboard, type PluginKeyboardConfig } from \"./keyboard\";\nexport { PluginClipboard, type PluginClipboardConfig } from \"./clipboard\";\nexport { PluginSync, type PluginSyncConfig } from \"./sync\";\nexport { PluginDebug, type PluginDebugConfig } from \"./debug\";\nexport { PluginLoading, type PluginLoadingConfig } from \"./loading\";\nexport { PluginDataExport, type PluginDataExportConfig } from \"./data-export\";\nexport { PluginContextMenu, type PluginContextMenuConfig } from \"./context-menu\";\nexport { PluginAnomalyDetection, type PluginAnomalyDetectionConfig, type AnomalyDetectionResult, type AnomalyPoint, type AnomalyMethod } from \"./anomaly-detection\";\nexport { PluginMLIntegration, type PluginMLIntegrationConfig, type MLIntegrationAPI, type MLModelAPI, type PredictionResult, type VisualizationConfig } from \"./ml-integration\";\nexport { PluginPatternRecognition, type PluginPatternRecognitionConfig, type PatternRecognitionAPI, type PatternMatch, type PatternDetectionResult } from \"./pattern-recognition\";\nexport { PluginRegression, type PluginRegressionConfig, type RegressionAPI, type RegressionResult, type RegressionData } from \"./regression\";\nexport { PluginRadar, type PluginRadarConfig, type RadarAPI, type RadarSeriesData, type RadarPoint } from \"./radar\";\nexport { PluginSnapshot, type PluginSnapshotConfig, type SnapshotExportAPI, type SnapshotExportOptions, type SnapshotResolution, type SnapshotFormat } from \"./snapshot\";\nexport { PluginDataTransform, type PluginDataTransformConfig, type DataTransformAPI, type TransformOp, type TransformType } from \"./data-transform\";\nexport { PluginLaTeX, type PluginLaTeXConfig, type LaTeXPluginAPI, type LaTeXDimensions } from \"./latex\";\nexport * from \"./forecasting\";\n\n// Drag & Drop Editing\nexport { PluginDragEdit, type PluginDragEditConfig, type DragEditAPI, type DragEditEvent } from \"./drag-edit\";\n\n// Caching\nexport { PluginCaching, type PluginCachingConfig, type CachingAPI, type CacheStats } from \"./caching\";\n\n// Lazy Loading\nexport { PluginLazyLoad, type PluginLazyLoadConfig, type LazyLoadAPI, type DataProvider } from \"./lazy-load\";\n\n// Broken Axis\nexport { PluginBrokenAxis, type PluginBrokenAxisConfig, type BrokenAxisAPI, type AxisBreak } from \"./broken-axis\";\n\n// Video Recorder\nexport { PluginVideoRecorder, type PluginVideoRecorderConfig, type VideoRecorderAPI, type VideoRecorderOptions } from \"./video-recorder\";\n\n// Offscreen Rendering\nexport { PluginOffscreen, type PluginOffscreenConfig, type OffscreenAPI, type OffscreenStats, type OffscreenMode, type OffscreenTransferMode, type OffscreenFallbackMode } from \"./offscreen\";\n\n// Virtualization\nexport { PluginVirtualization, type PluginVirtualizationConfig, type VirtualizationAPI, type VirtualizationStats, type VirtualizationMode, type VirtualizationStrategy } from \"./virtualization\";\n\n// ROI\nexport { PluginROI, type PluginROIConfig, type RoiAPI, type RoiRegion, type RoiPoint, type RoiMaskResult, type RoiTool, type RoiEvent, type RoiSelectedEvent } from \"./roi\";\n\n// ============================================\n// Helper for creating typed plugins\n// ============================================\n\n/**\n * Helper function to create a plugin with proper typing\n * \n * @example\n * ```typescript\n * const MyPlugin = createPlugin({\n * manifest: {\n * name: 'my-plugin',\n * version: '1.0.0',\n * provides: ['analysis'],\n * },\n * onInit(ctx) {\n * ctx.log.info('Plugin initialized!');\n * },\n * onAfterRender(ctx, event) {\n * // Custom rendering\n * },\n * api: {\n * doSomething() { return 'done'; }\n * }\n * });\n * \n * chart.use(MyPlugin);\n * ```\n */\nexport function createPlugin<TConfig = void, TApi extends Record<string, unknown> = {}>(\n definition: import(\"./types\").ChartPlugin<TConfig> & { api?: TApi }\n): import(\"./types\").ChartPlugin<TConfig> & { api: TApi } {\n return definition as import(\"./types\").ChartPlugin<TConfig> & { api: TApi };\n}\n\n/**\n * Helper function to create a configurable plugin factory\n * \n * @example\n * ```typescript\n * interface MyConfig {\n * color: string;\n * enabled: boolean;\n * }\n * \n * const MyPlugin = createConfigurablePlugin<MyConfig>(\n * {\n * name: 'my-plugin',\n * version: '1.0.0',\n * },\n * (config) => ({\n * onInit(ctx) {\n * ctx.log.info(`Color: ${config?.color}`);\n * }\n * })\n * );\n * \n * chart.use(MyPlugin({ color: 'red', enabled: true }));\n * ```\n */\nexport function createConfigurablePlugin<TConfig = void>(\n manifest: import(\"./types\").PluginManifest,\n factory: (config?: TConfig) => Omit<import(\"./types\").ChartPlugin<TConfig>, \"manifest\">\n): import(\"./types\").PluginFactory<TConfig> {\n return (config?: TConfig) => ({\n ...factory(config),\n manifest,\n });\n}\n"],"names":["createRenderer","canvas","NativeWebGLRenderer","PluginRegistryImpl","__publicField","entry","name","existed","_a","capability","results","tag","lowerTag","t","registryInstance","getPluginRegistry","registerPlugin","definePlugin","manifest","factory","config","defineAndRegister","pluginFactory","loadPlugin","listPluginsByCategory","registry","categories","result","cat","validateManifest","errors","checkPluginCompatibility","engineVersion","warnings","reqMajor","curMajor","createPlugin","definition","createConfigurablePlugin"],"mappings":";;;;;;AA6FO,SAASA,EAAeC,GAA2C;AACxE,SAAO,IAAIC,EAAoBD,CAAM;AACvC;AC1EA,MAAME,EAA6C;AAAA,EAAnD;AACY,IAAAC,EAAA,qCAAc,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAKtB,SAASC,GAAkC;AACvC,UAAMC,IAAOD,EAAM,SAAS;AAE5B,IAAI,KAAK,QAAQ,IAAIC,CAAI,KACrB,QAAQ;AAAA,MACJ,8BAA8BA,CAAI;AAAA,IAAA,GAI1C,KAA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iCAAiC,GAK7CZ,EAAS,iBACJ,MAAM,QAAQA,EAAS,YAAY,KACpCY,EAAO,KAAK,+BAA+B,IAI/CZ,EAAS,aACJ,MAAM,QAAQA,EAAS,QAAQ,KAChCY,EAAO,KAAK,2BAA2B,IAIxCA;AACX;AAKO,SAASC,EACZb,GACAc,GAC2C;AAC3C,QAAMC,IAAqB,CAAA;AAE3B,MAAIf,EAAS,eAAe;AACxB,UAAM,CAACgB,CAAQ,IAAIhB,EAAS,cAAc,MAAM,GAAG,EAAE,IAAI,MAAM,GACzD,CAACiB,CAAQ,IAAIH,EAAc,MAAM,GAAG,EAAE,IAAI,MAAM;AAEtD,QAAIE,IAAWC;AACX,aAAO;AAAA,QACH,YAAY;AAAA,QACZ,UAAU;AAAA,UACN,2BAA2BjB,EAAS,aAAa,iBAAiBc,CAAa;AAAA,QAAA;AAAA,MACnF;AAIR,IAAIE,IAAWC,KACXF,EAAS;AAAA,MACL,gCAAgCf,EAAS,aAAa;AAAA,IAAA;AAAA,EAGlE;AAEA,SAAO,EAAE,YAAY,IAAM,UAAAe,EAAA;AAC/B;AC9FO,SAASG,EACZC,GACsD;AACtD,SAAOA;AACX;AA2BO,SAASC,EACZpB,GACAC,GACwC;AACxC,SAAO,CAACC,OAAsB;AAAA,IAC1B,GAAGD,EAAQC,CAAM;AAAA,IACjB,UAAAF;AAAA,EAAA;AAER;"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
function d(a, i) {
|
|
2
|
+
const e = i.length, n = a.map((t, c) => [...t, i[c]]);
|
|
3
|
+
for (let t = 0; t < e; t++) {
|
|
4
|
+
let c = t;
|
|
5
|
+
for (let s = t + 1; s < e; s++)
|
|
6
|
+
Math.abs(n[s][t]) > Math.abs(n[c][t]) && (c = s);
|
|
7
|
+
const l = n[t];
|
|
8
|
+
n[t] = n[c], n[c] = l;
|
|
9
|
+
const o = n[t][t];
|
|
10
|
+
if (Math.abs(o) < 1e-12)
|
|
11
|
+
throw new Error("Matrix is singular or near-singular");
|
|
12
|
+
for (let s = t + 1; s < e; s++) {
|
|
13
|
+
const f = n[s][t] / o;
|
|
14
|
+
for (let u = t; u <= e; u++)
|
|
15
|
+
n[s][u] -= f * n[t][u];
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
const r = new Array(e).fill(0);
|
|
19
|
+
for (let t = e - 1; t >= 0; t--) {
|
|
20
|
+
let c = 0;
|
|
21
|
+
for (let l = t + 1; l < e; l++)
|
|
22
|
+
c += n[t][l] * r[l];
|
|
23
|
+
r[t] = (n[t][e] - c) / n[t][t];
|
|
24
|
+
}
|
|
25
|
+
return r;
|
|
26
|
+
}
|
|
27
|
+
function w(a, i, e) {
|
|
28
|
+
const n = a.length;
|
|
29
|
+
if (n === 0) return 0;
|
|
30
|
+
let r = 0;
|
|
31
|
+
for (let o = 0; o < n; o++) r += i[o];
|
|
32
|
+
const t = r / n;
|
|
33
|
+
let c = 0, l = 0;
|
|
34
|
+
for (let o = 0; o < n; o++) {
|
|
35
|
+
const s = i[o], f = e(a[o]);
|
|
36
|
+
c += (s - t) * (s - t), l += (s - f) * (s - f);
|
|
37
|
+
}
|
|
38
|
+
return c === 0 ? 1 : 1 - l / c;
|
|
39
|
+
}
|
|
40
|
+
function v(a, i, e, n) {
|
|
41
|
+
const r = a.length;
|
|
42
|
+
if (r < 2) return 0;
|
|
43
|
+
let t = 0;
|
|
44
|
+
const c = e !== void 0 ? e : a[0], l = n !== void 0 ? n : a[r - 1];
|
|
45
|
+
for (let o = 0; o < r - 1; o++) {
|
|
46
|
+
const s = a[o], f = a[o + 1];
|
|
47
|
+
if (f < c) continue;
|
|
48
|
+
if (s > l) break;
|
|
49
|
+
const u = Math.max(s, c), h = Math.min(f, l);
|
|
50
|
+
if (u < h) {
|
|
51
|
+
const m = i[o] + (i[o + 1] - i[o]) * ((u - s) / (f - s)), g = i[o] + (i[o + 1] - i[o]) * ((h - s) / (f - s));
|
|
52
|
+
t += (h - u) * (m + g) / 2;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return t;
|
|
56
|
+
}
|
|
57
|
+
function b(a, i) {
|
|
58
|
+
const e = a.length;
|
|
59
|
+
if (e < 2) return new Float32Array(0);
|
|
60
|
+
const n = new Float32Array(e);
|
|
61
|
+
for (let r = 0; r < e - 1; r++) {
|
|
62
|
+
const t = a[r + 1] - a[r];
|
|
63
|
+
n[r] = t !== 0 ? (i[r + 1] - i[r]) / t : 0;
|
|
64
|
+
}
|
|
65
|
+
return n[e - 1] = n[e - 2], n;
|
|
66
|
+
}
|
|
67
|
+
function A(a, i) {
|
|
68
|
+
const e = a.length;
|
|
69
|
+
if (e < 1) return new Float32Array(0);
|
|
70
|
+
const n = new Float32Array(e);
|
|
71
|
+
n[0] = 0;
|
|
72
|
+
for (let r = 0; r < e - 1; r++) {
|
|
73
|
+
const c = (a[r + 1] - a[r]) * (i[r] + i[r + 1]) / 2;
|
|
74
|
+
n[r + 1] = n[r] + c;
|
|
75
|
+
}
|
|
76
|
+
return n;
|
|
77
|
+
}
|
|
78
|
+
export {
|
|
79
|
+
w as a,
|
|
80
|
+
A as c,
|
|
81
|
+
b as d,
|
|
82
|
+
v as i,
|
|
83
|
+
d as s
|
|
84
|
+
};
|
|
85
|
+
//# sourceMappingURL=math-Ddm2EZjj.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"math-Ddm2EZjj.js","sources":["../src/plugins/analysis/math.ts"],"sourcesContent":["/**\n * Mathematical utilities for numerical analysis and regression.\n */\n\n/**\n * Solve a system of linear equations Ax = B using Gaussian elimination with partial pivoting.\n * \n * @param A - Matrix coefficients\n * @param B - Right hand side vector\n * @returns Solution vector x\n */\nexport function solveLinearSystem(A: number[][], B: number[]): number[] {\n const n = B.length;\n const matrix = A.map((row, i) => [...row, B[i]]);\n\n for (let i = 0; i < n; i++) {\n // Partial pivoting\n let maxRow = i;\n for (let k = i + 1; k < n; k++) {\n if (Math.abs(matrix[k][i]) > Math.abs(matrix[maxRow][i])) {\n maxRow = k;\n }\n }\n\n // Swap rows\n const temp = matrix[i];\n matrix[i] = matrix[maxRow];\n matrix[maxRow] = temp;\n\n // Pivot must be non-zero\n const pivot = matrix[i][i];\n if (Math.abs(pivot) < 1e-12) {\n throw new Error(\"Matrix is singular or near-singular\");\n }\n\n // Eliminate below\n for (let k = i + 1; k < n; k++) {\n const factor = matrix[k][i] / pivot;\n for (let j = i; j <= n; j++) {\n matrix[k][j] -= factor * matrix[i][j];\n }\n }\n }\n\n // Back substitution\n const x = new Array(n).fill(0);\n for (let i = n - 1; i >= 0; i--) {\n let sum = 0;\n for (let j = i + 1; j < n; j++) {\n sum += matrix[i][j] * x[j];\n }\n x[i] = (matrix[i][n] - sum) / matrix[i][i];\n }\n\n return x;\n}\n\n/**\n * Calculate R² (coefficient of determination)\n */\nexport function calculateR2(\n x: number[] | Float32Array,\n y: number[] | Float32Array,\n fitFn: (x: number) => number\n): number {\n const n = x.length;\n if (n === 0) return 0;\n\n let sumY = 0;\n for (let i = 0; i < n; i++) sumY += y[i];\n const meanY = sumY / n;\n\n let ssTot = 0; // Total sum of squares\n let ssRes = 0; // Residual sum of squares\n\n for (let i = 0; i < n; i++) {\n const yi = y[i];\n const fi = fitFn(x[i]);\n ssTot += (yi - meanY) * (yi - meanY);\n ssRes += (yi - fi) * (yi - fi);\n }\n\n return ssTot === 0 ? 1 : 1 - ssRes / ssTot;\n}\n\n/**\n * Numerical integration using the trapezoidal rule.\n * \n * @param x - X values (must be sorted)\n * @param y - Y values\n * @param xMin - Optional start of integration range\n * @param xMax - Optional end of integration range\n */\nexport function integrate(\n x: number[] | Float32Array,\n y: number[] | Float32Array,\n xMin?: number,\n xMax?: number\n): number {\n const n = x.length;\n if (n < 2) return 0;\n\n let area = 0;\n const start = xMin !== undefined ? xMin : x[0];\n const end = xMax !== undefined ? xMax : x[n - 1];\n\n for (let i = 0; i < n - 1; i++) {\n const x1 = x[i];\n const x2 = x[i + 1];\n \n // Skip if outside range\n if (x2 < start) continue;\n if (x1 > end) break;\n\n // Handle partial intervals at boundaries\n const ia = Math.max(x1, start);\n const ib = Math.min(x2, end);\n\n if (ia < ib) {\n // Linear interpolation for y values at boundaries if needed\n const y1 = y[i] + (y[i + 1] - y[i]) * ((ia - x1) / (x2 - x1));\n const y2 = y[i] + (y[i + 1] - y[i]) * ((ib - x1) / (x2 - x1));\n \n area += (ib - ia) * (y1 + y2) / 2;\n }\n }\n\n return area;\n}\n\n/**\n * Calculate numerical derivative dy/dx\n */\nexport function derivative(\n x: number[] | Float32Array,\n y: number[] | Float32Array\n): Float32Array {\n const n = x.length;\n if (n < 2) return new Float32Array(0);\n\n const result = new Float32Array(n);\n for (let i = 0; i < n - 1; i++) {\n const dx = x[i + 1] - x[i];\n result[i] = dx !== 0 ? (y[i + 1] - y[i]) / dx : 0;\n }\n // Last point same as previous for length matching\n result[n - 1] = result[n - 2];\n return result;\n}\n\n/**\n * Calculate cumulative integral (area array)\n */\nexport function cumulativeIntegral(\n x: number[] | Float32Array,\n y: number[] | Float32Array\n): Float32Array {\n const n = x.length;\n if (n < 1) return new Float32Array(0);\n\n const result = new Float32Array(n);\n result[0] = 0;\n \n for (let i = 0; i < n - 1; i++) {\n const dx = x[i + 1] - x[i];\n const area = dx * (y[i] + y[i + 1]) / 2;\n result[i + 1] = result[i] + area;\n }\n \n return result;\n}\n"],"names":["solveLinearSystem","A","B","n","matrix","row","i","maxRow","k","temp","pivot","factor","j","x","sum","calculateR2","y","fitFn","sumY","meanY","ssTot","ssRes","yi","fi","integrate","xMin","xMax","area","start","end","x1","x2","ia","ib","y1","y2","derivative","result","dx","cumulativeIntegral"],"mappings":"AAWO,SAASA,EAAkBC,GAAeC,GAAuB;AACtE,QAAMC,IAAID,EAAE,QACNE,IAASH,EAAE,IAAI,CAACI,GAAKC,MAAM,CAAC,GAAGD,GAAKH,EAAEI,CAAC,CAAC,CAAC;AAE/C,WAASA,IAAI,GAAGA,IAAIH,GAAGG,KAAK;AAE1B,QAAIC,IAASD;A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