///
export interface CommanderInstruct {
/** 指令类别 */
type: 'info' | 'warn' | 'error';
/** 指令优先级 */
level?: number;
/** 指令内容 */
content: {
text?: string;
textArray?: string[];
};
}
export declare type onInstructFunc = (ins: CommanderInstruct) => void;
export interface CommanderStrategyOptions {
executeDuration?: number;
maxStateHistoryLen?: number;
enableStatePersist?: boolean;
statePersistExpireDuration?: number;
}
export declare abstract class CommanderStrategy {
protected key: string;
protected onExecute: onInstructFunc;
protected options: CommanderStrategyOptions;
/** 状态历史 */
stateHistory: T[];
/** 指令队列 */
instructs: CommanderInstruct[];
/** 是否在指令执行中 */
protected isExecuting: boolean;
protected intervalHandler: NodeJS.Timeout | number;
constructor(key: string, onExecute: onInstructFunc, options?: CommanderStrategyOptions);
pushState(nextState: T): Promise;
protected abstract inspect(currentState: T, nextState: T): Promise;
close(): Promise;
/** 添加指令到指令队列中 */
protected pushInstruct(instruct: CommanderInstruct): Promise;
/** 内部执行指令的操作 */
protected executeInstruction(ins: CommanderInstruct): Promise;
/** 定期执行任务 */
protected onInterval(): void;
}