@defcomm/meetingsdk 0.1.0 → 0.1.2

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/index.d.mts CHANGED
@@ -14,6 +14,7 @@ type Events = {
14
14
  participantId: string;
15
15
  decision: EntryDecision;
16
16
  } | string, decision?: EntryDecision) => void;
17
+ onActiveSpeakersChanged?: (participantIds: string[]) => void;
17
18
  onJoinApproved?: (requestId: string) => void;
18
19
  onJoinRejected?: (requestId: string) => void;
19
20
  onConnectionStateChanged?: (state: string) => void;
@@ -82,6 +83,7 @@ type ChatInput = {
82
83
  };
83
84
  type MeetingConfig = {
84
85
  roomId: string;
86
+ userId?: string;
85
87
  name: string;
86
88
  audioMuted?: boolean;
87
89
  videoMuted?: boolean;
@@ -94,7 +96,7 @@ type RecordingInfo = {
94
96
  stopped_at?: string;
95
97
  active?: boolean;
96
98
  };
97
- type StateScope = "participants" | "localParticipant" | "chat" | "presenter" | `participant:${string}`;
99
+ type StateScope = "participants" | "localParticipant" | "chat" | "presenter" | "activeSpeakers" | `participant:${string}`;
98
100
  type SDKError = {
99
101
  code: string;
100
102
  message: string;
@@ -115,6 +117,10 @@ interface TrackDescriptor {
115
117
  source: "camera" | "screen" | "audio";
116
118
  mid?: string;
117
119
  }
120
+ interface Recording {
121
+ started_at?: string;
122
+ recording_id?: string;
123
+ }
118
124
 
119
125
  declare const useLocalParticipant: () => {
120
126
  participant: Participant | null;
@@ -132,10 +138,12 @@ declare class MeetingState {
132
138
  localStream: MediaStream | null;
133
139
  chatMessages: Map<string, ChatMessage>;
134
140
  presenterId: string | null;
141
+ activeSpeakerIds: Set<string>;
135
142
  private listeners;
136
143
  subscribe(scope: StateScope, fn: Listener): () => void;
137
144
  notify(scope: StateScope): void;
138
145
  setPresenterId(id: string | null): void;
146
+ setActiveSpeakers(ids: string[]): void;
139
147
  addParticipant(p: Participant): boolean;
140
148
  removeParticipant(id: string): void;
141
149
  updateParticipantMedia(id: string, patch: Partial<NonNullable<Participant["media"]>>): void;
@@ -163,6 +171,9 @@ declare class VideoSDKCore {
163
171
  private intentionalDisconnect;
164
172
  private remoteStreams;
165
173
  private remoteScreenStreams;
174
+ private activeSpeakerDetector;
175
+ private joinPromise;
176
+ private disconnectPromise;
166
177
  private emitError;
167
178
  constructor(events?: Events, apiBase?: string, wsBase?: string);
168
179
  initLocal(video: HTMLVideoElement, name: string): Promise<void>;
@@ -197,6 +208,7 @@ declare class VideoSDKCore {
197
208
  sendChatMessage(payload: ChatInput): void;
198
209
  private cleanupRemoteParticipant;
199
210
  disconnect(): Promise<void>;
211
+ private performDisconnect;
200
212
  }
201
213
 
202
214
  /**
@@ -426,6 +438,7 @@ type MeetingContextValue = {
426
438
  participants: Map<string, Participant>;
427
439
  messages: ChatMessage[];
428
440
  presenterId: string | null;
441
+ activeSpeakerIds: string[];
429
442
  usePubSub: (topic: PubSubTopic) => PubSubHandle;
430
443
  approveJoinRequest: (requestId: string) => void;
431
444
  rejectJoinRequest: (requestId: string) => void;
@@ -437,8 +450,9 @@ type MeetingContextValue = {
437
450
  onEntryResponded: (cb: (payload: any, decision?: any) => void) => () => void;
438
451
  onMeetingLeft: (cb: () => void) => () => void;
439
452
  onTrackStateChanged: (cb: (track: any) => void) => () => void;
440
- onRecordingStarted: (cb: (recording: any) => void) => () => void;
453
+ onRecordingStarted: (cb: (recording: Recording) => void) => () => void;
441
454
  onRecordingStopped: (cb: (recording: any) => void) => () => void;
455
+ onActiveSpeakersChanged: (cb: (participantIds: string[]) => void) => () => void;
442
456
  };
443
457
  declare const MeetingProvider: ({ config, children, }: {
444
458
  config: MeetingConfig;
@@ -454,6 +468,7 @@ declare const useMeeting: (handlers?: {
454
468
  onTrackStateChanged?: (track: any) => void;
455
469
  onRecordingStarted?: (recording: any) => void;
456
470
  onRecordingStopped?: (recording: any) => void;
471
+ onActiveSpeakersChanged?: (participantIds: string[]) => void;
457
472
  }) => {
458
473
  join: (config?: MeetingConfig) => Promise<void>;
459
474
  leave: () => void;
@@ -478,6 +493,7 @@ declare const useMeeting: (handlers?: {
478
493
  participants: Map<string, Participant>;
479
494
  messages: ChatMessage[];
480
495
  presenterId: string | null;
496
+ activeSpeakerIds: string[];
481
497
  usePubSub: (topic: PubSubTopic) => {
482
498
  messages: ChatMessage[];
483
499
  publish: (input: ChatInput) => void;
@@ -492,8 +508,9 @@ declare const useMeeting: (handlers?: {
492
508
  onEntryResponded: (cb: (payload: any, decision?: any) => void) => () => void;
493
509
  onMeetingLeft: (cb: () => void) => () => void;
494
510
  onTrackStateChanged: (cb: (track: any) => void) => () => void;
495
- onRecordingStarted: (cb: (recording: any) => void) => () => void;
511
+ onRecordingStarted: (cb: (recording: Recording) => void) => () => void;
496
512
  onRecordingStopped: (cb: (recording: any) => void) => () => void;
513
+ onActiveSpeakersChanged: (cb: (participantIds: string[]) => void) => () => void;
497
514
  };
498
515
 
499
516
  declare const useParticipants: () => Participant[];
@@ -540,4 +557,36 @@ declare function useMeetingPreview(roomId: string, userId: string): {
540
557
  error: string | null;
541
558
  };
542
559
 
543
- export { type ChatInput, type MeetingConfig, MeetingProvider, MeetingState, type Participant, type ParticipantInfo, type RecordingInfo, SFUClient, type SFUConnectionState, type TrackInfo, VideoSDKCore, useLocalParticipant, useMeeting, useMeetingContext, useMeetingPreview, useParticipants, useRemoteMedia };
560
+ interface ActiveSpeakerDetectorOptions {
561
+ intervalMs?: number;
562
+ threshold?: number;
563
+ releaseThreshold?: number;
564
+ releaseMs?: number;
565
+ onActiveSpeakersChanged?: (participantIds: string[]) => void;
566
+ }
567
+ declare class ActiveSpeakerDetector {
568
+ private audioContext;
569
+ private speakers;
570
+ private timer;
571
+ private readonly intervalMs;
572
+ private readonly threshold;
573
+ private readonly releaseThreshold;
574
+ private readonly releaseMs;
575
+ private onActiveSpeakersChanged;
576
+ private lastEmitted;
577
+ constructor(options?: ActiveSpeakerDetectorOptions);
578
+ private ensureAudioContext;
579
+ resume(): Promise<void>;
580
+ addTrack(participantId: string, track: MediaStreamTrack): void;
581
+ removeParticipant(participantId: string): void;
582
+ removeTrack(track: MediaStreamTrack): void;
583
+ clear(): void;
584
+ start(): void;
585
+ stop(): void;
586
+ private sample;
587
+ private getActiveSpeakerIds;
588
+ private emitIfChanged;
589
+ destroy(): Promise<void>;
590
+ }
591
+
592
+ export { ActiveSpeakerDetector, type ChatInput, type MeetingConfig, MeetingProvider, MeetingState, type Participant, type ParticipantInfo, type RecordingInfo, SFUClient, type SFUConnectionState, type TrackInfo, VideoSDKCore, useLocalParticipant, useMeeting, useMeetingContext, useMeetingPreview, useParticipants, useRemoteMedia };
package/dist/index.d.ts CHANGED
@@ -14,6 +14,7 @@ type Events = {
14
14
  participantId: string;
15
15
  decision: EntryDecision;
16
16
  } | string, decision?: EntryDecision) => void;
17
+ onActiveSpeakersChanged?: (participantIds: string[]) => void;
17
18
  onJoinApproved?: (requestId: string) => void;
18
19
  onJoinRejected?: (requestId: string) => void;
19
20
  onConnectionStateChanged?: (state: string) => void;
@@ -82,6 +83,7 @@ type ChatInput = {
82
83
  };
83
84
  type MeetingConfig = {
84
85
  roomId: string;
86
+ userId?: string;
85
87
  name: string;
86
88
  audioMuted?: boolean;
87
89
  videoMuted?: boolean;
@@ -94,7 +96,7 @@ type RecordingInfo = {
94
96
  stopped_at?: string;
95
97
  active?: boolean;
96
98
  };
97
- type StateScope = "participants" | "localParticipant" | "chat" | "presenter" | `participant:${string}`;
99
+ type StateScope = "participants" | "localParticipant" | "chat" | "presenter" | "activeSpeakers" | `participant:${string}`;
98
100
  type SDKError = {
99
101
  code: string;
100
102
  message: string;
@@ -115,6 +117,10 @@ interface TrackDescriptor {
115
117
  source: "camera" | "screen" | "audio";
116
118
  mid?: string;
117
119
  }
120
+ interface Recording {
121
+ started_at?: string;
122
+ recording_id?: string;
123
+ }
118
124
 
119
125
  declare const useLocalParticipant: () => {
120
126
  participant: Participant | null;
@@ -132,10 +138,12 @@ declare class MeetingState {
132
138
  localStream: MediaStream | null;
133
139
  chatMessages: Map<string, ChatMessage>;
134
140
  presenterId: string | null;
141
+ activeSpeakerIds: Set<string>;
135
142
  private listeners;
136
143
  subscribe(scope: StateScope, fn: Listener): () => void;
137
144
  notify(scope: StateScope): void;
138
145
  setPresenterId(id: string | null): void;
146
+ setActiveSpeakers(ids: string[]): void;
139
147
  addParticipant(p: Participant): boolean;
140
148
  removeParticipant(id: string): void;
141
149
  updateParticipantMedia(id: string, patch: Partial<NonNullable<Participant["media"]>>): void;
@@ -163,6 +171,9 @@ declare class VideoSDKCore {
163
171
  private intentionalDisconnect;
164
172
  private remoteStreams;
165
173
  private remoteScreenStreams;
174
+ private activeSpeakerDetector;
175
+ private joinPromise;
176
+ private disconnectPromise;
166
177
  private emitError;
167
178
  constructor(events?: Events, apiBase?: string, wsBase?: string);
168
179
  initLocal(video: HTMLVideoElement, name: string): Promise<void>;
@@ -197,6 +208,7 @@ declare class VideoSDKCore {
197
208
  sendChatMessage(payload: ChatInput): void;
198
209
  private cleanupRemoteParticipant;
199
210
  disconnect(): Promise<void>;
211
+ private performDisconnect;
200
212
  }
201
213
 
202
214
  /**
@@ -426,6 +438,7 @@ type MeetingContextValue = {
426
438
  participants: Map<string, Participant>;
427
439
  messages: ChatMessage[];
428
440
  presenterId: string | null;
441
+ activeSpeakerIds: string[];
429
442
  usePubSub: (topic: PubSubTopic) => PubSubHandle;
430
443
  approveJoinRequest: (requestId: string) => void;
431
444
  rejectJoinRequest: (requestId: string) => void;
@@ -437,8 +450,9 @@ type MeetingContextValue = {
437
450
  onEntryResponded: (cb: (payload: any, decision?: any) => void) => () => void;
438
451
  onMeetingLeft: (cb: () => void) => () => void;
439
452
  onTrackStateChanged: (cb: (track: any) => void) => () => void;
440
- onRecordingStarted: (cb: (recording: any) => void) => () => void;
453
+ onRecordingStarted: (cb: (recording: Recording) => void) => () => void;
441
454
  onRecordingStopped: (cb: (recording: any) => void) => () => void;
455
+ onActiveSpeakersChanged: (cb: (participantIds: string[]) => void) => () => void;
442
456
  };
443
457
  declare const MeetingProvider: ({ config, children, }: {
444
458
  config: MeetingConfig;
@@ -454,6 +468,7 @@ declare const useMeeting: (handlers?: {
454
468
  onTrackStateChanged?: (track: any) => void;
455
469
  onRecordingStarted?: (recording: any) => void;
456
470
  onRecordingStopped?: (recording: any) => void;
471
+ onActiveSpeakersChanged?: (participantIds: string[]) => void;
457
472
  }) => {
458
473
  join: (config?: MeetingConfig) => Promise<void>;
459
474
  leave: () => void;
@@ -478,6 +493,7 @@ declare const useMeeting: (handlers?: {
478
493
  participants: Map<string, Participant>;
479
494
  messages: ChatMessage[];
480
495
  presenterId: string | null;
496
+ activeSpeakerIds: string[];
481
497
  usePubSub: (topic: PubSubTopic) => {
482
498
  messages: ChatMessage[];
483
499
  publish: (input: ChatInput) => void;
@@ -492,8 +508,9 @@ declare const useMeeting: (handlers?: {
492
508
  onEntryResponded: (cb: (payload: any, decision?: any) => void) => () => void;
493
509
  onMeetingLeft: (cb: () => void) => () => void;
494
510
  onTrackStateChanged: (cb: (track: any) => void) => () => void;
495
- onRecordingStarted: (cb: (recording: any) => void) => () => void;
511
+ onRecordingStarted: (cb: (recording: Recording) => void) => () => void;
496
512
  onRecordingStopped: (cb: (recording: any) => void) => () => void;
513
+ onActiveSpeakersChanged: (cb: (participantIds: string[]) => void) => () => void;
497
514
  };
498
515
 
499
516
  declare const useParticipants: () => Participant[];
@@ -540,4 +557,36 @@ declare function useMeetingPreview(roomId: string, userId: string): {
540
557
  error: string | null;
541
558
  };
542
559
 
543
- export { type ChatInput, type MeetingConfig, MeetingProvider, MeetingState, type Participant, type ParticipantInfo, type RecordingInfo, SFUClient, type SFUConnectionState, type TrackInfo, VideoSDKCore, useLocalParticipant, useMeeting, useMeetingContext, useMeetingPreview, useParticipants, useRemoteMedia };
560
+ interface ActiveSpeakerDetectorOptions {
561
+ intervalMs?: number;
562
+ threshold?: number;
563
+ releaseThreshold?: number;
564
+ releaseMs?: number;
565
+ onActiveSpeakersChanged?: (participantIds: string[]) => void;
566
+ }
567
+ declare class ActiveSpeakerDetector {
568
+ private audioContext;
569
+ private speakers;
570
+ private timer;
571
+ private readonly intervalMs;
572
+ private readonly threshold;
573
+ private readonly releaseThreshold;
574
+ private readonly releaseMs;
575
+ private onActiveSpeakersChanged;
576
+ private lastEmitted;
577
+ constructor(options?: ActiveSpeakerDetectorOptions);
578
+ private ensureAudioContext;
579
+ resume(): Promise<void>;
580
+ addTrack(participantId: string, track: MediaStreamTrack): void;
581
+ removeParticipant(participantId: string): void;
582
+ removeTrack(track: MediaStreamTrack): void;
583
+ clear(): void;
584
+ start(): void;
585
+ stop(): void;
586
+ private sample;
587
+ private getActiveSpeakerIds;
588
+ private emitIfChanged;
589
+ destroy(): Promise<void>;
590
+ }
591
+
592
+ export { ActiveSpeakerDetector, type ChatInput, type MeetingConfig, MeetingProvider, MeetingState, type Participant, type ParticipantInfo, type RecordingInfo, SFUClient, type SFUConnectionState, type TrackInfo, VideoSDKCore, useLocalParticipant, useMeeting, useMeetingContext, useMeetingPreview, useParticipants, useRemoteMedia };