polfan-server-js-client 0.4.0 → 0.4.2

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.
Files changed (40) hide show
  1. package/.idea/workspace.xml +71 -242
  2. package/build/index.cjs.js +219 -125
  3. package/build/index.cjs.js.map +1 -1
  4. package/build/index.umd.js +1 -1
  5. package/build/index.umd.js.map +1 -1
  6. package/build/types/AbstractChatClient.d.ts +7 -1
  7. package/build/types/Permissions.d.ts +8 -0
  8. package/build/types/state-tracker/TopicHistoryWindow.d.ts +26 -1
  9. package/build/types/types/src/index.d.ts +9 -1
  10. package/build/types/types/src/schemes/Message.d.ts +5 -1
  11. package/build/types/types/src/schemes/MessagePoll.d.ts +10 -0
  12. package/build/types/types/src/schemes/Reaction.d.ts +13 -0
  13. package/build/types/types/src/schemes/commands/CreateMessage.d.ts +3 -0
  14. package/build/types/types/src/schemes/commands/GetMessages.d.ts +5 -0
  15. package/build/types/types/src/schemes/commands/GetReactionDetails.d.ts +8 -0
  16. package/build/types/types/src/schemes/commands/React.d.ts +6 -0
  17. package/build/types/types/src/schemes/commands/Unreact.d.ts +6 -0
  18. package/build/types/types/src/schemes/events/Messages.d.ts +3 -0
  19. package/build/types/types/src/schemes/events/Reacted.d.ts +9 -0
  20. package/build/types/types/src/schemes/events/ReactionDetails.d.ts +11 -0
  21. package/build/types/types/src/schemes/events/ReactionUpdated.d.ts +8 -0
  22. package/package.json +43 -43
  23. package/src/AbstractChatClient.ts +12 -0
  24. package/src/Permissions.ts +2 -0
  25. package/src/index.ts +31 -31
  26. package/src/state-tracker/TopicHistoryWindow.ts +121 -42
  27. package/src/state-tracker/UsersManager.ts +51 -51
  28. package/src/types/src/index.ts +333 -313
  29. package/src/types/src/schemes/Message.ts +5 -1
  30. package/src/types/src/schemes/MessagePoll.ts +12 -0
  31. package/src/types/src/schemes/Reaction.ts +16 -0
  32. package/src/types/src/schemes/commands/CreateMessage.ts +3 -0
  33. package/src/types/src/schemes/commands/GetMessages.ts +5 -0
  34. package/src/types/src/schemes/commands/GetReactionDetails.ts +9 -0
  35. package/src/types/src/schemes/commands/React.ts +7 -0
  36. package/src/types/src/schemes/commands/Unreact.ts +7 -0
  37. package/src/types/src/schemes/events/Messages.ts +3 -0
  38. package/src/types/src/schemes/events/Reacted.ts +10 -0
  39. package/src/types/src/schemes/events/ReactionDetails.ts +12 -0
  40. package/src/types/src/schemes/events/ReactionUpdated.ts +9 -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, RoomMembersJoined, 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, FollowedTopics, FollowTopic, UpdateFollowedTopic, GetFollowedTopics, Messages, GetMessages, Topics, GetTopics, TopicUpdated, UpdateTopic, GetDiscoverableSpaces, DiscoverableSpaces, CreateEmoticon, DeleteEmoticon, GetEmoticons, Emoticons, EmoticonDeleted, NewEmoticon, Bans, GetBans, Ban, Unban, Kick, ClientData, GetClientData, SetClientData, GetRoomSummary, GetSpaceSummary, RoomSummaryEvent, SpaceSummaryEvent, UpdateSpaceMember, Relationships, RelationshipDeleted, NewRelationship, DeleteRelationship, CreateRelationship, RoomSummaryUpdated, Pong, Ping, RedactMessages, MessagesRedacted, ReportAbuse, UpdateRoomMember, GetRelationships, GetUserInfo, UserInfo, SetSessionData, SessionData, GetSessionData, SetUserData, UserData, GetUserData, UnfollowTopic, TopicUnfollowed, Invite, Uninvite, GetInvited, Invited } from "./types/src";
