Skip to content

配置域命名约定

配置管线(peel → normalize → merge → adapt → bind)的类型与方法命名。与 DESIGN.md 核心管线对照;本文是命名的权威来源。


三域

含义类型文件可否含糖
Raw用户写法(公开 flat)src/types/config-raw.ts✅(props.ref 可为 RefcloseOnCloseOnRaw 数组/Record 糖)
Canonicalstore、merge、adapter、refssrc/types/config.ts❌(ref 仅为 callback;closeOnCloseOn = Record<event, CloseOnEntry>
Boundbind 输出,可直接 h()src/types/bound.ts
text
Public flat (*Raw nodes)
  --toFragment* (peel + normalizeNode)-->
Canonical Fragment
  --merge / adapter / refs-->
Canonical Fragment
  --bindLayer-->
LayerBound

引入 LayerConfigFragmentRaw:双侧分栏只属于 Canonical;用户非标入口只有 flat。

不要Normalized 表示 bind 输出——bind 用 Boundnormalize* 专指 Raw → Canonical(糖展开)。


阶段动词

动词阶段规则
toFragment*peel + normalizeflat → Canonical LayerConfigFragment
normalizeNode* / normalizePropRef糖展开(拷贝,不 mutate 入参)Ref→callback、markRaw(component)
merge*叠 Canonical只吃 / 产出 Canonical
adapter整形FragmentFragment
bind*投影 runtimeFragment + visible/close → LayerBound

类型对照(节选)

RawCanonicalBound
CloseOnRawCloseOnCloseOnEntrywhen 可含 'none'(已写入 props onXxx
LayerPropsRawLayerPropsLayerBoundNode.props
LayerConfigNode*RawLayerConfigNode*LayerBoundNode
LayerConfigContent / Container
LayerConfigFragmentLayerBound

CloseOnRawnormalizeCloseOn → store 各 tier 的 CloseOn(完整 { when, confirmed },可含 when: 'none')。mergeCloseOnevent patch、整份 entry 替换,并将 when: 'none' 删 key;约定 merge 之后 / adapter / bind 不再保留 tombstone(bind 仍防御性跳过 none)。adapter 移除事件应删 key,勿写 when: 'none'

MIT Licensed