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