feat: bunch of small fixes
This commit is contained in:
@@ -38,7 +38,7 @@ export function serializeNode(node: SerializedNode | NodeInstance): SerializedNo
|
||||
id: node.id,
|
||||
position: [...node.position],
|
||||
type: node.type,
|
||||
props: node.props
|
||||
props: node.props ? JSON.parse(JSON.stringify(node.props)) : undefined
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -141,6 +141,7 @@ export class RemoteNodeRegistry implements NodeRegistry {
|
||||
wrapper = createWasmWrapper(wasmBuffer);
|
||||
} catch (error) {
|
||||
console.error(`Failed to create node wrapper for node: ${id}`, error);
|
||||
throw error;
|
||||
}
|
||||
|
||||
const rawDefinition = wrapper.get_definition();
|
||||
|
||||
@@ -19,7 +19,7 @@ export class ProjectManager {
|
||||
}
|
||||
|
||||
async saveGraph(g: Graph) {
|
||||
db.saveGraph(g);
|
||||
await db.saveGraph(g);
|
||||
}
|
||||
|
||||
private async init() {
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
import type { Graph, RuntimeExecutor } from '@nodarium/types';
|
||||
|
||||
export class RemoteRuntimeExecutor implements RuntimeExecutor {
|
||||
constructor(private url: string) {}
|
||||
|
||||
async execute(graph: Graph, settings: Record<string, unknown>): Promise<Int32Array> {
|
||||
const res = await fetch(this.url, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ graph, settings })
|
||||
});
|
||||
|
||||
if (!res.ok) {
|
||||
throw new Error(`Failed to execute graph`);
|
||||
}
|
||||
|
||||
return new Int32Array(await res.arrayBuffer());
|
||||
}
|
||||
}
|
||||
@@ -173,9 +173,7 @@ export class MemoryRuntimeExecutor implements RuntimeExecutor {
|
||||
constructor(
|
||||
private registry: NodeRegistry,
|
||||
public cache?: SyncCache<Int32Array>
|
||||
) {
|
||||
this.cache = undefined;
|
||||
}
|
||||
) {}
|
||||
|
||||
private async getNodeDefinitions(graph: Graph) {
|
||||
if (this.registry.status !== 'ready') {
|
||||
@@ -314,6 +312,7 @@ export class MemoryRuntimeExecutor implements RuntimeExecutor {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
a = performance.now();
|
||||
|
||||
// Collect the inputs for the node
|
||||
@@ -399,7 +398,7 @@ export class MemoryRuntimeExecutor implements RuntimeExecutor {
|
||||
log.groupEnd();
|
||||
} catch (e) {
|
||||
log.groupEnd();
|
||||
log.error(`Error executing node ${node_type.id || node.id}`, e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ import { debugNode } from '$lib/node-registry/debugNode';
|
||||
import { IndexDBCache, RemoteNodeRegistry } from '$lib/node-registry/index';
|
||||
import type { Graph } from '@nodarium/types';
|
||||
import { createPerformanceStore } from '@nodarium/utils';
|
||||
import * as Comlink from 'comlink';
|
||||
import { MemoryRuntimeExecutor } from './runtime-executor';
|
||||
import { MemoryRuntimeCache } from './runtime-executor-cache';
|
||||
|
||||
@@ -38,6 +39,9 @@ export async function executeGraph(
|
||||
performanceStore.startRun();
|
||||
const res = await executor.execute(graph, settings);
|
||||
performanceStore.stopRun();
|
||||
if (res?.buffer) {
|
||||
return Comlink.transfer(res, [res.buffer]);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user