@devanachat/sdk 0.8.0 → 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.
@@ -110,6 +110,10 @@ export declare class Permissions {
110
110
  value: number;
111
111
  maxLayer: Layer;
112
112
  };
113
+ UseExternalEmoticons: {
114
+ value: number;
115
+ maxLayer: Layer;
116
+ };
113
117
  };
114
118
  static getNames(): (keyof typeof this.list)[];
115
119
  static getByName(name: keyof typeof this.list): PermissionDefinition | undefined;
@@ -1,9 +1,8 @@
1
1
  import { User } from "./User";
2
2
  export interface Emoticon {
3
3
  id: string;
4
- spaceId?: string;
4
+ spaceId?: string | null;
5
5
  name: string;
6
6
  fileId: string;
7
- user: User;
8
- tag?: string;
7
+ user: User | null;
9
8
  }
@@ -63,7 +63,8 @@ export declare enum SpaceFeature {
63
63
  export declare enum UserFeature {
64
64
  MessageLength = "user.message.length",
65
65
  StorageLimit = "user.storage.limit",
66
- StorageSingleFileLimit = "user.storage.single_file_limit"
66
+ StorageSingleFileLimit = "user.storage.single_file_limit",
67
+ ExternalEmoticons = "user.external_emoticons"
67
68
  }
68
69
  /**
69
70
  * How far back a room of the space may be told to keep its history.
@@ -2,6 +2,7 @@ export type ReactionType = 'Emoji' | 'Emoticon';
2
2
  export interface MessageReaction {
3
3
  type: ReactionType;
4
4
  value: string;
5
+ name?: string | null;
5
6
  count: number;
6
7
  }
7
8
  export interface UserReaction {
@@ -9,5 +10,6 @@ export interface UserReaction {
9
10
  value: string;
10
11
  }
11
12
  export interface ToggledReaction extends UserReaction {
13
+ name?: string | null;
12
14
  isAdded: boolean;
13
15
  }
@@ -1,5 +1,5 @@
1
1
  export interface CreateEmoticon {
2
2
  name: string;
3
3
  fileId: string;
4
- spaceId?: string;
4
+ spaceId: string;
5
5
  }
@@ -1,3 +1,4 @@
1
1
  export interface GetEmoticons {
2
2
  spaceId?: string;
3
+ ids?: string[];
3
4
  }
@@ -1,4 +1,4 @@
1
1
  export interface EmoticonDeleted {
2
2
  emoticonId: string;
3
- spaceId?: string;
3
+ spaceId: string;
4
4
  }
@@ -2,5 +2,5 @@ import { Emoticon } from "../Emoticon";
2
2
  import { ChatLocation } from "../ChatLocation";
3
3
  export interface Emoticons {
4
4
  emoticons: Emoticon[];
5
- location: ChatLocation;
5
+ location: ChatLocation | null;
6
6
  }
@@ -7,7 +7,7 @@ export declare class EmoticonsManager {
7
7
  private list;
8
8
  private emoticonsPromises;
9
9
  constructor(tracker: ChatStateTracker);
10
- get(spaceId?: string): Promise<ObservableIndexedObjectCollection<Emoticon>>;
10
+ get(spaceId: string): Promise<ObservableIndexedObjectCollection<Emoticon>>;
11
11
  /**
12
12
  * For internal use.
13
13
  * @internal
@@ -11,6 +11,7 @@ export declare class RoomMessagesHistory {
11
11
  private readonly roomId;
12
12
  private historyWindows;
13
13
  private traverseLock;
14
+ private timeLimitedHistory;
14
15
  private room;
15
16
  constructor(room: Room | string, tracker: ChatStateTracker);
16
17
  /**
@@ -26,9 +27,15 @@ export declare class RoomMessagesHistory {
26
27
  *
27
28
  * The window bindings are preserved; only windows that the application had
28
29
  * actually pulled to the latest page (state === LATEST) are refreshed, with
29
- * a single resetToLatest instead of a chain of catch-up requests. Windows
30
- * that were never pulled (LIVE) or belong to an ephemeral room are left
30
+ * a single request instead of a chain of catch-up requests. Windows that
31
+ * were never pulled (LIVE) or belong to an ephemeral room are left
31
32
  * untouched so their in-memory context survives the reconnect.
33
+ *
34
+ * Rooms keeping the full history are reset to the latest page (the rest can
35
+ * always be traversed back), while the windows of rooms with a time-limited
36
+ * history (MaxAge) keep what they had loaded and get the missed messages on
37
+ * top - the server may no longer serve the older ones. If more messages were
38
+ * missed than a single page holds, the seam is recorded in the window gaps.
32
39
  */
33
40
  resync(room: Room): Promise<void>;
34
41
  /**
@@ -83,5 +90,5 @@ export declare class RoomMessagesHistory {
83
90
  _handleReacted(ev: Reacted): void;
84
91
  private createHistoryWindowForTopic;
85
92
  private createHistoryWindow;
86
- private updateTraverseLock;
93
+ private updateHistoryMode;
87
94
  }
@@ -86,10 +86,7 @@ export interface RoomFollowedTopicsSnapshot {
86
86
  followedTopics: FollowedTopic[];
87
87
  }
88
88
  export interface EmoticonsSnapshot {
89
- /**
90
- * Null for the global emoticons.
91
- */
92
- spaceId: string | null;
89
+ spaceId: string;
93
90
  emoticons: Emoticon[];
94
91
  }
