import { ThreadBoundaryError } from "./error.js";
export type RequestEvent<T> = {
    callArgs: T;
    id: number;
};
export declare enum IteratorEventType {
    next = "iterator.next",
    done = "iterator.done",
    error = "iterator.error"
}
export type IteratorEvent<V> = {
    type: IteratorEventType.next;
    id: number;
    item: V;
} | {
    type: IteratorEventType.done;
    id: number;
} | {
    type: IteratorEventType.error;
    id: number;
    error: ThreadBoundaryError;
};
export type AsyncIterableEventBus<Args, Item> = {
    emitRequest(data: RequestEvent<Args>): void;
    emitResponse(data: IteratorEvent<Item>): void;
    onRequest(handler: (data: RequestEvent<Args>) => void): void;
    onResponse(handler: (data: IteratorEvent<Item>) => void): void;
};
export declare class AsyncIterableBridgeCaller<Args, Item> {
    private readonly events;
    private nextRequestId;
    private readonly pending;
    constructor(events: Pick<AsyncIterableEventBus<Args, Item>, "onResponse" | "emitRequest">);
    get pendingCount(): number;
    getAsyncIterable(callArgs: Args): AsyncIterable<Item>;
    private onResponse;
}
export declare class AsyncIterableBridgeHandler<Args, Item> {
    private readonly events;
    private readonly handler;
    constructor(events: Pick<AsyncIterableEventBus<Args, Item>, "onRequest" | "emitResponse">, handler: (args: Args) => AsyncIterable<Item>);
    private onRequest;
}
//# sourceMappingURL=asyncIterableToEvents.d.ts.map