@poolse/react-native 3.0.0 → 3.2.0-dev.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 CHANGED
@@ -4,6 +4,23 @@ All notable changes to `@poolse/react-native` are documented here.
4
4
  Format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/);
5
5
  versions follow [semver](https://semver.org).
6
6
 
7
+ ## [3.2.0-dev.0] — 2026-11-04 (prerelease, npm tag `dev`)
8
+
9
+ ### Changed
10
+
11
+ - Moves with `@poolse/sdk` 3.2.0-dev.0.
12
+
13
+ ## [3.1.0] — 2026-10-27
14
+
15
+ ### Fixed
16
+
17
+ - `useAppStateLifecycle` no longer tears down every channel when the app
18
+ goes to the background. It pauses the socket and resumes it on return,
19
+ so mounted hooks keep receiving events; before, they went silent until
20
+ remounted. It now pauses only on `background`, not on iOS `inactive`
21
+ (notification centre, app switcher).
22
+ - `AttachmentPicker` declares the size of the bytes it actually uploads.
23
+ The server now refuses a file bigger than its declared size.
7
24
 
8
25
  ## [3.0.0] — 2026-10-26
9
26
 
@@ -88,7 +105,7 @@ versions follow [semver](https://semver.org).
88
105
  ### Added
89
106
 
90
107
  - `CallScreen onSpeakerChange` — fires with `(speakerOn,
91
- externalDevice)` whenever the audio route changes. Hosts use it to
108
+ externalDevice)` whenever the audio route changes. Hosts use it to
92
109
  drive the proximity sensor: the screen should only go dark near an
93
110
  ear when the sound is actually at the ear.
94
111
 
package/README.md CHANGED
@@ -1,10 +1,15 @@
1
1
  # `@poolse/react-native`
2
2
 
3
- Drop-in React Native chat SDK for Expo and bare React Native. `<ConversationView>` and `<PoolseInbox>` mount a complete chat surface with camera, attachments, markdown, typing indicators, reactions, threads, and AppState lifecycle baked in. Mirrors [`@poolse/react-ui`](https://www.npmjs.com/package/@poolse/react-ui) — same component names, same prop shapes — but implemented against native primitives (`View` / `Text` / `FlatList` / `TextInput` / `Pressable` / `Modal` / `KeyboardAvoidingView`).
3
+ Prebuilt React Native and Expo chat components for
4
+ [poolse](https://poolse.dev): `<PoolseInbox>`, `<ConversationView>` and the
5
+ pieces they are built from, a JS theme, the app-lifecycle hook, and building
6
+ blocks for a call screen. Built on
7
+ [`@poolse/react`](https://www.npmjs.com/package/@poolse/react).
4
8
 
5
- > **Source-available alternative to `sendbird-chat-react-native`, `stream-chat-react-native`, and CometChat React Native UIKit.** Works out of the box with Expo (SDK 50+) and bare React Native (≥ 0.73). JS theme tokens, no native module setup beyond standard peer deps.
9
+ Calls on phones (ringing a locked phone, CallKit, the Android call service)
10
+ are in [`@poolse/native`](https://www.npmjs.com/package/@poolse/native).
6
11
 
7
- Sits on top of [`@poolse/react`](https://www.npmjs.com/package/@poolse/react) (hooks) and [`@poolse/sdk`](https://www.npmjs.com/package/@poolse/sdk) (client).
12
+ Full reference: <https://poolse.dev/docs/sdk/react-native>
8
13
 
9
14
  ## Install
10
15
 
@@ -20,219 +25,98 @@ npx expo install \
20
25
  expo-image-manipulator
21
26
  ```
22
27
 
23
- Use `npx expo install` (not plain `npm install`) so each module is
24
- pinned to a version compatible with your Expo SDK. On bare React
25
- Native without the Expo CLI, swap it for `npm install` and pin
26
- versions yourself.
27
-
28
- **All peer dependencies are required.** The chat surface eagerly
29
- imports each one at module-load time (Metro can't follow `try /
30
- require`, so we don't try — see `2.1.1` release notes). If any peer
31
- is missing the bundle blows up the first time you mount
32
- `<ConversationView>` / `<PoolseInbox>` with "Requiring unknown
33
- module …".
34
-
35
- | Peer | What it powers |
36
- | -------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
37
- | `react-native-svg` | All `<PoolseIcon>` glyphs (send, reply, reactions, chevrons). |
38
- | `react-native-markdown-display` | Bold / italic / code / clickable links inside message bubbles. Disable with `markdown={false}` on `<ConversationView>` if you don't want it — the import still ships in the bundle. |
39
- | `react-native-safe-area-context` | Composer bottom inset when the keyboard is closed, and the `keyboardVerticalOffset` math `<PoolseInbox>` does for its header. Falls back to hardcoded iOS 50/34 constants if missing — usable, but wrong on devices with non-standard insets. |
40
- | `expo-clipboard` | The Copy action in the long-press message menu. |
41
- | `expo-image-picker` | Camera + Photo-library entries in `<AttachmentPicker>`. |
42
- | `expo-document-picker` | File entry in `<AttachmentPicker>`. |
43
- | `expo-image-manipulator` | WebP resize + compress on picked photos before upload (keeps payloads under ~250 KB). |
44
-
45
- **iOS Info.plist** (`app.json` → `ios.infoPlist`):
46
-
47
- ```json
48
- {
49
- "NSCameraUsageDescription": "Take photos to send in chat.",
50
- "NSPhotoLibraryUsageDescription": "Pick photos to send in chat."
51
- }
52
- ```
28
+ Every peer is required: the package imports each one when it loads, so a
29
+ missing one breaks the bundle. Peer ranges: `react` ≥ 18, `react-native` ≥
30
+ 0.73, `react-native-svg` ≥ 14, `react-native-safe-area-context` ≥ 4,
31
+ `react-native-markdown-display` ≥ 7, any `expo-*` version.
53
32
 
54
- Pass `camera={false}` to `<AttachmentPicker>` if you want to skip
55
- the camera entry (and Apple's review burden for `NSCameraUsageDescription`).
33
+ iOS needs `NSCameraUsageDescription` and `NSPhotoLibraryUsageDescription` in
34
+ `ios.infoPlist` for the attachment picker.
56
35
 
57
- **App root** — wrap once with `<SafeAreaProvider>` and `<PoolseProvider>`:
36
+ ## Quick start
58
37
 
59
38
  ```tsx
60
- import { SafeAreaProvider } from 'react-native-safe-area-context';
39
+ import { SafeAreaProvider, SafeAreaView } from 'react-native-safe-area-context';
61
40
  import { PoolseProvider } from '@poolse/react';
41
+ import { PoolseInbox, PoolseTheme, useAppStateLifecycle } from '@poolse/react-native';
62
42
 
63
43
  export default function App() {
64
44
  return (
65
45
  <SafeAreaProvider>
66
- <PoolseProvider config={{ getToken: ..., apiUrl: ... }}>
67
- <YourScreens />
46
+ <PoolseProvider config={config}>
47
+ <ChatRoot />
68
48
  </PoolseProvider>
69
49
  </SafeAreaProvider>
70
50
  );
71
51
  }
72
- ```
73
-
74
- ## Quick start
75
-
76
- The drop-in inbox — list + detail with a slide animation between them, edge-swipe back, plus built-in pickers when you provide a user directory:
77
-
78
- ```tsx
79
- import { PoolseProvider } from '@poolse/react';
80
- import { PoolseInbox, PoolseTheme } from '@poolse/react-native';
81
-
82
- const users = [
83
- { externalId: 'alice', name: 'Alice', avatarUrl: 'https://…' },
84
- { externalId: 'bob', name: 'Bob', avatarUrl: 'https://…' },
85
- ];
86
-
87
- export default function InboxScreen() {
88
- return (
89
- <PoolseProvider config={{ getToken, userResolver }}>
90
- <PoolseTheme>
91
- <PoolseInbox
92
- title="Chats"
93
- users={users}
94
- labelFor={(externalId) =>
95
- users.find((u) => u.externalId === externalId)?.name ?? externalId
96
- }
97
- avatarFor={(externalId) =>
98
- users.find((u) => u.externalId === externalId)?.avatarUrl ?? null
99
- }
100
- />
101
- </PoolseTheme>
102
- </PoolseProvider>
103
- );
104
- }
105
- ```
106
-
107
- If you'd rather render a single conversation (your app already owns the navigation), use `<ConversationView>` directly:
108
52
 
109
- ```tsx
110
- import { PoolseProvider } from '@poolse/react';
111
- import { PoolseTheme, ConversationView } from '@poolse/react-native';
112
-
113
- export default function ChatScreen({ conversationId }: { conversationId: string }) {
53
+ function ChatRoot() {
54
+ useAppStateLifecycle(); // inside the provider
114
55
  return (
115
- <PoolseProvider config={{ getToken, userResolver }}>
56
+ <SafeAreaView style={{ flex: 1 }}>
116
57
  <PoolseTheme>
117
- <ConversationView conversationId={conversationId} />
58
+ <PoolseInbox title="Chats" users={users} labelFor={labelFor} avatarFor={avatarFor} />
118
59
  </PoolseTheme>
119
- </PoolseProvider>
60
+ </SafeAreaView>
120
61
  );
121
62
  }
122
63
  ```
123
64
 
124
- The same `<PoolseProvider>` you use on web. Wrap it once at the app root if you have multiple chat screens. Drop the `<PoolseTheme>` wrapper if you don't need to override the brand defaults — every component has a fallback theme baked in.
125
-
126
- ## What ships
127
-
128
- | Component | What it does |
129
- | --------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
130
- | `<PoolseInbox>` | Full inbox shell — list + detail with an iOS-style slide animation between them, left-edge-swipe-back to return to the list, built-in `New chat` / `New group` picker sheets when `users` is provided. Imperative ref API: `open`, `openDirect`, `openGroup`, `promptNewChat`, `promptNewGroup`, `close`. |
131
- | `<ChatHeader>` | Title bar — direct chats resolve the other member's name + avatar via `labelFor` / `avatarFor`, groups show member count, presence-driven green dot. Optional `onBack` button. |
132
- | `<ConversationView>` | Composed chat surface — message list + composer + typing strip + thread modal. Single `KeyboardAvoidingView` covers the whole thing so the composer stays above the keyboard on both platforms. |
133
- | `<ThreadView>` | Bottom-sheet modal for thread replies. Reactions + attachments + pull-down-to-close via a 60-pt header drag strip. Composer reuses the same `UploadProvider` queue as the picker. |
134
- | `<GroupDetailsSheet>` | Bottom sheet showing a group's name, avatar, and member roster with presence. Opened from `<ChatHeader>`'s members button. |
135
- | `<MessageBubble>` / `<EditableMessageBubble>` | Single message render — body, meta, read receipt, quoted card, in-bubble attachments. |
136
- | `<MessageRow>` | Bubble + alignment + swipe-to-reply (capture-phase, 1:1 finger follow, sqrt-damped past 50pt threshold). |
137
- | `<MessageList>` | Inverted `FlatList` wrapper — stick-to-bottom, hold-position, auto-load-more. |
138
- | `<MessageComposer>` | Text input with auto-grow, send button, attach button, quote chip. |
139
- | `<MessageActions>` | Long-press menu (reply / quote / edit / delete / copy / react). |
140
- | `<TypingIndicator>` | Animated three-dot indicator + labels. |
141
- | `<ConversationList>` | `FlatList` of conversation rows. Direct rows pull the other member's name + avatar via `labelFor` / `avatarFor`; preview reads `last_message_preview` updated in realtime by the SDK's `conversation:updated` subscription. Unread badges. |
142
- | `<MemberList>` | Member roster with avatars + remove action. |
143
- | `<MentionInput>` | `TextInput` + autocomplete popover. |
144
- | `<ReactionStrip>` / `<ReactionPicker>` | Reaction summary + emoji picker sheet. |
145
- | `<AttachmentPreview>` / `<AttachmentPicker>` | Image or file card. Picker wraps `expo-image-picker` + `expo-document-picker`. |
146
- | `<UploadQueueStrip>` | Pending uploads with cancel. |
147
- | `<UserName>` / `useDisplayName(externalId)` | Display name resolution via the SDK's `userResolver`. |
148
- | `<Avatar>` | Initials + URL fallback, stable color per user. |
149
- | `<PoolseIcon>` / `<PoolseLogo>` | Brand chrome via `react-native-svg`. |
65
+ To show one conversation inside your own navigation, render
66
+ `<ConversationView conversationId={id} keyboardOffset={headerHeight} />`.
67
+
68
+ ## `useAppStateLifecycle()`
69
+
70
+ Call it once inside `<PoolseProvider>`. From 3.1 it pauses the socket when
71
+ the app goes to the background and resumes it when the app becomes active;
72
+ channels and listeners survive, and `useMessages` / `useConversations`
73
+ reload from REST after the reconnect. The iOS `inactive` state doesn't pause
74
+ anything. (In 3.0 it destroyed every channel instead, which left mounted
75
+ hooks silent until they remounted.)
76
+
77
+ ## Components
78
+
79
+ - Composed: `PoolseInbox` (ref: `open`, `openDirect`, `openGroup`,
80
+ `promptNewChat`, `promptNewGroup`, `close`), `ConversationView`,
81
+ `ChatHeader`, `ThreadView` (bottom sheet), `GroupDetailsSheet`.
82
+ - Messages: `MessageList`, `MessageRow`, `MessageBubble`, `MessageActions`
83
+ (long-press sheet), `TypingIndicator`, `DaySeparator`, `CallLogRow`,
84
+ `LiveCallBanner`, `ImageMosaic`.
85
+ - Composer: `MessageComposer`, `MentionInput`, `AttachmentPicker`,
86
+ `UploadQueueStrip`, `AttachmentPreview`. `AttachmentPicker` declares the
87
+ size of the bytes it uploads; a custom `onPickInputs` must set `byteSize`
88
+ to the size of `body`, because the server refuses a file bigger than
89
+ declared.
90
+ - Lists: `ConversationList`, `MemberList`.
91
+ - Reactions: `ReactionStrip`, `ReactionPicker`.
92
+ - Identity and brand: `UserName`, `useDisplayName`, `Avatar`, `PoolseIcon`,
93
+ `PoolseLogo`, `Primitives`.
94
+ - Call screen: `CallControlButton`, `CallAvatar`, `AudioRouteSheet`,
95
+ `callColors`, `useCallDuration`.
96
+
97
+ The names follow `@poolse/react-ui`, but the props differ in places (for
98
+ example `ThreadView` needs `visible` and `onClose`, and there is no
99
+ `EditableMessageBubble`); see the docs for each component's props.
150
100
 
151
101
  ## Theming
152
102
 
153
- JS object via `<PoolseTheme theme={overrides}>`. The full token
154
- surface mirrors the web `--poolse-*` CSS variables, grouped by
155
- purpose:
156
-
157
103
  ```tsx
158
- <PoolseTheme
159
- theme={{
160
- colors: {
161
- brand: '#ff5733',
162
- brandSoft: '#ffe9e3',
163
- onBrand: '#ffffff',
164
- },
165
- radii: {
166
- bubble: 18,
167
- },
168
- }}
169
- >
170
- {/* ... */}
104
+ <PoolseTheme mode="dark" theme={{ colors: { brand: '#ff5733' }, radii: { bubble: 18 } }}>
105
+ {children}
171
106
  </PoolseTheme>
172
107
  ```
173
108
 
174
- Pass nothing to use the brand defaults. Pass `mode="dark"` to swap
175
- to the warm dark palette. Deep-merges your overrides on top —
176
- unspecified tokens keep their default.
177
-
178
- ## Lifecycle
179
-
180
- ```tsx
181
- import { useAppStateLifecycle } from '@poolse/react-native';
182
-
183
- function App() {
184
- useAppStateLifecycle();
185
- return <PoolseProvider config={config}>{/* ... */}</PoolseProvider>;
186
- }
187
- ```
188
-
189
- Closes the SDK WebSocket cleanly when the app backgrounds (iOS /
190
- Android suspend sockets aggressively — keeping them open wastes
191
- battery and produces no benefit). Reopens on foreground and triggers
192
- a tail refetch on the currently-mounted `<ConversationView>` so the
193
- user lands on a fresh state instead of catching up via stale
194
- realtime.
195
-
196
- Pair with push notifications on your backend (subscribe to
197
- `message.created` / `mention.created` webhooks, fan out via APNs /
198
- FCM / Expo's push service) — that's how the user learns about new
199
- messages while the app is closed.
200
-
201
- ## Identity model
202
-
203
- Same SDK 2.0 contract as the web side. All component props that
204
- deal with users are keyed by your `external_id`:
205
-
206
- - `useUser(externalId)`, `useDisplayName(externalId)`
207
- - `<UserName externalId={message.sender_external_id} />`
208
- - `<MemberList labelFor={(externalId) => ...} avatarFor={(externalId) => ...} onlineExternalIds={set} />`
209
- - `<MessageBubble>` / `<MessageComposer>` / `<MentionInput>` / `<TypingIndicator>` — every `labelFor` is `(externalId) => string`.
210
-
211
- The wire still carries `user_id` (the poolse uuid) alongside
212
- `external_id`, but day-to-day app code never has to touch it.
213
-
214
- ## Differences from `@poolse/react-ui`
215
-
216
- | Concern | Web (`react-ui`) | Native (`react-native`) |
217
- | ------------------- | ----------------------------- | -------------------------------------------- |
218
- | Styling | CSS variables in `styles.css` | JS theme via `<PoolseTheme>` |
219
- | Action menu trigger | Hover | Long-press |
220
- | Reaction picker | Inline popover | Modal sheet |
221
- | Mention picker | Inline dropdown | Modal sheet |
222
- | Attachment picker | `<input type=file>` | `expo-image-picker` + `expo-document-picker` |
223
- | Message list | Reversed CSS flexbox | Inverted `FlatList` |
224
- | Markdown | `react-markdown` | Plain text |
225
-
226
- Everything else — feature flags, prop names, callback shapes, hook signatures — is intentionally identical so a web codebase ports across with mostly mechanical changes.
109
+ Overrides merge over the light or dark base theme one group at a time
110
+ (`colors`, `type`, `radii`, `spacing`, `shadows`). `mode` doesn't follow the
111
+ system by itself; pass `useColorScheme()` if you want that. Read the active
112
+ theme with `usePoolseTheme()`.
227
113
 
228
114
  ## Links
229
115
 
230
- - Docs: [poolse.dev/docs/sdk/react-native](https://poolse.dev/docs/sdk/react-native)
231
- - Source: [github.com/poolse-hq/js-sdk](https://github.com/poolse-hq/js-sdk/tree/main/packages/react-native)
232
- - Web sibling: [`@poolse/react-ui`](https://www.npmjs.com/package/@poolse/react-ui)
233
- - Hooks (used internally): [`@poolse/react`](https://www.npmjs.com/package/@poolse/react)
234
- - Core client: [`@poolse/sdk`](https://www.npmjs.com/package/@poolse/sdk)
116
+ - Docs: <https://poolse.dev/docs/sdk/react-native>
117
+ - Source: <https://github.com/poolse-hq/js-sdk>
235
118
 
236
119
  ## License
237
120
 
238
- Licensed under the [poolse SDK License](./LICENSE) from 3.0.0 (source-available, for use with the poolse Services only); versions before 3.0.0 remain MIT.
121
+ Licensed under the [poolse SDK License](./LICENSE) from 3.0.0; versions
122
+ before 3.0.0 remain MIT.
package/dist/index.cjs CHANGED
@@ -1343,7 +1343,8 @@ async function assetsToInputs(assets) {
1343
1343
  return {
1344
1344
  body: blob,
1345
1345
  contentType,
1346
- byteSize: asset.fileSize ?? blob.size,
1346
+ // The uploaded bytes: the server refuses a file bigger than declared.
1347
+ byteSize: blob.size || asset.fileSize || 0,
1347
1348
  filename: asset.fileName ?? `image-${Date.now()}.jpg`,
1348
1349
  _previewUri: asset.uri
1349
1350
  };
@@ -1406,7 +1407,8 @@ async function defaultAdapter(kind) {
1406
1407
  return {
1407
1408
  body: blob,
1408
1409
  contentType,
1409
- byteSize: asset.size ?? blob.size,
1410
+ // The uploaded bytes: the server refuses a file bigger than declared.
1411
+ byteSize: blob.size || asset.size || 0,
1410
1412
  filename: asset.name,
1411
1413
  _previewUri: asset.uri
1412
1414
  };
@@ -5437,22 +5439,9 @@ var primitives = { PoolseIcon, PoolseLogo, Avatar };
5437
5439
  function useAppStateLifecycle() {
5438
5440
  const poolse = react$1.usePoolse();
5439
5441
  react.useEffect(() => {
5440
- let prev = reactNative.AppState.currentState;
5441
5442
  const sub = reactNative.AppState.addEventListener("change", (next) => {
5442
- const wasActive = prev === "active";
5443
- const isActive = next === "active";
5444
- if (wasActive && !isActive) {
5445
- try {
5446
- poolse.realtime?.disconnect?.();
5447
- } catch {
5448
- }
5449
- } else if (!wasActive && isActive) {
5450
- try {
5451
- poolse.realtime?.connect?.();
5452
- } catch {
5453
- }
5454
- }
5455
- prev = next;
5443
+ if (next === "background") poolse.realtime.pause();
5444
+ else if (next === "active") poolse.realtime.resume();
5456
5445
  });
5457
5446
  return () => sub.remove();
5458
5447
  }, [poolse]);