@whereby.com/core 0.30.4 → 0.31.1
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 +264 -253
- package/dist/index.d.cts +53 -10
- package/dist/index.d.mts +53 -10
- package/dist/index.d.ts +53 -10
- package/dist/index.mjs +264 -253
- package/dist/legacy-esm.js +264 -253
- package/package.json +2 -2
package/dist/legacy-esm.js
CHANGED
|
@@ -74,7 +74,7 @@ const createReactor = (selectors, callback) => {
|
|
|
74
74
|
});
|
|
75
75
|
};
|
|
76
76
|
|
|
77
|
-
const coreVersion = "0.
|
|
77
|
+
const coreVersion = "0.31.1";
|
|
78
78
|
|
|
79
79
|
const initialState$g = {
|
|
80
80
|
isNodeSdk: false,
|
|
@@ -513,59 +513,22 @@ const selectCloudRecordingStartedAt = (state) => state.cloudRecording.startedAt;
|
|
|
513
513
|
const selectCloudRecordingError = (state) => state.cloudRecording.error;
|
|
514
514
|
const selectIsCloudRecording = (state) => state.cloudRecording.isRecording;
|
|
515
515
|
|
|
516
|
-
const
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
516
|
+
const selectRoomConnectionRaw = (state) => state.roomConnection;
|
|
517
|
+
const selectRoomConnectionSession = (state) => state.roomConnection.session;
|
|
518
|
+
const selectRoomConnectionSessionId = (state) => { var _a; return (_a = state.roomConnection.session) === null || _a === void 0 ? void 0 : _a.id; };
|
|
519
|
+
const selectRoomConnectionStatus = (state) => state.roomConnection.status;
|
|
520
|
+
const selectRoomConnectionError = (state) => state.roomConnection.error;
|
|
521
|
+
|
|
522
|
+
function createRtcEventAction(name) {
|
|
523
|
+
return createAction(`rtcConnection/event/${name}`);
|
|
524
|
+
}
|
|
525
|
+
const rtcEvents = {
|
|
526
|
+
rtcManagerCreated: createRtcEventAction("rtcManagerCreated"),
|
|
527
|
+
rtcManagerDestroyed: createRtcEventAction("rtcManagerDestroyed"),
|
|
528
|
+
streamAdded: createRtcEventAction("streamAdded"),
|
|
520
529
|
};
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
name: "organization",
|
|
524
|
-
reducers: {},
|
|
525
|
-
extraReducers: (builder) => {
|
|
526
|
-
builder.addCase(doOrganizationFetch.pending, (state) => {
|
|
527
|
-
return Object.assign(Object.assign({}, state), { isFetching: true });
|
|
528
|
-
});
|
|
529
|
-
builder.addCase(doOrganizationFetch.fulfilled, (state, action) => {
|
|
530
|
-
if (!action.payload)
|
|
531
|
-
return Object.assign(Object.assign({}, state), { isFetching: true });
|
|
532
|
-
return Object.assign(Object.assign({}, state), { isFetching: false, data: action.payload });
|
|
533
|
-
});
|
|
534
|
-
builder.addCase(doOrganizationFetch.rejected, (state) => {
|
|
535
|
-
return Object.assign(Object.assign({}, state), { isFetching: false, error: true });
|
|
536
|
-
});
|
|
537
|
-
},
|
|
538
|
-
});
|
|
539
|
-
const doOrganizationFetch = createAppAsyncThunk("organization/doOrganizationFetch", (_, { extra, getState }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
540
|
-
try {
|
|
541
|
-
const roomUrl = selectAppRoomUrl(getState());
|
|
542
|
-
const organization = yield extra.services.fetchOrganizationFromRoomUrl(roomUrl || "");
|
|
543
|
-
if (!organization) {
|
|
544
|
-
throw new Error("Invalid room url");
|
|
545
|
-
}
|
|
546
|
-
return organization;
|
|
547
|
-
}
|
|
548
|
-
catch (error) {
|
|
549
|
-
console.error(error);
|
|
550
|
-
}
|
|
551
|
-
}));
|
|
552
|
-
const selectOrganizationRaw = (state) => state.organization;
|
|
553
|
-
const selectOrganizationId = (state) => { var _a; return (_a = state.organization.data) === null || _a === void 0 ? void 0 : _a.organizationId; };
|
|
554
|
-
const selectShouldFetchOrganization = createSelector(selectAppIsActive, selectOrganizationRaw, selectDeviceCredentialsRaw, (appIsActive, organization, deviceCredentials) => {
|
|
555
|
-
if (appIsActive &&
|
|
556
|
-
!organization.data &&
|
|
557
|
-
!organization.isFetching &&
|
|
558
|
-
!organization.error &&
|
|
559
|
-
!deviceCredentials.isFetching) {
|
|
560
|
-
return true;
|
|
561
|
-
}
|
|
562
|
-
return false;
|
|
563
|
-
});
|
|
564
|
-
createReactor([selectShouldFetchOrganization], ({ dispatch }, shouldFetchOrganization) => {
|
|
565
|
-
if (shouldFetchOrganization) {
|
|
566
|
-
dispatch(doOrganizationFetch());
|
|
567
|
-
}
|
|
568
|
-
});
|
|
530
|
+
|
|
531
|
+
const NON_PERSON_ROLES = ["recorder", "streamer"];
|
|
569
532
|
|
|
570
533
|
function fakeAudioStream() {
|
|
571
534
|
const audioCtx = new AudioContext();
|
|
@@ -1137,9 +1100,7 @@ startAppListening({
|
|
|
1137
1100
|
},
|
|
1138
1101
|
});
|
|
1139
1102
|
|
|
1140
|
-
const
|
|
1141
|
-
|
|
1142
|
-
const initialState$a = {
|
|
1103
|
+
const initialState$b = {
|
|
1143
1104
|
displayName: "",
|
|
1144
1105
|
id: "",
|
|
1145
1106
|
breakoutGroup: null,
|
|
@@ -1155,7 +1116,7 @@ const initialState$a = {
|
|
|
1155
1116
|
};
|
|
1156
1117
|
const localParticipantSlice = createSlice({
|
|
1157
1118
|
name: "localParticipant",
|
|
1158
|
-
initialState: initialState$
|
|
1119
|
+
initialState: initialState$b,
|
|
1159
1120
|
reducers: {
|
|
1160
1121
|
setDisplayName: (state, action) => {
|
|
1161
1122
|
return Object.assign(Object.assign({}, state), { displayName: action.payload.displayName });
|
|
@@ -1263,6 +1224,10 @@ startAppListening({
|
|
|
1263
1224
|
effect: ({ payload }, { dispatch, getState }) => {
|
|
1264
1225
|
const { enabled } = payload;
|
|
1265
1226
|
const { isVideoEnabled } = selectLocalParticipantRaw(getState());
|
|
1227
|
+
const roomConnectionStatus = selectRoomConnectionStatus(getState());
|
|
1228
|
+
if (roomConnectionStatus !== "connected") {
|
|
1229
|
+
return;
|
|
1230
|
+
}
|
|
1266
1231
|
dispatch(doEnableVideo({ enabled: enabled || !isVideoEnabled }));
|
|
1267
1232
|
},
|
|
1268
1233
|
});
|
|
@@ -1271,196 +1236,19 @@ startAppListening({
|
|
|
1271
1236
|
effect: ({ payload }, { dispatch, getState }) => {
|
|
1272
1237
|
const { enabled } = payload;
|
|
1273
1238
|
const { isAudioEnabled } = selectLocalParticipantRaw(getState());
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
});
|
|
1277
|
-
createReactor([selectLocalParticipantDisplayName, selectLocalParticipantStickyReaction], ({ dispatch }) => {
|
|
1278
|
-
dispatch(doSendClientMetadata());
|
|
1279
|
-
});
|
|
1280
|
-
|
|
1281
|
-
const initialState$9 = {
|
|
1282
|
-
session: null,
|
|
1283
|
-
status: "ready",
|
|
1284
|
-
error: null,
|
|
1285
|
-
};
|
|
1286
|
-
const roomConnectionSlice = createSlice({
|
|
1287
|
-
initialState: initialState$9,
|
|
1288
|
-
name: "roomConnection",
|
|
1289
|
-
reducers: {
|
|
1290
|
-
connectionStatusChanged: (state, action) => {
|
|
1291
|
-
return Object.assign(Object.assign({}, state), { status: action.payload });
|
|
1292
|
-
},
|
|
1293
|
-
},
|
|
1294
|
-
extraReducers: (builder) => {
|
|
1295
|
-
builder.addCase(signalEvents.roomJoined, (state, action) => {
|
|
1296
|
-
var _a, _b;
|
|
1297
|
-
const { error, isLocked } = action.payload;
|
|
1298
|
-
if (error === "room_locked" && isLocked) {
|
|
1299
|
-
return Object.assign(Object.assign({}, state), { status: "room_locked" });
|
|
1300
|
-
}
|
|
1301
|
-
if (error) {
|
|
1302
|
-
return Object.assign(Object.assign({}, state), { status: "disconnected", error });
|
|
1303
|
-
}
|
|
1304
|
-
return Object.assign(Object.assign({}, state), { status: "connected", session: (_b = (_a = action.payload.room) === null || _a === void 0 ? void 0 : _a.session) !== null && _b !== void 0 ? _b : null });
|
|
1305
|
-
});
|
|
1306
|
-
builder.addCase(signalEvents.disconnect, (state) => {
|
|
1307
|
-
if (["kicked", "left"].includes(state.status)) {
|
|
1308
|
-
return Object.assign({}, state);
|
|
1309
|
-
}
|
|
1310
|
-
return Object.assign(Object.assign({}, state), { status: "disconnected" });
|
|
1311
|
-
});
|
|
1312
|
-
builder.addCase(signalEvents.newClient, (state, action) => {
|
|
1313
|
-
var _a, _b;
|
|
1314
|
-
return Object.assign(Object.assign({}, state), { session: (_b = (_a = action.payload.room) === null || _a === void 0 ? void 0 : _a.session) !== null && _b !== void 0 ? _b : null });
|
|
1315
|
-
});
|
|
1316
|
-
builder.addCase(signalEvents.roomSessionEnded, (state, action) => {
|
|
1317
|
-
var _a;
|
|
1318
|
-
if (((_a = state.session) === null || _a === void 0 ? void 0 : _a.id) !== action.payload.roomSessionId) {
|
|
1319
|
-
return state;
|
|
1320
|
-
}
|
|
1321
|
-
return Object.assign(Object.assign({}, state), { session: null });
|
|
1322
|
-
});
|
|
1323
|
-
builder.addCase(signalEvents.clientKicked, (state) => {
|
|
1324
|
-
return Object.assign(Object.assign({}, state), { status: "kicked" });
|
|
1325
|
-
});
|
|
1326
|
-
builder.addCase(signalEvents.roomLeft, (state) => {
|
|
1327
|
-
return Object.assign(Object.assign({}, state), { status: "left" });
|
|
1328
|
-
});
|
|
1329
|
-
builder.addCase(socketReconnecting, (state) => {
|
|
1330
|
-
return Object.assign(Object.assign({}, state), { status: "reconnecting" });
|
|
1331
|
-
});
|
|
1332
|
-
},
|
|
1333
|
-
});
|
|
1334
|
-
const { connectionStatusChanged } = roomConnectionSlice.actions;
|
|
1335
|
-
const doKnockRoom = createAppThunk(() => (dispatch, getState) => {
|
|
1336
|
-
const state = getState();
|
|
1337
|
-
const socket = selectSignalConnectionRaw(state).socket;
|
|
1338
|
-
const roomName = selectAppRoomName(state);
|
|
1339
|
-
const roomKey = selectRoomKey(state);
|
|
1340
|
-
const displayName = selectAppDisplayName(state);
|
|
1341
|
-
const isDialIn = selectAppIsDialIn(state);
|
|
1342
|
-
const userAgent = selectAppUserAgent(state);
|
|
1343
|
-
const externalId = selectAppExternalId(state);
|
|
1344
|
-
const organizationId = selectOrganizationId(state);
|
|
1345
|
-
const connectionStatus = selectRoomConnectionStatus(state);
|
|
1346
|
-
if (connectionStatus !== "room_locked") {
|
|
1347
|
-
console.warn("Room is not locked, knock aborted");
|
|
1348
|
-
return;
|
|
1349
|
-
}
|
|
1350
|
-
socket === null || socket === void 0 ? void 0 : socket.emit("knock_room", {
|
|
1351
|
-
avatarUrl: null,
|
|
1352
|
-
config: {
|
|
1353
|
-
isAudioEnabled: true,
|
|
1354
|
-
isVideoEnabled: true,
|
|
1355
|
-
},
|
|
1356
|
-
deviceCapabilities: { canScreenshare: true },
|
|
1357
|
-
displayName,
|
|
1358
|
-
isCoLocated: false,
|
|
1359
|
-
isDialIn,
|
|
1360
|
-
isDevicePermissionDenied: false,
|
|
1361
|
-
kickFromOtherRooms: false,
|
|
1362
|
-
organizationId,
|
|
1363
|
-
roomKey,
|
|
1364
|
-
roomName,
|
|
1365
|
-
userAgent,
|
|
1366
|
-
externalId,
|
|
1367
|
-
});
|
|
1368
|
-
dispatch(connectionStatusChanged("knocking"));
|
|
1369
|
-
});
|
|
1370
|
-
const doConnectRoom = createAppThunk(() => (dispatch, getState) => {
|
|
1371
|
-
const state = getState();
|
|
1372
|
-
const socket = selectSignalConnectionRaw(state).socket;
|
|
1373
|
-
const roomName = selectAppRoomName(state);
|
|
1374
|
-
const roomKey = selectRoomKey(state);
|
|
1375
|
-
const displayName = selectAppDisplayName(state);
|
|
1376
|
-
const userAgent = selectAppUserAgent(state);
|
|
1377
|
-
const externalId = selectAppExternalId(state);
|
|
1378
|
-
const isDialIn = selectAppIsDialIn(state);
|
|
1379
|
-
const organizationId = selectOrganizationId(state);
|
|
1380
|
-
const isCameraEnabled = selectIsCameraEnabled(getState());
|
|
1381
|
-
const isMicrophoneEnabled = selectIsMicrophoneEnabled(getState());
|
|
1382
|
-
const clientClaim = selectLocalParticipantClientClaim(getState());
|
|
1383
|
-
socket === null || socket === void 0 ? void 0 : socket.emit("join_room", Object.assign({ avatarUrl: null, config: {
|
|
1384
|
-
isAudioEnabled: isMicrophoneEnabled,
|
|
1385
|
-
isVideoEnabled: isCameraEnabled,
|
|
1386
|
-
}, deviceCapabilities: { canScreenshare: true }, displayName, isCoLocated: false, isDialIn, isDevicePermissionDenied: false, kickFromOtherRooms: false, organizationId,
|
|
1387
|
-
roomKey,
|
|
1388
|
-
roomName,
|
|
1389
|
-
userAgent,
|
|
1390
|
-
externalId }, (clientClaim && { clientClaim })));
|
|
1391
|
-
dispatch(connectionStatusChanged("connecting"));
|
|
1392
|
-
});
|
|
1393
|
-
const selectRoomConnectionRaw = (state) => state.roomConnection;
|
|
1394
|
-
const selectRoomConnectionSession = (state) => state.roomConnection.session;
|
|
1395
|
-
const selectRoomConnectionSessionId = (state) => { var _a; return (_a = state.roomConnection.session) === null || _a === void 0 ? void 0 : _a.id; };
|
|
1396
|
-
const selectRoomConnectionStatus = (state) => state.roomConnection.status;
|
|
1397
|
-
const selectRoomConnectionError = (state) => state.roomConnection.error;
|
|
1398
|
-
const selectShouldConnectRoom = createSelector([
|
|
1399
|
-
selectAppIsActive,
|
|
1400
|
-
selectOrganizationId,
|
|
1401
|
-
selectRoomConnectionStatus,
|
|
1402
|
-
selectSignalConnectionDeviceIdentified,
|
|
1403
|
-
selectLocalMediaStatus,
|
|
1404
|
-
selectRoomConnectionError,
|
|
1405
|
-
], (appIsActive, hasOrganizationIdFetched, roomConnectionStatus, signalConnectionDeviceIdentified, localMediaStatus, roomConnectionError) => {
|
|
1406
|
-
if (appIsActive &&
|
|
1407
|
-
localMediaStatus === "started" &&
|
|
1408
|
-
signalConnectionDeviceIdentified &&
|
|
1409
|
-
!!hasOrganizationIdFetched &&
|
|
1410
|
-
["ready", "reconnecting", "disconnected"].includes(roomConnectionStatus) &&
|
|
1411
|
-
!roomConnectionError) {
|
|
1412
|
-
return true;
|
|
1413
|
-
}
|
|
1414
|
-
return false;
|
|
1415
|
-
});
|
|
1416
|
-
createReactor([selectShouldConnectRoom], ({ dispatch }, shouldConnectRoom) => {
|
|
1417
|
-
if (shouldConnectRoom) {
|
|
1418
|
-
dispatch(doConnectRoom());
|
|
1419
|
-
}
|
|
1420
|
-
});
|
|
1421
|
-
startAppListening({
|
|
1422
|
-
actionCreator: signalEvents.knockHandled,
|
|
1423
|
-
effect: ({ payload }, { dispatch, getState }) => {
|
|
1424
|
-
const { clientId, resolution } = payload;
|
|
1425
|
-
const state = getState();
|
|
1426
|
-
const selfId = selectSelfId(state);
|
|
1427
|
-
if (clientId !== selfId) {
|
|
1239
|
+
const roomConnectionStatus = selectRoomConnectionStatus(getState());
|
|
1240
|
+
if (roomConnectionStatus !== "connected") {
|
|
1428
1241
|
return;
|
|
1429
1242
|
}
|
|
1430
|
-
|
|
1431
|
-
dispatch(setRoomKey(payload.metadata.roomKey));
|
|
1432
|
-
dispatch(doConnectRoom());
|
|
1433
|
-
}
|
|
1434
|
-
else if (resolution === "rejected") {
|
|
1435
|
-
dispatch(connectionStatusChanged("knock_rejected"));
|
|
1436
|
-
}
|
|
1243
|
+
dispatch(doEnableAudio({ enabled: enabled || !isAudioEnabled }));
|
|
1437
1244
|
},
|
|
1438
1245
|
});
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
const roomConnectionStatus = selectRoomConnectionStatus(state);
|
|
1444
|
-
if (roomConnectionStatus === "connected") {
|
|
1445
|
-
const socket = selectSignalConnectionRaw(state).socket;
|
|
1446
|
-
socket === null || socket === void 0 ? void 0 : socket.emit("leave_room");
|
|
1447
|
-
dispatch(connectionStatusChanged("leaving"));
|
|
1448
|
-
}
|
|
1449
|
-
else {
|
|
1450
|
-
doSignalDisconnect();
|
|
1451
|
-
}
|
|
1452
|
-
},
|
|
1246
|
+
createReactor([selectLocalParticipantDisplayName, selectLocalParticipantStickyReaction, selectRoomConnectionStatus], ({ dispatch }, diplayName, stickyReaction, roomConnectionStatus) => {
|
|
1247
|
+
if (roomConnectionStatus === "connected") {
|
|
1248
|
+
dispatch(doSendClientMetadata());
|
|
1249
|
+
}
|
|
1453
1250
|
});
|
|
1454
1251
|
|
|
1455
|
-
function createRtcEventAction(name) {
|
|
1456
|
-
return createAction(`rtcConnection/event/${name}`);
|
|
1457
|
-
}
|
|
1458
|
-
const rtcEvents = {
|
|
1459
|
-
rtcManagerCreated: createRtcEventAction("rtcManagerCreated"),
|
|
1460
|
-
rtcManagerDestroyed: createRtcEventAction("rtcManagerDestroyed"),
|
|
1461
|
-
streamAdded: createRtcEventAction("streamAdded"),
|
|
1462
|
-
};
|
|
1463
|
-
|
|
1464
1252
|
function createRemoteParticipant(client, newJoiner = false) {
|
|
1465
1253
|
const { streams, role, breakoutGroup } = client, rest = __rest(client, ["streams", "role", "breakoutGroup"]);
|
|
1466
1254
|
return Object.assign(Object.assign({}, rest), { stream: null, streams: streams.map((streamId) => ({ id: streamId, state: newJoiner ? "new_accept" : "to_accept" })), isLocalParticipant: false, roleName: (role === null || role === void 0 ? void 0 : role.roleName) || "none", presentationStream: null, breakoutGroup: breakoutGroup || null, newJoiner });
|
|
@@ -1552,12 +1340,12 @@ function addStream(state, payload) {
|
|
|
1552
1340
|
presentationStream: stream,
|
|
1553
1341
|
});
|
|
1554
1342
|
}
|
|
1555
|
-
const initialState$
|
|
1343
|
+
const initialState$a = {
|
|
1556
1344
|
remoteParticipants: [],
|
|
1557
1345
|
};
|
|
1558
1346
|
const remoteParticipantsSlice = createSlice({
|
|
1559
1347
|
name: "remoteParticipants",
|
|
1560
|
-
initialState: initialState$
|
|
1348
|
+
initialState: initialState$a,
|
|
1561
1349
|
reducers: {
|
|
1562
1350
|
streamStatusUpdated: (state, action) => {
|
|
1563
1351
|
let newState = state;
|
|
@@ -1664,14 +1452,14 @@ const selectNumParticipants = createSelector(selectRemoteParticipants, selectLoc
|
|
|
1664
1452
|
return clients.length + 1;
|
|
1665
1453
|
});
|
|
1666
1454
|
|
|
1667
|
-
const initialState$
|
|
1455
|
+
const initialState$9 = {
|
|
1668
1456
|
status: "inactive",
|
|
1669
1457
|
stream: null,
|
|
1670
1458
|
error: null,
|
|
1671
1459
|
};
|
|
1672
1460
|
const localScreenshareSlice = createSlice({
|
|
1673
1461
|
name: "localScreenshare",
|
|
1674
|
-
initialState: initialState$
|
|
1462
|
+
initialState: initialState$9,
|
|
1675
1463
|
reducers: {
|
|
1676
1464
|
stopScreenshare(state, action) {
|
|
1677
1465
|
return Object.assign(Object.assign({}, state), { status: "inactive", stream: null });
|
|
@@ -1756,7 +1544,7 @@ const createWebRtcEmitter = (dispatch) => {
|
|
|
1756
1544
|
},
|
|
1757
1545
|
};
|
|
1758
1546
|
};
|
|
1759
|
-
const initialState$
|
|
1547
|
+
const initialState$8 = {
|
|
1760
1548
|
dispatcherCreated: false,
|
|
1761
1549
|
error: null,
|
|
1762
1550
|
isCreatingDispatcher: false,
|
|
@@ -1769,7 +1557,7 @@ const initialState$6 = {
|
|
|
1769
1557
|
};
|
|
1770
1558
|
const rtcConnectionSlice = createSlice({
|
|
1771
1559
|
name: "rtcConnection",
|
|
1772
|
-
initialState: initialState$
|
|
1560
|
+
initialState: initialState$8,
|
|
1773
1561
|
reducers: {
|
|
1774
1562
|
isAcceptingStreams: (state, action) => {
|
|
1775
1563
|
return Object.assign(Object.assign({}, state), { isAcceptingStreams: action.payload });
|
|
@@ -1779,7 +1567,7 @@ const rtcConnectionSlice = createSlice({
|
|
|
1779
1567
|
return Object.assign(Object.assign({}, state), { reportedStreamResolutions: Object.assign(Object.assign({}, state.reportedStreamResolutions), { [streamId]: { width, height } }) });
|
|
1780
1568
|
},
|
|
1781
1569
|
rtcDisconnected: () => {
|
|
1782
|
-
return Object.assign({}, initialState$
|
|
1570
|
+
return Object.assign({}, initialState$8);
|
|
1783
1571
|
},
|
|
1784
1572
|
rtcDispatcherCreated: (state, action) => {
|
|
1785
1573
|
return Object.assign(Object.assign({}, state), { dispatcherCreated: true, rtcManagerDispatcher: action.payload });
|
|
@@ -2053,12 +1841,12 @@ function isStreamerClient(client) {
|
|
|
2053
1841
|
function isRecorderClient(client) {
|
|
2054
1842
|
return client.roleName === "recorder";
|
|
2055
1843
|
}
|
|
2056
|
-
const initialState$
|
|
1844
|
+
const initialState$7 = {
|
|
2057
1845
|
isLocked: false,
|
|
2058
1846
|
};
|
|
2059
1847
|
const roomSlice = createSlice({
|
|
2060
1848
|
name: "room",
|
|
2061
|
-
initialState: initialState$
|
|
1849
|
+
initialState: initialState$7,
|
|
2062
1850
|
reducers: {},
|
|
2063
1851
|
extraReducers: (builder) => {
|
|
2064
1852
|
builder.addCase(signalEvents.roomJoined, (state, action) => {
|
|
@@ -2158,18 +1946,18 @@ const selectAllClientViews = createSelector(selectLocalParticipantView, selectRe
|
|
|
2158
1946
|
return [...(localParticipant ? [localParticipant] : []), ...remoteParticipants];
|
|
2159
1947
|
});
|
|
2160
1948
|
|
|
2161
|
-
const initialState$
|
|
1949
|
+
const initialState$6 = {
|
|
2162
1950
|
running: false,
|
|
2163
1951
|
};
|
|
2164
1952
|
const connectionMonitorSlice = createSlice({
|
|
2165
1953
|
name: "connectionMonitor",
|
|
2166
|
-
initialState: initialState$
|
|
1954
|
+
initialState: initialState$6,
|
|
2167
1955
|
reducers: {
|
|
2168
1956
|
connectionMonitorStarted: (state, action) => {
|
|
2169
1957
|
return Object.assign(Object.assign({}, state), { running: true, stopCallbackFunction: action.payload.stopIssueSubscription });
|
|
2170
1958
|
},
|
|
2171
1959
|
connectionMonitorStopped: () => {
|
|
2172
|
-
return Object.assign({}, initialState$
|
|
1960
|
+
return Object.assign({}, initialState$6);
|
|
2173
1961
|
},
|
|
2174
1962
|
},
|
|
2175
1963
|
});
|
|
@@ -2432,6 +2220,229 @@ startAppListening({
|
|
|
2432
2220
|
},
|
|
2433
2221
|
});
|
|
2434
2222
|
|
|
2223
|
+
const initialState$5 = {
|
|
2224
|
+
data: null,
|
|
2225
|
+
isFetching: false,
|
|
2226
|
+
error: null,
|
|
2227
|
+
};
|
|
2228
|
+
const organizationSlice = createSlice({
|
|
2229
|
+
initialState: initialState$5,
|
|
2230
|
+
name: "organization",
|
|
2231
|
+
reducers: {},
|
|
2232
|
+
extraReducers: (builder) => {
|
|
2233
|
+
builder.addCase(doOrganizationFetch.pending, (state) => {
|
|
2234
|
+
return Object.assign(Object.assign({}, state), { isFetching: true });
|
|
2235
|
+
});
|
|
2236
|
+
builder.addCase(doOrganizationFetch.fulfilled, (state, action) => {
|
|
2237
|
+
if (!action.payload)
|
|
2238
|
+
return Object.assign(Object.assign({}, state), { isFetching: true });
|
|
2239
|
+
return Object.assign(Object.assign({}, state), { isFetching: false, data: action.payload });
|
|
2240
|
+
});
|
|
2241
|
+
builder.addCase(doOrganizationFetch.rejected, (state) => {
|
|
2242
|
+
return Object.assign(Object.assign({}, state), { isFetching: false, error: true });
|
|
2243
|
+
});
|
|
2244
|
+
},
|
|
2245
|
+
});
|
|
2246
|
+
const doOrganizationFetch = createAppAsyncThunk("organization/doOrganizationFetch", (_, { extra, getState }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
2247
|
+
try {
|
|
2248
|
+
const roomUrl = selectAppRoomUrl(getState());
|
|
2249
|
+
const organization = yield extra.services.fetchOrganizationFromRoomUrl(roomUrl || "");
|
|
2250
|
+
if (!organization) {
|
|
2251
|
+
throw new Error("Invalid room url");
|
|
2252
|
+
}
|
|
2253
|
+
return organization;
|
|
2254
|
+
}
|
|
2255
|
+
catch (error) {
|
|
2256
|
+
console.error(error);
|
|
2257
|
+
}
|
|
2258
|
+
}));
|
|
2259
|
+
const selectOrganizationRaw = (state) => state.organization;
|
|
2260
|
+
const selectOrganizationId = (state) => { var _a; return (_a = state.organization.data) === null || _a === void 0 ? void 0 : _a.organizationId; };
|
|
2261
|
+
const selectShouldFetchOrganization = createSelector(selectAppIsActive, selectOrganizationRaw, selectDeviceCredentialsRaw, (appIsActive, organization, deviceCredentials) => {
|
|
2262
|
+
if (appIsActive &&
|
|
2263
|
+
!organization.data &&
|
|
2264
|
+
!organization.isFetching &&
|
|
2265
|
+
!organization.error &&
|
|
2266
|
+
!deviceCredentials.isFetching) {
|
|
2267
|
+
return true;
|
|
2268
|
+
}
|
|
2269
|
+
return false;
|
|
2270
|
+
});
|
|
2271
|
+
createReactor([selectShouldFetchOrganization], ({ dispatch }, shouldFetchOrganization) => {
|
|
2272
|
+
if (shouldFetchOrganization) {
|
|
2273
|
+
dispatch(doOrganizationFetch());
|
|
2274
|
+
}
|
|
2275
|
+
});
|
|
2276
|
+
|
|
2277
|
+
const initialState$4 = {
|
|
2278
|
+
session: null,
|
|
2279
|
+
status: "ready",
|
|
2280
|
+
error: null,
|
|
2281
|
+
};
|
|
2282
|
+
const roomConnectionSlice = createSlice({
|
|
2283
|
+
initialState: initialState$4,
|
|
2284
|
+
name: "roomConnection",
|
|
2285
|
+
reducers: {
|
|
2286
|
+
connectionStatusChanged: (state, action) => {
|
|
2287
|
+
return Object.assign(Object.assign({}, state), { status: action.payload });
|
|
2288
|
+
},
|
|
2289
|
+
},
|
|
2290
|
+
extraReducers: (builder) => {
|
|
2291
|
+
builder.addCase(signalEvents.roomJoined, (state, action) => {
|
|
2292
|
+
var _a, _b;
|
|
2293
|
+
const { error, isLocked } = action.payload;
|
|
2294
|
+
if (error === "room_locked" && isLocked) {
|
|
2295
|
+
return Object.assign(Object.assign({}, state), { status: "room_locked" });
|
|
2296
|
+
}
|
|
2297
|
+
if (error) {
|
|
2298
|
+
return Object.assign(Object.assign({}, state), { status: "disconnected", error });
|
|
2299
|
+
}
|
|
2300
|
+
return Object.assign(Object.assign({}, state), { status: "connected", session: (_b = (_a = action.payload.room) === null || _a === void 0 ? void 0 : _a.session) !== null && _b !== void 0 ? _b : null });
|
|
2301
|
+
});
|
|
2302
|
+
builder.addCase(signalEvents.disconnect, (state) => {
|
|
2303
|
+
if (["kicked", "left"].includes(state.status)) {
|
|
2304
|
+
return Object.assign({}, state);
|
|
2305
|
+
}
|
|
2306
|
+
return Object.assign(Object.assign({}, state), { status: "disconnected" });
|
|
2307
|
+
});
|
|
2308
|
+
builder.addCase(signalEvents.newClient, (state, action) => {
|
|
2309
|
+
var _a, _b;
|
|
2310
|
+
return Object.assign(Object.assign({}, state), { session: (_b = (_a = action.payload.room) === null || _a === void 0 ? void 0 : _a.session) !== null && _b !== void 0 ? _b : null });
|
|
2311
|
+
});
|
|
2312
|
+
builder.addCase(signalEvents.roomSessionEnded, (state, action) => {
|
|
2313
|
+
var _a;
|
|
2314
|
+
if (((_a = state.session) === null || _a === void 0 ? void 0 : _a.id) !== action.payload.roomSessionId) {
|
|
2315
|
+
return state;
|
|
2316
|
+
}
|
|
2317
|
+
return Object.assign(Object.assign({}, state), { session: null });
|
|
2318
|
+
});
|
|
2319
|
+
builder.addCase(signalEvents.clientKicked, (state) => {
|
|
2320
|
+
return Object.assign(Object.assign({}, state), { status: "kicked" });
|
|
2321
|
+
});
|
|
2322
|
+
builder.addCase(signalEvents.roomLeft, (state) => {
|
|
2323
|
+
return Object.assign(Object.assign({}, state), { status: "left" });
|
|
2324
|
+
});
|
|
2325
|
+
builder.addCase(socketReconnecting, (state) => {
|
|
2326
|
+
return Object.assign(Object.assign({}, state), { status: "reconnecting" });
|
|
2327
|
+
});
|
|
2328
|
+
},
|
|
2329
|
+
});
|
|
2330
|
+
const { connectionStatusChanged } = roomConnectionSlice.actions;
|
|
2331
|
+
const doKnockRoom = createAppThunk(() => (dispatch, getState) => {
|
|
2332
|
+
const state = getState();
|
|
2333
|
+
const socket = selectSignalConnectionRaw(state).socket;
|
|
2334
|
+
const roomName = selectAppRoomName(state);
|
|
2335
|
+
const roomKey = selectRoomKey(state);
|
|
2336
|
+
const displayName = selectAppDisplayName(state);
|
|
2337
|
+
const isDialIn = selectAppIsDialIn(state);
|
|
2338
|
+
const userAgent = selectAppUserAgent(state);
|
|
2339
|
+
const externalId = selectAppExternalId(state);
|
|
2340
|
+
const organizationId = selectOrganizationId(state);
|
|
2341
|
+
const connectionStatus = selectRoomConnectionStatus(state);
|
|
2342
|
+
if (connectionStatus !== "room_locked") {
|
|
2343
|
+
console.warn("Room is not locked, knock aborted");
|
|
2344
|
+
return;
|
|
2345
|
+
}
|
|
2346
|
+
socket === null || socket === void 0 ? void 0 : socket.emit("knock_room", {
|
|
2347
|
+
avatarUrl: null,
|
|
2348
|
+
config: {
|
|
2349
|
+
isAudioEnabled: true,
|
|
2350
|
+
isVideoEnabled: true,
|
|
2351
|
+
},
|
|
2352
|
+
deviceCapabilities: { canScreenshare: true },
|
|
2353
|
+
displayName,
|
|
2354
|
+
isCoLocated: false,
|
|
2355
|
+
isDialIn,
|
|
2356
|
+
isDevicePermissionDenied: false,
|
|
2357
|
+
kickFromOtherRooms: false,
|
|
2358
|
+
organizationId,
|
|
2359
|
+
roomKey,
|
|
2360
|
+
roomName,
|
|
2361
|
+
userAgent,
|
|
2362
|
+
externalId,
|
|
2363
|
+
});
|
|
2364
|
+
dispatch(connectionStatusChanged("knocking"));
|
|
2365
|
+
});
|
|
2366
|
+
const doConnectRoom = createAppThunk(() => (dispatch, getState) => {
|
|
2367
|
+
const state = getState();
|
|
2368
|
+
const socket = selectSignalConnectionRaw(state).socket;
|
|
2369
|
+
const roomName = selectAppRoomName(state);
|
|
2370
|
+
const roomKey = selectRoomKey(state);
|
|
2371
|
+
const displayName = selectAppDisplayName(state);
|
|
2372
|
+
const userAgent = selectAppUserAgent(state);
|
|
2373
|
+
const externalId = selectAppExternalId(state);
|
|
2374
|
+
const isDialIn = selectAppIsDialIn(state);
|
|
2375
|
+
const organizationId = selectOrganizationId(state);
|
|
2376
|
+
const isCameraEnabled = selectIsCameraEnabled(getState());
|
|
2377
|
+
const isMicrophoneEnabled = selectIsMicrophoneEnabled(getState());
|
|
2378
|
+
const clientClaim = selectLocalParticipantClientClaim(getState());
|
|
2379
|
+
socket === null || socket === void 0 ? void 0 : socket.emit("join_room", Object.assign({ avatarUrl: null, config: {
|
|
2380
|
+
isAudioEnabled: isMicrophoneEnabled,
|
|
2381
|
+
isVideoEnabled: isCameraEnabled,
|
|
2382
|
+
}, deviceCapabilities: { canScreenshare: true }, displayName, isCoLocated: false, isDialIn, isDevicePermissionDenied: false, kickFromOtherRooms: false, organizationId,
|
|
2383
|
+
roomKey,
|
|
2384
|
+
roomName,
|
|
2385
|
+
userAgent,
|
|
2386
|
+
externalId }, (clientClaim && { clientClaim })));
|
|
2387
|
+
dispatch(connectionStatusChanged("connecting"));
|
|
2388
|
+
});
|
|
2389
|
+
const selectShouldConnectRoom = createSelector([
|
|
2390
|
+
selectAppIsActive,
|
|
2391
|
+
selectOrganizationId,
|
|
2392
|
+
selectRoomConnectionStatus,
|
|
2393
|
+
selectSignalConnectionDeviceIdentified,
|
|
2394
|
+
selectLocalMediaStatus,
|
|
2395
|
+
selectRoomConnectionError,
|
|
2396
|
+
], (appIsActive, hasOrganizationIdFetched, roomConnectionStatus, signalConnectionDeviceIdentified, localMediaStatus, roomConnectionError) => {
|
|
2397
|
+
if (appIsActive &&
|
|
2398
|
+
localMediaStatus === "started" &&
|
|
2399
|
+
signalConnectionDeviceIdentified &&
|
|
2400
|
+
!!hasOrganizationIdFetched &&
|
|
2401
|
+
["ready", "reconnecting", "disconnected"].includes(roomConnectionStatus) &&
|
|
2402
|
+
!roomConnectionError) {
|
|
2403
|
+
return true;
|
|
2404
|
+
}
|
|
2405
|
+
return false;
|
|
2406
|
+
});
|
|
2407
|
+
createReactor([selectShouldConnectRoom], ({ dispatch }, shouldConnectRoom) => {
|
|
2408
|
+
if (shouldConnectRoom) {
|
|
2409
|
+
dispatch(doConnectRoom());
|
|
2410
|
+
}
|
|
2411
|
+
});
|
|
2412
|
+
startAppListening({
|
|
2413
|
+
actionCreator: signalEvents.knockHandled,
|
|
2414
|
+
effect: ({ payload }, { dispatch, getState }) => {
|
|
2415
|
+
const { clientId, resolution } = payload;
|
|
2416
|
+
const state = getState();
|
|
2417
|
+
const selfId = selectSelfId(state);
|
|
2418
|
+
if (clientId !== selfId) {
|
|
2419
|
+
return;
|
|
2420
|
+
}
|
|
2421
|
+
if (resolution === "accepted") {
|
|
2422
|
+
dispatch(setRoomKey(payload.metadata.roomKey));
|
|
2423
|
+
dispatch(doConnectRoom());
|
|
2424
|
+
}
|
|
2425
|
+
else if (resolution === "rejected") {
|
|
2426
|
+
dispatch(connectionStatusChanged("knock_rejected"));
|
|
2427
|
+
}
|
|
2428
|
+
},
|
|
2429
|
+
});
|
|
2430
|
+
startAppListening({
|
|
2431
|
+
actionCreator: doAppStop,
|
|
2432
|
+
effect: (_, { dispatch, getState }) => {
|
|
2433
|
+
const state = getState();
|
|
2434
|
+
const roomConnectionStatus = selectRoomConnectionStatus(state);
|
|
2435
|
+
if (roomConnectionStatus === "connected") {
|
|
2436
|
+
const socket = selectSignalConnectionRaw(state).socket;
|
|
2437
|
+
socket === null || socket === void 0 ? void 0 : socket.emit("leave_room");
|
|
2438
|
+
dispatch(connectionStatusChanged("leaving"));
|
|
2439
|
+
}
|
|
2440
|
+
else {
|
|
2441
|
+
doSignalDisconnect();
|
|
2442
|
+
}
|
|
2443
|
+
},
|
|
2444
|
+
});
|
|
2445
|
+
|
|
2435
2446
|
const rtcAnalyticsCustomEvents = {
|
|
2436
2447
|
audioEnabled: {
|
|
2437
2448
|
actions: [doEnableAudio.fulfilled],
|
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.31.1",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"clean": "rimraf dist node_modules .turbo",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"@reduxjs/toolkit": "^2.2.3",
|
|
52
|
-
"@whereby.com/media": "1.17.
|
|
52
|
+
"@whereby.com/media": "1.17.10",
|
|
53
53
|
"axios": "^1.2.3",
|
|
54
54
|
"btoa": "^1.2.1",
|
|
55
55
|
"events": "^3.3.0"
|