1
+ import { Bye, GetSession, JoinSpace, Session, SpaceJoined, Error as ErrorType, SpaceLeft, SpaceMemberJoined, SpaceMemberLeft, SpaceMemberUpdated, SpaceDeleted, SpaceMembers, SpaceRooms, NewRole, RoomDeleted, RoomJoined, RoomLeft, RoomMemberLeft, RoomMembersJoined, 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, FollowedTopics, FollowTopic, UpdateFollowedTopic, GetFollowedTopics, Messages, GetMessages, Topics, GetTopics, TopicUpdated, UpdateTopic, GetDiscoverableSpaces, DiscoverableSpaces, CreateEmoticon, DeleteEmoticon, GetEmoticons, Emoticons, EmoticonDeleted, NewEmoticon, Bans, GetBans, Ban, Unban, Kick, ClientData, GetClientData, SetClientData, GetRoomSummary, GetSpaceSummary, RoomSummaryEvent, SpaceSummaryEvent, UpdateSpaceMember, Relationships, RelationshipDeleted, NewRelationship, DeleteRelationship, CreateRelationship, RoomSummaryUpdated, Pong, Ping, RedactMessages, MessagesRedacted, ReportAbuse, UpdateRoomMember, GetRelationships, GetUserInfo, UserInfo, SetSessionData, SessionData, GetSessionData, SetUserData, UserData, GetUserData, UnfollowTopic, TopicUnfollowed, Invite, Uninvite, GetInvited, Invited, React, Unreact, GetReactionDetails, ReactionUpdated, Reacted, ReactionDetails } from "./types/src";
2
2
  import { EventTarget } from "./EventTarget";
3
3
  type ArrayOfPromiseResolvers = [(value: any) => void, (reason?: any) => void];
4
4
  type ExtraEventMap = Record<string, any>;
@@ -90,6 +90,9 @@ export type EventsMap = {
90
90
  Topics: Topics;
91
91
  TopicUpdated: TopicUpdated;
92
92
  MessagesRedacted: MessagesRedacted;
93
+ ReactionUpdated: ReactionUpdated;
94
+ Reacted: Reacted;
95
+ ReactionDetails: ReactionDetails;
93
96
  };
94
97
  /**
95
98
  * Map of commands and their corresponding events.
@@ -160,5 +163,8 @@ export type CommandsMap = {
160
163
  GetTopics: CommandDefinition<GetTopics, EventsMap['Topics']>;
161
164
  UpdateTopic: CommandDefinition<UpdateTopic, EventsMap['TopicUpdated']>;
162
165
  RedactMessages: CommandDefinition<RedactMessages, EventsMap['MessagesRedacted']>;
166
+ React: CommandDefinition<React, EventsMap['Reacted']>;
167
+ Unreact: CommandDefinition<Unreact, EventsMap['Reacted']>;
168
+ GetReactionDetails: CommandDefinition<GetReactionDetails, EventsMap['ReactionDetails']>;
163
169
  };
164
170
  export {};
@@ -90,6 +90,14 @@ export declare class Permissions {
90
90
  value: number;
91
91
  maxLayer: Layer;
92
92
  };
93
+ React: {
94
+ value: number;
95
+ maxLayer: Layer;
96
+ };
97
+ CreatePolls: {
98
+ value: number;
99
+ maxLayer: Layer;
100
+ };
93
101
  };
94
102
  static getNames(): (keyof typeof this.list)[];
95
103
  static getByName(name: keyof typeof this.list): PermissionDefinition | undefined;
@@ -1,4 +1,4 @@
1
- import { Message, Topic } from "../types/src";
1
+ import { Message, Topic, UserReaction } from "../types/src";
2
2
  import { ChatStateTracker } from "./ChatStateTracker";
3
3
  import { CollectionEventMap, ObservableIndexedObjectCollection } from "../IndexedObjectCollection";
4
4
  export declare enum WindowState {
@@ -94,10 +94,23 @@ export declare class TopicHistoryWindow extends TraversableRemoteCollection<Mess
94
94
  readonly WindowState: typeof WindowState;
95
95
  protected internalState: typeof TraversableRemoteCollection<Message>['prototype']['internalState'] & {
96
96
  traverseLock: boolean;
97
+ includeMyReactions: boolean;
98
+ myReactions: Record<string, UserReaction[]>;
97
99
  };
98
100
  constructor(roomId: string, topicId: string, tracker: ChatStateTracker, bindEvents?: boolean);
99
101
  createMirror(): TopicHistoryWindow;
100
102
  get isTraverseLocked(): boolean;
103
+ /**
104
+ * What the connected user has reacted with, keyed by message id. Kept apart from
105
+ * the messages, so the history itself is identical for every user.
106
+ */
107
+ get myReactions(): Readonly<Record<string, UserReaction[]>>;
108
+ /**
109
+ * Whether the history is fetched together with the reactions of the connected
110
+ * user. Turn it off only where the active state of a reaction is never rendered.
111
+ */
112
+ get includeMyReactions(): boolean;
113
+ set includeMyReactions(value: boolean);
101
114
  setTraverseLock(lock: boolean): Promise<void>;
