@marianmeres/webrtc 1.3.1 → 1.4.1

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.js CHANGED
@@ -2,41 +2,41 @@
2
2
  * Possible states of the WebRTC connection lifecycle.
3
3
  * The manager transitions between these states based on connection events.
4
4
  */
5
- export var WebRtcState;
6
- (function (WebRtcState) {
5
+ export var WebRTCState;
6
+ (function (WebRTCState) {
7
7
  /** Initial state, no resources allocated. */
8
- WebRtcState["IDLE"] = "IDLE";
8
+ WebRTCState["IDLE"] = "IDLE";
9
9
  /** Creating peer connection and setting up media tracks. */
10
- WebRtcState["INITIALIZING"] = "INITIALIZING";
10
+ WebRTCState["INITIALIZING"] = "INITIALIZING";
11
11
  /** Performing SDP offer/answer exchange. */
12
- WebRtcState["CONNECTING"] = "CONNECTING";
12
+ WebRTCState["CONNECTING"] = "CONNECTING";
13
13
  /** Connection established, communication active. */
14
- WebRtcState["CONNECTED"] = "CONNECTED";
14
+ WebRTCState["CONNECTED"] = "CONNECTED";
15
15
  /** Automatic reconnection in progress. */
16
- WebRtcState["RECONNECTING"] = "RECONNECTING";
16
+ WebRTCState["RECONNECTING"] = "RECONNECTING";
17
17
  /** Connection closed, can be restarted. */
18
- WebRtcState["DISCONNECTED"] = "DISCONNECTED";
18
+ WebRTCState["DISCONNECTED"] = "DISCONNECTED";
19
19
  /** Error state, requires reset() to recover. */
20
- WebRtcState["ERROR"] = "ERROR";
21
- })(WebRtcState || (WebRtcState = {}));
20
+ WebRTCState["ERROR"] = "ERROR";
21
+ })(WebRTCState || (WebRTCState = {}));
22
22
  /**
23
23
  * Internal FSM events that trigger state transitions.
24
24
  * These events are dispatched internally by the manager methods.
25
25
  */
26
- export var WebRtcFsmEvent;
27
- (function (WebRtcFsmEvent) {
26
+ export var WebRTCFsmEvent;
27
+ (function (WebRTCFsmEvent) {
28
28
  /** Triggers transition from IDLE to INITIALIZING. */
29
- WebRtcFsmEvent["INIT"] = "initialize";
29
+ WebRTCFsmEvent["INIT"] = "initialize";
30
30
  /** Triggers transition to CONNECTING state. */
31
- WebRtcFsmEvent["CONNECT"] = "connect";
31
+ WebRTCFsmEvent["CONNECT"] = "connect";
32
32
  /** Signals successful connection establishment. */
33
- WebRtcFsmEvent["CONNECTED"] = "connected";
33
+ WebRTCFsmEvent["CONNECTED"] = "connected";
34
34
  /** Triggers transition to RECONNECTING state. */
35
- WebRtcFsmEvent["RECONNECTING"] = "reconnecting";
35
+ WebRTCFsmEvent["RECONNECTING"] = "reconnecting";
36
36
  /** Triggers transition to DISCONNECTED state. */
37
- WebRtcFsmEvent["DISCONNECT"] = "disconnect";
37
+ WebRTCFsmEvent["DISCONNECT"] = "disconnect";
38
38
  /** Triggers transition to ERROR state. */
39
- WebRtcFsmEvent["ERROR"] = "error";
39
+ WebRTCFsmEvent["ERROR"] = "error";
40
40
  /** Resets the manager to IDLE state. */
41
- WebRtcFsmEvent["RESET"] = "reset";
42
- })(WebRtcFsmEvent || (WebRtcFsmEvent = {}));
41
+ WebRTCFsmEvent["RESET"] = "reset";
42
+ })(WebRTCFsmEvent || (WebRTCFsmEvent = {}));
@@ -1,4 +1,4 @@
1
- import { type WebRtcFactory, type WebRtcManagerConfig, WebRtcState, type WebRtcEvents, type GatherIceCandidatesOptions } from "./types.js";
1
+ import { type WebRTCFactory, type WebRTCManagerConfig, WebRTCState, type WebRTCEvents, type GatherIceCandidatesOptions } from "./types.js";
2
2
  /**
3
3
  * WebRTC connection manager with FSM-based lifecycle and event-driven architecture.
4
4
  *
@@ -14,7 +14,7 @@ import { type WebRtcFactory, type WebRtcManagerConfig, WebRtcState, type WebRtcE
14
14
  * enumerateDevices: () => navigator.mediaDevices.enumerateDevices(),
15
15
  * };
16
16
  *
17
- * const manager = new WebRtcManager(factory, {
17
+ * const manager = new WebRTCManager(factory, {
18
18
  * peerConfig: { iceServers: [{ urls: 'stun:stun.l.google.com:19302' }] },
19
19
  * enableMicrophone: true,
20
20
  * });
@@ -25,9 +25,9 @@ import { type WebRtcFactory, type WebRtcManagerConfig, WebRtcState, type WebRtcE
25
25
  * await manager.setLocalDescription(offer);
26
26
  * ```
27
27
  */
