@whereby.com/core 1.14.2 → 1.15.1

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.
@@ -76,7 +76,7 @@ const createReactor = (selectors, callback) => {
76
76
  });
77
77
  };
78
78
 
79
- const coreVersion = "1.14.2";
79
+ const coreVersion = "1.15.1";
80
80
 
81
81
  const initialState$2 = {
82
82
  displayName: null,
@@ -158,6 +158,7 @@ const signalEvents = {
158
158
  liveTranscriptionStopped: createSignalEventAction("liveTranscriptionStopped"),
159
159
  liveCaptionsStarted: createSignalEventAction("liveCaptionsStarted"),
160
160
  liveCaptionsStopped: createSignalEventAction("liveCaptionsStopped"),
161
+ liveCaption: createSignalEventAction("liveCaption"),
161
162
  };
162
163
 
163
164
  const ROOM_ACTION_PERMISSIONS_BY_ROLE = {
@@ -333,8 +334,9 @@ function forwardSocketEvents(socket, dispatch) {
333
334
  socket.on("spotlight_removed", (payload) => dispatch(signalEvents.spotlightRemoved(payload)));
334
335
  socket.on("live_transcription_started", (payload) => dispatch(signalEvents.liveTranscriptionStarted(payload)));
335
336
  socket.on("live_transcription_stopped", (payload) => dispatch(signalEvents.liveTranscriptionStopped(payload)));
336
- socket.on("live_captions_started", () => dispatch(signalEvents.liveCaptionsStarted()));
337
- socket.on("live_captions_stopped", () => dispatch(signalEvents.liveCaptionsStopped()));
337
+ socket.on("live_captions_started", (payload) => dispatch(signalEvents.liveCaptionsStarted(payload)));
338
+ socket.on("live_captions_stopped", (payload) => dispatch(signalEvents.liveCaptionsStopped(payload)));
339
+ socket.on("live_caption", (payload) => dispatch(signalEvents.liveCaption(payload)));
338
340
  socket.on("video_enable_requested", (payload) => dispatch(signalEvents.videoEnableRequested(payload)));
339
341
  socket.on("breakout_group_joined", (payload) => dispatch(signalEvents.breakoutGroupJoined(payload)));
340
342
  socket.on("breakout_session_updated", (payload) => dispatch(signalEvents.breakoutSessionUpdated(payload)));
@@ -2448,6 +2450,91 @@ const selectFileShareRaw = (state) => state.fileShare;
2448
2450
  const selectFileUploads = (state) => state.fileShare.uploads;
2449
2451
  const selectFileShareRequestInFlight = (state) => state.fileShare.requestInFlight;
2450
2452
 
2453
+ class LiveCaption {
2454
+ constructor({ resultId, senderId, text }) {
2455
+ this.resultId = resultId;
2456
+ this.participantId = senderId;
2457
+ this.text = text;
2458
+ this.timestamp = Date.now();
2459
+ }
2460
+ }
2461
+
2462
+ const initialLiveCaptionsState = {
2463
+ isCaptioning: false,
2464
+ captionLog: [],
2465
+ };
2466
+ const captionTimerIds = {};
2467
+ const LIVE_CAPTIONS_STALE_CAPTION_TIMEOUT = 5000;
2468
+ const liveCaptionsSlice = toolkit.createSlice({
2469
+ name: "liveCaptions",
2470
+ initialState: initialLiveCaptionsState,
2471
+ reducers: {
2472
+ captioningRequestStarted: (state) => {
2473
+ return Object.assign(Object.assign({}, state), { status: "requested" });
2474
+ },
2475
+ clearCaption: (state, action) => {
2476
+ return Object.assign(Object.assign({}, state), { captionLog: state.captionLog.filter(({ resultId }) => resultId !== action.payload.resultId) });
2477
+ },
2478
+ },
2479
+ extraReducers: (builder) => {
2480
+ builder.addCase(signalEvents.liveCaptionsStopped, (state) => {
2481
+ return Object.assign(Object.assign({}, state), { isCaptioning: false, startedAt: undefined, status: undefined, error: undefined, captionLog: [] });
2482
+ });
2483
+ builder.addCase(signalEvents.liveCaptionsStarted, (state, action) => {
2484
+ const { payload } = action;
2485
+ if (payload.error) {
2486
+ return Object.assign(Object.assign({}, state), { isCaptioning: false, startedAt: undefined, status: "error", error: payload.error, captionLog: [] });
2487
+ }
2488
+ return Object.assign(Object.assign({}, state), { isCaptioning: true, startedAt: Date.now(), status: "captioning", error: undefined, captionLog: [] });
2489
+ });
2490
+ builder.addCase(signalEvents.liveCaption, (state, action) => {
2491
+ const { payload } = action;
2492
+ const captionLog = [...state.captionLog];
2493
+ const lastCaption = captionLog.length ? captionLog[captionLog.length - 1] : undefined;
2494
+ if (!lastCaption || lastCaption.resultId !== payload.resultId) {
2495
+ return Object.assign(Object.assign({}, state), { captionLog: [...state.captionLog, new LiveCaption(payload)] });
2496
+ }
2497
+ return Object.assign(Object.assign({}, state), { captionLog: [
2498
+ ...state.captionLog.slice(0, state.captionLog.length - 1),
2499
+ Object.assign(Object.assign({}, lastCaption), { text: payload.text }),
2500
+ ] });
2501
+ });
2502
+ },
2503
+ });
2504
+ const { captioningRequestStarted, clearCaption } = liveCaptionsSlice.actions;
2505
+ const doStartLiveCaptions = createRoomConnectedThunk(() => (dispatch, getState) => {
2506
+ const state = getState();
2507
+ const socket = selectSignalConnectionRaw(state).socket;
2508
+ const status = selectLiveCaptionsStatus(state);
2509
+ if (status && ["captioning", "requested"].includes(status)) {
2510
+ return;
2511
+ }
2512
+ socket === null || socket === void 0 ? void 0 : socket.emit("live_captions_enabled");
2513
+ dispatch(captioningRequestStarted());
2514
+ });
2515
+ const doStopLiveCaptions = createRoomConnectedThunk(() => (_, getState) => {
2516
+ const state = getState();
2517
+ const socket = selectSignalConnectionRaw(state).socket;
2518
+ socket === null || socket === void 0 ? void 0 : socket.emit("live_captions_disabled");
2519
+ });
2520
+ const selectLiveCaptionsRaw = (state) => state.liveCaptions;
2521
+ const selectLiveCaptionsStatus = (state) => state.liveCaptions.status;
2522
+ const selectLiveCaptionsStartedAt = (state) => state.liveCaptions.startedAt;
2523
+ const selectLiveCaptionsError = (state) => state.liveCaptions.error;
2524
+ const selectLiveCaptionsLog = (state) => state.liveCaptions.captionLog;
2525
+ const selectIsLiveCaptions = (state) => state.liveCaptions.isCaptioning;
2526
+ startAppListening({
2527
+ actionCreator: signalEvents.liveCaption,
2528
+ effect: (action, { dispatch }) => {
2529
+ const resultId = action.payload.resultId;
2530
+ clearTimeout(captionTimerIds[resultId]);
2531
+ captionTimerIds[resultId] = setTimeout(() => {
2532
+ delete captionTimerIds[resultId];
2533
+ dispatch(clearCaption({ resultId }));
2534
+ }, LIVE_CAPTIONS_STALE_CAPTION_TIMEOUT);
2535
+ },
2536
+ });
2537
+
2451
2538
  const initialLiveTranscriptionState = {
2452
2539
  isInitiator: false,
2453
2540
  isTranscribing: false,
@@ -2467,20 +2554,17 @@ const liveTranscriptionSlice = toolkit.createSlice({
2467
2554
  });
2468
2555
  builder.addCase(signalEvents.liveTranscriptionStarted, (state, action) => {
2469
2556
  const { payload } = action;
2470
- if (!payload.error) {
2471
- return state;
2557
+ if (payload.error) {
2558
+ return Object.assign(Object.assign({}, state), { isInitiator: false, isTranscribing: false, status: "error", error: payload.error });
2472
2559
  }
2473
- return Object.assign(Object.assign({}, state), { isInitiator: false, isTranscribing: false, status: "error", error: payload.error });
2560
+ return Object.assign(Object.assign({}, state), { isTranscribing: true, status: "transcribing", startedAt: new Date().getTime() });
2474
2561
  });
2475
- builder.addCase(signalEvents.newClient, (state, { payload }) => {
2476
- var _a;
2477
- const { client } = payload;
2478
- if (((_a = client.role) === null || _a === void 0 ? void 0 : _a.roleName) === "captioner") {
2479
- return Object.assign(Object.assign({}, state), { isTranscribing: true, status: "transcribing", startedAt: client.startedLiveTranscriptionAt
2480
- ? new Date(client.startedLiveTranscriptionAt).getTime()
2481
- : new Date().getTime() });
2562
+ builder.addCase(signalEvents.roomJoined, (state, action) => {
2563
+ if ("error" in action.payload) {
2564
+ return state;
2482
2565
  }
2483
- return state;
2566
+ const { room } = action.payload || {};
2567
+ return Object.assign(Object.assign({}, state), { isTranscribing: Boolean(room === null || room === void 0 ? void 0 : room.liveTranscriptionId), status: (room === null || room === void 0 ? void 0 : room.liveTranscriptionId) ? "transcribing" : state.status, startedAt: (room === null || room === void 0 ? void 0 : room.liveTranscriptionId) ? new Date().getTime() : state.startedAt });
2484
2568
  });
2485
2569
  },
2486
2570
  });
@@ -3581,6 +3665,7 @@ const appReducer = toolkit.combineReducers({
3581
3665
  connectionMonitor: connectionMonitorSlice.reducer,
3582
3666
  deviceCredentials: deviceCredentialsSlice.reducer,
3583
3667
  fileShare: fileShareSlice.reducer,
3668
+ liveCaptions: liveCaptionsSlice.reducer,
3584
3669
  liveTranscription: liveTranscriptionSlice.reducer,
3585
3670
  localMedia: localMediaSlice.reducer,
3586
3671
  localParticipant: localParticipantSlice.reducer,
@@ -4367,8 +4452,10 @@ exports.authorizationSlice = authorizationSlice;
4367
4452
  exports.authorizationSliceInitialState = authorizationSliceInitialState;
4368
4453
  exports.breakoutSlice = breakoutSlice;
4369
4454
  exports.breakoutSliceInitialState = breakoutSliceInitialState;
4455
+ exports.captioningRequestStarted = captioningRequestStarted;
4370
4456
  exports.chatSlice = chatSlice;
4371
4457
  exports.chatSliceInitialState = chatSliceInitialState;
4458
+ exports.clearCaption = clearCaption;
4372
4459
  exports.clearFileUploads = clearFileUploads;
4373
4460
  exports.cloudRecordingSlice = cloudRecordingSlice;
4374
4461
  exports.connectionMonitorSlice = connectionMonitorSlice;
@@ -4435,11 +4522,13 @@ exports.doSignalIdentifyDevice = doSignalIdentifyDevice;
4435
4522
  exports.doSpotlightParticipant = doSpotlightParticipant;
4436
4523
  exports.doStartCloudRecording = doStartCloudRecording;
4437
4524
  exports.doStartConnectionMonitor = doStartConnectionMonitor;
4525
+ exports.doStartLiveCaptions = doStartLiveCaptions;
4438
4526
  exports.doStartLiveTranscription = doStartLiveTranscription;
4439
4527
  exports.doStartLocalMedia = doStartLocalMedia;
4440
4528
  exports.doStartScreenshare = doStartScreenshare;
4441
4529
  exports.doStopCloudRecording = doStopCloudRecording;
4442
4530
  exports.doStopConnectionMonitor = doStopConnectionMonitor;
4531
+ exports.doStopLiveCaptions = doStopLiveCaptions;
4443
4532
  exports.doStopLiveTranscription = doStopLiveTranscription;
4444
4533
  exports.doStopLocalMedia = doStopLocalMedia;
4445
4534
  exports.doStopScreenshare = doStopScreenshare;
@@ -4454,6 +4543,7 @@ exports.fileUploadFailed = fileUploadFailed;
4454
4543
  exports.fileUploadSucceeded = fileUploadSucceeded;
4455
4544
  exports.fileUploadsStarted = fileUploadsStarted;
4456
4545
  exports.initialCloudRecordingState = initialCloudRecordingState;
4546
+ exports.initialLiveCaptionsState = initialLiveCaptionsState;
4457
4547
  exports.initialLiveTranscriptionState = initialLiveTranscriptionState;
4458
4548
  exports.initialLocalMediaState = initialLocalMediaState;
4459
4549
  exports.initialNotificationsState = initialNotificationsState;
@@ -4461,6 +4551,7 @@ exports.initialState = initialState$2;
4461
4551
  exports.isAcceptingStreams = isAcceptingStreams;
4462
4552
  exports.isClientSpotlighted = isClientSpotlighted;
4463
4553
  exports.listenerMiddleware = listenerMiddleware;
4554
+ exports.liveCaptionsSlice = liveCaptionsSlice;
4464
4555
  exports.liveTranscriptionSlice = liveTranscriptionSlice;
4465
4556
  exports.localMediaSlice = localMediaSlice;
4466
4557
  exports.localMediaStopped = localMediaStopped;
@@ -4553,6 +4644,7 @@ exports.selectIsAuthorizedToSpotlight = selectIsAuthorizedToSpotlight;
4553
4644
  exports.selectIsCameraEnabled = selectIsCameraEnabled;
4554
4645
  exports.selectIsCloudRecording = selectIsCloudRecording;
4555
4646
  exports.selectIsHDModeEnabled = selectIsHDModeEnabled;
4647
+ exports.selectIsLiveCaptions = selectIsLiveCaptions;
4556
4648
  exports.selectIsLiveTranscription = selectIsLiveTranscription;
4557
4649
  exports.selectIsLocalMediaStarting = selectIsLocalMediaStarting;
4558
4650
  exports.selectIsLocalParticipantSpotlighted = selectIsLocalParticipantSpotlighted;
@@ -4562,6 +4654,11 @@ exports.selectIsSettingCameraDevice = selectIsSettingCameraDevice;
4562
4654
  exports.selectIsSettingMicrophoneDevice = selectIsSettingMicrophoneDevice;
4563
4655
  exports.selectIsToggleCamera = selectIsToggleCamera;
4564
4656
  exports.selectIsWidescreenModeEnabled = selectIsWidescreenModeEnabled;
4657
+ exports.selectLiveCaptionsError = selectLiveCaptionsError;
4658
+ exports.selectLiveCaptionsLog = selectLiveCaptionsLog;
4659
+ exports.selectLiveCaptionsRaw = selectLiveCaptionsRaw;
4660
+ exports.selectLiveCaptionsStartedAt = selectLiveCaptionsStartedAt;
4661
+ exports.selectLiveCaptionsStatus = selectLiveCaptionsStatus;
4565
4662
  exports.selectLiveTranscriptionError = selectLiveTranscriptionError;
4566
4663
  exports.selectLiveTranscriptionIsInitiator = selectLiveTranscriptionIsInitiator;
4567
4664
  exports.selectLiveTranscriptionRaw = selectLiveTranscriptionRaw;