Consolidate duplicated editor code, trim comments, refresh README
Split GraphCanvas (1076 -> 831 lines) into EdgeLayer and graphMenus; the port and marker menus were the same list and are now one function. Value specs of the inspector and the list tab share valueSpecs.ts, and the remaining copies (compound commands, type glyphs, typed asset lookup, name rule, play/editor world setup, marquee) are merged. Four copies had already drifted apart; merging them fixes: - "Disconnect N links" in the port menu is one undo step, not N - "+ Add collider" is hidden on a placed container instance, as in the hierarchy menu, instead of always failing - a bool property coerced from the text "false" becomes false - a port command on an unknown node type reports instead of crashing Comment-only edits leave the bundle byte-identical. README corrected in 35 places (step limit, jump-run clock, suite duration, 409 body, ...). Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9212e61c4c
commit
8f92a06c84
96 files changed
+999
-1261
No files matched your search
@@ -1,8 +1,7 @@
|
||||
import { RemoveNodeCommand, SetNodeParamCommand } from '../../core/commands/graphCommands';
|
||||
import { RemoveNodeCommand } from '../../core/commands/graphCommands';
|
||||
import {
|
||||
callProblem,
|
||||
declaresVariablePorts,
|
||||
type Graph,
|
||||
edgesInto,
|
||||
type GraphNode,
|
||||
inlineInputDef,
|
||||
@@ -12,18 +11,19 @@ import {
|
||||
} from '../../core/graph';
|
||||
import type { Asset } from '../../core/model/Asset';
|
||||
import { behaviorLookup } from '../../core/model/behaviorPrograms';
|
||||
import { findAsset, type Project } from '../../core/model/Project';
|
||||
import { findAssetOf, 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 { buildPortSection, buildVariablePortSection } from './portSection';
|
||||
import { listOpener, previewingHandlers } from './previewHandlers';
|
||||
import { currentNode, nodeParamValue } from './valueSpecs';
|
||||
|
||||
/** Structure-defining facts of a node selection: ports, connected inputs, declared variables. */
|
||||
export function nodeSignature(project: Project, assetId: string, nodeId: string): string {
|
||||
const asset = findAsset(project, assetId);
|
||||
if (!asset || asset.type !== 'behavior') return 'missing';
|
||||
const asset = findAssetOf(project, assetId, 'behavior');
|
||||
if (!asset) return 'missing';
|
||||
const node = asset.graph.nodes.find((n) => n.id === nodeId);
|
||||
if (!node) return 'missing';
|
||||
const lookup = behaviorLookup(project);
|
||||
@@ -41,8 +41,8 @@ export function nodeSignature(project: Project, assetId: string, nodeId: string)
|
||||
|
||||
/** Description, settings (params) and the inline values of unconnected data inputs. */
|
||||
export function buildNodeSection(host: InspectorHost, assetId: string, nodeId: string): void {
|
||||
const asset = findAsset(host.state.project, assetId);
|
||||
if (!asset || asset.type !== 'behavior') return;
|
||||
const asset = findAssetOf(host.state.project, assetId, 'behavior');
|
||||
if (!asset) return;
|
||||
const node = asset.graph.nodes.find((n) => n.id === nodeId);
|
||||
const def = node && resolveDef(node, asset.graph, behaviorLookup(host.state.project));
|
||||
if (!node || !def) return;
|
||||
@@ -126,25 +126,7 @@ function paramHandlers(
|
||||
): FieldHandlers {
|
||||
const key = def.key;
|
||||
return {
|
||||
...previewingHandlers<GraphNode>(host, {
|
||||
target: () => currentNode(host.state.project, assetId, nodeId)?.node,
|
||||
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),
|
||||
}),
|
||||
...previewingHandlers<GraphNode>(host, nodeParamValue(host.state, assetId, nodeId, key)),
|
||||
...listOpener(host.state, def, () => ({ kind: 'node', assetId, nodeId, key })),
|
||||
};
|
||||
}
|
||||
|
||||
/** The node together with the graph it sits in, because its ports are derived from both. */
|
||||
function currentNode(
|
||||
project: Project,
|
||||
assetId: string,
|
||||
nodeId: string,
|
||||
): { node: GraphNode; graph: Graph } | undefined {
|
||||
const asset = findAsset(project, assetId);
|
||||
if (asset?.type !== 'behavior') return undefined;
|
||||
const node = asset.graph.nodes.find((n) => n.id === nodeId);
|
||||
return node && { node, graph: asset.graph };
|
||||
}
|
||||
Reference in new issue
Block a user