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

@@ -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>;