///
import { Dispatcher } from 'undici';
import { InputGatedEventTarget } from '@miniflare/shared';
import { kWrapListener } from '@miniflare/shared';
import { Plugin } from '@miniflare/shared';
import { PluginContext } from '@miniflare/shared';
import { RequestInfo } from '@miniflare/core';
import { RequestInit } from '@miniflare/core';
import { Response } from '@miniflare/core';
import { SetupResult } from '@miniflare/shared';
import StandardWebSocket from 'ws';
export declare class CloseEvent extends Event {
readonly code: number;
readonly reason: string;
readonly wasClean: boolean;
constructor(type: "close", init?: {
code?: number;
reason?: string;
wasClean?: boolean;
});
}
export declare function coupleWebSocket(ws: StandardWebSocket, pair: WebSocket_2): Promise;
export declare class ErrorEvent extends Event {
readonly error: Error | null;
constructor(type: "error", init?: {
error?: Error;
});
}
declare const kAccepted: unique symbol;
/* Excluded from this release type: _kClose */
declare const kClosedIncoming: unique symbol;
declare const kClosedOutgoing: unique symbol;
declare const kConstructOnly: unique symbol;
declare const kCoupled: unique symbol;
declare const kError: unique symbol;
declare const kPair: unique symbol;
declare const kSend: unique symbol;
export declare class MessageEvent extends Event {
readonly data: ArrayBuffer | string;
constructor(type: "message", init: {
data: ArrayBuffer | string;
});
}
export declare function upgradingFetch(this: Dispatcher | unknown, input: RequestInfo, init?: RequestInit): Promise;
declare class WebSocket_2 extends InputGatedEventTarget {
#private;
static readonly READY_STATE_CONNECTING = 0;
static readonly READY_STATE_OPEN = 1;
static readonly READY_STATE_CLOSING = 2;
static readonly READY_STATE_CLOSED = 3;
[kPair]: WebSocket_2;
[kAccepted]: boolean;
[kCoupled]: boolean;
[kClosedOutgoing]: boolean;
[kClosedIncoming]: boolean;
constructor(url: string | URL, protocols?: string | string[]);
constructor(flag: typeof kConstructOnly);
protected [kWrapListener](listener: (event: WebSocketEventMap[Type]) => void): (event: WebSocketEventMap[Type]) => void;
get readyState(): number;
accept(): void;
send(message: ArrayBuffer | string): void;
/* Excluded from this release type: [kSend] */
close(code?: number, reason?: string): void;
/* Excluded from this release type: [_kClose] */
/* Excluded from this release type: [kError] */
}
export { WebSocket_2 as WebSocket }
export declare type WebSocketEventMap = {
open: Event;
message: MessageEvent;
close: CloseEvent;
error: ErrorEvent;
};
export declare type WebSocketPair = {
0: WebSocket_2;
1: WebSocket_2;
};
export declare const WebSocketPair: {
new (): WebSocketPair;
};
export declare class WebSocketPlugin extends Plugin {
#private;
constructor(ctx: PluginContext);
setup(): SetupResult;
fetch: (input: RequestInfo, init?: RequestInit | undefined) => Promise;
reload(): void;
dispose(): void;
}
export { }