@gamention/pulse-core 0.1.0 → 0.1.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.
- package/README.md +96 -0
- package/package.json +2 -2
package/README.md
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# @gamention/pulse-core
|
|
2
|
+
|
|
3
|
+
Core client SDK for **Pulse** — WebSocket connection management, state management, and API for real-time collaboration.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @gamention/pulse-core
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { PulseClient } from '@gamention/pulse-core';
|
|
15
|
+
|
|
16
|
+
const client = new PulseClient({
|
|
17
|
+
apiKey: 'pk_...',
|
|
18
|
+
token: 'jwt_token_from_your_backend',
|
|
19
|
+
room: 'my-page',
|
|
20
|
+
endpoint: 'wss://pulse.hire.rest',
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
client.connect();
|
|
24
|
+
|
|
25
|
+
// Listen for real-time events
|
|
26
|
+
client.state.on('threads', (threads) => {
|
|
27
|
+
console.log('Threads updated:', threads);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
client.state.on('presence', (users) => {
|
|
31
|
+
console.log('Online users:', users);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
// Create a comment thread
|
|
35
|
+
client.createThread('Great work on this section!', {
|
|
36
|
+
position: { x: 0.5, y: 0.3 },
|
|
37
|
+
mentions: [],
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
// Reply to a thread
|
|
41
|
+
client.reply('thread-id', 'Thanks!');
|
|
42
|
+
|
|
43
|
+
// React to a comment
|
|
44
|
+
client.addReaction('comment-id', 'comment', '\u{1F44D}');
|
|
45
|
+
|
|
46
|
+
// Upload a file
|
|
47
|
+
const result = await client.uploadFile(file);
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## API
|
|
51
|
+
|
|
52
|
+
### PulseClient
|
|
53
|
+
|
|
54
|
+
| Method | Description |
|
|
55
|
+
|--------|-------------|
|
|
56
|
+
| `connect()` | Connect to the WebSocket server |
|
|
57
|
+
| `disconnect()` | Disconnect and clean up |
|
|
58
|
+
| `createThread(body, options?)` | Create a new comment thread |
|
|
59
|
+
| `reply(threadId, body, mentions?)` | Reply to a thread |
|
|
60
|
+
| `editComment(commentId, body, mentions?)` | Edit a comment |
|
|
61
|
+
| `deleteComment(commentId)` | Delete a comment |
|
|
62
|
+
| `resolveThread(threadId, resolved?)` | Resolve/reopen a thread |
|
|
63
|
+
| `addReaction(targetId, targetType, emoji)` | Add a reaction |
|
|
64
|
+
| `removeReaction(reactionId)` | Remove a reaction |
|
|
65
|
+
| `moveCursor(position)` | Send cursor position |
|
|
66
|
+
| `uploadFile(file)` | Upload an image/audio/video file |
|
|
67
|
+
| `markRead(notificationId)` | Mark notification as read |
|
|
68
|
+
| `markAllRead()` | Mark all notifications as read |
|
|
69
|
+
|
|
70
|
+
### StateManager (`client.state`)
|
|
71
|
+
|
|
72
|
+
| Property | Description |
|
|
73
|
+
|----------|-------------|
|
|
74
|
+
| `user` | Current authenticated user |
|
|
75
|
+
| `threads` | All threads in the room |
|
|
76
|
+
| `presence` | Online users |
|
|
77
|
+
| `notifications` | User's notifications |
|
|
78
|
+
| `unreadCount` | Unread notification count |
|
|
79
|
+
|
|
80
|
+
Subscribe to changes with `client.state.on(event, callback)`.
|
|
81
|
+
|
|
82
|
+
## When to Use This
|
|
83
|
+
|
|
84
|
+
Use `@gamention/pulse-core` when you want to **build your own UI** on top of Pulse. For drop-in web components, use [`@gamention/pulse-elements`](https://www.npmjs.com/package/@gamention/pulse-elements) instead.
|
|
85
|
+
|
|
86
|
+
## Documentation
|
|
87
|
+
|
|
88
|
+
Full docs at **[pulse.hire.rest/docs](https://pulse.hire.rest/docs)**
|
|
89
|
+
|
|
90
|
+
- [Client SDK Reference](https://pulse.hire.rest/docs/sdk/client)
|
|
91
|
+
- [State & Events](https://pulse.hire.rest/docs/sdk/state)
|
|
92
|
+
- [Building Custom UI](https://pulse.hire.rest/docs/sdk/custom-ui)
|
|
93
|
+
|
|
94
|
+
## License
|
|
95
|
+
|
|
96
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gamention/pulse-core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Core client SDK for Pulse — WebSocket connection, state management, and API for real-time collaboration",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/pulse-core.cjs",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"access": "public"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@gamention/pulse-shared": "
|
|
35
|
+
"@gamention/pulse-shared": "^0.1.2"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"typescript": "^5.7.0",
|