@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.d.mts
CHANGED
|
@@ -59,6 +59,14 @@ type ChatMessage = {
|
|
|
59
59
|
} | null;
|
|
60
60
|
target?: string | null;
|
|
61
61
|
};
|
|
62
|
+
type PubSubMessage<T = unknown> = {
|
|
63
|
+
id: string;
|
|
64
|
+
topic: PubSubTopic;
|
|
65
|
+
sender_id: string;
|
|
66
|
+
sender_name?: string | null;
|
|
67
|
+
timestamp: number;
|
|
68
|
+
data: T;
|
|
69
|
+
};
|
|
62
70
|
type Participant = {
|
|
63
71
|
id: string;
|
|
64
72
|
name?: string;
|
|
@@ -98,6 +106,10 @@ type MeetingConfig = {
|
|
|
98
106
|
token?: string;
|
|
99
107
|
};
|
|
100
108
|
type PubSubTopic = "SECURE_CHAT" | "REACTION";
|
|
109
|
+
type PubSubHandle<T = unknown> = {
|
|
110
|
+
messages: PubSubMessage<T>[];
|
|
111
|
+
publish: (data: T) => void;
|
|
112
|
+
};
|
|
101
113
|
type RecordingInfo = {
|
|
102
114
|
recording_id: string;
|
|
103
115
|
started_at?: string;
|
|
@@ -263,10 +275,6 @@ interface ParticipantInfo {
|
|
|
263
275
|
[key: string]: any;
|
|
264
276
|
}
|
|
265
277
|
|
|
266
|
-
type PubSubHandle = {
|
|
267
|
-
messages: ChatMessage[];
|
|
268
|
-
publish: (input: ChatInput) => void;
|
|
269
|
-
};
|
|
270
278
|
type MeetingContextValue = {
|
|
271
279
|
sdk: VideoSDKCore;
|
|
272
280
|
join: (config?: Omit<MeetingConfig, "participantId">) => Promise<void>;
|
|
@@ -296,7 +304,8 @@ type MeetingContextValue = {
|
|
|
296
304
|
presenterId: string | null;
|
|
297
305
|
activeSpeakerIds: string[];
|
|
298
306
|
recording: RecordingInfo | null;
|
|
299
|
-
usePubSub: (topic: PubSubTopic) => PubSubHandle
|
|
307
|
+
usePubSub: <T = unknown>(topic: PubSubTopic) => PubSubHandle<T>;
|
|
308
|
+
onPubSubMessage: <T = unknown>(topic: PubSubTopic, cb: (message: PubSubMessage<T>) => void) => () => void;
|
|
300
309
|
approveJoinRequest: (requestId: string) => void;
|
|
301
310
|
rejectJoinRequest: (requestId: string) => void;
|
|
302
311
|
startRecording: () => Promise<void>;
|
|
@@ -358,10 +367,8 @@ declare const useMeeting: (handlers?: {
|
|
|
358
367
|
presenterId: string | null;
|
|
359
368
|
activeSpeakerIds: string[];
|
|
360
369
|
recording: RecordingInfo | null;
|
|
361
|
-
usePubSub: (topic: PubSubTopic) =>
|
|
362
|
-
|
|
363
|
-
publish: (input: ChatInput) => void;
|
|
364
|
-
};
|
|
370
|
+
usePubSub: <T = unknown>(topic: PubSubTopic) => PubSubHandle<T>;
|
|
371
|
+
onPubSubMessage: <T = unknown>(topic: PubSubTopic, cb: (message: PubSubMessage<T>) => void) => () => void;
|
|
365
372
|
approveJoinRequest: (requestId: string) => void;
|
|
366
373
|
rejectJoinRequest: (requestId: string) => void;
|
|
367
374
|
startRecording: () => Promise<void>;
|
|
@@ -456,4 +463,8 @@ declare class ActiveSpeakerDetector {
|
|
|
456
463
|
destroy(): Promise<void>;
|
|
457
464
|
}
|
|
458
465
|
|
|
459
|
-
|
|
466
|
+
declare function usePubSub<T = unknown>(topic: PubSubTopic, options?: {
|
|
467
|
+
onMessageReceived?: (message: PubSubMessage<T>) => void;
|
|
468
|
+
}): PubSubHandle<T>;
|
|
469
|
+
|
|
470
|
+
export { ActiveSpeakerDetector, type ChatInput, type MeetingConfig, MeetingProvider, MeetingState, type Participant, type ParticipantInfo, type Reaction, type RecordingInfo, type SFUConnectionState, type TrackInfo, VideoSDKCore, useLocalParticipant, useMeeting, useMeetingContext, useMeetingPreview, useParticipants, usePubSub, useRemoteMedia };
|
package/dist/index.d.ts
CHANGED
|
@@ -59,6 +59,14 @@ type ChatMessage = {
|
|
|
59
59
|
} | null;
|
|
60
60
|
target?: string | null;
|
|
61
61
|
};
|
|
62
|
+
type PubSubMessage<T = unknown> = {
|
|
63
|
+
id: string;
|
|
64
|
+
topic: PubSubTopic;
|
|
65
|
+
sender_id: string;
|
|
66
|
+
sender_name?: string | null;
|
|
67
|
+
timestamp: number;
|
|
68
|
+
data: T;
|
|
69
|
+
};
|
|
62
70
|
type Participant = {
|
|
63
71
|
id: string;
|
|
64
72
|
name?: string;
|
|
@@ -98,6 +106,10 @@ type MeetingConfig = {
|
|
|
98
106
|
token?: string;
|
|
99
107
|
};
|
|
100
108
|
type PubSubTopic = "SECURE_CHAT" | "REACTION";
|
|
109
|
+
type PubSubHandle<T = unknown> = {
|
|
110
|
+
messages: PubSubMessage<T>[];
|
|
111
|
+
publish: (data: T) => void;
|
|
112
|
+
};
|
|
101
113
|
type RecordingInfo = {
|
|
102
114
|
recording_id: string;
|
|
103
115
|
started_at?: string;
|
|
@@ -263,10 +275,6 @@ interface ParticipantInfo {
|
|
|
263
275
|
[key: string]: any;
|
|
264
276
|
}
|
|
265
277
|
|
|
266
|
-
type PubSubHandle = {
|
|
267
|
-
messages: ChatMessage[];
|
|
268
|
-
publish: (input: ChatInput) => void;
|
|
269
|
-
};
|
|
270
278
|
type MeetingContextValue = {
|
|
271
279
|
sdk: VideoSDKCore;
|
|
272
280
|
join: (config?: Omit<MeetingConfig, "participantId">) => Promise<void>;
|
|
@@ -296,7 +304,8 @@ type MeetingContextValue = {
|
|
|
296
304
|
presenterId: string | null;
|
|
297
305
|
activeSpeakerIds: string[];
|
|
298
306
|
recording: RecordingInfo | null;
|
|
299
|
-
usePubSub: (topic: PubSubTopic) => PubSubHandle
|
|
307
|
+
usePubSub: <T = unknown>(topic: PubSubTopic) => PubSubHandle<T>;
|
|
308
|
+
onPubSubMessage: <T = unknown>(topic: PubSubTopic, cb: (message: PubSubMessage<T>) => void) => () => void;
|
|
300
309
|
approveJoinRequest: (requestId: string) => void;
|
|
301
310
|
rejectJoinRequest: (requestId: string) => void;
|
|
302
311
|
startRecording: () => Promise<void>;
|
|
@@ -358,10 +367,8 @@ declare const useMeeting: (handlers?: {
|
|
|
358
367
|
presenterId: string | null;
|
|
359
368
|
activeSpeakerIds: string[];
|
|
360
369
|
recording: RecordingInfo | null;
|
|
361
|
-
usePubSub: (topic: PubSubTopic) =>
|
|
362
|
-
|
|
363
|
-
publish: (input: ChatInput) => void;
|
|
364
|
-
};
|
|
370
|
+
usePubSub: <T = unknown>(topic: PubSubTopic) => PubSubHandle<T>;
|
|
371
|
+
onPubSubMessage: <T = unknown>(topic: PubSubTopic, cb: (message: PubSubMessage<T>) => void) => () => void;
|
|
365
372
|
approveJoinRequest: (requestId: string) => void;
|
|
366
373
|
rejectJoinRequest: (requestId: string) => void;
|
|
367
374
|
startRecording: () => Promise<void>;
|
|
@@ -456,4 +463,8 @@ declare class ActiveSpeakerDetector {
|
|
|
456
463
|
destroy(): Promise<void>;
|
|
457
464
|
}
|
|
458
465
|
|
|
459
|
-
|
|
466
|
+
declare function usePubSub<T = unknown>(topic: PubSubTopic, options?: {
|
|
467
|
+
onMessageReceived?: (message: PubSubMessage<T>) => void;
|
|
468
|
+
}): PubSubHandle<T>;
|
|
469
|
+
|
|
470
|
+
export { ActiveSpeakerDetector, type ChatInput, type MeetingConfig, MeetingProvider, MeetingState, type Participant, type ParticipantInfo, type Reaction, type RecordingInfo, type SFUConnectionState, type TrackInfo, VideoSDKCore, useLocalParticipant, useMeeting, useMeetingContext, useMeetingPreview, useParticipants, usePubSub, useRemoteMedia };
|
package/dist/index.js
CHANGED
|
@@ -29,6 +29,7 @@ __export(index_exports, {
|
|
|
29
29
|
useMeetingContext: () => useMeetingContext,
|
|
30
30
|
useMeetingPreview: () => useMeetingPreview,
|
|
31
31
|
useParticipants: () => useParticipants,
|
|
32
|
+
usePubSub: () => usePubSub,
|
|
32
33
|
useRemoteMedia: () => useRemoteMedia
|
|
33
34
|
});
|
|
34
35
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -2825,6 +2826,9 @@ var MeetingProvider = ({
|
|
|
2825
2826
|
const recordingStartedListeners = (0, import_react2.useRef)(/* @__PURE__ */ new Set());
|
|
2826
2827
|
const recordingStoppedListeners = (0, import_react2.useRef)(/* @__PURE__ */ new Set());
|
|
2827
2828
|
const reactionListeners = (0, import_react2.useRef)(/* @__PURE__ */ new Set());
|
|
2829
|
+
const pubSubListeners = (0, import_react2.useRef)(
|
|
2830
|
+
/* @__PURE__ */ new Map()
|
|
2831
|
+
);
|
|
2828
2832
|
const activeSpeakerListeners = (0, import_react2.useRef)(
|
|
2829
2833
|
/* @__PURE__ */ new Set()
|
|
2830
2834
|
);
|
|
@@ -2860,6 +2864,19 @@ var MeetingProvider = ({
|
|
|
2860
2864
|
},
|
|
2861
2865
|
onReaction: (reaction) => {
|
|
2862
2866
|
reactionListeners.current.forEach((fn) => fn(reaction));
|
|
2867
|
+
const listeners = pubSubListeners.current.get("REACTION");
|
|
2868
|
+
if (!listeners) return;
|
|
2869
|
+
const message = {
|
|
2870
|
+
id: reaction.id,
|
|
2871
|
+
topic: "REACTION",
|
|
2872
|
+
sender_id: reaction.participant_id,
|
|
2873
|
+
sender_name: reaction.sender_name,
|
|
2874
|
+
timestamp: typeof reaction.timestamp === "number" ? reaction.timestamp : Date.parse(reaction.timestamp),
|
|
2875
|
+
data: {
|
|
2876
|
+
emoji: reaction.emoji
|
|
2877
|
+
}
|
|
2878
|
+
};
|
|
2879
|
+
listeners.forEach((fn) => fn(message));
|
|
2863
2880
|
},
|
|
2864
2881
|
onConnectionStateChanged: (state) => {
|
|
2865
2882
|
connectionStateListeners.current.forEach(
|
|
@@ -2922,12 +2939,48 @@ var MeetingProvider = ({
|
|
|
2922
2939
|
activeSpeakerIds,
|
|
2923
2940
|
recording,
|
|
2924
2941
|
usePubSub: (topic) => {
|
|
2925
|
-
if (topic
|
|
2926
|
-
|
|
2942
|
+
if (topic === "REACTION") {
|
|
2943
|
+
return {
|
|
2944
|
+
messages: [],
|
|
2945
|
+
publish: (data) => {
|
|
2946
|
+
const reaction = data;
|
|
2947
|
+
if (!reaction?.emoji) {
|
|
2948
|
+
console.warn("[PubSub] REACTION requires an emoji");
|
|
2949
|
+
return;
|
|
2950
|
+
}
|
|
2951
|
+
sdk.sendReaction(reaction.emoji);
|
|
2952
|
+
}
|
|
2953
|
+
};
|
|
2954
|
+
}
|
|
2955
|
+
if (topic === "SECURE_CHAT") {
|
|
2956
|
+
return {
|
|
2957
|
+
messages: sdk.state.getChatMessages().map((message) => ({
|
|
2958
|
+
id: message.id,
|
|
2959
|
+
topic: "SECURE_CHAT",
|
|
2960
|
+
sender_id: message.sender_id,
|
|
2961
|
+
sender_name: message.sender_name,
|
|
2962
|
+
timestamp: message.timestamp,
|
|
2963
|
+
data: message
|
|
2964
|
+
})),
|
|
2965
|
+
publish: (data) => {
|
|
2966
|
+
sdk.sendChatMessage(data);
|
|
2967
|
+
}
|
|
2968
|
+
};
|
|
2969
|
+
}
|
|
2970
|
+
throw new Error(`Unsupported PubSub topic: "${topic}"`);
|
|
2971
|
+
},
|
|
2972
|
+
onPubSubMessage: (topic, cb) => {
|
|
2973
|
+
let listeners = pubSubListeners.current.get(topic);
|
|
2974
|
+
if (!listeners) {
|
|
2975
|
+
listeners = /* @__PURE__ */ new Set();
|
|
2976
|
+
pubSubListeners.current.set(topic, listeners);
|
|
2927
2977
|
}
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2978
|
+
listeners.add(cb);
|
|
2979
|
+
return () => {
|
|
2980
|
+
listeners?.delete(cb);
|
|
2981
|
+
if (listeners?.size === 0) {
|
|
2982
|
+
pubSubListeners.current.delete(topic);
|
|
2983
|
+
}
|
|
2931
2984
|
};
|
|
2932
2985
|
},
|
|
2933
2986
|
approveJoinRequest: sdk.approveJoinRequest.bind(sdk),
|
|
@@ -3226,6 +3279,17 @@ function useMeetingPreview(roomId, participantId) {
|
|
|
3226
3279
|
error
|
|
3227
3280
|
};
|
|
3228
3281
|
}
|
|
3282
|
+
|
|
3283
|
+
// src/react/usePubSub.ts
|
|
3284
|
+
var import_react8 = require("react");
|
|
3285
|
+
function usePubSub(topic, options) {
|
|
3286
|
+
const ctx = useMeetingContext();
|
|
3287
|
+
(0, import_react8.useEffect)(() => {
|
|
3288
|
+
if (!options?.onMessageReceived) return;
|
|
3289
|
+
return ctx.onPubSubMessage(topic, options.onMessageReceived);
|
|
3290
|
+
}, [ctx, topic, options?.onMessageReceived]);
|
|
3291
|
+
return ctx.usePubSub(topic);
|
|
3292
|
+
}
|
|
3229
3293
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3230
3294
|
0 && (module.exports = {
|
|
3231
3295
|
ActiveSpeakerDetector,
|
|
@@ -3237,6 +3301,7 @@ function useMeetingPreview(roomId, participantId) {
|
|
|
3237
3301
|
useMeetingContext,
|
|
3238
3302
|
useMeetingPreview,
|
|
3239
3303
|
useParticipants,
|
|
3304
|
+
usePubSub,
|
|
3240
3305
|
useRemoteMedia
|
|
3241
3306
|
});
|
|
3242
3307
|
//# sourceMappingURL=index.js.map
|