@whereby.com/core 0.13.0 → 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 +156 -68
- package/dist/index.d.cts +315 -116
- package/dist/index.d.mts +315 -116
- package/dist/index.d.ts +315 -116
- package/dist/index.mjs +146 -64
- package/package.json +2 -2
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: [],
|
|
@@ -455,16 +497,6 @@ function fakeAudioStream() {
|
|
|
455
497
|
const oscillator = audioCtx.createOscillator();
|
|
456
498
|
const destination = audioCtx.createMediaStreamDestination();
|
|
457
499
|
oscillator.connect(destination);
|
|
458
|
-
oscillator.frequency.value = 400;
|
|
459
|
-
oscillator.type = "sine";
|
|
460
|
-
setInterval(() => {
|
|
461
|
-
if (oscillator.frequency.value <= 900) {
|
|
462
|
-
oscillator.frequency.value += 10;
|
|
463
|
-
}
|
|
464
|
-
else {
|
|
465
|
-
oscillator.frequency.value = 200;
|
|
466
|
-
}
|
|
467
|
-
}, 20);
|
|
468
500
|
oscillator.start();
|
|
469
501
|
return destination.stream;
|
|
470
502
|
}
|
|
@@ -516,7 +548,22 @@ function drawWebcamFrame(canvas) {
|
|
|
516
548
|
}
|
|
517
549
|
function fakeWebcamFrame(canvas) {
|
|
518
550
|
drawWebcamFrame(canvas);
|
|
519
|
-
|
|
551
|
+
setInterval(() => drawWebcamFrame(canvas), 50);
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
const CANVAS_VIDEO_FPS = 24;
|
|
555
|
+
function getAudioTrack() {
|
|
556
|
+
const audioStream = fakeAudioStream();
|
|
557
|
+
return audioStream.getAudioTracks()[0];
|
|
558
|
+
}
|
|
559
|
+
function getVideoTrack({ canvas }) {
|
|
560
|
+
fakeWebcamFrame(canvas);
|
|
561
|
+
const videoStream = canvas.captureStream(CANVAS_VIDEO_FPS);
|
|
562
|
+
return videoStream.getVideoTracks()[0];
|
|
563
|
+
}
|
|
564
|
+
function getFakeMediaStream({ canvas, hasAudio }) {
|
|
565
|
+
const tracks = [getVideoTrack({ canvas }), ...(hasAudio ? [getAudioTrack()] : [])];
|
|
566
|
+
return new MediaStream(tracks);
|
|
520
567
|
}
|
|
521
568
|
|
|
522
569
|
function debounce(fn, { delay = 500, edges } = {}) {
|
|
@@ -582,7 +629,8 @@ const initialLocalMediaState = {
|
|
|
582
629
|
isTogglingCamera: false,
|
|
583
630
|
lowDataMode: false,
|
|
584
631
|
microphoneEnabled: false,
|
|
585
|
-
status: "",
|
|
632
|
+
status: "inactive",
|
|
633
|
+
stream: undefined,
|
|
586
634
|
isSwitchingStream: false,
|
|
587
635
|
};
|
|
588
636
|
const localMediaSlice = toolkit.createSlice({
|
|
@@ -631,7 +679,7 @@ const localMediaSlice = toolkit.createSlice({
|
|
|
631
679
|
},
|
|
632
680
|
},
|
|
633
681
|
extraReducers: (builder) => {
|
|
634
|
-
builder.addCase(
|
|
682
|
+
builder.addCase(doAppConfigure, (state, action) => {
|
|
635
683
|
return Object.assign(Object.assign({}, state), { options: action.payload.localMediaOptions });
|
|
636
684
|
});
|
|
637
685
|
builder.addCase(doSetDevice.pending, (state, action) => {
|
|
@@ -914,8 +962,8 @@ const selectIsLocalMediaStarting = toolkit.createSelector(selectLocalMediaStatus
|
|
|
914
962
|
const selectCameraDevices = toolkit.createSelector(selectLocalMediaDevices, selectBusyDeviceIds, (devices, busyDeviceIds) => devices.filter((d) => d.kind === "videoinput").filter((d) => !busyDeviceIds.includes(d.deviceId)));
|
|
915
963
|
const selectMicrophoneDevices = toolkit.createSelector(selectLocalMediaDevices, selectBusyDeviceIds, (devices, busyDeviceIds) => devices.filter((d) => d.kind === "audioinput").filter((d) => !busyDeviceIds.includes(d.deviceId)));
|
|
916
964
|
const selectSpeakerDevices = toolkit.createSelector(selectLocalMediaDevices, (devices) => devices.filter((d) => d.kind === "audiooutput"));
|
|
917
|
-
const selectLocalMediaShouldStartWithOptions = toolkit.createSelector(
|
|
918
|
-
if (
|
|
965
|
+
const selectLocalMediaShouldStartWithOptions = toolkit.createSelector(selectAppIsActive, selectLocalMediaStatus, selectLocalMediaOptions, selectAppIsNodeSdk, (appIsActive, localMediaStatus, localMediaOptions, isNodeSdk) => {
|
|
966
|
+
if (appIsActive && ["inactive", "stopped"].includes(localMediaStatus) && !isNodeSdk && localMediaOptions) {
|
|
919
967
|
return localMediaOptions;
|
|
920
968
|
}
|
|
921
969
|
});
|
|
@@ -924,8 +972,8 @@ createReactor([selectLocalMediaShouldStartWithOptions], ({ dispatch }, options)
|
|
|
924
972
|
dispatch(doStartLocalMedia(options));
|
|
925
973
|
}
|
|
926
974
|
});
|
|
927
|
-
const selectLocalMediaShouldStop = toolkit.createSelector(
|
|
928
|
-
return !
|
|
975
|
+
const selectLocalMediaShouldStop = toolkit.createSelector(selectAppIsActive, selectLocalMediaStatus, selectLocalMediaOptions, (appIsActive, localMediaStatus, localMediaOptions) => {
|
|
976
|
+
return !appIsActive && localMediaStatus !== "inactive" && !!localMediaOptions;
|
|
929
977
|
});
|
|
930
978
|
createReactor([selectLocalMediaShouldStop], ({ dispatch }, localMediaShouldStop) => {
|
|
931
979
|
if (localMediaShouldStop) {
|
|
@@ -1058,7 +1106,7 @@ const localParticipantSlice = toolkit.createSlice({
|
|
|
1058
1106
|
},
|
|
1059
1107
|
},
|
|
1060
1108
|
extraReducers: (builder) => {
|
|
1061
|
-
builder.addCase(
|
|
1109
|
+
builder.addCase(doAppConfigure, (state, action) => {
|
|
1062
1110
|
return Object.assign(Object.assign({}, state), { displayName: action.payload.displayName });
|
|
1063
1111
|
});
|
|
1064
1112
|
builder.addCase(doEnableAudio.fulfilled, (state, action) => {
|
|
@@ -1100,7 +1148,7 @@ startAppListening({
|
|
|
1100
1148
|
});
|
|
1101
1149
|
|
|
1102
1150
|
const initialState$8 = {
|
|
1103
|
-
status: "",
|
|
1151
|
+
status: "inactive",
|
|
1104
1152
|
stream: null,
|
|
1105
1153
|
error: null,
|
|
1106
1154
|
};
|
|
@@ -1109,7 +1157,7 @@ const localScreenshareSlice = toolkit.createSlice({
|
|
|
1109
1157
|
initialState: initialState$8,
|
|
1110
1158
|
reducers: {
|
|
1111
1159
|
stopScreenshare(state, action) {
|
|
1112
|
-
return Object.assign(Object.assign({}, state), { status: "", stream: null });
|
|
1160
|
+
return Object.assign(Object.assign({}, state), { status: "inactive", stream: null });
|
|
1113
1161
|
},
|
|
1114
1162
|
},
|
|
1115
1163
|
extraReducers: (builder) => {
|
|
@@ -1120,7 +1168,7 @@ const localScreenshareSlice = toolkit.createSlice({
|
|
|
1120
1168
|
return Object.assign(Object.assign({}, state), { status: "active", stream });
|
|
1121
1169
|
});
|
|
1122
1170
|
builder.addCase(doStartScreenshare.rejected, (state, { payload }) => {
|
|
1123
|
-
return Object.assign(Object.assign({}, state), { error: payload, status: "", stream: null });
|
|
1171
|
+
return Object.assign(Object.assign({}, state), { error: payload, status: "inactive", stream: null });
|
|
1124
1172
|
});
|
|
1125
1173
|
},
|
|
1126
1174
|
});
|
|
@@ -1213,8 +1261,8 @@ const doOrganizationFetch = createAppAsyncThunk("organization/doOrganizationFetc
|
|
|
1213
1261
|
}));
|
|
1214
1262
|
const selectOrganizationRaw = (state) => state.organization;
|
|
1215
1263
|
const selectOrganizationId = (state) => { var _a; return (_a = state.organization.data) === null || _a === void 0 ? void 0 : _a.organizationId; };
|
|
1216
|
-
const selectShouldFetchOrganization = toolkit.createSelector(
|
|
1217
|
-
if (
|
|
1264
|
+
const selectShouldFetchOrganization = toolkit.createSelector(selectAppIsActive, selectOrganizationRaw, selectDeviceCredentialsRaw, (appIsActive, organization, deviceCredentials) => {
|
|
1265
|
+
if (appIsActive &&
|
|
1218
1266
|
!organization.data &&
|
|
1219
1267
|
!organization.isFetching &&
|
|
1220
1268
|
!organization.error &&
|
|
@@ -1473,19 +1521,22 @@ const doKickParticipant = createAppAuthorizedThunk((state) => selectIsAuthorized
|
|
|
1473
1521
|
const { socket } = selectSignalConnectionRaw(state);
|
|
1474
1522
|
socket === null || socket === void 0 ? void 0 : socket.emit("kick_client", { clientId: payload.clientId, reasonId: "kick" });
|
|
1475
1523
|
});
|
|
1476
|
-
const doEndMeeting = createAppAuthorizedThunk((state) => selectIsAuthorizedToEndMeeting(state), () => (
|
|
1524
|
+
const doEndMeeting = createAppAuthorizedThunk((state) => selectIsAuthorizedToEndMeeting(state), (payload) => (dispatch, getState) => {
|
|
1477
1525
|
const state = getState();
|
|
1478
1526
|
const clientsToKick = selectRemoteParticipants(state).map((c) => c.id);
|
|
1479
1527
|
if (clientsToKick.length) {
|
|
1480
1528
|
const { socket } = selectSignalConnectionRaw(state);
|
|
1481
1529
|
socket === null || socket === void 0 ? void 0 : socket.emit("kick_client", { clientIds: clientsToKick, reasonId: "end-meeting" });
|
|
1482
1530
|
}
|
|
1531
|
+
if (!payload.stayBehind) {
|
|
1532
|
+
dispatch(doAppStop());
|
|
1533
|
+
}
|
|
1483
1534
|
});
|
|
1484
1535
|
const selectRoomIsLocked = (state) => state.room.isLocked;
|
|
1485
1536
|
|
|
1486
1537
|
const initialState$4 = {
|
|
1487
1538
|
session: null,
|
|
1488
|
-
status: "
|
|
1539
|
+
status: "ready",
|
|
1489
1540
|
error: null,
|
|
1490
1541
|
};
|
|
1491
1542
|
const roomConnectionSlice = toolkit.createSlice({
|
|
@@ -1525,8 +1576,11 @@ const roomConnectionSlice = toolkit.createSlice({
|
|
|
1525
1576
|
builder.addCase(signalEvents.clientKicked, (state) => {
|
|
1526
1577
|
return Object.assign(Object.assign({}, state), { status: "kicked" });
|
|
1527
1578
|
});
|
|
1579
|
+
builder.addCase(signalEvents.roomLeft, (state) => {
|
|
1580
|
+
return Object.assign(Object.assign({}, state), { status: "left" });
|
|
1581
|
+
});
|
|
1528
1582
|
builder.addCase(socketReconnecting, (state) => {
|
|
1529
|
-
return Object.assign(Object.assign({}, state), { status: "
|
|
1583
|
+
return Object.assign(Object.assign({}, state), { status: "reconnecting" });
|
|
1530
1584
|
});
|
|
1531
1585
|
},
|
|
1532
1586
|
});
|
|
@@ -1587,16 +1641,18 @@ const selectRoomConnectionSessionId = (state) => { var _a; return (_a = state.ro
|
|
|
1587
1641
|
const selectRoomConnectionStatus = (state) => state.roomConnection.status;
|
|
1588
1642
|
const selectRoomConnectionError = (state) => state.roomConnection.error;
|
|
1589
1643
|
const selectShouldConnectRoom = toolkit.createSelector([
|
|
1644
|
+
selectAppIsActive,
|
|
1590
1645
|
selectOrganizationId,
|
|
1591
1646
|
selectRoomConnectionStatus,
|
|
1592
1647
|
selectSignalConnectionDeviceIdentified,
|
|
1593
1648
|
selectLocalMediaStatus,
|
|
1594
1649
|
selectAppIsNodeSdk,
|
|
1595
|
-
], (hasOrganizationIdFetched, roomConnectionStatus, signalConnectionDeviceIdentified, localMediaStatus, isNodeSdk) => {
|
|
1596
|
-
if (
|
|
1650
|
+
], (appIsActive, hasOrganizationIdFetched, roomConnectionStatus, signalConnectionDeviceIdentified, localMediaStatus, isNodeSdk) => {
|
|
1651
|
+
if (appIsActive &&
|
|
1652
|
+
(localMediaStatus === "started" || isNodeSdk) &&
|
|
1597
1653
|
signalConnectionDeviceIdentified &&
|
|
1598
1654
|
!!hasOrganizationIdFetched &&
|
|
1599
|
-
["
|
|
1655
|
+
["ready", "reconnecting", "disconnected"].includes(roomConnectionStatus)) {
|
|
1600
1656
|
return true;
|
|
1601
1657
|
}
|
|
1602
1658
|
return false;
|
|
@@ -1624,6 +1680,21 @@ startAppListening({
|
|
|
1624
1680
|
}
|
|
1625
1681
|
},
|
|
1626
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
|
+
});
|
|
1627
1698
|
|
|
1628
1699
|
const createWebRtcEmitter = (dispatch) => {
|
|
1629
1700
|
return {
|
|
@@ -1649,7 +1720,7 @@ const initialState$3 = {
|
|
|
1649
1720
|
rtcManager: null,
|
|
1650
1721
|
rtcManagerDispatcher: null,
|
|
1651
1722
|
rtcManagerInitialized: false,
|
|
1652
|
-
status: "",
|
|
1723
|
+
status: "inactive",
|
|
1653
1724
|
isAcceptingStreams: false,
|
|
1654
1725
|
};
|
|
1655
1726
|
const rtcConnectionSlice = toolkit.createSlice({
|
|
@@ -1681,10 +1752,10 @@ const rtcConnectionSlice = toolkit.createSlice({
|
|
|
1681
1752
|
},
|
|
1682
1753
|
extraReducers: (builder) => {
|
|
1683
1754
|
builder.addCase(socketReconnecting, (state) => {
|
|
1684
|
-
return Object.assign(Object.assign({}, state), { status: "
|
|
1755
|
+
return Object.assign(Object.assign({}, state), { status: "reconnecting" });
|
|
1685
1756
|
});
|
|
1686
1757
|
builder.addCase(signalEvents.roomJoined, (state) => {
|
|
1687
|
-
return Object.assign(Object.assign({}, state), { status: state.status === "
|
|
1758
|
+
return Object.assign(Object.assign({}, state), { status: state.status === "reconnecting" ? "ready" : state.status });
|
|
1688
1759
|
});
|
|
1689
1760
|
},
|
|
1690
1761
|
});
|
|
@@ -1874,8 +1945,8 @@ createReactor([selectShouldInitializeRtc], ({ dispatch }, shouldInitializeRtc) =
|
|
|
1874
1945
|
dispatch(doRtcManagerInitialize());
|
|
1875
1946
|
}
|
|
1876
1947
|
});
|
|
1877
|
-
const selectShouldDisconnectRtc = toolkit.createSelector(selectRtcStatus,
|
|
1878
|
-
if (!
|
|
1948
|
+
const selectShouldDisconnectRtc = toolkit.createSelector(selectRtcStatus, selectAppIsActive, (status, appIsActive) => {
|
|
1949
|
+
if (!appIsActive && !["inactive", "disconnected"].includes(status)) {
|
|
1879
1950
|
return true;
|
|
1880
1951
|
}
|
|
1881
1952
|
return false;
|
|
@@ -2168,7 +2239,7 @@ const selectWaitingParticipants = (state) => state.waitingParticipants.waitingPa
|
|
|
2168
2239
|
|
|
2169
2240
|
var _a;
|
|
2170
2241
|
const IS_DEV = (_a = undefined === "true") !== null && _a !== void 0 ? _a : false;
|
|
2171
|
-
const
|
|
2242
|
+
const appReducer = toolkit.combineReducers({
|
|
2172
2243
|
app: appSlice.reducer,
|
|
2173
2244
|
authorization: authorizationSlice.reducer,
|
|
2174
2245
|
chat: chatSlice.reducer,
|
|
@@ -2187,6 +2258,17 @@ const rootReducer = toolkit.combineReducers({
|
|
|
2187
2258
|
streaming: streamingSlice.reducer,
|
|
2188
2259
|
waitingParticipants: waitingParticipantsSlice.reducer,
|
|
2189
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
|
+
};
|
|
2190
2272
|
const createStore = ({ preloadedState, injectServices, }) => {
|
|
2191
2273
|
return toolkit.configureStore({
|
|
2192
2274
|
devTools: IS_DEV,
|
|
@@ -3230,7 +3312,6 @@ exports.OrganizationService = OrganizationService;
|
|
|
3230
3312
|
exports.OrganizationServiceCache = OrganizationServiceCache;
|
|
3231
3313
|
exports.RoomService = RoomService;
|
|
3232
3314
|
exports.addAppListener = addAppListener;
|
|
3233
|
-
exports.appLeft = appLeft;
|
|
3234
3315
|
exports.appSlice = appSlice;
|
|
3235
3316
|
exports.authorizationSlice = authorizationSlice;
|
|
3236
3317
|
exports.chatSlice = chatSlice;
|
|
@@ -3248,7 +3329,10 @@ exports.deviceCredentialsSlice = deviceCredentialsSlice;
|
|
|
3248
3329
|
exports.deviceIdentified = deviceIdentified;
|
|
3249
3330
|
exports.deviceIdentifying = deviceIdentifying;
|
|
3250
3331
|
exports.doAcceptWaitingParticipant = doAcceptWaitingParticipant;
|
|
3251
|
-
exports.
|
|
3332
|
+
exports.doAppConfigure = doAppConfigure;
|
|
3333
|
+
exports.doAppReset = doAppReset;
|
|
3334
|
+
exports.doAppStart = doAppStart;
|
|
3335
|
+
exports.doAppStop = doAppStop;
|
|
3252
3336
|
exports.doConnectRoom = doConnectRoom;
|
|
3253
3337
|
exports.doConnectRtc = doConnectRtc;
|
|
3254
3338
|
exports.doDisconnectRtc = doDisconnectRtc;
|
|
@@ -3273,9 +3357,9 @@ exports.doSendChatMessage = doSendChatMessage;
|
|
|
3273
3357
|
exports.doSetDevice = doSetDevice;
|
|
3274
3358
|
exports.doSetDisplayName = doSetDisplayName;
|
|
3275
3359
|
exports.doSetLocalParticipant = doSetLocalParticipant;
|
|
3360
|
+
exports.doSignalConnect = doSignalConnect;
|
|
3276
3361
|
exports.doSignalDisconnect = doSignalDisconnect;
|
|
3277
3362
|
exports.doSignalIdentifyDevice = doSignalIdentifyDevice;
|
|
3278
|
-
exports.doSignalSocketConnect = doSignalSocketConnect;
|
|
3279
3363
|
exports.doStartCloudRecording = doStartCloudRecording;
|
|
3280
3364
|
exports.doStartLocalMedia = doStartLocalMedia;
|
|
3281
3365
|
exports.doStartScreenshare = doStartScreenshare;
|
|
@@ -3286,8 +3370,9 @@ exports.doSwitchLocalStream = doSwitchLocalStream;
|
|
|
3286
3370
|
exports.doToggleCamera = doToggleCamera;
|
|
3287
3371
|
exports.doToggleLowDataMode = doToggleLowDataMode;
|
|
3288
3372
|
exports.doUpdateDeviceList = doUpdateDeviceList;
|
|
3289
|
-
exports.
|
|
3290
|
-
exports.
|
|
3373
|
+
exports.getAudioTrack = getAudioTrack;
|
|
3374
|
+
exports.getFakeMediaStream = getFakeMediaStream;
|
|
3375
|
+
exports.getVideoTrack = getVideoTrack;
|
|
3291
3376
|
exports.initialCloudRecordingState = initialCloudRecordingState;
|
|
3292
3377
|
exports.initialLocalMediaState = initialLocalMediaState;
|
|
3293
3378
|
exports.isAcceptingStreams = isAcceptingStreams;
|
|
@@ -3319,12 +3404,14 @@ exports.rtcManagerDestroyed = rtcManagerDestroyed;
|
|
|
3319
3404
|
exports.rtcManagerInitialized = rtcManagerInitialized;
|
|
3320
3405
|
exports.selectAppDisplayName = selectAppDisplayName;
|
|
3321
3406
|
exports.selectAppExternalId = selectAppExternalId;
|
|
3407
|
+
exports.selectAppInitialConfig = selectAppInitialConfig;
|
|
3408
|
+
exports.selectAppIsActive = selectAppIsActive;
|
|
3409
|
+
exports.selectAppIsLoaded = selectAppIsLoaded;
|
|
3322
3410
|
exports.selectAppIsNodeSdk = selectAppIsNodeSdk;
|
|
3323
3411
|
exports.selectAppRaw = selectAppRaw;
|
|
3324
3412
|
exports.selectAppRoomName = selectAppRoomName;
|
|
3325
3413
|
exports.selectAppRoomUrl = selectAppRoomUrl;
|
|
3326
3414
|
exports.selectAppUserAgent = selectAppUserAgent;
|
|
3327
|
-
exports.selectAppWantsToJoin = selectAppWantsToJoin;
|
|
3328
3415
|
exports.selectAuthorizationRoleName = selectAuthorizationRoleName;
|
|
3329
3416
|
exports.selectBusyDeviceIds = selectBusyDeviceIds;
|
|
3330
3417
|
exports.selectCameraDeviceError = selectCameraDeviceError;
|
|
@@ -3399,6 +3486,7 @@ exports.selectShouldFetchDeviceCredentials = selectShouldFetchDeviceCredentials;
|
|
|
3399
3486
|
exports.selectShouldFetchOrganization = selectShouldFetchOrganization;
|
|
3400
3487
|
exports.selectShouldIdentifyDevice = selectShouldIdentifyDevice;
|
|
3401
3488
|
exports.selectShouldInitializeRtc = selectShouldInitializeRtc;
|
|
3489
|
+
exports.selectShouldReloadApp = selectShouldReloadApp;
|
|
3402
3490
|
exports.selectSignalConnectionDeviceIdentified = selectSignalConnectionDeviceIdentified;
|
|
3403
3491
|
exports.selectSignalConnectionRaw = selectSignalConnectionRaw;
|
|
3404
3492
|
exports.selectSignalConnectionSocket = selectSignalConnectionSocket;
|