import { AnyAction } from './AnyAction'; import type { Client } from './Client'; import { ClientContext } from './ClientContext'; import { ClientActionFactory } from './ClientActionFactory'; import { ClientActionConfig } from '../messages/ClientActionConfig'; export class ClientActionBox { public readonly staticContext = new ClientContext(this, true); public config!: ClientActionConfig; private context: Record = {}; private ready = false; constructor( readonly name: string, public readonly client: Client, public readonly actionFactory: ClientActionFactory = () => new AnyAction(), ) {} public setConfig(cfg: ClientActionConfig) { this.config = cfg; this.ready = true; } public getContext() { return this.context; } public setContext(context: Record) { this.context = context; } public isReady() { return this.ready; } public hasMethod(methodName: string): boolean { return !!this.config.methods[methodName]; } public isPermanent() { return !!this.config?.permanent; } }