@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.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: [],
|
|
@@ -453,16 +495,6 @@ function fakeAudioStream() {
|
|
|
453
495
|
const oscillator = audioCtx.createOscillator();
|
|
454
496
|
const destination = audioCtx.createMediaStreamDestination();
|
|
455
497
|
oscillator.connect(destination);
|
|
456
|
-
oscillator.frequency.value = 400;
|
|
457
|
-
oscillator.type = "sine";
|
|
458
|
-
setInterval(() => {
|
|
459
|
-
if (oscillator.frequency.value <= 900) {
|
|
460
|
-
oscillator.frequency.value += 10;
|
|
461
|
-
}
|
|
462
|
-
else {
|
|
463
|
-
oscillator.frequency.value = 200;
|
|
464
|
-
}
|
|
465
|
-
}, 20);
|
|
466
498
|
oscillator.start();
|
|
467
499
|
return destination.stream;
|
|
468
500
|
}
|
|
@@ -514,7 +546,22 @@ function drawWebcamFrame(canvas) {
|
|
|
514
546
|
}
|
|
515
547
|
function fakeWebcamFrame(canvas) {
|
|
516
548
|
drawWebcamFrame(canvas);
|
|
517
|
-
|
|
549
|
+
setInterval(() => drawWebcamFrame(canvas), 50);
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
const CANVAS_VIDEO_FPS = 24;
|
|
553
|
+
function getAudioTrack() {
|
|
554
|
+
const audioStream = fakeAudioStream();
|
|
555
|
+
return audioStream.getAudioTracks()[0];
|
|
556
|
+
}
|
|
557
|
+
function getVideoTrack({ canvas }) {
|
|
558
|
+
fakeWebcamFrame(canvas);
|
|
559
|
+
const videoStream = canvas.captureStream(CANVAS_VIDEO_FPS);
|
|
560
|
+
return videoStream.getVideoTracks()[0];
|
|
561
|
+
}
|
|
562
|
+
function getFakeMediaStream({ canvas, hasAudio }) {
|
|
563
|
+
const tracks = [getVideoTrack({ canvas }), ...(hasAudio ? [getAudioTrack()] : [])];
|
|
564
|
+
return new MediaStream(tracks);
|
|
518
565
|
}
|
|
519
566
|
|
|
520
567
|
function debounce(fn, { delay = 500, edges } = {}) {
|
|
@@ -580,7 +627,8 @@ const initialLocalMediaState = {
|
|
|
580
627
|
isTogglingCamera: false,
|
|
581
628
|
lowDataMode: false,
|
|
582
629
|
microphoneEnabled: false,
|
|
583
|
-
status: "",
|
|
630
|
+
status: "inactive",
|
|
631
|
+
stream: undefined,
|
|
584
632
|
isSwitchingStream: false,
|
|
585
633
|
};
|
|
586
634
|
const localMediaSlice = createSlice({
|
|
@@ -629,7 +677,7 @@ const localMediaSlice = createSlice({
|
|
|
629
677
|
},
|
|
630
678
|
},
|
|
631
679
|
extraReducers: (builder) => {
|
|
632
|
-
builder.addCase(
|
|
680
|
+
builder.addCase(doAppConfigure, (state, action) => {
|
|
633
681
|
return Object.assign(Object.assign({}, state), { options: action.payload.localMediaOptions });
|
|
634
682
|
});
|
|
635
683
|
builder.addCase(doSetDevice.pending, (state, action) => {
|
|
@@ -912,8 +960,8 @@ const selectIsLocalMediaStarting = createSelector(selectLocalMediaStatus, (statu
|
|
|
912
960
|
const selectCameraDevices = createSelector(selectLocalMediaDevices, selectBusyDeviceIds, (devices, busyDeviceIds) => devices.filter((d) => d.kind === "videoinput").filter((d) => !busyDeviceIds.includes(d.deviceId)));
|
|
913
961
|
const selectMicrophoneDevices = createSelector(selectLocalMediaDevices, selectBusyDeviceIds, (devices, busyDeviceIds) => devices.filter((d) => d.kind === "audioinput").filter((d) => !busyDeviceIds.includes(d.deviceId)));
|
|
914
962
|
const selectSpeakerDevices = createSelector(selectLocalMediaDevices, (devices) => devices.filter((d) => d.kind === "audiooutput"));
|
|
915
|
-
const selectLocalMediaShouldStartWithOptions = createSelector(
|
|
916
|
-
if (
|
|
963
|
+
const selectLocalMediaShouldStartWithOptions = createSelector(selectAppIsActive, selectLocalMediaStatus, selectLocalMediaOptions, selectAppIsNodeSdk, (appIsActive, localMediaStatus, localMediaOptions, isNodeSdk) => {
|
|
964
|
+
if (appIsActive && ["inactive", "stopped"].includes(localMediaStatus) && !isNodeSdk && localMediaOptions) {
|
|
917
965
|
return localMediaOptions;
|
|
918
966
|
}
|
|
919
967
|
});
|
|
@@ -922,8 +970,8 @@ createReactor([selectLocalMediaShouldStartWithOptions], ({ dispatch }, options)
|
|
|
922
970
|
dispatch(doStartLocalMedia(options));
|
|
923
971
|
}
|
|
924
972
|
});
|
|
925
|
-
const selectLocalMediaShouldStop = createSelector(
|
|
926
|
-
return !
|
|
973
|
+
const selectLocalMediaShouldStop = createSelector(selectAppIsActive, selectLocalMediaStatus, selectLocalMediaOptions, (appIsActive, localMediaStatus, localMediaOptions) => {
|
|
974
|
+
return !appIsActive && localMediaStatus !== "inactive" && !!localMediaOptions;
|
|
927
975
|
});
|
|
928
976
|
createReactor([selectLocalMediaShouldStop], ({ dispatch }, localMediaShouldStop) => {
|
|
929
977
|
if (localMediaShouldStop) {
|
|
@@ -1056,7 +1104,7 @@ const localParticipantSlice = createSlice({
|
|
|
1056
1104
|
},
|
|
1057
1105
|
},
|
|
1058
1106
|
extraReducers: (builder) => {
|
|
1059
|
-
builder.addCase(
|
|
1107
|
+
builder.addCase(doAppConfigure, (state, action) => {
|
|
1060
1108
|
return Object.assign(Object.assign({}, state), { displayName: action.payload.displayName });
|
|
1061
1109
|
});
|
|
1062
1110
|
builder.addCase(doEnableAudio.fulfilled, (state, action) => {
|
|
@@ -1098,7 +1146,7 @@ startAppListening({
|
|
|
1098
1146
|
});
|
|
1099
1147
|
|
|
1100
1148
|
const initialState$8 = {
|
|
1101
|
-
status: "",
|
|
1149
|
+
status: "inactive",
|
|
1102
1150
|
stream: null,
|
|
1103
1151
|
error: null,
|
|
1104
1152
|
};
|
|
@@ -1107,7 +1155,7 @@ const localScreenshareSlice = createSlice({
|
|
|
1107
1155
|
initialState: initialState$8,
|
|
1108
1156
|
reducers: {
|
|
1109
1157
|
stopScreenshare(state, action) {
|
|
1110
|
-
return Object.assign(Object.assign({}, state), { status: "", stream: null });
|
|
1158
|
+
return Object.assign(Object.assign({}, state), { status: "inactive", stream: null });
|
|
1111
1159
|
},
|
|
1112
1160
|
},
|
|
1113
1161
|
extraReducers: (builder) => {
|
|
@@ -1118,7 +1166,7 @@ const localScreenshareSlice = createSlice({
|
|
|
1118
1166
|
return Object.assign(Object.assign({}, state), { status: "active", stream });
|
|
1119
1167
|
});
|
|
1120
1168
|
builder.addCase(doStartScreenshare.rejected, (state, { payload }) => {
|
|
1121
|
-
return Object.assign(Object.assign({}, state), { error: payload, status: "", stream: null });
|
|
1169
|
+
return Object.assign(Object.assign({}, state), { error: payload, status: "inactive", stream: null });
|
|
1122
1170
|
});
|
|
1123
1171
|
},
|
|
1124
1172
|
});
|
|
@@ -1211,8 +1259,8 @@ const doOrganizationFetch = createAppAsyncThunk("organization/doOrganizationFetc
|
|
|
1211
1259
|
}));
|
|
1212
1260
|
const selectOrganizationRaw = (state) => state.organization;
|
|
1213
1261
|
const selectOrganizationId = (state) => { var _a; return (_a = state.organization.data) === null || _a === void 0 ? void 0 : _a.organizationId; };
|
|
1214
|
-
const selectShouldFetchOrganization = createSelector(
|
|
1215
|
-
if (
|
|
1262
|
+
const selectShouldFetchOrganization = createSelector(selectAppIsActive, selectOrganizationRaw, selectDeviceCredentialsRaw, (appIsActive, organization, deviceCredentials) => {
|
|
1263
|
+
if (appIsActive &&
|
|
1216
1264
|
!organization.data &&
|
|
1217
1265
|
!organization.isFetching &&
|
|
1218
1266
|
!organization.error &&
|
|
@@ -1471,19 +1519,22 @@ const doKickParticipant = createAppAuthorizedThunk((state) => selectIsAuthorized
|
|
|
1471
1519
|
const { socket } = selectSignalConnectionRaw(state);
|
|
1472
1520
|
socket === null || socket === void 0 ? void 0 : socket.emit("kick_client", { clientId: payload.clientId, reasonId: "kick" });
|
|
1473
1521
|
});
|
|
1474
|
-
const doEndMeeting = createAppAuthorizedThunk((state) => selectIsAuthorizedToEndMeeting(state), () => (
|
|
1522
|
+
const doEndMeeting = createAppAuthorizedThunk((state) => selectIsAuthorizedToEndMeeting(state), (payload) => (dispatch, getState) => {
|
|
1475
1523
|
const state = getState();
|
|
1476
1524
|
const clientsToKick = selectRemoteParticipants(state).map((c) => c.id);
|
|
1477
1525
|
if (clientsToKick.length) {
|
|
1478
1526
|
const { socket } = selectSignalConnectionRaw(state);
|
|
1479
1527
|
socket === null || socket === void 0 ? void 0 : socket.emit("kick_client", { clientIds: clientsToKick, reasonId: "end-meeting" });
|
|
1480
1528
|
}
|
|
1529
|
+
if (!payload.stayBehind) {
|
|
1530
|
+
dispatch(doAppStop());
|
|
1531
|
+
}
|
|
1481
1532
|
});
|
|
1482
1533
|
const selectRoomIsLocked = (state) => state.room.isLocked;
|
|
1483
1534
|
|
|
1484
1535
|
const initialState$4 = {
|
|
1485
1536
|
session: null,
|
|
1486
|
-
status: "
|
|
1537
|
+
status: "ready",
|
|
1487
1538
|
error: null,
|
|
1488
1539
|
};
|
|
1489
1540
|
const roomConnectionSlice = createSlice({
|
|
@@ -1523,8 +1574,11 @@ const roomConnectionSlice = createSlice({
|
|
|
1523
1574
|
builder.addCase(signalEvents.clientKicked, (state) => {
|
|
1524
1575
|
return Object.assign(Object.assign({}, state), { status: "kicked" });
|
|
1525
1576
|
});
|
|
1577
|
+
builder.addCase(signalEvents.roomLeft, (state) => {
|
|
1578
|
+
return Object.assign(Object.assign({}, state), { status: "left" });
|
|
1579
|
+
});
|
|
1526
1580
|
builder.addCase(socketReconnecting, (state) => {
|
|
1527
|
-
return Object.assign(Object.assign({}, state), { status: "
|
|
1581
|
+
return Object.assign(Object.assign({}, state), { status: "reconnecting" });
|
|
1528
1582
|
});
|
|
1529
1583
|
},
|
|
1530
1584
|
});
|
|
@@ -1585,16 +1639,18 @@ const selectRoomConnectionSessionId = (state) => { var _a; return (_a = state.ro
|
|
|
1585
1639
|
const selectRoomConnectionStatus = (state) => state.roomConnection.status;
|
|
1586
1640
|
const selectRoomConnectionError = (state) => state.roomConnection.error;
|
|
1587
1641
|
const selectShouldConnectRoom = createSelector([
|
|
1642
|
+
selectAppIsActive,
|
|
1588
1643
|
selectOrganizationId,
|
|
1589
1644
|
selectRoomConnectionStatus,
|
|
1590
1645
|
selectSignalConnectionDeviceIdentified,
|
|
1591
1646
|
selectLocalMediaStatus,
|
|
1592
1647
|
selectAppIsNodeSdk,
|
|
1593
|
-
], (hasOrganizationIdFetched, roomConnectionStatus, signalConnectionDeviceIdentified, localMediaStatus, isNodeSdk) => {
|
|
1594
|
-
if (
|
|
1648
|
+
], (appIsActive, hasOrganizationIdFetched, roomConnectionStatus, signalConnectionDeviceIdentified, localMediaStatus, isNodeSdk) => {
|
|
1649
|
+
if (appIsActive &&
|
|
1650
|
+
(localMediaStatus === "started" || isNodeSdk) &&
|
|
1595
1651
|
signalConnectionDeviceIdentified &&
|
|
1596
1652
|
!!hasOrganizationIdFetched &&
|
|
1597
|
-
["
|
|
1653
|
+
["ready", "reconnecting", "disconnected"].includes(roomConnectionStatus)) {
|
|
1598
1654
|
return true;
|
|
1599
1655
|
}
|
|
1600
1656
|
return false;
|
|
@@ -1622,6 +1678,21 @@ startAppListening({
|
|
|
1622
1678
|
}
|
|
1623
1679
|
},
|
|
1624
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
|
+
});
|
|
1625
1696
|
|
|
1626
1697
|
const createWebRtcEmitter = (dispatch) => {
|
|
1627
1698
|
return {
|
|
@@ -1647,7 +1718,7 @@ const initialState$3 = {
|
|
|
1647
1718
|
rtcManager: null,
|
|
1648
1719
|
rtcManagerDispatcher: null,
|
|
1649
1720
|
rtcManagerInitialized: false,
|
|
1650
|
-
status: "",
|
|
1721
|
+
status: "inactive",
|
|
1651
1722
|
isAcceptingStreams: false,
|
|
1652
1723
|
};
|
|
1653
1724
|
const rtcConnectionSlice = createSlice({
|
|
@@ -1679,10 +1750,10 @@ const rtcConnectionSlice = createSlice({
|
|
|
1679
1750
|
},
|
|
1680
1751
|
extraReducers: (builder) => {
|
|
1681
1752
|
builder.addCase(socketReconnecting, (state) => {
|
|
1682
|
-
return Object.assign(Object.assign({}, state), { status: "
|
|
1753
|
+
return Object.assign(Object.assign({}, state), { status: "reconnecting" });
|
|
1683
1754
|
});
|
|
1684
1755
|
builder.addCase(signalEvents.roomJoined, (state) => {
|
|
1685
|
-
return Object.assign(Object.assign({}, state), { status: state.status === "
|
|
1756
|
+
return Object.assign(Object.assign({}, state), { status: state.status === "reconnecting" ? "ready" : state.status });
|
|
1686
1757
|
});
|
|
1687
1758
|
},
|
|
1688
1759
|
});
|
|
@@ -1872,8 +1943,8 @@ createReactor([selectShouldInitializeRtc], ({ dispatch }, shouldInitializeRtc) =
|
|
|
1872
1943
|
dispatch(doRtcManagerInitialize());
|
|
1873
1944
|
}
|
|
1874
1945
|
});
|
|
1875
|
-
const selectShouldDisconnectRtc = createSelector(selectRtcStatus,
|
|
1876
|
-
if (!
|
|
1946
|
+
const selectShouldDisconnectRtc = createSelector(selectRtcStatus, selectAppIsActive, (status, appIsActive) => {
|
|
1947
|
+
if (!appIsActive && !["inactive", "disconnected"].includes(status)) {
|
|
1877
1948
|
return true;
|
|
1878
1949
|
}
|
|
1879
1950
|
return false;
|
|
@@ -2166,7 +2237,7 @@ const selectWaitingParticipants = (state) => state.waitingParticipants.waitingPa
|
|
|
2166
2237
|
|
|
2167
2238
|
var _a;
|
|
2168
2239
|
const IS_DEV = (_a = undefined === "true") !== null && _a !== void 0 ? _a : false;
|
|
2169
|
-
const
|
|
2240
|
+
const appReducer = combineReducers({
|
|
2170
2241
|
app: appSlice.reducer,
|
|
2171
2242
|
authorization: authorizationSlice.reducer,
|
|
2172
2243
|
chat: chatSlice.reducer,
|
|
@@ -2185,6 +2256,17 @@ const rootReducer = combineReducers({
|
|
|
2185
2256
|
streaming: streamingSlice.reducer,
|
|
2186
2257
|
waitingParticipants: waitingParticipantsSlice.reducer,
|
|
2187
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
|
+
};
|
|
2188
2270
|
const createStore = ({ preloadedState, injectServices, }) => {
|
|
2189
2271
|
return configureStore({
|
|
2190
2272
|
devTools: IS_DEV,
|
|
@@ -3219,4 +3301,4 @@ function createServices() {
|
|
|
3219
3301
|
};
|
|
3220
3302
|
}
|
|
3221
3303
|
|
|
3222
|
-
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
|
@@ -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.14.0",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"build": "rimraf dist && rollup -c rollup.config.js",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
52
|
"@reduxjs/toolkit": "^2.2.3",
|
|
53
|
-
"@whereby.com/media": "1.
|
|
53
|
+
"@whereby.com/media": "1.4.0",
|
|
54
54
|
"axios": "^1.2.3",
|
|
55
55
|
"btoa": "^1.2.1",
|
|
56
56
|
"events": "^3.3.0"
|