feat: add unified upload telemetry
Move upload activity out of the global footer into a compact eight-row sidebar panel, add vertical metric transitions, and draw a smoothed green upload-speed sparkline in the header. Localize the new surfaces, cover responsive Electron behavior, and extend the strict public source allowlist for the new bounded speed-history module and its tests.
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
(function (root) {
|
||||
'use strict';
|
||||
|
||||
function updateSpeedHistory(state, target, maxSamples = 160) {
|
||||
const nextTarget = Number.isFinite(Number(target)) ? Math.max(0, Number(target)) : 0;
|
||||
const previous = Number.isFinite(Number(state.display)) ? Math.max(0, Number(state.display)) : 0;
|
||||
const alpha = nextTarget >= previous ? 0.45 : 0.12;
|
||||
const display = previous + (nextTarget - previous) * alpha;
|
||||
state.display = display < 1 ? 0 : display;
|
||||
if (!Array.isArray(state.history)) state.history = [];
|
||||
state.history.push(state.display);
|
||||
const limit = Math.max(1, Math.floor(Number(maxSamples) || 160));
|
||||
if (state.history.length > limit) state.history.splice(0, state.history.length - limit);
|
||||
return state;
|
||||
}
|
||||
|
||||
const api = { updateSpeedHistory };
|
||||
if (typeof module !== 'undefined' && module.exports) module.exports = api;
|
||||
else if (root) root.SpeedHistory = api;
|
||||
})(typeof window !== 'undefined' ? window : this);
|
||||
Reference in New Issue
Block a user