@devanachat/sdk 0.10.0 → 0.12.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 +76 -0
- package/README.md +2 -2
- package/build/index.cjs.js +533 -147
- package/build/index.cjs.js.map +1 -1
- package/build/index.mjs +531 -148
- 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 +21 -4
- package/build/types/Permissions.d.ts +13 -1
- package/build/types/index.d.ts +4 -3
- package/build/types/protocol/index.d.ts +18 -4
- package/build/types/protocol/schemes/Message.d.ts +4 -0
- package/build/types/protocol/schemes/MessageEmbed.d.ts +83 -0
- package/build/types/protocol/schemes/Role.d.ts +6 -0
- package/build/types/protocol/schemes/Space.d.ts +1 -0
- package/build/types/protocol/schemes/Topic.d.ts +1 -0
- package/build/types/protocol/schemes/commands/AckInteraction.d.ts +10 -0
- package/build/types/protocol/schemes/commands/CreateMessage.d.ts +8 -0
- package/build/types/protocol/schemes/commands/GetGifCategories.d.ts +3 -0
- package/build/types/protocol/schemes/commands/GetMessages.d.ts +1 -0
- package/build/types/protocol/schemes/commands/Interact.d.ts +5 -0
- package/build/types/protocol/schemes/commands/SearchGifs.d.ts +5 -0
- package/build/types/protocol/schemes/commands/Type.d.ts +4 -0
- package/build/types/protocol/schemes/commands/UpdateMessage.d.ts +8 -0
- package/build/types/protocol/schemes/commands/UpdateRole.d.ts +2 -0
- package/build/types/protocol/schemes/commands/UpdateSpace.d.ts +1 -0
- package/build/types/protocol/schemes/commands/UpdateTopic.d.ts +1 -0
- package/build/types/protocol/schemes/events/Error.d.ts +3 -0
- package/build/types/protocol/schemes/events/FoundGifs.d.ts +14 -0
- package/build/types/protocol/schemes/events/GifCategories.d.ts +8 -0
- package/build/types/protocol/schemes/events/Interacted.d.ts +4 -0
- package/build/types/protocol/schemes/events/InteractionResolved.d.ts +7 -0
- package/build/types/protocol/schemes/events/MessageUpdated.d.ts +6 -0
- package/build/types/protocol/schemes/events/Messages.d.ts +6 -2
- package/build/types/protocol/schemes/events/NewInteraction.d.ts +10 -0
- package/build/types/protocol/schemes/events/NewMessage.d.ts +4 -0
- package/build/types/protocol/schemes/events/Typing.d.ts +5 -0
- package/build/types/state-tracker/PermissionsManager.d.ts +1 -1
- package/build/types/state-tracker/RoomMessagesHistory.d.ts +7 -2
- package/build/types/state-tracker/RoomsManager.d.ts +14 -1
- package/build/types/state-tracker/StateSnapshot.d.ts +5 -1
- package/build/types/state-tracker/TopicHistoryWindow.d.ts +29 -2
- package/build/types/state-tracker/TypingManager.d.ts +35 -0
- package/build/types/state-tracker/functions.d.ts +8 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Message, ReactionUpdated, MessagesRedacted, NewMessage, Reacted, Topic, UserReaction } from "../protocol";
|
|
1
|
+
import { Message, ReactionUpdated, MessagesRedacted, MessageUpdated, NewMessage, Reacted, Topic, UserReaction } from "../protocol";
|
|
2
2
|
import { ChatStateTracker } from "./ChatStateTracker";
|
|
3
3
|
import { CollectionEventMap, ObservableIndexedObjectCollection } from "../IndexedObjectCollection";
|
|
4
4
|
export declare enum WindowState {
|
|
@@ -143,6 +143,8 @@ export declare class TopicHistoryWindow extends TraversableRemoteCollection<Mess
|
|
|
143
143
|
traverseLock: boolean;
|
|
144
144
|
includeMyReactions: boolean;
|
|
145
145
|
myReactions: Record<string, UserReaction[]>;
|
|
146
|
+
includeRepliedMessages: boolean;
|
|
147
|
+
repliedMessages: Map<string, Message>;
|
|
146
148
|
liveLimit: number | null;
|
|
147
149
|
};
|
|
148
150
|
/**
|
|
@@ -166,6 +168,17 @@ export declare class TopicHistoryWindow extends TraversableRemoteCollection<Mess
|
|
|
166
168
|
*/
|
|
167
169
|
get includeMyReactions(): boolean;
|
|
168
170
|
set includeMyReactions(value: boolean);
|
|
171
|
+
/**
|
|
172
|
+
* Whether the history is fetched together with the messages its messages reply to.
|
|
173
|
+
* Turn it off only where replies are never shown with what they reply to.
|
|
174
|
+
*/
|
|
175
|
+
get includeRepliedMessages(): boolean;
|
|
176
|
+
set includeRepliedMessages(value: boolean);
|
|
177
|
+
/**
|
|
178
|
+
* The message the given one replies to: null when it replies to nothing or the replied message is gone,
|
|
179
|
+
* undefined when the window does not know it (replied messages are not fetched).
|
|
180
|
+
*/
|
|
181
|
+
getRepliedMessage(message: Message): Message | null | undefined;
|
|
169
182
|
/**
|
|
170
183
|
* Maximum number of items a window that has not been fetched yet (LIVE state) collects from the incoming
|
|
171
184
|
* messages. Null for the same as {@link limit}. It keeps the windows of topics nobody looks at small;
|
|
@@ -186,13 +199,14 @@ export declare class TopicHistoryWindow extends TraversableRemoteCollection<Mess
|
|
|
186
199
|
_exportLatest(limit: number): {
|
|
187
200
|
messages: Message[];
|
|
188
201
|
myReactions: Record<string, UserReaction[]>;
|
|
202
|
+
repliedMessages: Message[];
|
|
189
203
|
} | null;
|
|
190
204
|
/**
|
|
191
205
|
* Fill the window with saved latest messages, as if they were just fetched; the next reset to the latest replaces
|
|
192
206
|
* them.
|
|
193
207
|
* @internal
|
|
194
208
|
*/
|
|
195
|
-
_restoreLatest(messages: Message[], myReactions: Record<string, UserReaction[]
|
|
209
|
+
_restoreLatest(messages: Message[], myReactions: Record<string, UserReaction[]>, repliedMessages: Message[]): void;
|
|
196
210
|
/**
|
|
197
211
|
* For internal use.
|
|
198
212
|
* @internal
|
|
@@ -208,6 +222,13 @@ export declare class TopicHistoryWindow extends TraversableRemoteCollection<Mess
|
|
|
208
222
|
* mention has no reaction of this user left on it.
|
|
209
223
|
*/
|
|
210
224
|
private storeMyReactions;
|
|
225
|
+
/**
|
|
226
|
+
* The response is the truth for its replies: an original it leaves out is gone. The originals the page holds
|
|
227
|
+
* itself are kept too, as the window may drop them while their replies stay.
|
|
228
|
+
*/
|
|
229
|
+
private storeRepliedMessages;
|
|
230
|
+
private emitChange;
|
|
231
|
+
private repliesTo;
|
|
211
232
|
private getTopic;
|
|
212
233
|
private getLatestMessageId;
|
|
213
234
|
protected isLatestItemLoaded(): Promise<boolean>;
|
|
@@ -228,6 +249,12 @@ export declare class TopicHistoryWindow extends TraversableRemoteCollection<Mess
|
|
|
228
249
|
* @internal
|
|
229
250
|
*/
|
|
230
251
|
_handleReacted(ev: Reacted): void;
|
|
252
|
+
/**
|
|
253
|
+
* Replaces a loaded message, also where it is kept as a replied one.
|
|
254
|
+
* For internal use.
|
|
255
|
+
* @internal
|
|
256
|
+
*/
|
|
257
|
+
_handleMessageUpdated(ev: MessageUpdated): void;
|
|
231
258
|
/**
|
|
232
259
|
* For internal use.
|
|
233
260
|
* @internal
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ChatStateTracker } from "./ChatStateTracker";
|
|
2
|
+
import { ObservableIndexedCollection } from "../IndexedObjectCollection";
|
|
3
|
+
export declare const TYPING_INTERVAL_MS = 5000;
|
|
4
|
+
export declare const TYPING_TIMEOUT_MS: number;
|
|
5
|
+
/**
|
|
6
|
+
* Ids of the users typing in a topic, each mapped to the time (`Date.now()`) its typing expires at.
|
|
7
|
+
*/
|
|
8
|
+
export type TypingUsers = ObservableIndexedCollection<string, number>;
|
|
9
|
+
export declare class TypingManager {
|
|
10
|
+
private tracker;
|
|
11
|
+
private readonly topics;
|
|
12
|
+
private readonly lastSentAt;
|
|
13
|
+
constructor(tracker: ChatStateTracker);
|
|
14
|
+
/**
|
|
15
|
+
* Users typing in the topic, without you. Tracking of the topic starts with the first call, so the collection
|
|
16
|
+
* fills up with the next notifications, within {@link TYPING_INTERVAL_MS}. A user leaves it
|
|
17
|
+
* {@link TYPING_TIMEOUT_MS} after their last notification or at once with their message in the topic.
|
|
18
|
+
* Only ids are kept - resolve the users yourself, e.g. from {@link RoomsManager.getMembers}.
|
|
19
|
+
*/
|
|
20
|
+
get(roomId: string, topicId: string): TypingUsers;
|
|
21
|
+
/**
|
|
22
|
+
* Tell the other members of the room that you are typing in the topic. Call it on every change of the text:
|
|
23
|
+
* the command is sent at most once per {@link TYPING_INTERVAL_MS} for a topic, and again right after your
|
|
24
|
+
* message in it. Classic rooms do not support typing.
|
|
25
|
+
*/
|
|
26
|
+
notify(roomId: string, topicId: string): void;
|
|
27
|
+
private handleTyping;
|
|
28
|
+
private handleNewMessage;
|
|
29
|
+
private handleTopicDeleted;
|
|
30
|
+
private handleRoomGone;
|
|
31
|
+
private handleSession;
|
|
32
|
+
private clear;
|
|
33
|
+
private scheduleExpiry;
|
|
34
|
+
private expire;
|
|
35
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PmParticipant, Role, Room, RoomMember, SpaceMember, User } from "../protocol";
|
|
1
|
+
import { MessageReaction, PmParticipant, Role, Room, RoomMember, SpaceMember, ToggledReaction, User, UserReaction } from "../protocol";
|
|
2
2
|
/**
|
|
3
3
|
* @return New objects of the other roles whose priority has to move; the given roles are left intact.
|
|
4
4
|
*/
|
|
@@ -15,3 +15,10 @@ export declare function isGroupPm(room: Room): boolean;
|
|
|
15
15
|
export declare function getPmPeers(room: Room, meId: string): PmParticipant[];
|
|
16
16
|
export declare function getActivePmParticipants(room: Room): PmParticipant[];
|
|
17
17
|
export declare function isSameUser(a: User, b: User): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* The counter arrives as the global source of truth - only it is overwritten, and a reaction nobody holds any more
|
|
20
|
+
* (count 0) leaves the message.
|
|
21
|
+
* @return Null when the reactions stay as they are.
|
|
22
|
+
*/
|
|
23
|
+
export declare function applyReactionCounter(reactions: MessageReaction[], counter: MessageReaction): MessageReaction[] | null;
|
|
24
|
+
export declare function applyToggledReaction(own: UserReaction[], toggled: ToggledReaction): UserReaction[];
|
package/package.json
CHANGED