polfan-server-js-client 0.2.57 → 0.2.58
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 +4 -0
- package/babel.config.js +1 -1
- package/build/index.cjs.js +73 -66
- 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/IndexedObjectCollection.d.ts +4 -4
- package/build/types/state-tracker/TopicHistoryWindow.d.ts +18 -8
- package/package.json +2 -2
- package/src/IndexedObjectCollection.ts +4 -4
- package/src/state-tracker/TopicHistoryWindow.ts +60 -39
- package/tests/history-window.test.ts +1 -1
package/.idea/workspace.xml
CHANGED
|
@@ -5,12 +5,15 @@
|
|
|
5
5
|
</component>
|
|
6
6
|
<component name="ChangeListManager">
|
|
7
7
|
<list default="true" id="831dae43-0da1-47fd-a5f7-33dd5eec2992" name="Changes" comment="Collection integration with React JS rework">
|
|
8
|
+
<change beforePath="$PROJECT_DIR$/babel.config.js" beforeDir="false" afterPath="$PROJECT_DIR$/babel.config.js" afterDir="false" />
|
|
8
9
|
<change beforePath="$PROJECT_DIR$/build/index.cjs.js" beforeDir="false" afterPath="$PROJECT_DIR$/build/index.cjs.js" afterDir="false" />
|
|
9
10
|
<change beforePath="$PROJECT_DIR$/build/index.cjs.js.map" beforeDir="false" afterPath="$PROJECT_DIR$/build/index.cjs.js.map" afterDir="false" />
|
|
10
11
|
<change beforePath="$PROJECT_DIR$/build/index.umd.js" beforeDir="false" afterPath="$PROJECT_DIR$/build/index.umd.js" afterDir="false" />
|
|
11
12
|
<change beforePath="$PROJECT_DIR$/build/index.umd.js.map" beforeDir="false" afterPath="$PROJECT_DIR$/build/index.umd.js.map" afterDir="false" />
|
|
12
13
|
<change beforePath="$PROJECT_DIR$/build/types/state-tracker/TopicHistoryWindow.d.ts" beforeDir="false" afterPath="$PROJECT_DIR$/build/types/state-tracker/TopicHistoryWindow.d.ts" afterDir="false" />
|
|
14
|
+
<change beforePath="$PROJECT_DIR$/package-lock.json" beforeDir="false" afterPath="$PROJECT_DIR$/package-lock.json" afterDir="false" />
|
|
13
15
|
<change beforePath="$PROJECT_DIR$/package.json" beforeDir="false" afterPath="$PROJECT_DIR$/package.json" afterDir="false" />
|
|
16
|
+
<change beforePath="$PROJECT_DIR$/src/IndexedObjectCollection.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/IndexedObjectCollection.ts" afterDir="false" />
|
|
14
17
|
<change beforePath="$PROJECT_DIR$/src/state-tracker/TopicHistoryWindow.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/state-tracker/TopicHistoryWindow.ts" afterDir="false" />
|
|
15
18
|
<change beforePath="$PROJECT_DIR$/tests/history-window.test.ts" beforeDir="false" afterPath="$PROJECT_DIR$/tests/history-window.test.ts" afterDir="false" />
|
|
16
19
|
</list>
|
|
@@ -152,6 +155,7 @@
|
|
|
152
155
|
<workItem from="1762800459831" duration="10000" />
|
|
153
156
|
<workItem from="1763319451927" duration="2136000" />
|
|
154
157
|
<workItem from="1763410036992" duration="181000" />
|
|
158
|
+
<workItem from="1763457144937" duration="7689000" />
|
|
155
159
|
</task>
|
|
156
160
|
<task id="LOCAL-00013" summary="Permission related changes in protocol types">
|
|
157
161
|
<option name="closed" value="true" />
|
package/babel.config.js
CHANGED
package/build/index.cjs.js
CHANGED
|
@@ -195,7 +195,7 @@ class IndexedCollection {
|
|
|
195
195
|
}
|
|
196
196
|
return result;
|
|
197
197
|
}
|
|
198
|
-
|
|
198
|
+
createMirror() {
|
|
199
199
|
const copy = new IndexedCollection();
|
|
200
200
|
copy._items = this._items;
|
|
201
201
|
return copy;
|
|
@@ -203,8 +203,8 @@ class IndexedCollection {
|
|
|
203
203
|
}
|
|
204
204
|
class IndexedObjectCollection {
|
|
205
205
|
constructor(id, items = []) {
|
|
206
|
-
this.id = id;
|
|
207
206
|
IndexedObjectCollection_defineProperty(this, "_items", void 0);
|
|
207
|
+
this.id = id;
|
|
208
208
|
this._items = new IndexedCollection();
|
|
209
209
|
this.set(...items);
|
|
210
210
|
}
|
|
@@ -244,7 +244,7 @@ class IndexedObjectCollection {
|
|
|
244
244
|
}
|
|
245
245
|
return result;
|
|
246
246
|
}
|
|
247
|
-
|
|
247
|
+
createMirror() {
|
|
248
248
|
const copy = new IndexedObjectCollection(this.id);
|
|
249
249
|
copy._items = this._items;
|
|
250
250
|
return copy;
|
|
@@ -285,7 +285,7 @@ class ObservableIndexedCollection extends IndexedCollection {
|
|
|
285
285
|
});
|
|
286
286
|
}
|
|
287
287
|
}
|
|
288
|
-
|
|
288
|
+
createMirror() {
|
|
289
289
|
const copy = new ObservableIndexedCollection();
|
|
290
290
|
copy.eventTarget = this.eventTarget;
|
|
291
291
|
copy._items = this._items;
|
|
@@ -307,8 +307,8 @@ class ObservableIndexedCollection extends IndexedCollection {
|
|
|
307
307
|
class ObservableIndexedObjectCollection extends IndexedObjectCollection {
|
|
308
308
|
constructor(id, items = []) {
|
|
309
309
|
super(id);
|
|
310
|
-
this.id = id;
|
|
311
310
|
IndexedObjectCollection_defineProperty(this, "eventTarget", void 0);
|
|
311
|
+
this.id = id;
|
|
312
312
|
this.eventTarget = new EventTarget();
|
|
313
313
|
this.set(...items);
|
|
314
314
|
}
|
|
@@ -337,7 +337,7 @@ class ObservableIndexedObjectCollection extends IndexedObjectCollection {
|
|
|
337
337
|
});
|
|
338
338
|
}
|
|
339
339
|
}
|
|
340
|
-
|
|
340
|
+
createMirror() {
|
|
341
341
|
const copy = new ObservableIndexedObjectCollection(this.id);
|
|
342
342
|
copy.eventTarget = this.eventTarget;
|
|
343
343
|
copy._items = this._items;
|
|
@@ -423,64 +423,77 @@ let WindowState = /*#__PURE__*/function (WindowState) {
|
|
|
423
423
|
class TraversableRemoteCollection extends ObservableIndexedObjectCollection {
|
|
424
424
|
constructor(...args) {
|
|
425
425
|
super(...args);
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
TopicHistoryWindow_defineProperty(this, "currentState", WindowState.LIVE);
|
|
433
|
-
TopicHistoryWindow_defineProperty(this, "fetchingState", undefined);
|
|
426
|
+
TopicHistoryWindow_defineProperty(this, "internalState", {
|
|
427
|
+
current: WindowState.LIVE,
|
|
428
|
+
ongoing: undefined,
|
|
429
|
+
limit: 50,
|
|
430
|
+
oldestId: null
|
|
431
|
+
});
|
|
434
432
|
}
|
|
435
433
|
/**
|
|
436
434
|
* Current mode od collection window. To change mode, call one of available fetch methods.
|
|
437
435
|
*/
|
|
438
436
|
get state() {
|
|
439
|
-
return this.
|
|
437
|
+
return this.internalState.current;
|
|
438
|
+
}
|
|
439
|
+
/**
|
|
440
|
+
* Maximum numer of items stored in window.
|
|
441
|
+
* Null for unlimited.
|
|
442
|
+
*/
|
|
443
|
+
get limit() {
|
|
444
|
+
return this.internalState.limit;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
/**
|
|
448
|
+
* Maximum numer of items stored in window.
|
|
449
|
+
* Null for unlimited.
|
|
450
|
+
*/
|
|
451
|
+
set limit(value) {
|
|
452
|
+
this.internalState.limit = value;
|
|
440
453
|
}
|
|
441
454
|
get hasLatest() {
|
|
442
455
|
return [WindowState.LATEST, WindowState.LIVE].includes(this.state);
|
|
443
456
|
}
|
|
444
457
|
get hasOldest() {
|
|
445
|
-
return this.state === WindowState.OLDEST || this.oldestId !== null && this.has(this.oldestId);
|
|
458
|
+
return this.state === WindowState.OLDEST || this.internalState.oldestId !== null && this.has(this.internalState.oldestId);
|
|
446
459
|
}
|
|
447
460
|
async resetToLatest() {
|
|
448
|
-
if (this.
|
|
461
|
+
if (this.internalState.ongoing || this.internalState.current === WindowState.LATEST) {
|
|
449
462
|
return;
|
|
450
463
|
}
|
|
451
|
-
this.
|
|
464
|
+
this.internalState.ongoing = WindowState.LATEST;
|
|
452
465
|
let result;
|
|
453
466
|
try {
|
|
454
467
|
result = await this.fetchLatestItems();
|
|
455
468
|
} finally {
|
|
456
|
-
this.
|
|
469
|
+
this.internalState.ongoing = undefined;
|
|
457
470
|
}
|
|
458
471
|
this.deleteAll();
|
|
459
472
|
this.addItems(result, 'tail');
|
|
460
|
-
this.
|
|
473
|
+
this.internalState.current = WindowState.LATEST;
|
|
461
474
|
}
|
|
462
475
|
async fetchPrevious() {
|
|
463
|
-
if (this.
|
|
476
|
+
if (this.internalState.ongoing || this.hasOldest) {
|
|
464
477
|
return;
|
|
465
478
|
}
|
|
466
|
-
this.
|
|
479
|
+
this.internalState.ongoing = WindowState.PAST;
|
|
467
480
|
let result;
|
|
468
481
|
try {
|
|
469
482
|
result = await this.fetchItemsBefore();
|
|
470
483
|
} finally {
|
|
471
|
-
this.
|
|
484
|
+
this.internalState.ongoing = undefined;
|
|
472
485
|
}
|
|
473
486
|
if (!result) {
|
|
474
487
|
return this.resetToLatest();
|
|
475
488
|
}
|
|
476
489
|
if (!result.length) {
|
|
477
490
|
const firstItem = this.getAt(0);
|
|
478
|
-
this.oldestId = firstItem ? this.getId(firstItem) : null;
|
|
491
|
+
this.internalState.oldestId = firstItem ? this.getId(firstItem) : null;
|
|
479
492
|
await this.refreshFetchedState();
|
|
480
493
|
|
|
481
494
|
// LATEST state has priority over OLDEST
|
|
482
|
-
if (this.
|
|
483
|
-
this.
|
|
495
|
+
if (this.internalState.current === WindowState.PAST) {
|
|
496
|
+
this.internalState.current = WindowState.OLDEST;
|
|
484
497
|
}
|
|
485
498
|
return;
|
|
486
499
|
}
|
|
@@ -488,15 +501,15 @@ class TraversableRemoteCollection extends ObservableIndexedObjectCollection {
|
|
|
488
501
|
await this.refreshFetchedState();
|
|
489
502
|
}
|
|
490
503
|
async fetchNext() {
|
|
491
|
-
if (this.
|
|
504
|
+
if (this.internalState.ongoing || this.hasLatest) {
|
|
492
505
|
return;
|
|
493
506
|
}
|
|
494
|
-
this.
|
|
507
|
+
this.internalState.ongoing = WindowState.PAST;
|
|
495
508
|
let result;
|
|
496
509
|
try {
|
|
497
510
|
result = await this.fetchItemsAfter();
|
|
498
511
|
} finally {
|
|
499
|
-
this.
|
|
512
|
+
this.internalState.ongoing = undefined;
|
|
500
513
|
}
|
|
501
514
|
if (!result) {
|
|
502
515
|
await this.resetToLatest();
|
|
@@ -509,7 +522,7 @@ class TraversableRemoteCollection extends ObservableIndexedObjectCollection {
|
|
|
509
522
|
}
|
|
510
523
|
}
|
|
511
524
|
async refreshFetchedState() {
|
|
512
|
-
this.
|
|
525
|
+
this.internalState.current = (await this.isLatestItemLoaded()) ? WindowState.LATEST : WindowState.PAST;
|
|
513
526
|
}
|
|
514
527
|
addItems(newItems, to) {
|
|
515
528
|
let result;
|
|
@@ -539,53 +552,51 @@ class TraversableRemoteCollection extends ObservableIndexedObjectCollection {
|
|
|
539
552
|
}
|
|
540
553
|
}
|
|
541
554
|
class TopicHistoryWindow extends TraversableRemoteCollection {
|
|
542
|
-
constructor(roomId, topicId, tracker) {
|
|
555
|
+
constructor(roomId, topicId, tracker, bindEvents = true) {
|
|
543
556
|
super('id');
|
|
544
|
-
this.roomId = roomId;
|
|
545
|
-
this.topicId = topicId;
|
|
546
|
-
this.tracker = tracker;
|
|
547
557
|
/**
|
|
548
558
|
* Reexported available window modes enum.
|
|
549
559
|
*/
|
|
550
560
|
TopicHistoryWindow_defineProperty(this, "WindowState", WindowState);
|
|
551
|
-
|
|
552
|
-
this.
|
|
553
|
-
this.tracker
|
|
561
|
+
this.roomId = roomId;
|
|
562
|
+
this.topicId = topicId;
|
|
563
|
+
this.tracker = tracker;
|
|
564
|
+
this.internalState.traverseLock = false;
|
|
565
|
+
if (bindEvents) {
|
|
566
|
+
this.tracker.client.on('Session', ev => this.handleSession(ev));
|
|
567
|
+
this.tracker.client.on('NewMessage', ev => this.handleNewMessage(ev));
|
|
568
|
+
}
|
|
554
569
|
}
|
|
555
|
-
|
|
556
|
-
const copy = new TopicHistoryWindow(this.roomId, this.topicId, this.tracker);
|
|
570
|
+
createMirror() {
|
|
571
|
+
const copy = new TopicHistoryWindow(this.roomId, this.topicId, this.tracker, false);
|
|
557
572
|
copy.eventTarget = this.eventTarget;
|
|
558
573
|
copy._items = this._items;
|
|
559
|
-
copy.
|
|
560
|
-
copy.currentState = this.currentState;
|
|
561
|
-
copy.fetchingState = this.fetchingState;
|
|
562
|
-
copy.oldestId = this.oldestId;
|
|
563
|
-
copy.traverseLock = this.traverseLock;
|
|
574
|
+
copy.internalState = this.internalState;
|
|
564
575
|
return copy;
|
|
565
576
|
}
|
|
566
577
|
get isTraverseLocked() {
|
|
567
|
-
return this.traverseLock;
|
|
578
|
+
return this.internalState.traverseLock;
|
|
568
579
|
}
|
|
569
580
|
async setTraverseLock(lock) {
|
|
570
|
-
this.traverseLock = lock;
|
|
581
|
+
this.internalState.traverseLock = lock;
|
|
571
582
|
if (lock && this.state !== WindowState.LIVE && this.state !== WindowState.LATEST) {
|
|
572
583
|
await super.resetToLatest();
|
|
573
584
|
}
|
|
574
585
|
}
|
|
575
586
|
async resetToLatest() {
|
|
576
|
-
if (this.traverseLock) {
|
|
587
|
+
if (this.internalState.traverseLock) {
|
|
577
588
|
return;
|
|
578
589
|
}
|
|
579
590
|
return super.resetToLatest();
|
|
580
591
|
}
|
|
581
592
|
async fetchNext() {
|
|
582
|
-
if (this.traverseLock) {
|
|
593
|
+
if (this.internalState.traverseLock) {
|
|
583
594
|
return;
|
|
584
595
|
}
|
|
585
596
|
return super.fetchNext();
|
|
586
597
|
}
|
|
587
598
|
async fetchPrevious() {
|
|
588
|
-
if (this.traverseLock) {
|
|
599
|
+
if (this.internalState.traverseLock) {
|
|
589
600
|
return;
|
|
590
601
|
}
|
|
591
602
|
return super.fetchPrevious();
|
|
@@ -613,7 +624,7 @@ class TopicHistoryWindow extends TraversableRemoteCollection {
|
|
|
613
624
|
handleSession(ev) {
|
|
614
625
|
const rooms = ev.state.rooms;
|
|
615
626
|
if (rooms.find(room => room.id === this.roomId)) {
|
|
616
|
-
this.resetToLatest();
|
|
627
|
+
void this.resetToLatest();
|
|
617
628
|
} else {
|
|
618
629
|
this.deleteAll();
|
|
619
630
|
}
|
|
@@ -685,10 +696,10 @@ function RoomMessagesHistory_toPrimitive(input, hint) { if (typeof input !== "ob
|
|
|
685
696
|
|
|
686
697
|
class RoomMessagesHistory {
|
|
687
698
|
constructor(room, tracker) {
|
|
688
|
-
this.room = room;
|
|
689
|
-
this.tracker = tracker;
|
|
690
699
|
RoomMessagesHistory_defineProperty(this, "historyWindows", new IndexedCollection());
|
|
691
700
|
RoomMessagesHistory_defineProperty(this, "traverseLock", false);
|
|
701
|
+
this.room = room;
|
|
702
|
+
this.tracker = tracker;
|
|
692
703
|
this.tracker.client.on('RoomUpdated', ev => this.handleRoomUpdated(ev));
|
|
693
704
|
this.tracker.client.on('NewTopic', ev => this.handleNewTopic(ev));
|
|
694
705
|
this.tracker.client.on('TopicDeleted', ev => this.handleTopicDeleted(ev));
|
|
@@ -760,11 +771,11 @@ function MessagesManager_toPrimitive(input, hint) { if (typeof input !== "object
|
|
|
760
771
|
|
|
761
772
|
class MessagesManager {
|
|
762
773
|
constructor(tracker) {
|
|
763
|
-
this.tracker = tracker;
|
|
764
774
|
MessagesManager_defineProperty(this, "roomHistories", new IndexedCollection());
|
|
765
775
|
MessagesManager_defineProperty(this, "followedTopics", new IndexedCollection());
|
|
766
776
|
MessagesManager_defineProperty(this, "followedTopicsPromises", new PromiseRegistry());
|
|
767
777
|
MessagesManager_defineProperty(this, "deferredSession", new DeferredTask());
|
|
778
|
+
this.tracker = tracker;
|
|
768
779
|
this.tracker.client.on('Session', ev => this.handleSession(ev));
|
|
769
780
|
this.tracker.client.on('RoomJoined', ev => this.handleRoomJoin(ev));
|
|
770
781
|
this.tracker.client.on('NewTopic', ev => this.handleNewTopic(ev));
|
|
@@ -985,7 +996,6 @@ function RoomsManager_toPrimitive(input, hint) { if (typeof input !== "object" |
|
|
|
985
996
|
|
|
986
997
|
class RoomsManager {
|
|
987
998
|
constructor(tracker) {
|
|
988
|
-
this.tracker = tracker;
|
|
989
999
|
RoomsManager_defineProperty(this, "messages", void 0);
|
|
990
1000
|
RoomsManager_defineProperty(this, "list", new ObservableIndexedObjectCollection('id'));
|
|
991
1001
|
RoomsManager_defineProperty(this, "topics", new IndexedCollection());
|
|
@@ -993,6 +1003,7 @@ class RoomsManager {
|
|
|
993
1003
|
RoomsManager_defineProperty(this, "deferredSession", new DeferredTask());
|
|
994
1004
|
RoomsManager_defineProperty(this, "membersPromises", new PromiseRegistry());
|
|
995
1005
|
RoomsManager_defineProperty(this, "topicsPromises", new PromiseRegistry());
|
|
1006
|
+
this.tracker = tracker;
|
|
996
1007
|
this.messages = new MessagesManager(tracker);
|
|
997
1008
|
this.tracker.client.on('NewMessage', ev => this.handleNewMessage(ev));
|
|
998
1009
|
this.tracker.client.on('NewTopic', ev => this.handleNewTopic(ev));
|
|
@@ -1311,7 +1322,6 @@ function SpacesManager_toPrimitive(input, hint) { if (typeof input !== "object"
|
|
|
1311
1322
|
|
|
1312
1323
|
class SpacesManager {
|
|
1313
1324
|
constructor(tracker) {
|
|
1314
|
-
this.tracker = tracker;
|
|
1315
1325
|
SpacesManager_defineProperty(this, "list", new ObservableIndexedObjectCollection('id'));
|
|
1316
1326
|
SpacesManager_defineProperty(this, "roles", new IndexedCollection());
|
|
1317
1327
|
SpacesManager_defineProperty(this, "rooms", new IndexedCollection());
|
|
@@ -1320,6 +1330,7 @@ class SpacesManager {
|
|
|
1320
1330
|
SpacesManager_defineProperty(this, "deferredSession", new DeferredTask());
|
|
1321
1331
|
SpacesManager_defineProperty(this, "roomsPromises", new PromiseRegistry());
|
|
1322
1332
|
SpacesManager_defineProperty(this, "membersPromises", new PromiseRegistry());
|
|
1333
|
+
this.tracker = tracker;
|
|
1323
1334
|
this.tracker.client.on('NewRoom', ev => this.handleNewRoom(ev));
|
|
1324
1335
|
this.tracker.client.on('RoomDeleted', ev => this.handleRoomDeleted(ev));
|
|
1325
1336
|
this.tracker.client.on('RoomUpdated', ev => this.handleRoomUpdated(ev));
|
|
@@ -1680,9 +1691,9 @@ const getOvIdByObject = overwrites => getOvId(overwrites.location, overwrites.ta
|
|
|
1680
1691
|
class PermissionsManager extends EventTarget {
|
|
1681
1692
|
constructor(tracker) {
|
|
1682
1693
|
super();
|
|
1683
|
-
this.tracker = tracker;
|
|
1684
1694
|
PermissionsManager_defineProperty(this, "overwrites", new IndexedCollection());
|
|
1685
1695
|
PermissionsManager_defineProperty(this, "overwritesPromises", new PromiseRegistry());
|
|
1696
|
+
this.tracker = tracker;
|
|
1686
1697
|
this.tracker.client.on('PermissionOverwrites', ev => this.handlePermissionOverwrites(ev));
|
|
1687
1698
|
this.tracker.client.on('PermissionOverwritesUpdated', ev => this.handlePermissionOverwrites(ev));
|
|
1688
1699
|
this.tracker.client.on('SpaceDeleted', ev => this.handleSpaceDeleted(ev));
|
|
@@ -1920,9 +1931,9 @@ function EmoticonsManager_toPrimitive(input, hint) { if (typeof input !== "objec
|
|
|
1920
1931
|
const GLOBAL_KEY = 'global';
|
|
1921
1932
|
class EmoticonsManager {
|
|
1922
1933
|
constructor(tracker) {
|
|
1923
|
-
this.tracker = tracker;
|
|
1924
1934
|
EmoticonsManager_defineProperty(this, "list", new IndexedCollection());
|
|
1925
1935
|
EmoticonsManager_defineProperty(this, "emoticonsPromises", new PromiseRegistry());
|
|
1936
|
+
this.tracker = tracker;
|
|
1926
1937
|
this.tracker.client.on('Emoticons', ev => this.handleEmoticons(ev));
|
|
1927
1938
|
this.tracker.client.on('NewEmoticon', ev => this.handleNewEmoticon(ev));
|
|
1928
1939
|
this.tracker.client.on('EmoticonDeleted', ev => this.handleEmoticonDeleted(ev));
|
|
@@ -1978,9 +1989,9 @@ function UsersManager_toPrimitive(input, hint) { if (typeof input !== "object" |
|
|
|
1978
1989
|
|
|
1979
1990
|
class UsersManager {
|
|
1980
1991
|
constructor(tracker) {
|
|
1981
|
-
this.tracker = tracker;
|
|
1982
1992
|
UsersManager_defineProperty(this, "onlineStatus", new EventTarget());
|
|
1983
1993
|
UsersManager_defineProperty(this, "users", new ObservableIndexedObjectCollection('id'));
|
|
1994
|
+
this.tracker = tracker;
|
|
1984
1995
|
// RoomMemberUpdated & SpaceMemberUpdated events are not contains user object
|
|
1985
1996
|
tracker.client.on('UserUpdated', event => this.handleUsers([event.user]));
|
|
1986
1997
|
tracker.client.on('RoomMemberJoined', event => this.handleMembers([event.member]));
|
|
@@ -2025,9 +2036,9 @@ const getId = (refUserId, type) => `${refUserId}-${type}`;
|
|
|
2025
2036
|
const getIdFromRelationship = relationship => getId(relationship.refUser.id, relationship.type);
|
|
2026
2037
|
class RelationshipsManager {
|
|
2027
2038
|
constructor(tracker) {
|
|
2028
|
-
this.tracker = tracker;
|
|
2029
2039
|
RelationshipsManager_defineProperty(this, "relationships", new ObservableIndexedObjectCollection(getIdFromRelationship));
|
|
2030
2040
|
RelationshipsManager_defineProperty(this, "promises", new PromiseRegistry());
|
|
2041
|
+
this.tracker = tracker;
|
|
2031
2042
|
this.tracker.client.on('Relationships', ev => this.handleRelationships(ev));
|
|
2032
2043
|
this.tracker.client.on('NewRelationship', ev => this.handleNewRelationship(ev));
|
|
2033
2044
|
this.tracker.client.on('RelationshipDeleted', ev => this.handleRelationshipDeleted(ev));
|
|
@@ -2083,7 +2094,6 @@ function ChatStateTracker_toPrimitive(input, hint) { if (typeof input !== "objec
|
|
|
2083
2094
|
|
|
2084
2095
|
class ChatStateTracker {
|
|
2085
2096
|
constructor(client) {
|
|
2086
|
-
this.client = client;
|
|
2087
2097
|
/**
|
|
2088
2098
|
* State of your permissions.
|
|
2089
2099
|
*/
|
|
@@ -2110,6 +2120,7 @@ class ChatStateTracker {
|
|
|
2110
2120
|
ChatStateTracker_defineProperty(this, "relationships", new RelationshipsManager(this));
|
|
2111
2121
|
ChatStateTracker_defineProperty(this, "_me", null);
|
|
2112
2122
|
ChatStateTracker_defineProperty(this, "deferredSession", new DeferredTask());
|
|
2123
|
+
this.client = client;
|
|
2113
2124
|
this.client.on('Session', ev => this.handleSession(ev));
|
|
2114
2125
|
}
|
|
2115
2126
|
get me() {
|
|
@@ -2140,7 +2151,6 @@ var WebSocketChatClientEvent = /*#__PURE__*/function (WebSocketChatClientEvent)
|
|
|
2140
2151
|
class WebSocketChatClient extends AbstractChatClient {
|
|
2141
2152
|
constructor(options) {
|
|
2142
2153
|
super();
|
|
2143
|
-
this.options = options;
|
|
2144
2154
|
WebSocketChatClient_defineProperty(this, "Event", WebSocketChatClientEvent);
|
|
2145
2155
|
WebSocketChatClient_defineProperty(this, "state", void 0);
|
|
2146
2156
|
WebSocketChatClient_defineProperty(this, "ws", null);
|
|
@@ -2148,6 +2158,7 @@ class WebSocketChatClient extends AbstractChatClient {
|
|
|
2148
2158
|
WebSocketChatClient_defineProperty(this, "connectingTimeoutId", void 0);
|
|
2149
2159
|
WebSocketChatClient_defineProperty(this, "authenticated", void 0);
|
|
2150
2160
|
WebSocketChatClient_defineProperty(this, "authenticatedResolvers", void 0);
|
|
2161
|
+
this.options = options;
|
|
2151
2162
|
if (this.options.stateTracking ?? true) {
|
|
2152
2163
|
this.state = new ChatStateTracker(this);
|
|
2153
2164
|
}
|
|
@@ -2247,9 +2258,9 @@ var WebApiChatClientEvent = /*#__PURE__*/function (WebApiChatClientEvent) {
|
|
|
2247
2258
|
class WebApiChatClient extends AbstractChatClient {
|
|
2248
2259
|
constructor(options) {
|
|
2249
2260
|
super();
|
|
2250
|
-
this.options = options;
|
|
2251
2261
|
WebApiChatClient_defineProperty(this, "Event", WebApiChatClientEvent);
|
|
2252
2262
|
WebApiChatClient_defineProperty(this, "sendStack", void 0);
|
|
2263
|
+
this.options = options;
|
|
2253
2264
|
}
|
|
2254
2265
|
async send(commandType, commandData) {
|
|
2255
2266
|
const envelope = this.createEnvelope(commandType, commandData);
|
|
@@ -2305,13 +2316,9 @@ class WebApiChatClient extends AbstractChatClient {
|
|
|
2305
2316
|
}
|
|
2306
2317
|
}
|
|
2307
2318
|
;// CONCATENATED MODULE: ./src/AbstractRestClient.ts
|
|
2308
|
-
function AbstractRestClient_defineProperty(obj, key, value) { key = AbstractRestClient_toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2309
|
-
function AbstractRestClient_toPropertyKey(arg) { var key = AbstractRestClient_toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
2310
|
-
function AbstractRestClient_toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
2311
2319
|
class AbstractRestClient {
|
|
2312
2320
|
constructor(options) {
|
|
2313
2321
|
this.options = options;
|
|
2314
|
-
AbstractRestClient_defineProperty(this, "defaultUrl", void 0);
|
|
2315
2322
|
}
|
|
2316
2323
|
async send(method, uri, data = undefined) {
|
|
2317
2324
|
let url = this.getUrl(uri);
|