refactor: route all decoders through plugin runtime

This commit is contained in:
sjg
2026-08-01 13:06:38 +02:00
parent 508cf2ba87
commit 9fef0ebc7b
19 changed files with 255 additions and 319 deletions
@@ -82,7 +82,7 @@
}
cwWindow.updateCwBar = updateCwBar;
cwWindow.clearCwBar = function() {
cwWindow.resetCwHistoryView?.();
resetCwHistoryView();
};
cwWindow.closeCwBar = function() {
cwBarDismissedAtMs = Date.now();
@@ -302,26 +302,26 @@
void setCwTone(tone);
});
}
cwWindow.resetCwHistoryView = function() {
function resetCwHistoryView() {
if (cwOutputEl) cwOutputEl.innerHTML = "";
cwLastAppendTime = 0;
cwBarHistory = [];
cwBarCurrentLine = null;
updateCwBar();
drawCwTonePicker();
};
}
document.getElementById("settings-clear-cw-history")?.addEventListener("click", () => {
void (async () => {
if (!await cwWindow.trxUi.confirm({ title: "Clear CW history?", message: "All stored CW decodes will be permanently removed.", confirmLabel: "Clear history" })) return;
try {
await cwWindow.postPath?.("/clear_cw_decode");
cwWindow.resetCwHistoryView?.();
resetCwHistoryView();
} catch (error) {
console.error("CW history clear failed", error);
}
})();
});
cwWindow.onServerCw = function(evt) {
function onServerCw(evt) {
if (cwStatusEl) cwStatusEl.textContent = "Receiving";
if (evt.text && cwOutputEl) {
const now = Date.now();
@@ -375,14 +375,20 @@
cwTonePickerRaf = null;
drawCwTonePicker();
});
};
cwWindow.restoreCwHistory = function(events) {
}
function restoreCwHistory(events) {
if (!Array.isArray(events) || events.length === 0) return;
if (cwStatusEl) cwStatusEl.textContent = "Receiving";
for (const evt of events) {
cwWindow.onServerCw?.(evt);
onServerCw(evt);
}
};
}
cwWindow.trxPluginRuntime.registerDecoder({
id: "cw",
onMessage: onServerCw,
restore: restoreCwHistory,
reset: resetCwHistoryView
});
cwWindow.refreshCwTonePicker = function refreshCwTonePicker() {
ensureCwToneCanvasResolution();
drawCwTonePicker();