102
115
  resetToLatest(force?: boolean): Promise<void>;
103
116
  fetchNext(): Promise<void>;
@@ -112,9 +125,21 @@ export declare class TopicHistoryWindow extends TraversableRemoteCollection<Mess
112
125
  protected fetchItemsAround(id: string): Promise<Message[] | null>;
113
126
  protected fetchItemsBefore(): Promise<Message[] | null>;
114
127
  protected fetchLatestItems(): Promise<Message[]>;
128
+ private fetchMessages;
129
+ /**
130
+ * The response is the truth for every message it covers, so a message it does not
131
+ * mention has no reaction of this user left on it.
132
+ */
133
+ private storeMyReactions;
115
134
  private getTopic;
116
135
  private getLatestMessageId;
117
136
  protected isLatestItemLoaded(): Promise<boolean>;
118
137
  private handleNewMessage;
138
+ /**
139
+ * The counter arrives as the global source of truth - only it is overwritten, and
140
+ * a reaction nobody holds any more (count 0) leaves the message.
141
+ */
142
+ private handleReactionUpdated;
143
+ private handleReacted;
119
144
  private handleMessagesRedacted;
120
145
  }
@@ -145,4 +145,12 @@ import { Uninvite } from "./schemes/commands/Uninvite";
145
145
  import { GetInvited } from "./schemes/commands/GetInvited";
146
146
  import { Invited } from "./schemes/events/Invited";
147
147
  import { TopicUnfollowed } from "./schemes/events/TopicUnfollowed";
