{"version":3,"file":"web-socket-event.mjs","sourceRoot":"","sources":["../../../src/types/handlers/web-socket-event.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * The WebSocket open event.\n *\n * @property type - Always \"open\".\n * @property id - The unique identifier for the WebSocket connection.\n * @property origin - The origin of the WebSocket connection.\n */\nexport type WebSocketOpenEvent = {\n  type: 'open';\n  id: string;\n  origin: string;\n};\n\n/**\n * The WebSocket close event.\n *\n * @property type - Always \"close\".\n * @property id - The unique identifier for the WebSocket connection.\n * @property origin - The origin of the WebSocket connection.\n * @property code - The close code sent by the WebSocket server.\n * @property reason - The string indicating the reason for the connection being closed.\n * @property wasClean - A boolean value that indicates whether the connection was closed without errors.\n */\nexport type WebSocketCloseEvent = {\n  type: 'close';\n  id: string;\n  origin: string;\n  code: number;\n  reason: string | null;\n  wasClean: boolean | null;\n};\n\n/**\n * The WebSocket text message data.\n *\n * @property type - Always \"text\".\n * @property message - A string containing the message.\n */\nexport type WebSocketTextMessage = {\n  type: 'text';\n  message: string;\n};\n\n/**\n * The WebSocket binary message data.\n *\n * @property type - Always \"binary\".\n * @property message - An array of bytes containing the message.\n */\nexport type WebSocketBinaryMessage = {\n  type: 'binary';\n  message: number[];\n};\n\nexport type WebSocketMessageData =\n  | WebSocketTextMessage\n  | WebSocketBinaryMessage;\n\n/**\n * The WebSocket message event.\n *\n * @property type - Always \"message\".\n * @property id - The unique identifier for the WebSocket connection.\n * @property origin - The origin of the WebSocket connection.\n * @property data - The message data.\n */\nexport type WebSocketMessage = {\n  type: 'message';\n  id: string;\n  origin: string;\n  data: WebSocketMessageData;\n};\n\nexport type WebSocketEvent =\n  | WebSocketMessage\n  | WebSocketOpenEvent\n  | WebSocketCloseEvent;\n\n/**\n * The `onWebSocketEvent` handler, which is called when a Snap receives a WebSocket\n * event from the client.\n *\n * @param args - The request arguments.\n * @param args.event - The WebSocket event.\n * @returns Nothing.\n */\nexport type OnWebSocketEventHandler = (args: {\n  event: WebSocketEvent;\n}) => Promise<void>;\n"]}