import { StoreApi, UseBoundStore } from 'zustand'; /** * And Store 状态接口 * 替换原有的 Pinia andStore */ export interface AndStoreState { dataSets: Record>; commandQueues: Record; propsStore: Record>; validateStore: Record>; } export interface CommandItem { actionName: string; arg?: any; timestamp: number; } export interface AndStoreActions { setDataSet: (name: string, field: string, value: any, append?: boolean) => void; updateDataSet: (name: string, field: string, updater: (prev: any) => any) => void; getDataSet: (name: string, field: string) => any; setDataSetBatch: (name: string, data: Record) => void; clearDataSet: (name: string) => void; addCommand: (sessionId: string, command: CommandItem) => void; popCommand: (sessionId: string) => CommandItem | undefined; clearCommands: (sessionId: string) => void; getCommands: (sessionId: string) => CommandItem[]; setProps: (sessionId: string, componentId: string, props: any) => void; getProps: (sessionId: string, componentId: string) => any; setValidateResult: (sessionId: string | undefined, dataSet: string, dataSetField: string, message: string) => void; getValidateResult: (sessionId: string | undefined, dataSet: string, dataSetField: string) => string; getValidateResults: (sessionId: string | undefined, dataSet: string) => Record; reset: () => void; } export type AndStore = AndStoreState & AndStoreActions; /** * Zustand Store - 替换 Pinia 的 useItemStore */ export declare const useAndStore: UseBoundStore>; /** * 兼容层:模拟原 useStore 的行为 * 用于现有组件的渐进式迁移 */ export declare function useStore(config: { dataSet?: string; dataSetField?: string; }): { value: any; }; /** * 兼容层:通过名称获取整个数据集 */ export declare function useStoreByName(name: string): { value: any; }; /** * Hook: 添加命令到队列 */ export declare function useAddCommand(): (sessionId: string, command: CommandItem) => void; /** * Hook: 获取并消费命令 */ export declare function usePopCommand(): (sessionId: string) => CommandItem | undefined; /** * 按 dataSetKey + dataSetField 从 store 取数组,并订阅对应块以响应更新。 * 支持多级 dataSetField(如 value、value[0].rows)和 dataSetKey 带下标(如 list[0])。 * dataSetField 为空时传 '',与 getDataSet/setDataSet 一致:读整块对象;再按「整块为数组」或「.value 为数组」规范为数组。 * * 当 field 为空且根数据为数组时,仅订阅结构指纹(行数/id/type),不订阅正文 content; * 子组件应通过各自 dataSetField 订阅字段级更新(如 AndInputArea 的 [i].value.content)。 */ export declare function useStoreData(dataSetKey: string | undefined, dataSetField: string | undefined): any[]; /** * 兼容层:useItemStore - 模拟 Vue/Pinia 的 useItemStore * 用于生成的 React 代码、Extend 等。 * 不订阅 state.dataSets,避免任意 setDataSet 导致本组件重渲染(解决输入延迟); * items / getItem 通过 getState() 读最新值,子组件若需响应 store 变化请用 useAndStore(selector) 订阅具体 key。 * * 写入推荐用 setDataSet(name, field, value),可完全替代 updateItem: * - setDataSet(key, '', array) 等价于 updateItem(key, array)(field 空为整块对象) * - setDataSet 支持多级 field(如 'pagination.current')、name 下标(如 list[0]),更全面 * - updateItem 保留用于兼容旧代码 */ export declare function useItemStore(): { readonly items: Record>; getDataSet: (name: string, field: string) => any; setDataSet: (name: string, field: string, value: any, append?: boolean | undefined) => void; updateDataSet: (name: string, field: string, updater: (prev: any) => any) => void; updateItem: (key: string, value: any) => void; getItem: (key: string) => Record; }; /** * 兼容层:useCommandsStore - 模拟 Vue/Pinia 的 useCommandsStore * @param sessionId 会话 ID */ export declare function useCommandsStore(sessionId: string): { commands: CommandItem[]; addCommand: (actionName: string, arg: any) => void; popCommand: () => CommandItem | undefined; clearCommands: () => void; }; export default useAndStore; //# sourceMappingURL=useAndStore.d.ts.map