148
- export { Envelope, Message, MessageType, MessageAuthor, Role, Room, RoomType, RoomStream, RoomStreamType, RoomHistory, RoomHistoryMode, RoomMember, RoomSummary, RoomSummaryExtras, Space, SpaceMember, Topic, FollowedTopic, NotificationLevel, User, UserStatus, UserState, PermissionOverwritesValue, ChatLocation, SpaceSummary, SpaceDiscoverable, Emoticon, PermissionOverwritesTarget, BanObject, LeaveReason, UserRelationship, UserRelationshipType, CreateTopicInitialMessage, UserInformation, SessionPush, SessionData, SessionPlatform, UserData, PrivateMessagePolicy, Bye, Error, Messages, NewMessage, NewRole, NewRoom, NewTopic, TopicFollowed, TopicUnfollowed, FollowedTopics, FollowedTopicUpdated, ComputedPermissions, PermissionOverwrites, PermissionOverwritesUpdated, RoleDeleted, RoleUpdated, RoomDeleted, RoomUpdated, RoomJoined, RoomLeft, RoomMembersJoined, 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, SpaceSummaryEvent, RoomSummaryEvent, NewRelationship, RelationshipDeleted, Relationships, RoomSummaryUpdated, Pong, MessagesRedacted, UserInfo, Invited, AssignRole, GetMessages, CreateMessage, Ack, CreateRole, CreateRoom, CreateSpace, CreateTopic, FollowTopic, UnfollowTopic, UpdateFollowedTopic, 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, GetSpaceSummary, GetRoomSummary, UpdateSpaceMember, CreateRelationship, DeleteRelationship, GetRelationships, UpdateRoomMember, Ping, ReportAbuse, RedactMessages, GetUserInfo, SetSessionData, GetSessionData, SetUserData, GetUserData, Invite, Uninvite, GetInvited, };
148
+ import { MessageReaction, ReactionType, ToggledReaction, UserReaction } from "./schemes/Reaction";
149
+ import { MessagePoll, MessagePollOption } from "./schemes/MessagePoll";
150
+ import { React } from "./schemes/commands/React";
151
+ import { Unreact } from "./schemes/commands/Unreact";
152
+ import { GetReactionDetails } from "./schemes/commands/GetReactionDetails";
153
+ import { ReactionUpdated } from "./schemes/events/ReactionUpdated";
154
+ import { Reacted } from "./schemes/events/Reacted";
155
+ import { ReactionDetails } from "./schemes/events/ReactionDetails";
156
+ export { Envelope, Message, MessageType, MessageAuthor, Role, Room, RoomType, RoomStream, RoomStreamType, RoomHistory, RoomHistoryMode, RoomMember, RoomSummary, RoomSummaryExtras, Space, SpaceMember, Topic, FollowedTopic, NotificationLevel, User, UserStatus, UserState, PermissionOverwritesValue, ChatLocation, SpaceSummary, SpaceDiscoverable, Emoticon, PermissionOverwritesTarget, BanObject, LeaveReason, UserRelationship, UserRelationshipType, CreateTopicInitialMessage, UserInformation, SessionPush, SessionData, SessionPlatform, UserData, PrivateMessagePolicy, ReactionType, MessageReaction, UserReaction, ToggledReaction, MessagePoll, MessagePollOption, Bye, Error, Messages, NewMessage, NewRole, NewRoom, NewTopic, TopicFollowed, TopicUnfollowed, FollowedTopics, FollowedTopicUpdated, ComputedPermissions, PermissionOverwrites, PermissionOverwritesUpdated, RoleDeleted, RoleUpdated, RoomDeleted, RoomUpdated, RoomJoined, RoomLeft, RoomMembersJoined, 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, SpaceSummaryEvent, RoomSummaryEvent, NewRelationship, RelationshipDeleted, Relationships, RoomSummaryUpdated, Pong, MessagesRedacted, UserInfo, Invited, ReactionUpdated, Reacted, ReactionDetails, AssignRole, GetMessages, CreateMessage, Ack, CreateRole, CreateRoom, CreateSpace, CreateTopic, FollowTopic, UnfollowTopic, UpdateFollowedTopic, 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, GetSpaceSummary, GetRoomSummary, UpdateSpaceMember, CreateRelationship, DeleteRelationship, GetRelationships, UpdateRoomMember, Ping, ReportAbuse, RedactMessages, GetUserInfo, SetSessionData, GetSessionData, SetUserData, GetUserData, Invite, Uninvite, GetInvited, React, Unreact, GetReactionDetails, };
@@ -1,6 +1,8 @@
1
1
  import { User } from "./User";
2
2
  import { ChatLocation } from "./ChatLocation";
