@defcomm/meetingsdk 0.4.2 → 0.4.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.d.mts +31 -20
- package/dist/index.d.ts +31 -20
- package/dist/index.js +84 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +83 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -561,6 +561,11 @@ var SFUClient = class {
|
|
|
561
561
|
`${this.apiBase}/rooms/${encodeURIComponent(roomCode)}`
|
|
562
562
|
);
|
|
563
563
|
}
|
|
564
|
+
async getJoinState(roomCode) {
|
|
565
|
+
return this.request(
|
|
566
|
+
`${this.apiBase}/rooms/${encodeURIComponent(roomCode)}/join-state`
|
|
567
|
+
);
|
|
568
|
+
}
|
|
564
569
|
async deleteRoom(roomCode) {
|
|
565
570
|
return this.request(
|
|
566
571
|
`${this.apiBase}/rooms/${encodeURIComponent(roomCode)}`,
|
|
@@ -2019,6 +2024,14 @@ var VideoSDKCore = class {
|
|
|
2019
2024
|
});
|
|
2020
2025
|
return client.getRoom(roomCode);
|
|
2021
2026
|
}
|
|
2027
|
+
async getJoinState(roomCode) {
|
|
2028
|
+
const client = this.sfuClient ?? new SFUClient({
|
|
2029
|
+
apiBase: this.apiBase,
|
|
2030
|
+
wsBase: this.wsBase,
|
|
2031
|
+
participantId: this.myId
|
|
2032
|
+
});
|
|
2033
|
+
return client.getJoinState(roomCode);
|
|
2034
|
+
}
|
|
2022
2035
|
async deleteRoom(roomCode) {
|
|
2023
2036
|
const client = this.sfuClient ?? new SFUClient({
|
|
2024
2037
|
apiBase: this.apiBase,
|
|
@@ -2777,6 +2790,9 @@ var MeetingProvider = ({
|
|
|
2777
2790
|
const recordingStartedListeners = useRef(/* @__PURE__ */ new Set());
|
|
2778
2791
|
const recordingStoppedListeners = useRef(/* @__PURE__ */ new Set());
|
|
2779
2792
|
const reactionListeners = useRef(/* @__PURE__ */ new Set());
|
|
2793
|
+
const pubSubListeners = useRef(
|
|
2794
|
+
/* @__PURE__ */ new Map()
|
|
2795
|
+
);
|
|
2780
2796
|
const activeSpeakerListeners = useRef(
|
|
2781
2797
|
/* @__PURE__ */ new Set()
|
|
2782
2798
|
);
|
|
@@ -2812,6 +2828,19 @@ var MeetingProvider = ({
|
|
|
2812
2828
|
},
|
|
2813
2829
|
onReaction: (reaction) => {
|
|
2814
2830
|
reactionListeners.current.forEach((fn) => fn(reaction));
|
|
2831
|
+
const listeners = pubSubListeners.current.get("REACTION");
|
|
2832
|
+
if (!listeners) return;
|
|
2833
|
+
const message = {
|
|
2834
|
+
id: reaction.id,
|
|
2835
|
+
topic: "REACTION",
|
|
2836
|
+
sender_id: reaction.participant_id,
|
|
2837
|
+
sender_name: reaction.sender_name,
|
|
2838
|
+
timestamp: typeof reaction.timestamp === "number" ? reaction.timestamp : Date.parse(reaction.timestamp),
|
|
2839
|
+
data: {
|
|
2840
|
+
emoji: reaction.emoji
|
|
2841
|
+
}
|
|
2842
|
+
};
|
|
2843
|
+
listeners.forEach((fn) => fn(message));
|
|
2815
2844
|
},
|
|
2816
2845
|
onConnectionStateChanged: (state) => {
|
|
2817
2846
|
connectionStateListeners.current.forEach(
|
|
@@ -2855,6 +2884,7 @@ var MeetingProvider = ({
|
|
|
2855
2884
|
...config,
|
|
2856
2885
|
...joinConfig
|
|
2857
2886
|
}),
|
|
2887
|
+
getJoinState: (roomCode) => sdk.getJoinState(roomCode),
|
|
2858
2888
|
leave: () => sdk.disconnect(),
|
|
2859
2889
|
createRoom: sdk.createRoom.bind(sdk),
|
|
2860
2890
|
getRoom: sdk.getRoom.bind(sdk),
|
|
@@ -2873,12 +2903,48 @@ var MeetingProvider = ({
|
|
|
2873
2903
|
activeSpeakerIds,
|
|
2874
2904
|
recording,
|
|
2875
2905
|
usePubSub: (topic) => {
|
|
2876
|
-
if (topic
|
|
2877
|
-
|
|
2906
|
+
if (topic === "REACTION") {
|
|
2907
|
+
return {
|
|
2908
|
+
messages: [],
|
|
2909
|
+
publish: (data) => {
|
|
2910
|
+
const reaction = data;
|
|
2911
|
+
if (!reaction?.emoji) {
|
|
2912
|
+
console.warn("[PubSub] REACTION requires an emoji");
|
|
2913
|
+
return;
|
|
2914
|
+
}
|
|
2915
|
+
sdk.sendReaction(reaction.emoji);
|
|
2916
|
+
}
|
|
2917
|
+
};
|
|
2918
|
+
}
|
|
2919
|
+
if (topic === "SECURE_CHAT") {
|
|
2920
|
+
return {
|
|
2921
|
+
messages: sdk.state.getChatMessages().map((message) => ({
|
|
2922
|
+
id: message.id,
|
|
2923
|
+
topic: "SECURE_CHAT",
|
|
2924
|
+
sender_id: message.sender_id,
|
|
2925
|
+
sender_name: message.sender_name,
|
|
2926
|
+
timestamp: message.timestamp,
|
|
2927
|
+
data: message
|
|
2928
|
+
})),
|
|
2929
|
+
publish: (data) => {
|
|
2930
|
+
sdk.sendChatMessage(data);
|
|
2931
|
+
}
|
|
2932
|
+
};
|
|
2933
|
+
}
|
|
2934
|
+
throw new Error(`Unsupported PubSub topic: "${topic}"`);
|
|
2935
|
+
},
|
|
2936
|
+
onPubSubMessage: (topic, cb) => {
|
|
2937
|
+
let listeners = pubSubListeners.current.get(topic);
|
|
2938
|
+
if (!listeners) {
|
|
2939
|
+
listeners = /* @__PURE__ */ new Set();
|
|
2940
|
+
pubSubListeners.current.set(topic, listeners);
|
|
2878
2941
|
}
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2942
|
+
listeners.add(cb);
|
|
2943
|
+
return () => {
|
|
2944
|
+
listeners?.delete(cb);
|
|
2945
|
+
if (listeners?.size === 0) {
|
|
2946
|
+
pubSubListeners.current.delete(topic);
|
|
2947
|
+
}
|
|
2882
2948
|
};
|
|
2883
2949
|
},
|
|
2884
2950
|
approveJoinRequest: sdk.approveJoinRequest.bind(sdk),
|
|
@@ -3177,6 +3243,17 @@ function useMeetingPreview(roomId, participantId) {
|
|
|
3177
3243
|
error
|
|
3178
3244
|
};
|
|
3179
3245
|
}
|
|
3246
|
+
|
|
3247
|
+
// src/react/usePubSub.ts
|
|
3248
|
+
import { useEffect as useEffect7 } from "react";
|
|
3249
|
+
function usePubSub(topic, options) {
|
|
3250
|
+
const ctx = useMeetingContext();
|
|
3251
|
+
useEffect7(() => {
|
|
3252
|
+
if (!options?.onMessageReceived) return;
|
|
3253
|
+
return ctx.onPubSubMessage(topic, options.onMessageReceived);
|
|
3254
|
+
}, [ctx, topic, options?.onMessageReceived]);
|
|
3255
|
+
return ctx.usePubSub(topic);
|
|
3256
|
+
}
|
|
3180
3257
|
export {
|
|
3181
3258
|
ActiveSpeakerDetector,
|
|
3182
3259
|
MeetingProvider,
|
|
@@ -3187,6 +3264,7 @@ export {
|
|
|
3187
3264
|
useMeetingContext,
|
|
3188
3265
|
useMeetingPreview,
|
|
3189
3266
|
useParticipants,
|
|
3267
|
+
usePubSub,
|
|
3190
3268
|
useRemoteMedia
|
|
3191
3269
|
};
|
|
3192
3270
|
//# sourceMappingURL=index.mjs.map
|