@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.js
CHANGED
|
@@ -87,127 +87,26 @@ __export(src_exports, {
|
|
|
87
87
|
});
|
|
88
88
|
module.exports = __toCommonJS(src_exports);
|
|
89
89
|
|
|
90
|
-
// src/
|
|
91
|
-
var
|
|
92
|
-
__export(
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
WSClient: () => WSClient
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
// src/fabric/createHttpClient.ts
|
|
100
|
-
var import_core = require("@signalwire/core");
|
|
101
|
-
function http(input, init) {
|
|
102
|
-
return __async(this, null, function* () {
|
|
103
|
-
const response = yield fetch(input, init);
|
|
104
|
-
if (!response.ok) {
|
|
105
|
-
if (response.status === 401) {
|
|
106
|
-
throw new import_core.AuthError(response.status, "Unauthorized");
|
|
107
|
-
}
|
|
108
|
-
let errorResponse;
|
|
109
|
-
try {
|
|
110
|
-
errorResponse = yield response.json();
|
|
111
|
-
} catch (e) {
|
|
112
|
-
}
|
|
113
|
-
const errorMessage = (errorResponse == null ? void 0 : errorResponse.errors) ? JSON.stringify(errorResponse.errors) : "Not Found";
|
|
114
|
-
throw new import_core.HttpError(response.status, errorMessage, errorResponse);
|
|
115
|
-
}
|
|
116
|
-
try {
|
|
117
|
-
response.parsedBody = yield response.json();
|
|
118
|
-
} catch (e) {
|
|
119
|
-
}
|
|
120
|
-
return response;
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
var createHttpClient = (_a, fetcher = http) => {
|
|
124
|
-
var _b = _a, { baseUrl, timeout = 3e4 } = _b, globalOptions = __objRest(_b, ["baseUrl", "timeout"]);
|
|
125
|
-
const apiClient = (path, options) => __async(void 0, null, function* () {
|
|
126
|
-
const headers = __spreadValues(__spreadValues(__spreadValues({}, (options == null ? void 0 : options.body) ? { "Content-Type": "application/json" } : {}), globalOptions.headers), options == null ? void 0 : options.headers);
|
|
127
|
-
const reqInit = getRequestInit(__spreadProps(__spreadValues(__spreadValues({}, globalOptions), options), {
|
|
128
|
-
headers
|
|
129
|
-
}));
|
|
130
|
-
let timerId;
|
|
131
|
-
if (timeout) {
|
|
132
|
-
const controller = new AbortController();
|
|
133
|
-
const signal = controller.signal;
|
|
134
|
-
reqInit.signal = signal;
|
|
135
|
-
timerId = setTimeout(() => {
|
|
136
|
-
controller.abort();
|
|
137
|
-
}, timeout);
|
|
138
|
-
}
|
|
139
|
-
try {
|
|
140
|
-
const response = yield fetcher(getUrl({
|
|
141
|
-
path,
|
|
142
|
-
baseUrl,
|
|
143
|
-
searchParams: options == null ? void 0 : options.searchParams
|
|
144
|
-
}), reqInit);
|
|
145
|
-
return { body: response.parsedBody };
|
|
146
|
-
} catch (e) {
|
|
147
|
-
throw e;
|
|
148
|
-
} finally {
|
|
149
|
-
timerId && clearTimeout(timerId);
|
|
150
|
-
}
|
|
151
|
-
});
|
|
152
|
-
return apiClient;
|
|
153
|
-
};
|
|
154
|
-
var getBody = (body) => {
|
|
155
|
-
return typeof body === "string" ? body : JSON.stringify(body);
|
|
156
|
-
};
|
|
157
|
-
var getRequestInit = (options) => {
|
|
158
|
-
return Object.entries(options).reduce((reducer, [key, value]) => {
|
|
159
|
-
if (key === "body") {
|
|
160
|
-
return __spreadProps(__spreadValues({}, reducer), {
|
|
161
|
-
body: getBody(value)
|
|
162
|
-
});
|
|
163
|
-
} else if (value != void 0) {
|
|
164
|
-
return __spreadProps(__spreadValues({}, reducer), {
|
|
165
|
-
[key]: value
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
return reducer;
|
|
169
|
-
}, {});
|
|
170
|
-
};
|
|
171
|
-
var getUrl = ({
|
|
172
|
-
path,
|
|
173
|
-
baseUrl,
|
|
174
|
-
searchParams
|
|
175
|
-
}) => {
|
|
176
|
-
const url = new URL(path, baseUrl);
|
|
177
|
-
if (searchParams) {
|
|
178
|
-
Object.entries(searchParams).forEach(([key, value]) => {
|
|
179
|
-
if (value != void 0) {
|
|
180
|
-
url.searchParams.append(key, value);
|
|
181
|
-
}
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
return url.toString();
|
|
185
|
-
};
|
|
186
|
-
|
|
187
|
-
// src/video.ts
|
|
188
|
-
var video_exports = {};
|
|
189
|
-
__export(video_exports, {
|
|
190
|
-
RoomSession: () => RoomSession,
|
|
191
|
-
createClient: () => createClient,
|
|
192
|
-
createRoomObject: () => createRoomObject,
|
|
193
|
-
joinRoom: () => joinRoom
|
|
90
|
+
// src/chat/index.ts
|
|
91
|
+
var chat_exports = {};
|
|
92
|
+
__export(chat_exports, {
|
|
93
|
+
ChatMember: () => import_core36.ChatMember,
|
|
94
|
+
ChatMessage: () => import_core36.ChatMessage,
|
|
95
|
+
Client: () => Client2
|
|
194
96
|
});
|
|
195
97
|
|
|
196
|
-
// src/createRoomObject.ts
|
|
197
|
-
var import_core23 = require("@signalwire/core");
|
|
198
|
-
|
|
199
98
|
// src/createClient.ts
|
|
200
|
-
var
|
|
99
|
+
var import_core35 = require("@signalwire/core");
|
|
201
100
|
|
|
202
101
|
// src/Client.ts
|
|
203
|
-
var
|
|
102
|
+
var import_core34 = require("@signalwire/core");
|
|
204
103
|
|
|
205
104
|
// src/features/mediaElements/mediaElementsSagas.ts
|
|
206
|
-
var
|
|
105
|
+
var import_core3 = require("@signalwire/core");
|
|
207
106
|
var import_webrtc = require("@signalwire/webrtc");
|
|
208
107
|
|
|
209
108
|
// src/utils/videoElement.ts
|
|
210
|
-
var
|
|
109
|
+
var import_core = require("@signalwire/core");
|
|
211
110
|
var addSDKPrefix = (input) => {
|
|
212
111
|
return `sw-sdk-${input}`;
|
|
213
112
|
};
|
|
@@ -218,7 +117,7 @@ var buildVideo = () => {
|
|
|
218
117
|
video.playsInline = true;
|
|
219
118
|
video.addEventListener("pause", () => {
|
|
220
119
|
video.play().catch((error) => {
|
|
221
|
-
(0,
|
|
120
|
+
(0, import_core.getLogger)().error("Video Element Paused", video, error);
|
|
222
121
|
});
|
|
223
122
|
});
|
|
224
123
|
return video;
|
|
@@ -260,22 +159,22 @@ var _buildLayer = ({ location }) => {
|
|
|
260
159
|
return layer;
|
|
261
160
|
};
|
|
262
161
|
var makeLayoutChangedHandler = ({ localOverlay, rootElement }) => (_0) => __async(void 0, [_0], function* ({ layout, myMemberId, localStream }) {
|
|
263
|
-
(0,
|
|
162
|
+
(0, import_core.getLogger)().debug("Process layout.changed");
|
|
264
163
|
try {
|
|
265
164
|
const { layers = [] } = layout;
|
|
266
165
|
const location = layers.find(({ member_id }) => member_id === myMemberId);
|
|
267
166
|
let myLayer = localOverlay.domElement;
|
|
268
167
|
localOverlay.status = location ? "visible" : "hidden";
|
|
269
168
|
if (!location) {
|
|
270
|
-
(0,
|
|
169
|
+
(0, import_core.getLogger)().debug("Location not found");
|
|
271
170
|
if (myLayer) {
|
|
272
|
-
(0,
|
|
171
|
+
(0, import_core.getLogger)().debug("Current layer not visible");
|
|
273
172
|
localOverlay.hide();
|
|
274
173
|
}
|
|
275
174
|
return;
|
|
276
175
|
}
|
|
277
176
|
if (!myLayer) {
|
|
278
|
-
(0,
|
|
177
|
+
(0, import_core.getLogger)().debug("Build myLayer");
|
|
279
178
|
myLayer = _buildLayer({ location });
|
|
280
179
|
myLayer.id = localOverlay.id;
|
|
281
180
|
const localVideo = buildVideo();
|
|
@@ -289,17 +188,17 @@ var makeLayoutChangedHandler = ({ localOverlay, rootElement }) => (_0) => __asyn
|
|
|
289
188
|
const mcuLayers = rootElement.querySelector(".mcuLayers");
|
|
290
189
|
const exists = mcuLayers == null ? void 0 : mcuLayers.querySelector(`#${myLayer.id}`);
|
|
291
190
|
if (mcuLayers && !exists) {
|
|
292
|
-
(0,
|
|
191
|
+
(0, import_core.getLogger)().debug("Build myLayer append it");
|
|
293
192
|
mcuLayers.appendChild(myLayer);
|
|
294
193
|
localOverlay.domElement = myLayer;
|
|
295
194
|
localOverlay.setLocalOverlayMirror();
|
|
296
195
|
return;
|
|
297
196
|
}
|
|
298
|
-
(0,
|
|
197
|
+
(0, import_core.getLogger)().debug("Build myLayer >> wait next");
|
|
299
198
|
return;
|
|
300
199
|
}
|
|
301
200
|
const { top, left, width, height } = _getLocationStyles(location);
|
|
302
|
-
(0,
|
|
201
|
+
(0, import_core.getLogger)().debug("Update myLayer:", top, left, width, height);
|
|
303
202
|
const hasVideo = localStream.getVideoTracks().filter((t) => t.enabled && t.readyState === "live").length > 0;
|
|
304
203
|
if (hasVideo) {
|
|
305
204
|
localOverlay.setLocalOverlayMediaStream(localStream);
|
|
@@ -310,7 +209,7 @@ var makeLayoutChangedHandler = ({ localOverlay, rootElement }) => (_0) => __asyn
|
|
|
310
209
|
myLayer.style.width = width;
|
|
311
210
|
myLayer.style.height = height;
|
|
312
211
|
} catch (error) {
|
|
313
|
-
(0,
|
|
212
|
+
(0, import_core.getLogger)().error("Layout Changed Error", error);
|
|
314
213
|
}
|
|
315
214
|
});
|
|
316
215
|
var cleanupElement = (rootElement) => {
|
|
@@ -328,46 +227,6 @@ var setVideoMediaTrack = ({
|
|
|
328
227
|
element.remove();
|
|
329
228
|
});
|
|
330
229
|
};
|
|
331
|
-
var createRootElementResizeObserver = ({
|
|
332
|
-
video,
|
|
333
|
-
rootElement,
|
|
334
|
-
paddingWrapper
|
|
335
|
-
}) => {
|
|
336
|
-
const computePaddingWrapperWidth = (width, height) => {
|
|
337
|
-
const nativeVideoRatio = video.videoWidth / video.videoHeight;
|
|
338
|
-
const rootElementRatio = width / height;
|
|
339
|
-
if (nativeVideoRatio > rootElementRatio) {
|
|
340
|
-
return "100%";
|
|
341
|
-
} else {
|
|
342
|
-
return `${height * nativeVideoRatio}px`;
|
|
343
|
-
}
|
|
344
|
-
};
|
|
345
|
-
const maxPaddingBottom = video.videoHeight / video.videoWidth * 100;
|
|
346
|
-
const update = (0, import_core2.debounce)(({ width, height }) => {
|
|
347
|
-
if (paddingWrapper) {
|
|
348
|
-
const pb = height / width * 100;
|
|
349
|
-
paddingWrapper.style.paddingBottom = `${pb > maxPaddingBottom ? maxPaddingBottom : pb}%`;
|
|
350
|
-
paddingWrapper.style.width = computePaddingWrapperWidth(width, height);
|
|
351
|
-
}
|
|
352
|
-
}, 100);
|
|
353
|
-
const observer = new ResizeObserver((entries) => {
|
|
354
|
-
entries.forEach((entry) => {
|
|
355
|
-
if (entry.contentBoxSize) {
|
|
356
|
-
const { inlineSize, blockSize } = Array.isArray(entry.contentBoxSize) ? entry.contentBoxSize[0] : entry.contentBoxSize;
|
|
357
|
-
update({ width: inlineSize, height: blockSize });
|
|
358
|
-
} else if (entry.contentRect) {
|
|
359
|
-
update({
|
|
360
|
-
width: entry.contentRect.width,
|
|
361
|
-
height: entry.contentRect.height
|
|
362
|
-
});
|
|
363
|
-
}
|
|
364
|
-
});
|
|
365
|
-
});
|
|
366
|
-
return {
|
|
367
|
-
start: () => observer.observe(rootElement),
|
|
368
|
-
stop: () => observer.disconnect()
|
|
369
|
-
};
|
|
370
|
-
};
|
|
371
230
|
|
|
372
231
|
// src/utils/audioElement.ts
|
|
373
232
|
var setAudioMediaTrack = ({
|
|
@@ -385,8 +244,46 @@ var setAudioMediaTrack = ({
|
|
|
385
244
|
};
|
|
386
245
|
|
|
387
246
|
// src/features/actions.ts
|
|
388
|
-
var
|
|
389
|
-
var audioSetSpeakerAction =
|
|
247
|
+
var import_core2 = require("@signalwire/core");
|
|
248
|
+
var audioSetSpeakerAction = import_core2.actions.createAction("swJs/audioSetSpeakerAction");
|
|
249
|
+
|
|
250
|
+
// src/utils/aspectRatioListener.ts
|
|
251
|
+
var VIDEO_SIZING_EVENTS = ["loadedmetadata", "resize"];
|
|
252
|
+
function aspectRatioListener({ videoElement, paddingWrapper, fixInLandscapeOrientation = false, debugDivElementId = "videoDimensionsDebug", samplingInterval = 0 }) {
|
|
253
|
+
const buildHtmlContent = (event, width, height) => `Video dimensions on <strong>${event} event</strong>:</strong> ${width}x${height}px - fixInLandscapeOrientation: ${fixInLandscapeOrientation}`;
|
|
254
|
+
const appendDebugInfo = (containerElement, event) => {
|
|
255
|
+
const pEl = document.createElement("p");
|
|
256
|
+
pEl.innerHTML = buildHtmlContent(event, videoElement.videoWidth, videoElement.videoHeight);
|
|
257
|
+
containerElement.appendChild(pEl);
|
|
258
|
+
};
|
|
259
|
+
let debugElement;
|
|
260
|
+
try {
|
|
261
|
+
debugElement = document.getElementById(debugDivElementId);
|
|
262
|
+
} catch (e) {
|
|
263
|
+
}
|
|
264
|
+
VIDEO_SIZING_EVENTS.forEach((event) => videoElement.addEventListener(event, () => {
|
|
265
|
+
const paddingBottom = fixInLandscapeOrientation ? "56.25" : videoElement.videoHeight / videoElement.videoWidth * 100;
|
|
266
|
+
paddingWrapper.style.paddingBottom = `${paddingBottom}%`;
|
|
267
|
+
if (debugElement) {
|
|
268
|
+
appendDebugInfo(debugElement, event);
|
|
269
|
+
}
|
|
270
|
+
}));
|
|
271
|
+
if (samplingInterval > 0) {
|
|
272
|
+
setInterval(() => {
|
|
273
|
+
const paddingBottom = videoElement.videoHeight / videoElement.videoWidth * 100;
|
|
274
|
+
paddingWrapper.style.paddingBottom = `${paddingBottom}%`;
|
|
275
|
+
if (debugElement) {
|
|
276
|
+
let statsElement = debugElement.querySelector(".timer-values");
|
|
277
|
+
if (!statsElement) {
|
|
278
|
+
statsElement = document.createElement("div");
|
|
279
|
+
statsElement.className = "timer-values";
|
|
280
|
+
debugElement.appendChild(statsElement);
|
|
281
|
+
}
|
|
282
|
+
appendDebugInfo(debugElement, "timer");
|
|
283
|
+
}
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
}
|
|
390
287
|
|
|
391
288
|
// src/features/mediaElements/mediaElementsSagas.ts
|
|
392
289
|
var makeVideoElementSaga = ({
|
|
@@ -410,31 +307,31 @@ var makeVideoElementSaga = ({
|
|
|
410
307
|
},
|
|
411
308
|
set domElement(element) {
|
|
412
309
|
if (element) {
|
|
413
|
-
(0,
|
|
310
|
+
(0, import_core3.getLogger)().debug("Set localOverlay", element);
|
|
414
311
|
layerMap.set(this.id, element);
|
|
415
312
|
} else {
|
|
416
|
-
(0,
|
|
313
|
+
(0, import_core3.getLogger)().debug("Remove localOverlay");
|
|
417
314
|
layerMap.delete(this.id);
|
|
418
315
|
}
|
|
419
316
|
},
|
|
420
317
|
hide() {
|
|
421
318
|
if (!this.domElement) {
|
|
422
|
-
return (0,
|
|
319
|
+
return (0, import_core3.getLogger)().warn("Missing localOverlay to hide");
|
|
423
320
|
}
|
|
424
321
|
this.domElement.style.opacity = "0";
|
|
425
322
|
},
|
|
426
323
|
show() {
|
|
427
324
|
if (!this.domElement) {
|
|
428
|
-
return (0,
|
|
325
|
+
return (0, import_core3.getLogger)().warn("Missing localOverlay to show");
|
|
429
326
|
}
|
|
430
327
|
if (this.status === "hidden") {
|
|
431
|
-
return (0,
|
|
328
|
+
return (0, import_core3.getLogger)().info("localOverlay not visible");
|
|
432
329
|
}
|
|
433
330
|
this.domElement.style.opacity = "1";
|
|
434
331
|
},
|
|
435
332
|
setLocalOverlayMediaStream(stream) {
|
|
436
333
|
if (!this.domElement) {
|
|
437
|
-
return (0,
|
|
334
|
+
return (0, import_core3.getLogger)().warn("Missing localOverlay to set the local overlay stream");
|
|
438
335
|
}
|
|
439
336
|
const localVideo = this.domElement.querySelector("video");
|
|
440
337
|
if (localVideo) {
|
|
@@ -443,7 +340,7 @@ var makeVideoElementSaga = ({
|
|
|
443
340
|
},
|
|
444
341
|
setLocalOverlayMirror(mirror) {
|
|
445
342
|
if (!this.domElement || !this.domElement.firstChild) {
|
|
446
|
-
return (0,
|
|
343
|
+
return (0, import_core3.getLogger)().warn("Missing localOverlay to set the mirror");
|
|
447
344
|
}
|
|
448
345
|
const videoEl2 = this.domElement.firstChild;
|
|
449
346
|
if (mirror != null ? mirror : room.localOverlay.mirrored) {
|
|
@@ -473,11 +370,11 @@ var makeVideoElementSaga = ({
|
|
|
473
370
|
localOverlay.hide();
|
|
474
371
|
}
|
|
475
372
|
};
|
|
476
|
-
room.on(`${
|
|
373
|
+
room.on(`${import_core3.LOCAL_EVENT_PREFIX}.mirror.video`, (value) => {
|
|
477
374
|
localOverlay.setLocalOverlayMirror(value);
|
|
478
375
|
});
|
|
479
376
|
room.on("layout.changed", (params) => {
|
|
480
|
-
(0,
|
|
377
|
+
(0, import_core3.getLogger)().debug("Received layout.changed - videoTrack", hasVideoTrack);
|
|
481
378
|
if (hasVideoTrack) {
|
|
482
379
|
_processLayoutChanged(params);
|
|
483
380
|
return;
|
|
@@ -491,14 +388,14 @@ var makeVideoElementSaga = ({
|
|
|
491
388
|
try {
|
|
492
389
|
room.stopOutboundAudio();
|
|
493
390
|
} catch (error) {
|
|
494
|
-
(0,
|
|
391
|
+
(0, import_core3.getLogger)().error("Error handling audio_muted", error);
|
|
495
392
|
}
|
|
496
393
|
}
|
|
497
394
|
if (member == null ? void 0 : member.video_muted) {
|
|
498
395
|
try {
|
|
499
396
|
room.stopOutboundVideo();
|
|
500
397
|
} catch (error) {
|
|
501
|
-
(0,
|
|
398
|
+
(0, import_core3.getLogger)().error("Error handling video_muted", error);
|
|
502
399
|
}
|
|
503
400
|
}
|
|
504
401
|
if (room.localStream) {
|
|
@@ -512,7 +409,7 @@ var makeVideoElementSaga = ({
|
|
|
512
409
|
member.video_muted ? localOverlay.hide() : localOverlay.show();
|
|
513
410
|
}
|
|
514
411
|
} catch (error) {
|
|
515
|
-
(0,
|
|
412
|
+
(0, import_core3.getLogger)().error("Error handling video_muted", error);
|
|
516
413
|
}
|
|
517
414
|
});
|
|
518
415
|
let videoTask;
|
|
@@ -540,7 +437,7 @@ var makeVideoElementSaga = ({
|
|
|
540
437
|
videoTask == null ? void 0 : videoTask.cancel();
|
|
541
438
|
});
|
|
542
439
|
} catch (error) {
|
|
543
|
-
(0,
|
|
440
|
+
(0, import_core3.getLogger)().error("videoElementSaga", error);
|
|
544
441
|
}
|
|
545
442
|
};
|
|
546
443
|
};
|
|
@@ -550,7 +447,7 @@ var makeAudioElementSaga = ({ speakerId }) => {
|
|
|
550
447
|
runSaga
|
|
551
448
|
}) {
|
|
552
449
|
if (typeof Audio === "undefined") {
|
|
553
|
-
(0,
|
|
450
|
+
(0, import_core3.getLogger)().warn("`Audio` is not supported on this environment.");
|
|
554
451
|
return;
|
|
555
452
|
}
|
|
556
453
|
try {
|
|
@@ -574,7 +471,7 @@ var makeAudioElementSaga = ({ speakerId }) => {
|
|
|
574
471
|
audioTask == null ? void 0 : audioTask.cancel();
|
|
575
472
|
});
|
|
576
473
|
} catch (error) {
|
|
577
|
-
(0,
|
|
474
|
+
(0, import_core3.getLogger)().error("audioElementSaga", error);
|
|
578
475
|
}
|
|
579
476
|
};
|
|
580
477
|
};
|
|
@@ -582,14 +479,14 @@ function* audioElementActionsWatcher({
|
|
|
582
479
|
element,
|
|
583
480
|
room
|
|
584
481
|
}) {
|
|
585
|
-
const setSpeakerActionType =
|
|
482
|
+
const setSpeakerActionType = import_core3.actions.getCustomSagaActionType(room.__uuid, audioSetSpeakerAction);
|
|
586
483
|
while (true) {
|
|
587
|
-
const action = yield
|
|
484
|
+
const action = yield import_core3.sagaEffects.take([setSpeakerActionType]);
|
|
588
485
|
try {
|
|
589
486
|
switch (action.type) {
|
|
590
487
|
case setSpeakerActionType:
|
|
591
|
-
const response = yield
|
|
592
|
-
room.emit(`${
|
|
488
|
+
const response = yield import_core3.sagaEffects.call(import_webrtc.setMediaElementSinkId, element, action.payload);
|
|
489
|
+
room.emit(`${import_core3.LOCAL_EVENT_PREFIX}.speaker.updated`, action.payload);
|
|
593
490
|
room.settleCustomSagaTrigger({
|
|
594
491
|
dispatchId: action.dispatchId,
|
|
595
492
|
payload: response,
|
|
@@ -603,7 +500,7 @@ function* audioElementActionsWatcher({
|
|
|
603
500
|
payload: error,
|
|
604
501
|
kind: "reject"
|
|
605
502
|
});
|
|
606
|
-
(0,
|
|
503
|
+
(0, import_core3.getLogger)().error(error);
|
|
607
504
|
}
|
|
608
505
|
}
|
|
609
506
|
}
|
|
@@ -618,7 +515,7 @@ function* audioElementSetupWorker({
|
|
|
618
515
|
(0, import_webrtc.setMediaElementSinkId)(element, speakerId).catch(() => {
|
|
619
516
|
});
|
|
620
517
|
}
|
|
621
|
-
yield
|
|
518
|
+
yield import_core3.sagaEffects.fork(audioElementActionsWatcher, {
|
|
622
519
|
element,
|
|
623
520
|
room
|
|
624
521
|
});
|
|
@@ -638,7 +535,7 @@ function* videoElementSetupWorker({
|
|
|
638
535
|
return;
|
|
639
536
|
}
|
|
640
537
|
if (rootElement.querySelector(".mcuContent")) {
|
|
641
|
-
(0,
|
|
538
|
+
(0, import_core3.getLogger)().debug("MCU Content already there");
|
|
642
539
|
return;
|
|
643
540
|
}
|
|
644
541
|
const mcuWrapper = document.createElement("div");
|
|
@@ -650,10 +547,14 @@ function* videoElementSetupWorker({
|
|
|
650
547
|
mcuWrapper.appendChild(element);
|
|
651
548
|
const paddingWrapper = document.createElement("div");
|
|
652
549
|
paddingWrapper.classList.add("paddingWrapper");
|
|
653
|
-
paddingWrapper.style.paddingBottom = "56.25%";
|
|
654
550
|
paddingWrapper.style.position = "relative";
|
|
655
551
|
paddingWrapper.style.width = "100%";
|
|
656
552
|
paddingWrapper.appendChild(mcuWrapper);
|
|
553
|
+
aspectRatioListener({
|
|
554
|
+
videoElement: element,
|
|
555
|
+
paddingWrapper,
|
|
556
|
+
fixInLandscapeOrientation: rootElement.classList.contains("landscape-only")
|
|
557
|
+
});
|
|
657
558
|
const layersWrapper = document.createElement("div");
|
|
658
559
|
layersWrapper.classList.add("mcuLayers");
|
|
659
560
|
layersWrapper.style.display = "none";
|
|
@@ -671,31 +572,20 @@ function* videoElementSetupWorker({
|
|
|
671
572
|
rootElement.style.width = "100%";
|
|
672
573
|
rootElement.style.height = "100%";
|
|
673
574
|
rootElement.appendChild(relativeWrapper);
|
|
674
|
-
(0,
|
|
575
|
+
(0, import_core3.getLogger)().debug("MCU readyState 1 >>", element.readyState);
|
|
675
576
|
if (element.readyState === HTMLMediaElement.HAVE_NOTHING) {
|
|
676
|
-
(0,
|
|
677
|
-
yield
|
|
577
|
+
(0, import_core3.getLogger)().debug("Wait for the MCU to be ready");
|
|
578
|
+
yield import_core3.sagaEffects.call(waitForVideoReady, { element });
|
|
678
579
|
}
|
|
679
|
-
(0,
|
|
680
|
-
const rootElementResizeObserver = createRootElementResizeObserver({
|
|
681
|
-
rootElement,
|
|
682
|
-
video: element,
|
|
683
|
-
paddingWrapper
|
|
684
|
-
});
|
|
685
|
-
rootElementResizeObserver.start();
|
|
686
|
-
track.addEventListener("ended", () => {
|
|
687
|
-
if (rootElementResizeObserver) {
|
|
688
|
-
rootElementResizeObserver.stop();
|
|
689
|
-
}
|
|
690
|
-
});
|
|
580
|
+
(0, import_core3.getLogger)().debug("MCU is ready..");
|
|
691
581
|
layersWrapper.style.display = "block";
|
|
692
582
|
} catch (error) {
|
|
693
|
-
(0,
|
|
583
|
+
(0, import_core3.getLogger)().error("Handle video track error", error);
|
|
694
584
|
}
|
|
695
585
|
}
|
|
696
586
|
|
|
697
587
|
// src/BaseRoomSession.ts
|
|
698
|
-
var
|
|
588
|
+
var import_core14 = require("@signalwire/core");
|
|
699
589
|
var import_webrtc4 = require("@signalwire/webrtc");
|
|
700
590
|
|
|
701
591
|
// src/utils/constants.ts
|
|
@@ -707,7 +597,7 @@ var SCREENSHARE_AUDIO_CONSTRAINTS = {
|
|
|
707
597
|
};
|
|
708
598
|
|
|
709
599
|
// src/RoomSessionScreenShare.ts
|
|
710
|
-
var
|
|
600
|
+
var import_core4 = require("@signalwire/core");
|
|
711
601
|
var import_webrtc2 = require("@signalwire/webrtc");
|
|
712
602
|
var RoomSessionScreenShareConnection = class extends import_webrtc2.BaseConnection {
|
|
713
603
|
join() {
|
|
@@ -717,18 +607,18 @@ var RoomSessionScreenShareConnection = class extends import_webrtc2.BaseConnecti
|
|
|
717
607
|
return super.hangup();
|
|
718
608
|
}
|
|
719
609
|
};
|
|
720
|
-
var RoomSessionScreenShareAPI = (0,
|
|
721
|
-
audioMute:
|
|
722
|
-
audioUnmute:
|
|
723
|
-
videoMute:
|
|
724
|
-
videoUnmute:
|
|
725
|
-
setMicrophoneVolume:
|
|
726
|
-
setInputVolume:
|
|
727
|
-
setInputSensitivity:
|
|
610
|
+
var RoomSessionScreenShareAPI = (0, import_core4.extendComponent)(RoomSessionScreenShareConnection, {
|
|
611
|
+
audioMute: import_core4.Rooms.audioMuteMember,
|
|
612
|
+
audioUnmute: import_core4.Rooms.audioUnmuteMember,
|
|
613
|
+
videoMute: import_core4.Rooms.videoMuteMember,
|
|
614
|
+
videoUnmute: import_core4.Rooms.videoUnmuteMember,
|
|
615
|
+
setMicrophoneVolume: import_core4.Rooms.setInputVolumeMember,
|
|
616
|
+
setInputVolume: import_core4.Rooms.setInputVolumeMember,
|
|
617
|
+
setInputSensitivity: import_core4.Rooms.setInputSensitivityMember
|
|
728
618
|
});
|
|
729
619
|
|
|
730
620
|
// src/RoomSessionDevice.ts
|
|
731
|
-
var
|
|
621
|
+
var import_core5 = require("@signalwire/core");
|
|
732
622
|
var import_webrtc3 = require("@signalwire/webrtc");
|
|
733
623
|
var RoomSessionDeviceConnection = class extends import_webrtc3.BaseConnection {
|
|
734
624
|
join() {
|
|
@@ -738,25 +628,25 @@ var RoomSessionDeviceConnection = class extends import_webrtc3.BaseConnection {
|
|
|
738
628
|
return super.hangup();
|
|
739
629
|
}
|
|
740
630
|
};
|
|
741
|
-
var RoomSessionDeviceAPI = (0,
|
|
742
|
-
audioMute:
|
|
743
|
-
audioUnmute:
|
|
744
|
-
videoMute:
|
|
745
|
-
videoUnmute:
|
|
746
|
-
setInputVolume:
|
|
747
|
-
setMicrophoneVolume:
|
|
748
|
-
setInputSensitivity:
|
|
631
|
+
var RoomSessionDeviceAPI = (0, import_core5.extendComponent)(RoomSessionDeviceConnection, {
|
|
632
|
+
audioMute: import_core5.Rooms.audioMuteMember,
|
|
633
|
+
audioUnmute: import_core5.Rooms.audioUnmuteMember,
|
|
634
|
+
videoMute: import_core5.Rooms.videoMuteMember,
|
|
635
|
+
videoUnmute: import_core5.Rooms.videoUnmuteMember,
|
|
636
|
+
setInputVolume: import_core5.Rooms.setInputVolumeMember,
|
|
637
|
+
setMicrophoneVolume: import_core5.Rooms.setInputVolumeMember,
|
|
638
|
+
setInputSensitivity: import_core5.Rooms.setInputSensitivityMember
|
|
749
639
|
});
|
|
750
640
|
|
|
751
641
|
// src/video/memberListUpdatedWorker.ts
|
|
752
|
-
var
|
|
642
|
+
var import_core6 = require("@signalwire/core");
|
|
753
643
|
var noop = () => {
|
|
754
644
|
};
|
|
755
645
|
var EXTERNAL_MEMBER_LIST_UPDATED_EVENT = "memberList.updated";
|
|
756
|
-
var INTERNAL_MEMBER_LIST_UPDATED_EVENT = (0,
|
|
646
|
+
var INTERNAL_MEMBER_LIST_UPDATED_EVENT = (0, import_core6.toInternalEventName)({
|
|
757
647
|
event: EXTERNAL_MEMBER_LIST_UPDATED_EVENT
|
|
758
648
|
});
|
|
759
|
-
var SYNTHETIC_MEMBER_LIST_UPDATED_EVENT = (0,
|
|
649
|
+
var SYNTHETIC_MEMBER_LIST_UPDATED_EVENT = (0, import_core6.toSyntheticEvent)(INTERNAL_MEMBER_LIST_UPDATED_EVENT);
|
|
760
650
|
var MEMBER_LIST_EVENTS = [
|
|
761
651
|
"video.room.joined",
|
|
762
652
|
"video.member.joined",
|
|
@@ -767,7 +657,7 @@ var isMemberListEvent = (event) => {
|
|
|
767
657
|
return MEMBER_LIST_EVENTS.includes(event);
|
|
768
658
|
};
|
|
769
659
|
var getMemberListEventsToSubscribe = (subscriptions) => {
|
|
770
|
-
return (0,
|
|
660
|
+
return (0, import_core6.validateEventsToSubscribe)(MEMBER_LIST_EVENTS).filter((event) => {
|
|
771
661
|
return !subscriptions.includes(event);
|
|
772
662
|
});
|
|
773
663
|
};
|
|
@@ -829,10 +719,10 @@ function* membersListUpdatedWatcher({
|
|
|
829
719
|
instance.emit(SYNTHETIC_MEMBER_LIST_UPDATED_EVENT, memberListPayload);
|
|
830
720
|
}
|
|
831
721
|
while (true) {
|
|
832
|
-
const pubSubAction = yield
|
|
722
|
+
const pubSubAction = yield import_core6.sagaEffects.take(swEventChannel, ({ type }) => {
|
|
833
723
|
return isMemberListEvent(type);
|
|
834
724
|
});
|
|
835
|
-
yield
|
|
725
|
+
yield import_core6.sagaEffects.fork(worker, pubSubAction);
|
|
836
726
|
}
|
|
837
727
|
}
|
|
838
728
|
var memberListUpdatedWorker = function* membersChangedWorker({
|
|
@@ -844,7 +734,7 @@ var memberListUpdatedWorker = function* membersChangedWorker({
|
|
|
844
734
|
return;
|
|
845
735
|
}
|
|
846
736
|
const { cleanup } = initMemberListSubscriptions(instance, subscriptions);
|
|
847
|
-
yield
|
|
737
|
+
yield import_core6.sagaEffects.fork(membersListUpdatedWatcher, {
|
|
848
738
|
swEventChannel,
|
|
849
739
|
instance
|
|
850
740
|
});
|
|
@@ -854,16 +744,16 @@ var memberListUpdatedWorker = function* membersChangedWorker({
|
|
|
854
744
|
};
|
|
855
745
|
|
|
856
746
|
// src/video/childMemberJoinedWorker.ts
|
|
857
|
-
var
|
|
747
|
+
var import_core7 = require("@signalwire/core");
|
|
858
748
|
var childMemberJoinedWorker = function* (options) {
|
|
859
|
-
(0,
|
|
749
|
+
(0, import_core7.getLogger)().trace("childMemberJoinedWorker started");
|
|
860
750
|
const { channels, instance, initialState, onDone, onFail } = options;
|
|
861
751
|
const { swEventChannel } = channels;
|
|
862
752
|
const { parentId } = initialState;
|
|
863
753
|
if (!parentId) {
|
|
864
754
|
throw new Error("Missing parentId for childMemberJoinedWorker");
|
|
865
755
|
}
|
|
866
|
-
const action = yield
|
|
756
|
+
const action = yield import_core7.sagaEffects.take(swEventChannel, (action2) => {
|
|
867
757
|
if (action2.type === "video.member.joined") {
|
|
868
758
|
return action2.payload.member.parent_id === parentId;
|
|
869
759
|
}
|
|
@@ -871,12 +761,12 @@ var childMemberJoinedWorker = function* (options) {
|
|
|
871
761
|
});
|
|
872
762
|
const { member } = action.payload;
|
|
873
763
|
if (member == null ? void 0 : member.parent_id) {
|
|
874
|
-
const byId = yield
|
|
764
|
+
const byId = yield import_core7.sagaEffects.select(import_core7.componentSelectors.getComponentsById);
|
|
875
765
|
const parent = Object.values(byId).find((row) => {
|
|
876
766
|
return "memberId" in row && row.memberId === member.parent_id;
|
|
877
767
|
});
|
|
878
768
|
if (parent) {
|
|
879
|
-
yield
|
|
769
|
+
yield import_core7.sagaEffects.put(import_core7.componentActions.upsert({
|
|
880
770
|
id: instance.callId,
|
|
881
771
|
roomId: action.payload.room_id,
|
|
882
772
|
roomSessionId: action.payload.room_session_id,
|
|
@@ -887,16 +777,16 @@ var childMemberJoinedWorker = function* (options) {
|
|
|
887
777
|
onFail == null ? void 0 : onFail({ error: new Error("Unknown parent_id") });
|
|
888
778
|
}
|
|
889
779
|
}
|
|
890
|
-
(0,
|
|
780
|
+
(0, import_core7.getLogger)().trace("childMemberJoinedWorker ended");
|
|
891
781
|
};
|
|
892
782
|
|
|
893
783
|
// src/video/videoWorker.ts
|
|
894
|
-
var
|
|
784
|
+
var import_core11 = require("@signalwire/core");
|
|
895
785
|
|
|
896
786
|
// src/video/videoStreamWorker.ts
|
|
897
|
-
var
|
|
787
|
+
var import_core8 = require("@signalwire/core");
|
|
898
788
|
var videoStreamWorker = function* (options) {
|
|
899
|
-
(0,
|
|
789
|
+
(0, import_core8.getLogger)().trace("videoStreamWorker started");
|
|
900
790
|
const {
|
|
901
791
|
instance: roomSession,
|
|
902
792
|
action: { type, payload },
|
|
@@ -904,7 +794,7 @@ var videoStreamWorker = function* (options) {
|
|
|
904
794
|
} = options;
|
|
905
795
|
let streamInstance = get(payload.stream.id);
|
|
906
796
|
if (!streamInstance) {
|
|
907
|
-
streamInstance =
|
|
797
|
+
streamInstance = import_core8.Rooms.createRoomSessionStreamObject({
|
|
908
798
|
store: roomSession.store,
|
|
909
799
|
payload
|
|
910
800
|
});
|
|
@@ -921,16 +811,16 @@ var videoStreamWorker = function* (options) {
|
|
|
921
811
|
remove(payload.stream.id);
|
|
922
812
|
break;
|
|
923
813
|
default:
|
|
924
|
-
(0,
|
|
814
|
+
(0, import_core8.getLogger)().warn(`Unknown video.stream event: "${type}"`);
|
|
925
815
|
break;
|
|
926
816
|
}
|
|
927
|
-
(0,
|
|
817
|
+
(0, import_core8.getLogger)().trace("videoStreamWorker ended");
|
|
928
818
|
};
|
|
929
819
|
|
|
930
820
|
// src/video/videoRecordWorker.ts
|
|
931
|
-
var
|
|
821
|
+
var import_core9 = require("@signalwire/core");
|
|
932
822
|
var videoRecordWorker = function* (options) {
|
|
933
|
-
(0,
|
|
823
|
+
(0, import_core9.getLogger)().trace("videoRecordWorker started");
|
|
934
824
|
const {
|
|
935
825
|
instance: roomSession,
|
|
936
826
|
action: { type, payload },
|
|
@@ -938,7 +828,7 @@ var videoRecordWorker = function* (options) {
|
|
|
938
828
|
} = options;
|
|
939
829
|
let recordingInstance = get(payload.recording.id);
|
|
940
830
|
if (!recordingInstance) {
|
|
941
|
-
recordingInstance =
|
|
831
|
+
recordingInstance = import_core9.Rooms.createRoomSessionRecordingObject({
|
|
942
832
|
store: roomSession.store,
|
|
943
833
|
payload
|
|
944
834
|
});
|
|
@@ -946,7 +836,7 @@ var videoRecordWorker = function* (options) {
|
|
|
946
836
|
recordingInstance.setPayload(payload);
|
|
947
837
|
}
|
|
948
838
|
set(payload.recording.id, recordingInstance);
|
|
949
|
-
const event = (0,
|
|
839
|
+
const event = (0, import_core9.stripNamespacePrefix)(type);
|
|
950
840
|
switch (type) {
|
|
951
841
|
case "video.recording.started":
|
|
952
842
|
case "video.recording.updated": {
|
|
@@ -958,16 +848,16 @@ var videoRecordWorker = function* (options) {
|
|
|
958
848
|
remove(payload.recording.id);
|
|
959
849
|
break;
|
|
960
850
|
default:
|
|
961
|
-
(0,
|
|
851
|
+
(0, import_core9.getLogger)().warn(`Unknown video.stream event: "${type}"`);
|
|
962
852
|
break;
|
|
963
853
|
}
|
|
964
|
-
(0,
|
|
854
|
+
(0, import_core9.getLogger)().trace("videoRecordWorker ended");
|
|
965
855
|
};
|
|
966
856
|
|
|
967
857
|
// src/video/videoPlaybackWorker.ts
|
|
968
|
-
var
|
|
858
|
+
var import_core10 = require("@signalwire/core");
|
|
969
859
|
var videoPlaybackWorker = function* (options) {
|
|
970
|
-
(0,
|
|
860
|
+
(0, import_core10.getLogger)().trace("videoPlaybackWorker started");
|
|
971
861
|
const {
|
|
972
862
|
instance: roomSession,
|
|
973
863
|
action: { type, payload },
|
|
@@ -975,7 +865,7 @@ var videoPlaybackWorker = function* (options) {
|
|
|
975
865
|
} = options;
|
|
976
866
|
let playbackInstance = get(payload.playback.id);
|
|
977
867
|
if (!playbackInstance) {
|
|
978
|
-
playbackInstance =
|
|
868
|
+
playbackInstance = import_core10.Rooms.createRoomSessionPlaybackObject({
|
|
979
869
|
store: roomSession.store,
|
|
980
870
|
payload
|
|
981
871
|
});
|
|
@@ -983,7 +873,7 @@ var videoPlaybackWorker = function* (options) {
|
|
|
983
873
|
playbackInstance.setPayload(payload);
|
|
984
874
|
}
|
|
985
875
|
set(payload.playback.id, playbackInstance);
|
|
986
|
-
const event = (0,
|
|
876
|
+
const event = (0, import_core10.stripNamespacePrefix)(type);
|
|
987
877
|
switch (type) {
|
|
988
878
|
case "video.playback.started":
|
|
989
879
|
case "video.playback.updated": {
|
|
@@ -995,21 +885,22 @@ var videoPlaybackWorker = function* (options) {
|
|
|
995
885
|
remove(payload.playback.id);
|
|
996
886
|
break;
|
|
997
887
|
default:
|
|
998
|
-
(0,
|
|
888
|
+
(0, import_core10.getLogger)().warn(`Unknown video.stream event: "${type}"`);
|
|
999
889
|
break;
|
|
1000
890
|
}
|
|
1001
|
-
(0,
|
|
891
|
+
(0, import_core10.getLogger)().trace("videoPlaybackWorker ended");
|
|
1002
892
|
};
|
|
1003
893
|
|
|
1004
894
|
// src/video/videoWorker.ts
|
|
1005
895
|
var videoWorker = function* (options) {
|
|
896
|
+
(0, import_core11.getLogger)().trace("videoWorker started");
|
|
1006
897
|
const { channels, instance: roomSession } = options;
|
|
1007
898
|
const { swEventChannel } = channels;
|
|
1008
899
|
function* worker(action) {
|
|
1009
900
|
const { type, payload } = action;
|
|
1010
901
|
switch (type) {
|
|
1011
902
|
case "video.room.subscribed":
|
|
1012
|
-
yield
|
|
903
|
+
yield import_core11.sagaEffects.spawn(import_core11.MemberPosition.memberPositionWorker, __spreadProps(__spreadValues({}, options), {
|
|
1013
904
|
instance: roomSession,
|
|
1014
905
|
initialState: payload
|
|
1015
906
|
}));
|
|
@@ -1017,20 +908,20 @@ var videoWorker = function* (options) {
|
|
|
1017
908
|
case "video.playback.started":
|
|
1018
909
|
case "video.playback.updated":
|
|
1019
910
|
case "video.playback.ended":
|
|
1020
|
-
yield
|
|
911
|
+
yield import_core11.sagaEffects.fork(videoPlaybackWorker, __spreadValues({
|
|
1021
912
|
action
|
|
1022
913
|
}, options));
|
|
1023
914
|
return;
|
|
1024
915
|
case "video.recording.started":
|
|
1025
916
|
case "video.recording.updated":
|
|
1026
917
|
case "video.recording.ended":
|
|
1027
|
-
yield
|
|
918
|
+
yield import_core11.sagaEffects.fork(videoRecordWorker, __spreadValues({
|
|
1028
919
|
action
|
|
1029
920
|
}, options));
|
|
1030
921
|
return;
|
|
1031
922
|
case "video.stream.ended":
|
|
1032
923
|
case "video.stream.started":
|
|
1033
|
-
yield
|
|
924
|
+
yield import_core11.sagaEffects.fork(videoStreamWorker, __spreadValues({
|
|
1034
925
|
action
|
|
1035
926
|
}, options));
|
|
1036
927
|
return;
|
|
@@ -1051,16 +942,82 @@ var videoWorker = function* (options) {
|
|
|
1051
942
|
default:
|
|
1052
943
|
break;
|
|
1053
944
|
}
|
|
1054
|
-
|
|
945
|
+
const event = (0, import_core11.stripNamespacePrefix)(type, "video");
|
|
946
|
+
roomSession.emit(event, payload);
|
|
1055
947
|
}
|
|
1056
|
-
const
|
|
948
|
+
const isVideoOrCallEvent = (action) => {
|
|
949
|
+
return action.type.startsWith("video.") || action.type.startsWith("call.");
|
|
950
|
+
};
|
|
1057
951
|
while (true) {
|
|
1058
|
-
const action = yield
|
|
1059
|
-
yield
|
|
952
|
+
const action = yield import_core11.sagaEffects.take(swEventChannel, isVideoOrCallEvent);
|
|
953
|
+
yield import_core11.sagaEffects.fork(worker, action);
|
|
954
|
+
}
|
|
955
|
+
(0, import_core11.getLogger)().trace("videoWorker ended");
|
|
956
|
+
};
|
|
957
|
+
|
|
958
|
+
// src/video/videoMemberWorker.ts
|
|
959
|
+
var import_core12 = require("@signalwire/core");
|
|
960
|
+
var videoMemberWorker = function* (options) {
|
|
961
|
+
var _a, _b;
|
|
962
|
+
(0, import_core12.getLogger)().trace("videoMemberWorker started");
|
|
963
|
+
const {
|
|
964
|
+
instance: roomSession,
|
|
965
|
+
callSegments,
|
|
966
|
+
action: { type, payload },
|
|
967
|
+
instanceMap: { get, set, remove }
|
|
968
|
+
} = options;
|
|
969
|
+
const memberId = ((_a = payload.member) == null ? void 0 : _a.id) || ((_b = payload.member) == null ? void 0 : _b.member_id);
|
|
970
|
+
let memberInstance = get(memberId);
|
|
971
|
+
if (!memberInstance) {
|
|
972
|
+
memberInstance = import_core12.Rooms.createRoomSessionMemberObject({
|
|
973
|
+
store: roomSession.store,
|
|
974
|
+
payload
|
|
975
|
+
});
|
|
976
|
+
} else {
|
|
977
|
+
memberInstance.setPayload(payload);
|
|
978
|
+
}
|
|
979
|
+
set(memberId, memberInstance);
|
|
980
|
+
let newPayload = __spreadValues({}, payload);
|
|
981
|
+
const currentCallSegment = callSegments[callSegments.length - 1];
|
|
982
|
+
if (payload.member.member_id === currentCallSegment.memberId) {
|
|
983
|
+
newPayload = __spreadProps(__spreadValues({}, payload), {
|
|
984
|
+
member: __spreadProps(__spreadValues({}, payload.member), {
|
|
985
|
+
id: roomSession.callSegments[0].memberId,
|
|
986
|
+
member_id: roomSession.callSegments[0].memberId
|
|
987
|
+
})
|
|
988
|
+
});
|
|
989
|
+
}
|
|
990
|
+
const event = (0, import_core12.stripNamespacePrefix)(type);
|
|
991
|
+
if (type.startsWith("video.member.updated.")) {
|
|
992
|
+
roomSession.emit(event, newPayload);
|
|
993
|
+
}
|
|
994
|
+
switch (type) {
|
|
995
|
+
case "video.member.joined":
|
|
996
|
+
case "video.member.updated":
|
|
997
|
+
roomSession.emit(event, newPayload);
|
|
998
|
+
break;
|
|
999
|
+
case "video.member.left":
|
|
1000
|
+
roomSession.emit(event, newPayload);
|
|
1001
|
+
remove(memberId);
|
|
1002
|
+
break;
|
|
1003
|
+
case "video.member.talking":
|
|
1004
|
+
roomSession.emit(event, newPayload);
|
|
1005
|
+
if ("talking" in payload.member) {
|
|
1006
|
+
const suffix = payload.member.talking ? "started" : "ended";
|
|
1007
|
+
roomSession.emit(`${event}.${suffix}`, newPayload);
|
|
1008
|
+
const deprecatedSuffix = payload.member.talking ? "start" : "stop";
|
|
1009
|
+
roomSession.emit(`${event}.${deprecatedSuffix}`, newPayload);
|
|
1010
|
+
}
|
|
1011
|
+
break;
|
|
1012
|
+
default:
|
|
1013
|
+
break;
|
|
1060
1014
|
}
|
|
1061
|
-
(0, import_core12.getLogger)().trace("
|
|
1015
|
+
(0, import_core12.getLogger)().trace("videoMemberWorker ended");
|
|
1062
1016
|
};
|
|
1063
1017
|
|
|
1018
|
+
// src/video/videoRoomWorker.ts
|
|
1019
|
+
var import_core13 = require("@signalwire/core");
|
|
1020
|
+
|
|
1064
1021
|
// src/BaseRoomSession.ts
|
|
1065
1022
|
var RoomSessionConnection = class extends import_webrtc4.BaseConnection {
|
|
1066
1023
|
constructor(options) {
|
|
@@ -1070,6 +1027,9 @@ var RoomSessionConnection = class extends import_webrtc4.BaseConnection {
|
|
|
1070
1027
|
__publicField(this, "_mirrored");
|
|
1071
1028
|
__publicField(this, "_audioEl");
|
|
1072
1029
|
this._mirrored = options.mirrorLocalVideoOverlay;
|
|
1030
|
+
this.initWorker();
|
|
1031
|
+
}
|
|
1032
|
+
initWorker() {
|
|
1073
1033
|
this.runWorker("videoWorker", {
|
|
1074
1034
|
worker: videoWorker
|
|
1075
1035
|
});
|
|
@@ -1131,7 +1091,7 @@ var RoomSessionConnection = class extends import_webrtc4.BaseConnection {
|
|
|
1131
1091
|
layout,
|
|
1132
1092
|
positions
|
|
1133
1093
|
});
|
|
1134
|
-
const screenShare = (0,
|
|
1094
|
+
const screenShare = (0, import_core14.connect)({
|
|
1135
1095
|
store: this.store,
|
|
1136
1096
|
Component: RoomSessionScreenShareAPI
|
|
1137
1097
|
})(options);
|
|
@@ -1201,7 +1161,7 @@ var RoomSessionConnection = class extends import_webrtc4.BaseConnection {
|
|
|
1201
1161
|
memberId: this.memberId
|
|
1202
1162
|
})
|
|
1203
1163
|
});
|
|
1204
|
-
const roomDevice = (0,
|
|
1164
|
+
const roomDevice = (0, import_core14.connect)({
|
|
1205
1165
|
store: this.store,
|
|
1206
1166
|
Component: RoomSessionDeviceAPI
|
|
1207
1167
|
})(options);
|
|
@@ -1238,7 +1198,7 @@ var RoomSessionConnection = class extends import_webrtc4.BaseConnection {
|
|
|
1238
1198
|
}
|
|
1239
1199
|
updateSpeaker({ deviceId }) {
|
|
1240
1200
|
const prevId = this._audioEl.sinkId;
|
|
1241
|
-
this.once(`${
|
|
1201
|
+
this.once(`${import_core14.LOCAL_EVENT_PREFIX}.speaker.updated`, (newId) => __async(this, null, function* () {
|
|
1242
1202
|
const prevSpeaker = yield (0, import_webrtc4.getSpeakerById)(prevId);
|
|
1243
1203
|
const newSpeaker = yield (0, import_webrtc4.getSpeakerById)(newId);
|
|
1244
1204
|
const isSame = (newSpeaker == null ? void 0 : newSpeaker.deviceId) === (prevSpeaker == null ? void 0 : prevSpeaker.deviceId);
|
|
@@ -1325,60 +1285,60 @@ var RoomSessionConnection = class extends import_webrtc4.BaseConnection {
|
|
|
1325
1285
|
mirrored: this._mirrored,
|
|
1326
1286
|
setMirrored: (value) => {
|
|
1327
1287
|
this._mirrored = value;
|
|
1328
|
-
this.emit(`${
|
|
1288
|
+
this.emit(`${import_core14.LOCAL_EVENT_PREFIX}.mirror.video`, this._mirrored);
|
|
1329
1289
|
}
|
|
1330
1290
|
};
|
|
1331
1291
|
}
|
|
1332
1292
|
getSubscriptions() {
|
|
1333
1293
|
const eventNamesWithPrefix = this.eventNames().map((event) => `video.${event}`);
|
|
1334
|
-
return (0,
|
|
1335
|
-
}
|
|
1336
|
-
};
|
|
1337
|
-
var RoomSessionAPI = (0,
|
|
1338
|
-
audioMute:
|
|
1339
|
-
audioUnmute:
|
|
1340
|
-
videoMute:
|
|
1341
|
-
videoUnmute:
|
|
1342
|
-
deaf:
|
|
1343
|
-
undeaf:
|
|
1344
|
-
setInputVolume:
|
|
1345
|
-
setOutputVolume:
|
|
1346
|
-
setMicrophoneVolume:
|
|
1347
|
-
setSpeakerVolume:
|
|
1348
|
-
setInputSensitivity:
|
|
1349
|
-
removeMember:
|
|
1350
|
-
removeAllMembers:
|
|
1351
|
-
getMembers:
|
|
1352
|
-
getLayouts:
|
|
1353
|
-
setLayout:
|
|
1354
|
-
setPositions:
|
|
1355
|
-
setMemberPosition:
|
|
1356
|
-
hideVideoMuted:
|
|
1357
|
-
showVideoMuted:
|
|
1358
|
-
getRecordings:
|
|
1359
|
-
startRecording:
|
|
1360
|
-
getPlaybacks:
|
|
1361
|
-
play:
|
|
1362
|
-
setHideVideoMuted:
|
|
1363
|
-
getMeta:
|
|
1364
|
-
setMeta:
|
|
1365
|
-
updateMeta:
|
|
1366
|
-
deleteMeta:
|
|
1367
|
-
getMemberMeta:
|
|
1368
|
-
setMemberMeta:
|
|
1369
|
-
updateMemberMeta:
|
|
1370
|
-
deleteMemberMeta:
|
|
1371
|
-
promote:
|
|
1372
|
-
demote:
|
|
1373
|
-
getStreams:
|
|
1374
|
-
startStream:
|
|
1375
|
-
lock:
|
|
1376
|
-
unlock:
|
|
1377
|
-
setRaisedHand:
|
|
1378
|
-
setPrioritizeHandraise:
|
|
1294
|
+
return (0, import_core14.validateEventsToSubscribe)(eventNamesWithPrefix);
|
|
1295
|
+
}
|
|
1296
|
+
};
|
|
1297
|
+
var RoomSessionAPI = (0, import_core14.extendComponent)(RoomSessionConnection, {
|
|
1298
|
+
audioMute: import_core14.Rooms.audioMuteMember,
|
|
1299
|
+
audioUnmute: import_core14.Rooms.audioUnmuteMember,
|
|
1300
|
+
videoMute: import_core14.Rooms.videoMuteMember,
|
|
1301
|
+
videoUnmute: import_core14.Rooms.videoUnmuteMember,
|
|
1302
|
+
deaf: import_core14.Rooms.deafMember,
|
|
1303
|
+
undeaf: import_core14.Rooms.undeafMember,
|
|
1304
|
+
setInputVolume: import_core14.Rooms.setInputVolumeMember,
|
|
1305
|
+
setOutputVolume: import_core14.Rooms.setOutputVolumeMember,
|
|
1306
|
+
setMicrophoneVolume: import_core14.Rooms.setInputVolumeMember,
|
|
1307
|
+
setSpeakerVolume: import_core14.Rooms.setOutputVolumeMember,
|
|
1308
|
+
setInputSensitivity: import_core14.Rooms.setInputSensitivityMember,
|
|
1309
|
+
removeMember: import_core14.Rooms.removeMember,
|
|
1310
|
+
removeAllMembers: import_core14.Rooms.removeAllMembers,
|
|
1311
|
+
getMembers: import_core14.Rooms.getMembers,
|
|
1312
|
+
getLayouts: import_core14.Rooms.getLayouts,
|
|
1313
|
+
setLayout: import_core14.Rooms.setLayout,
|
|
1314
|
+
setPositions: import_core14.Rooms.setPositions,
|
|
1315
|
+
setMemberPosition: import_core14.Rooms.setMemberPosition,
|
|
1316
|
+
hideVideoMuted: import_core14.Rooms.hideVideoMuted,
|
|
1317
|
+
showVideoMuted: import_core14.Rooms.showVideoMuted,
|
|
1318
|
+
getRecordings: import_core14.Rooms.getRecordings,
|
|
1319
|
+
startRecording: import_core14.Rooms.startRecording,
|
|
1320
|
+
getPlaybacks: import_core14.Rooms.getPlaybacks,
|
|
1321
|
+
play: import_core14.Rooms.play,
|
|
1322
|
+
setHideVideoMuted: import_core14.Rooms.setHideVideoMuted,
|
|
1323
|
+
getMeta: import_core14.Rooms.getMeta,
|
|
1324
|
+
setMeta: import_core14.Rooms.setMeta,
|
|
1325
|
+
updateMeta: import_core14.Rooms.updateMeta,
|
|
1326
|
+
deleteMeta: import_core14.Rooms.deleteMeta,
|
|
1327
|
+
getMemberMeta: import_core14.Rooms.getMemberMeta,
|
|
1328
|
+
setMemberMeta: import_core14.Rooms.setMemberMeta,
|
|
1329
|
+
updateMemberMeta: import_core14.Rooms.updateMemberMeta,
|
|
1330
|
+
deleteMemberMeta: import_core14.Rooms.deleteMemberMeta,
|
|
1331
|
+
promote: import_core14.Rooms.promote,
|
|
1332
|
+
demote: import_core14.Rooms.demote,
|
|
1333
|
+
getStreams: import_core14.Rooms.getStreams,
|
|
1334
|
+
startStream: import_core14.Rooms.startStream,
|
|
1335
|
+
lock: import_core14.Rooms.lock,
|
|
1336
|
+
unlock: import_core14.Rooms.unlock,
|
|
1337
|
+
setRaisedHand: import_core14.Rooms.setRaisedHand,
|
|
1338
|
+
setPrioritizeHandraise: import_core14.Rooms.setPrioritizeHandraise
|
|
1379
1339
|
});
|
|
1380
1340
|
var createBaseRoomSessionObject = (params) => {
|
|
1381
|
-
const room = (0,
|
|
1341
|
+
const room = (0, import_core14.connect)({
|
|
1382
1342
|
store: params.store,
|
|
1383
1343
|
customSagas: params.customSagas,
|
|
1384
1344
|
Component: RoomSessionAPI
|
|
@@ -1387,41 +1347,41 @@ var createBaseRoomSessionObject = (params) => {
|
|
|
1387
1347
|
};
|
|
1388
1348
|
|
|
1389
1349
|
// src/cantina/VideoManager.ts
|
|
1390
|
-
var
|
|
1350
|
+
var import_core18 = require("@signalwire/core");
|
|
1391
1351
|
|
|
1392
1352
|
// src/cantina/workers/videoManagerWorker.ts
|
|
1393
|
-
var
|
|
1353
|
+
var import_core17 = require("@signalwire/core");
|
|
1394
1354
|
|
|
1395
1355
|
// src/cantina/workers/videoManagerRoomsWorker.ts
|
|
1396
|
-
var
|
|
1356
|
+
var import_core15 = require("@signalwire/core");
|
|
1397
1357
|
var videoManagerRoomsWorker = function* (options) {
|
|
1398
|
-
(0,
|
|
1358
|
+
(0, import_core15.getLogger)().trace("videoManagerRoomsWorker started");
|
|
1399
1359
|
const {
|
|
1400
1360
|
instance: client,
|
|
1401
1361
|
action: { type, payload }
|
|
1402
1362
|
} = options;
|
|
1403
1363
|
const modPayload = {
|
|
1404
|
-
rooms: payload.rooms.map((row) => (0,
|
|
1364
|
+
rooms: payload.rooms.map((row) => (0, import_core15.toExternalJSON)(row))
|
|
1405
1365
|
};
|
|
1406
|
-
client.emit((0,
|
|
1407
|
-
(0,
|
|
1366
|
+
client.emit((0, import_core15.stripNamespacePrefix)(type), modPayload);
|
|
1367
|
+
(0, import_core15.getLogger)().trace("videoManagerRoomsWorker ended");
|
|
1408
1368
|
};
|
|
1409
1369
|
|
|
1410
1370
|
// src/cantina/workers/videoManagerRoomWorker.ts
|
|
1411
|
-
var
|
|
1371
|
+
var import_core16 = require("@signalwire/core");
|
|
1412
1372
|
var videoManagerRoomWorker = function* (options) {
|
|
1413
|
-
(0,
|
|
1373
|
+
(0, import_core16.getLogger)().trace("videoManagerRoomWorker started");
|
|
1414
1374
|
const {
|
|
1415
1375
|
instance: client,
|
|
1416
1376
|
action: { type, payload }
|
|
1417
1377
|
} = options;
|
|
1418
|
-
client.emit((0,
|
|
1419
|
-
(0,
|
|
1378
|
+
client.emit((0, import_core16.stripNamespacePrefix)(type), (0, import_core16.toExternalJSON)(payload));
|
|
1379
|
+
(0, import_core16.getLogger)().trace("videoManagerRoomWorker ended");
|
|
1420
1380
|
};
|
|
1421
1381
|
|
|
1422
1382
|
// src/cantina/workers/videoManagerWorker.ts
|
|
1423
1383
|
var videoManagerWorker = function* (options) {
|
|
1424
|
-
(0,
|
|
1384
|
+
(0, import_core17.getLogger)().trace("videoManagerWorker started");
|
|
1425
1385
|
const {
|
|
1426
1386
|
channels: { swEventChannel }
|
|
1427
1387
|
} = options;
|
|
@@ -1429,7 +1389,7 @@ var videoManagerWorker = function* (options) {
|
|
|
1429
1389
|
const { type } = action;
|
|
1430
1390
|
switch (type) {
|
|
1431
1391
|
case "video-manager.rooms.subscribed":
|
|
1432
|
-
yield
|
|
1392
|
+
yield import_core17.sagaEffects.fork(videoManagerRoomsWorker, __spreadValues({
|
|
1433
1393
|
action
|
|
1434
1394
|
}, options));
|
|
1435
1395
|
break;
|
|
@@ -1438,26 +1398,26 @@ var videoManagerWorker = function* (options) {
|
|
|
1438
1398
|
case "video-manager.room.ended":
|
|
1439
1399
|
case "video-manager.room.started":
|
|
1440
1400
|
case "video-manager.room.updated":
|
|
1441
|
-
yield
|
|
1401
|
+
yield import_core17.sagaEffects.fork(videoManagerRoomWorker, __spreadValues({
|
|
1442
1402
|
action
|
|
1443
1403
|
}, options));
|
|
1444
1404
|
break;
|
|
1445
1405
|
default:
|
|
1446
|
-
(0,
|
|
1406
|
+
(0, import_core17.getLogger)().warn(`Unknown video-manager event: "${type}"`);
|
|
1447
1407
|
break;
|
|
1448
1408
|
}
|
|
1449
1409
|
}
|
|
1450
1410
|
while (true) {
|
|
1451
|
-
const action = yield
|
|
1411
|
+
const action = yield import_core17.sagaEffects.take(swEventChannel, (action2) => {
|
|
1452
1412
|
return action2.type.startsWith("video-manager.");
|
|
1453
1413
|
});
|
|
1454
|
-
yield
|
|
1414
|
+
yield import_core17.sagaEffects.fork(worker, action);
|
|
1455
1415
|
}
|
|
1456
|
-
(0,
|
|
1416
|
+
(0, import_core17.getLogger)().trace("videoManagerWorker ended");
|
|
1457
1417
|
};
|
|
1458
1418
|
|
|
1459
1419
|
// src/cantina/VideoManager.ts
|
|
1460
|
-
var VideoManagerAPI = class extends
|
|
1420
|
+
var VideoManagerAPI = class extends import_core18.BaseConsumer {
|
|
1461
1421
|
constructor(options) {
|
|
1462
1422
|
super(options);
|
|
1463
1423
|
this.runWorker("videoManagerWorker", {
|
|
@@ -1466,11 +1426,11 @@ var VideoManagerAPI = class extends import_core17.BaseConsumer {
|
|
|
1466
1426
|
}
|
|
1467
1427
|
getSubscriptions() {
|
|
1468
1428
|
const eventNamesWithPrefix = this.eventNames().map((event) => `video-manager.${event}`);
|
|
1469
|
-
return (0,
|
|
1429
|
+
return (0, import_core18.validateEventsToSubscribe)(eventNamesWithPrefix);
|
|
1470
1430
|
}
|
|
1471
1431
|
};
|
|
1472
1432
|
var createVideoManagerObject = (params) => {
|
|
1473
|
-
const manager = (0,
|
|
1433
|
+
const manager = (0, import_core18.connect)({
|
|
1474
1434
|
store: params.store,
|
|
1475
1435
|
Component: VideoManagerAPI
|
|
1476
1436
|
})(params);
|
|
@@ -1487,102 +1447,61 @@ var createVideoManagerObject = (params) => {
|
|
|
1487
1447
|
return proxy;
|
|
1488
1448
|
};
|
|
1489
1449
|
|
|
1490
|
-
// src/
|
|
1491
|
-
var
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1450
|
+
// src/fabric/CallFabricBaseRoomSession.ts
|
|
1451
|
+
var import_core33 = require("@signalwire/core");
|
|
1452
|
+
|
|
1453
|
+
// src/fabric/workers/wsClientWorker.ts
|
|
1454
|
+
var import_core19 = require("@signalwire/core");
|
|
1455
|
+
var wsClientWorker = function* (options) {
|
|
1456
|
+
(0, import_core19.getLogger)().trace("wsClientWorker started");
|
|
1457
|
+
const { channels, initialState } = options;
|
|
1458
|
+
const { swEventChannel } = channels;
|
|
1459
|
+
const { buildInboundCall } = initialState;
|
|
1460
|
+
while (true) {
|
|
1461
|
+
const action = yield import_core19.sagaEffects.take(swEventChannel, (action2) => {
|
|
1462
|
+
if (action2.type === "webrtc.message") {
|
|
1463
|
+
return action2.payload.method === "verto.invite";
|
|
1464
|
+
}
|
|
1465
|
+
return false;
|
|
1466
|
+
});
|
|
1467
|
+
(0, import_core19.getLogger)().debug("Receiving a new call over WebSocket", action);
|
|
1468
|
+
buildInboundCall(action.payload.params);
|
|
1497
1469
|
}
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
if (rootElement) {
|
|
1517
|
-
customSagas.push(makeVideoElementSaga({
|
|
1518
|
-
rootElement,
|
|
1519
|
-
applyLocalVideoOverlay
|
|
1520
|
-
}));
|
|
1521
|
-
}
|
|
1522
|
-
const room = createBaseRoomSessionObject(__spreadProps(__spreadValues({}, options), {
|
|
1523
|
-
store: this.store,
|
|
1524
|
-
customSagas
|
|
1525
|
-
}));
|
|
1526
|
-
if (stopMicrophoneWhileMuted) {
|
|
1527
|
-
room.on("member.updated.audio_muted", ({ member }) => {
|
|
1528
|
-
try {
|
|
1529
|
-
if (member.id === room.memberId && "audio_muted" in member) {
|
|
1530
|
-
member.audio_muted ? room.stopOutboundAudio() : room.restoreOutboundAudio();
|
|
1531
|
-
}
|
|
1532
|
-
} catch (error) {
|
|
1533
|
-
this.logger.error("Error handling audio_muted", error);
|
|
1534
|
-
}
|
|
1535
|
-
});
|
|
1536
|
-
}
|
|
1537
|
-
if (stopCameraWhileMuted) {
|
|
1538
|
-
room.on("member.updated.video_muted", ({ member }) => {
|
|
1539
|
-
try {
|
|
1540
|
-
if (member.id === room.memberId && "video_muted" in member) {
|
|
1541
|
-
member.video_muted ? room.stopOutboundVideo() : room.restoreOutboundVideo();
|
|
1542
|
-
}
|
|
1543
|
-
} catch (error) {
|
|
1544
|
-
this.logger.error("Error handling video_muted", error);
|
|
1545
|
-
}
|
|
1546
|
-
});
|
|
1547
|
-
}
|
|
1548
|
-
return room;
|
|
1549
|
-
}
|
|
1550
|
-
};
|
|
1551
|
-
}
|
|
1552
|
-
get chat() {
|
|
1553
|
-
if (!this._chat) {
|
|
1554
|
-
this._chat = import_core18.Chat.createBaseChatObject({
|
|
1555
|
-
store: this.store
|
|
1556
|
-
});
|
|
1557
|
-
}
|
|
1558
|
-
return this._chat;
|
|
1559
|
-
}
|
|
1560
|
-
get pubSub() {
|
|
1561
|
-
if (!this._pubSub) {
|
|
1562
|
-
this._pubSub = import_core18.PubSub.createBasePubSubObject({
|
|
1563
|
-
store: this.store
|
|
1564
|
-
});
|
|
1565
|
-
}
|
|
1566
|
-
return this._pubSub;
|
|
1567
|
-
}
|
|
1568
|
-
get videoManager() {
|
|
1569
|
-
if (!this._videoManager) {
|
|
1570
|
-
this._videoManager = createVideoManagerObject(this.options);
|
|
1571
|
-
}
|
|
1572
|
-
return this._videoManager;
|
|
1573
|
-
}
|
|
1574
|
-
reauthenticate(token) {
|
|
1575
|
-
this.store.dispatch(import_core18.actions.reauthAction({ token }));
|
|
1470
|
+
(0, import_core19.getLogger)().trace("wsClientWorker ended");
|
|
1471
|
+
};
|
|
1472
|
+
|
|
1473
|
+
// src/fabric/workers/conversationWorker.ts
|
|
1474
|
+
var import_core20 = require("@signalwire/core");
|
|
1475
|
+
var conversationWorker = function* (options) {
|
|
1476
|
+
(0, import_core20.getLogger)().debug("conversationWorker started");
|
|
1477
|
+
const {
|
|
1478
|
+
channels: { swEventChannel },
|
|
1479
|
+
initialState
|
|
1480
|
+
} = options;
|
|
1481
|
+
const { conversation } = initialState;
|
|
1482
|
+
const isConversationEvent = (action) => {
|
|
1483
|
+
return action.type === "conversation.message";
|
|
1484
|
+
};
|
|
1485
|
+
while (true) {
|
|
1486
|
+
const action = yield import_core20.sagaEffects.take(swEventChannel, isConversationEvent);
|
|
1487
|
+
conversation.handleEvent(action.payload);
|
|
1576
1488
|
}
|
|
1489
|
+
(0, import_core20.getLogger)().trace("conversationWorker ended");
|
|
1577
1490
|
};
|
|
1578
1491
|
|
|
1492
|
+
// src/fabric/workers/unifiedTargetWorker.ts
|
|
1493
|
+
var import_core25 = require("@signalwire/core");
|
|
1494
|
+
|
|
1495
|
+
// src/UnifiedJWTSession.ts
|
|
1496
|
+
var import_core24 = require("@signalwire/core");
|
|
1497
|
+
|
|
1579
1498
|
// src/JWTSession.ts
|
|
1580
1499
|
var import_jwt_decode2 = __toESM(require("jwt-decode"));
|
|
1581
|
-
var
|
|
1500
|
+
var import_core23 = require("@signalwire/core");
|
|
1582
1501
|
|
|
1583
1502
|
// src/utils/storage.ts
|
|
1584
1503
|
var import_jwt_decode = __toESM(require("jwt-decode"));
|
|
1585
|
-
var
|
|
1504
|
+
var import_core21 = require("@signalwire/core");
|
|
1586
1505
|
var getStorage = () => {
|
|
1587
1506
|
if (window && window.sessionStorage) {
|
|
1588
1507
|
return window.sessionStorage;
|
|
@@ -1597,7 +1516,7 @@ var sessionStorageManager = (token) => {
|
|
|
1597
1516
|
roomName = (_a = jwtPayload == null ? void 0 : jwtPayload.r) != null ? _a : "";
|
|
1598
1517
|
} catch (e) {
|
|
1599
1518
|
if (process.env.NODE_ENV !== "production") {
|
|
1600
|
-
(0,
|
|
1519
|
+
(0, import_core21.getLogger)().error("[sessionStorageManager] error decoding JWT", token);
|
|
1601
1520
|
}
|
|
1602
1521
|
roomName = "";
|
|
1603
1522
|
}
|
|
@@ -1610,11 +1529,11 @@ var sessionStorageManager = (token) => {
|
|
|
1610
1529
|
};
|
|
1611
1530
|
|
|
1612
1531
|
// src/utils/CloseEvent.ts
|
|
1613
|
-
var
|
|
1614
|
-
var SwCloseEvent = typeof CloseEvent === "function" ? CloseEvent :
|
|
1532
|
+
var import_core22 = require("@signalwire/core");
|
|
1533
|
+
var SwCloseEvent = typeof CloseEvent === "function" ? CloseEvent : import_core22.SWCloseEvent;
|
|
1615
1534
|
|
|
1616
1535
|
// src/JWTSession.ts
|
|
1617
|
-
var JWTSession = class extends
|
|
1536
|
+
var JWTSession = class extends import_core23.BaseJWTSession {
|
|
1618
1537
|
constructor(options) {
|
|
1619
1538
|
var _a;
|
|
1620
1539
|
let decodedJwt = {};
|
|
@@ -1624,16 +1543,16 @@ var JWTSession = class extends import_core21.BaseJWTSession {
|
|
|
1624
1543
|
});
|
|
1625
1544
|
} catch (e) {
|
|
1626
1545
|
if (process.env.NODE_ENV !== "production") {
|
|
1627
|
-
(0,
|
|
1546
|
+
(0, import_core23.getLogger)().debug("[JWTSession] error decoding the JWT");
|
|
1628
1547
|
}
|
|
1629
1548
|
}
|
|
1630
1549
|
super(__spreadProps(__spreadValues({}, options), {
|
|
1631
|
-
host:
|
|
1550
|
+
host: (decodedJwt == null ? void 0 : decodedJwt.ch) || options.host
|
|
1632
1551
|
}));
|
|
1633
1552
|
this.options = options;
|
|
1634
1553
|
__publicField(this, "WebSocketConstructor", WebSocket);
|
|
1635
1554
|
__publicField(this, "CloseEventConstructor", SwCloseEvent);
|
|
1636
|
-
__publicField(this, "agent", "@signalwire/js/browser/3.
|
|
1555
|
+
__publicField(this, "agent", "@signalwire/js/browser/3.27.0-dev.202404301530.94a97d7.0");
|
|
1637
1556
|
__publicField(this, "tokenTyp");
|
|
1638
1557
|
this.tokenTyp = (_a = decodedJwt.typ) != null ? _a : "VRT";
|
|
1639
1558
|
}
|
|
@@ -1716,23 +1635,725 @@ var JWTSession = class extends import_core21.BaseJWTSession {
|
|
|
1716
1635
|
}
|
|
1717
1636
|
};
|
|
1718
1637
|
|
|
1638
|
+
// src/fabric/workers/unifiedEventsWatcher.ts
|
|
1639
|
+
var import_core27 = require("@signalwire/core");
|
|
1640
|
+
|
|
1641
|
+
// src/fabric/workers/mappers/unifiedEventsMapper.ts
|
|
1642
|
+
var import_core26 = require("@signalwire/core");
|
|
1643
|
+
|
|
1644
|
+
// src/fabric/workers/callFabricWorker.ts
|
|
1645
|
+
var import_core32 = require("@signalwire/core");
|
|
1646
|
+
|
|
1647
|
+
// src/fabric/workers/callJoinWorker.ts
|
|
1648
|
+
var import_core29 = require("@signalwire/core");
|
|
1649
|
+
|
|
1650
|
+
// src/fabric/CallSegment.ts
|
|
1651
|
+
var import_core28 = require("@signalwire/core");
|
|
1652
|
+
var CallSegmentAPI = class extends import_core28.BaseComponent {
|
|
1653
|
+
constructor(options) {
|
|
1654
|
+
super(options);
|
|
1655
|
+
__publicField(this, "_payload");
|
|
1656
|
+
this._payload = options.payload;
|
|
1657
|
+
}
|
|
1658
|
+
get roomId() {
|
|
1659
|
+
return this._payload.room_id;
|
|
1660
|
+
}
|
|
1661
|
+
get roomSessionId() {
|
|
1662
|
+
return this._payload.room_session_id;
|
|
1663
|
+
}
|
|
1664
|
+
get callId() {
|
|
1665
|
+
return this._payload.call_id;
|
|
1666
|
+
}
|
|
1667
|
+
get memberId() {
|
|
1668
|
+
return this._payload.member_id;
|
|
1669
|
+
}
|
|
1670
|
+
get roomSession() {
|
|
1671
|
+
return this._payload.room_session;
|
|
1672
|
+
}
|
|
1673
|
+
get members() {
|
|
1674
|
+
return this._payload.members;
|
|
1675
|
+
}
|
|
1676
|
+
get member() {
|
|
1677
|
+
var _a;
|
|
1678
|
+
return (_a = this.members) == null ? void 0 : _a.find((member) => member.memberId === this.memberId);
|
|
1679
|
+
}
|
|
1680
|
+
setPayload(payload) {
|
|
1681
|
+
this._payload = payload;
|
|
1682
|
+
}
|
|
1683
|
+
};
|
|
1684
|
+
var createCallSegmentObject = (params) => {
|
|
1685
|
+
const playback = (0, import_core28.connect)({
|
|
1686
|
+
store: params.store,
|
|
1687
|
+
Component: CallSegmentAPI
|
|
1688
|
+
})(params);
|
|
1689
|
+
return playback;
|
|
1690
|
+
};
|
|
1691
|
+
|
|
1692
|
+
// src/fabric/workers/callJoinWorker.ts
|
|
1693
|
+
var callJoinWorker = function* (options) {
|
|
1694
|
+
var _a;
|
|
1695
|
+
(0, import_core29.getLogger)().trace("callJoinWorker started");
|
|
1696
|
+
const { action, callSegments, instanceMap, instance: cfRoomSession } = options;
|
|
1697
|
+
const { payload } = action;
|
|
1698
|
+
const { get, set } = instanceMap;
|
|
1699
|
+
const memberInstances = (_a = payload.room_session.members) == null ? void 0 : _a.map((member) => {
|
|
1700
|
+
let memberInstance = get(member.member_id);
|
|
1701
|
+
if (!memberInstance) {
|
|
1702
|
+
memberInstance = import_core29.Rooms.createRoomSessionMemberObject({
|
|
1703
|
+
store: cfRoomSession.store,
|
|
1704
|
+
payload: {
|
|
1705
|
+
room_id: payload.room_id,
|
|
1706
|
+
room_session_id: payload.room_session_id,
|
|
1707
|
+
member
|
|
1708
|
+
}
|
|
1709
|
+
});
|
|
1710
|
+
} else {
|
|
1711
|
+
memberInstance.setPayload({
|
|
1712
|
+
room_id: payload.room_id,
|
|
1713
|
+
room_session_id: payload.room_session_id,
|
|
1714
|
+
member
|
|
1715
|
+
});
|
|
1716
|
+
}
|
|
1717
|
+
set(member.member_id, memberInstance);
|
|
1718
|
+
return memberInstance;
|
|
1719
|
+
});
|
|
1720
|
+
const callSegmentInstance = createCallSegmentObject({
|
|
1721
|
+
store: cfRoomSession.store,
|
|
1722
|
+
payload: __spreadProps(__spreadValues({}, payload), {
|
|
1723
|
+
members: memberInstances
|
|
1724
|
+
})
|
|
1725
|
+
});
|
|
1726
|
+
callSegments.push(callSegmentInstance);
|
|
1727
|
+
cfRoomSession.runWorker("memberPositionWorker", __spreadProps(__spreadValues({
|
|
1728
|
+
worker: import_core29.MemberPosition.memberPositionWorker
|
|
1729
|
+
}, options), {
|
|
1730
|
+
instance: cfRoomSession,
|
|
1731
|
+
initialState: payload,
|
|
1732
|
+
dispatcher: function* (subType, subPayload) {
|
|
1733
|
+
yield import_core29.sagaEffects.fork(videoMemberWorker, __spreadProps(__spreadValues({}, options), {
|
|
1734
|
+
action: { type: subType, payload: subPayload }
|
|
1735
|
+
}));
|
|
1736
|
+
}
|
|
1737
|
+
}));
|
|
1738
|
+
for (const memberPayload of payload.room_session.members || []) {
|
|
1739
|
+
yield import_core29.sagaEffects.fork(videoMemberWorker, __spreadProps(__spreadValues({}, options), {
|
|
1740
|
+
action: {
|
|
1741
|
+
type: "video.member.joined",
|
|
1742
|
+
payload: { member: memberPayload }
|
|
1743
|
+
}
|
|
1744
|
+
}));
|
|
1745
|
+
}
|
|
1746
|
+
cfRoomSession.emit("room.subscribed", payload);
|
|
1747
|
+
cfRoomSession.emit("call.joined", payload);
|
|
1748
|
+
(0, import_core29.getLogger)().trace("callJoinWorker ended");
|
|
1749
|
+
};
|
|
1750
|
+
|
|
1751
|
+
// src/fabric/workers/callLeftWorker.ts
|
|
1752
|
+
var import_core30 = require("@signalwire/core");
|
|
1753
|
+
var callLeftWorker = function* (options) {
|
|
1754
|
+
(0, import_core30.getLogger)().trace("callLeftWorker started");
|
|
1755
|
+
const {
|
|
1756
|
+
action: { payload },
|
|
1757
|
+
instance: cfRoomSession,
|
|
1758
|
+
callSegments,
|
|
1759
|
+
instanceMap
|
|
1760
|
+
} = options;
|
|
1761
|
+
const { call_id, room_session_id } = payload;
|
|
1762
|
+
const segmentToRemoveIndex = callSegments.findIndex((segment) => segment.callId == call_id);
|
|
1763
|
+
if (segmentToRemoveIndex >= 0) {
|
|
1764
|
+
callSegments.splice(segmentToRemoveIndex, 1);
|
|
1765
|
+
}
|
|
1766
|
+
instanceMap.getAll().forEach(([key, obj]) => {
|
|
1767
|
+
if (obj instanceof import_core30.Rooms.RoomSessionMemberAPI && obj.roomSessionId === room_session_id) {
|
|
1768
|
+
instanceMap.remove(key);
|
|
1769
|
+
}
|
|
1770
|
+
});
|
|
1771
|
+
cfRoomSession.emit("call.left", payload);
|
|
1772
|
+
(0, import_core30.getLogger)().trace("callLeftWorker ended");
|
|
1773
|
+
};
|
|
1774
|
+
|
|
1775
|
+
// src/fabric/workers/callStateWorker.ts
|
|
1776
|
+
var import_core31 = require("@signalwire/core");
|
|
1777
|
+
var callStateWorker = function* (options) {
|
|
1778
|
+
(0, import_core31.getLogger)().trace("callStateWorker started");
|
|
1779
|
+
const {
|
|
1780
|
+
instance: cfRoomSession,
|
|
1781
|
+
action: { payload },
|
|
1782
|
+
callSegments
|
|
1783
|
+
} = options;
|
|
1784
|
+
switch (payload.call_state) {
|
|
1785
|
+
case "ended": {
|
|
1786
|
+
cfRoomSession.emit("call.state", payload);
|
|
1787
|
+
if (callSegments.length < 1 && cfRoomSession.state === "destroy") {
|
|
1788
|
+
console.log(">> destroy");
|
|
1789
|
+
cfRoomSession.destroy();
|
|
1790
|
+
}
|
|
1791
|
+
break;
|
|
1792
|
+
}
|
|
1793
|
+
default:
|
|
1794
|
+
cfRoomSession.emit("call.state", payload);
|
|
1795
|
+
break;
|
|
1796
|
+
}
|
|
1797
|
+
(0, import_core31.getLogger)().trace("callStateWorker ended");
|
|
1798
|
+
};
|
|
1799
|
+
|
|
1800
|
+
// src/fabric/workers/callFabricWorker.ts
|
|
1801
|
+
var callFabricWorker = function* (options) {
|
|
1802
|
+
(0, import_core32.getLogger)().trace("callFabricWorker started");
|
|
1803
|
+
const { channels, instance: roomSession } = options;
|
|
1804
|
+
const { swEventChannel } = channels;
|
|
1805
|
+
function* worker(action) {
|
|
1806
|
+
const { type, payload } = action;
|
|
1807
|
+
switch (type) {
|
|
1808
|
+
case "call.joined": {
|
|
1809
|
+
yield import_core32.sagaEffects.fork(callJoinWorker, __spreadValues({
|
|
1810
|
+
action
|
|
1811
|
+
}, options));
|
|
1812
|
+
return;
|
|
1813
|
+
}
|
|
1814
|
+
case "call.left": {
|
|
1815
|
+
yield import_core32.sagaEffects.fork(callLeftWorker, __spreadValues({
|
|
1816
|
+
action
|
|
1817
|
+
}, options));
|
|
1818
|
+
return;
|
|
1819
|
+
}
|
|
1820
|
+
case "call.state": {
|
|
1821
|
+
yield import_core32.sagaEffects.fork(callStateWorker, __spreadValues({
|
|
1822
|
+
action
|
|
1823
|
+
}, options));
|
|
1824
|
+
return;
|
|
1825
|
+
}
|
|
1826
|
+
case "call.started":
|
|
1827
|
+
case "call.updated":
|
|
1828
|
+
case "call.ended": {
|
|
1829
|
+
const action2 = type.split(".")[1];
|
|
1830
|
+
const newEventName = `room.${action2}`;
|
|
1831
|
+
roomSession.emit(newEventName, payload);
|
|
1832
|
+
break;
|
|
1833
|
+
}
|
|
1834
|
+
case "member.joined":
|
|
1835
|
+
case "member.left":
|
|
1836
|
+
case "member.updated":
|
|
1837
|
+
case "member.talking": {
|
|
1838
|
+
const updatedAction = __spreadProps(__spreadValues({}, action), {
|
|
1839
|
+
type: `video.${type}`
|
|
1840
|
+
});
|
|
1841
|
+
yield import_core32.sagaEffects.fork(videoMemberWorker, __spreadValues({
|
|
1842
|
+
action: updatedAction
|
|
1843
|
+
}, options));
|
|
1844
|
+
return;
|
|
1845
|
+
}
|
|
1846
|
+
case "layout.changed": {
|
|
1847
|
+
const updatedAction = __spreadProps(__spreadValues({}, action), {
|
|
1848
|
+
type: `video.${type}`
|
|
1849
|
+
});
|
|
1850
|
+
yield import_core32.sagaEffects.put(swEventChannel, updatedAction);
|
|
1851
|
+
break;
|
|
1852
|
+
}
|
|
1853
|
+
case "member.demoted":
|
|
1854
|
+
case "member.promoted": {
|
|
1855
|
+
const updatedAction = __spreadProps(__spreadValues({}, action), {
|
|
1856
|
+
type: `video.${type}`
|
|
1857
|
+
});
|
|
1858
|
+
yield import_core32.sagaEffects.put(swEventChannel, updatedAction);
|
|
1859
|
+
return;
|
|
1860
|
+
}
|
|
1861
|
+
default:
|
|
1862
|
+
break;
|
|
1863
|
+
}
|
|
1864
|
+
roomSession.emit(type, payload);
|
|
1865
|
+
}
|
|
1866
|
+
const isVideoOrCallEvent = (action) => {
|
|
1867
|
+
return action.type.startsWith("call.") || action.type.startsWith("member.") || action.type.startsWith("layout.");
|
|
1868
|
+
};
|
|
1869
|
+
while (true) {
|
|
1870
|
+
const action = yield import_core32.sagaEffects.take(swEventChannel, isVideoOrCallEvent);
|
|
1871
|
+
yield import_core32.sagaEffects.fork(worker, action);
|
|
1872
|
+
}
|
|
1873
|
+
(0, import_core32.getLogger)().trace("callFabricWorker ended");
|
|
1874
|
+
};
|
|
1875
|
+
|
|
1876
|
+
// src/fabric/CallFabricBaseRoomSession.ts
|
|
1877
|
+
var CallFabricRoomSessionConnection = class extends RoomSessionConnection {
|
|
1878
|
+
initWorker() {
|
|
1879
|
+
this.runWorker("callFabricWorker", {
|
|
1880
|
+
worker: callFabricWorker
|
|
1881
|
+
});
|
|
1882
|
+
}
|
|
1883
|
+
get selfMember() {
|
|
1884
|
+
var _a;
|
|
1885
|
+
return (_a = this.callSegments[0]) == null ? void 0 : _a.member;
|
|
1886
|
+
}
|
|
1887
|
+
get targetMember() {
|
|
1888
|
+
var _a;
|
|
1889
|
+
return (_a = this.callSegments[this.callSegments.length - 1]) == null ? void 0 : _a.member;
|
|
1890
|
+
}
|
|
1891
|
+
isSelfMember(id) {
|
|
1892
|
+
return this.callSegments.findIndex((segment) => segment.memberId === id) > -1;
|
|
1893
|
+
}
|
|
1894
|
+
executeAction(params, options = {}) {
|
|
1895
|
+
const { method, extraParams = {} } = params;
|
|
1896
|
+
return this.execute({
|
|
1897
|
+
method,
|
|
1898
|
+
params: __spreadValues({
|
|
1899
|
+
self: {
|
|
1900
|
+
member_id: this.selfMember.id,
|
|
1901
|
+
call_id: this.selfMember.callId,
|
|
1902
|
+
node_id: this.selfMember.nodeId
|
|
1903
|
+
}
|
|
1904
|
+
}, extraParams)
|
|
1905
|
+
}, options);
|
|
1906
|
+
}
|
|
1907
|
+
executeMemberAction(params, options = {}) {
|
|
1908
|
+
const { method, channel, memberId, extraParams = {} } = params;
|
|
1909
|
+
let targetMember = this.targetMember;
|
|
1910
|
+
if (memberId && !this.isSelfMember(memberId)) {
|
|
1911
|
+
const lastSegment = this.callSegments[this.callSegments.length - 1];
|
|
1912
|
+
const memberInCurrentSegment = lastSegment.members.find((member) => member.id === memberId);
|
|
1913
|
+
if (!memberInCurrentSegment) {
|
|
1914
|
+
throw new Error("The memberId is not a part of the current call segment!");
|
|
1915
|
+
} else {
|
|
1916
|
+
targetMember = memberInCurrentSegment;
|
|
1917
|
+
}
|
|
1918
|
+
}
|
|
1919
|
+
return this.execute({
|
|
1920
|
+
method,
|
|
1921
|
+
params: __spreadValues(__spreadProps(__spreadValues({}, channel && { channels: [channel] }), {
|
|
1922
|
+
self: {
|
|
1923
|
+
member_id: this.selfMember.id,
|
|
1924
|
+
call_id: this.selfMember.callId,
|
|
1925
|
+
node_id: this.selfMember.nodeId
|
|
1926
|
+
},
|
|
1927
|
+
target: {
|
|
1928
|
+
member_id: targetMember.id,
|
|
1929
|
+
call_id: targetMember.callId,
|
|
1930
|
+
node_id: targetMember.nodeId
|
|
1931
|
+
}
|
|
1932
|
+
}), extraParams)
|
|
1933
|
+
}, options);
|
|
1934
|
+
}
|
|
1935
|
+
audioMute(params) {
|
|
1936
|
+
return this.executeMemberAction({
|
|
1937
|
+
method: "call.mute",
|
|
1938
|
+
channel: "audio",
|
|
1939
|
+
memberId: params == null ? void 0 : params.memberId
|
|
1940
|
+
});
|
|
1941
|
+
}
|
|
1942
|
+
audioUnmute(params) {
|
|
1943
|
+
return this.executeMemberAction({
|
|
1944
|
+
method: "call.unmute",
|
|
1945
|
+
channel: "audio",
|
|
1946
|
+
memberId: params == null ? void 0 : params.memberId
|
|
1947
|
+
});
|
|
1948
|
+
}
|
|
1949
|
+
videoMute(params) {
|
|
1950
|
+
return this.executeMemberAction({
|
|
1951
|
+
method: "call.mute",
|
|
1952
|
+
channel: "video",
|
|
1953
|
+
memberId: params == null ? void 0 : params.memberId
|
|
1954
|
+
});
|
|
1955
|
+
}
|
|
1956
|
+
videoUnmute(params) {
|
|
1957
|
+
return this.executeMemberAction({
|
|
1958
|
+
method: "call.unmute",
|
|
1959
|
+
channel: "video",
|
|
1960
|
+
memberId: params == null ? void 0 : params.memberId
|
|
1961
|
+
});
|
|
1962
|
+
}
|
|
1963
|
+
deaf(params) {
|
|
1964
|
+
return this.executeMemberAction({
|
|
1965
|
+
method: "call.deaf",
|
|
1966
|
+
memberId: params == null ? void 0 : params.memberId
|
|
1967
|
+
});
|
|
1968
|
+
}
|
|
1969
|
+
undeaf(params) {
|
|
1970
|
+
return this.executeMemberAction({
|
|
1971
|
+
method: "call.undeaf",
|
|
1972
|
+
memberId: params == null ? void 0 : params.memberId
|
|
1973
|
+
});
|
|
1974
|
+
}
|
|
1975
|
+
getLayouts() {
|
|
1976
|
+
return this.executeAction({
|
|
1977
|
+
method: "call.layout.list"
|
|
1978
|
+
}, {
|
|
1979
|
+
transformResolve: (payload) => ({
|
|
1980
|
+
layouts: payload.layouts
|
|
1981
|
+
})
|
|
1982
|
+
});
|
|
1983
|
+
}
|
|
1984
|
+
getMembers() {
|
|
1985
|
+
return this.executeAction({
|
|
1986
|
+
method: "call.member.list"
|
|
1987
|
+
}, {
|
|
1988
|
+
transformResolve: (payload) => ({
|
|
1989
|
+
members: payload.members
|
|
1990
|
+
})
|
|
1991
|
+
});
|
|
1992
|
+
}
|
|
1993
|
+
removeMember(params) {
|
|
1994
|
+
if (!(params == null ? void 0 : params.memberId)) {
|
|
1995
|
+
throw new TypeError('Invalid or missing "memberId" argument');
|
|
1996
|
+
}
|
|
1997
|
+
return this.executeMemberAction({
|
|
1998
|
+
method: "call.member.remove",
|
|
1999
|
+
memberId: params.memberId
|
|
2000
|
+
});
|
|
2001
|
+
}
|
|
2002
|
+
setLayout(params) {
|
|
2003
|
+
const extraParams = {
|
|
2004
|
+
name: params == null ? void 0 : params.name,
|
|
2005
|
+
layout: Object.values((params == null ? void 0 : params.positions) || {})[0]
|
|
2006
|
+
};
|
|
2007
|
+
return this.executeAction({
|
|
2008
|
+
method: "call.layout.set",
|
|
2009
|
+
extraParams
|
|
2010
|
+
});
|
|
2011
|
+
}
|
|
2012
|
+
setInputVolume(params) {
|
|
2013
|
+
return this.executeMemberAction({
|
|
2014
|
+
method: "call.microphone.volume.set",
|
|
2015
|
+
memberId: params == null ? void 0 : params.memberId,
|
|
2016
|
+
extraParams: {
|
|
2017
|
+
volume: params == null ? void 0 : params.volume
|
|
2018
|
+
}
|
|
2019
|
+
});
|
|
2020
|
+
}
|
|
2021
|
+
setOutputVolume(params) {
|
|
2022
|
+
return this.executeMemberAction({
|
|
2023
|
+
method: "video.member.set_output_volume",
|
|
2024
|
+
memberId: params == null ? void 0 : params.memberId,
|
|
2025
|
+
extraParams: {
|
|
2026
|
+
volume: params == null ? void 0 : params.volume
|
|
2027
|
+
}
|
|
2028
|
+
});
|
|
2029
|
+
}
|
|
2030
|
+
setInputSensitivity(params) {
|
|
2031
|
+
return this.executeMemberAction({
|
|
2032
|
+
method: "call.microphone.sensitivity.set",
|
|
2033
|
+
memberId: params == null ? void 0 : params.memberId,
|
|
2034
|
+
extraParams: {
|
|
2035
|
+
value: params == null ? void 0 : params.value
|
|
2036
|
+
}
|
|
2037
|
+
});
|
|
2038
|
+
}
|
|
2039
|
+
};
|
|
2040
|
+
var createCallFabricBaseRoomSessionObject = (params) => {
|
|
2041
|
+
const room = (0, import_core33.connect)({
|
|
2042
|
+
store: params.store,
|
|
2043
|
+
customSagas: params.customSagas,
|
|
2044
|
+
Component: CallFabricRoomSessionConnection
|
|
2045
|
+
})(params);
|
|
2046
|
+
return room;
|
|
2047
|
+
};
|
|
2048
|
+
|
|
2049
|
+
// src/Client.ts
|
|
2050
|
+
var ClientAPI = class extends import_core34.BaseClient {
|
|
2051
|
+
constructor() {
|
|
2052
|
+
super(...arguments);
|
|
2053
|
+
__publicField(this, "_videoManager");
|
|
2054
|
+
__publicField(this, "_chat");
|
|
2055
|
+
__publicField(this, "_pubSub");
|
|
2056
|
+
}
|
|
2057
|
+
get rooms() {
|
|
2058
|
+
return {
|
|
2059
|
+
makeRoomObject: (makeRoomOptions) => {
|
|
2060
|
+
const _a = makeRoomOptions, {
|
|
2061
|
+
rootElement,
|
|
2062
|
+
applyLocalVideoOverlay = true,
|
|
2063
|
+
stopCameraWhileMuted = true,
|
|
2064
|
+
stopMicrophoneWhileMuted = true,
|
|
2065
|
+
unifiedEventing = false
|
|
2066
|
+
} = _a, options = __objRest(_a, [
|
|
2067
|
+
"rootElement",
|
|
2068
|
+
"applyLocalVideoOverlay",
|
|
2069
|
+
"stopCameraWhileMuted",
|
|
2070
|
+
"stopMicrophoneWhileMuted",
|
|
2071
|
+
"unifiedEventing"
|
|
2072
|
+
]);
|
|
2073
|
+
const customSagas = [];
|
|
2074
|
+
customSagas.push(makeAudioElementSaga({
|
|
2075
|
+
speakerId: options.speakerId
|
|
2076
|
+
}));
|
|
2077
|
+
if (rootElement) {
|
|
2078
|
+
customSagas.push(makeVideoElementSaga({
|
|
2079
|
+
rootElement,
|
|
2080
|
+
applyLocalVideoOverlay
|
|
2081
|
+
}));
|
|
2082
|
+
}
|
|
2083
|
+
let roomSessionObject = createBaseRoomSessionObject;
|
|
2084
|
+
if (unifiedEventing) {
|
|
2085
|
+
roomSessionObject = createCallFabricBaseRoomSessionObject;
|
|
2086
|
+
}
|
|
2087
|
+
const room = roomSessionObject(__spreadProps(__spreadValues({}, options), {
|
|
2088
|
+
store: this.store,
|
|
2089
|
+
customSagas
|
|
2090
|
+
}));
|
|
2091
|
+
if (stopMicrophoneWhileMuted) {
|
|
2092
|
+
room.on("member.updated.audio_muted", ({ member }) => {
|
|
2093
|
+
try {
|
|
2094
|
+
if (member.id === room.memberId && "audio_muted" in member) {
|
|
2095
|
+
member.audio_muted ? room.stopOutboundAudio() : room.restoreOutboundAudio();
|
|
2096
|
+
}
|
|
2097
|
+
} catch (error) {
|
|
2098
|
+
this.logger.error("Error handling audio_muted", error);
|
|
2099
|
+
}
|
|
2100
|
+
});
|
|
2101
|
+
}
|
|
2102
|
+
if (stopCameraWhileMuted) {
|
|
2103
|
+
room.on("member.updated.video_muted", ({ member }) => {
|
|
2104
|
+
try {
|
|
2105
|
+
if (member.id === room.memberId && "video_muted" in member) {
|
|
2106
|
+
member.video_muted ? room.stopOutboundVideo() : room.restoreOutboundVideo();
|
|
2107
|
+
}
|
|
2108
|
+
} catch (error) {
|
|
2109
|
+
this.logger.error("Error handling video_muted", error);
|
|
2110
|
+
}
|
|
2111
|
+
});
|
|
2112
|
+
}
|
|
2113
|
+
return room;
|
|
2114
|
+
}
|
|
2115
|
+
};
|
|
2116
|
+
}
|
|
2117
|
+
get chat() {
|
|
2118
|
+
if (!this._chat) {
|
|
2119
|
+
this._chat = import_core34.Chat.createBaseChatObject({
|
|
2120
|
+
store: this.store
|
|
2121
|
+
});
|
|
2122
|
+
}
|
|
2123
|
+
return this._chat;
|
|
2124
|
+
}
|
|
2125
|
+
get pubSub() {
|
|
2126
|
+
if (!this._pubSub) {
|
|
2127
|
+
this._pubSub = import_core34.PubSub.createBasePubSubObject({
|
|
2128
|
+
store: this.store
|
|
2129
|
+
});
|
|
2130
|
+
}
|
|
2131
|
+
return this._pubSub;
|
|
2132
|
+
}
|
|
2133
|
+
get videoManager() {
|
|
2134
|
+
if (!this._videoManager) {
|
|
2135
|
+
this._videoManager = createVideoManagerObject(this.options);
|
|
2136
|
+
}
|
|
2137
|
+
return this._videoManager;
|
|
2138
|
+
}
|
|
2139
|
+
reauthenticate(token) {
|
|
2140
|
+
this.store.dispatch(import_core34.actions.reauthAction({ token }));
|
|
2141
|
+
}
|
|
2142
|
+
};
|
|
2143
|
+
|
|
1719
2144
|
// src/createClient.ts
|
|
1720
2145
|
var createClient = (userOptions) => {
|
|
1721
2146
|
const baseUserOptions = __spreadProps(__spreadValues({}, userOptions), {
|
|
1722
|
-
emitter: (0,
|
|
2147
|
+
emitter: (0, import_core35.getEventEmitter)()
|
|
1723
2148
|
});
|
|
1724
|
-
const store = (0,
|
|
2149
|
+
const store = (0, import_core35.configureStore)({
|
|
1725
2150
|
userOptions: baseUserOptions,
|
|
1726
2151
|
SessionConstructor: JWTSession
|
|
1727
2152
|
});
|
|
1728
|
-
const client = (0,
|
|
2153
|
+
const client = (0, import_core35.connect)({
|
|
1729
2154
|
store,
|
|
1730
2155
|
Component: ClientAPI
|
|
1731
2156
|
})(baseUserOptions);
|
|
1732
2157
|
return client;
|
|
1733
2158
|
};
|
|
1734
2159
|
|
|
2160
|
+
// src/chat/Client.ts
|
|
2161
|
+
var INTERCEPTED_METHODS = [
|
|
2162
|
+
"subscribe",
|
|
2163
|
+
"publish",
|
|
2164
|
+
"getMessages",
|
|
2165
|
+
"getMembers",
|
|
2166
|
+
"getMemberState",
|
|
2167
|
+
"getAllowedChannels",
|
|
2168
|
+
"setMemberState"
|
|
2169
|
+
];
|
|
2170
|
+
var Client2 = function(chatOptions) {
|
|
2171
|
+
const client = createClient(chatOptions);
|
|
2172
|
+
const createInterceptor = (prop) => {
|
|
2173
|
+
return (...params) => __async(this, null, function* () {
|
|
2174
|
+
yield client.connect();
|
|
2175
|
+
return client.chat[prop](...params);
|
|
2176
|
+
});
|
|
2177
|
+
};
|
|
2178
|
+
const interceptors = {
|
|
2179
|
+
_session: client,
|
|
2180
|
+
disconnect: () => client.disconnect()
|
|
2181
|
+
};
|
|
2182
|
+
return new Proxy(client.chat, {
|
|
2183
|
+
get(target, prop, receiver) {
|
|
2184
|
+
if (prop in interceptors) {
|
|
2185
|
+
return interceptors[prop];
|
|
2186
|
+
}
|
|
2187
|
+
if (INTERCEPTED_METHODS.includes(prop)) {
|
|
2188
|
+
return createInterceptor(prop);
|
|
2189
|
+
}
|
|
2190
|
+
return Reflect.get(target, prop, receiver);
|
|
2191
|
+
}
|
|
2192
|
+
});
|
|
2193
|
+
};
|
|
2194
|
+
|
|
2195
|
+
// src/chat/index.ts
|
|
2196
|
+
var import_core36 = require("@signalwire/core");
|
|
2197
|
+
|
|
2198
|
+
// src/pubSub/index.ts
|
|
2199
|
+
var pubSub_exports = {};
|
|
2200
|
+
__export(pubSub_exports, {
|
|
2201
|
+
Client: () => Client3,
|
|
2202
|
+
PubSubMessage: () => PubSubMessage
|
|
2203
|
+
});
|
|
2204
|
+
var import_core38 = require("@signalwire/core");
|
|
2205
|
+
|
|
2206
|
+
// src/utils/interfaces.ts
|
|
2207
|
+
var import_core37 = require("@signalwire/core");
|
|
2208
|
+
var INTERNAL_MEMBER_UPDATED_EVENTS = Object.keys(import_core37.INTERNAL_MEMBER_UPDATABLE_PROPS).map((key) => {
|
|
2209
|
+
return `member.updated.${key}`;
|
|
2210
|
+
});
|
|
2211
|
+
|
|
2212
|
+
// src/pubSub/Client.ts
|
|
2213
|
+
var INTERCEPTED_METHODS2 = [
|
|
2214
|
+
"getAllowedChannels",
|
|
2215
|
+
"subscribe",
|
|
2216
|
+
"publish"
|
|
2217
|
+
];
|
|
2218
|
+
var Client3 = function(pubSubOptions) {
|
|
2219
|
+
const client = createClient(pubSubOptions);
|
|
2220
|
+
const createInterceptor = (prop) => {
|
|
2221
|
+
return (...params) => __async(this, null, function* () {
|
|
2222
|
+
yield client.connect();
|
|
2223
|
+
return client.pubSub[prop](...params);
|
|
2224
|
+
});
|
|
2225
|
+
};
|
|
2226
|
+
const interceptors = {
|
|
2227
|
+
_session: client,
|
|
2228
|
+
disconnect: () => client.disconnect()
|
|
2229
|
+
};
|
|
2230
|
+
return new Proxy(client.pubSub, {
|
|
2231
|
+
get(target, prop, receiver) {
|
|
2232
|
+
if (prop in interceptors) {
|
|
2233
|
+
return interceptors[prop];
|
|
2234
|
+
}
|
|
2235
|
+
if (INTERCEPTED_METHODS2.includes(prop)) {
|
|
2236
|
+
return createInterceptor(prop);
|
|
2237
|
+
}
|
|
2238
|
+
return Reflect.get(target, prop, receiver);
|
|
2239
|
+
}
|
|
2240
|
+
});
|
|
2241
|
+
};
|
|
2242
|
+
|
|
2243
|
+
// src/pubSub/index.ts
|
|
2244
|
+
var PubSubMessage = import_core38.PubSub.PubSubMessage;
|
|
2245
|
+
|
|
2246
|
+
// src/fabric/index.ts
|
|
2247
|
+
var fabric_exports = {};
|
|
2248
|
+
__export(fabric_exports, {
|
|
2249
|
+
Client: () => Client4,
|
|
2250
|
+
ConversationAPI: () => ConversationAPI,
|
|
2251
|
+
HTTPClient: () => HTTPClient,
|
|
2252
|
+
IncomingCallManager: () => IncomingCallManager,
|
|
2253
|
+
SWClient: () => SWClient,
|
|
2254
|
+
SignalWire: () => SignalWire,
|
|
2255
|
+
WSClient: () => WSClient
|
|
2256
|
+
});
|
|
2257
|
+
|
|
2258
|
+
// src/fabric/createHttpClient.ts
|
|
2259
|
+
var import_core39 = require("@signalwire/core");
|
|
2260
|
+
function http(input, init) {
|
|
2261
|
+
return __async(this, null, function* () {
|
|
2262
|
+
const response = yield fetch(input, init);
|
|
2263
|
+
if (!response.ok) {
|
|
2264
|
+
if (response.status === 401) {
|
|
2265
|
+
throw new import_core39.AuthError(response.status, "Unauthorized");
|
|
2266
|
+
}
|
|
2267
|
+
let errorResponse;
|
|
2268
|
+
try {
|
|
2269
|
+
errorResponse = yield response.json();
|
|
2270
|
+
} catch (e) {
|
|
2271
|
+
}
|
|
2272
|
+
const errorMessage = (errorResponse == null ? void 0 : errorResponse.errors) ? JSON.stringify(errorResponse.errors) : "Not Found";
|
|
2273
|
+
throw new import_core39.HttpError(response.status, errorMessage, errorResponse);
|
|
2274
|
+
}
|
|
2275
|
+
try {
|
|
2276
|
+
response.parsedBody = yield response.json();
|
|
2277
|
+
} catch (e) {
|
|
2278
|
+
}
|
|
2279
|
+
return response;
|
|
2280
|
+
});
|
|
2281
|
+
}
|
|
2282
|
+
var createHttpClient = (_a, fetcher = http) => {
|
|
2283
|
+
var _b = _a, { baseUrl, timeout = 3e4 } = _b, globalOptions = __objRest(_b, ["baseUrl", "timeout"]);
|
|
2284
|
+
const apiClient = (path, options) => __async(void 0, null, function* () {
|
|
2285
|
+
const headers = __spreadValues(__spreadValues(__spreadValues({}, (options == null ? void 0 : options.body) ? { "Content-Type": "application/json" } : {}), globalOptions.headers), options == null ? void 0 : options.headers);
|
|
2286
|
+
const reqInit = getRequestInit(__spreadProps(__spreadValues(__spreadValues({}, globalOptions), options), {
|
|
2287
|
+
headers
|
|
2288
|
+
}));
|
|
2289
|
+
let timerId;
|
|
2290
|
+
if (timeout) {
|
|
2291
|
+
const controller = new AbortController();
|
|
2292
|
+
const signal = controller.signal;
|
|
2293
|
+
reqInit.signal = signal;
|
|
2294
|
+
timerId = setTimeout(() => {
|
|
2295
|
+
controller.abort();
|
|
2296
|
+
}, timeout);
|
|
2297
|
+
}
|
|
2298
|
+
try {
|
|
2299
|
+
const response = yield fetcher(getUrl({
|
|
2300
|
+
path,
|
|
2301
|
+
baseUrl,
|
|
2302
|
+
searchParams: options == null ? void 0 : options.searchParams
|
|
2303
|
+
}), reqInit);
|
|
2304
|
+
return { body: response.parsedBody };
|
|
2305
|
+
} catch (e) {
|
|
2306
|
+
throw e;
|
|
2307
|
+
} finally {
|
|
2308
|
+
timerId && clearTimeout(timerId);
|
|
2309
|
+
}
|
|
2310
|
+
});
|
|
2311
|
+
return apiClient;
|
|
2312
|
+
};
|
|
2313
|
+
var getBody = (body) => {
|
|
2314
|
+
return typeof body === "string" ? body : JSON.stringify(body);
|
|
2315
|
+
};
|
|
2316
|
+
var getRequestInit = (options) => {
|
|
2317
|
+
return Object.entries(options).reduce((reducer, [key, value]) => {
|
|
2318
|
+
if (key === "body") {
|
|
2319
|
+
return __spreadProps(__spreadValues({}, reducer), {
|
|
2320
|
+
body: getBody(value)
|
|
2321
|
+
});
|
|
2322
|
+
} else if (value != void 0) {
|
|
2323
|
+
return __spreadProps(__spreadValues({}, reducer), {
|
|
2324
|
+
[key]: value
|
|
2325
|
+
});
|
|
2326
|
+
}
|
|
2327
|
+
return reducer;
|
|
2328
|
+
}, {});
|
|
2329
|
+
};
|
|
2330
|
+
var getUrl = ({
|
|
2331
|
+
path,
|
|
2332
|
+
baseUrl,
|
|
2333
|
+
searchParams
|
|
2334
|
+
}) => {
|
|
2335
|
+
const url = new URL(path, baseUrl);
|
|
2336
|
+
if (searchParams) {
|
|
2337
|
+
Object.entries(searchParams).forEach(([key, value]) => {
|
|
2338
|
+
if (value != void 0) {
|
|
2339
|
+
url.searchParams.append(key, value);
|
|
2340
|
+
}
|
|
2341
|
+
});
|
|
2342
|
+
}
|
|
2343
|
+
return url.toString();
|
|
2344
|
+
};
|
|
2345
|
+
|
|
2346
|
+
// src/video.ts
|
|
2347
|
+
var video_exports = {};
|
|
2348
|
+
__export(video_exports, {
|
|
2349
|
+
RoomSession: () => RoomSession,
|
|
2350
|
+
createClient: () => createClient,
|
|
2351
|
+
createRoomObject: () => createRoomObject,
|
|
2352
|
+
joinRoom: () => joinRoom
|
|
2353
|
+
});
|
|
2354
|
+
|
|
1735
2355
|
// src/createRoomObject.ts
|
|
2356
|
+
var import_core40 = require("@signalwire/core");
|
|
1736
2357
|
var VIDEO_CONSTRAINTS = {
|
|
1737
2358
|
aspectRatio: { ideal: 16 / 9 }
|
|
1738
2359
|
};
|
|
@@ -1771,7 +2392,7 @@ var createRoomObject = (roomOptions) => {
|
|
|
1771
2392
|
rootElement = el;
|
|
1772
2393
|
} else {
|
|
1773
2394
|
rootElement = document.body;
|
|
1774
|
-
(0,
|
|
2395
|
+
(0, import_core40.getLogger)().warn(`We couldn't find an element with id: ${rootElementId}: using 'document.body' instead.`);
|
|
1775
2396
|
}
|
|
1776
2397
|
}
|
|
1777
2398
|
const roomObject = client.rooms.makeRoomObject({
|
|
@@ -1798,7 +2419,7 @@ var createRoomObject = (roomOptions) => {
|
|
|
1798
2419
|
});
|
|
1799
2420
|
yield roomObject.join();
|
|
1800
2421
|
} catch (error) {
|
|
1801
|
-
(0,
|
|
2422
|
+
(0, import_core40.getLogger)().error("Join", error);
|
|
1802
2423
|
client.disconnect();
|
|
1803
2424
|
reject2(error);
|
|
1804
2425
|
}
|
|
@@ -1833,10 +2454,10 @@ var joinRoom = (roomOptions) => {
|
|
|
1833
2454
|
};
|
|
1834
2455
|
|
|
1835
2456
|
// src/RoomSession.ts
|
|
1836
|
-
var
|
|
2457
|
+
var import_core42 = require("@signalwire/core");
|
|
1837
2458
|
|
|
1838
2459
|
// src/utils/roomSession.ts
|
|
1839
|
-
var
|
|
2460
|
+
var import_core41 = require("@signalwire/core");
|
|
1840
2461
|
var getJoinMediaParams = (options) => {
|
|
1841
2462
|
const {
|
|
1842
2463
|
authState,
|
|
@@ -1847,7 +2468,7 @@ var getJoinMediaParams = (options) => {
|
|
|
1847
2468
|
receiveAudio,
|
|
1848
2469
|
receiveVideo
|
|
1849
2470
|
} = options;
|
|
1850
|
-
(0,
|
|
2471
|
+
(0, import_core41.getLogger)().debug("getJoinMediaParams options", __spreadValues({}, options));
|
|
1851
2472
|
const { audio_allowed, video_allowed, join_as } = authState;
|
|
1852
2473
|
const joinAs = join_as != null ? join_as : "member";
|
|
1853
2474
|
const canSend = joinAs === "member";
|
|
@@ -1860,16 +2481,16 @@ var getJoinMediaParams = (options) => {
|
|
|
1860
2481
|
const reqToReceiveAudio = Boolean(receiveAudio != null ? receiveAudio : audio);
|
|
1861
2482
|
const reqToReceiveVideo = Boolean(receiveVideo != null ? receiveVideo : video);
|
|
1862
2483
|
if (!canSendAudio && reqToSendAudio) {
|
|
1863
|
-
(0,
|
|
2484
|
+
(0, import_core41.getLogger)().info("Not allowed to send audio on this room. Default values will be used.");
|
|
1864
2485
|
}
|
|
1865
2486
|
if (!canSendVideo && reqToSendVideo) {
|
|
1866
|
-
(0,
|
|
2487
|
+
(0, import_core41.getLogger)().info("Not allowed to send video on this room. Default values will be used.");
|
|
1867
2488
|
}
|
|
1868
2489
|
if (!canReceiveAudio && reqToReceiveAudio) {
|
|
1869
|
-
(0,
|
|
2490
|
+
(0, import_core41.getLogger)().info("Not allowed to receive video from the room. Default values will be used.");
|
|
1870
2491
|
}
|
|
1871
2492
|
if (!canReceiveVideo && reqToReceiveVideo) {
|
|
1872
|
-
(0,
|
|
2493
|
+
(0, import_core41.getLogger)().info("Not allowed to receive video from the room. Default values will be used.");
|
|
1873
2494
|
}
|
|
1874
2495
|
return {
|
|
1875
2496
|
mustSendAudio: canSendAudio && reqToSendAudio,
|
|
@@ -1964,7 +2585,7 @@ var RoomSession = function(roomOptions) {
|
|
|
1964
2585
|
const deprecatedParams = ["audio", "video"];
|
|
1965
2586
|
deprecatedParams.forEach((param) => {
|
|
1966
2587
|
if (param in roomOptions) {
|
|
1967
|
-
(0,
|
|
2588
|
+
(0, import_core42.getLogger)().warn(`The '${param}' parameter on the RoomSession constructor is deprecated. Set it on the '.join()' function instead.`);
|
|
1968
2589
|
}
|
|
1969
2590
|
});
|
|
1970
2591
|
const allowReattach = (roomOptions == null ? void 0 : roomOptions.reattach) !== false;
|
|
@@ -2035,7 +2656,7 @@ var RoomSession = function(roomOptions) {
|
|
|
2035
2656
|
const audio = (_a2 = params == null ? void 0 : params.audio) != null ? _a2 : audioFromConstructor;
|
|
2036
2657
|
const video = (_b = params == null ? void 0 : params.video) != null ? _b : videoFromConstructor;
|
|
2037
2658
|
const authState = client._sessionAuthState;
|
|
2038
|
-
(0,
|
|
2659
|
+
(0, import_core42.getLogger)().debug("getJoinMediaParams authState?", authState);
|
|
2039
2660
|
if (authState && authState.type === "video") {
|
|
2040
2661
|
const mediaOptions = getJoinMediaParams(__spreadValues({
|
|
2041
2662
|
authState,
|
|
@@ -2048,7 +2669,7 @@ var RoomSession = function(roomOptions) {
|
|
|
2048
2669
|
${JSON.stringify(params, null, 2)}
|
|
2049
2670
|
`));
|
|
2050
2671
|
}
|
|
2051
|
-
(0,
|
|
2672
|
+
(0, import_core42.getLogger)().debug("Set mediaOptions", mediaOptions);
|
|
2052
2673
|
room.updateMediaOptions({
|
|
2053
2674
|
audio: mediaOptions.mustSendAudio ? audio || true : false,
|
|
2054
2675
|
video: mediaOptions.mustSendVideo ? video || true : false,
|
|
@@ -2063,7 +2684,7 @@ ${JSON.stringify(params, null, 2)}
|
|
|
2063
2684
|
REQUIRED_EVENTS.forEach((event) => room.once(event, noop2));
|
|
2064
2685
|
yield room.join();
|
|
2065
2686
|
} catch (error) {
|
|
2066
|
-
(0,
|
|
2687
|
+
(0, import_core42.getLogger)().error("RoomSession Join", error);
|
|
2067
2688
|
client.disconnect();
|
|
2068
2689
|
reject(error);
|
|
2069
2690
|
}
|
|
@@ -2128,7 +2749,7 @@ var buildCall = ({
|
|
|
2128
2749
|
};
|
|
2129
2750
|
|
|
2130
2751
|
// src/fabric/Client.ts
|
|
2131
|
-
var
|
|
2752
|
+
var Client4 = class {
|
|
2132
2753
|
constructor(options) {
|
|
2133
2754
|
this.options = options;
|
|
2134
2755
|
__publicField(this, "httpClient");
|
|
@@ -2255,48 +2876,95 @@ var SWClient = class {
|
|
|
2255
2876
|
};
|
|
2256
2877
|
|
|
2257
2878
|
// src/fabric/WSClient.ts
|
|
2258
|
-
var
|
|
2259
|
-
|
|
2260
|
-
// src/fabric/
|
|
2261
|
-
var
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
}
|
|
2279
|
-
|
|
2280
|
-
|
|
2879
|
+
var import_core43 = require("@signalwire/core");
|
|
2880
|
+
|
|
2881
|
+
// src/fabric/IncomingCallManager.ts
|
|
2882
|
+
var IncomingCallManager = class {
|
|
2883
|
+
constructor(_buildCallObject, _executeReject) {
|
|
2884
|
+
this._buildCallObject = _buildCallObject;
|
|
2885
|
+
this._executeReject = _executeReject;
|
|
2886
|
+
__publicField(this, "_pendingInvites", {});
|
|
2887
|
+
__publicField(this, "_handlers", {});
|
|
2888
|
+
}
|
|
2889
|
+
_buildNotification(invite) {
|
|
2890
|
+
const accept = (params) => __async(this, null, function* () {
|
|
2891
|
+
return new Promise((resolve, reject2) => {
|
|
2892
|
+
delete this._pendingInvites[invite.callID];
|
|
2893
|
+
try {
|
|
2894
|
+
const call = this._buildCallObject(invite, params);
|
|
2895
|
+
call.answer();
|
|
2896
|
+
resolve(call);
|
|
2897
|
+
} catch (e) {
|
|
2898
|
+
reject2(e);
|
|
2899
|
+
}
|
|
2900
|
+
});
|
|
2901
|
+
});
|
|
2902
|
+
const reject = () => {
|
|
2903
|
+
delete this._pendingInvites[invite.callID];
|
|
2904
|
+
return this._executeReject(invite.callID, invite.nodeId);
|
|
2905
|
+
};
|
|
2906
|
+
return {
|
|
2907
|
+
invite: {
|
|
2908
|
+
details: invite,
|
|
2909
|
+
accept: (params) => accept(params),
|
|
2910
|
+
reject: () => reject()
|
|
2911
|
+
}
|
|
2912
|
+
};
|
|
2913
|
+
}
|
|
2914
|
+
setNotificationHandlers(handlers) {
|
|
2915
|
+
this._handlers.all = handlers.all;
|
|
2916
|
+
if (handlers.pushNotification && this._handlers.all != handlers.pushNotification || !handlers.pushNotification) {
|
|
2917
|
+
this._handlers.pushNotification = handlers.pushNotification;
|
|
2918
|
+
}
|
|
2919
|
+
if (handlers.websocket && this._handlers.all != handlers.websocket || !handlers.websocket) {
|
|
2920
|
+
this._handlers.websocket = handlers.websocket;
|
|
2921
|
+
}
|
|
2922
|
+
}
|
|
2923
|
+
handleIncomingInvite(incomingInvite) {
|
|
2924
|
+
var _a, _b;
|
|
2925
|
+
if (incomingInvite.callID in this._pendingInvites) {
|
|
2926
|
+
console.log(`skiping nottification for pending invite to callID: ${incomingInvite.callID}`);
|
|
2927
|
+
return;
|
|
2928
|
+
}
|
|
2929
|
+
this._pendingInvites[incomingInvite.callID] = incomingInvite;
|
|
2930
|
+
if (!(this._handlers.all || this._handlers[incomingInvite.source])) {
|
|
2931
|
+
console.log("skiping nottification no listeners:");
|
|
2932
|
+
return;
|
|
2933
|
+
}
|
|
2934
|
+
const notification = this._buildNotification(incomingInvite);
|
|
2935
|
+
(_b = (_a = this._handlers).all) == null ? void 0 : _b.call(_a, notification);
|
|
2936
|
+
const handler = this._handlers[incomingInvite.source];
|
|
2937
|
+
handler == null ? void 0 : handler(notification);
|
|
2938
|
+
}
|
|
2939
|
+
};
|
|
2940
|
+
|
|
2941
|
+
// src/fabric/WSClient.ts
|
|
2281
2942
|
var WSClient = class {
|
|
2282
2943
|
constructor(options) {
|
|
2283
2944
|
this.options = options;
|
|
2284
2945
|
__publicField(this, "wsClient");
|
|
2285
|
-
__publicField(this, "logger", (0,
|
|
2286
|
-
this
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2946
|
+
__publicField(this, "logger", (0, import_core43.getLogger)());
|
|
2947
|
+
__publicField(this, "_incomingCallManager");
|
|
2948
|
+
this.wsClient = createClient(__spreadProps(__spreadValues({}, this.options), {
|
|
2949
|
+
unifiedEventing: true
|
|
2950
|
+
}));
|
|
2951
|
+
this._incomingCallManager = new IncomingCallManager((payload, params) => this.buildInboundCall(payload, params), (callId, nodeId) => this.executeVertoBye(callId, nodeId));
|
|
2952
|
+
}
|
|
2953
|
+
get clientApi() {
|
|
2954
|
+
return this.wsClient;
|
|
2294
2955
|
}
|
|
2295
2956
|
connect() {
|
|
2296
|
-
this
|
|
2297
|
-
|
|
2957
|
+
return __async(this, null, function* () {
|
|
2958
|
+
if (!this.wsClient.connected) {
|
|
2959
|
+
this.wsClient.runWorker("wsClientWorker", {
|
|
2960
|
+
worker: wsClientWorker,
|
|
2961
|
+
initialState: {
|
|
2962
|
+
buildInboundCall: (incomingInvite) => this.notifyIncomingInvite("websocket", incomingInvite)
|
|
2963
|
+
}
|
|
2964
|
+
});
|
|
2965
|
+
yield this.wsClient.connect();
|
|
2966
|
+
}
|
|
2298
2967
|
});
|
|
2299
|
-
return this.wsClient.connect();
|
|
2300
2968
|
}
|
|
2301
2969
|
disconnect() {
|
|
2302
2970
|
return this.wsClient.disconnect();
|
|
@@ -2304,20 +2972,23 @@ var WSClient = class {
|
|
|
2304
2972
|
dial(params) {
|
|
2305
2973
|
return __async(this, null, function* () {
|
|
2306
2974
|
return new Promise((resolve, reject) => __async(this, null, function* () {
|
|
2975
|
+
var _a, _b;
|
|
2307
2976
|
try {
|
|
2308
|
-
console.log("WSClient dial with:", params);
|
|
2309
2977
|
yield this.connect();
|
|
2310
2978
|
const call = this.wsClient.rooms.makeRoomObject({
|
|
2979
|
+
audio: (_a = params.audio) != null ? _a : true,
|
|
2980
|
+
video: (_b = params.video) != null ? _b : true,
|
|
2311
2981
|
negotiateAudio: true,
|
|
2312
2982
|
negotiateVideo: true,
|
|
2313
|
-
rootElement:
|
|
2983
|
+
rootElement: params.rootElement,
|
|
2314
2984
|
applyLocalVideoOverlay: true,
|
|
2315
2985
|
stopCameraWhileMuted: true,
|
|
2316
2986
|
stopMicrophoneWhileMuted: true,
|
|
2317
2987
|
destinationNumber: params.to,
|
|
2318
2988
|
watchMediaPackets: false,
|
|
2319
2989
|
nodeId: params.nodeId,
|
|
2320
|
-
disableUdpIceServers:
|
|
2990
|
+
disableUdpIceServers: params.disableUdpIceServers || false,
|
|
2991
|
+
unifiedEventing: true
|
|
2321
2992
|
});
|
|
2322
2993
|
call.once("destroy", () => {
|
|
2323
2994
|
this.logger.debug("RTC Connection Destroyed");
|
|
@@ -2329,18 +3000,17 @@ var WSClient = class {
|
|
|
2329
3000
|
call.start = () => {
|
|
2330
3001
|
return new Promise((resolve2, reject2) => __async(this, null, function* () {
|
|
2331
3002
|
try {
|
|
2332
|
-
call.once("verto.display", () => resolve2(call));
|
|
2333
3003
|
call.once("room.subscribed", () => resolve2(call));
|
|
2334
3004
|
yield call.join();
|
|
2335
3005
|
} catch (error) {
|
|
2336
|
-
(0,
|
|
3006
|
+
(0, import_core43.getLogger)().error("WSClient call start", error);
|
|
2337
3007
|
reject2(error);
|
|
2338
3008
|
}
|
|
2339
3009
|
}));
|
|
2340
3010
|
};
|
|
2341
3011
|
resolve(call);
|
|
2342
3012
|
} catch (error) {
|
|
2343
|
-
(0,
|
|
3013
|
+
(0, import_core43.getLogger)().error("WSClient dial", error);
|
|
2344
3014
|
reject(error);
|
|
2345
3015
|
}
|
|
2346
3016
|
}));
|
|
@@ -2366,15 +3036,6 @@ var WSClient = class {
|
|
|
2366
3036
|
display_direction
|
|
2367
3037
|
}
|
|
2368
3038
|
} = jsonrpc;
|
|
2369
|
-
this.logger.debug("handlePushNotification data", {
|
|
2370
|
-
callID,
|
|
2371
|
-
sdp,
|
|
2372
|
-
caller_id_name,
|
|
2373
|
-
caller_id_number,
|
|
2374
|
-
callee_id_name,
|
|
2375
|
-
callee_id_number,
|
|
2376
|
-
display_direction
|
|
2377
|
-
});
|
|
2378
3039
|
try {
|
|
2379
3040
|
yield this.connect();
|
|
2380
3041
|
try {
|
|
@@ -2382,29 +3043,48 @@ var WSClient = class {
|
|
|
2382
3043
|
} catch (error) {
|
|
2383
3044
|
this.logger.warn("Verto Subscribe", error);
|
|
2384
3045
|
}
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
remoteSdp: sdp,
|
|
2394
|
-
prevCallId: callID,
|
|
3046
|
+
this.notifyIncomingInvite("pushNotification", {
|
|
3047
|
+
callID,
|
|
3048
|
+
sdp,
|
|
3049
|
+
caller_id_name,
|
|
3050
|
+
caller_id_number,
|
|
3051
|
+
callee_id_name,
|
|
3052
|
+
callee_id_number,
|
|
3053
|
+
display_direction,
|
|
2395
3054
|
nodeId
|
|
2396
3055
|
});
|
|
2397
|
-
|
|
2398
|
-
(0, import_core27.getLogger)().debug("RTC Connection Destroyed");
|
|
2399
|
-
});
|
|
2400
|
-
call.attachPreConnectWorkers();
|
|
2401
|
-
(0, import_core27.getLogger)().debug("Resolving Call", call);
|
|
2402
|
-
resolve({ resultType: "inboundCall", resultObject: call });
|
|
3056
|
+
resolve({ resultType: "inboundCall" });
|
|
2403
3057
|
} catch (error) {
|
|
2404
3058
|
reject(error);
|
|
2405
3059
|
}
|
|
2406
3060
|
}));
|
|
2407
3061
|
}
|
|
3062
|
+
notifyIncomingInvite(source, buildCallParams) {
|
|
3063
|
+
this._incomingCallManager.handleIncomingInvite(__spreadValues({
|
|
3064
|
+
source
|
|
3065
|
+
}, buildCallParams));
|
|
3066
|
+
}
|
|
3067
|
+
executeVertoBye(callId, nodeId) {
|
|
3068
|
+
return __async(this, null, function* () {
|
|
3069
|
+
try {
|
|
3070
|
+
return yield this.wsClient.execute({
|
|
3071
|
+
method: "webrtc.verto",
|
|
3072
|
+
params: {
|
|
3073
|
+
callID: callId,
|
|
3074
|
+
node_id: nodeId,
|
|
3075
|
+
message: (0, import_core43.VertoBye)({
|
|
3076
|
+
cause: "USER_BUSY",
|
|
3077
|
+
causeCode: "17",
|
|
3078
|
+
dialogParams: { callID: callId }
|
|
3079
|
+
})
|
|
3080
|
+
}
|
|
3081
|
+
});
|
|
3082
|
+
} catch (error) {
|
|
3083
|
+
this.logger.warn("The call is not available anymore", callId);
|
|
3084
|
+
throw error;
|
|
3085
|
+
}
|
|
3086
|
+
});
|
|
3087
|
+
}
|
|
2408
3088
|
executeVertoSubscribe(callId, nodeId) {
|
|
2409
3089
|
return __async(this, null, function* () {
|
|
2410
3090
|
try {
|
|
@@ -2414,7 +3094,7 @@ var WSClient = class {
|
|
|
2414
3094
|
callID: callId,
|
|
2415
3095
|
node_id: nodeId,
|
|
2416
3096
|
subscribe: [],
|
|
2417
|
-
message: (0,
|
|
3097
|
+
message: (0, import_core43.VertoSubscribe)({
|
|
2418
3098
|
sessid: callId,
|
|
2419
3099
|
eventChannel: []
|
|
2420
3100
|
})
|
|
@@ -2426,6 +3106,33 @@ var WSClient = class {
|
|
|
2426
3106
|
}
|
|
2427
3107
|
});
|
|
2428
3108
|
}
|
|
3109
|
+
buildInboundCall(payload, params) {
|
|
3110
|
+
var _a, _b;
|
|
3111
|
+
(0, import_core43.getLogger)().debug("Build new call to answer");
|
|
3112
|
+
const { callID, nodeId, sdp } = payload;
|
|
3113
|
+
const call = this.wsClient.rooms.makeRoomObject({
|
|
3114
|
+
audio: (_a = params.audio) != null ? _a : true,
|
|
3115
|
+
video: (_b = params.video) != null ? _b : true,
|
|
3116
|
+
negotiateAudio: true,
|
|
3117
|
+
negotiateVideo: true,
|
|
3118
|
+
rootElement: params.rootElement,
|
|
3119
|
+
applyLocalVideoOverlay: true,
|
|
3120
|
+
stopCameraWhileMuted: true,
|
|
3121
|
+
stopMicrophoneWhileMuted: true,
|
|
3122
|
+
watchMediaPackets: false,
|
|
3123
|
+
remoteSdp: sdp,
|
|
3124
|
+
prevCallId: callID,
|
|
3125
|
+
nodeId,
|
|
3126
|
+
disableUdpIceServers: params.disableUdpIceServers || false,
|
|
3127
|
+
unifiedEventing: true
|
|
3128
|
+
});
|
|
3129
|
+
call.once("destroy", () => {
|
|
3130
|
+
(0, import_core43.getLogger)().debug("RTC Connection Destroyed");
|
|
3131
|
+
});
|
|
3132
|
+
call.attachPreConnectWorkers();
|
|
3133
|
+
(0, import_core43.getLogger)().debug("Resolving Call", call);
|
|
3134
|
+
return call;
|
|
3135
|
+
}
|
|
2429
3136
|
updateToken(token) {
|
|
2430
3137
|
return new Promise((resolve, reject) => {
|
|
2431
3138
|
this.wsClient.once("session.auth_error", (error) => {
|
|
@@ -2437,11 +3144,65 @@ var WSClient = class {
|
|
|
2437
3144
|
this.wsClient.reauthenticate(token);
|
|
2438
3145
|
});
|
|
2439
3146
|
}
|
|
3147
|
+
online(_0) {
|
|
3148
|
+
return __async(this, arguments, function* ({ incomingCallHandlers }) {
|
|
3149
|
+
this._incomingCallManager.setNotificationHandlers(incomingCallHandlers);
|
|
3150
|
+
yield this.connect();
|
|
3151
|
+
return this.wsClient.execute({
|
|
3152
|
+
method: "subscriber.online",
|
|
3153
|
+
params: {}
|
|
3154
|
+
});
|
|
3155
|
+
});
|
|
3156
|
+
}
|
|
3157
|
+
offline() {
|
|
3158
|
+
this._incomingCallManager.setNotificationHandlers({});
|
|
3159
|
+
return this.wsClient.execute({
|
|
3160
|
+
method: "subscriber.offline",
|
|
3161
|
+
params: {}
|
|
3162
|
+
});
|
|
3163
|
+
}
|
|
2440
3164
|
};
|
|
2441
3165
|
|
|
2442
3166
|
// src/fabric/HTTPClient.ts
|
|
2443
|
-
var import_core28 = require("@signalwire/core");
|
|
2444
3167
|
var import_jwt_decode3 = __toESM(require("jwt-decode"));
|
|
3168
|
+
var import_core44 = require("@signalwire/core");
|
|
3169
|
+
|
|
3170
|
+
// src/utils/paginatedResult.ts
|
|
3171
|
+
function buildPaginatedResult(body, client) {
|
|
3172
|
+
const anotherPage = (url) => __async(this, null, function* () {
|
|
3173
|
+
const { body: body2 } = yield client(url);
|
|
3174
|
+
return buildPaginatedResult(body2, client);
|
|
3175
|
+
});
|
|
3176
|
+
return {
|
|
3177
|
+
data: body.data,
|
|
3178
|
+
self: () => __async(this, null, function* () {
|
|
3179
|
+
const { self } = body.links;
|
|
3180
|
+
return self ? anotherPage(self) : void 0;
|
|
3181
|
+
}),
|
|
3182
|
+
nextPage: () => __async(this, null, function* () {
|
|
3183
|
+
const { next } = body.links;
|
|
3184
|
+
return next ? anotherPage(next) : void 0;
|
|
3185
|
+
}),
|
|
3186
|
+
prevPage: () => __async(this, null, function* () {
|
|
3187
|
+
const { prev } = body.links;
|
|
3188
|
+
return prev ? anotherPage(prev) : void 0;
|
|
3189
|
+
}),
|
|
3190
|
+
firstPage: () => __async(this, null, function* () {
|
|
3191
|
+
const { first } = body.links;
|
|
3192
|
+
return first ? anotherPage(first) : void 0;
|
|
3193
|
+
}),
|
|
3194
|
+
hasNext: Boolean(body.links.next),
|
|
3195
|
+
hasPrev: Boolean(body.links.prev)
|
|
3196
|
+
};
|
|
3197
|
+
}
|
|
3198
|
+
|
|
3199
|
+
// src/utils/makeQueryParamsUrl.ts
|
|
3200
|
+
function makeQueryParamsUrls(path, queryParams) {
|
|
3201
|
+
const queryString = queryParams.toString();
|
|
3202
|
+
return queryString ? `${path}?${queryString}` : path;
|
|
3203
|
+
}
|
|
3204
|
+
|
|
3205
|
+
// src/fabric/HTTPClient.ts
|
|
2445
3206
|
var HTTPClient = class {
|
|
2446
3207
|
constructor(options) {
|
|
2447
3208
|
this.options = options;
|
|
@@ -2453,6 +3214,9 @@ var HTTPClient = class {
|
|
|
2453
3214
|
}
|
|
2454
3215
|
});
|
|
2455
3216
|
}
|
|
3217
|
+
get fetch() {
|
|
3218
|
+
return this.httpClient;
|
|
3219
|
+
}
|
|
2456
3220
|
get httpHost() {
|
|
2457
3221
|
let decodedJwt = {};
|
|
2458
3222
|
try {
|
|
@@ -2461,7 +3225,7 @@ var HTTPClient = class {
|
|
|
2461
3225
|
});
|
|
2462
3226
|
} catch (e) {
|
|
2463
3227
|
if (process.env.NODE_ENV !== "production") {
|
|
2464
|
-
(0,
|
|
3228
|
+
(0, import_core44.getLogger)().debug("[JWTSession] error decoding the JWT");
|
|
2465
3229
|
}
|
|
2466
3230
|
}
|
|
2467
3231
|
const host = this.options.host || (decodedJwt == null ? void 0 : decodedJwt.ch);
|
|
@@ -2470,45 +3234,30 @@ var HTTPClient = class {
|
|
|
2470
3234
|
}
|
|
2471
3235
|
return `fabric.${host.split(".").splice(1).join(".")}`;
|
|
2472
3236
|
}
|
|
3237
|
+
getAddress(options) {
|
|
3238
|
+
return __async(this, null, function* () {
|
|
3239
|
+
const { id } = options;
|
|
3240
|
+
let path = `/api/fabric/addresses/${id}`;
|
|
3241
|
+
const { body } = yield this.httpClient(path);
|
|
3242
|
+
return body;
|
|
3243
|
+
});
|
|
3244
|
+
}
|
|
2473
3245
|
getAddresses(options) {
|
|
2474
3246
|
return __async(this, null, function* () {
|
|
2475
|
-
const { type, displayName } = options || {};
|
|
2476
|
-
let path = "/addresses";
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
queryParams.append("type", type);
|
|
2481
|
-
}
|
|
2482
|
-
if (displayName) {
|
|
2483
|
-
queryParams.append("display_name", displayName);
|
|
2484
|
-
}
|
|
2485
|
-
path += `?${queryParams.toString()}`;
|
|
3247
|
+
const { type, displayName, pageSize } = options || {};
|
|
3248
|
+
let path = "/api/fabric/addresses";
|
|
3249
|
+
const queryParams = new URLSearchParams();
|
|
3250
|
+
if (type) {
|
|
3251
|
+
queryParams.append("type", type);
|
|
2486
3252
|
}
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
nextPage: () => __async(this, null, function* () {
|
|
2496
|
-
const { next } = body2.links;
|
|
2497
|
-
return next ? anotherPage(next) : void 0;
|
|
2498
|
-
}),
|
|
2499
|
-
prevPage: () => __async(this, null, function* () {
|
|
2500
|
-
const { prev } = body2.links;
|
|
2501
|
-
return prev ? anotherPage(prev) : void 0;
|
|
2502
|
-
}),
|
|
2503
|
-
firstPage: () => __async(this, null, function* () {
|
|
2504
|
-
const { first } = body2.links;
|
|
2505
|
-
return first ? anotherPage(first) : void 0;
|
|
2506
|
-
}),
|
|
2507
|
-
hasNext: Boolean(body2.links.next),
|
|
2508
|
-
hasPrev: Boolean(body2.links.prev)
|
|
2509
|
-
};
|
|
2510
|
-
};
|
|
2511
|
-
return buildResult(body);
|
|
3253
|
+
if (displayName) {
|
|
3254
|
+
queryParams.append("display_name", displayName);
|
|
3255
|
+
}
|
|
3256
|
+
if (pageSize) {
|
|
3257
|
+
queryParams.append("page_size", pageSize.toString());
|
|
3258
|
+
}
|
|
3259
|
+
const { body } = yield this.httpClient(makeQueryParamsUrls(path, queryParams));
|
|
3260
|
+
return buildPaginatedResult(body, this.httpClient);
|
|
2512
3261
|
});
|
|
2513
3262
|
}
|
|
2514
3263
|
registerDevice(_0) {
|
|
@@ -2535,6 +3284,143 @@ var HTTPClient = class {
|
|
|
2535
3284
|
});
|
|
2536
3285
|
});
|
|
2537
3286
|
}
|
|
3287
|
+
getSubscriberInfo() {
|
|
3288
|
+
return __async(this, null, function* () {
|
|
3289
|
+
let path = "/api/fabric/subscriber/info";
|
|
3290
|
+
const { body } = yield this.httpClient(path);
|
|
3291
|
+
return body;
|
|
3292
|
+
});
|
|
3293
|
+
}
|
|
3294
|
+
};
|
|
3295
|
+
|
|
3296
|
+
// src/fabric/ConversationAPI.ts
|
|
3297
|
+
var ConversationAPI = class {
|
|
3298
|
+
constructor(conversation, data) {
|
|
3299
|
+
this.conversation = conversation;
|
|
3300
|
+
this.data = data;
|
|
3301
|
+
}
|
|
3302
|
+
get id() {
|
|
3303
|
+
return this.data.id;
|
|
3304
|
+
}
|
|
3305
|
+
get created_at() {
|
|
3306
|
+
return this.data.created_at;
|
|
3307
|
+
}
|
|
3308
|
+
get last_message_at() {
|
|
3309
|
+
return this.data.last_message_at;
|
|
3310
|
+
}
|
|
3311
|
+
get metadata() {
|
|
3312
|
+
return this.data.metadata;
|
|
3313
|
+
}
|
|
3314
|
+
get name() {
|
|
3315
|
+
return this.data.name;
|
|
3316
|
+
}
|
|
3317
|
+
sendMessage(options) {
|
|
3318
|
+
return this.conversation.sendMessage({
|
|
3319
|
+
addressId: this.id,
|
|
3320
|
+
text: options.text
|
|
3321
|
+
});
|
|
3322
|
+
}
|
|
3323
|
+
getMessages(options) {
|
|
3324
|
+
return this.conversation.getConversationMessages(__spreadValues({ addressId: this.id }, options));
|
|
3325
|
+
}
|
|
3326
|
+
};
|
|
3327
|
+
|
|
3328
|
+
// src/fabric/Conversation.ts
|
|
3329
|
+
var Conversation = class {
|
|
3330
|
+
constructor(options) {
|
|
3331
|
+
__publicField(this, "httpClient");
|
|
3332
|
+
__publicField(this, "wsClient");
|
|
3333
|
+
__publicField(this, "callbacks", []);
|
|
3334
|
+
this.httpClient = options.httpClient;
|
|
3335
|
+
this.wsClient = options.wsClient;
|
|
3336
|
+
this.wsClient.clientApi.runWorker("conversationWorker", {
|
|
3337
|
+
worker: conversationWorker,
|
|
3338
|
+
initialState: {
|
|
3339
|
+
conversation: this
|
|
3340
|
+
}
|
|
3341
|
+
});
|
|
3342
|
+
}
|
|
3343
|
+
sendMessage(options) {
|
|
3344
|
+
return __async(this, null, function* () {
|
|
3345
|
+
try {
|
|
3346
|
+
const { addressId, text } = options;
|
|
3347
|
+
const path = "/api/fabric/messages";
|
|
3348
|
+
const { body } = yield this.httpClient.fetch(path, {
|
|
3349
|
+
method: "POST",
|
|
3350
|
+
body: {
|
|
3351
|
+
conversation_id: addressId,
|
|
3352
|
+
text
|
|
3353
|
+
}
|
|
3354
|
+
});
|
|
3355
|
+
return body;
|
|
3356
|
+
} catch (error) {
|
|
3357
|
+
throw new Error("Error sending message to conversation!", error);
|
|
3358
|
+
}
|
|
3359
|
+
});
|
|
3360
|
+
}
|
|
3361
|
+
getConversations(options) {
|
|
3362
|
+
return __async(this, null, function* () {
|
|
3363
|
+
try {
|
|
3364
|
+
const { pageSize } = options || {};
|
|
3365
|
+
const path = "/api/fabric/conversations";
|
|
3366
|
+
const queryParams = new URLSearchParams();
|
|
3367
|
+
if (pageSize) {
|
|
3368
|
+
queryParams.append("page_size", pageSize.toString());
|
|
3369
|
+
}
|
|
3370
|
+
const { body } = yield this.httpClient.fetch(makeQueryParamsUrls(path, queryParams));
|
|
3371
|
+
const self = this;
|
|
3372
|
+
const data = body.data.map((conversation) => new ConversationAPI(self, conversation));
|
|
3373
|
+
return buildPaginatedResult(__spreadProps(__spreadValues({}, body), { data }), this.httpClient.fetch);
|
|
3374
|
+
} catch (error) {
|
|
3375
|
+
throw new Error("Error fetching the conversation history!", error);
|
|
3376
|
+
}
|
|
3377
|
+
});
|
|
3378
|
+
}
|
|
3379
|
+
getMessages(options) {
|
|
3380
|
+
return __async(this, null, function* () {
|
|
3381
|
+
try {
|
|
3382
|
+
const { pageSize } = options || {};
|
|
3383
|
+
const path = "/api/fabric/messages";
|
|
3384
|
+
const queryParams = new URLSearchParams();
|
|
3385
|
+
if (pageSize) {
|
|
3386
|
+
queryParams.append("page_size", pageSize.toString());
|
|
3387
|
+
}
|
|
3388
|
+
const { body } = yield this.httpClient.fetch(makeQueryParamsUrls(path, queryParams));
|
|
3389
|
+
return buildPaginatedResult(body, this.httpClient.fetch);
|
|
3390
|
+
} catch (error) {
|
|
3391
|
+
throw new Error("Error fetching the conversation messages!", error);
|
|
3392
|
+
}
|
|
3393
|
+
});
|
|
3394
|
+
}
|
|
3395
|
+
getConversationMessages(options) {
|
|
3396
|
+
return __async(this, null, function* () {
|
|
3397
|
+
try {
|
|
3398
|
+
const { addressId, pageSize } = options || {};
|
|
3399
|
+
const path = `/api/fabric/conversations/${addressId}/messages`;
|
|
3400
|
+
const queryParams = new URLSearchParams();
|
|
3401
|
+
if (pageSize) {
|
|
3402
|
+
queryParams.append("page_size", pageSize.toString());
|
|
3403
|
+
}
|
|
3404
|
+
const { body } = yield this.httpClient.fetch(makeQueryParamsUrls(path, queryParams));
|
|
3405
|
+
return buildPaginatedResult(body, this.httpClient.fetch);
|
|
3406
|
+
} catch (error) {
|
|
3407
|
+
throw new Error("Error fetching the conversation messages!", error);
|
|
3408
|
+
}
|
|
3409
|
+
});
|
|
3410
|
+
}
|
|
3411
|
+
subscribe(callback) {
|
|
3412
|
+
return __async(this, null, function* () {
|
|
3413
|
+
this.wsClient.connect();
|
|
3414
|
+
this.callbacks.push(callback);
|
|
3415
|
+
});
|
|
3416
|
+
}
|
|
3417
|
+
handleEvent(event) {
|
|
3418
|
+
if (this.callbacks.length) {
|
|
3419
|
+
this.callbacks.forEach((callback) => {
|
|
3420
|
+
callback(event);
|
|
3421
|
+
});
|
|
3422
|
+
}
|
|
3423
|
+
}
|
|
2538
3424
|
};
|
|
2539
3425
|
|
|
2540
3426
|
// src/fabric/SignalWire.ts
|
|
@@ -2543,16 +3429,30 @@ var SignalWire = (options) => {
|
|
|
2543
3429
|
try {
|
|
2544
3430
|
const httpClient = new HTTPClient(options);
|
|
2545
3431
|
const wsClient = new WSClient(options);
|
|
3432
|
+
const conversation = new Conversation({ httpClient, wsClient });
|
|
2546
3433
|
resolve({
|
|
2547
3434
|
httpHost: httpClient.httpHost,
|
|
2548
|
-
getAddresses: httpClient.getAddresses.bind(httpClient),
|
|
2549
3435
|
registerDevice: httpClient.registerDevice.bind(httpClient),
|
|
2550
3436
|
unregisterDevice: httpClient.unregisterDevice.bind(httpClient),
|
|
3437
|
+
getSubscriberInfo: httpClient.getSubscriberInfo.bind(httpClient),
|
|
2551
3438
|
connect: wsClient.connect.bind(wsClient),
|
|
2552
3439
|
disconnect: wsClient.disconnect.bind(wsClient),
|
|
3440
|
+
online: wsClient.online.bind(wsClient),
|
|
3441
|
+
offline: wsClient.offline.bind(wsClient),
|
|
2553
3442
|
dial: wsClient.dial.bind(wsClient),
|
|
2554
3443
|
handlePushNotification: wsClient.handlePushNotification.bind(wsClient),
|
|
2555
3444
|
updateToken: wsClient.updateToken.bind(wsClient),
|
|
3445
|
+
address: {
|
|
3446
|
+
getAddresses: httpClient.getAddresses.bind(httpClient),
|
|
3447
|
+
getAddress: httpClient.getAddress.bind(httpClient)
|
|
3448
|
+
},
|
|
3449
|
+
conversation: {
|
|
3450
|
+
getConversations: conversation.getConversations.bind(conversation),
|
|
3451
|
+
getMessages: conversation.getMessages.bind(conversation),
|
|
3452
|
+
getConversationMessages: conversation.getConversationMessages.bind(conversation),
|
|
3453
|
+
subscribe: conversation.subscribe.bind(conversation),
|
|
3454
|
+
sendMessage: conversation.sendMessage.bind(conversation)
|
|
3455
|
+
},
|
|
2556
3456
|
__httpClient: httpClient,
|
|
2557
3457
|
__wsClient: wsClient
|
|
2558
3458
|
});
|
|
@@ -2562,100 +3462,6 @@ var SignalWire = (options) => {
|
|
|
2562
3462
|
}));
|
|
2563
3463
|
};
|
|
2564
3464
|
|
|
2565
|
-
// src/chat/index.ts
|
|
2566
|
-
var chat_exports = {};
|
|
2567
|
-
__export(chat_exports, {
|
|
2568
|
-
ChatMember: () => import_core29.ChatMember,
|
|
2569
|
-
ChatMessage: () => import_core29.ChatMessage,
|
|
2570
|
-
Client: () => Client3
|
|
2571
|
-
});
|
|
2572
|
-
|
|
2573
|
-
// src/chat/Client.ts
|
|
2574
|
-
var INTERCEPTED_METHODS = [
|
|
2575
|
-
"subscribe",
|
|
2576
|
-
"publish",
|
|
2577
|
-
"getMessages",
|
|
2578
|
-
"getMembers",
|
|
2579
|
-
"getMemberState",
|
|
2580
|
-
"getAllowedChannels",
|
|
2581
|
-
"setMemberState"
|
|
2582
|
-
];
|
|
2583
|
-
var Client3 = function(chatOptions) {
|
|
2584
|
-
const client = createClient(chatOptions);
|
|
2585
|
-
const createInterceptor = (prop) => {
|
|
2586
|
-
return (...params) => __async(this, null, function* () {
|
|
2587
|
-
yield client.connect();
|
|
2588
|
-
return client.chat[prop](...params);
|
|
2589
|
-
});
|
|
2590
|
-
};
|
|
2591
|
-
const interceptors = {
|
|
2592
|
-
_session: client,
|
|
2593
|
-
disconnect: () => client.disconnect()
|
|
2594
|
-
};
|
|
2595
|
-
return new Proxy(client.chat, {
|
|
2596
|
-
get(target, prop, receiver) {
|
|
2597
|
-
if (prop in interceptors) {
|
|
2598
|
-
return interceptors[prop];
|
|
2599
|
-
}
|
|
2600
|
-
if (INTERCEPTED_METHODS.includes(prop)) {
|
|
2601
|
-
return createInterceptor(prop);
|
|
2602
|
-
}
|
|
2603
|
-
return Reflect.get(target, prop, receiver);
|
|
2604
|
-
}
|
|
2605
|
-
});
|
|
2606
|
-
};
|
|
2607
|
-
|
|
2608
|
-
// src/chat/index.ts
|
|
2609
|
-
var import_core29 = require("@signalwire/core");
|
|
2610
|
-
|
|
2611
|
-
// src/pubSub/index.ts
|
|
2612
|
-
var pubSub_exports = {};
|
|
2613
|
-
__export(pubSub_exports, {
|
|
2614
|
-
Client: () => Client4,
|
|
2615
|
-
PubSubMessage: () => PubSubMessage
|
|
2616
|
-
});
|
|
2617
|
-
var import_core31 = require("@signalwire/core");
|
|
2618
|
-
|
|
2619
|
-
// src/utils/interfaces.ts
|
|
2620
|
-
var import_core30 = require("@signalwire/core");
|
|
2621
|
-
var INTERNAL_MEMBER_UPDATED_EVENTS = Object.keys(import_core30.INTERNAL_MEMBER_UPDATABLE_PROPS).map((key) => {
|
|
2622
|
-
return `member.updated.${key}`;
|
|
2623
|
-
});
|
|
2624
|
-
|
|
2625
|
-
// src/pubSub/Client.ts
|
|
2626
|
-
var INTERCEPTED_METHODS2 = [
|
|
2627
|
-
"getAllowedChannels",
|
|
2628
|
-
"subscribe",
|
|
2629
|
-
"publish"
|
|
2630
|
-
];
|
|
2631
|
-
var Client4 = function(pubSubOptions) {
|
|
2632
|
-
const client = createClient(pubSubOptions);
|
|
2633
|
-
const createInterceptor = (prop) => {
|
|
2634
|
-
return (...params) => __async(this, null, function* () {
|
|
2635
|
-
yield client.connect();
|
|
2636
|
-
return client.pubSub[prop](...params);
|
|
2637
|
-
});
|
|
2638
|
-
};
|
|
2639
|
-
const interceptors = {
|
|
2640
|
-
_session: client,
|
|
2641
|
-
disconnect: () => client.disconnect()
|
|
2642
|
-
};
|
|
2643
|
-
return new Proxy(client.pubSub, {
|
|
2644
|
-
get(target, prop, receiver) {
|
|
2645
|
-
if (prop in interceptors) {
|
|
2646
|
-
return interceptors[prop];
|
|
2647
|
-
}
|
|
2648
|
-
if (INTERCEPTED_METHODS2.includes(prop)) {
|
|
2649
|
-
return createInterceptor(prop);
|
|
2650
|
-
}
|
|
2651
|
-
return Reflect.get(target, prop, receiver);
|
|
2652
|
-
}
|
|
2653
|
-
});
|
|
2654
|
-
};
|
|
2655
|
-
|
|
2656
|
-
// src/pubSub/index.ts
|
|
2657
|
-
var PubSubMessage = import_core31.PubSub.PubSubMessage;
|
|
2658
|
-
|
|
2659
3465
|
// src/webrtc.ts
|
|
2660
3466
|
var webrtc_exports = {};
|
|
2661
3467
|
__export(webrtc_exports, {
|