polfan-server-js-client 0.3.3 → 0.4.1

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 (69) hide show
  1. package/.gitmodules +3 -3
  2. package/.idea/shelf/Uncommitted_changes_before_Checkout_at_05_08_2026_17_28_[Changes]/shelved.patch +447 -0
  3. package/.idea/shelf/Uncommitted_changes_before_Checkout_at_05_08_2026_17_28_[Changes]1/shelved.patch +0 -0
  4. package/.idea/shelf/Uncommitted_changes_before_Checkout_at_05_08_2026_17_28__Changes_.xml +4 -0
  5. package/.idea/workspace.xml +61 -52
  6. package/CODE_OF_CONDUCT.md +76 -76
  7. package/README.md +44 -44
  8. package/babel.config.js +5 -5
  9. package/build/index.cjs.js +398 -427
  10. package/build/index.cjs.js.map +1 -1
  11. package/build/index.umd.js +1 -1
  12. package/build/index.umd.js.map +1 -1
  13. package/build/types/index.d.ts +2 -1
  14. package/build/types/state-tracker/RoomMessagesHistory.d.ts +4 -15
  15. package/build/types/state-tracker/TopicHistoryWindow.d.ts +0 -48
  16. package/build/types/types/src/index.d.ts +11 -3
  17. package/build/types/types/src/schemes/Message.d.ts +5 -1
  18. package/build/types/types/src/schemes/MessagePoll.d.ts +10 -0
  19. package/build/types/types/src/schemes/Reaction.d.ts +13 -0
  20. package/build/types/types/src/schemes/SessionData.d.ts +6 -0
  21. package/build/types/types/src/schemes/User.d.ts +15 -0
  22. package/build/types/types/src/schemes/UserData.d.ts +5 -0
  23. package/build/types/types/src/schemes/commands/CreateMessage.d.ts +3 -0
  24. package/build/types/types/src/schemes/commands/GetMessages.d.ts +5 -0
  25. package/build/types/types/src/schemes/commands/GetReactionDetails.d.ts +8 -0
  26. package/build/types/types/src/schemes/commands/React.d.ts +6 -0
  27. package/build/types/types/src/schemes/commands/SetSessionData.d.ts +9 -1
  28. package/build/types/types/src/schemes/commands/SetUserData.d.ts +1 -0
  29. package/build/types/types/src/schemes/commands/Unreact.d.ts +6 -0
  30. package/build/types/types/src/schemes/events/Messages.d.ts +3 -0
  31. package/build/types/types/src/schemes/events/Reacted.d.ts +9 -0
  32. package/build/types/types/src/schemes/events/ReactionDetails.d.ts +11 -0
  33. package/build/types/types/src/schemes/events/ReactionUpdated.d.ts +8 -0
  34. package/jest.config.ts +199 -199
  35. package/package.json +1 -1
  36. package/scripts/getPackageJson.js +24 -24
  37. package/src/FilesClient.ts +42 -42
  38. package/src/index.ts +2 -0
  39. package/src/state-tracker/ChatStateTracker.ts +71 -71
  40. package/src/state-tracker/RoomMessagesHistory.ts +9 -27
  41. package/src/state-tracker/TopicHistoryWindow.ts +1 -133
  42. package/src/state-tracker/UsersManager.ts +1 -1
  43. package/src/state-tracker/functions.ts +28 -28
  44. package/src/types/src/index.ts +24 -2
  45. package/src/types/src/schemes/Message.ts +5 -1
  46. package/src/types/src/schemes/MessagePoll.ts +12 -0
  47. package/src/types/src/schemes/Reaction.ts +16 -0
  48. package/src/types/src/schemes/SessionData.ts +8 -1
  49. package/src/types/src/schemes/User.ts +17 -1
  50. package/src/types/src/schemes/UserData.ts +5 -0
  51. package/src/types/src/schemes/commands/CreateMessage.ts +3 -0
  52. package/src/types/src/schemes/commands/GetMessages.ts +5 -0
  53. package/src/types/src/schemes/commands/GetReactionDetails.ts +9 -0
  54. package/src/types/src/schemes/commands/React.ts +7 -0
  55. package/src/types/src/schemes/commands/SetSessionData.ts +11 -2
  56. package/src/types/src/schemes/commands/SetUserData.ts +1 -0
  57. package/src/types/src/schemes/commands/Unreact.ts +7 -0
  58. package/src/types/src/schemes/events/Messages.ts +3 -0
  59. package/src/types/src/schemes/events/Reacted.ts +10 -0
  60. package/src/types/src/schemes/events/ReactionDetails.ts +12 -0
  61. package/src/types/src/schemes/events/ReactionUpdated.ts +9 -0
  62. package/tests/async-utils.test.ts +29 -29
  63. package/tests/history-window.test.ts +0 -131
  64. package/tests/space-roles.test.ts +42 -42
  65. package/tests/state-reconnect.test.ts +0 -260
  66. package/.idea/shelf/Uncommitted_changes_before_Checkout_at_26_07_2026_21_26_[Changes]/shelved.patch +0 -174
  67. package/.idea/shelf/Uncommitted_changes_before_Checkout_at_26_07_2026_21_26__Changes_.xml +0 -4
  68. package/.idea/shelf/Uncommitted_changes_before_rebase_[Changes]/shelved.patch +0 -18
  69. package/.idea/shelf/Uncommitted_changes_before_rebase__Changes_.xml +0 -4
