/// <reference types="node" />
import { GuestProtocolMethods, WasmRsGuestProtocol } from './protocol.js';
import { Wasi, WasiOptions } from './wasi.js';
type HostCall = (binding: string, namespace: string, operation: string, payload: Uint8Array) => Uint8Array;
type Writer = (message: string) => void;
interface Invocation {
    operation: string;
    operationEncoded: Uint8Array;
    msg: Uint8Array;
}
declare class ModuleState {
    guestRequest?: Invocation;
    guestResponse?: Uint8Array;
    hostResponse?: Uint8Array;
    guestError?: string;
    hostError?: string;
    hostCallback: HostCall;
    writer: Writer;
    constructor(hostCall?: HostCall, writer?: Writer);
}
export declare class WasmRsModule {
    private module;
    constructor(module: WebAssembly.Module);
    static from(any: any): WasmRsModule;
    static compile(source: ArrayBufferLike): Promise<WasmRsModule>;
    static compileStreaming(source: Response): Promise<WasmRsModule>;
    instantiate(options?: Options): Promise<WasmRsInstance>;
}
export declare class WasmRsInstance extends EventTarget {
    guestBufferStart: number;
    hostBufferStart: number;
    state: ModuleState;
    guestSend: WasmRsGuestProtocol[GuestProtocolMethods.SEND];
    guestOpListRequest: WasmRsGuestProtocol[GuestProtocolMethods.OP_LIST_REQUEST];
    textEncoder: TextEncoder;
    textDecoder: TextDecoder;
    instance: WebAssembly.Instance;
    operations: OperationList;
    constructor(options?: Options);
    static setWasi(wasi: Wasi): void;
    initialize(instance: WebAssembly.Instance): void;
    getProtocolExport<N extends keyof WasmRsGuestProtocol>(name: N): WasmRsGuestProtocol[N];
    send(payload: Buffer): void;
    getCallerMemory(): WebAssembly.Memory;
    close(): void;
}
export declare class FrameEvent extends Event {
    payload: Uint8Array;
    constructor(type: string, payload: Uint8Array);
}
export interface Options {
    hostCall?: HostCall;
    writer?: Writer;
    wasi?: WasiOptions;
}
export declare class OperationList {
    imports: Operation[];
    exports: Operation[];
    constructor(imports: Operation[], exports: Operation[]);
    getExport(namespace: string, operation: string): Operation;
    getImport(namespace: string, operation: string): Operation;
}
export declare class Operation {
    index: number;
    kind: OperationType;
    namespace: string;
    operation: string;
    constructor(index: number, kind: OperationType, namespace: string, operation: string);
    asEncoded(): Uint8Array;
}
declare enum OperationType {
    RR = 0,
    FNF = 1,
    RS = 2,
    RC = 3
}
export {};
