File tree Expand file tree Collapse file tree 1 file changed +14
-13
lines changed Expand file tree Collapse file tree 1 file changed +14
-13
lines changed Original file line number Diff line number Diff line change 55import { Event , ConversationCallbackType } from '../types/base' ;
66
77// Use native WebSocket in browser, ws library in Node.js
8- const WebSocketImpl = ( ( ) => {
9- if ( typeof window !== 'undefined' && window . WebSocket ) {
10- // Browser environment
11- return window . WebSocket ;
12- } else {
13- // Node.js environment
14- try {
15- const ws = require ( 'ws' ) ;
16- return ws ;
17- } catch ( e ) {
18- throw new Error ( 'WebSocket implementation not available. Install ws package for Node.js environments.' ) ;
19- }
8+ let WebSocketImpl : any ;
9+
10+ if ( typeof window !== 'undefined' && window . WebSocket ) {
11+ // Browser environment
12+ WebSocketImpl = window . WebSocket ;
13+ } else {
14+ // Node.js environment
15+ try {
16+ // eslint-disable-next-line @typescript-eslint/no-var-requires
17+ const ws = require ( 'ws' ) ;
18+ WebSocketImpl = ws ;
19+ } catch ( e ) {
20+ throw new Error ( 'WebSocket implementation not available. Install ws package for Node.js environments.' ) ;
2021 }
21- } ) ( ) ;
22+ }
2223
2324export interface WebSocketClientOptions {
2425 host : string ;
You can’t perform that action at this time.
0 commit comments