@whereby.com/core 1.12.1 → 1.13.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.mjs CHANGED
@@ -969,6 +969,63 @@ class RoomService {
969
969
  }
970
970
  }
971
971
 
972
+ /******************************************************************************
973
+ Copyright (c) Microsoft Corporation.
974
+
975
+ Permission to use, copy, modify, and/or distribute this software for any
976
+ purpose with or without fee is hereby granted.
977
+
978
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
979
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
980
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
981
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
982
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
983
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
984
+ PERFORMANCE OF THIS SOFTWARE.
985
+ ***************************************************************************** */
986
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
987
+
988
+
989
+ function __rest(s, e) {
990
+ var t = {};
991
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
992
+ t[p] = s[p];
993
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
994
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
995
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
996
+ t[p[i]] = s[p[i]];
997
+ }
998
+ return t;
999
+ }
1000
+
1001
+ function __awaiter(thisArg, _arguments, P, generator) {
1002
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
1003
+ return new (P || (P = Promise))(function (resolve, reject) {
1004
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
1005
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
1006
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
1007
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
1008
+ });
1009
+ }
1010
+
1011
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
1012
+ var e = new Error(message);
1013
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
1014
+ };
1015
+
1016
+ function getUsableCameraEffectPresets() {
1017
+ return __awaiter(this, void 0, void 0, function* () {
1018
+ const { getUsablePresets } = yield import('@whereby.com/camera-effects');
1019
+ return getUsablePresets();
1020
+ });
1021
+ }
1022
+ function isAudioDenoiserSupported() {
1023
+ return __awaiter(this, void 0, void 0, function* () {
1024
+ const { canUse } = yield import('@whereby.com/audio-denoiser');
1025
+ return canUse();
1026
+ });
1027
+ }
1028
+
972
1029
  class RoomParticipant {
973
1030
  constructor({ breakoutGroup, displayName, id, isAudioEnabled, isAudioRecorder, isDialIn, isVideoEnabled, stickyReaction, stream, }) {
974
1031
  this.isLocalParticipant = false;
@@ -1156,9 +1213,9 @@ const createReactor = (selectors, callback) => {
1156
1213
  });
1157
1214
  };
1158
1215
 
1159
- const coreVersion = "1.12.1";
1216
+ const coreVersion = "1.13.0";
1160
1217
 