@@ -0,0 +1,4 @@
1
+ <changelist name="Uncommitted_changes_before_Checkout_at_05_08_2026_17_28_[Changes]" date="1785943698237" recycled="false" toDelete="true">
2
+ <option name="PATH" value="$PROJECT_DIR$/.idea/shelf/Uncommitted_changes_before_Checkout_at_05_08_2026_17_28_[Changes]/shelved.patch" />
3
+ <option name="DESCRIPTION" value="Uncommitted changes before Checkout at 05.08.2026 17:28 [Changes]" />
4
+ </changelist>
@@ -4,7 +4,7 @@
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="Custom avatars support" />
7
+ <list default="true" id="831dae43-0da1-47fd-a5f7-33dd5eec2992" name="Changes" comment="Reacting changes" />
8
8
  <option name="SHOW_DIALOG" value="false" />
9
9
  <option name="HIGHLIGHT_CONFLICTS" value="true" />
10
10
  <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
@@ -14,7 +14,7 @@
14
14
  <execution />
15
15
  </component>
16
16
  <component name="EmbeddingIndexingInfo">
17
- <option name="cachedIndexableFilesCount" value="212" />
17
+ <option name="cachedIndexableFilesCount" value="213" />
18
18
  </component>
19
19
  <component name="Git.Rebase.Settings">
20
20
  <option name="NEW_BASE" value="origin/main" />
@@ -22,7 +22,7 @@
22
22
  <component name="Git.Settings">
23
23
  <option name="RECENT_BRANCH_BY_REPOSITORY">
24
24
  <map>
25
- <entry key="$PROJECT_DIR$" value="claude/avatars-room-space-support-bvrcaz" />
25
+ <entry key="$PROJECT_DIR$" value="claude/room-messages-reconnect-history-kfddmm" />
26
26
  <entry key="$PROJECT_DIR$/src/types" value="main" />
27
27
  </map>
28
28
  </option>
@@ -67,34 +67,34 @@
67
67
  <option name="hideEmptyMiddlePackages" value="true" />
68
68
  <option name="showLibraryContents" value="true" />
69
69
  </component>
