@onebun/core 0.1.20 → 0.1.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -26,6 +26,11 @@ export interface WsAuthData {
26
26
  token?: string;
27
27
  }
28
28
 
29
+ /**
30
+ * WebSocket protocol used by the client
31
+ */
32
+ export type WsProtocol = 'native' | 'socketio';
33
+
29
34
  /**
30
35
  * WebSocket client data (fixed fields)
31
36
  */
@@ -40,6 +45,8 @@ export interface WsClientData {
40
45
  auth: WsAuthData | null;
41
46
  /** Custom metadata */
42
47
  metadata: Record<string, unknown>;
48
+ /** Protocol used by the client */
49
+ protocol: WsProtocol;
43
50
  }
44
51
 
45
52
  /**
@@ -178,18 +185,30 @@ export interface WsStorageOptions {
178
185
  };
179
186
  }
180
187
 
188
+ /**
189
+ * Socket.IO-specific options (optional; when enabled, Socket.IO runs on its own path)
190
+ */
191
+ export interface WebSocketSocketIOOptions {
192
+ /** Enable Socket.IO protocol (default: false) */
193
+ enabled?: boolean;
194
+ /** Path for Socket.IO connections (default: '/socket.io') */
195
+ path?: string;
196
+ /** Ping interval in milliseconds (default: 25000) */
197
+ pingInterval?: number;
198
+ /** Ping timeout in milliseconds (default: 20000) */
199
+ pingTimeout?: number;
200
+ }
201
+
181
202
  /**
182
203
  * WebSocket configuration for OneBunApplication
183
204
  */
184
205
  export interface WebSocketApplicationOptions {
185
206
  /** Enable/disable WebSocket (default: auto - enabled if gateways exist) */
186
207
  enabled?: boolean;
208
+ /** Socket.IO options; when enabled, Socket.IO is served on socketio.path */
209
+ socketio?: WebSocketSocketIOOptions;
187
210
  /** Storage options */
188
211
  storage?: WsStorageOptions;
189
- /** Ping interval in milliseconds for heartbeat (socket.io) */
190
- pingInterval?: number;
191
- /** Ping timeout in milliseconds (socket.io) */
192
- pingTimeout?: number;
193
212
  /** Maximum payload size in bytes */
194
213
  maxPayload?: number;
195
214
  }
@@ -315,15 +334,19 @@ export function isWsHandlerResponse(value: unknown): value is WsHandlerResponse
315
334
  * Check if value is a valid WsClientData
316
335
  */
317
336
  export function isWsClientData(value: unknown): value is WsClientData {
337
+ const v = value as WsClientData;
338
+
318
339
  return (
319
340
  typeof value === 'object' &&
320
341
  value !== null &&
321
342
  'id' in value &&
322
- typeof (value as WsClientData).id === 'string' &&
343
+ typeof v.id === 'string' &&
323
344
  'rooms' in value &&
324
- Array.isArray((value as WsClientData).rooms) &&
345
+ Array.isArray(v.rooms) &&
325
346
  'connectedAt' in value &&
326
- typeof (value as WsClientData).connectedAt === 'number'
347
+ typeof v.connectedAt === 'number' &&
348
+ 'protocol' in value &&
349
+ (v.protocol === 'native' || v.protocol === 'socketio')
327
350
  );
328
351
  }
329
352