Fix findUsages/undo/node-lookup bugs, split Viewport and Editor, share command and inspector helpers

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
rootandClaude Opus 5 committed 2026-09-08 09:22:49 +02:00
1 parent 1eb28314cf
commit f140c2fd77
58 files changed
+1969 -1171

No files matched your search

+8 -25
View File
@@ -2,12 +2,12 @@ import { RemoveNodeCommand, SetNodeParamCommand } from '../../core/commands/grap
import { edgesInto, type GraphNode, inlineInputDef, inlineInputs, nodeDef } from '../../core/graph';
import type { Asset } from '../../core/model/Asset';
import { isPlaceableType } from '../../core/model/AssetTypes';
import type { PropertyValue } from '../../core/model/Properties';
import { findAsset, type Project } from '../../core/model/Project';
import type { PropertyDef } from '../../core/properties/PropertySchema';
import { Button, Label } from '../../ui';
import { createFieldRow, type FieldHandlers } from './fieldFactory';
import { addGap, addNote, addTitle, type InspectorHost } from './host';
import { previewingHandlers } from './previewHandlers';
/** Structure-defining facts of a node selection: type, connected inputs, declared variables. */
export function nodeSignature(project: Project, assetId: string, nodeId: string): string {
@@ -83,30 +83,13 @@ function resolveParamDef(project: Project, param: PropertyDef, asset: Asset): Pr
/** Previews straight into the node's params; the command records the value from before the preview. */
function paramHandlers(host: InspectorHost, assetId: string, nodeId: string, key: string): FieldHandlers {
let original: PropertyValue | undefined;
let had = false;
return {
onInput: (value) => {
const target = currentNode(host.state.project, assetId, nodeId);
if (!target) return;
if (original === undefined) {
had = target.params[key] !== undefined;
original = target.params[key] ?? value;
}
target.params[key] = value;
host.state.preview();
},
onChange: (value) => {
const target = currentNode(host.state.project, assetId, nodeId);
if (!target) return;
if (original !== undefined) {
if (had) target.params[key] = original;
else delete target.params[key];
}
original = undefined;
host.state.execute(new SetNodeParamCommand(assetId, nodeId, key, value));
},
};
return previewingHandlers<GraphNode>(host, {
target: () => currentNode(host.state.project, assetId, nodeId),
read: (node) => node.params[key],
write: (node, value) => (node.params[key] = value),
remove: (node) => delete node.params[key],
commit: (value) => new SetNodeParamCommand(assetId, nodeId, key, value),
});
}
function currentNode(project: Project, assetId: string, nodeId: string): GraphNode | undefined {