95
92
  export declare function withoutPresence(user: User): User;
@@ -29,11 +29,14 @@ export declare abstract class TraversableRemoteCollection<ItemT, EventMapT exten
29
29
  protected internalState: {
30
30
  current: WindowState;
31
31
  ongoing?: WindowState;
32
+ fetchSettled?: Promise<void>;
33
+ settleFetch?: () => void;
32
34
  limit: number | null;
33
35
  retainRatio: number;
34
36
  fetchLimit: number;
35
37
  lastFetchCount: number;
36
38
  oldestId: string | null;
39
+ gaps: string[];
37
40
  };
38
41
  /**
39
42
  * Number of items to fetch per request.
@@ -62,16 +65,36 @@ export declare abstract class TraversableRemoteCollection<ItemT, EventMapT exten
62
65
  */
63
66
  set retainRatio(value: number);
64
67
  get hasLatest(): boolean;
68
+ /**
69
+ * IDs of the items with a gap in front of them: the item right above in the window is not the real predecessor,
70
+ * an unknown number of items in between was never fetched. Such a seam appears when {@link resyncToLatest} gets
71
+ * a full page that does not reach the loaded items. A marker lives as long as its item stays in the window and
72
+ * is closed once the items right before it are fetched.
73
+ */
74
+ get gaps(): readonly string[];
65
75
  get hasOldest(): boolean;
66
76
  abstract createMirror(): TraversableRemoteCollection<ItemT, EventMapT>;
67
77
  resetToLatest(force?: boolean): Promise<void>;
78
+ /**
79
+ * Refresh the window with the latest page, keeping the already loaded items instead of replacing them - the
80
+ * reconnect-friendly variant of {@link resetToLatest}. The page is merged on top of the loaded items (an item in
81
+ * both is taken from the page) and only the window size limit pushes the oldest ones out. When the page is full
82
+ * and does not reach the newest loaded item, both parts are still kept and the seam is recorded in {@link gaps}.
83
+ */
84
+ resyncToLatest(): Promise<void>;
68
85
  fetchPrevious(): Promise<void>;
69
86
  fetchNext(): Promise<void>;
70
87
  /**
71
88
  * Append the items that follow the last one in the window; an empty window gets the latest items.
72
89
  */
73
90
  protected fetchAfterLast(): Promise<void>;
91
+ /**
92
+ * Load the items around the given one. Asked for while another fetch is running, it waits for that fetch to end
93
+ * instead of being dropped - when the call returns, the window either holds the item or it could not be loaded.
94
+ */
74
95
  jumpTo(id: string): Promise<void>;
96
+ delete(...ids: string[]): void;
97
+ deleteAll(): void;
75
98
  protected abstract fetchLatestItems(): Promise<ItemT[]>;
76
99
  protected abstract fetchItemsBefore(): Promise<ItemT[] | null>;
77
100
  protected abstract fetchItemsAfter(): Promise<ItemT[] | null>;
@@ -84,6 +107,13 @@ export declare abstract class TraversableRemoteCollection<ItemT, EventMapT exten
84
107
  * @return Ids of the items trimmed out.
85
108
  */
86
109
  protected addItems(newItems: ItemT[], to: 'head' | 'tail', highWatermark?: number | null): string[];
110
+ protected beginFetch(kind: WindowState): void;
111
+ protected endFetch(): void;
112
+ /**
113
+ * Replace the whole content without emitting an event; the old gap markers mean nothing for the new content.
114
+ */
115
+ protected replaceItems(items: ItemT[]): void;
116
+ protected forgetGapsOf(ids: string[]): void;
87
117
  protected emitChangeWithDiff(itemChanged: boolean, originalState: WindowState): void;
88
118
  /**
89
119
  * Drop the oldest items, so that at most `keep` remain. The newest items stay, so whether the window holds the
@@ -145,6 +175,7 @@ export declare class TopicHistoryWindow extends TraversableRemoteCollection<Mess
145
175
  set liveLimit(value: number | null);
146
176
  setTraverseLock(lock: boolean): Promise<void>;
147
177
  resetToLatest(force?: boolean): Promise<void>;
178
+ resyncToLatest(): Promise<void>;
148
179
  fetchNext(): Promise<void>;
149
180
  fetchPrevious(): Promise<void>;
150
181
  jumpTo(id: string): Promise<void>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devanachat/sdk",
3
- "version": "0.8.0",
3
+ "version": "0.9.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",