Runtime API / Interface

RuntimeChildSpec

描述一个运行时 child 的稳定身份、来源、父级、挂载位置、输入和所有权策略。

使用说明

三种 child 来源

每个 spec 必须且只能提供以下一种来源:

字段 用途 默认所有权
ref 精确 Component Ref,由 componentResolver 加载 Runtime-owned
artifact 已在当前进程取得的本地 Artifact Runtime-owned
instance 已经存在的 live Instance caller-owned

持久化 Composition IR 应优先保存带 hash 与 ABI 的 exact ref。artifact 适合本地运行组合;instance 只能用于当前 Runtime 生命周期,不能写入 Artifact。

key 在一次 reconcile 的完整列表中必须唯一。parentKey 负责父子所有权层级;mount 负责逻辑挂载位置。对于 artifact,Runtime 以对象 identity 判断是否可复用,而不是对 Artifact 做深比较。

mount 不是 DOM target

这里的 mount 类型是 FlamoMountPoint,描述 child 在父实例图中的逻辑位置:

  • { kind: 'root' }:挂到父 boundary 根;
  • { kind: 'node', nodeId }:挂到父级指定节点;
  • { kind: 'slot', slotId, outletId }:挂到指定 slot outlet;
  • { kind: 'portal', portalTarget }:逻辑 owner 仍是父实例,但物理位置由 portal target 决定。

它不同于 runtime.mount(target, artifact) 的 FlamoMountTarget,不会把 child 或父 Instance 重新绑定到浏览器 DOM 元素。