70
- <component name="PropertiesComponent">{
71
- &quot;keyToString&quot;: {
72
- &quot;RunOnceActivity.MCP Project settings loaded&quot;: &quot;true&quot;,
73
- &quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
74
- &quot;RunOnceActivity.TerminalTabsStorage.copyFrom.TerminalArrangementManager&quot;: &quot;true&quot;,
75
- &quot;RunOnceActivity.TerminalTabsStorage.copyFrom.TerminalArrangementManager.252&quot;: &quot;true&quot;,
76
- &quot;RunOnceActivity.git.unshallow&quot;: &quot;true&quot;,
77
- &quot;RunOnceActivity.typescript.service.memoryLimit.init&quot;: &quot;true&quot;,
78
- &quot;codeWithMe.voiceChat.enabledByDefault&quot;: &quot;false&quot;,
79
- &quot;com.intellij.ml.llm.matterhorn.ej.ui.settings.DefaultModelSelectionForGA.v1&quot;: &quot;true&quot;,
80
- &quot;git-widget-placeholder&quot;: &quot;main&quot;,
81
- &quot;git.auto.fetch.suggestion.counter&quot;: &quot;3&quot;,
82
- &quot;ignore.virus.scanning.warn.message&quot;: &quot;true&quot;,
83
- &quot;junie.onboarding.icon.badge.shown&quot;: &quot;true&quot;,
84
- &quot;last_opened_file_path&quot;: &quot;//wsl.localhost/Debian/home/jarek/polfan-js-client-library&quot;,
85
- &quot;node.js.detected.package.eslint&quot;: &quot;true&quot;,
86
- &quot;node.js.detected.package.tslint&quot;: &quot;true&quot;,
87
- &quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;,
88
- &quot;node.js.selected.package.tslint&quot;: &quot;(autodetect)&quot;,
89
- &quot;nodejs_package_manager_path&quot;: &quot;npm&quot;,
90
- &quot;npm.build:node.executor&quot;: &quot;Run&quot;,
91
- &quot;settings.editor.selected.configurable&quot;: &quot;com.github.copilot.settings.chat.ChatConfigurable&quot;,
92
- &quot;to.speed.mode.migration.done&quot;: &quot;true&quot;,
93
- &quot;ts.external.directory.path&quot;: &quot;\\\\wsl.localhost\\Debian\\home\\jarek\\polfan-js-client-library\\node_modules\\typescript\\lib&quot;,
94
- &quot;vcs.patch.to.clipboard&quot;: &quot;true&quot;,
95
- &quot;vue.rearranger.settings.migration&quot;: &quot;true&quot;
70
+ <component name="PropertiesComponent"><![CDATA[{
71
+ "keyToString": {
72
+ "RunOnceActivity.MCP Project settings loaded": "true",
73
+ "RunOnceActivity.ShowReadmeOnStart": "true",
74
+ "RunOnceActivity.TerminalTabsStorage.copyFrom.TerminalArrangementManager": "true",
75
+ "RunOnceActivity.TerminalTabsStorage.copyFrom.TerminalArrangementManager.252": "true",
76
+ "RunOnceActivity.git.unshallow": "true",
77
+ "RunOnceActivity.typescript.service.memoryLimit.init": "true",
78
+ "codeWithMe.voiceChat.enabledByDefault": "false",
79
+ "com.intellij.ml.llm.matterhorn.ej.ui.settings.DefaultModelSelectionForGA.v1": "true",
80
+ "git-widget-placeholder": "claude/chat-reactions-polls-system-hwea5i",
81
+ "git.auto.fetch.suggestion.counter": "3",
82
+ "ignore.virus.scanning.warn.message": "true",
83
+ "junie.onboarding.icon.badge.shown": "true",
84
+ "last_opened_file_path": "//wsl.localhost/Debian/home/jarek/polfan-js-client-library",
85
+ "node.js.detected.package.eslint": "true",
86
+ "node.js.detected.package.tslint": "true",
87
+ "node.js.selected.package.eslint": "(autodetect)",
88
+ "node.js.selected.package.tslint": "(autodetect)",
89
+ "nodejs_package_manager_path": "npm",
90
+ "npm.build:node.executor": "Run",
91
+ "settings.editor.selected.configurable": "com.github.copilot.settings.chat.ChatConfigurable",
92
+ "to.speed.mode.migration.done": "true",
93
+ "ts.external.directory.path": "\\\\wsl.localhost\\Debian\\home\\jarek\\polfan-js-client-library\\node_modules\\typescript\\lib",
94
+ "vcs.patch.to.clipboard": "true",
95
+ "vue.rearranger.settings.migration": "true"
96
96
  }
97
- }</component>
97
+ }]]></component>
98
98
  <component name="RunManager">
99
99
  <configuration name="build:node" type="js.build_tools.npm" temporary="true" nameIsGenerated="true">
100
100
  <package-json value="$PROJECT_DIR$/package.json" />
@@ -112,6 +112,7 @@
112
112
  <item itemvalue="npm.build:node" />
113
113
  <item itemvalue="npm.build:node" />
114
114
  <item itemvalue="npm.build:node" />
115
+ <item itemvalue="npm.build:node" />
115
116
  </list>
116
117
  </recent_temporary>
117
118
  </component>
@@ -242,23 +243,10 @@
242
243
  <workItem from="1784524117686" duration="79000" />
243
244
  <workItem from="1784562428378" duration="25143000" />
244
245
  <workItem from="1785316847947" duration="4816000" />
245
- <workItem from="1785689068542" duration="2232000" />
246
- </task>
247
- <task id="LOCAL-00065" summary="Align to custom colors and nicks protocol changes">
248
- <option name="closed" value="true" />
249
- <created>1764689897013</created>
250
- <option name="number" value="00065" />
251
- <option name="presentableId" value="LOCAL-00065" />
252
- <option name="project" value="LOCAL" />
253
- <updated>1764689897014</updated>
254
- </task>
255
- <task id="LOCAL-00066" summary="Connection handling optimizations">
256
- <option name="closed" value="true" />
257
- <created>1764955397384</created>
258
- <option name="number" value="00066" />
259
- <option name="presentableId" value="LOCAL-00066" />
260
- <option name="project" value="LOCAL" />
261
- <updated>1764955397384</updated>
246
+ <workItem from="1785689068542" duration="6390000" />
247
+ <workItem from="1786526830597" duration="598000" />
248
+ <workItem from="1787125977456" duration="278000" />
249
+ <workItem from="1787576741803" duration="2076000" />
262
250
  </task>
263
251
  <task id="LOCAL-00067" summary="Ping-pong connection monitoring">
264
252
  <option name="closed" value="true" />
@@ -636,7 +624,23 @@
636
624
  <option name="project" value="LOCAL" />
637
625
  <updated>1785594413375</updated>
638
626
  </task>
639
- <option name="localTasksCounter" value="114" />
627
+ <task id="LOCAL-00114" summary="User presence status support">
628
+ <option name="closed" value="true" />
629
+ <created>1787126229969</created>
630
+ <option name="number" value="00114" />
631
+ <option name="presentableId" value="LOCAL-00114" />
632
+ <option name="project" value="LOCAL" />
633
+ <updated>1787126229970</updated>
634
+ </task>
635
+ <task id="LOCAL-00115" summary="Reacting changes">
636
+ <option name="closed" value="true" />
637
+ <created>1787581107970</created>
638
+ <option name="number" value="00115" />
639
+ <option name="presentableId" value="LOCAL-00115" />
640
+ <option name="project" value="LOCAL" />
641
+ <updated>1787581107970</updated>
642
+ </task>
643
+ <option name="localTasksCounter" value="116" />
640
644
  <servers />
641
645
  </component>
642
646
  <component name="TypeScriptGeneratedFilesManager">
@@ -648,6 +652,11 @@
648
652
  <entry key="Branch">
649
653
  <value>
650
654
  <list>
655
+ <RecentGroup>
656
+ <option name="FILTER_VALUES">
657
+ <option value="claude/chat-reactions-polls-system-hwea5i" />
658
+ </option>
659
+ </RecentGroup>
651
660
  <RecentGroup>
652
661
  <option name="FILTER_VALUES">
653
662
  <option value="claude/avatars-room-space-support-bvrcaz" />
@@ -688,7 +697,7 @@
688
697
  <entry key="branch">
689
698
  <value>
690
699
  <list>
691
- <option value="claude/avatars-room-space-support-bvrcaz" />
700
+ <option value="claude/chat-reactions-polls-system-hwea5i" />
692
701
  </list>
693
702
  </value>
694
703
  </entry>
@@ -701,8 +710,6 @@
701
710
  </option>
702
711
  </component>
703
712
  <component name="VcsManagerConfiguration">
704
- <MESSAGE value="TopicHistoryWindow retainRatio and event handling improvements" />
705
- <MESSAGE value="Remove removed message from Topic last message" />
706
713
  <MESSAGE value="Update Topic on redacted message" />
707
714
  <MESSAGE value="Fix room member update event handle" />
708
715
  <MESSAGE value="Fix room member update event handle" />
@@ -726,7 +733,9 @@
726
733
  <MESSAGE value="Add members to rooms and invitation only rooms support" />
727
734
  <MESSAGE value="Introduce room invitations and manual member adding" />
728
735
  <MESSAGE value="Custom avatars support" />
729
- <option name="LAST_COMMIT_MESSAGE" value="Custom avatars support" />
736
+ <MESSAGE value="User presence status support" />
737
+ <MESSAGE value="Reacting changes" />
738
+ <option name="LAST_COMMIT_MESSAGE" value="Reacting changes" />
730
739
  </component>
731
740
  <component name="XSLT-Support.FileAssociations.UIState">
732
741
  <expand />
@@ -1,76 +1,76 @@
1
- # Contributor Covenant Code of Conduct
2
-
3
- ## Our Pledge
4
-
5
- In the interest of fostering an open and welcoming environment, we as
6
- contributors and maintainers pledge to making participation in our project and
7
- our community a harassment-free experience for everyone, regardless of age, body
8
- size, disability, ethnicity, sex characteristics, gender identity and expression,
9
- level of experience, education, socio-economic status, nationality, personal
10
- appearance, race, religion, or sexual identity and orientation.
11
-
12
- ## Our Standards
13
-
14
- Examples of behavior that contributes to creating a positive environment
15
- include:
16
-
17
- * Using welcoming and inclusive language
18
- * Being respectful of differing viewpoints and experiences
19
- * Gracefully accepting constructive criticism
20
- * Focusing on what is best for the community
21
- * Showing empathy towards other community members
22
-
23
- Examples of unacceptable behavior by participants include:
24
-
25
- * The use of sexualized language or imagery and unwelcome sexual attention or
26
- advances
27
- * Trolling, insulting/derogatory comments, and personal or political attacks
28
- * Public or private harassment
29
- * Publishing others' private information, such as a physical or electronic
30
- address, without explicit permission
31
- * Other conduct which could reasonably be considered inappropriate in a
32
- professional setting
33
-
34
- ## Our Responsibilities
35
-
36
- Project maintainers are responsible for clarifying the standards of acceptable
37
- behavior and are expected to take appropriate and fair corrective action in
38
- response to any instances of unacceptable behavior.
39
-
40
- Project maintainers have the right and responsibility to remove, edit, or
41
- reject comments, commits, code, wiki edits, issues, and other contributions
42
- that are not aligned to this Code of Conduct, or to ban temporarily or
43
- permanently any contributor for other behaviors that they deem inappropriate,
44
- threatening, offensive, or harmful.
45
-
46
- ## Scope
47
-
48
- This Code of Conduct applies both within project spaces and in public spaces
49
- when an individual is representing the project or its community. Examples of
50
- representing a project or community include using an official project e-mail
51
- address, posting via an official social media account, or acting as an appointed
52
- representative at an online or offline event. Representation of a project may be
53
- further defined and clarified by project maintainers.
54
-
55
- ## Enforcement
56
-
57
- Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
- reported by contacting the project team at opensource@hodgef.com. All
59
- complaints will be reviewed and investigated and will result in a response that
60
- is deemed necessary and appropriate to the circumstances. The project team is
61
- obligated to maintain confidentiality with regard to the reporter of an incident.
62
- Further details of specific enforcement policies may be posted separately.
63
-
64
- Project maintainers who do not follow or enforce the Code of Conduct in good
65
- faith may face temporary or permanent repercussions as determined by other
66
- members of the project's leadership.
67
-
68
- ## Attribution
69
-
70
- This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
- available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
72
-
73
- [homepage]: https://www.contributor-covenant.org
74
-
75
- For answers to common questions about this code of conduct, see
76
- https://www.contributor-covenant.org/faq
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, sex characteristics, gender identity and expression,
9
+ level of experience, education, socio-economic status, nationality, personal
10
+ appearance, race, religion, or sexual identity and orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at opensource@hodgef.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
72
+
73
+ [homepage]: https://www.contributor-covenant.org
74
+
75
+ For answers to common questions about this code of conduct, see
76
+ https://www.contributor-covenant.org/faq
package/README.md CHANGED
@@ -1,45 +1,45 @@
1
- # pserv-js-client-library
2
- TypeScript client library to handle connection with Devana (new Polfan) chat service.
3
-
4
- ## How to use?
5
-
6
- ```js
7
- (async () => {
8
- // Get access token by credentials
9
- const token = await PServ.AuthClient.createToken('login', 'password');
10
-
11
- // Create web api client (there is also WebSocket client available)
12
- const client = new PServ.WebApiChatClient({
13
- token: token.token, // Pass received token
14
- url: 'https://pserv-api-address',
15
- });
16
-
17
- // Call `GetSession` command which returns user session data
18
- const session = await client.send('GetSession');
19
-
20
- console.log("My nick:", session.user.nick);
21
- console.log("The rooms you are in:", session.rooms);
22
- console.log("The spaces you are in:", session.spaces);
23
- console.log("The version of server you connected to:", session.serverVersion);
24
- })();
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,
1
+ # pserv-js-client-library
2
+ TypeScript client library to handle connection with Devana (new Polfan) chat service.
3
+
4
+ ## How to use?
5
+
6
+ ```js
7
+ (async () => {
8
+ // Get access token by credentials
9
+ const token = await PServ.AuthClient.createToken('login', 'password');
10
+
11
+ // Create web api client (there is also WebSocket client available)
12
+ const client = new PServ.WebApiChatClient({
13
+ token: token.token, // Pass received token
14
+ url: 'https://pserv-api-address',
15
+ });
16
+
17
+ // Call `GetSession` command which returns user session data
18
+ const session = await client.send('GetSession');
19
+
20
+ console.log("My nick:", session.user.nick);
21
+ console.log("The rooms you are in:", session.rooms);
22
+ console.log("The spaces you are in:", session.spaces);
23
+ console.log("The version of server you connected to:", session.serverVersion);
24
+ })();
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
45
  because some structures are rebuild from scratch on `Session` event.
package/babel.config.js CHANGED
@@ -1,6 +1,6 @@
1
- module.exports = {
2
- presets: [
3
- ["@babel/preset-env"],
4
- ["@babel/preset-typescript", { allowDeclareFields: true }],
5
- ],
1
+ module.exports = {
2
+ presets: [
3
+ ["@babel/preset-env"],
4
+ ["@babel/preset-typescript", { allowDeclareFields: true }],
5
+ ],
6
6
  };