feat: add "*"/any type input for dev page

This commit is contained in:
Max Richter
2026-01-22 15:54:08 +01:00
parent 6f5c5bb46e
commit 841b447ac3
13 changed files with 273 additions and 220 deletions

View File

@@ -25,14 +25,14 @@ const clone = 'structuredClone' in self
? self.structuredClone
: (args: any) => JSON.parse(JSON.stringify(args));
function areSocketsCompatible(
export function areSocketsCompatible(
output: string | undefined,
inputs: string | (string | undefined)[] | undefined
) {
if (Array.isArray(inputs) && output) {
return inputs.includes(output);
return inputs.includes('*') || inputs.includes(output);
}
return inputs === output;
return inputs === output || inputs === '*';
}
function areEdgesEqual(firstEdge: Edge, secondEdge: Edge) {
@@ -268,14 +268,7 @@ export class GraphManager extends EventEmitter<{
private _init(graph: Graph) {
const nodes = new Map(
graph.nodes.map((node) => {
const nodeType = this.registry.getNode(node.type);
const n = node as NodeInstance;
if (nodeType) {
n.state = {
type: nodeType
};
}
return [node.id, n];
return [node.id, node as NodeInstance];
})
);
@@ -300,6 +293,30 @@ export class GraphManager extends EventEmitter<{
this.execute();
}
private async loadAllCollections() {
// Fetch all nodes from all collections of the loaded nodes
const nodeIds = Array.from(new Set([...this.graph.nodes.map((n) => n.type)]));
const allCollections = new Set<`${string}/${string}`>();
for (const id of nodeIds) {
const [user, collection] = id.split('/');
allCollections.add(`${user}/${collection}`);
}
const allCollectionIds = await Promise
.all([...allCollections]
.map(async (collection) =>
remoteRegistry
.fetchCollection(collection)
.then((collection: { nodes: { id: NodeId }[] }) => {
return collection.nodes.map(n => n.id.replace(/\.wasm$/, '') as NodeId);
})
));
const missingNodeIds = [...new Set(allCollectionIds.flat())];
this.registry.load(missingNodeIds);
}
async load(graph: Graph) {
const a = performance.now();
@@ -308,25 +325,16 @@ export class GraphManager extends EventEmitter<{
this.status = 'loading';
this.id = graph.id;
logger.info('loading graph', { nodes: graph.nodes, edges: graph.edges, id: graph.id });
const nodeIds = Array.from(new Set([...graph.nodes.map((n) => n.type)]));
await this.registry.load(nodeIds);
// Fetch all nodes from all collections of the loaded nodes
const allCollections = new Set<`${string}/${string}`>();
for (const id of nodeIds) {
const [user, collection] = id.split('/');
allCollections.add(`${user}/${collection}`);
}
for (const collection of allCollections) {
remoteRegistry
.fetchCollection(collection)
.then((collection: { nodes: { id: NodeId }[] }) => {
const ids = collection.nodes.map((n) => n.id);
return this.registry.load(ids);
});
}
logger.info('loading graph', {
nodes: graph.nodes,
edges: graph.edges,
id: graph.id,
ids: nodeIds
});
await this.registry.load(nodeIds);
logger.info('loaded node types', this.registry.getAllNodes());
@@ -384,7 +392,9 @@ export class GraphManager extends EventEmitter<{
this.loaded = true;
logger.log(`Graph loaded in ${performance.now() - a}ms`);
setTimeout(() => this.execute(), 100);
this.loadAllCollections(); // lazily load all nodes from all collections
}
getAllNodes() {
@@ -491,10 +501,10 @@ export class GraphManager extends EventEmitter<{
const inputs = Object.entries(to.state?.type?.inputs ?? {});
const outputs = from.state?.type?.outputs ?? [];
for (let i = 0; i < inputs.length; i++) {
const [inputName, input] = inputs[0];
const [inputName, input] = inputs[i];
for (let o = 0; o < outputs.length; o++) {
const output = outputs[0];
if (input.type === output) {
const output = outputs[o];
if (input.type === output || input.type === '*') {
return this.createEdge(from, o, to, inputName);
}
}
@@ -724,6 +734,7 @@ export class GraphManager extends EventEmitter<{
getPossibleSockets({ node, index }: Socket): [NodeInstance, string | number][] {
const nodeType = node?.state?.type;
console.log({ node: $state.snapshot(node), index, nodeType });
if (!nodeType) return [];
const sockets: [NodeInstance, string | number][] = [];
@@ -783,6 +794,7 @@ export class GraphManager extends EventEmitter<{
}
}
console.log(`Found ${sockets.length} possible sockets`, sockets);
return sockets;
}

View File

@@ -58,7 +58,9 @@ export class GraphState {
wrapper = $state<HTMLDivElement>(null!);
rect: DOMRect = $derived(
(this.wrapper && this.width && this.height) ? this.wrapper.getBoundingClientRect() : new DOMRect(0, 0, 0, 0)
(this.wrapper && this.width && this.height)
? this.wrapper.getBoundingClientRect()
: new DOMRect(0, 0, 0, 0)
);
camera = $state<OrthographicCamera>(null!);
@@ -168,11 +170,14 @@ export class GraphState {
(node?.state?.y ?? node.position[1]) + 2.5 + 10 * index
];
} else {
const _index = Object.keys(node.state?.type?.inputs || {}).indexOf(index);
return [
const inputs = node.state.type?.inputs || this.graph.registry.getNode(node.type)?.inputs
|| {};
const _index = Object.keys(inputs).indexOf(index);
const pos = [
node?.state?.x ?? node.position[0],
(node?.state?.y ?? node.position[1]) + 10 + 10 * _index
];
] as [number, number];
return pos;
}
}
@@ -248,7 +253,7 @@ export class GraphState {
let { node, index, position } = socket;
// remove existing edge
// if the socket is an input socket -> remove existing edges
if (typeof index === 'string') {
const edges = this.graph.getEdgesToNode(node);
for (const edge of edges) {

View File

@@ -57,7 +57,7 @@
];
const input = Object.entries(newNode?.state?.type?.inputs || {}).find(
(inp) => inp[1].type === socketType,
(inp) => inp[1].type === socketType || inp[1].type === "*",
);
if (input) {

View File

@@ -29,11 +29,11 @@
let {
graph,
registry,
settings = $bindable(),
activeNode = $bindable(),
showGrid = $bindable(true),
snapToGrid = $bindable(true),
showHelp = $bindable(false),
settings = $bindable(),
settingTypes = $bindable(),
onsave,
onresult,

View File

@@ -1,21 +1,21 @@
import { create, type Delta } from "jsondiffpatch";
import type { Graph } from "@nodarium/types";
import { clone } from "./helpers/index.js";
import { createLogger } from "@nodarium/utils";
import type { Graph } from '@nodarium/types';
import { createLogger } from '@nodarium/utils';
import { create, type Delta } from 'jsondiffpatch';
import { clone } from './helpers/index.js';
const diff = create({
objectHash: function (obj, index) {
if (obj === null) return obj;
if ("id" in obj) return obj.id as string;
if ("_id" in obj) return obj._id as string;
if ('id' in obj) return obj.id as string;
if ('_id' in obj) return obj._id as string;
if (Array.isArray(obj)) {
return obj.join("-");
return obj.join('-');
}
return "$$index:" + index;
},
return '$$index:' + index;
}
});
const log = createLogger("history");
const log = createLogger('history');
log.mute();
export class HistoryManager {
@@ -26,7 +26,7 @@ export class HistoryManager {
private opts = {
debounce: 400,
maxHistory: 100,
maxHistory: 100
};
constructor({ maxHistory = 100, debounce = 100 } = {}) {
@@ -40,12 +40,12 @@ export class HistoryManager {
if (!this.state) {
this.state = clone(state);
this.initialState = this.state;
log.log("initial state saved");
log.log('initial state saved');
} else {
const newState = state;
const delta = diff.diff(this.state, newState);
if (delta) {
log.log("saving state");
log.log('saving state');
// Add the delta to history
if (this.index < this.history.length - 1) {
// Clear the history after the current index if new changes are made
@@ -61,7 +61,7 @@ export class HistoryManager {
}
this.state = newState;
} else {
log.log("no changes");
log.log('no changes');
}
}
}
@@ -75,7 +75,7 @@ export class HistoryManager {
undo() {
if (this.index === -1 && this.initialState) {
log.log("reached start, loading initial state");
log.log('reached start, loading initial state');
return clone(this.initialState);
} else {
const delta = this.history[this.index];
@@ -95,7 +95,7 @@ export class HistoryManager {
this.state = nextState;
return clone(nextState);
} else {
log.log("reached end");
log.log('reached end');
}
}
}

View File

@@ -20,7 +20,7 @@ export async function getNodeWasm(id: `${string}/${string}/${string}`) {
const wasmBytes = await getWasm(id);
if (!wasmBytes) return null;
const wrapper = createWasmWrapper(wasmBytes);
const wrapper = createWasmWrapper(wasmBytes.buffer);
return wrapper;
}

View File

@@ -4,47 +4,47 @@ import type {
NodeInput,
NodeRegistry,
RuntimeExecutor,
SyncCache,
} from "@nodarium/types";
SyncCache
} from '@nodarium/types';
import {
concatEncodedArrays,
createLogger,
encodeFloat,
fastHashArrayBuffer,
type PerformanceStore,
} from "@nodarium/utils";
import type { RuntimeNode } from "./types";
type PerformanceStore
} from '@nodarium/utils';
import type { RuntimeNode } from './types';
const log = createLogger("runtime-executor");
const log = createLogger('runtime-executor');
log.mute();
function getValue(input: NodeInput, value?: unknown) {
if (value === undefined && "value" in input) {
if (value === undefined && 'value' in input) {
value = input.value;
}
if (input.type === "float") {
if (input.type === 'float') {
return encodeFloat(value as number);
}
if (Array.isArray(value)) {
if (input.type === "vec3") {
if (input.type === 'vec3') {
return [
0,
value.length + 1,
...value.map((v) => encodeFloat(v)),
1,
1,
1
] as number[];
}
return [0, value.length + 1, ...value, 1, 1] as number[];
}
if (typeof value === "boolean") {
if (typeof value === 'boolean') {
return value ? 1 : 0;
}
if (typeof value === "number") {
if (typeof value === 'number') {
return value;
}
@@ -52,6 +52,7 @@ function getValue(input: NodeInput, value?: unknown) {
return value;
}
console.error({ input, value });
throw new Error(`Unknown input type ${input.type}`);
}
@@ -62,16 +63,18 @@ export class MemoryRuntimeExecutor implements RuntimeExecutor {
perf?: PerformanceStore;
private results: Record<string, Int32Array> = {};
constructor(
private registry: NodeRegistry,
public cache?: SyncCache<Int32Array>,
public cache?: SyncCache<Int32Array>
) {
this.cache = undefined;
}
private async getNodeDefinitions(graph: Graph) {
if (this.registry.status !== "ready") {
throw new Error("Node registry is not ready");
if (this.registry.status !== 'ready') {
throw new Error('Node registry is not ready');
}
await this.registry.load(graph.nodes.map((node) => node.type));
@@ -98,21 +101,18 @@ export class MemoryRuntimeExecutor implements RuntimeExecutor {
depth: 0,
children: [],
parents: [],
inputNodes: {},
}
return n
})
inputNodes: {}
};
return n;
});
const outputNode = graphNodes.find((node) =>
node.type.endsWith("/output"),
);
const outputNode = graphNodes.find((node) => node.type.endsWith('/output'));
if (!outputNode) {
throw new Error("No output node found");
throw new Error('No output node found');
}
const nodeMap = new Map(
graphNodes.map((node) => [node.id, node]),
graphNodes.map((node) => [node.id, node])
);
// loop through all edges and assign the parent and child nodes to each node
@@ -146,7 +146,7 @@ export class MemoryRuntimeExecutor implements RuntimeExecutor {
}
async execute(graph: Graph, settings: Record<string, unknown>) {
this.perf?.addPoint("runtime");
this.perf?.addPoint('runtime');
let a = performance.now();
@@ -154,7 +154,7 @@ export class MemoryRuntimeExecutor implements RuntimeExecutor {
const [outputNode, nodes] = await this.addMetaData(graph);
let b = performance.now();
this.perf?.addPoint("collect-metadata", b - a);
this.perf?.addPoint('collect-metadata', b - a);
/*
* Here we sort the nodes into buckets, which we then execute one by one
@@ -169,13 +169,13 @@ export class MemoryRuntimeExecutor implements RuntimeExecutor {
// we execute the nodes from the bottom up
const sortedNodes = nodes.sort(
(a, b) => (b.state?.depth || 0) - (a.state?.depth || 0),
(a, b) => (b.state?.depth || 0) - (a.state?.depth || 0)
);
// here we store the intermediate results of the nodes
const results: Record<string, Int32Array> = {};
this.results = {};
if (settings["randomSeed"]) {
if (settings['randomSeed']) {
this.seed = Math.floor(Math.random() * 100000000);
}
@@ -192,7 +192,7 @@ export class MemoryRuntimeExecutor implements RuntimeExecutor {
// Collect the inputs for the node
const inputs = Object.entries(node_type.inputs || {}).map(
([key, input]) => {
if (input.type === "seed") {
if (input.type === 'seed') {
return this.seed;
}
@@ -204,12 +204,12 @@ export class MemoryRuntimeExecutor implements RuntimeExecutor {
// check if the input is connected to another node
const inputNode = node.state.inputNodes[key];
if (inputNode) {
if (results[inputNode.id] === undefined) {
if (this.results[inputNode.id] === undefined) {
throw new Error(
`Node ${node.type} is missing input from node ${inputNode.type}`,
`Node ${node.type} is missing input from node ${inputNode.type}`
);
}
return results[inputNode.id];
return this.results[inputNode.id];
}
// If the value is stored in the node itself, we use that value
@@ -218,45 +218,45 @@ export class MemoryRuntimeExecutor implements RuntimeExecutor {
}
return getValue(input);
},
}
);
b = performance.now();
this.perf?.addPoint("collected-inputs", b - a);
this.perf?.addPoint('collected-inputs', b - a);
try {
a = performance.now();
const encoded_inputs = concatEncodedArrays(inputs);
b = performance.now();
this.perf?.addPoint("encoded-inputs", b - a);
this.perf?.addPoint('encoded-inputs', b - a);
a = performance.now();
let inputHash = `node-${node.id}-${fastHashArrayBuffer(encoded_inputs)}`;
b = performance.now();
this.perf?.addPoint("hash-inputs", b - a);
this.perf?.addPoint('hash-inputs', b - a);
let cachedValue = this.cache?.get(inputHash);
if (cachedValue !== undefined) {
log.log(`Using cached value for ${node_type.id || node.id}`);
this.perf?.addPoint("cache-hit", 1);
results[node.id] = cachedValue as Int32Array;
this.perf?.addPoint('cache-hit', 1);
this.results[node.id] = cachedValue as Int32Array;
continue;
}
this.perf?.addPoint("cache-hit", 0);
this.perf?.addPoint('cache-hit', 0);
log.group(`executing ${node_type.id}-${node.id}`);
log.log(`Inputs:`, inputs);
a = performance.now();
results[node.id] = node_type.execute(encoded_inputs);
log.log("Executed", node.type, node.id)
this.results[node.id] = node_type.execute(encoded_inputs);
log.log('Executed', node.type, node.id);
b = performance.now();
if (this.cache && node.id !== outputNode.id) {
this.cache.set(inputHash, results[node.id]);
this.cache.set(inputHash, this.results[node.id]);
}
this.perf?.addPoint("node/" + node_type.id, b - a);
log.log("Result:", results[node.id]);
this.perf?.addPoint('node/' + node_type.id, b - a);
log.log('Result:', this.results[node.id]);
log.groupEnd();
} catch (e) {
log.groupEnd();
@@ -265,17 +265,21 @@ export class MemoryRuntimeExecutor implements RuntimeExecutor {
}
// return the result of the parent of the output node
const res = results[outputNode.id];
const res = this.results[outputNode.id];
if (this.cache) {
this.cache.size = sortedNodes.length * 2;
}
this.perf?.endPoint("runtime");
this.perf?.endPoint('runtime');
return res as unknown as Int32Array;
}
getIntermediateResults() {
return this.results;
}
getPerformanceData() {
return this.perf?.get();
}

View File

@@ -90,11 +90,6 @@
let graphSettingTypes = $state({
randomSeed: { type: "boolean", value: false },
});
$effect(() => {
if (graphSettings && graphSettingTypes) {
manager?.setSettings($state.snapshot(graphSettings));
}
});
async function update(
g: Graph,

View File

@@ -3,6 +3,6 @@
const { children } = $props<{ children?: Snippet }>();
</script>
<main class="w-screen overflow-x-hidden">
<main class="w-screen h-screen overflow-x-hidden">
{@render children()}
</main>

View File

@@ -1,88 +1,73 @@
<script lang="ts">
import NodeHTML from "$lib/graph-interface/node/NodeHTML.svelte";
import { localState } from "$lib/helpers/localState.svelte";
import * as templates from "$lib/graph-templates";
import Panel from "$lib/sidebar/Panel.svelte";
import Sidebar from "$lib/sidebar/Sidebar.svelte";
import { IndexDBCache, RemoteNodeRegistry } from "@nodarium/registry";
import { type NodeId, type NodeInstance } from "@nodarium/types";
import Code from "./Code.svelte";
import GraphInterface from "$lib/graph-interface";
import { RemoteNodeRegistry } from "@nodarium/registry";
import { type Graph } from "@nodarium/types";
import Grid from "$lib/grid";
import {
concatEncodedArrays,
createWasmWrapper,
encodeNestedArray,
} from "@nodarium/utils";
import { MemoryRuntimeExecutor } from "$lib/runtime";
import devPlant from "./dev-graph.json";
import { decodeNestedArray } from "@nodarium/utils";
const registryCache = new IndexDBCache("node-registry");
const nodeRegistry = new RemoteNodeRegistry("", registryCache);
let result = $state<Int32Array>();
let activeNode = localState<NodeId | undefined>(
"node.dev.activeNode",
undefined,
);
let nodeWasm = $state<ArrayBuffer>();
let nodeInstance = $state<NodeInstance>();
let nodeWasmWrapper = $state<ReturnType<typeof createWasmWrapper>>();
async function fetchNodeData(nodeId?: NodeId) {
nodeWasm = undefined;
nodeInstance = undefined;
if (!nodeId) return;
const data = await nodeRegistry.fetchNodeDefinition(nodeId);
nodeWasm = await nodeRegistry.fetchArrayBuffer("nodes/" + nodeId + ".wasm");
nodeInstance = {
id: 0,
type: nodeId,
position: [0, 0] as [number, number],
props: {},
state: {
type: data,
const nodeRegistry = new RemoteNodeRegistry("");
nodeRegistry.overwriteNode("max/plantarium/output", {
id: "max/plantarium/output",
meta: {
title: "Debug View",
description: "",
},
inputs: {
out: {
type: "*",
},
};
nodeWasmWrapper = createWasmWrapper(nodeWasm);
},
execute(input: Int32Array) {
result = input;
return input;
},
});
const runtimeExecutor = new MemoryRuntimeExecutor(nodeRegistry);
let graph = $state(
localStorage.getItem("nodes.dev.graph")
? JSON.parse(localStorage.getItem("nodes.dev.graph")!)
: devPlant,
);
function handleSave(graph: Graph) {
localStorage.setItem("nodes.dev.graph", JSON.stringify(graph));
}
$effect(() => {
fetchNodeData(activeNode.value);
let graphSettings = $state<Record<string, any>>({});
let graphSettingTypes = $state({
randomSeed: { type: "boolean", value: false },
});
$effect(() => {
if (nodeInstance?.props && nodeWasmWrapper) {
const keys = Object.keys(nodeInstance.state.type?.inputs || {});
let ins = Object.values(nodeInstance.props) as number[];
if (keys[0] === "plant") {
ins = [[0, 0, 0, 0, 0, 0, 0, 0], ...ins];
}
const inputs = concatEncodedArrays(encodeNestedArray(ins));
nodeWasmWrapper?.execute(inputs);
}
});
async function handleResult(res: unknown) {
const result = await runtimeExecutor.execute(graph, graphSettings);
console.log({ res, result });
}
</script>
<div class="node-wrapper absolute bottom-8 left-8">
{#if nodeInstance}
<NodeHTML inView position="relative" z={5} bind:node={nodeInstance} />
{/if}
</div>
<Grid.Row>
<Grid.Cell>
<pre>
<code>
{JSON.stringify(nodeInstance?.props)}
</code>
</pre>
{#if result}
<pre><code>{JSON.stringify(decodeNestedArray(result))}</code></pre>
{/if}
</Grid.Cell>
<Grid.Cell>
<div class="h-screen w-[80vw] overflow-y-auto">
{#if nodeWasm}
<Code wasm={nodeWasm} />
{/if}
</div>
<GraphInterface
{graph}
registry={nodeRegistry}
bind:settings={graphSettings}
bind:settingTypes={graphSettingTypes}
onsave={(g) => handleSave(g)}
onresult={(result) => handleResult(result)}
/>
</Grid.Cell>
</Grid.Row>
@@ -92,22 +77,7 @@
classes="text-green-400"
title="Node Store"
icon="i-[tabler--database]"
>
<div class="p-4 flex flex-col gap-2">
{#await nodeRegistry.fetchCollection("max/plantarium")}
<p>Loading Nodes...</p>
{:then result}
{#each result.nodes as n}
<button
class="cursor-pointer p-2 bg-layer-1 {activeNode.value === n.id
? 'outline outline-offset-1'
: ''}"
onclick={() => (activeNode.value = n.id)}>{n.id}</button
>
{/each}
{/await}
</div>
</Panel>
></Panel>
</Sidebar>
<style>

View File

@@ -0,0 +1,53 @@
{
"settings": {
"resolution.circle": 26,
"resolution.curve": 39
},
"nodes": [
{
"id": 9,
"position": [
220,
80
],
"type": "max/plantarium/output",
"props": {}
},
{
"id": 10,
"position": [
195,
80
],
"type": "max/plantarium/math",
"props": {
"op_type": 0,
"a": 2,
"b": 2
}
},
{
"id": 11,
"position": [
170,
80
],
"type": "max/plantarium/float",
"props": {
"value": 0.1
}
},
{
"id": 12,
"position": [
170,
100
],
"type": "max/plantarium/float",
"props": {
"value": 0.1
}
}
],
"edges": []
}

View File

@@ -2,6 +2,7 @@ import {
type AsyncCache,
type NodeDefinition,
NodeDefinitionSchema,
type NodeId,
type NodeRegistry
} from '@nodarium/types';
import { createLogger, createWasmWrapper } from '@nodarium/utils';
@@ -153,6 +154,13 @@ export class RemoteNodeRegistry implements NodeRegistry {
}
getAllNodes() {
return [...this.nodes.values()];
const allNodes = [...this.nodes.values()];
log.info('getting all nodes', allNodes);
return allNodes;
}
async overwriteNode(nodeId: NodeId, node: NodeDefinition) {
log.info('Overwritten node', { nodeId, node });
this.nodes.set(nodeId, node);
}
}

View File

@@ -1,4 +1,4 @@
import { z } from "zod";
import { z } from 'zod';
const DefaultOptionsSchema = z.object({
internal: z.boolean().optional(),
@@ -9,72 +9,77 @@ const DefaultOptionsSchema = z.object({
accepts: z
.array(
z.union([
z.literal("float"),
z.literal("integer"),
z.literal("boolean"),
z.literal("select"),
z.literal("seed"),
z.literal("vec3"),
z.literal("geometry"),
z.literal("path"),
]),
z.literal('float'),
z.literal('integer'),
z.literal('boolean'),
z.literal('select'),
z.literal('seed'),
z.literal('vec3'),
z.literal('geometry'),
z.literal('path')
])
)
.optional(),
hidden: z.boolean().optional(),
hidden: z.boolean().optional()
});
export const NodeInputFloatSchema = z.object({
...DefaultOptionsSchema.shape,
type: z.literal("float"),
element: z.literal("slider").optional(),
type: z.literal('float'),
element: z.literal('slider').optional(),
value: z.number().optional(),
min: z.number().optional(),
max: z.number().optional(),
step: z.number().optional(),
step: z.number().optional()
});
export const NodeInputIntegerSchema = z.object({
...DefaultOptionsSchema.shape,
type: z.literal("integer"),
element: z.literal("slider").optional(),
type: z.literal('integer'),
element: z.literal('slider').optional(),
value: z.number().optional(),
min: z.number().optional(),
max: z.number().optional(),
max: z.number().optional()
});
export const NodeInputBooleanSchema = z.object({
...DefaultOptionsSchema.shape,
type: z.literal("boolean"),
value: z.boolean().optional(),
type: z.literal('boolean'),
value: z.boolean().optional()
});
export const NodeInputSelectSchema = z.object({
...DefaultOptionsSchema.shape,
type: z.literal("select"),
type: z.literal('select'),
options: z.array(z.string()).optional(),
value: z.string().optional(),
value: z.string().optional()
});
export const NodeInputSeedSchema = z.object({
...DefaultOptionsSchema.shape,
type: z.literal("seed"),
value: z.number().optional(),
type: z.literal('seed'),
value: z.number().optional()
});
export const NodeInputVec3Schema = z.object({
...DefaultOptionsSchema.shape,
type: z.literal("vec3"),
value: z.array(z.number()).optional(),
type: z.literal('vec3'),
value: z.array(z.number()).optional()
});
export const NodeInputGeometrySchema = z.object({
...DefaultOptionsSchema.shape,
type: z.literal("geometry"),
type: z.literal('geometry')
});
export const NodeInputPathSchema = z.object({
...DefaultOptionsSchema.shape,
type: z.literal("path"),
type: z.literal('path')
});
export const NodeInputAnySchema = z.object({
...DefaultOptionsSchema.shape,
type: z.literal('*')
});
export const NodeInputSchema = z.union([
@@ -87,6 +92,7 @@ export const NodeInputSchema = z.union([
NodeInputVec3Schema,
NodeInputGeometrySchema,
NodeInputPathSchema,
NodeInputAnySchema
]);
export type NodeInput = z.infer<typeof NodeInputSchema>;