@opencx/widget-react-headless 5.0.0 → 5.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 +30 -0
- package/dist/index.cjs +15 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1330 -1303
- package/dist/index.js.map +1 -1
- package/dist/package.json.d.ts +4 -2
- package/dist/src/agent-chat/AgentChatContext.d.ts +7 -0
- package/dist/src/agent-chat/AgentChatContext.d.ts.map +1 -1
- package/dist/src/agent-chat/agent-chat-transport.d.ts +9 -0
- package/dist/src/agent-chat/agent-chat-transport.d.ts.map +1 -1
- package/dist/src/agent-chat/resume-signals.d.ts +11 -0
- package/dist/src/agent-chat/resume-signals.d.ts.map +1 -0
- package/dist/src/agent-chat/useAgentChat.d.ts +1 -0
- package/dist/src/agent-chat/useAgentChat.d.ts.map +1 -1
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -64,3 +64,33 @@ opt-outs. Changing visibility refreshes existing history; `useAgentChatUi()`
|
|
|
64
64
|
immediately hides opted-out activity in both live and cached turns, including
|
|
65
65
|
while that refresh is pending or fails. Integrations keeping a separate cache
|
|
66
66
|
can use `applyPresentation(items, presentation)` to apply the same display rules.
|
|
67
|
+
|
|
68
|
+
## React Native
|
|
69
|
+
|
|
70
|
+
Streaming in React Native needs Expo SDK 52 or later and three things from the
|
|
71
|
+
app:
|
|
72
|
+
|
|
73
|
+
```tsx
|
|
74
|
+
import { fetch as expoFetch } from 'expo/fetch';
|
|
75
|
+
|
|
76
|
+
<WidgetProvider
|
|
77
|
+
components={yourComponents}
|
|
78
|
+
options={{
|
|
79
|
+
token: '<WIDGET_TOKEN>',
|
|
80
|
+
streaming: true,
|
|
81
|
+
streamingFetch: expoFetch as typeof fetch,
|
|
82
|
+
}}
|
|
83
|
+
>
|
|
84
|
+
<YourChat />
|
|
85
|
+
</WidgetProvider>;
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
1. `streamingFetch`: React Native's built-in fetch cannot read a response
|
|
89
|
+
while it arrives. Every other request keeps using the global fetch.
|
|
90
|
+
2. Globals the stream reader uses: `structuredClone` and `TextDecoderStream`.
|
|
91
|
+
Install polyfills for them at startup, before the widget is imported.
|
|
92
|
+
3. Resuming a dropped reply: browsers resume when the tab is visible again or
|
|
93
|
+
the network returns. React Native has neither event, so call
|
|
94
|
+
`useAgentChatUi().resumeInterruptedTurn()` when `AppState` becomes
|
|
95
|
+
`active` and when connectivity returns. It does nothing unless the last
|
|
96
|
+
reply was cut off.
|