feat: some shit
Some checks failed
Deploy to GitHub Pages / build_site (push) Failing after 6s

This commit is contained in:
2024-12-18 17:26:24 +01:00
parent 9d4d67f086
commit 0c9a9269c4
20 changed files with 361 additions and 197 deletions

View File

@ -1,5 +1,5 @@
import { type NodeRegistry, type NodeDefinition, NodeDefinitionSchema, type AsyncCache } from "@nodes/types";
import { createWasmWrapper, createLogger } from "@nodes/utils";
import { NodeDefinitionSchema, type AsyncCache, type NodeDefinition, type NodeRegistry } from "@nodes/types";
import { createLogger, createWasmWrapper } from "@nodes/utils";
const log = createLogger("node-registry");
log.mute();
@ -49,18 +49,21 @@ export class RemoteNodeRegistry implements NodeRegistry {
private async fetchNodeWasm(nodeId: `${string}/${string}/${string}`) {
const response = await this.fetch(`${this.url}/nodes/${nodeId}.wasm`);
if (!response.ok) {
if (this.cache) {
let value = await this.cache.get(nodeId);
if (value) {
return value;
}
}
const fetchNode = async () => {
const response = await this.fetch(`${this.url}/nodes/${nodeId}.wasm`);
return response.arrayBuffer();
}
const res = await Promise.race([
fetchNode(),
this.cache?.get(nodeId)
]);
if (!res) {
throw new Error(`Failed to load node wasm ${nodeId}`);
}
return response.arrayBuffer();
return res;
}
async load(nodeIds: `${string}/${string}/${string}`[]) {