@defcomm/meetingsdk 0.5.2 → 0.5.4

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
@@ -260,9 +260,9 @@ var MeetingState = class {
260
260
  cameraTrack: void 0,
261
261
  screenTrack: void 0,
262
262
  audioTrack: void 0,
263
- micEnabled: true,
264
- camEnabled: true,
265
- isScreenSharing: false,
263
+ micEnabled: p.media?.micEnabled ?? false,
264
+ camEnabled: p.media?.camEnabled ?? false,
265
+ isScreenSharing: p.media?.isScreenSharing ?? false,
266
266
  ...p.media,
267
267
  ...patch
268
268
  }
@@ -852,9 +852,15 @@ var SFUClient = class {
852
852
  if (!participantId) break;
853
853
  const participant = this.participants.get(participantId);
854
854
  if (participant) {
855
- this.participants.set(participantId, { ...participant, permissions: payload.permissions });
855
+ this.participants.set(participantId, {
856
+ ...participant,
857
+ permissions: payload.permissions
858
+ });
856
859
  }
857
- this.onParticipantPermissionsChanged(participantId, payload.permissions);
860
+ this.onParticipantPermissionsChanged(
861
+ participantId,
862
+ payload.permissions
863
+ );
858
864
  break;
859
865
  }
860
866
  case "publish_answer": {
@@ -1769,42 +1775,48 @@ var SFUClient = class {
1769
1775
  this.pendingJoinRequestId = null;
1770
1776
  }
1771
1777
  async muteAllAudio() {
1772
- if (!this.send({ type: "mute_all_audio" })) throw new Error("SFU signaling is not connected");
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 } })) {
1778
+ if (!this.send({ type: "mute_all_audio" }))
1777
1779
  throw new Error("SFU signaling is not connected");
1778
- }
1779
1780
  }