28
- export declare class WebRtcManager<TContext = unknown> {
28
+ export declare class WebRTCManager<TContext = unknown> {
29
29
  #private;
30
- /** Event emitted when connection state changes. Payload: {@link WebRtcState} */
30
+ /** Event emitted when connection state changes. Payload: {@link WebRTCState} */
31
31
  static readonly EVENT_STATE_CHANGE = "state_change";
32
32
  /** Event emitted when local media stream changes. Payload: `MediaStream | null` */
33
33
  static readonly EVENT_LOCAL_STREAM = "local_stream";
@@ -59,24 +59,24 @@ export declare class WebRtcManager<TContext = unknown> {
59
59
  * @example
60
60
  * ```typescript
61
61
  * // With type parameter for full type safety:
62
- * const manager = new WebRtcManager<{ audioStream: MediaStream; sessionId: string }>(factory);
62
+ * const manager = new WebRTCManager<{ audioStream: MediaStream; sessionId: string }>(factory);
63
63
  * manager.context = { audioStream: myStream, sessionId: '123' };
64
64
  * manager.context.audioStream; // typed as MediaStream
65
65
  *
66
66
  * // Without type parameter (backwards compatible):
67
- * const manager = new WebRtcManager(factory);
67
+ * const manager = new WebRTCManager(factory);
68
68
  * manager.context = { anything: 'goes' };
69
69
  * ```
70
70
  */
71
71
  context: TContext | null;
72
72
  /**
73
- * Creates a new WebRtcManager instance.
73
+ * Creates a new WebRTCManager instance.
74
74
  * @param factory - Factory object providing WebRTC primitives (peer connection, media, devices).
75
75
  * @param config - Optional configuration for the manager.
76
76
  */
77
- constructor(factory: WebRtcFactory, config?: WebRtcManagerConfig);
77
+ constructor(factory: WebRTCFactory, config?: WebRTCManagerConfig);
78
78
  /** Returns the current state of the WebRTC connection. */
79
- get state(): WebRtcState;
79
+ get state(): WebRTCState;
80
80
  /** Returns a readonly map of all active data channels indexed by label. */
81
81
  get dataChannels(): ReadonlyMap<string, RTCDataChannel>;
82
82
  /** Returns the local media stream, or null if not initialized. */
@@ -93,7 +93,7 @@ export declare class WebRtcManager<TContext = unknown> {
93
93
  * @param handler - Callback function that receives the event data.
94
94
  * @returns Unsubscribe function to remove the event listener.
95
95
  */
96
- on(event: keyof WebRtcEvents, handler: (data: any) => void): () => void;
96
+ on(event: keyof WebRTCEvents, handler: (data: any) => void): () => void;
97
97
  /**
98
98
  * Subscribe to the overall state of the WebRTC manager.
99
99
  * Compatible with Svelte stores - immediately calls handler with current state,
@@ -102,7 +102,7 @@ export declare class WebRtcManager<TContext = unknown> {
102
102
  * @returns Unsubscribe function to remove the event listener.
103
103
  */
104
104
  subscribe(handler: (state: {
105
- state: WebRtcState;
105
+ state: WebRTCState;
106
106
  localStream: MediaStream | null;
107
107
  remoteStream: MediaStream | null;
108
108
  dataChannels: ReadonlyMap<string, RTCDataChannel>;