@defcomm/meetingsdk 0.6.2 → 0.6.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
@@ -286,6 +286,7 @@ var MeetingState = class {
286
286
  name: patch.name ?? "",
287
287
  isHost: patch.isHost ?? false,
288
288
  isModerator: patch.isModerator ?? false,
289
+ handRaised: patch.handRaised ?? false,
289
290
  permissions: patch.permissions,
290
291
  media: {
291
292
  stream: patch.media?.stream ?? null,
@@ -333,6 +334,21 @@ var MeetingState = class {
333
334
  };
334
335
  this.notify("localParticipant");
335
336
  }
337
+ setParticipantHandRaised(id, raised) {
338
+ const p = id === this.localParticipant?.id ? this.localParticipant : this.participants.get(id);
339
+ if (!p || p.handRaised === raised) return;
340
+ const updated = { ...p, handRaised: raised };
341
+ if (id === this.localParticipant?.id) {
342
+ this.localParticipant = updated;
343
+ this.notify("localParticipant");
344
+ } else {
345
+ const next = new Map(this.participants);
346
+ next.set(id, updated);
347
+ this.participants = next;
348
+ this.notify(`participant:${id}`);
349
+ this.notify("participants");
350
+ }
351
+ }
336
352
  // ---- chat ----
337
353
  addChatMessage(msg) {
338
354
  this.chatMessages.set(msg.id, msg);
@@ -481,6 +497,8 @@ var SFUClient = class {
481
497
  });
482
498
  this.onReaction = options.onReaction || (() => {
483
499
  });
500
+ this.onHandRaised = options.onHandRaised || (() => {
501
+ });
484
502
  this.onRoomUpdate = options.onRoomUpdate || (() => {
485
503
  });
486
504
  this.onNetworkQuality = options.onNetworkQuality || (() => {
@@ -798,8 +816,9 @@ var SFUClient = class {
798
816
  case "join_approved": {
799
817
  const requestId = payload.request_id || message.request_id;
800
818
  if (!requestId) break;
819
+ const participantId = payload.user_id || payload.participant_id || payload.participantId || payload.request?.user_id || payload.request?.participant_id;
801
820
  this.pendingJoinRequestId = requestId;
802
- this.onJoinApproved(requestId);
821
+ this.onJoinApproved(requestId, participantId);
803
822
  if (this.ws?.readyState === WebSocket.OPEN) {
804
823
  this.setState("joining");
805
824
  this.send({
@@ -822,9 +841,10 @@ var SFUClient = class {
822
841
  break;
823
842
  }
824
843
  case "join_rejected": {
825
- const requestId = payload.request_id || message.request_id;
844
+ const requestId = payload.request_id;
826
845
  const reason = payload.reason;
827
- this.onJoinRejected(requestId, reason);
846
+ const participantId = payload.user_id || payload.participant_id;
847
+ this.onJoinRejected(requestId, reason, participantId);
828
848
  this.pendingJoinRequestId = null;
829
849
  this.intentionalClose = true;
830
850
  this.failJoin(new Error(reason || "Join request rejected"));
@@ -1079,10 +1099,20 @@ var SFUClient = class {
1079
1099
  if (reaction?.id && reaction?.emoji) this.onReaction(reaction);
1080
1100
  break;
1081
1101
  }
1102
+ case "hand_raised": {
1103
+ const participantId = String(
1104
+ payload.participant_id ?? payload.participantId ?? ""
1105
+ );
1106
+ const raised = Boolean(payload.raised);
1107
+ if (participantId) this.onHandRaised(participantId, raised);
1108
+ break;
1109
+ }
1082
1110
  case "network_quality": {
1083
1111
  const raw = payload.quality || payload;
1084
1112
  const quality = {
1085
- participant_id: String(raw.participant_id ?? this.currentParticipantId ?? this.participantId),
1113
+ participant_id: String(
1114
+ raw.participant_id ?? this.currentParticipantId ?? this.participantId
1115
+ ),
1086
1116
  quality: String(raw.quality ?? "unknown"),
1087
1117
  score: Number(raw.score ?? 0),
1088
1118
  recommended_action: String(raw.recommended_action ?? "maintain"),
@@ -1542,7 +1572,9 @@ var SFUClient = class {
1542
1572
  */
1543
1573
  async getMediaDevices() {
1544
1574
  if (!navigator.mediaDevices?.enumerateDevices) {
1545
- throw new Error("Media device enumeration is not supported on this device");
1575
+ throw new Error(
1576
+ "Media device enumeration is not supported on this device"
1577
+ );
1546
1578
  }
1547
1579
  return navigator.mediaDevices.enumerateDevices();
1548
1580
  }
@@ -1862,7 +1894,9 @@ var SFUClient = class {
1862
1894
  );
1863
1895
  const text = await response.text();
1864
1896
  if (!response.ok) {
1865
- throw new Error(`Meeting summary request failed: ${response.status} ${text}`);
1897
+ throw new Error(
1898
+ `Meeting summary request failed: ${response.status} ${text}`
1899
+ );
1866
1900
  }
1867
1901
  return JSON.parse(text);
1868
1902
  }
@@ -2004,6 +2038,14 @@ var SFUClient = class {
2004
2038
  }
2005
2039
  });
2006
2040
  }
2041
+ setHandRaised(raised) {
2042
+ this.send({
2043
+ type: "set_hand_raised",
2044
+ payload: {
2045
+ raised
2046
+ }
2047
+ });
2048
+ }
2007
2049
  removeRemoteParticipant(participantId) {
2008
2050
  const stream = this.remoteStreams.get(participantId);
2009
2051
  if (stream) {
@@ -2438,6 +2480,7 @@ var VideoSDKCore = class {
2438
2480
  isHost,
2439
2481
  isModerator,
2440
2482
  permissions,
2483
+ handRaised: Boolean(local?.hand_raised),
2441
2484
  media: {
2442
2485
  micEnabled: !Boolean(local?.audio_muted),
2443
2486
  camEnabled: !Boolean(local?.video_muted)
@@ -2465,6 +2508,7 @@ var VideoSDKCore = class {
2465
2508
  this.state.updateLocalParticipant({
2466
2509
  id: this.myId,
2467
2510
  name: this.participantName,
2511
+ handRaised: Boolean(local.hand_raised),
2468
2512
  media: {
2469
2513
  micEnabled: !Boolean(local.audio_muted),
2470
2514
  camEnabled: !Boolean(local.video_muted),
@@ -2496,23 +2540,32 @@ var VideoSDKCore = class {
2496
2540
  onJoinPending: (info) => {
2497
2541
  console.log("[SFU] Join request pending", info);
2498
2542
  },
2499
- onJoinApproved: (requestId) => {
2500
- console.log("[SFU] Join approved", requestId);
2543
+ onJoinApproved: (requestId, participantId) => {
2544
+ const targetParticipantId = participantId || this.myId;
2545
+ console.log("[SFU] Join approved", {
2546
+ requestId,
2547
+ participantId: targetParticipantId
2548
+ });
2501
2549
  this.events.onJoinApproved?.(requestId);
2502
2550
  this.events.onEntryResponded?.(
2503
2551
  {
2504
- participantId: this.myId,
2552
+ participantId: targetParticipantId,
2505
2553
  decision: "approved"
2506
2554
  },
2507
2555
  "approved"
2508
2556
  );
2509
2557
  },
2510
- onJoinRejected: (requestId, reason) => {
2511
- console.warn("[SFU] Join rejected", requestId, reason);
2558
+ onJoinRejected: (requestId, reason, participantId) => {
2559
+ const targetParticipantId = participantId || this.myId;
2560
+ console.warn("[SFU] Join rejected", {
2561
+ requestId,
2562
+ participantId: targetParticipantId,
2563
+ reason
2564
+ });
2512
2565
  this.events.onJoinRejected?.(requestId);
2513
2566
  this.events.onEntryResponded?.(
2514
2567
  {
2515
- participantId: this.myId,
2568
+ participantId: targetParticipantId,
2516
2569
  decision: "rejected"
2517
2570
  },
2518
2571
  "rejected"
@@ -2543,6 +2596,10 @@ var VideoSDKCore = class {
2543
2596
  onReaction: (reaction) => {
2544
2597
  this.events.onReaction?.(reaction);
2545
2598
  },
2599
+ onHandRaised: (participantId, raised) => {
2600
+ this.state.setParticipantHandRaised(participantId, raised);
2601
+ this.events.onHandRaised?.(participantId, raised);
2602
+ },
2546
2603
  onJoinRequestCanceled: (requestId) => {
2547
2604
  this.events.onJoinRequestCanceled?.(requestId);
2548
2605
  },
@@ -2568,6 +2625,7 @@ var VideoSDKCore = class {
2568
2625
  id: this.myId,
2569
2626
  name: this.participantName,
2570
2627
  isHost: current?.isHost,
2628
+ handRaised: current?.handRaised,
2571
2629
  isModerator: Boolean(permissions?.moderate),
2572
2630
  permissions
2573
2631
  });
@@ -2597,6 +2655,7 @@ var VideoSDKCore = class {
2597
2655
  id: pid,
2598
2656
  name: pname,
2599
2657
  isModerator: Boolean(participant?.permissions?.moderate),
2658
+ handRaised: Boolean(participant?.hand_raised),
2600
2659
  permissions: participant?.permissions,
2601
2660
  connectionState: "connected",
2602
2661
  media: {
@@ -3114,6 +3173,16 @@ var VideoSDKCore = class {
3114
3173
  }
3115
3174
  this.sfuClient.sendReaction(reaction);
3116
3175
  }
3176
+ setHandRaised(raised) {
3177
+ if (!this.sfuClient) {
3178
+ console.warn("SFU Client not connected");
3179
+ return;
3180
+ }
3181
+ this.sfuClient.setHandRaised(raised);
3182
+ }
3183
+ toggleHandRaised() {
3184
+ this.setHandRaised(!Boolean(this.state.localParticipant?.handRaised));
3185
+ }
3117
3186
  /**
3118
3187
  * Generic PubSub publishing entry point.
3119
3188
  *
@@ -3234,6 +3303,9 @@ var MeetingProvider = ({
3234
3303
  const recordingStartedListeners = useRef(/* @__PURE__ */ new Set());
3235
3304
  const recordingStoppedListeners = useRef(/* @__PURE__ */ new Set());
3236
3305
  const reactionListeners = useRef(/* @__PURE__ */ new Set());
3306
+ const handRaisedListeners = useRef(
3307
+ /* @__PURE__ */ new Set()
3308
+ );
3237
3309
  const pubSubListeners = useRef(
3238
3310
  /* @__PURE__ */ new Map()
3239
3311
  );
@@ -3337,6 +3409,9 @@ var MeetingProvider = ({
3337
3409
  );
3338
3410
  pubSubListeners.current.get("REACTION")?.forEach((fn) => fn(message));
3339
3411
  },
3412
+ onHandRaised: (participantId, raised) => {
3413
+ handRaisedListeners.current.forEach((fn) => fn(participantId, raised));
3414
+ },
3340
3415
  onNetworkQuality: (quality) => {
3341
3416
  networkQualityListeners.current.forEach((fn) => fn(quality));
3342
3417
  },
@@ -3409,6 +3484,8 @@ var MeetingProvider = ({
3409
3484
  stopScreenShare: sdk.stopScreenShare.bind(sdk),
3410
3485
  sendMessage: sdk.sendChatMessage.bind(sdk),
3411
3486
  sendReaction: sdk.sendReaction.bind(sdk),
3487
+ setHandRaised: sdk.setHandRaised.bind(sdk),
3488
+ toggleHandRaised: sdk.toggleHandRaised.bind(sdk),
3412
3489
  room: sdk.getMeeting(),
3413
3490
  localParticipant,
3414
3491
  participants,
@@ -3534,6 +3611,10 @@ var MeetingProvider = ({
3534
3611
  reactionListeners.current.add(cb);
3535
3612
  return () => reactionListeners.current.delete(cb);
3536
3613
  },
3614
+ onHandRaised: (cb) => {
3615
+ handRaisedListeners.current.add(cb);
3616
+ return () => handRaisedListeners.current.delete(cb);
3617
+ },
3537
3618
  onNetworkQuality: (cb) => {
3538
3619
  networkQualityListeners.current.add(cb);
3539
3620
  return () => networkQualityListeners.current.delete(cb);
@@ -3701,6 +3782,10 @@ var useMeeting = (handlers) => {
3701
3782
  if (!handlers?.onReaction) return;
3702
3783
  return ctx.onReaction(handlers.onReaction);
3703
3784
  }, [handlers?.onReaction]);
3785
+ useEffect3(() => {
3786
+ if (!handlers?.onHandRaised) return;
3787
+ return ctx.onHandRaised(handlers.onHandRaised);
3788
+ }, [handlers?.onHandRaised]);
3704
3789
  const { sdk: _, ...publicApi } = ctx;
3705
3790
  return publicApi;
3706
3791
  };