diff --git a/app/src/lib/graph-interface/graph/Wrapper.svelte b/app/src/lib/graph-interface/graph/Wrapper.svelte index b272b65..60d18be 100644 --- a/app/src/lib/graph-interface/graph/Wrapper.svelte +++ b/app/src/lib/graph-interface/graph/Wrapper.svelte @@ -27,6 +27,8 @@ export let showGrid = false; export let snapToGrid = false; + export let settingTypes = {}; + const updateSettings = debounce((s) => { manager.setSettings(s); }, 200); @@ -36,7 +38,8 @@ } manager.on("settings", (settings) => { - dispatch("settings", settings); + settingTypes = settings.types; + $settings = settings.values; }); manager.on("result", (result) => { diff --git a/app/src/lib/node-registry-client.ts b/app/src/lib/node-registry-client.ts index 529b905..8fc35e0 100644 --- a/app/src/lib/node-registry-client.ts +++ b/app/src/lib/node-registry-client.ts @@ -3,6 +3,8 @@ import { createWasmWrapper } from "@nodes/utils"; import { createLogger } from "./helpers"; const log = createLogger("node-registry"); +log.mute(); + export class RemoteNodeRegistry implements NodeRegistry { status: "loading" | "ready" | "error" = "loading"; @@ -10,9 +12,6 @@ export class RemoteNodeRegistry implements NodeRegistry { constructor(private url: string) { } - async loadNode(id: `${string}/${string}/${string}`) { - } - async fetchUsers() { const response = await fetch(`${this.url}/nodes/users.json`); if (!response.ok) { @@ -58,6 +57,10 @@ export class RemoteNodeRegistry implements NodeRegistry { const nodes = await Promise.all(nodeIds.map(async id => { + if (this.nodes.has(id)) { + return this.nodes.get(id); + } + const wasmResponse = await this.fetchNode(id); const wrapper = createWasmWrapper(wasmResponse); diff --git a/app/src/lib/node-store/NodeStore.svelte b/app/src/lib/node-store/NodeStore.svelte index c448eb6..6190726 100644 --- a/app/src/lib/node-store/NodeStore.svelte +++ b/app/src/lib/node-store/NodeStore.svelte @@ -4,7 +4,7 @@ import BreadCrumbs from "./BreadCrumbs.svelte"; import DraggableNode from "./DraggableNode.svelte"; - export let nodeRegistry: RemoteNodeRegistry; + export let registry: RemoteNodeRegistry; const activeId = localStore< `${string}` | `${string}/${string}` | `${string}/${string}/${string}` @@ -20,7 +20,7 @@

Users

- {#await nodeRegistry.fetchUsers()} + {#await registry.fetchUsers()}
Loading...
{:then users} {#each users as user} @@ -34,7 +34,7 @@
{error.message}
{/await} {:else if !activeCollection} - {#await nodeRegistry.fetchUser(activeUser)} + {#await registry.fetchUser(activeUser)}
Loading...
{:then user}
@@ -68,11 +68,11 @@ >

Nodes

- {#await nodeRegistry.fetchCollection(`${activeUser}/${activeCollection}`)} + {#await registry.fetchCollection(`${activeUser}/${activeCollection}`)}
Loading...
{:then collection} {#each collection.nodes as node} - {#await nodeRegistry.fetchNodeDefinition(node.id)} + {#await registry.fetchNodeDefinition(node.id)}
Loading...
{:then node} diff --git a/app/src/lib/performance/PerformanceViewer.svelte b/app/src/lib/performance/PerformanceViewer.svelte index 9810b90..23f72ed 100644 --- a/app/src/lib/performance/PerformanceViewer.svelte +++ b/app/src/lib/performance/PerformanceViewer.svelte @@ -1,14 +1,14 @@ -{#if $store.runs.length !== 0} +{#if data.runs.length !== 0} {#each getPerformanceData() as [key, value]}

{key}: {Math.floor(value * 100) / 100}ms

{/each} diff --git a/app/src/lib/performance/index.ts b/app/src/lib/performance/index.ts index 694e160..761dcdd 100644 --- a/app/src/lib/performance/index.ts +++ b/app/src/lib/performance/index.ts @@ -1,6 +1,6 @@ import { readable, type Readable } from "svelte/store"; -type PerformanceData = { +export type PerformanceData = { total: Record; runs: Record[]; } @@ -8,6 +8,7 @@ export interface PerformanceStore extends Readable { startRun(): void; stopRun(): void; addPoint(name: string, value?: number): void; + get: () => PerformanceData; } export function createPerformanceStore(): PerformanceStore { @@ -41,7 +42,7 @@ export function createPerformanceStore(): PerformanceStore { data.runs.push(currentRun); currentRun = undefined; - set(data); + if (set) set(data); } } @@ -51,11 +52,16 @@ export function createPerformanceStore(): PerformanceStore { currentRun[name].push(value); } + function get() { + return data; + } + return { subscribe, startRun, stopRun, addPoint, + get } } diff --git a/app/src/lib/result-viewer/Viewer.svelte b/app/src/lib/result-viewer/Viewer.svelte index a59034c..d420f3f 100644 --- a/app/src/lib/result-viewer/Viewer.svelte +++ b/app/src/lib/result-viewer/Viewer.svelte @@ -1,7 +1,6 @@ + +{#if $visible} +
+ {#if title} +
+

{title}

+
+ {/if} + +
+{/if} + + diff --git a/app/src/lib/settings/Settings.svelte b/app/src/lib/settings/Settings.svelte index aa2ddc6..b8dbae7 100644 --- a/app/src/lib/settings/Settings.svelte +++ b/app/src/lib/settings/Settings.svelte @@ -1,33 +1,34 @@
@@ -81,25 +60,7 @@ {/each}
- {#if $activePanel && panels[$activePanel] && panels[$activePanel].hidden !== true} -

{panels[$activePanel].id}

- {#key $activePanel} - {#if panels[$activePanel]?.component} - - {:else} -
- -
- {/if} - {/key} - {/if} +
diff --git a/app/src/lib/settings/app-settings.ts b/app/src/lib/settings/app-settings.ts index 97b23f8..3e9b489 100644 --- a/app/src/lib/settings/app-settings.ts +++ b/app/src/lib/settings/app-settings.ts @@ -10,6 +10,7 @@ export const AppSettings = localStore("node-settings", { showVertices: false, centerCamera: true, showStemLines: false, + amount: 5 }); const themes = ["dark", "light", "catppuccin", "solarized", "high-contrast", "nord", "dracula"]; diff --git a/app/src/lib/settings/panels/ActiveNode.svelte b/app/src/lib/settings/panels/ActiveNodeSettings.svelte similarity index 95% rename from app/src/lib/settings/panels/ActiveNode.svelte rename to app/src/lib/settings/panels/ActiveNodeSettings.svelte index 531fb97..cef8d16 100644 --- a/app/src/lib/settings/panels/ActiveNode.svelte +++ b/app/src/lib/settings/panels/ActiveNodeSettings.svelte @@ -1,6 +1,6 @@ + +{#key settings} + +{/key} diff --git a/app/src/lib/settings/panels/Keymap.svelte b/app/src/lib/settings/panels/Keymap.svelte index 8857f33..32eb0df 100644 --- a/app/src/lib/settings/panels/Keymap.svelte +++ b/app/src/lib/settings/panels/Keymap.svelte @@ -3,7 +3,7 @@ import { ShortCut } from "@nodes/ui"; export let keymap: ReturnType; - const keys = keymap.keys; + const keys = keymap?.keys;
@@ -13,7 +13,12 @@ {#each $keys as key} {#if key.description}
- +

{key.description}

{/if} diff --git a/app/src/lib/settings/NestedSettings.svelte b/app/src/lib/settings/panels/NestedSettings.svelte similarity index 80% rename from app/src/lib/settings/NestedSettings.svelte rename to app/src/lib/settings/panels/NestedSettings.svelte index b94a8b3..93fc8c1 100644 --- a/app/src/lib/settings/NestedSettings.svelte +++ b/app/src/lib/settings/panels/NestedSettings.svelte @@ -4,8 +4,12 @@ import Input from "@nodes/ui"; import type { Writable } from "svelte/store"; + type Button = { type: "button"; label?: string; callback: () => void }; + + type Input = NodeInput | Button; + interface Nested { - [key: string]: Nested | NodeInput; + [key: string]: (Nested & { __title?: string }) | Input; } export let id: string; @@ -20,22 +24,23 @@ export let depth = 0; const keys = Object.keys(settings).filter((key) => key !== "__title"); - function isNodeInput(v: NodeInput | Nested): v is NodeInput { + function isNodeInput(v: Input | Nested): v is Input { return v && "type" in v; } + console.log({ settings, store }); -{#if store} +{#if $store} {#each keys as key} {@const value = settings[key]}
- {#if isNodeInput(value)} + {#if value !== undefined && isNodeInput(value)}
- {#if settings[key].type === "button"} - value?.callback?.()} + >{value.label || key} - {:else if "setting" in value} + {:else if "setting" in value && value.setting !== undefined} {:else} diff --git a/app/src/lib/worker-runtime-executor-backend.ts b/app/src/lib/worker-runtime-executor-backend.ts new file mode 100644 index 0000000..3074896 --- /dev/null +++ b/app/src/lib/worker-runtime-executor-backend.ts @@ -0,0 +1,19 @@ +import { MemoryRuntimeExecutor } from "./runtime-executor"; +import { RemoteNodeRegistry } from "./node-registry-client"; +import type { Graph } from "@nodes/types"; +import { createPerformanceStore } from "./performance"; + +const nodeRegistry = new RemoteNodeRegistry(""); +const executor = new MemoryRuntimeExecutor(nodeRegistry); + +const performanceStore = createPerformanceStore(); +executor.perf = performanceStore; + +export async function executeGraph(graph: Graph, settings: Record): Promise { + await nodeRegistry.load(graph.nodes.map((n) => n.type)); + return executor.execute(graph, settings); +} + +export function getPerformanceData() { + return performanceStore.get(); +} diff --git a/app/src/lib/worker-runtime-executor.ts b/app/src/lib/worker-runtime-executor.ts new file mode 100644 index 0000000..2b273b6 --- /dev/null +++ b/app/src/lib/worker-runtime-executor.ts @@ -0,0 +1,16 @@ +/// + +import type { Graph, RuntimeExecutor } from "@nodes/types"; + +export class WorkerRuntimeExecutor implements RuntimeExecutor { + private worker = new ComlinkWorker(new URL("./worker-runtime-executor-backend.ts", import.meta.url)); + constructor() { + } + async execute(graph: Graph, settings: Record) { + return this.worker.executeGraph(graph, settings); + } + async getPerformanceData() { + return this.worker.getPerformanceData(); + } +} + diff --git a/app/src/routes/+page.svelte b/app/src/routes/+page.svelte index c0b490f..b82c3f2 100644 --- a/app/src/routes/+page.svelte +++ b/app/src/routes/+page.svelte @@ -1,17 +1,14 @@
- + {#key graph} - + + + + + + + + + {#if performanceData} + + {/if} + + + {#if keymap} + + {/if} + + + {#if Object.keys(graphSettingTypes).length > 0} + + {/if} + + + + + {/key} diff --git a/nodes/max/plantarium/noise/src/input.json b/nodes/max/plantarium/noise/src/input.json index 66e740e..bfb88d4 100644 --- a/nodes/max/plantarium/noise/src/input.json +++ b/nodes/max/plantarium/noise/src/input.json @@ -10,18 +10,18 @@ "scale": { "type": "float", "min": 0.1, - "max": 100 + "max": 10 }, "strength": { "type": "float", "min": 0.1, - "max": 100 + "max": 10 }, "fixBottom": { "type": "float", "label": "Fixate bottom of plant", "hidden": true, - "value": 0, + "value": 1, "min": 0, "max": 1 }, diff --git a/packages/types/src/components.ts b/packages/types/src/components.ts index 5a5e203..df8c0d5 100644 --- a/packages/types/src/components.ts +++ b/packages/types/src/components.ts @@ -33,7 +33,7 @@ export interface RuntimeExecutor { * @param graph - The graph to execute * @returns The result of the execution */ - execute: (graph: Graph, settings: Record) => unknown; + execute: (graph: Graph, settings: Record) => Int32Array; } export interface RuntimeCache {