polfan-server-js-client 0.2.86 → 0.2.88
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/.idea/workspace.xml +52 -62
- package/build/index.cjs.js +47 -9
- package/build/index.cjs.js.map +1 -1
- package/build/index.umd.js +1 -1
- package/build/index.umd.js.map +1 -1
- package/build/types/state-tracker/RoomsManager.d.ts +1 -0
- package/build/types/state-tracker/TopicHistoryWindow.d.ts +12 -3
- package/package.json +1 -1
- package/src/state-tracker/RoomsManager.ts +11 -0
- package/src/state-tracker/TopicHistoryWindow.ts +32 -10
- package/tests/history-window.test.ts +35 -1
package/.idea/workspace.xml
CHANGED
|
@@ -4,22 +4,8 @@
|
|
|
4
4
|
<option name="autoReloadType" value="SELECTIVE" />
|
|
5
5
|
</component>
|
|
6
6
|
<component name="ChangeListManager">
|
|
7
|
-
<list default="true" id="831dae43-0da1-47fd-a5f7-33dd5eec2992" name="Changes" comment="
|
|
8
|
-
<change
|
|
9
|
-
<change afterPath="$PROJECT_DIR$/src/types/src/schemes/commands/GetUserInfo.ts" afterDir="false" />
|
|
10
|
-
<change afterPath="$PROJECT_DIR$/src/types/src/schemes/events/UserInfo.ts" afterDir="false" />
|
|
11
|
-
<change beforePath="$PROJECT_DIR$/build/index.cjs.js.map" beforeDir="false" afterPath="$PROJECT_DIR$/build/index.cjs.js.map" afterDir="false" />
|
|
12
|
-
<change beforePath="$PROJECT_DIR$/build/index.umd.js.map" beforeDir="false" afterPath="$PROJECT_DIR$/build/index.umd.js.map" afterDir="false" />
|
|
13
|
-
<change beforePath="$PROJECT_DIR$/package.json" beforeDir="false" afterPath="$PROJECT_DIR$/package.json" afterDir="false" />
|
|
14
|
-
<change beforePath="$PROJECT_DIR$/src/AbstractChatClient.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/AbstractChatClient.ts" afterDir="false" />
|
|
15
|
-
<change beforePath="$PROJECT_DIR$/src/types" beforeDir="false" afterPath="$PROJECT_DIR$/src/types" afterDir="false" />
|
|
16
|
-
<change beforePath="$PROJECT_DIR$/src/types/src/index.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/types/src/index.ts" afterDir="false" />
|
|
17
|
-
<change beforePath="$PROJECT_DIR$/src/types/src/schemes/BanObject.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/types/src/schemes/BanObject.ts" afterDir="false" />
|
|
18
|
-
<change beforePath="$PROJECT_DIR$/src/types/src/schemes/RoomSummary.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/types/src/schemes/RoomSummary.ts" afterDir="false" />
|
|
19
|
-
<change beforePath="$PROJECT_DIR$/src/types/src/schemes/commands/Ban.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/types/src/schemes/commands/Ban.ts" afterDir="false" />
|
|
20
|
-
<change beforePath="$PROJECT_DIR$/src/types/src/schemes/commands/GetBans.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/types/src/schemes/commands/GetBans.ts" afterDir="false" />
|
|
21
|
-
<change beforePath="$PROJECT_DIR$/src/types/src/schemes/commands/Unban.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/types/src/schemes/commands/Unban.ts" afterDir="false" />
|
|
22
|
-
<change beforePath="$PROJECT_DIR$/src/types/src/schemes/events/Session.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/types/src/schemes/events/Session.ts" afterDir="false" />
|
|
7
|
+
<list default="true" id="831dae43-0da1-47fd-a5f7-33dd5eec2992" name="Changes" comment="TopicHistoryWindow retainRatio and event handling improvements">
|
|
8
|
+
<change beforePath="$PROJECT_DIR$/src/state-tracker/RoomsManager.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/state-tracker/RoomsManager.ts" afterDir="false" />
|
|
23
9
|
</list>
|
|
24
10
|
<option name="SHOW_DIALOG" value="false" />
|
|
25
11
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
|
@@ -69,35 +55,36 @@
|
|
|
69
55
|
<option name="hideEmptyMiddlePackages" value="true" />
|
|
70
56
|
<option name="showLibraryContents" value="true" />
|
|
71
57
|
</component>
|
|
72
|
-
<component name="PropertiesComponent"
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
58
|
+
<component name="PropertiesComponent">{
|
|
59
|
+
"keyToString": {
|
|
60
|
+
"RunOnceActivity.MCP Project settings loaded": "true",
|
|
61
|
+
"RunOnceActivity.ShowReadmeOnStart": "true",
|
|
62
|
+
"RunOnceActivity.TerminalTabsStorage.copyFrom.TerminalArrangementManager": "true",
|
|
63
|
+
"RunOnceActivity.TerminalTabsStorage.copyFrom.TerminalArrangementManager.252": "true",
|
|
64
|
+
"RunOnceActivity.git.unshallow": "true",
|
|
65
|
+
"RunOnceActivity.typescript.service.memoryLimit.init": "true",
|
|
66
|
+
"codeWithMe.voiceChat.enabledByDefault": "false",
|
|
67
|
+
"com.intellij.ml.llm.matterhorn.ej.ui.settings.DefaultModelSelectionForGA.v1": "true",
|
|
68
|
+
"git-widget-placeholder": "master",
|
|
69
|
+
"ignore.virus.scanning.warn.message": "true",
|
|
70
|
+
"junie.onboarding.icon.badge.shown": "true",
|
|
71
|
+
"last_opened_file_path": "//wsl.localhost/Debian/home/jarek/polfan-js-client-library",
|
|
72
|
+
"node.js.detected.package.eslint": "true",
|
|
73
|
+
"node.js.detected.package.tslint": "true",
|
|
74
|
+
"node.js.selected.package.eslint": "(autodetect)",
|
|
75
|
+
"node.js.selected.package.tslint": "(autodetect)",
|
|
76
|
+
"nodejs_package_manager_path": "npm",
|
|
77
|
+
"settings.editor.selected.configurable": "com.github.copilot.settings.chat.ChatConfigurable",
|
|
78
|
+
"to.speed.mode.migration.done": "true",
|
|
79
|
+
"ts.external.directory.path": "\\\\wsl.localhost\\Debian\\home\\jarek\\polfan-js-client-library\\node_modules\\typescript\\lib",
|
|
80
|
+
"vue.rearranger.settings.migration": "true"
|
|
94
81
|
}
|
|
95
|
-
}
|
|
82
|
+
}</component>
|
|
96
83
|
<component name="SharedIndexes">
|
|
97
84
|
<attachedChunks>
|
|
98
85
|
<set>
|
|
99
|
-
<option value="bundled-js-predefined-d6986cc7102b-
|
|
100
|
-
<option value="bundled-php-predefined-a98d8de5180a-
|
|
86
|
+
<option value="bundled-js-predefined-d6986cc7102b-31caf2ab9e3c-JavaScript-PS-261.23567.149" />
|
|
87
|
+
<option value="bundled-php-predefined-a98d8de5180a-022fa7b8ab75-com.jetbrains.php.sharedIndexes-PS-261.23567.149" />
|
|
101
88
|
</set>
|
|
102
89
|
</attachedChunks>
|
|
103
90
|
</component>
|
|
@@ -200,23 +187,10 @@
|
|
|
200
187
|
<workItem from="1774871561103" duration="4164000" />
|
|
201
188
|
<workItem from="1775031025390" duration="593000" />
|
|
202
189
|
<workItem from="1775641624063" duration="1179000" />
|
|
203
|
-
<workItem from="1776327180094" duration="
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
<
|
|
207
|
-
<created>1751160521070</created>
|
|
208
|
-
<option name="number" value="00036" />
|
|
209
|
-
<option name="presentableId" value="LOCAL-00036" />
|
|
210
|
-
<option name="project" value="LOCAL" />
|
|
211
|
-
<updated>1751160521070</updated>
|
|
212
|
-
</task>
|
|
213
|
-
<task id="LOCAL-00037" summary="Dedicated event for user status change">
|
|
214
|
-
<option name="closed" value="true" />
|
|
215
|
-
<created>1751547708628</created>
|
|
216
|
-
<option name="number" value="00037" />
|
|
217
|
-
<option name="presentableId" value="LOCAL-00037" />
|
|
218
|
-
<option name="project" value="LOCAL" />
|
|
219
|
-
<updated>1751547708628</updated>
|
|
190
|
+
<workItem from="1776327180094" duration="5055000" />
|
|
191
|
+
<workItem from="1777136687009" duration="3369000" />
|
|
192
|
+
<workItem from="1777301595900" duration="1696000" />
|
|
193
|
+
<workItem from="1778067371586" duration="1297000" />
|
|
220
194
|
</task>
|
|
221
195
|
<task id="LOCAL-00038" summary="Dedicated event for user status change">
|
|
222
196
|
<option name="closed" value="true" />
|
|
@@ -594,7 +568,23 @@
|
|
|
594
568
|
<option name="project" value="LOCAL" />
|
|
595
569
|
<updated>1769894114639</updated>
|
|
596
570
|
</task>
|
|
597
|
-
<
|
|
571
|
+
<task id="LOCAL-00085" summary="Adjust to ban changes">
|
|
572
|
+
<option name="closed" value="true" />
|
|
573
|
+
<created>1776807618896</created>
|
|
574
|
+
<option name="number" value="00085" />
|
|
575
|
+
<option name="presentableId" value="LOCAL-00085" />
|
|
576
|
+
<option name="project" value="LOCAL" />
|
|
577
|
+
<updated>1776807618896</updated>
|
|
578
|
+
</task>
|
|
579
|
+
<task id="LOCAL-00086" summary="TopicHistoryWindow retainRatio and event handling improvements">
|
|
580
|
+
<option name="closed" value="true" />
|
|
581
|
+
<created>1777303294828</created>
|
|
582
|
+
<option name="number" value="00086" />
|
|
583
|
+
<option name="presentableId" value="LOCAL-00086" />
|
|
584
|
+
<option name="project" value="LOCAL" />
|
|
585
|
+
<updated>1777303294829</updated>
|
|
586
|
+
</task>
|
|
587
|
+
<option name="localTasksCounter" value="87" />
|
|
598
588
|
<servers />
|
|
599
589
|
</component>
|
|
600
590
|
<component name="TypeScriptGeneratedFilesManager">
|
|
@@ -612,8 +602,6 @@
|
|
|
612
602
|
</option>
|
|
613
603
|
</component>
|
|
614
604
|
<component name="VcsManagerConfiguration">
|
|
615
|
-
<MESSAGE value="Protocol version support" />
|
|
616
|
-
<MESSAGE value="Update room on recipient user change" />
|
|
617
605
|
<MESSAGE value="Fix websocket state error handling" />
|
|
618
606
|
<MESSAGE value="Collection integration with React JS rework" />
|
|
619
607
|
<MESSAGE value="Update deps and improve library building" />
|
|
@@ -637,7 +625,9 @@
|
|
|
637
625
|
<MESSAGE value="Improve EventTarget typings" />
|
|
638
626
|
<MESSAGE value="Delete redacted messages, improve collections, add tests" />
|
|
639
627
|
<MESSAGE value="Fix emitting event with deleted topics" />
|
|
640
|
-
<
|
|
628
|
+
<MESSAGE value="Adjust to ban changes" />
|
|
629
|
+
<MESSAGE value="TopicHistoryWindow retainRatio and event handling improvements" />
|
|
630
|
+
<option name="LAST_COMMIT_MESSAGE" value="TopicHistoryWindow retainRatio and event handling improvements" />
|
|
641
631
|
</component>
|
|
642
632
|
<component name="XSLT-Support.FileAssociations.UIState">
|
|
643
633
|
<expand />
|
package/build/index.cjs.js
CHANGED
|
@@ -685,7 +685,8 @@ var TraversableRemoteCollection = /*#__PURE__*/function (_ObservableIndexedObj)
|
|
|
685
685
|
TopicHistoryWindow_defineProperty(_this, "internalState", {
|
|
686
686
|
current: WindowState.LIVE,
|
|
687
687
|
ongoing: undefined,
|
|
688
|
-
limit:
|
|
688
|
+
limit: 1000,
|
|
689
|
+
retainRatio: 1,
|
|
689
690
|
fetchLimit: 50,
|
|
690
691
|
lastFetchCount: 0,
|
|
691
692
|
oldestId: null
|
|
@@ -720,7 +721,7 @@ var TraversableRemoteCollection = /*#__PURE__*/function (_ObservableIndexedObj)
|
|
|
720
721
|
}
|
|
721
722
|
|
|
722
723
|
/**
|
|
723
|
-
* Maximum
|
|
724
|
+
* Maximum number of items stored in window (High Watermark).
|
|
724
725
|
* Null for unlimited.
|
|
725
726
|
*/
|
|
726
727
|
}, {
|
|
@@ -730,12 +731,28 @@ var TraversableRemoteCollection = /*#__PURE__*/function (_ObservableIndexedObj)
|
|
|
730
731
|
}
|
|
731
732
|
|
|
732
733
|
/**
|
|
733
|
-
* Maximum
|
|
734
|
+
* Maximum number of items stored in window (High Watermark).
|
|
734
735
|
* Null for unlimited.
|
|
735
736
|
*/,
|
|
736
737
|
set: function set(value) {
|
|
737
738
|
this.internalState.limit = value;
|
|
738
739
|
}
|
|
740
|
+
|
|
741
|
+
/**
|
|
742
|
+
* Percentage of limit to keep when trimming.
|
|
743
|
+
*/
|
|
744
|
+
}, {
|
|
745
|
+
key: "retainRatio",
|
|
746
|
+
get: function get() {
|
|
747
|
+
return this.internalState.retainRatio;
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
/**
|
|
751
|
+
* Percentage of limit to keep when trimming.
|
|
752
|
+
*/,
|
|
753
|
+
set: function set(value) {
|
|
754
|
+
this.internalState.retainRatio = value;
|
|
755
|
+
}
|
|
739
756
|
}, {
|
|
740
757
|
key: "hasLatest",
|
|
741
758
|
get: function get() {
|
|
@@ -772,7 +789,7 @@ var TraversableRemoteCollection = /*#__PURE__*/function (_ObservableIndexedObj)
|
|
|
772
789
|
this.internalState.ongoing = undefined;
|
|
773
790
|
return _context.f(4);
|
|
774
791
|
case 5:
|
|
775
|
-
this.deleteAll();
|
|
792
|
+
this._items.deleteAll(); // Directly call deleteAll to prevent event emit.
|
|
776
793
|
this.addItems(result, 'tail');
|
|
777
794
|
this.internalState.current = WindowState.LATEST;
|
|
778
795
|
case 6:
|
|
@@ -941,25 +958,28 @@ var TraversableRemoteCollection = /*#__PURE__*/function (_ObservableIndexedObj)
|
|
|
941
958
|
if (to === 'tail') {
|
|
942
959
|
result = this.trimItemsArrayToLimit([].concat(TopicHistoryWindow_toConsumableArray(this.items), TopicHistoryWindow_toConsumableArray(newItems)), 'head');
|
|
943
960
|
}
|
|
944
|
-
this.deleteAll();
|
|
961
|
+
this._items.deleteAll(); // Directly call deleteAll to prevent event emit.
|
|
945
962
|
this.set.apply(this, TopicHistoryWindow_toConsumableArray(result));
|
|
946
963
|
}
|
|
947
964
|
|
|
948
965
|
/**
|
|
949
|
-
* Return array with messages
|
|
966
|
+
* Return array with messages trimmed using High/Low Watermark strategy.
|
|
950
967
|
*/
|
|
951
968
|
}, {
|
|
952
969
|
key: "trimItemsArrayToLimit",
|
|
953
970
|
value: function trimItemsArrayToLimit(items, from) {
|
|
954
|
-
|
|
971
|
+
var highWatermark = this.limit;
|
|
972
|
+
if (highWatermark === null || items.length <= highWatermark) {
|
|
955
973
|
return items;
|
|
956
974
|
}
|
|
975
|
+
var lowWatermark = Math.floor(highWatermark * this.internalState.retainRatio);
|
|
957
976
|
if (from === 'head') {
|
|
958
|
-
return items.slice(-
|
|
977
|
+
return items.slice(-lowWatermark);
|
|
959
978
|
}
|
|
960
979
|
if (from === 'tail') {
|
|
961
|
-
return items.slice(0,
|
|
980
|
+
return items.slice(0, lowWatermark);
|
|
962
981
|
}
|
|
982
|
+
return items;
|
|
963
983
|
}
|
|
964
984
|
}]);
|
|
965
985
|
}(ObservableIndexedObjectCollection);
|
|
@@ -2081,6 +2101,9 @@ var RoomsManager = /*#__PURE__*/function () {
|
|
|
2081
2101
|
this.tracker.client.on('NewMessage', function (ev) {
|
|
2082
2102
|
return _this.handleNewMessage(ev);
|
|
2083
2103
|
});
|
|
2104
|
+
this.tracker.client.on('MessagesRedacted', function (ev) {
|
|
2105
|
+
return _this.handleMessagesRedacted(ev);
|
|
2106
|
+
});
|
|
2084
2107
|
this.tracker.client.on('NewTopic', function (ev) {
|
|
2085
2108
|
return _this.handleNewTopic(ev);
|
|
2086
2109
|
});
|
|
@@ -2614,6 +2637,21 @@ var RoomsManager = /*#__PURE__*/function () {
|
|
|
2614
2637
|
}));
|
|
2615
2638
|
}
|
|
2616
2639
|
}
|
|
2640
|
+
}, {
|
|
2641
|
+
key: "handleMessagesRedacted",
|
|
2642
|
+
value: function handleMessagesRedacted(ev) {
|
|
2643
|
+
// Remove redacted messages from topic.lastMessage
|
|
2644
|
+
var topics = this.topics.get(ev.location.roomId);
|
|
2645
|
+
var updatedTopics = topics.items.filter(function (topic) {
|
|
2646
|
+
var _topic$lastMessage;
|
|
2647
|
+
return ((_topic$lastMessage = topic.lastMessage) === null || _topic$lastMessage === void 0 ? void 0 : _topic$lastMessage.id) && ev.ids.includes(topic.lastMessage.id);
|
|
2648
|
+
}).map(function (topic) {
|
|
2649
|
+
return RoomsManager_objectSpread(RoomsManager_objectSpread({}, topic), {}, {
|
|
2650
|
+
lastMessage: null
|
|
2651
|
+
});
|
|
2652
|
+
});
|
|
2653
|
+
topics.set.apply(topics, RoomsManager_toConsumableArray(updatedTopics));
|
|
2654
|
+
}
|
|
2617
2655
|
}]);
|
|
2618
2656
|
}();
|
|
2619
2657
|
;// ./src/state-tracker/functions.ts
|