@speechos/core 0.2.5 → 0.2.6

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.
package/dist/types.d.cts CHANGED
@@ -35,6 +35,13 @@ export interface SpeechOSCoreConfig {
35
35
  host?: string;
36
36
  /** Enable debug logging */
37
37
  debug?: boolean;
38
+ /**
39
+ * Custom WebSocket factory for creating connections.
40
+ * Used by the Chrome extension to route WebSocket traffic through the
41
+ * service worker, bypassing page CSP restrictions.
42
+ * If not provided, uses the native WebSocket constructor.
43
+ */
44
+ webSocketFactory?: WebSocketFactory;
38
45
  }
39
46
  /**
40
47
  * Session settings passed when starting a voice session
@@ -236,3 +243,31 @@ export type StateChangeCallback = (newState: SpeechOSState, prevState: SpeechOSS
236
243
  * Unsubscribe function returned by event listeners
237
244
  */
238
245
  export type UnsubscribeFn = () => void;
246
+ /**
247
+ * Minimal WebSocket-like interface used by the SDK.
248
+ * This allows the extension to provide a proxy WebSocket that routes
249
+ * traffic through the service worker to bypass page CSP restrictions.
250
+ */
251
+ export interface WebSocketLike {
252
+ /** Current connection state (0=CONNECTING, 1=OPEN, 2=CLOSING, 3=CLOSED) */
253
+ readonly readyState: number;
254
+ /** Number of bytes of data queued for transmission */
255
+ readonly bufferedAmount: number;
256
+ /** Send data over the connection */
257
+ send(data: string | ArrayBuffer | Blob): void;
258
+ /** Close the connection */
259
+ close(code?: number, reason?: string): void;
260
+ /** Called when connection opens */
261
+ onopen: ((event: Event) => void) | null;
262
+ /** Called when a message is received */
263
+ onmessage: ((event: MessageEvent) => void) | null;
264
+ /** Called when an error occurs */
265
+ onerror: ((event: Event) => void) | null;
266
+ /** Called when connection closes */
267
+ onclose: ((event: CloseEvent) => void) | null;
268
+ }
269
+ /**
270
+ * Factory function type for creating WebSocket-like connections.
271
+ * Used by extensions to provide a proxy WebSocket that bypasses page CSP.
272
+ */
273
+ export type WebSocketFactory = (url: string) => WebSocketLike;
package/dist/types.d.ts CHANGED
@@ -35,6 +35,13 @@ export interface SpeechOSCoreConfig {
35
35
  host?: string;
36
36
  /** Enable debug logging */
37
37
  debug?: boolean;
38
+ /**
39
+ * Custom WebSocket factory for creating connections.
40
+ * Used by the Chrome extension to route WebSocket traffic through the
41
+ * service worker, bypassing page CSP restrictions.
42
+ * If not provided, uses the native WebSocket constructor.
43
+ */
44
+ webSocketFactory?: WebSocketFactory;
38
45
  }
39
46
  /**
40
47
  * Session settings passed when starting a voice session
@@ -236,3 +243,31 @@ export type StateChangeCallback = (newState: SpeechOSState, prevState: SpeechOSS
236
243
  * Unsubscribe function returned by event listeners
237
244
  */
238
245
  export type UnsubscribeFn = () => void;
246
+ /**
247
+ * Minimal WebSocket-like interface used by the SDK.
248
+ * This allows the extension to provide a proxy WebSocket that routes
249
+ * traffic through the service worker to bypass page CSP restrictions.
250
+ */
251
+ export interface WebSocketLike {
252
+ /** Current connection state (0=CONNECTING, 1=OPEN, 2=CLOSING, 3=CLOSED) */
253
+ readonly readyState: number;
254
+ /** Number of bytes of data queued for transmission */
255
+ readonly bufferedAmount: number;
256
+ /** Send data over the connection */
257
+ send(data: string | ArrayBuffer | Blob): void;
258
+ /** Close the connection */
259
+ close(code?: number, reason?: string): void;
260
+ /** Called when connection opens */
261
+ onopen: ((event: Event) => void) | null;
262
+ /** Called when a message is received */
263
+ onmessage: ((event: MessageEvent) => void) | null;
264
+ /** Called when an error occurs */
265
+ onerror: ((event: Event) => void) | null;
266
+ /** Called when connection closes */
267
+ onclose: ((event: CloseEvent) => void) | null;
268
+ }
269
+ /**
270
+ * Factory function type for creating WebSocket-like connections.
271
+ * Used by extensions to provide a proxy WebSocket that bypasses page CSP.
272
+ */
273
+ export type WebSocketFactory = (url: string) => WebSocketLike;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@speechos/core",
3
- "version": "0.2.5",
3
+ "version": "0.2.6",
4
4
  "description": "Headless core SDK for SpeechOS - state, events, LiveKit integration",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",