@whereby.com/core 1.13.0 → 1.14.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.
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { AxiosRequestConfig } from 'axios';
2
2
  import { EventEmitter } from 'events';
3
- import { RoleName, ChatMessage as ChatMessage$2, BreakoutConfig, RtcManager, RtcManagerDispatcher, ServerSocket, RoomJoinedErrors, RoomJoinedSuccess } from '@whereby.com/media';
4
- export { RoomJoinedSuccess } from '@whereby.com/media';
3
+ import { RoleName, ChatMessage as ChatMessage$2, ChatFileShare, FileShareErrorCode, BreakoutConfig, RtcManager, RtcManagerDispatcher, ServerSocket, RoomJoinedErrors, RoomJoinedSuccess } from '@whereby.com/media';
4
+ export { ChatFileShare, RoomJoinedSuccess } from '@whereby.com/media';
5
5
  import * as redux_thunk from 'redux-thunk';
6
6
  import * as _reduxjs_toolkit from '@reduxjs/toolkit';
7
7
  import * as redux from 'redux';
@@ -509,6 +509,7 @@ interface rtcAnalyticsState {
509
509
 
510
510
  type ChatMessage$1 = Pick<ChatMessage$2, "id" | "senderId" | "parentId" | "timestamp" | "text" | "sig"> & {
511
511
  removed: boolean;
512
+ file?: ChatFileShare;
512
513
  };
513
514
  interface ChatState {
514
515
  chatMessages: ChatMessage$1[];
@@ -595,6 +596,23 @@ interface LiveTranscriptionState$1 {
595
596
  startedAt?: number;
596
597
  }
597
598
 
599
+ type FileShareError = FileShareErrorCode | "upload_failed" | "too_many_files" | "unsupported_file_type" | "file_too_large";
600
+ declare const MAX_FILES_PER_UPLOAD = 10;
601
+ declare const MAX_FILE_SIZE: number;
602
+ declare const ACCEPTED_FILE_TYPES: Record<string, string[]>;
603
+ interface FileUpload {
604
+ id: string;
605
+ name: string;
606
+ size: number;
607
+ type: string;
608
+ status: "uploading" | "sent" | "error";
609
+ error?: FileShareError;
610
+ }
611
+ interface FileShareState {
612
+ uploads: FileUpload[];
613
+ requestInFlight: boolean;
614
+ }
615
+
598
616
  interface CloudRecordingState$1 {
599
617
  isInitiator: boolean;
600
618
  isRecording: boolean;
@@ -797,6 +815,7 @@ declare const appReducer: redux.Reducer<{
797
815
  cloudRecording: CloudRecordingState$1;
798
816
  connectionMonitor: ConnectionMonitorState;
799
817
  deviceCredentials: DeviceCredentialsState;
818
+ fileShare: FileShareState;
800
819
  liveTranscription: LiveTranscriptionState$1;
801
820
  localMedia: LocalMediaState$1;
802
821
  localParticipant: LocalParticipantState$1;
@@ -822,6 +841,7 @@ declare const appReducer: redux.Reducer<{
822
841
  cloudRecording: CloudRecordingState$1 | undefined;
823
842
  connectionMonitor: ConnectionMonitorState | undefined;
824
843
  deviceCredentials: DeviceCredentialsState | undefined;
844
+ fileShare: FileShareState | undefined;
825
845
  liveTranscription: LiveTranscriptionState$1 | undefined;
826
846
  localMedia: LocalMediaState$1 | undefined;
827
847
  localParticipant: LocalParticipantState$1 | undefined;
@@ -851,6 +871,7 @@ declare const createStore: ({ preloadedState, injectServices, }: {
851
871
  cloudRecording: CloudRecordingState$1;
852
872
  connectionMonitor: ConnectionMonitorState;
853
873
  deviceCredentials: DeviceCredentialsState;
874
+ fileShare: FileShareState;
854
875
  liveTranscription: LiveTranscriptionState$1;
855
876
  localMedia: LocalMediaState$1;
856
877
  localParticipant: LocalParticipantState$1;
@@ -877,6 +898,7 @@ declare const createStore: ({ preloadedState, injectServices, }: {
877
898
  cloudRecording: CloudRecordingState$1;
878
899
  connectionMonitor: ConnectionMonitorState;
879
900
  deviceCredentials: DeviceCredentialsState;
901
+ fileShare: FileShareState;
880
902
  liveTranscription: LiveTranscriptionState$1;
881
903
  localMedia: LocalMediaState$1;
882
904
  localParticipant: LocalParticipantState$1;
@@ -1081,11 +1103,13 @@ interface ChatMessageState {
1081
1103
  senderId: string;
1082
1104
  timestamp: string;
1083
1105
  text: string;
1106
+ file?: ChatFileShare;
1084
1107
  }
1085
1108
  type ScreenshareState = Screenshare;
1086
1109
  type LocalScreenshareStatus = "starting" | "active";
1087
1110
  type ChatMessage = Pick<ChatMessage$2, "id" | "senderId" | "parentId" | "timestamp" | "text" | "sig"> & {
1088
1111
  removed: boolean;
1112
+ file?: ChatFileShare;
1089
1113
  };
1090
1114
  type CloudRecordingState = {
1091
1115
  error?: string;
@@ -1120,6 +1144,7 @@ interface RoomConnectionState {
1120
1144
  connectionStatus: ConnectionStatus;
1121
1145
  connectionError: string | null;
1122
1146
  chatMessages: ChatMessage[];
1147
+ fileUploads: FileUpload[];
1123
1148
  cloudRecording?: CloudRecordingState;
1124
1149
  breakout: BreakoutState;
1125
1150
  events?: NotificationsEventEmitter;
@@ -1190,6 +1215,7 @@ declare class RoomConnectionClient extends BaseClient<RoomConnectionState, RoomC
1190
1215
  private breakoutSubscribers;
1191
1216
  private cameraStateSubscribers;
1192
1217
  private chatMessageSubscribers;
1218
+ private fileUploadsSubscribers;
1193
1219
  private cloudRecordingSubscribers;
1194
1220
  private connectionErrorSubscribers;
1195
1221
  private connectionStatusSubscribers;
@@ -1206,6 +1232,7 @@ declare class RoomConnectionClient extends BaseClient<RoomConnectionState, RoomC
1206
1232
  protected handleStateChanges(state: RoomConnectionState, previousState: RoomConnectionState): void;
1207
1233
  private registerAppListeners;
1208
1234
  subscribeToChatMessages(callback: (messages: ChatMessage[]) => void): () => void;
1235
+ subscribeToFileUploads(callback: (uploads: FileUpload[]) => void): () => void;
1209
1236
  subscribeToCloudRecording(callback: (status: CloudRecordingState | undefined) => void): () => void;
1210
1237
  subscribeToLiveTranscription(callback: (status: LiveTranscriptionState | undefined) => void): () => void;
1211
1238
  subscribeToBreakoutConfig(callback: (config: BreakoutState) => void): () => void;
@@ -1228,6 +1255,8 @@ declare class RoomConnectionClient extends BaseClient<RoomConnectionState, RoomC
1228
1255
  joinRoom(): Promise<RoomJoinedSuccess>;
1229
1256
  sendChatMessage(text: string, parentId?: string): void;
1230
1257
  removeChatMessage(id: string, sig?: string | null): void;
1258
+ sendFiles(files: File[]): void;
1259
+ downloadFile(file: ChatFileShare): Promise<Blob>;
1231
1260
  knock(): void;
1232
1261
  cancelKnock(): void;
1233
1262
  leaveRoom(): void;
@@ -1280,5 +1309,5 @@ declare class WherebyClient {
1280
1309
  destroy(): void;
1281
1310
  }
1282
1311
 
1283
- 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 };
1284
- export type { AppConfig, BreakoutState, ChatMessage, ChatMessageEvent, ChatMessageState, ClientView, CloudRecordingState, ConnectionStatus, FullOrganizationPermissions, GridEvents, GridState, LiveStreamState, LiveTranscriptionState, LocalMediaEvents, LocalMediaOptions, LocalMediaState, LocalParticipantState, LocalScreenshareStatus, NotificationEvents, NotificationsEventEmitter, OrganizationLimits, OrganizationOnboardingSurvey, OrganizationPermissionAction, OrganizationPermissions, OrganizationPreferences, RemoteParticipant, RemoteParticipantData, RemoteParticipantState, RequestAudioEvent, RequestVideoEvent, RoomConnectionEvents, RoomConnectionState, Screenshare, ScreenshareState, SignalClientEvent, SignalStatusEvent, StickyReaction, StickyReactionEvent, StreamState, WaitingParticipant, WaitingParticipantState, WherebyClientOptions };
1312
+ 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 };
1313
+ export type { AppConfig, BreakoutState, ChatMessage, ChatMessageEvent, ChatMessageState, ClientView, CloudRecordingState, ConnectionStatus, FileShareError, FileUpload, FullOrganizationPermissions, GridEvents, GridState, LiveStreamState, LiveTranscriptionState, LocalMediaEvents, LocalMediaOptions, LocalMediaState, LocalParticipantState, LocalScreenshareStatus, NotificationEvents, NotificationsEventEmitter, OrganizationLimits, OrganizationOnboardingSurvey, OrganizationPermissionAction, OrganizationPermissions, OrganizationPreferences, RemoteParticipant, RemoteParticipantData, RemoteParticipantState, RequestAudioEvent, RequestVideoEvent, RoomConnectionEvents, RoomConnectionState, Screenshare, ScreenshareState, SignalClientEvent, SignalStatusEvent, StickyReaction, StickyReactionEvent, StreamState, WaitingParticipant, WaitingParticipantState, WherebyClientOptions };
package/dist/index.mjs CHANGED
@@ -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 = {}) {
@@ -1195,6 +1196,7 @@ function parseUnverifiedRoomKeyData(roomKey) {
1195
1196
 
1196
1197
  const listenerMiddleware = createListenerMiddleware();
1197
1198
  const startAppListening = listenerMiddleware.startListening;
1199
+ const addAppListener = addListener;
1198
1200
  const createReactor = (selectors, callback) => {
1199
1201
  return startAppListening({
1200
1202
  predicate: (_, currentState, previousState) => {
@@ -1213,7 +1215,7 @@ const createReactor = (selectors, callback) => {
1213
1215
  });
1214
1216
  };
1215
1217
 
1216
- const coreVersion = "1.13.0";
1218
+ const coreVersion = "1.14.1";
1217
1219
 
1218
1220
  const initialState$2 = {
1219
1221
  displayName: null,
@@ -1266,6 +1268,7 @@ const signalEvents = {
1266
1268
  breakoutSessionUpdated: createSignalEventAction("breakoutSessionUpdated"),
1267
1269
  chatMessage: createSignalEventAction("chatMessage"),
1268
1270
  chatMessageRemoved: createSignalEventAction("chatMessageRemoved"),
1271
+ fileSharingError: createSignalEventAction("fileSharingError"),
1269
1272
  clientLeft: createSignalEventAction("clientLeft"),
1270
1273
  clientKicked: createSignalEventAction("clientKicked"),
1271
1274
  clientMetadataReceived: createSignalEventAction("clientMetadataReceived"),
@@ -1446,7 +1449,13 @@ function forwardSocketEvents(socket, dispatch) {
1446
1449
  socket.on("video_enabled", (payload) => dispatch(signalEvents.videoEnabled(payload)));
1447
1450
  socket.on("audio_enable_requested", (payload) => dispatch(signalEvents.audioEnableRequested(payload)));
1448
1451
  socket.on("client_metadata_received", (payload) => dispatch(signalEvents.clientMetadataReceived(payload)));
1449
- 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
+ });
1450
1459
  socket.on("chat_message_removed", (payload) => dispatch(signalEvents.chatMessageRemoved(payload)));
1451
1460
  socket.on("disconnect", () => dispatch(signalEvents.disconnect()));
1452
1461
  socket.on("room_knocked", (payload) => dispatch(signalEvents.roomKnocked(payload)));
@@ -2277,15 +2286,7 @@ const chatSlice = createSlice({
2277
2286
  reducers: {},
2278
2287
  extraReducers(builder) {
2279
2288
  builder.addCase(signalEvents.chatMessage, (state, action) => {
2280
- const message = {
2281
- id: action.payload.id,
2282
- senderId: action.payload.senderId,
2283
- parentId: action.payload.parentId,
2284
- timestamp: action.payload.timestamp,
2285
- text: action.payload.text,
2286
- sig: action.payload.sig,
2287
- removed: false,
2288
- };
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 }));
2289
2290
  return Object.assign(Object.assign({}, state), { chatMessages: [...state.chatMessages, message] });
2290
2291
  });
2291
2292
  builder.addCase(signalEvents.chatMessageRemoved, (state, action) => {
@@ -3384,6 +3385,175 @@ createReactor([selectShouldStopConnectionMonitor], ({ dispatch }, shouldStartCon
3384
3385
  }
3385
3386
  });
3386
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
+
3387
3557
  const initialLiveTranscriptionState = {
3388
3558
  isInitiator: false,
3389
3559
  isTranscribing: false,
@@ -4502,6 +4672,7 @@ const appReducer = combineReducers({
4502
4672
  cloudRecording: cloudRecordingSlice.reducer,
4503
4673
  connectionMonitor: connectionMonitorSlice.reducer,
4504
4674
  deviceCredentials: deviceCredentialsSlice.reducer,
4675
+ fileShare: fileShareSlice.reducer,
4505
4676
  liveTranscription: liveTranscriptionSlice.reducer,
4506
4677
  localMedia: localMediaSlice.reducer,
4507
4678
  localParticipant: localParticipantSlice.reducer,
@@ -4870,9 +5041,10 @@ const SPOTLIGHT_PARTICIPANT_REMOVED = "spotlight:participant-removed";
4870
5041
  const ROOM_JOINED = "room:joined";
4871
5042
  const ROOM_JOINED_ERROR = "room:joined:error";
4872
5043
 
4873
- 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) => {
4874
5045
  const state = {
4875
5046
  chatMessages,
5047
+ fileUploads,
4876
5048
  cloudRecording: cloudRecording.status
4877
5049
  ? {
4878
5050
  error: cloudRecording.error,
@@ -4921,6 +5093,7 @@ class RoomConnectionClient extends BaseClient {
4921
5093
  this.breakoutSubscribers = new Set();
4922
5094
  this.cameraStateSubscribers = new Set();
4923
5095
  this.chatMessageSubscribers = new Set();
5096
+ this.fileUploadsSubscribers = new Set();
4924
5097
  this.cloudRecordingSubscribers = new Set();
4925
5098
  this.connectionErrorSubscribers = new Set();
4926
5099
  this.connectionStatusSubscribers = new Set();
@@ -4941,6 +5114,9 @@ class RoomConnectionClient extends BaseClient {
4941
5114
  if (state.chatMessages !== previousState.chatMessages) {
4942
5115
  this.chatMessageSubscribers.forEach((cb) => cb(state.chatMessages));
4943
5116
  }
5117
+ if (state.fileUploads !== previousState.fileUploads) {
5118
+ this.fileUploadsSubscribers.forEach((cb) => cb(state.fileUploads));
5119
+ }
4944
5120
  if (state.cloudRecording !== previousState.cloudRecording) {
4945
5121
  this.cloudRecordingSubscribers.forEach((cb) => cb(state.cloudRecording));
4946
5122
  this.emit(CLOUD_RECORDING_STATUS_CHANGED, state.cloudRecording);
@@ -5051,6 +5227,10 @@ class RoomConnectionClient extends BaseClient {
5051
5227
  this.chatMessageSubscribers.add(callback);
5052
5228
  return () => this.chatMessageSubscribers.delete(callback);
5053
5229
  }
5230
+ subscribeToFileUploads(callback) {
5231
+ this.fileUploadsSubscribers.add(callback);
5232
+ return () => this.fileUploadsSubscribers.delete(callback);
5233
+ }
5054
5234
  subscribeToCloudRecording(callback) {
5055
5235
  this.cloudRecordingSubscribers.add(callback);
5056
5236
  return () => this.cloudRecordingSubscribers.delete(callback);
@@ -5161,6 +5341,12 @@ class RoomConnectionClient extends BaseClient {
5161
5341
  removeChatMessage(id, sig) {
5162
5342
  this.store.dispatch(doRemoveChatMessage({ id, sig }));
5163
5343
  }
5344
+ sendFiles(files) {
5345
+ this.store.dispatch(doSendFiles({ files }));
5346
+ }
5347
+ downloadFile(file) {
5348
+ return this.store.dispatch(doDownloadFile({ file })).unwrap();
5349
+ }
5164
5350
  knock() {
5165
5351
  this.store.dispatch(doKnockRoom());
5166
5352
  }
@@ -5318,6 +5504,7 @@ class RoomConnectionClient extends BaseClient {
5318
5504
  this.breakoutSubscribers.clear();
5319
5505
  this.cameraStateSubscribers.clear();
5320
5506
  this.chatMessageSubscribers.clear();
5507
+ this.fileUploadsSubscribers.clear();
5321
5508
  this.cloudRecordingSubscribers.clear();
5322
5509
  this.connectionErrorSubscribers.clear();
5323
5510
  this.connectionStatusSubscribers.clear();
@@ -5359,4 +5546,4 @@ class WherebyClient {
5359
5546
  }
5360
5547
  }
5361
5548
 
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 };
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 };