@whereby.com/core 1.12.1 → 1.14.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/index.cjs CHANGED
@@ -5,6 +5,7 @@ var media = require('@whereby.com/media');
5
5
  var axios = require('axios');
6
6
  var events$1 = require('events');
7
7
  var toolkit = require('@reduxjs/toolkit');
8
+ var uuid = require('uuid');
8
9
 
9
10
  class Response {
10
11
  constructor(initialValues = {}) {
@@ -971,6 +972,63 @@ class RoomService {
971
972
  }
972
973
  }
973
974
 
975
+ /******************************************************************************
976
+ Copyright (c) Microsoft Corporation.
977
+
978
+ Permission to use, copy, modify, and/or distribute this software for any
979
+ purpose with or without fee is hereby granted.
980
+
981
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
982
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
983
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
984
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
985
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
986
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
987
+ PERFORMANCE OF THIS SOFTWARE.
988
+ ***************************************************************************** */
989
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
990
+
991
+
992
+ function __rest(s, e) {
993
+ var t = {};
994
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
995
+ t[p] = s[p];
996
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
997
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
998
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
999
+ t[p[i]] = s[p[i]];
1000
+ }
1001
+ return t;
1002
+ }
1003
+
1004
+ function __awaiter(thisArg, _arguments, P, generator) {
1005
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
1006
+ return new (P || (P = Promise))(function (resolve, reject) {
1007
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
1008
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
1009
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
1010
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
1011
+ });
1012
+ }
1013
+
1014
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
1015
+ var e = new Error(message);
1016
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
1017
+ };
1018
+
1019
+ function getUsableCameraEffectPresets() {
1020
+ return __awaiter(this, void 0, void 0, function* () {
1021
+ const { getUsablePresets } = yield import('@whereby.com/camera-effects');
1022
+ return getUsablePresets();
1023
+ });
1024
+ }
1025
+ function isAudioDenoiserSupported() {
1026
+ return __awaiter(this, void 0, void 0, function* () {
1027
+ const { canUse } = yield import('@whereby.com/audio-denoiser');
1028
+ return canUse();
1029
+ });
1030
+ }
1031
+
974
1032
  class RoomParticipant {
975
1033
  constructor({ breakoutGroup, displayName, id, isAudioEnabled, isAudioRecorder, isDialIn, isVideoEnabled, stickyReaction, stream, }) {
976
1034
  this.isLocalParticipant = false;
@@ -1140,6 +1198,7 @@ function parseUnverifiedRoomKeyData(roomKey) {
1140
1198
 
1141
1199
  const listenerMiddleware = toolkit.createListenerMiddleware();
1142
1200
  const startAppListening = listenerMiddleware.startListening;
1201
+ const addAppListener = toolkit.addListener;
1143
1202
  const createReactor = (selectors, callback) => {
1144
1203
  return startAppListening({
1145
1204
  predicate: (_, currentState, previousState) => {
@@ -1158,9 +1217,9 @@ const createReactor = (selectors, callback) => {
1158
1217
  });
1159
1218
  };
1160
1219
 
1161
- const coreVersion = "1.12.1";
1220
+ const coreVersion = "1.14.0";
1162
1221
 
1163
- const initialState$1 = {
1222
+ const initialState$2 = {
1164
1223
  displayName: null,
1165
1224
  externalId: null,
1166
1225
  ignoreBreakoutGroups: false,
@@ -1175,7 +1234,7 @@ const initialState$1 = {
1175
1234
  };
1176
1235
  const appSlice = toolkit.createSlice({
1177
1236
  name: "app",
1178
- initialState: initialState$1,
1237
+ initialState: initialState$2,
1179
1238
  reducers: {
1180
1239
  doAppStart: (state, action) => {
1181
1240
  const url = new URL(action.payload.roomUrl);
@@ -1211,6 +1270,7 @@ const signalEvents = {
1211
1270
  breakoutSessionUpdated: createSignalEventAction("breakoutSessionUpdated"),
1212
1271
  chatMessage: createSignalEventAction("chatMessage"),
1213
1272
  chatMessageRemoved: createSignalEventAction("chatMessageRemoved"),
1273
+ fileSharingError: createSignalEventAction("fileSharingError"),
1214
1274
  clientLeft: createSignalEventAction("clientLeft"),
1215
1275
  clientKicked: createSignalEventAction("clientKicked"),
1216
1276
  clientMetadataReceived: createSignalEventAction("clientMetadataReceived"),
@@ -1338,50 +1398,6 @@ function createAuthorizedRoomConnectedThunk(authorizationSelector, thunk) {
1338
1398
  });
1339
1399
  }
1340
1400
 
1341
- /******************************************************************************
1342
- Copyright (c) Microsoft Corporation.
1343
-
1344
- Permission to use, copy, modify, and/or distribute this software for any
1345
- purpose with or without fee is hereby granted.
1346
-
1347
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
1348
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
1349
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
1350
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
1351
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
1352
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
1353
- PERFORMANCE OF THIS SOFTWARE.
1354
- ***************************************************************************** */
1355
- /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
1356
-
1357
-
1358
- function __rest(s, e) {
1359
- var t = {};
1360
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
1361
- t[p] = s[p];
1362
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
1363
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
1364
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
1365
- t[p[i]] = s[p[i]];
1366
- }
1367
- return t;
1368
- }
1369
-
1370
- function __awaiter(thisArg, _arguments, P, generator) {
1371
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
1372
- return new (P || (P = Promise))(function (resolve, reject) {
1373
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
1374
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
1375
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
1376
- step((generator = generator.apply(thisArg, _arguments || [])).next());
1377
- });
1378
- }
1379
-
1380
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
1381
- var e = new Error(message);
1382
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
1383
- };
1384
-
1385
1401
  const deviceCredentialsSliceInitialState = {
1386
1402
  isFetching: false,
1387
1403
  data: null,
@@ -1435,7 +1451,13 @@ function forwardSocketEvents(socket, dispatch) {
1435
1451
  socket.on("video_enabled", (payload) => dispatch(signalEvents.videoEnabled(payload)));
1436
1452
  socket.on("audio_enable_requested", (payload) => dispatch(signalEvents.audioEnableRequested(payload)));
1437
1453
  socket.on("client_metadata_received", (payload) => dispatch(signalEvents.clientMetadataReceived(payload)));
1438
- socket.on("chat_message", (payload) => dispatch(signalEvents.chatMessage(payload)));
1454
+ socket.on("chat_message", (payload) => {
1455
+ if (media.isFileShareError(payload)) {
1456
+ dispatch(signalEvents.fileSharingError(payload));
1457
+ return;
1458
+ }
1459
+ dispatch(signalEvents.chatMessage(payload));
1460
+ });
1439
1461
  socket.on("chat_message_removed", (payload) => dispatch(signalEvents.chatMessageRemoved(payload)));
1440
1462
  socket.on("disconnect", () => dispatch(signalEvents.disconnect()));
1441
1463
  socket.on("room_knocked", (payload) => dispatch(signalEvents.roomKnocked(payload)));
@@ -2099,9 +2121,10 @@ startAppListening({
2099
2121
  const devices = selectLocalMediaDevices(state);
2100
2122
  if (!stream)
2101
2123
  return;
2124
+ const beforeEffectTracks = selectLocalMediaBeforeEffectTracks(state);
2102
2125
  const deviceData = media.getDeviceData({
2103
- audioTrack: stream.getAudioTracks()[0],
2104
- videoTrack: stream.getVideoTracks()[0],
2126
+ audioTrack: (beforeEffectTracks === null || beforeEffectTracks === void 0 ? void 0 : beforeEffectTracks.audio) || stream.getAudioTracks()[0],
2127
+ videoTrack: (beforeEffectTracks === null || beforeEffectTracks === void 0 ? void 0 : beforeEffectTracks.video) || stream.getVideoTracks()[0],
2105
2128
  devices,
2106
2129
  });
2107
2130
  dispatch(localStreamMetadataUpdated(deviceData));
@@ -2265,15 +2288,7 @@ const chatSlice = toolkit.createSlice({
2265
2288
  reducers: {},
2266
2289
  extraReducers(builder) {
2267
2290
  builder.addCase(signalEvents.chatMessage, (state, action) => {
2268
- const message = {
2269
- id: action.payload.id,
2270
- senderId: action.payload.senderId,
2271
- parentId: action.payload.parentId,
2272
- timestamp: action.payload.timestamp,
2273
- text: action.payload.text,
2274
- sig: action.payload.sig,
2275
- removed: false,
2276
- };
2291
+ const message = Object.assign({ id: action.payload.id, senderId: action.payload.senderId, parentId: action.payload.parentId, timestamp: action.payload.timestamp, text: action.payload.text, sig: action.payload.sig, removed: false }, (action.payload.file && { file: action.payload.file }));
2277
2292
  return Object.assign(Object.assign({}, state), { chatMessages: [...state.chatMessages, message] });
2278
2293
  });
2279
2294
  builder.addCase(signalEvents.chatMessageRemoved, (state, action) => {
@@ -3372,6 +3387,175 @@ createReactor([selectShouldStopConnectionMonitor], ({ dispatch }, shouldStartCon
3372
3387
  }
3373
3388
  });
3374
3389
 
3390
+ const MAX_FILES_PER_UPLOAD = 10;
3391
+ const MAX_FILE_SIZE = 15 * 1024 * 1024;
3392
+ const ACCEPTED_FILE_TYPES = {
3393
+ "application/doc": [".doc", ".docx"],
3394
+ "application/msword": [".doc", ".docx"],
3395
+ "application/pdf": [".pdf"],
3396
+ "application/rtf": [".rtf"],
3397
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": [".xlsx"],
3398
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document": [".docx"],
3399
+ "audio/mpeg": [".mp3"],
3400
+ "audio/wav": [".wav"],
3401
+ "image/gif": [".gif"],
3402
+ "image/jpeg": [".jpeg", ".jpg"],
3403
+ "image/png": [".png"],
3404
+ "image/webp": [".webp"],
3405
+ "text/csv": [".csv"],
3406
+ "text/plain": [".txt"],
3407
+ "video/mp4": [".mp4"],
3408
+ "video/quicktime": [".mov"],
3409
+ "video/webm": [".webm"],
3410
+ "video/x-matroska": [".mkv"],
3411
+ };
3412
+ function isAcceptedFileType(file) {
3413
+ if (file.type && ACCEPTED_FILE_TYPES[file.type]) {
3414
+ return true;
3415
+ }
3416
+ const dot = file.name.lastIndexOf(".");
3417
+ if (dot < 0) {
3418
+ return false;
3419
+ }
3420
+ const extension = file.name.slice(dot).toLowerCase();
3421
+ return Object.values(ACCEPTED_FILE_TYPES).some((extensions) => extensions.includes(extension));
3422
+ }
3423
+ function validateFile(file) {
3424
+ if (!isAcceptedFileType(file)) {
3425
+ return "unsupported_file_type";
3426
+ }
3427
+ if (file.size > MAX_FILE_SIZE) {
3428
+ return "file_too_large";
3429
+ }
3430
+ return undefined;
3431
+ }
3432
+ const fileShareSliceInitialState = {
3433
+ uploads: [],
3434
+ requestInFlight: false,
3435
+ };
3436
+ const fileShareSlice = toolkit.createSlice({
3437
+ name: "fileShare",
3438
+ initialState: fileShareSliceInitialState,
3439
+ reducers: {
3440
+ fileUploadsStarted: (state, action) => {
3441
+ state.uploads.push(...action.payload);
3442
+ state.requestInFlight = true;
3443
+ },
3444
+ fileShareRequestSettled: (state) => {
3445
+ state.requestInFlight = false;
3446
+ },
3447
+ fileUploadSucceeded: (state, action) => {
3448
+ const upload = state.uploads.find((u) => u.id === action.payload.id);
3449
+ if (upload) {
3450
+ upload.status = "sent";
3451
+ }
3452
+ },
3453
+ fileUploadFailed: (state, action) => {
3454
+ const upload = state.uploads.find((u) => u.id === action.payload.id);
3455
+ if (upload) {
3456
+ upload.status = "error";
3457
+ upload.error = action.payload.error;
3458
+ }
3459
+ },
3460
+ clearFileUploads: (state) => {
3461
+ state.uploads = [];
3462
+ },
3463
+ },
3464
+ });
3465
+ const { fileUploadsStarted, fileShareRequestSettled, fileUploadSucceeded, fileUploadFailed, clearFileUploads } = fileShareSlice.actions;
3466
+ function uploadFile(file, uploadUrl) {
3467
+ const form = new FormData();
3468
+ form.append("Content-Type", file.type);
3469
+ Object.entries(uploadUrl.fields).forEach(([key, value]) => form.append(key, value));
3470
+ form.append("file", file);
3471
+ return fetch(uploadUrl.url, { method: "POST", body: form });
3472
+ }
3473
+ const doSendFiles = createAsyncRoomConnectedThunk("fileShare/sendFiles", (payload_1, _a) => __awaiter(void 0, [payload_1, _a], void 0, function* (payload, { dispatch, getState }) {
3474
+ const state = getState();
3475
+ if (state.fileShare.requestInFlight) {
3476
+ return Promise.reject(new Error("A file upload request is already in flight"));
3477
+ }
3478
+ const socket = selectSignalConnectionRaw(state).socket;
3479
+ if (!socket) {
3480
+ return Promise.reject(new Error("No signal connection"));
3481
+ }
3482
+ const breakoutCurrentId = selectBreakoutCurrentId(state);
3483
+ const { files } = payload;
3484
+ if (!files.length) {
3485
+ return;
3486
+ }
3487
+ const tooManyFiles = files.length > MAX_FILES_PER_UPLOAD;
3488
+ const entries = files.map((file) => {
3489
+ const error = tooManyFiles ? "too_many_files" : validateFile(file);
3490
+ const upload = Object.assign({ id: uuid.v4(), name: file.name, size: file.size, type: file.type, status: error ? "error" : "uploading" }, (error && { error }));
3491
+ return { file, upload };
3492
+ });
3493
+ dispatch(fileUploadsStarted(entries.map((entry) => entry.upload)));
3494
+ const accepted = entries.filter((entry) => entry.upload.status === "uploading");
3495
+ if (!accepted.length) {
3496
+ dispatch(fileShareRequestSettled());
3497
+ return;
3498
+ }
3499
+ const acceptedFiles = accepted.map((entry) => entry.file);
3500
+ const outcome = yield new Promise((resolve) => {
3501
+ let settled = false;
3502
+ const removeListener = dispatch(addAppListener({
3503
+ actionCreator: signalEvents.fileSharingError,
3504
+ effect: (action, listenerApi) => {
3505
+ if (settled)
3506
+ return;
3507
+ settled = true;
3508
+ listenerApi.unsubscribe();
3509
+ resolve({ error: action.payload.error });
3510
+ },
3511
+ }));
3512
+ socket.emit("request_file_upload_url", { files: acceptedFiles.map((f) => ({ name: f.name, size: f.size, type: f.type })) }, (urls) => {
3513
+ if (settled)
3514
+ return;
3515
+ settled = true;
3516
+ removeListener({ cancelActive: true });
3517
+ resolve({ urls });
3518
+ });
3519
+ });
3520
+ dispatch(fileShareRequestSettled());
3521
+ if ("error" in outcome) {
3522
+ accepted.forEach((entry) => dispatch(fileUploadFailed({ id: entry.upload.id, error: outcome.error })));
3523
+ return;
3524
+ }
3525
+ yield Promise.all(accepted.map((_a, index_1) => __awaiter(void 0, [_a, index_1], void 0, function* ({ file, upload }, index) {
3526
+ const urls = outcome.urls[index];
3527
+ if (!urls) {
3528
+ dispatch(fileUploadFailed({ id: upload.id, error: "upload_failed" }));
3529
+ return;
3530
+ }
3531
+ try {
3532
+ const response = yield uploadFile(file, urls.uploadUrl);
3533
+ if (!response.ok) {
3534
+ throw new Error(`S3 upload failed with status ${response.status}`);
3535
+ }
3536
+ socket.emit("chat_message", Object.assign({ text: "", file: {
3537
+ downloadUrl: urls.downloadUrl,
3538
+ name: file.name,
3539
+ size: file.size,
3540
+ type: file.type,
3541
+ key: urls.uploadUrl.fields.key,
3542
+ } }, (breakoutCurrentId && { breakoutGroup: breakoutCurrentId })));
3543
+ dispatch(fileUploadSucceeded({ id: upload.id }));
3544
+ }
3545
+ catch (_b) {
3546
+ dispatch(fileUploadFailed({ id: upload.id, error: "upload_failed" }));
3547
+ }
3548
+ })));
3549
+ }));
3550
+ const doDownloadFile = createAppAsyncThunk("fileShare/downloadFile", (payload) => __awaiter(void 0, void 0, void 0, function* () {
3551
+ const response = yield fetch(payload.file.downloadUrl, { mode: "cors", cache: "no-cache" });
3552
+ if (!response.ok) {
3553
+ throw new Error(`Failed to download file: ${response.status}`);
3554
+ }
3555
+ return response.blob();
3556
+ }));
3557
+ const selectFileUploads = (state) => state.fileShare.uploads;
3558
+
3375
3559
  const initialLiveTranscriptionState = {
3376
3560
  isInitiator: false,
3377
3561
  isTranscribing: false,
@@ -4246,13 +4430,13 @@ const doRejectWaitingParticipant = createRoomConnectedThunk((payload) => (dispat
4246
4430
  });
4247
4431
  const selectWaitingParticipants = (state) => state.waitingParticipants.waitingParticipants;
4248
4432
 
4249
- const initialState = {
4433
+ const initialState$1 = {
4250
4434
  isSwitching: false,
4251
4435
  raw: {},
4252
4436
  };
4253
4437
  const cameraEffectsSlice = toolkit.createSlice({
4254
4438
  name: "cameraEffects",
4255
- initialState,
4439
+ initialState: initialState$1,
4256
4440
  reducers: {
4257
4441
  cameraEffectsSwitching(state, action) {
4258
4442
  state.isSwitching = action.payload.isSwitching;
@@ -4322,7 +4506,7 @@ const doCameraEffectsSwitchPreset = createAppAsyncThunk("cameraEffects/switchPre
4322
4506
  mod = yield import('@whereby.com/camera-effects');
4323
4507
  }
4324
4508
  catch (_f) {
4325
- throw new Error("@whereby.com/camera-effects is not installed. Add it as a dependency to enable camera effects.");
4509
+ throw new Error("Failed to load @whereby.com/camera-effects. Check your network connection and that the package is resolvable.");
4326
4510
  }
4327
4511
  const { createEffectStream, getUsablePresets } = mod;
4328
4512
  const usable = getUsablePresets({ filter: () => true, options: { allowSafari } });
@@ -4350,9 +4534,139 @@ startAppListening({
4350
4534
  },
4351
4535
  });
4352
4536
 
4537
+ const initialState = {
4538
+ wanted: false,
4539
+ isSwitching: false,
4540
+ raw: {},
4541
+ };
4542
+ const audioDenoiserSlice = toolkit.createSlice({
4543
+ name: "audioDenoiser",
4544
+ initialState,
4545
+ reducers: {
4546
+ audioDenoiserSwitching(state, action) {
4547
+ state.isSwitching = action.payload.isSwitching;
4548
+ },
4549
+ audioDenoiserWantedSet(state, action) {
4550
+ state.wanted = action.payload.wanted;
4551
+ },
4552
+ audioDenoiserApplied(state, action) {
4553
+ state.raw = action.payload;
4554
+ state.error = undefined;
4555
+ state.isSwitching = false;
4556
+ },
4557
+ audioDenoiserCleared(state) {
4558
+ state.raw = {};
4559
+ state.error = undefined;
4560
+ state.isSwitching = false;
4561
+ },
4562
+ audioDenoiserError(state, action) {
4563
+ state.error = action.payload.error;
4564
+ state.isSwitching = false;
4565
+ },
4566
+ },
4567
+ });
4568
+ const { audioDenoiserSwitching, audioDenoiserWantedSet, audioDenoiserApplied, audioDenoiserCleared, audioDenoiserError, } = audioDenoiserSlice.actions;
4569
+ const selectAudioDenoiserRaw = (state) => state.audioDenoiser.raw;
4570
+ const selectAudioDenoiserWanted = (state) => state.audioDenoiser.wanted;
4571
+ const selectAudioDenoiserEnabled = (state) => !!state.audioDenoiser.raw.stop;
4572
+ const doAudioDenoiserApply = createAppAsyncThunk("audioDenoiser/apply", (_1, _a) => __awaiter(void 0, [_1, _a], void 0, function* (_, { getState, dispatch, rejectWithValue }) {
4573
+ var _b;
4574
+ const state = getState();
4575
+ if (selectLocalMediaIsSwitchingStream(state))
4576
+ return;
4577
+ const localStream = selectLocalMediaStream(state);
4578
+ if (!((_b = localStream === null || localStream === void 0 ? void 0 : localStream.getAudioTracks()) === null || _b === void 0 ? void 0 : _b[0])) {
4579
+ return;
4580
+ }
4581
+ if (selectAudioDenoiserEnabled(state))
4582
+ return;
4583
+ dispatch(audioDenoiserSwitching({ isSwitching: true }));
4584
+ try {
4585
+ let mod;
4586
+ try {
4587
+ mod = yield import('@whereby.com/audio-denoiser');
4588
+ }
4589
+ catch (_c) {
4590
+ throw new Error("Failed to load @whereby.com/audio-denoiser. Check your network connection and that the package is resolvable.");
4591
+ }
4592
+ const { applyAudioDenoiser, canUse } = mod;
4593
+ if (!canUse()) {
4594
+ throw new Error("Audio denoiser is not supported in this browser");
4595
+ }
4596
+ const handle = yield applyAudioDenoiser({
4597
+ inputStream: localStream,
4598
+ doCaptureException: (err, ctx) => {
4599
+ console.error("[audioDenoiser]", err, ctx);
4600
+ },
4601
+ });
4602
+ yield dispatch(doLocalStreamEffect({ effectStream: handle.outputStream, only: "audio" }));
4603
+ dispatch(audioDenoiserApplied({
4604
+ stop: handle.stop,
4605
+ outputStream: handle.outputStream,
4606
+ audioContext: handle.audioContext,
4607
+ denoiserNode: handle.denoiserNode,
4608
+ }));
4609
+ }
4610
+ catch (error) {
4611
+ dispatch(audioDenoiserError({ error }));
4612
+ return rejectWithValue(error);
4613
+ }
4614
+ }));
4615
+ const doAudioDenoiserTeardown = createAppAsyncThunk("audioDenoiser/teardown", (_1, _a) => __awaiter(void 0, [_1, _a], void 0, function* (_, { getState, dispatch }) {
4616
+ const raw = selectAudioDenoiserRaw(getState());
4617
+ if (!raw.stop)
4618
+ return;
4619
+ dispatch(audioDenoiserSwitching({ isSwitching: true }));
4620
+ try {
4621
+ if (raw.outputStream) {
4622
+ yield dispatch(doLocalStreamEffect({ effectStream: undefined, only: "audio" }));
4623
+ }
4624
+ raw.stop();
4625
+ }
4626
+ finally {
4627
+ dispatch(audioDenoiserCleared());
4628
+ }
4629
+ }));
4630
+ const doAudioDenoiserEnable = createAppAsyncThunk("audioDenoiser/enable", (_1, _a) => __awaiter(void 0, [_1, _a], void 0, function* (_, { dispatch }) {
4631
+ dispatch(audioDenoiserWantedSet({ wanted: true }));
4632
+ yield dispatch(doAudioDenoiserApply());
4633
+ }));
4634
+ const doAudioDenoiserDisable = createAppAsyncThunk("audioDenoiser/disable", (arg_1, _a) => __awaiter(void 0, [arg_1, _a], void 0, function* (arg, { dispatch }) {
4635
+ if (!(arg === null || arg === void 0 ? void 0 : arg.keepWanted)) {
4636
+ dispatch(audioDenoiserWantedSet({ wanted: false }));
4637
+ }
4638
+ yield dispatch(doAudioDenoiserTeardown());
4639
+ }));
4640
+ startAppListening({
4641
+ actionCreator: doSwitchLocalStream.pending,
4642
+ effect: (_1, _a) => __awaiter(void 0, [_1, _a], void 0, function* (_, { getState, dispatch }) {
4643
+ if (selectAudioDenoiserEnabled(getState())) {
4644
+ yield dispatch(doAudioDenoiserDisable({ keepWanted: true }));
4645
+ }
4646
+ }),
4647
+ });
4648
+ startAppListening({
4649
+ actionCreator: doSwitchLocalStream.fulfilled,
4650
+ effect: (_1, _a) => __awaiter(void 0, [_1, _a], void 0, function* (_, { getState, dispatch }) {
4651
+ const state = getState();
4652
+ if (selectAudioDenoiserWanted(state) && !selectAudioDenoiserEnabled(state)) {
4653
+ yield dispatch(doAudioDenoiserApply());
4654
+ }
4655
+ }),
4656
+ });
4657
+ startAppListening({
4658
+ actionCreator: doAppStop,
4659
+ effect: (_, { dispatch, getState }) => {
4660
+ if (selectAudioDenoiserRaw(getState()).stop) {
4661
+ dispatch(doAudioDenoiserDisable());
4662
+ }
4663
+ },
4664
+ });
4665
+
4353
4666
  const IS_DEV = undefined === "true";
4354
4667
  const appReducer = toolkit.combineReducers({
4355
4668
  app: appSlice.reducer,
4669
+ audioDenoiser: audioDenoiserSlice.reducer,
4356
4670
  authorization: authorizationSlice.reducer,
4357
4671
  breakout: breakoutSlice.reducer,
4358
4672
  cameraEffects: cameraEffectsSlice.reducer,
@@ -4360,6 +4674,7 @@ const appReducer = toolkit.combineReducers({
4360
4674
  cloudRecording: cloudRecordingSlice.reducer,
4361
4675
  connectionMonitor: connectionMonitorSlice.reducer,
4362
4676
  deviceCredentials: deviceCredentialsSlice.reducer,
4677
+ fileShare: fileShareSlice.reducer,
4363
4678
  liveTranscription: liveTranscriptionSlice.reducer,
4364
4679
  localMedia: localMediaSlice.reducer,
4365
4680
  localParticipant: localParticipantSlice.reducer,
@@ -4383,6 +4698,7 @@ const rootReducer = (state, action) => {
4383
4698
  app: Object.assign(Object.assign({}, appSlice.getInitialState()), { initialConfig: (_a = state === null || state === void 0 ? void 0 : state.app) === null || _a === void 0 ? void 0 : _a.initialConfig }),
4384
4699
  localMedia: Object.assign(Object.assign({}, localMediaSlice.getInitialState()), state === null || state === void 0 ? void 0 : state.localMedia),
4385
4700
  cameraEffects: Object.assign(Object.assign({}, cameraEffectsSlice.getInitialState()), state === null || state === void 0 ? void 0 : state.cameraEffects),
4701
+ audioDenoiser: Object.assign(Object.assign({}, audioDenoiserSlice.getInitialState()), state === null || state === void 0 ? void 0 : state.audioDenoiser),
4386
4702
  };
4387
4703
  return appReducer(resetState, action);
4388
4704
  }
@@ -4727,9 +5043,10 @@ const SPOTLIGHT_PARTICIPANT_REMOVED = "spotlight:participant-removed";
4727
5043
  const ROOM_JOINED = "room:joined";
4728
5044
  const ROOM_JOINED_ERROR = "room:joined:error";
4729
5045
 
4730
- const selectRoomConnectionState = toolkit.createSelector(selectChatMessages, selectCloudRecordingRaw, selectBreakoutCurrentGroup, selectBreakoutActive, selectBreakoutGroupedParticipants, selectAllClientViewsInCurrentGroup, selectLiveTranscriptionRaw, selectLocalParticipantRaw, selectLocalMediaStream, selectRemoteParticipants, selectScreenshares, selectRoomConnectionStatus, selectRoomConnectionError, selectStreamingRaw, selectWaitingParticipants, selectNotificationsEmitter, selectSpotlightedClientViews, selectIsCameraEnabled, selectIsMicrophoneEnabled, (chatMessages, cloudRecording, breakoutCurrentGroup, breakoutActive, breakoutGroupedParticipants, clientViewsInCurrentGroup, liveTranscription, localParticipant, localMediaStream, remoteParticipants, screenshares, connectionStatus, connectionError, streaming, waitingParticipants, notificationsEmitter, spotlightedClientViews, isCameraEnabled, isMicrophoneEnabled) => {
5046
+ const selectRoomConnectionState = toolkit.createSelector(selectChatMessages, selectFileUploads, selectCloudRecordingRaw, selectBreakoutCurrentGroup, selectBreakoutActive, selectBreakoutGroupedParticipants, selectAllClientViewsInCurrentGroup, selectLiveTranscriptionRaw, selectLocalParticipantRaw, selectLocalMediaStream, selectRemoteParticipants, selectScreenshares, selectRoomConnectionStatus, selectRoomConnectionError, selectStreamingRaw, selectWaitingParticipants, selectNotificationsEmitter, selectSpotlightedClientViews, selectIsCameraEnabled, selectIsMicrophoneEnabled, (chatMessages, fileUploads, cloudRecording, breakoutCurrentGroup, breakoutActive, breakoutGroupedParticipants, clientViewsInCurrentGroup, liveTranscription, localParticipant, localMediaStream, remoteParticipants, screenshares, connectionStatus, connectionError, streaming, waitingParticipants, notificationsEmitter, spotlightedClientViews, isCameraEnabled, isMicrophoneEnabled) => {
4731
5047
  const state = {
4732
5048
  chatMessages,
5049
+ fileUploads,
4733
5050
  cloudRecording: cloudRecording.status
4734
5051
  ? {
4735
5052
  error: cloudRecording.error,
@@ -4778,6 +5095,7 @@ class RoomConnectionClient extends BaseClient {
4778
5095
  this.breakoutSubscribers = new Set();
4779
5096
  this.cameraStateSubscribers = new Set();
4780
5097
  this.chatMessageSubscribers = new Set();
5098
+ this.fileUploadsSubscribers = new Set();
4781
5099
  this.cloudRecordingSubscribers = new Set();
4782
5100
  this.connectionErrorSubscribers = new Set();
4783
5101
  this.connectionStatusSubscribers = new Set();
@@ -4798,6 +5116,9 @@ class RoomConnectionClient extends BaseClient {
4798
5116
  if (state.chatMessages !== previousState.chatMessages) {
4799
5117
  this.chatMessageSubscribers.forEach((cb) => cb(state.chatMessages));
4800
5118
  }
5119
+ if (state.fileUploads !== previousState.fileUploads) {
5120
+ this.fileUploadsSubscribers.forEach((cb) => cb(state.fileUploads));
5121
+ }
4801
5122
  if (state.cloudRecording !== previousState.cloudRecording) {
4802
5123
  this.cloudRecordingSubscribers.forEach((cb) => cb(state.cloudRecording));
4803
5124
  this.emit(CLOUD_RECORDING_STATUS_CHANGED, state.cloudRecording);
@@ -4908,6 +5229,10 @@ class RoomConnectionClient extends BaseClient {
4908
5229
  this.chatMessageSubscribers.add(callback);
4909
5230
  return () => this.chatMessageSubscribers.delete(callback);
4910
5231
  }
5232
+ subscribeToFileUploads(callback) {
5233
+ this.fileUploadsSubscribers.add(callback);
5234
+ return () => this.fileUploadsSubscribers.delete(callback);
5235
+ }
4911
5236
  subscribeToCloudRecording(callback) {
4912
5237
  this.cloudRecordingSubscribers.add(callback);
4913
5238
  return () => this.cloudRecordingSubscribers.delete(callback);
@@ -5018,6 +5343,12 @@ class RoomConnectionClient extends BaseClient {
5018
5343
  removeChatMessage(id, sig) {
5019
5344
  this.store.dispatch(doRemoveChatMessage({ id, sig }));
5020
5345
  }
5346
+ sendFiles(files) {
5347
+ this.store.dispatch(doSendFiles({ files }));
5348
+ }
5349
+ downloadFile(file) {
5350
+ return this.store.dispatch(doDownloadFile({ file })).unwrap();
5351
+ }
5021
5352
  knock() {
5022
5353
  this.store.dispatch(doKnockRoom());
5023
5354
  }
@@ -5145,6 +5476,28 @@ class RoomConnectionClient extends BaseClient {
5145
5476
  return Promise.resolve();
5146
5477
  });
5147
5478
  }
5479
+ enableAudioDenoiser() {
5480
+ return __awaiter(this, void 0, void 0, function* () {
5481
+ try {
5482
+ yield this.store.dispatch(doAudioDenoiserEnable());
5483
+ }
5484
+ catch (error) {
5485
+ return Promise.reject(error);
5486
+ }
5487
+ return Promise.resolve();
5488
+ });
5489
+ }
5490
+ disableAudioDenoiser() {
5491
+ return __awaiter(this, void 0, void 0, function* () {
5492
+ try {
5493
+ yield this.store.dispatch(doAudioDenoiserDisable());
5494
+ }
5495
+ catch (error) {
5496
+ return Promise.reject(error);
5497
+ }
5498
+ return Promise.resolve();
5499
+ });
5500
+ }
5148
5501
  destroy() {
5149
5502
  super.destroy();
5150
5503
  this.store.dispatch(doAppStop());
@@ -5153,6 +5506,7 @@ class RoomConnectionClient extends BaseClient {
5153
5506
  this.breakoutSubscribers.clear();
5154
5507
  this.cameraStateSubscribers.clear();
5155
5508
  this.chatMessageSubscribers.clear();
5509
+ this.fileUploadsSubscribers.clear();
5156
5510
  this.cloudRecordingSubscribers.clear();
5157
5511
  this.connectionErrorSubscribers.clear();
5158
5512
  this.connectionStatusSubscribers.clear();
@@ -5194,6 +5548,7 @@ class WherebyClient {
5194
5548
  }
5195
5549
  }
5196
5550
 
5551
+ exports.ACCEPTED_FILE_TYPES = ACCEPTED_FILE_TYPES;
5197
5552
  exports.ApiClient = ApiClient;
5198
5553
  exports.BREAKOUT_CONFIG_CHANGED = BREAKOUT_CONFIG_CHANGED;
5199
5554
  exports.CAMERA_DEVICES_CHANGED = CAMERA_DEVICES_CHANGED;
@@ -5221,6 +5576,8 @@ exports.LOCAL_SCREENSHARE_STATUS_CHANGED = LOCAL_SCREENSHARE_STATUS_CHANGED;
5221
5576
  exports.LOCAL_STREAM_CHANGED = LOCAL_STREAM_CHANGED;
5222
5577
  exports.LocalMediaClient = LocalMediaClient;
5223
5578
  exports.LocalParticipant = LocalParticipant;
5579
+ exports.MAX_FILES_PER_UPLOAD = MAX_FILES_PER_UPLOAD;
5580
+ exports.MAX_FILE_SIZE = MAX_FILE_SIZE;
5224
5581
  exports.MICROPHONE_DEVICES_CHANGED = MICROPHONE_DEVICES_CHANGED;
5225
5582
  exports.MICROPHONE_DEVICE_ERROR_CHANGED = MICROPHONE_DEVICE_ERROR_CHANGED;
5226
5583
  exports.MICROPHONE_STATE_CHANGED = MICROPHONE_STATE_CHANGED;
@@ -5247,6 +5604,8 @@ exports.createServices = createServices;
5247
5604
  exports.debounce = debounce;
5248
5605
  exports.getAudioTrack = getAudioTrack;
5249
5606
  exports.getFakeMediaStream = getFakeMediaStream;
5607
+ exports.getUsableCameraEffectPresets = getUsableCameraEffectPresets;
5250
5608
  exports.getVideoTrack = getVideoTrack;
5251
5609
  exports.hasValue = hasValue;
5610
+ exports.isAudioDenoiserSupported = isAudioDenoiserSupported;
5252
5611
  exports.parseUnverifiedRoomKeyData = parseUnverifiedRoomKeyData;