@devanachat/sdk 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/CHANGELOG.md +50 -0
- package/build/index.cjs.js +271 -14
- package/build/index.cjs.js.map +1 -1
- package/build/index.mjs +271 -15
- package/build/index.mjs.map +1 -1
- package/build/index.umd.js +1 -1
- package/build/index.umd.js.map +1 -1
- package/build/types/AbstractChatClient.d.ts +16 -1
- package/build/types/Permissions.d.ts +34 -0
- package/build/types/index.d.ts +4 -3
- package/build/types/protocol/index.d.ts +21 -2
- package/build/types/protocol/schemes/Call.d.ts +35 -0
- package/build/types/protocol/schemes/IncomingCall.d.ts +6 -0
- package/build/types/protocol/schemes/Message.d.ts +3 -1
- package/build/types/protocol/schemes/MessageCall.d.ts +9 -0
- package/build/types/protocol/schemes/Room.d.ts +2 -0
- package/build/types/protocol/schemes/RoomCall.d.ts +6 -0
- package/build/types/protocol/schemes/UserData.d.ts +1 -0
- package/build/types/protocol/schemes/UserState.d.ts +4 -0
- package/build/types/protocol/schemes/commands/DeclineCall.d.ts +3 -0
- package/build/types/protocol/schemes/commands/GetCallMembers.d.ts +5 -0
- package/build/types/protocol/schemes/commands/InviteToCall.d.ts +5 -0
- package/build/types/protocol/schemes/commands/JoinCall.d.ts +4 -0
- package/build/types/protocol/schemes/commands/KickCallMember.d.ts +4 -0
- package/build/types/protocol/schemes/commands/MuteCallMember.d.ts +4 -0
- package/build/types/protocol/schemes/commands/SetPermissionOverwrites.d.ts +1 -0
- package/build/types/protocol/schemes/commands/SetSessionData.d.ts +1 -0
- package/build/types/protocol/schemes/commands/SetUserData.d.ts +1 -0
- package/build/types/protocol/schemes/commands/UpdateCallMember.d.ts +7 -0
- package/build/types/protocol/schemes/commands/UpdateRoom.d.ts +2 -0
- package/build/types/protocol/schemes/events/CallJoined.d.ts +7 -0
- package/build/types/protocol/schemes/events/CallMemberJoined.d.ts +5 -0
- package/build/types/protocol/schemes/events/CallMemberLeft.d.ts +4 -0
- package/build/types/protocol/schemes/events/CallMemberUpdated.d.ts +6 -0
- package/build/types/protocol/schemes/events/CallMembers.d.ts +5 -0
- package/build/types/protocol/schemes/events/CallUpdated.d.ts +5 -0
- package/build/types/protocol/schemes/events/CallVideoLimitReached.d.ts +4 -0
- package/build/types/protocol/schemes/events/Error.d.ts +6 -0
- package/build/types/protocol/schemes/events/IncomingCallUpdated.d.ts +5 -0
- package/build/types/state-tracker/CallsManager.d.ts +74 -0
- package/build/types/state-tracker/ChatStateTracker.d.ts +5 -0
- package/build/types/state-tracker/StateSnapshot.d.ts +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,56 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [0.14.0]
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- Voice and video calls in rooms. The protocol: commands `JoinCall` (answered with `CallJoined`: the media server URL,
|
|
14
|
+
token and quality), `DeclineCall`, `InviteToCall`, `MuteCallMember` and `KickCallMember`; events
|
|
15
|
+
`CallUpdated` (a call started, changed or ended), `CallMemberJoined`, `CallMemberUpdated` and `CallMemberLeft`
|
|
16
|
+
(a change of a single member), `IncomingCallUpdated` (an `IncomingCall` - the call and its caller - started or
|
|
17
|
+
stopped ringing at you) and `CallVideoLimitReached` (the server took your camera or screen share away because of
|
|
18
|
+
the video limit of the call); `Session.state.calls` with the ongoing calls, each with its `location`, and
|
|
19
|
+
`Session.state.incomingCalls` with the calls ringing at you; the `Call` message type
|
|
20
|
+
with `Message.call` (status, the `mode` the call had, duration, `memberCount` and some of the members in
|
|
21
|
+
`partialMembers`) and the
|
|
22
|
+
`CallJoin` / `CallLeave` messages in the call's topic; the `GetCallMembers` command answered with `CallMembers`
|
|
23
|
+
(`CallsManager.getMembers(messageId, {limit, offset})`) for all the members of the call of a message;
|
|
24
|
+
`SessionPush.voipToken` for the iOS PushKit token; error codes `CallsUnavailable`, `CallFull`, `CallNotFound` and
|
|
25
|
+
`TooManyCallInvitees`. The SDK does the signalling only - connect to the media server with the access yourself.
|
|
26
|
+
- `ChatStateTracker.calls` (`CallsManager`): `get()` - the ongoing calls in your rooms keyed by room id, `getRinging()`
|
|
27
|
+
- the calls ringing at you, and `join`, `decline`, `invite`, `muteMember` and `kickMember`. The member events
|
|
28
|
+
replace the tracked call with a new object, and a `getRinging()` entry is replaced with a new object when its call
|
|
29
|
+
changes. `CallUpdated` of a room you are not in is ignored. Calls are not part of the state snapshot.
|
|
30
|
+
- Call modes, set per room in `Room.call` / `UpdateRoom.call` (`RoomCall`: `mode`, `userLimit`, `turnSeconds`):
|
|
31
|
+
`Conversation` (everyone speaks), `Stage` (moderators bring listeners who raised a hand on the stage) and `Queue`
|
|
32
|
+
(members raise a hand to take turns). `Call.mode`, `Call.turn` (who speaks until when, and by when they have to turn
|
|
33
|
+
the microphone on, or the turn ends - null once they did), `CallMember.handRaisedAt` (`CallsManager.getQueue(call)`
|
|
34
|
+
orders the raised hands), `CallMemberFlag` (`Camera`, `ScreenShare`, `Speaker`, `RaiseBlocked`), the optional title of a call
|
|
35
|
+
started with `JoinCall`, the `UpdateCallMember` command (`CallsManager.updateMember`: raising and lowering a hand,
|
|
36
|
+
moving on and off the stage, which also ends or skips a turn) and the `CallMode` error code for an operation the
|
|
37
|
+
mode of the call does not allow.
|
|
38
|
+
- `UserData.acceptCalls` (true by default) and `SetUserData.acceptCalls` (null or left out keeps it): with it off,
|
|
39
|
+
`JoinCall` starting a call in a one-to-one private room with you fails with the new `CallsNotAccepted` error code.
|
|
40
|
+
- `Call.autoEndAt`: when the server ends the call because nobody is left to talk with (null while it is not going to).
|
|
41
|
+
- Permissions `JoinCalls` (2^30), `ShareVideo` (2^31), `InviteToCall` (2^32) and `ManageCalls` (2^33). The last
|
|
42
|
+
three lie beyond the 31 bits JavaScript bitwise operators handle, so check and build permission masks with the
|
|
43
|
+
new `Permissions.has(mask, name)`, `Permissions.union(...masks)` and `Permissions.subtract(mask, removed)` instead
|
|
44
|
+
of `&`, `|` and `~`.
|
|
45
|
+
- `SetPermissionOverwrites.knownPermissions`: the mask of the permissions the client knows. The server changes only
|
|
46
|
+
these bits of the overwrites; without it, it keeps the bits from 2^30 up, so an older client does not clear the call
|
|
47
|
+
permissions it cannot show. `Permissions.getKnownMask()` gives the mask of all the permissions of the SDK for it.
|
|
48
|
+
|
|
49
|
+
### Changed
|
|
50
|
+
|
|
51
|
+
- `Room.call` is required, as are `UserState.calls` and `UserState.incomingCalls` - the server always sends them.
|
|
52
|
+
`MessageType` has the new `Call`, `CallJoin` and `CallLeave` values, so a `switch` over it may need new cases.
|
|
53
|
+
- State snapshots: version 4 (rooms with `call`); older snapshots are rejected.
|
|
54
|
+
|
|
55
|
+
### Fixed
|
|
56
|
+
|
|
57
|
+
- `PermissionsManager` computes permissions beyond the 31st bit correctly.
|
|
58
|
+
|
|
9
59
|
## [0.13.0]
|
|
10
60
|
|
|
11
61
|
### Added
|
package/build/index.cjs.js
CHANGED
|
@@ -40,6 +40,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
40
40
|
// EXPORTS
|
|
41
41
|
__webpack_require__.d(__webpack_exports__, {
|
|
42
42
|
AbstractRestClient: () => (/* reexport */ AbstractRestClient),
|
|
43
|
+
CallMemberFlag: () => (/* reexport */ CallMemberFlag),
|
|
43
44
|
ErrorCode: () => (/* reexport */ ErrorCode),
|
|
44
45
|
FilesClient: () => (/* reexport */ FilesClient),
|
|
45
46
|
HistoryRotation: () => (/* reexport */ HistoryRotation),
|
|
@@ -2289,7 +2290,7 @@ let UserStatus = /*#__PURE__*/function (UserStatus) {
|
|
|
2289
2290
|
/**
|
|
2290
2291
|
* Version of the {@link StateSnapshot} format. A snapshot of any other version is rejected on import.
|
|
2291
2292
|
*/
|
|
2292
|
-
const STATE_SNAPSHOT_VERSION =
|
|
2293
|
+
const STATE_SNAPSHOT_VERSION = 4;
|
|
2293
2294
|
|
|
2294
2295
|
/**
|
|
2295
2296
|
* Plain, JSON-serializable copy of the state tracked by {@link ChatStateTracker}, made to restore the state at the
|
|
@@ -3413,6 +3414,12 @@ class PermissionDefinition {
|
|
|
3413
3414
|
value;
|
|
3414
3415
|
maxLayer;
|
|
3415
3416
|
}
|
|
3417
|
+
const WORD = 2 ** 32;
|
|
3418
|
+
function combineWords(a, b, operation) {
|
|
3419
|
+
const high = operation(Math.floor(a / WORD), Math.floor(b / WORD)) >>> 0;
|
|
3420
|
+
const low = operation(a % WORD, b % WORD) >>> 0;
|
|
3421
|
+
return high * WORD + low;
|
|
3422
|
+
}
|
|
3416
3423
|
class Permissions {
|
|
3417
3424
|
static list = {
|
|
3418
3425
|
Root: {
|
|
@@ -3431,7 +3438,6 @@ class Permissions {
|
|
|
3431
3438
|
value: 1 << 3,
|
|
3432
3439
|
maxLayer: Layer.Space
|
|
3433
3440
|
},
|
|
3434
|
-
//ManageRoom: {value: 1 << 4, maxLayer: Layer.Room},
|
|
3435
3441
|
CreateTopics: {
|
|
3436
3442
|
value: 1 << 5,
|
|
3437
3443
|
maxLayer: Layer.Room
|
|
@@ -3531,8 +3537,59 @@ class Permissions {
|
|
|
3531
3537
|
EditMessages: {
|
|
3532
3538
|
value: 1 << 29,
|
|
3533
3539
|
maxLayer: Layer.Topic
|
|
3540
|
+
},
|
|
3541
|
+
JoinCalls: {
|
|
3542
|
+
value: 2 ** 30,
|
|
3543
|
+
maxLayer: Layer.Room
|
|
3544
|
+
},
|
|
3545
|
+
ShareVideo: {
|
|
3546
|
+
value: 2 ** 31,
|
|
3547
|
+
maxLayer: Layer.Room
|
|
3548
|
+
},
|
|
3549
|
+
InviteToCall: {
|
|
3550
|
+
value: 2 ** 32,
|
|
3551
|
+
maxLayer: Layer.Room
|
|
3552
|
+
},
|
|
3553
|
+
ManageCalls: {
|
|
3554
|
+
value: 2 ** 33,
|
|
3555
|
+
maxLayer: Layer.Room
|
|
3534
3556
|
}
|
|
3535
3557
|
};
|
|
3558
|
+
|
|
3559
|
+
/**
|
|
3560
|
+
* Whether the permission mask (e.g. from {@link PermissionsManager.calculatePermissions}) grants the permission.
|
|
3561
|
+
* Use it and {@link union} / {@link subtract} instead of `&` and `|`: JavaScript bitwise operators keep only
|
|
3562
|
+
* 32 bits, and permissions go beyond them.
|
|
3563
|
+
*/
|
|
3564
|
+
static has(mask, name) {
|
|
3565
|
+
const value = this.list[name].value;
|
|
3566
|
+
return combineWords(mask, value, (a, b) => a & b) === value;
|
|
3567
|
+
}
|
|
3568
|
+
|
|
3569
|
+
/**
|
|
3570
|
+
* The permission masks combined (`a | b`), safe for permissions beyond 32 bits.
|
|
3571
|
+
*/
|
|
3572
|
+
static union(...masks) {
|
|
3573
|
+
let result = 0;
|
|
3574
|
+
for (const mask of masks) {
|
|
3575
|
+
result = combineWords(result, mask, (a, b) => a | b);
|
|
3576
|
+
}
|
|
3577
|
+
return result;
|
|
3578
|
+
}
|
|
3579
|
+
|
|
3580
|
+
/**
|
|
3581
|
+
* The mask without the permissions of `removed` (`mask & ~removed`), safe for permissions beyond 32 bits.
|
|
3582
|
+
*/
|
|
3583
|
+
static subtract(mask, removed) {
|
|
3584
|
+
return combineWords(mask, removed, (a, b) => a & ~b);
|
|
3585
|
+
}
|
|
3586
|
+
|
|
3587
|
+
/**
|
|
3588
|
+
* Mask of all the permissions this version of the SDK knows - for `SetPermissionOverwrites.knownPermissions`.
|
|
3589
|
+
*/
|
|
3590
|
+
static getKnownMask() {
|
|
3591
|
+
return this.union(...Object.values(this.list).map(permission => permission.value));
|
|
3592
|
+
}
|
|
3536
3593
|
static getNames() {
|
|
3537
3594
|
return Object.keys(this.list);
|
|
3538
3595
|
}
|
|
@@ -3596,11 +3653,11 @@ class PermissionsManager extends EventTarget {
|
|
|
3596
3653
|
}
|
|
3597
3654
|
const ownedPermissions = await this.calculatePermissions(location);
|
|
3598
3655
|
const missing = [];
|
|
3599
|
-
|
|
3600
|
-
if (
|
|
3656
|
+
for (const name of permissionNames) {
|
|
3657
|
+
if (!Permissions.has(ownedPermissions, name)) {
|
|
3601
3658
|
missing.push(name);
|
|
3602
3659
|
}
|
|
3603
|
-
}
|
|
3660
|
+
}
|
|
3604
3661
|
return {
|
|
3605
3662
|
ok: missing.length === 0,
|
|
3606
3663
|
hasAll: missing.length === 0,
|
|
@@ -3751,8 +3808,8 @@ class PermissionsManager extends EventTarget {
|
|
|
3751
3808
|
for (const {
|
|
3752
3809
|
overwrites
|
|
3753
3810
|
} of rolesOverwrites) {
|
|
3754
|
-
allow
|
|
3755
|
-
deny
|
|
3811
|
+
allow = Permissions.union(allow, overwrites.allow ?? 0);
|
|
3812
|
+
deny = Permissions.union(deny, overwrites.deny ?? 0);
|
|
3756
3813
|
}
|
|
3757
3814
|
return {
|
|
3758
3815
|
allow,
|
|
@@ -3762,19 +3819,15 @@ class PermissionsManager extends EventTarget {
|
|
|
3762
3819
|
resolveOverwritesHierarchy(permissionOverwritesValues) {
|
|
3763
3820
|
let result = 0;
|
|
3764
3821
|
for (const value of permissionOverwritesValues) {
|
|
3765
|
-
if (value.allow
|
|
3822
|
+
if (Permissions.has(value.allow ?? 0, 'Root')) {
|
|
3766
3823
|
return this.getRootAccessValue();
|
|
3767
3824
|
}
|
|
3768
|
-
result = result
|
|
3825
|
+
result = Permissions.union(Permissions.subtract(result, value.deny ?? 0), value.allow ?? 0);
|
|
3769
3826
|
}
|
|
3770
3827
|
return result;
|
|
3771
3828
|
}
|
|
3772
3829
|
getRootAccessValue() {
|
|
3773
|
-
|
|
3774
|
-
for (const name of Permissions.getNames()) {
|
|
3775
|
-
result |= Permissions.getByName(name).value;
|
|
3776
|
-
}
|
|
3777
|
-
return result;
|
|
3830
|
+
return Permissions.union(...Permissions.getNames().map(name => Permissions.getByName(name).value));
|
|
3778
3831
|
}
|
|
3779
3832
|
async fetchComputedPermissions(location) {
|
|
3780
3833
|
const result = await this.tracker.client.send('GetComputedPermissions', {
|
|
@@ -4084,6 +4137,189 @@ class RelationshipsManager {
|
|
|
4084
4137
|
this.promises.forgetAll();
|
|
4085
4138
|
}
|
|
4086
4139
|
}
|
|
4140
|
+
;// ./src/state-tracker/CallsManager.ts
|
|
4141
|
+
|
|
4142
|
+
class CallsManager {
|
|
4143
|
+
list = new ObservableIndexedObjectCollection(call => call.location.roomId);
|
|
4144
|
+
ringing = new ObservableIndexedObjectCollection(incoming => incoming.call.location.roomId);
|
|
4145
|
+
constructor(tracker) {
|
|
4146
|
+
this.tracker = tracker;
|
|
4147
|
+
this.tracker.client.on('Session', ev => this.handleSession(ev));
|
|
4148
|
+
this.tracker.client.on('CallUpdated', ev => this.handleCallUpdated(ev));
|
|
4149
|
+
this.tracker.client.on('CallMemberJoined', ev => this.handleMemberChanged(ev.roomId, ev.member.user.id, ev.member));
|
|
4150
|
+
this.tracker.client.on('CallMemberUpdated', ev => this.handleMemberChanged(ev.roomId, ev.userId, ev.member));
|
|
4151
|
+
this.tracker.client.on('CallMemberLeft', ev => this.handleMemberChanged(ev.roomId, ev.userId));
|
|
4152
|
+
this.tracker.client.on('IncomingCallUpdated', ev => this.handleIncomingCallUpdated(ev));
|
|
4153
|
+
this.tracker.client.on('RoomLeft', ev => this.handleRoomGone(ev));
|
|
4154
|
+
this.tracker.client.on('RoomDeleted', ev => this.handleRoomGone(ev));
|
|
4155
|
+
this.tracker.client.on('SpaceLeft', ev => this.handleSpaceGone(ev));
|
|
4156
|
+
this.tracker.client.on('SpaceDeleted', ev => this.handleSpaceGone(ev));
|
|
4157
|
+
}
|
|
4158
|
+
|
|
4159
|
+
/**
|
|
4160
|
+
* Ongoing calls in the rooms you are a member of, keyed by room id - at most one per room. Filled with the
|
|
4161
|
+
* session and kept current by the server; a call leaves the collection when its last member leaves.
|
|
4162
|
+
* Not part of the state snapshot, so it stays empty until the first session.
|
|
4163
|
+
*/
|
|
4164
|
+
async get() {
|
|
4165
|
+
await this.tracker.getMe();
|
|
4166
|
+
return this.list;
|
|
4167
|
+
}
|
|
4168
|
+
|
|
4169
|
+
/**
|
|
4170
|
+
* Calls ringing at you, keyed by room id. A call leaves the collection when it is answered or declined on any of
|
|
4171
|
+
* your devices, or when it ends. Filled with the session, like the ongoing calls.
|
|
4172
|
+
*/
|
|
4173
|
+
async getRinging() {
|
|
4174
|
+
await this.tracker.getMe();
|
|
4175
|
+
return this.ringing;
|
|
4176
|
+
}
|
|
4177
|
+
|
|
4178
|
+
/**
|
|
4179
|
+
* Members of the call with a raised hand, in the order they raised it - the queue in the `Queue` mode.
|
|
4180
|
+
*/
|
|
4181
|
+
getQueue(call) {
|
|
4182
|
+
return call.members.filter(member => member.handRaisedAt)
|
|
4183
|
+
// Whole seconds; the server breaks ties by comparing user ids as plain strings.
|
|
4184
|
+
.sort((a, b) => Date.parse(a.handRaisedAt) - Date.parse(b.handRaisedAt) || (a.user.id < b.user.id ? -1 : Number(a.user.id > b.user.id)));
|
|
4185
|
+
}
|
|
4186
|
+
|
|
4187
|
+
/**
|
|
4188
|
+
* A page of the members of the call the call message stands for, in the order they joined. The message itself
|
|
4189
|
+
* carries only some of them (`MessageCall.partialMembers`) and their count.
|
|
4190
|
+
*/
|
|
4191
|
+
async getMembers(messageId, page = {}) {
|
|
4192
|
+
return (await this.send('GetCallMembers', {
|
|
4193
|
+
messageId,
|
|
4194
|
+
...page
|
|
4195
|
+
})).members;
|
|
4196
|
+
}
|
|
4197
|
+
|
|
4198
|
+
/**
|
|
4199
|
+
* Join the call in the room, starting it if there is none. Connect to the media server with the returned access
|
|
4200
|
+
* yourself; leaving the call is disconnecting from it. Joining another call makes the server end your
|
|
4201
|
+
* participation in the previous one. In the `Stage` and `Queue` modes you join as a listener (a moderator as a
|
|
4202
|
+
* speaker), and the title given when starting the call names its topic.
|
|
4203
|
+
*/
|
|
4204
|
+
join(roomId, title) {
|
|
4205
|
+
return this.send('JoinCall', {
|
|
4206
|
+
roomId,
|
|
4207
|
+
title
|
|
4208
|
+
});
|
|
4209
|
+
}
|
|
4210
|
+
|
|
4211
|
+
/**
|
|
4212
|
+
* Stop the call ringing at you, on all of your devices. In a one-to-one private room it also ends the call.
|
|
4213
|
+
*/
|
|
4214
|
+
async decline(roomId) {
|
|
4215
|
+
await this.send('DeclineCall', {
|
|
4216
|
+
roomId
|
|
4217
|
+
});
|
|
4218
|
+
}
|
|
4219
|
+
|
|
4220
|
+
/**
|
|
4221
|
+
* Invite the given members of the room, or the room members having one of the roles, to the call - it rings at
|
|
4222
|
+
* them. Members already in the call and you are skipped.
|
|
4223
|
+
*/
|
|
4224
|
+
async invite(roomId, target) {
|
|
4225
|
+
await this.send('InviteToCall', {
|
|
4226
|
+
roomId,
|
|
4227
|
+
...target
|
|
4228
|
+
});
|
|
4229
|
+
}
|
|
4230
|
+
|
|
4231
|
+
/**
|
|
4232
|
+
* Turn off the microphone of a call member. Only they can turn it on again.
|
|
4233
|
+
*/
|
|
4234
|
+
async muteMember(roomId, userId) {
|
|
4235
|
+
await this.send('MuteCallMember', {
|
|
4236
|
+
roomId,
|
|
4237
|
+
userId
|
|
4238
|
+
});
|
|
4239
|
+
}
|
|
4240
|
+
async kickMember(roomId, userId) {
|
|
4241
|
+
await this.send('KickCallMember', {
|
|
4242
|
+
roomId,
|
|
4243
|
+
userId
|
|
4244
|
+
});
|
|
4245
|
+
}
|
|
4246
|
+
|
|
4247
|
+
/**
|
|
4248
|
+
* Raise or lower your hand (in the `Queue` mode: enter or leave the queue) and leave the stage, which in the
|
|
4249
|
+
* `Queue` mode ends your turn. A moderator also moves a member to the stage and off it (skipping their turn),
|
|
4250
|
+
* lowers their hand and blocks them from raising it until the call ends.
|
|
4251
|
+
*/
|
|
4252
|
+
async updateMember(roomId, userId, change) {
|
|
4253
|
+
await this.send('UpdateCallMember', {
|
|
4254
|
+
roomId,
|
|
4255
|
+
userId,
|
|
4256
|
+
...change
|
|
4257
|
+
});
|
|
4258
|
+
}
|
|
4259
|
+
async send(type, data) {
|
|
4260
|
+
const result = await this.tracker.client.send(type, data);
|
|
4261
|
+
if (result.error) {
|
|
4262
|
+
throw result.error;
|
|
4263
|
+
}
|
|
4264
|
+
return result.data;
|
|
4265
|
+
}
|
|
4266
|
+
handleSession(ev) {
|
|
4267
|
+
this.list.reconcile(...ev.state.calls);
|
|
4268
|
+
this.ringing.reconcile(...ev.state.incomingCalls);
|
|
4269
|
+
}
|
|
4270
|
+
handleCallUpdated(ev) {
|
|
4271
|
+
if (ev.call) {
|
|
4272
|
+
// An update sent before the server learned you left the room
|
|
4273
|
+
if (this.tracker.rooms._getRoom(ev.roomId)) {
|
|
4274
|
+
this.setCall(ev.call);
|
|
4275
|
+
}
|
|
4276
|
+
} else {
|
|
4277
|
+
this.list.delete(ev.roomId);
|
|
4278
|
+
this.ringing.delete(ev.roomId);
|
|
4279
|
+
}
|
|
4280
|
+
}
|
|
4281
|
+
handleIncomingCallUpdated(ev) {
|
|
4282
|
+
if (ev.incomingCall) {
|
|
4283
|
+
this.ringing.set(ev.incomingCall);
|
|
4284
|
+
} else {
|
|
4285
|
+
this.ringing.delete(ev.roomId);
|
|
4286
|
+
}
|
|
4287
|
+
}
|
|
4288
|
+
handleMemberChanged(roomId, userId, member) {
|
|
4289
|
+
const call = this.list.get(roomId);
|
|
4290
|
+
if (!call) {
|
|
4291
|
+
return;
|
|
4292
|
+
}
|
|
4293
|
+
const members = call.members.filter(item => item.user.id !== userId);
|
|
4294
|
+
if (member) {
|
|
4295
|
+
const index = call.members.findIndex(item => item.user.id === userId);
|
|
4296
|
+
members.splice(index === -1 ? members.length : index, 0, member);
|
|
4297
|
+
}
|
|
4298
|
+
this.setCall({
|
|
4299
|
+
...call,
|
|
4300
|
+
members
|
|
4301
|
+
});
|
|
4302
|
+
}
|
|
4303
|
+
setCall(call) {
|
|
4304
|
+
this.list.set(call);
|
|
4305
|
+
const incoming = this.ringing.get(call.location.roomId);
|
|
4306
|
+
if (incoming) {
|
|
4307
|
+
this.ringing.set({
|
|
4308
|
+
...incoming,
|
|
4309
|
+
call
|
|
4310
|
+
});
|
|
4311
|
+
}
|
|
4312
|
+
}
|
|
4313
|
+
handleRoomGone(ev) {
|
|
4314
|
+
this.list.delete(ev.id);
|
|
4315
|
+
this.ringing.delete(ev.id);
|
|
4316
|
+
}
|
|
4317
|
+
handleSpaceGone(ev) {
|
|
4318
|
+
const roomIdsOf = calls => calls.filter(call => call.location.spaceId === ev.id).map(call => call.location.roomId);
|
|
4319
|
+
this.list.delete(...roomIdsOf(this.list.items));
|
|
4320
|
+
this.ringing.delete(...roomIdsOf(this.ringing.items.map(incoming => incoming.call)));
|
|
4321
|
+
}
|
|
4322
|
+
}
|
|
4087
4323
|
;// ./src/state-tracker/ChatStateTracker.ts
|
|
4088
4324
|
|
|
4089
4325
|
|
|
@@ -4093,6 +4329,7 @@ class RelationshipsManager {
|
|
|
4093
4329
|
|
|
4094
4330
|
|
|
4095
4331
|
|
|
4332
|
+
|
|
4096
4333
|
class ChatStateTracker {
|
|
4097
4334
|
client;
|
|
4098
4335
|
|
|
@@ -4125,6 +4362,11 @@ class ChatStateTracker {
|
|
|
4125
4362
|
* State of relationships with other users.
|
|
4126
4363
|
*/
|
|
4127
4364
|
relationships;
|
|
4365
|
+
|
|
4366
|
+
/**
|
|
4367
|
+
* State of the calls in your rooms and of the calls ringing at you.
|
|
4368
|
+
*/
|
|
4369
|
+
calls;
|
|
4128
4370
|
_me = null;
|
|
4129
4371
|
deferredSession = new DeferredTask();
|
|
4130
4372
|
sessionReceived = false;
|
|
@@ -4138,6 +4380,7 @@ class ChatStateTracker {
|
|
|
4138
4380
|
this.emoticons = new EmoticonsManager(this);
|
|
4139
4381
|
this.users = new UsersManager(this);
|
|
4140
4382
|
this.relationships = new RelationshipsManager(this);
|
|
4383
|
+
this.calls = new CallsManager(this);
|
|
4141
4384
|
|
|
4142
4385
|
// Registered after the managers, so it runs once they have applied the session.
|
|
4143
4386
|
this.client.on('Session', ev => this.handleSessionAfterImport(ev));
|
|
@@ -4751,9 +4994,22 @@ class FilesClient extends AbstractRestClient {
|
|
|
4751
4994
|
return this.send('GET', 'files?' + searchParams);
|
|
4752
4995
|
}
|
|
4753
4996
|
}
|
|
4997
|
+
;// ./src/protocol/schemes/Call.ts
|
|
4998
|
+
let CallMemberFlag = /*#__PURE__*/function (CallMemberFlag) {
|
|
4999
|
+
CallMemberFlag[CallMemberFlag["Camera"] = 1] = "Camera";
|
|
5000
|
+
CallMemberFlag[CallMemberFlag["ScreenShare"] = 2] = "ScreenShare";
|
|
5001
|
+
CallMemberFlag[CallMemberFlag["Speaker"] = 4] = "Speaker";
|
|
5002
|
+
CallMemberFlag[CallMemberFlag["RaiseBlocked"] = 16] = "RaiseBlocked";
|
|
5003
|
+
return CallMemberFlag;
|
|
5004
|
+
}({});
|
|
4754
5005
|
;// ./src/protocol/schemes/events/Error.ts
|
|
4755
5006
|
let ErrorCode = /*#__PURE__*/function (ErrorCode) {
|
|
4756
5007
|
ErrorCode["Authentication"] = "AuthenticationException";
|
|
5008
|
+
ErrorCode["CallFull"] = "CallFullException";
|
|
5009
|
+
ErrorCode["CallMode"] = "CallModeException";
|
|
5010
|
+
ErrorCode["CallNotFound"] = "CallNotFoundException";
|
|
5011
|
+
ErrorCode["CallsNotAccepted"] = "CallsNotAcceptedException";
|
|
5012
|
+
ErrorCode["CallsUnavailable"] = "CallsUnavailableException";
|
|
4757
5013
|
ErrorCode["CommandRateLimitExceeded"] = "CommandRateLimitExceededException";
|
|
4758
5014
|
ErrorCode["InvalidSearchQuery"] = "InvalidSearchQueryException";
|
|
4759
5015
|
ErrorCode["MessageSearchUnavailable"] = "MessageSearchUnavailableException";
|
|
@@ -4762,6 +5018,7 @@ let ErrorCode = /*#__PURE__*/function (ErrorCode) {
|
|
|
4762
5018
|
ErrorCode["RoomIgnored"] = "RoomIgnoredException";
|
|
4763
5019
|
ErrorCode["RoomNotFound"] = "RoomNotFoundException";
|
|
4764
5020
|
ErrorCode["SpaceJoinRestricted"] = "SpaceJoinRestrictedException";
|
|
5021
|
+
ErrorCode["TooManyCallInvitees"] = "TooManyCallInviteesException";
|
|
4765
5022
|
ErrorCode["TopicNotFound"] = "TopicNotFoundException";
|
|
4766
5023
|
ErrorCode["UserNotFound"] = "UserNotFoundException";
|
|
4767
5024
|
return ErrorCode;
|