@defcomm/meetingsdk 0.6.6 → 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.d.mts +9 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +91 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +91 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
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);
|
|
@@ -819,6 +849,22 @@ var SFUClient = class {
|
|
|
819
849
|
const participantId = payload.user_id || payload.participant_id;
|
|
820
850
|
this.pendingJoinRequestId = requestId;
|
|
821
851
|
this.onJoinApproved(requestId, participantId);
|
|
852
|
+
if (this.ws?.readyState === WebSocket.OPEN) {
|
|
853
|
+
this.setState("joining");
|
|
854
|
+
this.send({
|
|
855
|
+
type: "join",
|
|
856
|
+
request_id: requestId,
|
|
857
|
+
payload: {
|
|
858
|
+
token: this.token,
|
|
859
|
+
room_code: this.room,
|
|
860
|
+
resume_token: this.resumeToken,
|
|
861
|
+
display_name: this.joinOptions.displayName,
|
|
862
|
+
avatar_url: this.joinOptions.avatarUrl,
|
|
863
|
+
audio_muted: this.desiredAudioMuted,
|
|
864
|
+
video_muted: this.desiredVideoMuted
|
|
865
|
+
}
|
|
866
|
+
});
|
|
867
|
+
}
|
|
822
868
|
break;
|
|
823
869
|
}
|
|
824
870
|
case "join_rejected": {
|
|
@@ -1196,7 +1242,6 @@ var SFUClient = class {
|
|
|
1196
1242
|
}
|
|
1197
1243
|
for (const participant of this.participants.values()) {
|
|
1198
1244
|
if (participant.participant_id !== this.currentParticipantId) {
|
|
1199
|
-
this.onParticipantJoined(participant);
|
|
1200
1245
|
this.onParticipantPresence(
|
|
1201
1246
|
participant.participant_id,
|
|
1202
1247
|
String(participant.presence || "connected")
|
|
@@ -2481,6 +2526,36 @@ var VideoSDKCore = class {
|
|
|
2481
2526
|
},
|
|
2482
2527
|
onRoomUpdate: (payload) => {
|
|
2483
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
|
+
}
|
|
2484
2559
|
const local = participants.find(
|
|
2485
2560
|
(p) => p?.participant_id === this.myId
|
|
2486
2561
|
);
|
|
@@ -3294,6 +3369,9 @@ var MeetingProvider = ({
|
|
|
3294
3369
|
const participantJoinedListeners = useRef(
|
|
3295
3370
|
/* @__PURE__ */ new Set()
|
|
3296
3371
|
);
|
|
3372
|
+
const participantPresenceListeners = useRef(
|
|
3373
|
+
/* @__PURE__ */ new Set()
|
|
3374
|
+
);
|
|
3297
3375
|
const participantLeftListeners = useRef(
|
|
3298
3376
|
/* @__PURE__ */ new Set()
|
|
3299
3377
|
);
|
|
@@ -3382,7 +3460,9 @@ var MeetingProvider = ({
|
|
|
3382
3460
|
pubSubListeners.current.get("REACTION")?.forEach((fn) => fn(message));
|
|
3383
3461
|
},
|
|
3384
3462
|
onHandRaised: (participantId, raised) => {
|
|
3385
|
-
handRaisedListeners.current.forEach(
|
|
3463
|
+
handRaisedListeners.current.forEach(
|
|
3464
|
+
(fn) => fn(participantId, raised)
|
|
3465
|
+
);
|
|
3386
3466
|
},
|
|
3387
3467
|
onNetworkQuality: (quality) => {
|
|
3388
3468
|
networkQualityListeners.current.forEach((fn) => fn(quality));
|
|
@@ -3395,6 +3475,11 @@ var MeetingProvider = ({
|
|
|
3395
3475
|
onParticipantJoined: (participant) => {
|
|
3396
3476
|
participantJoinedListeners.current.forEach((fn) => fn(participant));
|
|
3397
3477
|
},
|
|
3478
|
+
onParticipantPresence: (participantId, presence) => {
|
|
3479
|
+
participantPresenceListeners.current.forEach(
|
|
3480
|
+
(fn) => fn(participantId, presence)
|
|
3481
|
+
);
|
|
3482
|
+
},
|
|
3398
3483
|
onParticipantLeft: (participant) => {
|
|
3399
3484
|
participantLeftListeners.current.forEach((fn) => fn(participant));
|
|
3400
3485
|
}
|
|
@@ -3607,6 +3692,10 @@ var MeetingProvider = ({
|
|
|
3607
3692
|
participantJoinedListeners.current.add(cb);
|
|
3608
3693
|
return () => participantJoinedListeners.current.delete(cb);
|
|
3609
3694
|
},
|
|
3695
|
+
onParticipantPresence: (cb) => {
|
|
3696
|
+
participantPresenceListeners.current.add(cb);
|
|
3697
|
+
return () => participantPresenceListeners.current.delete(cb);
|
|
3698
|
+
},
|
|
3610
3699
|
onChatMessage: (cb) => {
|
|
3611
3700
|
chatMessageListeners.current.add(cb);
|
|
3612
3701
|
return () => chatMessageListeners.current.delete(cb);
|