@defcomm/meetingsdk 0.4.3 → 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 +21 -10
- package/dist/index.d.ts +21 -10
- package/dist/index.js +70 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +69 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -2790,6 +2790,9 @@ var MeetingProvider = ({
|
|
|
2790
2790
|
const recordingStartedListeners = useRef(/* @__PURE__ */ new Set());
|
|
2791
2791
|
const recordingStoppedListeners = useRef(/* @__PURE__ */ new Set());
|
|
2792
2792
|
const reactionListeners = useRef(/* @__PURE__ */ new Set());
|
|
2793
|
+
const pubSubListeners = useRef(
|
|
2794
|
+
/* @__PURE__ */ new Map()
|
|
2795
|
+
);
|
|
2793
2796
|
const activeSpeakerListeners = useRef(
|
|
2794
2797
|
/* @__PURE__ */ new Set()
|
|
2795
2798
|
);
|
|
@@ -2825,6 +2828,19 @@ var MeetingProvider = ({
|
|
|
2825
2828
|
},
|
|
2826
2829
|
onReaction: (reaction) => {
|
|
2827
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));
|
|
2828
2844
|
},
|
|
2829
2845
|
onConnectionStateChanged: (state) => {
|
|
2830
2846
|
connectionStateListeners.current.forEach(
|
|
@@ -2887,12 +2903,48 @@ var MeetingProvider = ({
|
|
|
2887
2903
|
activeSpeakerIds,
|
|
2888
2904
|
recording,
|
|
2889
2905
|
usePubSub: (topic) => {
|
|
2890
|
-
if (topic
|
|
2891
|
-
|
|
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);
|
|
2892
2941
|
}
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
|
|
2942
|
+
listeners.add(cb);
|
|
2943
|
+
return () => {
|
|
2944
|
+
listeners?.delete(cb);
|
|
2945
|
+
if (listeners?.size === 0) {
|
|
2946
|
+
pubSubListeners.current.delete(topic);
|
|
2947
|
+
}
|
|
2896
2948
|
};
|
|
2897
2949
|
},
|
|
2898
2950
|
approveJoinRequest: sdk.approveJoinRequest.bind(sdk),
|
|
@@ -3191,6 +3243,17 @@ function useMeetingPreview(roomId, participantId) {
|
|
|
3191
3243
|
error
|
|
3192
3244
|
};
|
|
3193
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
|
+
}
|
|
3194
3257
|
export {
|
|
3195
3258
|
ActiveSpeakerDetector,
|
|
3196
3259
|
MeetingProvider,
|
|
@@ -3201,6 +3264,7 @@ export {
|
|
|
3201
3264
|
useMeetingContext,
|
|
3202
3265
|
useMeetingPreview,
|
|
3203
3266
|
useParticipants,
|
|
3267
|
+
usePubSub,
|
|
3204
3268
|
useRemoteMedia
|
|
3205
3269
|
};
|
|
3206
3270
|
//# sourceMappingURL=index.mjs.map
|