chore: setup linting
This commit is contained in:
@@ -3,8 +3,8 @@ name = "nodarium_types"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
license = "MIT"
|
||||
description = "Types for Nodarium"
|
||||
repository = "https://github.com/jim-fx/nodes"
|
||||
description = "Types for Nodarium"
|
||||
|
||||
[dependencies]
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
|
||||
@@ -3,6 +3,10 @@
|
||||
"version": "0.0.0",
|
||||
"description": "",
|
||||
"main": "src/index.ts",
|
||||
"scripts": {
|
||||
"format": "dprint fmt -c '../../.dprint.jsonc' .",
|
||||
"format:check": "dprint check -c '../../.dprint.jsonc' ."
|
||||
},
|
||||
"exports": {
|
||||
".": {
|
||||
"import": "./src/index.ts",
|
||||
@@ -14,5 +18,8 @@
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"zod": "^4.3.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"dprint": "^0.51.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import type { Graph, NodeDefinition, NodeId } from "./types";
|
||||
import type { Graph, NodeDefinition, NodeId } from './types';
|
||||
|
||||
export interface NodeRegistry {
|
||||
/**
|
||||
* The status of the node registry
|
||||
* @remarks The status should be "loading" when the registry is loading, "ready" when the registry is ready, and "error" if an error occurred while loading the registry
|
||||
*/
|
||||
status: "loading" | "ready" | "error";
|
||||
status: 'loading' | 'ready' | 'error';
|
||||
/**
|
||||
* Load the nodes with the given ids
|
||||
* @param nodeIds - The ids of the nodes to load
|
||||
@@ -31,7 +31,7 @@ export interface NodeRegistry {
|
||||
* @param wasmBuffer - The WebAssembly buffer for the node
|
||||
* @returns The node definition
|
||||
*/
|
||||
register: (wasmBuffer: ArrayBuffer) => Promise<NodeDefinition>;
|
||||
register: (id: string, wasmBuffer: ArrayBuffer) => Promise<NodeDefinition>;
|
||||
}
|
||||
|
||||
export interface RuntimeExecutor {
|
||||
@@ -42,7 +42,7 @@ export interface RuntimeExecutor {
|
||||
*/
|
||||
execute: (
|
||||
graph: Graph,
|
||||
settings: Record<string, unknown>,
|
||||
settings: Record<string, unknown>
|
||||
) => Promise<Int32Array>;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,14 @@
|
||||
export type { AsyncCache, NodeRegistry, RuntimeExecutor, SyncCache } from './components';
|
||||
export type { NodeInput } from './inputs';
|
||||
export type { Box, Edge, Graph, NodeDefinition, NodeId, NodeInstance, SerializedNode, Socket } from './types';
|
||||
export type {
|
||||
Box,
|
||||
Edge,
|
||||
Graph,
|
||||
NodeDefinition,
|
||||
NodeId,
|
||||
NodeInstance,
|
||||
SerializedNode,
|
||||
Socket
|
||||
} from './types';
|
||||
export { GraphSchema, NodeSchema } from './types';
|
||||
export { NodeDefinitionSchema } from './types';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { z } from "zod";
|
||||
import { z } from 'zod';
|
||||
|
||||
const DefaultOptionsSchema = z.object({
|
||||
internal: z.boolean().optional(),
|
||||
@@ -9,72 +9,74 @@ 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'),
|
||||
value: z.array(z.number()).optional()
|
||||
});
|
||||
|
||||
export const NodeInputPathSchema = z.object({
|
||||
...DefaultOptionsSchema.shape,
|
||||
type: z.literal("path"),
|
||||
type: z.literal('path'),
|
||||
value: z.array(z.number()).optional()
|
||||
});
|
||||
|
||||
export const NodeInputSchema = z.union([
|
||||
@@ -86,7 +88,7 @@ export const NodeInputSchema = z.union([
|
||||
NodeInputSeedSchema,
|
||||
NodeInputVec3Schema,
|
||||
NodeInputGeometrySchema,
|
||||
NodeInputPathSchema,
|
||||
NodeInputPathSchema
|
||||
]);
|
||||
|
||||
export type NodeInput = z.infer<typeof NodeInputSchema>;
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
type ExtractValues<T> = {
|
||||
[K in keyof T]: T[K] extends { value: infer V }
|
||||
? V
|
||||
: T[K] extends object
|
||||
? ExtractValues<T[K]>
|
||||
[K in keyof T]: T[K] extends { value: infer V } ? V
|
||||
: T[K] extends object ? ExtractValues<T[K]>
|
||||
: never;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user