Interface Wasm

Interface for WebAssembly management functionality

interface Wasm {
    detectWasiRequirements(wasmBytes: Uint8Array): Promise<boolean>;
    loadEmscripten(path: string): Promise<void>;
    loadWasiComponent(
        path: string,
        streams: WasiStreamOptions,
        args?: string[],
        shell?: Shell,
        pid?: number,
    ): Promise<WasiComponentResult>;
    loadWasm(path: string): Promise<{ instance: Instance; module: Module }>;
}

Methods

  • Load an emscripten JS file compiled using -sSINGLE_FILE

    Parameters

    • path: string

      Path to the emscripten JS file

    Returns Promise<void>

  • Load a WASI component with stream integration

    Parameters

    • path: string

      Path to the WASM file

    • streams: WasiStreamOptions

      Stream options for stdin/stdout/stderr

    • Optionalargs: string[]

      Command line arguments

    • Optionalshell: Shell

      Optional shell instance to use for environment variables

    • Optionalpid: number

      Optional process ID for the WASM execution context

    Returns Promise<WasiComponentResult>

    The WASM instance and exit code promise