DSL node sugar 让编写简洁,但不会创建一套不同的 renderer contract。compiler 会把常见形式降为语义 AUP node:
| DSL 形式 | 编译为 |
|---|---|
stack、row、grid、card | view |
h1、h2、h3、p、badge | text |
button、tab | action |
repeat | afs-list |
内联 literal 会变成 text.content 或 action.label;key=value 提供属性。值可以是 string、number、boolean、null、object 或 array。DSL 有 compile-time 的 +、* 操作和 macro substitution;它不是通用 JavaScript expression language。
data、visibility 与 event
button rename "Rename" primary ->
set headline props {content: "Renamed"}
button load "Load" primary ->
set list src "/modules/index"from 设置 src;show if 设置 visible;on <event> -> ... 能绑定明确名称的 event。裸 -> 只用于 action/button 的 click shorthand。
show if 是呈现控制,不是 authorization。tree 被隐藏不代表 AFS access policy 已经生效。
另一个 node 要引用 ID 时应明确写出
作者不写时 compiler 可以推断稳定 ID。但 event target、patch、test anchor 或其他 node 必须命名目标时,应给它显式 ID。这会让 source 更容易 review,也避免 refactor 时意外改变身份。
-> page 会降为当前 root update { target: "_root", set: { page } };新 source 应使用 DSL 形式,不要手写 legacy top-level page field。
runtime 语义字段见 节点、事件与消息;compile-time component 与 loop 见 组件、循环与 i18n。