@devanachat/sdk 0.11.0 → 0.13.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.
Files changed (38) hide show
  1. package/CHANGELOG.md +85 -0
  2. package/README.md +15 -7
  3. package/build/index.cjs.js +436 -144
  4. package/build/index.cjs.js.map +1 -1
  5. package/build/index.mjs +436 -145
  6. package/build/index.mjs.map +1 -1
  7. package/build/index.umd.js +1 -1
  8. package/build/index.umd.js.map +1 -1
  9. package/build/types/AbstractChatClient.d.ts +18 -3
  10. package/build/types/Permissions.d.ts +5 -1
  11. package/build/types/WebSocketChatClient.d.ts +29 -2
  12. package/build/types/index.d.ts +2 -2
  13. package/build/types/protocol/index.d.ts +15 -3
  14. package/build/types/protocol/schemes/Message.d.ts +4 -0
  15. package/build/types/protocol/schemes/MessageEmbed.d.ts +83 -0
  16. package/build/types/protocol/schemes/commands/AckInteraction.d.ts +10 -0
  17. package/build/types/protocol/schemes/commands/CreateMessage.d.ts +9 -0
  18. package/build/types/protocol/schemes/commands/GetGifCategories.d.ts +3 -0
  19. package/build/types/protocol/schemes/commands/GetMessages.d.ts +1 -0
  20. package/build/types/protocol/schemes/commands/Interact.d.ts +5 -0
  21. package/build/types/protocol/schemes/commands/SearchGifs.d.ts +5 -0
  22. package/build/types/protocol/schemes/commands/UpdateMessage.d.ts +8 -0
  23. package/build/types/protocol/schemes/events/Bye.d.ts +1 -0
  24. package/build/types/protocol/schemes/events/Error.d.ts +1 -0
  25. package/build/types/protocol/schemes/events/FoundGifs.d.ts +14 -0
  26. package/build/types/protocol/schemes/events/GifCategories.d.ts +8 -0
  27. package/build/types/protocol/schemes/events/Interacted.d.ts +4 -0
  28. package/build/types/protocol/schemes/events/InteractionResolved.d.ts +7 -0
  29. package/build/types/protocol/schemes/events/MessageUpdated.d.ts +6 -0
  30. package/build/types/protocol/schemes/events/Messages.d.ts +6 -2
  31. package/build/types/protocol/schemes/events/NewInteraction.d.ts +10 -0
  32. package/build/types/protocol/schemes/events/NewMessage.d.ts +3 -0
  33. package/build/types/state-tracker/RoomMessagesHistory.d.ts +7 -2
  34. package/build/types/state-tracker/RoomsManager.d.ts +12 -1
  35. package/build/types/state-tracker/StateSnapshot.d.ts +5 -1
  36. package/build/types/state-tracker/TopicHistoryWindow.d.ts +29 -2
  37. package/build/types/state-tracker/functions.d.ts +8 -1
  38. 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[]>): void;
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
@@ -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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devanachat/sdk",
3
- "version": "0.11.0",
3
+ "version": "0.13.0",
4
4
  "description": "TypeScript/JavaScript SDK for the Devana chat platform: WebSocket and Web API clients, state tracking, permissions and files.",
5
5
  "keywords": [
6
6
  "devana",