/** * AtomVM Runtime class * * **Poka-Yoke Design**: * - State machine prevents invalid operations (cannot execute before load) * - Validation prevents invalid inputs (non-empty moduleName) * - Type guards ensure state consistency */ export class AtomVMRuntime { /** * @param {Object} terminal - Terminal UI instance for logging * @param {string} moduleName - Name of module to execute (required, non-empty) */ constructor(terminal: any, moduleName: string); terminal: any; atomvmModule: any; memory: any; moduleName: string; /** @type {RuntimeState} */ state: RuntimeState; /** * Type guard: Check if runtime is ready for operations * * **Poka-Yoke**: Prevents operations in invalid states * * @returns {boolean} True if runtime is ready */ isReady(): boolean; /** * Type guard: Check if runtime is loaded * * **Poka-yoke**: Ensures state consistency * * @returns {boolean} True if runtime is loaded */ isLoaded(): boolean; /** * Load AtomVM WASM module * * Loads the AtomVM.js script which contains the full Emscripten module. * The module will be available globally as `Module` after loading. * * **Poka-Yoke**: State machine prevents multiple loads and loads after destroy * * @returns {Promise} * @throws {Error} If state is invalid or SharedArrayBuffer unavailable */ loadWASM(): Promise; /** * Run example BEAM code * * Loads and executes a test .avm file using real AtomVM execution. * * **Poka-Yoke**: State machine prevents execution before load * * @returns {Promise} * @throws {Error} If runtime is not ready */ runExample(): Promise; /** * Execute .avm file * * **Poka-Yoke**: State machine and validation prevent invalid operations * * @param {string} avmPath - Path to .avm file to execute (required, non-empty) * @returns {Promise} Execution result * @throws {Error} If runtime is not ready or avmPath is invalid */ executeBeam(avmPath: string): Promise; /** * Clean up resources * * **Poka-Yoke**: Terminal state prevents further operations */ destroy(): void; } /** * Runtime state machine states * * **Poka-Yoke**: Enum prevents invalid states. Cannot be in multiple states simultaneously. * Valid transitions: * - Uninitialized => Loading => Ready * - Uninitialized => Loading => Error * - Ready => Executing => Ready * - Any => Destroyed (terminal state) */ export type RuntimeState = "Uninitialized" | "Loading" | "Ready" | "Executing" | "Error" | "Destroyed";