feat: add flat_tree allgorithm

This commit is contained in:
2024-04-10 21:57:03 +02:00
parent 2ed1501747
commit e2940183f1
9 changed files with 179 additions and 9 deletions

View File

@@ -41,6 +41,8 @@ const nodeTypes: NodeType[] = [
const log = createLogger("node-registry");
export class RemoteNodeRegistry implements NodeRegistry {
status: "loading" | "ready" | "error" = "loading";
private nodes: Map<string, NodeType> = new Map();
constructor(private url: string) { }
@@ -55,6 +57,7 @@ export class RemoteNodeRegistry implements NodeRegistry {
const wasmResponse = await fetch(`${nodeUrl}/wasm`);
const wrapperReponse = await fetch(`${nodeUrl}/wrapper`);
if (!wrapperReponse.ok) {
this.status = "error";
throw new Error(`Failed to load node ${id}`);
}
@@ -68,6 +71,7 @@ wasm = val;`);
wasmWrapper.__wbg_set_wasm(instance.exports);
if (!response.ok) {
this.status = "error";
throw new Error(`Failed to load node ${id}`);
}
const node = await response.json();
@@ -78,6 +82,7 @@ wasm = val;`);
const duration = performance.now() - a;
log.log("loaded nodes in", duration, "ms");
this.status = "ready";
}
getNode(id: string) {