@whereby.com/core 0.9.2 → 0.11.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 +203 -111
- package/dist/index.d.cts +189 -32
- package/dist/index.d.mts +189 -32
- package/dist/index.d.ts +189 -32
- package/dist/index.mjs +195 -111
- package/package.json +1 -10
package/dist/index.mjs
CHANGED
|
@@ -11,6 +11,16 @@ function createAppAsyncThunk(typePrefix, payloadCreator) {
|
|
|
11
11
|
function createAppThunk(thunk) {
|
|
12
12
|
return thunk;
|
|
13
13
|
}
|
|
14
|
+
function createAppAuthorizedThunk(authorizationSelector, thunk) {
|
|
15
|
+
return createAppThunk((payload) => (dispatch, getState, extra) => {
|
|
16
|
+
const isAuthorized = authorizationSelector(getState());
|
|
17
|
+
if (!isAuthorized) {
|
|
18
|
+
console.warn("Not authorized to perform this action");
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
return thunk(payload)(dispatch, getState, extra);
|
|
22
|
+
});
|
|
23
|
+
}
|
|
14
24
|
|
|
15
25
|
const listenerMiddleware = createListenerMiddleware();
|
|
16
26
|
const startAppListening = listenerMiddleware.startListening;
|
|
@@ -33,13 +43,12 @@ const createReactor = (selectors, callback) => {
|
|
|
33
43
|
});
|
|
34
44
|
};
|
|
35
45
|
|
|
36
|
-
const coreVersion = "0.
|
|
46
|
+
const coreVersion = "0.11.0";
|
|
37
47
|
|
|
38
|
-
const initialState$
|
|
48
|
+
const initialState$d = {
|
|
39
49
|
isNodeSdk: false,
|
|
40
50
|
wantsToJoin: false,
|
|
41
51
|
roomName: null,
|
|
42
|
-
roomKey: null,
|
|
43
52
|
roomUrl: null,
|
|
44
53
|
displayName: null,
|
|
45
54
|
userAgent: `core:${coreVersion}`,
|
|
@@ -47,7 +56,7 @@ const initialState$c = {
|
|
|
47
56
|
};
|
|
48
57
|
const appSlice = createSlice({
|
|
49
58
|
name: "app",
|
|
50
|
-
initialState: initialState$
|
|
59
|
+
initialState: initialState$d,
|
|
51
60
|
reducers: {
|
|
52
61
|
doAppJoin: (state, action) => {
|
|
53
62
|
const url = new URL(action.payload.roomUrl);
|
|
@@ -56,17 +65,13 @@ const appSlice = createSlice({
|
|
|
56
65
|
appLeft: (state) => {
|
|
57
66
|
return Object.assign(Object.assign({}, state), { wantsToJoin: false });
|
|
58
67
|
},
|
|
59
|
-
setRoomKey: (state, action) => {
|
|
60
|
-
return Object.assign(Object.assign({}, state), { roomKey: action.payload });
|
|
61
|
-
},
|
|
62
68
|
},
|
|
63
69
|
});
|
|
64
|
-
const { doAppJoin, appLeft
|
|
70
|
+
const { doAppJoin, appLeft } = appSlice.actions;
|
|
65
71
|
const selectAppRaw = (state) => state.app;
|
|
66
72
|
const selectAppWantsToJoin = (state) => state.app.wantsToJoin;
|
|
67
73
|
const selectAppRoomName = (state) => state.app.roomName;
|
|
68
74
|
const selectAppRoomUrl = (state) => state.app.roomUrl;
|
|
69
|
-
const selectAppRoomKey = (state) => state.app.roomKey;
|
|
70
75
|
const selectAppDisplayName = (state) => state.app.displayName;
|
|
71
76
|
const selectAppUserAgent = (state) => state.app.userAgent;
|
|
72
77
|
const selectAppExternalId = (state) => state.app.externalId;
|
|
@@ -77,6 +82,7 @@ function createSignalEventAction(name) {
|
|
|
77
82
|
}
|
|
78
83
|
const signalEvents = {
|
|
79
84
|
audioEnabled: createSignalEventAction("audioEnabled"),
|
|
85
|
+
audioEnableRequested: createSignalEventAction("audioEnableRequested"),
|
|
80
86
|
chatMessage: createSignalEventAction("chatMessage"),
|
|
81
87
|
clientLeft: createSignalEventAction("clientLeft"),
|
|
82
88
|
clientKicked: createSignalEventAction("clientKicked"),
|
|
@@ -89,6 +95,7 @@ const signalEvents = {
|
|
|
89
95
|
newClient: createSignalEventAction("newClient"),
|
|
90
96
|
roomJoined: createSignalEventAction("roomJoined"),
|
|
91
97
|
roomKnocked: createSignalEventAction("roomKnocked"),
|
|
98
|
+
roomLocked: createSignalEventAction("roomLocked"),
|
|
92
99
|
roomSessionEnded: createSignalEventAction("roomSessionEnded"),
|
|
93
100
|
screenshareStarted: createSignalEventAction("screenshareStarted"),
|
|
94
101
|
screenshareStopped: createSignalEventAction("screenshareStopped"),
|
|
@@ -140,13 +147,13 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
140
147
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
141
148
|
};
|
|
142
149
|
|
|
143
|
-
const initialState$
|
|
150
|
+
const initialState$c = {
|
|
144
151
|
isFetching: false,
|
|
145
152
|
data: null,
|
|
146
153
|
};
|
|
147
154
|
const deviceCredentialsSlice = createSlice({
|
|
148
155
|
name: "deviceCredentials",
|
|
149
|
-
initialState: initialState$
|
|
156
|
+
initialState: initialState$c,
|
|
150
157
|
reducers: {},
|
|
151
158
|
extraReducers: (builder) => {
|
|
152
159
|
builder.addCase(doGetDeviceCredentials.pending, (state) => {
|
|
@@ -191,10 +198,12 @@ function forwardSocketEvents(socket, dispatch) {
|
|
|
191
198
|
socket.on("client_kicked", (payload) => dispatch(signalEvents.clientKicked(payload)));
|
|
192
199
|
socket.on("audio_enabled", (payload) => dispatch(signalEvents.audioEnabled(payload)));
|
|
193
200
|
socket.on("video_enabled", (payload) => dispatch(signalEvents.videoEnabled(payload)));
|
|
201
|
+
socket.on("audio_enable_requested", (payload) => dispatch(signalEvents.audioEnableRequested(payload)));
|
|
194
202
|
socket.on("client_metadata_received", (payload) => dispatch(signalEvents.clientMetadataReceived(payload)));
|
|
195
203
|
socket.on("chat_message", (payload) => dispatch(signalEvents.chatMessage(payload)));
|
|
196
204
|
socket.on("disconnect", () => dispatch(signalEvents.disconnect()));
|
|
197
205
|
socket.on("room_knocked", (payload) => dispatch(signalEvents.roomKnocked(payload)));
|
|
206
|
+
socket.on("room_locked", (payload) => dispatch(signalEvents.roomLocked(payload)));
|
|
198
207
|
socket.on("room_session_ended", (payload) => dispatch(signalEvents.roomSessionEnded(payload)));
|
|
199
208
|
socket.on("knocker_left", (payload) => dispatch(signalEvents.knockerLeft(payload)));
|
|
200
209
|
socket.on("knock_handled", (payload) => dispatch(signalEvents.knockHandled(payload)));
|
|
@@ -213,7 +222,7 @@ function createSocket() {
|
|
|
213
222
|
};
|
|
214
223
|
return new ServerSocket(socketHost, socketOverrides);
|
|
215
224
|
}
|
|
216
|
-
const initialState$
|
|
225
|
+
const initialState$b = {
|
|
217
226
|
deviceIdentified: false,
|
|
218
227
|
isIdentifyingDevice: false,
|
|
219
228
|
status: "",
|
|
@@ -221,7 +230,7 @@ const initialState$a = {
|
|
|
221
230
|
};
|
|
222
231
|
const signalConnectionSlice = createSlice({
|
|
223
232
|
name: "signalConnection",
|
|
224
|
-
initialState: initialState$
|
|
233
|
+
initialState: initialState$b,
|
|
225
234
|
reducers: {
|
|
226
235
|
socketConnecting: (state) => {
|
|
227
236
|
return Object.assign(Object.assign({}, state), { status: "connecting" });
|
|
@@ -320,92 +329,6 @@ createReactor([selectShouldIdentifyDevice, selectDeviceCredentialsRaw], ({ dispa
|
|
|
320
329
|
}
|
|
321
330
|
});
|
|
322
331
|
|
|
323
|
-
const initialState$9 = {
|
|
324
|
-
chatMessages: [],
|
|
325
|
-
};
|
|
326
|
-
const chatSlice = createSlice({
|
|
327
|
-
name: "chat",
|
|
328
|
-
initialState: initialState$9,
|
|
329
|
-
reducers: {},
|
|
330
|
-
extraReducers(builder) {
|
|
331
|
-
builder.addCase(signalEvents.chatMessage, (state, action) => {
|
|
332
|
-
const message = {
|
|
333
|
-
senderId: action.payload.senderId,
|
|
334
|
-
timestamp: action.payload.timestamp,
|
|
335
|
-
text: action.payload.text,
|
|
336
|
-
};
|
|
337
|
-
return Object.assign(Object.assign({}, state), { chatMessages: [...state.chatMessages, message] });
|
|
338
|
-
});
|
|
339
|
-
},
|
|
340
|
-
});
|
|
341
|
-
const doSendChatMessage = createAppThunk((payload) => (_, getState) => {
|
|
342
|
-
const state = getState();
|
|
343
|
-
const socket = selectSignalConnectionRaw(state).socket;
|
|
344
|
-
socket === null || socket === void 0 ? void 0 : socket.emit("chat_message", { text: payload.text });
|
|
345
|
-
});
|
|
346
|
-
const selectChatRaw = (state) => state.chat;
|
|
347
|
-
const selectChatMessages = (state) => state.chat.chatMessages;
|
|
348
|
-
|
|
349
|
-
const initialCloudRecordingState = {
|
|
350
|
-
isRecording: false,
|
|
351
|
-
error: null,
|
|
352
|
-
startedAt: undefined,
|
|
353
|
-
};
|
|
354
|
-
const cloudRecordingSlice = createSlice({
|
|
355
|
-
name: "cloudRecording",
|
|
356
|
-
initialState: initialCloudRecordingState,
|
|
357
|
-
reducers: {
|
|
358
|
-
recordingRequestStarted: (state) => {
|
|
359
|
-
return Object.assign(Object.assign({}, state), { status: "requested" });
|
|
360
|
-
},
|
|
361
|
-
},
|
|
362
|
-
extraReducers: (builder) => {
|
|
363
|
-
builder.addCase(signalEvents.cloudRecordingStopped, (state) => {
|
|
364
|
-
return Object.assign(Object.assign({}, state), { isRecording: false, status: undefined });
|
|
365
|
-
});
|
|
366
|
-
builder.addCase(signalEvents.cloudRecordingStarted, (state, action) => {
|
|
367
|
-
const { payload } = action;
|
|
368
|
-
if (!payload.error) {
|
|
369
|
-
return state;
|
|
370
|
-
}
|
|
371
|
-
return Object.assign(Object.assign({}, state), { isRecording: false, status: "error", error: payload.error });
|
|
372
|
-
});
|
|
373
|
-
builder.addCase(signalEvents.newClient, (state, { payload }) => {
|
|
374
|
-
var _a;
|
|
375
|
-
const { client } = payload;
|
|
376
|
-
if (((_a = client.role) === null || _a === void 0 ? void 0 : _a.roleName) === "recorder") {
|
|
377
|
-
return Object.assign(Object.assign({}, state), { isRecording: true, status: "recording", startedAt: client.startedCloudRecordingAt
|
|
378
|
-
? new Date(client.startedCloudRecordingAt).getTime()
|
|
379
|
-
: new Date().getTime() });
|
|
380
|
-
}
|
|
381
|
-
return state;
|
|
382
|
-
});
|
|
383
|
-
},
|
|
384
|
-
});
|
|
385
|
-
const { recordingRequestStarted } = cloudRecordingSlice.actions;
|
|
386
|
-
const doStartCloudRecording = createAppThunk(() => (dispatch, getState) => {
|
|
387
|
-
const state = getState();
|
|
388
|
-
const socket = selectSignalConnectionRaw(state).socket;
|
|
389
|
-
const status = selectCloudRecordingStatus(state);
|
|
390
|
-
if (status && ["recording", "requested"].includes(status)) {
|
|
391
|
-
return;
|
|
392
|
-
}
|
|
393
|
-
socket === null || socket === void 0 ? void 0 : socket.emit("start_recording", {
|
|
394
|
-
recording: "cloud",
|
|
395
|
-
});
|
|
396
|
-
dispatch(recordingRequestStarted());
|
|
397
|
-
});
|
|
398
|
-
const doStopCloudRecording = createAppThunk(() => (dispatch, getState) => {
|
|
399
|
-
const state = getState();
|
|
400
|
-
const socket = selectSignalConnectionRaw(state).socket;
|
|
401
|
-
socket === null || socket === void 0 ? void 0 : socket.emit("stop_recording");
|
|
402
|
-
});
|
|
403
|
-
const selectCloudRecordingRaw = (state) => state.cloudRecording;
|
|
404
|
-
const selectCloudRecordingStatus = (state) => state.cloudRecording.status;
|
|
405
|
-
const selectCloudRecordingStartedAt = (state) => state.cloudRecording.startedAt;
|
|
406
|
-
const selectCloudRecordingError = (state) => state.cloudRecording.error;
|
|
407
|
-
const selectIsCloudRecording = (state) => state.cloudRecording.isRecording;
|
|
408
|
-
|
|
409
332
|
function fakeAudioStream() {
|
|
410
333
|
const audioCtx = new AudioContext();
|
|
411
334
|
const oscillator = audioCtx.createOscillator();
|
|
@@ -513,6 +436,22 @@ function parseRoomUrlAndSubdomain(roomAttribute, subdomainAttribute) {
|
|
|
513
436
|
};
|
|
514
437
|
}
|
|
515
438
|
|
|
439
|
+
function parseUnverifiedRoomKeyData(roomKey) {
|
|
440
|
+
const [, roomKeyData] = /\.(.*)\./i.exec(roomKey) || [];
|
|
441
|
+
if (!roomKeyData) {
|
|
442
|
+
return {};
|
|
443
|
+
}
|
|
444
|
+
else {
|
|
445
|
+
try {
|
|
446
|
+
const base64DecodedJwtData = atob(roomKeyData);
|
|
447
|
+
return JSON.parse(base64DecodedJwtData);
|
|
448
|
+
}
|
|
449
|
+
catch (e) {
|
|
450
|
+
return {};
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
|
|
516
455
|
const initialLocalMediaState = {
|
|
517
456
|
busyDeviceIds: [],
|
|
518
457
|
cameraEnabled: false,
|
|
@@ -941,8 +880,17 @@ startAppListening({
|
|
|
941
880
|
dispatch(localStreamMetadataUpdated(deviceData));
|
|
942
881
|
},
|
|
943
882
|
});
|
|
883
|
+
startAppListening({
|
|
884
|
+
actionCreator: signalEvents.audioEnableRequested,
|
|
885
|
+
effect: ({ payload }, { dispatch }) => {
|
|
886
|
+
const { enable } = payload;
|
|
887
|
+
if (!enable) {
|
|
888
|
+
dispatch(toggleMicrophoneEnabled({ enabled: false }));
|
|
889
|
+
}
|
|
890
|
+
},
|
|
891
|
+
});
|
|
944
892
|
|
|
945
|
-
const initialState$
|
|
893
|
+
const initialState$a = {
|
|
946
894
|
displayName: "",
|
|
947
895
|
id: "",
|
|
948
896
|
isAudioEnabled: true,
|
|
@@ -950,7 +898,7 @@ const initialState$8 = {
|
|
|
950
898
|
isLocalParticipant: true,
|
|
951
899
|
stream: undefined,
|
|
952
900
|
isScreenSharing: false,
|
|
953
|
-
roleName: "",
|
|
901
|
+
roleName: "none",
|
|
954
902
|
clientClaim: undefined,
|
|
955
903
|
};
|
|
956
904
|
const doEnableAudio = createAppAsyncThunk("localParticipant/doEnableAudio", (payload, { getState }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -976,7 +924,7 @@ const doSetDisplayName = createAppAsyncThunk("localParticipant/doSetDisplayName"
|
|
|
976
924
|
}));
|
|
977
925
|
const localParticipantSlice = createSlice({
|
|
978
926
|
name: "localParticipant",
|
|
979
|
-
initialState: initialState$
|
|
927
|
+
initialState: initialState$a,
|
|
980
928
|
reducers: {
|
|
981
929
|
doSetLocalParticipant: (state, action) => {
|
|
982
930
|
return Object.assign(Object.assign({}, state), action.payload);
|
|
@@ -998,7 +946,7 @@ const localParticipantSlice = createSlice({
|
|
|
998
946
|
builder.addCase(signalEvents.roomJoined, (state, action) => {
|
|
999
947
|
var _a, _b;
|
|
1000
948
|
const client = (_b = (_a = action.payload) === null || _a === void 0 ? void 0 : _a.room) === null || _b === void 0 ? void 0 : _b.clients.find((c) => { var _a; return c.id === ((_a = action.payload) === null || _a === void 0 ? void 0 : _a.selfId); });
|
|
1001
|
-
return Object.assign(Object.assign({}, state), { id: action.payload.selfId,
|
|
949
|
+
return Object.assign(Object.assign({}, state), { id: action.payload.selfId, roleName: (client === null || client === void 0 ? void 0 : client.role.roleName) || "none", clientClaim: action.payload.clientClaim });
|
|
1002
950
|
});
|
|
1003
951
|
},
|
|
1004
952
|
});
|
|
@@ -1025,6 +973,136 @@ startAppListening({
|
|
|
1025
973
|
},
|
|
1026
974
|
});
|
|
1027
975
|
|
|
976
|
+
const ACTION_PERMISSIONS_BY_ROLE = {
|
|
977
|
+
canLockRoom: ["host"],
|
|
978
|
+
canRequestAudioEnable: ["host"],
|
|
979
|
+
};
|
|
980
|
+
const initialState$9 = {
|
|
981
|
+
roomKey: null,
|
|
982
|
+
roomLocked: false,
|
|
983
|
+
};
|
|
984
|
+
const authorizationSlice = createSlice({
|
|
985
|
+
name: "authorization",
|
|
986
|
+
initialState: initialState$9,
|
|
987
|
+
reducers: {
|
|
988
|
+
setRoomKey: (state, action) => {
|
|
989
|
+
return Object.assign(Object.assign({}, state), { roomKey: action.payload });
|
|
990
|
+
},
|
|
991
|
+
},
|
|
992
|
+
extraReducers: (builder) => {
|
|
993
|
+
builder.addCase(doAppJoin, (state, action) => {
|
|
994
|
+
return Object.assign(Object.assign({}, state), { roomKey: action.payload.roomKey });
|
|
995
|
+
});
|
|
996
|
+
builder.addCase(signalEvents.roomJoined, (state, action) => {
|
|
997
|
+
const { error, isLocked } = action.payload;
|
|
998
|
+
if (error) {
|
|
999
|
+
return state;
|
|
1000
|
+
}
|
|
1001
|
+
return Object.assign(Object.assign({}, state), { roomLocked: isLocked });
|
|
1002
|
+
});
|
|
1003
|
+
builder.addCase(signalEvents.roomLocked, (state, action) => {
|
|
1004
|
+
const { isLocked } = action.payload;
|
|
1005
|
+
return Object.assign(Object.assign({}, state), { roomLocked: isLocked });
|
|
1006
|
+
});
|
|
1007
|
+
},
|
|
1008
|
+
});
|
|
1009
|
+
const { setRoomKey } = authorizationSlice.actions;
|
|
1010
|
+
const doLockRoom = createAppAuthorizedThunk((state) => selectIsAuthorizedToLockRoom(state), (payload) => (_, getState) => {
|
|
1011
|
+
const state = getState();
|
|
1012
|
+
const { socket } = selectSignalConnectionRaw(state);
|
|
1013
|
+
socket === null || socket === void 0 ? void 0 : socket.emit("set_lock", { locked: payload.locked });
|
|
1014
|
+
});
|
|
1015
|
+
const selectAuthorizationRoomKey = (state) => state.authorization.roomKey;
|
|
1016
|
+
const selectAuthorizationRoomLocked = (state) => state.authorization.roomLocked;
|
|
1017
|
+
const selectIsAuthorizedToLockRoom = createSelector(selectLocalParticipantRole, (localParticipantRole) => ACTION_PERMISSIONS_BY_ROLE.canLockRoom.includes(localParticipantRole));
|
|
1018
|
+
const selectIsAuthorizedToRequestAudioEnable = createSelector(selectLocalParticipantRole, (localParticipantRole) => ACTION_PERMISSIONS_BY_ROLE.canRequestAudioEnable.includes(localParticipantRole));
|
|
1019
|
+
|
|
1020
|
+
const initialState$8 = {
|
|
1021
|
+
chatMessages: [],
|
|
1022
|
+
};
|
|
1023
|
+
const chatSlice = createSlice({
|
|
1024
|
+
name: "chat",
|
|
1025
|
+
initialState: initialState$8,
|
|
1026
|
+
reducers: {},
|
|
1027
|
+
extraReducers(builder) {
|
|
1028
|
+
builder.addCase(signalEvents.chatMessage, (state, action) => {
|
|
1029
|
+
const message = {
|
|
1030
|
+
senderId: action.payload.senderId,
|
|
1031
|
+
timestamp: action.payload.timestamp,
|
|
1032
|
+
text: action.payload.text,
|
|
1033
|
+
};
|
|
1034
|
+
return Object.assign(Object.assign({}, state), { chatMessages: [...state.chatMessages, message] });
|
|
1035
|
+
});
|
|
1036
|
+
},
|
|
1037
|
+
});
|
|
1038
|
+
const doSendChatMessage = createAppThunk((payload) => (_, getState) => {
|
|
1039
|
+
const state = getState();
|
|
1040
|
+
const socket = selectSignalConnectionRaw(state).socket;
|
|
1041
|
+
socket === null || socket === void 0 ? void 0 : socket.emit("chat_message", { text: payload.text });
|
|
1042
|
+
});
|
|
1043
|
+
const selectChatRaw = (state) => state.chat;
|
|
1044
|
+
const selectChatMessages = (state) => state.chat.chatMessages;
|
|
1045
|
+
|
|
1046
|
+
const initialCloudRecordingState = {
|
|
1047
|
+
isRecording: false,
|
|
1048
|
+
error: null,
|
|
1049
|
+
startedAt: undefined,
|
|
1050
|
+
};
|
|
1051
|
+
const cloudRecordingSlice = createSlice({
|
|
1052
|
+
name: "cloudRecording",
|
|
1053
|
+
initialState: initialCloudRecordingState,
|
|
1054
|
+
reducers: {
|
|
1055
|
+
recordingRequestStarted: (state) => {
|
|
1056
|
+
return Object.assign(Object.assign({}, state), { status: "requested" });
|
|
1057
|
+
},
|
|
1058
|
+
},
|
|
1059
|
+
extraReducers: (builder) => {
|
|
1060
|
+
builder.addCase(signalEvents.cloudRecordingStopped, (state) => {
|
|
1061
|
+
return Object.assign(Object.assign({}, state), { isRecording: false, status: undefined });
|
|
1062
|
+
});
|
|
1063
|
+
builder.addCase(signalEvents.cloudRecordingStarted, (state, action) => {
|
|
1064
|
+
const { payload } = action;
|
|
1065
|
+
if (!payload.error) {
|
|
1066
|
+
return state;
|
|
1067
|
+
}
|
|
1068
|
+
return Object.assign(Object.assign({}, state), { isRecording: false, status: "error", error: payload.error });
|
|
1069
|
+
});
|
|
1070
|
+
builder.addCase(signalEvents.newClient, (state, { payload }) => {
|
|
1071
|
+
var _a;
|
|
1072
|
+
const { client } = payload;
|
|
1073
|
+
if (((_a = client.role) === null || _a === void 0 ? void 0 : _a.roleName) === "recorder") {
|
|
1074
|
+
return Object.assign(Object.assign({}, state), { isRecording: true, status: "recording", startedAt: client.startedCloudRecordingAt
|
|
1075
|
+
? new Date(client.startedCloudRecordingAt).getTime()
|
|
1076
|
+
: new Date().getTime() });
|
|
1077
|
+
}
|
|
1078
|
+
return state;
|
|
1079
|
+
});
|
|
1080
|
+
},
|
|
1081
|
+
});
|
|
1082
|
+
const { recordingRequestStarted } = cloudRecordingSlice.actions;
|
|
1083
|
+
const doStartCloudRecording = createAppThunk(() => (dispatch, getState) => {
|
|
1084
|
+
const state = getState();
|
|
1085
|
+
const socket = selectSignalConnectionRaw(state).socket;
|
|
1086
|
+
const status = selectCloudRecordingStatus(state);
|
|
1087
|
+
if (status && ["recording", "requested"].includes(status)) {
|
|
1088
|
+
return;
|
|
1089
|
+
}
|
|
1090
|
+
socket === null || socket === void 0 ? void 0 : socket.emit("start_recording", {
|
|
1091
|
+
recording: "cloud",
|
|
1092
|
+
});
|
|
1093
|
+
dispatch(recordingRequestStarted());
|
|
1094
|
+
});
|
|
1095
|
+
const doStopCloudRecording = createAppThunk(() => (dispatch, getState) => {
|
|
1096
|
+
const state = getState();
|
|
1097
|
+
const socket = selectSignalConnectionRaw(state).socket;
|
|
1098
|
+
socket === null || socket === void 0 ? void 0 : socket.emit("stop_recording");
|
|
1099
|
+
});
|
|
1100
|
+
const selectCloudRecordingRaw = (state) => state.cloudRecording;
|
|
1101
|
+
const selectCloudRecordingStatus = (state) => state.cloudRecording.status;
|
|
1102
|
+
const selectCloudRecordingStartedAt = (state) => state.cloudRecording.startedAt;
|
|
1103
|
+
const selectCloudRecordingError = (state) => state.cloudRecording.error;
|
|
1104
|
+
const selectIsCloudRecording = (state) => state.cloudRecording.isRecording;
|
|
1105
|
+
|
|
1028
1106
|
const initialState$7 = {
|
|
1029
1107
|
status: "",
|
|
1030
1108
|
stream: null,
|
|
@@ -1165,9 +1243,9 @@ const rtcEvents = {
|
|
|
1165
1243
|
};
|
|
1166
1244
|
|
|
1167
1245
|
const NON_PERSON_ROLES = ["recorder", "streamer"];
|
|
1168
|
-
function
|
|
1169
|
-
const { streams } = client, rest = __rest(client, ["streams"]);
|
|
1170
|
-
return Object.assign(Object.assign({}, rest), { stream: null, streams: streams.map((streamId) => ({ id: streamId, state: newJoiner ? "new_accept" : "to_accept" })), isLocalParticipant: false, presentationStream: null, newJoiner });
|
|
1246
|
+
function createRemoteParticipant(client, newJoiner = false) {
|
|
1247
|
+
const { streams, role } = client, rest = __rest(client, ["streams", "role"]);
|
|
1248
|
+
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 });
|
|
1171
1249
|
}
|
|
1172
1250
|
function findParticipant(state, participantId) {
|
|
1173
1251
|
const index = state.remoteParticipants.findIndex((c) => c.id === participantId);
|
|
@@ -1291,7 +1369,7 @@ const remoteParticipantsSlice = createSlice({
|
|
|
1291
1369
|
return Object.assign(Object.assign({}, state), { remoteParticipants: clients
|
|
1292
1370
|
.filter((c) => c.id !== selfId)
|
|
1293
1371
|
.filter((c) => !NON_PERSON_ROLES.includes(c.role.roleName))
|
|
1294
|
-
.map((c) =>
|
|
1372
|
+
.map((c) => createRemoteParticipant(c)) });
|
|
1295
1373
|
});
|
|
1296
1374
|
builder.addCase(rtcEvents.streamAdded, (state, action) => {
|
|
1297
1375
|
return addStream(state, action.payload);
|
|
@@ -1301,7 +1379,7 @@ const remoteParticipantsSlice = createSlice({
|
|
|
1301
1379
|
if (NON_PERSON_ROLES.includes(client.role.roleName)) {
|
|
1302
1380
|
return state;
|
|
1303
1381
|
}
|
|
1304
|
-
return addParticipant(state,
|
|
1382
|
+
return addParticipant(state, createRemoteParticipant(client, true));
|
|
1305
1383
|
});
|
|
1306
1384
|
builder.addCase(signalEvents.clientLeft, (state, action) => {
|
|
1307
1385
|
const { clientId } = action.payload;
|
|
@@ -1336,6 +1414,11 @@ const remoteParticipantsSlice = createSlice({
|
|
|
1336
1414
|
},
|
|
1337
1415
|
});
|
|
1338
1416
|
const { participantStreamAdded, participantStreamIdAdded, streamStatusUpdated } = remoteParticipantsSlice.actions;
|
|
1417
|
+
const doRequestAudioEnable = createAppAuthorizedThunk((state) => selectIsAuthorizedToRequestAudioEnable(state), (payload) => (_, getState) => {
|
|
1418
|
+
const state = getState();
|
|
1419
|
+
const socket = selectSignalConnectionRaw(state).socket;
|
|
1420
|
+
socket === null || socket === void 0 ? void 0 : socket.emit("request_audio_enable", payload);
|
|
1421
|
+
});
|
|
1339
1422
|
const selectRemoteParticipantsRaw = (state) => state.remoteParticipants;
|
|
1340
1423
|
const selectRemoteParticipants = (state) => state.remoteParticipants.remoteParticipants;
|
|
1341
1424
|
const selectScreenshares = createSelector(selectLocalScreenshareStream, selectRemoteParticipants, (localScreenshareStream, remoteParticipants) => {
|
|
@@ -1415,7 +1498,7 @@ const doKnockRoom = createAppThunk(() => (dispatch, getState) => {
|
|
|
1415
1498
|
const state = getState();
|
|
1416
1499
|
const socket = selectSignalConnectionRaw(state).socket;
|
|
1417
1500
|
const roomName = selectAppRoomName(state);
|
|
1418
|
-
const roomKey =
|
|
1501
|
+
const roomKey = selectAuthorizationRoomKey(state);
|
|
1419
1502
|
const displayName = selectAppDisplayName(state);
|
|
1420
1503
|
const userAgent = selectAppUserAgent(state);
|
|
1421
1504
|
const externalId = selectAppExternalId(state);
|
|
@@ -1444,7 +1527,7 @@ const doConnectRoom = createAppThunk(() => (dispatch, getState) => {
|
|
|
1444
1527
|
const state = getState();
|
|
1445
1528
|
const socket = selectSignalConnectionRaw(state).socket;
|
|
1446
1529
|
const roomName = selectAppRoomName(state);
|
|
1447
|
-
const roomKey =
|
|
1530
|
+
const roomKey = selectAuthorizationRoomKey(state);
|
|
1448
1531
|
const displayName = selectAppDisplayName(state);
|
|
1449
1532
|
const userAgent = selectAppUserAgent(state);
|
|
1450
1533
|
const externalId = selectAppExternalId(state);
|
|
@@ -2035,6 +2118,7 @@ var _a;
|
|
|
2035
2118
|
const IS_DEV = (_a = undefined === "true") !== null && _a !== void 0 ? _a : false;
|
|
2036
2119
|
const rootReducer = combineReducers({
|
|
2037
2120
|
app: appSlice.reducer,
|
|
2121
|
+
authorization: authorizationSlice.reducer,
|
|
2038
2122
|
chat: chatSlice.reducer,
|
|
2039
2123
|
cloudRecording: cloudRecordingSlice.reducer,
|
|
2040
2124
|
deviceCredentials: deviceCredentialsSlice.reducer,
|
|
@@ -3084,4 +3168,4 @@ function createServices() {
|
|
|
3084
3168
|
};
|
|
3085
3169
|
}
|
|
3086
3170
|
|
|
3087
|
-
export { ApiClient, Credentials, CredentialsService, LocalParticipant, OrganizationApiClient, OrganizationService, OrganizationServiceCache, RoomService, addAppListener, appLeft, appSlice, chatSlice, cloudRecordingSlice, createAppAsyncThunk, createAppThunk, createReactor, createServices, createStore, createWebRtcEmitter, debounce, deviceBusy, deviceCredentialsSlice, deviceIdentified, deviceIdentifying, doAcceptWaitingParticipant, doAppJoin, doConnectRoom, doConnectRtc, doDisconnectRtc, doEnableAudio, doEnableVideo, doGetDeviceCredentials, doHandleAcceptStreams, doHandleStreamingStarted, doHandleStreamingStopped, doKnockRoom, doOrganizationFetch, doRejectWaitingParticipant, doRtcAnalyticsCustomEventsInitialize, doRtcManagerCreated, doRtcManagerInitialize, doRtcReportStreamResolution, doSendChatMessage, doSetDevice, doSetDisplayName, doSetLocalParticipant, doSignalDisconnect, doSignalIdentifyDevice, doSignalReconnect, doSignalSocketConnect, doStartCloudRecording, doStartLocalMedia, doStartScreenshare, doStopCloudRecording, doStopLocalMedia, doStopScreenshare, doSwitchLocalStream, doToggleCamera, doUpdateDeviceList, fakeAudioStream, fakeWebcamFrame, initialCloudRecordingState, initialLocalMediaState, isAcceptingStreams, listenerMiddleware, localMediaSlice, localMediaStopped, localParticipantSlice, localScreenshareSlice, localStreamMetadataUpdated, observeStore, organizationSlice, parseRoomUrlAndSubdomain, participantStreamAdded, participantStreamIdAdded, recordingRequestStarted, remoteParticipantsSlice, resolutionReported, roomConnectionSlice, rootReducer, rtcAnalyticsCustomEvents, rtcAnalyticsSlice, rtcConnectionSlice, rtcDisconnected, rtcDispatcherCreated, rtcManagerCreated, rtcManagerDestroyed, rtcManagerInitialized, selectAppDisplayName, selectAppExternalId, selectAppIsNodeSdk, selectAppRaw,
|
|
3171
|
+
export { ApiClient, Credentials, CredentialsService, LocalParticipant, OrganizationApiClient, OrganizationService, OrganizationServiceCache, RoomService, addAppListener, appLeft, appSlice, authorizationSlice, chatSlice, cloudRecordingSlice, createAppAsyncThunk, createAppAuthorizedThunk, createAppThunk, createReactor, createServices, createStore, createWebRtcEmitter, debounce, deviceBusy, deviceCredentialsSlice, deviceIdentified, deviceIdentifying, doAcceptWaitingParticipant, doAppJoin, doConnectRoom, doConnectRtc, doDisconnectRtc, doEnableAudio, doEnableVideo, doGetDeviceCredentials, doHandleAcceptStreams, doHandleStreamingStarted, doHandleStreamingStopped, doKnockRoom, doLockRoom, doOrganizationFetch, doRejectWaitingParticipant, doRequestAudioEnable, doRtcAnalyticsCustomEventsInitialize, doRtcManagerCreated, doRtcManagerInitialize, doRtcReportStreamResolution, doSendChatMessage, doSetDevice, doSetDisplayName, doSetLocalParticipant, doSignalDisconnect, doSignalIdentifyDevice, doSignalReconnect, doSignalSocketConnect, doStartCloudRecording, doStartLocalMedia, doStartScreenshare, doStopCloudRecording, doStopLocalMedia, doStopScreenshare, doSwitchLocalStream, doToggleCamera, doUpdateDeviceList, fakeAudioStream, fakeWebcamFrame, initialCloudRecordingState, initialLocalMediaState, isAcceptingStreams, listenerMiddleware, localMediaSlice, localMediaStopped, localParticipantSlice, localScreenshareSlice, localStreamMetadataUpdated, observeStore, organizationSlice, parseRoomUrlAndSubdomain, parseUnverifiedRoomKeyData, participantStreamAdded, participantStreamIdAdded, recordingRequestStarted, remoteParticipantsSlice, resolutionReported, roomConnectionSlice, rootReducer, rtcAnalyticsCustomEvents, rtcAnalyticsSlice, rtcConnectionSlice, rtcDisconnected, rtcDispatcherCreated, rtcManagerCreated, rtcManagerDestroyed, rtcManagerInitialized, selectAppDisplayName, selectAppExternalId, selectAppIsNodeSdk, selectAppRaw, selectAppRoomName, selectAppRoomUrl, selectAppUserAgent, selectAppWantsToJoin, selectAuthorizationRoomKey, selectAuthorizationRoomLocked, selectBusyDeviceIds, selectCameraDeviceError, selectCameraDevices, selectChatMessages, selectChatRaw, selectCloudRecordingError, selectCloudRecordingRaw, selectCloudRecordingStartedAt, selectCloudRecordingStatus, selectCurrentCameraDeviceId, selectCurrentMicrophoneDeviceId, selectDeviceCredentialsRaw, selectDeviceId, selectHasFetchedDeviceCredentials, selectIsAcceptingStreams, selectIsAuthorizedToLockRoom, selectIsAuthorizedToRequestAudioEnable, selectIsCameraEnabled, selectIsCloudRecording, selectIsLocalMediaStarting, selectIsMicrophoneEnabled, selectIsSettingCameraDevice, selectIsSettingMicrophoneDevice, selectIsToggleCamera, selectLocalMediaConstraintsOptions, selectLocalMediaDevices, selectLocalMediaIsSwitchingStream, selectLocalMediaOptions, selectLocalMediaOwnsStream, selectLocalMediaRaw, selectLocalMediaShouldStartWithOptions, selectLocalMediaShouldStop, selectLocalMediaStartError, selectLocalMediaStatus, selectLocalMediaStream, selectLocalParticipantClientClaim, selectLocalParticipantIsScreenSharing, selectLocalParticipantRaw, selectLocalParticipantRole, selectLocalScreenshareRaw, selectLocalScreenshareStatus, selectLocalScreenshareStream, selectMicrophoneDeviceError, selectMicrophoneDevices, selectOrganizationId, selectOrganizationRaw, selectRemoteParticipants, selectRemoteParticipantsRaw, selectRoomConnectionError, selectRoomConnectionRaw, selectRoomConnectionSession, selectRoomConnectionSessionId, selectRoomConnectionStatus, selectRtcConnectionRaw, selectRtcDispatcherCreated, selectRtcIsCreatingDispatcher, selectRtcManager, selectRtcManagerInitialized, selectRtcStatus, selectScreenshares, selectSelfId, selectShouldConnectRoom, selectShouldConnectRtc, selectShouldConnectSignal, selectShouldDisconnectRtc, selectShouldFetchDeviceCredentials, selectShouldFetchOrganization, selectShouldIdentifyDevice, selectShouldInitializeRtc, selectSignalConnectionDeviceIdentified, selectSignalConnectionRaw, selectSignalConnectionSocket, selectSignalIsIdentifyingDevice, selectSignalStatus, selectSpeakerDevices, selectStreamingRaw, selectStreamsToAccept, selectWaitingParticipants, selectWaitingParticipantsRaw, setCurrentCameraDeviceId, setCurrentMicrophoneDeviceId, setLocalMediaOptions, setLocalMediaStream, setRoomKey, signalConnectionSlice, socketConnected, socketConnecting, socketDisconnected, socketReconnecting, startAppListening, stopScreenshare, streamStatusUpdated, streamingSlice, toggleCameraEnabled, 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.
|
|
5
|
+
"version": "0.11.0",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"build": "rimraf dist && rollup -c rollup.config.js",
|
|
@@ -38,21 +38,12 @@
|
|
|
38
38
|
}
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@rollup/plugin-commonjs": "^25.0.7",
|
|
42
|
-
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
43
|
-
"@rollup/plugin-replace": "^5.0.5",
|
|
44
41
|
"@types/btoa": "^1.2.3",
|
|
45
42
|
"@types/node": "^20.11.19",
|
|
46
43
|
"@types/uuid": "^9.0.7",
|
|
47
44
|
"deep-object-diff": "^1.1.9",
|
|
48
45
|
"dotenv": "^16.4.5",
|
|
49
46
|
"dotenv-run-script": "^0.4.1",
|
|
50
|
-
"rimraf": "^5.0.5",
|
|
51
|
-
"rollup": "^4.12.0",
|
|
52
|
-
"rollup-plugin-dts": "^6.1.0",
|
|
53
|
-
"rollup-plugin-polyfill-node": "^0.13.0",
|
|
54
|
-
"rollup-plugin-terser": "^7.0.2",
|
|
55
|
-
"rollup-plugin-typescript2": "^0.36.0",
|
|
56
47
|
"tslib": "^2.4.1",
|
|
57
48
|
"uuid": "^9.0.1",
|
|
58
49
|
"yalc": "^1.0.0-pre.53"
|