1780
- async unmuteParticipant(participantId) {
1781
+ async muteParticipant(participantId) {
1781
1782
  if (!participantId) throw new Error("participantId is required");
1782
- if (!this.send({ type: "unmute_participant", payload: { participant_id: participantId } })) {
1783
+ if (!this.send({
1784
+ type: "mute_participant",
1785
+ payload: { participant_id: participantId }
1786
+ })) {
1783
1787
  throw new Error("SFU signaling is not connected");
1784
1788
  }
1785
1789
  }
1786
- async unmuteAllAudio() {
1787
- if (!this.send({ type: "unmute_all_audio" })) throw new Error("SFU signaling is not connected");
1788
- }
1789
1790
  async removeParticipant(participantId) {
1790
1791
  if (!participantId) throw new Error("participantId is required");
1791
- if (!this.send({ type: "remove_participant", payload: { participant_id: participantId } })) {
1792
+ if (!this.send({
1793
+ type: "remove_participant",
1794
+ payload: { participant_id: participantId }
1795
+ })) {
1792
1796
  throw new Error("SFU signaling is not connected");
1793
1797
  }
1794
1798
  }
1795
1799
  async getModerators(roomCode) {
1796
- return this.request(`${this.apiBase}/rooms/${encodeURIComponent(roomCode)}/moderators`);
1800
+ return this.request(
1801
+ `${this.apiBase}/rooms/${encodeURIComponent(roomCode)}/moderators`
1802
+ );
1797
1803
  }
1798
1804
  async addModerator(roomCode, userId) {
1799
- return this.request(`${this.apiBase}/rooms/${encodeURIComponent(roomCode)}/moderators`, {
1800
- method: "POST",
1801
- body: JSON.stringify({ user_id: userId })
1802
- });
1805
+ return this.request(
1806
+ `${this.apiBase}/rooms/${encodeURIComponent(roomCode)}/moderators`,
1807
+ {
1808
+ method: "POST",
1809
+ body: JSON.stringify({ user_id: userId })
1810
+ }
1811
+ );
1803
1812
  }
1804
1813
  async removeModerator(roomCode, userId) {
1805
- return this.request(`${this.apiBase}/rooms/${encodeURIComponent(roomCode)}/moderators/${encodeURIComponent(userId)}`, {
1806
- method: "DELETE"
1807
- });
1814
+ return this.request(
1815
+ `${this.apiBase}/rooms/${encodeURIComponent(roomCode)}/moderators/${encodeURIComponent(userId)}`,
1816
+ {
1817
+ method: "DELETE"
1818
+ }
1819
+ );
1808
1820
  }
1809
1821
  isSocketOpen() {
1810
1822
  return this.ws?.readyState === WebSocket.OPEN;
@@ -2229,10 +2241,24 @@ var VideoSDKCore = class {
2229
2241
  this.handleSFUState(state);
2230
2242
  },
2231
2243
  onConnected: (payload, resumed) => {
2232
- console.log(`[SFU] ${resumed ? "Resumed" : "Joined"} room`, payload);
2244
+ const local = (payload?.participants || []).find(
2245
+ (participant) => participant?.participant_id === this.myId
2246
+ );
2247
+ const permissions = local?.permissions ?? payload?.permissions ?? {};
2248
+ const isModerator = Boolean(permissions?.moderate);
2249
+ const isHost = Boolean(
2250
+ local?.is_host ?? local?.isHost ?? permissions?.host
2251
+ );
2233
2252
  this.state.updateLocalParticipant({
2234
2253
  id: this.myId,
2235
- name: this.participantName
2254
+ name: local?.user_metadata?.name,
2255
+ isHost,
2256
+ isModerator,
2257
+ permissions,
2258
+ media: {
2259
+ micEnabled: !Boolean(local?.audio_muted),
2260
+ camEnabled: !Boolean(local?.video_muted)
2261
+ }
2236
2262
  });
2237
2263
  },
2238
2264
  onDisconnected: () => {
@@ -2351,7 +2377,13 @@ var VideoSDKCore = class {
2351
2377
  onParticipantPermissionsChanged: (participantId, permissions) => {
2352
2378
  if (participantId === this.myId) {
2353
2379
  const current = this.state.localParticipant;
2354
- this.state.updateLocalParticipant({ id: this.myId, name: this.participantName, isHost: current?.isHost, isModerator: Boolean(permissions?.moderate), permissions });
2380
+ this.state.updateLocalParticipant({
2381
+ id: this.myId,
2382
+ name: this.participantName,
2383
+ isHost: current?.isHost,
2384
+ isModerator: Boolean(permissions?.moderate),
2385
+ permissions
2386
+ });
2355
2387
  }
2356
2388
  },
2357
2389
  onJoinRequested: (request) => {
@@ -2717,14 +2749,6 @@ var VideoSDKCore = class {
2717
2749
  if (!this.sfuClient) throw new Error("SFU client is not connected");
2718
2750
  return this.sfuClient.muteParticipant(participantId);
2719
2751
  }
2720
- async unmuteParticipant(participantId) {
2721
- if (!this.sfuClient) throw new Error("SFU client is not connected");
2722
- return this.sfuClient.unmuteParticipant(participantId);
2723
- }
2724
- async unmuteAllAudio() {
2725
- if (!this.sfuClient) throw new Error("SFU client is not connected");
2726
- return this.sfuClient.unmuteAllAudio();
2727
- }
2728
2752
  async removeParticipant(participantId) {
2729
2753
  if (!this.sfuClient) throw new Error("SFU client is not connected");
2730
2754
  return this.sfuClient.removeParticipant(participantId);
@@ -3173,9 +3197,7 @@ var MeetingProvider = ({
3173
3197
  rejectJoinRequest: sdk.rejectJoinRequest.bind(sdk),
3174
3198
  cancelJoinRequest: sdk.cancelJoinRequest.bind(sdk),
3175
3199
  muteAllAudio: sdk.muteAllAudio.bind(sdk),
3176
- unmuteAllAudio: sdk.unmuteAllAudio.bind(sdk),
3177
3200
  muteParticipant: sdk.muteParticipant.bind(sdk),
3178
- unmuteParticipant: sdk.unmuteParticipant.bind(sdk),
3179
3201
  removeParticipant: sdk.removeParticipant.bind(sdk),
3180
3202
  getModerators: sdk.getModerators.bind(sdk),
3181
3203
  addModerator: sdk.addModerator.bind(sdk),