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