@casual-simulation/aux-runtime
Version:
Runtime for AUX projects
125 lines • 4.4 kB
TypeScript
import type { PrecalculatedBot, Bot, PrecalculatedTags, BotSpace, BotSignatures, CompiledBotListeners, RuntimeBot, CompiledBotModules, CompiledBotExports, DynamicBotListeners } from '@casual-simulation/aux-common/bots';
import type { Breakpoint, InterpreterAfterStop, InterpreterBeforeStop, InterpreterContinuation, InterpreterStop } from '@casual-simulation/js-interpreter';
import type { ScriptError } from './AuxResults';
import type { RuntimeActions } from './RuntimeEvents';
/**
* Defines bots state that contains compiled bots.
*/
export interface CompiledBotsState {
[id: string]: CompiledBot;
}
/**
* A bot that has been pre-compiled so that running tag listeners or formulas is quick.
*/
export interface CompiledBot extends PrecalculatedBot {
/**
* The tags that are listeners and have been compiled into functions.
*/
listeners: CompiledBotListeners;
/**
* The listeners that have been overridden by the user.
* These listeners will override the compiled listeners.
*/
listenerOverrides: CompiledBotListeners;
/**
* The dynamic listeners that have been registered at runtime.
*/
dynamicListeners: DynamicBotListeners;
/**
* The modules that are defined by this bot.
*/
modules: CompiledBotModules;
/**
* The exports that the compiled bot has.
*/
exports: CompiledBotExports;
/**
* The script bot that the compiled bot has been setup to use.
*/
script: RuntimeBot;
/**
* The tag values that were originally on the bot before an edit was applied.
*/
originalTagEditValues: Bot['tags'];
/**
* The tag mask values that were originally on the bot before an edit was applied.
*/
originalTagMaskEditValues: Bot['masks'];
/**
* The list of breakpoints that are registered on this bot.
*/
breakpoints: RuntimeBreakpoint[];
/**
* The number of errors that have occurred on each tag in this bot.
*/
errorCounts: TagErrorCounts;
}
interface TagErrorCounts {
[tag: string]: number;
}
export type RuntimeGenerator = Generator<InterpreterStop, any, InterpreterContinuation>;
export type RuntimeStop = RuntimeBeforeStop | RuntimeAfterStop;
export interface RuntimeStopBase {
/**
* The ID of the stop.
*/
stopId: string | number;
/**
* The breakpoint that the runtime hit.
*/
breakpoint: RuntimeBreakpoint;
}
export interface RuntimeBeforeStop extends Omit<InterpreterBeforeStop, 'breakpoint'>, RuntimeStopBase {
}
export interface RuntimeAfterStop extends Omit<InterpreterAfterStop, 'breakpoint'>, RuntimeStopBase {
}
/**
* Defines an interface that represents the state that the runtime needs in order to resume a runtime stop.
*/
export interface RuntimeStopState {
/**
* The ID of this stop.
*/
stopId: string | number;
/**
* The generator that was currently executing.
*/
generator: RuntimeGenerator;
/**
* The current list of batched actions.
*/
actions: RuntimeActions[];
/**
* The current list of batched errors.
*/
errors: ScriptError[];
resolve: (result: any | PromiseLike<any>) => void;
reject: (result: any) => void;
}
/**
* Defines an interface that represents a breakpoint that was set on a runtime.
*/
export interface RuntimeBreakpoint extends Omit<Breakpoint, 'func'> {
/**
* The ID of the bot that the breakpoint should be set on.
*/
botId: string;
/**
* The name of the tag that the breakpoint should be set on.
*/
tag: string;
}
/**
* Creates a new compiled bot with the given values.
* Useful for testing.
* @param id The ID of the bot.
* @param values The values that the bot contains.
* @param tags The tags that the bot contains.
* @param space The space that the bot is in.
* @param compiledValues The compiled values that the bot should use.
* @param listeners The listeners that the bot should have.
* @param modules The modules that the bot should have.
*/
export declare function createCompiledBot(id?: string, values?: PrecalculatedTags, tags?: Bot['tags'], space?: BotSpace, listeners?: CompiledBotListeners, signatures?: BotSignatures, modules?: CompiledBotModules, dynamicListeners?: DynamicBotListeners, listenerOverrides?: CompiledBotListeners): CompiledBot;
export {};
//# sourceMappingURL=CompiledBot.d.ts.map