Replace the five variable nodes with one Variables node
A single node now lists any number of variables. Every entry is an output that reads the current value whenever it is pulled; an entry switched to Set is also an input and is written when the flow arrives. Exec pins only exist while at least one entry writes, and all inputs are read before any write, so one node can swap two variables. Get/Set variable, Get/Set variables and Variable are gone. Old project files are converted on load: each old node becomes a Variables node with the same variables, edges and typed values. A written port without a typed value now shows the zero of its kind on the node body, matching what the inspector shows and what the run writes. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
854ae2e756
commit
7c63c884ef
40 files changed
+895
-590
No files matched your search
@@ -9,7 +9,6 @@ import {
|
||||
portSignature,
|
||||
resolveDef,
|
||||
} from '../../core/graph';
|
||||
import type { Asset } from '../../core/model/Asset';
|
||||
import { behaviorLookup } from '../../core/model/behaviorPrograms';
|
||||
import { findAssetOf, type Project } from '../../core/model/Project';
|
||||
import type { PropertyDef } from '../../core/properties/PropertySchema';
|
||||
@@ -33,7 +32,7 @@ export function nodeSignature(project: Project, assetId: string, nodeId: string)
|
||||
.filter((p) => edgesInto(asset.graph, node.id, p.key).length > 0)
|
||||
.map((p) => p.key)
|
||||
: [];
|
||||
const declared = (node.ports ?? []).map((p) => `${p.key}:${p.kind}`).join(',');
|
||||
const declared = (node.ports ?? []).map((p) => `${p.key}:${p.kind}${p.write ? ':set' : ''}`).join(',');
|
||||
return `${portSignature(node, asset.graph, lookup, assetId)}|${declared}|${connected.join(',')}|${asset.variables
|
||||
.map((v) => v.key)
|
||||
.join(',')}`;
|
||||
@@ -58,12 +57,11 @@ export function buildNodeSection(host: InspectorHost, assetId: string, nodeId: s
|
||||
|
||||
if (def.params.length > 0) addTitle(host, 'SETTINGS');
|
||||
for (const param of def.params) {
|
||||
const effective = resolveParamDef(param, asset);
|
||||
const row = createFieldRow(
|
||||
host,
|
||||
effective,
|
||||
node.params[param.key] ?? effective.default,
|
||||
paramHandlers(host, assetId, nodeId, effective),
|
||||
param,
|
||||
node.params[param.key] ?? param.default,
|
||||
paramHandlers(host, assetId, nodeId, param),
|
||||
);
|
||||
host.fields.set(`param:${param.key}`, row);
|
||||
host.body.add(row.row);
|
||||
@@ -101,15 +99,6 @@ export function refreshNodeSection(host: InspectorHost, assetId: string, nodeId:
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Variable params are the one setting a node cannot declare on its own: their options are the
|
||||
* variables of the behavior it sits in. Everything else is used exactly as declared.
|
||||
*/
|
||||
function resolveParamDef(param: PropertyDef, asset: Asset): PropertyDef {
|
||||
if (param.kind !== 'enum' || param.key !== 'variable' || asset.type !== 'behavior') return param;
|
||||
return { ...param, options: asset.variables.map((v) => ({ value: v.key, label: v.key })) };
|
||||
}
|
||||
|
||||
/** Previews straight into the node's params; the command records the value from before the preview. */
|
||||
function paramHandlers(
|
||||
host: InspectorHost,
|
||||
|
||||
Reference in new issue
Block a user