Go backend (#1555)

* Replaces old Deno server with a Go implementation
* Restructured the code base accordingly
This commit is contained in:
Zef Hemel
2025-09-19 13:23:20 +02:00
committed by GitHub
parent ff2cb27a1b
commit a524c64884
322 changed files with 3841 additions and 3228 deletions
+36
View File
@@ -0,0 +1,36 @@
export const activeWidgets = new Set<DomWidget>();
export interface DomWidget {
dom?: HTMLElement;
renderContent(
div: HTMLElement,
cachedHtml: string | undefined,
): Promise<void>;
}
export async function reloadAllWidgets() {
for (const widget of [...activeWidgets]) {
if (!widget.dom || !widget.dom.parentNode) {
activeWidgets.delete(widget);
continue;
}
// Create an empty widget DIV node
const newEl = document.createElement("div");
await widget.renderContent(newEl, undefined);
// Replace the old widget with the new one
widget.dom.innerHTML = "";
widget.dom.appendChild(newEl);
}
}
function garbageCollectWidgets() {
for (const widget of activeWidgets) {
if (!widget.dom || !widget.dom.parentNode) {
// console.log("Garbage collecting widget", widget.bodyText);
activeWidgets.delete(widget);
}
}
}
setInterval(garbageCollectWidgets, 5000);