@defcomm/meetingsdk 0.6.7 → 0.6.8

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
@@ -248,6 +248,36 @@ var MeetingState = class {
248
248
  this.notify("participants");
249
249
  return true;
250
250
  }
251
+ /**
252
+ * Reconcile a participant received from a room snapshot without emitting a
253
+ * lifecycle/join event. Snapshot data is authoritative for current room
254
+ * membership, including after a reconnect/resume.
255
+ */
256
+ upsertParticipantSnapshot(p) {
257
+ if (!p?.id) return;
258
+ const current = this.participants.get(p.id);
259
+ const updated = {
260
+ ...current ?? {},
261
+ ...p,
262
+ media: {
263
+ stream: current?.media?.stream ?? null,
264
+ screenStream: current?.media?.screenStream,
265
+ cameraTrack: current?.media?.cameraTrack,
266
+ screenTrack: current?.media?.screenTrack,
267
+ audioTrack: current?.media?.audioTrack,
268
+ micEnabled: current?.media?.micEnabled ?? !(p.media?.micEnabled === false),
269
+ camEnabled: current?.media?.camEnabled ?? !(p.media?.camEnabled === false),
270
+ isScreenSharing: current?.media?.isScreenSharing ?? false,
271
+ ...current?.media,
272
+ ...p.media
273
+ }
274
+ };
275
+ const next = new Map(this.participants);
276
+ next.set(p.id, updated);
277
+ this.participants = next;
278
+ this.notify(`participant:${p.id}`);
279
+ this.notify("participants");
280
+ }
251
281
  removeParticipant(id) {
252
282
  const next = new Map(this.participants);
253
283
  next.delete(id);
@@ -1212,7 +1242,6 @@ var SFUClient = class {
1212
1242
  }
1213
1243
  for (const participant of this.participants.values()) {
1214
1244
  if (participant.participant_id !== this.currentParticipantId) {
1215
- this.onParticipantJoined(participant);
1216
1245
  this.onParticipantPresence(
1217
1246
  participant.participant_id,
1218
1247
  String(participant.presence || "connected")
@@ -2497,6 +2526,36 @@ var VideoSDKCore = class {
2497
2526
  },
2498
2527
  onRoomUpdate: (payload) => {
2499
2528
  const participants = payload?.participants || [];
2529
+ const snapshotParticipantIds = /* @__PURE__ */ new Set();
2530
+ for (const participant of participants) {
2531
+ const pid = participant?.participant_id;
2532
+ if (!pid || pid === this.myId) continue;
2533
+ snapshotParticipantIds.add(pid);
2534
+ const current = this.state.getParticipant(pid);
2535
+ const name = participant?.user_metadata?.name || participant?.display_name || current?.name || "Participant";
2536
+ this.state.upsertParticipantSnapshot({
2537
+ id: pid,
2538
+ name,
2539
+ isModerator: Boolean(participant?.permissions?.moderate),
2540
+ isHost: Boolean(
2541
+ participant?.is_host ?? participant?.isHost ?? participant?.permissions?.host
2542
+ ),
2543
+ handRaised: Boolean(participant?.hand_raised),
2544
+ permissions: participant?.permissions,
2545
+ connectionState: participant?.presence === "reconnecting" ? "reconnecting" : participant?.presence === "disconnected" ? "disconnected" : "connected",
2546
+ media: {
2547
+ ...current?.media || {},
2548
+ micEnabled: !Boolean(participant?.audio_muted),
2549
+ camEnabled: !Boolean(participant?.video_muted),
2550
+ isScreenSharing: Boolean(participant?.screen_sharing)
2551
+ }
2552
+ });
2553
+ }
2554
+ for (const [pid] of this.state.participants) {
2555
+ if (pid === this.myId || snapshotParticipantIds.has(pid)) continue;
2556
+ this.cleanupRemoteParticipant(pid);
2557
+ this.state.removeParticipant(pid);
2558
+ }
2500
2559
  const local = participants.find(
2501
2560
  (p) => p?.participant_id === this.myId
2502
2561
  );
@@ -3310,6 +3369,9 @@ var MeetingProvider = ({
3310
3369
  const participantJoinedListeners = useRef(
3311
3370
  /* @__PURE__ */ new Set()
3312
3371
  );
3372
+ const participantPresenceListeners = useRef(
3373
+ /* @__PURE__ */ new Set()
3374
+ );
3313
3375
  const participantLeftListeners = useRef(
3314
3376
  /* @__PURE__ */ new Set()
3315
3377
  );
@@ -3398,7 +3460,9 @@ var MeetingProvider = ({
3398
3460
  pubSubListeners.current.get("REACTION")?.forEach((fn) => fn(message));
3399
3461
  },
3400
3462
  onHandRaised: (participantId, raised) => {
3401
- handRaisedListeners.current.forEach((fn) => fn(participantId, raised));
3463
+ handRaisedListeners.current.forEach(
3464
+ (fn) => fn(participantId, raised)
3465
+ );
3402
3466
  },
3403
3467
  onNetworkQuality: (quality) => {
3404
3468
  networkQualityListeners.current.forEach((fn) => fn(quality));
@@ -3411,6 +3475,11 @@ var MeetingProvider = ({
3411
3475
  onParticipantJoined: (participant) => {
3412
3476
  participantJoinedListeners.current.forEach((fn) => fn(participant));
3413
3477
  },
3478
+ onParticipantPresence: (participantId, presence) => {
3479
+ participantPresenceListeners.current.forEach(
3480
+ (fn) => fn(participantId, presence)
3481
+ );
3482
+ },
3414
3483
  onParticipantLeft: (participant) => {
3415
3484
  participantLeftListeners.current.forEach((fn) => fn(participant));
3416
3485
  }
@@ -3623,6 +3692,10 @@ var MeetingProvider = ({
3623
3692
  participantJoinedListeners.current.add(cb);
3624
3693
  return () => participantJoinedListeners.current.delete(cb);
3625
3694
  },
3695
+ onParticipantPresence: (cb) => {
3696
+ participantPresenceListeners.current.add(cb);
3697
+ return () => participantPresenceListeners.current.delete(cb);
3698
+ },
3626
3699
  onChatMessage: (cb) => {
3627
3700
  chatMessageListeners.current.add(cb);
3628
3701
  return () => chatMessageListeners.current.delete(cb);