@whereby.com/core 0.13.1 → 0.14.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 +137 -55
- package/dist/index.d.cts +307 -113
- package/dist/index.d.mts +307 -113
- package/dist/index.d.ts +307 -113
- package/dist/index.mjs +130 -53
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createAsyncThunk, createListenerMiddleware, addListener, createSlice,
|
|
1
|
+
import { createAsyncThunk, createListenerMiddleware, addListener, createSlice, createSelector, createAction, isAnyOf, combineReducers, configureStore } from '@reduxjs/toolkit';
|
|
2
2
|
import { ServerSocket, getDeviceData, getStream, getUpdatedDevices, RtcManagerDispatcher, assert, fromLocation } from '@whereby.com/media';
|
|
3
3
|
import { Chrome111 } from 'mediasoup-client/lib/handlers/Chrome111.js';
|
|
4
4
|
import nodeBtoa from 'btoa';
|
|
@@ -43,39 +43,61 @@ const createReactor = (selectors, callback) => {
|
|
|
43
43
|
});
|
|
44
44
|
};
|
|
45
45
|
|
|
46
|
-
const coreVersion = "0.
|
|
46
|
+
const coreVersion = "0.14.0";
|
|
47
47
|
|
|
48
48
|
const initialState$e = {
|
|
49
49
|
isNodeSdk: false,
|
|
50
|
-
|
|
50
|
+
isActive: false,
|
|
51
51
|
roomName: null,
|
|
52
52
|
roomUrl: null,
|
|
53
53
|
displayName: null,
|
|
54
54
|
userAgent: `core:${coreVersion}`,
|
|
55
55
|
externalId: null,
|
|
56
|
+
isLoaded: false,
|
|
56
57
|
};
|
|
57
58
|
const appSlice = createSlice({
|
|
58
59
|
name: "app",
|
|
59
60
|
initialState: initialState$e,
|
|
60
61
|
reducers: {
|
|
61
|
-
|
|
62
|
+
doAppConfigure: (state, action) => {
|
|
62
63
|
const url = new URL(action.payload.roomUrl);
|
|
63
|
-
return Object.assign(Object.assign(Object.assign({}, state), action.payload), { roomName: url.pathname,
|
|
64
|
+
return Object.assign(Object.assign(Object.assign({}, state), action.payload), { roomName: url.pathname, initialConfig: Object.assign({}, action.payload), isLoaded: true });
|
|
64
65
|
},
|
|
65
|
-
|
|
66
|
-
return Object.assign(Object.assign({}, state), {
|
|
66
|
+
doAppStart: (state) => {
|
|
67
|
+
return Object.assign(Object.assign({}, state), { isActive: true });
|
|
68
|
+
},
|
|
69
|
+
doAppStop: (state) => {
|
|
70
|
+
return Object.assign(Object.assign({}, state), { isActive: false });
|
|
71
|
+
},
|
|
72
|
+
doAppReset: (state) => {
|
|
73
|
+
return Object.assign(Object.assign({}, state), { isLoaded: false });
|
|
67
74
|
},
|
|
68
75
|
},
|
|
69
76
|
});
|
|
70
|
-
const {
|
|
77
|
+
const { doAppConfigure, doAppStop, doAppReset, doAppStart } = appSlice.actions;
|
|
71
78
|
const selectAppRaw = (state) => state.app;
|
|
72
|
-
const
|
|
79
|
+
const selectAppIsActive = (state) => state.app.isActive;
|
|
73
80
|
const selectAppRoomName = (state) => state.app.roomName;
|
|
74
81
|
const selectAppRoomUrl = (state) => state.app.roomUrl;
|
|
75
82
|
const selectAppDisplayName = (state) => state.app.displayName;
|
|
76
83
|
const selectAppUserAgent = (state) => state.app.userAgent;
|
|
77
84
|
const selectAppExternalId = (state) => state.app.externalId;
|
|
78
85
|
const selectAppIsNodeSdk = (state) => state.app.isNodeSdk;
|
|
86
|
+
const selectAppInitialConfig = (state) => state.app.initialConfig;
|
|
87
|
+
const selectAppIsLoaded = (state) => state.app.isLoaded;
|
|
88
|
+
const selectShouldReloadApp = createSelector(selectAppIsLoaded, selectAppInitialConfig, (appIsLoaded, appInitialConfig) => {
|
|
89
|
+
return !appIsLoaded && appInitialConfig;
|
|
90
|
+
});
|
|
91
|
+
startAppListening({
|
|
92
|
+
actionCreator: doAppReset,
|
|
93
|
+
effect: (_, { dispatch, getState }) => {
|
|
94
|
+
const state = getState();
|
|
95
|
+
const appInitialConfig = selectAppInitialConfig(state);
|
|
96
|
+
if (appInitialConfig) {
|
|
97
|
+
dispatch(doAppConfigure(appInitialConfig));
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
});
|
|
79
101
|
|
|
80
102
|
function createSignalEventAction(name) {
|
|
81
103
|
return createAction(`signalConnection/event/${name}`);
|
|
@@ -95,6 +117,7 @@ const signalEvents = {
|
|
|
95
117
|
newClient: createSignalEventAction("newClient"),
|
|
96
118
|
roomJoined: createSignalEventAction("roomJoined"),
|
|
97
119
|
roomKnocked: createSignalEventAction("roomKnocked"),
|
|
120
|
+
roomLeft: createSignalEventAction("roomLeft"),
|
|
98
121
|
roomLocked: createSignalEventAction("roomLocked"),
|
|
99
122
|
roomSessionEnded: createSignalEventAction("roomSessionEnded"),
|
|
100
123
|
screenshareStarted: createSignalEventAction("screenshareStarted"),
|
|
@@ -122,7 +145,7 @@ const authorizationSlice = createSlice({
|
|
|
122
145
|
},
|
|
123
146
|
},
|
|
124
147
|
extraReducers: (builder) => {
|
|
125
|
-
builder.addCase(
|
|
148
|
+
builder.addCase(doAppConfigure, (state, action) => {
|
|
126
149
|
return Object.assign(Object.assign({}, state), { roomKey: action.payload.roomKey });
|
|
127
150
|
});
|
|
128
151
|
builder.addCase(signalEvents.roomJoined, (state, action) => {
|
|
@@ -216,8 +239,8 @@ const doGetDeviceCredentials = createAppAsyncThunk("deviceCredentials/doGetDevic
|
|
|
216
239
|
const selectDeviceCredentialsRaw = (state) => state.deviceCredentials;
|
|
217
240
|
const selectHasFetchedDeviceCredentials = (state) => { var _a; return !!((_a = state.deviceCredentials.data) === null || _a === void 0 ? void 0 : _a.credentials); };
|
|
218
241
|
const selectDeviceId = (state) => { var _a, _b; return (_b = (_a = state.deviceCredentials.data) === null || _a === void 0 ? void 0 : _a.credentials) === null || _b === void 0 ? void 0 : _b.uuid; };
|
|
219
|
-
const selectShouldFetchDeviceCredentials = createSelector(
|
|
220
|
-
if (
|
|
242
|
+
const selectShouldFetchDeviceCredentials = createSelector(selectAppIsActive, selectDeviceCredentialsRaw, (appIsActive, deviceCredentials) => {
|
|
243
|
+
if (appIsActive && !deviceCredentials.isFetching && !deviceCredentials.data) {
|
|
221
244
|
return true;
|
|
222
245
|
}
|
|
223
246
|
return false;
|
|
@@ -240,6 +263,7 @@ function forwardSocketEvents(socket, dispatch) {
|
|
|
240
263
|
socket.on("chat_message", (payload) => dispatch(signalEvents.chatMessage(payload)));
|
|
241
264
|
socket.on("disconnect", () => dispatch(signalEvents.disconnect()));
|
|
242
265
|
socket.on("room_knocked", (payload) => dispatch(signalEvents.roomKnocked(payload)));
|
|
266
|
+
socket.on("room_left", () => dispatch(signalEvents.roomLeft()));
|
|
243
267
|
socket.on("room_locked", (payload) => dispatch(signalEvents.roomLocked(payload)));
|
|
244
268
|
socket.on("room_session_ended", (payload) => dispatch(signalEvents.roomSessionEnded(payload)));
|
|
245
269
|
socket.on("knocker_left", (payload) => dispatch(signalEvents.knockerLeft(payload)));
|
|
@@ -262,7 +286,7 @@ function createSocket() {
|
|
|
262
286
|
const initialState$b = {
|
|
263
287
|
deviceIdentified: false,
|
|
264
288
|
isIdentifyingDevice: false,
|
|
265
|
-
status: "",
|
|
289
|
+
status: "ready",
|
|
266
290
|
socket: null,
|
|
267
291
|
};
|
|
268
292
|
const signalConnectionSlice = createSlice({
|
|
@@ -279,7 +303,7 @@ const signalConnectionSlice = createSlice({
|
|
|
279
303
|
return Object.assign(Object.assign({}, state), { deviceIdentified: false, status: "disconnected" });
|
|
280
304
|
},
|
|
281
305
|
socketReconnecting: (state) => {
|
|
282
|
-
return Object.assign(Object.assign({}, state), { status: "
|
|
306
|
+
return Object.assign(Object.assign({}, state), { status: "reconnecting" });
|
|
283
307
|
},
|
|
284
308
|
deviceIdentifying: (state) => {
|
|
285
309
|
return Object.assign(Object.assign({}, state), { isIdentifyingDevice: true });
|
|
@@ -295,7 +319,7 @@ const signalConnectionSlice = createSlice({
|
|
|
295
319
|
},
|
|
296
320
|
});
|
|
297
321
|
const { deviceIdentifying, deviceIdentified, socketConnected, socketConnecting, socketDisconnected, socketReconnecting, } = signalConnectionSlice.actions;
|
|
298
|
-
const
|
|
322
|
+
const doSignalConnect = createAppThunk(() => {
|
|
299
323
|
return (dispatch, getState) => {
|
|
300
324
|
if (selectSignalConnectionSocket(getState())) {
|
|
301
325
|
return;
|
|
@@ -323,31 +347,31 @@ const doSignalIdentifyDevice = createAppThunk(({ deviceCredentials }) => (dispat
|
|
|
323
347
|
dispatch(deviceIdentifying());
|
|
324
348
|
});
|
|
325
349
|
const doSignalDisconnect = createAppThunk(() => (dispatch, getState) => {
|
|
326
|
-
const
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
350
|
+
const state = getState();
|
|
351
|
+
const signalStatus = selectSignalStatus(state);
|
|
352
|
+
if (signalStatus === "connected") {
|
|
353
|
+
const socket = selectSignalConnectionRaw(state).socket;
|
|
354
|
+
socket === null || socket === void 0 ? void 0 : socket.disconnect();
|
|
355
|
+
dispatch(socketDisconnected());
|
|
356
|
+
}
|
|
357
|
+
else {
|
|
358
|
+
doAppReset();
|
|
359
|
+
}
|
|
330
360
|
});
|
|
331
361
|
const selectSignalConnectionRaw = (state) => state.signalConnection;
|
|
332
362
|
const selectSignalIsIdentifyingDevice = (state) => state.signalConnection.isIdentifyingDevice;
|
|
333
363
|
const selectSignalConnectionDeviceIdentified = (state) => state.signalConnection.deviceIdentified;
|
|
334
364
|
const selectSignalStatus = (state) => state.signalConnection.status;
|
|
335
365
|
const selectSignalConnectionSocket = (state) => state.signalConnection.socket;
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
effect: (_, { dispatch }) => {
|
|
339
|
-
dispatch(doSignalDisconnect());
|
|
340
|
-
},
|
|
341
|
-
});
|
|
342
|
-
const selectShouldConnectSignal = createSelector(selectAppWantsToJoin, selectSignalStatus, (wantsToJoin, signalStatus) => {
|
|
343
|
-
if (wantsToJoin && ["", "reconnect"].includes(signalStatus)) {
|
|
366
|
+
const selectShouldConnectSignal = createSelector(selectAppIsActive, selectSignalStatus, (appIsActive, signalStatus) => {
|
|
367
|
+
if (appIsActive && ["ready", "reconnecting"].includes(signalStatus)) {
|
|
344
368
|
return true;
|
|
345
369
|
}
|
|
346
370
|
return false;
|
|
347
371
|
});
|
|
348
372
|
createReactor([selectShouldConnectSignal], ({ dispatch }, shouldConnectSignal) => {
|
|
349
373
|
if (shouldConnectSignal) {
|
|
350
|
-
dispatch(
|
|
374
|
+
dispatch(doSignalConnect());
|
|
351
375
|
}
|
|
352
376
|
});
|
|
353
377
|
const selectShouldIdentifyDevice = createSelector(selectDeviceCredentialsRaw, selectSignalStatus, selectSignalConnectionDeviceIdentified, selectSignalIsIdentifyingDevice, (deviceCredentialsRaw, signalStatus, deviceIdentified, isIdentifyingDevice) => {
|
|
@@ -361,6 +385,24 @@ createReactor([selectShouldIdentifyDevice, selectDeviceCredentialsRaw], ({ dispa
|
|
|
361
385
|
dispatch(doSignalIdentifyDevice({ deviceCredentials: deviceCredentialsRaw.data }));
|
|
362
386
|
}
|
|
363
387
|
});
|
|
388
|
+
startAppListening({
|
|
389
|
+
actionCreator: signalEvents.roomLeft,
|
|
390
|
+
effect: (_, { dispatch }) => {
|
|
391
|
+
dispatch(doSignalDisconnect());
|
|
392
|
+
},
|
|
393
|
+
});
|
|
394
|
+
startAppListening({
|
|
395
|
+
actionCreator: signalEvents.clientKicked,
|
|
396
|
+
effect: (_, { dispatch }) => {
|
|
397
|
+
dispatch(doSignalDisconnect());
|
|
398
|
+
},
|
|
399
|
+
});
|
|
400
|
+
startAppListening({
|
|
401
|
+
actionCreator: socketDisconnected,
|
|
402
|
+
effect: (_, { dispatch }) => {
|
|
403
|
+
dispatch(doAppReset());
|
|
404
|
+
},
|
|
405
|
+
});
|
|
364
406
|
|
|
365
407
|
const initialState$a = {
|
|
366
408
|
chatMessages: [],
|
|
@@ -585,7 +627,8 @@ const initialLocalMediaState = {
|
|
|
585
627
|
isTogglingCamera: false,
|
|
586
628
|
lowDataMode: false,
|
|
587
629
|
microphoneEnabled: false,
|
|
588
|
-
status: "",
|
|
630
|
+
status: "inactive",
|
|
631
|
+
stream: undefined,
|
|
589
632
|
isSwitchingStream: false,
|
|
590
633
|
};
|
|
591
634
|
const localMediaSlice = createSlice({
|
|
@@ -634,7 +677,7 @@ const localMediaSlice = createSlice({
|
|
|
634
677
|
},
|
|
635
678
|
},
|
|
636
679
|
extraReducers: (builder) => {
|
|
637
|
-
builder.addCase(
|
|
680
|
+
builder.addCase(doAppConfigure, (state, action) => {
|
|
638
681
|
return Object.assign(Object.assign({}, state), { options: action.payload.localMediaOptions });
|
|
639
682
|
});
|
|
640
683
|
builder.addCase(doSetDevice.pending, (state, action) => {
|
|
@@ -917,8 +960,8 @@ const selectIsLocalMediaStarting = createSelector(selectLocalMediaStatus, (statu
|
|
|
917
960
|
const selectCameraDevices = createSelector(selectLocalMediaDevices, selectBusyDeviceIds, (devices, busyDeviceIds) => devices.filter((d) => d.kind === "videoinput").filter((d) => !busyDeviceIds.includes(d.deviceId)));
|
|
918
961
|
const selectMicrophoneDevices = createSelector(selectLocalMediaDevices, selectBusyDeviceIds, (devices, busyDeviceIds) => devices.filter((d) => d.kind === "audioinput").filter((d) => !busyDeviceIds.includes(d.deviceId)));
|
|
919
962
|
const selectSpeakerDevices = createSelector(selectLocalMediaDevices, (devices) => devices.filter((d) => d.kind === "audiooutput"));
|
|
920
|
-
const selectLocalMediaShouldStartWithOptions = createSelector(
|
|
921
|
-
if (
|
|
963
|
+
const selectLocalMediaShouldStartWithOptions = createSelector(selectAppIsActive, selectLocalMediaStatus, selectLocalMediaOptions, selectAppIsNodeSdk, (appIsActive, localMediaStatus, localMediaOptions, isNodeSdk) => {
|
|
964
|
+
if (appIsActive && ["inactive", "stopped"].includes(localMediaStatus) && !isNodeSdk && localMediaOptions) {
|
|
922
965
|
return localMediaOptions;
|
|
923
966
|
}
|
|
924
967
|
});
|
|
@@ -927,8 +970,8 @@ createReactor([selectLocalMediaShouldStartWithOptions], ({ dispatch }, options)
|
|
|
927
970
|
dispatch(doStartLocalMedia(options));
|
|
928
971
|
}
|
|
929
972
|
});
|
|
930
|
-
const selectLocalMediaShouldStop = createSelector(
|
|
931
|
-
return !
|
|
973
|
+
const selectLocalMediaShouldStop = createSelector(selectAppIsActive, selectLocalMediaStatus, selectLocalMediaOptions, (appIsActive, localMediaStatus, localMediaOptions) => {
|
|
974
|
+
return !appIsActive && localMediaStatus !== "inactive" && !!localMediaOptions;
|
|
932
975
|
});
|
|
933
976
|
createReactor([selectLocalMediaShouldStop], ({ dispatch }, localMediaShouldStop) => {
|
|
934
977
|
if (localMediaShouldStop) {
|
|
@@ -1061,7 +1104,7 @@ const localParticipantSlice = createSlice({
|
|
|
1061
1104
|
},
|
|
1062
1105
|
},
|
|
1063
1106
|
extraReducers: (builder) => {
|
|
1064
|
-
builder.addCase(
|
|
1107
|
+
builder.addCase(doAppConfigure, (state, action) => {
|
|
1065
1108
|
return Object.assign(Object.assign({}, state), { displayName: action.payload.displayName });
|
|
1066
1109
|
});
|
|
1067
1110
|
builder.addCase(doEnableAudio.fulfilled, (state, action) => {
|
|
@@ -1103,7 +1146,7 @@ startAppListening({
|
|
|
1103
1146
|
});
|
|
1104
1147
|
|
|
1105
1148
|
const initialState$8 = {
|
|
1106
|
-
status: "",
|
|
1149
|
+
status: "inactive",
|
|
1107
1150
|
stream: null,
|
|
1108
1151
|
error: null,
|
|
1109
1152
|
};
|
|
@@ -1112,7 +1155,7 @@ const localScreenshareSlice = createSlice({
|
|
|
1112
1155
|
initialState: initialState$8,
|
|
1113
1156
|
reducers: {
|
|
1114
1157
|
stopScreenshare(state, action) {
|
|
1115
|
-
return Object.assign(Object.assign({}, state), { status: "", stream: null });
|
|
1158
|
+
return Object.assign(Object.assign({}, state), { status: "inactive", stream: null });
|
|
1116
1159
|
},
|
|
1117
1160
|
},
|
|
1118
1161
|
extraReducers: (builder) => {
|
|
@@ -1123,7 +1166,7 @@ const localScreenshareSlice = createSlice({
|
|
|
1123
1166
|
return Object.assign(Object.assign({}, state), { status: "active", stream });
|
|
1124
1167
|
});
|
|
1125
1168
|
builder.addCase(doStartScreenshare.rejected, (state, { payload }) => {
|
|
1126
|
-
return Object.assign(Object.assign({}, state), { error: payload, status: "", stream: null });
|
|
1169
|
+
return Object.assign(Object.assign({}, state), { error: payload, status: "inactive", stream: null });
|
|
1127
1170
|
});
|
|
1128
1171
|
},
|
|
1129
1172
|
});
|
|
@@ -1216,8 +1259,8 @@ const doOrganizationFetch = createAppAsyncThunk("organization/doOrganizationFetc
|
|
|
1216
1259
|
}));
|
|
1217
1260
|
const selectOrganizationRaw = (state) => state.organization;
|
|
1218
1261
|
const selectOrganizationId = (state) => { var _a; return (_a = state.organization.data) === null || _a === void 0 ? void 0 : _a.organizationId; };
|
|
1219
|
-
const selectShouldFetchOrganization = createSelector(
|
|
1220
|
-
if (
|
|
1262
|
+
const selectShouldFetchOrganization = createSelector(selectAppIsActive, selectOrganizationRaw, selectDeviceCredentialsRaw, (appIsActive, organization, deviceCredentials) => {
|
|
1263
|
+
if (appIsActive &&
|
|
1221
1264
|
!organization.data &&
|
|
1222
1265
|
!organization.isFetching &&
|
|
1223
1266
|
!organization.error &&
|
|
@@ -1476,19 +1519,22 @@ const doKickParticipant = createAppAuthorizedThunk((state) => selectIsAuthorized
|
|
|
1476
1519
|
const { socket } = selectSignalConnectionRaw(state);
|
|
1477
1520
|
socket === null || socket === void 0 ? void 0 : socket.emit("kick_client", { clientId: payload.clientId, reasonId: "kick" });
|
|
1478
1521
|
});
|
|
1479
|
-
const doEndMeeting = createAppAuthorizedThunk((state) => selectIsAuthorizedToEndMeeting(state), () => (
|
|
1522
|
+
const doEndMeeting = createAppAuthorizedThunk((state) => selectIsAuthorizedToEndMeeting(state), (payload) => (dispatch, getState) => {
|
|
1480
1523
|
const state = getState();
|
|
1481
1524
|
const clientsToKick = selectRemoteParticipants(state).map((c) => c.id);
|
|
1482
1525
|
if (clientsToKick.length) {
|
|
1483
1526
|
const { socket } = selectSignalConnectionRaw(state);
|
|
1484
1527
|
socket === null || socket === void 0 ? void 0 : socket.emit("kick_client", { clientIds: clientsToKick, reasonId: "end-meeting" });
|
|
1485
1528
|
}
|
|
1529
|
+
if (!payload.stayBehind) {
|
|
1530
|
+
dispatch(doAppStop());
|
|
1531
|
+
}
|
|
1486
1532
|
});
|
|
1487
1533
|
const selectRoomIsLocked = (state) => state.room.isLocked;
|
|
1488
1534
|
|
|
1489
1535
|
const initialState$4 = {
|
|
1490
1536
|
session: null,
|
|
1491
|
-
status: "
|
|
1537
|
+
status: "ready",
|
|
1492
1538
|
error: null,
|
|
1493
1539
|
};
|
|
1494
1540
|
const roomConnectionSlice = createSlice({
|
|
@@ -1528,8 +1574,11 @@ const roomConnectionSlice = createSlice({
|
|
|
1528
1574
|
builder.addCase(signalEvents.clientKicked, (state) => {
|
|
1529
1575
|
return Object.assign(Object.assign({}, state), { status: "kicked" });
|
|
1530
1576
|
});
|
|
1577
|
+
builder.addCase(signalEvents.roomLeft, (state) => {
|
|
1578
|
+
return Object.assign(Object.assign({}, state), { status: "left" });
|
|
1579
|
+
});
|
|
1531
1580
|
builder.addCase(socketReconnecting, (state) => {
|
|
1532
|
-
return Object.assign(Object.assign({}, state), { status: "
|
|
1581
|
+
return Object.assign(Object.assign({}, state), { status: "reconnecting" });
|
|
1533
1582
|
});
|
|
1534
1583
|
},
|
|
1535
1584
|
});
|
|
@@ -1590,16 +1639,18 @@ const selectRoomConnectionSessionId = (state) => { var _a; return (_a = state.ro
|
|
|
1590
1639
|
const selectRoomConnectionStatus = (state) => state.roomConnection.status;
|
|
1591
1640
|
const selectRoomConnectionError = (state) => state.roomConnection.error;
|
|
1592
1641
|
const selectShouldConnectRoom = createSelector([
|
|
1642
|
+
selectAppIsActive,
|
|
1593
1643
|
selectOrganizationId,
|
|
1594
1644
|
selectRoomConnectionStatus,
|
|
1595
1645
|
selectSignalConnectionDeviceIdentified,
|
|
1596
1646
|
selectLocalMediaStatus,
|
|
1597
1647
|
selectAppIsNodeSdk,
|
|
1598
|
-
], (hasOrganizationIdFetched, roomConnectionStatus, signalConnectionDeviceIdentified, localMediaStatus, isNodeSdk) => {
|
|
1599
|
-
if (
|
|
1648
|
+
], (appIsActive, hasOrganizationIdFetched, roomConnectionStatus, signalConnectionDeviceIdentified, localMediaStatus, isNodeSdk) => {
|
|
1649
|
+
if (appIsActive &&
|
|
1650
|
+
(localMediaStatus === "started" || isNodeSdk) &&
|
|
1600
1651
|
signalConnectionDeviceIdentified &&
|
|
1601
1652
|
!!hasOrganizationIdFetched &&
|
|
1602
|
-
["
|
|
1653
|
+
["ready", "reconnecting", "disconnected"].includes(roomConnectionStatus)) {
|
|
1603
1654
|
return true;
|
|
1604
1655
|
}
|
|
1605
1656
|
return false;
|
|
@@ -1627,6 +1678,21 @@ startAppListening({
|
|
|
1627
1678
|
}
|
|
1628
1679
|
},
|
|
1629
1680
|
});
|
|
1681
|
+
startAppListening({
|
|
1682
|
+
actionCreator: doAppStop,
|
|
1683
|
+
effect: (_, { dispatch, getState }) => {
|
|
1684
|
+
const state = getState();
|
|
1685
|
+
const roomConnectionStatus = selectRoomConnectionStatus(state);
|
|
1686
|
+
if (roomConnectionStatus === "connected") {
|
|
1687
|
+
const socket = selectSignalConnectionRaw(state).socket;
|
|
1688
|
+
socket === null || socket === void 0 ? void 0 : socket.emit("leave_room");
|
|
1689
|
+
dispatch(connectionStatusChanged("leaving"));
|
|
1690
|
+
}
|
|
1691
|
+
else {
|
|
1692
|
+
doSignalDisconnect();
|
|
1693
|
+
}
|
|
1694
|
+
},
|
|
1695
|
+
});
|
|
1630
1696
|
|
|
1631
1697
|
const createWebRtcEmitter = (dispatch) => {
|
|
1632
1698
|
return {
|
|
@@ -1652,7 +1718,7 @@ const initialState$3 = {
|
|
|
1652
1718
|
rtcManager: null,
|
|
1653
1719
|
rtcManagerDispatcher: null,
|
|
1654
1720
|
rtcManagerInitialized: false,
|
|
1655
|
-
status: "",
|
|
1721
|
+
status: "inactive",
|
|
1656
1722
|
isAcceptingStreams: false,
|
|
1657
1723
|
};
|
|
1658
1724
|
const rtcConnectionSlice = createSlice({
|
|
@@ -1684,10 +1750,10 @@ const rtcConnectionSlice = createSlice({
|
|
|
1684
1750
|
},
|
|
1685
1751
|
extraReducers: (builder) => {
|
|
1686
1752
|
builder.addCase(socketReconnecting, (state) => {
|
|
1687
|
-
return Object.assign(Object.assign({}, state), { status: "
|
|
1753
|
+
return Object.assign(Object.assign({}, state), { status: "reconnecting" });
|
|
1688
1754
|
});
|
|
1689
1755
|
builder.addCase(signalEvents.roomJoined, (state) => {
|
|
1690
|
-
return Object.assign(Object.assign({}, state), { status: state.status === "
|
|
1756
|
+
return Object.assign(Object.assign({}, state), { status: state.status === "reconnecting" ? "ready" : state.status });
|
|
1691
1757
|
});
|
|
1692
1758
|
},
|
|
1693
1759
|
});
|
|
@@ -1877,8 +1943,8 @@ createReactor([selectShouldInitializeRtc], ({ dispatch }, shouldInitializeRtc) =
|
|
|
1877
1943
|
dispatch(doRtcManagerInitialize());
|
|
1878
1944
|
}
|
|
1879
1945
|
});
|
|
1880
|
-
const selectShouldDisconnectRtc = createSelector(selectRtcStatus,
|
|
1881
|
-
if (!
|
|
1946
|
+
const selectShouldDisconnectRtc = createSelector(selectRtcStatus, selectAppIsActive, (status, appIsActive) => {
|
|
1947
|
+
if (!appIsActive && !["inactive", "disconnected"].includes(status)) {
|
|
1882
1948
|
return true;
|
|
1883
1949
|
}
|
|
1884
1950
|
return false;
|
|
@@ -2171,7 +2237,7 @@ const selectWaitingParticipants = (state) => state.waitingParticipants.waitingPa
|
|
|
2171
2237
|
|
|
2172
2238
|
var _a;
|
|
2173
2239
|
const IS_DEV = (_a = undefined === "true") !== null && _a !== void 0 ? _a : false;
|
|
2174
|
-
const
|
|
2240
|
+
const appReducer = combineReducers({
|
|
2175
2241
|
app: appSlice.reducer,
|
|
2176
2242
|
authorization: authorizationSlice.reducer,
|
|
2177
2243
|
chat: chatSlice.reducer,
|
|
@@ -2190,6 +2256,17 @@ const rootReducer = combineReducers({
|
|
|
2190
2256
|
streaming: streamingSlice.reducer,
|
|
2191
2257
|
waitingParticipants: waitingParticipantsSlice.reducer,
|
|
2192
2258
|
});
|
|
2259
|
+
const rootReducer = (state, action) => {
|
|
2260
|
+
var _a;
|
|
2261
|
+
if (doAppReset.match(action)) {
|
|
2262
|
+
const resetState = {
|
|
2263
|
+
app: Object.assign(Object.assign({}, appSlice.getInitialState()), { initialConfig: (_a = state === null || state === void 0 ? void 0 : state.app) === null || _a === void 0 ? void 0 : _a.initialConfig }),
|
|
2264
|
+
localMedia: Object.assign(Object.assign({}, localMediaSlice.getInitialState()), state === null || state === void 0 ? void 0 : state.localMedia),
|
|
2265
|
+
};
|
|
2266
|
+
return appReducer(resetState, action);
|
|
2267
|
+
}
|
|
2268
|
+
return appReducer(state, action);
|
|
2269
|
+
};
|
|
2193
2270
|
const createStore = ({ preloadedState, injectServices, }) => {
|
|
2194
2271
|
return configureStore({
|
|
2195
2272
|
devTools: IS_DEV,
|
|
@@ -3224,4 +3301,4 @@ function createServices() {
|
|
|
3224
3301
|
};
|
|
3225
3302
|
}
|
|
3226
3303
|
|
|
3227
|
-
export { ApiClient, Credentials, CredentialsService, LocalParticipant, OrganizationApiClient, OrganizationService, OrganizationServiceCache, RoomService, addAppListener,
|
|
3304
|
+
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, doAppConfigure, doAppReset, doAppStart, doAppStop, doConnectRoom, doConnectRtc, doDisconnectRtc, doEnableAudio, doEnableVideo, doEndMeeting, doGetDeviceCredentials, doHandleAcceptStreams, doHandleStreamingStarted, doHandleStreamingStopped, doKickParticipant, doKnockRoom, doLockRoom, doOrganizationFetch, doRejectWaitingParticipant, doRequestAudioEnable, doRtcAnalyticsCustomEventsInitialize, doRtcManagerCreated, doRtcManagerInitialize, doRtcReportStreamResolution, doSendChatMessage, doSetDevice, doSetDisplayName, doSetLocalParticipant, doSignalConnect, doSignalDisconnect, doSignalIdentifyDevice, doStartCloudRecording, doStartLocalMedia, doStartScreenshare, doStopCloudRecording, doStopLocalMedia, doStopScreenshare, doSwitchLocalStream, doToggleCamera, doToggleLowDataMode, doUpdateDeviceList, getAudioTrack, getFakeMediaStream, getVideoTrack, initialCloudRecordingState, initialLocalMediaState, isAcceptingStreams, listenerMiddleware, localMediaSlice, localMediaStopped, localParticipantSlice, localScreenshareSlice, localStreamMetadataUpdated, observeStore, organizationSlice, parseRoomUrlAndSubdomain, parseUnverifiedRoomKeyData, participantStreamAdded, participantStreamIdAdded, recordingRequestStarted, remoteParticipantsSlice, resolutionReported, roomConnectionSlice, roomSlice, rootReducer, rtcAnalyticsCustomEvents, rtcAnalyticsSlice, rtcConnectionSlice, rtcDisconnected, rtcDispatcherCreated, rtcManagerCreated, rtcManagerDestroyed, rtcManagerInitialized, selectAppDisplayName, selectAppExternalId, selectAppInitialConfig, selectAppIsActive, selectAppIsLoaded, selectAppIsNodeSdk, selectAppRaw, selectAppRoomName, selectAppRoomUrl, selectAppUserAgent, selectAuthorizationRoleName, selectBusyDeviceIds, selectCameraDeviceError, selectCameraDevices, selectChatMessages, selectChatRaw, selectCloudRecordingError, selectCloudRecordingRaw, selectCloudRecordingStartedAt, selectCloudRecordingStatus, selectCurrentCameraDeviceId, selectCurrentMicrophoneDeviceId, selectDeviceCredentialsRaw, selectDeviceId, selectHasFetchedDeviceCredentials, selectIsAcceptingStreams, selectIsAuthorizedToEndMeeting, selectIsAuthorizedToKickClient, selectIsAuthorizedToLockRoom, selectIsAuthorizedToRequestAudioEnable, selectIsCameraEnabled, selectIsCloudRecording, selectIsLocalMediaStarting, selectIsLowDataModeEnabled, selectIsMicrophoneEnabled, selectIsSettingCameraDevice, selectIsSettingMicrophoneDevice, selectIsToggleCamera, selectLocalMediaConstraintsOptions, selectLocalMediaDevices, selectLocalMediaIsSwitchingStream, selectLocalMediaOptions, selectLocalMediaOwnsStream, selectLocalMediaRaw, selectLocalMediaShouldStartWithOptions, selectLocalMediaShouldStop, selectLocalMediaStartError, selectLocalMediaStatus, selectLocalMediaStream, selectLocalParticipantClientClaim, selectLocalParticipantIsScreenSharing, selectLocalParticipantRaw, selectLocalScreenshareRaw, selectLocalScreenshareStatus, selectLocalScreenshareStream, selectMicrophoneDeviceError, selectMicrophoneDevices, selectOrganizationId, selectOrganizationRaw, 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, selectShouldReloadApp, 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, toggleLowDataModeEnabled, toggleMicrophoneEnabled, updateReportedValues, waitingParticipantsSlice };
|
package/package.json
CHANGED