@devanachat/sdk 0.8.1 → 0.9.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 +34 -4
- package/build/index.cjs.js +41 -20
- package/build/index.cjs.js.map +1 -1
- package/build/index.mjs +41 -20
- 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/Permissions.d.ts +4 -0
- package/build/types/protocol/schemes/Emoticon.d.ts +2 -3
- package/build/types/protocol/schemes/Entitlements.d.ts +2 -1
- package/build/types/protocol/schemes/Reaction.d.ts +2 -0
- package/build/types/protocol/schemes/commands/CreateEmoticon.d.ts +1 -1
- package/build/types/protocol/schemes/commands/GetEmoticons.d.ts +1 -0
- package/build/types/protocol/schemes/events/EmoticonDeleted.d.ts +1 -1
- package/build/types/protocol/schemes/events/Emoticons.d.ts +1 -1
- package/build/types/state-tracker/EmoticonsManager.d.ts +1 -1
- package/build/types/state-tracker/StateSnapshot.d.ts +1 -4
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,7 +4,37 @@ All notable changes to this project are documented in this file.
|
|
|
4
4
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and the project follows
|
|
5
5
|
[semver](https://semver.org) (`0.x` minor releases may break the API).
|
|
6
6
|
|
|
7
|
-
## [
|
|
7
|
+
## [Unreleased]
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- `Permissions.list.UseExternalEmoticons` (`1 << 26`, space and room layer): using emoticons of other spaces.
|
|
12
|
+
- `UserFeature.ExternalEmoticons` (`user.external_emoticons`): the account may use emoticons outside their spaces.
|
|
13
|
+
- `MessageReaction.name` and `ToggledReaction.name`: the emoticon name of an `Emoticon` reaction.
|
|
14
|
+
- `GetEmoticons` takes `ids` (up to 100) and returns those of the emoticons the user may see - the ones of the spaces
|
|
15
|
+
they belong to and of the spaces that let their emoticons be used outside (space flag `1 << 2`, `spaceId` and `user`
|
|
16
|
+
null for a space the user does not belong to); the rest is left out. The response has `location: null` and does not
|
|
17
|
+
change the collections returned by `EmoticonsManager.get()`.
|
|
18
|
+
|
|
19
|
+
### Changed
|
|
20
|
+
|
|
21
|
+
- **Breaking:** there are no global emoticons any more. `EmoticonsManager.get()` requires a `spaceId`,
|
|
22
|
+
`CreateEmoticon.spaceId` and `EmoticonDeleted.spaceId` are required, and `EmoticonsSnapshot.spaceId` is a string -
|
|
23
|
+
global emoticons kept in an older snapshot are dropped on import.
|
|
24
|
+
- **Breaking:** `Emoticon.tag` (emoticon categories) is gone. `Emoticon.spaceId` and `Emoticon.user` (the author) are
|
|
25
|
+
`null` for an emoticon of a space the user does not belong to.
|
|
26
|
+
- **Breaking (protocol):** an `Emoticon` reaction (`React`, `Unreact`, `GetReactionDetails`, reactions of a message,
|
|
27
|
+
poll options) is identified by the emoticon id in `value` instead of its name. Servers before this change send the
|
|
28
|
+
name in `value` and no `name` - an application that has to work with both tells them apart by the length of `value`
|
|
29
|
+
(a name has at most 20 characters, an id 22).
|
|
30
|
+
|
|
31
|
+
### Fixed
|
|
32
|
+
|
|
33
|
+
- Withdrawing the last own reaction from a message (`Reacted` with `isAdded: false`) left it in
|
|
34
|
+
`TopicHistoryWindow.myReactions` in apps built with Babel's loose object rest transform (e.g. `babel-preset-expo` on
|
|
35
|
+
web) - it dropped the message ID from the exclusion list (babel/babel#18196).
|
|
36
|
+
|
|
37
|
+
## [0.8.1]
|
|
8
38
|
|
|
9
39
|
### Added
|
|
10
40
|
|
|
@@ -28,7 +58,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
|
28
58
|
earlier jump) waits for it to end and then jumps, instead of returning at once without loading anything - a caller
|
|
29
59
|
checking `has(id)` afterwards took the message for missing.
|
|
30
60
|
|
|
31
|
-
## [0.8.0]
|
|
61
|
+
## [0.8.0]
|
|
32
62
|
|
|
33
63
|
### Added
|
|
34
64
|
|
|
@@ -53,7 +83,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
|
53
83
|
fetches it anew (as on a reconnect) and fetches the restored topics other than the default ones.
|
|
54
84
|
- Type exports `StateSnapshot`, `StateSnapshotIntent`, `TopicHistorySnapshot`, `RoomMembersSnapshot`,
|
|
55
85
|
`SpaceRoomsSnapshot`, `RoomFollowedTopicsSnapshot`, `EmoticonsSnapshot` and the `STATE_SNAPSHOT_VERSION` constant.
|
|
56
|
-
## [0.7.0]
|
|
86
|
+
## [0.7.0]
|
|
57
87
|
|
|
58
88
|
### Added
|
|
59
89
|
|
|
@@ -97,7 +127,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
|
97
127
|
|
|
98
128
|
Migrating from `polfan-server-js-client` 0.5.0: see [docs/migration-0.5-to-0.7.md](docs/migration-0.5-to-0.7.md).
|
|
99
129
|
|
|
100
|
-
## [0.6.0]
|
|
130
|
+
## [0.6.0]
|
|
101
131
|
|
|
102
132
|
The first release under the new name. Earlier versions were published as `polfan-server-js-client`.
|
|
103
133
|
|
package/build/index.cjs.js
CHANGED
|
@@ -1118,10 +1118,12 @@ class TopicHistoryWindow extends TraversableRemoteCollection {
|
|
|
1118
1118
|
value
|
|
1119
1119
|
});
|
|
1120
1120
|
}
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1121
|
+
|
|
1122
|
+
// Not `{[ev.messageId]: _, ...rest}` - Babel's loose object rest drops the key when the binding is unused (babel/babel#18196)
|
|
1123
|
+
const myReactions = {
|
|
1124
|
+
...this.internalState.myReactions
|
|
1125
|
+
};
|
|
1126
|
+
delete myReactions[ev.messageId];
|
|
1125
1127
|
if (own.length) {
|
|
1126
1128
|
myReactions[ev.messageId] = own;
|
|
1127
1129
|
}
|
|
@@ -2154,7 +2156,15 @@ class RoomsManager {
|
|
|
2154
2156
|
const promise = this.tracker.client.send('GetTopics', {
|
|
2155
2157
|
roomId,
|
|
2156
2158
|
topicIds: idsToFetch
|
|
2157
|
-
}).then(result =>
|
|
2159
|
+
}).then(result => {
|
|
2160
|
+
const topics = this.topics.get(roomId);
|
|
2161
|
+
if (topics) {
|
|
2162
|
+
topics.set(...result.data.topics);
|
|
2163
|
+
} else {
|
|
2164
|
+
// A room not joined yet has nowhere to keep them - let them be fetched again once it is.
|
|
2165
|
+
this.topicsPromises.forget(...idsToFetch.map(topicId => roomId + topicId));
|
|
2166
|
+
}
|
|
2167
|
+
});
|
|
2158
2168
|
idsToFetch.forEach(topicId => this.topicsPromises.register(promise, roomId + topicId));
|
|
2159
2169
|
}
|
|
2160
2170
|
for (const topicId of tryToFetchTopicIds) {
|
|
@@ -3058,6 +3068,10 @@ class Permissions {
|
|
|
3058
3068
|
SearchMessages: {
|
|
3059
3069
|
value: 1 << 25,
|
|
3060
3070
|
maxLayer: Layer.Room
|
|
3071
|
+
},
|
|
3072
|
+
UseExternalEmoticons: {
|
|
3073
|
+
value: 1 << 26,
|
|
3074
|
+
maxLayer: Layer.Room
|
|
3061
3075
|
}
|
|
3062
3076
|
};
|
|
3063
3077
|
static getNames() {
|
|
@@ -3351,7 +3365,6 @@ class PermissionsManager extends EventTarget {
|
|
|
3351
3365
|
;// ./src/state-tracker/EmoticonsManager.ts
|
|
3352
3366
|
|
|
3353
3367
|
|
|
3354
|
-
const GLOBAL_KEY = 'global';
|
|
3355
3368
|
class EmoticonsManager {
|
|
3356
3369
|
list = new IndexedCollection();
|
|
3357
3370
|
emoticonsPromises = new PromiseRegistry();
|
|
@@ -3364,8 +3377,7 @@ class EmoticonsManager {
|
|
|
3364
3377
|
this.tracker.client.on('Session', () => this.handleSession());
|
|
3365
3378
|
}
|
|
3366
3379
|
async get(spaceId) {
|
|
3367
|
-
|
|
3368
|
-
if (this.emoticonsPromises.notExist(key)) {
|
|
3380
|
+
if (this.emoticonsPromises.notExist(spaceId)) {
|
|
3369
3381
|
this.emoticonsPromises.registerByFunction(async () => {
|
|
3370
3382
|
const result = await this.tracker.client.send('GetEmoticons', {
|
|
3371
3383
|
spaceId
|
|
@@ -3374,10 +3386,10 @@ class EmoticonsManager {
|
|
|
3374
3386
|
throw result.error;
|
|
3375
3387
|
}
|
|
3376
3388
|
this.handleEmoticons(result.data);
|
|
3377
|
-
},
|
|
3389
|
+
}, spaceId);
|
|
3378
3390
|
}
|
|
3379
|
-
await this.emoticonsPromises.get(
|
|
3380
|
-
return this.list.get(
|
|
3391
|
+
await this.emoticonsPromises.get(spaceId);
|
|
3392
|
+
return this.list.get(spaceId);
|
|
3381
3393
|
}
|
|
3382
3394
|
|
|
3383
3395
|
/**
|
|
@@ -3385,8 +3397,8 @@ class EmoticonsManager {
|
|
|
3385
3397
|
* @internal
|
|
3386
3398
|
*/
|
|
3387
3399
|
_exportEmoticons() {
|
|
3388
|
-
return Array.from(this.list.items).map(([
|
|
3389
|
-
spaceId
|
|
3400
|
+
return Array.from(this.list.items).map(([spaceId, emoticons]) => ({
|
|
3401
|
+
spaceId,
|
|
3390
3402
|
emoticons: emoticons.items
|
|
3391
3403
|
}));
|
|
3392
3404
|
}
|
|
@@ -3401,17 +3413,19 @@ class EmoticonsManager {
|
|
|
3401
3413
|
spaceId,
|
|
3402
3414
|
emoticons
|
|
3403
3415
|
} of snapshots) {
|
|
3404
|
-
|
|
3416
|
+
// TODO(emoticons-compat): snapshots written before the global emoticons were gone still hold them under
|
|
3417
|
+
// null - drop the comment once no such snapshot can be left on a device (the check itself stays).
|
|
3418
|
+
if (!joinedSpaceIds.has(spaceId)) {
|
|
3405
3419
|
continue;
|
|
3406
3420
|
}
|
|
3407
3421
|
this.handleEmoticons({
|
|
3408
3422
|
location: {
|
|
3409
|
-
spaceId
|
|
3423
|
+
spaceId
|
|
3410
3424
|
},
|
|
3411
3425
|
emoticons
|
|
3412
3426
|
});
|
|
3413
3427
|
// Served from the snapshot until the session invalidates it.
|
|
3414
|
-
this.emoticonsPromises.register(Promise.resolve(), spaceId
|
|
3428
|
+
this.emoticonsPromises.register(Promise.resolve(), spaceId);
|
|
3415
3429
|
}
|
|
3416
3430
|
}
|
|
3417
3431
|
|
|
@@ -3420,13 +3434,19 @@ class EmoticonsManager {
|
|
|
3420
3434
|
* @internal
|
|
3421
3435
|
*/
|
|
3422
3436
|
_forgetSpacesExcept(spaceIds) {
|
|
3423
|
-
const keptKeys = new Set(
|
|
3437
|
+
const keptKeys = new Set(spaceIds);
|
|
3424
3438
|
const removedKeys = Array.from(this.list.items.keys()).filter(key => !keptKeys.has(key));
|
|
3425
3439
|
this.list.delete(...removedKeys);
|
|
3426
3440
|
this.emoticonsPromises.forget(...removedKeys);
|
|
3427
3441
|
}
|
|
3428
3442
|
handleEmoticons(event) {
|
|
3429
|
-
|
|
3443
|
+
// A selection by ids has no location.
|
|
3444
|
+
// TODO(emoticons-compat): one without a space is the always empty list of the gone global emoticons, sent
|
|
3445
|
+
// until the server stops answering old clients that way.
|
|
3446
|
+
const spaceId = event.location?.spaceId;
|
|
3447
|
+
if (!spaceId) {
|
|
3448
|
+
return;
|
|
3449
|
+
}
|
|
3430
3450
|
if (!this.list.has(spaceId)) {
|
|
3431
3451
|
this.list.set([spaceId, new ObservableIndexedObjectCollection('id')]);
|
|
3432
3452
|
}
|
|
@@ -3437,11 +3457,11 @@ class EmoticonsManager {
|
|
|
3437
3457
|
this.list.get(spaceId).reconcile(...event.emoticons);
|
|
3438
3458
|
}
|
|
3439
3459
|
handleNewEmoticon(ev) {
|
|
3440
|
-
const collection = this.list.get(ev.emoticon.spaceId
|
|
3460
|
+
const collection = this.list.get(ev.emoticon.spaceId);
|
|
3441
3461
|
collection?.set(ev.emoticon);
|
|
3442
3462
|
}
|
|
3443
3463
|
handleEmoticonDeleted(ev) {
|
|
3444
|
-
const collection = this.list.get(ev.spaceId
|
|
3464
|
+
const collection = this.list.get(ev.spaceId);
|
|
3445
3465
|
collection?.delete(ev.emoticonId);
|
|
3446
3466
|
}
|
|
3447
3467
|
handleSpaceDeleted(event) {
|
|
@@ -4324,6 +4344,7 @@ let UserFeature = /*#__PURE__*/function (UserFeature) {
|
|
|
4324
4344
|
UserFeature["MessageLength"] = "user.message.length";
|
|
4325
4345
|
UserFeature["StorageLimit"] = "user.storage.limit";
|
|
4326
4346
|
UserFeature["StorageSingleFileLimit"] = "user.storage.single_file_limit";
|
|
4347
|
+
UserFeature["ExternalEmoticons"] = "user.external_emoticons";
|
|
4327
4348
|
return UserFeature;
|
|
4328
4349
|
}({});
|
|
4329
4350
|
|