@whereby.com/core 1.15.1 → 1.15.2

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
@@ -1226,7 +1226,7 @@ const createReactor = (selectors, callback) => {
1226
1226
  });
1227
1227
  };
1228
1228
 
1229
- const coreVersion = "1.15.1";
1229
+ const coreVersion = "1.15.2";
1230
1230
 
1231
1231
  const initialState$2 = {
1232
1232
  displayName: null,
@@ -2107,7 +2107,7 @@ startAppListening({
2107
2107
  const oldValue = selectCurrentCameraDeviceId(previousState);
2108
2108
  const newValue = selectCurrentCameraDeviceId(currentState);
2109
2109
  const isReady = selectLocalMediaStatus(previousState) === "started";
2110
- return isReady && oldValue !== newValue;
2110
+ return isReady && !!oldValue && !!newValue && oldValue !== newValue;
2111
2111
  },
2112
2112
  effect: (_action, { dispatch }) => {
2113
2113
  dispatch(doSetDevice({ audio: false, video: true }));
@@ -4511,6 +4511,7 @@ const doRejectWaitingParticipant = createRoomConnectedThunk((payload) => (dispat
4511
4511
  const selectWaitingParticipants = (state) => state.waitingParticipants.waitingParticipants;
4512
4512
 
4513
4513
  const initialState$1 = {
4514
+ isPaused: false,
4514
4515
  isSwitching: false,
4515
4516
  raw: {},
4516
4517
  };
@@ -4525,28 +4526,50 @@ const cameraEffectsSlice = toolkit.createSlice({
4525
4526
  state.currentEffectId = null;
4526
4527
  state.setup = undefined;
4527
4528
  state.params = undefined;
4529
+ state.backgroundUrl = undefined;
4530
+ state.allowSafari = undefined;
4531
+ state.isPaused = false;
4528
4532
  state.raw = {};
4529
4533
  state.error = undefined;
4530
4534
  state.isSwitching = false;
4531
4535
  },
4532
4536
  cameraEffectsUpdated(state, action) {
4533
- const { effectId, setup, params, raw } = action.payload;
4537
+ const { effectId, setup, params, backgroundUrl, allowSafari, raw } = action.payload;
4534
4538
  state.currentEffectId = effectId;
4535
4539
  state.setup = setup;
4536
4540
  state.params = params;
4541
+ state.backgroundUrl = backgroundUrl;
4542
+ state.allowSafari = allowSafari;
4543
+ state.isPaused = false;
4537
4544
  if (raw)
4538
4545
  state.raw = raw;
4539
4546
  state.error = undefined;
4540
4547
  state.isSwitching = false;
4541
4548
  },
4549
+ cameraEffectsPaused(state, action) {
4550
+ const payload = action.payload;
4551
+ if ((payload === null || payload === void 0 ? void 0 : payload.effectId) !== undefined) {
4552
+ state.currentEffectId = payload.effectId;
4553
+ state.setup = payload.setup;
4554
+ state.params = payload.params;
4555
+ state.backgroundUrl = payload.backgroundUrl;
4556
+ state.allowSafari = payload.allowSafari;
4557
+ }
4558
+ state.isPaused = true;
4559
+ state.raw = {};
4560
+ state.error = undefined;
4561
+ state.isSwitching = false;
4562
+ },
4542
4563
  cameraEffectsError(state, action) {
4543
4564
  state.error = action.payload.error;
4544
4565
  state.isSwitching = false;
4545
4566
  },
4546
4567
  },
4547
4568
  });
4548
- const { cameraEffectsSwitching, cameraEffectsCleared, cameraEffectsUpdated, cameraEffectsError } = cameraEffectsSlice.actions;
4569
+ const { cameraEffectsSwitching, cameraEffectsCleared, cameraEffectsUpdated, cameraEffectsPaused, cameraEffectsError, } = cameraEffectsSlice.actions;
4549
4570
  const selectCameraEffectsRaw = (state) => state.cameraEffects.raw;
4571
+ const selectCameraEffectId = (state) => state.cameraEffects.currentEffectId;
4572
+ const selectIsCameraEffectPaused = (state) => state.cameraEffects.isPaused;
4550
4573
  const doCameraEffectsSwitchPreset = createAppAsyncThunk("cameraEffects/switchPreset", (_a, _b) => __awaiter(void 0, [_a, _b], void 0, function* ({ effectId, setup, params, allowSafari, backgroundUrl, }, { getState, dispatch, rejectWithValue }) {
4551
4574
  var _c, _d, _e;
4552
4575
  const state = getState();
@@ -4559,7 +4582,12 @@ const doCameraEffectsSwitchPreset = createAppAsyncThunk("cameraEffects/switchPre
4559
4582
  const raw = selectCameraEffectsRaw(state);
4560
4583
  const localStream = selectLocalMediaStream(state);
4561
4584
  if (!((_c = localStream === null || localStream === void 0 ? void 0 : localStream.getVideoTracks()) === null || _c === void 0 ? void 0 : _c[0])) {
4562
- dispatch(cameraEffectsCleared());
4585
+ if (!effectId) {
4586
+ dispatch(cameraEffectsCleared());
4587
+ }
4588
+ else {
4589
+ dispatch(cameraEffectsPaused({ effectId, setup, params, backgroundUrl, allowSafari }));
4590
+ }
4563
4591
  return;
4564
4592
  }
4565
4593
  if (!effectId) {
@@ -4573,7 +4601,7 @@ const doCameraEffectsSwitchPreset = createAppAsyncThunk("cameraEffects/switchPre
4573
4601
  if (raw.tryUpdate) {
4574
4602
  const ok = yield raw.tryUpdate(effectId, Object.assign({}, (setup || {})), mergedParams);
4575
4603
  if (ok) {
4576
- dispatch(cameraEffectsUpdated({ effectId, setup, params }));
4604
+ dispatch(cameraEffectsUpdated({ effectId, setup, params, backgroundUrl, allowSafari }));
4577
4605
  return;
4578
4606
  }
4579
4607
  }
@@ -4595,7 +4623,14 @@ const doCameraEffectsSwitchPreset = createAppAsyncThunk("cameraEffects/switchPre
4595
4623
  }
4596
4624
  const { stream: effectStream, stop, tryUpdate, } = yield createEffectStream(localStream, effectId, setup, mergedParams);
4597
4625
  yield dispatch(doLocalStreamEffect({ effectStream, only: "video" }));
4598
- dispatch(cameraEffectsUpdated({ effectId, setup, params, raw: { stop, tryUpdate, effectStream } }));
4626
+ dispatch(cameraEffectsUpdated({
4627
+ effectId,
4628
+ setup,
4629
+ params,
4630
+ backgroundUrl,
4631
+ allowSafari,
4632
+ raw: { stop, tryUpdate, effectStream },
4633
+ }));
4599
4634
  }
4600
4635
  catch (error) {
4601
4636
  dispatch(cameraEffectsError({ error }));
@@ -4605,6 +4640,22 @@ const doCameraEffectsSwitchPreset = createAppAsyncThunk("cameraEffects/switchPre
4605
4640
  const doCameraEffectsClear = createAppAsyncThunk("cameraEffects/clear", (_1, _a) => __awaiter(void 0, [_1, _a], void 0, function* (_, { dispatch }) {
4606
4641
  yield dispatch(doCameraEffectsSwitchPreset({ effectId: null }));
4607
4642
  }));
4643
+ const doCameraEffectsPause = createAppAsyncThunk("cameraEffects/pause", (_1, _a) => __awaiter(void 0, [_1, _a], void 0, function* (_, { dispatch, getState }) {
4644
+ var _b;
4645
+ const raw = selectCameraEffectsRaw(getState());
4646
+ (_b = raw.stop) === null || _b === void 0 ? void 0 : _b.call(raw);
4647
+ yield dispatch(doLocalStreamEffect({ effectStream: undefined, only: "video", stopBeforeTrack: true }));
4648
+ dispatch(cameraEffectsPaused());
4649
+ }));
4650
+ const doCameraEffectsResume = createAppAsyncThunk("cameraEffects/resume", (_1, _a) => __awaiter(void 0, [_1, _a], void 0, function* (_, { dispatch, getState }) {
4651
+ const state = getState();
4652
+ const effectId = selectCameraEffectId(state);
4653
+ if (!effectId) {
4654
+ return;
4655
+ }
4656
+ const { setup, params, backgroundUrl, allowSafari } = state.cameraEffects;
4657
+ yield dispatch(doCameraEffectsSwitchPreset({ effectId, setup, params, backgroundUrl, allowSafari }));
4658
+ }));
4608
4659
  startAppListening({
4609
4660
  actionCreator: doAppStop,
4610
4661
  effect: (_, { dispatch, getState }) => {
@@ -4613,6 +4664,28 @@ startAppListening({
4613
4664
  }
4614
4665
  },
4615
4666
  });
4667
+ startAppListening({
4668
+ actionCreator: doToggleCamera.fulfilled,
4669
+ effect: (_, { dispatch, getState }) => {
4670
+ var _a;
4671
+ const state = getState();
4672
+ const cameraEnabled = selectIsCameraEnabled(state);
4673
+ const effectId = selectCameraEffectId(state);
4674
+ const isPaused = selectIsCameraEffectPaused(state);
4675
+ if (!cameraEnabled) {
4676
+ const raw = selectCameraEffectsRaw(state);
4677
+ if (effectId && raw.stop && !isPaused) {
4678
+ dispatch(doCameraEffectsPause());
4679
+ }
4680
+ }
4681
+ else if (effectId && isPaused) {
4682
+ const stream = selectLocalMediaStream(state);
4683
+ if ((_a = stream === null || stream === void 0 ? void 0 : stream.getVideoTracks()) === null || _a === void 0 ? void 0 : _a[0]) {
4684
+ dispatch(doCameraEffectsResume());
4685
+ }
4686
+ }
4687
+ },
4688
+ });
4616
4689
 
4617
4690
  const initialState = {
4618
4691
  wanted: false,
package/dist/index.d.cts CHANGED
@@ -643,6 +643,9 @@ interface CameraEffectsState {
643
643
  currentEffectId?: string | null;
644
644
  setup?: Setup;
645
645
  params?: Params;
646
+ backgroundUrl?: string;
647
+ allowSafari?: boolean;
648
+ isPaused: boolean;
646
649
  isSwitching: boolean;
647
650
  error?: unknown;
648
651
  raw: {
package/dist/index.d.mts CHANGED
@@ -643,6 +643,9 @@ interface CameraEffectsState {
643
643
  currentEffectId?: string | null;
644
644
  setup?: Setup;
645
645
  params?: Params;
646
+ backgroundUrl?: string;
647
+ allowSafari?: boolean;
648
+ isPaused: boolean;
646
649
  isSwitching: boolean;
647
650
  error?: unknown;
648
651
  raw: {
package/dist/index.d.ts CHANGED
@@ -643,6 +643,9 @@ interface CameraEffectsState {
643
643
  currentEffectId?: string | null;
644
644
  setup?: Setup;
645
645
  params?: Params;
646
+ backgroundUrl?: string;
647
+ allowSafari?: boolean;
648
+ isPaused: boolean;
646
649
  isSwitching: boolean;
647
650
  error?: unknown;
648
651
  raw: {
package/dist/index.mjs CHANGED
@@ -1224,7 +1224,7 @@ const createReactor = (selectors, callback) => {
1224
1224
  });
1225
1225
  };
1226
1226
 
1227
- const coreVersion = "1.15.1";
1227
+ const coreVersion = "1.15.2";
1228
1228
 
1229
1229
  const initialState$2 = {
1230
1230
  displayName: null,
@@ -2105,7 +2105,7 @@ startAppListening({
2105
2105
  const oldValue = selectCurrentCameraDeviceId(previousState);
2106
2106
  const newValue = selectCurrentCameraDeviceId(currentState);
2107
2107
  const isReady = selectLocalMediaStatus(previousState) === "started";
2108
- return isReady && oldValue !== newValue;
2108
+ return isReady && !!oldValue && !!newValue && oldValue !== newValue;
2109
2109
  },
2110
2110
  effect: (_action, { dispatch }) => {
2111
2111
  dispatch(doSetDevice({ audio: false, video: true }));
@@ -4509,6 +4509,7 @@ const doRejectWaitingParticipant = createRoomConnectedThunk((payload) => (dispat
4509
4509
  const selectWaitingParticipants = (state) => state.waitingParticipants.waitingParticipants;
4510
4510
 
4511
4511
  const initialState$1 = {
4512
+ isPaused: false,
4512
4513
  isSwitching: false,
4513
4514
  raw: {},
4514
4515
  };
@@ -4523,28 +4524,50 @@ const cameraEffectsSlice = createSlice({
4523
4524
  state.currentEffectId = null;
4524
4525
  state.setup = undefined;
4525
4526
  state.params = undefined;
4527
+ state.backgroundUrl = undefined;
4528
+ state.allowSafari = undefined;
4529
+ state.isPaused = false;
4526
4530
  state.raw = {};
4527
4531
  state.error = undefined;
4528
4532
  state.isSwitching = false;
4529
4533
  },
4530
4534
  cameraEffectsUpdated(state, action) {
4531
- const { effectId, setup, params, raw } = action.payload;
4535
+ const { effectId, setup, params, backgroundUrl, allowSafari, raw } = action.payload;
4532
4536
  state.currentEffectId = effectId;
4533
4537
  state.setup = setup;
4534
4538
  state.params = params;
4539
+ state.backgroundUrl = backgroundUrl;
4540
+ state.allowSafari = allowSafari;
4541
+ state.isPaused = false;
4535
4542
  if (raw)
4536
4543
  state.raw = raw;
4537
4544
  state.error = undefined;
4538
4545
  state.isSwitching = false;
4539
4546
  },
4547
+ cameraEffectsPaused(state, action) {
4548
+ const payload = action.payload;
4549
+ if ((payload === null || payload === void 0 ? void 0 : payload.effectId) !== undefined) {
4550
+ state.currentEffectId = payload.effectId;
4551
+ state.setup = payload.setup;
4552
+ state.params = payload.params;
4553
+ state.backgroundUrl = payload.backgroundUrl;
4554
+ state.allowSafari = payload.allowSafari;
4555
+ }
4556
+ state.isPaused = true;
4557
+ state.raw = {};
4558
+ state.error = undefined;
4559
+ state.isSwitching = false;
4560
+ },
4540
4561
  cameraEffectsError(state, action) {
4541
4562
  state.error = action.payload.error;
4542
4563
  state.isSwitching = false;
4543
4564
  },
4544
4565
  },
4545
4566
  });
4546
- const { cameraEffectsSwitching, cameraEffectsCleared, cameraEffectsUpdated, cameraEffectsError } = cameraEffectsSlice.actions;
4567
+ const { cameraEffectsSwitching, cameraEffectsCleared, cameraEffectsUpdated, cameraEffectsPaused, cameraEffectsError, } = cameraEffectsSlice.actions;
4547
4568
  const selectCameraEffectsRaw = (state) => state.cameraEffects.raw;
4569
+ const selectCameraEffectId = (state) => state.cameraEffects.currentEffectId;
4570
+ const selectIsCameraEffectPaused = (state) => state.cameraEffects.isPaused;
4548
4571
  const doCameraEffectsSwitchPreset = createAppAsyncThunk("cameraEffects/switchPreset", (_a, _b) => __awaiter(void 0, [_a, _b], void 0, function* ({ effectId, setup, params, allowSafari, backgroundUrl, }, { getState, dispatch, rejectWithValue }) {
4549
4572
  var _c, _d, _e;
4550
4573
  const state = getState();
@@ -4557,7 +4580,12 @@ const doCameraEffectsSwitchPreset = createAppAsyncThunk("cameraEffects/switchPre
4557
4580
  const raw = selectCameraEffectsRaw(state);
4558
4581
  const localStream = selectLocalMediaStream(state);
4559
4582
  if (!((_c = localStream === null || localStream === void 0 ? void 0 : localStream.getVideoTracks()) === null || _c === void 0 ? void 0 : _c[0])) {
4560
- dispatch(cameraEffectsCleared());
4583
+ if (!effectId) {
4584
+ dispatch(cameraEffectsCleared());
4585
+ }
4586
+ else {
4587
+ dispatch(cameraEffectsPaused({ effectId, setup, params, backgroundUrl, allowSafari }));
4588
+ }
4561
4589
  return;
4562
4590
  }
4563
4591
  if (!effectId) {
@@ -4571,7 +4599,7 @@ const doCameraEffectsSwitchPreset = createAppAsyncThunk("cameraEffects/switchPre
4571
4599
  if (raw.tryUpdate) {
4572
4600
  const ok = yield raw.tryUpdate(effectId, Object.assign({}, (setup || {})), mergedParams);
4573
4601
  if (ok) {
4574
- dispatch(cameraEffectsUpdated({ effectId, setup, params }));
4602
+ dispatch(cameraEffectsUpdated({ effectId, setup, params, backgroundUrl, allowSafari }));
4575
4603
  return;
4576
4604
  }
4577
4605
  }
@@ -4593,7 +4621,14 @@ const doCameraEffectsSwitchPreset = createAppAsyncThunk("cameraEffects/switchPre
4593
4621
  }
4594
4622
  const { stream: effectStream, stop, tryUpdate, } = yield createEffectStream(localStream, effectId, setup, mergedParams);
4595
4623
  yield dispatch(doLocalStreamEffect({ effectStream, only: "video" }));
4596
- dispatch(cameraEffectsUpdated({ effectId, setup, params, raw: { stop, tryUpdate, effectStream } }));
4624
+ dispatch(cameraEffectsUpdated({
4625
+ effectId,
4626
+ setup,
4627
+ params,
4628
+ backgroundUrl,
4629
+ allowSafari,
4630
+ raw: { stop, tryUpdate, effectStream },
4631
+ }));
4597
4632
  }
4598
4633
  catch (error) {
4599
4634
  dispatch(cameraEffectsError({ error }));
@@ -4603,6 +4638,22 @@ const doCameraEffectsSwitchPreset = createAppAsyncThunk("cameraEffects/switchPre
4603
4638
  const doCameraEffectsClear = createAppAsyncThunk("cameraEffects/clear", (_1, _a) => __awaiter(void 0, [_1, _a], void 0, function* (_, { dispatch }) {
4604
4639
  yield dispatch(doCameraEffectsSwitchPreset({ effectId: null }));
4605
4640
  }));
4641
+ const doCameraEffectsPause = createAppAsyncThunk("cameraEffects/pause", (_1, _a) => __awaiter(void 0, [_1, _a], void 0, function* (_, { dispatch, getState }) {
4642
+ var _b;
4643
+ const raw = selectCameraEffectsRaw(getState());
4644
+ (_b = raw.stop) === null || _b === void 0 ? void 0 : _b.call(raw);
4645
+ yield dispatch(doLocalStreamEffect({ effectStream: undefined, only: "video", stopBeforeTrack: true }));
4646
+ dispatch(cameraEffectsPaused());
4647
+ }));
4648
+ const doCameraEffectsResume = createAppAsyncThunk("cameraEffects/resume", (_1, _a) => __awaiter(void 0, [_1, _a], void 0, function* (_, { dispatch, getState }) {
4649
+ const state = getState();
4650
+ const effectId = selectCameraEffectId(state);
4651
+ if (!effectId) {
4652
+ return;
4653
+ }
4654
+ const { setup, params, backgroundUrl, allowSafari } = state.cameraEffects;
4655
+ yield dispatch(doCameraEffectsSwitchPreset({ effectId, setup, params, backgroundUrl, allowSafari }));
4656
+ }));
4606
4657
  startAppListening({
4607
4658
  actionCreator: doAppStop,
4608
4659
  effect: (_, { dispatch, getState }) => {
@@ -4611,6 +4662,28 @@ startAppListening({
4611
4662
  }
4612
4663
  },
4613
4664
  });
4665
+ startAppListening({
4666
+ actionCreator: doToggleCamera.fulfilled,
4667
+ effect: (_, { dispatch, getState }) => {
4668
+ var _a;
4669
+ const state = getState();
4670
+ const cameraEnabled = selectIsCameraEnabled(state);
4671
+ const effectId = selectCameraEffectId(state);
4672
+ const isPaused = selectIsCameraEffectPaused(state);
4673
+ if (!cameraEnabled) {
4674
+ const raw = selectCameraEffectsRaw(state);
4675
+ if (effectId && raw.stop && !isPaused) {
4676
+ dispatch(doCameraEffectsPause());
4677
+ }
4678
+ }
4679
+ else if (effectId && isPaused) {
4680
+ const stream = selectLocalMediaStream(state);
4681
+ if ((_a = stream === null || stream === void 0 ? void 0 : stream.getVideoTracks()) === null || _a === void 0 ? void 0 : _a[0]) {
4682
+ dispatch(doCameraEffectsResume());
4683
+ }
4684
+ }
4685
+ },
4686
+ });
4614
4687
 
4615
4688
  const initialState = {
4616
4689
  wanted: false,
@@ -1224,7 +1224,7 @@ const createReactor = (selectors, callback) => {
1224
1224
  });
1225
1225
  };
1226
1226
 
1227
- const coreVersion = "1.15.1";
1227
+ const coreVersion = "1.15.2";
1228
1228
 
1229
1229
  const initialState$2 = {
1230
1230
  displayName: null,
@@ -2105,7 +2105,7 @@ startAppListening({
2105
2105
  const oldValue = selectCurrentCameraDeviceId(previousState);
2106
2106
  const newValue = selectCurrentCameraDeviceId(currentState);
2107
2107
  const isReady = selectLocalMediaStatus(previousState) === "started";
2108
- return isReady && oldValue !== newValue;
2108
+ return isReady && !!oldValue && !!newValue && oldValue !== newValue;
2109
2109
  },
2110
2110
  effect: (_action, { dispatch }) => {
2111
2111
  dispatch(doSetDevice({ audio: false, video: true }));
@@ -4509,6 +4509,7 @@ const doRejectWaitingParticipant = createRoomConnectedThunk((payload) => (dispat
4509
4509
  const selectWaitingParticipants = (state) => state.waitingParticipants.waitingParticipants;
4510
4510
 
4511
4511
  const initialState$1 = {
4512
+ isPaused: false,
4512
4513
  isSwitching: false,
4513
4514
  raw: {},
4514
4515
  };
@@ -4523,28 +4524,50 @@ const cameraEffectsSlice = createSlice({
4523
4524
  state.currentEffectId = null;
4524
4525
  state.setup = undefined;
4525
4526
  state.params = undefined;
4527
+ state.backgroundUrl = undefined;
4528
+ state.allowSafari = undefined;
4529
+ state.isPaused = false;
4526
4530
  state.raw = {};
4527
4531
  state.error = undefined;
4528
4532
  state.isSwitching = false;
4529
4533
  },
4530
4534
  cameraEffectsUpdated(state, action) {
4531
- const { effectId, setup, params, raw } = action.payload;
4535
+ const { effectId, setup, params, backgroundUrl, allowSafari, raw } = action.payload;
4532
4536
  state.currentEffectId = effectId;
4533
4537
  state.setup = setup;
4534
4538
  state.params = params;
4539
+ state.backgroundUrl = backgroundUrl;
4540
+ state.allowSafari = allowSafari;
4541
+ state.isPaused = false;
4535
4542
  if (raw)
4536
4543
  state.raw = raw;
4537
4544
  state.error = undefined;
4538
4545
  state.isSwitching = false;
4539
4546
  },
4547
+ cameraEffectsPaused(state, action) {
4548
+ const payload = action.payload;
4549
+ if ((payload === null || payload === void 0 ? void 0 : payload.effectId) !== undefined) {
4550
+ state.currentEffectId = payload.effectId;
4551
+ state.setup = payload.setup;
4552
+ state.params = payload.params;
4553
+ state.backgroundUrl = payload.backgroundUrl;
4554
+ state.allowSafari = payload.allowSafari;
4555
+ }
4556
+ state.isPaused = true;
4557
+ state.raw = {};
4558
+ state.error = undefined;
4559
+ state.isSwitching = false;
4560
+ },
4540
4561
  cameraEffectsError(state, action) {
4541
4562
  state.error = action.payload.error;
4542
4563
  state.isSwitching = false;
4543
4564
  },
4544
4565
  },
4545
4566
  });
4546
- const { cameraEffectsSwitching, cameraEffectsCleared, cameraEffectsUpdated, cameraEffectsError } = cameraEffectsSlice.actions;
4567
+ const { cameraEffectsSwitching, cameraEffectsCleared, cameraEffectsUpdated, cameraEffectsPaused, cameraEffectsError, } = cameraEffectsSlice.actions;
4547
4568
  const selectCameraEffectsRaw = (state) => state.cameraEffects.raw;
4569
+ const selectCameraEffectId = (state) => state.cameraEffects.currentEffectId;
4570
+ const selectIsCameraEffectPaused = (state) => state.cameraEffects.isPaused;
4548
4571
  const doCameraEffectsSwitchPreset = createAppAsyncThunk("cameraEffects/switchPreset", (_a, _b) => __awaiter(void 0, [_a, _b], void 0, function* ({ effectId, setup, params, allowSafari, backgroundUrl, }, { getState, dispatch, rejectWithValue }) {
4549
4572
  var _c, _d, _e;
4550
4573
  const state = getState();
@@ -4557,7 +4580,12 @@ const doCameraEffectsSwitchPreset = createAppAsyncThunk("cameraEffects/switchPre
4557
4580
  const raw = selectCameraEffectsRaw(state);
4558
4581
  const localStream = selectLocalMediaStream(state);
4559
4582
  if (!((_c = localStream === null || localStream === void 0 ? void 0 : localStream.getVideoTracks()) === null || _c === void 0 ? void 0 : _c[0])) {
4560
- dispatch(cameraEffectsCleared());
4583
+ if (!effectId) {
4584
+ dispatch(cameraEffectsCleared());
4585
+ }
4586
+ else {
4587
+ dispatch(cameraEffectsPaused({ effectId, setup, params, backgroundUrl, allowSafari }));
4588
+ }
4561
4589
  return;
4562
4590
  }
4563
4591
  if (!effectId) {
@@ -4571,7 +4599,7 @@ const doCameraEffectsSwitchPreset = createAppAsyncThunk("cameraEffects/switchPre
4571
4599
  if (raw.tryUpdate) {
4572
4600
  const ok = yield raw.tryUpdate(effectId, Object.assign({}, (setup || {})), mergedParams);
4573
4601
  if (ok) {
4574
- dispatch(cameraEffectsUpdated({ effectId, setup, params }));
4602
+ dispatch(cameraEffectsUpdated({ effectId, setup, params, backgroundUrl, allowSafari }));
4575
4603
  return;
4576
4604
  }
4577
4605
  }
@@ -4593,7 +4621,14 @@ const doCameraEffectsSwitchPreset = createAppAsyncThunk("cameraEffects/switchPre
4593
4621
  }
4594
4622
  const { stream: effectStream, stop, tryUpdate, } = yield createEffectStream(localStream, effectId, setup, mergedParams);
4595
4623
  yield dispatch(doLocalStreamEffect({ effectStream, only: "video" }));
4596
- dispatch(cameraEffectsUpdated({ effectId, setup, params, raw: { stop, tryUpdate, effectStream } }));
4624
+ dispatch(cameraEffectsUpdated({
4625
+ effectId,
4626
+ setup,
4627
+ params,
4628
+ backgroundUrl,
4629
+ allowSafari,
4630
+ raw: { stop, tryUpdate, effectStream },
4631
+ }));
4597
4632
  }
4598
4633
  catch (error) {
4599
4634
  dispatch(cameraEffectsError({ error }));
@@ -4603,6 +4638,22 @@ const doCameraEffectsSwitchPreset = createAppAsyncThunk("cameraEffects/switchPre
4603
4638
  const doCameraEffectsClear = createAppAsyncThunk("cameraEffects/clear", (_1, _a) => __awaiter(void 0, [_1, _a], void 0, function* (_, { dispatch }) {
4604
4639
  yield dispatch(doCameraEffectsSwitchPreset({ effectId: null }));
4605
4640
  }));
4641
+ const doCameraEffectsPause = createAppAsyncThunk("cameraEffects/pause", (_1, _a) => __awaiter(void 0, [_1, _a], void 0, function* (_, { dispatch, getState }) {
4642
+ var _b;
4643
+ const raw = selectCameraEffectsRaw(getState());
4644
+ (_b = raw.stop) === null || _b === void 0 ? void 0 : _b.call(raw);
4645
+ yield dispatch(doLocalStreamEffect({ effectStream: undefined, only: "video", stopBeforeTrack: true }));
4646
+ dispatch(cameraEffectsPaused());
4647
+ }));
4648
+ const doCameraEffectsResume = createAppAsyncThunk("cameraEffects/resume", (_1, _a) => __awaiter(void 0, [_1, _a], void 0, function* (_, { dispatch, getState }) {
4649
+ const state = getState();
4650
+ const effectId = selectCameraEffectId(state);
4651
+ if (!effectId) {
4652
+ return;
4653
+ }
4654
+ const { setup, params, backgroundUrl, allowSafari } = state.cameraEffects;
4655
+ yield dispatch(doCameraEffectsSwitchPreset({ effectId, setup, params, backgroundUrl, allowSafari }));
4656
+ }));
4606
4657
  startAppListening({
4607
4658
  actionCreator: doAppStop,
4608
4659
  effect: (_, { dispatch, getState }) => {
@@ -4611,6 +4662,28 @@ startAppListening({
4611
4662
  }
4612
4663
  },
4613
4664
  });
4665
+ startAppListening({
4666
+ actionCreator: doToggleCamera.fulfilled,
4667
+ effect: (_, { dispatch, getState }) => {
4668
+ var _a;
4669
+ const state = getState();
4670
+ const cameraEnabled = selectIsCameraEnabled(state);
4671
+ const effectId = selectCameraEffectId(state);
4672
+ const isPaused = selectIsCameraEffectPaused(state);
4673
+ if (!cameraEnabled) {
4674
+ const raw = selectCameraEffectsRaw(state);
4675
+ if (effectId && raw.stop && !isPaused) {
4676
+ dispatch(doCameraEffectsPause());
4677
+ }
4678
+ }
4679
+ else if (effectId && isPaused) {
4680
+ const stream = selectLocalMediaStream(state);
4681
+ if ((_a = stream === null || stream === void 0 ? void 0 : stream.getVideoTracks()) === null || _a === void 0 ? void 0 : _a[0]) {
4682
+ dispatch(doCameraEffectsResume());
4683
+ }
4684
+ }
4685
+ },
4686
+ });
4614
4687
 
4615
4688
  const initialState = {
4616
4689
  wanted: false,
@@ -76,7 +76,7 @@ const createReactor = (selectors, callback) => {
76
76
  });
77
77
  };
78
78
 
79
- const coreVersion = "1.15.1";
79
+ const coreVersion = "1.15.2";
80
80
 
81
81
  const initialState$2 = {
82
82
  displayName: null,
@@ -975,7 +975,7 @@ startAppListening({
975
975
  const oldValue = selectCurrentCameraDeviceId(previousState);
976
976
  const newValue = selectCurrentCameraDeviceId(currentState);
977
977
  const isReady = selectLocalMediaStatus(previousState) === "started";
978
- return isReady && oldValue !== newValue;
978
+ return isReady && !!oldValue && !!newValue && oldValue !== newValue;
979
979
  },
980
980
  effect: (_action, { dispatch }) => {
981
981
  dispatch(doSetDevice({ audio: false, video: true }));
@@ -3421,6 +3421,7 @@ const selectWaitingParticipantsRaw = (state) => state.waitingParticipants;
3421
3421
  const selectWaitingParticipants = (state) => state.waitingParticipants.waitingParticipants;
3422
3422
 
3423
3423
  const initialState$1 = {
3424
+ isPaused: false,
3424
3425
  isSwitching: false,
3425
3426
  raw: {},
3426
3427
  };
@@ -3435,28 +3436,50 @@ const cameraEffectsSlice = toolkit.createSlice({
3435
3436
  state.currentEffectId = null;
3436
3437
  state.setup = undefined;
3437
3438
  state.params = undefined;
3439
+ state.backgroundUrl = undefined;
3440
+ state.allowSafari = undefined;
3441
+ state.isPaused = false;
3438
3442
  state.raw = {};
3439
3443
  state.error = undefined;
3440
3444
  state.isSwitching = false;
3441
3445
  },
3442
3446
  cameraEffectsUpdated(state, action) {
3443
- const { effectId, setup, params, raw } = action.payload;
3447
+ const { effectId, setup, params, backgroundUrl, allowSafari, raw } = action.payload;
3444
3448
  state.currentEffectId = effectId;
3445
3449
  state.setup = setup;
3446
3450
  state.params = params;
3451
+ state.backgroundUrl = backgroundUrl;
3452
+ state.allowSafari = allowSafari;
3453
+ state.isPaused = false;
3447
3454
  if (raw)
3448
3455
  state.raw = raw;
3449
3456
  state.error = undefined;
3450
3457
  state.isSwitching = false;
3451
3458
  },
3459
+ cameraEffectsPaused(state, action) {
3460
+ const payload = action.payload;
3461
+ if ((payload === null || payload === void 0 ? void 0 : payload.effectId) !== undefined) {
3462
+ state.currentEffectId = payload.effectId;
3463
+ state.setup = payload.setup;
3464
+ state.params = payload.params;
3465
+ state.backgroundUrl = payload.backgroundUrl;
3466
+ state.allowSafari = payload.allowSafari;
3467
+ }
3468
+ state.isPaused = true;
3469
+ state.raw = {};
3470
+ state.error = undefined;
3471
+ state.isSwitching = false;
3472
+ },
3452
3473
  cameraEffectsError(state, action) {
3453
3474
  state.error = action.payload.error;
3454
3475
  state.isSwitching = false;
3455
3476
  },
3456
3477
  },
3457
3478
  });
3458
- const { cameraEffectsSwitching, cameraEffectsCleared, cameraEffectsUpdated, cameraEffectsError } = cameraEffectsSlice.actions;
3479
+ const { cameraEffectsSwitching, cameraEffectsCleared, cameraEffectsUpdated, cameraEffectsPaused, cameraEffectsError, } = cameraEffectsSlice.actions;
3459
3480
  const selectCameraEffectsRaw = (state) => state.cameraEffects.raw;
3481
+ const selectCameraEffectId = (state) => state.cameraEffects.currentEffectId;
3482
+ const selectIsCameraEffectPaused = (state) => state.cameraEffects.isPaused;
3460
3483
  const doCameraEffectsSwitchPreset = createAppAsyncThunk("cameraEffects/switchPreset", (_a, _b) => __awaiter(void 0, [_a, _b], void 0, function* ({ effectId, setup, params, allowSafari, backgroundUrl, }, { getState, dispatch, rejectWithValue }) {
3461
3484
  var _c, _d, _e;
3462
3485
  const state = getState();
@@ -3469,7 +3492,12 @@ const doCameraEffectsSwitchPreset = createAppAsyncThunk("cameraEffects/switchPre
3469
3492
  const raw = selectCameraEffectsRaw(state);
3470
3493
  const localStream = selectLocalMediaStream(state);
3471
3494
  if (!((_c = localStream === null || localStream === void 0 ? void 0 : localStream.getVideoTracks()) === null || _c === void 0 ? void 0 : _c[0])) {
3472
- dispatch(cameraEffectsCleared());
3495
+ if (!effectId) {
3496
+ dispatch(cameraEffectsCleared());
3497
+ }
3498
+ else {
3499
+ dispatch(cameraEffectsPaused({ effectId, setup, params, backgroundUrl, allowSafari }));
3500
+ }
3473
3501
  return;
3474
3502
  }
3475
3503
  if (!effectId) {
@@ -3483,7 +3511,7 @@ const doCameraEffectsSwitchPreset = createAppAsyncThunk("cameraEffects/switchPre
3483
3511
  if (raw.tryUpdate) {
3484
3512
  const ok = yield raw.tryUpdate(effectId, Object.assign({}, (setup || {})), mergedParams);
3485
3513
  if (ok) {
3486
- dispatch(cameraEffectsUpdated({ effectId, setup, params }));
3514
+ dispatch(cameraEffectsUpdated({ effectId, setup, params, backgroundUrl, allowSafari }));
3487
3515
  return;
3488
3516
  }
3489
3517
  }
@@ -3505,7 +3533,14 @@ const doCameraEffectsSwitchPreset = createAppAsyncThunk("cameraEffects/switchPre
3505
3533
  }
3506
3534
  const { stream: effectStream, stop, tryUpdate, } = yield createEffectStream(localStream, effectId, setup, mergedParams);
3507
3535
  yield dispatch(doLocalStreamEffect({ effectStream, only: "video" }));
3508
- dispatch(cameraEffectsUpdated({ effectId, setup, params, raw: { stop, tryUpdate, effectStream } }));
3536
+ dispatch(cameraEffectsUpdated({
3537
+ effectId,
3538
+ setup,
3539
+ params,
3540
+ backgroundUrl,
3541
+ allowSafari,
3542
+ raw: { stop, tryUpdate, effectStream },
3543
+ }));
3509
3544
  }
3510
3545
  catch (error) {
3511
3546
  dispatch(cameraEffectsError({ error }));
@@ -3515,6 +3550,22 @@ const doCameraEffectsSwitchPreset = createAppAsyncThunk("cameraEffects/switchPre
3515
3550
  const doCameraEffectsClear = createAppAsyncThunk("cameraEffects/clear", (_1, _a) => __awaiter(void 0, [_1, _a], void 0, function* (_, { dispatch }) {
3516
3551
  yield dispatch(doCameraEffectsSwitchPreset({ effectId: null }));
3517
3552
  }));
3553
+ const doCameraEffectsPause = createAppAsyncThunk("cameraEffects/pause", (_1, _a) => __awaiter(void 0, [_1, _a], void 0, function* (_, { dispatch, getState }) {
3554
+ var _b;
3555
+ const raw = selectCameraEffectsRaw(getState());
3556
+ (_b = raw.stop) === null || _b === void 0 ? void 0 : _b.call(raw);
3557
+ yield dispatch(doLocalStreamEffect({ effectStream: undefined, only: "video", stopBeforeTrack: true }));
3558
+ dispatch(cameraEffectsPaused());
3559
+ }));
3560
+ const doCameraEffectsResume = createAppAsyncThunk("cameraEffects/resume", (_1, _a) => __awaiter(void 0, [_1, _a], void 0, function* (_, { dispatch, getState }) {
3561
+ const state = getState();
3562
+ const effectId = selectCameraEffectId(state);
3563
+ if (!effectId) {
3564
+ return;
3565
+ }
3566
+ const { setup, params, backgroundUrl, allowSafari } = state.cameraEffects;
3567
+ yield dispatch(doCameraEffectsSwitchPreset({ effectId, setup, params, backgroundUrl, allowSafari }));
3568
+ }));
3518
3569
  startAppListening({
3519
3570
  actionCreator: doAppStop,
3520
3571
  effect: (_, { dispatch, getState }) => {
@@ -3523,6 +3574,28 @@ startAppListening({
3523
3574
  }
3524
3575
  },
3525
3576
  });
3577
+ startAppListening({
3578
+ actionCreator: doToggleCamera.fulfilled,
3579
+ effect: (_, { dispatch, getState }) => {
3580
+ var _a;
3581
+ const state = getState();
3582
+ const cameraEnabled = selectIsCameraEnabled(state);
3583
+ const effectId = selectCameraEffectId(state);
3584
+ const isPaused = selectIsCameraEffectPaused(state);
3585
+ if (!cameraEnabled) {
3586
+ const raw = selectCameraEffectsRaw(state);
3587
+ if (effectId && raw.stop && !isPaused) {
3588
+ dispatch(doCameraEffectsPause());
3589
+ }
3590
+ }
3591
+ else if (effectId && isPaused) {
3592
+ const stream = selectLocalMediaStream(state);
3593
+ if ((_a = stream === null || stream === void 0 ? void 0 : stream.getVideoTracks()) === null || _a === void 0 ? void 0 : _a[0]) {
3594
+ dispatch(doCameraEffectsResume());
3595
+ }
3596
+ }
3597
+ },
3598
+ });
3526
3599
 
3527
3600
  const initialState = {
3528
3601
  wanted: false,
@@ -790,6 +790,9 @@ interface CameraEffectsState {
790
790
  currentEffectId?: string | null;
791
791
  setup?: Setup;
792
792
  params?: Params;
793
+ backgroundUrl?: string;
794
+ allowSafari?: boolean;
795
+ isPaused: boolean;
793
796
  isSwitching: boolean;
794
797
  error?: unknown;
795
798
  raw: {
@@ -790,6 +790,9 @@ interface CameraEffectsState {
790
790
  currentEffectId?: string | null;
791
791
  setup?: Setup;
792
792
  params?: Params;
793
+ backgroundUrl?: string;
794
+ allowSafari?: boolean;
795
+ isPaused: boolean;
793
796
  isSwitching: boolean;
794
797
  error?: unknown;
795
798
  raw: {
@@ -790,6 +790,9 @@ interface CameraEffectsState {
790
790
  currentEffectId?: string | null;
791
791
  setup?: Setup;
792
792
  params?: Params;
793
+ backgroundUrl?: string;
794
+ allowSafari?: boolean;
795
+ isPaused: boolean;
793
796
  isSwitching: boolean;
794
797
  error?: unknown;
795
798
  raw: {
@@ -74,7 +74,7 @@ const createReactor = (selectors, callback) => {
74
74
  });
75
75
  };
76
76
 
77
- const coreVersion = "1.15.1";
77
+ const coreVersion = "1.15.2";
78
78
 
79
79
  const initialState$2 = {
80
80
  displayName: null,
@@ -973,7 +973,7 @@ startAppListening({
973
973
  const oldValue = selectCurrentCameraDeviceId(previousState);
974
974
  const newValue = selectCurrentCameraDeviceId(currentState);
975
975
  const isReady = selectLocalMediaStatus(previousState) === "started";
976
- return isReady && oldValue !== newValue;
976
+ return isReady && !!oldValue && !!newValue && oldValue !== newValue;
977
977
  },
978
978
  effect: (_action, { dispatch }) => {
979
979
  dispatch(doSetDevice({ audio: false, video: true }));
@@ -3419,6 +3419,7 @@ const selectWaitingParticipantsRaw = (state) => state.waitingParticipants;
3419
3419
  const selectWaitingParticipants = (state) => state.waitingParticipants.waitingParticipants;
3420
3420
 
3421
3421
  const initialState$1 = {
3422
+ isPaused: false,
3422
3423
  isSwitching: false,
3423
3424
  raw: {},
3424
3425
  };
@@ -3433,28 +3434,50 @@ const cameraEffectsSlice = createSlice({
3433
3434
  state.currentEffectId = null;
3434
3435
  state.setup = undefined;
3435
3436
  state.params = undefined;
3437
+ state.backgroundUrl = undefined;
3438
+ state.allowSafari = undefined;
3439
+ state.isPaused = false;
3436
3440
  state.raw = {};
3437
3441
  state.error = undefined;
3438
3442
  state.isSwitching = false;
3439
3443
  },
3440
3444
  cameraEffectsUpdated(state, action) {
3441
- const { effectId, setup, params, raw } = action.payload;
3445
+ const { effectId, setup, params, backgroundUrl, allowSafari, raw } = action.payload;
3442
3446
  state.currentEffectId = effectId;
3443
3447
  state.setup = setup;
3444
3448
  state.params = params;
3449
+ state.backgroundUrl = backgroundUrl;
3450
+ state.allowSafari = allowSafari;
3451
+ state.isPaused = false;
3445
3452
  if (raw)
3446
3453
  state.raw = raw;
3447
3454
  state.error = undefined;
3448
3455
  state.isSwitching = false;
3449
3456
  },
3457
+ cameraEffectsPaused(state, action) {
3458
+ const payload = action.payload;
3459
+ if ((payload === null || payload === void 0 ? void 0 : payload.effectId) !== undefined) {
3460
+ state.currentEffectId = payload.effectId;
3461
+ state.setup = payload.setup;
3462
+ state.params = payload.params;
3463
+ state.backgroundUrl = payload.backgroundUrl;
3464
+ state.allowSafari = payload.allowSafari;
3465
+ }
3466
+ state.isPaused = true;
3467
+ state.raw = {};
3468
+ state.error = undefined;
3469
+ state.isSwitching = false;
3470
+ },
3450
3471
  cameraEffectsError(state, action) {
3451
3472
  state.error = action.payload.error;
3452
3473
  state.isSwitching = false;
3453
3474
  },
3454
3475
  },
3455
3476
  });
3456
- const { cameraEffectsSwitching, cameraEffectsCleared, cameraEffectsUpdated, cameraEffectsError } = cameraEffectsSlice.actions;
3477
+ const { cameraEffectsSwitching, cameraEffectsCleared, cameraEffectsUpdated, cameraEffectsPaused, cameraEffectsError, } = cameraEffectsSlice.actions;
3457
3478
  const selectCameraEffectsRaw = (state) => state.cameraEffects.raw;
3479
+ const selectCameraEffectId = (state) => state.cameraEffects.currentEffectId;
3480
+ const selectIsCameraEffectPaused = (state) => state.cameraEffects.isPaused;
3458
3481
  const doCameraEffectsSwitchPreset = createAppAsyncThunk("cameraEffects/switchPreset", (_a, _b) => __awaiter(void 0, [_a, _b], void 0, function* ({ effectId, setup, params, allowSafari, backgroundUrl, }, { getState, dispatch, rejectWithValue }) {
3459
3482
  var _c, _d, _e;
3460
3483
  const state = getState();
@@ -3467,7 +3490,12 @@ const doCameraEffectsSwitchPreset = createAppAsyncThunk("cameraEffects/switchPre
3467
3490
  const raw = selectCameraEffectsRaw(state);
3468
3491
  const localStream = selectLocalMediaStream(state);
3469
3492
  if (!((_c = localStream === null || localStream === void 0 ? void 0 : localStream.getVideoTracks()) === null || _c === void 0 ? void 0 : _c[0])) {
3470
- dispatch(cameraEffectsCleared());
3493
+ if (!effectId) {
3494
+ dispatch(cameraEffectsCleared());
3495
+ }
3496
+ else {
3497
+ dispatch(cameraEffectsPaused({ effectId, setup, params, backgroundUrl, allowSafari }));
3498
+ }
3471
3499
  return;
3472
3500
  }
3473
3501
  if (!effectId) {
@@ -3481,7 +3509,7 @@ const doCameraEffectsSwitchPreset = createAppAsyncThunk("cameraEffects/switchPre
3481
3509
  if (raw.tryUpdate) {
3482
3510
  const ok = yield raw.tryUpdate(effectId, Object.assign({}, (setup || {})), mergedParams);
3483
3511
  if (ok) {
3484
- dispatch(cameraEffectsUpdated({ effectId, setup, params }));
3512
+ dispatch(cameraEffectsUpdated({ effectId, setup, params, backgroundUrl, allowSafari }));
3485
3513
  return;
3486
3514
  }
3487
3515
  }
@@ -3503,7 +3531,14 @@ const doCameraEffectsSwitchPreset = createAppAsyncThunk("cameraEffects/switchPre
3503
3531
  }
3504
3532
  const { stream: effectStream, stop, tryUpdate, } = yield createEffectStream(localStream, effectId, setup, mergedParams);
3505
3533
  yield dispatch(doLocalStreamEffect({ effectStream, only: "video" }));
3506
- dispatch(cameraEffectsUpdated({ effectId, setup, params, raw: { stop, tryUpdate, effectStream } }));
3534
+ dispatch(cameraEffectsUpdated({
3535
+ effectId,
3536
+ setup,
3537
+ params,
3538
+ backgroundUrl,
3539
+ allowSafari,
3540
+ raw: { stop, tryUpdate, effectStream },
3541
+ }));
3507
3542
  }
3508
3543
  catch (error) {
3509
3544
  dispatch(cameraEffectsError({ error }));
@@ -3513,6 +3548,22 @@ const doCameraEffectsSwitchPreset = createAppAsyncThunk("cameraEffects/switchPre
3513
3548
  const doCameraEffectsClear = createAppAsyncThunk("cameraEffects/clear", (_1, _a) => __awaiter(void 0, [_1, _a], void 0, function* (_, { dispatch }) {
3514
3549
  yield dispatch(doCameraEffectsSwitchPreset({ effectId: null }));
3515
3550
  }));
3551
+ const doCameraEffectsPause = createAppAsyncThunk("cameraEffects/pause", (_1, _a) => __awaiter(void 0, [_1, _a], void 0, function* (_, { dispatch, getState }) {
3552
+ var _b;
3553
+ const raw = selectCameraEffectsRaw(getState());
3554
+ (_b = raw.stop) === null || _b === void 0 ? void 0 : _b.call(raw);
3555
+ yield dispatch(doLocalStreamEffect({ effectStream: undefined, only: "video", stopBeforeTrack: true }));
3556
+ dispatch(cameraEffectsPaused());
3557
+ }));
3558
+ const doCameraEffectsResume = createAppAsyncThunk("cameraEffects/resume", (_1, _a) => __awaiter(void 0, [_1, _a], void 0, function* (_, { dispatch, getState }) {
3559
+ const state = getState();
3560
+ const effectId = selectCameraEffectId(state);
3561
+ if (!effectId) {
3562
+ return;
3563
+ }
3564
+ const { setup, params, backgroundUrl, allowSafari } = state.cameraEffects;
3565
+ yield dispatch(doCameraEffectsSwitchPreset({ effectId, setup, params, backgroundUrl, allowSafari }));
3566
+ }));
3516
3567
  startAppListening({
3517
3568
  actionCreator: doAppStop,
3518
3569
  effect: (_, { dispatch, getState }) => {
@@ -3521,6 +3572,28 @@ startAppListening({
3521
3572
  }
3522
3573
  },
3523
3574
  });
3575
+ startAppListening({
3576
+ actionCreator: doToggleCamera.fulfilled,
3577
+ effect: (_, { dispatch, getState }) => {
3578
+ var _a;
3579
+ const state = getState();
3580
+ const cameraEnabled = selectIsCameraEnabled(state);
3581
+ const effectId = selectCameraEffectId(state);
3582
+ const isPaused = selectIsCameraEffectPaused(state);
3583
+ if (!cameraEnabled) {
3584
+ const raw = selectCameraEffectsRaw(state);
3585
+ if (effectId && raw.stop && !isPaused) {
3586
+ dispatch(doCameraEffectsPause());
3587
+ }
3588
+ }
3589
+ else if (effectId && isPaused) {
3590
+ const stream = selectLocalMediaStream(state);
3591
+ if ((_a = stream === null || stream === void 0 ? void 0 : stream.getVideoTracks()) === null || _a === void 0 ? void 0 : _a[0]) {
3592
+ dispatch(doCameraEffectsResume());
3593
+ }
3594
+ }
3595
+ },
3596
+ });
3524
3597
 
3525
3598
  const initialState = {
3526
3599
  wanted: false,
@@ -74,7 +74,7 @@ const createReactor = (selectors, callback) => {
74
74
  });
75
75
  };
76
76
 
77
- const coreVersion = "1.15.1";
77
+ const coreVersion = "1.15.2";
78
78
 
79
79
  const initialState$2 = {
80
80
  displayName: null,
@@ -973,7 +973,7 @@ startAppListening({
973
973
  const oldValue = selectCurrentCameraDeviceId(previousState);
974
974
  const newValue = selectCurrentCameraDeviceId(currentState);
975
975
  const isReady = selectLocalMediaStatus(previousState) === "started";
976
- return isReady && oldValue !== newValue;
976
+ return isReady && !!oldValue && !!newValue && oldValue !== newValue;
977
977
  },
978
978
  effect: (_action, { dispatch }) => {
979
979
  dispatch(doSetDevice({ audio: false, video: true }));
@@ -3419,6 +3419,7 @@ const selectWaitingParticipantsRaw = (state) => state.waitingParticipants;
3419
3419
  const selectWaitingParticipants = (state) => state.waitingParticipants.waitingParticipants;
3420
3420
 
3421
3421
  const initialState$1 = {
3422
+ isPaused: false,
3422
3423
  isSwitching: false,
3423
3424
  raw: {},
3424
3425
  };
@@ -3433,28 +3434,50 @@ const cameraEffectsSlice = createSlice({
3433
3434
  state.currentEffectId = null;
3434
3435
  state.setup = undefined;
3435
3436
  state.params = undefined;
3437
+ state.backgroundUrl = undefined;
3438
+ state.allowSafari = undefined;
3439
+ state.isPaused = false;
3436
3440
  state.raw = {};
3437
3441
  state.error = undefined;
3438
3442
  state.isSwitching = false;
3439
3443
  },
3440
3444
  cameraEffectsUpdated(state, action) {
3441
- const { effectId, setup, params, raw } = action.payload;
3445
+ const { effectId, setup, params, backgroundUrl, allowSafari, raw } = action.payload;
3442
3446
  state.currentEffectId = effectId;
3443
3447
  state.setup = setup;
3444
3448
  state.params = params;
3449
+ state.backgroundUrl = backgroundUrl;
3450
+ state.allowSafari = allowSafari;
3451
+ state.isPaused = false;
3445
3452
  if (raw)
3446
3453
  state.raw = raw;
3447
3454
  state.error = undefined;
3448
3455
  state.isSwitching = false;
3449
3456
  },
3457
+ cameraEffectsPaused(state, action) {
3458
+ const payload = action.payload;
3459
+ if ((payload === null || payload === void 0 ? void 0 : payload.effectId) !== undefined) {
3460
+ state.currentEffectId = payload.effectId;
3461
+ state.setup = payload.setup;
3462
+ state.params = payload.params;
3463
+ state.backgroundUrl = payload.backgroundUrl;
3464
+ state.allowSafari = payload.allowSafari;
3465
+ }
3466
+ state.isPaused = true;
3467
+ state.raw = {};
3468
+ state.error = undefined;
3469
+ state.isSwitching = false;
3470
+ },
3450
3471
  cameraEffectsError(state, action) {
3451
3472
  state.error = action.payload.error;
3452
3473
  state.isSwitching = false;
3453
3474
  },
3454
3475
  },
3455
3476
  });
3456
- const { cameraEffectsSwitching, cameraEffectsCleared, cameraEffectsUpdated, cameraEffectsError } = cameraEffectsSlice.actions;
3477
+ const { cameraEffectsSwitching, cameraEffectsCleared, cameraEffectsUpdated, cameraEffectsPaused, cameraEffectsError, } = cameraEffectsSlice.actions;
3457
3478
  const selectCameraEffectsRaw = (state) => state.cameraEffects.raw;
3479
+ const selectCameraEffectId = (state) => state.cameraEffects.currentEffectId;
3480
+ const selectIsCameraEffectPaused = (state) => state.cameraEffects.isPaused;
3458
3481
  const doCameraEffectsSwitchPreset = createAppAsyncThunk("cameraEffects/switchPreset", (_a, _b) => __awaiter(void 0, [_a, _b], void 0, function* ({ effectId, setup, params, allowSafari, backgroundUrl, }, { getState, dispatch, rejectWithValue }) {
3459
3482
  var _c, _d, _e;
3460
3483
  const state = getState();
@@ -3467,7 +3490,12 @@ const doCameraEffectsSwitchPreset = createAppAsyncThunk("cameraEffects/switchPre
3467
3490
  const raw = selectCameraEffectsRaw(state);
3468
3491
  const localStream = selectLocalMediaStream(state);
3469
3492
  if (!((_c = localStream === null || localStream === void 0 ? void 0 : localStream.getVideoTracks()) === null || _c === void 0 ? void 0 : _c[0])) {
3470
- dispatch(cameraEffectsCleared());
3493
+ if (!effectId) {
3494
+ dispatch(cameraEffectsCleared());
3495
+ }
3496
+ else {
3497
+ dispatch(cameraEffectsPaused({ effectId, setup, params, backgroundUrl, allowSafari }));
3498
+ }
3471
3499
  return;
3472
3500
  }
3473
3501
  if (!effectId) {
@@ -3481,7 +3509,7 @@ const doCameraEffectsSwitchPreset = createAppAsyncThunk("cameraEffects/switchPre
3481
3509
  if (raw.tryUpdate) {
3482
3510
  const ok = yield raw.tryUpdate(effectId, Object.assign({}, (setup || {})), mergedParams);
3483
3511
  if (ok) {
3484
- dispatch(cameraEffectsUpdated({ effectId, setup, params }));
3512
+ dispatch(cameraEffectsUpdated({ effectId, setup, params, backgroundUrl, allowSafari }));
3485
3513
  return;
3486
3514
  }
3487
3515
  }
@@ -3503,7 +3531,14 @@ const doCameraEffectsSwitchPreset = createAppAsyncThunk("cameraEffects/switchPre
3503
3531
  }
3504
3532
  const { stream: effectStream, stop, tryUpdate, } = yield createEffectStream(localStream, effectId, setup, mergedParams);
3505
3533
  yield dispatch(doLocalStreamEffect({ effectStream, only: "video" }));
3506
- dispatch(cameraEffectsUpdated({ effectId, setup, params, raw: { stop, tryUpdate, effectStream } }));
3534
+ dispatch(cameraEffectsUpdated({
3535
+ effectId,
3536
+ setup,
3537
+ params,
3538
+ backgroundUrl,
3539
+ allowSafari,
3540
+ raw: { stop, tryUpdate, effectStream },
3541
+ }));
3507
3542
  }
3508
3543
  catch (error) {
3509
3544
  dispatch(cameraEffectsError({ error }));
@@ -3513,6 +3548,22 @@ const doCameraEffectsSwitchPreset = createAppAsyncThunk("cameraEffects/switchPre
3513
3548
  const doCameraEffectsClear = createAppAsyncThunk("cameraEffects/clear", (_1, _a) => __awaiter(void 0, [_1, _a], void 0, function* (_, { dispatch }) {
3514
3549
  yield dispatch(doCameraEffectsSwitchPreset({ effectId: null }));
3515
3550
  }));
3551
+ const doCameraEffectsPause = createAppAsyncThunk("cameraEffects/pause", (_1, _a) => __awaiter(void 0, [_1, _a], void 0, function* (_, { dispatch, getState }) {
3552
+ var _b;
3553
+ const raw = selectCameraEffectsRaw(getState());
3554
+ (_b = raw.stop) === null || _b === void 0 ? void 0 : _b.call(raw);
3555
+ yield dispatch(doLocalStreamEffect({ effectStream: undefined, only: "video", stopBeforeTrack: true }));
3556
+ dispatch(cameraEffectsPaused());
3557
+ }));
3558
+ const doCameraEffectsResume = createAppAsyncThunk("cameraEffects/resume", (_1, _a) => __awaiter(void 0, [_1, _a], void 0, function* (_, { dispatch, getState }) {
3559
+ const state = getState();
3560
+ const effectId = selectCameraEffectId(state);
3561
+ if (!effectId) {
3562
+ return;
3563
+ }
3564
+ const { setup, params, backgroundUrl, allowSafari } = state.cameraEffects;
3565
+ yield dispatch(doCameraEffectsSwitchPreset({ effectId, setup, params, backgroundUrl, allowSafari }));
3566
+ }));
3516
3567
  startAppListening({
3517
3568
  actionCreator: doAppStop,
3518
3569
  effect: (_, { dispatch, getState }) => {
@@ -3521,6 +3572,28 @@ startAppListening({
3521
3572
  }
3522
3573
  },
3523
3574
  });
3575
+ startAppListening({
3576
+ actionCreator: doToggleCamera.fulfilled,
3577
+ effect: (_, { dispatch, getState }) => {
3578
+ var _a;
3579
+ const state = getState();
3580
+ const cameraEnabled = selectIsCameraEnabled(state);
3581
+ const effectId = selectCameraEffectId(state);
3582
+ const isPaused = selectIsCameraEffectPaused(state);
3583
+ if (!cameraEnabled) {
3584
+ const raw = selectCameraEffectsRaw(state);
3585
+ if (effectId && raw.stop && !isPaused) {
3586
+ dispatch(doCameraEffectsPause());
3587
+ }
3588
+ }
3589
+ else if (effectId && isPaused) {
3590
+ const stream = selectLocalMediaStream(state);
3591
+ if ((_a = stream === null || stream === void 0 ? void 0 : stream.getVideoTracks()) === null || _a === void 0 ? void 0 : _a[0]) {
3592
+ dispatch(doCameraEffectsResume());
3593
+ }
3594
+ }
3595
+ },
3596
+ });
3524
3597
 
3525
3598
  const initialState = {
3526
3599
  wanted: false,
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@whereby.com/core",
3
3
  "description": "Core library for whereby.com sdk",
4
4
  "author": "Whereby AS",
5
- "version": "1.15.1",
5
+ "version": "1.15.2",
6
6
  "license": "MIT",
7
7
  "publishConfig": {
8
8
  "access": "public"
@@ -60,8 +60,8 @@
60
60
  "typescript": "^5.8.3",
61
61
  "@whereby.com/eslint-config": "0.1.0",
62
62
  "@whereby.com/jest-config": "0.1.0",
63
- "@whereby.com/rollup-config": "0.1.1",
64
63
  "@whereby.com/prettier-config": "0.1.0",
64
+ "@whereby.com/rollup-config": "0.1.1",
65
65
  "@whereby.com/tsconfig": "0.1.0"
66
66
  },
67
67
  "dependencies": {