@whereby.com/core 0.16.3 → 0.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -43,7 +43,7 @@ const createReactor = (selectors, callback) => {
43
43
  });
44
44
  };
45
45
 
46
- const coreVersion = "0.16.3";
46
+ const coreVersion = "0.18.0";
47
47
 
48
48
  const initialState$f = {
49
49
  isNodeSdk: false,
@@ -1048,6 +1048,8 @@ startAppListening({
1048
1048
  },
1049
1049
  });
1050
1050
 
1051
+ const NON_PERSON_ROLES = ["recorder", "streamer"];
1052
+
1051
1053
  const initialState$a = {
1052
1054
  displayName: "",
1053
1055
  id: "",
@@ -1144,6 +1146,9 @@ const selectLocalParticipantView = createSelector(selectLocalParticipantRaw, sel
1144
1146
  isAudioEnabled: participant.isAudioEnabled,
1145
1147
  isVideoEnabled: participant.isVideoEnabled,
1146
1148
  };
1149
+ if (NON_PERSON_ROLES.includes(participant.roleName)) {
1150
+ return null;
1151
+ }
1147
1152
  return clientView;
1148
1153
  });
1149
1154
  startAppListening({
@@ -1251,7 +1256,6 @@ const rtcEvents = {
1251
1256
  streamAdded: createRtcEventAction("streamAdded"),
1252
1257
  };
1253
1258
 
1254
- const NON_PERSON_ROLES = ["recorder", "streamer"];
1255
1259
  function createRemoteParticipant(client, newJoiner = false) {
1256
1260
  const { streams, role } = client, rest = __rest(client, ["streams", "role"]);
1257
1261
  return Object.assign(Object.assign({}, rest), { stream: null, streams: streams.map((streamId) => ({ id: streamId, state: newJoiner ? "new_accept" : "to_accept" })), isLocalParticipant: false, roleName: (role === null || role === void 0 ? void 0 : role.roleName) || "none", presentationStream: null, newJoiner });
@@ -1440,8 +1444,15 @@ const doRequestAudioEnable = createAppAuthorizedThunk((state) => selectIsAuthori
1440
1444
  socket === null || socket === void 0 ? void 0 : socket.emit("request_audio_enable", payload);
1441
1445
  });
1442
1446
  const selectRemoteParticipantsRaw = (state) => state.remoteParticipants;
1443
- const selectRemoteParticipants = (state) => state.remoteParticipants.remoteParticipants;
1444
- const selectNumParticipants = createSelector(selectRemoteParticipants, (clients) => clients.filter((c) => !NON_PERSON_ROLES.includes(c.roleName)).length + 1);
1447
+ const selectRemoteClients = (state) => state.remoteParticipants.remoteParticipants;
1448
+ const selectRemoteParticipants = createSelector(selectRemoteClients, (clients) => clients.filter((c) => !NON_PERSON_ROLES.includes(c.roleName)));
1449
+ const selectNumClients = createSelector(selectRemoteClients, (clients) => clients.length + 1);
1450
+ const selectNumParticipants = createSelector(selectRemoteParticipants, selectLocalParticipantRaw, (clients, localParticipant) => {
1451
+ if (NON_PERSON_ROLES.includes(localParticipant.roleName)) {
1452
+ return clients.length;
1453
+ }
1454
+ return clients.length + 1;
1455
+ });
1445
1456
 
1446
1457
  const initialState$7 = {
1447
1458
  data: null,
@@ -1835,7 +1846,7 @@ const doKickParticipant = createAppAuthorizedThunk((state) => selectIsAuthorized
1835
1846
  });
1836
1847
  const doEndMeeting = createAppAuthorizedThunk((state) => selectIsAuthorizedToEndMeeting(state), (payload) => (dispatch, getState) => {
1837
1848
  const state = getState();
1838
- const clientsToKick = selectRemoteParticipants(state).map((c) => c.id);
1849
+ const clientsToKick = selectRemoteClients(state).map((c) => c.id);
1839
1850
  if (clientsToKick.length) {
1840
1851
  const { socket } = selectSignalConnectionRaw(state);
1841
1852
  socket === null || socket === void 0 ? void 0 : socket.emit("kick_client", { clientIds: clientsToKick, reasonId: "end-meeting" });
@@ -1902,7 +1913,7 @@ const selectRemoteClientViews = createSelector(selectLocalScreenshareStream, sel
1902
1913
  return views;
1903
1914
  });
1904
1915
  const selectAllClientViews = createSelector(selectLocalParticipantView, selectRemoteClientViews, (localParticipant, remoteParticipants) => {
1905
- return [localParticipant, ...remoteParticipants];
1916
+ return [...(localParticipant ? [localParticipant] : []), ...remoteParticipants];
1906
1917
  });
1907
1918
 
1908
1919
  const createWebRtcEmitter = (dispatch) => {
@@ -2017,7 +2028,7 @@ const doHandleAcceptStreams = createAppThunk((payload) => (dispatch, getState) =
2017
2028
  dispatch(isAcceptingStreams(true));
2018
2029
  const state = getState();
2019
2030
  const rtcManager = selectRtcConnectionRaw(state).rtcManager;
2020
- const remoteParticipants = selectRemoteParticipants(state);
2031
+ const remoteClients = selectRemoteClients(state);
2021
2032
  if (!rtcManager) {
2022
2033
  throw new Error("No rtc manager");
2023
2034
  }
@@ -2025,7 +2036,7 @@ const doHandleAcceptStreams = createAppThunk((payload) => (dispatch, getState) =
2025
2036
  const shouldAcceptNewClients = (_a = rtcManager.shouldAcceptStreamsFromBothSides) === null || _a === void 0 ? void 0 : _a.call(rtcManager);
2026
2037
  const updates = [];
2027
2038
  for (const { clientId, streamId, state } of payload) {
2028
- const participant = remoteParticipants.find((p) => p.id === clientId);
2039
+ const participant = remoteClients.find((p) => p.id === clientId);
2029
2040
  if (!participant)
2030
2041
  continue;
2031
2042
  if (state === "to_accept" ||
@@ -2165,7 +2176,7 @@ createReactor([selectShouldDisconnectRtc], ({ dispatch }, shouldDisconnectRtc) =
2165
2176
  dispatch(doDisconnectRtc());
2166
2177
  }
2167
2178
  });
2168
- const selectStreamsToAccept = createSelector(selectRtcStatus, selectRemoteParticipants, (rtcStatus, remoteParticipants) => {
2179
+ const selectStreamsToAccept = createSelector(selectRtcStatus, selectRemoteClients, (rtcStatus, remoteParticipants) => {
2169
2180
  if (rtcStatus !== "ready") {
2170
2181
  return [];
2171
2182
  }
@@ -2405,7 +2416,16 @@ const initialState$2 = {
2405
2416
  const spotlightsSlice = createSlice({
2406
2417
  name: "spotlights",
2407
2418
  initialState: initialState$2,
2408
- reducers: {},
2419
+ reducers: {
2420
+ addSpotlight(state, action) {
2421
+ const { clientId, streamId } = action.payload;
2422
+ return Object.assign(Object.assign({}, state), { sorted: mergeSpotlight(state.sorted, { clientId, streamId }) });
2423
+ },
2424
+ removeSpotlight(state, action) {
2425
+ const { clientId, streamId } = action.payload;
2426
+ return Object.assign(Object.assign({}, state), { sorted: state.sorted.filter((s) => !(s.clientId === clientId && s.streamId === streamId)) });
2427
+ },
2428
+ },
2409
2429
  extraReducers: (builder) => {
2410
2430
  builder.addCase(signalEvents.roomJoined, (state, action) => {
2411
2431
  if (!action.payload.room) {
@@ -2428,6 +2448,7 @@ const spotlightsSlice = createSlice({
2428
2448
  });
2429
2449
  },
2430
2450
  });
2451
+ const { addSpotlight, removeSpotlight } = spotlightsSlice.actions;
2431
2452
  const doSpotlightParticipant = createAppAuthorizedThunk((state) => selectIsAuthorizedToSpotlight(state), ({ id }) => (_, getState) => {
2432
2453
  const state = getState();
2433
2454
  const clientView = selectAllClientViews(state).find((c) => c.clientId === id);
@@ -2458,6 +2479,30 @@ const selectIsLocalParticipantSpotlighted = createSelector(selectLocalParticipan
2458
2479
  const selectSpotlightedClientViews = createSelector(selectAllClientViews, selectSpotlights, (clientViews, spotlights) => {
2459
2480
  return mapSpotlightsToClientViews(spotlights, clientViews);
2460
2481
  });
2482
+ startAppListening({
2483
+ actionCreator: doStartScreenshare.fulfilled,
2484
+ effect: ({ payload }, { getState, dispatch }) => {
2485
+ const { stream } = payload;
2486
+ const state = getState();
2487
+ const localParticipant = selectLocalParticipantRaw(state);
2488
+ if (!localParticipant) {
2489
+ return;
2490
+ }
2491
+ dispatch(addSpotlight({ clientId: localParticipant.id, streamId: stream.id }));
2492
+ },
2493
+ });
2494
+ startAppListening({
2495
+ actionCreator: stopScreenshare,
2496
+ effect: ({ payload }, { getState, dispatch }) => {
2497
+ const { stream } = payload;
2498
+ const state = getState();
2499
+ const localParticipant = selectLocalParticipantRaw(state);
2500
+ if (!localParticipant) {
2501
+ return;
2502
+ }
2503
+ dispatch(removeSpotlight({ clientId: localParticipant.id, streamId: stream.id }));
2504
+ },
2505
+ });
2461
2506
 
2462
2507
  const initialState$1 = {
2463
2508
  isStreaming: false,
@@ -3601,4 +3646,4 @@ function createServices() {
3601
3646
  };
3602
3647
  }
3603
3648
 
3604
- export { ApiClient, Credentials, CredentialsService, LocalParticipant, OrganizationApiClient, OrganizationService, OrganizationServiceCache, RoomService, addAppListener, appSlice, authorizationSlice, chatSlice, cloudRecordingSlice, createAppAsyncThunk, createAppAuthorizedThunk, createAppThunk, createReactor, createServices, createStore, createWebRtcEmitter, debounce, deviceBusy, deviceCredentialsSlice, deviceIdentified, deviceIdentifying, doAcceptWaitingParticipant, doAppStart, doAppStop, doClearNotifications, doConnectRoom, doConnectRtc, doDisconnectRtc, doEnableAudio, doEnableVideo, doEndMeeting, doGetDeviceCredentials, doHandleAcceptStreams, doHandleStreamingStarted, doHandleStreamingStopped, doKickParticipant, doKnockRoom, doLockRoom, doOrganizationFetch, doRejectWaitingParticipant, doRemoveSpotlight, doRequestAudioEnable, doRtcAnalyticsCustomEventsInitialize, doRtcManagerCreated, doRtcManagerInitialize, doRtcReportStreamResolution, doSendChatMessage, doSendClientMetadata, doSetDevice, doSetDisplayName, doSetLocalStickyReaction, doSetNotification, doSignalConnect, doSignalDisconnect, doSignalIdentifyDevice, doSpotlightParticipant, doStartCloudRecording, doStartLocalMedia, doStartScreenshare, doStopCloudRecording, doStopLocalMedia, doStopScreenshare, doSwitchLocalStream, doToggleCamera, doToggleLowDataMode, doUpdateDeviceList, getAudioTrack, getFakeMediaStream, getVideoTrack, hasValue, initialCloudRecordingState, initialLocalMediaState, initialNotificationsState, isAcceptingStreams, isClientSpotlighted, listenerMiddleware, localMediaSlice, localMediaStopped, localParticipantSlice, localScreenshareSlice, localStreamMetadataUpdated, notificationsSlice, observeStore, organizationSlice, parseRoomUrlAndSubdomain, parseUnverifiedRoomKeyData, participantStreamAdded, participantStreamIdAdded, recordingRequestStarted, remoteParticipantsSlice, resolutionReported, roomConnectionSlice, roomSlice, rootReducer, rtcAnalyticsCustomEvents, rtcAnalyticsSlice, rtcConnectionSlice, rtcDisconnected, rtcDispatcherCreated, rtcManagerCreated, rtcManagerDestroyed, rtcManagerInitialized, selectAllClientViews, selectAppDisplayName, selectAppExternalId, selectAppInitialConfig, selectAppIsActive, selectAppIsNodeSdk, selectAppRaw, selectAppRoomName, selectAppRoomUrl, selectAppUserAgent, selectAuthorizationRoleName, selectBusyDeviceIds, selectCameraDeviceError, selectCameraDevices, selectChatMessages, selectChatRaw, selectCloudRecordingError, selectCloudRecordingRaw, selectCloudRecordingStartedAt, selectCloudRecordingStatus, selectCurrentCameraDeviceId, selectCurrentMicrophoneDeviceId, selectCurrentSpeakerDeviceId, selectDeviceCredentialsRaw, selectDeviceId, selectHasFetchedDeviceCredentials, selectIsAcceptingStreams, selectIsAuthorizedToAskToSpeak, selectIsAuthorizedToEndMeeting, selectIsAuthorizedToKickClient, selectIsAuthorizedToLockRoom, selectIsAuthorizedToRequestAudioEnable, selectIsAuthorizedToSpotlight, selectIsCameraEnabled, selectIsCloudRecording, selectIsLocalMediaStarting, selectIsLocalParticipantSpotlighted, selectIsLowDataModeEnabled, selectIsMicrophoneEnabled, selectIsSettingCameraDevice, selectIsSettingMicrophoneDevice, selectIsToggleCamera, selectLocalMediaConstraintsOptions, selectLocalMediaDevices, selectLocalMediaIsSwitchingStream, selectLocalMediaOptions, selectLocalMediaOwnsStream, selectLocalMediaRaw, selectLocalMediaShouldStartWithOptions, selectLocalMediaShouldStop, selectLocalMediaStartError, selectLocalMediaStatus, selectLocalMediaStream, selectLocalParticipantClientClaim, selectLocalParticipantDisplayName, selectLocalParticipantIsScreenSharing, selectLocalParticipantRaw, selectLocalParticipantStickyReaction, selectLocalParticipantView, selectLocalScreenshareRaw, selectLocalScreenshareStatus, selectLocalScreenshareStream, selectMicrophoneDeviceError, selectMicrophoneDevices, selectNotificationsEmitter, selectNotificationsEvents, selectNotificationsRaw, selectNumParticipants, selectOrganizationId, selectOrganizationRaw, selectRemoteClientViews, selectRemoteParticipants, selectRemoteParticipantsRaw, selectRoomConnectionError, selectRoomConnectionRaw, selectRoomConnectionSession, selectRoomConnectionSessionId, selectRoomConnectionStatus, selectRoomIsLocked, selectRoomKey, selectRtcConnectionRaw, selectRtcDispatcherCreated, selectRtcIsCreatingDispatcher, selectRtcManager, selectRtcManagerInitialized, selectRtcStatus, selectScreenshares, selectSelfId, selectShouldConnectRoom, selectShouldConnectRtc, selectShouldConnectSignal, selectShouldDisconnectRtc, selectShouldFetchDeviceCredentials, selectShouldFetchOrganization, selectShouldIdentifyDevice, selectShouldInitializeRtc, selectSignalConnectionDeviceIdentified, selectSignalConnectionRaw, selectSignalConnectionSocket, selectSignalIsIdentifyingDevice, selectSignalStatus, selectSpeakerDevices, selectSpotlightedClientViews, selectSpotlights, selectSpotlightsRaw, selectStreamingRaw, selectStreamsToAccept, selectWaitingParticipants, selectWaitingParticipantsRaw, setCurrentCameraDeviceId, setCurrentMicrophoneDeviceId, setCurrentSpeakerDeviceId, setLocalMediaOptions, setLocalMediaStream, setRoomKey, signalConnectionSlice, signalEvents, socketConnected, socketConnecting, socketDisconnected, socketReconnecting, spotlightsSlice, startAppListening, stopScreenshare, streamIdForClient, streamStatusUpdated, streamingSlice, toggleCameraEnabled, toggleLowDataModeEnabled, toggleMicrophoneEnabled, updateReportedValues, waitingParticipantsSlice };
3649
+ export { ApiClient, Credentials, CredentialsService, LocalParticipant, OrganizationApiClient, OrganizationService, OrganizationServiceCache, RoomService, addAppListener, addSpotlight, appSlice, authorizationSlice, chatSlice, cloudRecordingSlice, createAppAsyncThunk, createAppAuthorizedThunk, createAppThunk, createReactor, createServices, createStore, createWebRtcEmitter, debounce, deviceBusy, deviceCredentialsSlice, deviceIdentified, deviceIdentifying, doAcceptWaitingParticipant, doAppStart, doAppStop, doClearNotifications, doConnectRoom, doConnectRtc, doDisconnectRtc, doEnableAudio, doEnableVideo, doEndMeeting, doGetDeviceCredentials, doHandleAcceptStreams, doHandleStreamingStarted, doHandleStreamingStopped, doKickParticipant, doKnockRoom, doLockRoom, doOrganizationFetch, doRejectWaitingParticipant, doRemoveSpotlight, doRequestAudioEnable, doRtcAnalyticsCustomEventsInitialize, doRtcManagerCreated, doRtcManagerInitialize, doRtcReportStreamResolution, doSendChatMessage, doSendClientMetadata, doSetDevice, doSetDisplayName, doSetLocalStickyReaction, doSetNotification, doSignalConnect, doSignalDisconnect, doSignalIdentifyDevice, doSpotlightParticipant, doStartCloudRecording, doStartLocalMedia, doStartScreenshare, doStopCloudRecording, doStopLocalMedia, doStopScreenshare, doSwitchLocalStream, doToggleCamera, doToggleLowDataMode, doUpdateDeviceList, getAudioTrack, getFakeMediaStream, getVideoTrack, hasValue, initialCloudRecordingState, initialLocalMediaState, initialNotificationsState, isAcceptingStreams, isClientSpotlighted, listenerMiddleware, localMediaSlice, localMediaStopped, localParticipantSlice, localScreenshareSlice, localStreamMetadataUpdated, notificationsSlice, observeStore, organizationSlice, parseRoomUrlAndSubdomain, parseUnverifiedRoomKeyData, participantStreamAdded, participantStreamIdAdded, recordingRequestStarted, remoteParticipantsSlice, removeSpotlight, resolutionReported, roomConnectionSlice, roomSlice, rootReducer, rtcAnalyticsCustomEvents, rtcAnalyticsSlice, rtcConnectionSlice, rtcDisconnected, rtcDispatcherCreated, rtcManagerCreated, rtcManagerDestroyed, rtcManagerInitialized, selectAllClientViews, selectAppDisplayName, selectAppExternalId, selectAppInitialConfig, selectAppIsActive, selectAppIsNodeSdk, selectAppRaw, selectAppRoomName, selectAppRoomUrl, selectAppUserAgent, selectAuthorizationRoleName, selectBusyDeviceIds, selectCameraDeviceError, selectCameraDevices, selectChatMessages, selectChatRaw, selectCloudRecordingError, selectCloudRecordingRaw, selectCloudRecordingStartedAt, selectCloudRecordingStatus, selectCurrentCameraDeviceId, selectCurrentMicrophoneDeviceId, selectCurrentSpeakerDeviceId, selectDeviceCredentialsRaw, selectDeviceId, selectHasFetchedDeviceCredentials, selectIsAcceptingStreams, selectIsAuthorizedToAskToSpeak, selectIsAuthorizedToEndMeeting, selectIsAuthorizedToKickClient, selectIsAuthorizedToLockRoom, selectIsAuthorizedToRequestAudioEnable, selectIsAuthorizedToSpotlight, selectIsCameraEnabled, selectIsCloudRecording, selectIsLocalMediaStarting, selectIsLocalParticipantSpotlighted, selectIsLowDataModeEnabled, selectIsMicrophoneEnabled, selectIsSettingCameraDevice, selectIsSettingMicrophoneDevice, selectIsToggleCamera, selectLocalMediaConstraintsOptions, selectLocalMediaDevices, selectLocalMediaIsSwitchingStream, selectLocalMediaOptions, selectLocalMediaOwnsStream, selectLocalMediaRaw, selectLocalMediaShouldStartWithOptions, selectLocalMediaShouldStop, selectLocalMediaStartError, selectLocalMediaStatus, selectLocalMediaStream, selectLocalParticipantClientClaim, selectLocalParticipantDisplayName, selectLocalParticipantIsScreenSharing, selectLocalParticipantRaw, selectLocalParticipantStickyReaction, selectLocalParticipantView, selectLocalScreenshareRaw, selectLocalScreenshareStatus, selectLocalScreenshareStream, selectMicrophoneDeviceError, selectMicrophoneDevices, selectNotificationsEmitter, selectNotificationsEvents, selectNotificationsRaw, selectNumClients, selectNumParticipants, selectOrganizationId, selectOrganizationRaw, selectRemoteClientViews, selectRemoteClients, selectRemoteParticipants, selectRemoteParticipantsRaw, selectRoomConnectionError, selectRoomConnectionRaw, selectRoomConnectionSession, selectRoomConnectionSessionId, selectRoomConnectionStatus, selectRoomIsLocked, selectRoomKey, selectRtcConnectionRaw, selectRtcDispatcherCreated, selectRtcIsCreatingDispatcher, selectRtcManager, selectRtcManagerInitialized, selectRtcStatus, selectScreenshares, selectSelfId, selectShouldConnectRoom, selectShouldConnectRtc, selectShouldConnectSignal, selectShouldDisconnectRtc, selectShouldFetchDeviceCredentials, selectShouldFetchOrganization, selectShouldIdentifyDevice, selectShouldInitializeRtc, selectSignalConnectionDeviceIdentified, selectSignalConnectionRaw, selectSignalConnectionSocket, selectSignalIsIdentifyingDevice, selectSignalStatus, selectSpeakerDevices, selectSpotlightedClientViews, selectSpotlights, selectSpotlightsRaw, selectStreamingRaw, selectStreamsToAccept, selectWaitingParticipants, selectWaitingParticipantsRaw, setCurrentCameraDeviceId, setCurrentMicrophoneDeviceId, setCurrentSpeakerDeviceId, setLocalMediaOptions, setLocalMediaStream, setRoomKey, signalConnectionSlice, signalEvents, socketConnected, socketConnecting, socketDisconnected, socketReconnecting, spotlightsSlice, startAppListening, stopScreenshare, streamIdForClient, streamStatusUpdated, streamingSlice, toggleCameraEnabled, toggleLowDataModeEnabled, toggleMicrophoneEnabled, updateReportedValues, waitingParticipantsSlice };
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": "0.16.3",
5
+ "version": "0.18.0",
6
6
  "license": "MIT",
7
7
  "scripts": {
8
8
  "build": "rimraf dist && rollup -c rollup.config.js",