Describe every value kind in one table instead of spreading it over the code

A kind like colour or texture used to be spelled out in five parallel
lists, its port type, its empty value, its glyph, its label and its list
tag - 22 literal places for texture alone. core/properties/kinds.ts now
holds one row per kind and the rest is derived from it, so adding a kind
is one row. The five literal nodes collapse into literals.ts, the six
kind menus into one helper.

Number, Text, Boolean is now the one order everywhere; the variable and
port menus used to list Boolean before Text.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
rootandClaude Opus 5 committed 2026-09-12 14:47:17 +02:00
1 parent 8a7185948d
commit 3ed8b68ecf
39 files changed
+699 -565

No files matched your search

+4 -7
View File
@@ -1,5 +1,6 @@
import { textOf } from '../model/Properties';
import { isValidFieldName } from '../properties/PropertySchema';
import { isTaggedKind } from '../properties/kinds';
import { flatDef, isValidFieldName } from '../properties/PropertySchema';
import { type DeclaredPort, declaredPortType, type Graph, type GraphNode } from './Graph';
import type { BehaviorLookup } from './lookup';
import { nodeDef, type NodeDef, type PortDef } from './NodeRegistry';
@@ -75,14 +76,10 @@ export function isTerminalNode(node: GraphNode): boolean {
return isTerminalType(node.type);
}
/** A color or texture port carries the field that edits it; the graph itself sees a number or a text. */
/** A tagged kind is one the value cannot show, so its port carries the field that edits it. */
export function portDefOf(port: DeclaredPort): PortDef {
const def: PortDef = { key: port.key, label: port.key, type: declaredPortType(port.kind) };
if (port.kind === 'color')
return { ...def, field: { key: port.key, label: port.key, kind: 'color', default: 0 } };
if (port.kind === 'texture')
return { ...def, field: { key: port.key, label: port.key, kind: 'texture', default: '' } };
return def;
return isTaggedKind(port.kind) ? { ...def, field: flatDef(port.key, port.kind) } : def;
}
/** The ports the start (or end) node of `graph` declares, as seen from a node calling it. */