refactor: add typed decoder plugin runtime
This commit is contained in:
@@ -488,10 +488,10 @@ function currentDecodeHistoryRetentionMs() {
|
||||
}
|
||||
window.getDecodeHistoryRetentionMs = currentDecodeHistoryRetentionMs;
|
||||
window.applyDecodeHistoryRetention = function() {
|
||||
if (typeof window.pruneAprsHistoryView === "function") window.pruneAprsHistoryView();
|
||||
if (typeof window.pruneHfAprsHistoryView === "function") window.pruneHfAprsHistoryView();
|
||||
if (typeof window.pruneAisHistoryView === "function") window.pruneAisHistoryView();
|
||||
if (typeof window.pruneVdesHistoryView === "function") window.pruneVdesHistoryView();
|
||||
window.trxPluginRuntime.prune("aprs");
|
||||
window.trxPluginRuntime.prune("hf_aprs");
|
||||
window.trxPluginRuntime.prune("ais");
|
||||
window.trxPluginRuntime.prune("vdes");
|
||||
if (typeof window.pruneFt8HistoryView === "function") window.pruneFt8HistoryView();
|
||||
if (typeof window.pruneWsprHistoryView === "function") window.pruneWsprHistoryView();
|
||||
};
|
||||
@@ -529,37 +529,6 @@ function setConnLostOverlay(visible, title = "Connection lost", sub = "Retrying
|
||||
const decodeHistoryTextDecoder = typeof TextDecoder === "function" ? new TextDecoder() : null;
|
||||
let decodeHistoryReplayActive = false;
|
||||
let decodeMapSyncPending = false;
|
||||
const _pendingDecodeHistory = {};
|
||||
const _pendingDecodeLive = {};
|
||||
window._trxDrainPendingDecode = function(kind) {
|
||||
const historyKey = {
|
||||
ais: "restoreAisHistory",
|
||||
vdes: "restoreVdesHistory",
|
||||
aprs: "restoreAprsHistory",
|
||||
hf_aprs: "restoreHfAprsHistory"
|
||||
}[kind];
|
||||
if (historyKey && _pendingDecodeHistory[kind] && window[historyKey]) {
|
||||
const msgs = _pendingDecodeHistory[kind];
|
||||
delete _pendingDecodeHistory[kind];
|
||||
window[historyKey](msgs);
|
||||
}
|
||||
const liveKey = {
|
||||
ais: "onServerAis",
|
||||
vdes: "onServerVdes",
|
||||
aprs: "onServerAprs",
|
||||
hf_aprs: "onServerHfAprs"
|
||||
}[kind];
|
||||
if (liveKey && _pendingDecodeLive[kind] && window[liveKey]) {
|
||||
const msgs = _pendingDecodeLive[kind];
|
||||
delete _pendingDecodeLive[kind];
|
||||
for (const msg of msgs) {
|
||||
try {
|
||||
window[liveKey](msg);
|
||||
} catch (_) {
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
function markDecodeMapSyncPending() {
|
||||
decodeMapSyncPending = true;
|
||||
}
|
||||
@@ -5888,21 +5857,8 @@ function updateDecodeStatus(text) {
|
||||
}
|
||||
}
|
||||
function dispatchDecodeMessage(msg, skipStats) {
|
||||
if (msg.type === "ais") {
|
||||
if (window.onServerAis) window.onServerAis(msg);
|
||||
else (_pendingDecodeLive.ais = _pendingDecodeLive.ais || []).push(msg);
|
||||
}
|
||||
if (msg.type === "vdes") {
|
||||
if (window.onServerVdes) window.onServerVdes(msg);
|
||||
else (_pendingDecodeLive.vdes = _pendingDecodeLive.vdes || []).push(msg);
|
||||
}
|
||||
if (msg.type === "aprs") {
|
||||
if (window.onServerAprs) window.onServerAprs(msg);
|
||||
else (_pendingDecodeLive.aprs = _pendingDecodeLive.aprs || []).push(msg);
|
||||
}
|
||||
if (msg.type === "hf_aprs") {
|
||||
if (window.onServerHfAprs) window.onServerHfAprs(msg);
|
||||
else (_pendingDecodeLive.hf_aprs = _pendingDecodeLive.hf_aprs || []).push(msg);
|
||||
if (msg.type === "ais" || msg.type === "vdes" || msg.type === "aprs" || msg.type === "hf_aprs") {
|
||||
window.trxPluginRuntime.dispatch(msg.type, msg);
|
||||
}
|
||||
if (msg.type === "cw" && window.onServerCw) window.onServerCw(msg);
|
||||
if (msg.type === "ft8" && window.onServerFt8) window.onServerFt8(msg);
|
||||
@@ -5929,20 +5885,8 @@ function dispatchDecodeBatch(batch) {
|
||||
const type = String(batch[0]?.type || "");
|
||||
const uniformType = batch.every((msg) => String(msg?.type || "") === type);
|
||||
if (uniformType) {
|
||||
if (type === "ais" && window.onServerAisBatch) {
|
||||
window.onServerAisBatch(batch);
|
||||
return;
|
||||
}
|
||||
if (type === "vdes" && window.onServerVdesBatch) {
|
||||
window.onServerVdesBatch(batch);
|
||||
return;
|
||||
}
|
||||
if (type === "aprs" && window.onServerAprsBatch) {
|
||||
window.onServerAprsBatch(batch);
|
||||
return;
|
||||
}
|
||||
if (type === "hf_aprs" && window.onServerHfAprsBatch) {
|
||||
window.onServerHfAprsBatch(batch);
|
||||
if (type === "ais" || type === "vdes" || type === "aprs" || type === "hf_aprs") {
|
||||
window.trxPluginRuntime.dispatchBatch(type, batch);
|
||||
return;
|
||||
}
|
||||
if (type === "ft8" && window.onServerFt8Batch) {
|
||||
@@ -6010,36 +5954,8 @@ function restoreDecodeHistoryGroup(kind, messages) {
|
||||
}
|
||||
window.trx.modules.map?.scheduleStatsRender();
|
||||
}
|
||||
if (kind === "ais") {
|
||||
if (window.restoreAisHistory) {
|
||||
window.restoreAisHistory(messages);
|
||||
} else {
|
||||
_pendingDecodeHistory.ais = (_pendingDecodeHistory.ais || []).concat(messages);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (kind === "vdes") {
|
||||
if (window.restoreVdesHistory) {
|
||||
window.restoreVdesHistory(messages);
|
||||
} else {
|
||||
_pendingDecodeHistory.vdes = (_pendingDecodeHistory.vdes || []).concat(messages);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (kind === "aprs") {
|
||||
if (window.restoreAprsHistory) {
|
||||
window.restoreAprsHistory(messages);
|
||||
} else {
|
||||
_pendingDecodeHistory.aprs = (_pendingDecodeHistory.aprs || []).concat(messages);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (kind === "hf_aprs") {
|
||||
if (window.restoreHfAprsHistory) {
|
||||
window.restoreHfAprsHistory(messages);
|
||||
} else {
|
||||
_pendingDecodeHistory.hf_aprs = (_pendingDecodeHistory.hf_aprs || []).concat(messages);
|
||||
}
|
||||
if (kind === "ais" || kind === "vdes" || kind === "aprs" || kind === "hf_aprs") {
|
||||
window.trxPluginRuntime.restore(kind, messages);
|
||||
return;
|
||||
}
|
||||
if (kind === "cw" && window.restoreCwHistory) {
|
||||
@@ -6074,11 +5990,11 @@ function connectDecode() {
|
||||
terminateDecodeHistoryWorker();
|
||||
decodeHistoryReplayActive = false;
|
||||
decodeMapSyncPending = false;
|
||||
for (const k in _pendingDecodeHistory) delete _pendingDecodeHistory[k];
|
||||
for (const k in _pendingDecodeLive) delete _pendingDecodeLive[k];
|
||||
if (window.resetAisHistoryView) window.resetAisHistoryView();
|
||||
if (window.resetVdesHistoryView) window.resetVdesHistoryView();
|
||||
if (window.resetAprsHistoryView) window.resetAprsHistoryView();
|
||||
window.trxPluginRuntime.clearQueued();
|
||||
window.trxPluginRuntime.reset("ais");
|
||||
window.trxPluginRuntime.reset("vdes");
|
||||
window.trxPluginRuntime.reset("aprs");
|
||||
window.trxPluginRuntime.reset("hf_aprs");
|
||||
if (window.resetCwHistoryView) window.resetCwHistoryView();
|
||||
if (window.resetFt8HistoryView) window.resetFt8HistoryView();
|
||||
if (window.resetFt4HistoryView) window.resetFt4HistoryView();
|
||||
|
||||
Reference in New Issue
Block a user