diff --git a/packages/http/src/adapter/index.d.ts b/packages/http/src/adapter/index.d.ts index 0107dba..10a1d22 100644 --- a/packages/http/src/adapter/index.d.ts +++ b/packages/http/src/adapter/index.d.ts @@ -1,6 +1,62 @@ import { LookupAddress } from 'dns' import { HTTP } from '../index.ts' -export { WebSocket } export function loadFile(url: string): Promise export function lookup(address: string): Promise + +export namespace WebSocket { + /** The connection is not yet open. */ + export const CONNECTING = 0 + /** The connection is open and ready to communicate. */ + export const OPEN = 1 + /** The connection is in the process of closing. */ + export const CLOSING = 2 + /** The connection is closed. */ + export const CLOSED = 3 + + export type ReadyState = + | typeof CONNECTING + | typeof OPEN + | typeof CLOSING + | typeof CLOSED + + export interface EventMap { + open: Event + error: ErrorEvent + message: MessageEvent + close: CloseEvent + } + + export interface EventListener { + (event: Event): void + } + + export interface Event { + type: string + target: WebSocket + } + + export interface CloseEvent extends Event { + code: number + reason: string + } + + export interface MessageEvent extends Event { + data: string + } + + export interface ErrorEvent extends Event { + message?: string + } +} + +export interface WebSocket { + readonly url?: string + readonly protocol?: string + readonly readyState?: number + close(code?: number, reason?: string): void + send(data: string): void + dispatchEvent?(event: any): boolean + addEventListener(type: K, listener: (event: WebSocket.EventMap[K]) => void): void + removeEventListener(type: K, listener: (event: WebSocket.EventMap[K]) => void): void +} diff --git a/readme.md b/readme.md deleted file mode 100644 index ea2d625..0000000 --- a/readme.md +++ /dev/null @@ -1,3 +0,0 @@ -# @cordisjs/std - -Standard library for Cordis.