@defcomm/meetingsdk 0.5.0 → 0.5.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
@@ -268,8 +268,10 @@ declare class VideoSDKCore {
268
268
  };
269
269
  approveJoinRequest(requestId: string): Promise<void>;
270
270
  rejectJoinRequest(requestId: string, reason?: string): Promise<void>;
271
- cancelJoinRequest(requestId: string): Promise<void | undefined>;
271
+ cancelJoinRequest(requestId?: string): Promise<void | undefined>;
272
272
  muteAllAudio(): Promise<void>;
273
+ muteParticipant(participantId: string): Promise<void>;
274
+ unmuteParticipant(participantId: string): Promise<void>;
273
275
  unmuteAllAudio(): Promise<void>;
274
276
  removeParticipant(participantId: string): Promise<void>;
275
277
  getModerators(roomCode: string): Promise<any>;
@@ -350,9 +352,11 @@ type MeetingContextValue = {
350
352
  onPubSubMessage: <T extends PubSubTopic>(topic: T, cb: (message: PubSubMessage<PubSubTopicConfig[T]["message"]>) => void) => () => void;
351
353
  approveJoinRequest: (requestId: string) => void;
352
354
  rejectJoinRequest: (requestId: string) => void;
353
- cancelJoinRequest: (requestId: string) => Promise<void> | undefined;
355
+ cancelJoinRequest: (requestId?: string) => Promise<void> | undefined;
354
356
  muteAllAudio: () => Promise<void>;
355
357
  unmuteAllAudio: () => Promise<void>;
358
+ muteParticipant: (participantId: string) => Promise<void>;
359
+ unmuteParticipant: (participantId: string) => Promise<void>;
356
360
  removeParticipant: (participantId: string) => Promise<void>;
357
361
  getModerators: (roomCode: string) => Promise<any> | undefined;
358
362
  addModerator: (roomCode: string, userId: string) => Promise<any> | undefined;
@@ -363,6 +367,9 @@ type MeetingContextValue = {
363
367
  onError: (cb: (err: any) => void) => () => void;
364
368
  onEntryRequested: (cb: (req: any) => void) => () => void;
365
369
  onEntryResponded: (cb: (payload: any, decision?: any) => void) => () => void;
370
+ onJoinRequestCanceled: (cb: (requestId: string) => void) => () => void;
371
+ onParticipantRemoved: (cb: (participantId: string, removedBy: string) => void) => () => void;
372
+ onParticipantPermissionsChanged: (cb: (participantId: string, permissions: any) => void) => () => void;
366
373
  onMeetingLeft: (cb: () => void) => () => void;
367
374
  onTrackStateChanged: (cb: (track: any) => void) => () => void;
368
375
  onRecordingStarted: (cb: (recording: Recording) => void) => () => void;
@@ -381,6 +388,9 @@ declare const useMeeting: (handlers?: {
381
388
  onError?: (err: any) => void;
382
389
  onEntryRequested?: (req: any) => void;
383
390
  onEntryResponded?: (payload: any, decision?: any) => void;
391
+ onJoinRequestCanceled?: (requestId: string) => void;
392
+ onParticipantRemoved?: (participantId: string, removedBy: string) => void;
393
+ onParticipantPermissionsChanged?: (participantId: string, permissions: any) => void;
384
394
  onMeetingLeft?: () => void;
385
395
  onTrackStateChanged?: (track: any) => void;
386
396
  onRecordingStarted?: (recording: any) => void;
@@ -420,9 +430,11 @@ declare const useMeeting: (handlers?: {
420
430
  onPubSubMessage: <T extends PubSubTopic>(topic: T, cb: (message: PubSubMessage<PubSubTopicConfig[T]["message"]>) => void) => () => void;
421
431
  approveJoinRequest: (requestId: string) => void;
422
432
  rejectJoinRequest: (requestId: string) => void;
423
- cancelJoinRequest: (requestId: string) => Promise<void> | undefined;
433
+ cancelJoinRequest: (requestId?: string) => Promise<void> | undefined;
424
434
  muteAllAudio: () => Promise<void>;
425
435
  unmuteAllAudio: () => Promise<void>;
436
+ muteParticipant: (participantId: string) => Promise<void>;
437
+ unmuteParticipant: (participantId: string) => Promise<void>;
426
438
  removeParticipant: (participantId: string) => Promise<void>;
427
439
  getModerators: (roomCode: string) => Promise<any> | undefined;
428
440
  addModerator: (roomCode: string, userId: string) => Promise<any> | undefined;
@@ -433,6 +445,9 @@ declare const useMeeting: (handlers?: {
433
445
  onError: (cb: (err: any) => void) => () => void;
434
446
  onEntryRequested: (cb: (req: any) => void) => () => void;
435
447
  onEntryResponded: (cb: (payload: any, decision?: any) => void) => () => void;
448
+ onJoinRequestCanceled: (cb: (requestId: string) => void) => () => void;
449
+ onParticipantRemoved: (cb: (participantId: string, removedBy: string) => void) => () => void;
450
+ onParticipantPermissionsChanged: (cb: (participantId: string, permissions: any) => void) => () => void;
436
451
  onMeetingLeft: (cb: () => void) => () => void;
437
452
  onTrackStateChanged: (cb: (track: any) => void) => () => void;
438
453
  onRecordingStarted: (cb: (recording: Recording) => void) => () => void;
package/dist/index.d.ts CHANGED
@@ -268,8 +268,10 @@ declare class VideoSDKCore {
268
268
  };
269
269
  approveJoinRequest(requestId: string): Promise<void>;
270
270
  rejectJoinRequest(requestId: string, reason?: string): Promise<void>;
271
- cancelJoinRequest(requestId: string): Promise<void | undefined>;
271
+ cancelJoinRequest(requestId?: string): Promise<void | undefined>;
272
272
  muteAllAudio(): Promise<void>;
273
+ muteParticipant(participantId: string): Promise<void>;
274
+ unmuteParticipant(participantId: string): Promise<void>;
273
275
  unmuteAllAudio(): Promise<void>;
274
276
  removeParticipant(participantId: string): Promise<void>;
275
277
  getModerators(roomCode: string): Promise<any>;
@@ -350,9 +352,11 @@ type MeetingContextValue = {
350
352
  onPubSubMessage: <T extends PubSubTopic>(topic: T, cb: (message: PubSubMessage<PubSubTopicConfig[T]["message"]>) => void) => () => void;
351
353
  approveJoinRequest: (requestId: string) => void;
352
354
  rejectJoinRequest: (requestId: string) => void;
353
- cancelJoinRequest: (requestId: string) => Promise<void> | undefined;
355
+ cancelJoinRequest: (requestId?: string) => Promise<void> | undefined;
354
356
  muteAllAudio: () => Promise<void>;
355
357
  unmuteAllAudio: () => Promise<void>;
358
+ muteParticipant: (participantId: string) => Promise<void>;
359
+ unmuteParticipant: (participantId: string) => Promise<void>;
356
360
  removeParticipant: (participantId: string) => Promise<void>;
357
361
  getModerators: (roomCode: string) => Promise<any> | undefined;
358
362
  addModerator: (roomCode: string, userId: string) => Promise<any> | undefined;
@@ -363,6 +367,9 @@ type MeetingContextValue = {
363
367
  onError: (cb: (err: any) => void) => () => void;
364
368
  onEntryRequested: (cb: (req: any) => void) => () => void;
365
369
  onEntryResponded: (cb: (payload: any, decision?: any) => void) => () => void;
370
+ onJoinRequestCanceled: (cb: (requestId: string) => void) => () => void;
371
+ onParticipantRemoved: (cb: (participantId: string, removedBy: string) => void) => () => void;
372
+ onParticipantPermissionsChanged: (cb: (participantId: string, permissions: any) => void) => () => void;
366
373
  onMeetingLeft: (cb: () => void) => () => void;
367
374
  onTrackStateChanged: (cb: (track: any) => void) => () => void;
368
375
  onRecordingStarted: (cb: (recording: Recording) => void) => () => void;
@@ -381,6 +388,9 @@ declare const useMeeting: (handlers?: {
381
388
  onError?: (err: any) => void;
382
389
  onEntryRequested?: (req: any) => void;
383
390
  onEntryResponded?: (payload: any, decision?: any) => void;
391
+ onJoinRequestCanceled?: (requestId: string) => void;
392
+ onParticipantRemoved?: (participantId: string, removedBy: string) => void;
393
+ onParticipantPermissionsChanged?: (participantId: string, permissions: any) => void;
384
394
  onMeetingLeft?: () => void;
385
395
  onTrackStateChanged?: (track: any) => void;
386
396
  onRecordingStarted?: (recording: any) => void;
@@ -420,9 +430,11 @@ declare const useMeeting: (handlers?: {
420
430
  onPubSubMessage: <T extends PubSubTopic>(topic: T, cb: (message: PubSubMessage<PubSubTopicConfig[T]["message"]>) => void) => () => void;
421
431
  approveJoinRequest: (requestId: string) => void;
422
432
  rejectJoinRequest: (requestId: string) => void;
423
- cancelJoinRequest: (requestId: string) => Promise<void> | undefined;
433
+ cancelJoinRequest: (requestId?: string) => Promise<void> | undefined;
424
434
  muteAllAudio: () => Promise<void>;
425
435
  unmuteAllAudio: () => Promise<void>;
436
+ muteParticipant: (participantId: string) => Promise<void>;
437
+ unmuteParticipant: (participantId: string) => Promise<void>;
426
438
  removeParticipant: (participantId: string) => Promise<void>;
427
439
  getModerators: (roomCode: string) => Promise<any> | undefined;
428
440
  addModerator: (roomCode: string, userId: string) => Promise<any> | undefined;
@@ -433,6 +445,9 @@ declare const useMeeting: (handlers?: {
433
445
  onError: (cb: (err: any) => void) => () => void;
434
446
  onEntryRequested: (cb: (req: any) => void) => () => void;
435
447
  onEntryResponded: (cb: (payload: any, decision?: any) => void) => () => void;
448
+ onJoinRequestCanceled: (cb: (requestId: string) => void) => () => void;
449
+ onParticipantRemoved: (cb: (participantId: string, removedBy: string) => void) => () => void;
450
+ onParticipantPermissionsChanged: (cb: (participantId: string, permissions: any) => void) => () => void;
436
451
  onMeetingLeft: (cb: () => void) => () => void;
437
452
  onTrackStateChanged: (cb: (track: any) => void) => () => void;
438
453
  onRecordingStarted: (cb: (recording: Recording) => void) => () => void;
package/dist/index.js CHANGED
@@ -309,6 +309,9 @@ var MeetingState = class {
309
309
  this.localParticipant = {
310
310
  id: patch.id ?? "",
311
311
  name: patch.name ?? "",
312
+ isHost: patch.isHost ?? false,
313
+ isModerator: patch.isModerator ?? false,
314
+ permissions: patch.permissions,
312
315
  media: {
313
316
  stream: patch.media?.stream ?? null,
314
317
  // ◄ FIX: Capture the stream from the patch here
@@ -348,6 +351,9 @@ var MeetingState = class {
348
351
  ...prev,
349
352
  id: patch.id ?? prev.id,
350
353
  name: patch.name ?? prev.name,
354
+ isHost: patch.isHost ?? prev.isHost,
355
+ isModerator: patch.isModerator ?? prev.isModerator,
356
+ permissions: patch.permissions ?? prev.permissions,
351
357
  media: nextMedia
352
358
  };
353
359
  this.notify("localParticipant");
@@ -1785,8 +1791,9 @@ var SFUClient = class {
1785
1791
  }
1786
1792
  }
1787
1793
  async cancelJoinRequest(requestId) {
1788
- if (!requestId) throw new Error("requestId is required");
1789
- if (!this.send({ type: "cancel_join_request", payload: { request_id: requestId } })) {
1794
+ const id = requestId || this.pendingJoinRequestId;
1795
+ if (!id) return;
1796
+ if (!this.send({ type: "cancel_join_request", payload: { request_id: id } })) {
1790
1797
  throw new Error("SFU signaling is not connected");
1791
1798
  }
1792
1799
  this.pendingJoinRequestId = null;
@@ -1794,6 +1801,18 @@ var SFUClient = class {
1794
1801
  async muteAllAudio() {
1795
1802
  if (!this.send({ type: "mute_all_audio" })) throw new Error("SFU signaling is not connected");
1796
1803
  }
1804
+ async muteParticipant(participantId) {
1805
+ if (!participantId) throw new Error("participantId is required");
1806
+ if (!this.send({ type: "mute_participant", payload: { participant_id: participantId } })) {
1807
+ throw new Error("SFU signaling is not connected");
1808
+ }
1809
+ }
1810
+ async unmuteParticipant(participantId) {
1811
+ if (!participantId) throw new Error("participantId is required");
1812
+ if (!this.send({ type: "unmute_participant", payload: { participant_id: participantId } })) {
1813
+ throw new Error("SFU signaling is not connected");
1814
+ }
1815
+ }
1797
1816
  async unmuteAllAudio() {
1798
1817
  if (!this.send({ type: "unmute_all_audio" })) throw new Error("SFU signaling is not connected");
1799
1818
  }
@@ -2362,7 +2381,7 @@ var VideoSDKCore = class {
2362
2381
  onParticipantPermissionsChanged: (participantId, permissions) => {
2363
2382
  if (participantId === this.myId) {
2364
2383
  const current = this.state.localParticipant;
2365
- this.state.updateLocalParticipant({ id: this.myId, name: this.participantName, isHost: Boolean(permissions?.moderate) && current?.isHost, isModerator: Boolean(permissions?.moderate), permissions });
2384
+ this.state.updateLocalParticipant({ id: this.myId, name: this.participantName, isHost: current?.isHost, isModerator: Boolean(permissions?.moderate), permissions });
2366
2385
  }
2367
2386
  },
2368
2387
  onJoinRequested: (request) => {
@@ -2724,6 +2743,14 @@ var VideoSDKCore = class {
2724
2743
  if (!this.sfuClient) throw new Error("SFU client is not connected");
2725
2744
  return this.sfuClient.muteAllAudio();
2726
2745
  }
2746
+ async muteParticipant(participantId) {
2747
+ if (!this.sfuClient) throw new Error("SFU client is not connected");
2748
+ return this.sfuClient.muteParticipant(participantId);
2749
+ }
2750
+ async unmuteParticipant(participantId) {
2751
+ if (!this.sfuClient) throw new Error("SFU client is not connected");
2752
+ return this.sfuClient.unmuteParticipant(participantId);
2753
+ }
2727
2754
  async unmuteAllAudio() {
2728
2755
  if (!this.sfuClient) throw new Error("SFU client is not connected");
2729
2756
  return this.sfuClient.unmuteAllAudio();
@@ -2971,6 +2998,9 @@ var MeetingProvider = ({
2971
2998
  const entryResponseListeners = (0, import_react2.useRef)(
2972
2999
  /* @__PURE__ */ new Set()
2973
3000
  );
3001
+ const joinRequestCanceledListeners = (0, import_react2.useRef)(/* @__PURE__ */ new Set());
3002
+ const participantRemovedListeners = (0, import_react2.useRef)(/* @__PURE__ */ new Set());
3003
+ const participantPermissionsChangedListeners = (0, import_react2.useRef)(/* @__PURE__ */ new Set());
2974
3004
  const meetingLeftListeners = (0, import_react2.useRef)(/* @__PURE__ */ new Set());
2975
3005
  const trackStateListeners = (0, import_react2.useRef)(/* @__PURE__ */ new Set());
2976
3006
  const recordingStartedListeners = (0, import_react2.useRef)(/* @__PURE__ */ new Set());
@@ -3002,6 +3032,15 @@ var MeetingProvider = ({
3002
3032
  onEntryResponded: (p, d) => {
3003
3033
  entryResponseListeners.current.forEach((fn) => fn(p, d));
3004
3034
  },
3035
+ onJoinRequestCanceled: (requestId) => {
3036
+ joinRequestCanceledListeners.current.forEach((fn) => fn(requestId));
3037
+ },
3038
+ onParticipantRemoved: (participantId, removedBy) => {
3039
+ participantRemovedListeners.current.forEach((fn) => fn(participantId, removedBy));
3040
+ },
3041
+ onParticipantPermissionsChanged: (participantId, permissions) => {
3042
+ participantPermissionsChangedListeners.current.forEach((fn) => fn(participantId, permissions));
3043
+ },
3005
3044
  onMeetingLeft: () => {
3006
3045
  meetingLeftListeners.current.forEach((fn) => fn());
3007
3046
  },
@@ -3165,6 +3204,8 @@ var MeetingProvider = ({
3165
3204
  cancelJoinRequest: sdk.cancelJoinRequest.bind(sdk),
3166
3205
  muteAllAudio: sdk.muteAllAudio.bind(sdk),
3167
3206
  unmuteAllAudio: sdk.unmuteAllAudio.bind(sdk),
3207
+ muteParticipant: sdk.muteParticipant.bind(sdk),
3208
+ unmuteParticipant: sdk.unmuteParticipant.bind(sdk),
3168
3209
  removeParticipant: sdk.removeParticipant.bind(sdk),
3169
3210
  getModerators: sdk.getModerators.bind(sdk),
3170
3211
  addModerator: sdk.addModerator.bind(sdk),
@@ -3190,6 +3231,24 @@ var MeetingProvider = ({
3190
3231
  entryResponseListeners.current.delete(cb);
3191
3232
  };
3192
3233
  },
3234
+ onJoinRequestCanceled: (cb) => {
3235
+ joinRequestCanceledListeners.current.add(cb);
3236
+ return () => {
3237
+ joinRequestCanceledListeners.current.delete(cb);
3238
+ };
3239
+ },
3240
+ onParticipantRemoved: (cb) => {
3241
+ participantRemovedListeners.current.add(cb);
3242
+ return () => {
3243
+ participantRemovedListeners.current.delete(cb);
3244
+ };
3245
+ },
3246
+ onParticipantPermissionsChanged: (cb) => {
3247
+ participantPermissionsChangedListeners.current.add(cb);
3248
+ return () => {
3249
+ participantPermissionsChangedListeners.current.delete(cb);
3250
+ };
3251
+ },
3193
3252
  onMeetingLeft: (cb) => {
3194
3253
  meetingLeftListeners.current.add(cb);
3195
3254
  return () => {
@@ -3308,6 +3367,18 @@ var useMeeting = (handlers) => {
3308
3367
  if (!handlers?.onEntryResponded) return;
3309
3368
  return ctx.onEntryResponded(handlers.onEntryResponded);
3310
3369
  }, [handlers?.onEntryResponded]);
3370
+ (0, import_react4.useEffect)(() => {
3371
+ if (!handlers?.onJoinRequestCanceled) return;
3372
+ return ctx.onJoinRequestCanceled(handlers.onJoinRequestCanceled);
3373
+ }, [handlers?.onJoinRequestCanceled]);
3374
+ (0, import_react4.useEffect)(() => {
3375
+ if (!handlers?.onParticipantRemoved) return;
3376
+ return ctx.onParticipantRemoved(handlers.onParticipantRemoved);
3377
+ }, [handlers?.onParticipantRemoved]);
3378
+ (0, import_react4.useEffect)(() => {
3379
+ if (!handlers?.onParticipantPermissionsChanged) return;
3380
+ return ctx.onParticipantPermissionsChanged(handlers.onParticipantPermissionsChanged);
3381
+ }, [handlers?.onParticipantPermissionsChanged]);
3311
3382
  (0, import_react4.useEffect)(() => {
3312
3383
  if (!handlers?.onMeetingLeft) return;
3313
3384
  return ctx.onMeetingLeft(handlers.onMeetingLeft);