28a63eaf88
新增 Rust 组件绑定命令,向 LLM 提供真实界面与素材像素并接受完整 Component 参数。 拆分节点布局与组件状态及 LLM 编辑权限,允许根节点承载组件并保持 Transform 只读。 接入五个素材一批的前端绑定循环、增量结果合并和调试入口。 生成更新后的 TypeScript 契约,并补齐 UI Editor 状态测试。
20 lines
798 B
TypeScript
20 lines
798 B
TypeScript
import type { BindingDTO } from './types/BindingDTO';
|
|
import type { Node } from './types/Node';
|
|
import type { State } from './types/State';
|
|
|
|
function applyChanges(node: Node, result: BindingDTO): void {
|
|
const change = result.changes.find((candidate) => candidate.node_id === node.id);
|
|
if (change) {
|
|
node.components = structuredClone(change.components);
|
|
node.metadata.components_status = structuredClone(change.components_status);
|
|
}
|
|
for (const child of node.children) applyChanges(child, result);
|
|
}
|
|
|
|
/** Applies only explicit component changes; omitted nodes remain untouched. */
|
|
export function applyBindingResult(state: State, result: BindingDTO): State {
|
|
const next = structuredClone(state);
|
|
for (const tree of next.ui_trees) applyChanges(tree.root, result);
|
|
return next;
|
|
}
|