polfan-server-js-client 0.2.3 → 0.2.7
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/copilot.data.migration.agent.xml +6 -0
- package/.idea/copilot.data.migration.ask.xml +6 -0
- package/.idea/copilot.data.migration.ask2agent.xml +6 -0
- package/.idea/copilot.data.migration.edit.xml +6 -0
- package/.idea/workspace.xml +401 -177
- package/README.md +22 -2
- package/babel.config.js +4 -5
- package/build/index.cjs.js +4595 -1816
- 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/AbstractChatClient.d.ts +14 -2
- package/build/types/FilesClient.d.ts +7 -6
- package/build/types/IndexedObjectCollection.d.ts +4 -3
- package/build/types/Permissions.d.ts +4 -0
- package/build/types/WebSocketChatClient.d.ts +23 -0
- package/build/types/state-tracker/ChatStateTracker.d.ts +5 -0
- package/build/types/state-tracker/RelationshipsManager.d.ts +15 -0
- package/build/types/state-tracker/RoomMessagesHistory.d.ts +2 -0
- package/build/types/state-tracker/SpacesManager.d.ts +1 -0
- package/build/types/state-tracker/TopicHistoryWindow.d.ts +23 -6
- package/build/types/state-tracker/UsersManager.d.ts +3 -1
- package/build/types/types/src/index.d.ts +14 -3
- package/build/types/types/src/schemes/Emoticon.d.ts +1 -0
- package/build/types/types/src/schemes/Message.d.ts +1 -1
- package/build/types/types/src/schemes/Room.d.ts +2 -0
- package/build/types/types/src/schemes/RoomHistory.d.ts +5 -0
- package/build/types/types/src/schemes/RoomMember.d.ts +3 -0
- package/build/types/types/src/schemes/RoomSummary.d.ts +1 -0
- package/build/types/types/src/schemes/SpaceSummary.d.ts +1 -0
- package/build/types/types/src/schemes/User.d.ts +2 -2
- package/build/types/types/src/schemes/UserRelationship.d.ts +6 -0
- package/build/types/types/src/schemes/commands/CreateMessage.d.ts +2 -0
- package/build/types/types/src/schemes/commands/CreateRelationship.d.ts +5 -0
- package/build/types/types/src/schemes/commands/CreateTopic.d.ts +5 -2
- package/build/types/types/src/schemes/commands/DeleteRelationship.d.ts +5 -0
- package/build/types/types/src/schemes/commands/GetRelationships.d.ts +2 -0
- package/build/types/types/src/schemes/commands/Ping.d.ts +2 -0
- package/build/types/types/src/schemes/commands/UpdateRoom.d.ts +2 -0
- package/build/types/types/src/schemes/commands/UpdateRoomMember.d.ts +7 -0
- package/build/types/types/src/schemes/commands/UpdateSpaceMember.d.ts +5 -0
- package/build/types/types/src/schemes/events/NewRelationship.d.ts +4 -0
- package/build/types/types/src/schemes/events/Pong.d.ts +2 -0
- package/build/types/types/src/schemes/events/RelationshipDeleted.d.ts +4 -0
- package/build/types/types/src/schemes/events/Relationships.d.ts +4 -0
- package/build/types/types/src/schemes/events/RoomSummaryUpdated.d.ts +7 -0
- package/build/types/types/src/schemes/events/Session.d.ts +1 -0
- package/package.json +15 -28
- package/src/AbstractChatClient.ts +30 -4
- package/src/FilesClient.ts +26 -13
- package/src/IndexedObjectCollection.ts +26 -10
- package/src/Permissions.ts +1 -0
- package/src/WebSocketChatClient.ts +92 -14
- package/src/state-tracker/ChatStateTracker.ts +22 -6
- package/src/state-tracker/EmoticonsManager.ts +6 -4
- package/src/state-tracker/MessagesManager.ts +3 -4
- package/src/state-tracker/RelationshipsManager.ts +68 -0
- package/src/state-tracker/RoomMessagesHistory.ts +20 -3
- package/src/state-tracker/RoomsManager.ts +38 -8
- package/src/state-tracker/SpacesManager.ts +28 -1
- package/src/state-tracker/TopicHistoryWindow.ts +92 -32
- package/src/state-tracker/UsersManager.ts +16 -6
- package/src/types/src/index.ts +30 -5
- package/src/types/src/schemes/Emoticon.ts +1 -0
- package/src/types/src/schemes/Message.ts +1 -1
- package/src/types/src/schemes/Room.ts +2 -0
- package/src/types/src/schemes/RoomHistory.ts +6 -0
- package/src/types/src/schemes/RoomMember.ts +3 -0
- package/src/types/src/schemes/RoomSummary.ts +1 -0
- package/src/types/src/schemes/SpaceSummary.ts +1 -0
- package/src/types/src/schemes/User.ts +2 -2
- package/src/types/src/schemes/UserRelationship.ts +8 -0
- package/src/types/src/schemes/commands/CreateMessage.ts +2 -0
- package/src/types/src/schemes/commands/CreateRelationship.ts +6 -0
- package/src/types/src/schemes/commands/CreateTopic.ts +6 -2
- package/src/types/src/schemes/commands/DeleteRelationship.ts +6 -0
- package/src/types/src/schemes/commands/GetRelationships.ts +3 -0
- package/src/types/src/schemes/commands/Ping.ts +3 -0
- package/src/types/src/schemes/commands/UpdateRoom.ts +2 -0
- package/src/types/src/schemes/commands/UpdateRoomMember.ts +7 -0
- package/src/types/src/schemes/commands/UpdateSpaceMember.ts +5 -0
- package/src/types/src/schemes/events/NewRelationship.ts +5 -0
- package/src/types/src/schemes/events/Pong.ts +3 -0
- package/src/types/src/schemes/events/RelationshipDeleted.ts +5 -0
- package/src/types/src/schemes/events/Relationships.ts +5 -0
- package/src/types/src/schemes/events/RoomSummaryUpdated.ts +8 -0
- package/src/types/src/schemes/events/Session.ts +1 -0
- package/tests/history-window.test.ts +6 -1
- package/webpack.config.browser.js +2 -24
- package/webpack.config.node.js +2 -14
- package/.eslintignore +0 -0
- package/.eslintrc.json +0 -0
- package/src/types/src/schemes/commands/SetCustomNick.ts +0 -5
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# pserv-js-client-library
|
|
2
|
-
TypeScript client library to handle connection with Polfan chat service.
|
|
2
|
+
TypeScript client library to handle connection with Devana (new Polfan) chat service.
|
|
3
3
|
|
|
4
4
|
## How to use?
|
|
5
5
|
|
|
@@ -22,4 +22,24 @@ TypeScript client library to handle connection with Polfan chat service.
|
|
|
22
22
|
console.log("The spaces you are in:", session.spaces);
|
|
23
23
|
console.log("The version of server you connected to:", session.serverVersion);
|
|
24
24
|
})();
|
|
25
|
-
```
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## State management
|
|
28
|
+
|
|
29
|
+
The library provides built-in state management for WebSocket client. To enable it, just pass `stateTracking`
|
|
30
|
+
option to the `WebSocketChatClient` constructor:
|
|
31
|
+
|
|
32
|
+
```js
|
|
33
|
+
const wsClient = new PServ.WebSocketChatClient({
|
|
34
|
+
token: 'your-access-token',
|
|
35
|
+
url: 'wss://pserv-websocket-address',
|
|
36
|
+
stateTracking: true, // Enable state tracking
|
|
37
|
+
});
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
With state tracking enabled, the client will automatically maintain the current state of rooms, users, and messages,
|
|
41
|
+
by handling incoming events from the server. Reactive data structures are available via `ObservableIndexedObjectCollection`
|
|
42
|
+
objects, which allows you to subscribe to changes.
|
|
43
|
+
|
|
44
|
+
**Important note:** you can cache these objects for the connection lifetime, but you should refetch them after reconnecting,
|
|
45
|
+
because some structures are rebuild from scratch on `Session` event.
|
package/babel.config.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
module.exports = {
|
|
2
|
-
presets: [
|
|
3
|
-
|
|
4
|
-
["@babel/
|
|
5
|
-
["@babel/plugin-transform-typescript"],
|
|
2
|
+
presets: [
|
|
3
|
+
["@babel/preset-env"],
|
|
4
|
+
["@babel/preset-typescript", { allowDeclareFields: true }],
|
|
6
5
|
],
|
|
7
|
-
};
|
|
6
|
+
};
|