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
@@ -37,13 +37,15 @@ test("CW entry appends server-decoded text and registers lifecycle callbacks", a
Math,
console,
});
const runtime = await readFile(new URL("../../assets/web/generated/plugin-runtime.js", import.meta.url), "utf8");
const source = await readFile(new URL("../../assets/web/generated/cw.js", import.meta.url), "utf8");
new vm.Script(runtime).runInContext(context);
new vm.Script(source).runInContext(context);
window.onServerCw({ text: "CQ", wpm: 18, tone_hz: 700, signal_on: true });
window.trxPluginRuntime.dispatch("cw", { text: "CQ", wpm: 18, tone_hz: 700, signal_on: true });
assert.equal(status.textContent, "Receiving");
assert.equal(output.children.length, 1);
assert.equal(output.children[0].textContent, "CQ");
assert.equal(typeof window.resetCwHistoryView, "function");
assert.equal(typeof window.restoreCwHistory, "function");
assert.equal(window.onServerCw, undefined);
assert.equal(window.trxPluginRuntime.hasDecoder("cw"), true);
});
@@ -29,10 +29,12 @@ test("FT2 entry normalizes audio offsets and registers typed callbacks", async (
Array,
console,
});
const runtime = await readFile(new URL("../../assets/web/generated/plugin-runtime.js", import.meta.url), "utf8");
const source = await readFile(new URL("../../assets/web/generated/ft2.js", import.meta.url), "utf8");
new vm.Script(runtime).runInContext(context);
new vm.Script(source).runInContext(context);
window.onServerFt2({ message: "CQ SP0ABC JO91", freq_hz: 1_250, ts_ms: Date.now(), snr_db: -8 });
window.trxPluginRuntime.dispatch("ft2", { message: "CQ SP0ABC JO91", freq_hz: 1_250, ts_ms: Date.now(), snr_db: -8 });
assert.equal(mapMessages.length, 1);
assert.equal(mapMessages[0][4].freq_hz, 14_075_250);
const bar = barRenderer();
@@ -59,12 +61,14 @@ test("FT8 entry installs shared parsing without relying on script globals", asyn
Set,
console,
});
const runtime = await readFile(new URL("../../assets/web/generated/plugin-runtime.js", import.meta.url), "utf8");
const source = await readFile(new URL("../../assets/web/generated/ft8.js", import.meta.url), "utf8");
new vm.Script(runtime).runInContext(context);
new vm.Script(source).runInContext(context);
const details = window.ft8ExtractLocatorDetails("K1ABC SP0ABC JO91");
assert.equal(details[0].source, "SP0ABC");
assert.equal(details[0].target, "K1ABC");
window.onServerFt8({ message: "K1ABC SP0ABC JO91", freq_hz: 500, ts_ms: Date.now() });
window.trxPluginRuntime.dispatch("ft8", { message: "K1ABC SP0ABC JO91", freq_hz: 500, ts_ms: Date.now() });
assert.equal(forwarded[0][4].freq_hz, 7_074_500);
});
@@ -26,12 +26,14 @@ test("satellite entry registers lifecycle callbacks and forwards georeferenced i
Error,
console,
});
const runtime = await readFile(new URL("../../assets/web/generated/plugin-runtime.js", import.meta.url), "utf8");
const source = await readFile(new URL("../../assets/web/generated/sat.js", import.meta.url), "utf8");
new vm.Script(runtime).runInContext(context);
new vm.Script(source).runInContext(context);
window.onServerLrptImage({ path: "/images/lrpt.png", geo_bounds: [50, 10, 55, 20], mcu_count: 100 });
window.trxPluginRuntime.dispatch("lrpt_image", { path: "/images/lrpt.png", geo_bounds: [50, 10, 55, 20], mcu_count: 100 });
assert.equal(overlays.length, 1);
assert.deepEqual(overlays[0].geo_bounds, [50, 10, 55, 20]);
assert.equal(typeof window.updateSatLiveState, "function");
assert.equal(typeof window.resetSatHistoryView, "function");
assert.equal(window.onServerLrptImage, undefined);
});
@@ -19,12 +19,14 @@ test("WEFAX entry exposes typed lifecycle handlers and renders decoder state", a
Uint8Array,
console,
});
const runtime = await readFile(new URL("../../assets/web/generated/plugin-runtime.js", import.meta.url), "utf8");
const source = await readFile(new URL("../../assets/web/generated/wefax.js", import.meta.url), "utf8");
new vm.Script(runtime).runInContext(context);
new vm.Script(source).runInContext(context);
assert.equal(typeof window.onServerWefaxProgress, "function");
assert.equal(typeof window.restoreWefaxHistory, "function");
window.onServerWefaxProgress({ state: "Scanning 12 MHz" });
assert.equal(window.onServerWefaxProgress, undefined);
assert.equal(window.trxPluginRuntime.hasDecoder("wefax_progress"), true);
window.trxPluginRuntime.dispatch("wefax_progress", { state: "Scanning 12 MHz" });
assert.equal(status.textContent, "Scanning 12 MHz");
assert.equal(status.style.color, "var(--text-accent)");
});
@@ -25,10 +25,12 @@ test("WSPR entry forwards decoded locators at their absolute frequency", async (
Element: class Element {},
console,
});
const runtime = await readFile(new URL("../../assets/web/generated/plugin-runtime.js", import.meta.url), "utf8");
const source = await readFile(new URL("../../assets/web/generated/wspr.js", import.meta.url), "utf8");
new vm.Script(runtime).runInContext(context);
new vm.Script(source).runInContext(context);
window.onServerWspr({ message: "SP0ABC JO91 37", freq_hz: 1_420, ts_ms: Date.now() });
window.trxPluginRuntime.dispatch("wspr", { message: "SP0ABC JO91 37", freq_hz: 1_420, ts_ms: Date.now() });
assert.equal(forwarded.length, 1);
assert.equal(forwarded[0][1][0], "JO91");
assert.equal(forwarded[0][4].freq_hz, 14_097_020);