Files
Multi-Hoster-Upload/lib/speed-history.js
T
Sucukdeluxe 6d458e37f3 fix: stabilize the header on first paint
Pass the installed version with the startup language so the renderer can display it before asynchronous initialization.

Seed and start the upload sparkline immediately, keep a fixed update-action slot across all update states, and remove the delayed automatic update check.

Add first-frame regression coverage for version, speed baseline, update geometry, and startup query behavior.
2026-08-20 13:27:55 +02:00

25 lines
1.1 KiB
JavaScript

(function (root) {
'use strict';
function createInitialSpeedHistoryState() {
return { display: 0, history: [0, 0] };
}
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, createInitialSpeedHistoryState };
if (typeof module !== 'undefined' && module.exports) module.exports = api;
else if (root) root.SpeedHistory = api;
})(typeof window !== 'undefined' ? window : this);