@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.cjs
CHANGED
|
@@ -45,39 +45,61 @@ const createReactor = (selectors, callback) => {
|
|
|
45
45
|
});
|
|
46
46
|
};
|
|
47
47
|
|
|
48
|
-
const coreVersion = "0.
|
|
48
|
+
const coreVersion = "0.14.0";
|
|
49
49
|
|
|
50
50
|
const initialState$e = {
|
|
51
51
|
isNodeSdk: false,
|
|
52
|
-
|
|
52
|
+
isActive: false,
|
|
53
53
|
roomName: null,
|
|
54
54
|
roomUrl: null,
|
|
55
55
|
displayName: null,
|
|
56
56
|
userAgent: `core:${coreVersion}`,
|
|
57
57
|
externalId: null,
|
|
58
|
+
isLoaded: false,
|
|
58
59
|
};
|
|
59
60
|
const appSlice = toolkit.createSlice({
|
|
60
61
|
name: "app",
|
|
61
62
|
initialState: initialState$e,
|
|
62
63
|
reducers: {
|
|
63
|
-
|
|
64
|
+
doAppConfigure: (state, action) => {
|
|
64
65
|
const url = new URL(action.payload.roomUrl);
|
|
65
|
-
return Object.assign(Object.assign(Object.assign({}, state), action.payload), { roomName: url.pathname,
|
|
66
|
+
return Object.assign(Object.assign(Object.assign({}, state), action.payload), { roomName: url.pathname, initialConfig: Object.assign({}, action.payload), isLoaded: true });
|
|
66
67
|
},
|
|
67
|
-
|
|
68
|
-
return Object.assign(Object.assign({}, state), {
|
|
68
|
+
doAppStart: (state) => {
|
|
69
|
+
return Object.assign(Object.assign({}, state), { isActive: true });
|
|
70
|
+
},
|
|
71
|
+
doAppStop: (state) => {
|
|
72
|
+
return Object.assign(Object.assign({}, state), { isActive: false });
|
|
73
|
+
},
|
|
74
|
+
doAppReset: (state) => {
|
|
75
|
+
return Object.assign(Object.assign({}, state), { isLoaded: false });
|
|
69
76
|
},
|
|
70
77
|
},
|
|
71
78
|
});
|
|
72
|
-
const {
|
|
79
|
+
const { doAppConfigure, doAppStop, doAppReset, doAppStart } = appSlice.actions;
|
|
73
80
|
const selectAppRaw = (state) => state.app;
|
|
74
|
-
const
|
|
81
|
+
const selectAppIsActive = (state) => state.app.isActive;
|
|
75
82
|
const selectAppRoomName = (state) => state.app.roomName;
|
|
76
83
|
const selectAppRoomUrl = (state) => state.app.roomUrl;
|
|
77
84
|
const selectAppDisplayName = (state) => state.app.displayName;
|
|
78
85
|
const selectAppUserAgent = (state) => state.app.userAgent;
|
|
79
86
|
const selectAppExternalId = (state) => state.app.externalId;
|
|
80
87
|
const selectAppIsNodeSdk = (state) => state.app.isNodeSdk;
|
|
88
|
+
const selectAppInitialConfig = (state) => state.app.initialConfig;
|
|
89
|
+
const selectAppIsLoaded = (state) => state.app.isLoaded;
|
|
90
|
+
const selectShouldReloadApp = toolkit.createSelector(selectAppIsLoaded, selectAppInitialConfig, (appIsLoaded, appInitialConfig) => {
|
|
91
|
+
return !appIsLoaded && appInitialConfig;
|
|
92
|
+
});
|
|
93
|
+
startAppListening({
|
|
94
|
+
actionCreator: doAppReset,
|
|
95
|
+
effect: (_, { dispatch, getState }) => {
|
|
96
|
+
const state = getState();
|
|
97
|
+
const appInitialConfig = selectAppInitialConfig(state);
|
|
98
|
+
if (appInitialConfig) {
|
|
99
|
+
dispatch(doAppConfigure(appInitialConfig));
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
});
|
|
81
103
|
|
|
82
104
|
function createSignalEventAction(name) {
|
|
83
105
|
return toolkit.createAction(`signalConnection/event/${name}`);
|
|
@@ -97,6 +119,7 @@ const signalEvents = {
|
|
|
97
119
|
newClient: createSignalEventAction("newClient"),
|
|
98
120
|
roomJoined: createSignalEventAction("roomJoined"),
|
|
99
121
|
roomKnocked: createSignalEventAction("roomKnocked"),
|
|
122
|
+
roomLeft: createSignalEventAction("roomLeft"),
|
|
100
123
|
roomLocked: createSignalEventAction("roomLocked"),
|
|
101
124
|
roomSessionEnded: createSignalEventAction("roomSessionEnded"),
|
|
102
125
|
screenshareStarted: createSignalEventAction("screenshareStarted"),
|
|
@@ -124,7 +147,7 @@ const authorizationSlice = toolkit.createSlice({
|
|
|
124
147
|
},
|
|
125
148
|
},
|
|
126
149
|
extraReducers: (builder) => {
|
|
127
|
-
builder.addCase(
|
|
150
|
+
builder.addCase(doAppConfigure, (state, action) => {
|
|
128
151
|
return Object.assign(Object.assign({}, state), { roomKey: action.payload.roomKey });
|
|
129
152
|
});
|
|
130
153
|
builder.addCase(signalEvents.roomJoined, (state, action) => {
|
|
@@ -218,8 +241,8 @@ const doGetDeviceCredentials = createAppAsyncThunk("deviceCredentials/doGetDevic
|
|
|
218
241
|
const selectDeviceCredentialsRaw = (state) => state.deviceCredentials;
|
|
219
242
|
const selectHasFetchedDeviceCredentials = (state) => { var _a; return !!((_a = state.deviceCredentials.data) === null || _a === void 0 ? void 0 : _a.credentials); };
|
|
220
243
|
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; };
|
|
221
|
-
const selectShouldFetchDeviceCredentials = toolkit.createSelector(
|
|
222
|
-
if (
|
|
244
|
+
const selectShouldFetchDeviceCredentials = toolkit.createSelector(selectAppIsActive, selectDeviceCredentialsRaw, (appIsActive, deviceCredentials) => {
|
|
245
|
+
if (appIsActive && !deviceCredentials.isFetching && !deviceCredentials.data) {
|
|
223
246
|
return true;
|
|
224
247
|
}
|
|
225
248
|
return false;
|
|
@@ -242,6 +265,7 @@ function forwardSocketEvents(socket, dispatch) {
|
|
|
242
265
|
socket.on("chat_message", (payload) => dispatch(signalEvents.chatMessage(payload)));
|
|
243
266
|
socket.on("disconnect", () => dispatch(signalEvents.disconnect()));
|
|
244
267
|
socket.on("room_knocked", (payload) => dispatch(signalEvents.roomKnocked(payload)));
|
|
268
|
+
socket.on("room_left", () => dispatch(signalEvents.roomLeft()));
|
|
245
269
|
socket.on("room_locked", (payload) => dispatch(signalEvents.roomLocked(payload)));
|
|
246
270
|
socket.on("room_session_ended", (payload) => dispatch(signalEvents.roomSessionEnded(payload)));
|
|
247
271
|
socket.on("knocker_left", (payload) => dispatch(signalEvents.knockerLeft(payload)));
|
|
@@ -264,7 +288,7 @@ function createSocket() {
|
|
|
264
288
|
const initialState$b = {
|
|
265
289
|
deviceIdentified: false,
|
|
266
290
|
isIdentifyingDevice: false,
|
|
267
|
-
status: "",
|
|
291
|
+
status: "ready",
|
|
268
292
|
socket: null,
|
|
269
293
|
};
|
|
270
294
|
const signalConnectionSlice = toolkit.createSlice({
|
|
@@ -281,7 +305,7 @@ const signalConnectionSlice = toolkit.createSlice({
|
|
|
281
305
|
return Object.assign(Object.assign({}, state), { deviceIdentified: false, status: "disconnected" });
|
|
282
306
|
},
|
|
283
307
|
socketReconnecting: (state) => {
|
|
284
|
-
return Object.assign(Object.assign({}, state), { status: "
|
|
308
|
+
return Object.assign(Object.assign({}, state), { status: "reconnecting" });
|
|
285
309
|
},
|
|
286
310
|
deviceIdentifying: (state) => {
|
|
287
311
|
return Object.assign(Object.assign({}, state), { isIdentifyingDevice: true });
|
|
@@ -297,7 +321,7 @@ const signalConnectionSlice = toolkit.createSlice({
|
|
|
297
321
|
},
|
|
298
322
|
});
|
|
299
323
|
const { deviceIdentifying, deviceIdentified, socketConnected, socketConnecting, socketDisconnected, socketReconnecting, } = signalConnectionSlice.actions;
|
|
300
|
-
const
|
|
324
|
+
const doSignalConnect = createAppThunk(() => {
|
|
301
325
|
return (dispatch, getState) => {
|
|
302
326
|
if (selectSignalConnectionSocket(getState())) {
|
|
303
327
|
return;
|
|
@@ -325,31 +349,31 @@ const doSignalIdentifyDevice = createAppThunk(({ deviceCredentials }) => (dispat
|
|
|
325
349
|
dispatch(deviceIdentifying());
|
|
326
350
|
});
|
|
327
351
|
const doSignalDisconnect = createAppThunk(() => (dispatch, getState) => {
|
|
328
|
-
const
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
352
|
+
const state = getState();
|
|
353
|
+
const signalStatus = selectSignalStatus(state);
|
|
354
|
+
if (signalStatus === "connected") {
|
|
355
|
+
const socket = selectSignalConnectionRaw(state).socket;
|
|
356
|
+
socket === null || socket === void 0 ? void 0 : socket.disconnect();
|
|
357
|
+
dispatch(socketDisconnected());
|
|
358
|
+
}
|
|
359
|
+
else {
|
|
360
|
+
doAppReset();
|
|
361
|
+
}
|
|
332
362
|
});
|
|
333
363
|
const selectSignalConnectionRaw = (state) => state.signalConnection;
|
|
334
364
|
const selectSignalIsIdentifyingDevice = (state) => state.signalConnection.isIdentifyingDevice;
|
|
335
365
|
const selectSignalConnectionDeviceIdentified = (state) => state.signalConnection.deviceIdentified;
|
|
336
366
|
const selectSignalStatus = (state) => state.signalConnection.status;
|
|
337
367
|
const selectSignalConnectionSocket = (state) => state.signalConnection.socket;
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
effect: (_, { dispatch }) => {
|
|
341
|
-
dispatch(doSignalDisconnect());
|
|
342
|
-
},
|
|
343
|
-
});
|
|
344
|
-
const selectShouldConnectSignal = toolkit.createSelector(selectAppWantsToJoin, selectSignalStatus, (wantsToJoin, signalStatus) => {
|
|
345
|
-
if (wantsToJoin && ["", "reconnect"].includes(signalStatus)) {
|
|
368
|
+
const selectShouldConnectSignal = toolkit.createSelector(selectAppIsActive, selectSignalStatus, (appIsActive, signalStatus) => {
|
|
369
|
+
if (appIsActive && ["ready", "reconnecting"].includes(signalStatus)) {
|
|
346
370
|
return true;
|
|
347
371
|
}
|
|
348
372
|
return false;
|
|
349
373
|
});
|
|
350
374
|
createReactor([selectShouldConnectSignal], ({ dispatch }, shouldConnectSignal) => {
|
|
351
375
|
if (shouldConnectSignal) {
|
|
352
|
-
dispatch(
|
|
376
|
+
dispatch(doSignalConnect());
|
|
353
377
|
}
|
|
354
378
|
});
|
|
355
379
|
const selectShouldIdentifyDevice = toolkit.createSelector(selectDeviceCredentialsRaw, selectSignalStatus, selectSignalConnectionDeviceIdentified, selectSignalIsIdentifyingDevice, (deviceCredentialsRaw, signalStatus, deviceIdentified, isIdentifyingDevice) => {
|
|
@@ -363,6 +387,24 @@ createReactor([selectShouldIdentifyDevice, selectDeviceCredentialsRaw], ({ dispa
|
|
|
363
387
|
dispatch(doSignalIdentifyDevice({ deviceCredentials: deviceCredentialsRaw.data }));
|
|
364
388
|
}
|
|
365
389
|
});
|
|
390
|
+
startAppListening({
|
|
391
|
+
actionCreator: signalEvents.roomLeft,
|
|
392
|
+
effect: (_, { dispatch }) => {
|
|
393
|
+
dispatch(doSignalDisconnect());
|
|
394
|
+
},
|
|
395
|
+
});
|
|
396
|
+
startAppListening({
|
|
397
|
+
actionCreator: signalEvents.clientKicked,
|
|
398
|
+
effect: (_, { dispatch }) => {
|
|
399
|
+
dispatch(doSignalDisconnect());
|
|
400
|
+
},
|
|
401
|
+
});
|
|
402
|
+
startAppListening({
|
|
403
|
+
actionCreator: socketDisconnected,
|
|
404
|
+
effect: (_, { dispatch }) => {
|
|
405
|
+
dispatch(doAppReset());
|
|
406
|
+
},
|
|
407
|
+
});
|
|
366
408
|
|
|
367
409
|
const initialState$a = {
|
|
368
410
|
chatMessages: [],
|
|
@@ -587,7 +629,8 @@ const initialLocalMediaState = {
|
|
|
587
629
|
isTogglingCamera: false,
|
|
588
630
|
lowDataMode: false,
|
|
589
631
|
microphoneEnabled: false,
|
|
590
|
-
status: "",
|
|
632
|
+
status: "inactive",
|
|
633
|
+
stream: undefined,
|
|
591
634
|
isSwitchingStream: false,
|
|
592
635
|
};
|
|
593
636
|
const localMediaSlice = toolkit.createSlice({
|
|
@@ -636,7 +679,7 @@ const localMediaSlice = toolkit.createSlice({
|
|
|
636
679
|
},
|
|
637
680
|
},
|
|
638
681
|
extraReducers: (builder) => {
|
|
639
|
-
builder.addCase(
|
|
682
|
+
builder.addCase(doAppConfigure, (state, action) => {
|
|
640
683
|
return Object.assign(Object.assign({}, state), { options: action.payload.localMediaOptions });
|
|
641
684
|
});
|
|
642
685
|
builder.addCase(doSetDevice.pending, (state, action) => {
|
|
@@ -919,8 +962,8 @@ const selectIsLocalMediaStarting = toolkit.createSelector(selectLocalMediaStatus
|
|
|
919
962
|
const selectCameraDevices = toolkit.createSelector(selectLocalMediaDevices, selectBusyDeviceIds, (devices, busyDeviceIds) => devices.filter((d) => d.kind === "videoinput").filter((d) => !busyDeviceIds.includes(d.deviceId)));
|
|
920
963
|
const selectMicrophoneDevices = toolkit.createSelector(selectLocalMediaDevices, selectBusyDeviceIds, (devices, busyDeviceIds) => devices.filter((d) => d.kind === "audioinput").filter((d) => !busyDeviceIds.includes(d.deviceId)));
|
|
921
964
|
const selectSpeakerDevices = toolkit.createSelector(selectLocalMediaDevices, (devices) => devices.filter((d) => d.kind === "audiooutput"));
|
|
922
|
-
const selectLocalMediaShouldStartWithOptions = toolkit.createSelector(
|
|
923
|
-
if (
|
|
965
|
+
const selectLocalMediaShouldStartWithOptions = toolkit.createSelector(selectAppIsActive, selectLocalMediaStatus, selectLocalMediaOptions, selectAppIsNodeSdk, (appIsActive, localMediaStatus, localMediaOptions, isNodeSdk) => {
|
|
966
|
+
if (appIsActive && ["inactive", "stopped"].includes(localMediaStatus) && !isNodeSdk && localMediaOptions) {
|
|
924
967
|
return localMediaOptions;
|
|
925
968
|
}
|
|
926
969
|
});
|
|
@@ -929,8 +972,8 @@ createReactor([selectLocalMediaShouldStartWithOptions], ({ dispatch }, options)
|
|
|
929
972
|
dispatch(doStartLocalMedia(options));
|
|
930
973
|
}
|
|
931
974
|
});
|
|
932
|
-
const selectLocalMediaShouldStop = toolkit.createSelector(
|
|
933
|
-
return !
|
|
975
|
+
const selectLocalMediaShouldStop = toolkit.createSelector(selectAppIsActive, selectLocalMediaStatus, selectLocalMediaOptions, (appIsActive, localMediaStatus, localMediaOptions) => {
|
|
976
|
+
return !appIsActive && localMediaStatus !== "inactive" && !!localMediaOptions;
|
|
934
977
|
});
|
|
935
978
|
createReactor([selectLocalMediaShouldStop], ({ dispatch }, localMediaShouldStop) => {
|
|
936
979
|
if (localMediaShouldStop) {
|
|
@@ -1063,7 +1106,7 @@ const localParticipantSlice = toolkit.createSlice({
|
|
|
1063
1106
|
},
|
|
1064
1107
|
},
|
|
1065
1108
|
extraReducers: (builder) => {
|
|
1066
|
-
builder.addCase(
|
|
1109
|
+
builder.addCase(doAppConfigure, (state, action) => {
|
|
1067
1110
|
return Object.assign(Object.assign({}, state), { displayName: action.payload.displayName });
|
|
1068
1111
|
});
|
|
1069
1112
|
builder.addCase(doEnableAudio.fulfilled, (state, action) => {
|
|
@@ -1105,7 +1148,7 @@ startAppListening({
|
|
|
1105
1148
|
});
|
|
1106
1149
|
|
|
1107
1150
|
const initialState$8 = {
|
|
1108
|
-
status: "",
|
|
1151
|
+
status: "inactive",
|
|
1109
1152
|
stream: null,
|
|
1110
1153
|
error: null,
|
|
1111
1154
|
};
|
|
@@ -1114,7 +1157,7 @@ const localScreenshareSlice = toolkit.createSlice({
|
|
|
1114
1157
|
initialState: initialState$8,
|
|
1115
1158
|
reducers: {
|
|
1116
1159
|
stopScreenshare(state, action) {
|
|
1117
|
-
return Object.assign(Object.assign({}, state), { status: "", stream: null });
|
|
1160
|
+
return Object.assign(Object.assign({}, state), { status: "inactive", stream: null });
|
|
1118
1161
|
},
|
|
1119
1162
|
},
|
|
1120
1163
|
extraReducers: (builder) => {
|
|
@@ -1125,7 +1168,7 @@ const localScreenshareSlice = toolkit.createSlice({
|
|
|
1125
1168
|
return Object.assign(Object.assign({}, state), { status: "active", stream });
|
|
1126
1169
|
});
|
|
1127
1170
|
builder.addCase(doStartScreenshare.rejected, (state, { payload }) => {
|
|
1128
|
-
return Object.assign(Object.assign({}, state), { error: payload, status: "", stream: null });
|
|
1171
|
+
return Object.assign(Object.assign({}, state), { error: payload, status: "inactive", stream: null });
|
|
1129
1172
|
});
|
|
1130
1173
|
},
|
|
1131
1174
|
});
|
|
@@ -1218,8 +1261,8 @@ const doOrganizationFetch = createAppAsyncThunk("organization/doOrganizationFetc
|
|
|
1218
1261
|
}));
|
|
1219
1262
|
const selectOrganizationRaw = (state) => state.organization;
|
|
1220
1263
|
const selectOrganizationId = (state) => { var _a; return (_a = state.organization.data) === null || _a === void 0 ? void 0 : _a.organizationId; };
|
|
1221
|
-
const selectShouldFetchOrganization = toolkit.createSelector(
|
|
1222
|
-
if (
|
|
1264
|
+
const selectShouldFetchOrganization = toolkit.createSelector(selectAppIsActive, selectOrganizationRaw, selectDeviceCredentialsRaw, (appIsActive, organization, deviceCredentials) => {
|
|
1265
|
+
if (appIsActive &&
|
|
1223
1266
|
!organization.data &&
|
|
1224
1267
|
!organization.isFetching &&
|
|
1225
1268
|
!organization.error &&
|
|
@@ -1478,19 +1521,22 @@ const doKickParticipant = createAppAuthorizedThunk((state) => selectIsAuthorized
|
|
|
1478
1521
|
const { socket } = selectSignalConnectionRaw(state);
|
|
1479
1522
|
socket === null || socket === void 0 ? void 0 : socket.emit("kick_client", { clientId: payload.clientId, reasonId: "kick" });
|
|
1480
1523
|
});
|
|
1481
|
-
const doEndMeeting = createAppAuthorizedThunk((state) => selectIsAuthorizedToEndMeeting(state), () => (
|
|
1524
|
+
const doEndMeeting = createAppAuthorizedThunk((state) => selectIsAuthorizedToEndMeeting(state), (payload) => (dispatch, getState) => {
|
|
1482
1525
|
const state = getState();
|
|
1483
1526
|
const clientsToKick = selectRemoteParticipants(state).map((c) => c.id);
|
|
1484
1527
|
if (clientsToKick.length) {
|
|
1485
1528
|
const { socket } = selectSignalConnectionRaw(state);
|
|
1486
1529
|
socket === null || socket === void 0 ? void 0 : socket.emit("kick_client", { clientIds: clientsToKick, reasonId: "end-meeting" });
|
|
1487
1530
|
}
|
|
1531
|
+
if (!payload.stayBehind) {
|
|
1532
|
+
dispatch(doAppStop());
|
|
1533
|
+
}
|
|
1488
1534
|
});
|
|
1489
1535
|
const selectRoomIsLocked = (state) => state.room.isLocked;
|
|
1490
1536
|
|
|
1491
1537
|
const initialState$4 = {
|
|
1492
1538
|
session: null,
|
|
1493
|
-
status: "
|
|
1539
|
+
status: "ready",
|
|
1494
1540
|
error: null,
|
|
1495
1541
|
};
|
|
1496
1542
|
const roomConnectionSlice = toolkit.createSlice({
|
|
@@ -1530,8 +1576,11 @@ const roomConnectionSlice = toolkit.createSlice({
|
|
|
1530
1576
|
builder.addCase(signalEvents.clientKicked, (state) => {
|
|
1531
1577
|
return Object.assign(Object.assign({}, state), { status: "kicked" });
|
|
1532
1578
|
});
|
|
1579
|
+
builder.addCase(signalEvents.roomLeft, (state) => {
|
|
1580
|
+
return Object.assign(Object.assign({}, state), { status: "left" });
|
|
1581
|
+
});
|
|
1533
1582
|
builder.addCase(socketReconnecting, (state) => {
|
|
1534
|
-
return Object.assign(Object.assign({}, state), { status: "
|
|
1583
|
+
return Object.assign(Object.assign({}, state), { status: "reconnecting" });
|
|
1535
1584
|
});
|
|
1536
1585
|
},
|
|
1537
1586
|
});
|
|
@@ -1592,16 +1641,18 @@ const selectRoomConnectionSessionId = (state) => { var _a; return (_a = state.ro
|
|
|
1592
1641
|
const selectRoomConnectionStatus = (state) => state.roomConnection.status;
|
|
1593
1642
|
const selectRoomConnectionError = (state) => state.roomConnection.error;
|
|
1594
1643
|
const selectShouldConnectRoom = toolkit.createSelector([
|
|
1644
|
+
selectAppIsActive,
|
|
1595
1645
|
selectOrganizationId,
|
|
1596
1646
|
selectRoomConnectionStatus,
|
|
1597
1647
|
selectSignalConnectionDeviceIdentified,
|
|
1598
1648
|
selectLocalMediaStatus,
|
|
1599
1649
|
selectAppIsNodeSdk,
|
|
1600
|
-
], (hasOrganizationIdFetched, roomConnectionStatus, signalConnectionDeviceIdentified, localMediaStatus, isNodeSdk) => {
|
|
1601
|
-
if (
|
|
1650
|
+
], (appIsActive, hasOrganizationIdFetched, roomConnectionStatus, signalConnectionDeviceIdentified, localMediaStatus, isNodeSdk) => {
|
|
1651
|
+
if (appIsActive &&
|
|
1652
|
+
(localMediaStatus === "started" || isNodeSdk) &&
|
|
1602
1653
|
signalConnectionDeviceIdentified &&
|
|
1603
1654
|
!!hasOrganizationIdFetched &&
|
|
1604
|
-
["
|
|
1655
|
+
["ready", "reconnecting", "disconnected"].includes(roomConnectionStatus)) {
|
|
1605
1656
|
return true;
|
|
1606
1657
|
}
|
|
1607
1658
|
return false;
|
|
@@ -1629,6 +1680,21 @@ startAppListening({
|
|
|
1629
1680
|
}
|
|
1630
1681
|
},
|
|
1631
1682
|
});
|
|
1683
|
+
startAppListening({
|
|
1684
|
+
actionCreator: doAppStop,
|
|
1685
|
+
effect: (_, { dispatch, getState }) => {
|
|
1686
|
+
const state = getState();
|
|
1687
|
+
const roomConnectionStatus = selectRoomConnectionStatus(state);
|
|
1688
|
+
if (roomConnectionStatus === "connected") {
|
|
1689
|
+
const socket = selectSignalConnectionRaw(state).socket;
|
|
1690
|
+
socket === null || socket === void 0 ? void 0 : socket.emit("leave_room");
|
|
1691
|
+
dispatch(connectionStatusChanged("leaving"));
|
|
1692
|
+
}
|
|
1693
|
+
else {
|
|
1694
|
+
doSignalDisconnect();
|
|
1695
|
+
}
|
|
1696
|
+
},
|
|
1697
|
+
});
|
|
1632
1698
|
|
|
1633
1699
|
const createWebRtcEmitter = (dispatch) => {
|
|
1634
1700
|
return {
|
|
@@ -1654,7 +1720,7 @@ const initialState$3 = {
|
|
|
1654
1720
|
rtcManager: null,
|
|
1655
1721
|
rtcManagerDispatcher: null,
|
|
1656
1722
|
rtcManagerInitialized: false,
|
|
1657
|
-
status: "",
|
|
1723
|
+
status: "inactive",
|
|
1658
1724
|
isAcceptingStreams: false,
|
|
1659
1725
|
};
|
|
1660
1726
|
const rtcConnectionSlice = toolkit.createSlice({
|
|
@@ -1686,10 +1752,10 @@ const rtcConnectionSlice = toolkit.createSlice({
|
|
|
1686
1752
|
},
|
|
1687
1753
|
extraReducers: (builder) => {
|
|
1688
1754
|
builder.addCase(socketReconnecting, (state) => {
|
|
1689
|
-
return Object.assign(Object.assign({}, state), { status: "
|
|
1755
|
+
return Object.assign(Object.assign({}, state), { status: "reconnecting" });
|
|
1690
1756
|
});
|
|
1691
1757
|
builder.addCase(signalEvents.roomJoined, (state) => {
|
|
1692
|
-
return Object.assign(Object.assign({}, state), { status: state.status === "
|
|
1758
|
+
return Object.assign(Object.assign({}, state), { status: state.status === "reconnecting" ? "ready" : state.status });
|
|
1693
1759
|
});
|
|
1694
1760
|
},
|
|
1695
1761
|
});
|
|
@@ -1879,8 +1945,8 @@ createReactor([selectShouldInitializeRtc], ({ dispatch }, shouldInitializeRtc) =
|
|
|
1879
1945
|
dispatch(doRtcManagerInitialize());
|
|
1880
1946
|
}
|
|
1881
1947
|
});
|
|
1882
|
-
const selectShouldDisconnectRtc = toolkit.createSelector(selectRtcStatus,
|
|
1883
|
-
if (!
|
|
1948
|
+
const selectShouldDisconnectRtc = toolkit.createSelector(selectRtcStatus, selectAppIsActive, (status, appIsActive) => {
|
|
1949
|
+
if (!appIsActive && !["inactive", "disconnected"].includes(status)) {
|
|
1884
1950
|
return true;
|
|
1885
1951
|
}
|
|
1886
1952
|
return false;
|
|
@@ -2173,7 +2239,7 @@ const selectWaitingParticipants = (state) => state.waitingParticipants.waitingPa
|
|
|
2173
2239
|
|
|
2174
2240
|
var _a;
|
|
2175
2241
|
const IS_DEV = (_a = undefined === "true") !== null && _a !== void 0 ? _a : false;
|
|
2176
|
-
const
|
|
2242
|
+
const appReducer = toolkit.combineReducers({
|
|
2177
2243
|
app: appSlice.reducer,
|
|
2178
2244
|
authorization: authorizationSlice.reducer,
|
|
2179
2245
|
chat: chatSlice.reducer,
|
|
@@ -2192,6 +2258,17 @@ const rootReducer = toolkit.combineReducers({
|
|
|
2192
2258
|
streaming: streamingSlice.reducer,
|
|
2193
2259
|
waitingParticipants: waitingParticipantsSlice.reducer,
|
|
2194
2260
|
});
|
|
2261
|
+
const rootReducer = (state, action) => {
|
|
2262
|
+
var _a;
|
|
2263
|
+
if (doAppReset.match(action)) {
|
|
2264
|
+
const resetState = {
|
|
2265
|
+
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 }),
|
|
2266
|
+
localMedia: Object.assign(Object.assign({}, localMediaSlice.getInitialState()), state === null || state === void 0 ? void 0 : state.localMedia),
|
|
2267
|
+
};
|
|
2268
|
+
return appReducer(resetState, action);
|
|
2269
|
+
}
|
|
2270
|
+
return appReducer(state, action);
|
|
2271
|
+
};
|
|
2195
2272
|
const createStore = ({ preloadedState, injectServices, }) => {
|
|
2196
2273
|
return toolkit.configureStore({
|
|
2197
2274
|
devTools: IS_DEV,
|
|
@@ -3235,7 +3312,6 @@ exports.OrganizationService = OrganizationService;
|
|
|
3235
3312
|
exports.OrganizationServiceCache = OrganizationServiceCache;
|
|
3236
3313
|
exports.RoomService = RoomService;
|
|
3237
3314
|
exports.addAppListener = addAppListener;
|
|
3238
|
-
exports.appLeft = appLeft;
|
|
3239
3315
|
exports.appSlice = appSlice;
|
|
3240
3316
|
exports.authorizationSlice = authorizationSlice;
|
|
3241
3317
|
exports.chatSlice = chatSlice;
|
|
@@ -3253,7 +3329,10 @@ exports.deviceCredentialsSlice = deviceCredentialsSlice;
|
|
|
3253
3329
|
exports.deviceIdentified = deviceIdentified;
|
|
3254
3330
|
exports.deviceIdentifying = deviceIdentifying;
|
|
3255
3331
|
exports.doAcceptWaitingParticipant = doAcceptWaitingParticipant;
|
|
3256
|
-
exports.
|
|
3332
|
+
exports.doAppConfigure = doAppConfigure;
|
|
3333
|
+
exports.doAppReset = doAppReset;
|
|
3334
|
+
exports.doAppStart = doAppStart;
|
|
3335
|
+
exports.doAppStop = doAppStop;
|
|
3257
3336
|
exports.doConnectRoom = doConnectRoom;
|
|
3258
3337
|
exports.doConnectRtc = doConnectRtc;
|
|
3259
3338
|
exports.doDisconnectRtc = doDisconnectRtc;
|
|
@@ -3278,9 +3357,9 @@ exports.doSendChatMessage = doSendChatMessage;
|
|
|
3278
3357
|
exports.doSetDevice = doSetDevice;
|
|
3279
3358
|
exports.doSetDisplayName = doSetDisplayName;
|
|
3280
3359
|
exports.doSetLocalParticipant = doSetLocalParticipant;
|
|
3360
|
+
exports.doSignalConnect = doSignalConnect;
|
|
3281
3361
|
exports.doSignalDisconnect = doSignalDisconnect;
|
|
3282
3362
|
exports.doSignalIdentifyDevice = doSignalIdentifyDevice;
|
|
3283
|
-
exports.doSignalSocketConnect = doSignalSocketConnect;
|
|
3284
3363
|
exports.doStartCloudRecording = doStartCloudRecording;
|
|
3285
3364
|
exports.doStartLocalMedia = doStartLocalMedia;
|
|
3286
3365
|
exports.doStartScreenshare = doStartScreenshare;
|
|
@@ -3325,12 +3404,14 @@ exports.rtcManagerDestroyed = rtcManagerDestroyed;
|
|
|
3325
3404
|
exports.rtcManagerInitialized = rtcManagerInitialized;
|
|
3326
3405
|
exports.selectAppDisplayName = selectAppDisplayName;
|
|
3327
3406
|
exports.selectAppExternalId = selectAppExternalId;
|
|
3407
|
+
exports.selectAppInitialConfig = selectAppInitialConfig;
|
|
3408
|
+
exports.selectAppIsActive = selectAppIsActive;
|
|
3409
|
+
exports.selectAppIsLoaded = selectAppIsLoaded;
|
|
3328
3410
|
exports.selectAppIsNodeSdk = selectAppIsNodeSdk;
|
|
3329
3411
|
exports.selectAppRaw = selectAppRaw;
|
|
3330
3412
|
exports.selectAppRoomName = selectAppRoomName;
|
|
3331
3413
|
exports.selectAppRoomUrl = selectAppRoomUrl;
|
|
3332
3414
|
exports.selectAppUserAgent = selectAppUserAgent;
|
|
3333
|
-
exports.selectAppWantsToJoin = selectAppWantsToJoin;
|
|
3334
3415
|
exports.selectAuthorizationRoleName = selectAuthorizationRoleName;
|
|
3335
3416
|
exports.selectBusyDeviceIds = selectBusyDeviceIds;
|
|
3336
3417
|
exports.selectCameraDeviceError = selectCameraDeviceError;
|
|
@@ -3405,6 +3486,7 @@ exports.selectShouldFetchDeviceCredentials = selectShouldFetchDeviceCredentials;
|
|
|
3405
3486
|
exports.selectShouldFetchOrganization = selectShouldFetchOrganization;
|
|
3406
3487
|
exports.selectShouldIdentifyDevice = selectShouldIdentifyDevice;
|
|
3407
3488
|
exports.selectShouldInitializeRtc = selectShouldInitializeRtc;
|
|
3489
|
+
exports.selectShouldReloadApp = selectShouldReloadApp;
|
|
3408
3490
|
exports.selectSignalConnectionDeviceIdentified = selectSignalConnectionDeviceIdentified;
|
|
3409
3491
|
exports.selectSignalConnectionRaw = selectSignalConnectionRaw;
|
|
3410
3492
|
exports.selectSignalConnectionSocket = selectSignalConnectionSocket;
|