polfan-server-js-client 0.1.99934 → 0.1.99936
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 +54 -20
- package/build/index.js +19 -19
- package/build/index.js.map +1 -1
- package/build/types/AbstractChatClient.d.ts +4 -1
- package/build/types/IndexedObjectCollection.d.ts +3 -2
- package/build/types/types/src/index.d.ts +5 -1
- package/build/types/types/src/schemes/Room.d.ts +2 -0
- package/build/types/types/src/schemes/RoomStream.d.ts +5 -0
- package/build/types/types/src/schemes/commands/GetClientData.d.ts +2 -0
- package/build/types/types/src/schemes/commands/SetClientData.d.ts +1 -0
- package/build/types/types/src/schemes/commands/UpdateRoom.d.ts +2 -0
- package/build/types/types/src/schemes/events/ClientData.d.ts +1 -0
- package/package.json +1 -1
- package/src/AbstractChatClient.ts +4 -1
- package/src/IndexedObjectCollection.ts +10 -8
- package/src/state-tracker/RoomsManager.ts +2 -2
- package/src/state-tracker/SpacesManager.ts +1 -1
- package/src/types/src/index.ts +9 -0
- package/src/types/src/schemes/Room.ts +2 -0
- package/src/types/src/schemes/RoomStream.ts +6 -0
- package/src/types/src/schemes/commands/GetClientData.ts +3 -0
- package/src/types/src/schemes/commands/SetClientData.ts +1 -0
- package/src/types/src/schemes/commands/UpdateRoom.ts +3 -0
- package/src/types/src/schemes/events/ClientData.ts +1 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Bye, GetSession, JoinSpace, Session, SpaceJoined, Error as ErrorType, SpaceLeft, SpaceMemberJoined, SpaceMemberLeft, SpaceMemberUpdated, SpaceDeleted, SpaceMembers, SpaceRooms, NewRole, RoomDeleted, RoomJoined, RoomLeft, RoomMemberLeft, RoomMemberJoined, RoomMembers, NewRoom, NewTopic, TopicDeleted, NewMessage, GetPermissionOverwrites, GetComputedPermissions, LeaveSpace, CreateSpace, DeleteSpace, GetSpaceMembers, GetSpaceRooms, CreateRole, DeleteRole, AssignRole, DeassignRole, SetPermissionOverwrites, JoinRoom, LeaveRoom, CreateRoom, DeleteRoom, GetRoomMembers, CreateTopic, DeleteTopic, CreateMessage, Envelope, PermissionOverwrites, PermissionOverwritesUpdated, RoomMemberUpdated, UpdateRole, RoleUpdated, Ack, UserUpdated, UpdateRoom, RoomUpdated, UpdateSpace, SpaceUpdated, PermissionOverwriteTargets, GetPermissionOverwriteTargets, Owners, Ok, GetOwners, CreateOwner, RoleDeleted, FollowedTopicUpdated, TopicFollowed, TopicUnfollowed, FollowedTopics, FollowTopic, UnfollowTopic, GetFollowedTopics, Messages, GetMessages, Topics, GetTopics, TopicUpdated, UpdateTopic, GetDiscoverableSpaces, DiscoverableSpaces, CreateEmoticon, DeleteEmoticon, GetEmoticons, Emoticons, EmoticonDeleted, NewEmoticon, Bans, GetBans, Ban, Unban, Kick } from "./types/src/index";
|
|
1
|
+
import { Bye, GetSession, JoinSpace, Session, SpaceJoined, Error as ErrorType, SpaceLeft, SpaceMemberJoined, SpaceMemberLeft, SpaceMemberUpdated, SpaceDeleted, SpaceMembers, SpaceRooms, NewRole, RoomDeleted, RoomJoined, RoomLeft, RoomMemberLeft, RoomMemberJoined, RoomMembers, NewRoom, NewTopic, TopicDeleted, NewMessage, GetPermissionOverwrites, GetComputedPermissions, LeaveSpace, CreateSpace, DeleteSpace, GetSpaceMembers, GetSpaceRooms, CreateRole, DeleteRole, AssignRole, DeassignRole, SetPermissionOverwrites, JoinRoom, LeaveRoom, CreateRoom, DeleteRoom, GetRoomMembers, CreateTopic, DeleteTopic, CreateMessage, Envelope, PermissionOverwrites, PermissionOverwritesUpdated, RoomMemberUpdated, UpdateRole, RoleUpdated, Ack, UserUpdated, UpdateRoom, RoomUpdated, UpdateSpace, SpaceUpdated, PermissionOverwriteTargets, GetPermissionOverwriteTargets, Owners, Ok, GetOwners, CreateOwner, RoleDeleted, FollowedTopicUpdated, TopicFollowed, TopicUnfollowed, FollowedTopics, FollowTopic, UnfollowTopic, GetFollowedTopics, Messages, GetMessages, Topics, GetTopics, TopicUpdated, UpdateTopic, GetDiscoverableSpaces, DiscoverableSpaces, CreateEmoticon, DeleteEmoticon, GetEmoticons, Emoticons, EmoticonDeleted, NewEmoticon, Bans, GetBans, Ban, Unban, Kick, ClientData, GetClientData, SetClientData } from "./types/src/index";
|
|
2
2
|
import { EventTarget } from "./EventTarget";
|
|
3
3
|
type ArrayOfPromiseResolvers = [(value: any) => void, (reason?: any) => void];
|
|
4
4
|
export declare abstract class AbstractChatClient extends EventTarget {
|
|
@@ -33,6 +33,7 @@ export type EventsMap = {
|
|
|
33
33
|
EmoticonDeleted: EmoticonDeleted;
|
|
34
34
|
Emoticons: Emoticons;
|
|
35
35
|
Bans: Bans;
|
|
36
|
+
ClientData: ClientData;
|
|
36
37
|
DiscoverableSpaces: DiscoverableSpaces;
|
|
37
38
|
SpaceJoined: SpaceJoined;
|
|
38
39
|
SpaceLeft: SpaceLeft;
|
|
@@ -86,6 +87,8 @@ export type CommandsMap = {
|
|
|
86
87
|
Ban: [Ban, EventsMap['Ok']];
|
|
87
88
|
Unban: [Unban, EventsMap['Ok']];
|
|
88
89
|
Kick: [Kick, EventsMap['Ok']];
|
|
90
|
+
GetClientData: [GetClientData, EventsMap['ClientData']];
|
|
91
|
+
SetClientData: [SetClientData, EventsMap['Ok']];
|
|
89
92
|
GetDiscoverableSpaces: [GetDiscoverableSpaces, EventsMap['DiscoverableSpaces']];
|
|
90
93
|
JoinSpace: [JoinSpace, EventsMap['SpaceJoined']];
|
|
91
94
|
LeaveSpace: [LeaveSpace, EventsMap['SpaceLeft']];
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { EventTarget, ObservableInterface } from "./EventTarget";
|
|
2
2
|
export declare class IndexedCollection<KeyT, ValueT> {
|
|
3
3
|
protected _items: Map<KeyT, ValueT>;
|
|
4
|
+
protected _mutationCounter: number;
|
|
4
5
|
constructor(items?: [key: KeyT, value: ValueT][]);
|
|
6
|
+
get mutationCounter(): number;
|
|
5
7
|
get items(): Map<KeyT, ValueT>;
|
|
6
8
|
get length(): number;
|
|
7
9
|
set(...items: [KeyT, ValueT][]): void;
|
|
@@ -10,7 +12,6 @@ export declare class IndexedCollection<KeyT, ValueT> {
|
|
|
10
12
|
delete(...ids: KeyT[]): void;
|
|
11
13
|
deleteAll(): void;
|
|
12
14
|
findBy(field: keyof ValueT, valueToFind: any, limit?: number): IndexedCollection<KeyT, ValueT>;
|
|
13
|
-
map<MapT = any>(callback: (item: ValueT, index: KeyT) => MapT): MapT[];
|
|
14
15
|
}
|
|
15
16
|
export declare class IndexedObjectCollection<T> {
|
|
16
17
|
readonly id: keyof T | ((item: T) => any);
|
|
@@ -18,6 +19,7 @@ export declare class IndexedObjectCollection<T> {
|
|
|
18
19
|
constructor(id: keyof T | ((item: T) => any), items?: T[]);
|
|
19
20
|
get items(): T[];
|
|
20
21
|
get length(): number;
|
|
22
|
+
get mutationCounter(): number;
|
|
21
23
|
set(...items: T[]): void;
|
|
22
24
|
get(id: any): T | undefined;
|
|
23
25
|
getAt(index: number): T | undefined;
|
|
@@ -25,7 +27,6 @@ export declare class IndexedObjectCollection<T> {
|
|
|
25
27
|
delete(...ids: any[]): void;
|
|
26
28
|
deleteAll(): void;
|
|
27
29
|
findBy(field: keyof T, valueToFind: any, limit?: number): IndexedObjectCollection<T>;
|
|
28
|
-
map<MapT = any>(callback: (item: T, index: number, array: T[]) => MapT): MapT[];
|
|
29
30
|
protected getId(item: T): any;
|
|
30
31
|
}
|
|
31
32
|
interface ObservableCollectionEvent<KeyT> {
|
|
@@ -107,4 +107,8 @@ import { BanObject } from "./schemes/BanObject";
|
|
|
107
107
|
import { Bans } from "./schemes/events/Bans";
|
|
108
108
|
import { Kick } from "./schemes/commands/Kick";
|
|
109
109
|
import { LeaveReason } from "./schemes/LeaveReason";
|
|
110
|
-
|
|
110
|
+
import { GetClientData } from "./schemes/commands/GetClientData";
|
|
111
|
+
import { SetClientData } from "./schemes/commands/SetClientData";
|
|
112
|
+
import { ClientData } from "./schemes/events/ClientData";
|
|
113
|
+
import { RoomStream, RoomStreamType } from "./schemes/RoomStream";
|
|
114
|
+
export { Envelope, Message, MessageType, Role, Room, RoomFlag, RoomType, RoomMember, RoomSummary, Space, SpaceMember, Topic, FollowedTopic, User, UserState, PermissionOverwritesValue, ChatLocation, SpaceSummary, SpaceDiscoverable, Emoticon, PermissionOverwritesTarget, BanObject, LeaveReason, RoomStream, RoomStreamType, Bye, Error, Messages, NewMessage, NewRole, NewRoom, NewTopic, TopicFollowed, TopicUnfollowed, FollowedTopics, FollowedTopicUpdated, ComputedPermissions, PermissionOverwrites, PermissionOverwritesUpdated, RoleDeleted, RoleUpdated, RoomDeleted, RoomUpdated, RoomJoined, RoomLeft, RoomMemberJoined, RoomMemberLeft, RoomMembers, RoomMemberUpdated, UserUpdated, Session, SpaceDeleted, SpaceUpdated, SpaceJoined, SpaceLeft, SpaceMemberJoined, SpaceMemberLeft, SpaceMembers, SpaceMemberUpdated, SpaceRooms, TopicDeleted, TopicUpdated, PermissionOverwriteTargets, Owners, Ok, DiscoverableSpaces, Emoticons, EmoticonDeleted, NewEmoticon, Bans, ClientData, AssignRole, GetMessages, CreateMessage, Ack, CreateRole, CreateRoom, CreateSpace, CreateTopic, FollowTopic, UnfollowTopic, GetFollowedTopics, DeassignRole, DeleteRole, DeleteRoom, DeleteSpace, DeleteTopic, SetPermissionOverwrites, GetPermissionOverwrites, GetComputedPermissions, GetRoomMembers, GetSession, GetSpaceMembers, GetSpaceRooms, JoinRoom, JoinSpace, LeaveRoom, LeaveSpace, UpdateRole, UpdateSpace, UpdateRoom, UpdateTopic, GetPermissionOverwriteTargets, CreateOwner, DeleteOwner, GetOwners, Topics, GetTopics, GetDiscoverableSpaces, GetEmoticons, CreateEmoticon, DeleteEmoticon, Ban, Unban, GetBans, Kick, GetClientData, SetClientData, };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Topic } from "./Topic";
|
|
2
2
|
import { User } from "./User";
|
|
3
|
+
import { RoomStream } from "./RoomStream";
|
|
3
4
|
export type RoomType = 'Text' | 'ClassicText' | 'Pm';
|
|
4
5
|
export declare enum RoomFlag {
|
|
5
6
|
AllowSystemMessages = 1
|
|
@@ -13,4 +14,5 @@ export interface Room {
|
|
|
13
14
|
defaultTopic: Topic | null;
|
|
14
15
|
recipients: User[] | null;
|
|
15
16
|
flags: number;
|
|
17
|
+
stream: RoomStream | null;
|
|
16
18
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type SetClientData = Record<string, any>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type ClientData = Record<string, any>;
|
package/package.json
CHANGED
|
@@ -82,7 +82,7 @@ import {
|
|
|
82
82
|
GetEmoticons,
|
|
83
83
|
Emoticons,
|
|
84
84
|
EmoticonDeleted,
|
|
85
|
-
NewEmoticon, Bans, GetBans, Ban, Unban, Kick,
|
|
85
|
+
NewEmoticon, Bans, GetBans, Ban, Unban, Kick, ClientData, GetClientData, SetClientData,
|
|
86
86
|
} from "./types/src/index";
|
|
87
87
|
import {EventTarget} from "./EventTarget";
|
|
88
88
|
import {ErrorObject} from "css-minimizer-webpack-plugin";
|
|
@@ -160,6 +160,7 @@ export type EventsMap = {
|
|
|
160
160
|
EmoticonDeleted: EmoticonDeleted,
|
|
161
161
|
Emoticons: Emoticons,
|
|
162
162
|
Bans: Bans,
|
|
163
|
+
ClientData: ClientData,
|
|
163
164
|
// Space events
|
|
164
165
|
DiscoverableSpaces: DiscoverableSpaces,
|
|
165
166
|
SpaceJoined: SpaceJoined,
|
|
@@ -218,6 +219,8 @@ export type CommandsMap = {
|
|
|
218
219
|
Ban: [Ban, EventsMap['Ok']],
|
|
219
220
|
Unban: [Unban, EventsMap['Ok']],
|
|
220
221
|
Kick: [Kick, EventsMap['Ok']],
|
|
222
|
+
GetClientData: [GetClientData, EventsMap['ClientData']],
|
|
223
|
+
SetClientData: [SetClientData, EventsMap['Ok']],
|
|
221
224
|
// Space commands
|
|
222
225
|
GetDiscoverableSpaces: [GetDiscoverableSpaces, EventsMap['DiscoverableSpaces']],
|
|
223
226
|
JoinSpace: [JoinSpace, EventsMap['SpaceJoined']],
|
|
@@ -2,11 +2,16 @@ import {EventTarget, ObservableInterface} from "./EventTarget";
|
|
|
2
2
|
|
|
3
3
|
export class IndexedCollection<KeyT, ValueT> {
|
|
4
4
|
protected _items: Map<KeyT, ValueT> = new Map();
|
|
5
|
+
protected _mutationCounter: number = 0;
|
|
5
6
|
|
|
6
7
|
public constructor(items: [key: KeyT, value: ValueT][] = []) {
|
|
7
8
|
this.set(...items);
|
|
8
9
|
}
|
|
9
10
|
|
|
11
|
+
public get mutationCounter(): number {
|
|
12
|
+
return this._mutationCounter;
|
|
13
|
+
}
|
|
14
|
+
|
|
10
15
|
public get items(): Map<KeyT, ValueT> {
|
|
11
16
|
return this._items;
|
|
12
17
|
}
|
|
@@ -16,6 +21,7 @@ export class IndexedCollection<KeyT, ValueT> {
|
|
|
16
21
|
}
|
|
17
22
|
|
|
18
23
|
public set(...items: [KeyT, ValueT][]): void {
|
|
24
|
+
this._mutationCounter++;
|
|
19
25
|
for (const item of items) {
|
|
20
26
|
this._items.set(item[0], item[1]);
|
|
21
27
|
}
|
|
@@ -52,10 +58,6 @@ export class IndexedCollection<KeyT, ValueT> {
|
|
|
52
58
|
}
|
|
53
59
|
return result;
|
|
54
60
|
}
|
|
55
|
-
|
|
56
|
-
public map<MapT = any>(callback: (item: ValueT, index: KeyT) => MapT): MapT[] {
|
|
57
|
-
return Array.from(this.items.entries()).map((entry) => callback(entry[1], entry[0]));
|
|
58
|
-
}
|
|
59
61
|
}
|
|
60
62
|
|
|
61
63
|
export class IndexedObjectCollection<T> {
|
|
@@ -77,6 +79,10 @@ export class IndexedObjectCollection<T> {
|
|
|
77
79
|
return this._items.length;
|
|
78
80
|
}
|
|
79
81
|
|
|
82
|
+
public get mutationCounter(): number {
|
|
83
|
+
return this._items.mutationCounter;
|
|
84
|
+
}
|
|
85
|
+
|
|
80
86
|
public set(...items: T[]): void {
|
|
81
87
|
this._items.set(...(items.map(item => [this.getId(item), item] as [string, T])));
|
|
82
88
|
}
|
|
@@ -114,10 +120,6 @@ export class IndexedObjectCollection<T> {
|
|
|
114
120
|
return result;
|
|
115
121
|
}
|
|
116
122
|
|
|
117
|
-
public map<MapT = any>(callback: (item: T, index: number, array: T[]) => MapT): MapT[] {
|
|
118
|
-
return this.items.map(callback);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
123
|
protected getId(item: T): any {
|
|
122
124
|
return typeof this.id === 'function' ? this.id(item) : item[this.id];
|
|
123
125
|
}
|
|
@@ -124,7 +124,7 @@ export class RoomsManager {
|
|
|
124
124
|
this.membersPromises.forget(...roomIds);
|
|
125
125
|
|
|
126
126
|
for (const roomId of roomIds) {
|
|
127
|
-
const topicIds: string[] = this.topics.get(roomId)?.map(topic => topic.id) ?? [];
|
|
127
|
+
const topicIds: string[] = this.topics.get(roomId)?.items.map(topic => topic.id) ?? [];
|
|
128
128
|
this.messages._deleteByTopicIds(roomId, ...topicIds);
|
|
129
129
|
}
|
|
130
130
|
|
|
@@ -133,7 +133,7 @@ export class RoomsManager {
|
|
|
133
133
|
|
|
134
134
|
private deleteRoomsBySpaceId(spaceId: string): void {
|
|
135
135
|
this.deleteRoom(
|
|
136
|
-
...this.list.findBy('spaceId', spaceId).map(room => room.id)
|
|
136
|
+
...this.list.findBy('spaceId', spaceId).items.map(room => room.id)
|
|
137
137
|
);
|
|
138
138
|
}
|
|
139
139
|
|
|
@@ -184,7 +184,7 @@ export class SpacesManager {
|
|
|
184
184
|
}
|
|
185
185
|
|
|
186
186
|
private handleSpaceDeleted(ev: SpaceDeleted | SpaceLeft): void {
|
|
187
|
-
const roomIds = this.rooms.get(ev.id)?.map(item => item.id) ?? [];
|
|
187
|
+
const roomIds = this.rooms.get(ev.id)?.items.map(item => item.id) ?? [];
|
|
188
188
|
this.roomIdToSpaceId.delete(...roomIds);
|
|
189
189
|
|
|
190
190
|
this.roles.delete(ev.id);
|
package/src/types/src/index.ts
CHANGED
|
@@ -107,6 +107,10 @@ import {BanObject} from "./schemes/BanObject";
|
|
|
107
107
|
import {Bans} from "./schemes/events/Bans";
|
|
108
108
|
import {Kick} from "./schemes/commands/Kick";
|
|
109
109
|
import {LeaveReason} from "./schemes/LeaveReason";
|
|
110
|
+
import {GetClientData} from "./schemes/commands/GetClientData";
|
|
111
|
+
import {SetClientData} from "./schemes/commands/SetClientData";
|
|
112
|
+
import {ClientData} from "./schemes/events/ClientData";
|
|
113
|
+
import {RoomStream, RoomStreamType} from "./schemes/RoomStream";
|
|
110
114
|
|
|
111
115
|
export {
|
|
112
116
|
// objects
|
|
@@ -133,6 +137,8 @@ export {
|
|
|
133
137
|
PermissionOverwritesTarget,
|
|
134
138
|
BanObject,
|
|
135
139
|
LeaveReason,
|
|
140
|
+
RoomStream,
|
|
141
|
+
RoomStreamType,
|
|
136
142
|
// events
|
|
137
143
|
Bye,
|
|
138
144
|
Error,
|
|
@@ -179,6 +185,7 @@ export {
|
|
|
179
185
|
EmoticonDeleted,
|
|
180
186
|
NewEmoticon,
|
|
181
187
|
Bans,
|
|
188
|
+
ClientData,
|
|
182
189
|
// commands
|
|
183
190
|
AssignRole,
|
|
184
191
|
GetMessages,
|
|
@@ -225,4 +232,6 @@ export {
|
|
|
225
232
|
Unban,
|
|
226
233
|
GetBans,
|
|
227
234
|
Kick,
|
|
235
|
+
GetClientData,
|
|
236
|
+
SetClientData,
|
|
228
237
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {Topic} from "./Topic";
|
|
2
2
|
import {User} from "./User";
|
|
3
|
+
import {RoomStream} from "./RoomStream";
|
|
3
4
|
|
|
4
5
|
export type RoomType = 'Text' | 'ClassicText' | 'Pm';
|
|
5
6
|
|
|
@@ -16,4 +17,5 @@ export interface Room {
|
|
|
16
17
|
defaultTopic: Topic | null;
|
|
17
18
|
recipients: User[] | null;
|
|
18
19
|
flags: number;
|
|
20
|
+
stream: RoomStream | null;
|
|
19
21
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type SetClientData = Record<string, any>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type ClientData = Record<string, any>;
|