@whereby.com/core 1.1.8 → 1.2.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.cjs +69 -22
- package/dist/index.d.cts +11 -2
- package/dist/index.d.mts +11 -2
- package/dist/index.d.ts +11 -2
- package/dist/index.mjs +70 -23
- package/dist/legacy-esm.js +70 -23
- package/dist/redux/index.cjs +35 -8
- package/dist/redux/index.d.cts +14 -1
- package/dist/redux/index.d.mts +14 -1
- package/dist/redux/index.d.ts +14 -1
- package/dist/redux/index.js +34 -9
- package/dist/redux/index.mjs +34 -9
- package/package.json +5 -5
package/dist/index.cjs
CHANGED
|
@@ -1147,12 +1147,13 @@ const createReactor = (selectors, callback) => {
|
|
|
1147
1147
|
});
|
|
1148
1148
|
};
|
|
1149
1149
|
|
|
1150
|
-
const coreVersion = "1.
|
|
1150
|
+
const coreVersion = "1.2.0";
|
|
1151
1151
|
|
|
1152
1152
|
const initialState = {
|
|
1153
1153
|
isNodeSdk: false,
|
|
1154
1154
|
isActive: false,
|
|
1155
1155
|
isDialIn: false,
|
|
1156
|
+
isAssistant: false,
|
|
1156
1157
|
ignoreBreakoutGroups: false,
|
|
1157
1158
|
roomName: null,
|
|
1158
1159
|
roomUrl: null,
|
|
@@ -1166,7 +1167,7 @@ const appSlice = toolkit.createSlice({
|
|
|
1166
1167
|
reducers: {
|
|
1167
1168
|
doAppStart: (state, action) => {
|
|
1168
1169
|
const url = new URL(action.payload.roomUrl);
|
|
1169
|
-
return Object.assign(Object.assign(Object.assign({}, state), action.payload), { roomName: url.pathname, initialConfig: Object.assign({}, action.payload), isActive: true });
|
|
1170
|
+
return Object.assign(Object.assign(Object.assign({}, state), action.payload), { roomName: url.pathname, initialConfig: Object.assign({}, action.payload), isActive: true, isAssistant: Boolean(action.payload.assistantKey) });
|
|
1170
1171
|
},
|
|
1171
1172
|
doAppStop: (state) => {
|
|
1172
1173
|
return Object.assign(Object.assign({}, state), { isActive: false });
|
|
@@ -1176,6 +1177,7 @@ const appSlice = toolkit.createSlice({
|
|
|
1176
1177
|
const { doAppStop, doAppStart } = appSlice.actions;
|
|
1177
1178
|
const selectAppIsActive = (state) => state.app.isActive;
|
|
1178
1179
|
const selectAppIsDialIn = (state) => state.app.isDialIn;
|
|
1180
|
+
const selectAppIsAssistant = (state) => state.app.isAssistant;
|
|
1179
1181
|
const selectAppRoomName = (state) => state.app.roomName;
|
|
1180
1182
|
const selectAppRoomUrl = (state) => state.app.roomUrl;
|
|
1181
1183
|
const selectAppDisplayName = (state) => state.app.displayName;
|
|
@@ -1232,6 +1234,7 @@ const ROOM_ACTION_PERMISSIONS_BY_ROLE = {
|
|
|
1232
1234
|
};
|
|
1233
1235
|
const authorizationSliceInitialState = {
|
|
1234
1236
|
roomKey: null,
|
|
1237
|
+
assistantKey: null,
|
|
1235
1238
|
roleName: "none",
|
|
1236
1239
|
};
|
|
1237
1240
|
const authorizationSlice = toolkit.createSlice({
|
|
@@ -1244,7 +1247,7 @@ const authorizationSlice = toolkit.createSlice({
|
|
|
1244
1247
|
},
|
|
1245
1248
|
extraReducers: (builder) => {
|
|
1246
1249
|
builder.addCase(doAppStart, (state, action) => {
|
|
1247
|
-
return Object.assign(Object.assign({}, state), { roomKey: action.payload.roomKey });
|
|
1250
|
+
return Object.assign(Object.assign({}, state), { roomKey: action.payload.roomKey, assistantKey: action.payload.assistantKey });
|
|
1248
1251
|
});
|
|
1249
1252
|
builder.addCase(signalEvents.roomJoined, (state, action) => {
|
|
1250
1253
|
if ("error" in action.payload) {
|
|
@@ -1261,6 +1264,7 @@ const authorizationSlice = toolkit.createSlice({
|
|
|
1261
1264
|
});
|
|
1262
1265
|
const { setRoomKey } = authorizationSlice.actions;
|
|
1263
1266
|
const selectRoomKey = (state) => state.authorization.roomKey;
|
|
1267
|
+
const selectAssistantKey = (state) => state.authorization.assistantKey;
|
|
1264
1268
|
const selectAuthorizationRoleName = (state) => state.authorization.roleName;
|
|
1265
1269
|
const selectIsAuthorizedToLockRoom = toolkit.createSelector(selectAuthorizationRoleName, (localParticipantRole) => ROOM_ACTION_PERMISSIONS_BY_ROLE.canLockRoom.includes(localParticipantRole));
|
|
1266
1270
|
const selectIsAuthorizedToRequestAudioEnable = toolkit.createSelector(selectAuthorizationRoleName, (localParticipantRole) => ROOM_ACTION_PERMISSIONS_BY_ROLE.canRequestAudioEnable.includes(localParticipantRole));
|
|
@@ -1656,8 +1660,8 @@ const localMediaSlice = toolkit.createSlice({
|
|
|
1656
1660
|
let cameraEnabled = false;
|
|
1657
1661
|
let microphoneDeviceId = undefined;
|
|
1658
1662
|
let microphoneEnabled = false;
|
|
1659
|
-
const audioTrack = stream.getAudioTracks()[0];
|
|
1660
|
-
const videoTrack = stream.getVideoTracks()[0];
|
|
1663
|
+
const audioTrack = stream === null || stream === void 0 ? void 0 : stream.getAudioTracks()[0];
|
|
1664
|
+
const videoTrack = stream === null || stream === void 0 ? void 0 : stream.getVideoTracks()[0];
|
|
1661
1665
|
if (audioTrack) {
|
|
1662
1666
|
microphoneDeviceId = audioTrack.getSettings().deviceId;
|
|
1663
1667
|
microphoneEnabled = audioTrack.enabled;
|
|
@@ -1843,7 +1847,7 @@ const doStartLocalMedia = createAppAsyncThunk("localMedia/doStartLocalMedia", (p
|
|
|
1843
1847
|
return Promise.resolve({ stream: payload, onDeviceChange });
|
|
1844
1848
|
}
|
|
1845
1849
|
if (!(payload.audio || payload.video)) {
|
|
1846
|
-
return { stream:
|
|
1850
|
+
return { stream: undefined, onDeviceChange };
|
|
1847
1851
|
}
|
|
1848
1852
|
else {
|
|
1849
1853
|
dispatch(setLocalMediaOptions({ options: payload }));
|
|
@@ -3060,6 +3064,20 @@ startAppListening({
|
|
|
3060
3064
|
dispatch(rtcClientConnectionStatusChanged({ localParticipantId: localParticipant.id }));
|
|
3061
3065
|
},
|
|
3062
3066
|
});
|
|
3067
|
+
startAppListening({
|
|
3068
|
+
actionCreator: doStartLocalMedia.fulfilled,
|
|
3069
|
+
effect: ({ payload }, { getState }) => {
|
|
3070
|
+
const { rtcManager, rtcManagerInitialized } = selectRtcConnectionRaw(getState());
|
|
3071
|
+
if (!rtcManager || !rtcManagerInitialized)
|
|
3072
|
+
return;
|
|
3073
|
+
const isCameraEnabled = selectIsCameraEnabled(getState());
|
|
3074
|
+
const isMicrophoneEnabled = selectIsMicrophoneEnabled(getState());
|
|
3075
|
+
const { stream } = payload;
|
|
3076
|
+
if (stream) {
|
|
3077
|
+
rtcManager.addNewStream("0", payload.stream, !isMicrophoneEnabled, !isCameraEnabled);
|
|
3078
|
+
}
|
|
3079
|
+
},
|
|
3080
|
+
});
|
|
3063
3081
|
const selectShouldConnectRtc = toolkit.createSelector(selectRtcStatus, selectAppIsActive, selectRtcDispatcherCreated, selectRtcIsCreatingDispatcher, selectSignalConnectionSocket, (rtcStatus, appIsActive, dispatcherCreated, isCreatingDispatcher, signalSocket) => {
|
|
3064
3082
|
if (appIsActive && rtcStatus === "inactive" && !dispatcherCreated && !isCreatingDispatcher && signalSocket) {
|
|
3065
3083
|
return true;
|
|
@@ -3370,8 +3388,13 @@ startAppListening({
|
|
|
3370
3388
|
dispatch(doEnableAudio({ enabled: enabled || !isAudioEnabled }));
|
|
3371
3389
|
},
|
|
3372
3390
|
});
|
|
3373
|
-
createReactor([
|
|
3374
|
-
|
|
3391
|
+
createReactor([
|
|
3392
|
+
selectLocalParticipantDisplayName,
|
|
3393
|
+
selectLocalParticipantStickyReaction,
|
|
3394
|
+
selectRoomConnectionStatus,
|
|
3395
|
+
selectAppIsAssistant,
|
|
3396
|
+
], ({ dispatch }, diplayName, stickyReaction, roomConnectionStatus, isAssistant) => {
|
|
3397
|
+
if (roomConnectionStatus === "connected" && !isAssistant) {
|
|
3375
3398
|
dispatch(doSendClientMetadata());
|
|
3376
3399
|
}
|
|
3377
3400
|
});
|
|
@@ -3699,6 +3722,7 @@ const doConnectRoom = createAppThunk(() => (dispatch, getState) => {
|
|
|
3699
3722
|
const socket = selectSignalConnectionRaw(state).socket;
|
|
3700
3723
|
const roomName = selectAppRoomName(state);
|
|
3701
3724
|
const roomKey = selectRoomKey(state);
|
|
3725
|
+
const assistantKey = selectAssistantKey(state);
|
|
3702
3726
|
const displayName = selectAppDisplayName(state);
|
|
3703
3727
|
const userAgent = selectAppUserAgent(state);
|
|
3704
3728
|
const externalId = selectAppExternalId(state);
|
|
@@ -3712,6 +3736,7 @@ const doConnectRoom = createAppThunk(() => (dispatch, getState) => {
|
|
|
3712
3736
|
isVideoEnabled: isCameraEnabled,
|
|
3713
3737
|
}, deviceCapabilities: { canScreenshare: true }, displayName, isCoLocated: false, isDialIn, isDevicePermissionDenied: false, kickFromOtherRooms: false, organizationId,
|
|
3714
3738
|
roomKey,
|
|
3739
|
+
assistantKey,
|
|
3715
3740
|
roomName,
|
|
3716
3741
|
userAgent,
|
|
3717
3742
|
externalId }, (clientClaim && { clientClaim })));
|
|
@@ -4334,7 +4359,7 @@ class LocalMediaClient extends BaseClient {
|
|
|
4334
4359
|
}
|
|
4335
4360
|
startMedia() {
|
|
4336
4361
|
return __awaiter(this, arguments, void 0, function* (options = { audio: true, video: true }) {
|
|
4337
|
-
return this.store.dispatch(doStartLocalMedia(options));
|
|
4362
|
+
return yield this.store.dispatch(doStartLocalMedia(options));
|
|
4338
4363
|
});
|
|
4339
4364
|
}
|
|
4340
4365
|
toggleCamera(enabled) {
|
|
@@ -4591,19 +4616,41 @@ class RoomConnectionClient extends BaseClient {
|
|
|
4591
4616
|
this.options = options;
|
|
4592
4617
|
}
|
|
4593
4618
|
joinRoom() {
|
|
4594
|
-
|
|
4595
|
-
|
|
4596
|
-
|
|
4597
|
-
|
|
4598
|
-
|
|
4599
|
-
|
|
4600
|
-
|
|
4601
|
-
|
|
4602
|
-
|
|
4603
|
-
|
|
4604
|
-
|
|
4605
|
-
|
|
4606
|
-
|
|
4619
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4620
|
+
const { roomUrl } = this.options;
|
|
4621
|
+
if (!roomUrl) {
|
|
4622
|
+
throw new Error("Room URL is required to join a room.");
|
|
4623
|
+
}
|
|
4624
|
+
const roomConfig = {
|
|
4625
|
+
localMediaOptions: this.options.localMediaOptions || undefined,
|
|
4626
|
+
displayName: this.options.displayName || "Guest",
|
|
4627
|
+
roomKey: this.options.roomKey || null,
|
|
4628
|
+
externalId: this.options.externalId || null,
|
|
4629
|
+
sdkVersion: `core:${coreVersion}`,
|
|
4630
|
+
roomUrl,
|
|
4631
|
+
assistantKey: this.options.assistantKey || null,
|
|
4632
|
+
isNodeSdk: this.options.isNodeSdk || false,
|
|
4633
|
+
};
|
|
4634
|
+
this.store.dispatch(doAppStart(roomConfig));
|
|
4635
|
+
let resolve;
|
|
4636
|
+
let reject;
|
|
4637
|
+
const promise = new Promise((res, rej) => {
|
|
4638
|
+
resolve = res;
|
|
4639
|
+
reject = rej;
|
|
4640
|
+
});
|
|
4641
|
+
const unsubscribeRoomJoined = this.store.dispatch(toolkit.addListener({
|
|
4642
|
+
actionCreator: signalEvents.roomJoined,
|
|
4643
|
+
effect: ({ payload }) => {
|
|
4644
|
+
unsubscribeRoomJoined();
|
|
4645
|
+
if ("error" in payload) {
|
|
4646
|
+
reject === null || reject === void 0 ? void 0 : reject(payload.error);
|
|
4647
|
+
return;
|
|
4648
|
+
}
|
|
4649
|
+
resolve === null || resolve === void 0 ? void 0 : resolve(payload);
|
|
4650
|
+
},
|
|
4651
|
+
}));
|
|
4652
|
+
return promise;
|
|
4653
|
+
});
|
|
4607
4654
|
}
|
|
4608
4655
|
sendChatMessage(text) {
|
|
4609
4656
|
this.store.dispatch(doSendChatMessage({ text }));
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +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 } from '@whereby.com/media';
|
|
3
|
+
import { RoleName, ChatMessage as ChatMessage$2, BreakoutConfig, RtcManager, RtcManagerDispatcher, ServerSocket, RoomJoinedErrors, RoomJoinedSuccess } from '@whereby.com/media';
|
|
4
|
+
export { RoomJoinedSuccess } from '@whereby.com/media';
|
|
4
5
|
import * as redux_thunk from 'redux-thunk';
|
|
5
6
|
import * as _reduxjs_toolkit from '@reduxjs/toolkit';
|
|
6
7
|
import * as redux from 'redux';
|
|
@@ -587,6 +588,7 @@ interface CloudRecordingState$1 {
|
|
|
587
588
|
|
|
588
589
|
interface AuthorizationState {
|
|
589
590
|
roomKey: string | null;
|
|
591
|
+
assistantKey?: string | null;
|
|
590
592
|
roleName: RoleName;
|
|
591
593
|
}
|
|
592
594
|
|
|
@@ -670,6 +672,7 @@ interface AppConfig {
|
|
|
670
672
|
displayName: string;
|
|
671
673
|
localMediaOptions?: LocalMediaOptions$1;
|
|
672
674
|
roomKey: string | null;
|
|
675
|
+
assistantKey?: string | null;
|
|
673
676
|
roomUrl: string;
|
|
674
677
|
userAgent?: string;
|
|
675
678
|
externalId: string | null;
|
|
@@ -678,6 +681,7 @@ interface AppState {
|
|
|
678
681
|
isNodeSdk: boolean;
|
|
679
682
|
isActive: boolean;
|
|
680
683
|
isDialIn: boolean;
|
|
684
|
+
isAssistant: boolean;
|
|
681
685
|
ignoreBreakoutGroups: boolean;
|
|
682
686
|
roomUrl: string | null;
|
|
683
687
|
roomName: string | null;
|
|
@@ -955,6 +959,9 @@ declare class LocalMediaClient extends BaseClient<LocalMediaState, LocalMediaEve
|
|
|
955
959
|
startMedia(options?: LocalMediaOptions$1 | MediaStream): Promise<_reduxjs_toolkit.PayloadAction<{
|
|
956
960
|
stream: MediaStream;
|
|
957
961
|
onDeviceChange: DebouncedFunction;
|
|
962
|
+
} | {
|
|
963
|
+
stream: undefined;
|
|
964
|
+
onDeviceChange: DebouncedFunction;
|
|
958
965
|
}, string, {
|
|
959
966
|
arg: LocalMediaOptions$1 | MediaStream;
|
|
960
967
|
requestId: string;
|
|
@@ -988,8 +995,10 @@ interface WherebyClientOptions {
|
|
|
988
995
|
localMediaOptions?: LocalMediaOptions;
|
|
989
996
|
displayName?: string;
|
|
990
997
|
roomUrl?: string;
|
|
998
|
+
assistantKey?: string | null;
|
|
991
999
|
roomKey?: string | null;
|
|
992
1000
|
externalId?: string | null;
|
|
1001
|
+
isNodeSdk?: boolean;
|
|
993
1002
|
}
|
|
994
1003
|
type RemoteParticipantState = Omit<RemoteParticipant, "newJoiner" | "streams">;
|
|
995
1004
|
interface LocalParticipantState extends LocalParticipant {
|
|
@@ -1124,7 +1133,7 @@ declare class RoomConnectionClient extends BaseClient<RoomConnectionState, RoomC
|
|
|
1124
1133
|
getState(): RoomConnectionState;
|
|
1125
1134
|
getNotificationsEventEmitter(): NotificationsEventEmitter;
|
|
1126
1135
|
initialize(options: WherebyClientOptions): void;
|
|
1127
|
-
joinRoom():
|
|
1136
|
+
joinRoom(): Promise<RoomJoinedSuccess>;
|
|
1128
1137
|
sendChatMessage(text: string): void;
|
|
1129
1138
|
knock(): void;
|
|
1130
1139
|
leaveRoom(): void;
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +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 } from '@whereby.com/media';
|
|
3
|
+
import { RoleName, ChatMessage as ChatMessage$2, BreakoutConfig, RtcManager, RtcManagerDispatcher, ServerSocket, RoomJoinedErrors, RoomJoinedSuccess } from '@whereby.com/media';
|
|
4
|
+
export { RoomJoinedSuccess } from '@whereby.com/media';
|
|
4
5
|
import * as redux_thunk from 'redux-thunk';
|
|
5
6
|
import * as _reduxjs_toolkit from '@reduxjs/toolkit';
|
|
6
7
|
import * as redux from 'redux';
|
|
@@ -587,6 +588,7 @@ interface CloudRecordingState$1 {
|
|
|
587
588
|
|
|
588
589
|
interface AuthorizationState {
|
|
589
590
|
roomKey: string | null;
|
|
591
|
+
assistantKey?: string | null;
|
|
590
592
|
roleName: RoleName;
|
|
591
593
|
}
|
|
592
594
|
|
|
@@ -670,6 +672,7 @@ interface AppConfig {
|
|
|
670
672
|
displayName: string;
|
|
671
673
|
localMediaOptions?: LocalMediaOptions$1;
|
|
672
674
|
roomKey: string | null;
|
|
675
|
+
assistantKey?: string | null;
|
|
673
676
|
roomUrl: string;
|
|
674
677
|
userAgent?: string;
|
|
675
678
|
externalId: string | null;
|
|
@@ -678,6 +681,7 @@ interface AppState {
|
|
|
678
681
|
isNodeSdk: boolean;
|
|
679
682
|
isActive: boolean;
|
|
680
683
|
isDialIn: boolean;
|
|
684
|
+
isAssistant: boolean;
|
|
681
685
|
ignoreBreakoutGroups: boolean;
|
|
682
686
|
roomUrl: string | null;
|
|
683
687
|
roomName: string | null;
|
|
@@ -955,6 +959,9 @@ declare class LocalMediaClient extends BaseClient<LocalMediaState, LocalMediaEve
|
|
|
955
959
|
startMedia(options?: LocalMediaOptions$1 | MediaStream): Promise<_reduxjs_toolkit.PayloadAction<{
|
|
956
960
|
stream: MediaStream;
|
|
957
961
|
onDeviceChange: DebouncedFunction;
|
|
962
|
+
} | {
|
|
963
|
+
stream: undefined;
|
|
964
|
+
onDeviceChange: DebouncedFunction;
|
|
958
965
|
}, string, {
|
|
959
966
|
arg: LocalMediaOptions$1 | MediaStream;
|
|
960
967
|
requestId: string;
|
|
@@ -988,8 +995,10 @@ interface WherebyClientOptions {
|
|
|
988
995
|
localMediaOptions?: LocalMediaOptions;
|
|
989
996
|
displayName?: string;
|
|
990
997
|
roomUrl?: string;
|
|
998
|
+
assistantKey?: string | null;
|
|
991
999
|
roomKey?: string | null;
|
|
992
1000
|
externalId?: string | null;
|
|
1001
|
+
isNodeSdk?: boolean;
|
|
993
1002
|
}
|
|
994
1003
|
type RemoteParticipantState = Omit<RemoteParticipant, "newJoiner" | "streams">;
|
|
995
1004
|
interface LocalParticipantState extends LocalParticipant {
|
|
@@ -1124,7 +1133,7 @@ declare class RoomConnectionClient extends BaseClient<RoomConnectionState, RoomC
|
|
|
1124
1133
|
getState(): RoomConnectionState;
|
|
1125
1134
|
getNotificationsEventEmitter(): NotificationsEventEmitter;
|
|
1126
1135
|
initialize(options: WherebyClientOptions): void;
|
|
1127
|
-
joinRoom():
|
|
1136
|
+
joinRoom(): Promise<RoomJoinedSuccess>;
|
|
1128
1137
|
sendChatMessage(text: string): void;
|
|
1129
1138
|
knock(): void;
|
|
1130
1139
|
leaveRoom(): void;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +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 } from '@whereby.com/media';
|
|
3
|
+
import { RoleName, ChatMessage as ChatMessage$2, BreakoutConfig, RtcManager, RtcManagerDispatcher, ServerSocket, RoomJoinedErrors, RoomJoinedSuccess } from '@whereby.com/media';
|
|
4
|
+
export { RoomJoinedSuccess } from '@whereby.com/media';
|
|
4
5
|
import * as redux_thunk from 'redux-thunk';
|
|
5
6
|
import * as _reduxjs_toolkit from '@reduxjs/toolkit';
|
|
6
7
|
import * as redux from 'redux';
|
|
@@ -587,6 +588,7 @@ interface CloudRecordingState$1 {
|
|
|
587
588
|
|
|
588
589
|
interface AuthorizationState {
|
|
589
590
|
roomKey: string | null;
|
|
591
|
+
assistantKey?: string | null;
|
|
590
592
|
roleName: RoleName;
|
|
591
593
|
}
|
|
592
594
|
|
|
@@ -670,6 +672,7 @@ interface AppConfig {
|
|
|
670
672
|
displayName: string;
|
|
671
673
|
localMediaOptions?: LocalMediaOptions$1;
|
|
672
674
|
roomKey: string | null;
|
|
675
|
+
assistantKey?: string | null;
|
|
673
676
|
roomUrl: string;
|
|
674
677
|
userAgent?: string;
|
|
675
678
|
externalId: string | null;
|
|
@@ -678,6 +681,7 @@ interface AppState {
|
|
|
678
681
|
isNodeSdk: boolean;
|
|
679
682
|
isActive: boolean;
|
|
680
683
|
isDialIn: boolean;
|
|
684
|
+
isAssistant: boolean;
|
|
681
685
|
ignoreBreakoutGroups: boolean;
|
|
682
686
|
roomUrl: string | null;
|
|
683
687
|
roomName: string | null;
|
|
@@ -955,6 +959,9 @@ declare class LocalMediaClient extends BaseClient<LocalMediaState, LocalMediaEve
|
|
|
955
959
|
startMedia(options?: LocalMediaOptions$1 | MediaStream): Promise<_reduxjs_toolkit.PayloadAction<{
|
|
956
960
|
stream: MediaStream;
|
|
957
961
|
onDeviceChange: DebouncedFunction;
|
|
962
|
+
} | {
|
|
963
|
+
stream: undefined;
|
|
964
|
+
onDeviceChange: DebouncedFunction;
|
|
958
965
|
}, string, {
|
|
959
966
|
arg: LocalMediaOptions$1 | MediaStream;
|
|
960
967
|
requestId: string;
|
|
@@ -988,8 +995,10 @@ interface WherebyClientOptions {
|
|
|
988
995
|
localMediaOptions?: LocalMediaOptions;
|
|
989
996
|
displayName?: string;
|
|
990
997
|
roomUrl?: string;
|
|
998
|
+
assistantKey?: string | null;
|
|
991
999
|
roomKey?: string | null;
|
|
992
1000
|
externalId?: string | null;
|
|
1001
|
+
isNodeSdk?: boolean;
|
|
993
1002
|
}
|
|
994
1003
|
type RemoteParticipantState = Omit<RemoteParticipant, "newJoiner" | "streams">;
|
|
995
1004
|
interface LocalParticipantState extends LocalParticipant {
|
|
@@ -1124,7 +1133,7 @@ declare class RoomConnectionClient extends BaseClient<RoomConnectionState, RoomC
|
|
|
1124
1133
|
getState(): RoomConnectionState;
|
|
1125
1134
|
getNotificationsEventEmitter(): NotificationsEventEmitter;
|
|
1126
1135
|
initialize(options: WherebyClientOptions): void;
|
|
1127
|
-
joinRoom():
|
|
1136
|
+
joinRoom(): Promise<RoomJoinedSuccess>;
|
|
1128
1137
|
sendChatMessage(text: string): void;
|
|
1129
1138
|
knock(): void;
|
|
1130
1139
|
leaveRoom(): void;
|
package/dist/index.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import nodeBtoa from 'btoa';
|
|
|
2
2
|
import { assert, fromLocation, ServerSocket, getDeviceData, getStream, getUpdatedDevices, 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 } from '@reduxjs/toolkit';
|
|
5
|
+
import { createListenerMiddleware, createSlice, createAction, createSelector, createAsyncThunk, isAnyOf, combineReducers, configureStore, addListener } from '@reduxjs/toolkit';
|
|
6
6
|
|
|
7
7
|
class Response {
|
|
8
8
|
constructor(initialValues = {}) {
|
|
@@ -1145,12 +1145,13 @@ const createReactor = (selectors, callback) => {
|
|
|
1145
1145
|
});
|
|
1146
1146
|
};
|
|
1147
1147
|
|
|
1148
|
-
const coreVersion = "1.
|
|
1148
|
+
const coreVersion = "1.2.0";
|
|
1149
1149
|
|
|
1150
1150
|
const initialState = {
|
|
1151
1151
|
isNodeSdk: false,
|
|
1152
1152
|
isActive: false,
|
|
1153
1153
|
isDialIn: false,
|
|
1154
|
+
isAssistant: false,
|
|
1154
1155
|
ignoreBreakoutGroups: false,
|
|
1155
1156
|
roomName: null,
|
|
1156
1157
|
roomUrl: null,
|
|
@@ -1164,7 +1165,7 @@ const appSlice = createSlice({
|
|
|
1164
1165
|
reducers: {
|
|
1165
1166
|
doAppStart: (state, action) => {
|
|
1166
1167
|
const url = new URL(action.payload.roomUrl);
|
|
1167
|
-
return Object.assign(Object.assign(Object.assign({}, state), action.payload), { roomName: url.pathname, initialConfig: Object.assign({}, action.payload), isActive: true });
|
|
1168
|
+
return Object.assign(Object.assign(Object.assign({}, state), action.payload), { roomName: url.pathname, initialConfig: Object.assign({}, action.payload), isActive: true, isAssistant: Boolean(action.payload.assistantKey) });
|
|
1168
1169
|
},
|
|
1169
1170
|
doAppStop: (state) => {
|
|
1170
1171
|
return Object.assign(Object.assign({}, state), { isActive: false });
|
|
@@ -1174,6 +1175,7 @@ const appSlice = createSlice({
|
|
|
1174
1175
|
const { doAppStop, doAppStart } = appSlice.actions;
|
|
1175
1176
|
const selectAppIsActive = (state) => state.app.isActive;
|
|
1176
1177
|
const selectAppIsDialIn = (state) => state.app.isDialIn;
|
|
1178
|
+
const selectAppIsAssistant = (state) => state.app.isAssistant;
|
|
1177
1179
|
const selectAppRoomName = (state) => state.app.roomName;
|
|
1178
1180
|
const selectAppRoomUrl = (state) => state.app.roomUrl;
|
|
1179
1181
|
const selectAppDisplayName = (state) => state.app.displayName;
|
|
@@ -1230,6 +1232,7 @@ const ROOM_ACTION_PERMISSIONS_BY_ROLE = {
|
|
|
1230
1232
|
};
|
|
1231
1233
|
const authorizationSliceInitialState = {
|
|
1232
1234
|
roomKey: null,
|
|
1235
|
+
assistantKey: null,
|
|
1233
1236
|
roleName: "none",
|
|
1234
1237
|
};
|
|
1235
1238
|
const authorizationSlice = createSlice({
|
|
@@ -1242,7 +1245,7 @@ const authorizationSlice = createSlice({
|
|
|
1242
1245
|
},
|
|
1243
1246
|
extraReducers: (builder) => {
|
|
1244
1247
|
builder.addCase(doAppStart, (state, action) => {
|
|
1245
|
-
return Object.assign(Object.assign({}, state), { roomKey: action.payload.roomKey });
|
|
1248
|
+
return Object.assign(Object.assign({}, state), { roomKey: action.payload.roomKey, assistantKey: action.payload.assistantKey });
|
|
1246
1249
|
});
|
|
1247
1250
|
builder.addCase(signalEvents.roomJoined, (state, action) => {
|
|
1248
1251
|
if ("error" in action.payload) {
|
|
@@ -1259,6 +1262,7 @@ const authorizationSlice = createSlice({
|
|
|
1259
1262
|
});
|
|
1260
1263
|
const { setRoomKey } = authorizationSlice.actions;
|
|
1261
1264
|
const selectRoomKey = (state) => state.authorization.roomKey;
|
|
1265
|
+
const selectAssistantKey = (state) => state.authorization.assistantKey;
|
|
1262
1266
|
const selectAuthorizationRoleName = (state) => state.authorization.roleName;
|
|
1263
1267
|
const selectIsAuthorizedToLockRoom = createSelector(selectAuthorizationRoleName, (localParticipantRole) => ROOM_ACTION_PERMISSIONS_BY_ROLE.canLockRoom.includes(localParticipantRole));
|
|
1264
1268
|
const selectIsAuthorizedToRequestAudioEnable = createSelector(selectAuthorizationRoleName, (localParticipantRole) => ROOM_ACTION_PERMISSIONS_BY_ROLE.canRequestAudioEnable.includes(localParticipantRole));
|
|
@@ -1654,8 +1658,8 @@ const localMediaSlice = createSlice({
|
|
|
1654
1658
|
let cameraEnabled = false;
|
|
1655
1659
|
let microphoneDeviceId = undefined;
|
|
1656
1660
|
let microphoneEnabled = false;
|
|
1657
|
-
const audioTrack = stream.getAudioTracks()[0];
|
|
1658
|
-
const videoTrack = stream.getVideoTracks()[0];
|
|
1661
|
+
const audioTrack = stream === null || stream === void 0 ? void 0 : stream.getAudioTracks()[0];
|
|
1662
|
+
const videoTrack = stream === null || stream === void 0 ? void 0 : stream.getVideoTracks()[0];
|
|
1659
1663
|
if (audioTrack) {
|
|
1660
1664
|
microphoneDeviceId = audioTrack.getSettings().deviceId;
|
|
1661
1665
|
microphoneEnabled = audioTrack.enabled;
|
|
@@ -1841,7 +1845,7 @@ const doStartLocalMedia = createAppAsyncThunk("localMedia/doStartLocalMedia", (p
|
|
|
1841
1845
|
return Promise.resolve({ stream: payload, onDeviceChange });
|
|
1842
1846
|
}
|
|
1843
1847
|
if (!(payload.audio || payload.video)) {
|
|
1844
|
-
return { stream:
|
|
1848
|
+
return { stream: undefined, onDeviceChange };
|
|
1845
1849
|
}
|
|
1846
1850
|
else {
|
|
1847
1851
|
dispatch(setLocalMediaOptions({ options: payload }));
|
|
@@ -3058,6 +3062,20 @@ startAppListening({
|
|
|
3058
3062
|
dispatch(rtcClientConnectionStatusChanged({ localParticipantId: localParticipant.id }));
|
|
3059
3063
|
},
|
|
3060
3064
|
});
|
|
3065
|
+
startAppListening({
|
|
3066
|
+
actionCreator: doStartLocalMedia.fulfilled,
|
|
3067
|
+
effect: ({ payload }, { getState }) => {
|
|
3068
|
+
const { rtcManager, rtcManagerInitialized } = selectRtcConnectionRaw(getState());
|
|
3069
|
+
if (!rtcManager || !rtcManagerInitialized)
|
|
3070
|
+
return;
|
|
3071
|
+
const isCameraEnabled = selectIsCameraEnabled(getState());
|
|
3072
|
+
const isMicrophoneEnabled = selectIsMicrophoneEnabled(getState());
|
|
3073
|
+
const { stream } = payload;
|
|
3074
|
+
if (stream) {
|
|
3075
|
+
rtcManager.addNewStream("0", payload.stream, !isMicrophoneEnabled, !isCameraEnabled);
|
|
3076
|
+
}
|
|
3077
|
+
},
|
|
3078
|
+
});
|
|
3061
3079
|
const selectShouldConnectRtc = createSelector(selectRtcStatus, selectAppIsActive, selectRtcDispatcherCreated, selectRtcIsCreatingDispatcher, selectSignalConnectionSocket, (rtcStatus, appIsActive, dispatcherCreated, isCreatingDispatcher, signalSocket) => {
|
|
3062
3080
|
if (appIsActive && rtcStatus === "inactive" && !dispatcherCreated && !isCreatingDispatcher && signalSocket) {
|
|
3063
3081
|
return true;
|
|
@@ -3368,8 +3386,13 @@ startAppListening({
|
|
|
3368
3386
|
dispatch(doEnableAudio({ enabled: enabled || !isAudioEnabled }));
|
|
3369
3387
|
},
|
|
3370
3388
|
});
|
|
3371
|
-
createReactor([
|
|
3372
|
-
|
|
3389
|
+
createReactor([
|
|
3390
|
+
selectLocalParticipantDisplayName,
|
|
3391
|
+
selectLocalParticipantStickyReaction,
|
|
3392
|
+
selectRoomConnectionStatus,
|
|
3393
|
+
selectAppIsAssistant,
|
|
3394
|
+
], ({ dispatch }, diplayName, stickyReaction, roomConnectionStatus, isAssistant) => {
|
|
3395
|
+
if (roomConnectionStatus === "connected" && !isAssistant) {
|
|
3373
3396
|
dispatch(doSendClientMetadata());
|
|
3374
3397
|
}
|
|
3375
3398
|
});
|
|
@@ -3697,6 +3720,7 @@ const doConnectRoom = createAppThunk(() => (dispatch, getState) => {
|
|
|
3697
3720
|
const socket = selectSignalConnectionRaw(state).socket;
|
|
3698
3721
|
const roomName = selectAppRoomName(state);
|
|
3699
3722
|
const roomKey = selectRoomKey(state);
|
|
3723
|
+
const assistantKey = selectAssistantKey(state);
|
|
3700
3724
|
const displayName = selectAppDisplayName(state);
|
|
3701
3725
|
const userAgent = selectAppUserAgent(state);
|
|
3702
3726
|
const externalId = selectAppExternalId(state);
|
|
@@ -3710,6 +3734,7 @@ const doConnectRoom = createAppThunk(() => (dispatch, getState) => {
|
|
|
3710
3734
|
isVideoEnabled: isCameraEnabled,
|
|
3711
3735
|
}, deviceCapabilities: { canScreenshare: true }, displayName, isCoLocated: false, isDialIn, isDevicePermissionDenied: false, kickFromOtherRooms: false, organizationId,
|
|
3712
3736
|
roomKey,
|
|
3737
|
+
assistantKey,
|
|
3713
3738
|
roomName,
|
|
3714
3739
|
userAgent,
|
|
3715
3740
|
externalId }, (clientClaim && { clientClaim })));
|
|
@@ -4332,7 +4357,7 @@ class LocalMediaClient extends BaseClient {
|
|
|
4332
4357
|
}
|
|
4333
4358
|
startMedia() {
|
|
4334
4359
|
return __awaiter(this, arguments, void 0, function* (options = { audio: true, video: true }) {
|
|
4335
|
-
return this.store.dispatch(doStartLocalMedia(options));
|
|
4360
|
+
return yield this.store.dispatch(doStartLocalMedia(options));
|
|
4336
4361
|
});
|
|
4337
4362
|
}
|
|
4338
4363
|
toggleCamera(enabled) {
|
|
@@ -4589,19 +4614,41 @@ class RoomConnectionClient extends BaseClient {
|
|
|
4589
4614
|
this.options = options;
|
|
4590
4615
|
}
|
|
4591
4616
|
joinRoom() {
|
|
4592
|
-
|
|
4593
|
-
|
|
4594
|
-
|
|
4595
|
-
|
|
4596
|
-
|
|
4597
|
-
|
|
4598
|
-
|
|
4599
|
-
|
|
4600
|
-
|
|
4601
|
-
|
|
4602
|
-
|
|
4603
|
-
|
|
4604
|
-
|
|
4617
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4618
|
+
const { roomUrl } = this.options;
|
|
4619
|
+
if (!roomUrl) {
|
|
4620
|
+
throw new Error("Room URL is required to join a room.");
|
|
4621
|
+
}
|
|
4622
|
+
const roomConfig = {
|
|
4623
|
+
localMediaOptions: this.options.localMediaOptions || undefined,
|
|
4624
|
+
displayName: this.options.displayName || "Guest",
|
|
4625
|
+
roomKey: this.options.roomKey || null,
|
|
4626
|
+
externalId: this.options.externalId || null,
|
|
4627
|
+
sdkVersion: `core:${coreVersion}`,
|
|
4628
|
+
roomUrl,
|
|
4629
|
+
assistantKey: this.options.assistantKey || null,
|
|
4630
|
+
isNodeSdk: this.options.isNodeSdk || false,
|
|
4631
|
+
};
|
|
4632
|
+
this.store.dispatch(doAppStart(roomConfig));
|
|
4633
|
+
let resolve;
|
|
4634
|
+
let reject;
|
|
4635
|
+
const promise = new Promise((res, rej) => {
|
|
4636
|
+
resolve = res;
|
|
4637
|
+
reject = rej;
|
|
4638
|
+
});
|
|
4639
|
+
const unsubscribeRoomJoined = this.store.dispatch(addListener({
|
|
4640
|
+
actionCreator: signalEvents.roomJoined,
|
|
4641
|
+
effect: ({ payload }) => {
|
|
4642
|
+
unsubscribeRoomJoined();
|
|
4643
|
+
if ("error" in payload) {
|
|
4644
|
+
reject === null || reject === void 0 ? void 0 : reject(payload.error);
|
|
4645
|
+
return;
|
|
4646
|
+
}
|
|
4647
|
+
resolve === null || resolve === void 0 ? void 0 : resolve(payload);
|
|
4648
|
+
},
|
|
4649
|
+
}));
|
|
4650
|
+
return promise;
|
|
4651
|
+
});
|
|
4605
4652
|
}
|
|
4606
4653
|
sendChatMessage(text) {
|
|
4607
4654
|
this.store.dispatch(doSendChatMessage({ text }));
|