import { ReadonlyKeys, WritableKeys } from "tc-shared/proto"; export declare type UiVariable = Transferable | undefined | null | number | string | object; export declare type UiVariableMap = { [key: string]: any; }; export declare type ReadonlyVariables = Pick>; export declare type WriteableVariables = Pick>; declare type UiVariableEditor = Variables[T] extends { __readonly: any; } ? never : (newValue: Variables[T], customData: any) => Variables[T] | void | boolean; declare type UiVariableEditorPromise = Variables[T] extends { __readonly: any; } ? never : (newValue: Variables[T], customData: any) => Promise; export declare abstract class UiVariableProvider { private variableProvider; private variableEditor; private artificialDelay; protected constructor(); destroy(): void; getArtificialDelay(): number; setArtificialDelay(value: number): void; setVariableProvider(variable: T, provider: (customData: any) => Variables[T] | Promise): void; setVariableProviderAsync(variable: T, provider: (customData: any) => Promise): void; /** * @param variable * @param editor If the editor returns `false` or a new variable, such variable will be used */ setVariableEditor(variable: T, editor: UiVariableEditor): void; setVariableEditorAsync(variable: T, editor: UiVariableEditorPromise): void; /** * Send/update a variable * @param variable The target variable to send. * @param customData * @param forceSend If `true` the variable will be send event though it hasn't changed. */ sendVariable(variable: T, customData?: any, forceSend?: boolean): void | Promise; getVariable(variable: T, customData?: any, ignoreCache?: boolean): Promise; getVariableSync(variable: T, customData?: any, ignoreCache?: boolean): Variables[T]; protected resolveVariable(variable: string, customData: any): Promise | any; protected doEditVariable(variable: string, customData: any, newValue: any): Promise | void; private handleEditResult; private handleEditError; protected abstract doSendVariable(variable: string, customData: any, value: any): any; } export declare type UiVariableStatus = { status: "loading"; localValue: Variables[T] | undefined; remoteValue: undefined; setValue: (newValue: Variables[T], localOnly?: boolean) => void; } | { status: "loaded" | "applying"; localValue: Variables[T]; remoteValue: Variables[T]; setValue: (newValue: Variables[T], localOnly?: boolean) => void; }; export declare type UiReadOnlyVariableStatus = { status: "loading" | "loaded"; value: Variables[T]; }; export declare abstract class UiVariableConsumer { private variableCache; destroy(): void; private getOrCreateVariable; private derefVariable; setVariable>(variable: T, customData: any, newValue: Variables[T]): void; useVariable>(variable: T, customData?: any, defaultValue?: Variables[T]): UiVariableStatus; useReadOnly(variable: T, customData?: any, defaultValue?: never): UiReadOnlyVariableStatus; useReadOnly(variable: T, customData: any | undefined, defaultValue: Variables[T]): Variables[T]; protected notifyRemoteVariable(variable: string, customData: any | undefined, value: any): void; protected abstract doRequestVariable(variable: string, customData: any | undefined): any; protected abstract doEditVariable(variable: string, customData: any | undefined, value: any): Promise | void; } export {};