For AI agents: the complete documentation index is available at /next/zh/llms.txt, the full documentation bundle is available at /next/zh/llms-full.txt, and this page is available as Markdown at /next/zh/api/genui/a2ui/interfaces/MessageStore.md.
Lynx
  • 简体中文
  • 接口: MessageStore

    一个纯追加式的缓冲区,存放由开发者 IO 模块产生的原始协议消息。该 store 对 v0.9 协议一无所知——它不解析、不处理,也不解释消息,只负责:

    1. 按到达顺序存储消息。
    2. 有新消息到达时通知订阅者。
    3. 通过 getSnapshot() 返回当前快照(两次变更之间引用保持稳定——这是 useSyncExternalStore 所要求的)。

    感知协议的处理——surface、signal、resource、action 分发——由 <A2UI>(渲染器组件)负责。不想了解协议的开发者应使用 <A2UI>;了解协议的开发者可以直接基于快照运行自己的 MessageProcessor。

    属性

    getSnapshot

    readonly getSnapshot: () => readonly ServerToClientMessage[]

    useSyncExternalStore 的 getSnapshot 约定——在两次 push 之间保持稳定。

    返回

    readonly ServerToClientMessage[]


    subscribe

    readonly subscribe: (cb: () => void) => () => void

    useSyncExternalStore 的 subscribe 约定。

    参数

    参数类型
    cb() => void

    返回

    () => void

    方法

    clear()

    clear(): void

    重置缓冲区,并通知订阅者。

    返回

    void


    push()

    push(message: ServerToClientMessage | readonly ServerToClientMessage[]): void

    向缓冲区追加一条或多条原始消息。每次调用只通知订阅者一次(传入单个数组参数时会合并为一次通知)。

    参数

    参数类型
    messageServerToClientMessage | readonly ServerToClientMessage[]

    返回

    void

    除非另有说明,本项目采用知识共享署名 4.0 国际许可协议进行许可,代码示例采用 Apache License 2.0 许可协议进行许可。