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"]; ]) as Graph["edges"];
const serialized = { const serialized = {
id: this.graph.id, id: this.graph.id,
settings: this.settings, settings: $state.snapshot(this.settings),
nodes, nodes,
edges, edges,
}; };

View File

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

View File

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

View File

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