import type { Emitter } from "@codesandbox/pitcher-common"; import type { PitcherNotification, PitcherRequest, PitcherResponse } from "@codesandbox/pitcher-protocol"; import type { PendingPitcherMessage } from "../common/PendingPitcherMessage"; export interface IRequestOptions { /** * The timeout for when to dispose the message when no response received */ timeoutMs?: number; /** * When request can not be sent, queue the message to send again on reconnect. * Defaults to: `true` */ queueForReconnect?: boolean; /** * When eligable for seamless forking, different requests requires different strategies. By default we send * the request to the current VM, but certain requests like creating a file should be be queued and then some requests * could immediately be disposed. Both "queue" and "dispose" will * emit the seamless fork required event. The "queuedDuringFork" will make the message normally go through, * but when forking it will be queued. LSP messages does this to avoid errors in the console. */ seamlessForkStrategy?: "queue" | "dispose" | "queueDuringFork"; } export type ErrorEvent = { message: string; extras: { source: string; type: string; request: PitcherRequest; }; }; export interface IPitcherMessageHandler { onInstanceChangeRequired: Emitter["event"]; onMessage: Emitter["event"]; onError: Emitter["event"]; onNotification(method: T, cb: (params: Notification extends { method: T; } ? Notification["params"] : never) => void): () => void; receiveMessage(blob: Uint8Array): void; /** * Replaces the current sending message handler with a new one, bound to a new connection. We do this instead of emitting an event * as we want to deal with any errors */ setOnSendRequest(onSendRequest: (request: PendingPitcherMessage) => void): void; request(pitcherRequest: T, options: IRequestOptions): void; getPendingMessages(): Map>; disposePendingMessages(exceptions?: Uint8Array[]): void; disableSeamlessFork(): void; flushReconnectQueue(): Promise; dispose(): void; } //# sourceMappingURL=IPitcherMessageHandler.d.ts.map