@poolse/react 3.7.1 → 3.8.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/CHANGELOG.md +21 -0
- package/README.md +52 -25
- package/dist/index.cjs +385 -50
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +170 -8
- package/dist/index.d.ts +170 -8
- package/dist/index.js +363 -54
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,27 @@ All notable changes to `@poolse/react` are documented here. Format follows
|
|
|
4
4
|
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/); versions follow
|
|
5
5
|
[semver](https://semver.org).
|
|
6
6
|
|
|
7
|
+
## [3.8.0] - 2026-11-21
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- `<PoolseProvider client={…}>` takes a client it never destroys (several
|
|
12
|
+
workspaces side by side; a hidden or unmounted provider keeps its client
|
|
13
|
+
connected and warm) and `background` (`client.setBackground`). `config`
|
|
14
|
+
is optional when `client` is given.
|
|
15
|
+
- The conversation store lives with the client, so a remounted provider is
|
|
16
|
+
warm; its rows feed `client.unread` and `client.cache`.
|
|
17
|
+
- `useMessages`: cached history at once (`fromCache`), readable offline;
|
|
18
|
+
sends through the outbox with `retry(id)` / `discard(id)`.
|
|
19
|
+
- `useUnreadTotals(client?)`, `useUnreadQueue()` / `orderUnread`,
|
|
20
|
+
`useOutbox()`, `useClientTimings()`, `filterConversations()`. Re-exports
|
|
21
|
+
`Poolse`, `createIndexedDbStorage`, `memoryStorage`, `MessageQueuedError`.
|
|
22
|
+
|
|
23
|
+
### Changed
|
|
24
|
+
|
|
25
|
+
- A send that fails no longer disappears: queued offline, or kept as failed
|
|
26
|
+
(see `@poolse/sdk` `outbox`). `outbox: false` restores the old behaviour.
|
|
27
|
+
|
|
7
28
|
## [3.7.1] - 2026-11-21
|
|
8
29
|
|
|
9
30
|
- No changes; released with the other `@poolse/*` packages at 3.7.1.
|
package/README.md
CHANGED
|
@@ -60,31 +60,54 @@ The provider creates one `Poolse` instance per mount. Function options are
|
|
|
60
60
|
read through a ref, so new closures on each render are fine. Remount with a
|
|
61
61
|
new `key` to switch user.
|
|
62
62
|
|
|
63
|
+
### Several workspaces
|
|
64
|
+
|
|
65
|
+
Create one client per workspace outside React and hand each to its own
|
|
66
|
+
provider. Providers side by side never share state, and a provider never
|
|
67
|
+
destroys a client it was given — unmounting or hiding a workspace keeps its
|
|
68
|
+
socket and its warm cache, so switching back is a view change:
|
|
69
|
+
|
|
70
|
+
```tsx
|
|
71
|
+
<PoolseProvider client={acme} background={current !== acme}>
|
|
72
|
+
<Workspace />
|
|
73
|
+
</PoolseProvider>
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
The conversation list store lives with the client (`chat.scoped`), so a
|
|
77
|
+
remounted provider shows it at once; `useMessages` shows the client's cached
|
|
78
|
+
messages at once (`fromCache: true`) while the page refetches. `background`
|
|
79
|
+
closes the socket while true (phones; leave it unset on desktop). Sign out
|
|
80
|
+
of one with `client.destroy({ clearStorage: true })`.
|
|
81
|
+
|
|
63
82
|
## Hooks
|
|
64
83
|
|
|
65
|
-
| Hook | Returns
|
|
66
|
-
| -------------------------------------------------------------------------------- |
|
|
67
|
-
| `usePoolse()` | The `Poolse` instance.
|
|
68
|
-
| `useMe()` | `{ me, loading, error }`
|
|
69
|
-
| `useConversation(id \| null)` | `{ conversation, loading, error, refetch }`
|
|
70
|
-
| `useConversations()` | `{ conversations, loading, error, refetch, hasMore, loadingMore, loadMore, create, unreadCounts, mentionUnreadCounts, markConversationRead }`
|
|
71
|
-
| `
|
|
72
|
-
| `
|
|
73
|
-
| `
|
|
74
|
-
| `
|
|
75
|
-
| `
|
|
76
|
-
| `
|
|
77
|
-
| `
|
|
78
|
-
| `
|
|
79
|
-
| `
|
|
80
|
-
| `
|
|
81
|
-
| `
|
|
82
|
-
| `
|
|
83
|
-
| `
|
|
84
|
-
| `
|
|
85
|
-
| `
|
|
86
|
-
| `
|
|
87
|
-
| `
|
|
84
|
+
| Hook | Returns |
|
|
85
|
+
| -------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
86
|
+
| `usePoolse()` | The `Poolse` instance. |
|
|
87
|
+
| `useMe()` | `{ me, loading, error }` |
|
|
88
|
+
| `useConversation(id \| null)` | `{ conversation, loading, error, refetch }` |
|
|
89
|
+
| `useConversations()` | `{ conversations, loading, error, refetch, hasMore, loadingMore, loadMore, create, unreadCounts, mentionUnreadCounts, markConversationRead }` |
|
|
90
|
+
| `useUnreadTotals(client?)` | `{ unread, mentions, conversations, source, loading, error, refresh }` for one client, live — pass a client to read one outside its provider (a workspace rail) |
|
|
91
|
+
| `useUnreadQueue({ mentionsFirst?, filter? })` | `{ queue, current, remaining, next(), skip(), markRead(id), reset() }` — unread conversations by latest activity; `next()` marks `current` read and moves on |
|
|
92
|
+
| `useOutbox({ conversationId?, client? })` | `{ entries, pending, failed, retry, remove, flush }` |
|
|
93
|
+
| `useClientTimings(client?)` | the client's `timings.get()`, re-rendering as timings land |
|
|
94
|
+
| `useMessages(conversationId)` | `{ messages, loading, error, hasMore, loadMore, loadUntil(messageId), send, retry(id), discard(id), edit, delete, markReadUpTo, fromCache, refetch }`, oldest first |
|
|
95
|
+
| `useThread(conversationId, rootId)` | `{ replies, loading, error, hasMore, loadMore, sendReply, edit, delete }` |
|
|
96
|
+
| `useReactions(messageId, { conversationId, initialReactions?, currentUserId? })` | `{ reactions, addReaction, removeReaction }` |
|
|
97
|
+
| `useTyping(conversationId)` | `{ typing: Set<externalId>, signalTyping }` |
|
|
98
|
+
| `usePresence(conversationId)` / `useConversationPresence` | `{ online: Set<externalId> }` — who has the conversation open |
|
|
99
|
+
| `useUserPresence(id \| null)` | `Presence \| null` — `state`: `online`, `away`, `in_call`, `offline` |
|
|
100
|
+
| `usePresenceMany(ids)` | `Record<id, Presence>` (known ids only) |
|
|
101
|
+
| `useMembers(conversationId)` | `{ members, loading, error, refetch, addMembers(externalIds, { role? }), removeMember(externalId) }` |
|
|
102
|
+
| `useAttachmentUpload()` | `{ queue, attachment, uploading, error, upload(input), uploadAll(inputs), cancel(localId), remove(localId), reset }` |
|
|
103
|
+
| `useAttachmentUrl(id \| null)` | `{ url, loading, error }` (not renewed; URLs last one hour) |
|
|
104
|
+
| `useUser(externalId)` | `{ profile, loading }` |
|
|
105
|
+
| `useAppEvent(handler)` | Calls `handler({ type, data })` for each `app:event` sent to the user |
|
|
106
|
+
| `useRealtimeStatus()` | `'idle' \| 'connecting' \| 'connected' \| 'reconnecting' \| 'closed'` |
|
|
107
|
+
| `useReadReceipts()` | `{ visible, mode, shared, canChange, setShared }` |
|
|
108
|
+
| `useLiveCall(conversationId \| null)` | `{ call, participantIds, refresh }` |
|
|
109
|
+
| `useRoom(conversationId \| null, { livekit })` | `{ live, presentIds, joined, joining, join, leave, media, error }` |
|
|
110
|
+
| `useCallRoom(conversationId \| null, { livekit, … })` | Call media: participants, mic, camera, devices |
|
|
88
111
|
|
|
89
112
|
Helpers: `canEditOwnMessage`, `EDIT_WINDOW_MS`, `receiptsOf`,
|
|
90
113
|
`computeGroupPosition`, `sameGroup`, `sameDay`, `formatDayLabel`, plus
|
|
@@ -95,8 +118,12 @@ Notes that trip people up:
|
|
|
95
118
|
- `useTyping`, `usePresence`, `useUser` and `useMembers().removeMember` use
|
|
96
119
|
**your** user ids (`external_id`). `useReactions`' `currentUserId` and the
|
|
97
120
|
`reactions` map use **poolse** user ids (`me.id`).
|
|
98
|
-
- `useMessages().send`
|
|
99
|
-
|
|
121
|
+
- `useMessages().send` goes through the client's outbox (3.8): offline, the
|
|
122
|
+
row stays as `local_status: 'queued'` and goes out on reconnect (the promise
|
|
123
|
+
rejects with `MessageQueuedError` — not a failure to show); refused (4xx), it
|
|
124
|
+
stays as `'failed'` with `local_error` until `retry(id)` / `discard(id)`.
|
|
125
|
+
With `outbox: false` in the config it removes the row and rejects, as
|
|
126
|
+
before. Thread replies (`useThread`) don't use the outbox yet.
|
|
100
127
|
- `useAttachmentUpload().upload` takes `{ body, contentType, byteSize, filename? }`,
|
|
101
128
|
not a bare `File`. Send `item.attachment.id`, not `item.localId`.
|
|
102
129
|
- From 3.1, `useMessages` (the newest 50, merged in) and `useConversations`
|