@bootdesk/js-web-adapter-core 0.1.0
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 +78 -0
- package/dist/index.cjs +1042 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +433 -0
- package/dist/index.d.ts +433 -0
- package/dist/index.js +997 -0
- package/dist/index.js.map +1 -0
- package/package.json +53 -0
package/README.md
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# @bootdesk/js-web-adapter-core
|
|
2
|
+
|
|
3
|
+
Core JavaScript SDK for BootDesk Chat SDK — framework-agnostic chat client with real-time broadcasting, streaming, and push notifications.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @bootdesk/js-web-adapter-core
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { WebChatClient } from "@bootdesk/js-web-adapter-core";
|
|
15
|
+
|
|
16
|
+
const client = new WebChatClient({
|
|
17
|
+
baseUrl: "https://your-app.com/api/chat",
|
|
18
|
+
token: "your-auth-token",
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
const unsub = client.onNewMessage((event) => {
|
|
22
|
+
console.log("New message:", event.message.text);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
await client.connect();
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## API
|
|
29
|
+
|
|
30
|
+
### WebChatClient
|
|
31
|
+
|
|
32
|
+
| Method | Description |
|
|
33
|
+
|--------|-------------|
|
|
34
|
+
| `connect()` | Initialize connection, start listening |
|
|
35
|
+
| `disconnect()` | Cleanup, remove listeners |
|
|
36
|
+
| `loadMessages(threadId, options?)` | Fetch paginated messages |
|
|
37
|
+
| `sendMessage(text, attachments?)` | Send a new message |
|
|
38
|
+
| `editMessage(messageId, text)` | Edit an existing message |
|
|
39
|
+
| `deleteMessage(messageId)` | Delete a message |
|
|
40
|
+
| `addReaction(messageId, emoji)` | Add a reaction |
|
|
41
|
+
| `removeReaction(messageId, emoji)` | Remove a reaction |
|
|
42
|
+
| `onNewMessage(cb)` | Subscribe to new messages |
|
|
43
|
+
| `onMessageEdited(cb)` | Subscribe to edits |
|
|
44
|
+
| `onMessageDeleted(cb)` | Subscribe to deletions |
|
|
45
|
+
| `onReactionAdded(cb)` | Subscribe to reaction adds |
|
|
46
|
+
| `onReactionRemoved(cb)` | Subscribe to reaction removes |
|
|
47
|
+
| `onTypingStarted(cb)` | Subscribe to typing events |
|
|
48
|
+
| `onStreamingChunk(cb)` | Subscribe to streaming chunks |
|
|
49
|
+
|
|
50
|
+
### Broadcasting
|
|
51
|
+
|
|
52
|
+
```typescript
|
|
53
|
+
import { PusherBroadcastClient } from "@bootdesk/js-web-adapter-core";
|
|
54
|
+
|
|
55
|
+
const broadcast = new PusherBroadcastClient({
|
|
56
|
+
key: "pusher-key",
|
|
57
|
+
cluster: "us2",
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
const client = new WebChatClient({ baseUrl, token, broadcast });
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Push Notifications
|
|
64
|
+
|
|
65
|
+
```typescript
|
|
66
|
+
import { PushManager, createPushSubscriptionHandlers } from "@bootdesk/js-web-adapter-core";
|
|
67
|
+
|
|
68
|
+
const manager = new PushManager(
|
|
69
|
+
"https://your-app.com/api/push",
|
|
70
|
+
createPushSubscriptionHandlers(fetch),
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
await manager.subscribe();
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## License
|
|
77
|
+
|
|
78
|
+
MIT
|