@devanachat/sdk 0.8.0 → 0.8.1
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 +24 -1
- package/build/index.cjs.js +136 -24
- package/build/index.cjs.js.map +1 -1
- package/build/index.mjs +136 -24
- 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/state-tracker/RoomMessagesHistory.d.ts +10 -3
- package/build/types/state-tracker/TopicHistoryWindow.d.ts +31 -0
- package/package.json +1 -1
|
@@ -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
|
|
30
|
-
*
|
|
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
|
|
93
|
+
private updateHistoryMode;
|
|
87
94
|
}
|
|
@@ -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