3
- export type MessageType = 'Text' | 'RoomJoin' | 'RoomMemberAdd' | 'RoomLeave' | 'SpaceJoin' | 'SpaceLeave' | 'TopicChange' | 'CustomNickChange' | 'Ephemeral';
3
+ import { MessageReaction } from "./Reaction";
4
+ import { MessagePoll } from "./MessagePoll";
5
+ export type MessageType = 'Text' | 'RoomJoin' | 'RoomMemberAdd' | 'RoomLeave' | 'SpaceJoin' | 'SpaceLeave' | 'TopicChange' | 'CustomNickChange' | 'Ephemeral' | 'Poll';
4
6
  export interface MessageAuthor {
5
7
  user: User;
6
8
  customNick?: string;
@@ -15,4 +17,6 @@ export interface Message {
15
17
  content?: string;
16
18
  topicRef: string | null;
17
19
  attachments: string[] | null;
20
+ reactions: MessageReaction[];
21
+ poll?: MessagePoll;
18
22
  }
@@ -0,0 +1,10 @@
1
+ import { ReactionType } from "./Reaction";
2
+ export interface MessagePollOption {
3
+ type: ReactionType;
4
+ value: string;
5
+ label: string;
6
+ }
7
+ export interface MessagePoll {
8
+ multipleChoice: boolean;
9
+ options: MessagePollOption[];
10
+ }
@@ -0,0 +1,13 @@
1
+ export type ReactionType = 'Emoji' | 'Emoticon';
2
+ export interface MessageReaction {
3
+ type: ReactionType;
4
+ value: string;
5
+ count: number;
6
+ }
7
+ export interface UserReaction {
8
+ type: ReactionType;
9
+ value: string;
10
+ }
11
+ export interface ToggledReaction extends UserReaction {
12
+ isAdded: boolean;
13
+ }
@@ -1,8 +1,11 @@
1
1
  import { ChatLocation } from "../ChatLocation";
2
+ import { MessagePoll } from "../MessagePoll";
2
3
  export interface CreateMessage {
3
4
  location: ChatLocation;
4
5
  content: string;
5
6
  attachments?: string[];
6
7
  customNick?: string;
7
8
  customColor?: string;
9
+ /** Turns the message into a poll; its content becomes the question. */
10
+ poll?: MessagePoll;
8
11
  }
@@ -5,4 +5,9 @@ export interface GetMessages {
5
5
  after?: string;
6
6
  around?: string;
7
7
  limit?: number;
8
+ /**
9
+ * Pull the reactions of the asking user along with the messages, instead of
10
+ * asking for their own state separately.
11
+ */
12
+ includeMyReactions?: boolean;
8
13
  }
@@ -0,0 +1,8 @@
1
+ import { ReactionType } from "../Reaction";
2
+ export interface GetReactionDetails {
3
+ messageId: string;
4
+ type: ReactionType;
5
+ value: string;
6
+ limit?: number;
7
+ offset?: number;
8
+ }
@@ -0,0 +1,6 @@
1
+ import { ReactionType } from "../Reaction";
2
+ export interface React {
3
+ messageId: string;
4
+ type: ReactionType;
5
+ value: string;
6
+ }
@@ -0,0 +1,6 @@
1
+ import { ReactionType } from "../Reaction";
2
+ export interface Unreact {
3
+ messageId: string;
4
+ type: ReactionType;
5
+ value: string;
6
+ }
@@ -1,6 +1,9 @@
1
1
  import { ChatLocation } from "../ChatLocation";
2
2
  import { Message } from "../Message";
3
+ import { UserReaction } from "../Reaction";
3
4
  export interface Messages {
4
5
  location: ChatLocation;
5
6
  messages: Message[];
7
+ /** Message id => reactions of the asking user; present only when requested. */
8
+ myReactions?: Record<string, UserReaction[]>;
6
9
  }
@@ -0,0 +1,9 @@
1
+ import { ToggledReaction } from "../Reaction";
2
+ /**
3
+ * Sent to every client of the voting user, so all of their devices know what they
4
+ * voted for without refetching the message history.
5
+ */
6
+ export interface Reacted {
7
+ messageId: string;
8
+ reaction: ToggledReaction;
9
+ }
@@ -0,0 +1,11 @@
1
+ import { ReactionType } from "../Reaction";
2
+ /**
3
+ * Who reacted, oldest vote first. Only the ids travel - the nicks are already
4
+ * known from the room members collection.
5
+ */
6
+ export interface ReactionDetails {
7
+ messageId: string;
8
+ type: ReactionType;
9
+ value: string;
10
+ userIds: string[];
11
+ }
@@ -0,0 +1,8 @@
1
+ import { MessageReaction } from "../Reaction";
2
+ /**
3
+ * The single source of truth of a reaction counter, broadcast to the whole room.
4
+ */
5
+ export interface ReactionUpdated {
6
+ messageId: string;
7
+ reaction: MessageReaction;
8
+ }
package/package.json CHANGED
@@ -1,43 +1,43 @@
1
- {
2
- "name": "polfan-server-js-client",
3
- "version": "0.4.0",
4
- "description": "JavaScript client library for handling communication with Polfan chat server.",
5
- "author": "Jarosław Żak",
6
- "license": "MIT",
7
- "main": "build/index.cjs.js",
8
- "browser": "build/index.umd.js",
9
- "types": "build/types/index.d.ts",
10
- "exports": {
11
- ".": {
12
- "types": "./build/types/index.d.ts",
13
- "require": "./build/index.cjs.js",
14
- "browser": "./build/index.umd.js",
15
- "default": "./build/index.cjs.js"
16
- }
17
- },
18
- "scripts": {
19
- "build": "npm run build:node && npm run build:browser && tsc",
20
- "build:node": "webpack --config webpack.config.node.js",
21
- "build:browser": "webpack --config webpack.config.browser.js",
22
- "test": "jest",
23
- "coverage": "npm run test -- --coverage",
24
- "trypublish": "npm publish || true"
25
- },
26
- "devDependencies": {
27
- "@babel/cli": "^7.28.3",
28
- "@babel/core": "^7.28.5",
29
- "@babel/preset-env": "^7.28.5",
30
- "@babel/preset-typescript": "^7.28.5",
31
- "@types/jest": "^29.5.14",
32
- "babel-loader": "^9.2.1",
33
- "file-loader": "^6.2.0",
34
- "jest": "^29.7.0",
35
- "ts-node": "^10.9.2",
36
- "typescript": "^4.9.5",
37
- "webpack": "^5.103.0",
38
- "webpack-cli": "^5.1.4"
39
- },
40
- "dependencies": {
41
- "terser-webpack-plugin": "^5.3.14"
42
- }
43
- }
1
+ {
2
+ "name": "polfan-server-js-client",
3
+ "version": "0.4.2",
4
+ "description": "JavaScript client library for handling communication with Polfan chat server.",
5
+ "author": "Jarosław Żak",
6
+ "license": "MIT",
7
+ "main": "build/index.cjs.js",
8
+ "browser": "build/index.umd.js",
9
+ "types": "build/types/index.d.ts",
10
+ "exports": {
11
+ ".": {
12
+ "types": "./build/types/index.d.ts",
13
+ "require": "./build/index.cjs.js",
14
+ "browser": "./build/index.umd.js",
15
+ "default": "./build/index.cjs.js"
16
+ }
17
+ },
18
+ "scripts": {
19
+ "build": "npm run build:node && npm run build:browser && tsc",
20
+ "build:node": "webpack --config webpack.config.node.js",
21
+ "build:browser": "webpack --config webpack.config.browser.js",
22
+ "test": "jest",
23
+ "coverage": "npm run test -- --coverage",
24
+ "trypublish": "npm publish || true"
25
+ },
26
+ "devDependencies": {
27
+ "@babel/cli": "^7.28.3",
28
+ "@babel/core": "^7.28.5",
29
+ "@babel/preset-env": "^7.28.5",
30
+ "@babel/preset-typescript": "^7.28.5",
31
+ "@types/jest": "^29.5.14",
32
+ "babel-loader": "^9.2.1",
33
+ "file-loader": "^6.2.0",
34
+ "jest": "^29.7.0",
35
+ "ts-node": "^10.9.2",
36
+ "typescript": "^4.9.5",
37
+ "webpack": "^5.103.0",
38
+ "webpack-cli": "^5.1.4"
39
+ },
40
+ "dependencies": {
41
+ "terser-webpack-plugin": "^5.3.14"
42
+ }
43
+ }
@@ -122,6 +122,12 @@ import {
122
122
  Uninvite,
123
123
  GetInvited,
124
124
  Invited,
125
+ React,
126
+ Unreact,
127
+ GetReactionDetails,
128
+ ReactionUpdated,
129
+ Reacted,
130
+ ReactionDetails,
125
131
  } from "./types/src";
126
132
  import {EventTarget} from "./EventTarget";
127
133
 
@@ -263,6 +269,9 @@ export type CommandResponse<CommandType extends keyof CommandsMap> = CommandsMap
263
269
  Topics: Topics,
264
270
  TopicUpdated: TopicUpdated,
265
271
  MessagesRedacted: MessagesRedacted,
272
+ ReactionUpdated: ReactionUpdated,
273
+ Reacted: Reacted,
274
+ ReactionDetails: ReactionDetails,
266
275
  };
