fix: make node wasm loading work
All checks were successful
Deploy to GitHub Pages / build_site (push) Successful in 2m32s

This commit is contained in:
2025-11-26 12:10:25 +01:00
parent 0894141d3e
commit d3a9b3f056
4 changed files with 22 additions and 12 deletions

View File

@@ -88,7 +88,7 @@ export class GraphManager extends EventEmitter<{
]) as Graph["edges"];
const serialized = {
id: this.graph.id,
settings: this.settings,
settings: $state.snapshot(this.settings),
nodes,
edges,
};

View File

@@ -4,7 +4,7 @@
import type { NodeInput } from "@nodes/types";
import Input from "@nodes/ui";
type Button = { type: "button"; label?: string };
type Button = { type: "button"; callback: () => void; label?: string };
type InputType = NodeInput | Button;
@@ -99,7 +99,7 @@
Array.isArray((node as any).options) &&
typeof internalValue === "number"
) {
value[key] = (node as any).options[internalValue] as any;
value[key] = (node as any)?.options?.[internalValue] as any;
} else {
value[key] = internalValue as any;
}
@@ -110,11 +110,13 @@
<!-- Leaf input -->
<div class="input input-{type[key].type}" class:first-level={depth === 1}>
{#if type[key].type === "button"}
<button onclick={() => type[key].callback()}>
<button onclick={() => "callback" in type[key] && type[key].callback()}>
{type[key].label || key}
</button>
{:else}
{#if type[key]?.label !== false}
<label for={id}>{type[key].label || key}</label>
{/if}
<Input {id} input={type[key]} bind:value={internalValue} />
{/if}
</div>

View File

@@ -89,6 +89,14 @@ export const AppSettingTypes = {
label: "Show Stem Lines",
value: false,
},
logging: {
title: "Logging",
logLevel: {
type: "select",
label: false,
options: ["info","warning","error"]
}
},
stressTest: {
title: "Stress Test",
amount: {

View File

@@ -37,7 +37,7 @@ export class RemoteNodeRegistry implements NodeRegistry {
constructor(
private url: string,
private cache?: AsyncCache<ArrayBuffer>,
) {}
) { }
async fetchUsers() {
return this.fetchJson(`nodes/users.json`);
@@ -56,17 +56,17 @@ export class RemoteNodeRegistry implements NodeRegistry {
}
private async fetchNodeWasm(nodeId: `${string}/${string}/${string}`) {
const cachedNode = this.cache?.get(nodeId);
if(cachedNode){
const cachedNode = await this.cache?.get(nodeId);
if (cachedNode) {
return cachedNode;
}
const node = this.fetchArrayBuffer(`nodes/${nodeId}.wasm`);
if (node) {
return node;
const node = await this.fetchArrayBuffer(`nodes/${nodeId}.wasm`);
if (!node) {
throw new Error(`Failed to load node wasm ${nodeId}`);
}
throw new Error(`Failed to load node wasm ${nodeId}`);
return node;
}
async load(nodeIds: `${string}/${string}/${string}`[]) {