refactor: merge get_outputs macros into define_node and include_definition

This commit is contained in:
2024-04-16 13:58:10 +02:00
parent 097b99ef55
commit 8f594aebe3
19 changed files with 130 additions and 149 deletions

View File

@ -1,7 +1,5 @@
import { createWasmWrapper } from "@nodes/utils"
export async function getNodeWasm(id: `${string}/${string}/${string}`) {
const wasmResponse = await fetch(`/n/${id}/wasm`);
@ -23,14 +21,11 @@ export async function getNode(id: `${string}/${string}/${string}`) {
const wrapper = await getNodeWasm(id);
const outputs = wrapper?.get_outputs?.() || [];
const rawInputs = wrapper.get_inputs();
const { inputs, outputs } = wrapper?.get_definition?.();
try {
const inputTypes = JSON.parse(rawInputs);
return { id, outputs, inputs: inputTypes }
return { id, inputs, outputs }
} catch (e) {
console.log(rawInputs);
console.log("Failed to parse input types for node", { id, rawInputs });
console.log("Failed to parse input types for node", { id });
}