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:
1 parent
8a7185948d
commit
3ed8b68ecf
39 files changed
+699
-565
No files matched your search
+13
-15
@@ -1,7 +1,6 @@
|
||||
// Importing the graph package index is what registers the built-in nodes.
|
||||
import {
|
||||
createEmptyGraph,
|
||||
DECLARED_PORT_KINDS,
|
||||
type DeclaredPort,
|
||||
type DeclaredPortKind,
|
||||
type Graph,
|
||||
@@ -15,36 +14,35 @@ import type { Asset, TextureFrame } from '../model/Asset';
|
||||
import { isAssetType } from '../model/AssetTypes';
|
||||
import { emptyEdit, type InstanceEdit, isEmptyEdit } from '../model/instance';
|
||||
import {
|
||||
colorItem,
|
||||
colorItemValue,
|
||||
type FieldValue,
|
||||
isTextureItem,
|
||||
textureItem,
|
||||
textureItemValue,
|
||||
isColorItem,
|
||||
type PropertyBag,
|
||||
type PropertyValue,
|
||||
type StructValue,
|
||||
tagOf,
|
||||
} from '../model/Properties';
|
||||
import { PROJECT_FORMAT_VERSION, type Project } from '../model/Project';
|
||||
import type { SceneObject } from '../model/SceneObject';
|
||||
import { isTextureFile, normalizeFrameRect } from '../model/texture';
|
||||
import { hasParentCycle } from '../model/walk';
|
||||
import type { FlatItem } from '../properties/listItems';
|
||||
import {
|
||||
DECLARED_PORT_KINDS,
|
||||
FIELD_KINDS,
|
||||
type FieldKind,
|
||||
isTaggedKind,
|
||||
VARIABLE_KINDS,
|
||||
type VariableKind,
|
||||
} from '../properties/kinds';
|
||||
import { type FlatItem, makeFlatItem } from '../properties/listItems';
|
||||
import {
|
||||
coerceValue,
|
||||
COMMON_PROPS,
|
||||
FIELD_KINDS,
|
||||
type FieldKind,
|
||||
isValidFieldName,
|
||||
isValidVariableName,
|
||||
type PropertyDef,
|
||||
type PropertySchema,
|
||||
schemaFor,
|
||||
type StructFieldDef,
|
||||
VARIABLE_KINDS,
|
||||
variableDef,
|
||||
type VariableKind,
|
||||
} from '../properties/PropertySchema';
|
||||
|
||||
/**
|
||||
@@ -356,11 +354,11 @@ function asStoredValue(value: unknown): PropertyValue | undefined {
|
||||
const isPrimitive = (value: unknown): value is number | string | boolean =>
|
||||
typeof value === 'number' || typeof value === 'string' || typeof value === 'boolean';
|
||||
|
||||
/** A primitive, or the objects a flat position may hold: a tagged color or texture. */
|
||||
/** A primitive, or the one object a flat position may hold: a tagged item. */
|
||||
const asFlatItem = (value: unknown): FlatItem | undefined => {
|
||||
if (isPrimitive(value)) return value;
|
||||
if (isColorItem(value)) return colorItem(colorItemValue(value));
|
||||
return isTextureItem(value) ? textureItem(textureItemValue(value)) : undefined;
|
||||
const tag = tagOf(value);
|
||||
return tag !== undefined && isTaggedKind(tag) ? makeFlatItem(tag, value as PropertyValue) : undefined;
|
||||
};
|
||||
|
||||
/** A list item: a flat one, or a struct of flat ones. */
|
||||
|
||||
Reference in new issue
Block a user