@signalwire/js 3.26.0 → 3.27.0-dev.202404301530.94a97d7.0
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/core/src/BaseComponent.d.ts +10 -0
- package/dist/core/src/BaseComponent.d.ts.map +1 -1
- package/dist/core/src/BaseJWTSession.d.ts.map +1 -1
- package/dist/core/src/BaseSession.d.ts +3 -0
- package/dist/core/src/BaseSession.d.ts.map +1 -1
- package/dist/core/src/RPCMessages/RPCConnect.d.ts +14 -0
- package/dist/core/src/RPCMessages/RPCConnect.d.ts.map +1 -1
- package/dist/core/src/index.d.ts +4 -3
- package/dist/core/src/index.d.ts.map +1 -1
- package/dist/core/src/memberPosition/workers.d.ts.map +1 -1
- package/dist/core/src/redux/index.d.ts +5 -0
- package/dist/core/src/redux/index.d.ts.map +1 -1
- package/dist/core/src/redux/interfaces.d.ts +2 -0
- package/dist/core/src/redux/interfaces.d.ts.map +1 -1
- package/dist/core/src/redux/utils/useInstanceMap.d.ts +2 -0
- package/dist/core/src/redux/utils/useInstanceMap.d.ts.map +1 -1
- package/dist/core/src/rooms/RoomSessionMember.d.ts +39 -0
- package/dist/core/src/rooms/RoomSessionMember.d.ts.map +1 -0
- package/dist/core/src/rooms/index.d.ts +1 -0
- package/dist/core/src/rooms/index.d.ts.map +1 -1
- package/dist/core/src/rooms/methods.d.ts +2 -2
- package/dist/core/src/rooms/methods.d.ts.map +1 -1
- package/dist/core/src/testUtils.d.ts +8 -0
- package/dist/core/src/testUtils.d.ts.map +1 -1
- package/dist/core/src/types/callSegment.d.ts +21 -0
- package/dist/core/src/types/callSegment.d.ts.map +1 -0
- package/dist/core/src/types/callfabric.d.ts +337 -16
- package/dist/core/src/types/callfabric.d.ts.map +1 -1
- package/dist/core/src/types/conversation.d.ts +24 -0
- package/dist/core/src/types/conversation.d.ts.map +1 -0
- package/dist/core/src/types/index.d.ts +15 -1
- package/dist/core/src/types/index.d.ts.map +1 -1
- package/dist/core/src/types/unified.d.ts +36 -0
- package/dist/core/src/types/unified.d.ts.map +1 -0
- package/dist/core/src/types/utils.d.ts +3 -0
- package/dist/core/src/types/utils.d.ts.map +1 -1
- package/dist/core/src/types/videoMember.d.ts +11 -1
- package/dist/core/src/types/videoMember.d.ts.map +1 -1
- package/dist/core/src/types/videoRoomSession.d.ts +3 -0
- package/dist/core/src/types/videoRoomSession.d.ts.map +1 -1
- package/dist/core/src/utils/index.d.ts +1 -0
- package/dist/core/src/utils/index.d.ts.map +1 -1
- package/dist/core/src/utils/interfaces.d.ts +16 -9
- package/dist/core/src/utils/interfaces.d.ts.map +1 -1
- package/dist/core/src/utils/mapObject.d.ts +7 -0
- package/dist/core/src/utils/mapObject.d.ts.map +1 -0
- package/dist/core/src/utils/mapObject.test.d.ts +2 -0
- package/dist/core/src/utils/mapObject.test.d.ts.map +1 -0
- package/dist/core/src/workers/executeActionWorker.d.ts.map +1 -1
- package/dist/index.esm.js +1352 -527
- package/dist/index.esm.js.map +3 -3
- package/dist/index.js +1448 -642
- package/dist/index.js.map +3 -3
- package/dist/index.umd.js +3 -3
- package/dist/index.umd.js.map +1 -1
- package/dist/js/src/BaseRoomSession.d.ts +6 -4
- package/dist/js/src/BaseRoomSession.d.ts.map +1 -1
- package/dist/js/src/Client.d.ts +1 -0
- package/dist/js/src/Client.d.ts.map +1 -1
- package/dist/js/src/JWTSession.d.ts.map +1 -1
- package/dist/js/src/UnifiedJWTSession.d.ts +16 -0
- package/dist/js/src/UnifiedJWTSession.d.ts.map +1 -0
- package/dist/js/src/fabric/CallFabricBaseRoomSession.d.ts +30 -0
- package/dist/js/src/fabric/CallFabricBaseRoomSession.d.ts.map +1 -0
- package/dist/js/src/fabric/CallSegment.d.ts +26 -0
- package/dist/js/src/fabric/CallSegment.d.ts.map +1 -0
- package/dist/js/src/fabric/Conversation.d.ts +144 -0
- package/dist/js/src/fabric/Conversation.d.ts.map +1 -0
- package/dist/js/src/fabric/ConversationAPI.d.ts +61 -0
- package/dist/js/src/fabric/ConversationAPI.d.ts.map +1 -0
- package/dist/js/src/fabric/HTTPClient.d.ts +45 -27
- package/dist/js/src/fabric/HTTPClient.d.ts.map +1 -1
- package/dist/js/src/fabric/IncomingCallManager.d.ts +14 -0
- package/dist/js/src/fabric/IncomingCallManager.d.ts.map +1 -0
- package/dist/js/src/fabric/SignalWire.d.ts +1 -16
- package/dist/js/src/fabric/SignalWire.d.ts.map +1 -1
- package/dist/js/src/fabric/WSClient.d.ts +23 -28
- package/dist/js/src/fabric/WSClient.d.ts.map +1 -1
- package/dist/js/src/fabric/createHttpClient.d.ts +1 -0
- package/dist/js/src/fabric/createHttpClient.d.ts.map +1 -1
- package/dist/js/src/fabric/index.d.ts +3 -0
- package/dist/js/src/fabric/index.d.ts.map +1 -1
- package/dist/js/src/fabric/types.d.ts +93 -0
- package/dist/js/src/fabric/types.d.ts.map +1 -0
- package/dist/js/src/fabric/workers/callFabricWorker.d.ts +7 -0
- package/dist/js/src/fabric/workers/callFabricWorker.d.ts.map +1 -0
- package/dist/js/src/fabric/workers/callJoinWorker.d.ts +4 -0
- package/dist/js/src/fabric/workers/callJoinWorker.d.ts.map +1 -0
- package/dist/js/src/fabric/workers/callLeftWorker.d.ts +4 -0
- package/dist/js/src/fabric/workers/callLeftWorker.d.ts.map +1 -0
- package/dist/js/src/fabric/workers/callStateWorker.d.ts +4 -0
- package/dist/js/src/fabric/workers/callStateWorker.d.ts.map +1 -0
- package/dist/js/src/fabric/workers/conversationWorker.d.ts +4 -0
- package/dist/js/src/fabric/workers/conversationWorker.d.ts.map +1 -0
- package/dist/js/src/fabric/workers/index.d.ts +6 -0
- package/dist/js/src/fabric/workers/index.d.ts.map +1 -0
- package/dist/js/src/fabric/workers/mappers/unifiedEventsMapper.d.ts +3 -0
- package/dist/js/src/fabric/workers/mappers/unifiedEventsMapper.d.ts.map +1 -0
- package/dist/js/src/fabric/workers/unifiedEventsWatcher.d.ts +7 -0
- package/dist/js/src/fabric/workers/unifiedEventsWatcher.d.ts.map +1 -0
- package/dist/js/src/fabric/workers/unifiedTargetWorker.d.ts +3 -0
- package/dist/js/src/fabric/workers/unifiedTargetWorker.d.ts.map +1 -0
- package/dist/js/src/fabric/{WSClientWorker.d.ts → workers/wsClientWorker.d.ts} +3 -3
- package/dist/js/src/fabric/workers/wsClientWorker.d.ts.map +1 -0
- package/dist/js/src/features/mediaElements/mediaElementsSagas.d.ts.map +1 -1
- package/dist/js/src/index.d.ts +7 -8
- package/dist/js/src/index.d.ts.map +1 -1
- package/dist/js/src/testUtils.d.ts +17 -0
- package/dist/js/src/testUtils.d.ts.map +1 -1
- package/dist/js/src/utils/UnifiedRequestMapper.d.ts +4 -0
- package/dist/js/src/utils/UnifiedRequestMapper.d.ts.map +1 -0
- package/dist/js/src/utils/aspectRatioListener.d.ts +8 -0
- package/dist/js/src/utils/aspectRatioListener.d.ts.map +1 -0
- package/dist/js/src/utils/interfaces.d.ts +3 -1
- package/dist/js/src/utils/interfaces.d.ts.map +1 -1
- package/dist/js/src/utils/makeQueryParamsUrl.d.ts +9 -0
- package/dist/js/src/utils/makeQueryParamsUrl.d.ts.map +1 -0
- package/dist/js/src/utils/paginatedResult.d.ts +44 -0
- package/dist/js/src/utils/paginatedResult.d.ts.map +1 -0
- package/dist/js/src/utils/videoElement.d.ts +4 -0
- package/dist/js/src/utils/videoElement.d.ts.map +1 -1
- package/dist/js/src/video/videoMemberWorker.d.ts +6 -0
- package/dist/js/src/video/videoMemberWorker.d.ts.map +1 -0
- package/dist/js/src/video/videoRoomWorker.d.ts +4 -0
- package/dist/js/src/video/videoRoomWorker.d.ts.map +1 -0
- package/dist/js/src/video/videoWorker.d.ts.map +1 -1
- package/dist/js/src/video/videoWorkerUnifiedEventing.d.ts +4 -0
- package/dist/js/src/video/videoWorkerUnifiedEventing.d.ts.map +1 -0
- package/dist/js/src/video/workers.d.ts +5 -0
- package/dist/js/src/video/workers.d.ts.map +1 -1
- package/dist/js/tsconfig.build.tsbuildinfo +1 -1
- package/dist/webrtc/src/BaseConnection.d.ts.map +1 -1
- package/dist/webrtc/src/RTCPeer.d.ts.map +1 -1
- package/dist/webrtc/src/workers/roomSubscribedWorker.d.ts.map +1 -1
- package/package.json +6 -3
- package/src/BaseRoomSession.test.ts +3 -2
- package/src/BaseRoomSession.ts +8 -2
- package/src/Client.ts +10 -2
- package/src/JWTSession.test.ts +2 -2
- package/src/JWTSession.ts +1 -1
- package/src/UnifiedJWTSession.ts +78 -0
- package/src/fabric/CallFabricBaseRoomSession.test.ts +460 -0
- package/src/fabric/CallFabricBaseRoomSession.ts +269 -0
- package/src/fabric/CallSegment.ts +83 -0
- package/src/fabric/Conversation.test.ts +257 -0
- package/src/fabric/Conversation.ts +150 -0
- package/src/fabric/ConversationAPI.ts +44 -0
- package/src/fabric/HTTPClient.test.ts +23 -18
- package/src/fabric/HTTPClient.ts +52 -55
- package/src/fabric/IncomingCallManager.test.ts +245 -0
- package/src/fabric/IncomingCallManager.ts +89 -0
- package/src/fabric/SignalWire.ts +20 -17
- package/src/fabric/WSClient.ts +153 -117
- package/src/fabric/createHttpClient.ts +2 -0
- package/src/fabric/index.ts +3 -0
- package/src/fabric/types.ts +104 -0
- package/src/fabric/workers/callFabricWorker.ts +121 -0
- package/src/fabric/workers/callJoinWorker.ts +90 -0
- package/src/fabric/workers/callLeftWorker.ts +47 -0
- package/src/fabric/workers/callStateWorker.ts +39 -0
- package/src/fabric/workers/conversationWorker.ts +41 -0
- package/src/fabric/workers/index.ts +5 -0
- package/src/fabric/workers/mappers/unifiedEventsMapper.ts +54 -0
- package/src/fabric/workers/unifiedEventsWatcher.ts +75 -0
- package/src/fabric/workers/unifiedTargetWorker.ts +96 -0
- package/src/fabric/{WSClientWorker.ts → workers/wsClientWorker.ts} +14 -18
- package/src/features/mediaElements/mediaElementsSagas.ts +9 -15
- package/src/index.ts +25 -9
- package/src/testUtils.ts +83 -0
- package/src/utils/UnifiedRequestMapper.ts +149 -0
- package/src/utils/aspectRatioListener.ts +40 -0
- package/src/utils/interfaces.ts +3 -0
- package/src/utils/makeQueryParamsUrl.ts +14 -0
- package/src/utils/paginatedResult.ts +34 -0
- package/src/utils/videoElement.ts +4 -0
- package/src/video/videoMemberWorker.ts +107 -0
- package/src/video/videoRoomWorker.ts +103 -0
- package/src/video/videoWorker.ts +8 -3
- package/src/video/videoWorkerUnifiedEventing.ts +95 -0
- package/src/video/workers.ts +5 -0
- package/dist/js/src/fabric/WSClientWorker.d.ts.map +0 -1
package/dist/index.esm.js
CHANGED
|
@@ -38,117 +38,18 @@ var __publicField = (obj, key, value) => {
|
|
|
38
38
|
return value;
|
|
39
39
|
};
|
|
40
40
|
|
|
41
|
-
// src/
|
|
42
|
-
var
|
|
43
|
-
__export(
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
WSClient: () => WSClient
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
// src/fabric/createHttpClient.ts
|
|
51
|
-
import { AuthError, HttpError } from "@signalwire/core";
|
|
52
|
-
async function http(input, init) {
|
|
53
|
-
const response = await fetch(input, init);
|
|
54
|
-
if (!response.ok) {
|
|
55
|
-
if (response.status === 401) {
|
|
56
|
-
throw new AuthError(response.status, "Unauthorized");
|
|
57
|
-
}
|
|
58
|
-
let errorResponse;
|
|
59
|
-
try {
|
|
60
|
-
errorResponse = await response.json();
|
|
61
|
-
} catch (e) {
|
|
62
|
-
}
|
|
63
|
-
const errorMessage = (errorResponse == null ? void 0 : errorResponse.errors) ? JSON.stringify(errorResponse.errors) : "Not Found";
|
|
64
|
-
throw new HttpError(response.status, errorMessage, errorResponse);
|
|
65
|
-
}
|
|
66
|
-
try {
|
|
67
|
-
response.parsedBody = await response.json();
|
|
68
|
-
} catch (e) {
|
|
69
|
-
}
|
|
70
|
-
return response;
|
|
71
|
-
}
|
|
72
|
-
var createHttpClient = (_a, fetcher = http) => {
|
|
73
|
-
var _b = _a, { baseUrl, timeout = 3e4 } = _b, globalOptions = __objRest(_b, ["baseUrl", "timeout"]);
|
|
74
|
-
const apiClient = async (path, options) => {
|
|
75
|
-
const headers = __spreadValues(__spreadValues(__spreadValues({}, (options == null ? void 0 : options.body) ? { "Content-Type": "application/json" } : {}), globalOptions.headers), options == null ? void 0 : options.headers);
|
|
76
|
-
const reqInit = getRequestInit(__spreadProps(__spreadValues(__spreadValues({}, globalOptions), options), {
|
|
77
|
-
headers
|
|
78
|
-
}));
|
|
79
|
-
let timerId;
|
|
80
|
-
if (timeout) {
|
|
81
|
-
const controller = new AbortController();
|
|
82
|
-
const signal = controller.signal;
|
|
83
|
-
reqInit.signal = signal;
|
|
84
|
-
timerId = setTimeout(() => {
|
|
85
|
-
controller.abort();
|
|
86
|
-
}, timeout);
|
|
87
|
-
}
|
|
88
|
-
try {
|
|
89
|
-
const response = await fetcher(getUrl({
|
|
90
|
-
path,
|
|
91
|
-
baseUrl,
|
|
92
|
-
searchParams: options == null ? void 0 : options.searchParams
|
|
93
|
-
}), reqInit);
|
|
94
|
-
return { body: response.parsedBody };
|
|
95
|
-
} catch (e) {
|
|
96
|
-
throw e;
|
|
97
|
-
} finally {
|
|
98
|
-
timerId && clearTimeout(timerId);
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
return apiClient;
|
|
102
|
-
};
|
|
103
|
-
var getBody = (body) => {
|
|
104
|
-
return typeof body === "string" ? body : JSON.stringify(body);
|
|
105
|
-
};
|
|
106
|
-
var getRequestInit = (options) => {
|
|
107
|
-
return Object.entries(options).reduce((reducer, [key, value]) => {
|
|
108
|
-
if (key === "body") {
|
|
109
|
-
return __spreadProps(__spreadValues({}, reducer), {
|
|
110
|
-
body: getBody(value)
|
|
111
|
-
});
|
|
112
|
-
} else if (value != void 0) {
|
|
113
|
-
return __spreadProps(__spreadValues({}, reducer), {
|
|
114
|
-
[key]: value
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
return reducer;
|
|
118
|
-
}, {});
|
|
119
|
-
};
|
|
120
|
-
var getUrl = ({
|
|
121
|
-
path,
|
|
122
|
-
baseUrl,
|
|
123
|
-
searchParams
|
|
124
|
-
}) => {
|
|
125
|
-
const url = new URL(path, baseUrl);
|
|
126
|
-
if (searchParams) {
|
|
127
|
-
Object.entries(searchParams).forEach(([key, value]) => {
|
|
128
|
-
if (value != void 0) {
|
|
129
|
-
url.searchParams.append(key, value);
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
return url.toString();
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
// src/video.ts
|
|
137
|
-
var video_exports = {};
|
|
138
|
-
__export(video_exports, {
|
|
139
|
-
RoomSession: () => RoomSession,
|
|
140
|
-
createClient: () => createClient,
|
|
141
|
-
createRoomObject: () => createRoomObject,
|
|
142
|
-
joinRoom: () => joinRoom
|
|
41
|
+
// src/chat/index.ts
|
|
42
|
+
var chat_exports = {};
|
|
43
|
+
__export(chat_exports, {
|
|
44
|
+
ChatMember: () => ChatMember,
|
|
45
|
+
ChatMessage: () => ChatMessage,
|
|
46
|
+
Client: () => Client2
|
|
143
47
|
});
|
|
144
48
|
|
|
145
|
-
// src/createRoomObject.ts
|
|
146
|
-
import { getLogger as getLogger13 } from "@signalwire/core";
|
|
147
|
-
|
|
148
49
|
// src/createClient.ts
|
|
149
50
|
import {
|
|
150
51
|
configureStore,
|
|
151
|
-
connect as
|
|
52
|
+
connect as connect5,
|
|
152
53
|
getEventEmitter
|
|
153
54
|
} from "@signalwire/core";
|
|
154
55
|
|
|
@@ -294,46 +195,6 @@ var setVideoMediaTrack = ({
|
|
|
294
195
|
element.remove();
|
|
295
196
|
});
|
|
296
197
|
};
|
|
297
|
-
var createRootElementResizeObserver = ({
|
|
298
|
-
video,
|
|
299
|
-
rootElement,
|
|
300
|
-
paddingWrapper
|
|
301
|
-
}) => {
|
|
302
|
-
const computePaddingWrapperWidth = (width, height) => {
|
|
303
|
-
const nativeVideoRatio = video.videoWidth / video.videoHeight;
|
|
304
|
-
const rootElementRatio = width / height;
|
|
305
|
-
if (nativeVideoRatio > rootElementRatio) {
|
|
306
|
-
return "100%";
|
|
307
|
-
} else {
|
|
308
|
-
return `${height * nativeVideoRatio}px`;
|
|
309
|
-
}
|
|
310
|
-
};
|
|
311
|
-
const maxPaddingBottom = video.videoHeight / video.videoWidth * 100;
|
|
312
|
-
const update = debounce(({ width, height }) => {
|
|
313
|
-
if (paddingWrapper) {
|
|
314
|
-
const pb = height / width * 100;
|
|
315
|
-
paddingWrapper.style.paddingBottom = `${pb > maxPaddingBottom ? maxPaddingBottom : pb}%`;
|
|
316
|
-
paddingWrapper.style.width = computePaddingWrapperWidth(width, height);
|
|
317
|
-
}
|
|
318
|
-
}, 100);
|
|
319
|
-
const observer = new ResizeObserver((entries) => {
|
|
320
|
-
entries.forEach((entry) => {
|
|
321
|
-
if (entry.contentBoxSize) {
|
|
322
|
-
const { inlineSize, blockSize } = Array.isArray(entry.contentBoxSize) ? entry.contentBoxSize[0] : entry.contentBoxSize;
|
|
323
|
-
update({ width: inlineSize, height: blockSize });
|
|
324
|
-
} else if (entry.contentRect) {
|
|
325
|
-
update({
|
|
326
|
-
width: entry.contentRect.width,
|
|
327
|
-
height: entry.contentRect.height
|
|
328
|
-
});
|
|
329
|
-
}
|
|
330
|
-
});
|
|
331
|
-
});
|
|
332
|
-
return {
|
|
333
|
-
start: () => observer.observe(rootElement),
|
|
334
|
-
stop: () => observer.disconnect()
|
|
335
|
-
};
|
|
336
|
-
};
|
|
337
198
|
|
|
338
199
|
// src/utils/audioElement.ts
|
|
339
200
|
var setAudioMediaTrack = ({
|
|
@@ -354,6 +215,44 @@ var setAudioMediaTrack = ({
|
|
|
354
215
|
import { actions } from "@signalwire/core";
|
|
355
216
|
var audioSetSpeakerAction = actions.createAction("swJs/audioSetSpeakerAction");
|
|
356
217
|
|
|
218
|
+
// src/utils/aspectRatioListener.ts
|
|
219
|
+
var VIDEO_SIZING_EVENTS = ["loadedmetadata", "resize"];
|
|
220
|
+
function aspectRatioListener({ videoElement, paddingWrapper, fixInLandscapeOrientation = false, debugDivElementId = "videoDimensionsDebug", samplingInterval = 0 }) {
|
|
221
|
+
const buildHtmlContent = (event, width, height) => `Video dimensions on <strong>${event} event</strong>:</strong> ${width}x${height}px - fixInLandscapeOrientation: ${fixInLandscapeOrientation}`;
|
|
222
|
+
const appendDebugInfo = (containerElement, event) => {
|
|
223
|
+
const pEl = document.createElement("p");
|
|
224
|
+
pEl.innerHTML = buildHtmlContent(event, videoElement.videoWidth, videoElement.videoHeight);
|
|
225
|
+
containerElement.appendChild(pEl);
|
|
226
|
+
};
|
|
227
|
+
let debugElement;
|
|
228
|
+
try {
|
|
229
|
+
debugElement = document.getElementById(debugDivElementId);
|
|
230
|
+
} catch (e) {
|
|
231
|
+
}
|
|
232
|
+
VIDEO_SIZING_EVENTS.forEach((event) => videoElement.addEventListener(event, () => {
|
|
233
|
+
const paddingBottom = fixInLandscapeOrientation ? "56.25" : videoElement.videoHeight / videoElement.videoWidth * 100;
|
|
234
|
+
paddingWrapper.style.paddingBottom = `${paddingBottom}%`;
|
|
235
|
+
if (debugElement) {
|
|
236
|
+
appendDebugInfo(debugElement, event);
|
|
237
|
+
}
|
|
238
|
+
}));
|
|
239
|
+
if (samplingInterval > 0) {
|
|
240
|
+
setInterval(() => {
|
|
241
|
+
const paddingBottom = videoElement.videoHeight / videoElement.videoWidth * 100;
|
|
242
|
+
paddingWrapper.style.paddingBottom = `${paddingBottom}%`;
|
|
243
|
+
if (debugElement) {
|
|
244
|
+
let statsElement = debugElement.querySelector(".timer-values");
|
|
245
|
+
if (!statsElement) {
|
|
246
|
+
statsElement = document.createElement("div");
|
|
247
|
+
statsElement.className = "timer-values";
|
|
248
|
+
debugElement.appendChild(statsElement);
|
|
249
|
+
}
|
|
250
|
+
appendDebugInfo(debugElement, "timer");
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
357
256
|
// src/features/mediaElements/mediaElementsSagas.ts
|
|
358
257
|
var makeVideoElementSaga = ({
|
|
359
258
|
rootElement,
|
|
@@ -616,10 +515,14 @@ function* videoElementSetupWorker({
|
|
|
616
515
|
mcuWrapper.appendChild(element);
|
|
617
516
|
const paddingWrapper = document.createElement("div");
|
|
618
517
|
paddingWrapper.classList.add("paddingWrapper");
|
|
619
|
-
paddingWrapper.style.paddingBottom = "56.25%";
|
|
620
518
|
paddingWrapper.style.position = "relative";
|
|
621
519
|
paddingWrapper.style.width = "100%";
|
|
622
520
|
paddingWrapper.appendChild(mcuWrapper);
|
|
521
|
+
aspectRatioListener({
|
|
522
|
+
videoElement: element,
|
|
523
|
+
paddingWrapper,
|
|
524
|
+
fixInLandscapeOrientation: rootElement.classList.contains("landscape-only")
|
|
525
|
+
});
|
|
623
526
|
const layersWrapper = document.createElement("div");
|
|
624
527
|
layersWrapper.classList.add("mcuLayers");
|
|
625
528
|
layersWrapper.style.display = "none";
|
|
@@ -643,17 +546,6 @@ function* videoElementSetupWorker({
|
|
|
643
546
|
yield sagaEffects.call(waitForVideoReady, { element });
|
|
644
547
|
}
|
|
645
548
|
getLogger2().debug("MCU is ready..");
|
|
646
|
-
const rootElementResizeObserver = createRootElementResizeObserver({
|
|
647
|
-
rootElement,
|
|
648
|
-
video: element,
|
|
649
|
-
paddingWrapper
|
|
650
|
-
});
|
|
651
|
-
rootElementResizeObserver.start();
|
|
652
|
-
track.addEventListener("ended", () => {
|
|
653
|
-
if (rootElementResizeObserver) {
|
|
654
|
-
rootElementResizeObserver.stop();
|
|
655
|
-
}
|
|
656
|
-
});
|
|
657
549
|
layersWrapper.style.display = "block";
|
|
658
550
|
} catch (error) {
|
|
659
551
|
getLogger2().error("Handle video track error", error);
|
|
@@ -663,7 +555,7 @@ function* videoElementSetupWorker({
|
|
|
663
555
|
// src/BaseRoomSession.ts
|
|
664
556
|
import {
|
|
665
557
|
connect,
|
|
666
|
-
Rooms as
|
|
558
|
+
Rooms as Rooms8,
|
|
667
559
|
extendComponent as extendComponent3,
|
|
668
560
|
LOCAL_EVENT_PREFIX as LOCAL_EVENT_PREFIX2,
|
|
669
561
|
validateEventsToSubscribe as validateEventsToSubscribe2
|
|
@@ -1013,6 +905,7 @@ var videoPlaybackWorker = function* (options) {
|
|
|
1013
905
|
|
|
1014
906
|
// src/video/videoWorker.ts
|
|
1015
907
|
var videoWorker = function* (options) {
|
|
908
|
+
getLogger7().trace("videoWorker started");
|
|
1016
909
|
const { channels, instance: roomSession } = options;
|
|
1017
910
|
const { swEventChannel } = channels;
|
|
1018
911
|
function* worker(action) {
|
|
@@ -1061,16 +954,91 @@ var videoWorker = function* (options) {
|
|
|
1061
954
|
default:
|
|
1062
955
|
break;
|
|
1063
956
|
}
|
|
1064
|
-
|
|
957
|
+
const event = stripNamespacePrefix3(type, "video");
|
|
958
|
+
roomSession.emit(event, payload);
|
|
1065
959
|
}
|
|
1066
|
-
const
|
|
960
|
+
const isVideoOrCallEvent = (action) => {
|
|
961
|
+
return action.type.startsWith("video.") || action.type.startsWith("call.");
|
|
962
|
+
};
|
|
1067
963
|
while (true) {
|
|
1068
|
-
const action = yield sagaEffects4.take(swEventChannel,
|
|
964
|
+
const action = yield sagaEffects4.take(swEventChannel, isVideoOrCallEvent);
|
|
1069
965
|
yield sagaEffects4.fork(worker, action);
|
|
1070
966
|
}
|
|
1071
967
|
getLogger7().trace("videoWorker ended");
|
|
1072
968
|
};
|
|
1073
969
|
|
|
970
|
+
// src/video/videoMemberWorker.ts
|
|
971
|
+
import {
|
|
972
|
+
Rooms as Rooms6,
|
|
973
|
+
getLogger as getLogger8,
|
|
974
|
+
stripNamespacePrefix as stripNamespacePrefix4
|
|
975
|
+
} from "@signalwire/core";
|
|
976
|
+
var videoMemberWorker = function* (options) {
|
|
977
|
+
var _a, _b;
|
|
978
|
+
getLogger8().trace("videoMemberWorker started");
|
|
979
|
+
const {
|
|
980
|
+
instance: roomSession,
|
|
981
|
+
callSegments,
|
|
982
|
+
action: { type, payload },
|
|
983
|
+
instanceMap: { get, set, remove }
|
|
984
|
+
} = options;
|
|
985
|
+
const memberId = ((_a = payload.member) == null ? void 0 : _a.id) || ((_b = payload.member) == null ? void 0 : _b.member_id);
|
|
986
|
+
let memberInstance = get(memberId);
|
|
987
|
+
if (!memberInstance) {
|
|
988
|
+
memberInstance = Rooms6.createRoomSessionMemberObject({
|
|
989
|
+
store: roomSession.store,
|
|
990
|
+
payload
|
|
991
|
+
});
|
|
992
|
+
} else {
|
|
993
|
+
memberInstance.setPayload(payload);
|
|
994
|
+
}
|
|
995
|
+
set(memberId, memberInstance);
|
|
996
|
+
let newPayload = __spreadValues({}, payload);
|
|
997
|
+
const currentCallSegment = callSegments[callSegments.length - 1];
|
|
998
|
+
if (payload.member.member_id === currentCallSegment.memberId) {
|
|
999
|
+
newPayload = __spreadProps(__spreadValues({}, payload), {
|
|
1000
|
+
member: __spreadProps(__spreadValues({}, payload.member), {
|
|
1001
|
+
id: roomSession.callSegments[0].memberId,
|
|
1002
|
+
member_id: roomSession.callSegments[0].memberId
|
|
1003
|
+
})
|
|
1004
|
+
});
|
|
1005
|
+
}
|
|
1006
|
+
const event = stripNamespacePrefix4(type);
|
|
1007
|
+
if (type.startsWith("video.member.updated.")) {
|
|
1008
|
+
roomSession.emit(event, newPayload);
|
|
1009
|
+
}
|
|
1010
|
+
switch (type) {
|
|
1011
|
+
case "video.member.joined":
|
|
1012
|
+
case "video.member.updated":
|
|
1013
|
+
roomSession.emit(event, newPayload);
|
|
1014
|
+
break;
|
|
1015
|
+
case "video.member.left":
|
|
1016
|
+
roomSession.emit(event, newPayload);
|
|
1017
|
+
remove(memberId);
|
|
1018
|
+
break;
|
|
1019
|
+
case "video.member.talking":
|
|
1020
|
+
roomSession.emit(event, newPayload);
|
|
1021
|
+
if ("talking" in payload.member) {
|
|
1022
|
+
const suffix = payload.member.talking ? "started" : "ended";
|
|
1023
|
+
roomSession.emit(`${event}.${suffix}`, newPayload);
|
|
1024
|
+
const deprecatedSuffix = payload.member.talking ? "start" : "stop";
|
|
1025
|
+
roomSession.emit(`${event}.${deprecatedSuffix}`, newPayload);
|
|
1026
|
+
}
|
|
1027
|
+
break;
|
|
1028
|
+
default:
|
|
1029
|
+
break;
|
|
1030
|
+
}
|
|
1031
|
+
getLogger8().trace("videoMemberWorker ended");
|
|
1032
|
+
};
|
|
1033
|
+
|
|
1034
|
+
// src/video/videoRoomWorker.ts
|
|
1035
|
+
import {
|
|
1036
|
+
getLogger as getLogger9,
|
|
1037
|
+
Rooms as Rooms7,
|
|
1038
|
+
sagaEffects as sagaEffects5,
|
|
1039
|
+
MemberPosition as MemberPosition2
|
|
1040
|
+
} from "@signalwire/core";
|
|
1041
|
+
|
|
1074
1042
|
// src/BaseRoomSession.ts
|
|
1075
1043
|
var RoomSessionConnection = class extends BaseConnection3 {
|
|
1076
1044
|
constructor(options) {
|
|
@@ -1080,6 +1048,9 @@ var RoomSessionConnection = class extends BaseConnection3 {
|
|
|
1080
1048
|
__publicField(this, "_mirrored");
|
|
1081
1049
|
__publicField(this, "_audioEl");
|
|
1082
1050
|
this._mirrored = options.mirrorLocalVideoOverlay;
|
|
1051
|
+
this.initWorker();
|
|
1052
|
+
}
|
|
1053
|
+
initWorker() {
|
|
1083
1054
|
this.runWorker("videoWorker", {
|
|
1084
1055
|
worker: videoWorker
|
|
1085
1056
|
});
|
|
@@ -1337,47 +1308,47 @@ var RoomSessionConnection = class extends BaseConnection3 {
|
|
|
1337
1308
|
}
|
|
1338
1309
|
};
|
|
1339
1310
|
var RoomSessionAPI = extendComponent3(RoomSessionConnection, {
|
|
1340
|
-
audioMute:
|
|
1341
|
-
audioUnmute:
|
|
1342
|
-
videoMute:
|
|
1343
|
-
videoUnmute:
|
|
1344
|
-
deaf:
|
|
1345
|
-
undeaf:
|
|
1346
|
-
setInputVolume:
|
|
1347
|
-
setOutputVolume:
|
|
1348
|
-
setMicrophoneVolume:
|
|
1349
|
-
setSpeakerVolume:
|
|
1350
|
-
setInputSensitivity:
|
|
1351
|
-
removeMember:
|
|
1352
|
-
removeAllMembers:
|
|
1353
|
-
getMembers:
|
|
1354
|
-
getLayouts:
|
|
1355
|
-
setLayout:
|
|
1356
|
-
setPositions:
|
|
1357
|
-
setMemberPosition:
|
|
1358
|
-
hideVideoMuted:
|
|
1359
|
-
showVideoMuted:
|
|
1360
|
-
getRecordings:
|
|
1361
|
-
startRecording:
|
|
1362
|
-
getPlaybacks:
|
|
1363
|
-
play:
|
|
1364
|
-
setHideVideoMuted:
|
|
1365
|
-
getMeta:
|
|
1366
|
-
setMeta:
|
|
1367
|
-
updateMeta:
|
|
1368
|
-
deleteMeta:
|
|
1369
|
-
getMemberMeta:
|
|
1370
|
-
setMemberMeta:
|
|
1371
|
-
updateMemberMeta:
|
|
1372
|
-
deleteMemberMeta:
|
|
1373
|
-
promote:
|
|
1374
|
-
demote:
|
|
1375
|
-
getStreams:
|
|
1376
|
-
startStream:
|
|
1377
|
-
lock:
|
|
1378
|
-
unlock:
|
|
1379
|
-
setRaisedHand:
|
|
1380
|
-
setPrioritizeHandraise:
|
|
1311
|
+
audioMute: Rooms8.audioMuteMember,
|
|
1312
|
+
audioUnmute: Rooms8.audioUnmuteMember,
|
|
1313
|
+
videoMute: Rooms8.videoMuteMember,
|
|
1314
|
+
videoUnmute: Rooms8.videoUnmuteMember,
|
|
1315
|
+
deaf: Rooms8.deafMember,
|
|
1316
|
+
undeaf: Rooms8.undeafMember,
|
|
1317
|
+
setInputVolume: Rooms8.setInputVolumeMember,
|
|
1318
|
+
setOutputVolume: Rooms8.setOutputVolumeMember,
|
|
1319
|
+
setMicrophoneVolume: Rooms8.setInputVolumeMember,
|
|
1320
|
+
setSpeakerVolume: Rooms8.setOutputVolumeMember,
|
|
1321
|
+
setInputSensitivity: Rooms8.setInputSensitivityMember,
|
|
1322
|
+
removeMember: Rooms8.removeMember,
|
|
1323
|
+
removeAllMembers: Rooms8.removeAllMembers,
|
|
1324
|
+
getMembers: Rooms8.getMembers,
|
|
1325
|
+
getLayouts: Rooms8.getLayouts,
|
|
1326
|
+
setLayout: Rooms8.setLayout,
|
|
1327
|
+
setPositions: Rooms8.setPositions,
|
|
1328
|
+
setMemberPosition: Rooms8.setMemberPosition,
|
|
1329
|
+
hideVideoMuted: Rooms8.hideVideoMuted,
|
|
1330
|
+
showVideoMuted: Rooms8.showVideoMuted,
|
|
1331
|
+
getRecordings: Rooms8.getRecordings,
|
|
1332
|
+
startRecording: Rooms8.startRecording,
|
|
1333
|
+
getPlaybacks: Rooms8.getPlaybacks,
|
|
1334
|
+
play: Rooms8.play,
|
|
1335
|
+
setHideVideoMuted: Rooms8.setHideVideoMuted,
|
|
1336
|
+
getMeta: Rooms8.getMeta,
|
|
1337
|
+
setMeta: Rooms8.setMeta,
|
|
1338
|
+
updateMeta: Rooms8.updateMeta,
|
|
1339
|
+
deleteMeta: Rooms8.deleteMeta,
|
|
1340
|
+
getMemberMeta: Rooms8.getMemberMeta,
|
|
1341
|
+
setMemberMeta: Rooms8.setMemberMeta,
|
|
1342
|
+
updateMemberMeta: Rooms8.updateMemberMeta,
|
|
1343
|
+
deleteMemberMeta: Rooms8.deleteMemberMeta,
|
|
1344
|
+
promote: Rooms8.promote,
|
|
1345
|
+
demote: Rooms8.demote,
|
|
1346
|
+
getStreams: Rooms8.getStreams,
|
|
1347
|
+
startStream: Rooms8.startStream,
|
|
1348
|
+
lock: Rooms8.lock,
|
|
1349
|
+
unlock: Rooms8.unlock,
|
|
1350
|
+
setRaisedHand: Rooms8.setRaisedHand,
|
|
1351
|
+
setPrioritizeHandraise: Rooms8.setPrioritizeHandraise
|
|
1381
1352
|
});
|
|
1382
1353
|
var createBaseRoomSessionObject = (params) => {
|
|
1383
1354
|
const room = connect({
|
|
@@ -1396,16 +1367,16 @@ import {
|
|
|
1396
1367
|
} from "@signalwire/core";
|
|
1397
1368
|
|
|
1398
1369
|
// src/cantina/workers/videoManagerWorker.ts
|
|
1399
|
-
import { getLogger as
|
|
1370
|
+
import { getLogger as getLogger12, sagaEffects as sagaEffects6 } from "@signalwire/core";
|
|
1400
1371
|
|
|
1401
1372
|
// src/cantina/workers/videoManagerRoomsWorker.ts
|
|
1402
1373
|
import {
|
|
1403
|
-
getLogger as
|
|
1374
|
+
getLogger as getLogger10,
|
|
1404
1375
|
toExternalJSON,
|
|
1405
|
-
stripNamespacePrefix as
|
|
1376
|
+
stripNamespacePrefix as stripNamespacePrefix5
|
|
1406
1377
|
} from "@signalwire/core";
|
|
1407
1378
|
var videoManagerRoomsWorker = function* (options) {
|
|
1408
|
-
|
|
1379
|
+
getLogger10().trace("videoManagerRoomsWorker started");
|
|
1409
1380
|
const {
|
|
1410
1381
|
instance: client,
|
|
1411
1382
|
action: { type, payload }
|
|
@@ -1413,29 +1384,29 @@ var videoManagerRoomsWorker = function* (options) {
|
|
|
1413
1384
|
const modPayload = {
|
|
1414
1385
|
rooms: payload.rooms.map((row) => toExternalJSON(row))
|
|
1415
1386
|
};
|
|
1416
|
-
client.emit(
|
|
1417
|
-
|
|
1387
|
+
client.emit(stripNamespacePrefix5(type), modPayload);
|
|
1388
|
+
getLogger10().trace("videoManagerRoomsWorker ended");
|
|
1418
1389
|
};
|
|
1419
1390
|
|
|
1420
1391
|
// src/cantina/workers/videoManagerRoomWorker.ts
|
|
1421
1392
|
import {
|
|
1422
|
-
getLogger as
|
|
1393
|
+
getLogger as getLogger11,
|
|
1423
1394
|
toExternalJSON as toExternalJSON2,
|
|
1424
|
-
stripNamespacePrefix as
|
|
1395
|
+
stripNamespacePrefix as stripNamespacePrefix6
|
|
1425
1396
|
} from "@signalwire/core";
|
|
1426
1397
|
var videoManagerRoomWorker = function* (options) {
|
|
1427
|
-
|
|
1398
|
+
getLogger11().trace("videoManagerRoomWorker started");
|
|
1428
1399
|
const {
|
|
1429
1400
|
instance: client,
|
|
1430
1401
|
action: { type, payload }
|
|
1431
1402
|
} = options;
|
|
1432
|
-
client.emit(
|
|
1433
|
-
|
|
1403
|
+
client.emit(stripNamespacePrefix6(type), toExternalJSON2(payload));
|
|
1404
|
+
getLogger11().trace("videoManagerRoomWorker ended");
|
|
1434
1405
|
};
|
|
1435
1406
|
|
|
1436
1407
|
// src/cantina/workers/videoManagerWorker.ts
|
|
1437
1408
|
var videoManagerWorker = function* (options) {
|
|
1438
|
-
|
|
1409
|
+
getLogger12().trace("videoManagerWorker started");
|
|
1439
1410
|
const {
|
|
1440
1411
|
channels: { swEventChannel }
|
|
1441
1412
|
} = options;
|
|
@@ -1443,7 +1414,7 @@ var videoManagerWorker = function* (options) {
|
|
|
1443
1414
|
const { type } = action;
|
|
1444
1415
|
switch (type) {
|
|
1445
1416
|
case "video-manager.rooms.subscribed":
|
|
1446
|
-
yield
|
|
1417
|
+
yield sagaEffects6.fork(videoManagerRoomsWorker, __spreadValues({
|
|
1447
1418
|
action
|
|
1448
1419
|
}, options));
|
|
1449
1420
|
break;
|
|
@@ -1452,22 +1423,22 @@ var videoManagerWorker = function* (options) {
|
|
|
1452
1423
|
case "video-manager.room.ended":
|
|
1453
1424
|
case "video-manager.room.started":
|
|
1454
1425
|
case "video-manager.room.updated":
|
|
1455
|
-
yield
|
|
1426
|
+
yield sagaEffects6.fork(videoManagerRoomWorker, __spreadValues({
|
|
1456
1427
|
action
|
|
1457
1428
|
}, options));
|
|
1458
1429
|
break;
|
|
1459
1430
|
default:
|
|
1460
|
-
|
|
1431
|
+
getLogger12().warn(`Unknown video-manager event: "${type}"`);
|
|
1461
1432
|
break;
|
|
1462
1433
|
}
|
|
1463
1434
|
}
|
|
1464
1435
|
while (true) {
|
|
1465
|
-
const action = yield
|
|
1436
|
+
const action = yield sagaEffects6.take(swEventChannel, (action2) => {
|
|
1466
1437
|
return action2.type.startsWith("video-manager.");
|
|
1467
1438
|
});
|
|
1468
|
-
yield
|
|
1439
|
+
yield sagaEffects6.fork(worker, action);
|
|
1469
1440
|
}
|
|
1470
|
-
|
|
1441
|
+
getLogger12().trace("videoManagerWorker ended");
|
|
1471
1442
|
};
|
|
1472
1443
|
|
|
1473
1444
|
// src/cantina/VideoManager.ts
|
|
@@ -1501,105 +1472,77 @@ var createVideoManagerObject = (params) => {
|
|
|
1501
1472
|
return proxy;
|
|
1502
1473
|
};
|
|
1503
1474
|
|
|
1504
|
-
// src/
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
"stopCameraWhileMuted",
|
|
1524
|
-
"stopMicrophoneWhileMuted"
|
|
1525
|
-
]);
|
|
1526
|
-
const customSagas = [];
|
|
1527
|
-
customSagas.push(makeAudioElementSaga({
|
|
1528
|
-
speakerId: options.speakerId
|
|
1529
|
-
}));
|
|
1530
|
-
if (rootElement) {
|
|
1531
|
-
customSagas.push(makeVideoElementSaga({
|
|
1532
|
-
rootElement,
|
|
1533
|
-
applyLocalVideoOverlay
|
|
1534
|
-
}));
|
|
1535
|
-
}
|
|
1536
|
-
const room = createBaseRoomSessionObject(__spreadProps(__spreadValues({}, options), {
|
|
1537
|
-
store: this.store,
|
|
1538
|
-
customSagas
|
|
1539
|
-
}));
|
|
1540
|
-
if (stopMicrophoneWhileMuted) {
|
|
1541
|
-
room.on("member.updated.audio_muted", ({ member }) => {
|
|
1542
|
-
try {
|
|
1543
|
-
if (member.id === room.memberId && "audio_muted" in member) {
|
|
1544
|
-
member.audio_muted ? room.stopOutboundAudio() : room.restoreOutboundAudio();
|
|
1545
|
-
}
|
|
1546
|
-
} catch (error) {
|
|
1547
|
-
this.logger.error("Error handling audio_muted", error);
|
|
1548
|
-
}
|
|
1549
|
-
});
|
|
1550
|
-
}
|
|
1551
|
-
if (stopCameraWhileMuted) {
|
|
1552
|
-
room.on("member.updated.video_muted", ({ member }) => {
|
|
1553
|
-
try {
|
|
1554
|
-
if (member.id === room.memberId && "video_muted" in member) {
|
|
1555
|
-
member.video_muted ? room.stopOutboundVideo() : room.restoreOutboundVideo();
|
|
1556
|
-
}
|
|
1557
|
-
} catch (error) {
|
|
1558
|
-
this.logger.error("Error handling video_muted", error);
|
|
1559
|
-
}
|
|
1560
|
-
});
|
|
1561
|
-
}
|
|
1562
|
-
return room;
|
|
1475
|
+
// src/fabric/CallFabricBaseRoomSession.ts
|
|
1476
|
+
import {
|
|
1477
|
+
connect as connect4
|
|
1478
|
+
} from "@signalwire/core";
|
|
1479
|
+
|
|
1480
|
+
// src/fabric/workers/wsClientWorker.ts
|
|
1481
|
+
import {
|
|
1482
|
+
getLogger as getLogger13,
|
|
1483
|
+
sagaEffects as sagaEffects7
|
|
1484
|
+
} from "@signalwire/core";
|
|
1485
|
+
var wsClientWorker = function* (options) {
|
|
1486
|
+
getLogger13().trace("wsClientWorker started");
|
|
1487
|
+
const { channels, initialState } = options;
|
|
1488
|
+
const { swEventChannel } = channels;
|
|
1489
|
+
const { buildInboundCall } = initialState;
|
|
1490
|
+
while (true) {
|
|
1491
|
+
const action = yield sagaEffects7.take(swEventChannel, (action2) => {
|
|
1492
|
+
if (action2.type === "webrtc.message") {
|
|
1493
|
+
return action2.payload.method === "verto.invite";
|
|
1563
1494
|
}
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
this._chat = ChatNamespace.createBaseChatObject({
|
|
1569
|
-
store: this.store
|
|
1570
|
-
});
|
|
1571
|
-
}
|
|
1572
|
-
return this._chat;
|
|
1495
|
+
return false;
|
|
1496
|
+
});
|
|
1497
|
+
getLogger13().debug("Receiving a new call over WebSocket", action);
|
|
1498
|
+
buildInboundCall(action.payload.params);
|
|
1573
1499
|
}
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
}
|
|
1586
|
-
|
|
1587
|
-
}
|
|
1588
|
-
|
|
1589
|
-
|
|
1500
|
+
getLogger13().trace("wsClientWorker ended");
|
|
1501
|
+
};
|
|
1502
|
+
|
|
1503
|
+
// src/fabric/workers/conversationWorker.ts
|
|
1504
|
+
import {
|
|
1505
|
+
getLogger as getLogger14,
|
|
1506
|
+
sagaEffects as sagaEffects8
|
|
1507
|
+
} from "@signalwire/core";
|
|
1508
|
+
var conversationWorker = function* (options) {
|
|
1509
|
+
getLogger14().debug("conversationWorker started");
|
|
1510
|
+
const {
|
|
1511
|
+
channels: { swEventChannel },
|
|
1512
|
+
initialState
|
|
1513
|
+
} = options;
|
|
1514
|
+
const { conversation } = initialState;
|
|
1515
|
+
const isConversationEvent = (action) => {
|
|
1516
|
+
return action.type === "conversation.message";
|
|
1517
|
+
};
|
|
1518
|
+
while (true) {
|
|
1519
|
+
const action = yield sagaEffects8.take(swEventChannel, isConversationEvent);
|
|
1520
|
+
conversation.handleEvent(action.payload);
|
|
1590
1521
|
}
|
|
1522
|
+
getLogger14().trace("conversationWorker ended");
|
|
1591
1523
|
};
|
|
1592
1524
|
|
|
1525
|
+
// src/fabric/workers/unifiedTargetWorker.ts
|
|
1526
|
+
import {
|
|
1527
|
+
getLogger as getLogger17,
|
|
1528
|
+
sagaEffects as sagaEffects9
|
|
1529
|
+
} from "@signalwire/core";
|
|
1530
|
+
|
|
1531
|
+
// src/UnifiedJWTSession.ts
|
|
1532
|
+
import {
|
|
1533
|
+
isJSONRPCRequest
|
|
1534
|
+
} from "@signalwire/core";
|
|
1535
|
+
|
|
1593
1536
|
// src/JWTSession.ts
|
|
1594
1537
|
import jwtDecode2 from "jwt-decode";
|
|
1595
1538
|
import {
|
|
1596
1539
|
BaseJWTSession,
|
|
1597
|
-
getLogger as
|
|
1540
|
+
getLogger as getLogger16
|
|
1598
1541
|
} from "@signalwire/core";
|
|
1599
1542
|
|
|
1600
1543
|
// src/utils/storage.ts
|
|
1601
1544
|
import jwtDecode from "jwt-decode";
|
|
1602
|
-
import { getLogger as
|
|
1545
|
+
import { getLogger as getLogger15 } from "@signalwire/core";
|
|
1603
1546
|
var getStorage = () => {
|
|
1604
1547
|
if (window && window.sessionStorage) {
|
|
1605
1548
|
return window.sessionStorage;
|
|
@@ -1614,7 +1557,7 @@ var sessionStorageManager = (token) => {
|
|
|
1614
1557
|
roomName = (_a = jwtPayload == null ? void 0 : jwtPayload.r) != null ? _a : "";
|
|
1615
1558
|
} catch (e) {
|
|
1616
1559
|
if (process.env.NODE_ENV !== "production") {
|
|
1617
|
-
|
|
1560
|
+
getLogger15().error("[sessionStorageManager] error decoding JWT", token);
|
|
1618
1561
|
}
|
|
1619
1562
|
roomName = "";
|
|
1620
1563
|
}
|
|
@@ -1641,16 +1584,16 @@ var JWTSession = class extends BaseJWTSession {
|
|
|
1641
1584
|
});
|
|
1642
1585
|
} catch (e) {
|
|
1643
1586
|
if (process.env.NODE_ENV !== "production") {
|
|
1644
|
-
|
|
1587
|
+
getLogger16().debug("[JWTSession] error decoding the JWT");
|
|
1645
1588
|
}
|
|
1646
1589
|
}
|
|
1647
1590
|
super(__spreadProps(__spreadValues({}, options), {
|
|
1648
|
-
host:
|
|
1591
|
+
host: (decodedJwt == null ? void 0 : decodedJwt.ch) || options.host
|
|
1649
1592
|
}));
|
|
1650
1593
|
this.options = options;
|
|
1651
1594
|
__publicField(this, "WebSocketConstructor", WebSocket);
|
|
1652
1595
|
__publicField(this, "CloseEventConstructor", SwCloseEvent);
|
|
1653
|
-
__publicField(this, "agent", "@signalwire/js/browser/3.
|
|
1596
|
+
__publicField(this, "agent", "@signalwire/js/browser/3.27.0-dev.202404301530.94a97d7.0");
|
|
1654
1597
|
__publicField(this, "tokenTyp");
|
|
1655
1598
|
this.tokenTyp = (_a = decodedJwt.typ) != null ? _a : "VRT";
|
|
1656
1599
|
}
|
|
@@ -1725,6 +1668,532 @@ var JWTSession = class extends BaseJWTSession {
|
|
|
1725
1668
|
}
|
|
1726
1669
|
};
|
|
1727
1670
|
|
|
1671
|
+
// src/fabric/workers/unifiedEventsWatcher.ts
|
|
1672
|
+
import {
|
|
1673
|
+
getLogger as getLogger18,
|
|
1674
|
+
sagaEffects as sagaEffects10,
|
|
1675
|
+
isMappableObject
|
|
1676
|
+
} from "@signalwire/core";
|
|
1677
|
+
|
|
1678
|
+
// src/fabric/workers/mappers/unifiedEventsMapper.ts
|
|
1679
|
+
import { mapObject } from "@signalwire/core";
|
|
1680
|
+
|
|
1681
|
+
// src/fabric/workers/callFabricWorker.ts
|
|
1682
|
+
import {
|
|
1683
|
+
getLogger as getLogger22,
|
|
1684
|
+
sagaEffects as sagaEffects12
|
|
1685
|
+
} from "@signalwire/core";
|
|
1686
|
+
|
|
1687
|
+
// src/fabric/workers/callJoinWorker.ts
|
|
1688
|
+
import {
|
|
1689
|
+
getLogger as getLogger19,
|
|
1690
|
+
sagaEffects as sagaEffects11,
|
|
1691
|
+
Rooms as Rooms9,
|
|
1692
|
+
MemberPosition as MemberPosition3
|
|
1693
|
+
} from "@signalwire/core";
|
|
1694
|
+
|
|
1695
|
+
// src/fabric/CallSegment.ts
|
|
1696
|
+
import {
|
|
1697
|
+
BaseComponent,
|
|
1698
|
+
connect as connect3
|
|
1699
|
+
} from "@signalwire/core";
|
|
1700
|
+
var CallSegmentAPI = class extends BaseComponent {
|
|
1701
|
+
constructor(options) {
|
|
1702
|
+
super(options);
|
|
1703
|
+
__publicField(this, "_payload");
|
|
1704
|
+
this._payload = options.payload;
|
|
1705
|
+
}
|
|
1706
|
+
get roomId() {
|
|
1707
|
+
return this._payload.room_id;
|
|
1708
|
+
}
|
|
1709
|
+
get roomSessionId() {
|
|
1710
|
+
return this._payload.room_session_id;
|
|
1711
|
+
}
|
|
1712
|
+
get callId() {
|
|
1713
|
+
return this._payload.call_id;
|
|
1714
|
+
}
|
|
1715
|
+
get memberId() {
|
|
1716
|
+
return this._payload.member_id;
|
|
1717
|
+
}
|
|
1718
|
+
get roomSession() {
|
|
1719
|
+
return this._payload.room_session;
|
|
1720
|
+
}
|
|
1721
|
+
get members() {
|
|
1722
|
+
return this._payload.members;
|
|
1723
|
+
}
|
|
1724
|
+
get member() {
|
|
1725
|
+
var _a;
|
|
1726
|
+
return (_a = this.members) == null ? void 0 : _a.find((member) => member.memberId === this.memberId);
|
|
1727
|
+
}
|
|
1728
|
+
setPayload(payload) {
|
|
1729
|
+
this._payload = payload;
|
|
1730
|
+
}
|
|
1731
|
+
};
|
|
1732
|
+
var createCallSegmentObject = (params) => {
|
|
1733
|
+
const playback = connect3({
|
|
1734
|
+
store: params.store,
|
|
1735
|
+
Component: CallSegmentAPI
|
|
1736
|
+
})(params);
|
|
1737
|
+
return playback;
|
|
1738
|
+
};
|
|
1739
|
+
|
|
1740
|
+
// src/fabric/workers/callJoinWorker.ts
|
|
1741
|
+
var callJoinWorker = function* (options) {
|
|
1742
|
+
var _a;
|
|
1743
|
+
getLogger19().trace("callJoinWorker started");
|
|
1744
|
+
const { action, callSegments, instanceMap, instance: cfRoomSession } = options;
|
|
1745
|
+
const { payload } = action;
|
|
1746
|
+
const { get, set } = instanceMap;
|
|
1747
|
+
const memberInstances = (_a = payload.room_session.members) == null ? void 0 : _a.map((member) => {
|
|
1748
|
+
let memberInstance = get(member.member_id);
|
|
1749
|
+
if (!memberInstance) {
|
|
1750
|
+
memberInstance = Rooms9.createRoomSessionMemberObject({
|
|
1751
|
+
store: cfRoomSession.store,
|
|
1752
|
+
payload: {
|
|
1753
|
+
room_id: payload.room_id,
|
|
1754
|
+
room_session_id: payload.room_session_id,
|
|
1755
|
+
member
|
|
1756
|
+
}
|
|
1757
|
+
});
|
|
1758
|
+
} else {
|
|
1759
|
+
memberInstance.setPayload({
|
|
1760
|
+
room_id: payload.room_id,
|
|
1761
|
+
room_session_id: payload.room_session_id,
|
|
1762
|
+
member
|
|
1763
|
+
});
|
|
1764
|
+
}
|
|
1765
|
+
set(member.member_id, memberInstance);
|
|
1766
|
+
return memberInstance;
|
|
1767
|
+
});
|
|
1768
|
+
const callSegmentInstance = createCallSegmentObject({
|
|
1769
|
+
store: cfRoomSession.store,
|
|
1770
|
+
payload: __spreadProps(__spreadValues({}, payload), {
|
|
1771
|
+
members: memberInstances
|
|
1772
|
+
})
|
|
1773
|
+
});
|
|
1774
|
+
callSegments.push(callSegmentInstance);
|
|
1775
|
+
cfRoomSession.runWorker("memberPositionWorker", __spreadProps(__spreadValues({
|
|
1776
|
+
worker: MemberPosition3.memberPositionWorker
|
|
1777
|
+
}, options), {
|
|
1778
|
+
instance: cfRoomSession,
|
|
1779
|
+
initialState: payload,
|
|
1780
|
+
dispatcher: function* (subType, subPayload) {
|
|
1781
|
+
yield sagaEffects11.fork(videoMemberWorker, __spreadProps(__spreadValues({}, options), {
|
|
1782
|
+
action: { type: subType, payload: subPayload }
|
|
1783
|
+
}));
|
|
1784
|
+
}
|
|
1785
|
+
}));
|
|
1786
|
+
for (const memberPayload of payload.room_session.members || []) {
|
|
1787
|
+
yield sagaEffects11.fork(videoMemberWorker, __spreadProps(__spreadValues({}, options), {
|
|
1788
|
+
action: {
|
|
1789
|
+
type: "video.member.joined",
|
|
1790
|
+
payload: { member: memberPayload }
|
|
1791
|
+
}
|
|
1792
|
+
}));
|
|
1793
|
+
}
|
|
1794
|
+
cfRoomSession.emit("room.subscribed", payload);
|
|
1795
|
+
cfRoomSession.emit("call.joined", payload);
|
|
1796
|
+
getLogger19().trace("callJoinWorker ended");
|
|
1797
|
+
};
|
|
1798
|
+
|
|
1799
|
+
// src/fabric/workers/callLeftWorker.ts
|
|
1800
|
+
import {
|
|
1801
|
+
getLogger as getLogger20,
|
|
1802
|
+
Rooms as Rooms10
|
|
1803
|
+
} from "@signalwire/core";
|
|
1804
|
+
var callLeftWorker = function* (options) {
|
|
1805
|
+
getLogger20().trace("callLeftWorker started");
|
|
1806
|
+
const {
|
|
1807
|
+
action: { payload },
|
|
1808
|
+
instance: cfRoomSession,
|
|
1809
|
+
callSegments,
|
|
1810
|
+
instanceMap
|
|
1811
|
+
} = options;
|
|
1812
|
+
const { call_id, room_session_id } = payload;
|
|
1813
|
+
const segmentToRemoveIndex = callSegments.findIndex((segment) => segment.callId == call_id);
|
|
1814
|
+
if (segmentToRemoveIndex >= 0) {
|
|
1815
|
+
callSegments.splice(segmentToRemoveIndex, 1);
|
|
1816
|
+
}
|
|
1817
|
+
instanceMap.getAll().forEach(([key, obj]) => {
|
|
1818
|
+
if (obj instanceof Rooms10.RoomSessionMemberAPI && obj.roomSessionId === room_session_id) {
|
|
1819
|
+
instanceMap.remove(key);
|
|
1820
|
+
}
|
|
1821
|
+
});
|
|
1822
|
+
cfRoomSession.emit("call.left", payload);
|
|
1823
|
+
getLogger20().trace("callLeftWorker ended");
|
|
1824
|
+
};
|
|
1825
|
+
|
|
1826
|
+
// src/fabric/workers/callStateWorker.ts
|
|
1827
|
+
import {
|
|
1828
|
+
getLogger as getLogger21
|
|
1829
|
+
} from "@signalwire/core";
|
|
1830
|
+
var callStateWorker = function* (options) {
|
|
1831
|
+
getLogger21().trace("callStateWorker started");
|
|
1832
|
+
const {
|
|
1833
|
+
instance: cfRoomSession,
|
|
1834
|
+
action: { payload },
|
|
1835
|
+
callSegments
|
|
1836
|
+
} = options;
|
|
1837
|
+
switch (payload.call_state) {
|
|
1838
|
+
case "ended": {
|
|
1839
|
+
cfRoomSession.emit("call.state", payload);
|
|
1840
|
+
if (callSegments.length < 1 && cfRoomSession.state === "destroy") {
|
|
1841
|
+
console.log(">> destroy");
|
|
1842
|
+
cfRoomSession.destroy();
|
|
1843
|
+
}
|
|
1844
|
+
break;
|
|
1845
|
+
}
|
|
1846
|
+
default:
|
|
1847
|
+
cfRoomSession.emit("call.state", payload);
|
|
1848
|
+
break;
|
|
1849
|
+
}
|
|
1850
|
+
getLogger21().trace("callStateWorker ended");
|
|
1851
|
+
};
|
|
1852
|
+
|
|
1853
|
+
// src/fabric/workers/callFabricWorker.ts
|
|
1854
|
+
var callFabricWorker = function* (options) {
|
|
1855
|
+
getLogger22().trace("callFabricWorker started");
|
|
1856
|
+
const { channels, instance: roomSession } = options;
|
|
1857
|
+
const { swEventChannel } = channels;
|
|
1858
|
+
function* worker(action) {
|
|
1859
|
+
const { type, payload } = action;
|
|
1860
|
+
switch (type) {
|
|
1861
|
+
case "call.joined": {
|
|
1862
|
+
yield sagaEffects12.fork(callJoinWorker, __spreadValues({
|
|
1863
|
+
action
|
|
1864
|
+
}, options));
|
|
1865
|
+
return;
|
|
1866
|
+
}
|
|
1867
|
+
case "call.left": {
|
|
1868
|
+
yield sagaEffects12.fork(callLeftWorker, __spreadValues({
|
|
1869
|
+
action
|
|
1870
|
+
}, options));
|
|
1871
|
+
return;
|
|
1872
|
+
}
|
|
1873
|
+
case "call.state": {
|
|
1874
|
+
yield sagaEffects12.fork(callStateWorker, __spreadValues({
|
|
1875
|
+
action
|
|
1876
|
+
}, options));
|
|
1877
|
+
return;
|
|
1878
|
+
}
|
|
1879
|
+
case "call.started":
|
|
1880
|
+
case "call.updated":
|
|
1881
|
+
case "call.ended": {
|
|
1882
|
+
const action2 = type.split(".")[1];
|
|
1883
|
+
const newEventName = `room.${action2}`;
|
|
1884
|
+
roomSession.emit(newEventName, payload);
|
|
1885
|
+
break;
|
|
1886
|
+
}
|
|
1887
|
+
case "member.joined":
|
|
1888
|
+
case "member.left":
|
|
1889
|
+
case "member.updated":
|
|
1890
|
+
case "member.talking": {
|
|
1891
|
+
const updatedAction = __spreadProps(__spreadValues({}, action), {
|
|
1892
|
+
type: `video.${type}`
|
|
1893
|
+
});
|
|
1894
|
+
yield sagaEffects12.fork(videoMemberWorker, __spreadValues({
|
|
1895
|
+
action: updatedAction
|
|
1896
|
+
}, options));
|
|
1897
|
+
return;
|
|
1898
|
+
}
|
|
1899
|
+
case "layout.changed": {
|
|
1900
|
+
const updatedAction = __spreadProps(__spreadValues({}, action), {
|
|
1901
|
+
type: `video.${type}`
|
|
1902
|
+
});
|
|
1903
|
+
yield sagaEffects12.put(swEventChannel, updatedAction);
|
|
1904
|
+
break;
|
|
1905
|
+
}
|
|
1906
|
+
case "member.demoted":
|
|
1907
|
+
case "member.promoted": {
|
|
1908
|
+
const updatedAction = __spreadProps(__spreadValues({}, action), {
|
|
1909
|
+
type: `video.${type}`
|
|
1910
|
+
});
|
|
1911
|
+
yield sagaEffects12.put(swEventChannel, updatedAction);
|
|
1912
|
+
return;
|
|
1913
|
+
}
|
|
1914
|
+
default:
|
|
1915
|
+
break;
|
|
1916
|
+
}
|
|
1917
|
+
roomSession.emit(type, payload);
|
|
1918
|
+
}
|
|
1919
|
+
const isVideoOrCallEvent = (action) => {
|
|
1920
|
+
return action.type.startsWith("call.") || action.type.startsWith("member.") || action.type.startsWith("layout.");
|
|
1921
|
+
};
|
|
1922
|
+
while (true) {
|
|
1923
|
+
const action = yield sagaEffects12.take(swEventChannel, isVideoOrCallEvent);
|
|
1924
|
+
yield sagaEffects12.fork(worker, action);
|
|
1925
|
+
}
|
|
1926
|
+
getLogger22().trace("callFabricWorker ended");
|
|
1927
|
+
};
|
|
1928
|
+
|
|
1929
|
+
// src/fabric/CallFabricBaseRoomSession.ts
|
|
1930
|
+
var CallFabricRoomSessionConnection = class extends RoomSessionConnection {
|
|
1931
|
+
initWorker() {
|
|
1932
|
+
this.runWorker("callFabricWorker", {
|
|
1933
|
+
worker: callFabricWorker
|
|
1934
|
+
});
|
|
1935
|
+
}
|
|
1936
|
+
get selfMember() {
|
|
1937
|
+
var _a;
|
|
1938
|
+
return (_a = this.callSegments[0]) == null ? void 0 : _a.member;
|
|
1939
|
+
}
|
|
1940
|
+
get targetMember() {
|
|
1941
|
+
var _a;
|
|
1942
|
+
return (_a = this.callSegments[this.callSegments.length - 1]) == null ? void 0 : _a.member;
|
|
1943
|
+
}
|
|
1944
|
+
isSelfMember(id) {
|
|
1945
|
+
return this.callSegments.findIndex((segment) => segment.memberId === id) > -1;
|
|
1946
|
+
}
|
|
1947
|
+
executeAction(params, options = {}) {
|
|
1948
|
+
const { method, extraParams = {} } = params;
|
|
1949
|
+
return this.execute({
|
|
1950
|
+
method,
|
|
1951
|
+
params: __spreadValues({
|
|
1952
|
+
self: {
|
|
1953
|
+
member_id: this.selfMember.id,
|
|
1954
|
+
call_id: this.selfMember.callId,
|
|
1955
|
+
node_id: this.selfMember.nodeId
|
|
1956
|
+
}
|
|
1957
|
+
}, extraParams)
|
|
1958
|
+
}, options);
|
|
1959
|
+
}
|
|
1960
|
+
executeMemberAction(params, options = {}) {
|
|
1961
|
+
const { method, channel, memberId, extraParams = {} } = params;
|
|
1962
|
+
let targetMember = this.targetMember;
|
|
1963
|
+
if (memberId && !this.isSelfMember(memberId)) {
|
|
1964
|
+
const lastSegment = this.callSegments[this.callSegments.length - 1];
|
|
1965
|
+
const memberInCurrentSegment = lastSegment.members.find((member) => member.id === memberId);
|
|
1966
|
+
if (!memberInCurrentSegment) {
|
|
1967
|
+
throw new Error("The memberId is not a part of the current call segment!");
|
|
1968
|
+
} else {
|
|
1969
|
+
targetMember = memberInCurrentSegment;
|
|
1970
|
+
}
|
|
1971
|
+
}
|
|
1972
|
+
return this.execute({
|
|
1973
|
+
method,
|
|
1974
|
+
params: __spreadValues(__spreadProps(__spreadValues({}, channel && { channels: [channel] }), {
|
|
1975
|
+
self: {
|
|
1976
|
+
member_id: this.selfMember.id,
|
|
1977
|
+
call_id: this.selfMember.callId,
|
|
1978
|
+
node_id: this.selfMember.nodeId
|
|
1979
|
+
},
|
|
1980
|
+
target: {
|
|
1981
|
+
member_id: targetMember.id,
|
|
1982
|
+
call_id: targetMember.callId,
|
|
1983
|
+
node_id: targetMember.nodeId
|
|
1984
|
+
}
|
|
1985
|
+
}), extraParams)
|
|
1986
|
+
}, options);
|
|
1987
|
+
}
|
|
1988
|
+
audioMute(params) {
|
|
1989
|
+
return this.executeMemberAction({
|
|
1990
|
+
method: "call.mute",
|
|
1991
|
+
channel: "audio",
|
|
1992
|
+
memberId: params == null ? void 0 : params.memberId
|
|
1993
|
+
});
|
|
1994
|
+
}
|
|
1995
|
+
audioUnmute(params) {
|
|
1996
|
+
return this.executeMemberAction({
|
|
1997
|
+
method: "call.unmute",
|
|
1998
|
+
channel: "audio",
|
|
1999
|
+
memberId: params == null ? void 0 : params.memberId
|
|
2000
|
+
});
|
|
2001
|
+
}
|
|
2002
|
+
videoMute(params) {
|
|
2003
|
+
return this.executeMemberAction({
|
|
2004
|
+
method: "call.mute",
|
|
2005
|
+
channel: "video",
|
|
2006
|
+
memberId: params == null ? void 0 : params.memberId
|
|
2007
|
+
});
|
|
2008
|
+
}
|
|
2009
|
+
videoUnmute(params) {
|
|
2010
|
+
return this.executeMemberAction({
|
|
2011
|
+
method: "call.unmute",
|
|
2012
|
+
channel: "video",
|
|
2013
|
+
memberId: params == null ? void 0 : params.memberId
|
|
2014
|
+
});
|
|
2015
|
+
}
|
|
2016
|
+
deaf(params) {
|
|
2017
|
+
return this.executeMemberAction({
|
|
2018
|
+
method: "call.deaf",
|
|
2019
|
+
memberId: params == null ? void 0 : params.memberId
|
|
2020
|
+
});
|
|
2021
|
+
}
|
|
2022
|
+
undeaf(params) {
|
|
2023
|
+
return this.executeMemberAction({
|
|
2024
|
+
method: "call.undeaf",
|
|
2025
|
+
memberId: params == null ? void 0 : params.memberId
|
|
2026
|
+
});
|
|
2027
|
+
}
|
|
2028
|
+
getLayouts() {
|
|
2029
|
+
return this.executeAction({
|
|
2030
|
+
method: "call.layout.list"
|
|
2031
|
+
}, {
|
|
2032
|
+
transformResolve: (payload) => ({
|
|
2033
|
+
layouts: payload.layouts
|
|
2034
|
+
})
|
|
2035
|
+
});
|
|
2036
|
+
}
|
|
2037
|
+
getMembers() {
|
|
2038
|
+
return this.executeAction({
|
|
2039
|
+
method: "call.member.list"
|
|
2040
|
+
}, {
|
|
2041
|
+
transformResolve: (payload) => ({
|
|
2042
|
+
members: payload.members
|
|
2043
|
+
})
|
|
2044
|
+
});
|
|
2045
|
+
}
|
|
2046
|
+
removeMember(params) {
|
|
2047
|
+
if (!(params == null ? void 0 : params.memberId)) {
|
|
2048
|
+
throw new TypeError('Invalid or missing "memberId" argument');
|
|
2049
|
+
}
|
|
2050
|
+
return this.executeMemberAction({
|
|
2051
|
+
method: "call.member.remove",
|
|
2052
|
+
memberId: params.memberId
|
|
2053
|
+
});
|
|
2054
|
+
}
|
|
2055
|
+
setLayout(params) {
|
|
2056
|
+
const extraParams = {
|
|
2057
|
+
name: params == null ? void 0 : params.name,
|
|
2058
|
+
layout: Object.values((params == null ? void 0 : params.positions) || {})[0]
|
|
2059
|
+
};
|
|
2060
|
+
return this.executeAction({
|
|
2061
|
+
method: "call.layout.set",
|
|
2062
|
+
extraParams
|
|
2063
|
+
});
|
|
2064
|
+
}
|
|
2065
|
+
setInputVolume(params) {
|
|
2066
|
+
return this.executeMemberAction({
|
|
2067
|
+
method: "call.microphone.volume.set",
|
|
2068
|
+
memberId: params == null ? void 0 : params.memberId,
|
|
2069
|
+
extraParams: {
|
|
2070
|
+
volume: params == null ? void 0 : params.volume
|
|
2071
|
+
}
|
|
2072
|
+
});
|
|
2073
|
+
}
|
|
2074
|
+
setOutputVolume(params) {
|
|
2075
|
+
return this.executeMemberAction({
|
|
2076
|
+
method: "video.member.set_output_volume",
|
|
2077
|
+
memberId: params == null ? void 0 : params.memberId,
|
|
2078
|
+
extraParams: {
|
|
2079
|
+
volume: params == null ? void 0 : params.volume
|
|
2080
|
+
}
|
|
2081
|
+
});
|
|
2082
|
+
}
|
|
2083
|
+
setInputSensitivity(params) {
|
|
2084
|
+
return this.executeMemberAction({
|
|
2085
|
+
method: "call.microphone.sensitivity.set",
|
|
2086
|
+
memberId: params == null ? void 0 : params.memberId,
|
|
2087
|
+
extraParams: {
|
|
2088
|
+
value: params == null ? void 0 : params.value
|
|
2089
|
+
}
|
|
2090
|
+
});
|
|
2091
|
+
}
|
|
2092
|
+
};
|
|
2093
|
+
var createCallFabricBaseRoomSessionObject = (params) => {
|
|
2094
|
+
const room = connect4({
|
|
2095
|
+
store: params.store,
|
|
2096
|
+
customSagas: params.customSagas,
|
|
2097
|
+
Component: CallFabricRoomSessionConnection
|
|
2098
|
+
})(params);
|
|
2099
|
+
return room;
|
|
2100
|
+
};
|
|
2101
|
+
|
|
2102
|
+
// src/Client.ts
|
|
2103
|
+
var ClientAPI = class extends BaseClient {
|
|
2104
|
+
constructor() {
|
|
2105
|
+
super(...arguments);
|
|
2106
|
+
__publicField(this, "_videoManager");
|
|
2107
|
+
__publicField(this, "_chat");
|
|
2108
|
+
__publicField(this, "_pubSub");
|
|
2109
|
+
}
|
|
2110
|
+
get rooms() {
|
|
2111
|
+
return {
|
|
2112
|
+
makeRoomObject: (makeRoomOptions) => {
|
|
2113
|
+
const _a = makeRoomOptions, {
|
|
2114
|
+
rootElement,
|
|
2115
|
+
applyLocalVideoOverlay = true,
|
|
2116
|
+
stopCameraWhileMuted = true,
|
|
2117
|
+
stopMicrophoneWhileMuted = true,
|
|
2118
|
+
unifiedEventing = false
|
|
2119
|
+
} = _a, options = __objRest(_a, [
|
|
2120
|
+
"rootElement",
|
|
2121
|
+
"applyLocalVideoOverlay",
|
|
2122
|
+
"stopCameraWhileMuted",
|
|
2123
|
+
"stopMicrophoneWhileMuted",
|
|
2124
|
+
"unifiedEventing"
|
|
2125
|
+
]);
|
|
2126
|
+
const customSagas = [];
|
|
2127
|
+
customSagas.push(makeAudioElementSaga({
|
|
2128
|
+
speakerId: options.speakerId
|
|
2129
|
+
}));
|
|
2130
|
+
if (rootElement) {
|
|
2131
|
+
customSagas.push(makeVideoElementSaga({
|
|
2132
|
+
rootElement,
|
|
2133
|
+
applyLocalVideoOverlay
|
|
2134
|
+
}));
|
|
2135
|
+
}
|
|
2136
|
+
let roomSessionObject = createBaseRoomSessionObject;
|
|
2137
|
+
if (unifiedEventing) {
|
|
2138
|
+
roomSessionObject = createCallFabricBaseRoomSessionObject;
|
|
2139
|
+
}
|
|
2140
|
+
const room = roomSessionObject(__spreadProps(__spreadValues({}, options), {
|
|
2141
|
+
store: this.store,
|
|
2142
|
+
customSagas
|
|
2143
|
+
}));
|
|
2144
|
+
if (stopMicrophoneWhileMuted) {
|
|
2145
|
+
room.on("member.updated.audio_muted", ({ member }) => {
|
|
2146
|
+
try {
|
|
2147
|
+
if (member.id === room.memberId && "audio_muted" in member) {
|
|
2148
|
+
member.audio_muted ? room.stopOutboundAudio() : room.restoreOutboundAudio();
|
|
2149
|
+
}
|
|
2150
|
+
} catch (error) {
|
|
2151
|
+
this.logger.error("Error handling audio_muted", error);
|
|
2152
|
+
}
|
|
2153
|
+
});
|
|
2154
|
+
}
|
|
2155
|
+
if (stopCameraWhileMuted) {
|
|
2156
|
+
room.on("member.updated.video_muted", ({ member }) => {
|
|
2157
|
+
try {
|
|
2158
|
+
if (member.id === room.memberId && "video_muted" in member) {
|
|
2159
|
+
member.video_muted ? room.stopOutboundVideo() : room.restoreOutboundVideo();
|
|
2160
|
+
}
|
|
2161
|
+
} catch (error) {
|
|
2162
|
+
this.logger.error("Error handling video_muted", error);
|
|
2163
|
+
}
|
|
2164
|
+
});
|
|
2165
|
+
}
|
|
2166
|
+
return room;
|
|
2167
|
+
}
|
|
2168
|
+
};
|
|
2169
|
+
}
|
|
2170
|
+
get chat() {
|
|
2171
|
+
if (!this._chat) {
|
|
2172
|
+
this._chat = ChatNamespace.createBaseChatObject({
|
|
2173
|
+
store: this.store
|
|
2174
|
+
});
|
|
2175
|
+
}
|
|
2176
|
+
return this._chat;
|
|
2177
|
+
}
|
|
2178
|
+
get pubSub() {
|
|
2179
|
+
if (!this._pubSub) {
|
|
2180
|
+
this._pubSub = PubSubNamespace.createBasePubSubObject({
|
|
2181
|
+
store: this.store
|
|
2182
|
+
});
|
|
2183
|
+
}
|
|
2184
|
+
return this._pubSub;
|
|
2185
|
+
}
|
|
2186
|
+
get videoManager() {
|
|
2187
|
+
if (!this._videoManager) {
|
|
2188
|
+
this._videoManager = createVideoManagerObject(this.options);
|
|
2189
|
+
}
|
|
2190
|
+
return this._videoManager;
|
|
2191
|
+
}
|
|
2192
|
+
reauthenticate(token) {
|
|
2193
|
+
this.store.dispatch(actions3.reauthAction({ token }));
|
|
2194
|
+
}
|
|
2195
|
+
};
|
|
2196
|
+
|
|
1728
2197
|
// src/createClient.ts
|
|
1729
2198
|
var createClient = (userOptions) => {
|
|
1730
2199
|
const baseUserOptions = __spreadProps(__spreadValues({}, userOptions), {
|
|
@@ -1734,14 +2203,208 @@ var createClient = (userOptions) => {
|
|
|
1734
2203
|
userOptions: baseUserOptions,
|
|
1735
2204
|
SessionConstructor: JWTSession
|
|
1736
2205
|
});
|
|
1737
|
-
const client =
|
|
2206
|
+
const client = connect5({
|
|
1738
2207
|
store,
|
|
1739
2208
|
Component: ClientAPI
|
|
1740
2209
|
})(baseUserOptions);
|
|
1741
2210
|
return client;
|
|
1742
2211
|
};
|
|
1743
2212
|
|
|
2213
|
+
// src/chat/Client.ts
|
|
2214
|
+
var INTERCEPTED_METHODS = [
|
|
2215
|
+
"subscribe",
|
|
2216
|
+
"publish",
|
|
2217
|
+
"getMessages",
|
|
2218
|
+
"getMembers",
|
|
2219
|
+
"getMemberState",
|
|
2220
|
+
"getAllowedChannels",
|
|
2221
|
+
"setMemberState"
|
|
2222
|
+
];
|
|
2223
|
+
var Client2 = function(chatOptions) {
|
|
2224
|
+
const client = createClient(chatOptions);
|
|
2225
|
+
const createInterceptor = (prop) => {
|
|
2226
|
+
return async (...params) => {
|
|
2227
|
+
await client.connect();
|
|
2228
|
+
return client.chat[prop](...params);
|
|
2229
|
+
};
|
|
2230
|
+
};
|
|
2231
|
+
const interceptors = {
|
|
2232
|
+
_session: client,
|
|
2233
|
+
disconnect: () => client.disconnect()
|
|
2234
|
+
};
|
|
2235
|
+
return new Proxy(client.chat, {
|
|
2236
|
+
get(target, prop, receiver) {
|
|
2237
|
+
if (prop in interceptors) {
|
|
2238
|
+
return interceptors[prop];
|
|
2239
|
+
}
|
|
2240
|
+
if (INTERCEPTED_METHODS.includes(prop)) {
|
|
2241
|
+
return createInterceptor(prop);
|
|
2242
|
+
}
|
|
2243
|
+
return Reflect.get(target, prop, receiver);
|
|
2244
|
+
}
|
|
2245
|
+
});
|
|
2246
|
+
};
|
|
2247
|
+
|
|
2248
|
+
// src/chat/index.ts
|
|
2249
|
+
import { ChatMember, ChatMessage } from "@signalwire/core";
|
|
2250
|
+
|
|
2251
|
+
// src/pubSub/index.ts
|
|
2252
|
+
var pubSub_exports = {};
|
|
2253
|
+
__export(pubSub_exports, {
|
|
2254
|
+
Client: () => Client3,
|
|
2255
|
+
PubSubMessage: () => PubSubMessage
|
|
2256
|
+
});
|
|
2257
|
+
import { PubSub } from "@signalwire/core";
|
|
2258
|
+
|
|
2259
|
+
// src/utils/interfaces.ts
|
|
2260
|
+
import { INTERNAL_MEMBER_UPDATABLE_PROPS } from "@signalwire/core";
|
|
2261
|
+
var INTERNAL_MEMBER_UPDATED_EVENTS = Object.keys(INTERNAL_MEMBER_UPDATABLE_PROPS).map((key) => {
|
|
2262
|
+
return `member.updated.${key}`;
|
|
2263
|
+
});
|
|
2264
|
+
|
|
2265
|
+
// src/pubSub/Client.ts
|
|
2266
|
+
var INTERCEPTED_METHODS2 = [
|
|
2267
|
+
"getAllowedChannels",
|
|
2268
|
+
"subscribe",
|
|
2269
|
+
"publish"
|
|
2270
|
+
];
|
|
2271
|
+
var Client3 = function(pubSubOptions) {
|
|
2272
|
+
const client = createClient(pubSubOptions);
|
|
2273
|
+
const createInterceptor = (prop) => {
|
|
2274
|
+
return async (...params) => {
|
|
2275
|
+
await client.connect();
|
|
2276
|
+
return client.pubSub[prop](...params);
|
|
2277
|
+
};
|
|
2278
|
+
};
|
|
2279
|
+
const interceptors = {
|
|
2280
|
+
_session: client,
|
|
2281
|
+
disconnect: () => client.disconnect()
|
|
2282
|
+
};
|
|
2283
|
+
return new Proxy(client.pubSub, {
|
|
2284
|
+
get(target, prop, receiver) {
|
|
2285
|
+
if (prop in interceptors) {
|
|
2286
|
+
return interceptors[prop];
|
|
2287
|
+
}
|
|
2288
|
+
if (INTERCEPTED_METHODS2.includes(prop)) {
|
|
2289
|
+
return createInterceptor(prop);
|
|
2290
|
+
}
|
|
2291
|
+
return Reflect.get(target, prop, receiver);
|
|
2292
|
+
}
|
|
2293
|
+
});
|
|
2294
|
+
};
|
|
2295
|
+
|
|
2296
|
+
// src/pubSub/index.ts
|
|
2297
|
+
var PubSubMessage = PubSub.PubSubMessage;
|
|
2298
|
+
|
|
2299
|
+
// src/fabric/index.ts
|
|
2300
|
+
var fabric_exports = {};
|
|
2301
|
+
__export(fabric_exports, {
|
|
2302
|
+
Client: () => Client4,
|
|
2303
|
+
ConversationAPI: () => ConversationAPI,
|
|
2304
|
+
HTTPClient: () => HTTPClient,
|
|
2305
|
+
IncomingCallManager: () => IncomingCallManager,
|
|
2306
|
+
SWClient: () => SWClient,
|
|
2307
|
+
SignalWire: () => SignalWire,
|
|
2308
|
+
WSClient: () => WSClient
|
|
2309
|
+
});
|
|
2310
|
+
|
|
2311
|
+
// src/fabric/createHttpClient.ts
|
|
2312
|
+
import { AuthError, HttpError } from "@signalwire/core";
|
|
2313
|
+
async function http(input, init) {
|
|
2314
|
+
const response = await fetch(input, init);
|
|
2315
|
+
if (!response.ok) {
|
|
2316
|
+
if (response.status === 401) {
|
|
2317
|
+
throw new AuthError(response.status, "Unauthorized");
|
|
2318
|
+
}
|
|
2319
|
+
let errorResponse;
|
|
2320
|
+
try {
|
|
2321
|
+
errorResponse = await response.json();
|
|
2322
|
+
} catch (e) {
|
|
2323
|
+
}
|
|
2324
|
+
const errorMessage = (errorResponse == null ? void 0 : errorResponse.errors) ? JSON.stringify(errorResponse.errors) : "Not Found";
|
|
2325
|
+
throw new HttpError(response.status, errorMessage, errorResponse);
|
|
2326
|
+
}
|
|
2327
|
+
try {
|
|
2328
|
+
response.parsedBody = await response.json();
|
|
2329
|
+
} catch (e) {
|
|
2330
|
+
}
|
|
2331
|
+
return response;
|
|
2332
|
+
}
|
|
2333
|
+
var createHttpClient = (_a, fetcher = http) => {
|
|
2334
|
+
var _b = _a, { baseUrl, timeout = 3e4 } = _b, globalOptions = __objRest(_b, ["baseUrl", "timeout"]);
|
|
2335
|
+
const apiClient = async (path, options) => {
|
|
2336
|
+
const headers = __spreadValues(__spreadValues(__spreadValues({}, (options == null ? void 0 : options.body) ? { "Content-Type": "application/json" } : {}), globalOptions.headers), options == null ? void 0 : options.headers);
|
|
2337
|
+
const reqInit = getRequestInit(__spreadProps(__spreadValues(__spreadValues({}, globalOptions), options), {
|
|
2338
|
+
headers
|
|
2339
|
+
}));
|
|
2340
|
+
let timerId;
|
|
2341
|
+
if (timeout) {
|
|
2342
|
+
const controller = new AbortController();
|
|
2343
|
+
const signal = controller.signal;
|
|
2344
|
+
reqInit.signal = signal;
|
|
2345
|
+
timerId = setTimeout(() => {
|
|
2346
|
+
controller.abort();
|
|
2347
|
+
}, timeout);
|
|
2348
|
+
}
|
|
2349
|
+
try {
|
|
2350
|
+
const response = await fetcher(getUrl({
|
|
2351
|
+
path,
|
|
2352
|
+
baseUrl,
|
|
2353
|
+
searchParams: options == null ? void 0 : options.searchParams
|
|
2354
|
+
}), reqInit);
|
|
2355
|
+
return { body: response.parsedBody };
|
|
2356
|
+
} catch (e) {
|
|
2357
|
+
throw e;
|
|
2358
|
+
} finally {
|
|
2359
|
+
timerId && clearTimeout(timerId);
|
|
2360
|
+
}
|
|
2361
|
+
};
|
|
2362
|
+
return apiClient;
|
|
2363
|
+
};
|
|
2364
|
+
var getBody = (body) => {
|
|
2365
|
+
return typeof body === "string" ? body : JSON.stringify(body);
|
|
2366
|
+
};
|
|
2367
|
+
var getRequestInit = (options) => {
|
|
2368
|
+
return Object.entries(options).reduce((reducer, [key, value]) => {
|
|
2369
|
+
if (key === "body") {
|
|
2370
|
+
return __spreadProps(__spreadValues({}, reducer), {
|
|
2371
|
+
body: getBody(value)
|
|
2372
|
+
});
|
|
2373
|
+
} else if (value != void 0) {
|
|
2374
|
+
return __spreadProps(__spreadValues({}, reducer), {
|
|
2375
|
+
[key]: value
|
|
2376
|
+
});
|
|
2377
|
+
}
|
|
2378
|
+
return reducer;
|
|
2379
|
+
}, {});
|
|
2380
|
+
};
|
|
2381
|
+
var getUrl = ({
|
|
2382
|
+
path,
|
|
2383
|
+
baseUrl,
|
|
2384
|
+
searchParams
|
|
2385
|
+
}) => {
|
|
2386
|
+
const url = new URL(path, baseUrl);
|
|
2387
|
+
if (searchParams) {
|
|
2388
|
+
Object.entries(searchParams).forEach(([key, value]) => {
|
|
2389
|
+
if (value != void 0) {
|
|
2390
|
+
url.searchParams.append(key, value);
|
|
2391
|
+
}
|
|
2392
|
+
});
|
|
2393
|
+
}
|
|
2394
|
+
return url.toString();
|
|
2395
|
+
};
|
|
2396
|
+
|
|
2397
|
+
// src/video.ts
|
|
2398
|
+
var video_exports = {};
|
|
2399
|
+
__export(video_exports, {
|
|
2400
|
+
RoomSession: () => RoomSession,
|
|
2401
|
+
createClient: () => createClient,
|
|
2402
|
+
createRoomObject: () => createRoomObject,
|
|
2403
|
+
joinRoom: () => joinRoom
|
|
2404
|
+
});
|
|
2405
|
+
|
|
1744
2406
|
// src/createRoomObject.ts
|
|
2407
|
+
import { getLogger as getLogger23 } from "@signalwire/core";
|
|
1745
2408
|
var VIDEO_CONSTRAINTS = {
|
|
1746
2409
|
aspectRatio: { ideal: 16 / 9 }
|
|
1747
2410
|
};
|
|
@@ -1780,7 +2443,7 @@ var createRoomObject = (roomOptions) => {
|
|
|
1780
2443
|
rootElement = el;
|
|
1781
2444
|
} else {
|
|
1782
2445
|
rootElement = document.body;
|
|
1783
|
-
|
|
2446
|
+
getLogger23().warn(`We couldn't find an element with id: ${rootElementId}: using 'document.body' instead.`);
|
|
1784
2447
|
}
|
|
1785
2448
|
}
|
|
1786
2449
|
const roomObject = client.rooms.makeRoomObject({
|
|
@@ -1807,7 +2470,7 @@ var createRoomObject = (roomOptions) => {
|
|
|
1807
2470
|
});
|
|
1808
2471
|
await roomObject.join();
|
|
1809
2472
|
} catch (error) {
|
|
1810
|
-
|
|
2473
|
+
getLogger23().error("Join", error);
|
|
1811
2474
|
client.disconnect();
|
|
1812
2475
|
reject2(error);
|
|
1813
2476
|
}
|
|
@@ -1843,11 +2506,11 @@ var joinRoom = (roomOptions) => {
|
|
|
1843
2506
|
|
|
1844
2507
|
// src/RoomSession.ts
|
|
1845
2508
|
import {
|
|
1846
|
-
getLogger as
|
|
2509
|
+
getLogger as getLogger25
|
|
1847
2510
|
} from "@signalwire/core";
|
|
1848
2511
|
|
|
1849
2512
|
// src/utils/roomSession.ts
|
|
1850
|
-
import { getLogger as
|
|
2513
|
+
import { getLogger as getLogger24 } from "@signalwire/core";
|
|
1851
2514
|
var getJoinMediaParams = (options) => {
|
|
1852
2515
|
const {
|
|
1853
2516
|
authState,
|
|
@@ -1858,7 +2521,7 @@ var getJoinMediaParams = (options) => {
|
|
|
1858
2521
|
receiveAudio,
|
|
1859
2522
|
receiveVideo
|
|
1860
2523
|
} = options;
|
|
1861
|
-
|
|
2524
|
+
getLogger24().debug("getJoinMediaParams options", __spreadValues({}, options));
|
|
1862
2525
|
const { audio_allowed, video_allowed, join_as } = authState;
|
|
1863
2526
|
const joinAs = join_as != null ? join_as : "member";
|
|
1864
2527
|
const canSend = joinAs === "member";
|
|
@@ -1871,16 +2534,16 @@ var getJoinMediaParams = (options) => {
|
|
|
1871
2534
|
const reqToReceiveAudio = Boolean(receiveAudio != null ? receiveAudio : audio);
|
|
1872
2535
|
const reqToReceiveVideo = Boolean(receiveVideo != null ? receiveVideo : video);
|
|
1873
2536
|
if (!canSendAudio && reqToSendAudio) {
|
|
1874
|
-
|
|
2537
|
+
getLogger24().info("Not allowed to send audio on this room. Default values will be used.");
|
|
1875
2538
|
}
|
|
1876
2539
|
if (!canSendVideo && reqToSendVideo) {
|
|
1877
|
-
|
|
2540
|
+
getLogger24().info("Not allowed to send video on this room. Default values will be used.");
|
|
1878
2541
|
}
|
|
1879
2542
|
if (!canReceiveAudio && reqToReceiveAudio) {
|
|
1880
|
-
|
|
2543
|
+
getLogger24().info("Not allowed to receive video from the room. Default values will be used.");
|
|
1881
2544
|
}
|
|
1882
2545
|
if (!canReceiveVideo && reqToReceiveVideo) {
|
|
1883
|
-
|
|
2546
|
+
getLogger24().info("Not allowed to receive video from the room. Default values will be used.");
|
|
1884
2547
|
}
|
|
1885
2548
|
return {
|
|
1886
2549
|
mustSendAudio: canSendAudio && reqToSendAudio,
|
|
@@ -1975,7 +2638,7 @@ var RoomSession = function(roomOptions) {
|
|
|
1975
2638
|
const deprecatedParams = ["audio", "video"];
|
|
1976
2639
|
deprecatedParams.forEach((param) => {
|
|
1977
2640
|
if (param in roomOptions) {
|
|
1978
|
-
|
|
2641
|
+
getLogger25().warn(`The '${param}' parameter on the RoomSession constructor is deprecated. Set it on the '.join()' function instead.`);
|
|
1979
2642
|
}
|
|
1980
2643
|
});
|
|
1981
2644
|
const allowReattach = (roomOptions == null ? void 0 : roomOptions.reattach) !== false;
|
|
@@ -2046,7 +2709,7 @@ var RoomSession = function(roomOptions) {
|
|
|
2046
2709
|
const audio = (_a2 = params == null ? void 0 : params.audio) != null ? _a2 : audioFromConstructor;
|
|
2047
2710
|
const video = (_b = params == null ? void 0 : params.video) != null ? _b : videoFromConstructor;
|
|
2048
2711
|
const authState = client._sessionAuthState;
|
|
2049
|
-
|
|
2712
|
+
getLogger25().debug("getJoinMediaParams authState?", authState);
|
|
2050
2713
|
if (authState && authState.type === "video") {
|
|
2051
2714
|
const mediaOptions = getJoinMediaParams(__spreadValues({
|
|
2052
2715
|
authState,
|
|
@@ -2059,7 +2722,7 @@ var RoomSession = function(roomOptions) {
|
|
|
2059
2722
|
${JSON.stringify(params, null, 2)}
|
|
2060
2723
|
`));
|
|
2061
2724
|
}
|
|
2062
|
-
|
|
2725
|
+
getLogger25().debug("Set mediaOptions", mediaOptions);
|
|
2063
2726
|
room.updateMediaOptions({
|
|
2064
2727
|
audio: mediaOptions.mustSendAudio ? audio || true : false,
|
|
2065
2728
|
video: mediaOptions.mustSendVideo ? video || true : false,
|
|
@@ -2074,7 +2737,7 @@ ${JSON.stringify(params, null, 2)}
|
|
|
2074
2737
|
REQUIRED_EVENTS.forEach((event) => room.once(event, noop2));
|
|
2075
2738
|
await room.join();
|
|
2076
2739
|
} catch (error) {
|
|
2077
|
-
|
|
2740
|
+
getLogger25().error("RoomSession Join", error);
|
|
2078
2741
|
client.disconnect();
|
|
2079
2742
|
reject(error);
|
|
2080
2743
|
}
|
|
@@ -2139,7 +2802,7 @@ var buildCall = ({
|
|
|
2139
2802
|
};
|
|
2140
2803
|
|
|
2141
2804
|
// src/fabric/Client.ts
|
|
2142
|
-
var
|
|
2805
|
+
var Client4 = class {
|
|
2143
2806
|
constructor(options) {
|
|
2144
2807
|
this.options = options;
|
|
2145
2808
|
__publicField(this, "httpClient");
|
|
@@ -2255,30 +2918,67 @@ var SWClient = class {
|
|
|
2255
2918
|
}
|
|
2256
2919
|
};
|
|
2257
2920
|
|
|
2258
|
-
// src/fabric/WSClient.ts
|
|
2259
|
-
import { getLogger as
|
|
2260
|
-
|
|
2261
|
-
// src/fabric/
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2921
|
+
// src/fabric/WSClient.ts
|
|
2922
|
+
import { getLogger as getLogger26, VertoSubscribe, VertoBye } from "@signalwire/core";
|
|
2923
|
+
|
|
2924
|
+
// src/fabric/IncomingCallManager.ts
|
|
2925
|
+
var IncomingCallManager = class {
|
|
2926
|
+
constructor(_buildCallObject, _executeReject) {
|
|
2927
|
+
this._buildCallObject = _buildCallObject;
|
|
2928
|
+
this._executeReject = _executeReject;
|
|
2929
|
+
__publicField(this, "_pendingInvites", {});
|
|
2930
|
+
__publicField(this, "_handlers", {});
|
|
2931
|
+
}
|
|
2932
|
+
_buildNotification(invite) {
|
|
2933
|
+
const accept = async (params) => {
|
|
2934
|
+
return new Promise((resolve, reject2) => {
|
|
2935
|
+
delete this._pendingInvites[invite.callID];
|
|
2936
|
+
try {
|
|
2937
|
+
const call = this._buildCallObject(invite, params);
|
|
2938
|
+
call.answer();
|
|
2939
|
+
resolve(call);
|
|
2940
|
+
} catch (e) {
|
|
2941
|
+
reject2(e);
|
|
2942
|
+
}
|
|
2943
|
+
});
|
|
2944
|
+
};
|
|
2945
|
+
const reject = () => {
|
|
2946
|
+
delete this._pendingInvites[invite.callID];
|
|
2947
|
+
return this._executeReject(invite.callID, invite.nodeId);
|
|
2948
|
+
};
|
|
2949
|
+
return {
|
|
2950
|
+
invite: {
|
|
2951
|
+
details: invite,
|
|
2952
|
+
accept: (params) => accept(params),
|
|
2953
|
+
reject: () => reject()
|
|
2276
2954
|
}
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2955
|
+
};
|
|
2956
|
+
}
|
|
2957
|
+
setNotificationHandlers(handlers) {
|
|
2958
|
+
this._handlers.all = handlers.all;
|
|
2959
|
+
if (handlers.pushNotification && this._handlers.all != handlers.pushNotification || !handlers.pushNotification) {
|
|
2960
|
+
this._handlers.pushNotification = handlers.pushNotification;
|
|
2961
|
+
}
|
|
2962
|
+
if (handlers.websocket && this._handlers.all != handlers.websocket || !handlers.websocket) {
|
|
2963
|
+
this._handlers.websocket = handlers.websocket;
|
|
2964
|
+
}
|
|
2965
|
+
}
|
|
2966
|
+
handleIncomingInvite(incomingInvite) {
|
|
2967
|
+
var _a, _b;
|
|
2968
|
+
if (incomingInvite.callID in this._pendingInvites) {
|
|
2969
|
+
console.log(`skiping nottification for pending invite to callID: ${incomingInvite.callID}`);
|
|
2970
|
+
return;
|
|
2971
|
+
}
|
|
2972
|
+
this._pendingInvites[incomingInvite.callID] = incomingInvite;
|
|
2973
|
+
if (!(this._handlers.all || this._handlers[incomingInvite.source])) {
|
|
2974
|
+
console.log("skiping nottification no listeners:");
|
|
2975
|
+
return;
|
|
2976
|
+
}
|
|
2977
|
+
const notification = this._buildNotification(incomingInvite);
|
|
2978
|
+
(_b = (_a = this._handlers).all) == null ? void 0 : _b.call(_a, notification);
|
|
2979
|
+
const handler = this._handlers[incomingInvite.source];
|
|
2980
|
+
handler == null ? void 0 : handler(notification);
|
|
2280
2981
|
}
|
|
2281
|
-
getLogger16().trace("WSClientWorker ended");
|
|
2282
2982
|
};
|
|
2283
2983
|
|
|
2284
2984
|
// src/fabric/WSClient.ts
|
|
@@ -2286,41 +2986,49 @@ var WSClient = class {
|
|
|
2286
2986
|
constructor(options) {
|
|
2287
2987
|
this.options = options;
|
|
2288
2988
|
__publicField(this, "wsClient");
|
|
2289
|
-
__publicField(this, "logger",
|
|
2290
|
-
this
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
},
|
|
2296
|
-
logLevel: "debug"
|
|
2297
|
-
});
|
|
2989
|
+
__publicField(this, "logger", getLogger26());
|
|
2990
|
+
__publicField(this, "_incomingCallManager");
|
|
2991
|
+
this.wsClient = createClient(__spreadProps(__spreadValues({}, this.options), {
|
|
2992
|
+
unifiedEventing: true
|
|
2993
|
+
}));
|
|
2994
|
+
this._incomingCallManager = new IncomingCallManager((payload, params) => this.buildInboundCall(payload, params), (callId, nodeId) => this.executeVertoBye(callId, nodeId));
|
|
2298
2995
|
}
|
|
2299
|
-
|
|
2300
|
-
this.wsClient
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2996
|
+
get clientApi() {
|
|
2997
|
+
return this.wsClient;
|
|
2998
|
+
}
|
|
2999
|
+
async connect() {
|
|
3000
|
+
if (!this.wsClient.connected) {
|
|
3001
|
+
this.wsClient.runWorker("wsClientWorker", {
|
|
3002
|
+
worker: wsClientWorker,
|
|
3003
|
+
initialState: {
|
|
3004
|
+
buildInboundCall: (incomingInvite) => this.notifyIncomingInvite("websocket", incomingInvite)
|
|
3005
|
+
}
|
|
3006
|
+
});
|
|
3007
|
+
await this.wsClient.connect();
|
|
3008
|
+
}
|
|
2304
3009
|
}
|
|
2305
3010
|
disconnect() {
|
|
2306
3011
|
return this.wsClient.disconnect();
|
|
2307
3012
|
}
|
|
2308
3013
|
async dial(params) {
|
|
2309
3014
|
return new Promise(async (resolve, reject) => {
|
|
3015
|
+
var _a, _b;
|
|
2310
3016
|
try {
|
|
2311
|
-
console.log("WSClient dial with:", params);
|
|
2312
3017
|
await this.connect();
|
|
2313
3018
|
const call = this.wsClient.rooms.makeRoomObject({
|
|
3019
|
+
audio: (_a = params.audio) != null ? _a : true,
|
|
3020
|
+
video: (_b = params.video) != null ? _b : true,
|
|
2314
3021
|
negotiateAudio: true,
|
|
2315
3022
|
negotiateVideo: true,
|
|
2316
|
-
rootElement:
|
|
3023
|
+
rootElement: params.rootElement,
|
|
2317
3024
|
applyLocalVideoOverlay: true,
|
|
2318
3025
|
stopCameraWhileMuted: true,
|
|
2319
3026
|
stopMicrophoneWhileMuted: true,
|
|
2320
3027
|
destinationNumber: params.to,
|
|
2321
3028
|
watchMediaPackets: false,
|
|
2322
3029
|
nodeId: params.nodeId,
|
|
2323
|
-
disableUdpIceServers:
|
|
3030
|
+
disableUdpIceServers: params.disableUdpIceServers || false,
|
|
3031
|
+
unifiedEventing: true
|
|
2324
3032
|
});
|
|
2325
3033
|
call.once("destroy", () => {
|
|
2326
3034
|
this.logger.debug("RTC Connection Destroyed");
|
|
@@ -2332,18 +3040,17 @@ var WSClient = class {
|
|
|
2332
3040
|
call.start = () => {
|
|
2333
3041
|
return new Promise(async (resolve2, reject2) => {
|
|
2334
3042
|
try {
|
|
2335
|
-
call.once("verto.display", () => resolve2(call));
|
|
2336
3043
|
call.once("room.subscribed", () => resolve2(call));
|
|
2337
3044
|
await call.join();
|
|
2338
3045
|
} catch (error) {
|
|
2339
|
-
|
|
3046
|
+
getLogger26().error("WSClient call start", error);
|
|
2340
3047
|
reject2(error);
|
|
2341
3048
|
}
|
|
2342
3049
|
});
|
|
2343
3050
|
};
|
|
2344
3051
|
resolve(call);
|
|
2345
3052
|
} catch (error) {
|
|
2346
|
-
|
|
3053
|
+
getLogger26().error("WSClient dial", error);
|
|
2347
3054
|
reject(error);
|
|
2348
3055
|
}
|
|
2349
3056
|
});
|
|
@@ -2368,15 +3075,6 @@ var WSClient = class {
|
|
|
2368
3075
|
display_direction
|
|
2369
3076
|
}
|
|
2370
3077
|
} = jsonrpc;
|
|
2371
|
-
this.logger.debug("handlePushNotification data", {
|
|
2372
|
-
callID,
|
|
2373
|
-
sdp,
|
|
2374
|
-
caller_id_name,
|
|
2375
|
-
caller_id_number,
|
|
2376
|
-
callee_id_name,
|
|
2377
|
-
callee_id_number,
|
|
2378
|
-
display_direction
|
|
2379
|
-
});
|
|
2380
3078
|
try {
|
|
2381
3079
|
await this.connect();
|
|
2382
3080
|
try {
|
|
@@ -2384,29 +3082,46 @@ var WSClient = class {
|
|
|
2384
3082
|
} catch (error) {
|
|
2385
3083
|
this.logger.warn("Verto Subscribe", error);
|
|
2386
3084
|
}
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
remoteSdp: sdp,
|
|
2396
|
-
prevCallId: callID,
|
|
3085
|
+
this.notifyIncomingInvite("pushNotification", {
|
|
3086
|
+
callID,
|
|
3087
|
+
sdp,
|
|
3088
|
+
caller_id_name,
|
|
3089
|
+
caller_id_number,
|
|
3090
|
+
callee_id_name,
|
|
3091
|
+
callee_id_number,
|
|
3092
|
+
display_direction,
|
|
2397
3093
|
nodeId
|
|
2398
3094
|
});
|
|
2399
|
-
|
|
2400
|
-
getLogger17().debug("RTC Connection Destroyed");
|
|
2401
|
-
});
|
|
2402
|
-
call.attachPreConnectWorkers();
|
|
2403
|
-
getLogger17().debug("Resolving Call", call);
|
|
2404
|
-
resolve({ resultType: "inboundCall", resultObject: call });
|
|
3095
|
+
resolve({ resultType: "inboundCall" });
|
|
2405
3096
|
} catch (error) {
|
|
2406
3097
|
reject(error);
|
|
2407
3098
|
}
|
|
2408
3099
|
});
|
|
2409
3100
|
}
|
|
3101
|
+
notifyIncomingInvite(source, buildCallParams) {
|
|
3102
|
+
this._incomingCallManager.handleIncomingInvite(__spreadValues({
|
|
3103
|
+
source
|
|
3104
|
+
}, buildCallParams));
|
|
3105
|
+
}
|
|
3106
|
+
async executeVertoBye(callId, nodeId) {
|
|
3107
|
+
try {
|
|
3108
|
+
return await this.wsClient.execute({
|
|
3109
|
+
method: "webrtc.verto",
|
|
3110
|
+
params: {
|
|
3111
|
+
callID: callId,
|
|
3112
|
+
node_id: nodeId,
|
|
3113
|
+
message: VertoBye({
|
|
3114
|
+
cause: "USER_BUSY",
|
|
3115
|
+
causeCode: "17",
|
|
3116
|
+
dialogParams: { callID: callId }
|
|
3117
|
+
})
|
|
3118
|
+
}
|
|
3119
|
+
});
|
|
3120
|
+
} catch (error) {
|
|
3121
|
+
this.logger.warn("The call is not available anymore", callId);
|
|
3122
|
+
throw error;
|
|
3123
|
+
}
|
|
3124
|
+
}
|
|
2410
3125
|
async executeVertoSubscribe(callId, nodeId) {
|
|
2411
3126
|
try {
|
|
2412
3127
|
return await this.wsClient.execute({
|
|
@@ -2426,6 +3141,33 @@ var WSClient = class {
|
|
|
2426
3141
|
throw error;
|
|
2427
3142
|
}
|
|
2428
3143
|
}
|
|
3144
|
+
buildInboundCall(payload, params) {
|
|
3145
|
+
var _a, _b;
|
|
3146
|
+
getLogger26().debug("Build new call to answer");
|
|
3147
|
+
const { callID, nodeId, sdp } = payload;
|
|
3148
|
+
const call = this.wsClient.rooms.makeRoomObject({
|
|
3149
|
+
audio: (_a = params.audio) != null ? _a : true,
|
|
3150
|
+
video: (_b = params.video) != null ? _b : true,
|
|
3151
|
+
negotiateAudio: true,
|
|
3152
|
+
negotiateVideo: true,
|
|
3153
|
+
rootElement: params.rootElement,
|
|
3154
|
+
applyLocalVideoOverlay: true,
|
|
3155
|
+
stopCameraWhileMuted: true,
|
|
3156
|
+
stopMicrophoneWhileMuted: true,
|
|
3157
|
+
watchMediaPackets: false,
|
|
3158
|
+
remoteSdp: sdp,
|
|
3159
|
+
prevCallId: callID,
|
|
3160
|
+
nodeId,
|
|
3161
|
+
disableUdpIceServers: params.disableUdpIceServers || false,
|
|
3162
|
+
unifiedEventing: true
|
|
3163
|
+
});
|
|
3164
|
+
call.once("destroy", () => {
|
|
3165
|
+
getLogger26().debug("RTC Connection Destroyed");
|
|
3166
|
+
});
|
|
3167
|
+
call.attachPreConnectWorkers();
|
|
3168
|
+
getLogger26().debug("Resolving Call", call);
|
|
3169
|
+
return call;
|
|
3170
|
+
}
|
|
2429
3171
|
updateToken(token) {
|
|
2430
3172
|
return new Promise((resolve, reject) => {
|
|
2431
3173
|
this.wsClient.once("session.auth_error", (error) => {
|
|
@@ -2437,13 +3179,65 @@ var WSClient = class {
|
|
|
2437
3179
|
this.wsClient.reauthenticate(token);
|
|
2438
3180
|
});
|
|
2439
3181
|
}
|
|
3182
|
+
async online({ incomingCallHandlers }) {
|
|
3183
|
+
this._incomingCallManager.setNotificationHandlers(incomingCallHandlers);
|
|
3184
|
+
await this.connect();
|
|
3185
|
+
return this.wsClient.execute({
|
|
3186
|
+
method: "subscriber.online",
|
|
3187
|
+
params: {}
|
|
3188
|
+
});
|
|
3189
|
+
}
|
|
3190
|
+
offline() {
|
|
3191
|
+
this._incomingCallManager.setNotificationHandlers({});
|
|
3192
|
+
return this.wsClient.execute({
|
|
3193
|
+
method: "subscriber.offline",
|
|
3194
|
+
params: {}
|
|
3195
|
+
});
|
|
3196
|
+
}
|
|
2440
3197
|
};
|
|
2441
3198
|
|
|
2442
3199
|
// src/fabric/HTTPClient.ts
|
|
3200
|
+
import jwtDecode3 from "jwt-decode";
|
|
2443
3201
|
import {
|
|
2444
|
-
getLogger as
|
|
3202
|
+
getLogger as getLogger27
|
|
2445
3203
|
} from "@signalwire/core";
|
|
2446
|
-
|
|
3204
|
+
|
|
3205
|
+
// src/utils/paginatedResult.ts
|
|
3206
|
+
function buildPaginatedResult(body, client) {
|
|
3207
|
+
const anotherPage = async (url) => {
|
|
3208
|
+
const { body: body2 } = await client(url);
|
|
3209
|
+
return buildPaginatedResult(body2, client);
|
|
3210
|
+
};
|
|
3211
|
+
return {
|
|
3212
|
+
data: body.data,
|
|
3213
|
+
self: async () => {
|
|
3214
|
+
const { self } = body.links;
|
|
3215
|
+
return self ? anotherPage(self) : void 0;
|
|
3216
|
+
},
|
|
3217
|
+
nextPage: async () => {
|
|
3218
|
+
const { next } = body.links;
|
|
3219
|
+
return next ? anotherPage(next) : void 0;
|
|
3220
|
+
},
|
|
3221
|
+
prevPage: async () => {
|
|
3222
|
+
const { prev } = body.links;
|
|
3223
|
+
return prev ? anotherPage(prev) : void 0;
|
|
3224
|
+
},
|
|
3225
|
+
firstPage: async () => {
|
|
3226
|
+
const { first } = body.links;
|
|
3227
|
+
return first ? anotherPage(first) : void 0;
|
|
3228
|
+
},
|
|
3229
|
+
hasNext: Boolean(body.links.next),
|
|
3230
|
+
hasPrev: Boolean(body.links.prev)
|
|
3231
|
+
};
|
|
3232
|
+
}
|
|
3233
|
+
|
|
3234
|
+
// src/utils/makeQueryParamsUrl.ts
|
|
3235
|
+
function makeQueryParamsUrls(path, queryParams) {
|
|
3236
|
+
const queryString = queryParams.toString();
|
|
3237
|
+
return queryString ? `${path}?${queryString}` : path;
|
|
3238
|
+
}
|
|
3239
|
+
|
|
3240
|
+
// src/fabric/HTTPClient.ts
|
|
2447
3241
|
var HTTPClient = class {
|
|
2448
3242
|
constructor(options) {
|
|
2449
3243
|
this.options = options;
|
|
@@ -2455,6 +3249,9 @@ var HTTPClient = class {
|
|
|
2455
3249
|
}
|
|
2456
3250
|
});
|
|
2457
3251
|
}
|
|
3252
|
+
get fetch() {
|
|
3253
|
+
return this.httpClient;
|
|
3254
|
+
}
|
|
2458
3255
|
get httpHost() {
|
|
2459
3256
|
let decodedJwt = {};
|
|
2460
3257
|
try {
|
|
@@ -2463,7 +3260,7 @@ var HTTPClient = class {
|
|
|
2463
3260
|
});
|
|
2464
3261
|
} catch (e) {
|
|
2465
3262
|
if (process.env.NODE_ENV !== "production") {
|
|
2466
|
-
|
|
3263
|
+
getLogger27().debug("[JWTSession] error decoding the JWT");
|
|
2467
3264
|
}
|
|
2468
3265
|
}
|
|
2469
3266
|
const host = this.options.host || (decodedJwt == null ? void 0 : decodedJwt.ch);
|
|
@@ -2472,44 +3269,27 @@ var HTTPClient = class {
|
|
|
2472
3269
|
}
|
|
2473
3270
|
return `fabric.${host.split(".").splice(1).join(".")}`;
|
|
2474
3271
|
}
|
|
3272
|
+
async getAddress(options) {
|
|
3273
|
+
const { id } = options;
|
|
3274
|
+
let path = `/api/fabric/addresses/${id}`;
|
|
3275
|
+
const { body } = await this.httpClient(path);
|
|
3276
|
+
return body;
|
|
3277
|
+
}
|
|
2475
3278
|
async getAddresses(options) {
|
|
2476
|
-
const { type, displayName } = options || {};
|
|
2477
|
-
let path = "/addresses";
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
queryParams.append("type", type);
|
|
2482
|
-
}
|
|
2483
|
-
if (displayName) {
|
|
2484
|
-
queryParams.append("display_name", displayName);
|
|
2485
|
-
}
|
|
2486
|
-
path += `?${queryParams.toString()}`;
|
|
3279
|
+
const { type, displayName, pageSize } = options || {};
|
|
3280
|
+
let path = "/api/fabric/addresses";
|
|
3281
|
+
const queryParams = new URLSearchParams();
|
|
3282
|
+
if (type) {
|
|
3283
|
+
queryParams.append("type", type);
|
|
2487
3284
|
}
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
nextPage: async () => {
|
|
2497
|
-
const { next } = body2.links;
|
|
2498
|
-
return next ? anotherPage(next) : void 0;
|
|
2499
|
-
},
|
|
2500
|
-
prevPage: async () => {
|
|
2501
|
-
const { prev } = body2.links;
|
|
2502
|
-
return prev ? anotherPage(prev) : void 0;
|
|
2503
|
-
},
|
|
2504
|
-
firstPage: async () => {
|
|
2505
|
-
const { first } = body2.links;
|
|
2506
|
-
return first ? anotherPage(first) : void 0;
|
|
2507
|
-
},
|
|
2508
|
-
hasNext: Boolean(body2.links.next),
|
|
2509
|
-
hasPrev: Boolean(body2.links.prev)
|
|
2510
|
-
};
|
|
2511
|
-
};
|
|
2512
|
-
return buildResult(body);
|
|
3285
|
+
if (displayName) {
|
|
3286
|
+
queryParams.append("display_name", displayName);
|
|
3287
|
+
}
|
|
3288
|
+
if (pageSize) {
|
|
3289
|
+
queryParams.append("page_size", pageSize.toString());
|
|
3290
|
+
}
|
|
3291
|
+
const { body } = await this.httpClient(makeQueryParamsUrls(path, queryParams));
|
|
3292
|
+
return buildPaginatedResult(body, this.httpClient);
|
|
2513
3293
|
}
|
|
2514
3294
|
async registerDevice({
|
|
2515
3295
|
deviceType,
|
|
@@ -2531,6 +3311,131 @@ var HTTPClient = class {
|
|
|
2531
3311
|
method: "DELETE"
|
|
2532
3312
|
});
|
|
2533
3313
|
}
|
|
3314
|
+
async getSubscriberInfo() {
|
|
3315
|
+
let path = "/api/fabric/subscriber/info";
|
|
3316
|
+
const { body } = await this.httpClient(path);
|
|
3317
|
+
return body;
|
|
3318
|
+
}
|
|
3319
|
+
};
|
|
3320
|
+
|
|
3321
|
+
// src/fabric/ConversationAPI.ts
|
|
3322
|
+
var ConversationAPI = class {
|
|
3323
|
+
constructor(conversation, data) {
|
|
3324
|
+
this.conversation = conversation;
|
|
3325
|
+
this.data = data;
|
|
3326
|
+
}
|
|
3327
|
+
get id() {
|
|
3328
|
+
return this.data.id;
|
|
3329
|
+
}
|
|
3330
|
+
get created_at() {
|
|
3331
|
+
return this.data.created_at;
|
|
3332
|
+
}
|
|
3333
|
+
get last_message_at() {
|
|
3334
|
+
return this.data.last_message_at;
|
|
3335
|
+
}
|
|
3336
|
+
get metadata() {
|
|
3337
|
+
return this.data.metadata;
|
|
3338
|
+
}
|
|
3339
|
+
get name() {
|
|
3340
|
+
return this.data.name;
|
|
3341
|
+
}
|
|
3342
|
+
sendMessage(options) {
|
|
3343
|
+
return this.conversation.sendMessage({
|
|
3344
|
+
addressId: this.id,
|
|
3345
|
+
text: options.text
|
|
3346
|
+
});
|
|
3347
|
+
}
|
|
3348
|
+
getMessages(options) {
|
|
3349
|
+
return this.conversation.getConversationMessages(__spreadValues({ addressId: this.id }, options));
|
|
3350
|
+
}
|
|
3351
|
+
};
|
|
3352
|
+
|
|
3353
|
+
// src/fabric/Conversation.ts
|
|
3354
|
+
var Conversation = class {
|
|
3355
|
+
constructor(options) {
|
|
3356
|
+
__publicField(this, "httpClient");
|
|
3357
|
+
__publicField(this, "wsClient");
|
|
3358
|
+
__publicField(this, "callbacks", []);
|
|
3359
|
+
this.httpClient = options.httpClient;
|
|
3360
|
+
this.wsClient = options.wsClient;
|
|
3361
|
+
this.wsClient.clientApi.runWorker("conversationWorker", {
|
|
3362
|
+
worker: conversationWorker,
|
|
3363
|
+
initialState: {
|
|
3364
|
+
conversation: this
|
|
3365
|
+
}
|
|
3366
|
+
});
|
|
3367
|
+
}
|
|
3368
|
+
async sendMessage(options) {
|
|
3369
|
+
try {
|
|
3370
|
+
const { addressId, text } = options;
|
|
3371
|
+
const path = "/api/fabric/messages";
|
|
3372
|
+
const { body } = await this.httpClient.fetch(path, {
|
|
3373
|
+
method: "POST",
|
|
3374
|
+
body: {
|
|
3375
|
+
conversation_id: addressId,
|
|
3376
|
+
text
|
|
3377
|
+
}
|
|
3378
|
+
});
|
|
3379
|
+
return body;
|
|
3380
|
+
} catch (error) {
|
|
3381
|
+
throw new Error("Error sending message to conversation!", error);
|
|
3382
|
+
}
|
|
3383
|
+
}
|
|
3384
|
+
async getConversations(options) {
|
|
3385
|
+
try {
|
|
3386
|
+
const { pageSize } = options || {};
|
|
3387
|
+
const path = "/api/fabric/conversations";
|
|
3388
|
+
const queryParams = new URLSearchParams();
|
|
3389
|
+
if (pageSize) {
|
|
3390
|
+
queryParams.append("page_size", pageSize.toString());
|
|
3391
|
+
}
|
|
3392
|
+
const { body } = await this.httpClient.fetch(makeQueryParamsUrls(path, queryParams));
|
|
3393
|
+
const self = this;
|
|
3394
|
+
const data = body.data.map((conversation) => new ConversationAPI(self, conversation));
|
|
3395
|
+
return buildPaginatedResult(__spreadProps(__spreadValues({}, body), { data }), this.httpClient.fetch);
|
|
3396
|
+
} catch (error) {
|
|
3397
|
+
throw new Error("Error fetching the conversation history!", error);
|
|
3398
|
+
}
|
|
3399
|
+
}
|
|
3400
|
+
async getMessages(options) {
|
|
3401
|
+
try {
|
|
3402
|
+
const { pageSize } = options || {};
|
|
3403
|
+
const path = "/api/fabric/messages";
|
|
3404
|
+
const queryParams = new URLSearchParams();
|
|
3405
|
+
if (pageSize) {
|
|
3406
|
+
queryParams.append("page_size", pageSize.toString());
|
|
3407
|
+
}
|
|
3408
|
+
const { body } = await this.httpClient.fetch(makeQueryParamsUrls(path, queryParams));
|
|
3409
|
+
return buildPaginatedResult(body, this.httpClient.fetch);
|
|
3410
|
+
} catch (error) {
|
|
3411
|
+
throw new Error("Error fetching the conversation messages!", error);
|
|
3412
|
+
}
|
|
3413
|
+
}
|
|
3414
|
+
async getConversationMessages(options) {
|
|
3415
|
+
try {
|
|
3416
|
+
const { addressId, pageSize } = options || {};
|
|
3417
|
+
const path = `/api/fabric/conversations/${addressId}/messages`;
|
|
3418
|
+
const queryParams = new URLSearchParams();
|
|
3419
|
+
if (pageSize) {
|
|
3420
|
+
queryParams.append("page_size", pageSize.toString());
|
|
3421
|
+
}
|
|
3422
|
+
const { body } = await this.httpClient.fetch(makeQueryParamsUrls(path, queryParams));
|
|
3423
|
+
return buildPaginatedResult(body, this.httpClient.fetch);
|
|
3424
|
+
} catch (error) {
|
|
3425
|
+
throw new Error("Error fetching the conversation messages!", error);
|
|
3426
|
+
}
|
|
3427
|
+
}
|
|
3428
|
+
async subscribe(callback) {
|
|
3429
|
+
this.wsClient.connect();
|
|
3430
|
+
this.callbacks.push(callback);
|
|
3431
|
+
}
|
|
3432
|
+
handleEvent(event) {
|
|
3433
|
+
if (this.callbacks.length) {
|
|
3434
|
+
this.callbacks.forEach((callback) => {
|
|
3435
|
+
callback(event);
|
|
3436
|
+
});
|
|
3437
|
+
}
|
|
3438
|
+
}
|
|
2534
3439
|
};
|
|
2535
3440
|
|
|
2536
3441
|
// src/fabric/SignalWire.ts
|
|
@@ -2539,16 +3444,30 @@ var SignalWire = (options) => {
|
|
|
2539
3444
|
try {
|
|
2540
3445
|
const httpClient = new HTTPClient(options);
|
|
2541
3446
|
const wsClient = new WSClient(options);
|
|
3447
|
+
const conversation = new Conversation({ httpClient, wsClient });
|
|
2542
3448
|
resolve({
|
|
2543
3449
|
httpHost: httpClient.httpHost,
|
|
2544
|
-
getAddresses: httpClient.getAddresses.bind(httpClient),
|
|
2545
3450
|
registerDevice: httpClient.registerDevice.bind(httpClient),
|
|
2546
3451
|
unregisterDevice: httpClient.unregisterDevice.bind(httpClient),
|
|
3452
|
+
getSubscriberInfo: httpClient.getSubscriberInfo.bind(httpClient),
|
|
2547
3453
|
connect: wsClient.connect.bind(wsClient),
|
|
2548
3454
|
disconnect: wsClient.disconnect.bind(wsClient),
|
|
3455
|
+
online: wsClient.online.bind(wsClient),
|
|
3456
|
+
offline: wsClient.offline.bind(wsClient),
|
|
2549
3457
|
dial: wsClient.dial.bind(wsClient),
|
|
2550
3458
|
handlePushNotification: wsClient.handlePushNotification.bind(wsClient),
|
|
2551
3459
|
updateToken: wsClient.updateToken.bind(wsClient),
|
|
3460
|
+
address: {
|
|
3461
|
+
getAddresses: httpClient.getAddresses.bind(httpClient),
|
|
3462
|
+
getAddress: httpClient.getAddress.bind(httpClient)
|
|
3463
|
+
},
|
|
3464
|
+
conversation: {
|
|
3465
|
+
getConversations: conversation.getConversations.bind(conversation),
|
|
3466
|
+
getMessages: conversation.getMessages.bind(conversation),
|
|
3467
|
+
getConversationMessages: conversation.getConversationMessages.bind(conversation),
|
|
3468
|
+
subscribe: conversation.subscribe.bind(conversation),
|
|
3469
|
+
sendMessage: conversation.sendMessage.bind(conversation)
|
|
3470
|
+
},
|
|
2552
3471
|
__httpClient: httpClient,
|
|
2553
3472
|
__wsClient: wsClient
|
|
2554
3473
|
});
|
|
@@ -2558,100 +3477,6 @@ var SignalWire = (options) => {
|
|
|
2558
3477
|
});
|
|
2559
3478
|
};
|
|
2560
3479
|
|
|
2561
|
-
// src/chat/index.ts
|
|
2562
|
-
var chat_exports = {};
|
|
2563
|
-
__export(chat_exports, {
|
|
2564
|
-
ChatMember: () => ChatMember,
|
|
2565
|
-
ChatMessage: () => ChatMessage,
|
|
2566
|
-
Client: () => Client3
|
|
2567
|
-
});
|
|
2568
|
-
|
|
2569
|
-
// src/chat/Client.ts
|
|
2570
|
-
var INTERCEPTED_METHODS = [
|
|
2571
|
-
"subscribe",
|
|
2572
|
-
"publish",
|
|
2573
|
-
"getMessages",
|
|
2574
|
-
"getMembers",
|
|
2575
|
-
"getMemberState",
|
|
2576
|
-
"getAllowedChannels",
|
|
2577
|
-
"setMemberState"
|
|
2578
|
-
];
|
|
2579
|
-
var Client3 = function(chatOptions) {
|
|
2580
|
-
const client = createClient(chatOptions);
|
|
2581
|
-
const createInterceptor = (prop) => {
|
|
2582
|
-
return async (...params) => {
|
|
2583
|
-
await client.connect();
|
|
2584
|
-
return client.chat[prop](...params);
|
|
2585
|
-
};
|
|
2586
|
-
};
|
|
2587
|
-
const interceptors = {
|
|
2588
|
-
_session: client,
|
|
2589
|
-
disconnect: () => client.disconnect()
|
|
2590
|
-
};
|
|
2591
|
-
return new Proxy(client.chat, {
|
|
2592
|
-
get(target, prop, receiver) {
|
|
2593
|
-
if (prop in interceptors) {
|
|
2594
|
-
return interceptors[prop];
|
|
2595
|
-
}
|
|
2596
|
-
if (INTERCEPTED_METHODS.includes(prop)) {
|
|
2597
|
-
return createInterceptor(prop);
|
|
2598
|
-
}
|
|
2599
|
-
return Reflect.get(target, prop, receiver);
|
|
2600
|
-
}
|
|
2601
|
-
});
|
|
2602
|
-
};
|
|
2603
|
-
|
|
2604
|
-
// src/chat/index.ts
|
|
2605
|
-
import { ChatMember, ChatMessage } from "@signalwire/core";
|
|
2606
|
-
|
|
2607
|
-
// src/pubSub/index.ts
|
|
2608
|
-
var pubSub_exports = {};
|
|
2609
|
-
__export(pubSub_exports, {
|
|
2610
|
-
Client: () => Client4,
|
|
2611
|
-
PubSubMessage: () => PubSubMessage
|
|
2612
|
-
});
|
|
2613
|
-
import { PubSub } from "@signalwire/core";
|
|
2614
|
-
|
|
2615
|
-
// src/utils/interfaces.ts
|
|
2616
|
-
import { INTERNAL_MEMBER_UPDATABLE_PROPS } from "@signalwire/core";
|
|
2617
|
-
var INTERNAL_MEMBER_UPDATED_EVENTS = Object.keys(INTERNAL_MEMBER_UPDATABLE_PROPS).map((key) => {
|
|
2618
|
-
return `member.updated.${key}`;
|
|
2619
|
-
});
|
|
2620
|
-
|
|
2621
|
-
// src/pubSub/Client.ts
|
|
2622
|
-
var INTERCEPTED_METHODS2 = [
|
|
2623
|
-
"getAllowedChannels",
|
|
2624
|
-
"subscribe",
|
|
2625
|
-
"publish"
|
|
2626
|
-
];
|
|
2627
|
-
var Client4 = function(pubSubOptions) {
|
|
2628
|
-
const client = createClient(pubSubOptions);
|
|
2629
|
-
const createInterceptor = (prop) => {
|
|
2630
|
-
return async (...params) => {
|
|
2631
|
-
await client.connect();
|
|
2632
|
-
return client.pubSub[prop](...params);
|
|
2633
|
-
};
|
|
2634
|
-
};
|
|
2635
|
-
const interceptors = {
|
|
2636
|
-
_session: client,
|
|
2637
|
-
disconnect: () => client.disconnect()
|
|
2638
|
-
};
|
|
2639
|
-
return new Proxy(client.pubSub, {
|
|
2640
|
-
get(target, prop, receiver) {
|
|
2641
|
-
if (prop in interceptors) {
|
|
2642
|
-
return interceptors[prop];
|
|
2643
|
-
}
|
|
2644
|
-
if (INTERCEPTED_METHODS2.includes(prop)) {
|
|
2645
|
-
return createInterceptor(prop);
|
|
2646
|
-
}
|
|
2647
|
-
return Reflect.get(target, prop, receiver);
|
|
2648
|
-
}
|
|
2649
|
-
});
|
|
2650
|
-
};
|
|
2651
|
-
|
|
2652
|
-
// src/pubSub/index.ts
|
|
2653
|
-
var PubSubMessage = PubSub.PubSubMessage;
|
|
2654
|
-
|
|
2655
3480
|
// src/webrtc.ts
|
|
2656
3481
|
var webrtc_exports = {};
|
|
2657
3482
|
__export(webrtc_exports, {
|