1161
- const initialState$1 = {
1218
+ const initialState$2 = {
1162
1219
  displayName: null,
1163
1220
  externalId: null,
1164
1221
  ignoreBreakoutGroups: false,
@@ -1173,7 +1230,7 @@ const initialState$1 = {
1173
1230
  };
1174
1231
  const appSlice = createSlice({
1175
1232
  name: "app",
1176
- initialState: initialState$1,
1233
+ initialState: initialState$2,
1177
1234
  reducers: {
1178
1235
  doAppStart: (state, action) => {
1179
1236
  const url = new URL(action.payload.roomUrl);
@@ -1336,50 +1393,6 @@ function createAuthorizedRoomConnectedThunk(authorizationSelector, thunk) {
1336
1393
  });
1337
1394
  }
1338
1395
 
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
1396
  const deviceCredentialsSliceInitialState = {
1384
1397
  isFetching: false,
1385
1398
  data: null,
@@ -2097,9 +2110,10 @@ startAppListening({
2097
2110
  const devices = selectLocalMediaDevices(state);
2098
2111
  if (!stream)
2099
2112
  return;
2113
+ const beforeEffectTracks = selectLocalMediaBeforeEffectTracks(state);
2100
2114
  const deviceData = getDeviceData({
2101
- audioTrack: stream.getAudioTracks()[0],
2102
- videoTrack: stream.getVideoTracks()[0],
2115
+ audioTrack: (beforeEffectTracks === null || beforeEffectTracks === void 0 ? void 0 : beforeEffectTracks.audio) || stream.getAudioTracks()[0],
2116
+ videoTrack: (beforeEffectTracks === null || beforeEffectTracks === void 0 ? void 0 : beforeEffectTracks.video) || stream.getVideoTracks()[0],
2103
2117
  devices,
2104
2118
  });
2105
2119
  dispatch(localStreamMetadataUpdated(deviceData));
@@ -4244,13 +4258,13 @@ const doRejectWaitingParticipant = createRoomConnectedThunk((payload) => (dispat
4244
4258
  });
4245
4259
  const selectWaitingParticipants = (state) => state.waitingParticipants.waitingParticipants;
4246
4260
 
4247
- const initialState = {
4261
+ const initialState$1 = {
4248
4262
  isSwitching: false,
4249
4263
  raw: {},
4250
4264
  };
4251
4265
  const cameraEffectsSlice = createSlice({
4252
4266
  name: "cameraEffects",
4253
- initialState,
4267
+ initialState: initialState$1,
4254
4268
  reducers: {
4255
4269
  cameraEffectsSwitching(state, action) {
4256
4270
  state.isSwitching = action.payload.isSwitching;
@@ -4320,7 +4334,7 @@ const doCameraEffectsSwitchPreset = createAppAsyncThunk("cameraEffects/switchPre
4320
4334
  mod = yield import('@whereby.com/camera-effects');
4321
4335
  }
4322
4336
  catch (_f) {
4323
- throw new Error("@whereby.com/camera-effects is not installed. Add it as a dependency to enable camera effects.");
4337
+ throw new Error("Failed to load @whereby.com/camera-effects. Check your network connection and that the package is resolvable.");
4324
4338
  }
4325
4339
  const { createEffectStream, getUsablePresets } = mod;
4326
4340
  const usable = getUsablePresets({ filter: () => true, options: { allowSafari } });
@@ -4348,9 +4362,139 @@ startAppListening({
4348
4362
  },
4349
4363
  });
4350
4364
 
4365
+ const initialState = {
4366
+ wanted: false,
4367
+ isSwitching: false,
4368
+ raw: {},
4369
+ };
4370
+ const audioDenoiserSlice = createSlice({
4371
+ name: "audioDenoiser",
4372
+ initialState,
4373
+ reducers: {
4374
+ audioDenoiserSwitching(state, action) {
4375
+ state.isSwitching = action.payload.isSwitching;
4376
+ },
4377
+ audioDenoiserWantedSet(state, action) {
4378
+ state.wanted = action.payload.wanted;
4379
+ },
4380
+ audioDenoiserApplied(state, action) {
4381
+ state.raw = action.payload;
4382
+ state.error = undefined;
4383
+ state.isSwitching = false;
4384
+ },
4385
+ audioDenoiserCleared(state) {
4386
+ state.raw = {};
4387
+ state.error = undefined;
4388
+ state.isSwitching = false;
4389
+ },
4390
+ audioDenoiserError(state, action) {
4391
+ state.error = action.payload.error;
4392
+ state.isSwitching = false;
4393
+ },
4394
+ },
4395
+ });
4396
+ const { audioDenoiserSwitching, audioDenoiserWantedSet, audioDenoiserApplied, audioDenoiserCleared, audioDenoiserError, } = audioDenoiserSlice.actions;
4397
+ const selectAudioDenoiserRaw = (state) => state.audioDenoiser.raw;
4398
+ const selectAudioDenoiserWanted = (state) => state.audioDenoiser.wanted;
4399
+ const selectAudioDenoiserEnabled = (state) => !!state.audioDenoiser.raw.stop;
4400
+ const doAudioDenoiserApply = createAppAsyncThunk("audioDenoiser/apply", (_1, _a) => __awaiter(void 0, [_1, _a], void 0, function* (_, { getState, dispatch, rejectWithValue }) {
4401
+ var _b;
4402
+ const state = getState();
4403
+ if (selectLocalMediaIsSwitchingStream(state))
4404
+ return;
4405
+ const localStream = selectLocalMediaStream(state);
4406
+ if (!((_b = localStream === null || localStream === void 0 ? void 0 : localStream.getAudioTracks()) === null || _b === void 0 ? void 0 : _b[0])) {
4407
+ return;
4408
+ }
4409
+ if (selectAudioDenoiserEnabled(state))
4410
+ return;
4411
+ dispatch(audioDenoiserSwitching({ isSwitching: true }));
4412
+ try {
4413
+ let mod;
4414
+ try {
4415
+ mod = yield import('@whereby.com/audio-denoiser');
4416
+ }
4417
+ catch (_c) {
4418
+ throw new Error("Failed to load @whereby.com/audio-denoiser. Check your network connection and that the package is resolvable.");
4419
+ }
4420
+ const { applyAudioDenoiser, canUse } = mod;
4421
+ if (!canUse()) {
4422
+ throw new Error("Audio denoiser is not supported in this browser");
4423
+ }
4424
+ const handle = yield applyAudioDenoiser({
4425
+ inputStream: localStream,
4426
+ doCaptureException: (err, ctx) => {
4427
+ console.error("[audioDenoiser]", err, ctx);
4428
+ },
4429
+ });
4430
+ yield dispatch(doLocalStreamEffect({ effectStream: handle.outputStream, only: "audio" }));
4431
+ dispatch(audioDenoiserApplied({
4432
+ stop: handle.stop,
4433
+ outputStream: handle.outputStream,
4434
+ audioContext: handle.audioContext,
4435
+ denoiserNode: handle.denoiserNode,
4436
+ }));
4437
+ }
4438
+ catch (error) {
4439
+ dispatch(audioDenoiserError({ error }));
4440
+ return rejectWithValue(error);
4441
+ }
4442
+ }));
4443
+ const doAudioDenoiserTeardown = createAppAsyncThunk("audioDenoiser/teardown", (_1, _a) => __awaiter(void 0, [_1, _a], void 0, function* (_, { getState, dispatch }) {
4444
+ const raw = selectAudioDenoiserRaw(getState());
4445
+ if (!raw.stop)
4446
+ return;
4447
+ dispatch(audioDenoiserSwitching({ isSwitching: true }));
4448
+ try {
4449
+ if (raw.outputStream) {
4450
+ yield dispatch(doLocalStreamEffect({ effectStream: undefined, only: "audio" }));
4451
+ }
4452
+ raw.stop();
4453
+ }
4454
+ finally {
4455
+ dispatch(audioDenoiserCleared());
4456
+ }
4457
+ }));
4458
+ const doAudioDenoiserEnable = createAppAsyncThunk("audioDenoiser/enable", (_1, _a) => __awaiter(void 0, [_1, _a], void 0, function* (_, { dispatch }) {
4459
+ dispatch(audioDenoiserWantedSet({ wanted: true }));
4460
+ yield dispatch(doAudioDenoiserApply());
4461
+ }));
4462
+ const doAudioDenoiserDisable = createAppAsyncThunk("audioDenoiser/disable", (arg_1, _a) => __awaiter(void 0, [arg_1, _a], void 0, function* (arg, { dispatch }) {
4463
+ if (!(arg === null || arg === void 0 ? void 0 : arg.keepWanted)) {
4464
+ dispatch(audioDenoiserWantedSet({ wanted: false }));
4465
+ }
4466
+ yield dispatch(doAudioDenoiserTeardown());
4467
+ }));
4468
+ startAppListening({
4469
+ actionCreator: doSwitchLocalStream.pending,
4470
+ effect: (_1, _a) => __awaiter(void 0, [_1, _a], void 0, function* (_, { getState, dispatch }) {
4471
+ if (selectAudioDenoiserEnabled(getState())) {
4472
+ yield dispatch(doAudioDenoiserDisable({ keepWanted: true }));
4473
+ }
4474
+ }),
4475
+ });
4476
+ startAppListening({
4477
+ actionCreator: doSwitchLocalStream.fulfilled,
4478
+ effect: (_1, _a) => __awaiter(void 0, [_1, _a], void 0, function* (_, { getState, dispatch }) {
4479
+ const state = getState();
4480
+ if (selectAudioDenoiserWanted(state) && !selectAudioDenoiserEnabled(state)) {
4481
+ yield dispatch(doAudioDenoiserApply());
4482
+ }
4483
+ }),
4484
+ });
4485
+ startAppListening({
4486
+ actionCreator: doAppStop,
4487
+ effect: (_, { dispatch, getState }) => {
4488
+ if (selectAudioDenoiserRaw(getState()).stop) {
4489
+ dispatch(doAudioDenoiserDisable());
4490
+ }
4491
+ },
4492
+ });
4493
+
4351
4494
  const IS_DEV = undefined === "true";
4352
4495
  const appReducer = combineReducers({
4353
4496
  app: appSlice.reducer,
4497
+ audioDenoiser: audioDenoiserSlice.reducer,
4354
4498
  authorization: authorizationSlice.reducer,
4355
4499
  breakout: breakoutSlice.reducer,
4356
4500
  cameraEffects: cameraEffectsSlice.reducer,
@@ -4381,6 +4525,7 @@ const rootReducer = (state, action) => {
4381
4525
  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
4526
  localMedia: Object.assign(Object.assign({}, localMediaSlice.getInitialState()), state === null || state === void 0 ? void 0 : state.localMedia),
4383
4527
  cameraEffects: Object.assign(Object.assign({}, cameraEffectsSlice.getInitialState()), state === null || state === void 0 ? void 0 : state.cameraEffects),
4528
+ audioDenoiser: Object.assign(Object.assign({}, audioDenoiserSlice.getInitialState()), state === null || state === void 0 ? void 0 : state.audioDenoiser),
4384
4529
  };
4385
4530
  return appReducer(resetState, action);
4386
4531
  }
@@ -5143,6 +5288,28 @@ class RoomConnectionClient extends BaseClient {
5143
5288
  return Promise.resolve();
5144
5289
  });
5145
5290
  }
5291
+ enableAudioDenoiser() {
5292
+ return __awaiter(this, void 0, void 0, function* () {
5293
+ try {
5294
+ yield this.store.dispatch(doAudioDenoiserEnable());
5295
+ }
5296
+ catch (error) {
5297
+ return Promise.reject(error);
5298
+ }
5299
+ return Promise.resolve();
5300
+ });
5301
+ }
5302
+ disableAudioDenoiser() {
5303
+ return __awaiter(this, void 0, void 0, function* () {
5304
+ try {
5305
+ yield this.store.dispatch(doAudioDenoiserDisable());
5306
+ }
5307
+ catch (error) {
5308
+ return Promise.reject(error);
5309
+ }
5310
+ return Promise.resolve();
5311
+ });
5312
+ }
5146
5313
  destroy() {
5147
5314
  super.destroy();
5148
5315
  this.store.dispatch(doAppStop());
@@ -5192,4 +5359,4 @@ class WherebyClient {
5192
5359
  }
5193
5360
  }
5194
5361
 
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 };
5362
+ 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, getUsableCameraEffectPresets, getVideoTrack, hasValue, isAudioDenoiserSupported, parseUnverifiedRoomKeyData };