@reverbia/sdk 1.0.0-next.20251208111334 → 1.0.0-next.20251208112742

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 (2) hide show
  1. package/README.md +104 -0
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -177,6 +177,110 @@ if (response.data) {
177
177
  }
178
178
  ```
179
179
 
180
+ ## React Native (Expo)
181
+
182
+ The SDK supports React Native via Expo with streaming support. For a complete
183
+ example, see
184
+ [ai-example-expo](https://github.com/zeta-chain/ai-example-expo).
185
+
186
+ ### Installation
187
+
188
+ ```bash
189
+ pnpm install @reverbia/sdk@next web-streams-polyfill react-native-get-random-values @ethersproject/shims buffer
190
+ ```
191
+
192
+ ### Polyfill Setup
193
+
194
+ Create a custom entry point file (e.g., `entrypoint.js`) and update
195
+ `package.json` to use it:
196
+
197
+ ```json
198
+ {
199
+ "main": "entrypoint.js"
200
+ }
201
+ ```
202
+
203
+ ```javascript
204
+ // entrypoint.js
205
+
206
+ // Import polyfills in this exact order
207
+ import "react-native-get-random-values";
208
+ import "@ethersproject/shims";
209
+ import { Buffer } from "buffer";
210
+ global.Buffer = Buffer;
211
+
212
+ // Web Streams polyfill for SSE streaming
213
+ import { ReadableStream, TransformStream } from "web-streams-polyfill";
214
+ if (typeof globalThis.ReadableStream === "undefined") {
215
+ globalThis.ReadableStream = ReadableStream;
216
+ }
217
+ if (typeof globalThis.TransformStream === "undefined") {
218
+ globalThis.TransformStream = TransformStream;
219
+ }
220
+
221
+ // SDK polyfills (TextDecoderStream for streaming)
222
+ import "@reverbia/sdk/polyfills";
223
+
224
+ // Then import expo router
225
+ import "expo-router/entry";
226
+ ```
227
+
228
+ ### Usage
229
+
230
+ Import from `@reverbia/sdk/expo` instead of `@reverbia/sdk/react`:
231
+
232
+ ```typescript
233
+ import { useIdentityToken } from "@privy-io/expo";
234
+ import { useChat } from "@reverbia/sdk/expo";
235
+
236
+ function ChatComponent() {
237
+ const { getIdentityToken } = useIdentityToken();
238
+
239
+ const { isLoading, sendMessage } = useChat({
240
+ getToken: getIdentityToken,
241
+ baseUrl: "https://ai-portal-dev.zetachain.com",
242
+ onData: (chunk) => {
243
+ // Handle streaming chunks
244
+ const content =
245
+ typeof chunk === "string"
246
+ ? chunk
247
+ : chunk.choices?.[0]?.delta?.content || "";
248
+ console.log("Received:", content);
249
+ },
250
+ onFinish: () => {
251
+ console.log("Stream finished");
252
+ },
253
+ onError: (error) => {
254
+ console.error("Error:", error);
255
+ },
256
+ });
257
+
258
+ const handleSend = async () => {
259
+ await sendMessage({
260
+ messages: [{ role: "user", content: "Hello!" }],
261
+ model: "openai/gpt-4o",
262
+ });
263
+ };
264
+ }
265
+ ```
266
+
267
+ ### Authentication
268
+
269
+ Use `@privy-io/expo` for authentication in React Native:
270
+
271
+ ```typescript
272
+ import { PrivyProvider, usePrivy } from "@privy-io/expo";
273
+ import { useIdentityToken } from "@privy-io/expo";
274
+
275
+ // Wrap your app with PrivyProvider
276
+ <PrivyProvider appId="your-app-id" clientId="your-client-id">
277
+ <App />
278
+ </PrivyProvider>;
279
+
280
+ // Get identity token for API calls
281
+ const { getIdentityToken } = useIdentityToken();
282
+ ```
283
+
180
284
  ## Contributing
181
285
 
182
286
  Contributions are welcome! Please feel free to submit a pull request.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reverbia/sdk",
3
- "version": "1.0.0-next.20251208111334",
3
+ "version": "1.0.0-next.20251208112742",
4
4
  "description": "",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",