267
276
 
268
277
  /**
@@ -338,4 +347,7 @@ export type CommandsMap = {
338
347
  GetTopics: CommandDefinition<GetTopics, EventsMap['Topics']>,
339
348
  UpdateTopic: CommandDefinition<UpdateTopic, EventsMap['TopicUpdated']>,
340
349
  RedactMessages: CommandDefinition<RedactMessages, EventsMap['MessagesRedacted']>,
350
+ React: CommandDefinition<React, EventsMap['Reacted']>,
351
+ Unreact: CommandDefinition<Unreact, EventsMap['Reacted']>,
352
+ GetReactionDetails: CommandDefinition<GetReactionDetails, EventsMap['ReactionDetails']>,
341
353
  }
@@ -33,6 +33,8 @@ export class Permissions {
33
33
  ChangeOwnColor: {value: 1 << 18, maxLayer: Layer.Room},
34
34
  RedactMessages: {value: 1 << 19, maxLayer: Layer.Topic},
35
35
  AddMembers: {value: 1 << 20, maxLayer: Layer.Space},
36
+ React: {value: 1 << 21, maxLayer: Layer.Topic},
37
+ CreatePolls: {value: 1 << 22, maxLayer: Layer.Topic},
36
38
  };
37
39
 
38
40
  public static getNames(): (keyof typeof this.list)[] {
package/src/index.ts CHANGED
@@ -1,32 +1,32 @@
1
- import {WebSocketChatClient} from "./WebSocketChatClient";
2
- import {WebApiChatClient} from "./WebApiChatClient";
3
- import {
4
- IndexedCollection,
5
- IndexedObjectCollection,
6
- ObservableIndexedCollection,
7
- ObservableIndexedObjectCollection
8
- } from "./IndexedObjectCollection";
9
- import {FilesClient, File} from "./FilesClient";
10
- import { Permissions, PermissionDefinition, Layer } from "./Permissions";
11
- import * as ChatTypes from './types/src';
12
- import {UserStatus} from './types/src';
13
- import {extractUserFromMember} from "./state-tracker/functions";
14
- import {AbstractRestClient} from "./AbstractRestClient";
15
- import {UnreadSummary} from "./state-tracker/FollowedTopicsManager";
16
-
17
- export {
18
- IndexedCollection, ObservableIndexedCollection,
19
- IndexedObjectCollection, ObservableIndexedObjectCollection,
20
- Permissions, PermissionDefinition, Layer,
21
- WebSocketChatClient, WebApiChatClient,
22
- FilesClient,
23
- AbstractRestClient,
24
- extractUserFromMember,
25
- UserStatus,
26
- };
27
-
28
- export type {
29
- ChatTypes,
30
- File,
31
- UnreadSummary,
1
+ import {WebSocketChatClient} from "./WebSocketChatClient";
2
+ import {WebApiChatClient} from "./WebApiChatClient";
3
+ import {
4
+ IndexedCollection,
5
+ IndexedObjectCollection,
6
+ ObservableIndexedCollection,
7
+ ObservableIndexedObjectCollection
8
+ } from "./IndexedObjectCollection";
9
+ import {FilesClient, File} from "./FilesClient";
10
+ import { Permissions, PermissionDefinition, Layer } from "./Permissions";
11
+ import * as ChatTypes from './types/src';
12
+ import {UserStatus} from './types/src';
13
+ import {extractUserFromMember} from "./state-tracker/functions";
14
+ import {AbstractRestClient} from "./AbstractRestClient";
15
+ import {UnreadSummary} from "./state-tracker/FollowedTopicsManager";
16
+
17
+ export {
18
+ IndexedCollection, ObservableIndexedCollection,
19
+ IndexedObjectCollection, ObservableIndexedObjectCollection,
20
+ Permissions, PermissionDefinition, Layer,
21
+ WebSocketChatClient, WebApiChatClient,
22
+ FilesClient,
23
+ AbstractRestClient,
24
+ extractUserFromMember,
25
+ UserStatus,
26
+ };
27
+
28
+ export type {
29
+ ChatTypes,
30
+ File,
31
+ UnreadSummary,
32
32
  };