Make texture and colour full kinds and drop the load-time migrations
- `Texture` and `Color` can be picked as a variable kind, a struct field kind and a declared port kind; a new `Texture` node hands a picture id into the graph. Declared, a texture is its bare id – the `$texture` tag stays a list-only thing. - The `String` node is labelled "Text" like its kind; the type id stays. - Whole-number inputs (`Item at`, `Set item`, `Sub list`, `Fill`, `Repeat`, `Substring`, `To text`) show no decimals (`int()` in shared.ts). - All server projects are reseeded, so `legacyNodes.ts`, `migrateDeclaredLists` and the `ownerId` fallback go, with their tests. - Note `reseed-because-of-list` moved to done/; new note `refactor-types`. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
1 parent
11c900c998
commit
8a7185948d
39 files changed
+378
-765
No files matched your search
@@ -9,7 +9,6 @@ import {
|
||||
import {
|
||||
emptyFieldValue,
|
||||
type FieldKind,
|
||||
type ListItemKind,
|
||||
type PropertyDef,
|
||||
type StructFieldDef,
|
||||
} from '../../core/properties/PropertySchema';
|
||||
@@ -204,11 +203,6 @@ export function removeButton(onClick: () => void): Button {
|
||||
export const READ_ONLY: FieldHandlers = { onInput: () => {}, onChange: () => {} };
|
||||
|
||||
/** A primitive as a property definition, so one widget set serves a list item and a struct field. */
|
||||
/** The def a list item draws with: the flat kinds plus `texture`, which only a list item may be. */
|
||||
export function itemDef(key: string, kind: Exclude<ListItemKind, 'struct'>, label = key): PropertyDef {
|
||||
return kind === 'texture' ? { key, label, kind: 'texture', default: '' } : primitiveDef(key, kind, label);
|
||||
}
|
||||
|
||||
export function primitiveDef(key: string, kind: FieldKind, label = key): PrimitiveDef {
|
||||
switch (kind) {
|
||||
case 'number':
|
||||
@@ -219,6 +213,8 @@ export function primitiveDef(key: string, kind: FieldKind, label = key): Primiti
|
||||
return { key, label, kind: 'boolean', default: false };
|
||||
case 'color':
|
||||
return { key, label, kind: 'color', default: 0 };
|
||||
case 'texture':
|
||||
return { key, label, kind: 'texture', default: '' };
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
DECLARED_PORT_KINDS,
|
||||
type DeclaredPort,
|
||||
type GraphNode,
|
||||
isPortOf,
|
||||
isTerminalNode,
|
||||
missingFieldPorts,
|
||||
OBJECT_BEHAVIOR_PARAM,
|
||||
@@ -155,7 +156,7 @@ function buildPickedPortSection(
|
||||
continue;
|
||||
}
|
||||
const def = choices.find((d) => d.key === port.key);
|
||||
const known = def !== undefined && portKindOf(def) === port.kind;
|
||||
const known = def !== undefined && isPortOf(port, def);
|
||||
const choose = new Dropdown(port.key, { variant: known ? 'default' : 'danger' });
|
||||
choose.onClick = () => {
|
||||
const items = pick(port.key, (next) =>
|
||||
@@ -163,7 +164,7 @@ function buildPickedPortSection(
|
||||
);
|
||||
new Menu(items, { searchable }).openBelow(choose);
|
||||
};
|
||||
portRow(host, assetId, node, port, choose, toggle);
|
||||
portRow(host, assetId, node, def && known ? { ...port, kind: portKindOf(def) } : port, choose, toggle);
|
||||
if (!known) addNote(host, `"${port.key}" is not a ${noun.toLowerCase()} of ${owner}.`, 'warning');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,6 @@ import {
|
||||
createField,
|
||||
type FieldContext,
|
||||
NAME_WIDTH,
|
||||
itemDef,
|
||||
primitiveDef,
|
||||
READ_ONLY,
|
||||
removeButton,
|
||||
@@ -225,7 +224,7 @@ export class ListEditor extends VStack {
|
||||
else {
|
||||
const field = createField(
|
||||
this.ctx,
|
||||
itemDef(String(index), kind),
|
||||
primitiveDef(String(index), kind),
|
||||
itemValue(item) ?? '',
|
||||
access.itemHandlers(index),
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user