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

+6 -6
View File
@@ -56,7 +56,7 @@ export const propertiesOf = (objectType, objectBehavior) => ({
/**
* A behavior variable declaration. `fields` is the shape of a `struct`; a `list` declares nothing,
* its items each carry their own kind (a colour as `colorItem`).
* its items each carry their own kind (a colour or a texture as `tagged`).
*/
export const variable = (key, kind, value, fields) => ({
key,
@@ -69,8 +69,8 @@ export const variable = (key, kind, value, fields) => ({
/** A struct field declaration. */
export const field = (key, kind = 'number') => ({ key, kind });
/** A colour as a list item: inside a list, 0xRRGGBB would otherwise be a plain number. */
export const colorItem = (color) => ({ $color: color });
/** A picture as a list item – a texture, one of its frames or an animation, all one id. */
export const textureItem = (id) => ({ $texture: id });
/**
* A list item of a kind JSON cannot show: inside a list a colour would be a plain number and a
* texture id a plain text, so it wears its kind as a tag – `{ $color: 0xff0000 }`.
*/
export const tagged = (kind, value) => ({ [`$${kind}`]: value });
+3 -12
View File
@@ -19,16 +19,7 @@
*/
import { fileURLToPath } from 'node:url';
import {
edge,
node,
port,
propertiesOf,
sceneObject,
textureItem,
variable,
written,
} from './lib/builders.mjs';
import { edge, node, port, propertiesOf, sceneObject, tagged, variable, written } from './lib/builders.mjs';
import { PROJECTS, cliArgs, uploadTexture, writeProject } from './lib/projects.mjs';
const { projectId, baseUrl } = cliArgs('seed-actor.mjs', PROJECTS.actor);
@@ -80,8 +71,8 @@ const walkAnimations = DIRECTIONS.map((dir, row) => ({
}));
/** The two lists the graph indexes: one walk animation and one standing frame per direction. */
const WALK_PICTURES = DIRECTIONS.map((dir) => textureItem(WALK(dir)));
const IDLE_PICTURES = DIRECTIONS.map((_, row) => textureItem(idleFrame(row)));
const WALK_PICTURES = DIRECTIONS.map((dir) => tagged('texture', WALK(dir)));
const IDLE_PICTURES = DIRECTIONS.map((_, row) => tagged('texture', idleFrame(row)));
/**
* Sets `facing` to a constant – one per direction, so no edge has to cross the graph. It is the row
+6 -2
View File
@@ -8,13 +8,13 @@
* Usage: node tools/seed-tetris.mjs [projectId] [baseUrl]
*/
import {
colorItem,
edge,
field,
node,
port,
propertiesOf,
sceneObject,
tagged,
variable,
written,
} from './lib/builders.mjs';
@@ -891,7 +891,11 @@ const tetrisVariables = [
variable('grid', 'list', EMPTY_GRID),
variable('shapes', 'list', shapeTable()),
// Tagged, because a list says nothing about its items and a colour is a number like any other.
variable('colors', 'list', SHAPE_COLORS.map(colorItem)),
variable(
'colors',
'list',
SHAPE_COLORS.map((color) => tagged('color', color)),
),
variable('spawnX', 'list', spawnColumns()),
// The falling piece and the one move being tried on it – four numbers each, and never apart.
variable('piece', 'struct', NO_PIECE, PIECE_FIELDS),