@defcomm/meetingsdk 0.6.2 → 0.6.3

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
@@ -30,6 +30,7 @@ type Events = {
30
30
  onMeetingLeft?: () => void;
31
31
  onChatMessage?: (msg: ChatMessage) => void;
32
32
  onReaction?: (reaction: Reaction) => void;
33
+ onHandRaised?: (participantId: string, raised: boolean) => void;
33
34
  onNetworkQuality?: (quality: NetworkQuality) => void;
34
35
  onScreenShareStarted?: (peerId: string, stream: MediaStream) => void;
35
36
  onScreenShareStopped?: (peerId: string) => void;
@@ -104,6 +105,7 @@ type Participant = {
104
105
  isLocal?: boolean;
105
106
  media?: ParticipantMedia;
106
107
  isPresenter?: boolean;
108
+ handRaised?: boolean;
107
109
  connectionState?: "connected" | "reconnecting" | "disconnected";
108
110
  };
109
111
  type ParticipantMedia = {
@@ -239,6 +241,7 @@ interface VideoSDKCoreOptions {
239
241
  onRoomUpdate?: (data: any) => void;
240
242
  onChatMessage?: (message: ChatMessage) => void;
241
243
  onReaction?: (reaction: Reaction) => void;
244
+ onHandRaised?: (participantId: string, raised: boolean) => void;
242
245
  onNetworkQuality?: (quality: NetworkQuality) => void;
243
246
  onMuteStateChanged?: (peerId: string, kind: "audio" | "video", muted: boolean) => void;
244
247
  }
@@ -260,6 +263,7 @@ type LocalParticipantPatch = {
260
263
  name?: string;
261
264
  isHost?: boolean;
262
265
  isModerator?: boolean;
266
+ handRaised?: boolean;
263
267
  permissions?: any;
264
268
  media?: Partial<ParticipantMedia>;
265
269
  };
@@ -284,6 +288,7 @@ declare class MeetingState {
284
288
  removeParticipant(id: string): void;
285
289
  updateParticipantMedia(id: string, patch: Partial<NonNullable<Participant["media"]>>): void;
286
290
  updateLocalParticipant(patch: LocalParticipantPatch): void;
291
+ setParticipantHandRaised(id: string, raised: boolean): void;
287
292
  addChatMessage(msg: ChatMessage): void;
288
293
  getChatMessages(): ChatMessage[];
289
294
  clearChat(): void;
@@ -359,6 +364,8 @@ declare class VideoSDKCore {
359
364
  }>;
360
365
  sendChatMessage(payload: ChatInput): void;
361
366
  sendReaction(reaction: string): void;
367
+ setHandRaised(raised: boolean): void;
368
+ toggleHandRaised(): void;
362
369
  /**
363
370
  * Generic PubSub publishing entry point.
364
371
  *
@@ -417,6 +424,8 @@ type MeetingContextValue = {
417
424
  stopScreenShare: () => void;
418
425
  sendMessage: (input: ChatInput) => void;
419
426
  sendReaction: (emoji: string) => void;
427
+ setHandRaised: (raised: boolean) => void;
428
+ toggleHandRaised: () => void;
420
429
  room: {
421
430
  id: string | null;
422
431
  name: string | null;
@@ -453,6 +462,7 @@ type MeetingContextValue = {
453
462
  onRecordingStarted: (cb: (recording: Recording) => void) => () => void;
454
463
  onRecordingStopped: (cb: (recording: any) => void) => () => void;
455
464
  onReaction: (cb: (reaction: Reaction) => void) => () => void;
465
+ onHandRaised: (cb: (participantId: string, raised: boolean) => void) => () => void;
456
466
  onConnectionStateChanged: (cb: (state: SFUConnectionState) => void) => () => void;
457
467
  onActiveSpeakersChanged: (cb: (participantIds: string[]) => void) => () => void;
458
468
  onNetworkQuality: (cb: (quality: NetworkQuality) => void) => () => void;
@@ -478,6 +488,7 @@ declare const useMeeting: (handlers?: {
478
488
  onRecordingStarted?: (recording: any) => void;
479
489
  onRecordingStopped?: (recording: any) => void;
480
490
  onReaction?: (reaction: any) => void;
491
+ onHandRaised?: (participantId: string, raised: boolean) => void;
481
492
  onActiveSpeakersChanged?: (participantIds: string[]) => void;
482
493
  onConnectionStateChanged?: (state: SFUConnectionState) => void;
483
494
  onNetworkQuality?: (quality: NetworkQuality) => void;
@@ -509,6 +520,8 @@ declare const useMeeting: (handlers?: {
509
520
  stopScreenShare: () => void;
510
521
  sendMessage: (input: ChatInput) => void;
511
522
  sendReaction: (emoji: string) => void;
523
+ setHandRaised: (raised: boolean) => void;
524
+ toggleHandRaised: () => void;
512
525
  room: {
513
526
  id: string | null;
514
527
  name: string | null;
@@ -545,6 +558,7 @@ declare const useMeeting: (handlers?: {
545
558
  onRecordingStarted: (cb: (recording: Recording) => void) => () => void;
546
559
  onRecordingStopped: (cb: (recording: any) => void) => () => void;
547
560
  onReaction: (cb: (reaction: Reaction) => void) => () => void;
561
+ onHandRaised: (cb: (participantId: string, raised: boolean) => void) => () => void;
548
562
  onConnectionStateChanged: (cb: (state: SFUConnectionState) => void) => () => void;
549
563
  onActiveSpeakersChanged: (cb: (participantIds: string[]) => void) => () => void;
550
564
  onNetworkQuality: (cb: (quality: NetworkQuality) => void) => () => void;
package/dist/index.d.ts CHANGED
@@ -30,6 +30,7 @@ type Events = {
30
30
  onMeetingLeft?: () => void;
31
31
  onChatMessage?: (msg: ChatMessage) => void;
32
32
  onReaction?: (reaction: Reaction) => void;
33
+ onHandRaised?: (participantId: string, raised: boolean) => void;
33
34
  onNetworkQuality?: (quality: NetworkQuality) => void;
34
35
  onScreenShareStarted?: (peerId: string, stream: MediaStream) => void;
35
36
  onScreenShareStopped?: (peerId: string) => void;
@@ -104,6 +105,7 @@ type Participant = {
104
105
  isLocal?: boolean;
105
106
  media?: ParticipantMedia;
106
107
  isPresenter?: boolean;
108
+ handRaised?: boolean;
107
109
  connectionState?: "connected" | "reconnecting" | "disconnected";
108
110
  };
109
111
  type ParticipantMedia = {
@@ -239,6 +241,7 @@ interface VideoSDKCoreOptions {
239
241
  onRoomUpdate?: (data: any) => void;
240
242
  onChatMessage?: (message: ChatMessage) => void;
241
243
  onReaction?: (reaction: Reaction) => void;
244
+ onHandRaised?: (participantId: string, raised: boolean) => void;
242
245
  onNetworkQuality?: (quality: NetworkQuality) => void;
243
246
  onMuteStateChanged?: (peerId: string, kind: "audio" | "video", muted: boolean) => void;
244
247
  }
@@ -260,6 +263,7 @@ type LocalParticipantPatch = {
260
263
  name?: string;
261
264
  isHost?: boolean;
262
265
  isModerator?: boolean;
266
+ handRaised?: boolean;
263
267
  permissions?: any;
264
268
  media?: Partial<ParticipantMedia>;
265
269
  };
@@ -284,6 +288,7 @@ declare class MeetingState {
284
288
  removeParticipant(id: string): void;
285
289
  updateParticipantMedia(id: string, patch: Partial<NonNullable<Participant["media"]>>): void;
286
290
  updateLocalParticipant(patch: LocalParticipantPatch): void;
291
+ setParticipantHandRaised(id: string, raised: boolean): void;
287
292
  addChatMessage(msg: ChatMessage): void;
288
293
  getChatMessages(): ChatMessage[];
289
294
  clearChat(): void;
@@ -359,6 +364,8 @@ declare class VideoSDKCore {
359
364
  }>;
360
365
  sendChatMessage(payload: ChatInput): void;
361
366
  sendReaction(reaction: string): void;
367
+ setHandRaised(raised: boolean): void;
368
+ toggleHandRaised(): void;
362
369
  /**
363
370
  * Generic PubSub publishing entry point.
364
371
  *
@@ -417,6 +424,8 @@ type MeetingContextValue = {
417
424
  stopScreenShare: () => void;
418
425
  sendMessage: (input: ChatInput) => void;
419
426
  sendReaction: (emoji: string) => void;
427
+ setHandRaised: (raised: boolean) => void;
428
+ toggleHandRaised: () => void;
420
429
  room: {
421
430
  id: string | null;
422
431
  name: string | null;
@@ -453,6 +462,7 @@ type MeetingContextValue = {
453
462
  onRecordingStarted: (cb: (recording: Recording) => void) => () => void;
454
463
  onRecordingStopped: (cb: (recording: any) => void) => () => void;
455
464
  onReaction: (cb: (reaction: Reaction) => void) => () => void;
465
+ onHandRaised: (cb: (participantId: string, raised: boolean) => void) => () => void;
456
466
  onConnectionStateChanged: (cb: (state: SFUConnectionState) => void) => () => void;
457
467
  onActiveSpeakersChanged: (cb: (participantIds: string[]) => void) => () => void;
458
468
  onNetworkQuality: (cb: (quality: NetworkQuality) => void) => () => void;
@@ -478,6 +488,7 @@ declare const useMeeting: (handlers?: {
478
488
  onRecordingStarted?: (recording: any) => void;
479
489
  onRecordingStopped?: (recording: any) => void;
480
490
  onReaction?: (reaction: any) => void;
491
+ onHandRaised?: (participantId: string, raised: boolean) => void;
481
492
  onActiveSpeakersChanged?: (participantIds: string[]) => void;
482
493
  onConnectionStateChanged?: (state: SFUConnectionState) => void;
483
494
  onNetworkQuality?: (quality: NetworkQuality) => void;
@@ -509,6 +520,8 @@ declare const useMeeting: (handlers?: {
509
520
  stopScreenShare: () => void;
510
521
  sendMessage: (input: ChatInput) => void;
511
522
  sendReaction: (emoji: string) => void;
523
+ setHandRaised: (raised: boolean) => void;
524
+ toggleHandRaised: () => void;
512
525
  room: {
513
526
  id: string | null;
514
527
  name: string | null;
@@ -545,6 +558,7 @@ declare const useMeeting: (handlers?: {
545
558
  onRecordingStarted: (cb: (recording: Recording) => void) => () => void;
546
559
  onRecordingStopped: (cb: (recording: any) => void) => () => void;
547
560
  onReaction: (cb: (reaction: Reaction) => void) => () => void;
561
+ onHandRaised: (cb: (participantId: string, raised: boolean) => void) => () => void;
548
562
  onConnectionStateChanged: (cb: (state: SFUConnectionState) => void) => () => void;
549
563
  onActiveSpeakersChanged: (cb: (participantIds: string[]) => void) => () => void;
550
564
  onNetworkQuality: (cb: (quality: NetworkQuality) => void) => () => void;
package/dist/index.js CHANGED
@@ -317,6 +317,7 @@ var MeetingState = class {
317
317
  name: patch.name ?? "",
318
318
  isHost: patch.isHost ?? false,
319
319
  isModerator: patch.isModerator ?? false,
320
+ handRaised: patch.handRaised ?? false,
320
321
  permissions: patch.permissions,
321
322
  media: {
322
323
  stream: patch.media?.stream ?? null,
@@ -364,6 +365,21 @@ var MeetingState = class {
364
365
  };
365
366
  this.notify("localParticipant");
366
367
  }
368
+ setParticipantHandRaised(id, raised) {
369
+ const p = id === this.localParticipant?.id ? this.localParticipant : this.participants.get(id);
370
+ if (!p || p.handRaised === raised) return;
371
+ const updated = { ...p, handRaised: raised };
372
+ if (id === this.localParticipant?.id) {
373
+ this.localParticipant = updated;
374
+ this.notify("localParticipant");
375
+ } else {
376
+ const next = new Map(this.participants);
377
+ next.set(id, updated);
378
+ this.participants = next;
379
+ this.notify(`participant:${id}`);
380
+ this.notify("participants");
381
+ }
382
+ }
367
383
  // ---- chat ----
368
384
  addChatMessage(msg) {
369
385
  this.chatMessages.set(msg.id, msg);
@@ -512,6 +528,8 @@ var SFUClient = class {
512
528
  });
513
529
  this.onReaction = options.onReaction || (() => {
514
530
  });
531
+ this.onHandRaised = options.onHandRaised || (() => {
532
+ });
515
533
  this.onRoomUpdate = options.onRoomUpdate || (() => {
516
534
  });
517
535
  this.onNetworkQuality = options.onNetworkQuality || (() => {
@@ -1110,6 +1128,12 @@ var SFUClient = class {
1110
1128
  if (reaction?.id && reaction?.emoji) this.onReaction(reaction);
1111
1129
  break;
1112
1130
  }
1131
+ case "hand_raised": {
1132
+ const participantId = String(payload.participant_id ?? payload.participantId ?? "");
1133
+ const raised = Boolean(payload.raised);
1134
+ if (participantId) this.onHandRaised(participantId, raised);
1135
+ break;
1136
+ }
1113
1137
  case "network_quality": {
1114
1138
  const raw = payload.quality || payload;
1115
1139
  const quality = {
@@ -2035,6 +2059,14 @@ var SFUClient = class {
2035
2059
  }
2036
2060
  });
2037
2061
  }
2062
+ setHandRaised(raised) {
2063
+ this.send({
2064
+ type: "set_hand_raised",
2065
+ payload: {
2066
+ raised
2067
+ }
2068
+ });
2069
+ }
2038
2070
  removeRemoteParticipant(participantId) {
2039
2071
  const stream = this.remoteStreams.get(participantId);
2040
2072
  if (stream) {
@@ -2469,6 +2501,7 @@ var VideoSDKCore = class {
2469
2501
  isHost,
2470
2502
  isModerator,
2471
2503
  permissions,
2504
+ handRaised: Boolean(local?.hand_raised),
2472
2505
  media: {
2473
2506
  micEnabled: !Boolean(local?.audio_muted),
2474
2507
  camEnabled: !Boolean(local?.video_muted)
@@ -2496,6 +2529,7 @@ var VideoSDKCore = class {
2496
2529
  this.state.updateLocalParticipant({
2497
2530
  id: this.myId,
2498
2531
  name: this.participantName,
2532
+ handRaised: Boolean(local.hand_raised),
2499
2533
  media: {
2500
2534
  micEnabled: !Boolean(local.audio_muted),
2501
2535
  camEnabled: !Boolean(local.video_muted),
@@ -2574,6 +2608,10 @@ var VideoSDKCore = class {
2574
2608
  onReaction: (reaction) => {
2575
2609
  this.events.onReaction?.(reaction);
2576
2610
  },
2611
+ onHandRaised: (participantId, raised) => {
2612
+ this.state.setParticipantHandRaised(participantId, raised);
2613
+ this.events.onHandRaised?.(participantId, raised);
2614
+ },
2577
2615
  onJoinRequestCanceled: (requestId) => {
2578
2616
  this.events.onJoinRequestCanceled?.(requestId);
2579
2617
  },
@@ -2599,6 +2637,7 @@ var VideoSDKCore = class {
2599
2637
  id: this.myId,
2600
2638
  name: this.participantName,
2601
2639
  isHost: current?.isHost,
2640
+ handRaised: current?.handRaised,
2602
2641
  isModerator: Boolean(permissions?.moderate),
2603
2642
  permissions
2604
2643
  });
@@ -2628,6 +2667,7 @@ var VideoSDKCore = class {
2628
2667
  id: pid,
2629
2668
  name: pname,
2630
2669
  isModerator: Boolean(participant?.permissions?.moderate),
2670
+ handRaised: Boolean(participant?.hand_raised),
2631
2671
  permissions: participant?.permissions,
2632
2672
  connectionState: "connected",
2633
2673
  media: {
@@ -3145,6 +3185,16 @@ var VideoSDKCore = class {
3145
3185
  }
3146
3186
  this.sfuClient.sendReaction(reaction);
3147
3187
  }
3188
+ setHandRaised(raised) {
3189
+ if (!this.sfuClient) {
3190
+ console.warn("SFU Client not connected");
3191
+ return;
3192
+ }
3193
+ this.sfuClient.setHandRaised(raised);
3194
+ }
3195
+ toggleHandRaised() {
3196
+ this.setHandRaised(!Boolean(this.state.localParticipant?.handRaised));
3197
+ }
3148
3198
  /**
3149
3199
  * Generic PubSub publishing entry point.
3150
3200
  *
@@ -3265,6 +3315,9 @@ var MeetingProvider = ({
3265
3315
  const recordingStartedListeners = (0, import_react2.useRef)(/* @__PURE__ */ new Set());
3266
3316
  const recordingStoppedListeners = (0, import_react2.useRef)(/* @__PURE__ */ new Set());
3267
3317
  const reactionListeners = (0, import_react2.useRef)(/* @__PURE__ */ new Set());
3318
+ const handRaisedListeners = (0, import_react2.useRef)(
3319
+ /* @__PURE__ */ new Set()
3320
+ );
3268
3321
  const pubSubListeners = (0, import_react2.useRef)(
3269
3322
  /* @__PURE__ */ new Map()
3270
3323
  );
@@ -3368,6 +3421,9 @@ var MeetingProvider = ({
3368
3421
  );
3369
3422
  pubSubListeners.current.get("REACTION")?.forEach((fn) => fn(message));
3370
3423
  },
3424
+ onHandRaised: (participantId, raised) => {
3425
+ handRaisedListeners.current.forEach((fn) => fn(participantId, raised));
3426
+ },
3371
3427
  onNetworkQuality: (quality) => {
3372
3428
  networkQualityListeners.current.forEach((fn) => fn(quality));
3373
3429
  },
@@ -3440,6 +3496,8 @@ var MeetingProvider = ({
3440
3496
  stopScreenShare: sdk.stopScreenShare.bind(sdk),
3441
3497
  sendMessage: sdk.sendChatMessage.bind(sdk),
3442
3498
  sendReaction: sdk.sendReaction.bind(sdk),
3499
+ setHandRaised: sdk.setHandRaised.bind(sdk),
3500
+ toggleHandRaised: sdk.toggleHandRaised.bind(sdk),
3443
3501
  room: sdk.getMeeting(),
3444
3502
  localParticipant,
3445
3503
  participants,
@@ -3565,6 +3623,10 @@ var MeetingProvider = ({
3565
3623
  reactionListeners.current.add(cb);
3566
3624
  return () => reactionListeners.current.delete(cb);
3567
3625
  },
3626
+ onHandRaised: (cb) => {
3627
+ handRaisedListeners.current.add(cb);
3628
+ return () => handRaisedListeners.current.delete(cb);
3629
+ },
3568
3630
  onNetworkQuality: (cb) => {
3569
3631
  networkQualityListeners.current.add(cb);
3570
3632
  return () => networkQualityListeners.current.delete(cb);
@@ -3732,6 +3794,10 @@ var useMeeting = (handlers) => {
3732
3794
  if (!handlers?.onReaction) return;
3733
3795
  return ctx.onReaction(handlers.onReaction);
3734
3796
  }, [handlers?.onReaction]);
3797
+ (0, import_react4.useEffect)(() => {
3798
+ if (!handlers?.onHandRaised) return;
3799
+ return ctx.onHandRaised(handlers.onHandRaised);
3800
+ }, [handlers?.onHandRaised]);
3735
3801
  const { sdk: _, ...publicApi } = ctx;
3736
3802
  return publicApi;
3737
3803
  };