@defcomm/meetingsdk 0.6.1 → 0.6.2
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/README.md +742 -899
- package/dist/index.d.mts +13 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +46 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +46 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -9,6 +9,8 @@ type Events = {
|
|
|
9
9
|
onTrack?: (stream: MediaStream, peerId: string) => void;
|
|
10
10
|
onScreenTrack?: (stream: MediaStream, peerId: string) => void;
|
|
11
11
|
onUserJoined?: (p: Participant) => void;
|
|
12
|
+
/** Fired when a remote participant permanently joins the meeting. */
|
|
13
|
+
onParticipantJoined?: (p: Participant) => void;
|
|
12
14
|
onEntryRequested?: (req: EntryRequest) => void;
|
|
13
15
|
onEntryResponded?: (payload: {
|
|
14
16
|
participantId: string;
|
|
@@ -23,6 +25,8 @@ type Events = {
|
|
|
23
25
|
onConnectionStateChanged?: (state: string) => void;
|
|
24
26
|
onRoomUpdate?: (data: any) => void;
|
|
25
27
|
onUserLeft?: (id: string) => void;
|
|
28
|
+
/** Fired when a remote participant permanently leaves the meeting. */
|
|
29
|
+
onParticipantLeft?: (p: Participant) => void;
|
|
26
30
|
onMeetingLeft?: () => void;
|
|
27
31
|
onChatMessage?: (msg: ChatMessage) => void;
|
|
28
32
|
onReaction?: (reaction: Reaction) => void;
|
|
@@ -452,6 +456,9 @@ type MeetingContextValue = {
|
|
|
452
456
|
onConnectionStateChanged: (cb: (state: SFUConnectionState) => void) => () => void;
|
|
453
457
|
onActiveSpeakersChanged: (cb: (participantIds: string[]) => void) => () => void;
|
|
454
458
|
onNetworkQuality: (cb: (quality: NetworkQuality) => void) => () => void;
|
|
459
|
+
onChatMessage: (cb: (message: ChatMessage) => void) => () => void;
|
|
460
|
+
onParticipantJoined: (cb: (participant: Participant) => void) => () => void;
|
|
461
|
+
onParticipantLeft: (cb: (participant: Participant) => void) => () => void;
|
|
455
462
|
};
|
|
456
463
|
declare const MeetingProvider: ({ config, children, }: {
|
|
457
464
|
config: MeetingConfig;
|
|
@@ -474,6 +481,9 @@ declare const useMeeting: (handlers?: {
|
|
|
474
481
|
onActiveSpeakersChanged?: (participantIds: string[]) => void;
|
|
475
482
|
onConnectionStateChanged?: (state: SFUConnectionState) => void;
|
|
476
483
|
onNetworkQuality?: (quality: NetworkQuality) => void;
|
|
484
|
+
onParticipantJoined?: (participant: Participant) => void;
|
|
485
|
+
onParticipantLeft?: (participant: Participant) => void;
|
|
486
|
+
onChatMessage?: (message: ChatMessage) => void;
|
|
477
487
|
}) => {
|
|
478
488
|
join: (config?: Omit<MeetingConfig, "participantId" | "token">) => Promise<void>;
|
|
479
489
|
getJoinState: (roomCode: string) => Promise<JoinState>;
|
|
@@ -538,6 +548,9 @@ declare const useMeeting: (handlers?: {
|
|
|
538
548
|
onConnectionStateChanged: (cb: (state: SFUConnectionState) => void) => () => void;
|
|
539
549
|
onActiveSpeakersChanged: (cb: (participantIds: string[]) => void) => () => void;
|
|
540
550
|
onNetworkQuality: (cb: (quality: NetworkQuality) => void) => () => void;
|
|
551
|
+
onChatMessage: (cb: (message: ChatMessage) => void) => () => void;
|
|
552
|
+
onParticipantJoined: (cb: (participant: Participant) => void) => () => void;
|
|
553
|
+
onParticipantLeft: (cb: (participant: Participant) => void) => () => void;
|
|
541
554
|
};
|
|
542
555
|
|
|
543
556
|
declare const useParticipants: () => Participant[];
|
package/dist/index.d.ts
CHANGED
|
@@ -9,6 +9,8 @@ type Events = {
|
|
|
9
9
|
onTrack?: (stream: MediaStream, peerId: string) => void;
|
|
10
10
|
onScreenTrack?: (stream: MediaStream, peerId: string) => void;
|
|
11
11
|
onUserJoined?: (p: Participant) => void;
|
|
12
|
+
/** Fired when a remote participant permanently joins the meeting. */
|
|
13
|
+
onParticipantJoined?: (p: Participant) => void;
|
|
12
14
|
onEntryRequested?: (req: EntryRequest) => void;
|
|
13
15
|
onEntryResponded?: (payload: {
|
|
14
16
|
participantId: string;
|
|
@@ -23,6 +25,8 @@ type Events = {
|
|
|
23
25
|
onConnectionStateChanged?: (state: string) => void;
|
|
24
26
|
onRoomUpdate?: (data: any) => void;
|
|
25
27
|
onUserLeft?: (id: string) => void;
|
|
28
|
+
/** Fired when a remote participant permanently leaves the meeting. */
|
|
29
|
+
onParticipantLeft?: (p: Participant) => void;
|
|
26
30
|
onMeetingLeft?: () => void;
|
|
27
31
|
onChatMessage?: (msg: ChatMessage) => void;
|
|
28
32
|
onReaction?: (reaction: Reaction) => void;
|
|
@@ -452,6 +456,9 @@ type MeetingContextValue = {
|
|
|
452
456
|
onConnectionStateChanged: (cb: (state: SFUConnectionState) => void) => () => void;
|
|
453
457
|
onActiveSpeakersChanged: (cb: (participantIds: string[]) => void) => () => void;
|
|
454
458
|
onNetworkQuality: (cb: (quality: NetworkQuality) => void) => () => void;
|
|
459
|
+
onChatMessage: (cb: (message: ChatMessage) => void) => () => void;
|
|
460
|
+
onParticipantJoined: (cb: (participant: Participant) => void) => () => void;
|
|
461
|
+
onParticipantLeft: (cb: (participant: Participant) => void) => () => void;
|
|
455
462
|
};
|
|
456
463
|
declare const MeetingProvider: ({ config, children, }: {
|
|
457
464
|
config: MeetingConfig;
|
|
@@ -474,6 +481,9 @@ declare const useMeeting: (handlers?: {
|
|
|
474
481
|
onActiveSpeakersChanged?: (participantIds: string[]) => void;
|
|
475
482
|
onConnectionStateChanged?: (state: SFUConnectionState) => void;
|
|
476
483
|
onNetworkQuality?: (quality: NetworkQuality) => void;
|
|
484
|
+
onParticipantJoined?: (participant: Participant) => void;
|
|
485
|
+
onParticipantLeft?: (participant: Participant) => void;
|
|
486
|
+
onChatMessage?: (message: ChatMessage) => void;
|
|
477
487
|
}) => {
|
|
478
488
|
join: (config?: Omit<MeetingConfig, "participantId" | "token">) => Promise<void>;
|
|
479
489
|
getJoinState: (roomCode: string) => Promise<JoinState>;
|
|
@@ -538,6 +548,9 @@ declare const useMeeting: (handlers?: {
|
|
|
538
548
|
onConnectionStateChanged: (cb: (state: SFUConnectionState) => void) => () => void;
|
|
539
549
|
onActiveSpeakersChanged: (cb: (participantIds: string[]) => void) => () => void;
|
|
540
550
|
onNetworkQuality: (cb: (quality: NetworkQuality) => void) => () => void;
|
|
551
|
+
onChatMessage: (cb: (message: ChatMessage) => void) => () => void;
|
|
552
|
+
onParticipantJoined: (cb: (participant: Participant) => void) => () => void;
|
|
553
|
+
onParticipantLeft: (cb: (participant: Participant) => void) => () => void;
|
|
541
554
|
};
|
|
542
555
|
|
|
543
556
|
declare const useParticipants: () => Participant[];
|
package/dist/index.js
CHANGED
|
@@ -2637,10 +2637,12 @@ var VideoSDKCore = class {
|
|
|
2637
2637
|
stream: null
|
|
2638
2638
|
}
|
|
2639
2639
|
});
|
|
2640
|
-
this.
|
|
2640
|
+
const joinedParticipant = this.state.getParticipant(pid) ?? {
|
|
2641
2641
|
id: pid,
|
|
2642
2642
|
name: pname
|
|
2643
|
-
}
|
|
2643
|
+
};
|
|
2644
|
+
this.events.onUserJoined?.(joinedParticipant);
|
|
2645
|
+
this.events.onParticipantJoined?.(joinedParticipant);
|
|
2644
2646
|
},
|
|
2645
2647
|
onParticipantPresence: (participantId, presence) => {
|
|
2646
2648
|
if (participantId === this.myId) {
|
|
@@ -2669,9 +2671,11 @@ var VideoSDKCore = class {
|
|
|
2669
2671
|
return;
|
|
2670
2672
|
}
|
|
2671
2673
|
console.log("[SFU] Participant permanently left", pid);
|
|
2674
|
+
const leavingParticipant = this.state.getParticipant(pid) ?? { id: pid };
|
|
2672
2675
|
this.cleanupRemoteParticipant(pid);
|
|
2673
2676
|
this.state.removeParticipant(pid);
|
|
2674
2677
|
this.events.onUserLeft?.(pid);
|
|
2678
|
+
this.events.onParticipantLeft?.(leavingParticipant);
|
|
2675
2679
|
},
|
|
2676
2680
|
// TRACKS
|
|
2677
2681
|
onParticipantMediaState: (participantId, audioMuted, videoMuted) => {
|
|
@@ -3274,6 +3278,15 @@ var MeetingProvider = ({
|
|
|
3274
3278
|
const connectionStateListeners = (0, import_react2.useRef)(
|
|
3275
3279
|
/* @__PURE__ */ new Set()
|
|
3276
3280
|
);
|
|
3281
|
+
const participantJoinedListeners = (0, import_react2.useRef)(
|
|
3282
|
+
/* @__PURE__ */ new Set()
|
|
3283
|
+
);
|
|
3284
|
+
const participantLeftListeners = (0, import_react2.useRef)(
|
|
3285
|
+
/* @__PURE__ */ new Set()
|
|
3286
|
+
);
|
|
3287
|
+
const chatMessageListeners = (0, import_react2.useRef)(
|
|
3288
|
+
/* @__PURE__ */ new Set()
|
|
3289
|
+
);
|
|
3277
3290
|
if (!sdkRef.current) {
|
|
3278
3291
|
sdkRef.current = new VideoSDKCore(
|
|
3279
3292
|
{
|
|
@@ -3334,6 +3347,7 @@ var MeetingProvider = ({
|
|
|
3334
3347
|
data: msg
|
|
3335
3348
|
};
|
|
3336
3349
|
pubSubListeners.current.get("SECURE_CHAT")?.forEach((fn) => fn(pubSubMessage));
|
|
3350
|
+
chatMessageListeners.current.forEach((fn) => fn(msg));
|
|
3337
3351
|
},
|
|
3338
3352
|
onReaction: (reaction) => {
|
|
3339
3353
|
reactionListeners.current.forEach((fn) => fn(reaction));
|
|
@@ -3361,6 +3375,12 @@ var MeetingProvider = ({
|
|
|
3361
3375
|
connectionStateListeners.current.forEach(
|
|
3362
3376
|
(fn) => fn(state)
|
|
3363
3377
|
);
|
|
3378
|
+
},
|
|
3379
|
+
onParticipantJoined: (participant) => {
|
|
3380
|
+
participantJoinedListeners.current.forEach((fn) => fn(participant));
|
|
3381
|
+
},
|
|
3382
|
+
onParticipantLeft: (participant) => {
|
|
3383
|
+
participantLeftListeners.current.forEach((fn) => fn(participant));
|
|
3364
3384
|
}
|
|
3365
3385
|
}
|
|
3366
3386
|
);
|
|
@@ -3560,6 +3580,18 @@ var MeetingProvider = ({
|
|
|
3560
3580
|
return () => {
|
|
3561
3581
|
activeSpeakerListeners.current.delete(cb);
|
|
3562
3582
|
};
|
|
3583
|
+
},
|
|
3584
|
+
onParticipantJoined: (cb) => {
|
|
3585
|
+
participantJoinedListeners.current.add(cb);
|
|
3586
|
+
return () => participantJoinedListeners.current.delete(cb);
|
|
3587
|
+
},
|
|
3588
|
+
onChatMessage: (cb) => {
|
|
3589
|
+
chatMessageListeners.current.add(cb);
|
|
3590
|
+
return () => chatMessageListeners.current.delete(cb);
|
|
3591
|
+
},
|
|
3592
|
+
onParticipantLeft: (cb) => {
|
|
3593
|
+
participantLeftListeners.current.add(cb);
|
|
3594
|
+
return () => participantLeftListeners.current.delete(cb);
|
|
3563
3595
|
}
|
|
3564
3596
|
};
|
|
3565
3597
|
}, [
|
|
@@ -3684,6 +3716,18 @@ var useMeeting = (handlers) => {
|
|
|
3684
3716
|
if (!handlers?.onNetworkQuality) return;
|
|
3685
3717
|
return ctx.onNetworkQuality(handlers.onNetworkQuality);
|
|
3686
3718
|
}, [handlers?.onNetworkQuality]);
|
|
3719
|
+
(0, import_react4.useEffect)(() => {
|
|
3720
|
+
if (!handlers?.onParticipantJoined) return;
|
|
3721
|
+
return ctx.onParticipantJoined(handlers.onParticipantJoined);
|
|
3722
|
+
}, [handlers?.onParticipantJoined]);
|
|
3723
|
+
(0, import_react4.useEffect)(() => {
|
|
3724
|
+
if (!handlers?.onParticipantLeft) return;
|
|
3725
|
+
return ctx.onParticipantLeft(handlers.onParticipantLeft);
|
|
3726
|
+
}, [handlers?.onParticipantLeft]);
|
|
3727
|
+
(0, import_react4.useEffect)(() => {
|
|
3728
|
+
if (!handlers?.onChatMessage) return;
|
|
3729
|
+
return ctx.onChatMessage(handlers.onChatMessage);
|
|
3730
|
+
}, [handlers?.onChatMessage]);
|
|
3687
3731
|
(0, import_react4.useEffect)(() => {
|
|
3688
3732
|
if (!handlers?.onReaction) return;
|
|
3689
3733
|
return ctx.onReaction(handlers.onReaction);
|