@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.mjs CHANGED
@@ -279,6 +279,9 @@ var MeetingState = class {
279
279
  this.localParticipant = {
280
280
  id: patch.id ?? "",
281
281
  name: patch.name ?? "",
282
+ isHost: patch.isHost ?? false,
283
+ isModerator: patch.isModerator ?? false,
284
+ permissions: patch.permissions,
282
285
  media: {
283
286
  stream: patch.media?.stream ?? null,
284
287
  // ◄ FIX: Capture the stream from the patch here
@@ -318,6 +321,9 @@ var MeetingState = class {
318
321
  ...prev,
319
322
  id: patch.id ?? prev.id,
320
323
  name: patch.name ?? prev.name,
324
+ isHost: patch.isHost ?? prev.isHost,
325
+ isModerator: patch.isModerator ?? prev.isModerator,
326
+ permissions: patch.permissions ?? prev.permissions,
321
327
  media: nextMedia
322
328
  };
323
329
  this.notify("localParticipant");
@@ -1755,8 +1761,9 @@ var SFUClient = class {
1755
1761
  }
1756
1762
  }
1757
1763
  async cancelJoinRequest(requestId) {
1758
- if (!requestId) throw new Error("requestId is required");
1759
- if (!this.send({ type: "cancel_join_request", payload: { request_id: requestId } })) {
1764
+ const id = requestId || this.pendingJoinRequestId;
1765
+ if (!id) return;
1766
+ if (!this.send({ type: "cancel_join_request", payload: { request_id: id } })) {
1760
1767
  throw new Error("SFU signaling is not connected");
1761
1768
  }
1762
1769
  this.pendingJoinRequestId = null;
@@ -1764,6 +1771,18 @@ var SFUClient = class {
1764
1771
  async muteAllAudio() {
1765
1772
  if (!this.send({ type: "mute_all_audio" })) throw new Error("SFU signaling is not connected");
1766
1773
  }
1774
+ async muteParticipant(participantId) {
1775
+ if (!participantId) throw new Error("participantId is required");
1776
+ if (!this.send({ type: "mute_participant", payload: { participant_id: participantId } })) {
1777
+ throw new Error("SFU signaling is not connected");
1778
+ }
1779
+ }
1780
+ async unmuteParticipant(participantId) {
1781
+ if (!participantId) throw new Error("participantId is required");
1782
+ if (!this.send({ type: "unmute_participant", payload: { participant_id: participantId } })) {
1783
+ throw new Error("SFU signaling is not connected");
1784
+ }
1785
+ }
1767
1786
  async unmuteAllAudio() {
1768
1787
  if (!this.send({ type: "unmute_all_audio" })) throw new Error("SFU signaling is not connected");
1769
1788
  }
@@ -2332,7 +2351,7 @@ var VideoSDKCore = class {
2332
2351
  onParticipantPermissionsChanged: (participantId, permissions) => {
2333
2352
  if (participantId === this.myId) {
2334
2353
  const current = this.state.localParticipant;
2335
- this.state.updateLocalParticipant({ id: this.myId, name: this.participantName, isHost: Boolean(permissions?.moderate) && current?.isHost, isModerator: Boolean(permissions?.moderate), permissions });
2354
+ this.state.updateLocalParticipant({ id: this.myId, name: this.participantName, isHost: current?.isHost, isModerator: Boolean(permissions?.moderate), permissions });
2336
2355
  }
2337
2356
  },
2338
2357
  onJoinRequested: (request) => {
@@ -2694,6 +2713,14 @@ var VideoSDKCore = class {
2694
2713
  if (!this.sfuClient) throw new Error("SFU client is not connected");
2695
2714
  return this.sfuClient.muteAllAudio();
2696
2715
  }
2716
+ async muteParticipant(participantId) {
2717
+ if (!this.sfuClient) throw new Error("SFU client is not connected");
2718
+ return this.sfuClient.muteParticipant(participantId);
2719
+ }
2720
+ async unmuteParticipant(participantId) {
2721
+ if (!this.sfuClient) throw new Error("SFU client is not connected");
2722
+ return this.sfuClient.unmuteParticipant(participantId);
2723
+ }
2697
2724
  async unmuteAllAudio() {
2698
2725
  if (!this.sfuClient) throw new Error("SFU client is not connected");
2699
2726
  return this.sfuClient.unmuteAllAudio();
@@ -2941,6 +2968,9 @@ var MeetingProvider = ({
2941
2968
  const entryResponseListeners = useRef(
2942
2969
  /* @__PURE__ */ new Set()
2943
2970
  );
2971
+ const joinRequestCanceledListeners = useRef(/* @__PURE__ */ new Set());
2972
+ const participantRemovedListeners = useRef(/* @__PURE__ */ new Set());
2973
+ const participantPermissionsChangedListeners = useRef(/* @__PURE__ */ new Set());
2944
2974
  const meetingLeftListeners = useRef(/* @__PURE__ */ new Set());
2945
2975
  const trackStateListeners = useRef(/* @__PURE__ */ new Set());
2946
2976
  const recordingStartedListeners = useRef(/* @__PURE__ */ new Set());
@@ -2972,6 +3002,15 @@ var MeetingProvider = ({
2972
3002
  onEntryResponded: (p, d) => {
2973
3003
  entryResponseListeners.current.forEach((fn) => fn(p, d));
2974
3004
  },
3005
+ onJoinRequestCanceled: (requestId) => {
3006
+ joinRequestCanceledListeners.current.forEach((fn) => fn(requestId));
3007
+ },
3008
+ onParticipantRemoved: (participantId, removedBy) => {
3009
+ participantRemovedListeners.current.forEach((fn) => fn(participantId, removedBy));
3010
+ },
3011
+ onParticipantPermissionsChanged: (participantId, permissions) => {
3012
+ participantPermissionsChangedListeners.current.forEach((fn) => fn(participantId, permissions));
3013
+ },
2975
3014
  onMeetingLeft: () => {
2976
3015
  meetingLeftListeners.current.forEach((fn) => fn());
2977
3016
  },
@@ -3135,6 +3174,8 @@ var MeetingProvider = ({
3135
3174
  cancelJoinRequest: sdk.cancelJoinRequest.bind(sdk),
3136
3175
  muteAllAudio: sdk.muteAllAudio.bind(sdk),
3137
3176
  unmuteAllAudio: sdk.unmuteAllAudio.bind(sdk),
3177
+ muteParticipant: sdk.muteParticipant.bind(sdk),
3178
+ unmuteParticipant: sdk.unmuteParticipant.bind(sdk),
3138
3179
  removeParticipant: sdk.removeParticipant.bind(sdk),
3139
3180
  getModerators: sdk.getModerators.bind(sdk),
3140
3181
  addModerator: sdk.addModerator.bind(sdk),
@@ -3160,6 +3201,24 @@ var MeetingProvider = ({
3160
3201
  entryResponseListeners.current.delete(cb);
3161
3202
  };
3162
3203
  },
3204
+ onJoinRequestCanceled: (cb) => {
3205
+ joinRequestCanceledListeners.current.add(cb);
3206
+ return () => {
3207
+ joinRequestCanceledListeners.current.delete(cb);
3208
+ };
3209
+ },
3210
+ onParticipantRemoved: (cb) => {
3211
+ participantRemovedListeners.current.add(cb);
3212
+ return () => {
3213
+ participantRemovedListeners.current.delete(cb);
3214
+ };
3215
+ },
3216
+ onParticipantPermissionsChanged: (cb) => {
3217
+ participantPermissionsChangedListeners.current.add(cb);
3218
+ return () => {
3219
+ participantPermissionsChangedListeners.current.delete(cb);
3220
+ };
3221
+ },
3163
3222
  onMeetingLeft: (cb) => {
3164
3223
  meetingLeftListeners.current.add(cb);
3165
3224
  return () => {
@@ -3278,6 +3337,18 @@ var useMeeting = (handlers) => {
3278
3337
  if (!handlers?.onEntryResponded) return;
3279
3338
  return ctx.onEntryResponded(handlers.onEntryResponded);
3280
3339
  }, [handlers?.onEntryResponded]);
3340
+ useEffect3(() => {
3341
+ if (!handlers?.onJoinRequestCanceled) return;
3342
+ return ctx.onJoinRequestCanceled(handlers.onJoinRequestCanceled);
3343
+ }, [handlers?.onJoinRequestCanceled]);
3344
+ useEffect3(() => {
3345
+ if (!handlers?.onParticipantRemoved) return;
3346
+ return ctx.onParticipantRemoved(handlers.onParticipantRemoved);
3347
+ }, [handlers?.onParticipantRemoved]);
3348
+ useEffect3(() => {
3349
+ if (!handlers?.onParticipantPermissionsChanged) return;
3350
+ return ctx.onParticipantPermissionsChanged(handlers.onParticipantPermissionsChanged);
3351
+ }, [handlers?.onParticipantPermissionsChanged]);
3281
3352
  useEffect3(() => {
3282
3353
  if (!handlers?.onMeetingLeft) return;
3283
3354
  return ctx.onMeetingLeft(handlers.onMeetingLeft);