@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.cjs CHANGED
@@ -5,6 +5,7 @@ var media = require('@whereby.com/media');
5
5
  var axios = require('axios');
6
6
  var events$1 = require('events');
7
7
  var toolkit = require('@reduxjs/toolkit');
8
+ var uuid = require('uuid');
8
9
 
9
10
  class Response {
10
11
  constructor(initialValues = {}) {
@@ -1197,6 +1198,7 @@ function parseUnverifiedRoomKeyData(roomKey) {
1197
1198
 
1198
1199
  const listenerMiddleware = toolkit.createListenerMiddleware();
1199
1200
  const startAppListening = listenerMiddleware.startListening;
1201
+ const addAppListener = toolkit.addListener;
1200
1202
  const createReactor = (selectors, callback) => {
1201
1203
  return startAppListening({
1202
1204
  predicate: (_, currentState, previousState) => {
@@ -1215,7 +1217,7 @@ const createReactor = (selectors, callback) => {
1215
1217
  });
1216
1218
  };
1217
1219
 
1218
- const coreVersion = "1.13.0";
1220
+ const coreVersion = "1.14.1";
1219
1221
 
1220
1222
  const initialState$2 = {
1221
1223
  displayName: null,
@@ -1268,6 +1270,7 @@ const signalEvents = {
1268
1270
  breakoutSessionUpdated: createSignalEventAction("breakoutSessionUpdated"),
1269
1271
  chatMessage: createSignalEventAction("chatMessage"),
1270
1272
  chatMessageRemoved: createSignalEventAction("chatMessageRemoved"),
1273
+ fileSharingError: createSignalEventAction("fileSharingError"),
1271
1274
  clientLeft: createSignalEventAction("clientLeft"),
1272
1275
  clientKicked: createSignalEventAction("clientKicked"),
1273
1276
  clientMetadataReceived: createSignalEventAction("clientMetadataReceived"),
@@ -1448,7 +1451,13 @@ function forwardSocketEvents(socket, dispatch) {
1448
1451
  socket.on("video_enabled", (payload) => dispatch(signalEvents.videoEnabled(payload)));
1449
1452
  socket.on("audio_enable_requested", (payload) => dispatch(signalEvents.audioEnableRequested(payload)));
1450
1453
  socket.on("client_metadata_received", (payload) => dispatch(signalEvents.clientMetadataReceived(payload)));
1451
- socket.on("chat_message", (payload) => dispatch(signalEvents.chatMessage(payload)));
1454
+ socket.on("chat_message", (payload) => {
1455
+ if (media.isFileShareError(payload)) {
1456
+ dispatch(signalEvents.fileSharingError(payload));
1457
+ return;
1458
+ }
1459
+ dispatch(signalEvents.chatMessage(payload));
1460
+ });
1452
1461
  socket.on("chat_message_removed", (payload) => dispatch(signalEvents.chatMessageRemoved(payload)));
1453
1462
  socket.on("disconnect", () => dispatch(signalEvents.disconnect()));
1454
1463
  socket.on("room_knocked", (payload) => dispatch(signalEvents.roomKnocked(payload)));
@@ -2279,15 +2288,7 @@ const chatSlice = toolkit.createSlice({
2279
2288
  reducers: {},
2280
2289
  extraReducers(builder) {
2281
2290
  builder.addCase(signalEvents.chatMessage, (state, action) => {
2282
- const message = {
2283
- id: action.payload.id,
2284
- senderId: action.payload.senderId,
2285
- parentId: action.payload.parentId,
2286
- timestamp: action.payload.timestamp,
2287
- text: action.payload.text,
2288
- sig: action.payload.sig,
2289
- removed: false,
2290
- };
2291
+ 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 }));
2291
2292
  return Object.assign(Object.assign({}, state), { chatMessages: [...state.chatMessages, message] });
2292
2293
  });
2293
2294
  builder.addCase(signalEvents.chatMessageRemoved, (state, action) => {
@@ -3386,6 +3387,175 @@ createReactor([selectShouldStopConnectionMonitor], ({ dispatch }, shouldStartCon
3386
3387
  }
3387
3388
  });
3388
3389
 
3390
+ const MAX_FILES_PER_UPLOAD = 10;
3391
+ const MAX_FILE_SIZE = 15 * 1024 * 1024;
3392
+ const ACCEPTED_FILE_TYPES = {
3393
+ "application/doc": [".doc", ".docx"],
3394
+ "application/msword": [".doc", ".docx"],
3395
+ "application/pdf": [".pdf"],
3396
+ "application/rtf": [".rtf"],
3397
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": [".xlsx"],
3398
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document": [".docx"],
3399
+ "audio/mpeg": [".mp3"],
3400
+ "audio/wav": [".wav"],
3401
+ "image/gif": [".gif"],
3402
+ "image/jpeg": [".jpeg", ".jpg"],
3403
+ "image/png": [".png"],
3404
+ "image/webp": [".webp"],
3405
+ "text/csv": [".csv"],
3406
+ "text/plain": [".txt"],
3407
+ "video/mp4": [".mp4"],
3408
+ "video/quicktime": [".mov"],
3409
+ "video/webm": [".webm"],
3410
+ "video/x-matroska": [".mkv"],
3411
+ };
3412
+ function isAcceptedFileType(file) {
3413
+ if (file.type && ACCEPTED_FILE_TYPES[file.type]) {
3414
+ return true;
3415
+ }
3416
+ const dot = file.name.lastIndexOf(".");
3417
+ if (dot < 0) {
3418
+ return false;
3419
+ }
3420
+ const extension = file.name.slice(dot).toLowerCase();
3421
+ return Object.values(ACCEPTED_FILE_TYPES).some((extensions) => extensions.includes(extension));
3422
+ }
3423
+ function validateFile(file) {
3424
+ if (!isAcceptedFileType(file)) {
3425
+ return "unsupported_file_type";
3426
+ }
3427
+ if (file.size > MAX_FILE_SIZE) {
3428
+ return "file_too_large";
3429
+ }
3430
+ return undefined;
3431
+ }
3432
+ const fileShareSliceInitialState = {
3433
+ uploads: [],
3434
+ requestInFlight: false,
3435
+ };
3436
+ const fileShareSlice = toolkit.createSlice({
3437
+ name: "fileShare",
3438
+ initialState: fileShareSliceInitialState,
3439
+ reducers: {
3440
+ fileUploadsStarted: (state, action) => {
3441
+ state.uploads.push(...action.payload);
3442
+ state.requestInFlight = true;
3443
+ },
3444
+ fileShareRequestSettled: (state) => {
3445
+ state.requestInFlight = false;
3446
+ },
3447
+ fileUploadSucceeded: (state, action) => {
3448
+ const upload = state.uploads.find((u) => u.id === action.payload.id);
3449
+ if (upload) {
3450
+ upload.status = "sent";
3451
+ }
3452
+ },
3453
+ fileUploadFailed: (state, action) => {
3454
+ const upload = state.uploads.find((u) => u.id === action.payload.id);
3455
+ if (upload) {
3456
+ upload.status = "error";
3457
+ upload.error = action.payload.error;
3458
+ }
3459
+ },
3460
+ clearFileUploads: (state) => {
3461
+ state.uploads = [];
3462
+ },
3463
+ },
3464
+ });
3465
+ const { fileUploadsStarted, fileShareRequestSettled, fileUploadSucceeded, fileUploadFailed, clearFileUploads } = fileShareSlice.actions;
3466
+ function uploadFile(file, uploadUrl) {
3467
+ const form = new FormData();
3468
+ form.append("Content-Type", file.type);
3469
+ Object.entries(uploadUrl.fields).forEach(([key, value]) => form.append(key, value));
3470
+ form.append("file", file);
3471
+ return fetch(uploadUrl.url, { method: "POST", body: form });
3472
+ }
3473
+ const doSendFiles = createAsyncRoomConnectedThunk("fileShare/sendFiles", (payload_1, _a) => __awaiter(void 0, [payload_1, _a], void 0, function* (payload, { dispatch, getState }) {
3474
+ const state = getState();
3475
+ if (state.fileShare.requestInFlight) {
3476
+ return Promise.reject(new Error("A file upload request is already in flight"));
3477
+ }
3478
+ const socket = selectSignalConnectionRaw(state).socket;
3479
+ if (!socket) {
3480
+ return Promise.reject(new Error("No signal connection"));
3481
+ }
3482
+ const breakoutCurrentId = selectBreakoutCurrentId(state);
3483
+ const { files } = payload;
3484
+ if (!files.length) {
3485
+ return;
3486
+ }
3487
+ const tooManyFiles = files.length > MAX_FILES_PER_UPLOAD;
3488
+ const entries = files.map((file) => {
3489
+ const error = tooManyFiles ? "too_many_files" : validateFile(file);
3490
+ const upload = Object.assign({ id: uuid.v4(), name: file.name, size: file.size, type: file.type, status: error ? "error" : "uploading" }, (error && { error }));
3491
+ return { file, upload };
3492
+ });
3493
+ dispatch(fileUploadsStarted(entries.map((entry) => entry.upload)));
3494
+ const accepted = entries.filter((entry) => entry.upload.status === "uploading");
3495
+ if (!accepted.length) {
3496
+ dispatch(fileShareRequestSettled());
3497
+ return;
3498
+ }
3499
+ const acceptedFiles = accepted.map((entry) => entry.file);
3500
+ const outcome = yield new Promise((resolve) => {
3501
+ let settled = false;
3502
+ const removeListener = dispatch(addAppListener({
3503
+ actionCreator: signalEvents.fileSharingError,
3504
+ effect: (action, listenerApi) => {
3505
+ if (settled)
3506
+ return;
3507
+ settled = true;
3508
+ listenerApi.unsubscribe();
3509
+ resolve({ error: action.payload.error });
3510
+ },
3511
+ }));
3512
+ socket.emit("request_file_upload_url", { files: acceptedFiles.map((f) => ({ name: f.name, size: f.size, type: f.type })) }, (urls) => {
3513
+ if (settled)
3514
+ return;
3515
+ settled = true;
3516
+ removeListener({ cancelActive: true });
3517
+ resolve({ urls });
3518
+ });
3519
+ });
3520
+ dispatch(fileShareRequestSettled());
3521
+ if ("error" in outcome) {
3522
+ accepted.forEach((entry) => dispatch(fileUploadFailed({ id: entry.upload.id, error: outcome.error })));
3523
+ return;
3524
+ }
3525
+ yield Promise.all(accepted.map((_a, index_1) => __awaiter(void 0, [_a, index_1], void 0, function* ({ file, upload }, index) {
3526
+ const urls = outcome.urls[index];
3527
+ if (!urls) {
3528
+ dispatch(fileUploadFailed({ id: upload.id, error: "upload_failed" }));
3529
+ return;
3530
+ }
3531
+ try {
3532
+ const response = yield uploadFile(file, urls.uploadUrl);
3533
+ if (!response.ok) {
3534
+ throw new Error(`S3 upload failed with status ${response.status}`);
3535
+ }
3536
+ socket.emit("chat_message", Object.assign({ text: "", file: {
3537
+ downloadUrl: urls.downloadUrl,
3538
+ name: file.name,
3539
+ size: file.size,
3540
+ type: file.type,
3541
+ key: urls.uploadUrl.fields.key,
3542
+ } }, (breakoutCurrentId && { breakoutGroup: breakoutCurrentId })));
3543
+ dispatch(fileUploadSucceeded({ id: upload.id }));
3544
+ }
3545
+ catch (_b) {
3546
+ dispatch(fileUploadFailed({ id: upload.id, error: "upload_failed" }));
3547
+ }
3548
+ })));
3549
+ }));
3550
+ const doDownloadFile = createAppAsyncThunk("fileShare/downloadFile", (payload) => __awaiter(void 0, void 0, void 0, function* () {
3551
+ const response = yield fetch(payload.file.downloadUrl, { mode: "cors", cache: "no-cache" });
3552
+ if (!response.ok) {
3553
+ throw new Error(`Failed to download file: ${response.status}`);
3554
+ }
3555
+ return response.blob();
3556
+ }));
3557
+ const selectFileUploads = (state) => state.fileShare.uploads;
3558
+
3389
3559
  const initialLiveTranscriptionState = {
3390
3560
  isInitiator: false,
3391
3561
  isTranscribing: false,
@@ -4504,6 +4674,7 @@ const appReducer = toolkit.combineReducers({
4504
4674
  cloudRecording: cloudRecordingSlice.reducer,
4505
4675
  connectionMonitor: connectionMonitorSlice.reducer,
4506
4676
  deviceCredentials: deviceCredentialsSlice.reducer,
4677
+ fileShare: fileShareSlice.reducer,
4507
4678
  liveTranscription: liveTranscriptionSlice.reducer,
4508
4679
  localMedia: localMediaSlice.reducer,
4509
4680
  localParticipant: localParticipantSlice.reducer,
@@ -4872,9 +5043,10 @@ const SPOTLIGHT_PARTICIPANT_REMOVED = "spotlight:participant-removed";
4872
5043
  const ROOM_JOINED = "room:joined";
4873
5044
  const ROOM_JOINED_ERROR = "room:joined:error";
4874
5045
 
4875
- const selectRoomConnectionState = toolkit.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) => {
5046
+ const selectRoomConnectionState = toolkit.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) => {
4876
5047
  const state = {
4877
5048
  chatMessages,
5049
+ fileUploads,
4878
5050
  cloudRecording: cloudRecording.status
4879
5051
  ? {
4880
5052
  error: cloudRecording.error,
@@ -4923,6 +5095,7 @@ class RoomConnectionClient extends BaseClient {
4923
5095
  this.breakoutSubscribers = new Set();
4924
5096
  this.cameraStateSubscribers = new Set();
4925
5097
  this.chatMessageSubscribers = new Set();
5098
+ this.fileUploadsSubscribers = new Set();
4926
5099
  this.cloudRecordingSubscribers = new Set();
4927
5100
  this.connectionErrorSubscribers = new Set();
4928
5101
  this.connectionStatusSubscribers = new Set();
@@ -4943,6 +5116,9 @@ class RoomConnectionClient extends BaseClient {
4943
5116
  if (state.chatMessages !== previousState.chatMessages) {
4944
5117
  this.chatMessageSubscribers.forEach((cb) => cb(state.chatMessages));
4945
5118
  }
5119
+ if (state.fileUploads !== previousState.fileUploads) {
5120
+ this.fileUploadsSubscribers.forEach((cb) => cb(state.fileUploads));
5121
+ }
4946
5122
  if (state.cloudRecording !== previousState.cloudRecording) {
4947
5123
  this.cloudRecordingSubscribers.forEach((cb) => cb(state.cloudRecording));
4948
5124
  this.emit(CLOUD_RECORDING_STATUS_CHANGED, state.cloudRecording);
@@ -5053,6 +5229,10 @@ class RoomConnectionClient extends BaseClient {
5053
5229
  this.chatMessageSubscribers.add(callback);
5054
5230
  return () => this.chatMessageSubscribers.delete(callback);
5055
5231
  }
5232
+ subscribeToFileUploads(callback) {
5233
+ this.fileUploadsSubscribers.add(callback);
5234
+ return () => this.fileUploadsSubscribers.delete(callback);
5235
+ }
5056
5236
  subscribeToCloudRecording(callback) {
5057
5237
  this.cloudRecordingSubscribers.add(callback);
5058
5238
  return () => this.cloudRecordingSubscribers.delete(callback);
@@ -5163,6 +5343,12 @@ class RoomConnectionClient extends BaseClient {
5163
5343
  removeChatMessage(id, sig) {
5164
5344
  this.store.dispatch(doRemoveChatMessage({ id, sig }));
5165
5345
  }
5346
+ sendFiles(files) {
5347
+ this.store.dispatch(doSendFiles({ files }));
5348
+ }
5349
+ downloadFile(file) {
5350
+ return this.store.dispatch(doDownloadFile({ file })).unwrap();
5351
+ }
5166
5352
  knock() {
5167
5353
  this.store.dispatch(doKnockRoom());
5168
5354
  }
@@ -5320,6 +5506,7 @@ class RoomConnectionClient extends BaseClient {
5320
5506
  this.breakoutSubscribers.clear();
5321
5507
  this.cameraStateSubscribers.clear();
5322
5508
  this.chatMessageSubscribers.clear();
5509
+ this.fileUploadsSubscribers.clear();
5323
5510
  this.cloudRecordingSubscribers.clear();
5324
5511
  this.connectionErrorSubscribers.clear();
5325
5512
  this.connectionStatusSubscribers.clear();
@@ -5361,6 +5548,7 @@ class WherebyClient {
5361
5548
  }
5362
5549
  }
5363
5550
 
5551
+ exports.ACCEPTED_FILE_TYPES = ACCEPTED_FILE_TYPES;
5364
5552
  exports.ApiClient = ApiClient;
5365
5553
  exports.BREAKOUT_CONFIG_CHANGED = BREAKOUT_CONFIG_CHANGED;
5366
5554
  exports.CAMERA_DEVICES_CHANGED = CAMERA_DEVICES_CHANGED;
@@ -5388,6 +5576,8 @@ exports.LOCAL_SCREENSHARE_STATUS_CHANGED = LOCAL_SCREENSHARE_STATUS_CHANGED;
5388
5576
  exports.LOCAL_STREAM_CHANGED = LOCAL_STREAM_CHANGED;
5389
5577
  exports.LocalMediaClient = LocalMediaClient;
5390
5578
  exports.LocalParticipant = LocalParticipant;
5579
+ exports.MAX_FILES_PER_UPLOAD = MAX_FILES_PER_UPLOAD;
5580
+ exports.MAX_FILE_SIZE = MAX_FILE_SIZE;
5391
5581
  exports.MICROPHONE_DEVICES_CHANGED = MICROPHONE_DEVICES_CHANGED;
5392
5582
  exports.MICROPHONE_DEVICE_ERROR_CHANGED = MICROPHONE_DEVICE_ERROR_CHANGED;
5393
5583
  exports.MICROPHONE_STATE_CHANGED = MICROPHONE_STATE_CHANGED;
package/dist/index.d.cts 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.d.mts 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 };