Home / Class/ WebSocket Class — vite Architecture

WebSocket Class — vite Architecture

Architecture documentation for the WebSocket class in ws.d.ts from the vite codebase.

Entity Profile

Dependency Diagram

graph TD
  d0a9456f_e01c_21ae_c99b_bce7bfc6f4b0["WebSocket"]
  f807a74d_76fa_6b24_918f_7ef78a219c18["ws.d.ts"]
  d0a9456f_e01c_21ae_c99b_bce7bfc6f4b0 -->|defined in| f807a74d_76fa_6b24_918f_7ef78a219c18
  48b3a0b5_3d0d_9bb9_a300_ccb432d98d46["constructor()"]
  d0a9456f_e01c_21ae_c99b_bce7bfc6f4b0 -->|method| 48b3a0b5_3d0d_9bb9_a300_ccb432d98d46
  de73087d_c822_817f_584e_74a354e251da["close()"]
  d0a9456f_e01c_21ae_c99b_bce7bfc6f4b0 -->|method| de73087d_c822_817f_584e_74a354e251da
  8f048f1e_88f4_56c2_5656_1e19b32b868a["ping()"]
  d0a9456f_e01c_21ae_c99b_bce7bfc6f4b0 -->|method| 8f048f1e_88f4_56c2_5656_1e19b32b868a
  2d676861_2923_788a_97ba_f6be44d4357d["pong()"]
  d0a9456f_e01c_21ae_c99b_bce7bfc6f4b0 -->|method| 2d676861_2923_788a_97ba_f6be44d4357d
  90ef2250_3b71_8c9d_9f2c_38ff1ccc6dc9["send()"]
  d0a9456f_e01c_21ae_c99b_bce7bfc6f4b0 -->|method| 90ef2250_3b71_8c9d_9f2c_38ff1ccc6dc9
  5a85a9e4_93b1_faac_28d6_337580ea5f02["terminate()"]
  d0a9456f_e01c_21ae_c99b_bce7bfc6f4b0 -->|method| 5a85a9e4_93b1_faac_28d6_337580ea5f02
  d816b3ef_4c2b_645b_9223_ae6a1845e799["pause()"]
  d0a9456f_e01c_21ae_c99b_bce7bfc6f4b0 -->|method| d816b3ef_4c2b_645b_9223_ae6a1845e799
  49dacc53_9b0d_8d62_97be_0085bb5186ea["resume()"]
  d0a9456f_e01c_21ae_c99b_bce7bfc6f4b0 -->|method| 49dacc53_9b0d_8d62_97be_0085bb5186ea
  11a04d65_d2ed_c2b0_fbbe_66c7947b3138["addEventListener()"]
  d0a9456f_e01c_21ae_c99b_bce7bfc6f4b0 -->|method| 11a04d65_d2ed_c2b0_fbbe_66c7947b3138
  a0007171_8936_e0dc_af81_b73662e0d45a["removeEventListener()"]
  d0a9456f_e01c_21ae_c99b_bce7bfc6f4b0 -->|method| a0007171_8936_e0dc_af81_b73662e0d45a
  c14c8e97_ac40_f6c8_b163_b030de0d2974["on()"]
  d0a9456f_e01c_21ae_c99b_bce7bfc6f4b0 -->|method| c14c8e97_ac40_f6c8_b163_b030de0d2974
  1fe5254b_d7b1_a834_31b2_4fe85ed2383b["once()"]
  d0a9456f_e01c_21ae_c99b_bce7bfc6f4b0 -->|method| 1fe5254b_d7b1_a834_31b2_4fe85ed2383b
  f1da9e26_4730_12c5_2dae_c9db1671db80["off()"]
  d0a9456f_e01c_21ae_c99b_bce7bfc6f4b0 -->|method| f1da9e26_4730_12c5_2dae_c9db1671db80

Relationship Graph

Source Code

packages/vite/src/types/ws.d.ts lines 34–300

declare class WebSocket extends EventEmitter {
  /** The connection is not yet open. */
  static readonly CONNECTING: 0
  /** The connection is open and ready to communicate. */
  static readonly OPEN: 1
  /** The connection is in the process of closing. */
  static readonly CLOSING: 2
  /** The connection is closed. */
  static readonly CLOSED: 3

  binaryType: 'nodebuffer' | 'arraybuffer' | 'fragments'
  readonly bufferedAmount: number
  readonly extensions: string
  /** Indicates whether the websocket is paused */
  readonly isPaused: boolean
  readonly protocol: string
  /** The current state of the connection */
  readonly readyState:
    | typeof WebSocket.CONNECTING
    | typeof WebSocket.OPEN
    | typeof WebSocket.CLOSING
    | typeof WebSocket.CLOSED
  readonly url: string

  /** The connection is not yet open. */
  readonly CONNECTING: 0
  /** The connection is open and ready to communicate. */
  readonly OPEN: 1
  /** The connection is in the process of closing. */
  readonly CLOSING: 2
  /** The connection is closed. */
  readonly CLOSED: 3

  onopen: ((event: WebSocket.Event) => void) | null
  onerror: ((event: WebSocket.ErrorEvent) => void) | null
  onclose: ((event: WebSocket.CloseEvent) => void) | null
  onmessage: ((event: WebSocket.MessageEvent) => void) | null

  constructor(address: null)
  constructor(
    address: string | URL,
    options?: WebSocket.ClientOptions | ClientRequestArgs,
  )
  constructor(
    address: string | URL,
    protocols?: string | string[],
    options?: WebSocket.ClientOptions | ClientRequestArgs,
  )

  close(code?: number, data?: string | Buffer): void
  ping(data?: any, mask?: boolean, cb?: (err: Error) => void): void
  pong(data?: any, mask?: boolean, cb?: (err: Error) => void): void
  send(data: any, cb?: (err?: Error) => void): void
  send(
    data: any,
    options: {
      mask?: boolean | undefined
      binary?: boolean | undefined
      compress?: boolean | undefined
      fin?: boolean | undefined
    },
    cb?: (err?: Error) => void,
  ): void
  terminate(): void

  /**
   * Pause the websocket causing it to stop emitting events. Some events can still be
   * emitted after this is called, until all buffered data is consumed. This method
   * is a noop if the ready state is `CONNECTING` or `CLOSED`.
   */
  pause(): void
  /**
   * Make a paused socket resume emitting events. This method is a noop if the ready
   * state is `CONNECTING` or `CLOSED`.
   */
  resume(): void

  // HTML5 WebSocket events
  addEventListener(
    method: 'message',
    cb: (event: WebSocket.MessageEvent) => void,

Frequently Asked Questions

What is the WebSocket class?
WebSocket is a class in the vite codebase, defined in packages/vite/src/types/ws.d.ts.
Where is WebSocket defined?
WebSocket is defined in packages/vite/src/types/ws.d.ts at line 34.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free